@openscout/scout 0.2.58 → 0.2.61
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/dist/client/assets/{arc.es-Bkj9Bkvx.js → arc.es-DgeMPL-I.js} +1 -1
- package/dist/client/assets/index-25TJx0iN.js +140 -0
- package/dist/client/assets/index-B1kglsyi.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/main.mjs +2576 -4579
- package/dist/pair-supervisor.mjs +1127 -2405
- package/dist/scout-control-plane-web.mjs +798 -2939
- package/package.json +2 -2
- package/dist/client/assets/index-BDyu05Hi.js +0 -140
- package/dist/client/assets/index-pbcZpgCR.css +0 -1
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
function aM(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in e)){const c=Object.getOwnPropertyDescriptor(a,i);c&&Object.defineProperty(e,i,c.get?c:{enumerable:!0,get:()=>a[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"]'))a(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).observe(document,{childList:!0,subtree:!0});function n(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(i){if(i.ep)return;i.ep=!0;const c=n(i);fetch(i.href,c)}})();function Ej(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mm={exports:{}},kl={};var Pb;function rM(){if(Pb)return kl;Pb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,i,c){var u=null;if(c!==void 0&&(u=""+c),i.key!==void 0&&(u=""+i.key),"key"in i){c={};for(var f in i)f!=="key"&&(c[f]=i[f])}else c=i;return i=c.ref,{$$typeof:e,type:a,key:u,ref:i!==void 0?i:null,props:c}}return kl.Fragment=t,kl.jsx=n,kl.jsxs=n,kl}var Ub;function iM(){return Ub||(Ub=1,Mm.exports=rM()),Mm.exports}var o=iM(),_m={exports:{}},Fe={};var Bb;function oM(){if(Bb)return Fe;Bb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),b=Symbol.iterator;function w(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,T={};function k(z,Z,J){this.props=z,this.context=Z,this.refs=T,this.updater=J||j}k.prototype.isReactComponent={},k.prototype.setState=function(z,Z){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,Z,"setState")},k.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function C(){}C.prototype=k.prototype;function S(z,Z,J){this.props=z,this.context=Z,this.refs=T,this.updater=J||j}var R=S.prototype=new C;R.constructor=S,N(R,k.prototype),R.isPureReactComponent=!0;var A=Array.isArray;function M(){}var O={H:null,A:null,T:null,S:null},V=Object.prototype.hasOwnProperty;function F(z,Z,J){var Q=J.ref;return{$$typeof:e,type:z,key:Z,ref:Q!==void 0?Q:null,props:J}}function I(z,Z){return F(z.type,Z,z.props)}function $(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function L(z){var Z={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(J){return Z[J]})}var U=/\/+/g;function Y(z,Z){return typeof z=="object"&&z!==null&&z.key!=null?L(""+z.key):Z.toString(36)}function K(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(M,M):(z.status="pending",z.then(function(Z){z.status==="pending"&&(z.status="fulfilled",z.value=Z)},function(Z){z.status==="pending"&&(z.status="rejected",z.reason=Z)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function D(z,Z,J,Q,pe){var re=typeof z;(re==="undefined"||re==="boolean")&&(z=null);var de=!1;if(z===null)de=!0;else switch(re){case"bigint":case"string":case"number":de=!0;break;case"object":switch(z.$$typeof){case e:case t:de=!0;break;case g:return de=z._init,D(de(z._payload),Z,J,Q,pe)}}if(de)return pe=pe(z),de=Q===""?"."+Y(z,0):Q,A(pe)?(J="",de!=null&&(J=de.replace(U,"$&/")+"/"),D(pe,Z,J,"",function(Re){return Re})):pe!=null&&($(pe)&&(pe=I(pe,J+(pe.key==null||z&&z.key===pe.key?"":(""+pe.key).replace(U,"$&/")+"/")+de)),Z.push(pe)),1;de=0;var fe=Q===""?".":Q+":";if(A(z))for(var xe=0;xe<z.length;xe++)Q=z[xe],re=fe+Y(Q,xe),de+=D(Q,Z,J,re,pe);else if(xe=w(z),typeof xe=="function")for(z=xe.call(z),xe=0;!(Q=z.next()).done;)Q=Q.value,re=fe+Y(Q,xe++),de+=D(Q,Z,J,re,pe);else if(re==="object"){if(typeof z.then=="function")return D(K(z),Z,J,Q,pe);throw Z=String(z),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return de}function P(z,Z,J){if(z==null)return z;var Q=[],pe=0;return D(z,Q,"","",function(re){return Z.call(J,re,pe++)}),Q}function B(z){if(z._status===-1){var Z=z._result;Z=Z(),Z.then(function(J){(z._status===0||z._status===-1)&&(z._status=1,z._result=J)},function(J){(z._status===0||z._status===-1)&&(z._status=2,z._result=J)}),z._status===-1&&(z._status=0,z._result=Z)}if(z._status===1)return z._result.default;throw z._result}var G=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},X={map:P,forEach:function(z,Z,J){P(z,function(){Z.apply(this,arguments)},J)},count:function(z){var Z=0;return P(z,function(){Z++}),Z},toArray:function(z){return P(z,function(Z){return Z})||[]},only:function(z){if(!$(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return Fe.Activity=x,Fe.Children=X,Fe.Component=k,Fe.Fragment=n,Fe.Profiler=i,Fe.PureComponent=S,Fe.StrictMode=a,Fe.Suspense=m,Fe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Fe.__COMPILER_RUNTIME={__proto__:null,c:function(z){return O.H.useMemoCache(z)}},Fe.cache=function(z){return function(){return z.apply(null,arguments)}},Fe.cacheSignal=function(){return null},Fe.cloneElement=function(z,Z,J){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var Q=N({},z.props),pe=z.key;if(Z!=null)for(re in Z.key!==void 0&&(pe=""+Z.key),Z)!V.call(Z,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&Z.ref===void 0||(Q[re]=Z[re]);var re=arguments.length-2;if(re===1)Q.children=J;else if(1<re){for(var de=Array(re),fe=0;fe<re;fe++)de[fe]=arguments[fe+2];Q.children=de}return F(z.type,pe,Q)},Fe.createContext=function(z){return z={$$typeof:u,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:c,_context:z},z},Fe.createElement=function(z,Z,J){var Q,pe={},re=null;if(Z!=null)for(Q in Z.key!==void 0&&(re=""+Z.key),Z)V.call(Z,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(pe[Q]=Z[Q]);var de=arguments.length-2;if(de===1)pe.children=J;else if(1<de){for(var fe=Array(de),xe=0;xe<de;xe++)fe[xe]=arguments[xe+2];pe.children=fe}if(z&&z.defaultProps)for(Q in de=z.defaultProps,de)pe[Q]===void 0&&(pe[Q]=de[Q]);return F(z,re,pe)},Fe.createRef=function(){return{current:null}},Fe.forwardRef=function(z){return{$$typeof:f,render:z}},Fe.isValidElement=$,Fe.lazy=function(z){return{$$typeof:g,_payload:{_status:-1,_result:z},_init:B}},Fe.memo=function(z,Z){return{$$typeof:h,type:z,compare:Z===void 0?null:Z}},Fe.startTransition=function(z){var Z=O.T,J={};O.T=J;try{var Q=z(),pe=O.S;pe!==null&&pe(J,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(M,G)}catch(re){G(re)}finally{Z!==null&&J.types!==null&&(Z.types=J.types),O.T=Z}},Fe.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Fe.use=function(z){return O.H.use(z)},Fe.useActionState=function(z,Z,J){return O.H.useActionState(z,Z,J)},Fe.useCallback=function(z,Z){return O.H.useCallback(z,Z)},Fe.useContext=function(z){return O.H.useContext(z)},Fe.useDebugValue=function(){},Fe.useDeferredValue=function(z,Z){return O.H.useDeferredValue(z,Z)},Fe.useEffect=function(z,Z){return O.H.useEffect(z,Z)},Fe.useEffectEvent=function(z){return O.H.useEffectEvent(z)},Fe.useId=function(){return O.H.useId()},Fe.useImperativeHandle=function(z,Z,J){return O.H.useImperativeHandle(z,Z,J)},Fe.useInsertionEffect=function(z,Z){return O.H.useInsertionEffect(z,Z)},Fe.useLayoutEffect=function(z,Z){return O.H.useLayoutEffect(z,Z)},Fe.useMemo=function(z,Z){return O.H.useMemo(z,Z)},Fe.useOptimistic=function(z,Z){return O.H.useOptimistic(z,Z)},Fe.useReducer=function(z,Z,J){return O.H.useReducer(z,Z,J)},Fe.useRef=function(z){return O.H.useRef(z)},Fe.useState=function(z){return O.H.useState(z)},Fe.useSyncExternalStore=function(z,Z,J){return O.H.useSyncExternalStore(z,Z,J)},Fe.useTransition=function(){return O.H.useTransition()},Fe.version="19.2.3",Fe}var Vb;function oc(){return Vb||(Vb=1,_m.exports=oM()),_m.exports}var v=oc();const io=Ej(v),Cj=aM({__proto__:null,default:io},[v]);var Om={exports:{}},El={},Im={exports:{}},Dm={};var Hb;function lM(){return Hb||(Hb=1,(function(e){function t(D,P){var B=D.length;D.push(P);e:for(;0<B;){var G=B-1>>>1,X=D[G];if(0<i(X,P))D[G]=P,D[B]=X,B=G;else break e}}function n(D){return D.length===0?null:D[0]}function a(D){if(D.length===0)return null;var P=D[0],B=D.pop();if(B!==P){D[0]=B;e:for(var G=0,X=D.length,z=X>>>1;G<z;){var Z=2*(G+1)-1,J=D[Z],Q=Z+1,pe=D[Q];if(0>i(J,B))Q<X&&0>i(pe,J)?(D[G]=pe,D[Q]=B,G=Q):(D[G]=J,D[Z]=B,G=Z);else if(Q<X&&0>i(pe,B))D[G]=pe,D[Q]=B,G=Q;else break e}}return P}function i(D,P){var B=D.sortIndex-P.sortIndex;return B!==0?B:D.id-P.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var m=[],h=[],g=1,x=null,b=3,w=!1,j=!1,N=!1,T=!1,k=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function R(D){for(var P=n(h);P!==null;){if(P.callback===null)a(h);else if(P.startTime<=D)a(h),P.sortIndex=P.expirationTime,t(m,P);else break;P=n(h)}}function A(D){if(N=!1,R(D),!j)if(n(m)!==null)j=!0,M||(M=!0,L());else{var P=n(h);P!==null&&K(A,P.startTime-D)}}var M=!1,O=-1,V=5,F=-1;function I(){return T?!0:!(e.unstable_now()-F<V)}function $(){if(T=!1,M){var D=e.unstable_now();F=D;var P=!0;try{e:{j=!1,N&&(N=!1,C(O),O=-1),w=!0;var B=b;try{t:{for(R(D),x=n(m);x!==null&&!(x.expirationTime>D&&I());){var G=x.callback;if(typeof G=="function"){x.callback=null,b=x.priorityLevel;var X=G(x.expirationTime<=D);if(D=e.unstable_now(),typeof X=="function"){x.callback=X,R(D),P=!0;break t}x===n(m)&&a(m),R(D)}else a(m);x=n(m)}if(x!==null)P=!0;else{var z=n(h);z!==null&&K(A,z.startTime-D),P=!1}}break e}finally{x=null,b=B,w=!1}P=void 0}}finally{P?L():M=!1}}}var L;if(typeof S=="function")L=function(){S($)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,Y=U.port2;U.port1.onmessage=$,L=function(){Y.postMessage(null)}}else L=function(){k($,0)};function K(D,P){O=k(function(){D(e.unstable_now())},P)}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(D){D.callback=null},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(D){switch(b){case 1:case 2:case 3:var P=3;break;default:P=b}var B=b;b=P;try{return D()}finally{b=B}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(D,P){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var B=b;b=D;try{return P()}finally{b=B}},e.unstable_scheduleCallback=function(D,P,B){var G=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?G+B:G):B=G,D){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=B+X,D={id:g++,callback:P,priorityLevel:D,startTime:B,expirationTime:X,sortIndex:-1},B>G?(D.sortIndex=B,t(h,D),n(m)===null&&D===n(h)&&(N?(C(O),O=-1):N=!0,K(A,B-G))):(D.sortIndex=X,t(m,D),j||w||(j=!0,M||(M=!0,L()))),D},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(D){var P=b;return function(){var B=b;b=P;try{return D.apply(this,arguments)}finally{b=B}}}})(Dm)),Dm}var Zb;function cM(){return Zb||(Zb=1,Im.exports=lM()),Im.exports}var zm={exports:{}},Rn={};var Fb;function uM(){if(Fb)return Rn;Fb=1;var e=oc();function t(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={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 c(m,h,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:x==null?null:""+x,children:m,containerInfo:h,implementation:g}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Rn.createPortal=function(m,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return c(m,h,null,g)},Rn.flushSync=function(m){var h=u.T,g=a.p;try{if(u.T=null,a.p=2,m)return m()}finally{u.T=h,a.p=g,a.d.f()}},Rn.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(m,h))},Rn.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Rn.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var g=h.as,x=f(g,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,w=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?a.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:x,integrity:b,fetchPriority:w}):g==="script"&&a.d.X(m,{crossOrigin:x,integrity:b,fetchPriority:w,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Rn.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=f(h.as,h.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(m)},Rn.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,x=f(g,h.crossOrigin);a.d.L(m,g,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Rn.preloadModule=function(m,h){if(typeof m=="string")if(h){var g=f(h.as,h.crossOrigin);a.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(m)},Rn.requestFormReset=function(m){a.d.r(m)},Rn.unstable_batchedUpdates=function(m,h){return m(h)},Rn.useFormState=function(m,h,g){return u.H.useFormState(m,h,g)},Rn.useFormStatus=function(){return u.H.useHostTransitionStatus()},Rn.version="19.2.3",Rn}var qb;function Tj(){if(qb)return zm.exports;qb=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(),zm.exports=uM(),zm.exports}var Yb;function dM(){if(Yb)return El;Yb=1;var e=cM(),t=oc(),n=Tj();function a(s){var r="https://react.dev/errors/"+s;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+s+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function c(s){var r=s,l=s;if(s.alternate)for(;r.return;)r=r.return;else{s=r;do r=s,(r.flags&4098)!==0&&(l=r.return),s=r.return;while(s)}return r.tag===3?l:null}function u(s){if(s.tag===13){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function f(s){if(s.tag===31){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function m(s){if(c(s)!==s)throw Error(a(188))}function h(s){var r=s.alternate;if(!r){if(r=c(s),r===null)throw Error(a(188));return r!==s?null:s}for(var l=s,d=r;;){var p=l.return;if(p===null)break;var y=p.alternate;if(y===null){if(d=p.return,d!==null){l=d;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===l)return m(p),s;if(y===d)return m(p),r;y=y.sibling}throw Error(a(188))}if(l.return!==d.return)l=p,d=y;else{for(var E=!1,_=p.child;_;){if(_===l){E=!0,l=p,d=y;break}if(_===d){E=!0,d=p,l=y;break}_=_.sibling}if(!E){for(_=y.child;_;){if(_===l){E=!0,l=y,d=p;break}if(_===d){E=!0,d=y,l=p;break}_=_.sibling}if(!E)throw Error(a(189))}}if(l.alternate!==d)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?s:r}function g(s){var r=s.tag;if(r===5||r===26||r===27||r===6)return s;for(s=s.child;s!==null;){if(r=g(s),r!==null)return r;s=s.sibling}return null}var x=Object.assign,b=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),S=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),I=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function L(s){return s===null||typeof s!="object"?null:(s=$&&s[$]||s["@@iterator"],typeof s=="function"?s:null)}var U=Symbol.for("react.client.reference");function Y(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===U?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case N:return"Fragment";case k:return"Profiler";case T:return"StrictMode";case A:return"Suspense";case M:return"SuspenseList";case F:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case j:return"Portal";case S:return s.displayName||"Context";case C:return(s._context.displayName||"Context")+".Consumer";case R:var r=s.render;return s=s.displayName,s||(s=r.displayName||r.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case O:return r=s.displayName||null,r!==null?r:Y(s.type)||"Memo";case V:r=s._payload,s=s._init;try{return Y(s(r))}catch{}}return null}var K=Array.isArray,D=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},G=[],X=-1;function z(s){return{current:s}}function Z(s){0>X||(s.current=G[X],G[X]=null,X--)}function J(s,r){X++,G[X]=s.current,s.current=r}var Q=z(null),pe=z(null),re=z(null),de=z(null);function fe(s,r){switch(J(re,r),J(pe,s),J(Q,null),r.nodeType){case 9:case 11:s=(s=r.documentElement)&&(s=s.namespaceURI)?lb(s):0;break;default:if(s=r.tagName,r=r.namespaceURI)r=lb(r),s=cb(r,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}Z(Q),J(Q,s)}function xe(){Z(Q),Z(pe),Z(re)}function Re(s){s.memoizedState!==null&&J(de,s);var r=Q.current,l=cb(r,s.type);r!==l&&(J(pe,s),J(Q,l))}function he(s){pe.current===s&&(Z(Q),Z(pe)),de.current===s&&(Z(de),wl._currentValue=B)}var Me,Se;function Ve(s){if(Me===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);Me=r&&r[1]||"",Se=-1<l.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+Me+s+Se}var Oe=!1;function we(s,r){if(!s||Oe)return"";Oe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var d={DetermineComponentFrameRoot:function(){try{if(r){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(ae){var se=ae}Reflect.construct(s,[],ue)}else{try{ue.call()}catch(ae){se=ae}s.call(ue.prototype)}}else{try{throw Error()}catch(ae){se=ae}(ue=s())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(ae){if(ae&&se&&typeof ae.stack=="string")return[ae.stack,se.stack]}return[null,null]}};d.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(d.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(d.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=d.DetermineComponentFrameRoot(),E=y[0],_=y[1];if(E&&_){var H=E.split(`
|
|
4
|
-
`),ne=_.split(`
|
|
5
|
-
`);for(p=d=0;d<H.length&&!H[d].includes("DetermineComponentFrameRoot");)d++;for(;p<ne.length&&!ne[p].includes("DetermineComponentFrameRoot");)p++;if(d===H.length||p===ne.length)for(d=H.length-1,p=ne.length-1;1<=d&&0<=p&&H[d]!==ne[p];)p--;for(;1<=d&&0<=p;d--,p--)if(H[d]!==ne[p]){if(d!==1||p!==1)do if(d--,p--,0>p||H[d]!==ne[p]){var ie=`
|
|
6
|
-
`+H[d].replace(" at new "," at ");return s.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",s.displayName)),ie}while(1<=d&&0<=p);break}}}finally{Oe=!1,Error.prepareStackTrace=l}return(l=s?s.displayName||s.name:"")?Ve(l):""}function ke(s,r){switch(s.tag){case 26:case 27:case 5:return Ve(s.type);case 16:return Ve("Lazy");case 13:return s.child!==r&&r!==null?Ve("Suspense Fallback"):Ve("Suspense");case 19:return Ve("SuspenseList");case 0:case 15:return we(s.type,!1);case 11:return we(s.type.render,!1);case 1:return we(s.type,!0);case 31:return Ve("Activity");default:return""}}function Ye(s){try{var r="",l=null;do r+=ke(s,l),l=s,s=s.return;while(s);return r}catch(d){return`
|
|
7
|
-
Error generating stack: `+d.message+`
|
|
8
|
-
`+d.stack}}var Ue=Object.prototype.hasOwnProperty,He=e.unstable_scheduleCallback,le=e.unstable_cancelCallback,ge=e.unstable_shouldYield,ve=e.unstable_requestPaint,je=e.unstable_now,Ne=e.unstable_getCurrentPriorityLevel,Je=e.unstable_ImmediatePriority,et=e.unstable_UserBlockingPriority,Ge=e.unstable_NormalPriority,Bt=e.unstable_LowPriority,kt=e.unstable_IdlePriority,fn=e.log,hn=e.unstable_setDisableYieldValue,on=null,Ie=null;function tt(s){if(typeof fn=="function"&&hn(s),Ie&&typeof Ie.setStrictMode=="function")try{Ie.setStrictMode(on,s)}catch{}}var ct=Math.clz32?Math.clz32:yn,xt=Math.log,zt=Math.LN2;function yn(s){return s>>>=0,s===0?32:31-(xt(s)/zt|0)|0}var Xt=256,mn=262144,ln=4194304;function xn(s){var r=s&42;if(r!==0)return r;switch(s&-s){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 s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ts(s,r,l){var d=s.pendingLanes;if(d===0)return 0;var p=0,y=s.suspendedLanes,E=s.pingedLanes;s=s.warmLanes;var _=d&134217727;return _!==0?(d=_&~y,d!==0?p=xn(d):(E&=_,E!==0?p=xn(E):l||(l=_&~s,l!==0&&(p=xn(l))))):(_=d&~y,_!==0?p=xn(_):E!==0?p=xn(E):l||(l=d&~s,l!==0&&(p=xn(l)))),p===0?0:r!==0&&r!==p&&(r&y)===0&&(y=p&-p,l=r&-r,y>=l||y===32&&(l&4194048)!==0)?r:p}function ee(s,r){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&r)===0}function me(s,r){switch(s){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 ye(){var s=ln;return ln<<=1,(ln&62914560)===0&&(ln=4194304),s}function Be(s){for(var r=[],l=0;31>l;l++)r.push(s);return r}function ze(s,r){s.pendingLanes|=r,r!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function ut(s,r,l,d,p,y){var E=s.pendingLanes;s.pendingLanes=l,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=l,s.entangledLanes&=l,s.errorRecoveryDisabledLanes&=l,s.shellSuspendCounter=0;var _=s.entanglements,H=s.expirationTimes,ne=s.hiddenUpdates;for(l=E&~l;0<l;){var ie=31-ct(l),ue=1<<ie;_[ie]=0,H[ie]=-1;var se=ne[ie];if(se!==null)for(ne[ie]=null,ie=0;ie<se.length;ie++){var ae=se[ie];ae!==null&&(ae.lane&=-536870913)}l&=~ue}d!==0&&Lt(s,d,0),y!==0&&p===0&&s.tag!==0&&(s.suspendedLanes|=y&~(E&~r))}function Lt(s,r,l){s.pendingLanes|=r,s.suspendedLanes&=~r;var d=31-ct(r);s.entangledLanes|=r,s.entanglements[d]=s.entanglements[d]|1073741824|l&261930}function Ft(s,r){var l=s.entangledLanes|=r;for(s=s.entanglements;l;){var d=31-ct(l),p=1<<d;p&r|s[d]&r&&(s[d]|=r),l&=~p}}function bn(s,r){var l=r&-r;return l=(l&42)!==0?1:qt(l),(l&(s.suspendedLanes|r))!==0?0:l}function qt(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=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:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function As(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function cn(){var s=P.p;return s!==0?s:(s=window.event,s===void 0?32:_b(s.type))}function yc(s,r){var l=P.p;try{return P.p=s,r()}finally{P.p=l}}var Ra=Math.random().toString(36).slice(2),wn="__reactFiber$"+Ra,Un="__reactProps$"+Ra,ci="__reactContainer$"+Ra,Sf="__reactEvents$"+Ra,YT="__reactListeners$"+Ra,GT="__reactHandles$"+Ra,Wv="__reactResources$"+Ra,zo="__reactMarker$"+Ra;function jf(s){delete s[wn],delete s[Un],delete s[Sf],delete s[YT],delete s[GT]}function ui(s){var r=s[wn];if(r)return r;for(var l=s.parentNode;l;){if(r=l[ci]||l[wn]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(s=gb(s);s!==null;){if(l=s[wn])return l;s=gb(s)}return r}s=l,l=s.parentNode}return null}function di(s){if(s=s[wn]||s[ci]){var r=s.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return s}return null}function Lo(s){var r=s.tag;if(r===5||r===26||r===27||r===6)return s.stateNode;throw Error(a(33))}function fi(s){var r=s[Wv];return r||(r=s[Wv]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function pn(s){s[zo]=!0}var Xv=new Set,Kv={};function Nr(s,r){hi(s,r),hi(s+"Capture",r)}function hi(s,r){for(Kv[s]=r,s=0;s<r.length;s++)Xv.add(r[s])}var WT=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]*$"),Jv={},Qv={};function XT(s){return Ue.call(Qv,s)?!0:Ue.call(Jv,s)?!1:WT.test(s)?Qv[s]=!0:(Jv[s]=!0,!1)}function xc(s,r,l){if(XT(r))if(l===null)s.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":s.removeAttribute(r);return;case"boolean":var d=r.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){s.removeAttribute(r);return}}s.setAttribute(r,""+l)}}function bc(s,r,l){if(l===null)s.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(r);return}s.setAttribute(r,""+l)}}function ia(s,r,l,d){if(d===null)s.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(l);return}s.setAttributeNS(r,l,""+d)}}function ds(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ey(s){var r=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function KT(s,r,l){var d=Object.getOwnPropertyDescriptor(s.constructor.prototype,r);if(!s.hasOwnProperty(r)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var p=d.get,y=d.set;return Object.defineProperty(s,r,{configurable:!0,get:function(){return p.call(this)},set:function(E){l=""+E,y.call(this,E)}}),Object.defineProperty(s,r,{enumerable:d.enumerable}),{getValue:function(){return l},setValue:function(E){l=""+E},stopTracking:function(){s._valueTracker=null,delete s[r]}}}}function Nf(s){if(!s._valueTracker){var r=ey(s)?"checked":"value";s._valueTracker=KT(s,r,""+s[r])}}function ty(s){if(!s)return!1;var r=s._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return s&&(d=ey(s)?s.checked?"true":"false":s.value),s=d,s!==l?(r.setValue(s),!0):!1}function wc(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var JT=/[\n"\\]/g;function fs(s){return s.replace(JT,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function kf(s,r,l,d,p,y,E,_){s.name="",E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?s.type=E:s.removeAttribute("type"),r!=null?E==="number"?(r===0&&s.value===""||s.value!=r)&&(s.value=""+ds(r)):s.value!==""+ds(r)&&(s.value=""+ds(r)):E!=="submit"&&E!=="reset"||s.removeAttribute("value"),r!=null?Ef(s,E,ds(r)):l!=null?Ef(s,E,ds(l)):d!=null&&s.removeAttribute("value"),p==null&&y!=null&&(s.defaultChecked=!!y),p!=null&&(s.checked=p&&typeof p!="function"&&typeof p!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?s.name=""+ds(_):s.removeAttribute("name")}function ny(s,r,l,d,p,y,E,_){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(s.type=y),r!=null||l!=null){if(!(y!=="submit"&&y!=="reset"||r!=null)){Nf(s);return}l=l!=null?""+ds(l):"",r=r!=null?""+ds(r):l,_||r===s.value||(s.value=r),s.defaultValue=r}d=d??p,d=typeof d!="function"&&typeof d!="symbol"&&!!d,s.checked=_?s.checked:!!d,s.defaultChecked=!!d,E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(s.name=E),Nf(s)}function Ef(s,r,l){r==="number"&&wc(s.ownerDocument)===s||s.defaultValue===""+l||(s.defaultValue=""+l)}function mi(s,r,l,d){if(s=s.options,r){r={};for(var p=0;p<l.length;p++)r["$"+l[p]]=!0;for(l=0;l<s.length;l++)p=r.hasOwnProperty("$"+s[l].value),s[l].selected!==p&&(s[l].selected=p),p&&d&&(s[l].defaultSelected=!0)}else{for(l=""+ds(l),r=null,p=0;p<s.length;p++){if(s[p].value===l){s[p].selected=!0,d&&(s[p].defaultSelected=!0);return}r!==null||s[p].disabled||(r=s[p])}r!==null&&(r.selected=!0)}}function sy(s,r,l){if(r!=null&&(r=""+ds(r),r!==s.value&&(s.value=r),l==null)){s.defaultValue!==r&&(s.defaultValue=r);return}s.defaultValue=l!=null?""+ds(l):""}function ay(s,r,l,d){if(r==null){if(d!=null){if(l!=null)throw Error(a(92));if(K(d)){if(1<d.length)throw Error(a(93));d=d[0]}l=d}l==null&&(l=""),r=l}l=ds(r),s.defaultValue=l,d=s.textContent,d===l&&d!==""&&d!==null&&(s.value=d),Nf(s)}function pi(s,r){if(r){var l=s.firstChild;if(l&&l===s.lastChild&&l.nodeType===3){l.nodeValue=r;return}}s.textContent=r}var QT=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 ry(s,r,l){var d=r.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?d?s.setProperty(r,""):r==="float"?s.cssFloat="":s[r]="":d?s.setProperty(r,l):typeof l!="number"||l===0||QT.has(r)?r==="float"?s.cssFloat=l:s[r]=(""+l).trim():s[r]=l+"px"}function iy(s,r,l){if(r!=null&&typeof r!="object")throw Error(a(62));if(s=s.style,l!=null){for(var d in l)!l.hasOwnProperty(d)||r!=null&&r.hasOwnProperty(d)||(d.indexOf("--")===0?s.setProperty(d,""):d==="float"?s.cssFloat="":s[d]="");for(var p in r)d=r[p],r.hasOwnProperty(p)&&l[p]!==d&&ry(s,p,d)}else for(var y in r)r.hasOwnProperty(y)&&ry(s,y,r[y])}function Cf(s){if(s.indexOf("-")===-1)return!1;switch(s){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 eA=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"]]),tA=/^[\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 Sc(s){return tA.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function oa(){}var Tf=null;function Af(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var gi=null,vi=null;function oy(s){var r=di(s);if(r&&(s=r.stateNode)){var l=s[Un]||null;e:switch(s=r.stateNode,r.type){case"input":if(kf(s,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),r=l.name,l.type==="radio"&&r!=null){for(l=s;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+fs(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==s&&d.form===s.form){var p=d[Un]||null;if(!p)throw Error(a(90));kf(d,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(r=0;r<l.length;r++)d=l[r],d.form===s.form&&ty(d)}break e;case"textarea":sy(s,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&mi(s,!!l.multiple,r,!1)}}}var Rf=!1;function ly(s,r,l){if(Rf)return s(r,l);Rf=!0;try{var d=s(r);return d}finally{if(Rf=!1,(gi!==null||vi!==null)&&(cu(),gi&&(r=gi,s=vi,vi=gi=null,oy(r),s)))for(r=0;r<s.length;r++)oy(s[r])}}function $o(s,r){var l=s.stateNode;if(l===null)return null;var d=l[Un]||null;if(d===null)return null;l=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(s=s.type,d=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!d;break e;default:s=!1}if(s)return null;if(l&&typeof l!="function")throw Error(a(231,r,typeof l));return l}var la=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Mf=!1;if(la)try{var Po={};Object.defineProperty(Po,"passive",{get:function(){Mf=!0}}),window.addEventListener("test",Po,Po),window.removeEventListener("test",Po,Po)}catch{Mf=!1}var Ma=null,_f=null,jc=null;function cy(){if(jc)return jc;var s,r=_f,l=r.length,d,p="value"in Ma?Ma.value:Ma.textContent,y=p.length;for(s=0;s<l&&r[s]===p[s];s++);var E=l-s;for(d=1;d<=E&&r[l-d]===p[y-d];d++);return jc=p.slice(s,1<d?1-d:void 0)}function Nc(s){var r=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&r===13&&(s=13)):s=r,s===10&&(s=13),32<=s||s===13?s:0}function kc(){return!0}function uy(){return!1}function Bn(s){function r(l,d,p,y,E){this._reactName=l,this._targetInst=p,this.type=d,this.nativeEvent=y,this.target=E,this.currentTarget=null;for(var _ in s)s.hasOwnProperty(_)&&(l=s[_],this[_]=l?l(y):y[_]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?kc:uy,this.isPropagationStopped=uy,this}return x(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=kc)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=kc)},persist:function(){},isPersistent:kc}),r}var kr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ec=Bn(kr),Uo=x({},kr,{view:0,detail:0}),nA=Bn(Uo),Of,If,Bo,Cc=x({},Uo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zf,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Bo&&(Bo&&s.type==="mousemove"?(Of=s.screenX-Bo.screenX,If=s.screenY-Bo.screenY):If=Of=0,Bo=s),Of)},movementY:function(s){return"movementY"in s?s.movementY:If}}),dy=Bn(Cc),sA=x({},Cc,{dataTransfer:0}),aA=Bn(sA),rA=x({},Uo,{relatedTarget:0}),Df=Bn(rA),iA=x({},kr,{animationName:0,elapsedTime:0,pseudoElement:0}),oA=Bn(iA),lA=x({},kr,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),cA=Bn(lA),uA=x({},kr,{data:0}),fy=Bn(uA),dA={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fA={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"},hA={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mA(s){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(s):(s=hA[s])?!!r[s]:!1}function zf(){return mA}var pA=x({},Uo,{key:function(s){if(s.key){var r=dA[s.key]||s.key;if(r!=="Unidentified")return r}return s.type==="keypress"?(s=Nc(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?fA[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zf,charCode:function(s){return s.type==="keypress"?Nc(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Nc(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),gA=Bn(pA),vA=x({},Cc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hy=Bn(vA),yA=x({},Uo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zf}),xA=Bn(yA),bA=x({},kr,{propertyName:0,elapsedTime:0,pseudoElement:0}),wA=Bn(bA),SA=x({},Cc,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),jA=Bn(SA),NA=x({},kr,{newState:0,oldState:0}),kA=Bn(NA),EA=[9,13,27,32],Lf=la&&"CompositionEvent"in window,Vo=null;la&&"documentMode"in document&&(Vo=document.documentMode);var CA=la&&"TextEvent"in window&&!Vo,my=la&&(!Lf||Vo&&8<Vo&&11>=Vo),py=" ",gy=!1;function vy(s,r){switch(s){case"keyup":return EA.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yy(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var yi=!1;function TA(s,r){switch(s){case"compositionend":return yy(r);case"keypress":return r.which!==32?null:(gy=!0,py);case"textInput":return s=r.data,s===py&&gy?null:s;default:return null}}function AA(s,r){if(yi)return s==="compositionend"||!Lf&&vy(s,r)?(s=cy(),jc=_f=Ma=null,yi=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return my&&r.locale!=="ko"?null:r.data;default:return null}}var RA={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 xy(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r==="input"?!!RA[s.type]:r==="textarea"}function by(s,r,l,d){gi?vi?vi.push(d):vi=[d]:gi=d,r=gu(r,"onChange"),0<r.length&&(l=new Ec("onChange","change",null,l,d),s.push({event:l,listeners:r}))}var Ho=null,Zo=null;function MA(s){nb(s,0)}function Tc(s){var r=Lo(s);if(ty(r))return s}function wy(s,r){if(s==="change")return r}var Sy=!1;if(la){var $f;if(la){var Pf="oninput"in document;if(!Pf){var jy=document.createElement("div");jy.setAttribute("oninput","return;"),Pf=typeof jy.oninput=="function"}$f=Pf}else $f=!1;Sy=$f&&(!document.documentMode||9<document.documentMode)}function Ny(){Ho&&(Ho.detachEvent("onpropertychange",ky),Zo=Ho=null)}function ky(s){if(s.propertyName==="value"&&Tc(Zo)){var r=[];by(r,Zo,s,Af(s)),ly(MA,r)}}function _A(s,r,l){s==="focusin"?(Ny(),Ho=r,Zo=l,Ho.attachEvent("onpropertychange",ky)):s==="focusout"&&Ny()}function OA(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Tc(Zo)}function IA(s,r){if(s==="click")return Tc(r)}function DA(s,r){if(s==="input"||s==="change")return Tc(r)}function zA(s,r){return s===r&&(s!==0||1/s===1/r)||s!==s&&r!==r}var Jn=typeof Object.is=="function"?Object.is:zA;function Fo(s,r){if(Jn(s,r))return!0;if(typeof s!="object"||s===null||typeof r!="object"||r===null)return!1;var l=Object.keys(s),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var p=l[d];if(!Ue.call(r,p)||!Jn(s[p],r[p]))return!1}return!0}function Ey(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Cy(s,r){var l=Ey(s);s=0;for(var d;l;){if(l.nodeType===3){if(d=s+l.textContent.length,s<=r&&d>=r)return{node:l,offset:r-s};s=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Ey(l)}}function Ty(s,r){return s&&r?s===r?!0:s&&s.nodeType===3?!1:r&&r.nodeType===3?Ty(s,r.parentNode):"contains"in s?s.contains(r):s.compareDocumentPosition?!!(s.compareDocumentPosition(r)&16):!1:!1}function Ay(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var r=wc(s.document);r instanceof s.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)s=r.contentWindow;else break;r=wc(s.document)}return r}function Uf(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r&&(r==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||r==="textarea"||s.contentEditable==="true")}var LA=la&&"documentMode"in document&&11>=document.documentMode,xi=null,Bf=null,qo=null,Vf=!1;function Ry(s,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Vf||xi==null||xi!==wc(d)||(d=xi,"selectionStart"in d&&Uf(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),qo&&Fo(qo,d)||(qo=d,d=gu(Bf,"onSelect"),0<d.length&&(r=new Ec("onSelect","select",null,r,l),s.push({event:r,listeners:d}),r.target=xi)))}function Er(s,r){var l={};return l[s.toLowerCase()]=r.toLowerCase(),l["Webkit"+s]="webkit"+r,l["Moz"+s]="moz"+r,l}var bi={animationend:Er("Animation","AnimationEnd"),animationiteration:Er("Animation","AnimationIteration"),animationstart:Er("Animation","AnimationStart"),transitionrun:Er("Transition","TransitionRun"),transitionstart:Er("Transition","TransitionStart"),transitioncancel:Er("Transition","TransitionCancel"),transitionend:Er("Transition","TransitionEnd")},Hf={},My={};la&&(My=document.createElement("div").style,"AnimationEvent"in window||(delete bi.animationend.animation,delete bi.animationiteration.animation,delete bi.animationstart.animation),"TransitionEvent"in window||delete bi.transitionend.transition);function Cr(s){if(Hf[s])return Hf[s];if(!bi[s])return s;var r=bi[s],l;for(l in r)if(r.hasOwnProperty(l)&&l in My)return Hf[s]=r[l];return s}var _y=Cr("animationend"),Oy=Cr("animationiteration"),Iy=Cr("animationstart"),$A=Cr("transitionrun"),PA=Cr("transitionstart"),UA=Cr("transitioncancel"),Dy=Cr("transitionend"),zy=new Map,Zf="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(" ");Zf.push("scrollEnd");function Rs(s,r){zy.set(s,r),Nr(r,[s])}var Ac=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},hs=[],wi=0,Ff=0;function Rc(){for(var s=wi,r=Ff=wi=0;r<s;){var l=hs[r];hs[r++]=null;var d=hs[r];hs[r++]=null;var p=hs[r];hs[r++]=null;var y=hs[r];if(hs[r++]=null,d!==null&&p!==null){var E=d.pending;E===null?p.next=p:(p.next=E.next,E.next=p),d.pending=p}y!==0&&Ly(l,p,y)}}function Mc(s,r,l,d){hs[wi++]=s,hs[wi++]=r,hs[wi++]=l,hs[wi++]=d,Ff|=d,s.lanes|=d,s=s.alternate,s!==null&&(s.lanes|=d)}function qf(s,r,l,d){return Mc(s,r,l,d),_c(s)}function Tr(s,r){return Mc(s,null,null,r),_c(s)}function Ly(s,r,l){s.lanes|=l;var d=s.alternate;d!==null&&(d.lanes|=l);for(var p=!1,y=s.return;y!==null;)y.childLanes|=l,d=y.alternate,d!==null&&(d.childLanes|=l),y.tag===22&&(s=y.stateNode,s===null||s._visibility&1||(p=!0)),s=y,y=y.return;return s.tag===3?(y=s.stateNode,p&&r!==null&&(p=31-ct(l),s=y.hiddenUpdates,d=s[p],d===null?s[p]=[r]:d.push(r),r.lane=l|536870912),y):null}function _c(s){if(50<ml)throw ml=0,tm=null,Error(a(185));for(var r=s.return;r!==null;)s=r,r=s.return;return s.tag===3?s.stateNode:null}var Si={};function BA(s,r,l,d){this.tag=s,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qn(s,r,l,d){return new BA(s,r,l,d)}function Yf(s){return s=s.prototype,!(!s||!s.isReactComponent)}function ca(s,r){var l=s.alternate;return l===null?(l=Qn(s.tag,r,s.key,s.mode),l.elementType=s.elementType,l.type=s.type,l.stateNode=s.stateNode,l.alternate=s,s.alternate=l):(l.pendingProps=r,l.type=s.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=s.flags&65011712,l.childLanes=s.childLanes,l.lanes=s.lanes,l.child=s.child,l.memoizedProps=s.memoizedProps,l.memoizedState=s.memoizedState,l.updateQueue=s.updateQueue,r=s.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=s.sibling,l.index=s.index,l.ref=s.ref,l.refCleanup=s.refCleanup,l}function $y(s,r){s.flags&=65011714;var l=s.alternate;return l===null?(s.childLanes=0,s.lanes=r,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=l.childLanes,s.lanes=l.lanes,s.child=l.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=l.memoizedProps,s.memoizedState=l.memoizedState,s.updateQueue=l.updateQueue,s.type=l.type,r=l.dependencies,s.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),s}function Oc(s,r,l,d,p,y){var E=0;if(d=s,typeof s=="function")Yf(s)&&(E=1);else if(typeof s=="string")E=qR(s,l,Q.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case F:return s=Qn(31,l,r,p),s.elementType=F,s.lanes=y,s;case N:return Ar(l.children,p,y,r);case T:E=8,p|=24;break;case k:return s=Qn(12,l,r,p|2),s.elementType=k,s.lanes=y,s;case A:return s=Qn(13,l,r,p),s.elementType=A,s.lanes=y,s;case M:return s=Qn(19,l,r,p),s.elementType=M,s.lanes=y,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case S:E=10;break e;case C:E=9;break e;case R:E=11;break e;case O:E=14;break e;case V:E=16,d=null;break e}E=29,l=Error(a(130,s===null?"null":typeof s,"")),d=null}return r=Qn(E,l,r,p),r.elementType=s,r.type=d,r.lanes=y,r}function Ar(s,r,l,d){return s=Qn(7,s,d,r),s.lanes=l,s}function Gf(s,r,l){return s=Qn(6,s,null,r),s.lanes=l,s}function Py(s){var r=Qn(18,null,null,0);return r.stateNode=s,r}function Wf(s,r,l){return r=Qn(4,s.children!==null?s.children:[],s.key,r),r.lanes=l,r.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},r}var Uy=new WeakMap;function ms(s,r){if(typeof s=="object"&&s!==null){var l=Uy.get(s);return l!==void 0?l:(r={value:s,source:r,stack:Ye(r)},Uy.set(s,r),r)}return{value:s,source:r,stack:Ye(r)}}var ji=[],Ni=0,Ic=null,Yo=0,ps=[],gs=0,_a=null,Bs=1,Vs="";function ua(s,r){ji[Ni++]=Yo,ji[Ni++]=Ic,Ic=s,Yo=r}function By(s,r,l){ps[gs++]=Bs,ps[gs++]=Vs,ps[gs++]=_a,_a=s;var d=Bs;s=Vs;var p=32-ct(d)-1;d&=~(1<<p),l+=1;var y=32-ct(r)+p;if(30<y){var E=p-p%5;y=(d&(1<<E)-1).toString(32),d>>=E,p-=E,Bs=1<<32-ct(r)+p|l<<p|d,Vs=y+s}else Bs=1<<y|l<<p|d,Vs=s}function Xf(s){s.return!==null&&(ua(s,1),By(s,1,0))}function Kf(s){for(;s===Ic;)Ic=ji[--Ni],ji[Ni]=null,Yo=ji[--Ni],ji[Ni]=null;for(;s===_a;)_a=ps[--gs],ps[gs]=null,Vs=ps[--gs],ps[gs]=null,Bs=ps[--gs],ps[gs]=null}function Vy(s,r){ps[gs++]=Bs,ps[gs++]=Vs,ps[gs++]=_a,Bs=r.id,Vs=r.overflow,_a=s}var Sn=null,Tt=null,ot=!1,Oa=null,vs=!1,Jf=Error(a(519));function Ia(s){var r=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Go(ms(r,s)),Jf}function Hy(s){var r=s.stateNode,l=s.type,d=s.memoizedProps;switch(r[wn]=s,r[Un]=d,l){case"dialog":st("cancel",r),st("close",r);break;case"iframe":case"object":case"embed":st("load",r);break;case"video":case"audio":for(l=0;l<gl.length;l++)st(gl[l],r);break;case"source":st("error",r);break;case"img":case"image":case"link":st("error",r),st("load",r);break;case"details":st("toggle",r);break;case"input":st("invalid",r),ny(r,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":st("invalid",r);break;case"textarea":st("invalid",r),ay(r,d.value,d.defaultValue,d.children)}l=d.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||r.textContent===""+l||d.suppressHydrationWarning===!0||ib(r.textContent,l)?(d.popover!=null&&(st("beforetoggle",r),st("toggle",r)),d.onScroll!=null&&st("scroll",r),d.onScrollEnd!=null&&st("scrollend",r),d.onClick!=null&&(r.onclick=oa),r=!0):r=!1,r||Ia(s,!0)}function Zy(s){for(Sn=s.return;Sn;)switch(Sn.tag){case 5:case 31:case 13:vs=!1;return;case 27:case 3:vs=!0;return;default:Sn=Sn.return}}function ki(s){if(s!==Sn)return!1;if(!ot)return Zy(s),ot=!0,!1;var r=s.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=s.type,l=!(l!=="form"&&l!=="button")||gm(s.type,s.memoizedProps)),l=!l),l&&Tt&&Ia(s),Zy(s),r===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(a(317));Tt=pb(s)}else if(r===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(a(317));Tt=pb(s)}else r===27?(r=Tt,Ga(s.type)?(s=wm,wm=null,Tt=s):Tt=r):Tt=Sn?xs(s.stateNode.nextSibling):null;return!0}function Rr(){Tt=Sn=null,ot=!1}function Qf(){var s=Oa;return s!==null&&(Fn===null?Fn=s:Fn.push.apply(Fn,s),Oa=null),s}function Go(s){Oa===null?Oa=[s]:Oa.push(s)}var eh=z(null),Mr=null,da=null;function Da(s,r,l){J(eh,r._currentValue),r._currentValue=l}function fa(s){s._currentValue=eh.current,Z(eh)}function th(s,r,l){for(;s!==null;){var d=s.alternate;if((s.childLanes&r)!==r?(s.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),s===l)break;s=s.return}}function nh(s,r,l,d){var p=s.child;for(p!==null&&(p.return=s);p!==null;){var y=p.dependencies;if(y!==null){var E=p.child;y=y.firstContext;e:for(;y!==null;){var _=y;y=p;for(var H=0;H<r.length;H++)if(_.context===r[H]){y.lanes|=l,_=y.alternate,_!==null&&(_.lanes|=l),th(y.return,l,s),d||(E=null);break e}y=_.next}}else if(p.tag===18){if(E=p.return,E===null)throw Error(a(341));E.lanes|=l,y=E.alternate,y!==null&&(y.lanes|=l),th(E,l,s),E=null}else E=p.child;if(E!==null)E.return=p;else for(E=p;E!==null;){if(E===s){E=null;break}if(p=E.sibling,p!==null){p.return=E.return,E=p;break}E=E.return}p=E}}function Ei(s,r,l,d){s=null;for(var p=r,y=!1;p!==null;){if(!y){if((p.flags&524288)!==0)y=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var E=p.alternate;if(E===null)throw Error(a(387));if(E=E.memoizedProps,E!==null){var _=p.type;Jn(p.pendingProps.value,E.value)||(s!==null?s.push(_):s=[_])}}else if(p===de.current){if(E=p.alternate,E===null)throw Error(a(387));E.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(s!==null?s.push(wl):s=[wl])}p=p.return}s!==null&&nh(r,s,l,d),r.flags|=262144}function Dc(s){for(s=s.firstContext;s!==null;){if(!Jn(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function _r(s){Mr=s,da=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function jn(s){return Fy(Mr,s)}function zc(s,r){return Mr===null&&_r(s),Fy(s,r)}function Fy(s,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},da===null){if(s===null)throw Error(a(308));da=r,s.dependencies={lanes:0,firstContext:r},s.flags|=524288}else da=da.next=r;return l}var VA=typeof AbortController<"u"?AbortController:function(){var s=[],r=this.signal={aborted:!1,addEventListener:function(l,d){s.push(d)}};this.abort=function(){r.aborted=!0,s.forEach(function(l){return l()})}},HA=e.unstable_scheduleCallback,ZA=e.unstable_NormalPriority,en={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function sh(){return{controller:new VA,data:new Map,refCount:0}}function Wo(s){s.refCount--,s.refCount===0&&HA(ZA,function(){s.controller.abort()})}var Xo=null,ah=0,Ci=0,Ti=null;function FA(s,r){if(Xo===null){var l=Xo=[];ah=0,Ci=om(),Ti={status:"pending",value:void 0,then:function(d){l.push(d)}}}return ah++,r.then(qy,qy),r}function qy(){if(--ah===0&&Xo!==null){Ti!==null&&(Ti.status="fulfilled");var s=Xo;Xo=null,Ci=0,Ti=null;for(var r=0;r<s.length;r++)(0,s[r])()}}function qA(s,r){var l=[],d={status:"pending",value:null,reason:null,then:function(p){l.push(p)}};return s.then(function(){d.status="fulfilled",d.value=r;for(var p=0;p<l.length;p++)(0,l[p])(r)},function(p){for(d.status="rejected",d.reason=p,p=0;p<l.length;p++)(0,l[p])(void 0)}),d}var Yy=D.S;D.S=function(s,r){Rx=je(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&FA(s,r),Yy!==null&&Yy(s,r)};var Or=z(null);function rh(){var s=Or.current;return s!==null?s:jt.pooledCache}function Lc(s,r){r===null?J(Or,Or.current):J(Or,r.pool)}function Gy(){var s=rh();return s===null?null:{parent:en._currentValue,pool:s}}var Ai=Error(a(460)),ih=Error(a(474)),$c=Error(a(542)),Pc={then:function(){}};function Wy(s){return s=s.status,s==="fulfilled"||s==="rejected"}function Xy(s,r,l){switch(l=s[l],l===void 0?s.push(r):l!==r&&(r.then(oa,oa),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw s=r.reason,Jy(s),s;default:if(typeof r.status=="string")r.then(oa,oa);else{if(s=jt,s!==null&&100<s.shellSuspendCounter)throw Error(a(482));s=r,s.status="pending",s.then(function(d){if(r.status==="pending"){var p=r;p.status="fulfilled",p.value=d}},function(d){if(r.status==="pending"){var p=r;p.status="rejected",p.reason=d}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw s=r.reason,Jy(s),s}throw Dr=r,Ai}}function Ir(s){try{var r=s._init;return r(s._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Dr=l,Ai):l}}var Dr=null;function Ky(){if(Dr===null)throw Error(a(459));var s=Dr;return Dr=null,s}function Jy(s){if(s===Ai||s===$c)throw Error(a(483))}var Ri=null,Ko=0;function Uc(s){var r=Ko;return Ko+=1,Ri===null&&(Ri=[]),Xy(Ri,s,r)}function Jo(s,r){r=r.props.ref,s.ref=r!==void 0?r:null}function Bc(s,r){throw r.$$typeof===b?Error(a(525)):(s=Object.prototype.toString.call(r),Error(a(31,s==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":s)))}function Qy(s){function r(W,q){if(s){var te=W.deletions;te===null?(W.deletions=[q],W.flags|=16):te.push(q)}}function l(W,q){if(!s)return null;for(;q!==null;)r(W,q),q=q.sibling;return null}function d(W){for(var q=new Map;W!==null;)W.key!==null?q.set(W.key,W):q.set(W.index,W),W=W.sibling;return q}function p(W,q){return W=ca(W,q),W.index=0,W.sibling=null,W}function y(W,q,te){return W.index=te,s?(te=W.alternate,te!==null?(te=te.index,te<q?(W.flags|=67108866,q):te):(W.flags|=67108866,q)):(W.flags|=1048576,q)}function E(W){return s&&W.alternate===null&&(W.flags|=67108866),W}function _(W,q,te,ce){return q===null||q.tag!==6?(q=Gf(te,W.mode,ce),q.return=W,q):(q=p(q,te),q.return=W,q)}function H(W,q,te,ce){var De=te.type;return De===N?ie(W,q,te.props.children,ce,te.key):q!==null&&(q.elementType===De||typeof De=="object"&&De!==null&&De.$$typeof===V&&Ir(De)===q.type)?(q=p(q,te.props),Jo(q,te),q.return=W,q):(q=Oc(te.type,te.key,te.props,null,W.mode,ce),Jo(q,te),q.return=W,q)}function ne(W,q,te,ce){return q===null||q.tag!==4||q.stateNode.containerInfo!==te.containerInfo||q.stateNode.implementation!==te.implementation?(q=Wf(te,W.mode,ce),q.return=W,q):(q=p(q,te.children||[]),q.return=W,q)}function ie(W,q,te,ce,De){return q===null||q.tag!==7?(q=Ar(te,W.mode,ce,De),q.return=W,q):(q=p(q,te),q.return=W,q)}function ue(W,q,te){if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return q=Gf(""+q,W.mode,te),q.return=W,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case w:return te=Oc(q.type,q.key,q.props,null,W.mode,te),Jo(te,q),te.return=W,te;case j:return q=Wf(q,W.mode,te),q.return=W,q;case V:return q=Ir(q),ue(W,q,te)}if(K(q)||L(q))return q=Ar(q,W.mode,te,null),q.return=W,q;if(typeof q.then=="function")return ue(W,Uc(q),te);if(q.$$typeof===S)return ue(W,zc(W,q),te);Bc(W,q)}return null}function se(W,q,te,ce){var De=q!==null?q.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return De!==null?null:_(W,q,""+te,ce);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case w:return te.key===De?H(W,q,te,ce):null;case j:return te.key===De?ne(W,q,te,ce):null;case V:return te=Ir(te),se(W,q,te,ce)}if(K(te)||L(te))return De!==null?null:ie(W,q,te,ce,null);if(typeof te.then=="function")return se(W,q,Uc(te),ce);if(te.$$typeof===S)return se(W,q,zc(W,te),ce);Bc(W,te)}return null}function ae(W,q,te,ce,De){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return W=W.get(te)||null,_(q,W,""+ce,De);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:return W=W.get(ce.key===null?te:ce.key)||null,H(q,W,ce,De);case j:return W=W.get(ce.key===null?te:ce.key)||null,ne(q,W,ce,De);case V:return ce=Ir(ce),ae(W,q,te,ce,De)}if(K(ce)||L(ce))return W=W.get(te)||null,ie(q,W,ce,De,null);if(typeof ce.then=="function")return ae(W,q,te,Uc(ce),De);if(ce.$$typeof===S)return ae(W,q,te,zc(q,ce),De);Bc(q,ce)}return null}function Ee(W,q,te,ce){for(var De=null,ft=null,Te=q,Ke=q=0,it=null;Te!==null&&Ke<te.length;Ke++){Te.index>Ke?(it=Te,Te=null):it=Te.sibling;var ht=se(W,Te,te[Ke],ce);if(ht===null){Te===null&&(Te=it);break}s&&Te&&ht.alternate===null&&r(W,Te),q=y(ht,q,Ke),ft===null?De=ht:ft.sibling=ht,ft=ht,Te=it}if(Ke===te.length)return l(W,Te),ot&&ua(W,Ke),De;if(Te===null){for(;Ke<te.length;Ke++)Te=ue(W,te[Ke],ce),Te!==null&&(q=y(Te,q,Ke),ft===null?De=Te:ft.sibling=Te,ft=Te);return ot&&ua(W,Ke),De}for(Te=d(Te);Ke<te.length;Ke++)it=ae(Te,W,Ke,te[Ke],ce),it!==null&&(s&&it.alternate!==null&&Te.delete(it.key===null?Ke:it.key),q=y(it,q,Ke),ft===null?De=it:ft.sibling=it,ft=it);return s&&Te.forEach(function(Qa){return r(W,Qa)}),ot&&ua(W,Ke),De}function Le(W,q,te,ce){if(te==null)throw Error(a(151));for(var De=null,ft=null,Te=q,Ke=q=0,it=null,ht=te.next();Te!==null&&!ht.done;Ke++,ht=te.next()){Te.index>Ke?(it=Te,Te=null):it=Te.sibling;var Qa=se(W,Te,ht.value,ce);if(Qa===null){Te===null&&(Te=it);break}s&&Te&&Qa.alternate===null&&r(W,Te),q=y(Qa,q,Ke),ft===null?De=Qa:ft.sibling=Qa,ft=Qa,Te=it}if(ht.done)return l(W,Te),ot&&ua(W,Ke),De;if(Te===null){for(;!ht.done;Ke++,ht=te.next())ht=ue(W,ht.value,ce),ht!==null&&(q=y(ht,q,Ke),ft===null?De=ht:ft.sibling=ht,ft=ht);return ot&&ua(W,Ke),De}for(Te=d(Te);!ht.done;Ke++,ht=te.next())ht=ae(Te,W,Ke,ht.value,ce),ht!==null&&(s&&ht.alternate!==null&&Te.delete(ht.key===null?Ke:ht.key),q=y(ht,q,Ke),ft===null?De=ht:ft.sibling=ht,ft=ht);return s&&Te.forEach(function(sM){return r(W,sM)}),ot&&ua(W,Ke),De}function St(W,q,te,ce){if(typeof te=="object"&&te!==null&&te.type===N&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case w:e:{for(var De=te.key;q!==null;){if(q.key===De){if(De=te.type,De===N){if(q.tag===7){l(W,q.sibling),ce=p(q,te.props.children),ce.return=W,W=ce;break e}}else if(q.elementType===De||typeof De=="object"&&De!==null&&De.$$typeof===V&&Ir(De)===q.type){l(W,q.sibling),ce=p(q,te.props),Jo(ce,te),ce.return=W,W=ce;break e}l(W,q);break}else r(W,q);q=q.sibling}te.type===N?(ce=Ar(te.props.children,W.mode,ce,te.key),ce.return=W,W=ce):(ce=Oc(te.type,te.key,te.props,null,W.mode,ce),Jo(ce,te),ce.return=W,W=ce)}return E(W);case j:e:{for(De=te.key;q!==null;){if(q.key===De)if(q.tag===4&&q.stateNode.containerInfo===te.containerInfo&&q.stateNode.implementation===te.implementation){l(W,q.sibling),ce=p(q,te.children||[]),ce.return=W,W=ce;break e}else{l(W,q);break}else r(W,q);q=q.sibling}ce=Wf(te,W.mode,ce),ce.return=W,W=ce}return E(W);case V:return te=Ir(te),St(W,q,te,ce)}if(K(te))return Ee(W,q,te,ce);if(L(te)){if(De=L(te),typeof De!="function")throw Error(a(150));return te=De.call(te),Le(W,q,te,ce)}if(typeof te.then=="function")return St(W,q,Uc(te),ce);if(te.$$typeof===S)return St(W,q,zc(W,te),ce);Bc(W,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,q!==null&&q.tag===6?(l(W,q.sibling),ce=p(q,te),ce.return=W,W=ce):(l(W,q),ce=Gf(te,W.mode,ce),ce.return=W,W=ce),E(W)):l(W,q)}return function(W,q,te,ce){try{Ko=0;var De=St(W,q,te,ce);return Ri=null,De}catch(Te){if(Te===Ai||Te===$c)throw Te;var ft=Qn(29,Te,null,W.mode);return ft.lanes=ce,ft.return=W,ft}}}var zr=Qy(!0),e0=Qy(!1),za=!1;function oh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lh(s,r){s=s.updateQueue,r.updateQueue===s&&(r.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function La(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function $a(s,r,l){var d=s.updateQueue;if(d===null)return null;if(d=d.shared,(pt&2)!==0){var p=d.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),d.pending=r,r=_c(s),Ly(s,null,l),r}return Mc(s,d,r,l),_c(s)}function Qo(s,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var d=r.lanes;d&=s.pendingLanes,l|=d,r.lanes=l,Ft(s,l)}}function ch(s,r){var l=s.updateQueue,d=s.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var p=null,y=null;if(l=l.firstBaseUpdate,l!==null){do{var E={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};y===null?p=y=E:y=y.next=E,l=l.next}while(l!==null);y===null?p=y=r:y=y.next=r}else p=y=r;l={baseState:d.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},s.updateQueue=l;return}s=l.lastBaseUpdate,s===null?l.firstBaseUpdate=r:s.next=r,l.lastBaseUpdate=r}var uh=!1;function el(){if(uh){var s=Ti;if(s!==null)throw s}}function tl(s,r,l,d){uh=!1;var p=s.updateQueue;za=!1;var y=p.firstBaseUpdate,E=p.lastBaseUpdate,_=p.shared.pending;if(_!==null){p.shared.pending=null;var H=_,ne=H.next;H.next=null,E===null?y=ne:E.next=ne,E=H;var ie=s.alternate;ie!==null&&(ie=ie.updateQueue,_=ie.lastBaseUpdate,_!==E&&(_===null?ie.firstBaseUpdate=ne:_.next=ne,ie.lastBaseUpdate=H))}if(y!==null){var ue=p.baseState;E=0,ie=ne=H=null,_=y;do{var se=_.lane&-536870913,ae=se!==_.lane;if(ae?(rt&se)===se:(d&se)===se){se!==0&&se===Ci&&(uh=!0),ie!==null&&(ie=ie.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Ee=s,Le=_;se=r;var St=l;switch(Le.tag){case 1:if(Ee=Le.payload,typeof Ee=="function"){ue=Ee.call(St,ue,se);break e}ue=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Le.payload,se=typeof Ee=="function"?Ee.call(St,ue,se):Ee,se==null)break e;ue=x({},ue,se);break e;case 2:za=!0}}se=_.callback,se!==null&&(s.flags|=64,ae&&(s.flags|=8192),ae=p.callbacks,ae===null?p.callbacks=[se]:ae.push(se))}else ae={lane:se,tag:_.tag,payload:_.payload,callback:_.callback,next:null},ie===null?(ne=ie=ae,H=ue):ie=ie.next=ae,E|=se;if(_=_.next,_===null){if(_=p.shared.pending,_===null)break;ae=_,_=ae.next,ae.next=null,p.lastBaseUpdate=ae,p.shared.pending=null}}while(!0);ie===null&&(H=ue),p.baseState=H,p.firstBaseUpdate=ne,p.lastBaseUpdate=ie,y===null&&(p.shared.lanes=0),Ha|=E,s.lanes=E,s.memoizedState=ue}}function t0(s,r){if(typeof s!="function")throw Error(a(191,s));s.call(r)}function n0(s,r){var l=s.callbacks;if(l!==null)for(s.callbacks=null,s=0;s<l.length;s++)t0(l[s],r)}var Mi=z(null),Vc=z(0);function s0(s,r){s=wa,J(Vc,s),J(Mi,r),wa=s|r.baseLanes}function dh(){J(Vc,wa),J(Mi,Mi.current)}function fh(){wa=Vc.current,Z(Mi),Z(Vc)}var es=z(null),ys=null;function Pa(s){var r=s.alternate;J(Kt,Kt.current&1),J(es,s),ys===null&&(r===null||Mi.current!==null||r.memoizedState!==null)&&(ys=s)}function hh(s){J(Kt,Kt.current),J(es,s),ys===null&&(ys=s)}function a0(s){s.tag===22?(J(Kt,Kt.current),J(es,s),ys===null&&(ys=s)):Ua()}function Ua(){J(Kt,Kt.current),J(es,es.current)}function ts(s){Z(es),ys===s&&(ys=null),Z(Kt)}var Kt=z(0);function Hc(s){for(var r=s;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||xm(l)||bm(l)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var ha=0,Xe=null,bt=null,tn=null,Zc=!1,_i=!1,Lr=!1,Fc=0,nl=0,Oi=null,YA=0;function Yt(){throw Error(a(321))}function mh(s,r){if(r===null)return!1;for(var l=0;l<r.length&&l<s.length;l++)if(!Jn(s[l],r[l]))return!1;return!0}function ph(s,r,l,d,p,y){return ha=y,Xe=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,D.H=s===null||s.memoizedState===null?B0:Rh,Lr=!1,y=l(d,p),Lr=!1,_i&&(y=i0(r,l,d,p)),r0(s),y}function r0(s){D.H=rl;var r=bt!==null&&bt.next!==null;if(ha=0,tn=bt=Xe=null,Zc=!1,nl=0,Oi=null,r)throw Error(a(300));s===null||nn||(s=s.dependencies,s!==null&&Dc(s)&&(nn=!0))}function i0(s,r,l,d){Xe=s;var p=0;do{if(_i&&(Oi=null),nl=0,_i=!1,25<=p)throw Error(a(301));if(p+=1,tn=bt=null,s.updateQueue!=null){var y=s.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}D.H=V0,y=r(l,d)}while(_i);return y}function GA(){var s=D.H,r=s.useState()[0];return r=typeof r.then=="function"?sl(r):r,s=s.useState()[0],(bt!==null?bt.memoizedState:null)!==s&&(Xe.flags|=1024),r}function gh(){var s=Fc!==0;return Fc=0,s}function vh(s,r,l){r.updateQueue=s.updateQueue,r.flags&=-2053,s.lanes&=~l}function yh(s){if(Zc){for(s=s.memoizedState;s!==null;){var r=s.queue;r!==null&&(r.pending=null),s=s.next}Zc=!1}ha=0,tn=bt=Xe=null,_i=!1,nl=Fc=0,Oi=null}function On(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?Xe.memoizedState=tn=s:tn=tn.next=s,tn}function Jt(){if(bt===null){var s=Xe.alternate;s=s!==null?s.memoizedState:null}else s=bt.next;var r=tn===null?Xe.memoizedState:tn.next;if(r!==null)tn=r,bt=s;else{if(s===null)throw Xe.alternate===null?Error(a(467)):Error(a(310));bt=s,s={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},tn===null?Xe.memoizedState=tn=s:tn=tn.next=s}return tn}function qc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function sl(s){var r=nl;return nl+=1,Oi===null&&(Oi=[]),s=Xy(Oi,s,r),r=Xe,(tn===null?r.memoizedState:tn.next)===null&&(r=r.alternate,D.H=r===null||r.memoizedState===null?B0:Rh),s}function Yc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return sl(s);if(s.$$typeof===S)return jn(s)}throw Error(a(438,String(s)))}function xh(s){var r=null,l=Xe.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var d=Xe.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(r={data:d.data.map(function(p){return p.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=qc(),Xe.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(s),d=0;d<s;d++)l[d]=I;return r.index++,l}function ma(s,r){return typeof r=="function"?r(s):r}function Gc(s){var r=Jt();return bh(r,bt,s)}function bh(s,r,l){var d=s.queue;if(d===null)throw Error(a(311));d.lastRenderedReducer=l;var p=s.baseQueue,y=d.pending;if(y!==null){if(p!==null){var E=p.next;p.next=y.next,y.next=E}r.baseQueue=p=y,d.pending=null}if(y=s.baseState,p===null)s.memoizedState=y;else{r=p.next;var _=E=null,H=null,ne=r,ie=!1;do{var ue=ne.lane&-536870913;if(ue!==ne.lane?(rt&ue)===ue:(ha&ue)===ue){var se=ne.revertLane;if(se===0)H!==null&&(H=H.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),ue===Ci&&(ie=!0);else if((ha&se)===se){ne=ne.next,se===Ci&&(ie=!0);continue}else ue={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},H===null?(_=H=ue,E=y):H=H.next=ue,Xe.lanes|=se,Ha|=se;ue=ne.action,Lr&&l(y,ue),y=ne.hasEagerState?ne.eagerState:l(y,ue)}else se={lane:ue,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},H===null?(_=H=se,E=y):H=H.next=se,Xe.lanes|=ue,Ha|=ue;ne=ne.next}while(ne!==null&&ne!==r);if(H===null?E=y:H.next=_,!Jn(y,s.memoizedState)&&(nn=!0,ie&&(l=Ti,l!==null)))throw l;s.memoizedState=y,s.baseState=E,s.baseQueue=H,d.lastRenderedState=y}return p===null&&(d.lanes=0),[s.memoizedState,d.dispatch]}function wh(s){var r=Jt(),l=r.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=s;var d=l.dispatch,p=l.pending,y=r.memoizedState;if(p!==null){l.pending=null;var E=p=p.next;do y=s(y,E.action),E=E.next;while(E!==p);Jn(y,r.memoizedState)||(nn=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),l.lastRenderedState=y}return[y,d]}function o0(s,r,l){var d=Xe,p=Jt(),y=ot;if(y){if(l===void 0)throw Error(a(407));l=l()}else l=r();var E=!Jn((bt||p).memoizedState,l);if(E&&(p.memoizedState=l,nn=!0),p=p.queue,Nh(u0.bind(null,d,p,s),[s]),p.getSnapshot!==r||E||tn!==null&&tn.memoizedState.tag&1){if(d.flags|=2048,Ii(9,{destroy:void 0},c0.bind(null,d,p,l,r),null),jt===null)throw Error(a(349));y||(ha&127)!==0||l0(d,r,l)}return l}function l0(s,r,l){s.flags|=16384,s={getSnapshot:r,value:l},r=Xe.updateQueue,r===null?(r=qc(),Xe.updateQueue=r,r.stores=[s]):(l=r.stores,l===null?r.stores=[s]:l.push(s))}function c0(s,r,l,d){r.value=l,r.getSnapshot=d,d0(r)&&f0(s)}function u0(s,r,l){return l(function(){d0(r)&&f0(s)})}function d0(s){var r=s.getSnapshot;s=s.value;try{var l=r();return!Jn(s,l)}catch{return!0}}function f0(s){var r=Tr(s,2);r!==null&&qn(r,s,2)}function Sh(s){var r=On();if(typeof s=="function"){var l=s;if(s=l(),Lr){tt(!0);try{l()}finally{tt(!1)}}}return r.memoizedState=r.baseState=s,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ma,lastRenderedState:s},r}function h0(s,r,l,d){return s.baseState=l,bh(s,bt,typeof d=="function"?d:ma)}function WA(s,r,l,d,p){if(Kc(s))throw Error(a(485));if(s=r.action,s!==null){var y={payload:p,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(E){y.listeners.push(E)}};D.T!==null?l(!0):y.isTransition=!1,d(y),l=r.pending,l===null?(y.next=r.pending=y,m0(r,y)):(y.next=l.next,r.pending=l.next=y)}}function m0(s,r){var l=r.action,d=r.payload,p=s.state;if(r.isTransition){var y=D.T,E={};D.T=E;try{var _=l(p,d),H=D.S;H!==null&&H(E,_),p0(s,r,_)}catch(ne){jh(s,r,ne)}finally{y!==null&&E.types!==null&&(y.types=E.types),D.T=y}}else try{y=l(p,d),p0(s,r,y)}catch(ne){jh(s,r,ne)}}function p0(s,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(d){g0(s,r,d)},function(d){return jh(s,r,d)}):g0(s,r,l)}function g0(s,r,l){r.status="fulfilled",r.value=l,v0(r),s.state=l,r=s.pending,r!==null&&(l=r.next,l===r?s.pending=null:(l=l.next,r.next=l,m0(s,l)))}function jh(s,r,l){var d=s.pending;if(s.pending=null,d!==null){d=d.next;do r.status="rejected",r.reason=l,v0(r),r=r.next;while(r!==d)}s.action=null}function v0(s){s=s.listeners;for(var r=0;r<s.length;r++)(0,s[r])()}function y0(s,r){return r}function x0(s,r){if(ot){var l=jt.formState;if(l!==null){e:{var d=Xe;if(ot){if(Tt){t:{for(var p=Tt,y=vs;p.nodeType!==8;){if(!y){p=null;break t}if(p=xs(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){Tt=xs(p.nextSibling),d=p.data==="F!";break e}}Ia(d)}d=!1}d&&(r=l[0])}}return l=On(),l.memoizedState=l.baseState=r,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:y0,lastRenderedState:r},l.queue=d,l=$0.bind(null,Xe,d),d.dispatch=l,d=Sh(!1),y=Ah.bind(null,Xe,!1,d.queue),d=On(),p={state:r,dispatch:null,action:s,pending:null},d.queue=p,l=WA.bind(null,Xe,p,y,l),p.dispatch=l,d.memoizedState=s,[r,l,!1]}function b0(s){var r=Jt();return w0(r,bt,s)}function w0(s,r,l){if(r=bh(s,r,y0)[0],s=Gc(ma)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var d=sl(r)}catch(E){throw E===Ai?$c:E}else d=r;r=Jt();var p=r.queue,y=p.dispatch;return l!==r.memoizedState&&(Xe.flags|=2048,Ii(9,{destroy:void 0},XA.bind(null,p,l),null)),[d,y,s]}function XA(s,r){s.action=r}function S0(s){var r=Jt(),l=bt;if(l!==null)return w0(r,l,s);Jt(),r=r.memoizedState,l=Jt();var d=l.queue.dispatch;return l.memoizedState=s,[r,d,!1]}function Ii(s,r,l,d){return s={tag:s,create:l,deps:d,inst:r,next:null},r=Xe.updateQueue,r===null&&(r=qc(),Xe.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=s.next=s:(d=l.next,l.next=s,s.next=d,r.lastEffect=s),s}function j0(){return Jt().memoizedState}function Wc(s,r,l,d){var p=On();Xe.flags|=s,p.memoizedState=Ii(1|r,{destroy:void 0},l,d===void 0?null:d)}function Xc(s,r,l,d){var p=Jt();d=d===void 0?null:d;var y=p.memoizedState.inst;bt!==null&&d!==null&&mh(d,bt.memoizedState.deps)?p.memoizedState=Ii(r,y,l,d):(Xe.flags|=s,p.memoizedState=Ii(1|r,y,l,d))}function N0(s,r){Wc(8390656,8,s,r)}function Nh(s,r){Xc(2048,8,s,r)}function KA(s){Xe.flags|=4;var r=Xe.updateQueue;if(r===null)r=qc(),Xe.updateQueue=r,r.events=[s];else{var l=r.events;l===null?r.events=[s]:l.push(s)}}function k0(s){var r=Jt().memoizedState;return KA({ref:r,nextImpl:s}),function(){if((pt&2)!==0)throw Error(a(440));return r.impl.apply(void 0,arguments)}}function E0(s,r){return Xc(4,2,s,r)}function C0(s,r){return Xc(4,4,s,r)}function T0(s,r){if(typeof r=="function"){s=s();var l=r(s);return function(){typeof l=="function"?l():r(null)}}if(r!=null)return s=s(),r.current=s,function(){r.current=null}}function A0(s,r,l){l=l!=null?l.concat([s]):null,Xc(4,4,T0.bind(null,r,s),l)}function kh(){}function R0(s,r){var l=Jt();r=r===void 0?null:r;var d=l.memoizedState;return r!==null&&mh(r,d[1])?d[0]:(l.memoizedState=[s,r],s)}function M0(s,r){var l=Jt();r=r===void 0?null:r;var d=l.memoizedState;if(r!==null&&mh(r,d[1]))return d[0];if(d=s(),Lr){tt(!0);try{s()}finally{tt(!1)}}return l.memoizedState=[d,r],d}function Eh(s,r,l){return l===void 0||(ha&1073741824)!==0&&(rt&261930)===0?s.memoizedState=r:(s.memoizedState=l,s=_x(),Xe.lanes|=s,Ha|=s,l)}function _0(s,r,l,d){return Jn(l,r)?l:Mi.current!==null?(s=Eh(s,l,d),Jn(s,r)||(nn=!0),s):(ha&42)===0||(ha&1073741824)!==0&&(rt&261930)===0?(nn=!0,s.memoizedState=l):(s=_x(),Xe.lanes|=s,Ha|=s,r)}function O0(s,r,l,d,p){var y=P.p;P.p=y!==0&&8>y?y:8;var E=D.T,_={};D.T=_,Ah(s,!1,r,l);try{var H=p(),ne=D.S;if(ne!==null&&ne(_,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var ie=qA(H,d);al(s,r,ie,as(s))}else al(s,r,d,as(s))}catch(ue){al(s,r,{then:function(){},status:"rejected",reason:ue},as())}finally{P.p=y,E!==null&&_.types!==null&&(E.types=_.types),D.T=E}}function JA(){}function Ch(s,r,l,d){if(s.tag!==5)throw Error(a(476));var p=I0(s).queue;O0(s,p,r,B,l===null?JA:function(){return D0(s),l(d)})}function I0(s){var r=s.memoizedState;if(r!==null)return r;r={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ma,lastRenderedState:B},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ma,lastRenderedState:l},next:null},s.memoizedState=r,s=s.alternate,s!==null&&(s.memoizedState=r),r}function D0(s){var r=I0(s);r.next===null&&(r=s.alternate.memoizedState),al(s,r.next.queue,{},as())}function Th(){return jn(wl)}function z0(){return Jt().memoizedState}function L0(){return Jt().memoizedState}function QA(s){for(var r=s.return;r!==null;){switch(r.tag){case 24:case 3:var l=as();s=La(l);var d=$a(r,s,l);d!==null&&(qn(d,r,l),Qo(d,r,l)),r={cache:sh()},s.payload=r;return}r=r.return}}function eR(s,r,l){var d=as();l={lane:d,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Kc(s)?P0(r,l):(l=qf(s,r,l,d),l!==null&&(qn(l,s,d),U0(l,r,d)))}function $0(s,r,l){var d=as();al(s,r,l,d)}function al(s,r,l,d){var p={lane:d,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Kc(s))P0(r,p);else{var y=s.alternate;if(s.lanes===0&&(y===null||y.lanes===0)&&(y=r.lastRenderedReducer,y!==null))try{var E=r.lastRenderedState,_=y(E,l);if(p.hasEagerState=!0,p.eagerState=_,Jn(_,E))return Mc(s,r,p,0),jt===null&&Rc(),!1}catch{}if(l=qf(s,r,p,d),l!==null)return qn(l,s,d),U0(l,r,d),!0}return!1}function Ah(s,r,l,d){if(d={lane:2,revertLane:om(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Kc(s)){if(r)throw Error(a(479))}else r=qf(s,l,d,2),r!==null&&qn(r,s,2)}function Kc(s){var r=s.alternate;return s===Xe||r!==null&&r===Xe}function P0(s,r){_i=Zc=!0;var l=s.pending;l===null?r.next=r:(r.next=l.next,l.next=r),s.pending=r}function U0(s,r,l){if((l&4194048)!==0){var d=r.lanes;d&=s.pendingLanes,l|=d,r.lanes=l,Ft(s,l)}}var rl={readContext:jn,use:Yc,useCallback:Yt,useContext:Yt,useEffect:Yt,useImperativeHandle:Yt,useLayoutEffect:Yt,useInsertionEffect:Yt,useMemo:Yt,useReducer:Yt,useRef:Yt,useState:Yt,useDebugValue:Yt,useDeferredValue:Yt,useTransition:Yt,useSyncExternalStore:Yt,useId:Yt,useHostTransitionStatus:Yt,useFormState:Yt,useActionState:Yt,useOptimistic:Yt,useMemoCache:Yt,useCacheRefresh:Yt};rl.useEffectEvent=Yt;var B0={readContext:jn,use:Yc,useCallback:function(s,r){return On().memoizedState=[s,r===void 0?null:r],s},useContext:jn,useEffect:N0,useImperativeHandle:function(s,r,l){l=l!=null?l.concat([s]):null,Wc(4194308,4,T0.bind(null,r,s),l)},useLayoutEffect:function(s,r){return Wc(4194308,4,s,r)},useInsertionEffect:function(s,r){Wc(4,2,s,r)},useMemo:function(s,r){var l=On();r=r===void 0?null:r;var d=s();if(Lr){tt(!0);try{s()}finally{tt(!1)}}return l.memoizedState=[d,r],d},useReducer:function(s,r,l){var d=On();if(l!==void 0){var p=l(r);if(Lr){tt(!0);try{l(r)}finally{tt(!1)}}}else p=r;return d.memoizedState=d.baseState=p,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:p},d.queue=s,s=s.dispatch=eR.bind(null,Xe,s),[d.memoizedState,s]},useRef:function(s){var r=On();return s={current:s},r.memoizedState=s},useState:function(s){s=Sh(s);var r=s.queue,l=$0.bind(null,Xe,r);return r.dispatch=l,[s.memoizedState,l]},useDebugValue:kh,useDeferredValue:function(s,r){var l=On();return Eh(l,s,r)},useTransition:function(){var s=Sh(!1);return s=O0.bind(null,Xe,s.queue,!0,!1),On().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,r,l){var d=Xe,p=On();if(ot){if(l===void 0)throw Error(a(407));l=l()}else{if(l=r(),jt===null)throw Error(a(349));(rt&127)!==0||l0(d,r,l)}p.memoizedState=l;var y={value:l,getSnapshot:r};return p.queue=y,N0(u0.bind(null,d,y,s),[s]),d.flags|=2048,Ii(9,{destroy:void 0},c0.bind(null,d,y,l,r),null),l},useId:function(){var s=On(),r=jt.identifierPrefix;if(ot){var l=Vs,d=Bs;l=(d&~(1<<32-ct(d)-1)).toString(32)+l,r="_"+r+"R_"+l,l=Fc++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=YA++,r="_"+r+"r_"+l.toString(32)+"_";return s.memoizedState=r},useHostTransitionStatus:Th,useFormState:x0,useActionState:x0,useOptimistic:function(s){var r=On();r.memoizedState=r.baseState=s;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=Ah.bind(null,Xe,!0,l),l.dispatch=r,[s,r]},useMemoCache:xh,useCacheRefresh:function(){return On().memoizedState=QA.bind(null,Xe)},useEffectEvent:function(s){var r=On(),l={impl:s};return r.memoizedState=l,function(){if((pt&2)!==0)throw Error(a(440));return l.impl.apply(void 0,arguments)}}},Rh={readContext:jn,use:Yc,useCallback:R0,useContext:jn,useEffect:Nh,useImperativeHandle:A0,useInsertionEffect:E0,useLayoutEffect:C0,useMemo:M0,useReducer:Gc,useRef:j0,useState:function(){return Gc(ma)},useDebugValue:kh,useDeferredValue:function(s,r){var l=Jt();return _0(l,bt.memoizedState,s,r)},useTransition:function(){var s=Gc(ma)[0],r=Jt().memoizedState;return[typeof s=="boolean"?s:sl(s),r]},useSyncExternalStore:o0,useId:z0,useHostTransitionStatus:Th,useFormState:b0,useActionState:b0,useOptimistic:function(s,r){var l=Jt();return h0(l,bt,s,r)},useMemoCache:xh,useCacheRefresh:L0};Rh.useEffectEvent=k0;var V0={readContext:jn,use:Yc,useCallback:R0,useContext:jn,useEffect:Nh,useImperativeHandle:A0,useInsertionEffect:E0,useLayoutEffect:C0,useMemo:M0,useReducer:wh,useRef:j0,useState:function(){return wh(ma)},useDebugValue:kh,useDeferredValue:function(s,r){var l=Jt();return bt===null?Eh(l,s,r):_0(l,bt.memoizedState,s,r)},useTransition:function(){var s=wh(ma)[0],r=Jt().memoizedState;return[typeof s=="boolean"?s:sl(s),r]},useSyncExternalStore:o0,useId:z0,useHostTransitionStatus:Th,useFormState:S0,useActionState:S0,useOptimistic:function(s,r){var l=Jt();return bt!==null?h0(l,bt,s,r):(l.baseState=s,[s,l.queue.dispatch])},useMemoCache:xh,useCacheRefresh:L0};V0.useEffectEvent=k0;function Mh(s,r,l,d){r=s.memoizedState,l=l(d,r),l=l==null?r:x({},r,l),s.memoizedState=l,s.lanes===0&&(s.updateQueue.baseState=l)}var _h={enqueueSetState:function(s,r,l){s=s._reactInternals;var d=as(),p=La(d);p.payload=r,l!=null&&(p.callback=l),r=$a(s,p,d),r!==null&&(qn(r,s,d),Qo(r,s,d))},enqueueReplaceState:function(s,r,l){s=s._reactInternals;var d=as(),p=La(d);p.tag=1,p.payload=r,l!=null&&(p.callback=l),r=$a(s,p,d),r!==null&&(qn(r,s,d),Qo(r,s,d))},enqueueForceUpdate:function(s,r){s=s._reactInternals;var l=as(),d=La(l);d.tag=2,r!=null&&(d.callback=r),r=$a(s,d,l),r!==null&&(qn(r,s,l),Qo(r,s,l))}};function H0(s,r,l,d,p,y,E){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(d,y,E):r.prototype&&r.prototype.isPureReactComponent?!Fo(l,d)||!Fo(p,y):!0}function Z0(s,r,l,d){s=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==s&&_h.enqueueReplaceState(r,r.state,null)}function $r(s,r){var l=r;if("ref"in r){l={};for(var d in r)d!=="ref"&&(l[d]=r[d])}if(s=s.defaultProps){l===r&&(l=x({},l));for(var p in s)l[p]===void 0&&(l[p]=s[p])}return l}function F0(s){Ac(s)}function q0(s){console.error(s)}function Y0(s){Ac(s)}function Jc(s,r){try{var l=s.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(d){setTimeout(function(){throw d})}}function G0(s,r,l){try{var d=s.onCaughtError;d(l.value,{componentStack:l.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function Oh(s,r,l){return l=La(l),l.tag=3,l.payload={element:null},l.callback=function(){Jc(s,r)},l}function W0(s){return s=La(s),s.tag=3,s}function X0(s,r,l,d){var p=l.type.getDerivedStateFromError;if(typeof p=="function"){var y=d.value;s.payload=function(){return p(y)},s.callback=function(){G0(r,l,d)}}var E=l.stateNode;E!==null&&typeof E.componentDidCatch=="function"&&(s.callback=function(){G0(r,l,d),typeof p!="function"&&(Za===null?Za=new Set([this]):Za.add(this));var _=d.stack;this.componentDidCatch(d.value,{componentStack:_!==null?_:""})})}function tR(s,r,l,d,p){if(l.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(r=l.alternate,r!==null&&Ei(r,l,p,!0),l=es.current,l!==null){switch(l.tag){case 31:case 13:return ys===null?uu():l.alternate===null&&Gt===0&&(Gt=3),l.flags&=-257,l.flags|=65536,l.lanes=p,d===Pc?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([d]):r.add(d),am(s,d,p)),!1;case 22:return l.flags|=65536,d===Pc?l.flags|=16384:(r=l.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([d])},l.updateQueue=r):(l=r.retryQueue,l===null?r.retryQueue=new Set([d]):l.add(d)),am(s,d,p)),!1}throw Error(a(435,l.tag))}return am(s,d,p),uu(),!1}if(ot)return r=es.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,d!==Jf&&(s=Error(a(422),{cause:d}),Go(ms(s,l)))):(d!==Jf&&(r=Error(a(423),{cause:d}),Go(ms(r,l))),s=s.current.alternate,s.flags|=65536,p&=-p,s.lanes|=p,d=ms(d,l),p=Oh(s.stateNode,d,p),ch(s,p),Gt!==4&&(Gt=2)),!1;var y=Error(a(520),{cause:d});if(y=ms(y,l),hl===null?hl=[y]:hl.push(y),Gt!==4&&(Gt=2),r===null)return!0;d=ms(d,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,s=p&-p,l.lanes|=s,s=Oh(l.stateNode,d,s),ch(l,s),!1;case 1:if(r=l.type,y=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Za===null||!Za.has(y))))return l.flags|=65536,p&=-p,l.lanes|=p,p=W0(p),X0(p,s,l,d),ch(l,p),!1}l=l.return}while(l!==null);return!1}var Ih=Error(a(461)),nn=!1;function Nn(s,r,l,d){r.child=s===null?e0(r,null,l,d):zr(r,s.child,l,d)}function K0(s,r,l,d,p){l=l.render;var y=r.ref;if("ref"in d){var E={};for(var _ in d)_!=="ref"&&(E[_]=d[_])}else E=d;return _r(r),d=ph(s,r,l,E,y,p),_=gh(),s!==null&&!nn?(vh(s,r,p),pa(s,r,p)):(ot&&_&&Xf(r),r.flags|=1,Nn(s,r,d,p),r.child)}function J0(s,r,l,d,p){if(s===null){var y=l.type;return typeof y=="function"&&!Yf(y)&&y.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=y,Q0(s,r,y,d,p)):(s=Oc(l.type,null,d,r,r.mode,p),s.ref=r.ref,s.return=r,r.child=s)}if(y=s.child,!Vh(s,p)){var E=y.memoizedProps;if(l=l.compare,l=l!==null?l:Fo,l(E,d)&&s.ref===r.ref)return pa(s,r,p)}return r.flags|=1,s=ca(y,d),s.ref=r.ref,s.return=r,r.child=s}function Q0(s,r,l,d,p){if(s!==null){var y=s.memoizedProps;if(Fo(y,d)&&s.ref===r.ref)if(nn=!1,r.pendingProps=d=y,Vh(s,p))(s.flags&131072)!==0&&(nn=!0);else return r.lanes=s.lanes,pa(s,r,p)}return Dh(s,r,l,d,p)}function ex(s,r,l,d){var p=d.children,y=s!==null?s.memoizedState:null;if(s===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((r.flags&128)!==0){if(y=y!==null?y.baseLanes|l:l,s!==null){for(d=r.child=s.child,p=0;d!==null;)p=p|d.lanes|d.childLanes,d=d.sibling;d=p&~y}else d=0,r.child=null;return tx(s,r,y,l,d)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},s!==null&&Lc(r,y!==null?y.cachePool:null),y!==null?s0(r,y):dh(),a0(r);else return d=r.lanes=536870912,tx(s,r,y!==null?y.baseLanes|l:l,l,d)}else y!==null?(Lc(r,y.cachePool),s0(r,y),Ua(),r.memoizedState=null):(s!==null&&Lc(r,null),dh(),Ua());return Nn(s,r,p,l),r.child}function il(s,r){return s!==null&&s.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function tx(s,r,l,d,p){var y=rh();return y=y===null?null:{parent:en._currentValue,pool:y},r.memoizedState={baseLanes:l,cachePool:y},s!==null&&Lc(r,null),dh(),a0(r),s!==null&&Ei(s,r,d,!0),r.childLanes=p,null}function Qc(s,r){return r=tu({mode:r.mode,children:r.children},s.mode),r.ref=s.ref,s.child=r,r.return=s,r}function nx(s,r,l){return zr(r,s.child,null,l),s=Qc(r,r.pendingProps),s.flags|=2,ts(r),r.memoizedState=null,s}function nR(s,r,l){var d=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,s===null){if(ot){if(d.mode==="hidden")return s=Qc(r,d),r.lanes=536870912,il(null,s);if(hh(r),(s=Tt)?(s=mb(s,vs),s=s!==null&&s.data==="&"?s:null,s!==null&&(r.memoizedState={dehydrated:s,treeContext:_a!==null?{id:Bs,overflow:Vs}:null,retryLane:536870912,hydrationErrors:null},l=Py(s),l.return=r,r.child=l,Sn=r,Tt=null)):s=null,s===null)throw Ia(r);return r.lanes=536870912,null}return Qc(r,d)}var y=s.memoizedState;if(y!==null){var E=y.dehydrated;if(hh(r),p)if(r.flags&256)r.flags&=-257,r=nx(s,r,l);else if(r.memoizedState!==null)r.child=s.child,r.flags|=128,r=null;else throw Error(a(558));else if(nn||Ei(s,r,l,!1),p=(l&s.childLanes)!==0,nn||p){if(d=jt,d!==null&&(E=bn(d,l),E!==0&&E!==y.retryLane))throw y.retryLane=E,Tr(s,E),qn(d,s,E),Ih;uu(),r=nx(s,r,l)}else s=y.treeContext,Tt=xs(E.nextSibling),Sn=r,ot=!0,Oa=null,vs=!1,s!==null&&Vy(r,s),r=Qc(r,d),r.flags|=4096;return r}return s=ca(s.child,{mode:d.mode,children:d.children}),s.ref=r.ref,r.child=s,s.return=r,s}function eu(s,r){var l=r.ref;if(l===null)s!==null&&s.ref!==null&&(r.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(a(284));(s===null||s.ref!==l)&&(r.flags|=4194816)}}function Dh(s,r,l,d,p){return _r(r),l=ph(s,r,l,d,void 0,p),d=gh(),s!==null&&!nn?(vh(s,r,p),pa(s,r,p)):(ot&&d&&Xf(r),r.flags|=1,Nn(s,r,l,p),r.child)}function sx(s,r,l,d,p,y){return _r(r),r.updateQueue=null,l=i0(r,d,l,p),r0(s),d=gh(),s!==null&&!nn?(vh(s,r,y),pa(s,r,y)):(ot&&d&&Xf(r),r.flags|=1,Nn(s,r,l,y),r.child)}function ax(s,r,l,d,p){if(_r(r),r.stateNode===null){var y=Si,E=l.contextType;typeof E=="object"&&E!==null&&(y=jn(E)),y=new l(d,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=_h,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=d,y.state=r.memoizedState,y.refs={},oh(r),E=l.contextType,y.context=typeof E=="object"&&E!==null?jn(E):Si,y.state=r.memoizedState,E=l.getDerivedStateFromProps,typeof E=="function"&&(Mh(r,l,E,d),y.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(E=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),E!==y.state&&_h.enqueueReplaceState(y,y.state,null),tl(r,d,y,p),el(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),d=!0}else if(s===null){y=r.stateNode;var _=r.memoizedProps,H=$r(l,_);y.props=H;var ne=y.context,ie=l.contextType;E=Si,typeof ie=="object"&&ie!==null&&(E=jn(ie));var ue=l.getDerivedStateFromProps;ie=typeof ue=="function"||typeof y.getSnapshotBeforeUpdate=="function",_=r.pendingProps!==_,ie||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(_||ne!==E)&&Z0(r,y,d,E),za=!1;var se=r.memoizedState;y.state=se,tl(r,d,y,p),el(),ne=r.memoizedState,_||se!==ne||za?(typeof ue=="function"&&(Mh(r,l,ue,d),ne=r.memoizedState),(H=za||H0(r,l,H,d,se,ne,E))?(ie||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=ne),y.props=d,y.state=ne,y.context=E,d=H):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{y=r.stateNode,lh(s,r),E=r.memoizedProps,ie=$r(l,E),y.props=ie,ue=r.pendingProps,se=y.context,ne=l.contextType,H=Si,typeof ne=="object"&&ne!==null&&(H=jn(ne)),_=l.getDerivedStateFromProps,(ne=typeof _=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(E!==ue||se!==H)&&Z0(r,y,d,H),za=!1,se=r.memoizedState,y.state=se,tl(r,d,y,p),el();var ae=r.memoizedState;E!==ue||se!==ae||za||s!==null&&s.dependencies!==null&&Dc(s.dependencies)?(typeof _=="function"&&(Mh(r,l,_,d),ae=r.memoizedState),(ie=za||H0(r,l,ie,d,se,ae,H)||s!==null&&s.dependencies!==null&&Dc(s.dependencies))?(ne||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(d,ae,H),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(d,ae,H)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=ae),y.props=d,y.state=ae,y.context=H,d=ie):(typeof y.componentDidUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=1024),d=!1)}return y=d,eu(s,r),d=(r.flags&128)!==0,y||d?(y=r.stateNode,l=d&&typeof l.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,s!==null&&d?(r.child=zr(r,s.child,null,p),r.child=zr(r,null,l,p)):Nn(s,r,l,p),r.memoizedState=y.state,s=r.child):s=pa(s,r,p),s}function rx(s,r,l,d){return Rr(),r.flags|=256,Nn(s,r,l,d),r.child}var zh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Lh(s){return{baseLanes:s,cachePool:Gy()}}function $h(s,r,l){return s=s!==null?s.childLanes&~l:0,r&&(s|=ss),s}function ix(s,r,l){var d=r.pendingProps,p=!1,y=(r.flags&128)!==0,E;if((E=y)||(E=s!==null&&s.memoizedState===null?!1:(Kt.current&2)!==0),E&&(p=!0,r.flags&=-129),E=(r.flags&32)!==0,r.flags&=-33,s===null){if(ot){if(p?Pa(r):Ua(),(s=Tt)?(s=mb(s,vs),s=s!==null&&s.data!=="&"?s:null,s!==null&&(r.memoizedState={dehydrated:s,treeContext:_a!==null?{id:Bs,overflow:Vs}:null,retryLane:536870912,hydrationErrors:null},l=Py(s),l.return=r,r.child=l,Sn=r,Tt=null)):s=null,s===null)throw Ia(r);return bm(s)?r.lanes=32:r.lanes=536870912,null}var _=d.children;return d=d.fallback,p?(Ua(),p=r.mode,_=tu({mode:"hidden",children:_},p),d=Ar(d,p,l,null),_.return=r,d.return=r,_.sibling=d,r.child=_,d=r.child,d.memoizedState=Lh(l),d.childLanes=$h(s,E,l),r.memoizedState=zh,il(null,d)):(Pa(r),Ph(r,_))}var H=s.memoizedState;if(H!==null&&(_=H.dehydrated,_!==null)){if(y)r.flags&256?(Pa(r),r.flags&=-257,r=Uh(s,r,l)):r.memoizedState!==null?(Ua(),r.child=s.child,r.flags|=128,r=null):(Ua(),_=d.fallback,p=r.mode,d=tu({mode:"visible",children:d.children},p),_=Ar(_,p,l,null),_.flags|=2,d.return=r,_.return=r,d.sibling=_,r.child=d,zr(r,s.child,null,l),d=r.child,d.memoizedState=Lh(l),d.childLanes=$h(s,E,l),r.memoizedState=zh,r=il(null,d));else if(Pa(r),bm(_)){if(E=_.nextSibling&&_.nextSibling.dataset,E)var ne=E.dgst;E=ne,d=Error(a(419)),d.stack="",d.digest=E,Go({value:d,source:null,stack:null}),r=Uh(s,r,l)}else if(nn||Ei(s,r,l,!1),E=(l&s.childLanes)!==0,nn||E){if(E=jt,E!==null&&(d=bn(E,l),d!==0&&d!==H.retryLane))throw H.retryLane=d,Tr(s,d),qn(E,s,d),Ih;xm(_)||uu(),r=Uh(s,r,l)}else xm(_)?(r.flags|=192,r.child=s.child,r=null):(s=H.treeContext,Tt=xs(_.nextSibling),Sn=r,ot=!0,Oa=null,vs=!1,s!==null&&Vy(r,s),r=Ph(r,d.children),r.flags|=4096);return r}return p?(Ua(),_=d.fallback,p=r.mode,H=s.child,ne=H.sibling,d=ca(H,{mode:"hidden",children:d.children}),d.subtreeFlags=H.subtreeFlags&65011712,ne!==null?_=ca(ne,_):(_=Ar(_,p,l,null),_.flags|=2),_.return=r,d.return=r,d.sibling=_,r.child=d,il(null,d),d=r.child,_=s.child.memoizedState,_===null?_=Lh(l):(p=_.cachePool,p!==null?(H=en._currentValue,p=p.parent!==H?{parent:H,pool:H}:p):p=Gy(),_={baseLanes:_.baseLanes|l,cachePool:p}),d.memoizedState=_,d.childLanes=$h(s,E,l),r.memoizedState=zh,il(s.child,d)):(Pa(r),l=s.child,s=l.sibling,l=ca(l,{mode:"visible",children:d.children}),l.return=r,l.sibling=null,s!==null&&(E=r.deletions,E===null?(r.deletions=[s],r.flags|=16):E.push(s)),r.child=l,r.memoizedState=null,l)}function Ph(s,r){return r=tu({mode:"visible",children:r},s.mode),r.return=s,s.child=r}function tu(s,r){return s=Qn(22,s,null,r),s.lanes=0,s}function Uh(s,r,l){return zr(r,s.child,null,l),s=Ph(r,r.pendingProps.children),s.flags|=2,r.memoizedState=null,s}function ox(s,r,l){s.lanes|=r;var d=s.alternate;d!==null&&(d.lanes|=r),th(s.return,r,l)}function Bh(s,r,l,d,p,y){var E=s.memoizedState;E===null?s.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:p,treeForkCount:y}:(E.isBackwards=r,E.rendering=null,E.renderingStartTime=0,E.last=d,E.tail=l,E.tailMode=p,E.treeForkCount=y)}function lx(s,r,l){var d=r.pendingProps,p=d.revealOrder,y=d.tail;d=d.children;var E=Kt.current,_=(E&2)!==0;if(_?(E=E&1|2,r.flags|=128):E&=1,J(Kt,E),Nn(s,r,d,l),d=ot?Yo:0,!_&&s!==null&&(s.flags&128)!==0)e:for(s=r.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&ox(s,l,r);else if(s.tag===19)ox(s,l,r);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break e;for(;s.sibling===null;){if(s.return===null||s.return===r)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(p){case"forwards":for(l=r.child,p=null;l!==null;)s=l.alternate,s!==null&&Hc(s)===null&&(p=l),l=l.sibling;l=p,l===null?(p=r.child,r.child=null):(p=l.sibling,l.sibling=null),Bh(r,!1,p,l,y,d);break;case"backwards":case"unstable_legacy-backwards":for(l=null,p=r.child,r.child=null;p!==null;){if(s=p.alternate,s!==null&&Hc(s)===null){r.child=p;break}s=p.sibling,p.sibling=l,l=p,p=s}Bh(r,!0,l,null,y,d);break;case"together":Bh(r,!1,null,null,void 0,d);break;default:r.memoizedState=null}return r.child}function pa(s,r,l){if(s!==null&&(r.dependencies=s.dependencies),Ha|=r.lanes,(l&r.childLanes)===0)if(s!==null){if(Ei(s,r,l,!1),(l&r.childLanes)===0)return null}else return null;if(s!==null&&r.child!==s.child)throw Error(a(153));if(r.child!==null){for(s=r.child,l=ca(s,s.pendingProps),r.child=l,l.return=r;s.sibling!==null;)s=s.sibling,l=l.sibling=ca(s,s.pendingProps),l.return=r;l.sibling=null}return r.child}function Vh(s,r){return(s.lanes&r)!==0?!0:(s=s.dependencies,!!(s!==null&&Dc(s)))}function sR(s,r,l){switch(r.tag){case 3:fe(r,r.stateNode.containerInfo),Da(r,en,s.memoizedState.cache),Rr();break;case 27:case 5:Re(r);break;case 4:fe(r,r.stateNode.containerInfo);break;case 10:Da(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,hh(r),null;break;case 13:var d=r.memoizedState;if(d!==null)return d.dehydrated!==null?(Pa(r),r.flags|=128,null):(l&r.child.childLanes)!==0?ix(s,r,l):(Pa(r),s=pa(s,r,l),s!==null?s.sibling:null);Pa(r);break;case 19:var p=(s.flags&128)!==0;if(d=(l&r.childLanes)!==0,d||(Ei(s,r,l,!1),d=(l&r.childLanes)!==0),p){if(d)return lx(s,r,l);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),J(Kt,Kt.current),d)break;return null;case 22:return r.lanes=0,ex(s,r,l,r.pendingProps);case 24:Da(r,en,s.memoizedState.cache)}return pa(s,r,l)}function cx(s,r,l){if(s!==null)if(s.memoizedProps!==r.pendingProps)nn=!0;else{if(!Vh(s,l)&&(r.flags&128)===0)return nn=!1,sR(s,r,l);nn=(s.flags&131072)!==0}else nn=!1,ot&&(r.flags&1048576)!==0&&By(r,Yo,r.index);switch(r.lanes=0,r.tag){case 16:e:{var d=r.pendingProps;if(s=Ir(r.elementType),r.type=s,typeof s=="function")Yf(s)?(d=$r(s,d),r.tag=1,r=ax(null,r,s,d,l)):(r.tag=0,r=Dh(null,r,s,d,l));else{if(s!=null){var p=s.$$typeof;if(p===R){r.tag=11,r=K0(null,r,s,d,l);break e}else if(p===O){r.tag=14,r=J0(null,r,s,d,l);break e}}throw r=Y(s)||s,Error(a(306,r,""))}}return r;case 0:return Dh(s,r,r.type,r.pendingProps,l);case 1:return d=r.type,p=$r(d,r.pendingProps),ax(s,r,d,p,l);case 3:e:{if(fe(r,r.stateNode.containerInfo),s===null)throw Error(a(387));d=r.pendingProps;var y=r.memoizedState;p=y.element,lh(s,r),tl(r,d,null,l);var E=r.memoizedState;if(d=E.cache,Da(r,en,d),d!==y.cache&&nh(r,[en],l,!0),el(),d=E.element,y.isDehydrated)if(y={element:d,isDehydrated:!1,cache:E.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=rx(s,r,d,l);break e}else if(d!==p){p=ms(Error(a(424)),r),Go(p),r=rx(s,r,d,l);break e}else for(s=r.stateNode.containerInfo,s.nodeType===9?s=s.body:s=s.nodeName==="HTML"?s.ownerDocument.body:s,Tt=xs(s.firstChild),Sn=r,ot=!0,Oa=null,vs=!0,l=e0(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Rr(),d===p){r=pa(s,r,l);break e}Nn(s,r,d,l)}r=r.child}return r;case 26:return eu(s,r),s===null?(l=bb(r.type,null,r.pendingProps,null))?r.memoizedState=l:ot||(l=r.type,s=r.pendingProps,d=vu(re.current).createElement(l),d[wn]=r,d[Un]=s,kn(d,l,s),pn(d),r.stateNode=d):r.memoizedState=bb(r.type,s.memoizedProps,r.pendingProps,s.memoizedState),null;case 27:return Re(r),s===null&&ot&&(d=r.stateNode=vb(r.type,r.pendingProps,re.current),Sn=r,vs=!0,p=Tt,Ga(r.type)?(wm=p,Tt=xs(d.firstChild)):Tt=p),Nn(s,r,r.pendingProps.children,l),eu(s,r),s===null&&(r.flags|=4194304),r.child;case 5:return s===null&&ot&&((p=d=Tt)&&(d=OR(d,r.type,r.pendingProps,vs),d!==null?(r.stateNode=d,Sn=r,Tt=xs(d.firstChild),vs=!1,p=!0):p=!1),p||Ia(r)),Re(r),p=r.type,y=r.pendingProps,E=s!==null?s.memoizedProps:null,d=y.children,gm(p,y)?d=null:E!==null&&gm(p,E)&&(r.flags|=32),r.memoizedState!==null&&(p=ph(s,r,GA,null,null,l),wl._currentValue=p),eu(s,r),Nn(s,r,d,l),r.child;case 6:return s===null&&ot&&((s=l=Tt)&&(l=IR(l,r.pendingProps,vs),l!==null?(r.stateNode=l,Sn=r,Tt=null,s=!0):s=!1),s||Ia(r)),null;case 13:return ix(s,r,l);case 4:return fe(r,r.stateNode.containerInfo),d=r.pendingProps,s===null?r.child=zr(r,null,d,l):Nn(s,r,d,l),r.child;case 11:return K0(s,r,r.type,r.pendingProps,l);case 7:return Nn(s,r,r.pendingProps,l),r.child;case 8:return Nn(s,r,r.pendingProps.children,l),r.child;case 12:return Nn(s,r,r.pendingProps.children,l),r.child;case 10:return d=r.pendingProps,Da(r,r.type,d.value),Nn(s,r,d.children,l),r.child;case 9:return p=r.type._context,d=r.pendingProps.children,_r(r),p=jn(p),d=d(p),r.flags|=1,Nn(s,r,d,l),r.child;case 14:return J0(s,r,r.type,r.pendingProps,l);case 15:return Q0(s,r,r.type,r.pendingProps,l);case 19:return lx(s,r,l);case 31:return nR(s,r,l);case 22:return ex(s,r,l,r.pendingProps);case 24:return _r(r),d=jn(en),s===null?(p=rh(),p===null&&(p=jt,y=sh(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=l),p=y),r.memoizedState={parent:d,cache:p},oh(r),Da(r,en,p)):((s.lanes&l)!==0&&(lh(s,r),tl(r,null,null,l),el()),p=s.memoizedState,y=r.memoizedState,p.parent!==d?(p={parent:d,cache:d},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),Da(r,en,d)):(d=y.cache,Da(r,en,d),d!==p.cache&&nh(r,[en],l,!0))),Nn(s,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(a(156,r.tag))}function ga(s){s.flags|=4}function Hh(s,r,l,d,p){if((r=(s.mode&32)!==0)&&(r=!1),r){if(s.flags|=16777216,(p&335544128)===p)if(s.stateNode.complete)s.flags|=8192;else if(zx())s.flags|=8192;else throw Dr=Pc,ih}else s.flags&=-16777217}function ux(s,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!kb(r))if(zx())s.flags|=8192;else throw Dr=Pc,ih}function nu(s,r){r!==null&&(s.flags|=4),s.flags&16384&&(r=s.tag!==22?ye():536870912,s.lanes|=r,$i|=r)}function ol(s,r){if(!ot)switch(s.tailMode){case"hidden":r=s.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?s.tail=null:l.sibling=null;break;case"collapsed":l=s.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||s.tail===null?s.tail=null:s.tail.sibling=null:d.sibling=null}}function At(s){var r=s.alternate!==null&&s.alternate.child===s.child,l=0,d=0;if(r)for(var p=s.child;p!==null;)l|=p.lanes|p.childLanes,d|=p.subtreeFlags&65011712,d|=p.flags&65011712,p.return=s,p=p.sibling;else for(p=s.child;p!==null;)l|=p.lanes|p.childLanes,d|=p.subtreeFlags,d|=p.flags,p.return=s,p=p.sibling;return s.subtreeFlags|=d,s.childLanes=l,r}function aR(s,r,l){var d=r.pendingProps;switch(Kf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return At(r),null;case 1:return At(r),null;case 3:return l=r.stateNode,d=null,s!==null&&(d=s.memoizedState.cache),r.memoizedState.cache!==d&&(r.flags|=2048),fa(en),xe(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(s===null||s.child===null)&&(ki(r)?ga(r):s===null||s.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Qf())),At(r),null;case 26:var p=r.type,y=r.memoizedState;return s===null?(ga(r),y!==null?(At(r),ux(r,y)):(At(r),Hh(r,p,null,d,l))):y?y!==s.memoizedState?(ga(r),At(r),ux(r,y)):(At(r),r.flags&=-16777217):(s=s.memoizedProps,s!==d&&ga(r),At(r),Hh(r,p,s,d,l)),null;case 27:if(he(r),l=re.current,p=r.type,s!==null&&r.stateNode!=null)s.memoizedProps!==d&&ga(r);else{if(!d){if(r.stateNode===null)throw Error(a(166));return At(r),null}s=Q.current,ki(r)?Hy(r):(s=vb(p,d,l),r.stateNode=s,ga(r))}return At(r),null;case 5:if(he(r),p=r.type,s!==null&&r.stateNode!=null)s.memoizedProps!==d&&ga(r);else{if(!d){if(r.stateNode===null)throw Error(a(166));return At(r),null}if(y=Q.current,ki(r))Hy(r);else{var E=vu(re.current);switch(y){case 1:y=E.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:y=E.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":y=E.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":y=E.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":y=E.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?E.createElement("select",{is:d.is}):E.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?E.createElement(p,{is:d.is}):E.createElement(p)}}y[wn]=r,y[Un]=d;e:for(E=r.child;E!==null;){if(E.tag===5||E.tag===6)y.appendChild(E.stateNode);else if(E.tag!==4&&E.tag!==27&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===r)break e;for(;E.sibling===null;){if(E.return===null||E.return===r)break e;E=E.return}E.sibling.return=E.return,E=E.sibling}r.stateNode=y;e:switch(kn(y,p,d),p){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&ga(r)}}return At(r),Hh(r,r.type,s===null?null:s.memoizedProps,r.pendingProps,l),null;case 6:if(s&&r.stateNode!=null)s.memoizedProps!==d&&ga(r);else{if(typeof d!="string"&&r.stateNode===null)throw Error(a(166));if(s=re.current,ki(r)){if(s=r.stateNode,l=r.memoizedProps,d=null,p=Sn,p!==null)switch(p.tag){case 27:case 5:d=p.memoizedProps}s[wn]=r,s=!!(s.nodeValue===l||d!==null&&d.suppressHydrationWarning===!0||ib(s.nodeValue,l)),s||Ia(r,!0)}else s=vu(s).createTextNode(d),s[wn]=r,r.stateNode=s}return At(r),null;case 31:if(l=r.memoizedState,s===null||s.memoizedState!==null){if(d=ki(r),l!==null){if(s===null){if(!d)throw Error(a(318));if(s=r.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(a(557));s[wn]=r}else Rr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;At(r),s=!1}else l=Qf(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=l),s=!0;if(!s)return r.flags&256?(ts(r),r):(ts(r),null);if((r.flags&128)!==0)throw Error(a(558))}return At(r),null;case 13:if(d=r.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(p=ki(r),d!==null&&d.dehydrated!==null){if(s===null){if(!p)throw Error(a(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(a(317));p[wn]=r}else Rr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;At(r),p=!1}else p=Qf(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(ts(r),r):(ts(r),null)}return ts(r),(r.flags&128)!==0?(r.lanes=l,r):(l=d!==null,s=s!==null&&s.memoizedState!==null,l&&(d=r.child,p=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(p=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==p&&(d.flags|=2048)),l!==s&&l&&(r.child.flags|=8192),nu(r,r.updateQueue),At(r),null);case 4:return xe(),s===null&&dm(r.stateNode.containerInfo),At(r),null;case 10:return fa(r.type),At(r),null;case 19:if(Z(Kt),d=r.memoizedState,d===null)return At(r),null;if(p=(r.flags&128)!==0,y=d.rendering,y===null)if(p)ol(d,!1);else{if(Gt!==0||s!==null&&(s.flags&128)!==0)for(s=r.child;s!==null;){if(y=Hc(s),y!==null){for(r.flags|=128,ol(d,!1),s=y.updateQueue,r.updateQueue=s,nu(r,s),r.subtreeFlags=0,s=l,l=r.child;l!==null;)$y(l,s),l=l.sibling;return J(Kt,Kt.current&1|2),ot&&ua(r,d.treeForkCount),r.child}s=s.sibling}d.tail!==null&&je()>ou&&(r.flags|=128,p=!0,ol(d,!1),r.lanes=4194304)}else{if(!p)if(s=Hc(y),s!==null){if(r.flags|=128,p=!0,s=s.updateQueue,r.updateQueue=s,nu(r,s),ol(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ot)return At(r),null}else 2*je()-d.renderingStartTime>ou&&l!==536870912&&(r.flags|=128,p=!0,ol(d,!1),r.lanes=4194304);d.isBackwards?(y.sibling=r.child,r.child=y):(s=d.last,s!==null?s.sibling=y:r.child=y,d.last=y)}return d.tail!==null?(s=d.tail,d.rendering=s,d.tail=s.sibling,d.renderingStartTime=je(),s.sibling=null,l=Kt.current,J(Kt,p?l&1|2:l&1),ot&&ua(r,d.treeForkCount),s):(At(r),null);case 22:case 23:return ts(r),fh(),d=r.memoizedState!==null,s!==null?s.memoizedState!==null!==d&&(r.flags|=8192):d&&(r.flags|=8192),d?(l&536870912)!==0&&(r.flags&128)===0&&(At(r),r.subtreeFlags&6&&(r.flags|=8192)):At(r),l=r.updateQueue,l!==null&&nu(r,l.retryQueue),l=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),d=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(d=r.memoizedState.cachePool.pool),d!==l&&(r.flags|=2048),s!==null&&Z(Or),null;case 24:return l=null,s!==null&&(l=s.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),fa(en),At(r),null;case 25:return null;case 30:return null}throw Error(a(156,r.tag))}function rR(s,r){switch(Kf(r),r.tag){case 1:return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 3:return fa(en),xe(),s=r.flags,(s&65536)!==0&&(s&128)===0?(r.flags=s&-65537|128,r):null;case 26:case 27:case 5:return he(r),null;case 31:if(r.memoizedState!==null){if(ts(r),r.alternate===null)throw Error(a(340));Rr()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 13:if(ts(r),s=r.memoizedState,s!==null&&s.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Rr()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 19:return Z(Kt),null;case 4:return xe(),null;case 10:return fa(r.type),null;case 22:case 23:return ts(r),fh(),s!==null&&Z(Or),s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 24:return fa(en),null;case 25:return null;default:return null}}function dx(s,r){switch(Kf(r),r.tag){case 3:fa(en),xe();break;case 26:case 27:case 5:he(r);break;case 4:xe();break;case 31:r.memoizedState!==null&&ts(r);break;case 13:ts(r);break;case 19:Z(Kt);break;case 10:fa(r.type);break;case 22:case 23:ts(r),fh(),s!==null&&Z(Or);break;case 24:fa(en)}}function ll(s,r){try{var l=r.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var p=d.next;l=p;do{if((l.tag&s)===s){d=void 0;var y=l.create,E=l.inst;d=y(),E.destroy=d}l=l.next}while(l!==p)}}catch(_){vt(r,r.return,_)}}function Ba(s,r,l){try{var d=r.updateQueue,p=d!==null?d.lastEffect:null;if(p!==null){var y=p.next;d=y;do{if((d.tag&s)===s){var E=d.inst,_=E.destroy;if(_!==void 0){E.destroy=void 0,p=r;var H=l,ne=_;try{ne()}catch(ie){vt(p,H,ie)}}}d=d.next}while(d!==y)}}catch(ie){vt(r,r.return,ie)}}function fx(s){var r=s.updateQueue;if(r!==null){var l=s.stateNode;try{n0(r,l)}catch(d){vt(s,s.return,d)}}}function hx(s,r,l){l.props=$r(s.type,s.memoizedProps),l.state=s.memoizedState;try{l.componentWillUnmount()}catch(d){vt(s,r,d)}}function cl(s,r){try{var l=s.ref;if(l!==null){switch(s.tag){case 26:case 27:case 5:var d=s.stateNode;break;case 30:d=s.stateNode;break;default:d=s.stateNode}typeof l=="function"?s.refCleanup=l(d):l.current=d}}catch(p){vt(s,r,p)}}function Hs(s,r){var l=s.ref,d=s.refCleanup;if(l!==null)if(typeof d=="function")try{d()}catch(p){vt(s,r,p)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(p){vt(s,r,p)}else l.current=null}function mx(s){var r=s.type,l=s.memoizedProps,d=s.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&d.focus();break e;case"img":l.src?d.src=l.src:l.srcSet&&(d.srcset=l.srcSet)}}catch(p){vt(s,s.return,p)}}function Zh(s,r,l){try{var d=s.stateNode;CR(d,s.type,l,r),d[Un]=r}catch(p){vt(s,s.return,p)}}function px(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Ga(s.type)||s.tag===4}function Fh(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||px(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Ga(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function qh(s,r,l){var d=s.tag;if(d===5||d===6)s=s.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(s,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(s),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=oa));else if(d!==4&&(d===27&&Ga(s.type)&&(l=s.stateNode,r=null),s=s.child,s!==null))for(qh(s,r,l),s=s.sibling;s!==null;)qh(s,r,l),s=s.sibling}function su(s,r,l){var d=s.tag;if(d===5||d===6)s=s.stateNode,r?l.insertBefore(s,r):l.appendChild(s);else if(d!==4&&(d===27&&Ga(s.type)&&(l=s.stateNode),s=s.child,s!==null))for(su(s,r,l),s=s.sibling;s!==null;)su(s,r,l),s=s.sibling}function gx(s){var r=s.stateNode,l=s.memoizedProps;try{for(var d=s.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);kn(r,d,l),r[wn]=s,r[Un]=l}catch(y){vt(s,s.return,y)}}var va=!1,sn=!1,Yh=!1,vx=typeof WeakSet=="function"?WeakSet:Set,gn=null;function iR(s,r){if(s=s.containerInfo,mm=Nu,s=Ay(s),Uf(s)){if("selectionStart"in s)var l={start:s.selectionStart,end:s.selectionEnd};else e:{l=(l=s.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var p=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{l.nodeType,y.nodeType}catch{l=null;break e}var E=0,_=-1,H=-1,ne=0,ie=0,ue=s,se=null;t:for(;;){for(var ae;ue!==l||p!==0&&ue.nodeType!==3||(_=E+p),ue!==y||d!==0&&ue.nodeType!==3||(H=E+d),ue.nodeType===3&&(E+=ue.nodeValue.length),(ae=ue.firstChild)!==null;)se=ue,ue=ae;for(;;){if(ue===s)break t;if(se===l&&++ne===p&&(_=E),se===y&&++ie===d&&(H=E),(ae=ue.nextSibling)!==null)break;ue=se,se=ue.parentNode}ue=ae}l=_===-1||H===-1?null:{start:_,end:H}}else l=null}l=l||{start:0,end:0}}else l=null;for(pm={focusedElem:s,selectionRange:l},Nu=!1,gn=r;gn!==null;)if(r=gn,s=r.child,(r.subtreeFlags&1028)!==0&&s!==null)s.return=r,gn=s;else for(;gn!==null;){switch(r=gn,y=r.alternate,s=r.flags,r.tag){case 0:if((s&4)!==0&&(s=r.updateQueue,s=s!==null?s.events:null,s!==null))for(l=0;l<s.length;l++)p=s[l],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&y!==null){s=void 0,l=r,p=y.memoizedProps,y=y.memoizedState,d=l.stateNode;try{var Ee=$r(l.type,p);s=d.getSnapshotBeforeUpdate(Ee,y),d.__reactInternalSnapshotBeforeUpdate=s}catch(Le){vt(l,l.return,Le)}}break;case 3:if((s&1024)!==0){if(s=r.stateNode.containerInfo,l=s.nodeType,l===9)ym(s);else if(l===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":ym(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(a(163))}if(s=r.sibling,s!==null){s.return=r.return,gn=s;break}gn=r.return}}function yx(s,r,l){var d=l.flags;switch(l.tag){case 0:case 11:case 15:xa(s,l),d&4&&ll(5,l);break;case 1:if(xa(s,l),d&4)if(s=l.stateNode,r===null)try{s.componentDidMount()}catch(E){vt(l,l.return,E)}else{var p=$r(l.type,r.memoizedProps);r=r.memoizedState;try{s.componentDidUpdate(p,r,s.__reactInternalSnapshotBeforeUpdate)}catch(E){vt(l,l.return,E)}}d&64&&fx(l),d&512&&cl(l,l.return);break;case 3:if(xa(s,l),d&64&&(s=l.updateQueue,s!==null)){if(r=null,l.child!==null)switch(l.child.tag){case 27:case 5:r=l.child.stateNode;break;case 1:r=l.child.stateNode}try{n0(s,r)}catch(E){vt(l,l.return,E)}}break;case 27:r===null&&d&4&&gx(l);case 26:case 5:xa(s,l),r===null&&d&4&&mx(l),d&512&&cl(l,l.return);break;case 12:xa(s,l);break;case 31:xa(s,l),d&4&&wx(s,l);break;case 13:xa(s,l),d&4&&Sx(s,l),d&64&&(s=l.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(l=pR.bind(null,l),DR(s,l))));break;case 22:if(d=l.memoizedState!==null||va,!d){r=r!==null&&r.memoizedState!==null||sn,p=va;var y=sn;va=d,(sn=r)&&!y?ba(s,l,(l.subtreeFlags&8772)!==0):xa(s,l),va=p,sn=y}break;case 30:break;default:xa(s,l)}}function xx(s){var r=s.alternate;r!==null&&(s.alternate=null,xx(r)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(r=s.stateNode,r!==null&&jf(r)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var $t=null,Vn=!1;function ya(s,r,l){for(l=l.child;l!==null;)bx(s,r,l),l=l.sibling}function bx(s,r,l){if(Ie&&typeof Ie.onCommitFiberUnmount=="function")try{Ie.onCommitFiberUnmount(on,l)}catch{}switch(l.tag){case 26:sn||Hs(l,r),ya(s,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:sn||Hs(l,r);var d=$t,p=Vn;Ga(l.type)&&($t=l.stateNode,Vn=!1),ya(s,r,l),yl(l.stateNode),$t=d,Vn=p;break;case 5:sn||Hs(l,r);case 6:if(d=$t,p=Vn,$t=null,ya(s,r,l),$t=d,Vn=p,$t!==null)if(Vn)try{($t.nodeType===9?$t.body:$t.nodeName==="HTML"?$t.ownerDocument.body:$t).removeChild(l.stateNode)}catch(y){vt(l,r,y)}else try{$t.removeChild(l.stateNode)}catch(y){vt(l,r,y)}break;case 18:$t!==null&&(Vn?(s=$t,fb(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,l.stateNode),qi(s)):fb($t,l.stateNode));break;case 4:d=$t,p=Vn,$t=l.stateNode.containerInfo,Vn=!0,ya(s,r,l),$t=d,Vn=p;break;case 0:case 11:case 14:case 15:Ba(2,l,r),sn||Ba(4,l,r),ya(s,r,l);break;case 1:sn||(Hs(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"&&hx(l,r,d)),ya(s,r,l);break;case 21:ya(s,r,l);break;case 22:sn=(d=sn)||l.memoizedState!==null,ya(s,r,l),sn=d;break;default:ya(s,r,l)}}function wx(s,r){if(r.memoizedState===null&&(s=r.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{qi(s)}catch(l){vt(r,r.return,l)}}}function Sx(s,r){if(r.memoizedState===null&&(s=r.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{qi(s)}catch(l){vt(r,r.return,l)}}function oR(s){switch(s.tag){case 31:case 13:case 19:var r=s.stateNode;return r===null&&(r=s.stateNode=new vx),r;case 22:return s=s.stateNode,r=s._retryCache,r===null&&(r=s._retryCache=new vx),r;default:throw Error(a(435,s.tag))}}function au(s,r){var l=oR(s);r.forEach(function(d){if(!l.has(d)){l.add(d);var p=gR.bind(null,s,d);d.then(p,p)}})}function Hn(s,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var p=l[d],y=s,E=r,_=E;e:for(;_!==null;){switch(_.tag){case 27:if(Ga(_.type)){$t=_.stateNode,Vn=!1;break e}break;case 5:$t=_.stateNode,Vn=!1;break e;case 3:case 4:$t=_.stateNode.containerInfo,Vn=!0;break e}_=_.return}if($t===null)throw Error(a(160));bx(y,E,p),$t=null,Vn=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)jx(r,s),r=r.sibling}var Ms=null;function jx(s,r){var l=s.alternate,d=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:Hn(r,s),Zn(s),d&4&&(Ba(3,s,s.return),ll(3,s),Ba(5,s,s.return));break;case 1:Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),d&64&&va&&(s=s.updateQueue,s!==null&&(d=s.callbacks,d!==null&&(l=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=l===null?d:l.concat(d))));break;case 26:var p=Ms;if(Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),d&4){var y=l!==null?l.memoizedState:null;if(d=s.memoizedState,l===null)if(d===null)if(s.stateNode===null){e:{d=s.type,l=s.memoizedProps,p=p.ownerDocument||p;t:switch(d){case"title":y=p.getElementsByTagName("title")[0],(!y||y[zo]||y[wn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(d),p.head.insertBefore(y,p.querySelector("head > title"))),kn(y,d,l),y[wn]=s,pn(y),d=y;break e;case"link":var E=jb("link","href",p).get(d+(l.href||""));if(E){for(var _=0;_<E.length;_++)if(y=E[_],y.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&y.getAttribute("rel")===(l.rel==null?null:l.rel)&&y.getAttribute("title")===(l.title==null?null:l.title)&&y.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){E.splice(_,1);break t}}y=p.createElement(d),kn(y,d,l),p.head.appendChild(y);break;case"meta":if(E=jb("meta","content",p).get(d+(l.content||""))){for(_=0;_<E.length;_++)if(y=E[_],y.getAttribute("content")===(l.content==null?null:""+l.content)&&y.getAttribute("name")===(l.name==null?null:l.name)&&y.getAttribute("property")===(l.property==null?null:l.property)&&y.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&y.getAttribute("charset")===(l.charSet==null?null:l.charSet)){E.splice(_,1);break t}}y=p.createElement(d),kn(y,d,l),p.head.appendChild(y);break;default:throw Error(a(468,d))}y[wn]=s,pn(y),d=y}s.stateNode=d}else Nb(p,s.type,s.stateNode);else s.stateNode=Sb(p,d,s.memoizedProps);else y!==d?(y===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):y.count--,d===null?Nb(p,s.type,s.stateNode):Sb(p,d,s.memoizedProps)):d===null&&s.stateNode!==null&&Zh(s,s.memoizedProps,l.memoizedProps)}break;case 27:Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),l!==null&&d&4&&Zh(s,s.memoizedProps,l.memoizedProps);break;case 5:if(Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),s.flags&32){p=s.stateNode;try{pi(p,"")}catch(Ee){vt(s,s.return,Ee)}}d&4&&s.stateNode!=null&&(p=s.memoizedProps,Zh(s,p,l!==null?l.memoizedProps:p)),d&1024&&(Yh=!0);break;case 6:if(Hn(r,s),Zn(s),d&4){if(s.stateNode===null)throw Error(a(162));d=s.memoizedProps,l=s.stateNode;try{l.nodeValue=d}catch(Ee){vt(s,s.return,Ee)}}break;case 3:if(bu=null,p=Ms,Ms=yu(r.containerInfo),Hn(r,s),Ms=p,Zn(s),d&4&&l!==null&&l.memoizedState.isDehydrated)try{qi(r.containerInfo)}catch(Ee){vt(s,s.return,Ee)}Yh&&(Yh=!1,Nx(s));break;case 4:d=Ms,Ms=yu(s.stateNode.containerInfo),Hn(r,s),Zn(s),Ms=d;break;case 12:Hn(r,s),Zn(s);break;case 31:Hn(r,s),Zn(s),d&4&&(d=s.updateQueue,d!==null&&(s.updateQueue=null,au(s,d)));break;case 13:Hn(r,s),Zn(s),s.child.flags&8192&&s.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(iu=je()),d&4&&(d=s.updateQueue,d!==null&&(s.updateQueue=null,au(s,d)));break;case 22:p=s.memoizedState!==null;var H=l!==null&&l.memoizedState!==null,ne=va,ie=sn;if(va=ne||p,sn=ie||H,Hn(r,s),sn=ie,va=ne,Zn(s),d&8192)e:for(r=s.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(l===null||H||va||sn||Pr(s)),l=null,r=s;;){if(r.tag===5||r.tag===26){if(l===null){H=l=r;try{if(y=H.stateNode,p)E=y.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none";else{_=H.stateNode;var ue=H.memoizedProps.style,se=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;_.style.display=se==null||typeof se=="boolean"?"":(""+se).trim()}}catch(Ee){vt(H,H.return,Ee)}}}else if(r.tag===6){if(l===null){H=r;try{H.stateNode.nodeValue=p?"":H.memoizedProps}catch(Ee){vt(H,H.return,Ee)}}}else if(r.tag===18){if(l===null){H=r;try{var ae=H.stateNode;p?hb(ae,!0):hb(H.stateNode,!1)}catch(Ee){vt(H,H.return,Ee)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===s)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;l===r&&(l=null),r=r.return}l===r&&(l=null),r.sibling.return=r.return,r=r.sibling}d&4&&(d=s.updateQueue,d!==null&&(l=d.retryQueue,l!==null&&(d.retryQueue=null,au(s,l))));break;case 19:Hn(r,s),Zn(s),d&4&&(d=s.updateQueue,d!==null&&(s.updateQueue=null,au(s,d)));break;case 30:break;case 21:break;default:Hn(r,s),Zn(s)}}function Zn(s){var r=s.flags;if(r&2){try{for(var l,d=s.return;d!==null;){if(px(d)){l=d;break}d=d.return}if(l==null)throw Error(a(160));switch(l.tag){case 27:var p=l.stateNode,y=Fh(s);su(s,y,p);break;case 5:var E=l.stateNode;l.flags&32&&(pi(E,""),l.flags&=-33);var _=Fh(s);su(s,_,E);break;case 3:case 4:var H=l.stateNode.containerInfo,ne=Fh(s);qh(s,ne,H);break;default:throw Error(a(161))}}catch(ie){vt(s,s.return,ie)}s.flags&=-3}r&4096&&(s.flags&=-4097)}function Nx(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var r=s;Nx(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),s=s.sibling}}function xa(s,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)yx(s,r.alternate,r),r=r.sibling}function Pr(s){for(s=s.child;s!==null;){var r=s;switch(r.tag){case 0:case 11:case 14:case 15:Ba(4,r,r.return),Pr(r);break;case 1:Hs(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&hx(r,r.return,l),Pr(r);break;case 27:yl(r.stateNode);case 26:case 5:Hs(r,r.return),Pr(r);break;case 22:r.memoizedState===null&&Pr(r);break;case 30:Pr(r);break;default:Pr(r)}s=s.sibling}}function ba(s,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var d=r.alternate,p=s,y=r,E=y.flags;switch(y.tag){case 0:case 11:case 15:ba(p,y,l),ll(4,y);break;case 1:if(ba(p,y,l),d=y,p=d.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(ne){vt(d,d.return,ne)}if(d=y,p=d.updateQueue,p!==null){var _=d.stateNode;try{var H=p.shared.hiddenCallbacks;if(H!==null)for(p.shared.hiddenCallbacks=null,p=0;p<H.length;p++)t0(H[p],_)}catch(ne){vt(d,d.return,ne)}}l&&E&64&&fx(y),cl(y,y.return);break;case 27:gx(y);case 26:case 5:ba(p,y,l),l&&d===null&&E&4&&mx(y),cl(y,y.return);break;case 12:ba(p,y,l);break;case 31:ba(p,y,l),l&&E&4&&wx(p,y);break;case 13:ba(p,y,l),l&&E&4&&Sx(p,y);break;case 22:y.memoizedState===null&&ba(p,y,l),cl(y,y.return);break;case 30:break;default:ba(p,y,l)}r=r.sibling}}function Gh(s,r){var l=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),s=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(s=r.memoizedState.cachePool.pool),s!==l&&(s!=null&&s.refCount++,l!=null&&Wo(l))}function Wh(s,r){s=null,r.alternate!==null&&(s=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==s&&(r.refCount++,s!=null&&Wo(s))}function _s(s,r,l,d){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)kx(s,r,l,d),r=r.sibling}function kx(s,r,l,d){var p=r.flags;switch(r.tag){case 0:case 11:case 15:_s(s,r,l,d),p&2048&&ll(9,r);break;case 1:_s(s,r,l,d);break;case 3:_s(s,r,l,d),p&2048&&(s=null,r.alternate!==null&&(s=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==s&&(r.refCount++,s!=null&&Wo(s)));break;case 12:if(p&2048){_s(s,r,l,d),s=r.stateNode;try{var y=r.memoizedProps,E=y.id,_=y.onPostCommit;typeof _=="function"&&_(E,r.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(H){vt(r,r.return,H)}}else _s(s,r,l,d);break;case 31:_s(s,r,l,d);break;case 13:_s(s,r,l,d);break;case 23:break;case 22:y=r.stateNode,E=r.alternate,r.memoizedState!==null?y._visibility&2?_s(s,r,l,d):ul(s,r):y._visibility&2?_s(s,r,l,d):(y._visibility|=2,Di(s,r,l,d,(r.subtreeFlags&10256)!==0||!1)),p&2048&&Gh(E,r);break;case 24:_s(s,r,l,d),p&2048&&Wh(r.alternate,r);break;default:_s(s,r,l,d)}}function Di(s,r,l,d,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=s,E=r,_=l,H=d,ne=E.flags;switch(E.tag){case 0:case 11:case 15:Di(y,E,_,H,p),ll(8,E);break;case 23:break;case 22:var ie=E.stateNode;E.memoizedState!==null?ie._visibility&2?Di(y,E,_,H,p):ul(y,E):(ie._visibility|=2,Di(y,E,_,H,p)),p&&ne&2048&&Gh(E.alternate,E);break;case 24:Di(y,E,_,H,p),p&&ne&2048&&Wh(E.alternate,E);break;default:Di(y,E,_,H,p)}r=r.sibling}}function ul(s,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var l=s,d=r,p=d.flags;switch(d.tag){case 22:ul(l,d),p&2048&&Gh(d.alternate,d);break;case 24:ul(l,d),p&2048&&Wh(d.alternate,d);break;default:ul(l,d)}r=r.sibling}}var dl=8192;function zi(s,r,l){if(s.subtreeFlags&dl)for(s=s.child;s!==null;)Ex(s,r,l),s=s.sibling}function Ex(s,r,l){switch(s.tag){case 26:zi(s,r,l),s.flags&dl&&s.memoizedState!==null&&YR(l,Ms,s.memoizedState,s.memoizedProps);break;case 5:zi(s,r,l);break;case 3:case 4:var d=Ms;Ms=yu(s.stateNode.containerInfo),zi(s,r,l),Ms=d;break;case 22:s.memoizedState===null&&(d=s.alternate,d!==null&&d.memoizedState!==null?(d=dl,dl=16777216,zi(s,r,l),dl=d):zi(s,r,l));break;default:zi(s,r,l)}}function Cx(s){var r=s.alternate;if(r!==null&&(s=r.child,s!==null)){r.child=null;do r=s.sibling,s.sibling=null,s=r;while(s!==null)}}function fl(s){var r=s.deletions;if((s.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var d=r[l];gn=d,Ax(d,s)}Cx(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Tx(s),s=s.sibling}function Tx(s){switch(s.tag){case 0:case 11:case 15:fl(s),s.flags&2048&&Ba(9,s,s.return);break;case 3:fl(s);break;case 12:fl(s);break;case 22:var r=s.stateNode;s.memoizedState!==null&&r._visibility&2&&(s.return===null||s.return.tag!==13)?(r._visibility&=-3,ru(s)):fl(s);break;default:fl(s)}}function ru(s){var r=s.deletions;if((s.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var d=r[l];gn=d,Ax(d,s)}Cx(s)}for(s=s.child;s!==null;){switch(r=s,r.tag){case 0:case 11:case 15:Ba(8,r,r.return),ru(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,ru(r));break;default:ru(r)}s=s.sibling}}function Ax(s,r){for(;gn!==null;){var l=gn;switch(l.tag){case 0:case 11:case 15:Ba(8,l,r);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var d=l.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:Wo(l.memoizedState.cache)}if(d=l.child,d!==null)d.return=l,gn=d;else e:for(l=s;gn!==null;){d=gn;var p=d.sibling,y=d.return;if(xx(d),d===l){gn=null;break e}if(p!==null){p.return=y,gn=p;break e}gn=y}}}var lR={getCacheForType:function(s){var r=jn(en),l=r.data.get(s);return l===void 0&&(l=s(),r.data.set(s,l)),l},cacheSignal:function(){return jn(en).controller.signal}},cR=typeof WeakMap=="function"?WeakMap:Map,pt=0,jt=null,nt=null,rt=0,gt=0,ns=null,Va=!1,Li=!1,Xh=!1,wa=0,Gt=0,Ha=0,Ur=0,Kh=0,ss=0,$i=0,hl=null,Fn=null,Jh=!1,iu=0,Rx=0,ou=1/0,lu=null,Za=null,un=0,Fa=null,Pi=null,Sa=0,Qh=0,em=null,Mx=null,ml=0,tm=null;function as(){return(pt&2)!==0&&rt!==0?rt&-rt:D.T!==null?om():cn()}function _x(){if(ss===0)if((rt&536870912)===0||ot){var s=mn;mn<<=1,(mn&3932160)===0&&(mn=262144),ss=s}else ss=536870912;return s=es.current,s!==null&&(s.flags|=32),ss}function qn(s,r,l){(s===jt&&(gt===2||gt===9)||s.cancelPendingCommit!==null)&&(Ui(s,0),qa(s,rt,ss,!1)),ze(s,l),((pt&2)===0||s!==jt)&&(s===jt&&((pt&2)===0&&(Ur|=l),Gt===4&&qa(s,rt,ss,!1)),Zs(s))}function Ox(s,r,l){if((pt&6)!==0)throw Error(a(327));var d=!l&&(r&127)===0&&(r&s.expiredLanes)===0||ee(s,r),p=d?fR(s,r):sm(s,r,!0),y=d;do{if(p===0){Li&&!d&&qa(s,r,0,!1);break}else{if(l=s.current.alternate,y&&!uR(l)){p=sm(s,r,!1),y=!1;continue}if(p===2){if(y=r,s.errorRecoveryDisabledLanes&y)var E=0;else E=s.pendingLanes&-536870913,E=E!==0?E:E&536870912?536870912:0;if(E!==0){r=E;e:{var _=s;p=hl;var H=_.current.memoizedState.isDehydrated;if(H&&(Ui(_,E).flags|=256),E=sm(_,E,!1),E!==2){if(Xh&&!H){_.errorRecoveryDisabledLanes|=y,Ur|=y,p=4;break e}y=Fn,Fn=p,y!==null&&(Fn===null?Fn=y:Fn.push.apply(Fn,y))}p=E}if(y=!1,p!==2)continue}}if(p===1){Ui(s,0),qa(s,r,0,!0);break}e:{switch(d=s,y=p,y){case 0:case 1:throw Error(a(345));case 4:if((r&4194048)!==r)break;case 6:qa(d,r,ss,!Va);break e;case 2:Fn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((r&62914560)===r&&(p=iu+300-je(),10<p)){if(qa(d,r,ss,!Va),Ts(d,0,!0)!==0)break e;Sa=r,d.timeoutHandle=ub(Ix.bind(null,d,l,Fn,lu,Jh,r,ss,Ur,$i,Va,y,"Throttled",-0,0),p);break e}Ix(d,l,Fn,lu,Jh,r,ss,Ur,$i,Va,y,null,-0,0)}}break}while(!0);Zs(s)}function Ix(s,r,l,d,p,y,E,_,H,ne,ie,ue,se,ae){if(s.timeoutHandle=-1,ue=r.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:oa},Ex(r,y,ue);var Ee=(y&62914560)===y?iu-je():(y&4194048)===y?Rx-je():0;if(Ee=GR(ue,Ee),Ee!==null){Sa=y,s.cancelPendingCommit=Ee(Vx.bind(null,s,r,y,l,d,p,E,_,H,ie,ue,null,se,ae)),qa(s,y,E,!ne);return}}Vx(s,r,y,l,d,p,E,_,H)}function uR(s){for(var r=s;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var d=0;d<l.length;d++){var p=l[d],y=p.getSnapshot;p=p.value;try{if(!Jn(y(),p))return!1}catch{return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function qa(s,r,l,d){r&=~Kh,r&=~Ur,s.suspendedLanes|=r,s.pingedLanes&=~r,d&&(s.warmLanes|=r),d=s.expirationTimes;for(var p=r;0<p;){var y=31-ct(p),E=1<<y;d[y]=-1,p&=~E}l!==0&&Lt(s,l,r)}function cu(){return(pt&6)===0?(pl(0),!1):!0}function nm(){if(nt!==null){if(gt===0)var s=nt.return;else s=nt,da=Mr=null,yh(s),Ri=null,Ko=0,s=nt;for(;s!==null;)dx(s.alternate,s),s=s.return;nt=null}}function Ui(s,r){var l=s.timeoutHandle;l!==-1&&(s.timeoutHandle=-1,RR(l)),l=s.cancelPendingCommit,l!==null&&(s.cancelPendingCommit=null,l()),Sa=0,nm(),jt=s,nt=l=ca(s.current,null),rt=r,gt=0,ns=null,Va=!1,Li=ee(s,r),Xh=!1,$i=ss=Kh=Ur=Ha=Gt=0,Fn=hl=null,Jh=!1,(r&8)!==0&&(r|=r&32);var d=s.entangledLanes;if(d!==0)for(s=s.entanglements,d&=r;0<d;){var p=31-ct(d),y=1<<p;r|=s[p],d&=~y}return wa=r,Rc(),l}function Dx(s,r){Xe=null,D.H=rl,r===Ai||r===$c?(r=Ky(),gt=3):r===ih?(r=Ky(),gt=4):gt=r===Ih?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,ns=r,nt===null&&(Gt=1,Jc(s,ms(r,s.current)))}function zx(){var s=es.current;return s===null?!0:(rt&4194048)===rt?ys===null:(rt&62914560)===rt||(rt&536870912)!==0?s===ys:!1}function Lx(){var s=D.H;return D.H=rl,s===null?rl:s}function $x(){var s=D.A;return D.A=lR,s}function uu(){Gt=4,Va||(rt&4194048)!==rt&&es.current!==null||(Li=!0),(Ha&134217727)===0&&(Ur&134217727)===0||jt===null||qa(jt,rt,ss,!1)}function sm(s,r,l){var d=pt;pt|=2;var p=Lx(),y=$x();(jt!==s||rt!==r)&&(lu=null,Ui(s,r)),r=!1;var E=Gt;e:do try{if(gt!==0&&nt!==null){var _=nt,H=ns;switch(gt){case 8:nm(),E=6;break e;case 3:case 2:case 9:case 6:es.current===null&&(r=!0);var ne=gt;if(gt=0,ns=null,Bi(s,_,H,ne),l&&Li){E=0;break e}break;default:ne=gt,gt=0,ns=null,Bi(s,_,H,ne)}}dR(),E=Gt;break}catch(ie){Dx(s,ie)}while(!0);return r&&s.shellSuspendCounter++,da=Mr=null,pt=d,D.H=p,D.A=y,nt===null&&(jt=null,rt=0,Rc()),E}function dR(){for(;nt!==null;)Px(nt)}function fR(s,r){var l=pt;pt|=2;var d=Lx(),p=$x();jt!==s||rt!==r?(lu=null,ou=je()+500,Ui(s,r)):Li=ee(s,r);e:do try{if(gt!==0&&nt!==null){r=nt;var y=ns;t:switch(gt){case 1:gt=0,ns=null,Bi(s,r,y,1);break;case 2:case 9:if(Wy(y)){gt=0,ns=null,Ux(r);break}r=function(){gt!==2&>!==9||jt!==s||(gt=7),Zs(s)},y.then(r,r);break e;case 3:gt=7;break e;case 4:gt=5;break e;case 7:Wy(y)?(gt=0,ns=null,Ux(r)):(gt=0,ns=null,Bi(s,r,y,7));break;case 5:var E=null;switch(nt.tag){case 26:E=nt.memoizedState;case 5:case 27:var _=nt;if(E?kb(E):_.stateNode.complete){gt=0,ns=null;var H=_.sibling;if(H!==null)nt=H;else{var ne=_.return;ne!==null?(nt=ne,du(ne)):nt=null}break t}}gt=0,ns=null,Bi(s,r,y,5);break;case 6:gt=0,ns=null,Bi(s,r,y,6);break;case 8:nm(),Gt=6;break e;default:throw Error(a(462))}}hR();break}catch(ie){Dx(s,ie)}while(!0);return da=Mr=null,D.H=d,D.A=p,pt=l,nt!==null?0:(jt=null,rt=0,Rc(),Gt)}function hR(){for(;nt!==null&&!ge();)Px(nt)}function Px(s){var r=cx(s.alternate,s,wa);s.memoizedProps=s.pendingProps,r===null?du(s):nt=r}function Ux(s){var r=s,l=r.alternate;switch(r.tag){case 15:case 0:r=sx(l,r,r.pendingProps,r.type,void 0,rt);break;case 11:r=sx(l,r,r.pendingProps,r.type.render,r.ref,rt);break;case 5:yh(r);default:dx(l,r),r=nt=$y(r,wa),r=cx(l,r,wa)}s.memoizedProps=s.pendingProps,r===null?du(s):nt=r}function Bi(s,r,l,d){da=Mr=null,yh(r),Ri=null,Ko=0;var p=r.return;try{if(tR(s,p,r,l,rt)){Gt=1,Jc(s,ms(l,s.current)),nt=null;return}}catch(y){if(p!==null)throw nt=p,y;Gt=1,Jc(s,ms(l,s.current)),nt=null;return}r.flags&32768?(ot||d===1?s=!0:Li||(rt&536870912)!==0?s=!1:(Va=s=!0,(d===2||d===9||d===3||d===6)&&(d=es.current,d!==null&&d.tag===13&&(d.flags|=16384))),Bx(r,s)):du(r)}function du(s){var r=s;do{if((r.flags&32768)!==0){Bx(r,Va);return}s=r.return;var l=aR(r.alternate,r,wa);if(l!==null){nt=l;return}if(r=r.sibling,r!==null){nt=r;return}nt=r=s}while(r!==null);Gt===0&&(Gt=5)}function Bx(s,r){do{var l=rR(s.alternate,s);if(l!==null){l.flags&=32767,nt=l;return}if(l=s.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(s=s.sibling,s!==null)){nt=s;return}nt=s=l}while(s!==null);Gt=6,nt=null}function Vx(s,r,l,d,p,y,E,_,H){s.cancelPendingCommit=null;do fu();while(un!==0);if((pt&6)!==0)throw Error(a(327));if(r!==null){if(r===s.current)throw Error(a(177));if(y=r.lanes|r.childLanes,y|=Ff,ut(s,l,y,E,_,H),s===jt&&(nt=jt=null,rt=0),Pi=r,Fa=s,Sa=l,Qh=y,em=p,Mx=d,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,vR(Ge,function(){return Yx(),null})):(s.callbackNode=null,s.callbackPriority=0),d=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||d){d=D.T,D.T=null,p=P.p,P.p=2,E=pt,pt|=4;try{iR(s,r,l)}finally{pt=E,P.p=p,D.T=d}}un=1,Hx(),Zx(),Fx()}}function Hx(){if(un===1){un=0;var s=Fa,r=Pi,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=D.T,D.T=null;var d=P.p;P.p=2;var p=pt;pt|=4;try{jx(r,s);var y=pm,E=Ay(s.containerInfo),_=y.focusedElem,H=y.selectionRange;if(E!==_&&_&&_.ownerDocument&&Ty(_.ownerDocument.documentElement,_)){if(H!==null&&Uf(_)){var ne=H.start,ie=H.end;if(ie===void 0&&(ie=ne),"selectionStart"in _)_.selectionStart=ne,_.selectionEnd=Math.min(ie,_.value.length);else{var ue=_.ownerDocument||document,se=ue&&ue.defaultView||window;if(se.getSelection){var ae=se.getSelection(),Ee=_.textContent.length,Le=Math.min(H.start,Ee),St=H.end===void 0?Le:Math.min(H.end,Ee);!ae.extend&&Le>St&&(E=St,St=Le,Le=E);var W=Cy(_,Le),q=Cy(_,St);if(W&&q&&(ae.rangeCount!==1||ae.anchorNode!==W.node||ae.anchorOffset!==W.offset||ae.focusNode!==q.node||ae.focusOffset!==q.offset)){var te=ue.createRange();te.setStart(W.node,W.offset),ae.removeAllRanges(),Le>St?(ae.addRange(te),ae.extend(q.node,q.offset)):(te.setEnd(q.node,q.offset),ae.addRange(te))}}}}for(ue=[],ae=_;ae=ae.parentNode;)ae.nodeType===1&&ue.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_<ue.length;_++){var ce=ue[_];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}Nu=!!mm,pm=mm=null}finally{pt=p,P.p=d,D.T=l}}s.current=r,un=2}}function Zx(){if(un===2){un=0;var s=Fa,r=Pi,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=D.T,D.T=null;var d=P.p;P.p=2;var p=pt;pt|=4;try{yx(s,r.alternate,r)}finally{pt=p,P.p=d,D.T=l}}un=3}}function Fx(){if(un===4||un===3){un=0,ve();var s=Fa,r=Pi,l=Sa,d=Mx;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?un=5:(un=0,Pi=Fa=null,qx(s,s.pendingLanes));var p=s.pendingLanes;if(p===0&&(Za=null),As(l),r=r.stateNode,Ie&&typeof Ie.onCommitFiberRoot=="function")try{Ie.onCommitFiberRoot(on,r,void 0,(r.current.flags&128)===128)}catch{}if(d!==null){r=D.T,p=P.p,P.p=2,D.T=null;try{for(var y=s.onRecoverableError,E=0;E<d.length;E++){var _=d[E];y(_.value,{componentStack:_.stack})}}finally{D.T=r,P.p=p}}(Sa&3)!==0&&fu(),Zs(s),p=s.pendingLanes,(l&261930)!==0&&(p&42)!==0?s===tm?ml++:(ml=0,tm=s):ml=0,pl(0)}}function qx(s,r){(s.pooledCacheLanes&=r)===0&&(r=s.pooledCache,r!=null&&(s.pooledCache=null,Wo(r)))}function fu(){return Hx(),Zx(),Fx(),Yx()}function Yx(){if(un!==5)return!1;var s=Fa,r=Qh;Qh=0;var l=As(Sa),d=D.T,p=P.p;try{P.p=32>l?32:l,D.T=null,l=em,em=null;var y=Fa,E=Sa;if(un=0,Pi=Fa=null,Sa=0,(pt&6)!==0)throw Error(a(331));var _=pt;if(pt|=4,Tx(y.current),kx(y,y.current,E,l),pt=_,pl(0,!1),Ie&&typeof Ie.onPostCommitFiberRoot=="function")try{Ie.onPostCommitFiberRoot(on,y)}catch{}return!0}finally{P.p=p,D.T=d,qx(s,r)}}function Gx(s,r,l){r=ms(l,r),r=Oh(s.stateNode,r,2),s=$a(s,r,2),s!==null&&(ze(s,2),Zs(s))}function vt(s,r,l){if(s.tag===3)Gx(s,s,l);else for(;r!==null;){if(r.tag===3){Gx(r,s,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(Za===null||!Za.has(d))){s=ms(l,s),l=W0(2),d=$a(r,l,2),d!==null&&(X0(l,d,r,s),ze(d,2),Zs(d));break}}r=r.return}}function am(s,r,l){var d=s.pingCache;if(d===null){d=s.pingCache=new cR;var p=new Set;d.set(r,p)}else p=d.get(r),p===void 0&&(p=new Set,d.set(r,p));p.has(l)||(Xh=!0,p.add(l),s=mR.bind(null,s,r,l),r.then(s,s))}function mR(s,r,l){var d=s.pingCache;d!==null&&d.delete(r),s.pingedLanes|=s.suspendedLanes&l,s.warmLanes&=~l,jt===s&&(rt&l)===l&&(Gt===4||Gt===3&&(rt&62914560)===rt&&300>je()-iu?(pt&2)===0&&Ui(s,0):Kh|=l,$i===rt&&($i=0)),Zs(s)}function Wx(s,r){r===0&&(r=ye()),s=Tr(s,r),s!==null&&(ze(s,r),Zs(s))}function pR(s){var r=s.memoizedState,l=0;r!==null&&(l=r.retryLane),Wx(s,l)}function gR(s,r){var l=0;switch(s.tag){case 31:case 13:var d=s.stateNode,p=s.memoizedState;p!==null&&(l=p.retryLane);break;case 19:d=s.stateNode;break;case 22:d=s.stateNode._retryCache;break;default:throw Error(a(314))}d!==null&&d.delete(r),Wx(s,l)}function vR(s,r){return He(s,r)}var hu=null,Vi=null,rm=!1,mu=!1,im=!1,Ya=0;function Zs(s){s!==Vi&&s.next===null&&(Vi===null?hu=Vi=s:Vi=Vi.next=s),mu=!0,rm||(rm=!0,xR())}function pl(s,r){if(!im&&mu){im=!0;do for(var l=!1,d=hu;d!==null;){if(s!==0){var p=d.pendingLanes;if(p===0)var y=0;else{var E=d.suspendedLanes,_=d.pingedLanes;y=(1<<31-ct(42|s)+1)-1,y&=p&~(E&~_),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(l=!0,Qx(d,y))}else y=rt,y=Ts(d,d===jt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ee(d,y)||(l=!0,Qx(d,y));d=d.next}while(l);im=!1}}function yR(){Xx()}function Xx(){mu=rm=!1;var s=0;Ya!==0&&AR()&&(s=Ya);for(var r=je(),l=null,d=hu;d!==null;){var p=d.next,y=Kx(d,r);y===0?(d.next=null,l===null?hu=p:l.next=p,p===null&&(Vi=l)):(l=d,(s!==0||(y&3)!==0)&&(mu=!0)),d=p}un!==0&&un!==5||pl(s),Ya!==0&&(Ya=0)}function Kx(s,r){for(var l=s.suspendedLanes,d=s.pingedLanes,p=s.expirationTimes,y=s.pendingLanes&-62914561;0<y;){var E=31-ct(y),_=1<<E,H=p[E];H===-1?((_&l)===0||(_&d)!==0)&&(p[E]=me(_,r)):H<=r&&(s.expiredLanes|=_),y&=~_}if(r=jt,l=rt,l=Ts(s,s===r?l:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),d=s.callbackNode,l===0||s===r&&(gt===2||gt===9)||s.cancelPendingCommit!==null)return d!==null&&d!==null&&le(d),s.callbackNode=null,s.callbackPriority=0;if((l&3)===0||ee(s,l)){if(r=l&-l,r===s.callbackPriority)return r;switch(d!==null&&le(d),As(l)){case 2:case 8:l=et;break;case 32:l=Ge;break;case 268435456:l=kt;break;default:l=Ge}return d=Jx.bind(null,s),l=He(l,d),s.callbackPriority=r,s.callbackNode=l,r}return d!==null&&d!==null&&le(d),s.callbackPriority=2,s.callbackNode=null,2}function Jx(s,r){if(un!==0&&un!==5)return s.callbackNode=null,s.callbackPriority=0,null;var l=s.callbackNode;if(fu()&&s.callbackNode!==l)return null;var d=rt;return d=Ts(s,s===jt?d:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),d===0?null:(Ox(s,d,r),Kx(s,je()),s.callbackNode!=null&&s.callbackNode===l?Jx.bind(null,s):null)}function Qx(s,r){if(fu())return null;Ox(s,r,!0)}function xR(){MR(function(){(pt&6)!==0?He(Je,yR):Xx()})}function om(){if(Ya===0){var s=Ci;s===0&&(s=Xt,Xt<<=1,(Xt&261888)===0&&(Xt=256)),Ya=s}return Ya}function eb(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:Sc(""+s)}function tb(s,r){var l=r.ownerDocument.createElement("input");return l.name=r.name,l.value=r.value,s.id&&l.setAttribute("form",s.id),r.parentNode.insertBefore(l,r),s=new FormData(s),l.parentNode.removeChild(l),s}function bR(s,r,l,d,p){if(r==="submit"&&l&&l.stateNode===p){var y=eb((p[Un]||null).action),E=d.submitter;E&&(r=(r=E[Un]||null)?eb(r.formAction):E.getAttribute("formAction"),r!==null&&(y=r,E=null));var _=new Ec("action","action",null,d,p);s.push({event:_,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(Ya!==0){var H=E?tb(p,E):new FormData(p);Ch(l,{pending:!0,data:H,method:p.method,action:y},null,H)}}else typeof y=="function"&&(_.preventDefault(),H=E?tb(p,E):new FormData(p),Ch(l,{pending:!0,data:H,method:p.method,action:y},y,H))},currentTarget:p}]})}}for(var lm=0;lm<Zf.length;lm++){var cm=Zf[lm],wR=cm.toLowerCase(),SR=cm[0].toUpperCase()+cm.slice(1);Rs(wR,"on"+SR)}Rs(_y,"onAnimationEnd"),Rs(Oy,"onAnimationIteration"),Rs(Iy,"onAnimationStart"),Rs("dblclick","onDoubleClick"),Rs("focusin","onFocus"),Rs("focusout","onBlur"),Rs($A,"onTransitionRun"),Rs(PA,"onTransitionStart"),Rs(UA,"onTransitionCancel"),Rs(Dy,"onTransitionEnd"),hi("onMouseEnter",["mouseout","mouseover"]),hi("onMouseLeave",["mouseout","mouseover"]),hi("onPointerEnter",["pointerout","pointerover"]),hi("onPointerLeave",["pointerout","pointerover"]),Nr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Nr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Nr("onBeforeInput",["compositionend","keypress","textInput","paste"]),Nr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Nr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Nr("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(" "),jR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(gl));function nb(s,r){r=(r&4)!==0;for(var l=0;l<s.length;l++){var d=s[l],p=d.event;d=d.listeners;e:{var y=void 0;if(r)for(var E=d.length-1;0<=E;E--){var _=d[E],H=_.instance,ne=_.currentTarget;if(_=_.listener,H!==y&&p.isPropagationStopped())break e;y=_,p.currentTarget=ne;try{y(p)}catch(ie){Ac(ie)}p.currentTarget=null,y=H}else for(E=0;E<d.length;E++){if(_=d[E],H=_.instance,ne=_.currentTarget,_=_.listener,H!==y&&p.isPropagationStopped())break e;y=_,p.currentTarget=ne;try{y(p)}catch(ie){Ac(ie)}p.currentTarget=null,y=H}}}}function st(s,r){var l=r[Sf];l===void 0&&(l=r[Sf]=new Set);var d=s+"__bubble";l.has(d)||(sb(r,s,2,!1),l.add(d))}function um(s,r,l){var d=0;r&&(d|=4),sb(l,s,d,r)}var pu="_reactListening"+Math.random().toString(36).slice(2);function dm(s){if(!s[pu]){s[pu]=!0,Xv.forEach(function(l){l!=="selectionchange"&&(jR.has(l)||um(l,!1,s),um(l,!0,s))});var r=s.nodeType===9?s:s.ownerDocument;r===null||r[pu]||(r[pu]=!0,um("selectionchange",!1,r))}}function sb(s,r,l,d){switch(_b(r)){case 2:var p=KR;break;case 8:p=JR;break;default:p=Em}l=p.bind(null,r,l,s),p=void 0,!Mf||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),d?p!==void 0?s.addEventListener(r,l,{capture:!0,passive:p}):s.addEventListener(r,l,!0):p!==void 0?s.addEventListener(r,l,{passive:p}):s.addEventListener(r,l,!1)}function fm(s,r,l,d,p){var y=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var E=d.tag;if(E===3||E===4){var _=d.stateNode.containerInfo;if(_===p)break;if(E===4)for(E=d.return;E!==null;){var H=E.tag;if((H===3||H===4)&&E.stateNode.containerInfo===p)return;E=E.return}for(;_!==null;){if(E=ui(_),E===null)return;if(H=E.tag,H===5||H===6||H===26||H===27){d=y=E;continue e}_=_.parentNode}}d=d.return}ly(function(){var ne=y,ie=Af(l),ue=[];e:{var se=zy.get(s);if(se!==void 0){var ae=Ec,Ee=s;switch(s){case"keypress":if(Nc(l)===0)break e;case"keydown":case"keyup":ae=gA;break;case"focusin":Ee="focus",ae=Df;break;case"focusout":Ee="blur",ae=Df;break;case"beforeblur":case"afterblur":ae=Df;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ae=dy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=aA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=xA;break;case _y:case Oy:case Iy:ae=oA;break;case Dy:ae=wA;break;case"scroll":case"scrollend":ae=nA;break;case"wheel":ae=jA;break;case"copy":case"cut":case"paste":ae=cA;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=hy;break;case"toggle":case"beforetoggle":ae=kA}var Le=(r&4)!==0,St=!Le&&(s==="scroll"||s==="scrollend"),W=Le?se!==null?se+"Capture":null:se;Le=[];for(var q=ne,te;q!==null;){var ce=q;if(te=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||te===null||W===null||(ce=$o(q,W),ce!=null&&Le.push(vl(q,ce,te))),St)break;q=q.return}0<Le.length&&(se=new ae(se,Ee,null,l,ie),ue.push({event:se,listeners:Le}))}}if((r&7)===0){e:{if(se=s==="mouseover"||s==="pointerover",ae=s==="mouseout"||s==="pointerout",se&&l!==Tf&&(Ee=l.relatedTarget||l.fromElement)&&(ui(Ee)||Ee[ci]))break e;if((ae||se)&&(se=ie.window===ie?ie:(se=ie.ownerDocument)?se.defaultView||se.parentWindow:window,ae?(Ee=l.relatedTarget||l.toElement,ae=ne,Ee=Ee?ui(Ee):null,Ee!==null&&(St=c(Ee),Le=Ee.tag,Ee!==St||Le!==5&&Le!==27&&Le!==6)&&(Ee=null)):(ae=null,Ee=ne),ae!==Ee)){if(Le=dy,ce="onMouseLeave",W="onMouseEnter",q="mouse",(s==="pointerout"||s==="pointerover")&&(Le=hy,ce="onPointerLeave",W="onPointerEnter",q="pointer"),St=ae==null?se:Lo(ae),te=Ee==null?se:Lo(Ee),se=new Le(ce,q+"leave",ae,l,ie),se.target=St,se.relatedTarget=te,ce=null,ui(ie)===ne&&(Le=new Le(W,q+"enter",Ee,l,ie),Le.target=te,Le.relatedTarget=St,ce=Le),St=ce,ae&&Ee)t:{for(Le=NR,W=ae,q=Ee,te=0,ce=W;ce;ce=Le(ce))te++;ce=0;for(var De=q;De;De=Le(De))ce++;for(;0<te-ce;)W=Le(W),te--;for(;0<ce-te;)q=Le(q),ce--;for(;te--;){if(W===q||q!==null&&W===q.alternate){Le=W;break t}W=Le(W),q=Le(q)}Le=null}else Le=null;ae!==null&&ab(ue,se,ae,Le,!1),Ee!==null&&St!==null&&ab(ue,St,Ee,Le,!0)}}e:{if(se=ne?Lo(ne):window,ae=se.nodeName&&se.nodeName.toLowerCase(),ae==="select"||ae==="input"&&se.type==="file")var ft=wy;else if(xy(se))if(Sy)ft=DA;else{ft=OA;var Te=_A}else ae=se.nodeName,!ae||ae.toLowerCase()!=="input"||se.type!=="checkbox"&&se.type!=="radio"?ne&&Cf(ne.elementType)&&(ft=wy):ft=IA;if(ft&&(ft=ft(s,ne))){by(ue,ft,l,ie);break e}Te&&Te(s,se,ne),s==="focusout"&&ne&&se.type==="number"&&ne.memoizedProps.value!=null&&Ef(se,"number",se.value)}switch(Te=ne?Lo(ne):window,s){case"focusin":(xy(Te)||Te.contentEditable==="true")&&(xi=Te,Bf=ne,qo=null);break;case"focusout":qo=Bf=xi=null;break;case"mousedown":Vf=!0;break;case"contextmenu":case"mouseup":case"dragend":Vf=!1,Ry(ue,l,ie);break;case"selectionchange":if(LA)break;case"keydown":case"keyup":Ry(ue,l,ie)}var Ke;if(Lf)e:{switch(s){case"compositionstart":var it="onCompositionStart";break e;case"compositionend":it="onCompositionEnd";break e;case"compositionupdate":it="onCompositionUpdate";break e}it=void 0}else yi?vy(s,l)&&(it="onCompositionEnd"):s==="keydown"&&l.keyCode===229&&(it="onCompositionStart");it&&(my&&l.locale!=="ko"&&(yi||it!=="onCompositionStart"?it==="onCompositionEnd"&&yi&&(Ke=cy()):(Ma=ie,_f="value"in Ma?Ma.value:Ma.textContent,yi=!0)),Te=gu(ne,it),0<Te.length&&(it=new fy(it,s,null,l,ie),ue.push({event:it,listeners:Te}),Ke?it.data=Ke:(Ke=yy(l),Ke!==null&&(it.data=Ke)))),(Ke=CA?TA(s,l):AA(s,l))&&(it=gu(ne,"onBeforeInput"),0<it.length&&(Te=new fy("onBeforeInput","beforeinput",null,l,ie),ue.push({event:Te,listeners:it}),Te.data=Ke)),bR(ue,s,ne,l,ie)}nb(ue,r)})}function vl(s,r,l){return{instance:s,listener:r,currentTarget:l}}function gu(s,r){for(var l=r+"Capture",d=[];s!==null;){var p=s,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=$o(s,l),p!=null&&d.unshift(vl(s,p,y)),p=$o(s,r),p!=null&&d.push(vl(s,p,y))),s.tag===3)return d;s=s.return}return[]}function NR(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function ab(s,r,l,d,p){for(var y=r._reactName,E=[];l!==null&&l!==d;){var _=l,H=_.alternate,ne=_.stateNode;if(_=_.tag,H!==null&&H===d)break;_!==5&&_!==26&&_!==27||ne===null||(H=ne,p?(ne=$o(l,y),ne!=null&&E.unshift(vl(l,ne,H))):p||(ne=$o(l,y),ne!=null&&E.push(vl(l,ne,H)))),l=l.return}E.length!==0&&s.push({event:r,listeners:E})}var kR=/\r\n?/g,ER=/\u0000|\uFFFD/g;function rb(s){return(typeof s=="string"?s:""+s).replace(kR,`
|
|
9
|
-
`).replace(ER,"")}function ib(s,r){return r=rb(r),rb(s)===r}function wt(s,r,l,d,p,y){switch(l){case"children":typeof d=="string"?r==="body"||r==="textarea"&&d===""||pi(s,d):(typeof d=="number"||typeof d=="bigint")&&r!=="body"&&pi(s,""+d);break;case"className":bc(s,"class",d);break;case"tabIndex":bc(s,"tabindex",d);break;case"dir":case"role":case"viewBox":case"width":case"height":bc(s,l,d);break;case"style":iy(s,d,y);break;case"data":if(r!=="object"){bc(s,"data",d);break}case"src":case"href":if(d===""&&(r!=="a"||l!=="href")){s.removeAttribute(l);break}if(d==null||typeof d=="function"||typeof d=="symbol"||typeof d=="boolean"){s.removeAttribute(l);break}d=Sc(""+d),s.setAttribute(l,d);break;case"action":case"formAction":if(typeof d=="function"){s.setAttribute(l,"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 y=="function"&&(l==="formAction"?(r!=="input"&&wt(s,r,"name",p.name,p,null),wt(s,r,"formEncType",p.formEncType,p,null),wt(s,r,"formMethod",p.formMethod,p,null),wt(s,r,"formTarget",p.formTarget,p,null)):(wt(s,r,"encType",p.encType,p,null),wt(s,r,"method",p.method,p,null),wt(s,r,"target",p.target,p,null)));if(d==null||typeof d=="symbol"||typeof d=="boolean"){s.removeAttribute(l);break}d=Sc(""+d),s.setAttribute(l,d);break;case"onClick":d!=null&&(s.onclick=oa);break;case"onScroll":d!=null&&st("scroll",s);break;case"onScrollEnd":d!=null&&st("scrollend",s);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(a(61));if(l=d.__html,l!=null){if(p.children!=null)throw Error(a(60));s.innerHTML=l}}break;case"multiple":s.multiple=d&&typeof d!="function"&&typeof d!="symbol";break;case"muted":s.muted=d&&typeof d!="function"&&typeof d!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(d==null||typeof d=="function"||typeof d=="boolean"||typeof d=="symbol"){s.removeAttribute("xlink:href");break}l=Sc(""+d),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":d!=null&&typeof d!="function"&&typeof d!="symbol"?s.setAttribute(l,""+d):s.removeAttribute(l);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":d&&typeof d!="function"&&typeof d!="symbol"?s.setAttribute(l,""):s.removeAttribute(l);break;case"capture":case"download":d===!0?s.setAttribute(l,""):d!==!1&&d!=null&&typeof d!="function"&&typeof d!="symbol"?s.setAttribute(l,d):s.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":d!=null&&typeof d!="function"&&typeof d!="symbol"&&!isNaN(d)&&1<=d?s.setAttribute(l,d):s.removeAttribute(l);break;case"rowSpan":case"start":d==null||typeof d=="function"||typeof d=="symbol"||isNaN(d)?s.removeAttribute(l):s.setAttribute(l,d);break;case"popover":st("beforetoggle",s),st("toggle",s),xc(s,"popover",d);break;case"xlinkActuate":ia(s,"http://www.w3.org/1999/xlink","xlink:actuate",d);break;case"xlinkArcrole":ia(s,"http://www.w3.org/1999/xlink","xlink:arcrole",d);break;case"xlinkRole":ia(s,"http://www.w3.org/1999/xlink","xlink:role",d);break;case"xlinkShow":ia(s,"http://www.w3.org/1999/xlink","xlink:show",d);break;case"xlinkTitle":ia(s,"http://www.w3.org/1999/xlink","xlink:title",d);break;case"xlinkType":ia(s,"http://www.w3.org/1999/xlink","xlink:type",d);break;case"xmlBase":ia(s,"http://www.w3.org/XML/1998/namespace","xml:base",d);break;case"xmlLang":ia(s,"http://www.w3.org/XML/1998/namespace","xml:lang",d);break;case"xmlSpace":ia(s,"http://www.w3.org/XML/1998/namespace","xml:space",d);break;case"is":xc(s,"is",d);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=eA.get(l)||l,xc(s,l,d))}}function hm(s,r,l,d,p,y){switch(l){case"style":iy(s,d,y);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(a(61));if(l=d.__html,l!=null){if(p.children!=null)throw Error(a(60));s.innerHTML=l}}break;case"children":typeof d=="string"?pi(s,d):(typeof d=="number"||typeof d=="bigint")&&pi(s,""+d);break;case"onScroll":d!=null&&st("scroll",s);break;case"onScrollEnd":d!=null&&st("scrollend",s);break;case"onClick":d!=null&&(s.onclick=oa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Kv.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(p=l.endsWith("Capture"),r=l.slice(2,p?l.length-7:void 0),y=s[Un]||null,y=y!=null?y[l]:null,typeof y=="function"&&s.removeEventListener(r,y,p),typeof d=="function")){typeof y!="function"&&y!==null&&(l in s?s[l]=null:s.hasAttribute(l)&&s.removeAttribute(l)),s.addEventListener(r,d,p);break e}l in s?s[l]=d:d===!0?s.setAttribute(l,""):xc(s,l,d)}}}function kn(s,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":st("error",s),st("load",s);var d=!1,p=!1,y;for(y in l)if(l.hasOwnProperty(y)){var E=l[y];if(E!=null)switch(y){case"src":d=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,r));default:wt(s,r,y,E,l,null)}}p&&wt(s,r,"srcSet",l.srcSet,l,null),d&&wt(s,r,"src",l.src,l,null);return;case"input":st("invalid",s);var _=y=E=p=null,H=null,ne=null;for(d in l)if(l.hasOwnProperty(d)){var ie=l[d];if(ie!=null)switch(d){case"name":p=ie;break;case"type":E=ie;break;case"checked":H=ie;break;case"defaultChecked":ne=ie;break;case"value":y=ie;break;case"defaultValue":_=ie;break;case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(a(137,r));break;default:wt(s,r,d,ie,l,null)}}ny(s,y,_,H,ne,E,p,!1);return;case"select":st("invalid",s),d=E=y=null;for(p in l)if(l.hasOwnProperty(p)&&(_=l[p],_!=null))switch(p){case"value":y=_;break;case"defaultValue":E=_;break;case"multiple":d=_;default:wt(s,r,p,_,l,null)}r=y,l=E,s.multiple=!!d,r!=null?mi(s,!!d,r,!1):l!=null&&mi(s,!!d,l,!0);return;case"textarea":st("invalid",s),y=p=d=null;for(E in l)if(l.hasOwnProperty(E)&&(_=l[E],_!=null))switch(E){case"value":d=_;break;case"defaultValue":p=_;break;case"children":y=_;break;case"dangerouslySetInnerHTML":if(_!=null)throw Error(a(91));break;default:wt(s,r,E,_,l,null)}ay(s,d,p,y);return;case"option":for(H in l)l.hasOwnProperty(H)&&(d=l[H],d!=null)&&(H==="selected"?s.selected=d&&typeof d!="function"&&typeof d!="symbol":wt(s,r,H,d,l,null));return;case"dialog":st("beforetoggle",s),st("toggle",s),st("cancel",s),st("close",s);break;case"iframe":case"object":st("load",s);break;case"video":case"audio":for(d=0;d<gl.length;d++)st(gl[d],s);break;case"image":st("error",s),st("load",s);break;case"details":st("toggle",s);break;case"embed":case"source":case"link":st("error",s),st("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ne in l)if(l.hasOwnProperty(ne)&&(d=l[ne],d!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,r));default:wt(s,r,ne,d,l,null)}return;default:if(Cf(r)){for(ie in l)l.hasOwnProperty(ie)&&(d=l[ie],d!==void 0&&hm(s,r,ie,d,l,void 0));return}}for(_ in l)l.hasOwnProperty(_)&&(d=l[_],d!=null&&wt(s,r,_,d,l,null))}function CR(s,r,l,d){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,y=null,E=null,_=null,H=null,ne=null,ie=null;for(ae in l){var ue=l[ae];if(l.hasOwnProperty(ae)&&ue!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":H=ue;default:d.hasOwnProperty(ae)||wt(s,r,ae,null,d,ue)}}for(var se in d){var ae=d[se];if(ue=l[se],d.hasOwnProperty(se)&&(ae!=null||ue!=null))switch(se){case"type":y=ae;break;case"name":p=ae;break;case"checked":ne=ae;break;case"defaultChecked":ie=ae;break;case"value":E=ae;break;case"defaultValue":_=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(a(137,r));break;default:ae!==ue&&wt(s,r,se,ae,d,ue)}}kf(s,E,_,H,ne,ie,y,p);return;case"select":ae=E=_=se=null;for(y in l)if(H=l[y],l.hasOwnProperty(y)&&H!=null)switch(y){case"value":break;case"multiple":ae=H;default:d.hasOwnProperty(y)||wt(s,r,y,null,d,H)}for(p in d)if(y=d[p],H=l[p],d.hasOwnProperty(p)&&(y!=null||H!=null))switch(p){case"value":se=y;break;case"defaultValue":_=y;break;case"multiple":E=y;default:y!==H&&wt(s,r,p,y,d,H)}r=_,l=E,d=ae,se!=null?mi(s,!!l,se,!1):!!d!=!!l&&(r!=null?mi(s,!!l,r,!0):mi(s,!!l,l?[]:"",!1));return;case"textarea":ae=se=null;for(_ in l)if(p=l[_],l.hasOwnProperty(_)&&p!=null&&!d.hasOwnProperty(_))switch(_){case"value":break;case"children":break;default:wt(s,r,_,null,d,p)}for(E in d)if(p=d[E],y=l[E],d.hasOwnProperty(E)&&(p!=null||y!=null))switch(E){case"value":se=p;break;case"defaultValue":ae=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(a(91));break;default:p!==y&&wt(s,r,E,p,d,y)}sy(s,se,ae);return;case"option":for(var Ee in l)se=l[Ee],l.hasOwnProperty(Ee)&&se!=null&&!d.hasOwnProperty(Ee)&&(Ee==="selected"?s.selected=!1:wt(s,r,Ee,null,d,se));for(H in d)se=d[H],ae=l[H],d.hasOwnProperty(H)&&se!==ae&&(se!=null||ae!=null)&&(H==="selected"?s.selected=se&&typeof se!="function"&&typeof se!="symbol":wt(s,r,H,se,d,ae));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 Le in l)se=l[Le],l.hasOwnProperty(Le)&&se!=null&&!d.hasOwnProperty(Le)&&wt(s,r,Le,null,d,se);for(ne in d)if(se=d[ne],ae=l[ne],d.hasOwnProperty(ne)&&se!==ae&&(se!=null||ae!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(a(137,r));break;default:wt(s,r,ne,se,d,ae)}return;default:if(Cf(r)){for(var St in l)se=l[St],l.hasOwnProperty(St)&&se!==void 0&&!d.hasOwnProperty(St)&&hm(s,r,St,void 0,d,se);for(ie in d)se=d[ie],ae=l[ie],!d.hasOwnProperty(ie)||se===ae||se===void 0&&ae===void 0||hm(s,r,ie,se,d,ae);return}}for(var W in l)se=l[W],l.hasOwnProperty(W)&&se!=null&&!d.hasOwnProperty(W)&&wt(s,r,W,null,d,se);for(ue in d)se=d[ue],ae=l[ue],!d.hasOwnProperty(ue)||se===ae||se==null&&ae==null||wt(s,r,ue,se,d,ae)}function ob(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function TR(){if(typeof performance.getEntriesByType=="function"){for(var s=0,r=0,l=performance.getEntriesByType("resource"),d=0;d<l.length;d++){var p=l[d],y=p.transferSize,E=p.initiatorType,_=p.duration;if(y&&_&&ob(E)){for(E=0,_=p.responseEnd,d+=1;d<l.length;d++){var H=l[d],ne=H.startTime;if(ne>_)break;var ie=H.transferSize,ue=H.initiatorType;ie&&ob(ue)&&(H=H.responseEnd,E+=ie*(H<_?1:(_-ne)/(H-ne)))}if(--d,r+=8*(y+E)/(p.duration/1e3),s++,10<s)break}}if(0<s)return r/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var mm=null,pm=null;function vu(s){return s.nodeType===9?s:s.ownerDocument}function lb(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function cb(s,r){if(s===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&r==="foreignObject"?0:s}function gm(s,r){return s==="textarea"||s==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var vm=null;function AR(){var s=window.event;return s&&s.type==="popstate"?s===vm?!1:(vm=s,!0):(vm=null,!1)}var ub=typeof setTimeout=="function"?setTimeout:void 0,RR=typeof clearTimeout=="function"?clearTimeout:void 0,db=typeof Promise=="function"?Promise:void 0,MR=typeof queueMicrotask=="function"?queueMicrotask:typeof db<"u"?function(s){return db.resolve(null).then(s).catch(_R)}:ub;function _R(s){setTimeout(function(){throw s})}function Ga(s){return s==="head"}function fb(s,r){var l=r,d=0;do{var p=l.nextSibling;if(s.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"||l==="/&"){if(d===0){s.removeChild(p),qi(r);return}d--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")d++;else if(l==="html")yl(s.ownerDocument.documentElement);else if(l==="head"){l=s.ownerDocument.head,yl(l);for(var y=l.firstChild;y;){var E=y.nextSibling,_=y.nodeName;y[zo]||_==="SCRIPT"||_==="STYLE"||_==="LINK"&&y.rel.toLowerCase()==="stylesheet"||l.removeChild(y),y=E}}else l==="body"&&yl(s.ownerDocument.body);l=p}while(l);qi(r)}function hb(s,r){var l=s;s=0;do{var d=l.nextSibling;if(l.nodeType===1?r?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(r?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),d&&d.nodeType===8)if(l=d.data,l==="/$"){if(s===0)break;s--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||s++;l=d}while(l)}function ym(s){var r=s.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var l=r;switch(r=r.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":ym(l),jf(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}s.removeChild(l)}}function OR(s,r,l,d){for(;s.nodeType===1;){var p=l;if(s.nodeName.toLowerCase()!==r.toLowerCase()){if(!d&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(d){if(!s[zo])switch(r){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(y=s.getAttribute("rel"),y==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(y!==p.rel||s.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||s.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||s.getAttribute("title")!==(p.title==null?null:p.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(y=s.getAttribute("src"),(y!==(p.src==null?null:p.src)||s.getAttribute("type")!==(p.type==null?null:p.type)||s.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&y&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(r==="input"&&s.type==="hidden"){var y=p.name==null?null:""+p.name;if(p.type==="hidden"&&s.getAttribute("name")===y)return s}else return s;if(s=xs(s.nextSibling),s===null)break}return null}function IR(s,r,l){if(r==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!l||(s=xs(s.nextSibling),s===null))return null;return s}function mb(s,r){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!r||(s=xs(s.nextSibling),s===null))return null;return s}function xm(s){return s.data==="$?"||s.data==="$~"}function bm(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function DR(s,r){var l=s.ownerDocument;if(s.data==="$~")s._reactRetry=r;else if(s.data!=="$?"||l.readyState!=="loading")r();else{var d=function(){r(),l.removeEventListener("DOMContentLoaded",d)};l.addEventListener("DOMContentLoaded",d),s._reactRetry=d}}function xs(s){for(;s!=null;s=s.nextSibling){var r=s.nodeType;if(r===1||r===3)break;if(r===8){if(r=s.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return s}var wm=null;function pb(s){s=s.nextSibling;for(var r=0;s;){if(s.nodeType===8){var l=s.data;if(l==="/$"||l==="/&"){if(r===0)return xs(s.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}s=s.nextSibling}return null}function gb(s){s=s.previousSibling;for(var r=0;s;){if(s.nodeType===8){var l=s.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(r===0)return s;r--}else l!=="/$"&&l!=="/&"||r++}s=s.previousSibling}return null}function vb(s,r,l){switch(r=vu(l),s){case"html":if(s=r.documentElement,!s)throw Error(a(452));return s;case"head":if(s=r.head,!s)throw Error(a(453));return s;case"body":if(s=r.body,!s)throw Error(a(454));return s;default:throw Error(a(451))}}function yl(s){for(var r=s.attributes;r.length;)s.removeAttributeNode(r[0]);jf(s)}var bs=new Map,yb=new Set;function yu(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var ja=P.d;P.d={f:zR,r:LR,D:$R,C:PR,L:UR,m:BR,X:HR,S:VR,M:ZR};function zR(){var s=ja.f(),r=cu();return s||r}function LR(s){var r=di(s);r!==null&&r.tag===5&&r.type==="form"?D0(r):ja.r(s)}var Hi=typeof document>"u"?null:document;function xb(s,r,l){var d=Hi;if(d&&typeof r=="string"&&r){var p=fs(r);p='link[rel="'+s+'"][href="'+p+'"]',typeof l=="string"&&(p+='[crossorigin="'+l+'"]'),yb.has(p)||(yb.add(p),s={rel:s,crossOrigin:l,href:r},d.querySelector(p)===null&&(r=d.createElement("link"),kn(r,"link",s),pn(r),d.head.appendChild(r)))}}function $R(s){ja.D(s),xb("dns-prefetch",s,null)}function PR(s,r){ja.C(s,r),xb("preconnect",s,r)}function UR(s,r,l){ja.L(s,r,l);var d=Hi;if(d&&s&&r){var p='link[rel="preload"][as="'+fs(r)+'"]';r==="image"&&l&&l.imageSrcSet?(p+='[imagesrcset="'+fs(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(p+='[imagesizes="'+fs(l.imageSizes)+'"]')):p+='[href="'+fs(s)+'"]';var y=p;switch(r){case"style":y=Zi(s);break;case"script":y=Fi(s)}bs.has(y)||(s=x({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:s,as:r},l),bs.set(y,s),d.querySelector(p)!==null||r==="style"&&d.querySelector(xl(y))||r==="script"&&d.querySelector(bl(y))||(r=d.createElement("link"),kn(r,"link",s),pn(r),d.head.appendChild(r)))}}function BR(s,r){ja.m(s,r);var l=Hi;if(l&&s){var d=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+fs(d)+'"][href="'+fs(s)+'"]',y=p;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=Fi(s)}if(!bs.has(y)&&(s=x({rel:"modulepreload",href:s},r),bs.set(y,s),l.querySelector(p)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(bl(y)))return}d=l.createElement("link"),kn(d,"link",s),pn(d),l.head.appendChild(d)}}}function VR(s,r,l){ja.S(s,r,l);var d=Hi;if(d&&s){var p=fi(d).hoistableStyles,y=Zi(s);r=r||"default";var E=p.get(y);if(!E){var _={loading:0,preload:null};if(E=d.querySelector(xl(y)))_.loading=5;else{s=x({rel:"stylesheet",href:s,"data-precedence":r},l),(l=bs.get(y))&&Sm(s,l);var H=E=d.createElement("link");pn(H),kn(H,"link",s),H._p=new Promise(function(ne,ie){H.onload=ne,H.onerror=ie}),H.addEventListener("load",function(){_.loading|=1}),H.addEventListener("error",function(){_.loading|=2}),_.loading|=4,xu(E,r,d)}E={type:"stylesheet",instance:E,count:1,state:_},p.set(y,E)}}}function HR(s,r){ja.X(s,r);var l=Hi;if(l&&s){var d=fi(l).hoistableScripts,p=Fi(s),y=d.get(p);y||(y=l.querySelector(bl(p)),y||(s=x({src:s,async:!0},r),(r=bs.get(p))&&jm(s,r),y=l.createElement("script"),pn(y),kn(y,"link",s),l.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(p,y))}}function ZR(s,r){ja.M(s,r);var l=Hi;if(l&&s){var d=fi(l).hoistableScripts,p=Fi(s),y=d.get(p);y||(y=l.querySelector(bl(p)),y||(s=x({src:s,async:!0,type:"module"},r),(r=bs.get(p))&&jm(s,r),y=l.createElement("script"),pn(y),kn(y,"link",s),l.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(p,y))}}function bb(s,r,l,d){var p=(p=re.current)?yu(p):null;if(!p)throw Error(a(446));switch(s){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Zi(l.href),l=fi(p).hoistableStyles,d=l.get(r),d||(d={type:"style",instance:null,count:0,state:null},l.set(r,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){s=Zi(l.href);var y=fi(p).hoistableStyles,E=y.get(s);if(E||(p=p.ownerDocument||p,E={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(s,E),(y=p.querySelector(xl(s)))&&!y._p&&(E.instance=y,E.state.loading=5),bs.has(s)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},bs.set(s,l),y||FR(p,s,l,E.state))),r&&d===null)throw Error(a(528,""));return E}if(r&&d!==null)throw Error(a(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Fi(l),l=fi(p).hoistableScripts,d=l.get(r),d||(d={type:"script",instance:null,count:0,state:null},l.set(r,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,s))}}function Zi(s){return'href="'+fs(s)+'"'}function xl(s){return'link[rel="stylesheet"]['+s+"]"}function wb(s){return x({},s,{"data-precedence":s.precedence,precedence:null})}function FR(s,r,l,d){s.querySelector('link[rel="preload"][as="style"]['+r+"]")?d.loading=1:(r=s.createElement("link"),d.preload=r,r.addEventListener("load",function(){return d.loading|=1}),r.addEventListener("error",function(){return d.loading|=2}),kn(r,"link",l),pn(r),s.head.appendChild(r))}function Fi(s){return'[src="'+fs(s)+'"]'}function bl(s){return"script[async]"+s}function Sb(s,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var d=s.querySelector('style[data-href~="'+fs(l.href)+'"]');if(d)return r.instance=d,pn(d),d;var p=x({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return d=(s.ownerDocument||s).createElement("style"),pn(d),kn(d,"style",p),xu(d,l.precedence,s),r.instance=d;case"stylesheet":p=Zi(l.href);var y=s.querySelector(xl(p));if(y)return r.state.loading|=4,r.instance=y,pn(y),y;d=wb(l),(p=bs.get(p))&&Sm(d,p),y=(s.ownerDocument||s).createElement("link"),pn(y);var E=y;return E._p=new Promise(function(_,H){E.onload=_,E.onerror=H}),kn(y,"link",d),r.state.loading|=4,xu(y,l.precedence,s),r.instance=y;case"script":return y=Fi(l.src),(p=s.querySelector(bl(y)))?(r.instance=p,pn(p),p):(d=l,(p=bs.get(y))&&(d=x({},l),jm(d,p)),s=s.ownerDocument||s,p=s.createElement("script"),pn(p),kn(p,"link",d),s.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(a(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(d=r.instance,r.state.loading|=4,xu(d,l.precedence,s));return r.instance}function xu(s,r,l){for(var d=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=d.length?d[d.length-1]:null,y=p,E=0;E<d.length;E++){var _=d[E];if(_.dataset.precedence===r)y=_;else if(y!==p)break}y?y.parentNode.insertBefore(s,y.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(s,r.firstChild))}function Sm(s,r){s.crossOrigin==null&&(s.crossOrigin=r.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=r.referrerPolicy),s.title==null&&(s.title=r.title)}function jm(s,r){s.crossOrigin==null&&(s.crossOrigin=r.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=r.referrerPolicy),s.integrity==null&&(s.integrity=r.integrity)}var bu=null;function jb(s,r,l){if(bu===null){var d=new Map,p=bu=new Map;p.set(l,d)}else p=bu,d=p.get(l),d||(d=new Map,p.set(l,d));if(d.has(s))return d;for(d.set(s,null),l=l.getElementsByTagName(s),p=0;p<l.length;p++){var y=l[p];if(!(y[zo]||y[wn]||s==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var E=y.getAttribute(r)||"";E=s+E;var _=d.get(E);_?_.push(y):d.set(E,[y])}}return d}function Nb(s,r,l){s=s.ownerDocument||s,s.head.insertBefore(l,r==="title"?s.querySelector("head > title"):null)}function qR(s,r,l){if(l===1||r.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(s=r.disabled,typeof r.precedence=="string"&&s==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function kb(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function YR(s,r,l,d){if(l.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var p=Zi(d.href),y=r.querySelector(xl(p));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(s.count++,s=wu.bind(s),r.then(s,s)),l.state.loading|=4,l.instance=y,pn(y);return}y=r.ownerDocument||r,d=wb(d),(p=bs.get(p))&&Sm(d,p),y=y.createElement("link"),pn(y);var E=y;E._p=new Promise(function(_,H){E.onload=_,E.onerror=H}),kn(y,"link",d),l.instance=y}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(s.count++,l=wu.bind(s),r.addEventListener("load",l),r.addEventListener("error",l))}}var Nm=0;function GR(s,r){return s.stylesheets&&s.count===0&&ju(s,s.stylesheets),0<s.count||0<s.imgCount?function(l){var d=setTimeout(function(){if(s.stylesheets&&ju(s,s.stylesheets),s.unsuspend){var y=s.unsuspend;s.unsuspend=null,y()}},6e4+r);0<s.imgBytes&&Nm===0&&(Nm=62500*TR());var p=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&ju(s,s.stylesheets),s.unsuspend)){var y=s.unsuspend;s.unsuspend=null,y()}},(s.imgBytes>Nm?50:800)+r);return s.unsuspend=l,function(){s.unsuspend=null,clearTimeout(d),clearTimeout(p)}}:null}function wu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ju(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var Su=null;function ju(s,r){s.stylesheets=null,s.unsuspend!==null&&(s.count++,Su=new Map,r.forEach(WR,s),Su=null,wu.call(s))}function WR(s,r){if(!(r.state.loading&4)){var l=Su.get(s);if(l)var d=l.get(null);else{l=new Map,Su.set(s,l);for(var p=s.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<p.length;y++){var E=p[y];(E.nodeName==="LINK"||E.getAttribute("media")!=="not all")&&(l.set(E.dataset.precedence,E),d=E)}d&&l.set(null,d)}p=r.instance,E=p.getAttribute("data-precedence"),y=l.get(E)||d,y===d&&l.set(null,p),l.set(E,p),this.count++,d=wu.bind(this),p.addEventListener("load",d),p.addEventListener("error",d),y?y.parentNode.insertBefore(p,y.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(p,s.firstChild)),r.state.loading|=4}}var wl={$$typeof:S,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function XR(s,r,l,d,p,y,E,_,H){this.tag=1,this.containerInfo=s,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=Be(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Be(0),this.hiddenUpdates=Be(null),this.identifierPrefix=d,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=E,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=H,this.incompleteTransitions=new Map}function Eb(s,r,l,d,p,y,E,_,H,ne,ie,ue){return s=new XR(s,r,l,E,H,ne,ie,ue,_),r=1,y===!0&&(r|=24),y=Qn(3,null,null,r),s.current=y,y.stateNode=s,r=sh(),r.refCount++,s.pooledCache=r,r.refCount++,y.memoizedState={element:d,isDehydrated:l,cache:r},oh(y),s}function Cb(s){return s?(s=Si,s):Si}function Tb(s,r,l,d,p,y){p=Cb(p),d.context===null?d.context=p:d.pendingContext=p,d=La(r),d.payload={element:l},y=y===void 0?null:y,y!==null&&(d.callback=y),l=$a(s,d,r),l!==null&&(qn(l,s,r),Qo(l,s,r))}function Ab(s,r){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var l=s.retryLane;s.retryLane=l!==0&&l<r?l:r}}function km(s,r){Ab(s,r),(s=s.alternate)&&Ab(s,r)}function Rb(s){if(s.tag===13||s.tag===31){var r=Tr(s,67108864);r!==null&&qn(r,s,67108864),km(s,67108864)}}function Mb(s){if(s.tag===13||s.tag===31){var r=as();r=qt(r);var l=Tr(s,r);l!==null&&qn(l,s,r),km(s,r)}}var Nu=!0;function KR(s,r,l,d){var p=D.T;D.T=null;var y=P.p;try{P.p=2,Em(s,r,l,d)}finally{P.p=y,D.T=p}}function JR(s,r,l,d){var p=D.T;D.T=null;var y=P.p;try{P.p=8,Em(s,r,l,d)}finally{P.p=y,D.T=p}}function Em(s,r,l,d){if(Nu){var p=Cm(d);if(p===null)fm(s,r,d,ku,l),Ob(s,d);else if(eM(p,s,r,l,d))d.stopPropagation();else if(Ob(s,d),r&4&&-1<QR.indexOf(s)){for(;p!==null;){var y=di(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var E=xn(y.pendingLanes);if(E!==0){var _=y;for(_.pendingLanes|=2,_.entangledLanes|=2;E;){var H=1<<31-ct(E);_.entanglements[1]|=H,E&=~H}Zs(y),(pt&6)===0&&(ou=je()+500,pl(0))}}break;case 31:case 13:_=Tr(y,2),_!==null&&qn(_,y,2),cu(),km(y,2)}if(y=Cm(d),y===null&&fm(s,r,d,ku,l),y===p)break;p=y}p!==null&&d.stopPropagation()}else fm(s,r,d,null,l)}}function Cm(s){return s=Af(s),Tm(s)}var ku=null;function Tm(s){if(ku=null,s=ui(s),s!==null){var r=c(s);if(r===null)s=null;else{var l=r.tag;if(l===13){if(s=u(r),s!==null)return s;s=null}else if(l===31){if(s=f(r),s!==null)return s;s=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;s=null}else r!==s&&(s=null)}}return ku=s,null}function _b(s){switch(s){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(Ne()){case Je:return 2;case et:return 8;case Ge:case Bt:return 32;case kt:return 268435456;default:return 32}default:return 32}}var Am=!1,Wa=null,Xa=null,Ka=null,Sl=new Map,jl=new Map,Ja=[],QR="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 Ob(s,r){switch(s){case"focusin":case"focusout":Wa=null;break;case"dragenter":case"dragleave":Xa=null;break;case"mouseover":case"mouseout":Ka=null;break;case"pointerover":case"pointerout":Sl.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":jl.delete(r.pointerId)}}function Nl(s,r,l,d,p,y){return s===null||s.nativeEvent!==y?(s={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:y,targetContainers:[p]},r!==null&&(r=di(r),r!==null&&Rb(r)),s):(s.eventSystemFlags|=d,r=s.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),s)}function eM(s,r,l,d,p){switch(r){case"focusin":return Wa=Nl(Wa,s,r,l,d,p),!0;case"dragenter":return Xa=Nl(Xa,s,r,l,d,p),!0;case"mouseover":return Ka=Nl(Ka,s,r,l,d,p),!0;case"pointerover":var y=p.pointerId;return Sl.set(y,Nl(Sl.get(y)||null,s,r,l,d,p)),!0;case"gotpointercapture":return y=p.pointerId,jl.set(y,Nl(jl.get(y)||null,s,r,l,d,p)),!0}return!1}function Ib(s){var r=ui(s.target);if(r!==null){var l=c(r);if(l!==null){if(r=l.tag,r===13){if(r=u(l),r!==null){s.blockedOn=r,yc(s.priority,function(){Mb(l)});return}}else if(r===31){if(r=f(l),r!==null){s.blockedOn=r,yc(s.priority,function(){Mb(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){s.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Eu(s){if(s.blockedOn!==null)return!1;for(var r=s.targetContainers;0<r.length;){var l=Cm(s.nativeEvent);if(l===null){l=s.nativeEvent;var d=new l.constructor(l.type,l);Tf=d,l.target.dispatchEvent(d),Tf=null}else return r=di(l),r!==null&&Rb(r),s.blockedOn=l,!1;r.shift()}return!0}function Db(s,r,l){Eu(s)&&l.delete(r)}function tM(){Am=!1,Wa!==null&&Eu(Wa)&&(Wa=null),Xa!==null&&Eu(Xa)&&(Xa=null),Ka!==null&&Eu(Ka)&&(Ka=null),Sl.forEach(Db),jl.forEach(Db)}function Cu(s,r){s.blockedOn===r&&(s.blockedOn=null,Am||(Am=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,tM)))}var Tu=null;function zb(s){Tu!==s&&(Tu=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Tu===s&&(Tu=null);for(var r=0;r<s.length;r+=3){var l=s[r],d=s[r+1],p=s[r+2];if(typeof d!="function"){if(Tm(d||l)===null)continue;break}var y=di(l);y!==null&&(s.splice(r,3),r-=3,Ch(y,{pending:!0,data:p,method:l.method,action:d},d,p))}}))}function qi(s){function r(H){return Cu(H,s)}Wa!==null&&Cu(Wa,s),Xa!==null&&Cu(Xa,s),Ka!==null&&Cu(Ka,s),Sl.forEach(r),jl.forEach(r);for(var l=0;l<Ja.length;l++){var d=Ja[l];d.blockedOn===s&&(d.blockedOn=null)}for(;0<Ja.length&&(l=Ja[0],l.blockedOn===null);)Ib(l),l.blockedOn===null&&Ja.shift();if(l=(s.ownerDocument||s).$$reactFormReplay,l!=null)for(d=0;d<l.length;d+=3){var p=l[d],y=l[d+1],E=p[Un]||null;if(typeof y=="function")E||zb(l);else if(E){var _=null;if(y&&y.hasAttribute("formAction")){if(p=y,E=y[Un]||null)_=E.formAction;else if(Tm(p)!==null)continue}else _=E.action;typeof _=="function"?l[d+1]=_:(l.splice(d,3),d-=3),zb(l)}}}function Lb(){function s(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(E){return p=E})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),d||setTimeout(l,20)}function l(){if(!d&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var d=!1,p=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){d=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function Rm(s){this._internalRoot=s}Au.prototype.render=Rm.prototype.render=function(s){var r=this._internalRoot;if(r===null)throw Error(a(409));var l=r.current,d=as();Tb(l,d,s,r,null,null)},Au.prototype.unmount=Rm.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var r=s.containerInfo;Tb(s.current,2,null,s,null,null),cu(),r[ci]=null}};function Au(s){this._internalRoot=s}Au.prototype.unstable_scheduleHydration=function(s){if(s){var r=cn();s={blockedOn:null,target:s,priority:r};for(var l=0;l<Ja.length&&r!==0&&r<Ja[l].priority;l++);Ja.splice(l,0,s),l===0&&Ib(s)}};var $b=t.version;if($b!=="19.2.3")throw Error(a(527,$b,"19.2.3"));P.findDOMNode=function(s){var r=s._reactInternals;if(r===void 0)throw typeof s.render=="function"?Error(a(188)):(s=Object.keys(s).join(","),Error(a(268,s)));return s=h(r),s=s!==null?g(s):null,s=s===null?null:s.stateNode,s};var nM={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ru.isDisabled&&Ru.supportsFiber)try{on=Ru.inject(nM),Ie=Ru}catch{}}return El.createRoot=function(s,r){if(!i(s))throw Error(a(299));var l=!1,d="",p=F0,y=q0,E=Y0;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(E=r.onRecoverableError)),r=Eb(s,1,!1,null,null,l,d,null,p,y,E,Lb),s[ci]=r.current,dm(s),new Rm(r)},El.hydrateRoot=function(s,r,l){if(!i(s))throw Error(a(299));var d=!1,p="",y=F0,E=q0,_=Y0,H=null;return l!=null&&(l.unstable_strictMode===!0&&(d=!0),l.identifierPrefix!==void 0&&(p=l.identifierPrefix),l.onUncaughtError!==void 0&&(y=l.onUncaughtError),l.onCaughtError!==void 0&&(E=l.onCaughtError),l.onRecoverableError!==void 0&&(_=l.onRecoverableError),l.formState!==void 0&&(H=l.formState)),r=Eb(s,1,!0,r,l??null,d,p,H,y,E,_,Lb),r.context=Cb(null),l=r.current,d=as(),d=qt(d),p=La(d),p.callback=null,$a(l,p,d),l=d,r.current.lanes=l,ze(r,l),Zs(r),s[ci]=r.current,dm(s),new Au(r)},El.version="19.2.3",El}var Gb;function fM(){if(Gb)return Om.exports;Gb=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(),Om.exports=dM(),Om.exports}var hM=fM();const Aj=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim();const mM=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const pM=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase());const Wb=e=>{const t=pM(e);return t.charAt(0).toUpperCase()+t.slice(1)};var gM={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 vM=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const yM=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:i="",children:c,iconNode:u,...f},m)=>v.createElement("svg",{ref:m,...gM,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:Aj("lucide",i),...!c&&!vM(f)&&{"aria-hidden":"true"},...f},[...u.map(([h,g])=>v.createElement(h,g)),...Array.isArray(c)?c:[c]]));const lc=(e,t)=>{const n=v.forwardRef(({className:a,...i},c)=>v.createElement(yM,{ref:c,iconNode:t,className:Aj(`lucide-${mM(Wb(e))}`,`lucide-${e}`,a),...i}));return n.displayName=Wb(e),n};const xM=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],bM=lc("chevron-down",xM);const wM=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],SM=lc("chevron-right",wM);const jM=[["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"}]],NM=lc("compass",jM);const kM=[["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"}]],EM=lc("sparkles",kM);const CM=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],TM=lc("terminal",CM);function AM(e){try{const t=localStorage.getItem(e);if(t)return JSON.parse(t)}catch{}}function RM(e,t){try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("hudson:saved",{detail:{key:e}}))}catch{}}const MM=()=>()=>{},_M=()=>!0,OM=()=>!1;function IM(){return v.useSyncExternalStore(MM,_M,OM)}function ka(e,t){const n=IM(),[a,i]=v.useState(t),c=v.useRef(!1);if(n&&!c.current){c.current=!0;const u=AM(e);u!==void 0&&i(u)}return v.useEffect(()=>{n&&RM(e,a)},[e,a,n]),[a,i]}var Rj="vercel.ai.error",DM=Symbol.for(Rj),Xb,Kb,ta=class Mj extends(Kb=Error,Xb=DM,Kb){constructor({name:t,message:n,cause:a}){super(n),this[Xb]=!0,this.name=t,this.cause=a}static isInstance(t){return Mj.hasMarker(t,Rj)}static hasMarker(t,n){const a=Symbol.for(n);return t!=null&&typeof t=="object"&&a in t&&typeof t[a]=="boolean"&&t[a]===!0}};function _j(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Oj="AI_InvalidArgumentError",Ij=`vercel.ai.error.${Oj}`,zM=Symbol.for(Ij),Jb,Qb,LM=class extends(Qb=ta,Jb=zM,Qb){constructor({message:e,cause:t,argument:n}){super({name:Oj,message:e,cause:t}),this[Jb]=!0,this.argument=n}static isInstance(e){return ta.hasMarker(e,Ij)}},Dj="AI_JSONParseError",zj=`vercel.ai.error.${Dj}`,$M=Symbol.for(zj),ew,tw,nw=class extends(tw=ta,ew=$M,tw){constructor({text:e,cause:t}){super({name:Dj,message:`JSON parsing failed: Text: ${e}.
|
|
10
|
-
Error message: ${_j(t)}`,cause:t}),this[ew]=!0,this.text=e}static isInstance(e){return ta.hasMarker(e,zj)}},Lj="AI_TypeValidationError",$j=`vercel.ai.error.${Lj}`,PM=Symbol.for($j),sw,aw,wo=class Dp extends(aw=ta,sw=PM,aw){constructor({value:t,cause:n,context:a}){let i="Type validation failed";if(a?.field&&(i+=` for ${a.field}`),a?.entityName||a?.entityId){i+=" (";const c=[];a.entityName&&c.push(a.entityName),a.entityId&&c.push(`id: "${a.entityId}"`),i+=c.join(", "),i+=")"}super({name:Lj,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
11
|
-
Error message: ${_j(n)}`,cause:n}),this[sw]=!0,this.value=t,this.context=a}static isInstance(t){return ta.hasMarker(t,$j)}static wrap({value:t,cause:n,context:a}){var i,c,u;return Dp.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===a?.field&&((c=n.context)==null?void 0:c.entityName)===a?.entityName&&((u=n.context)==null?void 0:u.entityId)===a?.entityId?n:new Dp({value:t,cause:n,context:a})}};function oe(e,t,n){function a(f,m){if(f._zod||Object.defineProperty(f,"_zod",{value:{def:m,constr:u,traits:new Set},enumerable:!1}),f._zod.traits.has(e))return;f._zod.traits.add(e),t(f,m);const h=u.prototype,g=Object.keys(h);for(let x=0;x<g.length;x++){const b=g[x];b in f||(f[b]=h[b].bind(f))}}const i=n?.Parent??Object;class c extends i{}Object.defineProperty(c,"name",{value:e});function u(f){var m;const h=n?.Parent?new c:this;a(h,f),(m=h._zod).deferred??(m.deferred=[]);for(const g of h._zod.deferred)g();return h}return Object.defineProperty(u,"init",{value:a}),Object.defineProperty(u,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(u,"name",{value:e}),u}class go extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Pj extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Uj={};function fr(e){return Uj}function Bj(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function zp(e,t){return typeof t=="bigint"?t.toString():t}function Kd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function zg(e){return e==null}function Lg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function UM(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let i=(a.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(a)){const m=a.match(/\d?e-(\d?)/);m?.[1]&&(i=Number.parseInt(m[1]))}const c=n>i?n:i,u=Number.parseInt(e.toFixed(c).replace(".","")),f=Number.parseInt(t.toFixed(c).replace(".",""));return u%f/10**c}const rw=Symbol("evaluating");function lt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==rw)return a===void 0&&(a=rw,a=n()),a},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function ii(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gr(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function iw(e){return JSON.stringify(e)}function BM(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Vj="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Gl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const VM=Kd(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function So(e){if(Gl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Gl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Hj(e){return So(e)?{...e}:Array.isArray(e)?[...e]:e}const HM=new Set(["string","number","symbol"]);function jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vr(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Ae(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 ZM(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const FM={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 qM(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const c=gr(e._zod.def,{get shape(){const u={};for(const f in t){if(!(f in n.shape))throw new Error(`Unrecognized key: "${f}"`);t[f]&&(u[f]=n.shape[f])}return ii(this,"shape",u),u},checks:[]});return vr(e,c)}function YM(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const c=gr(e._zod.def,{get shape(){const u={...e._zod.def.shape};for(const f in t){if(!(f in n.shape))throw new Error(`Unrecognized key: "${f}"`);t[f]&&delete u[f]}return ii(this,"shape",u),u},checks:[]});return vr(e,c)}function GM(e,t){if(!So(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const c=e._zod.def.shape;for(const u in t)if(Object.getOwnPropertyDescriptor(c,u)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=gr(e._zod.def,{get shape(){const c={...e._zod.def.shape,...t};return ii(this,"shape",c),c}});return vr(e,i)}function WM(e,t){if(!So(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=gr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return ii(this,"shape",a),a}});return vr(e,n)}function XM(e,t){const n=gr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return ii(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return vr(e,n)}function KM(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 u=gr(t._zod.def,{get shape(){const f=t._zod.def.shape,m={...f};if(n)for(const h in n){if(!(h in f))throw new Error(`Unrecognized key: "${h}"`);n[h]&&(m[h]=e?new e({type:"optional",innerType:f[h]}):f[h])}else for(const h in f)m[h]=e?new e({type:"optional",innerType:f[h]}):f[h];return ii(this,"shape",m),m},checks:[]});return vr(t,u)}function JM(e,t,n){const a=gr(t._zod.def,{get shape(){const i=t._zod.def.shape,c={...i};if(n)for(const u in n){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=new e({type:"nonoptional",innerType:i[u]}))}else for(const u in i)c[u]=new e({type:"nonoptional",innerType:i[u]});return ii(this,"shape",c),c}});return vr(t,a)}function oo(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 lo(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Mu(e){return typeof e=="string"?e:e?.message}function hr(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const i=Mu(e.inst?._zod.def?.error?.(e))??Mu(t?.error?.(e))??Mu(n.customError?.(e))??Mu(n.localeError?.(e))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function $g(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Wl(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const Zj=(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,zp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fj=oe("$ZodError",Zj),qj=oe("$ZodError",Zj,{Parent:Error});function QM(e,t=n=>n.message){const n={},a=[];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))):a.push(t(i));return{formErrors:a,fieldErrors:n}}function e2(e,t=n=>n.message){const n={_errors:[]},a=i=>{for(const c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>a({issues:u}));else if(c.code==="invalid_key")a({issues:c.issues});else if(c.code==="invalid_element")a({issues:c.issues});else if(c.path.length===0)n._errors.push(t(c));else{let u=n,f=0;for(;f<c.path.length;){const m=c.path[f];f===c.path.length-1?(u[m]=u[m]||{_errors:[]},u[m]._errors.push(t(c))):u[m]=u[m]||{_errors:[]},u=u[m],f++}}};return a(e),n}const Pg=e=>(t,n,a,i)=>{const c=a?Object.assign(a,{async:!1}):{async:!1},u=t._zod.run({value:n,issues:[]},c);if(u instanceof Promise)throw new go;if(u.issues.length){const f=new(i?.Err??e)(u.issues.map(m=>hr(m,c,fr())));throw Vj(f,i?.callee),f}return u.value},Ug=e=>async(t,n,a,i)=>{const c=a?Object.assign(a,{async:!0}):{async:!0};let u=t._zod.run({value:n,issues:[]},c);if(u instanceof Promise&&(u=await u),u.issues.length){const f=new(i?.Err??e)(u.issues.map(m=>hr(m,c,fr())));throw Vj(f,i?.callee),f}return u.value},Jd=e=>(t,n,a)=>{const i=a?{...a,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},i);if(c instanceof Promise)throw new go;return c.issues.length?{success:!1,error:new(e??Fj)(c.issues.map(u=>hr(u,i,fr())))}:{success:!0,data:c.value}},t2=Jd(qj),Qd=e=>async(t,n,a)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let c=t._zod.run({value:n,issues:[]},i);return c instanceof Promise&&(c=await c),c.issues.length?{success:!1,error:new e(c.issues.map(u=>hr(u,i,fr())))}:{success:!0,data:c.value}},n2=Qd(qj),s2=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Pg(e)(t,n,i)},a2=e=>(t,n,a)=>Pg(e)(t,n,a),r2=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Ug(e)(t,n,i)},i2=e=>async(t,n,a)=>Ug(e)(t,n,a),o2=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Jd(e)(t,n,i)},l2=e=>(t,n,a)=>Jd(e)(t,n,a),c2=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Qd(e)(t,n,i)},u2=e=>async(t,n,a)=>Qd(e)(t,n,a),d2=/^[cC][^\s-]{8,}$/,f2=/^[0-9a-z]+$/,h2=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,m2=/^[0-9a-vA-V]{20}$/,p2=/^[A-Za-z0-9]{27}$/,g2=/^[a-zA-Z0-9_-]{21}$/,v2=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,y2=/^([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})$/,ow=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)$/,x2=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,b2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function w2(){return new RegExp(b2,"u")}const S2=/^(?:(?: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])$/,j2=/^(([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}|:))$/,N2=/^((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])$/,k2=/^(([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])$/,E2=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yj=/^[A-Za-z0-9_-]*$/,C2=/^\+[1-9]\d{6,14}$/,Gj="(?:(?:\\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])))",T2=new RegExp(`^${Gj}$`);function Wj(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 A2(e){return new RegExp(`^${Wj(e)}$`)}function R2(e){const t=Wj({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${Gj}T(?:${a})$`)}const M2=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},_2=/^-?\d+$/,Xj=/^-?\d+(?:\.\d+)?$/,O2=/^(?:true|false)$/i,I2=/^null$/i,D2=/^[^A-Z]*$/,z2=/^[^a-z]*$/,Kn=oe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Kj={number:"number",bigint:"bigint",object:"date"},Jj=oe("$ZodCheckLessThan",(e,t)=>{Kn.init(e,t);const n=Kj[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,c=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<c&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qj=oe("$ZodCheckGreaterThan",(e,t)=>{Kn.init(e,t);const n=Kj[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,c=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>c&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),L2=oe("$ZodCheckMultipleOf",(e,t)=>{Kn.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.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):UM(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})}}),$2=oe("$ZodCheckNumberFormat",(e,t)=>{Kn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[i,c]=FM[t.format];e._zod.onattach.push(u=>{const f=u._zod.bag;f.format=t.format,f.minimum=i,f.maximum=c,n&&(f.pattern=_2)}),e._zod.check=u=>{const f=u.value;if(n){if(!Number.isInteger(f)){u.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:f,inst:e});return}if(!Number.isSafeInteger(f)){f>0?u.issues.push({input:f,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):u.issues.push({input:f,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}f<i&&u.issues.push({origin:"number",input:f,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),f>c&&u.issues.push({origin:"number",input:f,code:"too_big",maximum:c,inclusive:!0,inst:e,continue:!t.abort})}}),P2=oe("$ZodCheckMaxLength",(e,t)=>{var n;Kn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!zg(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const i=a.value;if(i.length<=t.maximum)return;const u=$g(i);a.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),U2=oe("$ZodCheckMinLength",(e,t)=>{var n;Kn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!zg(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const i=a.value;if(i.length>=t.minimum)return;const u=$g(i);a.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),B2=oe("$ZodCheckLengthEquals",(e,t)=>{var n;Kn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!zg(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=a=>{const i=a.value,c=i.length;if(c===t.length)return;const u=$g(i),f=c>t.length;a.issues.push({origin:u,...f?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),ef=oe("$ZodCheckStringFormat",(e,t)=>{var n,a;Kn.init(e,t),e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,t.pattern&&(c.patterns??(c.patterns=new Set),c.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})}):(a=e._zod).check??(a.check=()=>{})}),V2=oe("$ZodCheckRegex",(e,t)=>{ef.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})}}),H2=oe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=D2),ef.init(e,t)}),Z2=oe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=z2),ef.init(e,t)}),F2=oe("$ZodCheckIncludes",(e,t)=>{Kn.init(e,t);const n=jo(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(i=>{const c=i._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(a)}),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})}}),q2=oe("$ZodCheckStartsWith",(e,t)=>{Kn.init(e,t);const n=new RegExp(`^${jo(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),Y2=oe("$ZodCheckEndsWith",(e,t)=>{Kn.init(e,t);const n=new RegExp(`.*${jo(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),G2=oe("$ZodCheckOverwrite",(e,t)=>{Kn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class W2{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 a=t.split(`
|
|
12
|
-
`).filter(u=>u),i=Math.min(...a.map(u=>u.length-u.trimStart().length)),c=a.map(u=>u.slice(i)).map(u=>" ".repeat(this.indent*2)+u);for(const u of c)this.content.push(u)}compile(){const t=Function,n=this?.args,i=[...(this?.content??[""]).map(c=>` ${c}`)];return new t(...n,i.join(`
|
|
13
|
-
`))}}const X2={major:4,minor:3,patch:6},It=oe("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=X2;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const i of a)for(const c of i._zod.onattach)c(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(u,f,m)=>{let h=oo(u),g;for(const x of f){if(x._zod.def.when){if(!x._zod.def.when(u))continue}else if(h)continue;const b=u.issues.length,w=x._zod.check(u);if(w instanceof Promise&&m?.async===!1)throw new go;if(g||w instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await w,u.issues.length!==b&&(h||(h=oo(u,b)))});else{if(u.issues.length===b)continue;h||(h=oo(u,b))}}return g?g.then(()=>u):u},c=(u,f,m)=>{if(oo(u))return u.aborted=!0,u;const h=i(f,a,m);if(h instanceof Promise){if(m.async===!1)throw new go;return h.then(g=>e._zod.parse(g,m))}return e._zod.parse(h,m)};e._zod.run=(u,f)=>{if(f.skipChecks)return e._zod.parse(u,f);if(f.direction==="backward"){const h=e._zod.parse({value:u.value,issues:[]},{...f,skipChecks:!0});return h instanceof Promise?h.then(g=>c(g,u,f)):c(h,u,f)}const m=e._zod.parse(u,f);if(m instanceof Promise){if(f.async===!1)throw new go;return m.then(h=>i(h,a,f))}return i(m,a,f)}}lt(e,"~standard",()=>({validate:i=>{try{const c=t2(e,i);return c.success?{value:c.data}:{issues:c.error?.issues}}catch{return n2(e,i).then(u=>u.success?{value:u.data}:{issues:u.error?.issues})}},vendor:"zod",version:1}))}),Bg=oe("$ZodString",(e,t)=>{It.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??M2(e._zod.bag),e._zod.parse=(n,a)=>{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}}),Pt=oe("$ZodStringFormat",(e,t)=>{ef.init(e,t),Bg.init(e,t)}),K2=oe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=y2),Pt.init(e,t)}),J2=oe("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ow(a))}else t.pattern??(t.pattern=ow());Pt.init(e,t)}),Q2=oe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=x2),Pt.init(e,t)}),e_=oe("$ZodURL",(e,t)=>{Pt.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),i=new URL(a);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=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),t_=oe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=w2()),Pt.init(e,t)}),n_=oe("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=g2),Pt.init(e,t)}),s_=oe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=d2),Pt.init(e,t)}),a_=oe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=f2),Pt.init(e,t)}),r_=oe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=h2),Pt.init(e,t)}),i_=oe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=m2),Pt.init(e,t)}),o_=oe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=p2),Pt.init(e,t)}),l_=oe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=R2(t)),Pt.init(e,t)}),c_=oe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=T2),Pt.init(e,t)}),u_=oe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=A2(t)),Pt.init(e,t)}),d_=oe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=v2),Pt.init(e,t)}),f_=oe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=S2),Pt.init(e,t),e._zod.bag.format="ipv4"}),h_=oe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=j2),Pt.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})}}}),m_=oe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=N2),Pt.init(e,t)}),p_=oe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=k2),Pt.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[i,c]=a;if(!c)throw new Error;const u=Number(c);if(`${u}`!==c)throw new Error;if(u<0||u>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 eN(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const g_=oe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=E2),Pt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{eN(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function v_(e){if(!Yj.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return eN(n)}const y_=oe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Yj),Pt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{v_(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),x_=oe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=C2),Pt.init(e,t)});function b_(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const w_=oe("$ZodJWT",(e,t)=>{Pt.init(e,t),e._zod.check=n=>{b_(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),tN=oe("$ZodNumber",(e,t)=>{It.init(e,t),e._zod.pattern=e._zod.bag.pattern??Xj,e._zod.parse=(n,a)=>{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 c=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,...c?{received:c}:{}}),n}}),S_=oe("$ZodNumberFormat",(e,t)=>{$2.init(e,t),tN.init(e,t)}),j_=oe("$ZodBoolean",(e,t)=>{It.init(e,t),e._zod.pattern=O2,e._zod.parse=(n,a)=>{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}}),N_=oe("$ZodNull",(e,t)=>{It.init(e,t),e._zod.pattern=I2,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),k_=oe("$ZodUnknown",(e,t)=>{It.init(e,t),e._zod.parse=n=>n}),E_=oe("$ZodNever",(e,t)=>{It.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function lw(e,t,n){e.issues.length&&t.issues.push(...lo(n,e.issues)),t.value[n]=e.value}const C_=oe("$ZodArray",(e,t)=>{It.init(e,t),e._zod.parse=(n,a)=>{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 c=[];for(let u=0;u<i.length;u++){const f=i[u],m=t.element._zod.run({value:f,issues:[]},a);m instanceof Promise?c.push(m.then(h=>lw(h,n,u))):lw(m,n,u)}return c.length?Promise.all(c).then(()=>n):n}});function bd(e,t,n,a,i){if(e.issues.length){if(i&&!(n in a))return;t.issues.push(...lo(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function nN(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=ZM(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function sN(e,t,n,a,i,c){const u=[],f=i.keySet,m=i.catchall._zod,h=m.def.type,g=m.optout==="optional";for(const x in t){if(f.has(x))continue;if(h==="never"){u.push(x);continue}const b=m.run({value:t[x],issues:[]},a);b instanceof Promise?e.push(b.then(w=>bd(w,n,x,t,g))):bd(b,n,x,t,g)}return u.length&&n.issues.push({code:"unrecognized_keys",keys:u,input:t,inst:c}),e.length?Promise.all(e).then(()=>n):n}const T_=oe("$ZodObject",(e,t)=>{if(It.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const f=t.shape;Object.defineProperty(t,"shape",{get:()=>{const m={...f};return Object.defineProperty(t,"shape",{value:m}),m}})}const a=Kd(()=>nN(t));lt(e._zod,"propValues",()=>{const f=t.shape,m={};for(const h in f){const g=f[h]._zod;if(g.values){m[h]??(m[h]=new Set);for(const x of g.values)m[h].add(x)}}return m});const i=Gl,c=t.catchall;let u;e._zod.parse=(f,m)=>{u??(u=a.value);const h=f.value;if(!i(h))return f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f;f.value={};const g=[],x=u.shape;for(const b of u.keys){const w=x[b],j=w._zod.optout==="optional",N=w._zod.run({value:h[b],issues:[]},m);N instanceof Promise?g.push(N.then(T=>bd(T,f,b,h,j))):bd(N,f,b,h,j)}return c?sN(g,h,f,m,a.value,e):g.length?Promise.all(g).then(()=>f):f}}),A_=oe("$ZodObjectJIT",(e,t)=>{T_.init(e,t);const n=e._zod.parse,a=Kd(()=>nN(t)),i=b=>{const w=new W2(["shape","payload","ctx"]),j=a.value,N=S=>{const R=iw(S);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};w.write("const input = payload.value;");const T=Object.create(null);let k=0;for(const S of j.keys)T[S]=`key_${k++}`;w.write("const newResult = {};");for(const S of j.keys){const R=T[S],A=iw(S),O=b[S]?._zod?.optout==="optional";w.write(`const ${R} = ${N(S)};`),O?w.write(`
|
|
14
|
-
if (${R}.issues.length) {
|
|
15
|
-
if (${A} in input) {
|
|
16
|
-
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
17
|
-
...iss,
|
|
18
|
-
path: iss.path ? [${A}, ...iss.path] : [${A}]
|
|
19
|
-
})));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (${R}.value === undefined) {
|
|
24
|
-
if (${A} in input) {
|
|
25
|
-
newResult[${A}] = undefined;
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
newResult[${A}] = ${R}.value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
`):w.write(`
|
|
32
|
-
if (${R}.issues.length) {
|
|
33
|
-
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
34
|
-
...iss,
|
|
35
|
-
path: iss.path ? [${A}, ...iss.path] : [${A}]
|
|
36
|
-
})));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (${R}.value === undefined) {
|
|
40
|
-
if (${A} in input) {
|
|
41
|
-
newResult[${A}] = undefined;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
newResult[${A}] = ${R}.value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
`)}w.write("payload.value = newResult;"),w.write("return payload;");const C=w.compile();return(S,R)=>C(b,S,R)};let c;const u=Gl,f=!Uj.jitless,h=f&&VM.value,g=t.catchall;let x;e._zod.parse=(b,w)=>{x??(x=a.value);const j=b.value;return u(j)?f&&h&&w?.async===!1&&w.jitless!==!0?(c||(c=i(t.shape)),b=c(b,w),g?sN([],j,b,w,x,e):b):n(b,w):(b.issues.push({expected:"object",code:"invalid_type",input:j,inst:e}),b)}});function cw(e,t,n,a){for(const c of e)if(c.issues.length===0)return t.value=c.value,t;const i=e.filter(c=>!oo(c));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(c=>c.issues.map(u=>hr(u,a,fr())))}),t)}const aN=oe("$ZodUnion",(e,t)=>{It.init(e,t),lt(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),lt(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),lt(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),lt(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(c=>c._zod.pattern);return new RegExp(`^(${i.map(c=>Lg(c.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(i,c)=>{if(n)return a(i,c);let u=!1;const f=[];for(const m of t.options){const h=m._zod.run({value:i.value,issues:[]},c);if(h instanceof Promise)f.push(h),u=!0;else{if(h.issues.length===0)return h;f.push(h)}}return u?Promise.all(f).then(m=>cw(m,i,e,c)):cw(f,i,e,c)}}),R_=oe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,aN.init(e,t);const n=e._zod.parse;lt(e._zod,"propValues",()=>{const i={};for(const c of t.options){const u=c._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const[f,m]of Object.entries(u)){i[f]||(i[f]=new Set);for(const h of m)i[f].add(h)}}return i});const a=Kd(()=>{const i=t.options,c=new Map;for(const u of i){const f=u._zod.propValues?.[t.discriminator];if(!f||f.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const m of f){if(c.has(m))throw new Error(`Duplicate discriminator value "${String(m)}"`);c.set(m,u)}}return c});e._zod.parse=(i,c)=>{const u=i.value;if(!Gl(u))return i.issues.push({code:"invalid_type",expected:"object",input:u,inst:e}),i;const f=a.value.get(u?.[t.discriminator]);return f?f._zod.run(i,c):t.unionFallback?n(i,c):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:u,path:[t.discriminator],inst:e}),i)}}),M_=oe("$ZodIntersection",(e,t)=>{It.init(e,t),e._zod.parse=(n,a)=>{const i=n.value,c=t.left._zod.run({value:i,issues:[]},a),u=t.right._zod.run({value:i,issues:[]},a);return c instanceof Promise||u instanceof Promise?Promise.all([c,u]).then(([m,h])=>uw(n,m,h)):uw(n,c,u)}});function Lp(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(So(e)&&So(t)){const n=Object.keys(t),a=Object.keys(e).filter(c=>n.indexOf(c)!==-1),i={...e,...t};for(const c of a){const u=Lp(e[c],t[c]);if(!u.valid)return{valid:!1,mergeErrorPath:[c,...u.mergeErrorPath]};i[c]=u.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 a=0;a<e.length;a++){const i=e[a],c=t[a],u=Lp(i,c);if(!u.valid)return{valid:!1,mergeErrorPath:[a,...u.mergeErrorPath]};n.push(u.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function uw(e,t,n){const a=new Map;let i;for(const f of t.issues)if(f.code==="unrecognized_keys"){i??(i=f);for(const m of f.keys)a.has(m)||a.set(m,{}),a.get(m).l=!0}else e.issues.push(f);for(const f of n.issues)if(f.code==="unrecognized_keys")for(const m of f.keys)a.has(m)||a.set(m,{}),a.get(m).r=!0;else e.issues.push(f);const c=[...a].filter(([,f])=>f.l&&f.r).map(([f])=>f);if(c.length&&i&&e.issues.push({...i,keys:c}),oo(e))return e;const u=Lp(t.value,n.value);if(!u.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`);return e.value=u.data,e}const __=oe("$ZodRecord",(e,t)=>{It.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!So(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const c=[],u=t.keyType._zod.values;if(u){n.value={};const f=new Set;for(const h of u)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){f.add(typeof h=="number"?h.toString():h);const g=t.valueType._zod.run({value:i[h],issues:[]},a);g instanceof Promise?c.push(g.then(x=>{x.issues.length&&n.issues.push(...lo(h,x.issues)),n.value[h]=x.value})):(g.issues.length&&n.issues.push(...lo(h,g.issues)),n.value[h]=g.value)}let m;for(const h in i)f.has(h)||(m=m??[],m.push(h));m&&m.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:m})}else{n.value={};for(const f of Reflect.ownKeys(i)){if(f==="__proto__")continue;let m=t.keyType._zod.run({value:f,issues:[]},a);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof f=="string"&&Xj.test(f)&&m.issues.length){const x=t.keyType._zod.run({value:Number(f),issues:[]},a);if(x instanceof Promise)throw new Error("Async schemas not supported in object keys currently");x.issues.length===0&&(m=x)}if(m.issues.length){t.mode==="loose"?n.value[f]=i[f]:n.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map(x=>hr(x,a,fr())),input:f,path:[f],inst:e});continue}const g=t.valueType._zod.run({value:i[f],issues:[]},a);g instanceof Promise?c.push(g.then(x=>{x.issues.length&&n.issues.push(...lo(f,x.issues)),n.value[m.value]=x.value})):(g.issues.length&&n.issues.push(...lo(f,g.issues)),n.value[m.value]=g.value)}}return c.length?Promise.all(c).then(()=>n):n}}),O_=oe("$ZodEnum",(e,t)=>{It.init(e,t);const n=Bj(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(i=>HM.has(typeof i)).map(i=>typeof i=="string"?jo(i):i.toString()).join("|")})$`),e._zod.parse=(i,c)=>{const u=i.value;return a.has(u)||i.issues.push({code:"invalid_value",values:n,input:u,inst:e}),i}}),I_=oe("$ZodLiteral",(e,t)=>{if(It.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(a=>typeof a=="string"?jo(a):a?jo(a.toString()):String(a)).join("|")})$`),e._zod.parse=(a,i)=>{const c=a.value;return n.has(c)||a.issues.push({code:"invalid_value",values:t.values,input:c,inst:e}),a}}),D_=oe("$ZodTransform",(e,t)=>{It.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Pj(e.constructor.name);const i=t.transform(n.value,n);if(a.async)return(i instanceof Promise?i:Promise.resolve(i)).then(u=>(n.value=u,n));if(i instanceof Promise)throw new go;return n.value=i,n}});function dw(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const rN=oe("$ZodOptional",(e,t)=>{It.init(e,t),e._zod.optin="optional",e._zod.optout="optional",lt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),lt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Lg(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>dw(c,n.value)):dw(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),z_=oe("$ZodExactOptional",(e,t)=>{rN.init(e,t),lt(e._zod,"values",()=>t.innerType._zod.values),lt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),L_=oe("$ZodNullable",(e,t)=>{It.init(e,t),lt(e._zod,"optin",()=>t.innerType._zod.optin),lt(e._zod,"optout",()=>t.innerType._zod.optout),lt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Lg(n.source)}|null)$`):void 0}),lt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),$_=oe("$ZodDefault",(e,t)=>{It.init(e,t),e._zod.optin="optional",lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>fw(c,t)):fw(i,t)}});function fw(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const P_=oe("$ZodPrefault",(e,t)=>{It.init(e,t),e._zod.optin="optional",lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),U_=oe("$ZodNonOptional",(e,t)=>{It.init(e,t),lt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>hw(c,e)):hw(i,e)}});function hw(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 B_=oe("$ZodCatch",(e,t)=>{It.init(e,t),lt(e._zod,"optin",()=>t.innerType._zod.optin),lt(e._zod,"optout",()=>t.innerType._zod.optout),lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>(n.value=c.value,c.issues.length&&(n.value=t.catchValue({...n,error:{issues:c.issues.map(u=>hr(u,a,fr()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(c=>hr(c,a,fr()))},input:n.value}),n.issues=[]),n)}}),V_=oe("$ZodPipe",(e,t)=>{It.init(e,t),lt(e._zod,"values",()=>t.in._zod.values),lt(e._zod,"optin",()=>t.in._zod.optin),lt(e._zod,"optout",()=>t.out._zod.optout),lt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const c=t.out._zod.run(n,a);return c instanceof Promise?c.then(u=>_u(u,t.in,a)):_u(c,t.in,a)}const i=t.in._zod.run(n,a);return i instanceof Promise?i.then(c=>_u(c,t.out,a)):_u(i,t.out,a)}});function _u(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const H_=oe("$ZodReadonly",(e,t)=>{It.init(e,t),lt(e._zod,"propValues",()=>t.innerType._zod.propValues),lt(e._zod,"values",()=>t.innerType._zod.values),lt(e._zod,"optin",()=>t.innerType?._zod?.optin),lt(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(mw):mw(i)}});function mw(e){return e.value=Object.freeze(e.value),e}const Z_=oe("$ZodLazy",(e,t)=>{It.init(e,t),lt(e._zod,"innerType",()=>t.getter()),lt(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),lt(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),lt(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),lt(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,a)=>e._zod.innerType._zod.run(n,a)}),F_=oe("$ZodCustom",(e,t)=>{Kn.init(e,t),It.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,i=t.fn(a);if(i instanceof Promise)return i.then(c=>pw(c,n,a,e));pw(i,n,a,e)}});function pw(e,t,n,a){if(!e){const i={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(i.params=a._zod.def.params),t.issues.push(Wl(i))}}var gw;class q_{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.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 a={...this.get(n)??{}};delete a.id;const i={...a,...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 Y_(){return new q_}(gw=globalThis).__zod_globalRegistry??(gw.__zod_globalRegistry=Y_());const Rl=globalThis.__zod_globalRegistry;function G_(e,t){return new e({type:"string",...Ae(t)})}function W_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ae(t)})}function vw(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ae(t)})}function X_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ae(t)})}function K_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ae(t)})}function J_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ae(t)})}function Q_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ae(t)})}function eO(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ae(t)})}function tO(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ae(t)})}function nO(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ae(t)})}function sO(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ae(t)})}function aO(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ae(t)})}function rO(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ae(t)})}function iO(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ae(t)})}function oO(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ae(t)})}function lO(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ae(t)})}function cO(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ae(t)})}function uO(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ae(t)})}function dO(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ae(t)})}function fO(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ae(t)})}function hO(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ae(t)})}function mO(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ae(t)})}function pO(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ae(t)})}function gO(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ae(t)})}function vO(e,t){return new e({type:"string",format:"date",check:"string_format",...Ae(t)})}function yO(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ae(t)})}function xO(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ae(t)})}function bO(e,t){return new e({type:"number",checks:[],...Ae(t)})}function wO(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ae(t)})}function SO(e,t){return new e({type:"boolean",...Ae(t)})}function jO(e,t){return new e({type:"null",...Ae(t)})}function NO(e){return new e({type:"unknown"})}function kO(e,t){return new e({type:"never",...Ae(t)})}function yw(e,t){return new Jj({check:"less_than",...Ae(t),value:e,inclusive:!1})}function Lm(e,t){return new Jj({check:"less_than",...Ae(t),value:e,inclusive:!0})}function xw(e,t){return new Qj({check:"greater_than",...Ae(t),value:e,inclusive:!1})}function $m(e,t){return new Qj({check:"greater_than",...Ae(t),value:e,inclusive:!0})}function bw(e,t){return new L2({check:"multiple_of",...Ae(t),value:e})}function iN(e,t){return new P2({check:"max_length",...Ae(t),maximum:e})}function wd(e,t){return new U2({check:"min_length",...Ae(t),minimum:e})}function oN(e,t){return new B2({check:"length_equals",...Ae(t),length:e})}function EO(e,t){return new V2({check:"string_format",format:"regex",...Ae(t),pattern:e})}function CO(e){return new H2({check:"string_format",format:"lowercase",...Ae(e)})}function TO(e){return new Z2({check:"string_format",format:"uppercase",...Ae(e)})}function AO(e,t){return new F2({check:"string_format",format:"includes",...Ae(t),includes:e})}function RO(e,t){return new q2({check:"string_format",format:"starts_with",...Ae(t),prefix:e})}function MO(e,t){return new Y2({check:"string_format",format:"ends_with",...Ae(t),suffix:e})}function To(e){return new G2({check:"overwrite",tx:e})}function _O(e){return To(t=>t.normalize(e))}function OO(){return To(e=>e.trim())}function IO(){return To(e=>e.toLowerCase())}function DO(){return To(e=>e.toUpperCase())}function zO(){return To(e=>BM(e))}function LO(e,t,n){return new e({type:"array",element:t,...Ae(n)})}function $O(e,t,n){const a=Ae(n);return a.abort??(a.abort=!0),new e({type:"custom",check:"custom",fn:t,...a})}function PO(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ae(n)})}function UO(e){const t=BO(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Wl(a,n.value,t._zod.def));else{const i=a;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(Wl(i))}},e(n.value,n)));return t}function BO(e,t){const n=new Kn({check:"custom",...Ae(t)});return n._zod.check=e,n}function Sd(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??Rl,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 Ct(e,t,n={path:[],schemaPath:[]}){var a;const i=e._zod.def,c=t.seen.get(e);if(c)return c.count++,n.schemaPath.includes(e)&&(c.cycle=n.path),c.schema;const u={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,u);const f=e._zod.toJSONSchema?.();if(f)u.schema=f;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,u.schema,g);else{const b=u.schema,w=t.processors[i.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);w(e,t,b,g)}const x=e._zod.parent;x&&(u.ref||(u.ref=x),Ct(x,t,g),t.seen.get(x).isParent=!0)}const m=t.metadataRegistry.get(e);return m&&Object.assign(u.schema,m),t.io==="input"&&Dn(e)&&(delete u.schema.examples,delete u.schema.default),t.io==="input"&&u.schema._prefault&&((a=u.schema).default??(a.default=u.schema._prefault)),delete u.schema._prefault,t.seen.get(e).schema}function jd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const u of e.seen.entries()){const f=e.metadataRegistry.get(u[0])?.id;if(f){const m=a.get(f);if(m&&m!==u[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(f,u[0])}}const i=u=>{const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const x=e.external.registry.get(u[0])?.id,b=e.external.uri??(j=>j);if(x)return{ref:b(x)};const w=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=w,{defId:w,ref:`${b("__shared")}#/${f}/${w}`}}if(u[1]===n)return{ref:"#"};const h=`#/${f}/`,g=u[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:h+g}},c=u=>{if(u[1].schema.$ref)return;const f=u[1],{ref:m,defId:h}=i(u);f.def={...f.schema},h&&(f.defId=h);const g=f.schema;for(const x in g)delete g[x];g.$ref=m};if(e.cycles==="throw")for(const u of e.seen.entries()){const f=u[1];if(f.cycle)throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
|
|
48
|
-
|
|
49
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const f=u[1];if(t===u[0]){c(u);continue}if(e.external){const h=e.external.registry.get(u[0])?.id;if(t!==u[0]&&h){c(u);continue}}if(e.metadataRegistry.get(u[0])?.id){c(u);continue}if(f.cycle){c(u);continue}if(f.count>1&&e.reused==="ref"){c(u);continue}}}function Nd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=u=>{const f=e.seen.get(u);if(f.ref===null)return;const m=f.def??f.schema,h={...m},g=f.ref;if(f.ref=null,g){a(g);const b=e.seen.get(g),w=b.schema;if(w.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(m.allOf=m.allOf??[],m.allOf.push(w)):Object.assign(m,w),Object.assign(m,h),u._zod.parent===g)for(const N in m)N==="$ref"||N==="allOf"||N in h||delete m[N];if(w.$ref&&b.def)for(const N in m)N==="$ref"||N==="allOf"||N in b.def&&JSON.stringify(m[N])===JSON.stringify(b.def[N])&&delete m[N]}const x=u._zod.parent;if(x&&x!==g){a(x);const b=e.seen.get(x);if(b?.schema.$ref&&(m.$ref=b.schema.$ref,b.def))for(const w in m)w==="$ref"||w==="allOf"||w in b.def&&JSON.stringify(m[w])===JSON.stringify(b.def[w])&&delete m[w]}e.override({zodSchema:u,jsonSchema:m,path:f.path??[]})};for(const u of[...e.seen.entries()].reverse())a(u[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 u=e.external.registry.get(t)?.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(u)}Object.assign(i,n.def??n.schema);const c=e.external?.defs??{};for(const u of e.seen.entries()){const f=u[1];f.def&&f.defId&&(c[f.defId]=f.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?i.$defs=c:i.definitions=c);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:kd(t,"input",e.processors),output:kd(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Dn(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return Dn(a.element,n);if(a.type==="set")return Dn(a.valueType,n);if(a.type==="lazy")return Dn(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return Dn(a.innerType,n);if(a.type==="intersection")return Dn(a.left,n)||Dn(a.right,n);if(a.type==="record"||a.type==="map")return Dn(a.keyType,n)||Dn(a.valueType,n);if(a.type==="pipe")return Dn(a.in,n)||Dn(a.out,n);if(a.type==="object"){for(const i in a.shape)if(Dn(a.shape[i],n))return!0;return!1}if(a.type==="union"){for(const i of a.options)if(Dn(i,n))return!0;return!1}if(a.type==="tuple"){for(const i of a.items)if(Dn(i,n))return!0;return!!(a.rest&&Dn(a.rest,n))}return!1}const VO=(e,t={})=>n=>{const a=Sd({...n,processors:t});return Ct(e,a),jd(a,e),Nd(a,e)},kd=(e,t,n={})=>a=>{const{libraryOptions:i,target:c}=a??{},u=Sd({...i??{},target:c,io:t,processors:n});return Ct(e,u),jd(u,e),Nd(u,e)},HO={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},lN=(e,t,n,a)=>{const i=n;i.type="string";const{minimum:c,maximum:u,format:f,patterns:m,contentEncoding:h}=e._zod.bag;if(typeof c=="number"&&(i.minLength=c),typeof u=="number"&&(i.maxLength=u),f&&(i.format=HO[f]??f,i.format===""&&delete i.format,f==="time"&&delete i.format),h&&(i.contentEncoding=h),m&&m.size>0){const g=[...m];g.length===1?i.pattern=g[0].source:g.length>1&&(i.allOf=[...g.map(x=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:x.source}))])}},cN=(e,t,n,a)=>{const i=n,{minimum:c,maximum:u,format:f,multipleOf:m,exclusiveMaximum:h,exclusiveMinimum:g}=e._zod.bag;typeof f=="string"&&f.includes("int")?i.type="integer":i.type="number",typeof g=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=g,i.exclusiveMinimum=!0):i.exclusiveMinimum=g),typeof c=="number"&&(i.minimum=c,typeof g=="number"&&t.target!=="draft-04"&&(g>=c?delete i.minimum:delete i.exclusiveMinimum)),typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=h,i.exclusiveMaximum=!0):i.exclusiveMaximum=h),typeof u=="number"&&(i.maximum=u,typeof h=="number"&&t.target!=="draft-04"&&(h<=u?delete i.maximum:delete i.exclusiveMaximum)),typeof m=="number"&&(i.multipleOf=m)},uN=(e,t,n,a)=>{n.type="boolean"},ZO=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},FO=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},dN=(e,t,n,a)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},qO=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},YO=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},fN=(e,t,n,a)=>{n.not={}},GO=(e,t,n,a)=>{},hN=(e,t,n,a)=>{},WO=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},mN=(e,t,n,a)=>{const i=e._zod.def,c=Bj(i.entries);c.every(u=>typeof u=="number")&&(n.type="number"),c.every(u=>typeof u=="string")&&(n.type="string"),n.enum=c},pN=(e,t,n,a)=>{const i=e._zod.def,c=[];for(const u of i.values)if(u===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof u=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");c.push(Number(u))}else c.push(u);if(c.length!==0)if(c.length===1){const u=c[0];n.type=u===null?"null":typeof u,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[u]:n.const=u}else c.every(u=>typeof u=="number")&&(n.type="number"),c.every(u=>typeof u=="string")&&(n.type="string"),c.every(u=>typeof u=="boolean")&&(n.type="boolean"),c.every(u=>u===null)&&(n.type="null"),n.enum=c},XO=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},KO=(e,t,n,a)=>{const i=n,c=e._zod.pattern;if(!c)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=c.source},JO=(e,t,n,a)=>{const i=n,c={type:"string",format:"binary",contentEncoding:"binary"},{minimum:u,maximum:f,mime:m}=e._zod.bag;u!==void 0&&(c.minLength=u),f!==void 0&&(c.maxLength=f),m?m.length===1?(c.contentMediaType=m[0],Object.assign(i,c)):(Object.assign(i,c),i.anyOf=m.map(h=>({contentMediaType:h}))):Object.assign(i,c)},QO=(e,t,n,a)=>{n.type="boolean"},gN=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},eI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},vN=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},tI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},nI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},yN=(e,t,n,a)=>{const i=n,c=e._zod.def,{minimum:u,maximum:f}=e._zod.bag;typeof u=="number"&&(i.minItems=u),typeof f=="number"&&(i.maxItems=f),i.type="array",i.items=Ct(c.element,t,{...a,path:[...a.path,"items"]})},xN=(e,t,n,a)=>{const i=n,c=e._zod.def;i.type="object",i.properties={};const u=c.shape;for(const h in u)i.properties[h]=Ct(u[h],t,{...a,path:[...a.path,"properties",h]});const f=new Set(Object.keys(u)),m=new Set([...f].filter(h=>{const g=c.shape[h]._zod;return t.io==="input"?g.optin===void 0:g.optout===void 0}));m.size>0&&(i.required=Array.from(m)),c.catchall?._zod.def.type==="never"?i.additionalProperties=!1:c.catchall?c.catchall&&(i.additionalProperties=Ct(c.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},bN=(e,t,n,a)=>{const i=e._zod.def,c=i.inclusive===!1,u=i.options.map((f,m)=>Ct(f,t,{...a,path:[...a.path,c?"oneOf":"anyOf",m]}));c?n.oneOf=u:n.anyOf=u},wN=(e,t,n,a)=>{const i=e._zod.def,c=Ct(i.left,t,{...a,path:[...a.path,"allOf",0]}),u=Ct(i.right,t,{...a,path:[...a.path,"allOf",1]}),f=h=>"allOf"in h&&Object.keys(h).length===1,m=[...f(c)?c.allOf:[c],...f(u)?u.allOf:[u]];n.allOf=m},sI=(e,t,n,a)=>{const i=n,c=e._zod.def;i.type="array";const u=t.target==="draft-2020-12"?"prefixItems":"items",f=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",m=c.items.map((b,w)=>Ct(b,t,{...a,path:[...a.path,u,w]})),h=c.rest?Ct(c.rest,t,{...a,path:[...a.path,f,...t.target==="openapi-3.0"?[c.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=m,h&&(i.items=h)):t.target==="openapi-3.0"?(i.items={anyOf:m},h&&i.items.anyOf.push(h),i.minItems=m.length,h||(i.maxItems=m.length)):(i.items=m,h&&(i.additionalItems=h));const{minimum:g,maximum:x}=e._zod.bag;typeof g=="number"&&(i.minItems=g),typeof x=="number"&&(i.maxItems=x)},SN=(e,t,n,a)=>{const i=n,c=e._zod.def;i.type="object";const u=c.keyType,m=u._zod.bag?.patterns;if(c.mode==="loose"&&m&&m.size>0){const g=Ct(c.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});i.patternProperties={};for(const x of m)i.patternProperties[x.source]=g}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ct(c.keyType,t,{...a,path:[...a.path,"propertyNames"]})),i.additionalProperties=Ct(c.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const h=u._zod.values;if(h){const g=[...h].filter(x=>typeof x=="string"||typeof x=="number");g.length>0&&(i.required=g)}},jN=(e,t,n,a)=>{const i=e._zod.def,c=Ct(i.innerType,t,a),u=t.seen.get(e);t.target==="openapi-3.0"?(u.ref=i.innerType,n.nullable=!0):n.anyOf=[c,{type:"null"}]},NN=(e,t,n,a)=>{const i=e._zod.def;Ct(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType},kN=(e,t,n,a)=>{const i=e._zod.def;Ct(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},EN=(e,t,n,a)=>{const i=e._zod.def;Ct(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},CN=(e,t,n,a)=>{const i=e._zod.def;Ct(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType;let u;try{u=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=u},TN=(e,t,n,a)=>{const i=e._zod.def,c=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ct(c,t,a);const u=t.seen.get(e);u.ref=c},AN=(e,t,n,a)=>{const i=e._zod.def;Ct(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType,n.readOnly=!0},aI=(e,t,n,a)=>{const i=e._zod.def;Ct(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType},Vg=(e,t,n,a)=>{const i=e._zod.def;Ct(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType},RN=(e,t,n,a)=>{const i=e._zod.innerType;Ct(i,t,a);const c=t.seen.get(e);c.ref=i},ww={string:lN,number:cN,boolean:uN,bigint:ZO,symbol:FO,null:dN,undefined:qO,void:YO,never:fN,any:GO,unknown:hN,date:WO,enum:mN,literal:pN,nan:XO,template_literal:KO,file:JO,success:QO,custom:gN,function:eI,transform:vN,map:tI,set:nI,array:yN,object:xN,union:bN,intersection:wN,tuple:sI,record:SN,nullable:jN,nonoptional:NN,default:kN,prefault:EN,catch:CN,pipe:TN,readonly:AN,promise:aI,optional:Vg,lazy:RN};function rI(e,t){if("_idmap"in e){const a=e,i=Sd({...t,processors:ww}),c={};for(const m of a._idmap.entries()){const[h,g]=m;Ct(g,i)}const u={},f={registry:a,uri:t?.uri,defs:c};i.external=f;for(const m of a._idmap.entries()){const[h,g]=m;jd(i,g),u[h]=Nd(i,g)}if(Object.keys(c).length>0){const m=i.target==="draft-2020-12"?"$defs":"definitions";u.__shared={[m]:c}}return{schemas:u}}const n=Sd({...t,processors:ww});return Ct(e,n),jd(n,e),Nd(n,e)}const iI=oe("ZodISODateTime",(e,t)=>{l_.init(e,t),Ht.init(e,t)});function oI(e){return gO(iI,e)}const lI=oe("ZodISODate",(e,t)=>{c_.init(e,t),Ht.init(e,t)});function cI(e){return vO(lI,e)}const uI=oe("ZodISOTime",(e,t)=>{u_.init(e,t),Ht.init(e,t)});function dI(e){return yO(uI,e)}const fI=oe("ZodISODuration",(e,t)=>{d_.init(e,t),Ht.init(e,t)});function hI(e){return xO(fI,e)}const mI=(e,t)=>{Fj.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>e2(e,n)},flatten:{value:n=>QM(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,zp,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,zp,2)}},isEmpty:{get(){return e.issues.length===0}}})},Cs=oe("ZodError",mI,{Parent:Error}),pI=Pg(Cs),gI=Ug(Cs),vI=Jd(Cs),MN=Qd(Cs),yI=s2(Cs),xI=a2(Cs),bI=r2(Cs),wI=i2(Cs),SI=o2(Cs),jI=l2(Cs),NI=c2(Cs),kI=u2(Cs),Dt=oe("ZodType",(e,t)=>(It.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:kd(e,"input"),output:kd(e,"output")}}),e.toJSONSchema=VO(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(gr(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>vr(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>pI(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>vI(e,n,a),e.parseAsync=async(n,a)=>gI(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>MN(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>yI(e,n,a),e.decode=(n,a)=>xI(e,n,a),e.encodeAsync=async(n,a)=>bI(e,n,a),e.decodeAsync=async(n,a)=>wI(e,n,a),e.safeEncode=(n,a)=>SI(e,n,a),e.safeDecode=(n,a)=>jI(e,n,a),e.safeEncodeAsync=async(n,a)=>NI(e,n,a),e.safeDecodeAsync=async(n,a)=>kI(e,n,a),e.refine=(n,a)=>e.check(wD(n,a)),e.superRefine=n=>e.check(SD(n)),e.overwrite=n=>e.check(To(n)),e.optional=()=>Nw(e),e.exactOptional=()=>oD(e),e.nullable=()=>kw(e),e.nullish=()=>Nw(kw(e)),e.nonoptional=n=>hD(e,n),e.array=()=>Ao(e),e.or=n=>Pn([e,n]),e.and=n=>tD(e,n),e.transform=n=>Ew(e,rD(n)),e.default=n=>uD(e,n),e.prefault=n=>fD(e,n),e.catch=n=>pD(e,n),e.pipe=n=>Ew(e,n),e.readonly=()=>yD(e),e.describe=n=>{const a=e.clone();return Rl.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return Rl.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Rl.get(e);const a=e.clone();return Rl.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),_N=oe("_ZodString",(e,t)=>{Bg.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(a,i,c)=>lN(e,a,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(EO(...a)),e.includes=(...a)=>e.check(AO(...a)),e.startsWith=(...a)=>e.check(RO(...a)),e.endsWith=(...a)=>e.check(MO(...a)),e.min=(...a)=>e.check(wd(...a)),e.max=(...a)=>e.check(iN(...a)),e.length=(...a)=>e.check(oN(...a)),e.nonempty=(...a)=>e.check(wd(1,...a)),e.lowercase=a=>e.check(CO(a)),e.uppercase=a=>e.check(TO(a)),e.trim=()=>e.check(OO()),e.normalize=(...a)=>e.check(_O(...a)),e.toLowerCase=()=>e.check(IO()),e.toUpperCase=()=>e.check(DO()),e.slugify=()=>e.check(zO())}),EI=oe("ZodString",(e,t)=>{Bg.init(e,t),_N.init(e,t),e.email=n=>e.check(W_(CI,n)),e.url=n=>e.check(eO(TI,n)),e.jwt=n=>e.check(pO(HI,n)),e.emoji=n=>e.check(tO(AI,n)),e.guid=n=>e.check(vw(Sw,n)),e.uuid=n=>e.check(X_(Ou,n)),e.uuidv4=n=>e.check(K_(Ou,n)),e.uuidv6=n=>e.check(J_(Ou,n)),e.uuidv7=n=>e.check(Q_(Ou,n)),e.nanoid=n=>e.check(nO(RI,n)),e.guid=n=>e.check(vw(Sw,n)),e.cuid=n=>e.check(sO(MI,n)),e.cuid2=n=>e.check(aO(_I,n)),e.ulid=n=>e.check(rO(OI,n)),e.base64=n=>e.check(fO(UI,n)),e.base64url=n=>e.check(hO(BI,n)),e.xid=n=>e.check(iO(II,n)),e.ksuid=n=>e.check(oO(DI,n)),e.ipv4=n=>e.check(lO(zI,n)),e.ipv6=n=>e.check(cO(LI,n)),e.cidrv4=n=>e.check(uO($I,n)),e.cidrv6=n=>e.check(dO(PI,n)),e.e164=n=>e.check(mO(VI,n)),e.datetime=n=>e.check(oI(n)),e.date=n=>e.check(cI(n)),e.time=n=>e.check(dI(n)),e.duration=n=>e.check(hI(n))});function be(e){return G_(EI,e)}const Ht=oe("ZodStringFormat",(e,t)=>{Pt.init(e,t),_N.init(e,t)}),CI=oe("ZodEmail",(e,t)=>{Q2.init(e,t),Ht.init(e,t)}),Sw=oe("ZodGUID",(e,t)=>{K2.init(e,t),Ht.init(e,t)}),Ou=oe("ZodUUID",(e,t)=>{J2.init(e,t),Ht.init(e,t)}),TI=oe("ZodURL",(e,t)=>{e_.init(e,t),Ht.init(e,t)}),AI=oe("ZodEmoji",(e,t)=>{t_.init(e,t),Ht.init(e,t)}),RI=oe("ZodNanoID",(e,t)=>{n_.init(e,t),Ht.init(e,t)}),MI=oe("ZodCUID",(e,t)=>{s_.init(e,t),Ht.init(e,t)}),_I=oe("ZodCUID2",(e,t)=>{a_.init(e,t),Ht.init(e,t)}),OI=oe("ZodULID",(e,t)=>{r_.init(e,t),Ht.init(e,t)}),II=oe("ZodXID",(e,t)=>{i_.init(e,t),Ht.init(e,t)}),DI=oe("ZodKSUID",(e,t)=>{o_.init(e,t),Ht.init(e,t)}),zI=oe("ZodIPv4",(e,t)=>{f_.init(e,t),Ht.init(e,t)}),LI=oe("ZodIPv6",(e,t)=>{h_.init(e,t),Ht.init(e,t)}),$I=oe("ZodCIDRv4",(e,t)=>{m_.init(e,t),Ht.init(e,t)}),PI=oe("ZodCIDRv6",(e,t)=>{p_.init(e,t),Ht.init(e,t)}),UI=oe("ZodBase64",(e,t)=>{g_.init(e,t),Ht.init(e,t)}),BI=oe("ZodBase64URL",(e,t)=>{y_.init(e,t),Ht.init(e,t)}),VI=oe("ZodE164",(e,t)=>{x_.init(e,t),Ht.init(e,t)}),HI=oe("ZodJWT",(e,t)=>{w_.init(e,t),Ht.init(e,t)}),ON=oe("ZodNumber",(e,t)=>{tN.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(a,i,c)=>cN(e,a,i),e.gt=(a,i)=>e.check(xw(a,i)),e.gte=(a,i)=>e.check($m(a,i)),e.min=(a,i)=>e.check($m(a,i)),e.lt=(a,i)=>e.check(yw(a,i)),e.lte=(a,i)=>e.check(Lm(a,i)),e.max=(a,i)=>e.check(Lm(a,i)),e.int=a=>e.check(jw(a)),e.safe=a=>e.check(jw(a)),e.positive=a=>e.check(xw(0,a)),e.nonnegative=a=>e.check($m(0,a)),e.negative=a=>e.check(yw(0,a)),e.nonpositive=a=>e.check(Lm(0,a)),e.multipleOf=(a,i)=>e.check(bw(a,i)),e.step=(a,i)=>e.check(bw(a,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 ZI(e){return bO(ON,e)}const FI=oe("ZodNumberFormat",(e,t)=>{S_.init(e,t),ON.init(e,t)});function jw(e){return wO(FI,e)}const qI=oe("ZodBoolean",(e,t)=>{j_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>uN(e,n,a)});function zn(e){return SO(qI,e)}const YI=oe("ZodNull",(e,t)=>{N_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>dN(e,n,a)});function GI(e){return jO(YI,e)}const WI=oe("ZodUnknown",(e,t)=>{k_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>hN()});function Gs(){return NO(WI)}const XI=oe("ZodNever",(e,t)=>{E_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>fN(e,n,a)});function IN(e){return kO(XI,e)}const KI=oe("ZodArray",(e,t)=>{C_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>yN(e,n,a,i),e.element=t.element,e.min=(n,a)=>e.check(wd(n,a)),e.nonempty=n=>e.check(wd(1,n)),e.max=(n,a)=>e.check(iN(n,a)),e.length=(n,a)=>e.check(oN(n,a)),e.unwrap=()=>e.element});function Ao(e,t){return LO(KI,e,t)}const DN=oe("ZodObject",(e,t)=>{A_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>xN(e,n,a,i),lt(e,"shape",()=>t.shape),e.keyof=()=>LN(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Gs()}),e.loose=()=>e.clone({...e._zod.def,catchall:Gs()}),e.strict=()=>e.clone({...e._zod.def,catchall:IN()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>GM(e,n),e.safeExtend=n=>WM(e,n),e.merge=n=>XM(e,n),e.pick=n=>qM(e,n),e.omit=n=>YM(e,n),e.partial=(...n)=>KM($N,e,n[0]),e.required=(...n)=>JM(PN,e,n[0])});function Nt(e,t){const n={type:"object",shape:e??{},...Ae(t)};return new DN(n)}function Rt(e,t){return new DN({type:"object",shape:e,catchall:IN(),...Ae(t)})}const zN=oe("ZodUnion",(e,t)=>{aN.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>bN(e,n,a,i),e.options=t.options});function Pn(e,t){return new zN({type:"union",options:e,...Ae(t)})}const JI=oe("ZodDiscriminatedUnion",(e,t)=>{zN.init(e,t),R_.init(e,t)});function QI(e,t,n){return new JI({type:"union",options:t,discriminator:e,...Ae(n)})}const eD=oe("ZodIntersection",(e,t)=>{M_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>wN(e,n,a,i)});function tD(e,t){return new eD({type:"intersection",left:e,right:t})}const nD=oe("ZodRecord",(e,t)=>{__.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>SN(e,n,a,i),e.keyType=t.keyType,e.valueType=t.valueType});function Xl(e,t,n){return new nD({type:"record",keyType:e,valueType:t,...Ae(n)})}const $p=oe("ZodEnum",(e,t)=>{O_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(a,i,c)=>mN(e,a,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,i)=>{const c={};for(const u of a)if(n.has(u))c[u]=t.entries[u];else throw new Error(`Key ${u} not found in enum`);return new $p({...t,checks:[],...Ae(i),entries:c})},e.exclude=(a,i)=>{const c={...t.entries};for(const u of a)if(n.has(u))delete c[u];else throw new Error(`Key ${u} not found in enum`);return new $p({...t,checks:[],...Ae(i),entries:c})}});function LN(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new $p({type:"enum",entries:n,...Ae(t)})}const sD=oe("ZodLiteral",(e,t)=>{I_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>pN(e,n,a),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 $e(e,t){return new sD({type:"literal",values:Array.isArray(e)?e:[e],...Ae(t)})}const aD=oe("ZodTransform",(e,t)=>{D_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>vN(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Pj(e.constructor.name);n.addIssue=c=>{if(typeof c=="string")n.issues.push(Wl(c,n.value,t));else{const u=c;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=n.value),u.inst??(u.inst=e),n.issues.push(Wl(u))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(c=>(n.value=c,n)):(n.value=i,n)}});function rD(e){return new aD({type:"transform",transform:e})}const $N=oe("ZodOptional",(e,t)=>{rN.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Vg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Nw(e){return new $N({type:"optional",innerType:e})}const iD=oe("ZodExactOptional",(e,t)=>{z_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Vg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function oD(e){return new iD({type:"optional",innerType:e})}const lD=oe("ZodNullable",(e,t)=>{L_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>jN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function kw(e){return new lD({type:"nullable",innerType:e})}const cD=oe("ZodDefault",(e,t)=>{$_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>kN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function uD(e,t){return new cD({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Hj(t)}})}const dD=oe("ZodPrefault",(e,t)=>{P_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>EN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function fD(e,t){return new dD({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Hj(t)}})}const PN=oe("ZodNonOptional",(e,t)=>{U_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>NN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function hD(e,t){return new PN({type:"nonoptional",innerType:e,...Ae(t)})}const mD=oe("ZodCatch",(e,t)=>{B_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>CN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pD(e,t){return new mD({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const gD=oe("ZodPipe",(e,t)=>{V_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>TN(e,n,a,i),e.in=t.in,e.out=t.out});function Ew(e,t){return new gD({type:"pipe",in:e,out:t})}const vD=oe("ZodReadonly",(e,t)=>{H_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>AN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function yD(e){return new vD({type:"readonly",innerType:e})}const xD=oe("ZodLazy",(e,t)=>{Z_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>RN(e,n,a,i),e.unwrap=()=>e._zod.def.getter()});function bD(e){return new xD({type:"lazy",getter:e})}const Hg=oe("ZodCustom",(e,t)=>{F_.init(e,t),Dt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>gN(e,n)});function UN(e,t){return $O(Hg,e??(()=>!0),t)}function wD(e,t={}){return PO(Hg,e,t)}function SD(e){return UO(e)}function Ed(e,t={}){const n=new Hg({type:"custom",check:"custom",fn:a=>a instanceof e,abort:!0,...Ae(t)});return n._zod.bag.Class=e,n._zod.check=a=>{a.value instanceof e||a.issues.push({code:"invalid_type",expected:e.name,input:a.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Kl;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const c={};for(const u of i)c[u]=u;return c},e.getValidEnumValues=i=>{const c=e.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(const f of c)u[f]=i[f];return e.objectValues(u)},e.objectValues=i=>e.objectKeys(i).map(function(c){return i[c]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const c=[];for(const u in i)Object.prototype.hasOwnProperty.call(i,u)&&c.push(u);return c},e.find=(i,c)=>{for(const u of i)if(c(u))return u},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function a(i,c=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(c)}e.joinValues=a,e.jsonStringifyReplacer=(i,c)=>typeof c=="bigint"?c.toString():c})(Kl||(Kl={}));var Cw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Cw||(Cw={}));Kl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Kl.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 Cd extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};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(c){return c.message},a={_errors:[]},i=c=>{for(const u of c.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)a._errors.push(n(u));else{let f=a,m=0;for(;m<u.path.length;){const h=u.path[m];m===u.path.length-1?(f[h]=f[h]||{_errors:[]},f[h]._errors.push(n(u))):f[h]=f[h]||{_errors:[]},f=f[h],m++}}};return i(this),a}static assert(t){if(!(t instanceof Cd))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kl.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),a=[];for(const i of this.issues)if(i.path.length>0){const c=i.path[0];n[c]=n[c]||[],n[c].push(t(i))}else a.push(t(i));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}}Cd.create=e=>new Cd(e);var Tw;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Tw||(Tw={}));var We;(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"})(We||(We={}));class Aw 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 Rw=10,jD=13,Br=32;function Pm(e){}function ND(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=Pm,onError:n=Pm,onRetry:a=Pm,onComment:i}=e;let c="",u=!0,f,m="",h=0,g;function x(C){if(u){u=!1,b(C);return}const S=c===""?C:c+C;c=w(S)}function b(C){C.charCodeAt(0)===239&&C.charCodeAt(1)===187&&C.charCodeAt(2)===191&&(C=C.slice(3));const S=c===""?C:c+C;c=w(S)}function w(C){let S=0;if(C.indexOf("\r")===-1){let R=C.indexOf(`
|
|
50
|
-
`,S);for(;R!==-1;){if(S===R){h>0&&t({id:f,event:g,data:m}),f=void 0,m="",h=0,g=void 0,S=R+1,R=C.indexOf(`
|
|
51
|
-
`,S);continue}const A=C.charCodeAt(S);if(Mw(C,S,A)){const M=C.charCodeAt(S+5)===Br?S+6:S+5,O=C.slice(M,R);if(h===0&&C.charCodeAt(R+1)===Rw){t({id:f,event:g,data:O}),f=void 0,m="",g=void 0,S=R+2,R=C.indexOf(`
|
|
52
|
-
`,S);continue}m=h===0?O:`${m}
|
|
53
|
-
${O}`,h++}else _w(C,S,A)?g=C.slice(C.charCodeAt(S+6)===Br?S+7:S+6,R)||void 0:j(C,S,R);S=R+1,R=C.indexOf(`
|
|
54
|
-
`,S)}return C.slice(S)}for(;S<C.length;){const R=C.indexOf("\r",S),A=C.indexOf(`
|
|
55
|
-
`,S);let M=-1;if(R!==-1&&A!==-1?M=R<A?R:A:R!==-1?R===C.length-1?M=-1:M=R:A!==-1&&(M=A),M===-1)break;j(C,S,M),S=M+1,C.charCodeAt(S-1)===jD&&C.charCodeAt(S)===Rw&&S++}return C.slice(S)}function j(C,S,R){if(S===R){T();return}const A=C.charCodeAt(S);if(Mw(C,S,A)){const $=C.charCodeAt(S+5)===Br?S+6:S+5,L=C.slice($,R);m=h===0?L:`${m}
|
|
56
|
-
${L}`,h++;return}if(_w(C,S,A)){g=C.slice(C.charCodeAt(S+6)===Br?S+7:S+6,R)||void 0;return}if(A===105&&C.charCodeAt(S+1)===100&&C.charCodeAt(S+2)===58){const $=C.slice(C.charCodeAt(S+3)===Br?S+4:S+3,R);f=$.includes("\0")?void 0:$;return}if(A===58){if(i){const $=C.slice(S,R);i($.slice(C.charCodeAt(S+1)===Br?2:1))}return}const M=C.slice(S,R),O=M.indexOf(":");if(O===-1){N(M,"",M);return}const V=M.slice(0,O),F=M.charCodeAt(O+1)===Br?2:1,I=M.slice(O+F);N(V,I,M)}function N(C,S,R){switch(C){case"event":g=S||void 0;break;case"data":m=h===0?S:`${m}
|
|
57
|
-
${S}`,h++;break;case"id":f=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?a(parseInt(S,10)):n(new Aw(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:R}));break;default:n(new Aw(`Unknown field "${C.length>20?`${C.slice(0,20)}…`:C}"`,{type:"unknown-field",field:C,value:S,line:R}));break}}function T(){h>0&&t({id:f,event:g,data:m}),f=void 0,m="",h=0,g=void 0}function k(C={}){c&&C.consume&&j(c,0,c.length),u=!0,f=void 0,m="",h=0,g=void 0,c=""}return{feed:x,reset:k}}function Mw(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 _w(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 kD extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let i;super({start(c){i=ND({onEvent:u=>{c.enqueue(u)},onError(u){t==="terminate"?c.error(u):typeof t=="function"&&t(u)},onRetry:n,onComment:a})},transform(c){i.feed(c)}})}}var cc=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:a="-"}={})=>{const i=()=>{const c=n.length,u=new Array(t);for(let f=0;f<t;f++)u[f]=n[Math.random()*c|0];return u.join("")};if(e==null)return i;if(n.includes(a))throw new LM({argument:"separator",message:`The separator "${a}" must not be part of the alphabet "${n}".`});return()=>`${e}${a}${i()}`},ED=cc();function Yi(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,a)=>{t[a.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,a]of e)a!=null&&(t[n.toLowerCase()]=a)}return t}var CD=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,TD=/"(?: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 Ow(e){const t=JSON.parse(e);return t===null||typeof t!="object"||CD.test(e)===!1&&TD.test(e)===!1?t:AD(t)}function AD(e){let t=[e];for(;t.length;){const n=t;t=[];for(const a of n){if(Object.prototype.hasOwnProperty.call(a,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(a,"constructor")&&a.constructor!==null&&typeof a.constructor=="object"&&Object.prototype.hasOwnProperty.call(a.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in a){const c=a[i];c&&typeof c=="object"&&t.push(c)}}}return e}function RD(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Ow(e)}try{return Ow(e)}finally{Error.stackTraceLimit=t}}function Zg(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 a of Object.keys(n))n[a]=Vr(n[a])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Vr):Vr(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Vr)),e.allOf!=null&&(e.allOf=e.allOf.map(Vr)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Vr));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=Vr(t[n]);return e}function Vr(e){return typeof e=="boolean"?e:Zg(e)}var MD=Symbol("Let zodToJsonSchema decide on which parser to use"),Iw={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"},_D=e=>typeof e=="string"?{...Iw,name:e}:{...Iw,...e};function cs(){return{}}function OD(e,t){var n,a,i;const c={type:"array"};return(n=e.type)!=null&&n._def&&((i=(a=e.type)==null?void 0:a._def)==null?void 0:i.typeName)!==We.ZodAny&&(c.items=yt(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(c.minItems=e.minLength.value),e.maxLength&&(c.maxItems=e.maxLength.value),e.exactLength&&(c.minItems=e.exactLength.value,c.maxItems=e.exactLength.value),c}function ID(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 DD(){return{type:"boolean"}}function BN(e,t){return yt(e.type._def,t)}var zD=(e,t)=>yt(e.innerType._def,t);function VN(e,t,n){const a=n??t.dateStrategy;if(Array.isArray(a))return{anyOf:a.map((i,c)=>VN(e,t,i))};switch(a){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return LD(e)}}var LD=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 $D(e,t){return{...yt(e.innerType._def,t),default:e.defaultValue()}}function PD(e,t){return t.effectStrategy==="input"?yt(e.schema._def,t):cs()}function UD(e){return{type:"string",enum:Array.from(e.values)}}var BD=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function VD(e,t){const n=[yt(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),yt(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),a=[];return n.forEach(i=>{if(BD(i))a.push(...i.allOf);else{let c=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:u,...f}=i;c=f}a.push(c)}}),a.length?{allOf:a}:void 0}function HD(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 Um=void 0,Os={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:()=>(Um===void 0&&(Um=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Um),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 HN(e,t){const n={type:"string"};if(e.checks)for(const a of e.checks)switch(a.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,a.value):a.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,a.value):a.value;break;case"email":switch(t.emailStrategy){case"format:email":Is(n,"email",a.message,t);break;case"format:idn-email":Is(n,"idn-email",a.message,t);break;case"pattern:zod":In(n,Os.email,a.message,t);break}break;case"url":Is(n,"uri",a.message,t);break;case"uuid":Is(n,"uuid",a.message,t);break;case"regex":In(n,a.regex,a.message,t);break;case"cuid":In(n,Os.cuid,a.message,t);break;case"cuid2":In(n,Os.cuid2,a.message,t);break;case"startsWith":In(n,RegExp(`^${Bm(a.value,t)}`),a.message,t);break;case"endsWith":In(n,RegExp(`${Bm(a.value,t)}$`),a.message,t);break;case"datetime":Is(n,"date-time",a.message,t);break;case"date":Is(n,"date",a.message,t);break;case"time":Is(n,"time",a.message,t);break;case"duration":Is(n,"duration",a.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,a.value):a.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,a.value):a.value;break;case"includes":{In(n,RegExp(Bm(a.value,t)),a.message,t);break}case"ip":{a.version!=="v6"&&Is(n,"ipv4",a.message,t),a.version!=="v4"&&Is(n,"ipv6",a.message,t);break}case"base64url":In(n,Os.base64url,a.message,t);break;case"jwt":In(n,Os.jwt,a.message,t);break;case"cidr":{a.version!=="v6"&&In(n,Os.ipv4Cidr,a.message,t),a.version!=="v4"&&In(n,Os.ipv6Cidr,a.message,t);break}case"emoji":In(n,Os.emoji(),a.message,t);break;case"ulid":{In(n,Os.ulid,a.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Is(n,"binary",a.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{In(n,Os.base64,a.message,t);break}}break}case"nanoid":In(n,Os.nanoid,a.message,t)}return n}function Bm(e,t){return t.patternStrategy==="escape"?FD(e):e}var ZD=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function FD(e){let t="";for(let n=0;n<e.length;n++)ZD.has(e[n])||(t+="\\"),t+=e[n];return t}function Is(e,t,n,a){var i;e.format||(i=e.anyOf)!=null&&i.some(c=>c.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&a.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function In(e,t,n,a){var i;e.pattern||(i=e.allOf)!=null&&i.some(c=>c.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Dw(t,a),...n&&a.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Dw(t,a)}function Dw(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const a={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=a.i?e.source.toLowerCase():e.source;let c="",u=!1,f=!1,m=!1;for(let h=0;h<i.length;h++){if(u){c+=i[h],u=!1;continue}if(a.i){if(f){if(i[h].match(/[a-z]/)){m?(c+=i[h],c+=`${i[h-2]}-${i[h]}`.toUpperCase(),m=!1):i[h+1]==="-"&&((n=i[h+2])!=null&&n.match(/[a-z]/))?(c+=i[h],m=!0):c+=`${i[h]}${i[h].toUpperCase()}`;continue}}else if(i[h].match(/[a-z]/)){c+=`[${i[h]}${i[h].toUpperCase()}]`;continue}}if(a.m){if(i[h]==="^"){c+=`(^|(?<=[\r
|
|
58
|
-
]))`;continue}else if(i[h]==="$"){c+=`($|(?=[\r
|
|
59
|
-
]))`;continue}}if(a.s&&i[h]==="."){c+=f?`${i[h]}\r
|
|
60
|
-
`:`[${i[h]}\r
|
|
61
|
-
]`;continue}c+=i[h],i[h]==="\\"?u=!0:f&&i[h]==="]"?f=!1:!f&&i[h]==="["&&(f=!0)}try{new RegExp(c)}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 c}function ZN(e,t){var n,a,i,c,u,f;const m={type:"object",additionalProperties:(n=yt(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((a=e.keyType)==null?void 0:a._def.typeName)===We.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:h,...g}=HN(e.keyType._def,t);return{...m,propertyNames:g}}else{if(((c=e.keyType)==null?void 0:c._def.typeName)===We.ZodEnum)return{...m,propertyNames:{enum:e.keyType._def.values}};if(((u=e.keyType)==null?void 0:u._def.typeName)===We.ZodBranded&&e.keyType._def.type._def.typeName===We.ZodString&&((f=e.keyType._def.type._def.checks)!=null&&f.length)){const{type:h,...g}=BN(e.keyType._def,t);return{...m,propertyNames:g}}}return m}function qD(e,t){if(t.mapStrategy==="record")return ZN(e,t);const n=yt(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||cs(),a=yt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||cs();return{type:"array",maxItems:125,items:{type:"array",items:[n,a],minItems:2,maxItems:2}}}function YD(e){const t=e.values,a=Object.keys(e.values).filter(c=>typeof t[t[c]]!="number").map(c=>t[c]),i=Array.from(new Set(a.map(c=>typeof c)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:a}}function GD(){return{not:cs()}}function WD(){return{type:"null"}}var Pp={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function XD(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(a=>a._def.typeName in Pp&&(!a._def.checks||!a._def.checks.length))){const a=n.reduce((i,c)=>{const u=Pp[c._def.typeName];return u&&!i.includes(u)?[...i,u]:i},[]);return{type:a.length>1?a:a[0]}}else if(n.every(a=>a._def.typeName==="ZodLiteral"&&!a.description)){const a=n.reduce((i,c)=>{const u=typeof c._def.value;switch(u){case"string":case"number":case"boolean":return[...i,u];case"bigint":return[...i,"integer"];case"object":if(c._def.value===null)return[...i,"null"];default:return i}},[]);if(a.length===n.length){const i=a.filter((c,u,f)=>f.indexOf(c)===u);return{type:i.length>1?i:i[0],enum:n.reduce((c,u)=>c.includes(u._def.value)?c:[...c,u._def.value],[])}}}else if(n.every(a=>a._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((a,i)=>[...a,...i._def.values.filter(c=>!a.includes(c))],[])};return KD(e,t)}var KD=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((a,i)=>yt(a._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(a=>!!a&&(!t.strictUnions||typeof a=="object"&&Object.keys(a).length>0));return n.length?{anyOf:n}:void 0};function JD(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Pp[e.innerType._def.typeName],"null"]};const n=yt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function QD(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 e5(e,t){const n={type:"object",properties:{}},a=[],i=e.shape();for(const u in i){let f=i[u];if(f===void 0||f._def===void 0)continue;const m=n5(f),h=yt(f._def,{...t,currentPath:[...t.currentPath,"properties",u],propertyPath:[...t.currentPath,"properties",u]});h!==void 0&&(n.properties[u]=h,m||a.push(u))}a.length&&(n.required=a);const c=t5(e,t);return c!==void 0&&(n.additionalProperties=c),n}function t5(e,t){if(e.catchall._def.typeName!=="ZodNever")return yt(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 n5(e){try{return e.isOptional()}catch{return!0}}var s5=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return yt(e.innerType._def,t);const a=yt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:cs()},a]}:cs()},a5=(e,t)=>{if(t.pipeStrategy==="input")return yt(e.in._def,t);if(t.pipeStrategy==="output")return yt(e.out._def,t);const n=yt(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),a=yt(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,a].filter(i=>i!==void 0)}};function r5(e,t){return yt(e.type._def,t)}function i5(e,t){const a={type:"array",uniqueItems:!0,items:yt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(a.minItems=e.minSize.value),e.maxSize&&(a.maxItems=e.maxSize.value),a}function o5(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,a)=>yt(n._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((n,a)=>a===void 0?n:[...n,a],[]),additionalItems:yt(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,a)=>yt(n._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((n,a)=>a===void 0?n:[...n,a],[])}}function l5(){return{not:cs()}}function c5(){return cs()}var u5=(e,t)=>yt(e.innerType._def,t),d5=(e,t,n)=>{switch(t){case We.ZodString:return HN(e,n);case We.ZodNumber:return QD(e);case We.ZodObject:return e5(e,n);case We.ZodBigInt:return ID(e);case We.ZodBoolean:return DD();case We.ZodDate:return VN(e,n);case We.ZodUndefined:return l5();case We.ZodNull:return WD();case We.ZodArray:return OD(e,n);case We.ZodUnion:case We.ZodDiscriminatedUnion:return XD(e,n);case We.ZodIntersection:return VD(e,n);case We.ZodTuple:return o5(e,n);case We.ZodRecord:return ZN(e,n);case We.ZodLiteral:return HD(e);case We.ZodEnum:return UD(e);case We.ZodNativeEnum:return YD(e);case We.ZodNullable:return JD(e,n);case We.ZodOptional:return s5(e,n);case We.ZodMap:return qD(e,n);case We.ZodSet:return i5(e,n);case We.ZodLazy:return()=>e.getter()._def;case We.ZodPromise:return r5(e,n);case We.ZodNaN:case We.ZodNever:return GD();case We.ZodEffects:return PD(e,n);case We.ZodAny:return cs();case We.ZodUnknown:return c5();case We.ZodDefault:return $D(e,n);case We.ZodBranded:return BN(e,n);case We.ZodReadonly:return u5(e,n);case We.ZodCatch:return zD(e,n);case We.ZodPipeline:return a5(e,n);case We.ZodFunction:case We.ZodVoid:case We.ZodSymbol:return;default:return(a=>{})()}},f5=(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 yt(e,t,n=!1){var a;const i=t.seen.get(e);if(t.override){const m=(a=t.override)==null?void 0:a.call(t,e,t,i,n);if(m!==MD)return m}if(i&&!n){const m=h5(i,t);if(m!==void 0)return m}const c={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,c);const u=d5(e,e.typeName,t),f=typeof u=="function"?yt(u(),t):u;if(f&&m5(e,t,f),t.postProcess){const m=t.postProcess(f,e,t);return c.jsonSchema=f,m}return c.jsonSchema=f,f}var h5=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:f5(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,a)=>t.currentPath[a]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),cs()):t.$refStrategy==="seen"?cs():void 0}},m5=(e,t,n)=>(e.description&&(n.description=e.description),n),p5=e=>{const t=_D(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(([a,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,a],jsonSchema:void 0}]))}},g5=(e,t)=>{var n;const a=p5(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((h,[g,x])=>{var b;return{...h,[g]:(b=yt(x._def,{...a,currentPath:[...a.basePath,a.definitionPath,g]},!0))!=null?b:cs()}},{}):void 0;const c=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,u=(n=yt(e._def,c===void 0?a:{...a,currentPath:[...a.basePath,a.definitionPath,c]},!1))!=null?n:cs(),f=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;f!==void 0&&(u.title=f);const m=c===void 0?i?{...u,[a.definitionPath]:i}:u:{$ref:[...a.$refStrategy==="relative"?[]:a.basePath,a.definitionPath,c].join("/"),[a.definitionPath]:{...i,[c]:u}};return m.$schema="http://json-schema.org/draft-07/schema#",m},Up=Symbol.for("vercel.ai.schema");function v5(e){let t;return()=>(t==null&&(t=e()),t)}function tf(e,{validate:t}={}){return{[Up]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function y5(e){return typeof e=="object"&&e!==null&&Up in e&&e[Up]===!0&&"jsonSchema"in e&&"validate"in e}function Fg(e){return e==null?tf({properties:{},additionalProperties:!1}):y5(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?FN(e):x5(e):e()}function x5(e){return tf(()=>Zg(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 wo({value:t,cause:n.issues})}}})}function b5(e,t){var n;const a=(n=void 0)!=null?n:!1;return tf(()=>g5(e,{$refStrategy:a?"root":"none"}),{validate:async i=>{const c=await e.safeParseAsync(i);return c.success?{success:!0,value:c.data}:{success:!1,error:c.error}}})}function w5(e,t){var n;const a=(n=void 0)!=null?n:!1;return tf(()=>Zg(rI(e,{target:"draft-7",io:"input",reused:a?"ref":"inline"})),{validate:async i=>{const c=await MN(e,i);return c.success?{success:!0,value:c.data}:{success:!1,error:c.error}}})}function S5(e){return"_zod"in e}function FN(e,t){return S5(e)?w5(e):b5(e)}async function zw({value:e,schema:t,context:n}){const a=await Jl({value:e,schema:t,context:n});if(!a.success)throw wo.wrap({value:e,cause:a.error,context:n});return a.value}async function Jl({value:e,schema:t,context:n}){const a=Fg(t);try{if(a.validate==null)return{success:!0,value:e,rawValue:e};const i=await a.validate(e);return i.success?{success:!0,value:i.value,rawValue:e}:{success:!1,error:wo.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:wo.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function ei({text:e,schema:t}){try{const n=RD(e);return t==null?{success:!0,value:n,rawValue:n}:await Jl({value:n,schema:t})}catch(n){return{success:!1,error:nw.isInstance(n)?n:new nw({text:e,cause:n}),rawValue:void 0}}}function j5({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new kD).pipeThrough(new TransformStream({async transform({data:n},a){n!=="[DONE]"&&a.enqueue(await ei({text:n,schema:t}))}}))}async function nr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var N5=Object.defineProperty,k5=(e,t)=>{for(var n in t)N5(e,n,{get:t[n],enumerable:!0})},qN="AI_NoObjectGeneratedError",YN=`vercel.ai.error.${qN}`,E5=Symbol.for(YN),GN,lr=class extends ta{constructor({message:e="No object generated.",cause:t,text:n,response:a,usage:i,finishReason:c}){super({name:qN,message:e,cause:t}),this[GN]=!0,this.text=n,this.response=a,this.usage=i,this.finishReason=c}static isInstance(e){return ta.hasMarker(e,YN)}};GN=E5;var WN="AI_UIMessageStreamError",XN=`vercel.ai.error.${WN}`,C5=Symbol.for(XN),KN,Gi=class extends ta{constructor({chunkType:e,chunkId:t,message:n}){super({name:WN,message:n}),this[KN]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return ta.hasMarker(e,XN)}};KN=C5;var JN=Pn([be(),Ed(Uint8Array),Ed(ArrayBuffer),UN(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Ql=bD(()=>Pn([GI(),be(),ZI(),zn(),Xl(be(),Ql.optional()),Ao(Ql)])),at=Xl(be(),Xl(be(),Ql.optional())),QN=Nt({type:$e("text"),text:be(),providerOptions:at.optional()}),T5=Nt({type:$e("image"),image:Pn([JN,Ed(URL)]),mediaType:be().optional(),providerOptions:at.optional()}),ek=Nt({type:$e("file"),data:Pn([JN,Ed(URL)]),filename:be().optional(),mediaType:be(),providerOptions:at.optional()}),A5=Nt({type:$e("reasoning"),text:be(),providerOptions:at.optional()}),R5=Nt({type:$e("tool-call"),toolCallId:be(),toolName:be(),input:Gs(),providerOptions:at.optional(),providerExecuted:zn().optional()}),M5=QI("type",[Nt({type:$e("text"),value:be(),providerOptions:at.optional()}),Nt({type:$e("json"),value:Ql,providerOptions:at.optional()}),Nt({type:$e("execution-denied"),reason:be().optional(),providerOptions:at.optional()}),Nt({type:$e("error-text"),value:be(),providerOptions:at.optional()}),Nt({type:$e("error-json"),value:Ql,providerOptions:at.optional()}),Nt({type:$e("content"),value:Ao(Pn([Nt({type:$e("text"),text:be(),providerOptions:at.optional()}),Nt({type:$e("media"),data:be(),mediaType:be()}),Nt({type:$e("file-data"),data:be(),mediaType:be(),filename:be().optional(),providerOptions:at.optional()}),Nt({type:$e("file-url"),url:be(),providerOptions:at.optional()}),Nt({type:$e("file-id"),fileId:Pn([be(),Xl(be(),be())]),providerOptions:at.optional()}),Nt({type:$e("image-data"),data:be(),mediaType:be(),providerOptions:at.optional()}),Nt({type:$e("image-url"),url:be(),providerOptions:at.optional()}),Nt({type:$e("image-file-id"),fileId:Pn([be(),Xl(be(),be())]),providerOptions:at.optional()}),Nt({type:$e("custom"),providerOptions:at.optional()})]))})]),tk=Nt({type:$e("tool-result"),toolCallId:be(),toolName:be(),output:M5,providerOptions:at.optional()}),_5=Nt({type:$e("tool-approval-request"),approvalId:be(),toolCallId:be()}),O5=Nt({type:$e("tool-approval-response"),approvalId:be(),approved:zn(),reason:be().optional()}),I5=Nt({role:$e("system"),content:be(),providerOptions:at.optional()}),D5=Nt({role:$e("user"),content:Pn([be(),Ao(Pn([QN,T5,ek]))]),providerOptions:at.optional()}),z5=Nt({role:$e("assistant"),content:Pn([be(),Ao(Pn([QN,ek,A5,R5,tk,_5]))]),providerOptions:at.optional()}),L5=Nt({role:$e("tool"),content:Ao(Pn([tk,O5])),providerOptions:at.optional()});Pn([I5,D5,z5,L5]);function nk(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 a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const i=t[a];if(i===void 0)continue;const c=a in e?e[a]:void 0,u=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),f=c!=null&&typeof c=="object"&&!Array.isArray(c)&&!(c instanceof Date)&&!(c instanceof RegExp);u&&f?n[a]=nk(c,i):n[a]=i}return n}var $5={};k5($5,{array:()=>V5,choice:()=>H5,json:()=>Z5,object:()=>B5,text:()=>U5});function P5(e){const t=["ROOT"];let n=-1,a=null;function i(m,h,g){switch(m){case'"':{n=h,t.pop(),t.push(g),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=h,a=h,t.pop(),t.push(g),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=h,t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"{":{n=h,t.pop(),t.push(g),t.push("INSIDE_OBJECT_START");break}case"[":{n=h,t.pop(),t.push(g),t.push("INSIDE_ARRAY_START");break}}}function c(m,h){switch(m){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=h,t.pop();break}}}function u(m,h){switch(m){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=h,t.pop();break}}}for(let m=0;m<e.length;m++){const h=e[m];switch(t[t.length-1]){case"ROOT":i(h,m,"FINISH");break;case"INSIDE_OBJECT_START":{switch(h){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=m,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{h==='"'&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{h==='"'&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{h===":"&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(h,m,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{c(h,m);break}case"INSIDE_STRING":{switch(h){case'"':{t.pop(),n=m;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=m}break}case"INSIDE_ARRAY_START":{h==="]"?(n=m,t.pop()):(n=m,i(h,m,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(h){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=m,t.pop();break}default:{n=m;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(h,m,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=m;break}case"INSIDE_NUMBER":{switch(h){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=m;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,m),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(h,m);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(h,m);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,m);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const x=e.substring(a,m+1);!"false".startsWith(x)&&!"true".startsWith(x)&&!"null".startsWith(x)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?c(h,m):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,m)):n=m;break}}}let f=e.slice(0,n+1);for(let m=t.length-1;m>=0;m--)switch(t[m]){case"INSIDE_STRING":{f+='"';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":{f+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{f+="]";break}case"INSIDE_LITERAL":{const g=e.substring(a,e.length);"true".startsWith(g)?f+="true".slice(g.length):"false".startsWith(g)?f+="false".slice(g.length):"null".startsWith(g)&&(f+="null".slice(g.length))}}return f}async function uc(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await ei({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await ei({text:P5(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var U5=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),B5=({schema:e,name:t,description:n})=>{const a=Fg(e);return{name:"object",responseFormat:nr(a.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},c){const u=await ei({text:i});if(!u.success)throw new lr({message:"No object generated: could not parse the response.",cause:u.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});const f=await Jl({value:u.value,schema:a});if(!f.success)throw new lr({message:"No object generated: response did not match schema.",cause:f.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});return f.value},async parsePartialOutput({text:i}){const c=await uc(i);switch(c.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:c.value}}},createElementStreamTransform(){}}},V5=({element:e,name:t,description:n})=>{const a=Fg(e);return{name:"array",responseFormat:nr(a.jsonSchema).then(i=>{const{$schema:c,...u}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:u}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},c){const u=await ei({text:i});if(!u.success)throw new lr({message:"No object generated: could not parse the response.",cause:u.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});const f=u.value;if(f==null||typeof f!="object"||!("elements"in f)||!Array.isArray(f.elements))throw new lr({message:"No object generated: response did not match schema.",cause:new wo({value:f,cause:"response must be an object with an elements array"}),text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});for(const m of f.elements){const h=await Jl({value:m,schema:a});if(!h.success)throw new lr({message:"No object generated: response did not match schema.",cause:h.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason})}return f.elements},async parsePartialOutput({text:i}){const c=await uc(i);switch(c.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const u=c.value;if(u==null||typeof u!="object"||!("elements"in u)||!Array.isArray(u.elements))return;const f=c.state==="repaired-parse"&&u.elements.length>0?u.elements.slice(0,-1):u.elements,m=[];for(const h of f){const g=await Jl({value:h,schema:a});g.success&&m.push(g.value)}return{partial:m}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:c},u){if(c!=null)for(;i<c.length;i++)u.enqueue(c[i])}})}}},H5=({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:a},i){const c=await ei({text:a});if(!c.success)throw new lr({message:"No object generated: could not parse the response.",cause:c.error,text:a,response:i.response,usage:i.usage,finishReason:i.finishReason});const u=c.value;if(u==null||typeof u!="object"||!("result"in u)||typeof u.result!="string"||!e.includes(u.result))throw new lr({message:"No object generated: response did not match schema.",cause:new wo({value:u,cause:"response must be an object that contains a choice value."}),text:a,response:i.response,usage:i.usage,finishReason:i.finishReason});return u.result},async parsePartialOutput({text:a}){const i=await uc(a);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const c=i.value;if(c==null||typeof c!="object"||!("result"in c)||typeof c.result!="string")return;const u=e.filter(f=>f.startsWith(c.result));return i.state==="successful-parse"?u.includes(c.result)?{partial:c.result}:void 0:u.length===1?{partial:u[0]}:void 0}}},createElementStreamTransform(){}}),Z5=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},a){const i=await ei({text:n});if(!i.success)throw new lr({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:a.response,usage:a.usage,finishReason:a.finishReason});return i.value},async parsePartialOutput({text:n}){const a=await uc(n);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return a.value===void 0?void 0:{partial:a.value}}},createElementStreamTransform(){}});cc({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 F5=v5(()=>FN(Pn([Rt({type:$e("text-start"),id:be(),providerMetadata:at.optional()}),Rt({type:$e("text-delta"),id:be(),delta:be(),providerMetadata:at.optional()}),Rt({type:$e("text-end"),id:be(),providerMetadata:at.optional()}),Rt({type:$e("error"),errorText:be()}),Rt({type:$e("tool-input-start"),toolCallId:be(),toolName:be(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),title:be().optional()}),Rt({type:$e("tool-input-delta"),toolCallId:be(),inputTextDelta:be()}),Rt({type:$e("tool-input-available"),toolCallId:be(),toolName:be(),input:Gs(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),title:be().optional()}),Rt({type:$e("tool-input-error"),toolCallId:be(),toolName:be(),input:Gs(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),errorText:be(),title:be().optional()}),Rt({type:$e("tool-approval-request"),approvalId:be(),toolCallId:be()}),Rt({type:$e("tool-output-available"),toolCallId:be(),output:Gs(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),preliminary:zn().optional()}),Rt({type:$e("tool-output-error"),toolCallId:be(),errorText:be(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional()}),Rt({type:$e("tool-output-denied"),toolCallId:be()}),Rt({type:$e("reasoning-start"),id:be(),providerMetadata:at.optional()}),Rt({type:$e("reasoning-delta"),id:be(),delta:be(),providerMetadata:at.optional()}),Rt({type:$e("reasoning-end"),id:be(),providerMetadata:at.optional()}),Rt({type:$e("source-url"),sourceId:be(),url:be(),title:be().optional(),providerMetadata:at.optional()}),Rt({type:$e("source-document"),sourceId:be(),mediaType:be(),title:be(),filename:be().optional(),providerMetadata:at.optional()}),Rt({type:$e("file"),url:be(),mediaType:be(),providerMetadata:at.optional()}),Rt({type:UN(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:be().optional(),data:Gs(),transient:zn().optional()}),Rt({type:$e("start-step")}),Rt({type:$e("finish-step")}),Rt({type:$e("start"),messageId:be().optional(),messageMetadata:Gs().optional()}),Rt({type:$e("finish"),finishReason:LN(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Gs().optional()}),Rt({type:$e("abort"),reason:be().optional()}),Rt({type:$e("message-metadata"),messageMetadata:Gs()})])));function q5(e){return e.type.startsWith("data-")}function Bp(e){return e.type.startsWith("tool-")}function sk(e){return e.type==="dynamic-tool"}function ti(e){return Bp(e)||sk(e)}function Vp(e){return e.type.split("-").slice(1).join("-")}function ak(e){return sk(e)?e.toolName:Vp(e)}function Y5({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function G5({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:a,onError:i,onToolCall:c,onData:u}){return e.pipeThrough(new TransformStream({async transform(f,m){await a(async({state:h,write:g})=>{var x,b,w,j;function N(S){const A=h.message.parts.filter(ti).find(M=>M.toolCallId===S);if(A==null)throw new Gi({chunkType:"tool-invocation",chunkId:S,message:`No tool invocation found for tool call ID "${S}".`});return A}function T(S){var R;const A=h.message.parts.find(V=>Bp(V)&&V.toolCallId===S.toolCallId),M=S,O=A;if(A!=null){A.state=S.state,O.input=M.input,O.output=M.output,O.errorText=M.errorText,O.rawInput=M.rawInput,O.preliminary=M.preliminary,S.title!==void 0&&(O.title=S.title),O.providerExecuted=(R=M.providerExecuted)!=null?R:A.providerExecuted;const V=M.providerMetadata;if(V!=null)if(S.state==="output-available"||S.state==="output-error"){const F=A;F.resultProviderMetadata=V}else A.callProviderMetadata=V}else h.message.parts.push({type:`tool-${S.toolName}`,toolCallId:S.toolCallId,state:S.state,title:S.title,input:M.input,output:M.output,rawInput:M.rawInput,errorText:M.errorText,providerExecuted:M.providerExecuted,preliminary:M.preliminary,...M.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:M.providerMetadata}:{},...M.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:M.providerMetadata}:{}})}function k(S){var R,A;const M=h.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===S.toolCallId),O=S,V=M;if(M!=null){M.state=S.state,V.toolName=S.toolName,V.input=O.input,V.output=O.output,V.errorText=O.errorText,V.rawInput=(R=O.rawInput)!=null?R:V.rawInput,V.preliminary=O.preliminary,S.title!==void 0&&(V.title=S.title),V.providerExecuted=(A=O.providerExecuted)!=null?A:M.providerExecuted;const F=O.providerMetadata;if(F!=null)if(S.state==="output-available"||S.state==="output-error"){const I=M;I.resultProviderMetadata=F}else M.callProviderMetadata=F}else h.message.parts.push({type:"dynamic-tool",toolName:S.toolName,toolCallId:S.toolCallId,state:S.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,title:S.title,...O.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:O.providerMetadata}:{},...O.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:O.providerMetadata}:{}})}async function C(S){if(S!=null){const R=h.message.metadata!=null?nk(h.message.metadata,S):S;t!=null&&await zw({value:R,schema:t,context:{field:"message.metadata",entityId:h.message.id}}),h.message.metadata=R}}switch(f.type){case"text-start":{const S={type:"text",text:"",providerMetadata:f.providerMetadata,state:"streaming"};h.activeTextParts[f.id]=S,h.message.parts.push(S),g();break}case"text-delta":{const S=h.activeTextParts[f.id];if(S==null)throw new Gi({chunkType:"text-delta",chunkId:f.id,message:`Received text-delta for missing text part with ID "${f.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});S.text+=f.delta,S.providerMetadata=(x=f.providerMetadata)!=null?x:S.providerMetadata,g();break}case"text-end":{const S=h.activeTextParts[f.id];if(S==null)throw new Gi({chunkType:"text-end",chunkId:f.id,message:`Received text-end for missing text part with ID "${f.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});S.state="done",S.providerMetadata=(b=f.providerMetadata)!=null?b:S.providerMetadata,delete h.activeTextParts[f.id],g();break}case"reasoning-start":{const S={type:"reasoning",text:"",providerMetadata:f.providerMetadata,state:"streaming"};h.activeReasoningParts[f.id]=S,h.message.parts.push(S),g();break}case"reasoning-delta":{const S=h.activeReasoningParts[f.id];if(S==null)throw new Gi({chunkType:"reasoning-delta",chunkId:f.id,message:`Received reasoning-delta for missing reasoning part with ID "${f.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});S.text+=f.delta,S.providerMetadata=(w=f.providerMetadata)!=null?w:S.providerMetadata,g();break}case"reasoning-end":{const S=h.activeReasoningParts[f.id];if(S==null)throw new Gi({chunkType:"reasoning-end",chunkId:f.id,message:`Received reasoning-end for missing reasoning part with ID "${f.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});S.providerMetadata=(j=f.providerMetadata)!=null?j:S.providerMetadata,S.state="done",delete h.activeReasoningParts[f.id],g();break}case"file":{h.message.parts.push({type:"file",mediaType:f.mediaType,url:f.url,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}}),g();break}case"source-url":{h.message.parts.push({type:"source-url",sourceId:f.sourceId,url:f.url,title:f.title,providerMetadata:f.providerMetadata}),g();break}case"source-document":{h.message.parts.push({type:"source-document",sourceId:f.sourceId,mediaType:f.mediaType,title:f.title,filename:f.filename,providerMetadata:f.providerMetadata}),g();break}case"tool-input-start":{const S=h.message.parts.filter(Bp);h.partialToolCalls[f.toolCallId]={text:"",toolName:f.toolName,index:S.length,dynamic:f.dynamic,title:f.title},f.dynamic?k({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-streaming",input:void 0,providerExecuted:f.providerExecuted,title:f.title,providerMetadata:f.providerMetadata}):T({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-streaming",input:void 0,providerExecuted:f.providerExecuted,title:f.title,providerMetadata:f.providerMetadata}),g();break}case"tool-input-delta":{const S=h.partialToolCalls[f.toolCallId];if(S==null)throw new Gi({chunkType:"tool-input-delta",chunkId:f.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${f.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});S.text+=f.inputTextDelta;const{value:R}=await uc(S.text);S.dynamic?k({toolCallId:f.toolCallId,toolName:S.toolName,state:"input-streaming",input:R,title:S.title}):T({toolCallId:f.toolCallId,toolName:S.toolName,state:"input-streaming",input:R,title:S.title}),g();break}case"tool-input-available":{f.dynamic?k({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-available",input:f.input,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:f.title}):T({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-available",input:f.input,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:f.title}),g(),c&&!f.providerExecuted&&await c({toolCall:f});break}case"tool-input-error":{const S=h.message.parts.filter(ti).find(A=>A.toolCallId===f.toolCallId);(S!=null?S.type==="dynamic-tool":!!f.dynamic)?k({toolCallId:f.toolCallId,toolName:f.toolName,state:"output-error",input:f.input,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata}):T({toolCallId:f.toolCallId,toolName:f.toolName,state:"output-error",input:void 0,rawInput:f.input,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata}),g();break}case"tool-approval-request":{const S=N(f.toolCallId);S.state="approval-requested",S.approval={id:f.approvalId},g();break}case"tool-output-denied":{const S=N(f.toolCallId);S.state="output-denied",g();break}case"tool-output-available":{const S=N(f.toolCallId);S.type==="dynamic-tool"?k({toolCallId:f.toolCallId,toolName:S.toolName,state:"output-available",input:S.input,output:f.output,preliminary:f.preliminary,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:S.title}):T({toolCallId:f.toolCallId,toolName:Vp(S),state:"output-available",input:S.input,output:f.output,providerExecuted:f.providerExecuted,preliminary:f.preliminary,providerMetadata:f.providerMetadata,title:S.title}),g();break}case"tool-output-error":{const S=N(f.toolCallId);S.type==="dynamic-tool"?k({toolCallId:f.toolCallId,toolName:S.toolName,state:"output-error",input:S.input,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:S.title}):T({toolCallId:f.toolCallId,toolName:Vp(S),state:"output-error",input:S.input,rawInput:S.rawInput,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:S.title}),g();break}case"start-step":{h.message.parts.push({type:"step-start"});break}case"finish-step":{h.activeTextParts={},h.activeReasoningParts={};break}case"start":{f.messageId!=null&&(h.message.id=f.messageId),await C(f.messageMetadata),(f.messageId!=null||f.messageMetadata!=null)&&g();break}case"finish":{f.finishReason!=null&&(h.finishReason=f.finishReason),await C(f.messageMetadata),f.messageMetadata!=null&&g();break}case"message-metadata":{await C(f.messageMetadata),f.messageMetadata!=null&&g();break}case"error":{i?.(new Error(f.errorText));break}default:if(q5(f)){if(n?.[f.type]!=null){const A=h.message.parts.findIndex(O=>"id"in O&&"data"in O&&O.id===f.id&&O.type===f.type),M=A>=0?A:h.message.parts.length;await zw({value:f.data,schema:n[f.type],context:{field:`message.parts[${M}].data`,entityName:f.type,entityId:f.id}})}const S=f;if(S.transient){u?.(S);break}const R=S.id!=null?h.message.parts.find(A=>S.type===A.type&&S.id===A.id):void 0;R!=null?R.data=S.data:h.message.parts.push(S),u?.(S),g()}}m.enqueue(f)})}}))}async function W5({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:a}=await n.read();if(a)break}}catch(a){t?.(a)}finally{n.releaseLock()}}cc({prefix:"aitxt",size:24});cc({prefix:"aiobj",size:24});var X5=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(a){n(a)}}),this.processQueue()})}};cc({prefix:"aiobj",size:24});async function K5(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:a}=t,i=await new Promise((c,u)=>{const f=new FileReader;f.onload=m=>{var h;c((h=m.target)==null?void 0:h.result)},f.onerror=m=>u(m),f.readAsDataURL(t)});return{type:"file",mediaType:a,filename:n,url:i}}))}var J5=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:a,fetch:i,prepareSendMessagesRequest:c,prepareReconnectToStreamRequest:u}){this.api=e,this.credentials=t,this.headers=n,this.body=a,this.fetch=i,this.prepareSendMessagesRequest=c,this.prepareReconnectToStreamRequest=u}async sendMessages({abortSignal:e,...t}){var n,a,i,c,u;const f=await nr(this.body),m=await nr(this.headers),h=await nr(this.credentials),g={...Yi(m),...Yi(t.headers)},x=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...f,...t.body},headers:g,credentials:h,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),b=(a=x?.api)!=null?a:this.api,w=x?.headers!==void 0?Yi(x.headers):g,j=x?.body!==void 0?x.body:{...f,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},N=(i=x?.credentials)!=null?i:h,k=await((c=this.fetch)!=null?c:globalThis.fetch)(b,{method:"POST",headers:{"Content-Type":"application/json",...w},body:JSON.stringify(j),credentials:N,signal:e});if(!k.ok)throw new Error((u=await k.text())!=null?u:"Failed to fetch the chat response.");if(!k.body)throw new Error("The response body is empty.");return this.processResponseStream(k.body)}async reconnectToStream(e){var t,n,a,i,c;const u=await nr(this.body),f=await nr(this.headers),m=await nr(this.credentials),h={...Yi(f),...Yi(e.headers)},g=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...u,...e.body},headers:h,credentials:m,requestMetadata:e.metadata})),x=(n=g?.api)!=null?n:`${this.api}/${e.chatId}/stream`,b=g?.headers!==void 0?Yi(g.headers):h,w=(a=g?.credentials)!=null?a:m,N=await((i=this.fetch)!=null?i:globalThis.fetch)(x,{method:"GET",headers:b,credentials:w});if(N.status===204)return null;if(!N.ok)throw new Error((c=await N.text())!=null?c:"Failed to fetch the chat response.");if(!N.body)throw new Error("The response body is empty.");return this.processResponseStream(N.body)}},rk=class extends J5{constructor(e={}){super(e)}processResponseStream(e){return j5({stream:e,schema:F5}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},Q5=class{constructor({generateId:e=ED,id:t=e(),transport:n=new rk,messageMetadataSchema:a,dataPartSchemas:i,state:c,onError:u,onToolCall:f,onFinish:m,onData:h,sendAutomaticallyWhen:g}){this.activeResponse=void 0,this.jobExecutor=new X5,this.sendMessage=async(x,b)=>{var w,j,N,T;if(x==null){await this.makeRequest({trigger:"submit-message",messageId:(w=this.lastMessage)==null?void 0:w.id,...b});return}let k;if("text"in x||"files"in x?k={parts:[...Array.isArray(x.files)?x.files:await K5(x.files),..."text"in x&&x.text!=null?[{type:"text",text:x.text}]:[]]}:k=x,x.messageId!=null){const C=this.state.messages.findIndex(S=>S.id===x.messageId);if(C===-1)throw new Error(`message with id ${x.messageId} not found`);if(this.state.messages[C].role!=="user")throw new Error(`message with id ${x.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,C+1),this.state.replaceMessage(C,{...k,id:x.messageId,role:(j=k.role)!=null?j:"user",metadata:x.metadata})}else this.state.pushMessage({...k,id:(N=k.id)!=null?N:this.generateId(),role:(T=k.role)!=null?T:"user",metadata:x.metadata});await this.makeRequest({trigger:"submit-message",messageId:x.messageId,...b})},this.regenerate=async({messageId:x,...b}={})=>{const w=x==null?this.state.messages.length-1:this.state.messages.findIndex(j=>j.id===x);if(w===-1)throw new Error(`message ${x} 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:x,...b})},this.resumeStream=async(x={})=>{await this.makeRequest({trigger:"resume-stream",...x})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:x,approved:b,reason:w,options:j})=>this.jobExecutor.run(async()=>{const N=this.state.messages,T=N[N.length-1],k=C=>ti(C)&&C.state==="approval-requested"&&C.approval.id===x?{...C,state:"approval-responded",approval:{id:x,approved:b,reason:w}}:C;this.state.replaceMessage(N.length-1,{...T,parts:T.parts.map(k)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(k)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(C=>{var S;C&&this.makeRequest({trigger:"submit-message",messageId:(S=this.lastMessage)==null?void 0:S.id,...j})})}),this.addToolOutput=async({state:x="output-available",toolCallId:b,output:w,errorText:j,options:N})=>this.jobExecutor.run(async()=>{const T=this.state.messages,k=T[T.length-1],C=S=>ti(S)&&S.toolCallId===b?{...S,state:x,output:w,errorText:j}:S;this.state.replaceMessage(T.length-1,{...k,parts:k.parts.map(C)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(C)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(S=>{var R;S&&this.makeRequest({trigger:"submit-message",messageId:(R=this.lastMessage)==null?void 0:R.id,...N})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var x;this.status!=="streaming"&&this.status!=="submitted"||(x=this.activeResponse)!=null&&x.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=a,this.dataPartSchemas=i,this.state=c,this.onError=u,this.onToolCall=f,this.onFinish=m,this.onData=h,this.sendAutomaticallyWhen=g}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:a,messageId:i}){var c,u,f;let m;if(e==="resume-stream")try{const w=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:a});if(w==null)return;m=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 h=this.lastMessage;let g=!1,x=!1,b=!1;try{const w={state:Y5({lastMessage:this.state.snapshot(h),messageId:this.generateId()}),abortController:new AbortController};w.abortController.signal.addEventListener("abort",()=>{g=!0}),this.activeResponse=w;let j;e==="resume-stream"?j=m:j=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:w.abortController.signal,metadata:t,headers:n,body:a,trigger:e,messageId:i});const N=T=>this.jobExecutor.run(()=>T({state:w.state,write:()=>{var k;this.setStatus({status:"streaming"}),w.state.message.id===((k=this.lastMessage)==null?void 0:k.id)?this.state.replaceMessage(this.state.messages.length-1,w.state.message):this.state.pushMessage(w.state.message)}}));await W5({stream:G5({stream:j,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:N,onError:T=>{throw T}}),onError:T=>{throw T}}),this.setStatus({status:"ready"})}catch(w){if(g||w.name==="AbortError")return g=!0,this.setStatus({status:"ready"}),null;b=!0,w instanceof TypeError&&(w.message.toLowerCase().includes("fetch")||w.message.toLowerCase().includes("network"))&&(x=!0),this.onError&&w instanceof Error&&this.onError(w),this.setStatus({status:"error",error:w})}finally{try{(u=this.onFinish)==null||u.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:g,isDisconnect:x,isError:b,finishReason:(c=this.activeResponse)==null?void 0:c.state.finishReason})}catch(w){console.error(w)}this.activeResponse=void 0}!b&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(f=this.lastMessage)==null?void 0:f.id,metadata:t,headers:n,body:a})}},Vm,Lw;function ez(){if(Lw)return Vm;Lw=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let a,i=0;return function(...u){clearTimeout(a);const f=Date.now(),m=f-i,h=n-m;h<=0?(i=f,t.apply(this,u)):a=setTimeout(()=>{i=Date.now(),t.apply(this,u)},h)}}return Vm=e,Vm}var tz=ez();const nz=Ej(tz);var ik=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Mt=(e,t,n)=>(ik(e,t,"read from private field"),n?n.call(e):t.get(e)),qs=(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)},er=(e,t,n,a)=>(ik(e,t,"write to private field"),t.set(e,n),n);function sz(e,t){return t!=null?nz(e,t):e}var ws,ad,rd,Ml,_l,Ol,to,Hp,Zp,az=class{constructor(e=[]){qs(this,ws,void 0),qs(this,ad,"ready"),qs(this,rd,void 0),qs(this,Ml,new Set),qs(this,_l,new Set),qs(this,Ol,new Set),this.pushMessage=t=>{er(this,ws,Mt(this,ws).concat(t)),Mt(this,to).call(this)},this.popMessage=()=>{er(this,ws,Mt(this,ws).slice(0,-1)),Mt(this,to).call(this)},this.replaceMessage=(t,n)=>{er(this,ws,[...Mt(this,ws).slice(0,t),this.snapshot(n),...Mt(this,ws).slice(t+1)]),Mt(this,to).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const a=n?sz(t,n):t;return Mt(this,Ml).add(a),()=>{Mt(this,Ml).delete(a)}},this["~registerStatusCallback"]=t=>(Mt(this,_l).add(t),()=>{Mt(this,_l).delete(t)}),this["~registerErrorCallback"]=t=>(Mt(this,Ol).add(t),()=>{Mt(this,Ol).delete(t)}),qs(this,to,()=>{Mt(this,Ml).forEach(t=>t())}),qs(this,Hp,()=>{Mt(this,_l).forEach(t=>t())}),qs(this,Zp,()=>{Mt(this,Ol).forEach(t=>t())}),er(this,ws,e)}get status(){return Mt(this,ad)}set status(e){er(this,ad,e),Mt(this,Hp).call(this)}get error(){return Mt(this,rd)}set error(e){er(this,rd,e),Mt(this,Zp).call(this)}get messages(){return Mt(this,ws)}set messages(e){er(this,ws,[...e]),Mt(this,to).call(this)}};ws=new WeakMap;ad=new WeakMap;rd=new WeakMap;Ml=new WeakMap;_l=new WeakMap;Ol=new WeakMap;to=new WeakMap;Hp=new WeakMap;Zp=new WeakMap;var no,$w=class extends Q5{constructor({messages:e,...t}){const n=new az(e);super({...t,state:n}),qs(this,no,void 0),this["~registerMessagesCallback"]=(a,i)=>Mt(this,no)["~registerMessagesCallback"](a,i),this["~registerStatusCallback"]=a=>Mt(this,no)["~registerStatusCallback"](a),this["~registerErrorCallback"]=a=>Mt(this,no)["~registerErrorCallback"](a),er(this,no,n)}};no=new WeakMap;function rz({experimental_throttle:e,resume:t=!1,...n}={}){const a=v.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(a.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:b=>{var w,j;return(j=(w=a.current).onToolCall)==null?void 0:j.call(w,b)},onData:b=>{var w,j;return(j=(w=a.current).onData)==null?void 0:j.call(w,b)},onFinish:b=>{var w,j;return(j=(w=a.current).onFinish)==null?void 0:j.call(w,b)},onError:b=>{var w,j;return(j=(w=a.current).onError)==null?void 0:j.call(w,b)},sendAutomaticallyWhen:b=>{var w,j,N;return(N=(j=(w=a.current).sendAutomaticallyWhen)==null?void 0:j.call(w,b))!=null?N:!1}},c=v.useRef("chat"in n?n.chat:new $w(i));("chat"in n&&n.chat!==c.current||"id"in n&&c.current.id!==n.id)&&(c.current="chat"in n?n.chat:new $w(i));const f=v.useCallback(b=>c.current["~registerMessagesCallback"](b,e),[e,c.current.id]),m=v.useSyncExternalStore(f,()=>c.current.messages,()=>c.current.messages),h=v.useSyncExternalStore(c.current["~registerStatusCallback"],()=>c.current.status,()=>c.current.status),g=v.useSyncExternalStore(c.current["~registerErrorCallback"],()=>c.current.error,()=>c.current.error),x=v.useCallback(b=>{typeof b=="function"&&(b=b(c.current.messages)),c.current.messages=b},[c]);return v.useEffect(()=>{t&&c.current.resumeStream()},[t,c]),{id:c.current.id,messages:m,setMessages:x,sendMessage:c.current.sendMessage,regenerate:c.current.regenerate,clearError:c.current.clearError,stop:c.current.stop,error:g,resumeStream:c.current.resumeStream,status:h,addToolResult:c.current.addToolOutput,addToolOutput:c.current.addToolOutput,addToolApprovalResponse:c.current.addToolApprovalResponse}}function iz(e){const t={};for(const n of e.attachmentsRef.current??[])if(e.activeAttachmentsRef.current.has(n.label)){const a=n.content();a!==null&&(t[n.label.toLowerCase()]=a)}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 oz(e,t){e.current?.(t)}function lz(e,t){e.current?.(t)}function cz(e){const t=new Set;for(const n of e??[])if(n.role==="assistant")for(const a of n.parts??[])a&&ti(a)&&t.add(a.toolCallId);return t}function uz({toolset:e,chatId:t,initialMessages:n,context:a,onToolCall:i,mode:c,attachments:u,provider:f,model:m,sessionId:h,onSessionIdChange:g,onFinish:x,onError:b}){const w=v.useRef(i),j=v.useRef(x),N=v.useRef(b),T=v.useRef(h??crypto.randomUUID()),[k,C]=v.useState(new Set),S=v.useCallback(B=>{C(G=>{const X=new Set(G);return X.has(B)?X.delete(B):X.add(B),X})},[]),[R]=ka("hudson.settings",{}),A=c??R.aiMode??"api",M=v.useRef(k),O=v.useRef(u),V=v.useRef(a),F=v.useRef(e),I=v.useRef(A),$=v.useRef(f),L=v.useRef(m);v.useEffect(()=>{w.current=i},[i]),v.useEffect(()=>{j.current=x},[x]),v.useEffect(()=>{N.current=b},[b]),v.useEffect(()=>{h&&h!==T.current&&(T.current=h)},[h]),v.useEffect(()=>{g?.(T.current)},[g]),v.useEffect(()=>{M.current=k},[k]),v.useEffect(()=>{O.current=u},[u]),v.useEffect(()=>{V.current=a},[a]),v.useEffect(()=>{F.current=e},[e]),v.useEffect(()=>{I.current=A},[A]),v.useEffect(()=>{$.current=f},[f]),v.useEffect(()=>{L.current=m},[m]);const U=v.useMemo(()=>new rk({api:"/api/ai/chat",body:()=>iz({activeAttachmentsRef:M,attachmentsRef:O,contextRef:V,toolsetRef:F,modeRef:I,sessionIdRef:T,providerRef:$,modelRef:L})}),[]),Y=rz({id:t,messages:n,transport:U,onFinish:B=>oz(j,B),onError:B=>lz(N,B)}),K=v.useRef(cz(n)),D=v.useCallback(()=>{const B=crypto.randomUUID();T.current=B,g?.(B),K.current.clear(),Y.setMessages([])},[Y,g]),{messages:P}=Y;return v.useEffect(()=>{if(w.current){for(const B of P)if(B.role==="assistant"){for(const G of B.parts??[])if(G&&ti(G)){if("state"in G&&G.state==="input-streaming")continue;const X=G.toolCallId;if(!K.current.has(X)){K.current.add(X);const z=ak(G);w.current?.(z,G.input??{})}}}}},[P]),{messages:P,sendMessage:Y.sendMessage,stop:Y.stop,status:Y.status,setMessages:Y.setMessages,clearChat:D,error:Y.error,mode:A,attachments:u??[],activeAttachments:k,toggleAttachment:S}}function dz({app:e,commands:t,state:n,provider:a,model:i,onFinish:c}){const u=v.useMemo(()=>(e.intents??[]).map(h=>({commandId:h.commandId,title:h.title,description:h.description,category:h.category,keywords:h.keywords,shortcut:h.shortcut,dangerous:h.dangerous,params:h.params?.map(g=>({name:g.name,description:g.description,type:g.type,optional:g.optional,enum:g.enum}))})),[e.intents]),f=v.useMemo(()=>({appId:e.id,appName:e.name,appDescription:e.description,intents:u,state:n}),[e.id,e.name,e.description,u,n]),m=v.useCallback(h=>{const g=t.find(x=>x.id===h);if(!g){console.warn(`[useAssistant] no command for id "${h}"`);return}g.action()},[t]);return uz({toolset:"intents",context:f,provider:a,model:i,onFinish:c,onToolCall:(h,g)=>{if(h!=="dispatch")return;const x=g.commandId;typeof x=="string"&&m(x)}})}function fz(e={}){const{url:t="ws://localhost:3600",systemPrompt:n,cwd:a,workspaceFiles:i,autoConnect:c=!1,sessionKey:u,orphanTTL:f,backend:m,tmuxSession:h,agent:g,provider:x,model:b}=e,w=u?`hudson.relay.${u}`:null,j=()=>{if(!w)return null;try{return localStorage.getItem(w)}catch{return null}},N=de=>{if(w)try{de?localStorage.setItem(w,de):localStorage.removeItem(w)}catch{}},[T,k]=v.useState("disconnected"),[C,S]=v.useState(null),[R,A]=v.useState(null),[M,O]=v.useState(null),[V,F]=v.useState(a||"~"),I=v.useRef(null),$=v.useRef(null),L=v.useRef({cols:80,rows:24}),U=v.useRef(!1),Y=v.useRef(V);Y.current=V;const K=v.useRef(j()),D=v.useRef(null),P=v.useCallback(de=>{const fe=I.current;fe&&fe.readyState===WebSocket.OPEN&&fe.send(JSON.stringify(de))},[]),B=v.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null);const de=I.current;de&&(de.close(),I.current=null),U.current=!1,k("disconnected")},[]),G=v.useCallback(()=>{const de=Y.current;return{type:"session:init",cols:L.current.cols,rows:L.current.rows,...n?{systemPrompt:n}:{},...de?{cwd:de}:{},...i?{workspaceFiles:i}:{},...f?{orphanTTL:f}:{},...m?{backend:m}:{},...h?{tmuxSession:h}:{},...g?{agent:g}:{},...x?{provider:x}:{},...b?{model:b}:{}}},[n,i,f,m,h,g,x,b]),X=v.useCallback(()=>{U.current||(U.current=!0,K.current?P({type:"session:reconnect",sessionId:K.current,cols:L.current.cols,rows:L.current.rows}):P(G()))},[P,G]),z=v.useCallback(async()=>{I.current&&(I.current.close(),I.current=null),U.current=!1,k("connecting"),A(null),O(null);const de=t.replace(/^ws(s?):\/\//,"http$1://");try{await fetch(`${de}/health`,{signal:AbortSignal.timeout(2e3)})}catch{k("error"),A("Relay service is not running");return}const fe=new WebSocket(t);I.current=fe,fe.onopen=()=>{X()},fe.onmessage=xe=>{try{const Re=JSON.parse(xe.data);switch(Re.type){case"session:ready":K.current=Re.sessionId,N(Re.sessionId),S(Re.sessionId),k("connected"),A(null),O(null);break;case"session:expired":{K.current=null,N(null),U.current=!1,D.current&&D.current("\x1B[2J\x1B[H"),P(G()),U.current=!0;break}case"session:error":k("error"),A(Re.error||"Session failed to start");break;case"terminal:data":D.current&&Re.data&&D.current(Re.data);break;case"session:exit":K.current=null,N(null),S(null),O(Re.exitCode??null),Re.exitCode!==0?(k("error"),A(Re.reason||`Process exited with code ${Re.exitCode}`)):k("disconnected");break;case"session:detached":K.current=null,N(null),S(null);break}}catch{}},fe.onclose=()=>{I.current=null,U.current=!1,k(xe=>xe==="error"?xe:"disconnected")},fe.onerror=()=>{k("error"),A("Could not connect to relay")}},[t,X,P,n,i]),Z=v.useCallback(de=>{P({type:"terminal:input",data:de})},[P]),J=v.useCallback(de=>{P({type:"terminal:input",data:de+"\r"})},[P]),Q=v.useCallback((de,fe)=>{L.current={cols:de,rows:fe},U.current&&P({type:"terminal:resize",cols:de,rows:fe})},[P]),pe=v.useCallback(de=>{D.current=de},[]);v.useEffect(()=>(c&&z(),()=>{B()}),[]);const re=v.useCallback(()=>{if(B(),K.current=null,S(null),u)try{sessionStorage.removeItem(`hudson.relay.${u}`)}catch{}A(null),O(null),setTimeout(()=>z(),200)},[B,z,u]);return{status:T,sessionId:C,error:R,exitCode:M,cwd:V,setCwd:F,onData:pe,sendInput:Z,sendLine:J,resize:Q,connect:z,disconnect:B,restart:re}}const ok=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim();const hz=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const mz=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase());const Pw=e=>{const t=mz(e);return t.charAt(0).toUpperCase()+t.slice(1)};var pz={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 gz=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const vz=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:i="",children:c,iconNode:u,...f},m)=>v.createElement("svg",{ref:m,...pz,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:ok("lucide",i),...!c&&!gz(f)&&{"aria-hidden":"true"},...f},[...u.map(([h,g])=>v.createElement(h,g)),...Array.isArray(c)?c:[c]]));const Zt=(e,t)=>{const n=v.forwardRef(({className:a,...i},c)=>v.createElement(vz,{ref:c,iconNode:t,className:ok(`lucide-${hz(Pw(e))}`,`lucide-${e}`,a),...i}));return n.displayName=Pw(e),n};const yz=[["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"}]],xz=Zt("circle-alert",yz);const bz=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],wz=Zt("clock",bz);const Sz=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],jz=Zt("corner-down-left",Sz);const Nz=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Uw=Zt("loader-circle",Nz);const kz=[["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"}]],Ez=Zt("map",kz);const Cz=[["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"}]],lk=Zt("maximize-2",Cz);const Tz=[["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"}]],Az=Zt("mic",Tz);const Rz=[["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"}]],Mz=Zt("minimize-2",Rz);const _z=[["path",{d:"M5 12h14",key:"1ays0h"}]],Oz=Zt("minus",_z);const Iz=[["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"}]],Dz=Zt("panel-left-close",Iz);const zz=[["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"}]],Lz=Zt("panel-left-open",zz);const $z=[["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"}]],Pz=Zt("panel-right-close",$z);const Uz=[["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"}]],Bz=Zt("panel-right-open",Uz);const Vz=[["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"}]],Hz=Zt("paperclip",Vz);const Zz=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Fz=Zt("plus",Zz);const qz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qg=Zt("search",qz);const Yz=[["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"}]],Gz=Zt("sparkles",Yz);const Wz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ck=Zt("square",Wz);const Xz=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Kz=Zt("terminal",Xz);const Jz=[["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"}]],Qz=Zt("trash-2",Jz);const e4=[["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"}]],t4=Zt("volume-2",e4);const n4=[["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"}]],s4=Zt("volume-x",n4);const a4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],uk=Zt("x",a4);function r4({chat:e,placeholder:t="Ask AI...",inputExtras:n,inputStatus:a,inputValue:i,onInputChange:c}){const{messages:u,sendMessage:f,stop:m,status:h,clearChat:g,error:x,attachments:b,activeAttachments:w,toggleAttachment:j}=e,[N,T]=v.useState(""),k=i!==void 0,C=k?i:N,S=I=>{k?c?.(I):T(I)},R=v.useRef(null),A=v.useRef(null),M=h==="streaming"||h==="submitted",O=b.length>0;v.useEffect(()=>{const I=R.current;I&&(I.scrollTop=I.scrollHeight)},[u]),v.useEffect(()=>{A.current?.focus()},[]);const V=I=>{I.preventDefault();const $=C.trim();!$||M||(S(""),f({text:$}))},F=I=>{I.stopPropagation(),I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),V(I))};return o.jsxs("div",{className:"flex flex-col h-full font-mono text-[12px]",children:[o.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto frame-scrollbar p-3 space-y-3",children:[u.length===0&&o.jsx("div",{className:"text-neutral-500 text-center py-8 select-none",children:t}),u.map(I=>o.jsx("div",{className:`flex ${I.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 whitespace-pre-wrap break-words leading-relaxed ${I.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:(I.parts??[]).map(($,L)=>{if(!$)return null;if($.type==="text")return o.jsx("span",{children:$.text},L);if(ti($)){const U=ak($),Y=Object.entries($.input??{}).map(([K,D])=>`${K}: ${JSON.stringify(D)}`).join(", ");return o.jsxs("div",{className:"text-[11px] text-cyan-400/70 mt-1 font-mono",children:[o.jsx("span",{className:"text-neutral-500",children:"↳ "}),U,"(",Y,")"]},L)}return null})})},I.id)),M&&u[u.length-1]?.role!=="assistant"&&o.jsx("div",{className:"flex justify-start",children:o.jsx("div",{className:"bg-neutral-800/50 border border-neutral-700/50 rounded-lg px-3 py-2 text-neutral-400",children:o.jsx("span",{className:"animate-pulse",children:"..."})})})]}),x&&o.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:[o.jsx(xz,{size:12}),o.jsx("span",{className:"truncate",children:x.message||"An error occurred"})]}),o.jsxs("div",{className:"px-3 py-2.5 border-t border-neutral-700/50 bg-neutral-900/50",children:[O&&o.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[o.jsx(Hz,{size:11,className:"text-neutral-500 shrink-0"}),b.map(I=>{const $=w.has(I.label);return o.jsx("button",{type:"button",onClick:()=>j(I.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:I.label},I.label)}),w.size>0&&o.jsx("span",{className:"text-[10px] text-neutral-600 ml-1",children:"attached"})]}),o.jsxs("form",{onSubmit:V,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:[u.length>0&&o.jsx("button",{type:"button",onClick:()=>g(),className:"p-1 rounded text-neutral-500 hover:text-neutral-300 hover:bg-neutral-700 transition-colors",title:"Clear",children:o.jsx(Qz,{size:12})}),o.jsx("input",{ref:A,type:"text",value:C,onChange:I=>S(I.target.value),onKeyDown:F,placeholder:t,className:"flex-1 bg-transparent outline-none text-neutral-100 placeholder:text-neutral-500 caret-emerald-400",disabled:M}),M?o.jsx("button",{type:"button",onClick:()=>m(),className:"p-1.5 rounded text-amber-400 hover:bg-amber-900/20 transition-colors",title:"Stop",children:o.jsx(ck,{size:12})}):o.jsx("button",{type:"submit",disabled:!C.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 i4="modulepreload",o4=function(e){return"/"+e},Bw={},id=function(t,n,a){let i=Promise.resolve();if(n&&n.length>0){let m=function(h){return Promise.all(h.map(g=>Promise.resolve(g).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),f=u?.nonce||u?.getAttribute("nonce");i=m(n.map(h=>{if(h=o4(h),h in Bw)return;Bw[h]=!0;const g=h.endsWith(".css"),x=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${x}`))return;const b=document.createElement("link");if(b.rel=g?"stylesheet":i4,g||(b.as="script"),b.crossOrigin="",b.href=h,f&&b.setAttribute("nonce",f),document.head.appendChild(b),g)return new Promise((w,j)=>{b.addEventListener("load",w),b.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function c(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return i.then(u=>{for(const f of u||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})},l4={titleBarInset:0,dragRegionProps:{},onInteractiveMouseDown:void 0,isSSR:!0,apiBaseUrl:"",serviceApiUrl:""},c4=v.createContext(l4);function nf(){return v.useContext(c4)}const u4={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"},d4=`
|
|
66
|
-
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
67
|
-
.xterm.focus, .xterm:focus { outline: none; }
|
|
68
|
-
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
69
|
-
.xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
|
|
70
|
-
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
71
|
-
.xterm .composition-view.active { display: block; }
|
|
72
|
-
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
73
|
-
.xterm .xterm-screen { position: relative; }
|
|
74
|
-
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
75
|
-
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
76
|
-
.xterm.enable-mouse-events { cursor: default; }
|
|
77
|
-
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
78
|
-
.xterm.column-select.focus { cursor: crosshair; }
|
|
79
|
-
.xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
|
|
80
|
-
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
81
|
-
.xterm .xterm-accessibility-tree { font-family: monospace; user-select: text; white-space: pre; }
|
|
82
|
-
.xterm .xterm-accessibility-tree > div { transform-origin: left; width: fit-content; }
|
|
83
|
-
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
84
|
-
.xterm-dim { opacity: 1 !important; }
|
|
85
|
-
.xterm-underline-1 { text-decoration: underline; }
|
|
86
|
-
.xterm-underline-2 { text-decoration: double underline; }
|
|
87
|
-
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
88
|
-
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
89
|
-
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
90
|
-
.xterm-overline { text-decoration: overline; }
|
|
91
|
-
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
|
|
92
|
-
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
|
|
93
|
-
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
|
|
94
|
-
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
|
|
95
|
-
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
|
|
96
|
-
.xterm-strikethrough { text-decoration: line-through; }
|
|
97
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
98
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
99
|
-
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
100
|
-
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
101
|
-
.xterm .xterm-scrollable-element > .scrollbar { cursor: default; }
|
|
102
|
-
.xterm .xterm-scrollable-element > .scrollbar > .scra { cursor: pointer; font-size: 11px !important; }
|
|
103
|
-
.xterm .xterm-scrollable-element > .visible { opacity: 1; background: rgba(0,0,0,0); transition: opacity 100ms linear; z-index: 11; }
|
|
104
|
-
.xterm .xterm-scrollable-element > .invisible { opacity: 0; pointer-events: none; }
|
|
105
|
-
.xterm .xterm-scrollable-element > .invisible.fade { transition: opacity 800ms linear; }
|
|
106
|
-
.xterm .xterm-scrollable-element > .shadow { position: absolute; display: none; }
|
|
107
|
-
.xterm .xterm-scrollable-element > .shadow.top { display: block; top: 0; left: 3px; height: 3px; width: 100%; }
|
|
108
|
-
.xterm .xterm-scrollable-element > .shadow.left { display: block; top: 3px; left: 0; height: 100%; width: 3px; }
|
|
109
|
-
`;function f4(){if(typeof document>"u"||document.querySelector("[data-xterm-css]"))return;const e=document.createElement("style");e.setAttribute("data-xterm-css",""),e.textContent=d4,document.head.appendChild(e)}function h4(e){return new Promise((t,n)=>{const a=new FileReader;a.onload=()=>{const i=a.result;t(i.split(",")[1])},a.onerror=n,a.readAsDataURL(e)})}function m4({relay:e,fontSize:t=12,fontFamily:n="'JetBrains Mono', 'Hack Nerd Font', monospace",configItems:a,onOpenSettings:i,onStartService:c}){const{status:u,error:f,exitCode:m,cwd:h,setCwd:g,sendInput:x,resize:b,onData:w,connect:j,disconnect:N}=e,[T,k]=v.useState(!1),{apiBaseUrl:C}=nf(),S=v.useRef(null),R=v.useRef(null),A=v.useRef(null),M=v.useRef(null),[O,V]=v.useState(!1),[F,I]=v.useState(!1),$=v.useRef(0);v.useEffect(()=>{const Z=S.current;if(!Z)return;const J=Q=>{Q.key===" "&&!Q.metaKey&&!Q.ctrlKey&&!Q.altKey&&Q.stopPropagation()};return Z.addEventListener("keydown",J),()=>Z.removeEventListener("keydown",J)},[]);const L=`${C}/api/relay/upload`,U=v.useCallback(async Z=>{try{const J=await h4(Z),Q=await fetch(L,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Z.name,data:J})}),{path:pe}=await Q.json();return pe||null}catch(J){return console.error("File upload failed:",J),null}},[L]);v.useEffect(()=>{const Z=S.current;if(!Z)return;const J=async Q=>{if(!Q.clipboardData)return;const pe=Array.from(Q.clipboardData.items).filter(re=>re.type.startsWith("image/"));if(pe.length!==0){Q.preventDefault(),Q.stopPropagation();for(const re of pe){const de=re.getAsFile();if(!de)continue;const fe=await U(de);fe&&x(fe)}}};return Z.addEventListener("paste",J),()=>Z.removeEventListener("paste",J)},[x,U]);const Y=v.useCallback(Z=>{Z.preventDefault(),Z.dataTransfer.dropEffect="copy"},[]),K=v.useCallback(Z=>{Z.preventDefault(),$.current++,Z.dataTransfer.types.includes("Files")&&I(!0)},[]),D=v.useCallback(Z=>{Z.preventDefault(),$.current--,$.current===0&&I(!1)},[]),P=v.useCallback(async Z=>{Z.preventDefault(),$.current=0,I(!1);const J=Array.from(Z.dataTransfer.files).filter(Q=>Q.type.startsWith("image/"));if(J.length!==0)for(const Q of J){const pe=await U(Q);pe&&x(pe)}},[x,U]);v.useEffect(()=>{let Z=!1,J=null;async function Q(){const[{Terminal:pe},{FitAddon:re},de]=await Promise.all([id(()=>import("./xterm-B-qIQCd3.js"),[]),id(()=>import("./addon-fit-DX4qG4td.js"),[]),id(()=>import("./addon-webgl-DCtw1yLn.js"),[]).catch(()=>null)]);if(f4(),Z||!R.current)return;J=new pe({fontSize:t,fontFamily:n,theme:u4,cursorBlink:!0,cursorStyle:"bar",allowTransparency:!0,scrollback:5e3,convertEol:!1,allowProposedApi:!0});const fe=new re;if(J.loadAddon(fe),J.open(R.current),de)try{const xe=new de.WebglAddon;xe.onContextLoss(()=>{xe.dispose()}),J.loadAddon(xe)}catch{}try{fe.fit()}catch{}A.current=J,M.current=fe,b(J.cols,J.rows),J.onData(xe=>{x(xe)}),V(!0)}return Q(),()=>{Z=!0,J&&(J.dispose(),A.current=null,M.current=null)}},[]),v.useEffect(()=>{const Z=A.current;if(Z){Z.options.fontSize=t,Z.options.fontFamily=n;try{M.current?.fit()}catch{}}},[t,n]),v.useEffect(()=>{if(O)return w(Z=>{A.current?.write(Z)}),()=>{w(()=>{})}},[O,w]),v.useEffect(()=>{const Z=R.current;if(!Z||!O)return;const J=new ResizeObserver(()=>{const Q=M.current,pe=A.current;if(!(!Q||!pe))try{Q.fit(),b(pe.cols,pe.rows)}catch{}});return J.observe(Z),()=>J.disconnect()},[O,b]),v.useEffect(()=>{u==="connected"&&A.current&&A.current.focus()},[u]);const B=v.useCallback(()=>{u==="connected"&&A.current&&A.current.focus()},[u]),G=u==="error"&&f==="Relay service is not running",X=v.useCallback(async()=>{if(c){k(!0);try{await c()&&setTimeout(()=>j(),500)}finally{k(!1)}}},[c,j]);let z=null;return G?z=o.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:o.jsx("span",{className:"text-amber-400 text-[14px]",children:"!"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Relay service not running"}),o.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:c?"Start the relay service to open a terminal session.":"Start the relay service from the Workspace Manager."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[c&&o.jsx("button",{type:"button",onClick:X,disabled:T,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:T?"Starting...":"Start Service"}),o.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&&o.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"})]})]}):u==="error"&&f?z=o.jsxs("div",{className:"flex flex-col items-center gap-3 max-w-md text-center px-4",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/10 flex items-center justify-center",children:o.jsx("span",{className:"text-red-400 text-sm",children:"!"})}),o.jsx("span",{className:"text-red-400 text-[12px] font-medium",children:"Session failed"}),o.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:f}),m!==null&&m!==0&&o.jsxs("span",{className:"text-[10px] text-neutral-600",children:["Exit code ",m]}),o.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"})]}):u==="disconnected"?z=o.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-neutral-800 border border-neutral-700 flex items-center justify-center",children:o.jsx("span",{className:"text-neutral-500 text-[14px]",children:"▷"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Terminal relay disconnected"}),o.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:"Set working directory and connect."})]}),o.jsxs("form",{className:"w-full",onSubmit:Z=>{Z.preventDefault(),j()},children:[o.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-wider mb-1 block text-left",children:"Working Directory"}),o.jsx("input",{type:"text",value:h,onChange:Z=>g(Z.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"})]}),a&&a.length>0&&o.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:a.map(Z=>o.jsxs("div",{className:"contents",children:[o.jsx("span",{className:"text-neutral-500",children:Z.label}),o.jsx("span",{className:"text-neutral-400 truncate text-left",children:Z.value})]},Z.label))}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.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&&o.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"})]})]}):u==="connecting"&&(z=o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[o.jsx("div",{className:"w-6 h-6 border-2 border-neutral-600 border-t-cyan-400 rounded-full animate-spin"}),o.jsx("span",{className:"text-[12px] text-neutral-400",children:"Connecting to relay..."}),o.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"})]})),o.jsxs("div",{ref:S,className:"relative flex flex-col h-full overflow-hidden",onClick:B,onDragOver:Y,onDragEnter:K,onDragLeave:D,onDrop:P,children:[z&&o.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}),F&&o.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:o.jsx("span",{className:"text-cyan-400 font-mono text-sm",children:"Drop image to get path"})}),o.jsx("div",{ref:R,className:"flex-1 min-h-0 min-w-0 overflow-hidden",style:{visibility:z?"hidden":"visible",padding:"4px 8px"}})]})}function p4({app:e,commands:t,state:n,relayUrl:a="ws://localhost:3600",cwd:i,agent:c="pi",provider:u,model:f,backend:m="pty",tmuxSession:h,workspaceFiles:g,onOpenSettings:x,onStartService:b,voiceKit:w}){const[j,N]=ka(`assistant.${e.id}.mode`,"relay"),[T,k]=v.useState(""),[C,S]=ka(`assistant.${e.id}.voice.speakReplies`,w?.settings.speakReplies??!1),{serviceApiUrl:R}=nf(),A=v.useMemo(()=>v4(e),[e]),M=fz({url:a,systemPrompt:A,cwd:i,workspaceFiles:g,sessionKey:`assistant-${e.id}`,backend:m,tmuxSession:h,agent:c,provider:c==="pi"?u:void 0,model:c==="pi"?f:void 0}),O=v.useCallback(async()=>{if(b)return b();try{return(await(await fetch(`${R}/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}},[b,R]),V=v.useMemo(()=>{const B=[{label:"Relay",value:a},{label:"Agent",value:c}];return i&&B.push({label:"CWD",value:i}),c==="pi"&&f&&B.push({label:"Model",value:f}),B},[a,c,i,f]),[F,I]=v.useState("text"),$=dz({app:e,commands:t,state:n,provider:u,model:f,onFinish:({message:B,isAbort:G,isDisconnect:X,isError:z})=>{!w||!C||G||X||z||B.role==="assistant"&&w.speakReply(B,{surface:"hudson-assistant",appId:e.id,source:F})}}),L=v.useCallback(B=>{if(!w)return;const G=[T.trim(),B].filter(Boolean).join(" ");w.settings.autoSend&&$.status!=="streaming"&&$.status!=="submitted"?(k(""),I("voice"),$.sendMessage({text:G})):k(G)},[w,T,$]),U=v.useCallback(()=>{w&&(w.input.status==="recording"?w.input.stop():w.input.start(L))},[w,L]),Y=e.intents?.length??0,K=!!w,D=w?.input.status==="transcribing",P=w?.input.status==="recording";return o.jsxs("div",{className:"flex flex-col h-full",children:[o.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:[o.jsx(Gz,{size:11,className:"text-cyan-400/60"}),o.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-neutral-500",children:"Assistant"}),o.jsxs("span",{className:"text-[10px] font-mono text-neutral-600",children:["· ",e.name]}),o.jsx("div",{className:"flex-1"}),K&&j==="chat"&&o.jsx("button",{type:"button",onClick:()=>{C&&w?.output.stop(),S(!C)},className:`p-1 rounded transition-colors ${C?"text-cyan-300 hover:text-cyan-200":"text-neutral-500 hover:text-neutral-300"}`,title:C?"Speaker on (click to mute)":"Speaker off (click to enable)",children:w?.output.isPlaying?o.jsx(Uw,{size:12,className:"animate-spin"}):C?o.jsx(t4,{size:12}):o.jsx(s4,{size:12})}),o.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-neutral-700 p-0.5",children:[o.jsx(Hw,{active:j==="relay",onClick:()=>N("relay"),children:"Relay"}),o.jsx(Hw,{active:j==="chat",onClick:()=>N("chat"),children:"Chat"})]}),j==="relay"&&M.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>M.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"}),j==="relay"&&M.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>M.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"}),j==="relay"&&M.status!=="connected"&&M.status!=="connecting"&&o.jsx("button",{type:"button",onClick:()=>M.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"})]}),o.jsx("div",{className:"flex-1 min-h-0",children:j==="relay"?o.jsx(m4,{relay:M,configItems:V,onOpenSettings:x,onStartService:O}):o.jsx(r4,{chat:$,placeholder:Y===0?`Ask about ${e.name} — no intents declared, conversation only.`:`Ask ${e.name} to do something… (${Y} intent${Y===1?"":"s"})`,inputValue:T,onInputChange:B=>{F==="voice"&&B.length===0&&I("text"),k(B)},inputExtras:K&&w?.input.isSupported?o.jsx("button",{type:"button",onClick:U,disabled:D,className:`p-1 rounded transition-colors disabled:opacity-30 ${P?"bg-red-500/15 text-red-300 hover:bg-red-500/20":"text-neutral-500 hover:text-cyan-400"}`,title:P?"Stop recording":"Record voice prompt",children:D?o.jsx(Uw,{size:12,className:"animate-spin"}):P?o.jsx(ck,{size:11}):o.jsx(Az,{size:12})}):void 0,inputStatus:K&&w?o.jsx(g4,{inputStatus:w.input.status,inputError:w.input.error,outputStatus:w.output.status,outputError:w.output.error}):void 0})})]})}function g4({inputStatus:e,inputError:t,outputStatus:n,outputError:a}){const i=Vw(e)??Vw(n),c=t??a;return!i&&!c?null:o.jsxs("div",{className:"flex items-center gap-2",children:[i&&o.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border font-mono ${i.className}`,children:i.label}),c&&o.jsx("span",{className:"text-[10px] text-neutral-500 truncate flex-1",title:c,children:c})]})}function Vw(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 Hw({active:e,onClick:t,children:n}){return o.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 v4(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 a of n)t.push(`- ${a.title} — ${a.description}`);t.push("","These actions live inside the running app. You can describe them to the user, but you do not invoke them yourself — the user can trigger any of them via the command palette (Cmd+K).")}return t.push("","## How to behave","- Be terse. The user is in a terminal; respect their attention.","- Use your own tools (file ops, shell, etc.) freely if it helps.","- When asked to change something inside the app itself, prefer guiding the user to the matching command rather than hacking around it."),t.join(`
|
|
110
|
-
`)}typeof window<"u"&&localStorage.getItem("frame_sounds");const sf={panels:{statusBar:"bg-neutral-950/95 backdrop-blur-xl border-t border-neutral-700 shadow-[0_-5px_30px_rgba(0,0,0,0.6),inset_0_1px_0_rgba(255,255,255,0.06)] fixed bottom-0 left-0 right-0 z-[60]"},zIndex:{drawer:70},layout:{navHeight:48,statusBarHeight:28}},y4=sf.panels;function Yg(){const{titleBarInset:e}=nf();return v.useMemo(()=>{const t=sf.layout.navHeight+e;return{navTotalHeight:t,panelTopOffset:t}},[e])}const x4=({panOffset:e,scale:t,onPan:n,onPanStart:a,onPanEnd:i,isPanLocked:c=!1,onClick:u,showGuides:f=!1,onGuidesChange:m,gridOpacity:h=1})=>{const[g,x]=v.useState(f),[b,w]=v.useState(!1),j=v.useRef(!1),N=v.useRef({x:0,y:0}),T=v.useRef({active:!1,startX:0,startY:0}),k=v.useRef(null),C=v.useRef(null),S=v.useRef(null),R=4,A=v.useRef({x:0,y:0}),M=v.useRef(0),O=v.useRef(!1);v.useEffect(()=>{x(f)},[f]);const V=v.useCallback(X=>{const z=X;return z?z.tagName==="INPUT"||z.tagName==="TEXTAREA"||z.isContentEditable:!1},[]),F=v.useCallback(X=>{const z=X;return z?!!z.closest('button, [role="button"], a, input, textarea, select, [data-interactive="true"]'):!1},[]),I=v.useCallback(X=>{j.current=X,w(X)},[]);v.useEffect(()=>{const X=Q=>{if(M.current=Q.buttons,T.current.active&&(Q.buttons&1)!==1&&(T.current.active=!1),j.current&&(Q.buttons&1)!==1){I(!1),T.current.active=!1,i?.(),document.body.style.cursor="";return}if(c&&j.current){I(!1),T.current.active=!1,i?.(),document.body.style.cursor="";return}const pe=k.current?.getBoundingClientRect(),re=pe?Q.clientX-pe.left:Q.clientX,de=pe?Q.clientY-pe.top:Q.clientY;if(A.current={x:re,y:de},C.current&&(C.current.style.left=`${re}px`),S.current&&(S.current.style.top=`${de}px`),T.current.active&&!j.current){const fe=Q.clientX-T.current.startX,xe=Q.clientY-T.current.startY;Math.hypot(fe,xe)>=R&&(T.current.active=!1,I(!0),O.current=!0,a?.(),N.current={x:Q.clientX,y:Q.clientY},document.body.style.cursor="grabbing")}j.current&&(n({x:(Q.clientX-N.current.x)/t,y:(Q.clientY-N.current.y)/t}),N.current={x:Q.clientX,y:Q.clientY})},z=Q=>{M.current=Q.buttons,T.current.active=!1,j.current&&(I(!1),i?.(),document.body.style.cursor="")},Z=Q=>{(Q.metaKey||Q.ctrlKey)&&Q.key==="\\"&&(Q.preventDefault(),x(pe=>{const re=!pe;return m?.(re),re}))},J=()=>{T.current.active=!1,z(new MouseEvent("mouseup"))};return window.addEventListener("mousemove",X),window.addEventListener("mouseup",z),window.addEventListener("keydown",Z),window.addEventListener("blur",J),document.addEventListener("visibilitychange",J),()=>{window.removeEventListener("mousemove",X),window.removeEventListener("mouseup",z),window.removeEventListener("keydown",Z),window.removeEventListener("blur",J),document.removeEventListener("visibilitychange",J)}},[n,i,a,t,V,F,c,I,m]),v.useEffect(()=>{!c||!j.current||(I(!1),i?.(),document.body.style.cursor="")},[c,i,I]);const $=X=>{O.current=!1,!(c||X.button!==0)&&(V(X.target)||F(X.target)||(M.current=X.buttons,T.current={active:!0,startX:X.clientX,startY:X.clientY},X.preventDefault()))},L=X=>{!O.current&&u&&u(X),O.current=!1},[U,Y]=v.useState({w:0,h:0});v.useEffect(()=>{const X=()=>Y({w:window.innerWidth,h:window.innerHeight});return X(),window.addEventListener("resize",X),()=>window.removeEventListener("resize",X)},[]);const K=Math.max(.4,Math.min(2,t)),D=100*K,P=20*K,B=(U.w/2+e.x*t)%D,G=(U.h/2+e.y*t)%D;return o.jsxs("div",{ref:k,className:`absolute inset-0 z-0 overflow-hidden bg-black ${b?"cursor-grabbing":"cursor-grab"}`,onMouseDown:$,onClick:L,children:[o.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.5*h,transition:"opacity 1s ease",backgroundImage:"radial-gradient(circle, #444 1px, transparent 1px)",backgroundSize:`${P}px ${P}px`,backgroundPosition:`${B+100}px ${G+100}px`}}),o.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.25*h,transition:"opacity 1s ease",backgroundImage:"radial-gradient(circle, #555 1.5px, transparent 1.5px)",backgroundSize:`${D}px ${D}px`,backgroundPosition:`${B+100}px ${G+100}px`}}),g&&o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:C,className:"absolute top-0 bottom-0 w-px pointer-events-none bg-emerald-500/10",style:{left:0}}),o.jsx("div",{ref:S,className:"absolute left-0 right-0 h-px pointer-events-none bg-emerald-500/10",style:{top:0}})]})]})},b4=({scale:e,onZoom:t,min:n=.2,max:a=3,step:i=.1})=>{const[c,u]=v.useState(!1),[f,m]=v.useState(""),h=v.useRef(null),g=v.useCallback(T=>Math.min(a,Math.max(n,T)),[n,a]),x=v.useCallback(()=>{t(g(e+i))},[e,i,t,g]),b=v.useCallback(()=>{t(g(e-i))},[e,i,t,g]),w=v.useCallback(()=>{m(Math.round(e*100).toString()),u(!0)},[e]),j=v.useCallback(()=>{u(!1);const T=parseInt(f,10);!isNaN(T)&&T>0&&t(g(T/100))},[f,t,g]),N=v.useCallback(T=>{T.key==="Enter"?j():T.key==="Escape"&&u(!1)},[j]);return v.useEffect(()=>{c&&h.current&&(h.current.focus(),h.current.select())},[c]),o.jsxs("div",{className:"pointer-events-auto flex flex-col items-center bg-neutral-950/95 backdrop-blur-xl border border-neutral-700/80 rounded-md shadow-[0_0_20px_rgba(0,0,0,0.6)] overflow-hidden",children:[o.jsx("button",{onClick:x,className:"w-9 h-8 flex items-center justify-center hover:bg-white/10 text-neutral-300 hover:text-white transition-colors",title:"Zoom in",children:o.jsx(Fz,{size:14})}),o.jsx("div",{className:"w-full border-t border-b border-neutral-700/50",children:c?o.jsx("input",{ref:h,type:"text",value:f,onChange:T=>m(T.target.value.replace(/[^0-9]/g,"")),onBlur:j,onKeyDown:N,className:"w-9 py-1.5 text-center text-[11px] font-mono text-white bg-black/60 outline-none tabular-nums"}):o.jsxs("button",{onClick:w,className:"w-9 py-1.5 text-center text-[11px] font-mono text-neutral-200 hover:text-white hover:bg-white/10 transition-colors cursor-text tabular-nums",title:"Click to set zoom",children:[Math.round(e*100),"%"]})}),o.jsx("button",{onClick:b,className:"w-9 h-8 flex items-center justify-center hover:bg-white/10 text-neutral-300 hover:text-white transition-colors",title:"Zoom out",children:o.jsx(Oz,{size:14})})]})},w4={...Cj};let Zw=0;function S4(e,t="mui"){const[n,a]=v.useState(e),i=e||n;return v.useEffect(()=>{n==null&&(Zw+=1,a(`${t}-${Zw}`))},[n,t]),i}const Fw=w4.useId;function yr(e,t){if(Fw!==void 0){const n=Fw();return e??(t?`${t}-${n}`:n)}return S4(e,t)}function oi(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(a=>n.searchParams.append("args[]",a)),`Base UI error #${e}; visit ${n} for the full message.`}const dk=v.createContext(void 0);function af(e=!0){const t=v.useContext(dk);if(t===void 0&&!e)throw new Error(oi(25));return t}const fk=v.createContext(void 0);function hk(e){const t=v.useContext(fk);if(t===void 0&&!e)throw new Error(oi(33));return t}const Gg=v.createContext(void 0);function Ro(e){const t=v.useContext(Gg);if(t===void 0&&!e)throw new Error(oi(36));return t}const qw={};function Es(e,t){const n=v.useRef(qw);return n.current===qw&&(n.current=e(t)),n}function ec(e,t,n,a){const i=Es(mk).current;return N4(i,e,t,n,a)&&pk(i,[e,t,n,a]),i.callback}function j4(e){const t=Es(mk).current;return k4(t,e)&&pk(t,e),t.callback}function mk(){return{callback:null,cleanup:null,refs:[]}}function N4(e,t,n,a,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}function k4(e,t){return e.refs.length!==t.length||e.refs.some((n,a)=>n!==t[a])}function pk(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 a=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const c=t[i];if(c!=null)switch(typeof c){case"function":{const u=c(n);typeof u=="function"&&(a[i]=u);break}case"object":{c.current=n;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const c=t[i];if(c!=null)switch(typeof c){case"function":{const u=a[i];typeof u=="function"?u():c(null);break}case"object":{c.current=null;break}}}}}}}const E4=parseInt(v.version,10);function Wg(e){return E4>=e}function Yw(e){if(!v.isValidElement(e))return null;const t=e,n=t.props;return(Wg(19)?n?.ref:t.ref)??null}function Fp(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function C4(e,t){const n={};for(const a in e){const i=e[a];if(t?.hasOwnProperty(a)){const c=t[a](i);c!=null&&Object.assign(n,c);continue}i===!0?n[`data-${a.toLowerCase()}`]="":i&&(n[`data-${a.toLowerCase()}`]=i.toString())}return n}function T4(e,t){return typeof e=="function"?e(t):e}function A4(e,t){return typeof e=="function"?e(t):e}const Pl={};function rf(e,t,n,a,i){let c={...qp(e,Pl)};return t&&(c=od(c,t)),n&&(c=od(c,n)),a&&(c=od(c,a)),c}function R4(e){if(e.length===0)return Pl;if(e.length===1)return qp(e[0],Pl);let t={...qp(e[0],Pl)};for(let n=1;n<e.length;n+=1)t=od(t,e[n]);return t}function od(e,t){return gk(t)?t(e):M4(e,t)}function M4(e,t){if(!t)return e;for(const n in t){const a=t[n];switch(n){case"style":{e[n]=Fp(e.style,a);break}case"className":{e[n]=vk(e.className,a);break}default:_4(n,a)?e[n]=O4(e[n],a):e[n]=a}}return e}function _4(e,t){const n=e.charCodeAt(0),a=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&a===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function gk(e){return typeof e=="function"}function qp(e,t){return gk(e)?e(t):e??Pl}function O4(e,t){return t?e?n=>{if(I4(n)){const i=n;Yp(i);const c=t(i);return i.baseUIHandlerPrevented||e?.(i),c}const a=t(n);return e?.(n),a}:t:e}function Yp(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function vk(e,t){return t?e?t+" "+e:t:e}function I4(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function yk(){}const xk=Object.freeze([]),Wn=Object.freeze({}),D4=500,z4={style:{transition:"none"}},L4="data-base-ui-click-trigger",$4={fallbackAxisSide:"none"},P4={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function xr(e,t,n={}){const a=t.render,i=U4(t,n);if(n.enabled===!1)return null;const c=n.state??Wn;return B4(e,a,i,c)}function U4(e,t={}){const{className:n,style:a,render:i}=e,{state:c=Wn,ref:u,props:f,stateAttributesMapping:m,enabled:h=!0}=t,g=h?T4(n,c):void 0,x=h?A4(a,c):void 0,b=h?C4(c,m):Wn,w=h?Fp(b,Array.isArray(f)?R4(f):f)??Wn:Wn;return typeof document<"u"&&(h?Array.isArray(u)?w.ref=j4([w.ref,Yw(i),...u]):w.ref=ec(w.ref,Yw(i),u):ec(null,null)),h?(g!==void 0&&(w.className=vk(w.className,g)),x!==void 0&&(w.style=Fp(w.style,x)),w):Wn}function B4(e,t,n,a){if(t){if(typeof t=="function")return t(n,a);const i=rf(n,t.props);return i.ref=n.ref,v.cloneElement(t,i)}return V4(e,n)}function V4(e,t){return v.createElement(e,t)}let Td=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const H4={[Td.startingStyle]:""},Z4={[Td.endingStyle]:""},F4={transitionStatus(e){return e==="starting"?H4:e==="ending"?Z4:null}};let Xg=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Td.startingStyle]="startingStyle",e[e.endingStyle=Td.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),Gw=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const q4={[Gw.popupOpen]:"",[Gw.pressed]:""},Y4={[Xg.open]:""},G4={[Xg.closed]:""},W4={[Xg.anchorHidden]:""},X4={open(e){return e?q4:null}},bk={open(e){return e?Y4:G4},anchorHidden(e){return e?W4:null}},K4="none",Ad="trigger-press",Xr="trigger-hover",Ww="trigger-focus",Kg="outside-press",wk="item-press",of="focus-out",Sk="escape-key",ld="list-navigation",J4="cancel-open",Il="sibling-open",Q4="imperative-action",Hm=Cj[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],e3=Hm&&Hm!==v.useLayoutEffect?Hm:e=>e();function qe(e){const t=Es(t3).current;return t.next=e,e3(t.effect),t.trampoline}function t3(){const e={next:void 0,callback:n3,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function n3(){}function lf(){return typeof window<"u"}function br(e){return Jg(e)?(e.nodeName||"").toLowerCase():"#document"}function An(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ra(e){var t;return(t=(Jg(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Jg(e){return lf()?e instanceof Node||e instanceof An(e).Node:!1}function Ot(e){return lf()?e instanceof Element||e instanceof An(e).Element:!1}function Qt(e){return lf()?e instanceof HTMLElement||e instanceof An(e).HTMLElement:!1}function Gp(e){return!lf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof An(e).ShadowRoot}const s3=new Set(["inline","contents"]);function li(e){const{overflow:t,overflowX:n,overflowY:a,display:i}=us(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&!s3.has(i)}const a3=new Set(["table","td","th"]);function r3(e){return a3.has(br(e))}const i3=[":popover-open",":modal"];function cf(e){return i3.some(t=>{try{return e.matches(t)}catch{return!1}})}const o3=["transform","translate","scale","rotate","perspective"],l3=["transform","translate","scale","rotate","perspective","filter"],c3=["paint","layout","strict","content"];function Qg(e){const t=uf(),n=Ot(e)?us(e):e;return o3.some(a=>n[a]?n[a]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||l3.some(a=>(n.willChange||"").includes(a))||c3.some(a=>(n.contain||"").includes(a))}function u3(e){let t=na(e);for(;Qt(t)&&!Js(t);){if(Qg(t))return t;if(cf(t))return null;t=na(t)}return null}function uf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const d3=new Set(["html","body","#document"]);function Js(e){return d3.has(br(e))}function us(e){return An(e).getComputedStyle(e)}function df(e){return Ot(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function na(e){if(br(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gp(e)&&e.host||ra(e);return Gp(t)?t.host:t}function jk(e){const t=na(e);return Js(t)?e.ownerDocument?e.ownerDocument.body:e.body:Qt(t)&&li(t)?t:jk(t)}function cr(e,t,n){var a;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=jk(e),c=i===((a=e.ownerDocument)==null?void 0:a.body),u=An(i);if(c){const f=Wp(u);return t.concat(u,u.visualViewport||[],li(i)?i:[],f&&n?cr(f):[])}return t.concat(i,cr(i,[],n))}function Wp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const f3=()=>{},Ze=typeof document<"u"?v.useLayoutEffect:f3,h3=v.createContext(void 0);function m3(e=!1){const t=v.useContext(h3);if(t===void 0&&!e)throw new Error(oi(16));return t}function p3(e){const{focusableWhenDisabled:t,disabled:n,composite:a=!1,tabIndex:i=0,isNativeButton:c}=e,u=a&&t!==!1,f=a&&t===!1;return{props:v.useMemo(()=>{const h={onKeyDown(g){n&&t&&g.key!=="Tab"&&g.preventDefault()}};return a||(h.tabIndex=i,!c&&n&&(h.tabIndex=t?i:-1)),(c&&(t||u)||!c&&n)&&(h["aria-disabled"]=n),c&&(!t||f)&&(h.disabled=n),h},[a,n,t,u,f,c,i])}}function g3(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:a=0,native:i=!0}=e,c=v.useRef(null),u=m3(!0)!==void 0,f=qe(()=>{const b=c.current;return!!(b?.tagName==="A"&&b?.href)}),{props:m}=p3({focusableWhenDisabled:n,disabled:t,composite:u,tabIndex:a,isNativeButton:i}),h=v.useCallback(()=>{const b=c.current;v3(b)&&u&&t&&m.disabled===void 0&&b.disabled&&(b.disabled=!1)},[t,m.disabled,u]);Ze(h,[h]);const g=v.useCallback((b={})=>{const{onClick:w,onMouseDown:j,onKeyUp:N,onKeyDown:T,onPointerDown:k,...C}=b;return rf({type:i?"button":void 0,onClick(R){if(t){R.preventDefault();return}w?.(R)},onMouseDown(R){t||j?.(R)},onKeyDown(R){if(t||(Yp(R),T?.(R)),R.baseUIHandlerPrevented)return;const A=R.target===R.currentTarget&&!i&&!f()&&!t,M=R.key==="Enter",O=R.key===" ";A&&((O||M)&&R.preventDefault(),M&&w?.(R))},onKeyUp(R){t||(Yp(R),N?.(R)),!R.baseUIHandlerPrevented&&R.target===R.currentTarget&&!i&&!t&&R.key===" "&&w?.(R)},onPointerDown(R){if(t){R.preventDefault();return}k?.(R)}},i?void 0:{role:"button"},m,C)},[t,m,i,f]),x=qe(b=>{c.current=b,h()});return{getButtonProps:g,buttonRef:x}}function v3(e){return Qt(e)&&e.tagName==="BUTTON"}const y3={type:"regular-item"};function x3(e){const{closeOnClick:t,disabled:n=!1,highlighted:a,id:i,store:c,nativeButton:u,itemMetadata:f,nodeId:m}=e,h=v.useRef(null),g=af(!0),x=g!==void 0,{events:b}=c.useState("floatingTreeRoot"),{getButtonProps:w,buttonRef:j}=g3({disabled:n,focusableWhenDisabled:!0,native:u}),N=v.useCallback(k=>rf({id:i,role:"menuitem",tabIndex:a?0:-1,onMouseMove(C){m&&b.emit("itemhover",{nodeId:m,target:C.currentTarget})},onMouseEnter(){f.type==="submenu-trigger"&&f.setActive()},onKeyUp(C){C.key===" "&&c.context.typingRef.current&&C.preventBaseUIHandler()},onClick(C){t&&b.emit("close",{domEvent:C,reason:wk})},onMouseUp(C){if(g){const S=g.initialCursorPointRef.current;if(g.initialCursorPointRef.current=null,x&&S&&Math.abs(C.clientX-S.x)<=1&&Math.abs(C.clientY-S.y)<=1)return}h.current&&c.context.allowMouseUpTriggerRef.current&&(!x||C.button===2)&&f.type==="regular-item"&&h.current.click()}},k,w),[i,a,w,t,b,c,x,g,f,m]),T=ec(h,j);return v.useMemo(()=>({getItemProps:N,itemRef:T}),[N,T])}const Nk=v.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function b3(){return v.useContext(Nk)}let w3=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function S3(e={}){const{label:t,metadata:n,textRef:a,indexGuessBehavior:i,index:c}=e,{register:u,unregister:f,subscribeMapChange:m,elementsRef:h,labelsRef:g,nextIndexRef:x}=b3(),b=v.useRef(-1),[w,j]=v.useState(c??(i===w3.GuessFromOrder?()=>{if(b.current===-1){const k=x.current;x.current+=1,b.current=k}return b.current}:-1)),N=v.useRef(null),T=v.useCallback(k=>{if(N.current=k,w!==-1&&k!==null&&(h.current[w]=k,g)){const C=t!==void 0;g.current[w]=C?t:a?.current?.textContent??k.textContent}},[w,h,g,t,a]);return Ze(()=>{if(c!=null)return;const k=N.current;if(k)return u(k,n),()=>{f(k)}},[c,u,f,n]),Ze(()=>{if(c==null)return m(k=>{const C=N.current?k.get(N.current)?.index:null;C!=null&&j(C)})},[c,m,j]),v.useMemo(()=>({ref:T,index:w}),[w,T])}function kk(e){return yr(e,"base-ui")}function rn(e,t,n,a){let i=!1,c=!1;const u=Wn;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){c=!0},get isCanceled(){return i},get isPropagationAllowed(){return c},trigger:n,...u}}var ni=Tj();const j3=[];function Ek(e){v.useEffect(e,j3)}const Iu=null;class N3{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,a=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,a>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 Du=new N3;class Xs{static create(){return new Xs}static request(t){return Du.request(t)}static cancel(t){return Du.cancel(t)}currentId=Iu;request(t){this.cancel(),this.currentId=Du.request(()=>{this.currentId=Iu,t()})}cancel=()=>{this.currentId!==Iu&&(Du.cancel(this.currentId),this.currentId=Iu)};disposeEffect=()=>this.cancel}function ev(){const e=Es(Xs.create).current;return Ek(e.disposeEffect),e}function k3(e,t=!1,n=!1){const[a,i]=v.useState(e&&t?"idle":void 0),[c,u]=v.useState(e);return e&&!c&&(u(!0),i("starting")),!e&&c&&a!=="ending"&&!n&&i("ending"),!e&&!c&&a==="ending"&&i(void 0),Ze(()=>{if(!e&&c&&a!=="ending"&&n){const f=Xs.request(()=>{i("ending")});return()=>{Xs.cancel(f)}}},[e,c,a,n]),Ze(()=>{if(!e||t)return;const f=Xs.request(()=>{ni.flushSync(()=>{i(void 0)})});return()=>{Xs.cancel(f)}},[t,e]),Ze(()=>{if(!e||!t)return;e&&c&&a!=="idle"&&i("starting");const f=Xs.request(()=>{i("idle")});return()=>{Xs.cancel(f)}},[t,e,c,i,a]),v.useMemo(()=>({mounted:c,setMounted:u,transitionStatus:a}),[c,a])}function Yn(e){const t=Es(E3,e).current;return t.next=e,Ze(t.effect),t}function E3(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Zr(e){return e==null?e:"current"in e?e.current:e}function C3(e,t=!1,n=!0){const a=ev();return qe((i,c=null)=>{a.cancel();const u=Zr(e);u!=null&&(typeof u.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED?i():a.request(()=>{function f(){u&&Promise.all(u.getAnimations().map(m=>m.finished)).then(()=>{c!=null&&c.aborted||ni.flushSync(i)}).catch(()=>{if(n){if(c!=null&&c.aborted)return;ni.flushSync(i)}else u.getAnimations().length>0&&u.getAnimations().some(m=>m.pending||m.playState!=="finished")&&f()})}t?a.request(f):f()}))})}function Ck(e){const{enabled:t=!0,open:n,ref:a,onComplete:i}=e,c=Yn(n),u=qe(i),f=C3(a,n);v.useEffect(()=>{t&&f(()=>{n===c.current&&u()})},[t,n,u,f,c])}const Tk=v.createContext(void 0);function T3(){const e=v.useContext(Tk);if(e===void 0)throw new Error(oi(31));return e}const A3=v.forwardRef(function(t,n){const{render:a,className:i,...c}=t,[u,f]=v.useState(void 0),m=v.useMemo(()=>({setLabelId:f}),[f]),h=xr("div",t,{ref:n,props:{role:"group","aria-labelledby":u,...c}});return o.jsx(Tk.Provider,{value:m,children:h})}),R3=v.forwardRef(function(t,n){const{className:a,render:i,id:c,...u}=t,f=kk(c),{setLabelId:m}=T3();return Ze(()=>(m(f),()=>{m(void 0)}),[m,f]),xr("div",t,{ref:n,props:{id:f,role:"presentation",...u}})}),M3=v.forwardRef(function(t,n){const{render:a,className:i,id:c,label:u,nativeButton:f=!1,disabled:m=!1,closeOnClick:h=!0,...g}=t,x=S3({label:u}),b=hk(!0),w=kk(c),{store:j}=Ro(),N=j.useState("isActive",x.index),T=j.useState("itemProps"),{getItemProps:k,itemRef:C}=x3({closeOnClick:h,disabled:m,highlighted:N,id:w,store:j,nativeButton:f,nodeId:b?.nodeId,itemMetadata:y3}),S=v.useMemo(()=>({disabled:m,highlighted:N}),[m,N]);return xr("div",t,{state:S,props:[T,g,k],ref:[C,n,x.ref]})}),Cl=0;class No{static create(){return new No}currentId=Cl;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Cl,n()},t)}isStarted(){return this.currentId!==Cl}clear=()=>{this.currentId!==Cl&&(clearTimeout(this.currentId),this.currentId=Cl)};disposeEffect=()=>this.clear}function Us(){const e=Es(No.create).current;return Ek(e.disposeEffect),e}const Mo=typeof navigator<"u",Zm=z3(),Ak=$3(),Rk=L3(),_3=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),O3=Zm.platform==="MacIntel"&&Zm.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Zm.platform),I3=Mo&&/apple/i.test(navigator.vendor),Xp=Mo&&/android/i.test(Ak)||/android/i.test(Rk);Mo&&Ak.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const D3=Rk.includes("jsdom/");function z3(){if(!Mo)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 L3(){if(!Mo)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function $3(){if(!Mo)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Kp="data-base-ui-focusable",Mk="active",_k="selected",Ok="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",ur="ArrowLeft",dr="ArrowRight",tv="ArrowUp",dc="ArrowDown";function rr(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function _t(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Gp(n)){let a=t;for(;a;){if(e===a)return!0;a=a.parentNode||a.host}}return!1}function Gn(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Ds(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 P3(e){return e.matches("html,body")}function Cn(e){return e?.ownerDocument||document}function U3(e){return Qt(e)&&e.matches(Ok)}function Jp(e){return e?e.getAttribute("role")==="combobox"&&U3(e):!1}function Rd(e){return e?e.hasAttribute(Kp)?e:e.querySelector(`[${Kp}]`)||e:null}function vo(e,t,n=!0){return e.filter(i=>i.parentId===t&&(!n||i.context?.open)).flatMap(i=>[i,...vo(e,i.id,n)])}function Xw(e,t){let n=[],a=e.find(i=>i.id===t)?.parentId;for(;a;){const i=e.find(c=>c.id===a);a=i?.parentId,i&&(n=n.concat(i))}return n}function Tn(e){e.preventDefault(),e.stopPropagation()}function B3(e){return"nativeEvent"in e}function Ik(e){return e.mozInputSource===0&&e.isTrusted?!0:Xp&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Dk(e){return D3?!1:!Xp&&e.width===0&&e.height===0||Xp&&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 V3(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function H3(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Z3=["top","right","bottom","left"],ko=Math.min,rs=Math.max,Md=Math.round,co=Math.floor,Qs=e=>({x:e,y:e}),F3={left:"right",right:"left",bottom:"top",top:"bottom"},q3={start:"end",end:"start"};function Qp(e,t,n){return rs(e,ko(t,n))}function Ca(e,t){return typeof e=="function"?e(t):e}function is(e){return e.split("-")[0]}function wr(e){return e.split("-")[1]}function nv(e){return e==="x"?"y":"x"}function sv(e){return e==="y"?"height":"width"}const Y3=new Set(["top","bottom"]);function js(e){return Y3.has(is(e))?"y":"x"}function av(e){return nv(js(e))}function G3(e,t,n){n===void 0&&(n=!1);const a=wr(e),i=av(e),c=sv(i);let u=i==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return t.reference[c]>t.floating[c]&&(u=_d(u)),[u,_d(u)]}function W3(e){const t=_d(e);return[eg(e),t,eg(t)]}function eg(e){return e.replace(/start|end/g,t=>q3[t])}const Kw=["left","right"],Jw=["right","left"],X3=["top","bottom"],K3=["bottom","top"];function J3(e,t,n){switch(e){case"top":case"bottom":return n?t?Jw:Kw:t?Kw:Jw;case"left":case"right":return t?X3:K3;default:return[]}}function Q3(e,t,n,a){const i=wr(e);let c=J3(is(e),n==="start",a);return i&&(c=c.map(u=>u+"-"+i),t&&(c=c.concat(c.map(eg)))),c}function _d(e){return e.replace(/left|right|bottom|top/g,t=>F3[t])}function eL(e){return{top:0,right:0,bottom:0,left:0,...e}}function zk(e){return typeof e!="number"?eL(e):{top:e,right:e,bottom:e,left:e}}function Od(e){const{x:t,y:n,width:a,height:i}=e;return{width:a,height:i,top:n,left:t,right:t+a,bottom:n+i,x:t,y:n}}function zu(e,t,n){return Math.floor(e/t)!==n}function Ul(e,t){return t<0||t>=e.current.length}function Fm(e,t){return Mn(e,{disabledIndices:t})}function Qw(e,t){return Mn(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Mn(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:a,amount:i=1}={}){let c=t;do c+=n?-i:i;while(c>=0&&c<=e.current.length-1&&Bl(e,c,a));return c}function tL(e,{event:t,orientation:n,loopFocus:a,rtl:i,cols:c,disabledIndices:u,minIndex:f,maxIndex:m,prevIndex:h,stopEvent:g=!1}){let x=h;const b=[],w={};let j=!1;{let k=null,C=-1;e.current.forEach((S,R)=>{if(S==null)return;const A=S.closest('[role="row"]');A&&(j=!0),(A!==k||C===-1)&&(k=A,C+=1,b[C]=[]),b[C].push(R),w[R]=C})}const N=j&&b.length>0&&b.some(k=>k.length!==c);function T(k){if(!N||h===-1)return;const C=w[h];if(C==null)return;const S=b[C].indexOf(h);let R=k==="up"?C-1:C+1;a&&(R<0?R=b.length-1:R>=b.length&&(R=0));const A=new Set;for(;R>=0&&R<b.length&&!A.has(R);){A.add(R);const M=b[R];if(M.length===0){R=k==="up"?R-1:R+1;continue}const O=Math.min(S,M.length-1);for(let V=O;V>=0;V-=1){const F=M[V];if(!Bl(e,F,u))return F}R=k==="up"?R-1:R+1,a&&(R<0?R=b.length-1:R>=b.length&&(R=0))}}if(t.key===tv){const k=T("up");if(k!==void 0)g&&Tn(t),x=k;else{if(g&&Tn(t),h===-1)x=m;else if(x=Mn(e,{startingIndex:x,amount:c,decrement:!0,disabledIndices:u}),a&&(h-c<f||x<0)){const C=h%c,S=m%c,R=m-(S-C);S===C?x=m:x=S>C?R:R-c}Ul(e,x)&&(x=h)}}if(t.key===dc){const k=T("down");k!==void 0?(g&&Tn(t),x=k):(g&&Tn(t),h===-1?x=f:(x=Mn(e,{startingIndex:h,amount:c,disabledIndices:u}),a&&h+c>m&&(x=Mn(e,{startingIndex:h%c-c,amount:c,disabledIndices:u}))),Ul(e,x)&&(x=h))}if(n==="both"){const k=co(h/c);t.key===(i?ur:dr)&&(g&&Tn(t),h%c!==c-1?(x=Mn(e,{startingIndex:h,disabledIndices:u}),a&&zu(x,c,k)&&(x=Mn(e,{startingIndex:h-h%c-1,disabledIndices:u}))):a&&(x=Mn(e,{startingIndex:h-h%c-1,disabledIndices:u})),zu(x,c,k)&&(x=h)),t.key===(i?dr:ur)&&(g&&Tn(t),h%c!==0?(x=Mn(e,{startingIndex:h,decrement:!0,disabledIndices:u}),a&&zu(x,c,k)&&(x=Mn(e,{startingIndex:h+(c-h%c),decrement:!0,disabledIndices:u}))):a&&(x=Mn(e,{startingIndex:h+(c-h%c),decrement:!0,disabledIndices:u})),zu(x,c,k)&&(x=h));const C=co(m/c)===k;Ul(e,x)&&(a&&C?x=t.key===(i?dr:ur)?m:Mn(e,{startingIndex:h-h%c-1,disabledIndices:u}):x=h)}return x}function nL(e,t,n){const a=[];let i=0;return e.forEach(({width:c,height:u},f)=>{let m=!1;for(n&&(i=0);!m;){const h=[];for(let g=0;g<c;g+=1)for(let x=0;x<u;x+=1)h.push(i+g+x*t);i%t+c<=t&&h.every(g=>a[g]==null)?(h.forEach(g=>{a[g]=f}),m=!0):i+=1}}),[...a]}function sL(e,t,n,a,i){if(e===-1)return-1;const c=n.indexOf(e),u=t[e];switch(i){case"tl":return c;case"tr":return u?c+u.width-1:c;case"bl":return u?c+(u.height-1)*a:c;case"br":return n.lastIndexOf(e);default:return-1}}function aL(e,t){return t.flatMap((n,a)=>e.includes(n)?[a]:[])}function Bl(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const a=e.current[t];return a?a.hasAttribute("disabled")||a.getAttribute("aria-disabled")==="true":!1}var rL=["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] *)"],Id=rL.join(","),Lk=typeof Element>"u",Eo=Lk?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Dd=!Lk&&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},zd=function(t,n){var a;n===void 0&&(n=!0);var i=t==null||(a=t.getAttribute)===null||a===void 0?void 0:a.call(t,"inert"),c=i===""||i==="true",u=c||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):zd(t.parentNode));return u},iL=function(t){var n,a=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return a===""||a==="true"},$k=function(t,n,a){if(zd(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(Id));return n&&Eo.call(t,Id)&&i.unshift(t),i=i.filter(a),i},Ld=function(t,n,a){for(var i=[],c=Array.from(t);c.length;){var u=c.shift();if(!zd(u,!1))if(u.tagName==="SLOT"){var f=u.assignedElements(),m=f.length?f:u.children,h=Ld(m,!0,a);a.flatten?i.push.apply(i,h):i.push({scopeParent:u,candidates:h})}else{var g=Eo.call(u,Id);g&&a.filter(u)&&(n||!t.includes(u))&&i.push(u);var x=u.shadowRoot||typeof a.getShadowRoot=="function"&&a.getShadowRoot(u),b=!zd(x,!1)&&(!a.shadowRootFilter||a.shadowRootFilter(u));if(x&&b){var w=Ld(x===!0?u.children:x.children,!0,a);a.flatten?i.push.apply(i,w):i.push({scopeParent:u,candidates:w})}else c.unshift.apply(c,u.children)}}return i},Pk=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Uk=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||iL(t))&&!Pk(t)?0:t.tabIndex},oL=function(t,n){var a=Uk(t);return a<0&&n&&!Pk(t)?0:a},lL=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Bk=function(t){return t.tagName==="INPUT"},cL=function(t){return Bk(t)&&t.type==="hidden"},uL=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(a){return a.tagName==="SUMMARY"});return n},dL=function(t,n){for(var a=0;a<t.length;a++)if(t[a].checked&&t[a].form===n)return t[a]},fL=function(t){if(!t.name)return!0;var n=t.form||Dd(t),a=function(f){return n.querySelectorAll('input[type="radio"][name="'+f+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=a(window.CSS.escape(t.name));else try{i=a(t.name)}catch(u){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",u.message),!1}var c=dL(i,t.form);return!c||c===t},hL=function(t){return Bk(t)&&t.type==="radio"},mL=function(t){return hL(t)&&!fL(t)},pL=function(t){var n,a=t&&Dd(t),i=(n=a)===null||n===void 0?void 0:n.host,c=!1;if(a&&a!==t){var u,f,m;for(c=!!((u=i)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(i)||t!=null&&(m=t.ownerDocument)!==null&&m!==void 0&&m.contains(t));!c&&i;){var h,g,x;a=Dd(i),i=(h=a)===null||h===void 0?void 0:h.host,c=!!((g=i)!==null&&g!==void 0&&(x=g.ownerDocument)!==null&&x!==void 0&&x.contains(i))}}return c},e1=function(t){var n=t.getBoundingClientRect(),a=n.width,i=n.height;return a===0&&i===0},gL=function(t,n){var a=n.displayCheck,i=n.getShadowRoot;if(a==="full-native"&&"checkVisibility"in t){var c=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!c}if(getComputedStyle(t).visibility==="hidden")return!0;var u=Eo.call(t,"details>summary:first-of-type"),f=u?t.parentElement:t;if(Eo.call(f,"details:not([open]) *"))return!0;if(!a||a==="full"||a==="full-native"||a==="legacy-full"){if(typeof i=="function"){for(var m=t;t;){var h=t.parentElement,g=Dd(t);if(h&&!h.shadowRoot&&i(h)===!0)return e1(t);t.assignedSlot?t=t.assignedSlot:!h&&g!==t.ownerDocument?t=g.host:t=h}t=m}if(pL(t))return!t.getClientRects().length;if(a!=="legacy-full")return!0}else if(a==="non-zero-area")return e1(t);return!1},vL=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var a=0;a<n.children.length;a++){var i=n.children.item(a);if(i.tagName==="LEGEND")return Eo.call(n,"fieldset[disabled] *")?!0:!i.contains(t)}return!0}n=n.parentElement}return!1},tg=function(t,n){return!(n.disabled||cL(n)||gL(n,t)||uL(n)||vL(n))},ng=function(t,n){return!(mL(n)||Uk(n)<0||!tg(t,n))},yL=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Vk=function(t){var n=[],a=[];return t.forEach(function(i,c){var u=!!i.scopeParent,f=u?i.scopeParent:i,m=oL(f,u),h=u?Vk(i.candidates):f;m===0?u?n.push.apply(n,h):n.push(f):a.push({documentOrder:c,tabIndex:m,item:i,isScope:u,content:h})}),a.sort(lL).reduce(function(i,c){return c.isScope?i.push.apply(i,c.content):i.push(c.content),i},[]).concat(n)},ff=function(t,n){n=n||{};var a;return n.getShadowRoot?a=Ld([t],n.includeContainer,{filter:ng.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:yL}):a=$k(t,n.includeContainer,ng.bind(null,n)),Vk(a)},xL=function(t,n){n=n||{};var a;return n.getShadowRoot?a=Ld([t],n.includeContainer,{filter:tg.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):a=$k(t,n.includeContainer,tg.bind(null,n)),a},Hk=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Eo.call(t,Id)===!1?!1:ng(n,t)};const fc=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Zk(e,t){const n=ff(e,fc()),a=n.length;if(a===0)return;const i=rr(Cn(e)),c=n.indexOf(i),u=c===-1?t===1?0:a-1:c+t;return n[u]}function Fk(e){return Zk(Cn(e).body,1)||e}function qk(e){return Zk(Cn(e).body,-1)||e}function Vl(e,t){const n=t||e.currentTarget,a=e.relatedTarget;return!a||!_t(n,a)}function bL(e){ff(e,fc()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function t1(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const a=n.dataset.tabindex;delete n.dataset.tabindex,a?n.setAttribute("tabindex",a):n.removeAttribute("tabindex")})}function Yk(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(a=>a(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 Gk{nodesRef={current:[]};events=Yk();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(a=>a===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const Wk=v.createContext(null),Xk=v.createContext(null),Sr=()=>v.useContext(Wk)?.id||null,_o=e=>{const t=v.useContext(Xk);return e??t};function wL(e){const t=yr(),n=_o(e),a=Sr();return Ze(()=>{if(!t)return;const i={id:t,parentId:a};return n?.addNode(i),()=>{n?.removeNode(i)}},[n,t,a]),t}function SL(e){const{children:t,id:n}=e,a=Sr();return o.jsx(Wk.Provider,{value:v.useMemo(()=>({id:n,parentId:a}),[n,a]),children:t})}function jL(e){const{children:t,externalTree:n}=e,a=Es(()=>n??new Gk).current;return o.jsx(Xk.Provider,{value:a,children:t})}function tc(e){return`data-base-ui-${e}`}const Kk={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 si(e){return e?.ownerDocument||document}const $d=v.forwardRef(function(t,n){const[a,i]=v.useState();Ze(()=>{I3&&i("button")},[]);const c={tabIndex:0,role:a};return o.jsx("span",{...t,ref:n,style:Kk,"aria-hidden":a?void 0:!0,...c,"data-base-ui-focus-guard":""})});let n1=0;function cd(e,t={}){const{preventScroll:n=!1,cancelPrevious:a=!0,sync:i=!1}=t;a&&cancelAnimationFrame(n1);const c=()=>e?.focus({preventScroll:n});i?c():n1=requestAnimationFrame(c)}const yo={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function s1(e){return e==="inert"?yo.inert:e==="aria-hidden"?yo["aria-hidden"]:yo.none}let Lu=new WeakSet,$u={},qm=0;const Jk=e=>e&&(e.host||Jk(e.parentNode)),NL=(e,t)=>t.map(n=>{if(e.contains(n))return n;const a=Jk(n);return e.contains(a)?a:null}).filter(n=>n!=null);function kL(e,t,n,a){const i="data-base-ui-inert",c=a?"inert":n?"aria-hidden":null,u=NL(t,e),f=new Set,m=new Set(u),h=[];$u[i]||($u[i]=new WeakMap);const g=$u[i];u.forEach(x),b(t),f.clear();function x(w){!w||f.has(w)||(f.add(w),w.parentNode&&x(w.parentNode))}function b(w){!w||m.has(w)||[].forEach.call(w.children,j=>{if(br(j)!=="script")if(f.has(j))b(j);else{const N=c?j.getAttribute(c):null,T=N!==null&&N!=="false",k=s1(c),C=(k.get(j)||0)+1,S=(g.get(j)||0)+1;k.set(j,C),g.set(j,S),h.push(j),C===1&&T&&Lu.add(j),S===1&&j.setAttribute(i,""),!T&&c&&j.setAttribute(c,c==="inert"?"":"true")}})}return qm+=1,()=>{h.forEach(w=>{const j=s1(c),T=(j.get(w)||0)-1,k=(g.get(w)||0)-1;j.set(w,T),g.set(w,k),T||(!Lu.has(w)&&c&&w.removeAttribute(c),Lu.delete(w)),k||w.removeAttribute(i)}),qm-=1,qm||(yo.inert=new WeakMap,yo["aria-hidden"]=new WeakMap,yo.none=new WeakMap,Lu=new WeakSet,$u={})}}function EL(e,t=!1,n=!1){const a=Cn(e[0]).body;return kL(e.concat(Array.from(a.querySelectorAll("[aria-live]"))),a,t,n)}const Qk=v.createContext(null),eE=()=>v.useContext(Qk),CL=tc("portal");function TL(e={}){const{ref:t,container:n,componentProps:a=Wn,elementProps:i,elementState:c}=e,u=yr(),m=eE()?.portalNode,[h,g]=v.useState(null),[x,b]=v.useState(null),w=v.useRef(null);Ze(()=>{if(n===null){w.current&&(w.current=null,b(null),g(null));return}if(u==null)return;const T=(n&&(Jg(n)?n:n.current))??m??document.body;if(T==null){w.current&&(w.current=null,b(null),g(null));return}w.current!==T&&(w.current=T,b(null),g(T))},[n,m,u]);const j=xr("div",a,{ref:[t,b],state:c,props:[{id:u,[CL]:""},i]});return{portalNode:x,portalSubtree:h&&j?ni.createPortal(j,h):null}}const AL=v.forwardRef(function(t,n){const{children:a,container:i,className:c,render:u,renderGuards:f,...m}=t,{portalNode:h,portalSubtree:g}=TL({container:i,ref:n,componentProps:t,elementProps:m}),x=v.useRef(null),b=v.useRef(null),w=v.useRef(null),j=v.useRef(null),[N,T]=v.useState(null),k=N?.modal,C=N?.open,S=typeof f=="boolean"?f:!!N&&!N.modal&&N.open&&!!h;v.useEffect(()=>{if(!h||k)return;function A(M){h&&Vl(M)&&(M.type==="focusin"?t1:bL)(h)}return h.addEventListener("focusin",A,!0),h.addEventListener("focusout",A,!0),()=>{h.removeEventListener("focusin",A,!0),h.removeEventListener("focusout",A,!0)}},[h,k]),v.useEffect(()=>{!h||C||t1(h)},[C,h]);const R=v.useMemo(()=>({beforeOutsideRef:x,afterOutsideRef:b,beforeInsideRef:w,afterInsideRef:j,portalNode:h,setFocusManagerState:T}),[h]);return o.jsxs(v.Fragment,{children:[g,o.jsxs(Qk.Provider,{value:R,children:[S&&h&&o.jsx($d,{"data-type":"outside",ref:x,onFocus:A=>{if(Vl(A,h))w.current?.focus();else{const M=N?N.domReference:null;qk(M)?.focus()}}}),S&&h&&o.jsx("span",{"aria-owns":h.id,style:P4}),h&&ni.createPortal(a,h),S&&h&&o.jsx($d,{"data-type":"outside",ref:b,onFocus:A=>{if(Vl(A,h))j.current?.focus();else{const M=N?N.domReference:null;Fk(M)?.focus(),N?.closeOnFocusOut&&N?.onOpenChange(!1,rn(of,A.nativeEvent))}}})]})]})});function RL(e,t){const n=An(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 a1=20;let ir=[];function rv(){ir=ir.filter(e=>e.isConnected)}function ML(e){rv(),e&&br(e)!=="body"&&(ir.push(e),ir.length>a1&&(ir=ir.slice(-a1)))}function Ym(){return rv(),ir[ir.length-1]}function _L(e){if(!e)return null;const t=fc();return Hk(e,t)?e:ff(e,t)[0]||e}function OL(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():us(e).display!=="none"}function r1(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=fc(),i=xL(e,n).filter(u=>{const f=u.getAttribute("data-tabindex")||"";return Hk(u,n)||u.hasAttribute("data-tabindex")&&!f.startsWith("-")}),c=e.getAttribute("tabindex");t.current.includes("floating")||i.length===0?c!=="0"&&e.setAttribute("tabindex","0"):(c!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function IL(e){const{context:t,children:n,disabled:a=!1,order:i=["content"],initialFocus:c=!0,returnFocus:u=!0,restoreFocus:f=!1,modal:m=!0,closeOnFocusOut:h=!0,openInteractionType:g="",getInsideElements:x=()=>[],nextFocusableElement:b,previousFocusableElement:w,beforeContentFocusGuardRef:j,externalTree:N}=e,T="rootStore"in t?t.rootStore:t,k=T.useState("open"),C=T.useState("domReferenceElement"),S=T.useState("floatingElement"),{events:R,dataRef:A}=T.context,M=qe(()=>A.current.floatingContext?.nodeId),O=qe(x),V=c===!1,F=Jp(C)&&V,I=Yn(i),$=Yn(c),L=Yn(u),U=Yn(g),Y=_o(N),K=eE(),D=v.useRef(null),P=v.useRef(null),B=v.useRef(!1),G=v.useRef(!1),X=v.useRef(!1),z=v.useRef(-1),Z=v.useRef(""),J=v.useRef(""),Q=Us(),pe=Us(),re=ev(),de=K!=null,fe=Rd(S),xe=qe((we=fe)=>we?ff(we,fc()):[]),Re=qe(we=>{const ke=xe(we);return I.current.map(()=>ke).filter(Boolean).flat()});v.useEffect(()=>{if(a||!m)return;function we(Ye){Ye.key==="Tab"&&_t(fe,rr(Cn(fe)))&&xe().length===0&&!F&&Tn(Ye)}const ke=Cn(fe);return ke.addEventListener("keydown",we),()=>{ke.removeEventListener("keydown",we)}},[a,C,fe,m,I,F,xe,Re]),v.useEffect(()=>{if(a||!S)return;function we(ke){const Ye=Gn(ke),He=xe().indexOf(Ye);He!==-1&&(z.current=He)}return S.addEventListener("focusin",we),()=>{S.removeEventListener("focusin",we)}},[a,S,xe]),v.useEffect(()=>{if(a||!k)return;const we=Cn(fe);function ke(){X.current=!1}function Ye(He){const le=Gn(He),ge=_t(S,le)||_t(C,le)||_t(K?.portalNode,le);X.current=!ge,J.current=He.pointerType||"keyboard"}function Ue(){J.current="keyboard"}return we.addEventListener("pointerdown",Ye,!0),we.addEventListener("pointerup",ke,!0),we.addEventListener("pointercancel",ke,!0),we.addEventListener("keydown",Ue,!0),()=>{we.removeEventListener("pointerdown",Ye,!0),we.removeEventListener("pointerup",ke,!0),we.removeEventListener("pointercancel",ke,!0),we.removeEventListener("keydown",Ue,!0)}},[a,S,C,fe,k,K]),v.useEffect(()=>{if(a||!h)return;function we(){G.current=!0,pe.start(0,()=>{G.current=!1})}function ke(le){const ge=le.relatedTarget,ve=le.currentTarget,je=Gn(le);queueMicrotask(()=>{const Ne=M(),Je=T.context.triggerElements,et=!(_t(C,ge)||_t(S,ge)||_t(ge,S)||_t(K?.portalNode,ge)||ge!=null&&Je.hasElement(ge)||Je.hasMatchingElement(Ge=>_t(Ge,ge))||ge?.hasAttribute(tc("focus-guard"))||Y&&(vo(Y.nodesRef.current,Ne).find(Ge=>_t(Ge.context?.elements.floating,ge)||_t(Ge.context?.elements.domReference,ge))||Xw(Y.nodesRef.current,Ne).find(Ge=>[Ge.context?.elements.floating,Rd(Ge.context?.elements.floating)].includes(ge)||Ge.context?.elements.domReference===ge)));if(ve===C&&fe&&r1(fe,I),f&&ve!==C&&!OL(je)&&rr(Cn(fe))===Cn(fe).body){if(Qt(fe)&&(fe.focus(),f==="popup")){re.request(()=>{fe.focus()});return}const Ge=z.current,Bt=xe(),kt=Bt[Ge]||Bt[Bt.length-1]||fe;Qt(kt)&&kt.focus()}if(A.current.insideReactTree){A.current.insideReactTree=!1;return}(F||!m)&&ge&&et&&!G.current&&(F||ge!==Ym())&&(B.current=!0,T.setOpen(!1,rn(of,le)))})}function Ye(){X.current||(A.current.insideReactTree=!0,Q.start(0,()=>{A.current.insideReactTree=!1}))}const Ue=Qt(C)?C:null,He=[];if(!(!S&&!Ue))return Ue&&(Ue.addEventListener("focusout",ke),Ue.addEventListener("pointerdown",we),He.push(()=>{Ue.removeEventListener("focusout",ke),Ue.removeEventListener("pointerdown",we)})),S&&(S.addEventListener("focusout",ke),K&&(S.addEventListener("focusout",Ye,!0),He.push(()=>{S.removeEventListener("focusout",Ye,!0)})),He.push(()=>{S.removeEventListener("focusout",ke)})),()=>{He.forEach(le=>{le()})}},[a,C,S,fe,m,Y,K,T,h,f,xe,F,M,I,A,Q,pe,re]);const he=v.useRef(null),Me=v.useRef(null),Se=ec(he,j,K?.beforeInsideRef),Ve=ec(Me,K?.afterInsideRef);v.useEffect(()=>{if(a||!S||!k)return;const we=Array.from(K?.portalNode?.querySelectorAll(`[${tc("portal")}]`)||[]),Ye=(Y?Xw(Y.nodesRef.current,M()):[]).find(le=>Jp(le.context?.elements.domReference||null))?.context?.elements.domReference,Ue=[S,Ye,...we,...O(),D.current,P.current,he.current,Me.current,K?.beforeOutsideRef.current,K?.afterOutsideRef.current,Zr(w),Zr(b),F?C:null].filter(le=>le!=null),He=EL(Ue,m||F);return()=>{He()}},[k,a,C,S,m,I,K,F,Y,M,O,b,w]),Ze(()=>{if(!k||a||!Qt(fe))return;const we=Cn(fe),ke=rr(we);queueMicrotask(()=>{const Ye=Re(fe),Ue=$.current,He=typeof Ue=="function"?Ue(U.current||""):Ue;if(He===void 0||He===!1)return;let le;He===!0||He===null?le=Ye[0]||fe:le=Zr(He),le=le||Ye[0]||fe,!_t(fe,ke)&&cd(le,{preventScroll:le===fe})})},[a,k,fe,V,Re,$,U]),Ze(()=>{if(a||!fe)return;const we=Cn(fe),ke=rr(we);ML(ke);function Ye(le){if(le.open||(Z.current=RL(le.nativeEvent,J.current)),le.reason===Xr&&le.nativeEvent.type==="mouseleave"&&(B.current=!0),le.reason===Kg)if(le.nested)B.current=!1;else if(Ik(le.nativeEvent)||Dk(le.nativeEvent))B.current=!1;else{let ge=!1;document.createElement("div").focus({get preventScroll(){return ge=!0,!1}}),ge?B.current=!1:B.current=!0}}R.on("openchange",Ye);const Ue=we.createElement("span");Ue.setAttribute("tabindex","-1"),Ue.setAttribute("aria-hidden","true"),Object.assign(Ue.style,Kk),de&&C&&C.insertAdjacentElement("afterend",Ue);function He(){const le=L.current;let ge=typeof le=="function"?le(Z.current):le;if(ge===void 0||ge===!1)return null;if(ge===null&&(ge=!0),typeof ge=="boolean"){const je=C||Ym();return je&&je.isConnected?je:Ue}const ve=C||Ym()||Ue;return Zr(ge)||ve}return()=>{R.off("openchange",Ye);const le=rr(we),ge=_t(S,le)||Y&&vo(Y.nodesRef.current,M(),!1).some(je=>_t(je.context?.elements.floating,le)),ve=He();queueMicrotask(()=>{const je=_L(ve),Ne=typeof L.current!="boolean";L.current&&!B.current&&Qt(je)&&(!(!Ne&&je!==le&&le!==we.body)||ge)&&je.focus({preventScroll:!0}),Ue.remove()})}},[a,S,fe,L,A,R,Y,de,C,M]),v.useEffect(()=>{queueMicrotask(()=>{B.current=!1})},[a]),v.useEffect(()=>{if(a||!k)return;function we(Ye){Gn(Ye)?.closest(`[${L4}]`)&&(G.current=!0)}const ke=Cn(fe);return ke.addEventListener("pointerdown",we,!0),()=>{ke.removeEventListener("pointerdown",we,!0)}},[a,k,fe]),Ze(()=>{if(!a&&K)return K.setFocusManagerState({modal:m,closeOnFocusOut:h,open:k,onOpenChange:T.setOpen,domReference:C}),()=>{K.setFocusManagerState(null)}},[a,K,m,k,T,h,C]),Ze(()=>{if(!(a||!fe))return r1(fe,I),()=>{queueMicrotask(rv)}},[a,fe,I]);const Oe=!a&&(m?!F:!0)&&(de||m);return o.jsxs(v.Fragment,{children:[Oe&&o.jsx($d,{"data-type":"inside",ref:Se,onFocus:we=>{if(m){const ke=Re();cd(ke[ke.length-1])}else K?.portalNode&&(B.current=!1,Vl(we,K.portalNode)?Fk(C)?.focus():Zr(w??K.beforeOutsideRef)?.focus())}}),n,Oe&&o.jsx($d,{"data-type":"inside",ref:Ve,onFocus:we=>{m?cd(Re()[0]):K?.portalNode&&(h&&(B.current=!0),Vl(we,K.portalNode)?qk(C)?.focus():Zr(b??K.afterOutsideRef)?.focus())}})]})}function i1(e,t,n){let{reference:a,floating:i}=e;const c=js(t),u=av(t),f=sv(u),m=is(t),h=c==="y",g=a.x+a.width/2-i.width/2,x=a.y+a.height/2-i.height/2,b=a[f]/2-i[f]/2;let w;switch(m){case"top":w={x:g,y:a.y-i.height};break;case"bottom":w={x:g,y:a.y+a.height};break;case"right":w={x:a.x+a.width,y:x};break;case"left":w={x:a.x-i.width,y:x};break;default:w={x:a.x,y:a.y}}switch(wr(t)){case"start":w[u]-=b*(n&&h?-1:1);break;case"end":w[u]+=b*(n&&h?-1:1);break}return w}async function DL(e,t){var n;t===void 0&&(t={});const{x:a,y:i,platform:c,rects:u,elements:f,strategy:m}=e,{boundary:h="clippingAncestors",rootBoundary:g="viewport",elementContext:x="floating",altBoundary:b=!1,padding:w=0}=Ca(t,e),j=zk(w),T=f[b?x==="floating"?"reference":"floating":x],k=Od(await c.getClippingRect({element:(n=await(c.isElement==null?void 0:c.isElement(T)))==null||n?T:T.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(f.floating)),boundary:h,rootBoundary:g,strategy:m})),C=x==="floating"?{x:a,y:i,width:u.floating.width,height:u.floating.height}:u.reference,S=await(c.getOffsetParent==null?void 0:c.getOffsetParent(f.floating)),R=await(c.isElement==null?void 0:c.isElement(S))?await(c.getScale==null?void 0:c.getScale(S))||{x:1,y:1}:{x:1,y:1},A=Od(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:C,offsetParent:S,strategy:m}):C);return{top:(k.top-A.top+j.top)/R.y,bottom:(A.bottom-k.bottom+j.bottom)/R.y,left:(k.left-A.left+j.left)/R.x,right:(A.right-k.right+j.right)/R.x}}const zL=async(e,t,n)=>{const{placement:a="bottom",strategy:i="absolute",middleware:c=[],platform:u}=n,f=c.filter(Boolean),m=await(u.isRTL==null?void 0:u.isRTL(t));let h=await u.getElementRects({reference:e,floating:t,strategy:i}),{x:g,y:x}=i1(h,a,m),b=a,w={},j=0;for(let T=0;T<f.length;T++){var N;const{name:k,fn:C}=f[T],{x:S,y:R,data:A,reset:M}=await C({x:g,y:x,initialPlacement:a,placement:b,strategy:i,middlewareData:w,rects:h,platform:{...u,detectOverflow:(N=u.detectOverflow)!=null?N:DL},elements:{reference:e,floating:t}});g=S??g,x=R??x,w={...w,[k]:{...w[k],...A}},M&&j<=50&&(j++,typeof M=="object"&&(M.placement&&(b=M.placement),M.rects&&(h=M.rects===!0?await u.getElementRects({reference:e,floating:t,strategy:i}):M.rects),{x:g,y:x}=i1(h,b,m)),T=-1)}return{x:g,y:x,placement:b,strategy:i,middlewareData:w}},LL=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,a;const{placement:i,middlewareData:c,rects:u,initialPlacement:f,platform:m,elements:h}=t,{mainAxis:g=!0,crossAxis:x=!0,fallbackPlacements:b,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:N=!0,...T}=Ca(e,t);if((n=c.arrow)!=null&&n.alignmentOffset)return{};const k=is(i),C=js(f),S=is(f)===f,R=await(m.isRTL==null?void 0:m.isRTL(h.floating)),A=b||(S||!N?[_d(f)]:W3(f)),M=j!=="none";!b&&M&&A.push(...Q3(f,N,j,R));const O=[f,...A],V=await m.detectOverflow(t,T),F=[];let I=((a=c.flip)==null?void 0:a.overflows)||[];if(g&&F.push(V[k]),x){const Y=G3(i,u,R);F.push(V[Y[0]],V[Y[1]])}if(I=[...I,{placement:i,overflows:F}],!F.every(Y=>Y<=0)){var $,L;const Y=((($=c.flip)==null?void 0:$.index)||0)+1,K=O[Y];if(K&&(!(x==="alignment"?C!==js(K):!1)||I.every(B=>js(B.placement)===C?B.overflows[0]>0:!0)))return{data:{index:Y,overflows:I},reset:{placement:K}};let D=(L=I.filter(P=>P.overflows[0]<=0).sort((P,B)=>P.overflows[1]-B.overflows[1])[0])==null?void 0:L.placement;if(!D)switch(w){case"bestFit":{var U;const P=(U=I.filter(B=>{if(M){const G=js(B.placement);return G===C||G==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(G=>G>0).reduce((G,X)=>G+X,0)]).sort((B,G)=>B[1]-G[1])[0])==null?void 0:U[0];P&&(D=P);break}case"initialPlacement":D=f;break}if(i!==D)return{reset:{placement:D}}}return{}}}};function o1(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function l1(e){return Z3.some(t=>e[t]>=0)}const $L=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:a}=t,{strategy:i="referenceHidden",...c}=Ca(e,t);switch(i){case"referenceHidden":{const u=await a.detectOverflow(t,{...c,elementContext:"reference"}),f=o1(u,n.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:l1(f)}}}case"escaped":{const u=await a.detectOverflow(t,{...c,altBoundary:!0}),f=o1(u,n.floating);return{data:{escapedOffsets:f,escaped:l1(f)}}}default:return{}}}}},tE=new Set(["left","top"]);async function PL(e,t){const{placement:n,platform:a,elements:i}=e,c=await(a.isRTL==null?void 0:a.isRTL(i.floating)),u=is(n),f=wr(n),m=js(n)==="y",h=tE.has(u)?-1:1,g=c&&m?-1:1,x=Ca(t,e);let{mainAxis:b,crossAxis:w,alignmentAxis:j}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return f&&typeof j=="number"&&(w=f==="end"?j*-1:j),m?{x:w*g,y:b*h}:{x:b*h,y:w*g}}const UL=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:i,y:c,placement:u,middlewareData:f}=t,m=await PL(t,e);return u===((n=f.offset)==null?void 0:n.placement)&&(a=f.arrow)!=null&&a.alignmentOffset?{}:{x:i+m.x,y:c+m.y,data:{...m,placement:u}}}}},BL=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:i,platform:c}=t,{mainAxis:u=!0,crossAxis:f=!1,limiter:m={fn:k=>{let{x:C,y:S}=k;return{x:C,y:S}}},...h}=Ca(e,t),g={x:n,y:a},x=await c.detectOverflow(t,h),b=js(is(i)),w=nv(b);let j=g[w],N=g[b];if(u){const k=w==="y"?"top":"left",C=w==="y"?"bottom":"right",S=j+x[k],R=j-x[C];j=Qp(S,j,R)}if(f){const k=b==="y"?"top":"left",C=b==="y"?"bottom":"right",S=N+x[k],R=N-x[C];N=Qp(S,N,R)}const T=m.fn({...t,[w]:j,[b]:N});return{...T,data:{x:T.x-n,y:T.y-a,enabled:{[w]:u,[b]:f}}}}}},VL=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:a,placement:i,rects:c,middlewareData:u}=t,{offset:f=0,mainAxis:m=!0,crossAxis:h=!0}=Ca(e,t),g={x:n,y:a},x=js(i),b=nv(x);let w=g[b],j=g[x];const N=Ca(f,t),T=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(m){const S=b==="y"?"height":"width",R=c.reference[b]-c.floating[S]+T.mainAxis,A=c.reference[b]+c.reference[S]-T.mainAxis;w<R?w=R:w>A&&(w=A)}if(h){var k,C;const S=b==="y"?"width":"height",R=tE.has(is(i)),A=c.reference[x]-c.floating[S]+(R&&((k=u.offset)==null?void 0:k[x])||0)+(R?0:T.crossAxis),M=c.reference[x]+c.reference[S]+(R?0:((C=u.offset)==null?void 0:C[x])||0)-(R?T.crossAxis:0);j<A?j=A:j>M&&(j=M)}return{[b]:w,[x]:j}}}},HL=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:i,rects:c,platform:u,elements:f}=t,{apply:m=()=>{},...h}=Ca(e,t),g=await u.detectOverflow(t,h),x=is(i),b=wr(i),w=js(i)==="y",{width:j,height:N}=c.floating;let T,k;x==="top"||x==="bottom"?(T=x,k=b===(await(u.isRTL==null?void 0:u.isRTL(f.floating))?"start":"end")?"left":"right"):(k=x,T=b==="end"?"top":"bottom");const C=N-g.top-g.bottom,S=j-g.left-g.right,R=ko(N-g[T],C),A=ko(j-g[k],S),M=!t.middlewareData.shift;let O=R,V=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(V=S),(a=t.middlewareData.shift)!=null&&a.enabled.y&&(O=C),M&&!b){const I=rs(g.left,0),$=rs(g.right,0),L=rs(g.top,0),U=rs(g.bottom,0);w?V=j-2*(I!==0||$!==0?I+$:rs(g.left,g.right)):O=N-2*(L!==0||U!==0?L+U:rs(g.top,g.bottom))}await m({...t,availableWidth:V,availableHeight:O});const F=await u.getDimensions(f.floating);return j!==F.width||N!==F.height?{reset:{rects:!0}}:{}}}};function nE(e){const t=us(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const i=Qt(e),c=i?e.offsetWidth:n,u=i?e.offsetHeight:a,f=Md(n)!==c||Md(a)!==u;return f&&(n=c,a=u),{width:n,height:a,$:f}}function iv(e){return Ot(e)?e:e.contextElement}function xo(e){const t=iv(e);if(!Qt(t))return Qs(1);const n=t.getBoundingClientRect(),{width:a,height:i,$:c}=nE(t);let u=(c?Md(n.width):n.width)/a,f=(c?Md(n.height):n.height)/i;return(!u||!Number.isFinite(u))&&(u=1),(!f||!Number.isFinite(f))&&(f=1),{x:u,y:f}}const ZL=Qs(0);function sE(e){const t=An(e);return!uf()||!t.visualViewport?ZL:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function FL(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==An(e)?!1:t}function ai(e,t,n,a){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),c=iv(e);let u=Qs(1);t&&(a?Ot(a)&&(u=xo(a)):u=xo(e));const f=FL(c,n,a)?sE(c):Qs(0);let m=(i.left+f.x)/u.x,h=(i.top+f.y)/u.y,g=i.width/u.x,x=i.height/u.y;if(c){const b=An(c),w=a&&Ot(a)?An(a):a;let j=b,N=Wp(j);for(;N&&a&&w!==j;){const T=xo(N),k=N.getBoundingClientRect(),C=us(N),S=k.left+(N.clientLeft+parseFloat(C.paddingLeft))*T.x,R=k.top+(N.clientTop+parseFloat(C.paddingTop))*T.y;m*=T.x,h*=T.y,g*=T.x,x*=T.y,m+=S,h+=R,j=An(N),N=Wp(j)}}return Od({width:g,height:x,x:m,y:h})}function hf(e,t){const n=df(e).scrollLeft;return t?t.left+n:ai(ra(e)).left+n}function aE(e,t){const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-hf(e,n),i=n.top+t.scrollTop;return{x:a,y:i}}function qL(e){let{elements:t,rect:n,offsetParent:a,strategy:i}=e;const c=i==="fixed",u=ra(a),f=t?cf(t.floating):!1;if(a===u||f&&c)return n;let m={scrollLeft:0,scrollTop:0},h=Qs(1);const g=Qs(0),x=Qt(a);if((x||!x&&!c)&&((br(a)!=="body"||li(u))&&(m=df(a)),Qt(a))){const w=ai(a);h=xo(a),g.x=w.x+a.clientLeft,g.y=w.y+a.clientTop}const b=u&&!x&&!c?aE(u,m):Qs(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-m.scrollLeft*h.x+g.x+b.x,y:n.y*h.y-m.scrollTop*h.y+g.y+b.y}}function YL(e){return Array.from(e.getClientRects())}function GL(e){const t=ra(e),n=df(e),a=e.ownerDocument.body,i=rs(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),c=rs(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let u=-n.scrollLeft+hf(e);const f=-n.scrollTop;return us(a).direction==="rtl"&&(u+=rs(t.clientWidth,a.clientWidth)-i),{width:i,height:c,x:u,y:f}}const c1=25;function WL(e,t){const n=An(e),a=ra(e),i=n.visualViewport;let c=a.clientWidth,u=a.clientHeight,f=0,m=0;if(i){c=i.width,u=i.height;const g=uf();(!g||g&&t==="fixed")&&(f=i.offsetLeft,m=i.offsetTop)}const h=hf(a);if(h<=0){const g=a.ownerDocument,x=g.body,b=getComputedStyle(x),w=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,j=Math.abs(a.clientWidth-x.clientWidth-w);j<=c1&&(c-=j)}else h<=c1&&(c+=h);return{width:c,height:u,x:f,y:m}}const XL=new Set(["absolute","fixed"]);function KL(e,t){const n=ai(e,!0,t==="fixed"),a=n.top+e.clientTop,i=n.left+e.clientLeft,c=Qt(e)?xo(e):Qs(1),u=e.clientWidth*c.x,f=e.clientHeight*c.y,m=i*c.x,h=a*c.y;return{width:u,height:f,x:m,y:h}}function u1(e,t,n){let a;if(t==="viewport")a=WL(e,n);else if(t==="document")a=GL(ra(e));else if(Ot(t))a=KL(t,n);else{const i=sE(e);a={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Od(a)}function rE(e,t){const n=na(e);return n===t||!Ot(n)||Js(n)?!1:us(n).position==="fixed"||rE(n,t)}function JL(e,t){const n=t.get(e);if(n)return n;let a=cr(e,[],!1).filter(f=>Ot(f)&&br(f)!=="body"),i=null;const c=us(e).position==="fixed";let u=c?na(e):e;for(;Ot(u)&&!Js(u);){const f=us(u),m=Qg(u);!m&&f.position==="fixed"&&(i=null),(c?!m&&!i:!m&&f.position==="static"&&!!i&&XL.has(i.position)||li(u)&&!m&&rE(e,u))?a=a.filter(g=>g!==u):i=f,u=na(u)}return t.set(e,a),a}function QL(e){let{element:t,boundary:n,rootBoundary:a,strategy:i}=e;const u=[...n==="clippingAncestors"?cf(t)?[]:JL(t,this._c):[].concat(n),a],f=u[0],m=u.reduce((h,g)=>{const x=u1(t,g,i);return h.top=rs(x.top,h.top),h.right=ko(x.right,h.right),h.bottom=ko(x.bottom,h.bottom),h.left=rs(x.left,h.left),h},u1(t,f,i));return{width:m.right-m.left,height:m.bottom-m.top,x:m.left,y:m.top}}function e$(e){const{width:t,height:n}=nE(e);return{width:t,height:n}}function t$(e,t,n){const a=Qt(t),i=ra(t),c=n==="fixed",u=ai(e,!0,c,t);let f={scrollLeft:0,scrollTop:0};const m=Qs(0);function h(){m.x=hf(i)}if(a||!a&&!c)if((br(t)!=="body"||li(i))&&(f=df(t)),a){const w=ai(t,!0,c,t);m.x=w.x+t.clientLeft,m.y=w.y+t.clientTop}else i&&h();c&&!a&&i&&h();const g=i&&!a&&!c?aE(i,f):Qs(0),x=u.left+f.scrollLeft-m.x-g.x,b=u.top+f.scrollTop-m.y-g.y;return{x,y:b,width:u.width,height:u.height}}function Gm(e){return us(e).position==="static"}function d1(e,t){if(!Qt(e)||us(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ra(e)===n&&(n=n.ownerDocument.body),n}function iE(e,t){const n=An(e);if(cf(e))return n;if(!Qt(e)){let i=na(e);for(;i&&!Js(i);){if(Ot(i)&&!Gm(i))return i;i=na(i)}return n}let a=d1(e,t);for(;a&&r3(a)&&Gm(a);)a=d1(a,t);return a&&Js(a)&&Gm(a)&&!Qg(a)?n:a||u3(e)||n}const n$=async function(e){const t=this.getOffsetParent||iE,n=this.getDimensions,a=await n(e.floating);return{reference:t$(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function s$(e){return us(e).direction==="rtl"}const a$={convertOffsetParentRelativeRectToViewportRelativeRect:qL,getDocumentElement:ra,getClippingRect:QL,getOffsetParent:iE,getElementRects:n$,getClientRects:YL,getDimensions:e$,getScale:xo,isElement:Ot,isRTL:s$};function oE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function r$(e,t){let n=null,a;const i=ra(e);function c(){var f;clearTimeout(a),(f=n)==null||f.disconnect(),n=null}function u(f,m){f===void 0&&(f=!1),m===void 0&&(m=1),c();const h=e.getBoundingClientRect(),{left:g,top:x,width:b,height:w}=h;if(f||t(),!b||!w)return;const j=co(x),N=co(i.clientWidth-(g+b)),T=co(i.clientHeight-(x+w)),k=co(g),S={rootMargin:-j+"px "+-N+"px "+-T+"px "+-k+"px",threshold:rs(0,ko(1,m))||1};let R=!0;function A(M){const O=M[0].intersectionRatio;if(O!==m){if(!R)return u();O?u(!1,O):a=setTimeout(()=>{u(!1,1e-7)},1e3)}O===1&&!oE(h,e.getBoundingClientRect())&&u(),R=!1}try{n=new IntersectionObserver(A,{...S,root:i.ownerDocument})}catch{n=new IntersectionObserver(A,S)}n.observe(e)}return u(!0),c}function f1(e,t,n,a){a===void 0&&(a={});const{ancestorScroll:i=!0,ancestorResize:c=!0,elementResize:u=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:m=!1}=a,h=iv(e),g=i||c?[...h?cr(h):[],...cr(t)]:[];g.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),c&&k.addEventListener("resize",n)});const x=h&&f?r$(h,n):null;let b=-1,w=null;u&&(w=new ResizeObserver(k=>{let[C]=k;C&&C.target===h&&w&&(w.unobserve(t),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var S;(S=w)==null||S.observe(t)})),n()}),h&&!m&&w.observe(h),w.observe(t));let j,N=m?ai(e):null;m&&T();function T(){const k=ai(e);N&&!oE(N,k)&&n(),N=k,j=requestAnimationFrame(T)}return n(),()=>{var k;g.forEach(C=>{i&&C.removeEventListener("scroll",n),c&&C.removeEventListener("resize",n)}),x?.(),(k=w)==null||k.disconnect(),w=null,m&&cancelAnimationFrame(j)}}const i$=UL,o$=BL,l$=LL,c$=HL,u$=$L,d$=VL,f$=(e,t,n)=>{const a=new Map,i={platform:a$,...n},c={...i.platform,_c:a};return zL(e,t,{...i,platform:c})};var h$=typeof document<"u",m$=function(){},ud=h$?v.useLayoutEffect:m$;function Pd(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,a,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(a=n;a--!==0;)if(!Pd(e[a],t[a]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(t,i[a]))return!1;for(a=n;a--!==0;){const c=i[a];if(!(c==="_owner"&&e.$$typeof)&&!Pd(e[c],t[c]))return!1}return!0}return e!==e&&t!==t}function lE(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function h1(e,t){const n=lE(e);return Math.round(t*n)/n}function Wm(e){const t=v.useRef(e);return ud(()=>{t.current=e}),t}function p$(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:a=[],platform:i,elements:{reference:c,floating:u}={},transform:f=!0,whileElementsMounted:m,open:h}=e,[g,x]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[b,w]=v.useState(a);Pd(b,a)||w(a);const[j,N]=v.useState(null),[T,k]=v.useState(null),C=v.useCallback(B=>{B!==M.current&&(M.current=B,N(B))},[]),S=v.useCallback(B=>{B!==O.current&&(O.current=B,k(B))},[]),R=c||j,A=u||T,M=v.useRef(null),O=v.useRef(null),V=v.useRef(g),F=m!=null,I=Wm(m),$=Wm(i),L=Wm(h),U=v.useCallback(()=>{if(!M.current||!O.current)return;const B={placement:t,strategy:n,middleware:b};$.current&&(B.platform=$.current),f$(M.current,O.current,B).then(G=>{const X={...G,isPositioned:L.current!==!1};Y.current&&!Pd(V.current,X)&&(V.current=X,ni.flushSync(()=>{x(X)}))})},[b,t,n,$,L]);ud(()=>{h===!1&&V.current.isPositioned&&(V.current.isPositioned=!1,x(B=>({...B,isPositioned:!1})))},[h]);const Y=v.useRef(!1);ud(()=>(Y.current=!0,()=>{Y.current=!1}),[]),ud(()=>{if(R&&(M.current=R),A&&(O.current=A),R&&A){if(I.current)return I.current(R,A,U);U()}},[R,A,U,I,F]);const K=v.useMemo(()=>({reference:M,floating:O,setReference:C,setFloating:S}),[C,S]),D=v.useMemo(()=>({reference:R,floating:A}),[R,A]),P=v.useMemo(()=>{const B={position:n,left:0,top:0};if(!D.floating)return B;const G=h1(D.floating,g.x),X=h1(D.floating,g.y);return f?{...B,transform:"translate("+G+"px, "+X+"px)",...lE(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:X}},[n,f,D.floating,g.x,g.y]);return v.useMemo(()=>({...g,update:U,refs:K,elements:D,floatingStyles:P}),[g,U,K,D,P])}const g$=(e,t)=>({...i$(e),options:[e,t]}),v$=(e,t)=>({...o$(e),options:[e,t]}),y$=(e,t)=>({...d$(e),options:[e,t]}),x$=(e,t)=>({...l$(e),options:[e,t]}),b$=(e,t)=>({...c$(e),options:[e,t]}),w$=(e,t)=>({...u$(e),options:[e,t]}),S$={intentional:"onClick",sloppy:"onPointerDown"};function j$(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function N$(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingElement"),c=n.useState("referenceElement"),u=n.useState("domReferenceElement"),{onOpenChange:f,dataRef:m}=n.context,{enabled:h=!0,escapeKey:g=!0,outsidePress:x=!0,outsidePressEvent:b="sloppy",referencePress:w=!1,referencePressEvent:j="sloppy",ancestorScroll:N=!1,bubbles:T,externalTree:k}=t,C=_o(k),S=qe(typeof x=="function"?x:()=>!1),R=typeof x=="function"?S:x,A=v.useRef(!1),{escapeKey:M,outsidePress:O}=j$(T),V=v.useRef(null),F=Us(),I=Us(),$=qe(()=>{I.clear(),m.current.insideReactTree=!1}),L=v.useRef(!1),U=v.useRef(""),Y=qe(he=>{U.current=he.pointerType}),K=qe(()=>{const he=U.current,Me=he==="pen"||!he?"mouse":he,Se=typeof b=="function"?b():b;return typeof Se=="string"?Se:Se[Me]}),D=qe(he=>{if(!a||!h||!g||he.key!=="Escape"||L.current)return;const Me=m.current.floatingContext?.nodeId,Se=C?vo(C.nodesRef.current,Me):[];if(!M&&Se.length>0){let we=!0;if(Se.forEach(ke=>{ke.context?.open&&!ke.context.dataRef.current.__escapeKeyBubbles&&(we=!1)}),!we)return}const Ve=B3(he)?he.nativeEvent:he,Oe=rn(Sk,Ve);n.setOpen(!1,Oe),!M&&!Oe.isPropagationAllowed&&he.stopPropagation()}),P=qe(he=>{const Me=K();return Me==="intentional"&&he.type!=="click"||Me==="sloppy"&&he.type==="click"}),B=qe(()=>{m.current.insideReactTree=!0,I.start(0,$)}),G=qe((he,Me=!1)=>{if(P(he)){$();return}if(m.current.insideReactTree){$();return}if(K()==="intentional"&&Me||typeof R=="function"&&!R(he))return;const Se=Gn(he),Ve=`[${tc("inert")}]`,Oe=Cn(n.select("floatingElement")).querySelectorAll(Ve),we=n.context.triggerElements;if(Se&&(we.hasElement(Se)||we.hasMatchingElement(le=>_t(le,Se))))return;let ke=Ot(Se)?Se:null;for(;ke&&!Js(ke);){const le=na(ke);if(Js(le)||!Ot(le))break;ke=le}if(Oe.length&&Ot(Se)&&!P3(Se)&&!_t(Se,n.select("floatingElement"))&&Array.from(Oe).every(le=>!_t(ke,le)))return;if(Qt(Se)&&!("touches"in he)){const le=Js(Se),ge=us(Se),ve=/auto|scroll/,je=le||ve.test(ge.overflowX),Ne=le||ve.test(ge.overflowY),Je=je&&Se.clientWidth>0&&Se.scrollWidth>Se.clientWidth,et=Ne&&Se.clientHeight>0&&Se.scrollHeight>Se.clientHeight,Ge=ge.direction==="rtl",Bt=et&&(Ge?he.offsetX<=Se.offsetWidth-Se.clientWidth:he.offsetX>Se.clientWidth),kt=Je&&he.offsetY>Se.clientHeight;if(Bt||kt)return}const Ye=m.current.floatingContext?.nodeId,Ue=C&&vo(C.nodesRef.current,Ye).some(le=>Ds(he,le.context?.elements.floating));if(Ds(he,n.select("floatingElement"))||Ds(he,n.select("domReferenceElement"))||Ue)return;const He=C?vo(C.nodesRef.current,Ye):[];if(He.length>0){let le=!0;if(He.forEach(ge=>{ge.context?.open&&!ge.context.dataRef.current.__outsidePressBubbles&&(le=!1)}),!le)return}n.setOpen(!1,rn(Kg,he)),$()}),X=qe(he=>{K()!=="sloppy"||he.pointerType==="touch"||!n.select("open")||!h||Ds(he,n.select("floatingElement"))||Ds(he,n.select("domReferenceElement"))||G(he)}),z=qe(he=>{if(K()!=="sloppy"||!n.select("open")||!h||Ds(he,n.select("floatingElement"))||Ds(he,n.select("domReferenceElement")))return;const Me=he.touches[0];Me&&(V.current={startTime:Date.now(),startX:Me.clientX,startY:Me.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},F.start(1e3,()=>{V.current&&(V.current.dismissOnTouchEnd=!1,V.current.dismissOnMouseDown=!1)}))}),Z=qe(he=>{const Me=Gn(he);function Se(){z(he),Me?.removeEventListener(he.type,Se)}Me?.addEventListener(he.type,Se)}),J=qe(he=>{const Me=A.current;if(A.current=!1,F.clear(),he.type==="mousedown"&&V.current&&!V.current.dismissOnMouseDown)return;const Se=Gn(he);function Ve(){he.type==="pointerdown"?X(he):G(he,Me),Se?.removeEventListener(he.type,Ve)}Se?.addEventListener(he.type,Ve)}),Q=qe(he=>{if(K()!=="sloppy"||!V.current||Ds(he,n.select("floatingElement"))||Ds(he,n.select("domReferenceElement")))return;const Me=he.touches[0];if(!Me)return;const Se=Math.abs(Me.clientX-V.current.startX),Ve=Math.abs(Me.clientY-V.current.startY),Oe=Math.sqrt(Se*Se+Ve*Ve);Oe>5&&(V.current.dismissOnTouchEnd=!0),Oe>10&&(G(he),F.clear(),V.current=null)}),pe=qe(he=>{const Me=Gn(he);function Se(){Q(he),Me?.removeEventListener(he.type,Se)}Me?.addEventListener(he.type,Se)}),re=qe(he=>{K()!=="sloppy"||!V.current||Ds(he,n.select("floatingElement"))||Ds(he,n.select("domReferenceElement"))||(V.current.dismissOnTouchEnd&&G(he),F.clear(),V.current=null)}),de=qe(he=>{const Me=Gn(he);function Se(){re(he),Me?.removeEventListener(he.type,Se)}Me?.addEventListener(he.type,Se)});v.useEffect(()=>{if(!a||!h)return;m.current.__escapeKeyBubbles=M,m.current.__outsidePressBubbles=O;const he=new No;function Me(ke){n.setOpen(!1,rn(K4,ke))}function Se(){he.clear(),L.current=!0}function Ve(){he.start(uf()?5:0,()=>{L.current=!1})}const Oe=Cn(i);Oe.addEventListener("pointerdown",Y,!0),g&&(Oe.addEventListener("keydown",D),Oe.addEventListener("compositionstart",Se),Oe.addEventListener("compositionend",Ve)),R&&(Oe.addEventListener("click",J,!0),Oe.addEventListener("pointerdown",J,!0),Oe.addEventListener("touchstart",Z,!0),Oe.addEventListener("touchmove",pe,!0),Oe.addEventListener("touchend",de,!0),Oe.addEventListener("mousedown",J,!0));let we=[];return N&&(Ot(u)&&(we=cr(u)),Ot(i)&&(we=we.concat(cr(i))),!Ot(c)&&c&&c.contextElement&&(we=we.concat(cr(c.contextElement)))),we=we.filter(ke=>ke!==Oe.defaultView?.visualViewport),we.forEach(ke=>{ke.addEventListener("scroll",Me,{passive:!0})}),()=>{Oe.removeEventListener("pointerdown",Y,!0),g&&(Oe.removeEventListener("keydown",D),Oe.removeEventListener("compositionstart",Se),Oe.removeEventListener("compositionend",Ve)),R&&(Oe.removeEventListener("click",J,!0),Oe.removeEventListener("pointerdown",J,!0),Oe.removeEventListener("touchstart",Z,!0),Oe.removeEventListener("touchmove",pe,!0),Oe.removeEventListener("touchend",de,!0),Oe.removeEventListener("mousedown",J,!0)),we.forEach(ke=>{ke.removeEventListener("scroll",Me)}),he.clear()}},[m,i,c,u,g,R,a,f,N,h,M,O,D,G,J,X,Z,pe,de,Y,n]),v.useEffect($,[R,$]);const fe=v.useMemo(()=>({onKeyDown:D,...w&&{[S$[j]]:he=>{n.setOpen(!1,rn(Ad,he.nativeEvent))},...j!=="intentional"&&{onClick(he){n.setOpen(!1,rn(Ad,he.nativeEvent))}}}}),[D,n,w,j]),xe=qe(he=>{const Me=Gn(he.nativeEvent);!_t(n.select("floatingElement"),Me)||he.button!==0||(A.current=!0)}),Re=v.useMemo(()=>({onKeyDown:D,onPointerDown:xe,onMouseDown:xe,onMouseUp:xe,onClickCapture:B,onMouseDownCapture:B,onPointerDownCapture:B,onMouseUpCapture:B,onTouchEndCapture:B,onTouchMoveCapture:B}),[D,xe,B]);return v.useMemo(()=>h?{reference:fe,floating:Re,trigger:fe}:{},[h,fe,Re])}var Ud=Symbol("NOT_FOUND");function k$(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function E$(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function C$(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(a=>typeof a=="function"?`function ${a.name||"unnamed"}()`:typeof a).join(", ");throw new TypeError(`${t}[${n}]`)}}var m1=e=>Array.isArray(e)?e:[e];function T$(e){const t=Array.isArray(e[0])?e[0]:e;return C$(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function A$(e,t){const n=[],{length:a}=e;for(let i=0;i<a;i++)n.push(e[i].apply(null,t));return n}function R$(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Ud},put(n,a){t={key:n,value:a}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function M$(e,t){let n=[];function a(f){const m=n.findIndex(h=>t(f,h.key));if(m>-1){const h=n[m];return m>0&&(n.splice(m,1),n.unshift(h)),h.value}return Ud}function i(f,m){a(f)===Ud&&(n.unshift({key:f,value:m}),n.length>e&&n.pop())}function c(){return n}function u(){n=[]}return{get:a,put:i,getEntries:c,clear:u}}var _$=(e,t)=>e===t;function O$(e){return function(n,a){if(n===null||a===null||n.length!==a.length)return!1;const{length:i}=n;for(let c=0;c<i;c++)if(!e(n[c],a[c]))return!1;return!0}}function I$(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:a=_$,maxSize:i=1,resultEqualityCheck:c}=n,u=O$(a);let f=0;const m=i<=1?R$(u):M$(i,u);function h(){let g=m.get(arguments);if(g===Ud){if(g=e.apply(null,arguments),f++,c){const b=m.getEntries().find(w=>c(w.value,g));b&&(g=b.value,f!==0&&f--)}m.put(arguments,g)}return g}return h.clearCache=()=>{m.clear(),h.resetResultsCount()},h.resultsCount=()=>f,h.resetResultsCount=()=>{f=0},h}var D$=class{constructor(e){this.value=e}deref(){return this.value}},z$=typeof WeakRef<"u"?WeakRef:D$,L$=0,p1=1;function Pu(){return{s:L$,v:void 0,o:null,p:null}}function cE(e,t={}){let n=Pu();const{resultEqualityCheck:a}=t;let i,c=0;function u(){let f=n;const{length:m}=arguments;for(let x=0,b=m;x<b;x++){const w=arguments[x];if(typeof w=="function"||typeof w=="object"&&w!==null){let j=f.o;j===null&&(f.o=j=new WeakMap);const N=j.get(w);N===void 0?(f=Pu(),j.set(w,f)):f=N}else{let j=f.p;j===null&&(f.p=j=new Map);const N=j.get(w);N===void 0?(f=Pu(),j.set(w,f)):f=N}}const h=f;let g;if(f.s===p1)g=f.v;else if(g=e.apply(null,arguments),c++,a){const x=i?.deref?.()??i;x!=null&&a(x,g)&&(g=x,c!==0&&c--),i=typeof g=="object"&&g!==null||typeof g=="function"?new z$(g):g}return h.s=p1,h.v=g,g}return u.clearCache=()=>{n=Pu(),u.resetResultsCount()},u.resultsCount=()=>c,u.resetResultsCount=()=>{c=0},u}function uE(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,a=(...i)=>{let c=0,u=0,f,m={},h=i.pop();typeof h=="object"&&(m=h,h=i.pop()),k$(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const g={...n,...m},{memoize:x,memoizeOptions:b=[],argsMemoize:w=cE,argsMemoizeOptions:j=[]}=g,N=m1(b),T=m1(j),k=T$(i),C=x(function(){return c++,h.apply(null,arguments)},...N),S=w(function(){u++;const A=A$(k,arguments);return f=C.apply(null,A),f},...T);return Object.assign(S,{resultFunc:h,memoizedResultFunc:C,dependencies:k,dependencyRecomputations:()=>u,resetDependencyRecomputations:()=>{u=0},lastResult:()=>f,recomputations:()=>c,resetRecomputations:()=>{c=0},memoize:x,argsMemoize:w})};return Object.assign(a,{withTypes:()=>a}),a}var $$=uE(cE),P$=Object.assign((e,t=$$)=>{E$(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),a=n.map(c=>e[c]);return t(a,(...c)=>c.reduce((u,f,m)=>(u[n[m]]=f,u),{}))},{withTypes:()=>P$});uE({memoize:I$,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const Qe=(e,t,n,a,i,c,...u)=>{if(u.length>0)throw new Error(oi(1));let f;if(e)f=e;else throw new Error("Missing arguments");return f};var Xm={exports:{}},Km={};var g1;function U$(){if(g1)return Km;g1=1;var e=oc();function t(x,b){return x===b&&(x!==0||1/x===1/b)||x!==x&&b!==b}var n=typeof Object.is=="function"?Object.is:t,a=e.useState,i=e.useEffect,c=e.useLayoutEffect,u=e.useDebugValue;function f(x,b){var w=b(),j=a({inst:{value:w,getSnapshot:b}}),N=j[0].inst,T=j[1];return c(function(){N.value=w,N.getSnapshot=b,m(N)&&T({inst:N})},[x,w,b]),i(function(){return m(N)&&T({inst:N}),x(function(){m(N)&&T({inst:N})})},[x]),u(w),w}function m(x){var b=x.getSnapshot;x=x.value;try{var w=b();return!n(x,w)}catch{return!0}}function h(x,b){return b()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return Km.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Km}var v1;function dE(){return v1||(v1=1,Xm.exports=U$()),Xm.exports}var B$=dE(),Jm={exports:{}},Qm={};var y1;function V$(){if(y1)return Qm;y1=1;var e=oc(),t=dE();function n(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var a=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,c=e.useRef,u=e.useEffect,f=e.useMemo,m=e.useDebugValue;return Qm.useSyncExternalStoreWithSelector=function(h,g,x,b,w){var j=c(null);if(j.current===null){var N={hasValue:!1,value:null};j.current=N}else N=j.current;j=f(function(){function k(M){if(!C){if(C=!0,S=M,M=b(M),w!==void 0&&N.hasValue){var O=N.value;if(w(O,M))return R=O}return R=M}if(O=R,a(S,M))return O;var V=b(M);return w!==void 0&&w(O,V)?(S=M,O):(S=M,R=V)}var C=!1,S,R,A=x===void 0?null:x;return[function(){return k(g())},A===null?void 0:function(){return k(A())}]},[g,x,b,w]);var T=i(h,j[0],j[1]);return u(function(){N.hasValue=!0,N.value=T},[T]),m(T),T},Qm}var x1;function H$(){return x1||(x1=1,Jm.exports=V$()),Jm.exports}var Z$=H$();const F$=Wg(19),q$=F$?G$:W$;function Y$(e,t,n,a,i){return q$(e,t,n,a,i)}function G$(e,t,n,a,i){const c=v.useCallback(()=>t(e.getSnapshot(),n,a,i),[e,t,n,a,i]);return B$.useSyncExternalStore(e.subscribe,c,c)}function W$(e,t,n,a,i){return Z$.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,c=>t(c,n,a,i))}class Hl{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 a of this.listeners){if(n!==this.updateTick)return;a(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){Hl.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Hl.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Hl.prototype.setState.call(this,t)}}class fE extends Hl{constructor(t,n={},a){super(t),this.context=n,this.selectors=a}controlledValues=new Map;useSyncedValue(t,n){v.useDebugValue(t),Ze(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){Ze(()=>(this.state[t]!==n&&this.set(t,n),()=>{this.set(t,void 0)}),[t,n])}useSyncedValues(t){const n=Object.values(t);Ze(()=>{this.update(t)},n)}useControlledProp(t,n,a){v.useDebugValue(t);const i=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,i),!i&&!Object.is(this.state[t],a)&&super.setState({...this.state,[t]:a})),Ze(()=>{i&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,a,i])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const a in n)if(Object.hasOwn(n,a)&&this.controlledValues.get(a)===!0){delete n[a];continue}super.update(n)}setState(t){const n={...t};for(const a in n)if(Object.hasOwn(n,a)&&this.controlledValues.get(a)===!0){delete n[a];continue}super.setState({...this.state,...n})}select=(t,n,a,i)=>{const c=this.selectors[t];return c(this.state,n,a,i)};useState=(t,n,a,i)=>{v.useDebugValue(t);const c=this.selectors[t];return Y$(this,c,n,a,i)};useContextCallback(t,n){v.useDebugValue(t);const a=qe(n??yk);this.context[t]=a}useStateSetter(t){const n=v.useRef(void 0);return n.current===void 0&&(n.current=a=>{this.set(t,a)}),n.current}observe(t,n){let a;typeof t=="function"?a=t:a=this.selectors[t];let i=a(this.state);return n(i,i,this),this.subscribe(c=>{const u=a(c);if(!Object.is(i,u)){const f=i;i=u,n(u,f,this)}})}}const X$={open:Qe(e=>e.open),domReferenceElement:Qe(e=>e.domReferenceElement),referenceElement:Qe(e=>e.positionReference??e.referenceElement),floatingElement:Qe(e=>e.floatingElement),floatingId:Qe(e=>e.floatingId)};class ov extends fE{constructor(t){const{nested:n,noEmit:a,onOpenChange:i,triggerElements:c,...u}=t;super({...u,positionReference:u.referenceElement,domReferenceElement:u.referenceElement},{onOpenChange:i,dataRef:{current:{}},events:Yk(),nested:n,noEmit:a,triggerElements:c},X$)}setOpen=(t,n)=>{if((!t||!this.state.open||H3(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const a={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",a)}this.context.onOpenChange?.(t,n)}}function K$(e){const t=e.useState("open");Ze(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[a,i]=n.value;e.update({activeTriggerId:a,activeTriggerElement:i})}}},[t,e])}function J$(e,t,n){const{mounted:a,setMounted:i,transitionStatus:c}=k3(e);t.useSyncedValues({mounted:a,transitionStatus:c});const u=qe(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),f=t.useState("preventUnmountingOnClose");return Ck({enabled:!f,open:e,ref:t.context.popupRef,onComplete(){e||u()}}),{forceUnmount:u,transitionStatus:c}}class lv{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const a=this.idMap.get(t);a!==n&&(a!==void 0&&this.elements.delete(a),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 Q$(){return new ov({open:!1,floatingElement:null,referenceElement:null,triggerElements:new lv,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function eP(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Q$(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Wn,inactiveTriggerProps:Wn,popupProps:Wn}}const tP={open:Qe(e=>e.open),mounted:Qe(e=>e.mounted),transitionStatus:Qe(e=>e.transitionStatus),floatingRootContext:Qe(e=>e.floatingRootContext),preventUnmountingOnClose:Qe(e=>e.preventUnmountingOnClose),payload:Qe(e=>e.payload),activeTriggerId:Qe(e=>e.activeTriggerId),activeTriggerElement:Qe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:Qe((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:Qe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:Qe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:Qe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:Qe(e=>e.popupProps),popupElement:Qe(e=>e.popupElement),positionerElement:Qe(e=>e.positionerElement)};function nP(e){const{open:t=!1,onOpenChange:n,elements:a={}}=e,i=yr(),c=Sr()!=null,u=Es(()=>new ov({open:t,onOpenChange:n,referenceElement:a.reference??null,floatingElement:a.floating??null,triggerElements:a.triggers??new lv,floatingId:i,nested:c,noEmit:e.noEmit||!1})).current;return Ze(()=>{const f={open:t,floatingId:i};a.reference!==void 0&&(f.referenceElement=a.reference,f.domReferenceElement=Ot(a.reference)?a.reference:null),a.floating!==void 0&&(f.floatingElement=a.floating),u.update(f)},[t,i,a.reference,a.floating,u]),u.context.onOpenChange=n,u.context.nested=c,u.context.noEmit=e.noEmit||!1,u}function sP(e={}){const{nodeId:t,externalTree:n}=e,a=nP(e),i=e.rootContext||a,c={reference:i.useState("referenceElement"),floating:i.useState("floatingElement"),domReference:i.useState("domReferenceElement")},[u,f]=v.useState(null),m=v.useRef(null),h=_o(n);Ze(()=>{c.domReference&&(m.current=c.domReference)},[c.domReference]);const g=p$({...e,elements:{...c,...u&&{reference:u}}}),x=v.useCallback(O=>{const V=Ot(O)?{getBoundingClientRect:()=>O.getBoundingClientRect(),getClientRects:()=>O.getClientRects(),contextElement:O}:O;f(V),g.refs.setReference(V)},[g.refs]),[b,w]=v.useState(null),[j,N]=v.useState(null);i.useSyncedValue("referenceElement",b),i.useSyncedValue("domReferenceElement",Ot(b)?b:null),i.useSyncedValue("floatingElement",j);const T=v.useCallback(O=>{(Ot(O)||O===null)&&(m.current=O,w(O)),(Ot(g.refs.reference.current)||g.refs.reference.current===null||O!==null&&!Ot(O))&&g.refs.setReference(O)},[g.refs,w]),k=v.useCallback(O=>{N(O),g.refs.setFloating(O)},[g.refs]),C=v.useMemo(()=>({...g.refs,setReference:T,setFloating:k,setPositionReference:x,domReference:m}),[g.refs,T,k,x]),S=v.useMemo(()=>({...g.elements,domReference:c.domReference}),[g.elements,c.domReference]),R=i.useState("open"),A=i.useState("floatingId"),M=v.useMemo(()=>({...g,dataRef:i.context.dataRef,open:R,onOpenChange:i.setOpen,events:i.context.events,floatingId:A,refs:C,elements:S,nodeId:t,rootStore:i}),[g,C,S,t,i,R,A]);return Ze(()=>{i.context.dataRef.current.floatingContext=M;const O=h?.nodesRef.current.find(V=>V.id===t);O&&(O.context=M)}),v.useMemo(()=>({...g,context:M,refs:C,elements:S,rootStore:i}),[g,C,S,M,i])}function aP(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:a=!1,onOpenChange:i}=e,c=yr(),u=Sr()!=null,f=t.useState("open"),m=t.useState("activeTriggerElement"),h=t.useState(a?"popupElement":"positionerElement"),g=t.context.triggerElements,x=Es(()=>new ov({open:f,referenceElement:m,floatingElement:h,triggerElements:g,onOpenChange:i,floatingId:c,nested:u,noEmit:n})).current;return Ze(()=>{const b={open:f,floatingId:c,referenceElement:m,floatingElement:h};Ot(m)&&(b.domReferenceElement=m),x.update(b)},[f,c,m,h,x]),x.context.onOpenChange=i,x.context.nested=u,x.context.noEmit=n,x}const b1=tc("safe-polygon"),rP=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Ok}`;function iP(e){return e?!!e.closest(rP):!1}function oP(e){const t=v.useRef(void 0),n=v.useRef(!1),a=v.useRef(void 0),i=v.useRef(!0),c=v.useRef(!1),u=v.useRef(()=>{}),f=v.useRef(!1),m=Us(),h=Us(),g=v.useRef(void 0);return v.useMemo(()=>{const x=e.context.dataRef.current;return x.hoverInteractionState||(x.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:a,blockMouseMoveRef:i,performedPointerEventsMutationRef:c,unbindMouseMoveRef:u,restTimeoutPendingRef:f,openChangeTimeout:m,restTimeout:h,handleCloseOptionsRef:g}),x.hoverInteractionState},[e,t,n,a,i,c,u,f,m,h,g])}const lP=new Set(["click","mousedown"]);function cP(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingElement"),c=n.useState("domReferenceElement"),{dataRef:u}=n.context,{enabled:f=!0,closeDelay:m=0,externalTree:h}=t,{pointerTypeRef:g,interactedInsideRef:x,handlerRef:b,performedPointerEventsMutationRef:w,unbindMouseMoveRef:j,restTimeoutPendingRef:N,openChangeTimeout:T,handleCloseOptionsRef:k}=oP(n),C=_o(h),S=Sr(),R=qe(()=>x.current?!0:u.current.openEvent?lP.has(u.current.openEvent.type):!1),A=qe(()=>{const I=u.current.openEvent?.type;return I?.includes("mouse")&&I!=="mousedown"}),M=v.useCallback((I,$=!0)=>{const L=uP(m,g.current);L&&!b.current?T.start(L,()=>n.setOpen(!1,rn(Xr,I))):$&&(T.clear(),n.setOpen(!1,rn(Xr,I)))},[m,b,n,g,T]),O=qe(()=>{j.current(),b.current=void 0}),V=qe(()=>{if(w.current){const I=Cn(i).body;I.style.pointerEvents="",I.removeAttribute(b1),w.current=!1}}),F=qe(I=>{const $=Gn(I);if(!iP($)){x.current=!1;return}x.current=!0});Ze(()=>{a||(g.current=void 0,N.current=!1,x.current=!1,O(),V())},[a,g,N,x,O,V]),v.useEffect(()=>()=>{O()},[O]),v.useEffect(()=>V,[V]),Ze(()=>{if(f&&a&&k.current?.blockPointerEvents&&A()&&Ot(c)&&i){w.current=!0;const I=Cn(i).body;I.setAttribute(b1,"");const $=c,L=i,U=C?.nodesRef.current.find(Y=>Y.id===S)?.context?.elements.floating;return U&&(U.style.pointerEvents=""),I.style.pointerEvents="none",$.style.pointerEvents="auto",L.style.pointerEvents="auto",()=>{I.style.pointerEvents="",$.style.pointerEvents="",L.style.pointerEvents=""}}},[f,a,c,i,k,A,C,S,w]),v.useEffect(()=>{if(!f)return;function I(Y){if(R()||!u.current.floatingContext)return;const K=n.context.triggerElements;Y.relatedTarget&&K.hasElement(Y.relatedTarget)||(V(),O(),R()||M(Y))}function $(Y){T.clear(),V(),b.current?.(Y),O()}function L(Y){R()||M(Y,!1)}const U=i;return U&&(U.addEventListener("mouseleave",I),U.addEventListener("mouseenter",$),U.addEventListener("mouseleave",L),U.addEventListener("pointerdown",F,!0)),()=>{U&&(U.removeEventListener("mouseleave",I),U.removeEventListener("mouseenter",$),U.removeEventListener("mouseleave",L),U.removeEventListener("pointerdown",F,!0))}})}function uP(e,t){return t&&!V3(t)?0:typeof e=="function"?e():e}function dP(e=[]){const t=e.map(h=>h?.reference),n=e.map(h=>h?.floating),a=e.map(h=>h?.item),i=e.map(h=>h?.trigger),c=v.useCallback(h=>Uu(h,e,"reference"),t),u=v.useCallback(h=>Uu(h,e,"floating"),n),f=v.useCallback(h=>Uu(h,e,"item"),a),m=v.useCallback(h=>Uu(h,e,"trigger"),i);return v.useMemo(()=>({getReferenceProps:c,getFloatingProps:u,getItemProps:f,getTriggerProps:m}),[c,u,f,m])}function Uu(e,t,n){const a=new Map,i=n==="item",c={};n==="floating"&&(c.tabIndex=-1,c[Kp]="");for(const u in e)i&&e&&(u===Mk||u===_k)||(c[u]=e[u]);for(let u=0;u<t.length;u+=1){let f;const m=t[u]?.[n];typeof m=="function"?f=e?m(e):null:f=m,f&&w1(c,f,i,a)}return w1(c,e,i,a),c}function w1(e,t,n,a){for(const i in t){const c=t[i];n&&(i===Mk||i===_k)||(i.startsWith("on")?(a.has(i)||a.set(i,[]),typeof c=="function"&&(a.get(i)?.push(c),e[i]=(...u)=>a.get(i)?.map(f=>f(...u)).find(f=>f!==void 0))):e[i]=c)}}const fP="Escape";function mf(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Bu(e,t){return mf(t,e===tv||e===dc,e===ur||e===dr)}function ep(e,t,n){return mf(t,e===dc,n?e===ur:e===dr)||e==="Enter"||e===" "||e===""}function hP(e,t,n){return mf(t,n?e===ur:e===dr,e===dc)}function mP(e,t,n,a){const i=n?e===dr:e===ur,c=e===tv;return t==="both"||t==="horizontal"&&a&&a>1?e===fP:mf(t,i,c)}function pP(e,t){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingElement"),c=n.useState("domReferenceElement"),u=n.context.dataRef,{listRef:f,activeIndex:m,onNavigate:h=()=>{},enabled:g=!0,selectedIndex:x=null,allowEscape:b=!1,loopFocus:w=!1,nested:j=!1,rtl:N=!1,virtual:T=!1,focusItemOnOpen:k="auto",focusItemOnHover:C=!0,openOnArrowKeyDown:S=!0,disabledIndices:R=void 0,orientation:A="vertical",parentOrientation:M,cols:O=1,scrollItemIntoView:V=!0,itemSizes:F,dense:I=!1,id:$,resetOnPointerLeave:L=!0,externalTree:U}=t,Y=Rd(i),K=Yn(Y),D=Sr(),P=_o(U);Ze(()=>{u.current.orientation=A},[u,A]);const B=Jp(c),G=v.useRef(k),X=v.useRef(x??-1),z=v.useRef(null),Z=v.useRef(!0),J=qe(ve=>{h(X.current===-1?null:X.current,ve)}),Q=v.useRef(J),pe=v.useRef(!!i),re=v.useRef(a),de=v.useRef(!1),fe=v.useRef(!1),xe=Yn(R),Re=Yn(a),he=Yn(V),Me=Yn(x),Se=Yn(L),Ve=qe(()=>{function ve(et){T?P?.events.emit("virtualfocus",et):cd(et,{sync:de.current,preventScroll:!0})}const je=f.current[X.current],Ne=fe.current;je&&ve(je),(de.current?et=>et():requestAnimationFrame)(()=>{const et=f.current[X.current]||je;if(!et)return;je||ve(et);const Ge=he.current;Ge&&we&&(Ne||!Z.current)&&et.scrollIntoView?.(typeof Ge=="boolean"?{block:"nearest",inline:"nearest"}:Ge)})});Ze(()=>{g&&(a&&i?(X.current=x??-1,G.current&&x!=null&&(fe.current=!0,J())):pe.current&&(X.current=-1,Q.current()))},[g,a,i,x,J]),Ze(()=>{if(g){if(!a){de.current=!1;return}if(i)if(m==null){if(de.current=!1,Me.current!=null)return;if(pe.current&&(X.current=-1,Ve()),(!re.current||!pe.current)&&G.current&&(z.current!=null||G.current===!0&&z.current==null)){let ve=0;const je=()=>{f.current[0]==null?(ve<2&&(ve?requestAnimationFrame:queueMicrotask)(je),ve+=1):(X.current=z.current==null||ep(z.current,A,N)||j?Fm(f):Qw(f),z.current=null,J())};je()}}else Ul(f,m)||(X.current=m,Ve(),fe.current=!1)}},[g,a,i,m,Me,j,f,A,N,J,Ve,xe]),Ze(()=>{if(!g||i||!P||T||!pe.current)return;const ve=P.nodesRef.current,je=ve.find(et=>et.id===D)?.context?.elements.floating,Ne=rr(Cn(i)),Je=ve.some(et=>et.context&&_t(et.context.elements.floating,Ne));je&&!Je&&Z.current&&je.focus({preventScroll:!0})},[g,i,P,D,T]),Ze(()=>{Q.current=J,re.current=a,pe.current=!!i}),Ze(()=>{a||(z.current=null,G.current=k)},[a,k]);const Oe=m!=null,we=v.useMemo(()=>{function ve(Ne){if(!Re.current)return;const Je=f.current.indexOf(Ne.currentTarget);Je!==-1&&X.current!==Je&&(X.current=Je,J(Ne))}return{onFocus(Ne){de.current=!0,ve(Ne)},onClick:({currentTarget:Ne})=>Ne.focus({preventScroll:!0}),onMouseMove(Ne){de.current=!0,fe.current=!1,C&&ve(Ne)},onPointerLeave(Ne){if(!Re.current||!Z.current||Ne.pointerType==="touch")return;de.current=!0;const Je=Ne.relatedTarget;!C||f.current.includes(Je)||Se.current&&(X.current=-1,J(Ne),T||K.current?.focus({preventScroll:!0}))}}},[Re,K,C,f,J,Se,T]),ke=v.useCallback(()=>M??P?.nodesRef.current.find(ve=>ve.id===D)?.context?.dataRef?.current.orientation,[D,P,M]),Ye=qe(ve=>{if(Z.current=!1,de.current=!0,ve.which===229||!Re.current&&ve.currentTarget===K.current)return;if(j&&mP(ve.key,A,N,O)){Bu(ve.key,ke())||Tn(ve),n.setOpen(!1,rn(ld,ve.nativeEvent)),Qt(c)&&(T?P?.events.emit("virtualfocus",c):c.focus());return}const je=X.current,Ne=Fm(f,R),Je=Qw(f,R);if(B||(ve.key==="Home"&&(Tn(ve),X.current=Ne,J(ve)),ve.key==="End"&&(Tn(ve),X.current=Je,J(ve))),O>1){const et=F||Array.from({length:f.current.length},()=>({width:1,height:1})),Ge=nL(et,O,I),Bt=Ge.findIndex(hn=>hn!=null&&!Bl(f,hn,R)),kt=Ge.reduce((hn,on,Ie)=>on!=null&&!Bl(f,on,R)?Ie:hn,-1),fn=Ge[tL({current:Ge.map(hn=>hn!=null?f.current[hn]:null)},{event:ve,orientation:A,loopFocus:w,rtl:N,cols:O,disabledIndices:aL([...(typeof R!="function"?R:null)||f.current.map((hn,on)=>Bl(f,on,R)?on:void 0),void 0],Ge),minIndex:Bt,maxIndex:kt,prevIndex:sL(X.current>Je?Ne:X.current,et,Ge,O,ve.key===dc?"bl":ve.key===(N?ur:dr)?"tr":"tl"),stopEvent:!0})];if(fn!=null&&(X.current=fn,J(ve)),A==="both")return}if(Bu(ve.key,A)){if(Tn(ve),a&&!T&&rr(ve.currentTarget.ownerDocument)===ve.currentTarget){X.current=ep(ve.key,A,N)?Ne:Je,J(ve);return}ep(ve.key,A,N)?w?je>=Je?b&&je!==f.current.length?X.current=-1:(de.current=!1,X.current=Ne):X.current=Mn(f,{startingIndex:je,disabledIndices:R}):X.current=Math.min(Je,Mn(f,{startingIndex:je,disabledIndices:R})):w?je<=Ne?b&&je!==-1?X.current=f.current.length:(de.current=!1,X.current=Je):X.current=Mn(f,{startingIndex:je,decrement:!0,disabledIndices:R}):X.current=Math.max(Ne,Mn(f,{startingIndex:je,decrement:!0,disabledIndices:R})),Ul(f,X.current)&&(X.current=-1),J(ve)}}),Ue=v.useMemo(()=>T&&a&&Oe&&{"aria-activedescendant":`${$}-${m}`},[T,a,Oe,$,m]),He=v.useMemo(()=>({"aria-orientation":A==="both"?void 0:A,...B?{}:Ue,onKeyDown(ve){if(ve.key==="Tab"&&ve.shiftKey&&a&&!T){const je=Gn(ve.nativeEvent);if(je&&!_t(K.current,je))return;Tn(ve),n.setOpen(!1,rn(of,ve.nativeEvent)),Qt(c)&&c.focus();return}Ye(ve)},onPointerMove(){Z.current=!0}}),[Ue,Ye,K,A,B,n,a,T,c]),le=v.useMemo(()=>{function ve(Ne){k==="auto"&&Ik(Ne.nativeEvent)&&(G.current=!T)}function je(Ne){G.current=k,k==="auto"&&Dk(Ne.nativeEvent)&&(G.current=!0)}return{onKeyDown(Ne){const Je=n.select("open");Z.current=!1;const et=Ne.key.startsWith("Arrow"),Ge=hP(Ne.key,ke(),N),Bt=Bu(Ne.key,A),kt=(j?Ge:Bt)||Ne.key==="Enter"||Ne.key.trim()==="";if(T&&Je)return Ye(Ne);if(!(!Je&&!S&&et)){if(kt){const fn=Bu(Ne.key,ke());z.current=j&&fn?null:Ne.key}if(j){Ge&&(Tn(Ne),Je?(X.current=Fm(f,xe.current),J(Ne)):n.setOpen(!0,rn(ld,Ne.nativeEvent,Ne.currentTarget)));return}Bt&&(Me.current!=null&&(X.current=Me.current),Tn(Ne),!Je&&S?n.setOpen(!0,rn(ld,Ne.nativeEvent,Ne.currentTarget)):Ye(Ne),Je&&J(Ne))}},onFocus(Ne){n.select("open")&&!T&&(X.current=-1,J(Ne))},onPointerDown:je,onPointerEnter:je,onMouseDown:ve,onClick:ve}},[Ye,xe,k,f,j,J,n,S,A,ke,N,Me,T]),ge=v.useMemo(()=>({...Ue,...le}),[Ue,le]);return v.useMemo(()=>g?{reference:ge,floating:He,item:we,trigger:le}:{},[g,ge,He,le,we])}const gP=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function vP(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingId"),c=n.useState("domReferenceElement"),u=n.useState("floatingElement"),{enabled:f=!0,role:m="dialog"}=t,h=yr(),g=c?.id||h,x=v.useMemo(()=>Rd(u)?.id||i,[u,i]),b=gP.get(m)??m,j=Sr()!=null,N=v.useMemo(()=>b==="tooltip"||m==="label"?Wn:{"aria-haspopup":b==="alertdialog"?"dialog":b,"aria-expanded":"false",...b==="listbox"&&{role:"combobox"},...b==="menu"&&j&&{role:"menuitem"},...m==="select"&&{"aria-autocomplete":"none"},...m==="combobox"&&{"aria-autocomplete":"list"}},[b,j,m]),T=v.useMemo(()=>b==="tooltip"||m==="label"?{[`aria-${m==="label"?"labelledby":"describedby"}`]:a?x:void 0}:{...N,"aria-expanded":a?"true":"false","aria-controls":a?x:void 0,...b==="menu"&&{id:g}},[b,x,a,g,m,N]),k=v.useMemo(()=>{const S={id:x,...b&&{role:b}};return b==="tooltip"||m==="label"?S:{...S,...b==="menu"&&{"aria-labelledby":g}}},[b,x,g,m]),C=v.useCallback(({active:S,selected:R})=>{const A={role:"option",...S&&{id:`${x}-fui-option`}};switch(m){case"select":case"combobox":return{...A,"aria-selected":R}}return{}},[x,m]);return v.useMemo(()=>f?{reference:T,floating:k,item:C,trigger:N}:{},[f,T,k,N,C])}function yP(e,t){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.context.dataRef,{listRef:c,activeIndex:u,onMatch:f,onTypingChange:m,enabled:h=!0,findMatch:g=null,resetMs:x=750,ignoreKeys:b=xk,selectedIndex:w=null}=t,j=Us(),N=v.useRef(""),T=v.useRef(w??u??-1),k=v.useRef(null);Ze(()=>{a&&(j.clear(),k.current=null,N.current="")},[a,j]),Ze(()=>{a&&N.current===""&&(T.current=w??u??-1)},[a,w,u]);const C=qe(M=>{M?i.current.typing||(i.current.typing=M,m?.(M)):i.current.typing&&(i.current.typing=M,m?.(M))}),S=qe(M=>{function O(L,U,Y){const K=g?g(U,Y):U.find(D=>D?.toLocaleLowerCase().indexOf(Y.toLocaleLowerCase())===0);return K?L.indexOf(K):-1}const V=c.current;if(N.current.length>0&&N.current[0]!==" "&&(O(V,V,N.current)===-1?C(!1):M.key===" "&&Tn(M)),V==null||b.includes(M.key)||M.key.length!==1||M.ctrlKey||M.metaKey||M.altKey)return;a&&M.key!==" "&&(Tn(M),C(!0)),V.every(L=>L?L[0]?.toLocaleLowerCase()!==L[1]?.toLocaleLowerCase():!0)&&N.current===M.key&&(N.current="",T.current=k.current),N.current+=M.key,j.start(x,()=>{N.current="",T.current=k.current,C(!1)});const I=T.current,$=O(V,[...V.slice((I||0)+1),...V.slice(0,(I||0)+1)],N.current);$!==-1?(f?.($),k.current=$):M.key!==" "&&(N.current="",C(!1))}),R=v.useMemo(()=>({onKeyDown:S}),[S]),A=v.useMemo(()=>({onKeyDown:S,onKeyUp(M){M.key===" "&&C(!1)}}),[S,C]);return v.useMemo(()=>h?{reference:R,floating:A}:{},[h,R,A])}const xP=v.createContext(void 0);function bP(e){return v.useContext(xP)}const hE="ArrowUp",mE="ArrowDown",pE="ArrowLeft",gE="ArrowRight",vE="Home",yE="End",wP=new Set([pE,gE]),SP=new Set([hE,mE]),jP=new Set([...wP,...SP]);[...jP];const NP=new Set([hE,mE,pE,gE,vE,yE]);function kP(e){return e==="starting"?z4:Wn}const EP={...bk,...F4},CP=v.forwardRef(function(t,n){const{render:a,className:i,finalFocus:c,...u}=t,{store:f}=Ro(),{side:m,align:h}=hk(),g=bP()!=null,x=f.useState("open"),b=f.useState("transitionStatus"),w=f.useState("popupProps"),j=f.useState("mounted"),N=f.useState("instantType"),T=f.useState("activeTriggerElement"),k=f.useState("parent"),C=f.useState("lastOpenChangeReason"),S=f.useState("rootId"),R=f.useState("floatingRootContext"),A=f.useState("floatingTreeRoot"),M=f.useState("closeDelay"),O=f.useState("activeTriggerElement");Ck({open:x,ref:f.context.popupRef,onComplete(){x&&f.context.onOpenChangeComplete?.(!0)}}),v.useEffect(()=>{function U(Y){f.setOpen(!1,rn(Y.reason,Y.domEvent))}return A.events.on("close",U),()=>{A.events.off("close",U)}},[A.events,f]);const V=f.useState("hoverEnabled"),F=f.useState("disabled");cP(R,{enabled:V&&!F&&k.type!=="context-menu"&&k.type!=="menubar",closeDelay:M});const I=v.useMemo(()=>({transitionStatus:b,side:m,align:h,open:x,nested:k.type==="menu",instant:N}),[b,m,h,x,k.type,N]),$=xr("div",t,{state:I,ref:[n,f.context.popupRef],stateAttributesMapping:EP,props:[w,{onKeyDown(U){g&&NP.has(U.key)&&U.stopPropagation()}},kP(b),u,{"data-rootownerid":S}]});let L=k.type===void 0||k.type==="context-menu";return(T||k.type==="menubar"&&C!==Kg)&&(L=!0),o.jsx(IL,{context:R,modal:!1,disabled:!j,returnFocus:c===void 0?L:c,initialFocus:k.type!=="menu",restoreFocus:!0,externalTree:k.type!=="menubar"?A:void 0,previousFocusableElement:O,nextFocusableElement:k.type===void 0?f.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:k.type===void 0?f.context.beforeContentFocusGuardRef:void 0,children:$})}),xE=v.createContext(void 0);function TP(){const e=v.useContext(xE);if(e===void 0)throw new Error(oi(32));return e}const AP=v.forwardRef(function(t,n){const{keepMounted:a=!1,...i}=t,{store:c}=Ro();return c.useState("mounted")||a?o.jsx(xE.Provider,{value:a,children:o.jsx(AL,{ref:n,...i})}):null});function RP(e){return Wg(19)?e:e?"true":void 0}const MP=v.createContext(void 0);function bE(){return v.useContext(MP)?.direction??"ltr"}const _P=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:i,rects:c,platform:u,elements:f,middlewareData:m}=t,{element:h,padding:g=0,offsetParent:x="real"}=Ca(e,t)||{};if(h==null)return{};const b=zk(g),w={x:n,y:a},j=av(i),N=sv(j),T=await u.getDimensions(h),k=j==="y",C=k?"top":"left",S=k?"bottom":"right",R=k?"clientHeight":"clientWidth",A=c.reference[N]+c.reference[j]-w[j]-c.floating[N],M=w[j]-c.reference[j],O=x==="real"?await u.getOffsetParent?.(h):f.floating;let V=f.floating[R]||c.floating[N];(!V||!await u.isElement?.(O))&&(V=f.floating[R]||c.floating[N]);const F=A/2-M/2,I=V/2-T[N]/2-1,$=Math.min(b[C],I),L=Math.min(b[S],I),U=$,Y=V-T[N]-L,K=V/2-T[N]/2+F,D=Qp(U,K,Y),P=!m.arrow&&wr(i)!=null&&K!==D&&c.reference[N]/2-(K<U?$:L)-T[N]/2<0,B=P?K<U?K-U:K-Y:0;return{[j]:w[j]+B,data:{[j]:D,centerOffset:K-D-B,...P&&{alignmentOffset:B}},reset:P}}}),OP=(e,t)=>({..._P(e),options:[e,t]}),IP={name:"hide",async fn(e){const{width:t,height:n,x:a,y:i}=e.rects.reference,c=t===0&&n===0&&a===0&&i===0;return{data:{referenceHidden:(await w$().fn(e)).data?.referenceHidden||c}}}},DP={sideX:"left",sideY:"top"};function wE(e,t,n){const a=e==="inline-start"||e==="inline-end";return{top:"top",right:a?n?"inline-start":"inline-end":"right",bottom:"bottom",left:a?n?"inline-end":"inline-start":"left"}[t]}function S1(e,t,n){const{rects:a,placement:i}=e;return{side:wE(t,is(i),n),align:wr(i)||"center",anchor:{width:a.reference.width,height:a.reference.height},positioner:{width:a.floating.width,height:a.floating.height}}}function zP(e){const{anchor:t,positionMethod:n="absolute",side:a="bottom",sideOffset:i=0,align:c="center",alignOffset:u=0,collisionBoundary:f,collisionPadding:m=5,sticky:h=!1,arrowPadding:g=5,disableAnchorTracking:x=!1,keepMounted:b=!1,floatingRootContext:w,mounted:j,collisionAvoidance:N,shiftCrossAxis:T=!1,nodeId:k,adaptiveOrigin:C,lazyFlip:S=!1,externalTree:R}=e,[A,M]=v.useState(null);!j&&A!==null&&M(null);const O=N.side||"flip",V=N.align||"flip",F=N.fallbackAxisSide||"end",I=typeof t=="function"?t:void 0,$=qe(I),L=I?$:t,U=Yn(t),K=bE()==="rtl",D=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":K?"left":"right","inline-start":K?"right":"left"}[a],P=c==="center"?D:`${D}-${c}`;let B=m;const G=1,X=a==="bottom"?G:0,z=a==="top"?G:0,Z=a==="right"?G:0,J=a==="left"?G:0;typeof B=="number"?B={top:B+X,right:B+J,bottom:B+z,left:B+Z}:B&&(B={top:(B.top||0)+X,right:(B.right||0)+J,bottom:(B.bottom||0)+z,left:(B.left||0)+Z});const Q={boundary:f==="clipping-ancestors"?"clippingAncestors":f,padding:B},pe=v.useRef(null),re=Yn(i),de=Yn(u),Re=[g$(xt=>{const zt=S1(xt,a,K),yn=typeof re.current=="function"?re.current(zt):re.current,Xt=typeof de.current=="function"?de.current(zt):de.current;return{mainAxis:yn,crossAxis:Xt,alignmentAxis:Xt}},[typeof i!="function"?i:0,typeof u!="function"?u:0,K,a])],he=V==="none"&&O!=="shift",Me=!he&&(h||T||O==="shift"),Se=O==="none"?null:x$({...Q,padding:{top:B.top+G,right:B.right+G,bottom:B.bottom+G,left:B.left+G},mainAxis:!T&&O==="flip",crossAxis:V==="flip"?"alignment":!1,fallbackAxisSideDirection:F}),Ve=he?null:v$(xt=>{const zt=si(xt.elements.floating).documentElement;return{...Q,rootBoundary:T?{x:0,y:0,width:zt.clientWidth,height:zt.clientHeight}:void 0,mainAxis:V!=="none",crossAxis:Me,limiter:h||T?void 0:y$(yn=>{if(!pe.current)return{};const{width:Xt,height:mn}=pe.current.getBoundingClientRect(),ln=js(is(yn.placement)),xn=ln==="y"?Xt:mn,Ts=ln==="y"?B.left+B.right:B.top+B.bottom;return{offset:xn/2+Ts/2}})}},[Q,h,T,B,V]);O==="shift"||V==="shift"||c==="center"?Re.push(Ve,Se):Re.push(Se,Ve),Re.push(b$({...Q,apply({elements:{floating:xt},rects:{reference:zt},availableWidth:yn,availableHeight:Xt}){Object.entries({"--available-width":`${yn}px`,"--available-height":`${Xt}px`,"--anchor-width":`${zt.width}px`,"--anchor-height":`${zt.height}px`}).forEach(([mn,ln])=>{xt.style.setProperty(mn,ln)})}}),OP(()=>({element:pe.current||document.createElement("div"),padding:g,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(xt){const{elements:zt,middlewareData:yn,placement:Xt,rects:mn,y:ln}=xt,xn=is(Xt),Ts=js(xn),ee=pe.current,me=yn.arrow?.x||0,ye=yn.arrow?.y||0,Be=ee?.clientWidth||0,ze=ee?.clientHeight||0,ut=me+Be/2,Lt=ye+ze/2,Ft=Math.abs(yn.shift?.y||0),bn=mn.reference.height/2,qt=typeof i=="function"?i(S1(xt,a,K)):i,As=Ft>qt,cn={top:`${ut}px calc(100% + ${qt}px)`,bottom:`${ut}px ${-qt}px`,left:`calc(100% + ${qt}px) ${Lt}px`,right:`${-qt}px ${Lt}px`}[xn],yc=`${ut}px ${mn.reference.y+bn-ln}px`;return zt.floating.style.setProperty("--transform-origin",Me&&Ts==="y"&&As?yc:cn),{}}},IP,C),Ze(()=>{!j&&w&&w.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[j,w]);const Oe=v.useMemo(()=>({elementResize:!x&&typeof ResizeObserver<"u",layoutShift:!x&&typeof IntersectionObserver<"u"}),[x]),{refs:we,elements:ke,x:Ye,y:Ue,middlewareData:He,update:le,placement:ge,context:ve,isPositioned:je,floatingStyles:Ne}=sP({rootContext:w,placement:P,middleware:Re,strategy:n,whileElementsMounted:b?void 0:(...xt)=>f1(...xt,Oe),nodeId:k,externalTree:R}),{sideX:Je,sideY:et}=He.adaptiveOrigin||DP,Ge=je?n:"fixed",Bt=v.useMemo(()=>C?{position:Ge,[Je]:Ye,[et]:Ue}:{position:Ge,...Ne},[C,Ge,Je,Ye,et,Ue,Ne]),kt=v.useRef(null);Ze(()=>{if(!j)return;const xt=U.current,zt=typeof xt=="function"?xt():xt,Xt=(j1(zt)?zt.current:zt)||null||null;Xt!==kt.current&&(we.setPositionReference(Xt),kt.current=Xt)},[j,we,L,U]),v.useEffect(()=>{if(!j)return;const xt=U.current;typeof xt!="function"&&j1(xt)&&xt.current!==kt.current&&(we.setPositionReference(xt.current),kt.current=xt.current)},[j,we,L,U]),v.useEffect(()=>{if(b&&j&&ke.domReference&&ke.floating)return f1(ke.domReference,ke.floating,le,Oe)},[b,j,ke,le,Oe]);const fn=is(ge),hn=wE(a,fn,K),on=wr(ge)||"center",Ie=!!He.hide?.referenceHidden;Ze(()=>{S&&j&&je&&M(fn)},[S,j,je,fn]);const tt=v.useMemo(()=>({position:"absolute",top:He.arrow?.y,left:He.arrow?.x}),[He.arrow]),ct=He.arrow?.centerOffset!==0;return v.useMemo(()=>({positionerStyles:Bt,arrowStyles:tt,arrowRef:pe,arrowUncentered:ct,side:hn,align:on,physicalSide:fn,anchorHidden:Ie,refs:we,context:ve,isPositioned:je,update:le}),[Bt,tt,pe,ct,hn,on,fn,Ie,we,ve,je,le])}function j1(e){return e!=null&&"current"in e}function LP(e){const{children:t,elementsRef:n,labelsRef:a,onMapChange:i}=e,c=qe(i),u=v.useRef(0),f=Es(PP).current,m=Es($P).current,[h,g]=v.useState(0),x=v.useRef(h),b=qe((k,C)=>{m.set(k,C??null),x.current+=1,g(x.current)}),w=qe(k=>{m.delete(k),x.current+=1,g(x.current)}),j=v.useMemo(()=>{const k=new Map;return Array.from(m.keys()).filter(S=>S.isConnected).sort(UP).forEach((S,R)=>{const A=m.get(S)??{};k.set(S,{...A,index:R})}),k},[m,h]);Ze(()=>{if(typeof MutationObserver!="function"||j.size===0)return;const k=new MutationObserver(C=>{const S=new Set,R=A=>S.has(A)?S.delete(A):S.add(A);C.forEach(A=>{A.removedNodes.forEach(R),A.addedNodes.forEach(R)}),S.size===0&&(x.current+=1,g(x.current))});return j.forEach((C,S)=>{S.parentElement&&k.observe(S.parentElement,{childList:!0})}),()=>{k.disconnect()}},[j]),Ze(()=>{x.current===h&&(n.current.length!==j.size&&(n.current.length=j.size),a&&a.current.length!==j.size&&(a.current.length=j.size),u.current=j.size),c(j)},[c,j,n,a,h]),Ze(()=>()=>{n.current=[]},[n]),Ze(()=>()=>{a&&(a.current=[])},[a]);const N=qe(k=>(f.add(k),()=>{f.delete(k)}));Ze(()=>{f.forEach(k=>k(j))},[f,j]);const T=v.useMemo(()=>({register:b,unregister:w,subscribeMapChange:N,elementsRef:n,labelsRef:a,nextIndexRef:u}),[b,w,N,n,a,u]);return o.jsx(Nk.Provider,{value:T,children:t})}function $P(){return new Map}function PP(){return new Set}function UP(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 BP=v.forwardRef(function(t,n){const{cutout:a,...i}=t;let c;if(a){const u=a?.getBoundingClientRect();c=`polygon(
|
|
111
|
-
0% 0%,
|
|
112
|
-
100% 0%,
|
|
113
|
-
100% 100%,
|
|
114
|
-
0% 100%,
|
|
115
|
-
0% 0%,
|
|
116
|
-
${u.left}px ${u.top}px,
|
|
117
|
-
${u.left}px ${u.bottom}px,
|
|
118
|
-
${u.right}px ${u.bottom}px,
|
|
119
|
-
${u.right}px ${u.top}px,
|
|
120
|
-
${u.left}px ${u.top}px
|
|
121
|
-
)`}return o.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:c}})}),VP=v.forwardRef(function(t,n){const{anchor:a,positionMethod:i="absolute",className:c,render:u,side:f,align:m,sideOffset:h=0,alignOffset:g=0,collisionBoundary:x="clipping-ancestors",collisionPadding:b=5,arrowPadding:w=5,sticky:j=!1,disableAnchorTracking:N=!1,collisionAvoidance:T=$4,...k}=t,{store:C}=Ro(),S=TP(),R=af(!0),A=C.useState("parent"),M=C.useState("floatingRootContext"),O=C.useState("floatingTreeRoot"),V=C.useState("mounted"),F=C.useState("open"),I=C.useState("modal"),$=C.useState("activeTriggerElement"),L=C.useState("lastOpenChangeReason"),U=C.useState("floatingNodeId"),Y=C.useState("floatingParentNodeId");let K=a,D=h,P=g,B=m;A.type==="context-menu"&&(K=a??A.context?.anchor,B=B??"start",!f&&B!=="center"&&(P=t.alignOffset??2,D=t.sideOffset??-5));let G=f,X=B;A.type==="menu"?(G=G??"inline-end",X=X??"start"):A.type==="menubar"&&(G=G??"bottom",X=X??"start");const z=A.type==="context-menu",Z=zP({anchor:K,floatingRootContext:M,positionMethod:R?"fixed":i,mounted:V,side:G,sideOffset:D,align:X,alignOffset:P,arrowPadding:z?0:w,collisionBoundary:x,collisionPadding:b,sticky:j,nodeId:U,keepMounted:S,disableAnchorTracking:N,collisionAvoidance:T,shiftCrossAxis:z,externalTree:O}),J=v.useMemo(()=>{const xe={};return F||(xe.pointerEvents="none"),{role:"presentation",hidden:!V,style:{...Z.positionerStyles,...xe}}},[F,V,Z.positionerStyles]);v.useEffect(()=>{function xe(Re){Re.open?(Re.parentNodeId===U&&C.set("hoverEnabled",!1),Re.nodeId!==U&&Re.parentNodeId===C.select("floatingParentNodeId")&&C.setOpen(!1,rn(Il))):Re.parentNodeId===U&&Re.reason!==Il&&C.set("hoverEnabled",!0)}return O.events.on("menuopenchange",xe),()=>{O.events.off("menuopenchange",xe)}},[C,O.events,U]),v.useEffect(()=>{if(C.select("floatingParentNodeId")==null)return;function xe(Re){if(Re.open||Re.nodeId!==C.select("floatingParentNodeId"))return;const he=Re.reason??Il;C.setOpen(!1,rn(he))}return O.events.on("menuopenchange",xe),()=>{O.events.off("menuopenchange",xe)}},[O.events,C]),v.useEffect(()=>{function xe(Re){!F||Re.nodeId!==C.select("floatingParentNodeId")||Re.target&&$&&$!==Re.target&&C.setOpen(!1,rn(Il))}return O.events.on("itemhover",xe),()=>{O.events.off("itemhover",xe)}},[O.events,F,$,C]),v.useEffect(()=>{const xe={open:F,nodeId:U,parentNodeId:Y,reason:C.select("lastOpenChangeReason")};O.events.emit("menuopenchange",xe)},[O.events,F,C,U,Y]);const Q=v.useMemo(()=>({open:F,side:Z.side,align:Z.align,anchorHidden:Z.anchorHidden,nested:A.type==="menu"}),[F,Z.side,Z.align,Z.anchorHidden,A.type]),pe=v.useMemo(()=>({side:Z.side,align:Z.align,arrowRef:Z.arrowRef,arrowUncentered:Z.arrowUncentered,arrowStyles:Z.arrowStyles,nodeId:Z.context.nodeId}),[Z.side,Z.align,Z.arrowRef,Z.arrowUncentered,Z.arrowStyles,Z.context.nodeId]),re=xr("div",t,{state:Q,stateAttributesMapping:bk,ref:[n,C.useStateSetter("positionerElement")],props:[J,k]}),de=V&&A.type!=="menu"&&(A.type!=="menubar"&&I&&L!==Xr||A.type==="menubar"&&A.context.modal);let fe=null;return A.type==="menubar"?fe=A.context.contentElement:A.type===void 0&&(fe=$),o.jsxs(fk.Provider,{value:pe,children:[de&&o.jsx(BP,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:RP(!F),cutout:fe}),o.jsx(SL,{id:U,children:o.jsx(LP,{elementsRef:C.context.itemDomElements,labelsRef:C.context.itemLabels,children:re})})]})});let N1={},k1={},E1="";function HP(e){if(typeof document>"u")return!1;const t=si(e);return An(t).innerWidth-t.documentElement.clientWidth>0}function ZP(e){const t=si(e),n=t.documentElement,a=t.body,i=li(n)?n:a,c=i.style.overflow;return i.style.overflow="hidden",()=>{i.style.overflow=c}}function FP(e){const t=si(e),n=t.documentElement,a=t.body,i=An(n);let c=0,u=0;const f=Xs.create(),m=typeof CSS<"u"&&CSS.supports?.("scrollbar-gutter","stable");if(_3&&(i.visualViewport?.scale??1)!==1)return()=>{};function h(){const b=i.getComputedStyle(n),w=i.getComputedStyle(a),T=(b.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";c=n.scrollTop,u=n.scrollLeft,N1={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},E1=n.style.scrollBehavior,k1={position:a.style.position,height:a.style.height,width:a.style.width,boxSizing:a.style.boxSizing,overflowY:a.style.overflowY,overflowX:a.style.overflowX,scrollBehavior:a.style.scrollBehavior};const k=n.scrollHeight>n.clientHeight,C=n.scrollWidth>n.clientWidth,S=b.overflowY==="scroll"||w.overflowY==="scroll",R=b.overflowX==="scroll"||w.overflowX==="scroll",A=Math.max(0,i.innerWidth-n.clientWidth),M=Math.max(0,i.innerHeight-n.clientHeight),O=parseFloat(w.marginTop)+parseFloat(w.marginBottom),V=parseFloat(w.marginLeft)+parseFloat(w.marginRight),F=li(n)?n:a;if(m){n.style.scrollbarGutter=T,F.style.overflowY="hidden",F.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:T,overflowY:"hidden",overflowX:"hidden"}),(k||S)&&(n.style.overflowY="scroll"),(C||R)&&(n.style.overflowX="scroll"),Object.assign(a.style,{position:"relative",height:O||M?`calc(100dvh - ${O+M}px)`:"100dvh",width:V||A?`calc(100vw - ${V+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),a.scrollTop=c,a.scrollLeft=u,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function g(){Object.assign(n.style,N1),Object.assign(a.style,k1),m||(n.scrollTop=c,n.scrollLeft=u,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=E1)}function x(){g(),f.request(h)}return h(),i.addEventListener("resize",x),()=>{f.cancel(),g(),typeof i.removeEventListener=="function"&&i.removeEventListener("resize",x)}}class qP{lockCount=0;restore=null;timeoutLock=No.create();timeoutUnlock=No.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 a=si(t).documentElement,i=An(a).getComputedStyle(a).overflowY;if(i==="hidden"||i==="clip"){this.restore=yk;return}const c=O3||!HP(t);this.restore=c?ZP(t):FP(t)}}const YP=new qP;function GP(e=!0,t=null){Ze(()=>{if(e)return YP.acquire(t)},[e,t])}const WP=v.createContext(null);function XP(e){return v.useContext(WP)}function KP(e){const t=v.useRef(""),n=v.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:v.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 JP(e){const[t,n]=v.useState(null),a=qe((f,m)=>{e||n(m)}),i=v.useCallback(()=>{n(null)},[]),{onClick:c,onPointerDown:u}=KP(a);return v.useMemo(()=>({openMethod:t,reset:i,triggerProps:{onClick:c,onPointerDown:u}}),[t,i,c,u])}const QP={...tP,disabled:Qe(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:Qe(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:Qe(e=>e.parent.type==="menu"?e.parent.store.select("allowMouseEnter"):e.allowMouseEnter),stickIfOpen:Qe(e=>e.stickIfOpen),parent:Qe(e=>e.parent),rootId:Qe(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:Qe(e=>e.activeIndex),isActive:Qe((e,t)=>e.activeIndex===t),hoverEnabled:Qe(e=>e.hoverEnabled),instantType:Qe(e=>e.instantType),lastOpenChangeReason:Qe(e=>e.openChangeReason),floatingTreeRoot:Qe(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:Qe(e=>e.floatingNodeId),floatingParentNodeId:Qe(e=>e.floatingParentNodeId),itemProps:Qe(e=>e.itemProps),closeDelay:Qe(e=>e.closeDelay),keyboardEventRelay:Qe(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class cv extends fE{constructor(t){super({...e6(),...t},{positionerRef:v.createRef(),popupRef:v.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:v.createRef(),beforeContentFocusGuardRef:v.createRef(),onOpenChangeComplete:void 0,triggerElements:new lv},QP),this.observe(Qe(n=>n.allowMouseEnter),(n,a)=>{this.state.parent.type==="menu"&&n!==a&&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 Es(()=>t??new cv(n)).current}unsubscribeParentListener=null}function e6(){return{...eP(),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 Gk,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Wn,keyboardEventRelay:void 0,closeDelay:0}}const t6=v.createContext(void 0);function n6(){return v.useContext(t6)}function s6(e){const{children:t,open:n,onOpenChange:a,onOpenChangeComplete:i,defaultOpen:c=!1,disabled:u=!1,modal:f,loopFocus:m=!0,orientation:h="vertical",actionsRef:g,closeParentOnEsc:x=!0,handle:b,triggerId:w,defaultTriggerId:j=null,highlightItemOnHover:N=!0}=e,T=af(!0),k=Ro(!0),C=XP(),S=n6(),R=v.useMemo(()=>S&&k?{type:"menu",store:k.store}:C?{type:"menubar",context:C}:T&&!k?{type:"context-menu",context:T}:{type:void 0},[T,k,C,S]),A=cv.useStore(b?.store,{parent:R}),M=A.useState("floatingTreeRoot"),O=wL(M),V=Sr();Ze(()=>{T&&!k?A.update({parent:{type:"context-menu",context:T},floatingNodeId:O,floatingParentNodeId:V}):k&&A.update({floatingNodeId:O,floatingParentNodeId:V})},[T,k,O,V,A]),A.useControlledProp("open",n,c),A.useControlledProp("activeTriggerId",w,j),A.useContextCallback("onOpenChangeComplete",i);const F=A.useState("open"),I=A.useState("activeTriggerElement"),$=A.useState("positionerElement"),L=A.useState("hoverEnabled"),U=A.useState("modal"),Y=A.useState("disabled"),K=A.useState("lastOpenChangeReason"),D=A.useState("parent"),P=A.useState("activeIndex"),B=A.useState("payload"),G=A.useState("floatingParentNodeId"),X=v.useRef(null),z=G!=null;let Z;A.useSyncedValues({disabled:u,modal:D.type===void 0?f:void 0,rootId:yr()});const{openMethod:J,triggerProps:Q,reset:pe}=JP(F);K$(A);const{forceUnmount:re}=J$(F,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0}),pe()}),de=v.useRef(D.type!=="context-menu"),fe=Us();v.useEffect(()=>{if(F||(X.current=null),D.type==="context-menu"){if(!F){fe.clear(),de.current=!1;return}fe.start(500,()=>{de.current=!0})}},[fe,F,D.type]),GP(F&&U&&K!==Xr&&J!=="touch",$),Ze(()=>{!F&&!L&&A.set("hoverEnabled",!0)},[F,L,A]);const xe=v.useRef(!0),Re=Us(),he=qe((Ie,tt)=>{const ct=tt.reason;if(F===Ie&&tt.trigger===I||(tt.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},!Ie&&tt.trigger==null&&(tt.trigger=I??void 0),a?.(Ie,tt),tt.isCanceled))return;const xt={open:Ie,nativeEvent:tt.event,reason:tt.reason,nested:z};Z?.emit("openchange",xt);const zt=tt.event;if(Ie===!1&&zt?.type==="click"&&zt.pointerType==="touch"&&!xe.current)return;if(!Ie&&P!==null){const ln=A.context.itemDomElements.current[P];queueMicrotask(()=>{ln?.setAttribute("tabindex","-1")})}Ie&&ct===Ww?(xe.current=!1,Re.start(300,()=>{xe.current=!0})):(xe.current=!0,Re.clear());const yn=(ct===Ad||ct===wk)&&zt.detail===0&&zt?.isTrusted,Xt=!Ie&&(ct===Sk||ct==null);function mn(){const ln={open:Ie,openChangeReason:ct};X.current=tt.event??null;const xn=tt.trigger?.id??null;(xn||Ie)&&(ln.activeTriggerId=xn,ln.activeTriggerElement=tt.trigger??null),A.update(ln)}ct===Xr?ni.flushSync(mn):mn(),D.type==="menubar"&&(ct===Ww||ct===of||ct===Xr||ct===ld||ct===Il)?A.set("instantType","group"):yn||Xt?A.set("instantType",yn?"click":"dismiss"):A.set("instantType",void 0)}),Me=v.useCallback(Ie=>{const tt=rn(Ie);return tt.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},tt},[A]),Se=v.useCallback(()=>{A.setOpen(!1,Me(Q4))},[A,Me]);v.useImperativeHandle(g,()=>({unmount:re,close:Se}),[re,Se]);let Ve;D.type==="context-menu"&&(Ve=D.context),v.useImperativeHandle(Ve?.positionerRef,()=>$,[$]),v.useImperativeHandle(Ve?.actionsRef,()=>({setOpen:he}),[he]);const Oe=aP({popupStore:A,onOpenChange:he});Z=Oe.context.events,v.useEffect(()=>{const Ie=({open:tt,eventDetails:ct})=>he(tt,ct);return Z.on("setOpen",Ie),()=>{Z?.off("setOpen",Ie)}},[Z,he]);const we=N$(Oe,{enabled:!Y,bubbles:x&&D.type==="menu",outsidePress(){return D.type!=="context-menu"||X.current?.type==="contextmenu"?!0:de.current},externalTree:z?M:void 0}),ke=vP(Oe,{role:"menu"}),Ye=bE(),Ue=v.useCallback(Ie=>{A.select("activeIndex")!==Ie&&A.set("activeIndex",Ie)},[A]),He=pP(Oe,{enabled:!Y,listRef:A.context.itemDomElements,activeIndex:P,nested:D.type!==void 0,loopFocus:m,orientation:h,parentOrientation:D.type==="menubar"?D.context.orientation:void 0,rtl:Ye==="rtl",disabledIndices:xk,onNavigate:Ue,openOnArrowKeyDown:D.type!=="context-menu",externalTree:z?M:void 0,focusItemOnHover:N}),le=v.useCallback(Ie=>{A.context.typingRef.current=Ie},[A]),ge=yP(Oe,{listRef:A.context.itemLabels,activeIndex:P,resetMs:D4,onMatch:Ie=>{F&&Ie!==P&&A.set("activeIndex",Ie)},onTypingChange:le}),{getReferenceProps:ve,getFloatingProps:je,getItemProps:Ne,getTriggerProps:Je}=dP([we,ke,He,ge]),et=v.useMemo(()=>{const Ie=rf(ve(),{onMouseEnter(){A.set("hoverEnabled",!0)},onMouseMove(){A.set("allowMouseEnter",!0)}},Q);return delete Ie.role,Ie},[ve,A,Q]),Ge=v.useMemo(()=>{const Ie=Je();if(!Ie)return Ie;const{role:tt,["aria-controls"]:ct,...xt}=Ie;return xt},[Je]),Bt=ev(),kt=v.useMemo(()=>je({onMouseEnter(){D.type==="menu"&&Bt.request(()=>A.set("hoverEnabled",!1))},onMouseMove(){A.set("allowMouseEnter",!0)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(Ie){const tt=A.select("keyboardEventRelay");tt&&!Ie.isPropagationStopped()&&tt(Ie)}}),[je,D.type,Bt,A]),fn=v.useMemo(()=>Ne(),[Ne]);A.useSyncedValues({floatingRootContext:Oe,activeTriggerProps:et,inactiveTriggerProps:Ge,popupProps:kt,itemProps:fn});const hn=v.useMemo(()=>({store:A,parent:R}),[A,R]),on=o.jsx(Gg.Provider,{value:hn,children:typeof t=="function"?t({payload:B}):t});return D.type===void 0||D.type==="context-menu"?o.jsx(jL,{externalTree:M,children:on}):on}function SE(e){if(Qt(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!Js(e))return SE(na(e))}const a6=v.forwardRef(function(t,n){const{className:a,render:i,orientation:c="horizontal",...u}=t,f=v.useMemo(()=>({orientation:c}),[c]);return xr("div",t,{state:f,ref:n,props:[{role:"separator","aria-orientation":c},u]})});function r6(e){const[t,n]=v.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),a=v.useRef(null),i=v.useRef(null),c=v.useRef(null),u=v.useRef(null),f=v.useRef(!0),m=v.useRef(null),h=yr(),g=v.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:c,backdropRef:a,internalBackdropRef:i,positionerRef:u,allowMouseUpTriggerRef:f,initialCursorPointRef:m,rootId:h}),[t,h]);return o.jsx(dk.Provider,{value:g,children:o.jsx(Gg.Provider,{value:void 0,children:o.jsx(s6,{...e})})})}const C1=500,i6=v.forwardRef(function(t,n){const{render:a,className:i,...c}=t,{setAnchor:u,actionsRef:f,internalBackdropRef:m,backdropRef:h,positionerRef:g,allowMouseUpTriggerRef:x,initialCursorPointRef:b,rootId:w}=af(!1),{store:j}=Ro(!1),N=j.useState("open"),T=v.useRef(null),k=v.useRef(null),C=Us(),S=Us(),R=v.useRef(!1);function A(L,U,Y){const K=Y.type.startsWith("touch");b.current={x:L,y:U},u({getBoundingClientRect(){return DOMRect.fromRect({width:K?10:0,height:K?10:0,x:L,y:U})}}),R.current=!1,f.current?.setOpen(!0,rn(Ad,Y)),S.start(C1,()=>{R.current=!0})}function M(L){x.current=!0,Tn(L),A(L.clientX,L.clientY,L.nativeEvent),si(T.current).addEventListener("mouseup",Y=>{if(x.current=!1,!R.current)return;S.clear(),R.current=!1;const K=Gn(Y);_t(g.current,K)||w&&K&&SE(K)===w||f.current?.setOpen(!1,rn(J4,Y))},{once:!0})}function O(L){if(x.current=!1,L.touches.length===1){L.stopPropagation();const U=L.touches[0];k.current={x:U.clientX,y:U.clientY},C.start(C1,()=>{k.current&&A(k.current.x,k.current.y,L.nativeEvent)})}}function V(L){if(C.isStarted()&&k.current&&L.touches.length===1){const U=L.touches[0],Y=10,K=Math.abs(U.clientX-k.current.x),D=Math.abs(U.clientY-k.current.y);(K>Y||D>Y)&&C.clear()}}function F(){C.clear(),k.current=null}v.useEffect(()=>{function L(Y){const D=Gn(Y);(_t(T.current,D)||_t(m.current,D)||_t(h.current,D))&&Y.preventDefault()}const U=si(T.current);return U.addEventListener("contextmenu",L),()=>{U.removeEventListener("contextmenu",L)}},[h,m]);const I=v.useMemo(()=>({open:N}),[N]);return xr("div",t,{state:I,ref:[T,n],props:[{onContextMenu:M,onTouchStart:O,onTouchMove:V,onTouchEnd:F,onTouchCancel:F,style:{WebkitTouchCallout:"none"}},c],stateAttributesMapping:X4})}),uv=v.createContext({});function dv(e){const t=v.useRef(null);return t.current===null&&(t.current=e()),t.current}const jE=typeof window<"u",NE=jE?v.useLayoutEffect:v.useEffect,pf=v.createContext(null);function fv(e,t){e.indexOf(t)===-1&&e.push(t)}function Bd(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const sa=(e,t,n)=>n>t?t:n<e?e:n;let hv=()=>{};const Ta={},kE=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function EE(e){return typeof e=="object"&&e!==null}const CE=e=>/^0[^.\s]+$/u.test(e);function TE(e){let t;return()=>(t===void 0&&(t=e()),t)}const ks=e=>e,o6=(e,t)=>n=>t(e(n)),hc=(...e)=>e.reduce(o6),nc=(e,t,n)=>{const a=t-e;return a===0?1:(n-e)/a};class mv{constructor(){this.subscriptions=[]}add(t){return fv(this.subscriptions,t),()=>Bd(this.subscriptions,t)}notify(t,n,a){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,a);else for(let c=0;c<i;c++){const u=this.subscriptions[c];u&&u(t,n,a)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const $s=e=>e*1e3,Ns=e=>e/1e3;function AE(e,t){return t?e*(1e3/t):0}const RE=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,l6=1e-7,c6=12;function u6(e,t,n,a,i){let c,u,f=0;do u=t+(n-t)/2,c=RE(u,a,i)-e,c>0?n=u:t=u;while(Math.abs(c)>l6&&++f<c6);return u}function mc(e,t,n,a){if(e===t&&n===a)return ks;const i=c=>u6(c,0,1,e,n);return c=>c===0||c===1?c:RE(i(c),t,a)}const ME=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,_E=e=>t=>1-e(1-t),OE=mc(.33,1.53,.69,.99),pv=_E(OE),IE=ME(pv),DE=e=>(e*=2)<1?.5*pv(e):.5*(2-Math.pow(2,-10*(e-1))),gv=e=>1-Math.sin(Math.acos(e)),zE=_E(gv),LE=ME(gv),d6=mc(.42,0,1,1),f6=mc(0,0,.58,1),$E=mc(.42,0,.58,1),h6=e=>Array.isArray(e)&&typeof e[0]!="number",PE=e=>Array.isArray(e)&&typeof e[0]=="number",m6={linear:ks,easeIn:d6,easeInOut:$E,easeOut:f6,circIn:gv,circInOut:LE,circOut:zE,backIn:pv,backInOut:IE,backOut:OE,anticipate:DE},p6=e=>typeof e=="string",T1=e=>{if(PE(e)){hv(e.length===4);const[t,n,a,i]=e;return mc(t,n,a,i)}else if(p6(e))return m6[e];return e},Vu=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function g6(e,t){let n=new Set,a=new Set,i=!1,c=!1;const u=new WeakSet;let f={delta:0,timestamp:0,isProcessing:!1};function m(g){u.has(g)&&(h.schedule(g),e()),g(f)}const h={schedule:(g,x=!1,b=!1)=>{const j=b&&i?n:a;return x&&u.add(g),j.has(g)||j.add(g),g},cancel:g=>{a.delete(g),u.delete(g)},process:g=>{if(f=g,i){c=!0;return}i=!0,[n,a]=[a,n],n.forEach(m),n.clear(),i=!1,c&&(c=!1,h.process(g))}};return h}const v6=40;function UE(e,t){let n=!1,a=!0;const i={delta:0,timestamp:0,isProcessing:!1},c=()=>n=!0,u=Vu.reduce((S,R)=>(S[R]=g6(c),S),{}),{setup:f,read:m,resolveKeyframes:h,preUpdate:g,update:x,preRender:b,render:w,postRender:j}=u,N=()=>{const S=Ta.useManualTiming?i.timestamp:performance.now();n=!1,Ta.useManualTiming||(i.delta=a?1e3/60:Math.max(Math.min(S-i.timestamp,v6),1)),i.timestamp=S,i.isProcessing=!0,f.process(i),m.process(i),h.process(i),g.process(i),x.process(i),b.process(i),w.process(i),j.process(i),i.isProcessing=!1,n&&t&&(a=!1,e(N))},T=()=>{n=!0,a=!0,i.isProcessing||e(N)};return{schedule:Vu.reduce((S,R)=>{const A=u[R];return S[R]=(M,O=!1,V=!1)=>(n||T(),A.schedule(M,O,V)),S},{}),cancel:S=>{for(let R=0;R<Vu.length;R++)u[Vu[R]].cancel(S)},state:i,steps:u}}const{schedule:Et,cancel:mr,state:En,steps:tp}=UE(typeof requestAnimationFrame<"u"?requestAnimationFrame:ks,!0);let dd;function y6(){dd=void 0}const Ln={now:()=>(dd===void 0&&Ln.set(En.isProcessing||Ta.useManualTiming?En.timestamp:performance.now()),dd),set:e=>{dd=e,queueMicrotask(y6)}},BE=e=>t=>typeof t=="string"&&t.startsWith(e),VE=BE("--"),x6=BE("var(--"),vv=e=>x6(e)?b6.test(e.split("/*")[0].trim()):!1,b6=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function A1(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Oo={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},sc={...Oo,transform:e=>sa(0,1,e)},Hu={...Oo,default:1},Zl=e=>Math.round(e*1e5)/1e5,yv=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function w6(e){return e==null}const S6=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,xv=(e,t)=>n=>!!(typeof n=="string"&&S6.test(n)&&n.startsWith(e)||t&&!w6(n)&&Object.prototype.hasOwnProperty.call(n,t)),HE=(e,t,n)=>a=>{if(typeof a!="string")return a;const[i,c,u,f]=a.match(yv);return{[e]:parseFloat(i),[t]:parseFloat(c),[n]:parseFloat(u),alpha:f!==void 0?parseFloat(f):1}},j6=e=>sa(0,255,e),np={...Oo,transform:e=>Math.round(j6(e))},Yr={test:xv("rgb","red"),parse:HE("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:a=1})=>"rgba("+np.transform(e)+", "+np.transform(t)+", "+np.transform(n)+", "+Zl(sc.transform(a))+")"};function N6(e){let t="",n="",a="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),a=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),a=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,a+=a,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(a,16),alpha:i?parseInt(i,16)/255:1}}const sg={test:xv("#"),parse:N6,transform:Yr.transform},pc=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),tr=pc("deg"),ea=pc("%"),Ce=pc("px"),k6=pc("vh"),E6=pc("vw"),R1={...ea,parse:e=>ea.parse(e)/100,transform:e=>ea.transform(e*100)},uo={test:xv("hsl","hue"),parse:HE("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:a=1})=>"hsla("+Math.round(e)+", "+ea.transform(Zl(t))+", "+ea.transform(Zl(n))+", "+Zl(sc.transform(a))+")"},an={test:e=>Yr.test(e)||sg.test(e)||uo.test(e),parse:e=>Yr.test(e)?Yr.parse(e):uo.test(e)?uo.parse(e):sg.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Yr.transform(e):uo.transform(e),getAnimatableNone:e=>{const t=an.parse(e);return t.alpha=0,an.transform(t)}},C6=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function T6(e){return isNaN(e)&&typeof e=="string"&&(e.match(yv)?.length||0)+(e.match(C6)?.length||0)>0}const ZE="number",FE="color",A6="var",R6="var(",M1="${}",M6=/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 ac(e){const t=e.toString(),n=[],a={color:[],number:[],var:[]},i=[];let c=0;const f=t.replace(M6,m=>(an.test(m)?(a.color.push(c),i.push(FE),n.push(an.parse(m))):m.startsWith(R6)?(a.var.push(c),i.push(A6),n.push(m)):(a.number.push(c),i.push(ZE),n.push(parseFloat(m))),++c,M1)).split(M1);return{values:n,split:f,indexes:a,types:i}}function qE(e){return ac(e).values}function YE(e){const{split:t,types:n}=ac(e),a=t.length;return i=>{let c="";for(let u=0;u<a;u++)if(c+=t[u],i[u]!==void 0){const f=n[u];f===ZE?c+=Zl(i[u]):f===FE?c+=an.transform(i[u]):c+=i[u]}return c}}const _6=e=>typeof e=="number"?0:an.test(e)?an.getAnimatableNone(e):e;function O6(e){const t=qE(e);return YE(e)(t.map(_6))}const Ps={test:T6,parse:qE,createTransformer:YE,getAnimatableNone:O6};function sp(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 I6({hue:e,saturation:t,lightness:n,alpha:a}){e/=360,t/=100,n/=100;let i=0,c=0,u=0;if(!t)i=c=u=n;else{const f=n<.5?n*(1+t):n+t-n*t,m=2*n-f;i=sp(m,f,e+1/3),c=sp(m,f,e),u=sp(m,f,e-1/3)}return{red:Math.round(i*255),green:Math.round(c*255),blue:Math.round(u*255),alpha:a}}function Vd(e,t){return n=>n>0?t:e}const Vt=(e,t,n)=>e+(t-e)*n,ap=(e,t,n)=>{const a=e*e,i=n*(t*t-a)+a;return i<0?0:Math.sqrt(i)},D6=[sg,Yr,uo],z6=e=>D6.find(t=>t.test(e));function _1(e){const t=z6(e);if(!t)return!1;let n=t.parse(e);return t===uo&&(n=I6(n)),n}const O1=(e,t)=>{const n=_1(e),a=_1(t);if(!n||!a)return Vd(e,t);const i={...n};return c=>(i.red=ap(n.red,a.red,c),i.green=ap(n.green,a.green,c),i.blue=ap(n.blue,a.blue,c),i.alpha=Vt(n.alpha,a.alpha,c),Yr.transform(i))},ag=new Set(["none","hidden"]);function L6(e,t){return ag.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function $6(e,t){return n=>Vt(e,t,n)}function bv(e){return typeof e=="number"?$6:typeof e=="string"?vv(e)?Vd:an.test(e)?O1:B6:Array.isArray(e)?GE:typeof e=="object"?an.test(e)?O1:P6:Vd}function GE(e,t){const n=[...e],a=n.length,i=e.map((c,u)=>bv(c)(c,t[u]));return c=>{for(let u=0;u<a;u++)n[u]=i[u](c);return n}}function P6(e,t){const n={...e,...t},a={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(a[i]=bv(e[i])(e[i],t[i]));return i=>{for(const c in a)n[c]=a[c](i);return n}}function U6(e,t){const n=[],a={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const c=t.types[i],u=e.indexes[c][a[c]],f=e.values[u]??0;n[i]=f,a[c]++}return n}const B6=(e,t)=>{const n=Ps.createTransformer(t),a=ac(e),i=ac(t);return a.indexes.var.length===i.indexes.var.length&&a.indexes.color.length===i.indexes.color.length&&a.indexes.number.length>=i.indexes.number.length?ag.has(e)&&!i.values.length||ag.has(t)&&!a.values.length?L6(e,t):hc(GE(U6(a,i),i.values),n):Vd(e,t)};function WE(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Vt(e,t,n):bv(e)(e,t)}const V6=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>Et.update(t,n),stop:()=>mr(t),now:()=>En.isProcessing?En.timestamp:Ln.now()}},XE=(e,t,n=10)=>{let a="";const i=Math.max(Math.round(t/n),2);for(let c=0;c<i;c++)a+=Math.round(e(c/(i-1))*1e4)/1e4+", ";return`linear(${a.substring(0,a.length-2)})`},Hd=2e4;function wv(e){let t=0;const n=50;let a=e.next(t);for(;!a.done&&t<Hd;)t+=n,a=e.next(t);return t>=Hd?1/0:t}function H6(e,t=100,n){const a=n({...e,keyframes:[0,t]}),i=Math.min(wv(a),Hd);return{type:"keyframes",ease:c=>a.next(i*c).value/t,duration:Ns(i)}}const Z6=5;function KE(e,t,n){const a=Math.max(t-Z6,0);return AE(n-e(a),t-a)}const Wt={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},rp=.001;function F6({duration:e=Wt.duration,bounce:t=Wt.bounce,velocity:n=Wt.velocity,mass:a=Wt.mass}){let i,c,u=1-t;u=sa(Wt.minDamping,Wt.maxDamping,u),e=sa(Wt.minDuration,Wt.maxDuration,Ns(e)),u<1?(i=h=>{const g=h*u,x=g*e,b=g-n,w=rg(h,u),j=Math.exp(-x);return rp-b/w*j},c=h=>{const x=h*u*e,b=x*n+n,w=Math.pow(u,2)*Math.pow(h,2)*e,j=Math.exp(-x),N=rg(Math.pow(h,2),u);return(-i(h)+rp>0?-1:1)*((b-w)*j)/N}):(i=h=>{const g=Math.exp(-h*e),x=(h-n)*e+1;return-rp+g*x},c=h=>{const g=Math.exp(-h*e),x=(n-h)*(e*e);return g*x});const f=5/e,m=Y6(i,c,f);if(e=$s(e),isNaN(m))return{stiffness:Wt.stiffness,damping:Wt.damping,duration:e};{const h=Math.pow(m,2)*a;return{stiffness:h,damping:u*2*Math.sqrt(a*h),duration:e}}}const q6=12;function Y6(e,t,n){let a=n;for(let i=1;i<q6;i++)a=a-e(a)/t(a);return a}function rg(e,t){return e*Math.sqrt(1-t*t)}const G6=["duration","bounce"],W6=["stiffness","damping","mass"];function I1(e,t){return t.some(n=>e[n]!==void 0)}function X6(e){let t={velocity:Wt.velocity,stiffness:Wt.stiffness,damping:Wt.damping,mass:Wt.mass,isResolvedFromDuration:!1,...e};if(!I1(e,W6)&&I1(e,G6))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,a=2*Math.PI/(n*1.2),i=a*a,c=2*sa(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Wt.mass,stiffness:i,damping:c}}else{const n=F6({...e,velocity:0});t={...t,...n,mass:Wt.mass},t.isResolvedFromDuration=!0}return t}function Zd(e=Wt.visualDuration,t=Wt.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:a,restDelta:i}=n;const c=n.keyframes[0],u=n.keyframes[n.keyframes.length-1],f={done:!1,value:c},{stiffness:m,damping:h,mass:g,duration:x,velocity:b,isResolvedFromDuration:w}=X6({...n,velocity:-Ns(n.velocity||0)}),j=b||0,N=h/(2*Math.sqrt(m*g)),T=u-c,k=Ns(Math.sqrt(m/g)),C=Math.abs(T)<5;a||(a=C?Wt.restSpeed.granular:Wt.restSpeed.default),i||(i=C?Wt.restDelta.granular:Wt.restDelta.default);let S;if(N<1){const A=rg(k,N);S=M=>{const O=Math.exp(-N*k*M);return u-O*((j+N*k*T)/A*Math.sin(A*M)+T*Math.cos(A*M))}}else if(N===1)S=A=>u-Math.exp(-k*A)*(T+(j+k*T)*A);else{const A=k*Math.sqrt(N*N-1);S=M=>{const O=Math.exp(-N*k*M),V=Math.min(A*M,300);return u-O*((j+N*k*T)*Math.sinh(V)+A*T*Math.cosh(V))/A}}const R={calculatedDuration:w&&x||null,next:A=>{const M=S(A);if(w)f.done=A>=x;else{let O=A===0?j:0;N<1&&(O=A===0?$s(j):KE(S,A,M));const V=Math.abs(O)<=a,F=Math.abs(u-M)<=i;f.done=V&&F}return f.value=f.done?u:M,f},toString:()=>{const A=Math.min(wv(R),Hd),M=XE(O=>R.next(A*O).value,A,30);return A+"ms "+M},toTransition:()=>{}};return R}Zd.applyToOptions=e=>{const t=H6(e,100,Zd);return e.ease=t.ease,e.duration=$s(t.duration),e.type="keyframes",e};function ig({keyframes:e,velocity:t=0,power:n=.8,timeConstant:a=325,bounceDamping:i=10,bounceStiffness:c=500,modifyTarget:u,min:f,max:m,restDelta:h=.5,restSpeed:g}){const x=e[0],b={done:!1,value:x},w=V=>f!==void 0&&V<f||m!==void 0&&V>m,j=V=>f===void 0?m:m===void 0||Math.abs(f-V)<Math.abs(m-V)?f:m;let N=n*t;const T=x+N,k=u===void 0?T:u(T);k!==T&&(N=k-x);const C=V=>-N*Math.exp(-V/a),S=V=>k+C(V),R=V=>{const F=C(V),I=S(V);b.done=Math.abs(F)<=h,b.value=b.done?k:I};let A,M;const O=V=>{w(b.value)&&(A=V,M=Zd({keyframes:[b.value,j(b.value)],velocity:KE(S,V,b.value),damping:i,stiffness:c,restDelta:h,restSpeed:g}))};return O(0),{calculatedDuration:null,next:V=>{let F=!1;return!M&&A===void 0&&(F=!0,R(V),O(V)),A!==void 0&&V>=A?M.next(V-A):(!F&&R(V),b)}}}function K6(e,t,n){const a=[],i=n||Ta.mix||WE,c=e.length-1;for(let u=0;u<c;u++){let f=i(e[u],e[u+1]);if(t){const m=Array.isArray(t)?t[u]||ks:t;f=hc(m,f)}a.push(f)}return a}function J6(e,t,{clamp:n=!0,ease:a,mixer:i}={}){const c=e.length;if(hv(c===t.length),c===1)return()=>t[0];if(c===2&&t[0]===t[1])return()=>t[1];const u=e[0]===e[1];e[0]>e[c-1]&&(e=[...e].reverse(),t=[...t].reverse());const f=K6(t,a,i),m=f.length,h=g=>{if(u&&g<e[0])return t[0];let x=0;if(m>1)for(;x<e.length-2&&!(g<e[x+1]);x++);const b=nc(e[x],e[x+1],g);return f[x](b)};return n?g=>h(sa(e[0],e[c-1],g)):h}function Q6(e,t){const n=e[e.length-1];for(let a=1;a<=t;a++){const i=nc(0,t,a);e.push(Vt(n,1,i))}}function e8(e){const t=[0];return Q6(t,e.length-1),t}function t8(e,t){return e.map(n=>n*t)}function n8(e,t){return e.map(()=>t||$E).splice(0,e.length-1)}function Fl({duration:e=300,keyframes:t,times:n,ease:a="easeInOut"}){const i=h6(a)?a.map(T1):T1(a),c={done:!1,value:t[0]},u=t8(n&&n.length===t.length?n:e8(t),e),f=J6(u,t,{ease:Array.isArray(i)?i:n8(t,i)});return{calculatedDuration:e,next:m=>(c.value=f(m),c.done=m>=e,c)}}const s8=e=>e!==null;function Sv(e,{repeat:t,repeatType:n="loop"},a,i=1){const c=e.filter(s8),f=i<0||t&&n!=="loop"&&t%2===1?0:c.length-1;return!f||a===void 0?c[f]:a}const a8={decay:ig,inertia:ig,tween:Fl,keyframes:Fl,spring:Zd};function JE(e){typeof e.type=="string"&&(e.type=a8[e.type])}class jv{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 r8=e=>e/100;class Nv extends jv{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!==Ln.now()&&this.tick(Ln.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;JE(t);const{type:n=Fl,repeat:a=0,repeatDelay:i=0,repeatType:c,velocity:u=0}=t;let{keyframes:f}=t;const m=n||Fl;m!==Fl&&typeof f[0]!="number"&&(this.mixKeyframes=hc(r8,WE(f[0],f[1])),f=[0,100]);const h=m({...t,keyframes:f});c==="mirror"&&(this.mirroredGenerator=m({...t,keyframes:[...f].reverse(),velocity:-u})),h.calculatedDuration===null&&(h.calculatedDuration=wv(h));const{calculatedDuration:g}=h;this.calculatedDuration=g,this.resolvedDuration=g+i,this.totalDuration=this.resolvedDuration*(a+1)-i,this.generator=h}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:a,totalDuration:i,mixKeyframes:c,mirroredGenerator:u,resolvedDuration:f,calculatedDuration:m}=this;if(this.startTime===null)return a.next(0);const{delay:h=0,keyframes:g,repeat:x,repeatType:b,repeatDelay:w,type:j,onUpdate:N,finalKeyframe:T}=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 k=this.currentTime-h*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?k<0:k>i;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,R=a;if(x){const V=Math.min(this.currentTime,i)/f;let F=Math.floor(V),I=V%1;!I&&V>=1&&(I=1),I===1&&F--,F=Math.min(F,x+1),F%2&&(b==="reverse"?(I=1-I,w&&(I-=w/f)):b==="mirror"&&(R=u)),S=sa(0,1,I)*f}const A=C?{done:!1,value:g[0]}:R.next(S);c&&(A.value=c(A.value));let{done:M}=A;!C&&m!==null&&(M=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&M);return O&&j!==ig&&(A.value=Sv(g,this.options,T,this.speed)),N&&N(A.value),O&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return Ns(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ns(t)}get time(){return Ns(this.currentTime)}set time(t){t=$s(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(Ln.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Ns(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=V6,startTime:n}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),this.options.onPlay?.();const a=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=a):this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime||(this.startTime=n??a),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(Ln.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 i8(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Gr=e=>e*180/Math.PI,og=e=>{const t=Gr(Math.atan2(e[1],e[0]));return lg(t)},o8={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:og,rotateZ:og,skewX:e=>Gr(Math.atan(e[1])),skewY:e=>Gr(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},lg=e=>(e=e%360,e<0&&(e+=360),e),D1=og,z1=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),L1=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),l8={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:z1,scaleY:L1,scale:e=>(z1(e)+L1(e))/2,rotateX:e=>lg(Gr(Math.atan2(e[6],e[5]))),rotateY:e=>lg(Gr(Math.atan2(-e[2],e[0]))),rotateZ:D1,rotate:D1,skewX:e=>Gr(Math.atan(e[4])),skewY:e=>Gr(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function cg(e){return e.includes("scale")?1:0}function ug(e,t){if(!e||e==="none")return cg(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let a,i;if(n)a=l8,i=n;else{const f=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);a=o8,i=f}if(!i)return cg(t);const c=a[t],u=i[1].split(",").map(u8);return typeof c=="function"?c(u):u[c]}const c8=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return ug(n,t)};function u8(e){return parseFloat(e.trim())}const Io=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Do=new Set(Io),$1=e=>e===Oo||e===Ce,d8=new Set(["x","y","z"]),f8=Io.filter(e=>!d8.has(e));function h8(e){const t=[];return f8.forEach(n=>{const a=e.getValue(n);a!==void 0&&(t.push([n,a.get()]),a.set(n.startsWith("scale")?1:0))}),t}const or={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})=>ug(t,"x"),y:(e,{transform:t})=>ug(t,"y")};or.translateX=or.x;or.translateY=or.y;const Kr=new Set;let dg=!1,fg=!1,hg=!1;function QE(){if(fg){const e=Array.from(Kr).filter(a=>a.needsMeasurement),t=new Set(e.map(a=>a.element)),n=new Map;t.forEach(a=>{const i=h8(a);i.length&&(n.set(a,i),a.render())}),e.forEach(a=>a.measureInitialState()),t.forEach(a=>{a.render();const i=n.get(a);i&&i.forEach(([c,u])=>{a.getValue(c)?.set(u)})}),e.forEach(a=>a.measureEndState()),e.forEach(a=>{a.suspendedScrollY!==void 0&&window.scrollTo(0,a.suspendedScrollY)})}fg=!1,dg=!1,Kr.forEach(e=>e.complete(hg)),Kr.clear()}function eC(){Kr.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(fg=!0)})}function m8(){hg=!0,eC(),QE(),hg=!1}class kv{constructor(t,n,a,i,c,u=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=a,this.motionValue=i,this.element=c,this.isAsync=u}scheduleResolve(){this.state="scheduled",this.isAsync?(Kr.add(this),dg||(dg=!0,Et.read(eC),Et.resolveKeyframes(QE))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:a,motionValue:i}=this;if(t[0]===null){const c=i?.get(),u=t[t.length-1];if(c!==void 0)t[0]=c;else if(a&&n){const f=a.readValue(n,u);f!=null&&(t[0]=f)}t[0]===void 0&&(t[0]=u),i&&c===void 0&&i.set(t[0])}i8(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Kr.delete(this)}cancel(){this.state==="scheduled"&&(Kr.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const p8=e=>e.startsWith("--");function g8(e,t,n){p8(t)?e.style.setProperty(t,n):e.style[t]=n}const v8={};function tC(e,t){const n=TE(e);return()=>v8[t]??n()}const y8=tC(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),nC=tC(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Dl=([e,t,n,a])=>`cubic-bezier(${e}, ${t}, ${n}, ${a})`,P1={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Dl([0,.65,.55,1]),circOut:Dl([.55,0,1,.45]),backIn:Dl([.31,.01,.66,-.59]),backOut:Dl([.33,1.53,.69,.99])};function sC(e,t){if(e)return typeof e=="function"?nC()?XE(e,t):"ease-out":PE(e)?Dl(e):Array.isArray(e)?e.map(n=>sC(n,t)||P1.easeOut):P1[e]}function x8(e,t,n,{delay:a=0,duration:i=300,repeat:c=0,repeatType:u="loop",ease:f="easeOut",times:m}={},h=void 0){const g={[t]:n};m&&(g.offset=m);const x=sC(f,i);Array.isArray(x)&&(g.easing=x);const b={delay:a,duration:i,easing:Array.isArray(x)?"linear":x,fill:"both",iterations:c+1,direction:u==="reverse"?"alternate":"normal"};return h&&(b.pseudoElement=h),e.animate(g,b)}function aC(e){return typeof e=="function"&&"applyToOptions"in e}function b8({type:e,...t}){return aC(e)&&nC()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class rC extends jv{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:a,keyframes:i,pseudoElement:c,allowFlatten:u=!1,finalKeyframe:f,onComplete:m}=t;this.isPseudoElement=!!c,this.allowFlatten=u,this.options=t,hv(typeof t.type!="string");const h=b8(t);this.animation=x8(n,a,i,h,c),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!c){const g=Sv(i,this.options,f,this.speed);this.updateMotionValue?this.updateMotionValue(g):g8(n,a,g),this.animation.cancel()}m?.(),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 Ns(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ns(t)}get time(){return Ns(Number(this.animation.currentTime)||0)}set time(t){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=$s(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&&y8()?(this.animation.timeline=t,ks):n(this)}}const iC={anticipate:DE,backInOut:IE,circInOut:LE};function w8(e){return e in iC}function S8(e){typeof e.ease=="string"&&w8(e.ease)&&(e.ease=iC[e.ease])}const ip=10;class j8 extends rC{constructor(t){S8(t),JE(t),super(t),t.startTime!==void 0&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:a,onComplete:i,element:c,...u}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const f=new Nv({...u,autoplay:!1}),m=Math.max(ip,Ln.now()-this.startTime),h=sa(0,ip,m-ip);n.setWithVelocity(f.sample(Math.max(0,m-h)).value,f.sample(m).value,h),f.stop()}}const U1=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Ps.test(e)||e==="0")&&!e.startsWith("url("));function N8(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 k8(e,t,n,a){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const c=e[e.length-1],u=U1(i,t),f=U1(c,t);return!u||!f?!1:N8(e)||(n==="spring"||aC(n))&&a}function mg(e){e.duration=0,e.type="keyframes"}const E8=new Set(["opacity","clipPath","filter","transform"]),C8=TE(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function T8(e){const{motionValue:t,name:n,repeatDelay:a,repeatType:i,damping:c,type:u}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:m,transformTemplate:h}=t.owner.getProps();return C8()&&n&&E8.has(n)&&(n!=="transform"||!h)&&!m&&!a&&i!=="mirror"&&c!==0&&u!=="inertia"}const A8=40;class R8 extends jv{constructor({autoplay:t=!0,delay:n=0,type:a="keyframes",repeat:i=0,repeatDelay:c=0,repeatType:u="loop",keyframes:f,name:m,motionValue:h,element:g,...x}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ln.now();const b={autoplay:t,delay:n,type:a,repeat:i,repeatDelay:c,repeatType:u,name:m,motionValue:h,element:g,...x},w=g?.KeyframeResolver||kv;this.keyframeResolver=new w(f,(j,N,T)=>this.onKeyframesResolved(j,N,b,!T),m,h,g),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,a,i){this.keyframeResolver=void 0;const{name:c,type:u,velocity:f,delay:m,isHandoff:h,onUpdate:g}=a;this.resolvedAt=Ln.now(),k8(t,c,u,f)||((Ta.instantAnimations||!m)&&g?.(Sv(t,a,n)),t[0]=t[t.length-1],mg(a),a.repeat=0);const b={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>A8?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...a,keyframes:t},w=!h&&T8(b),j=b.motionValue?.owner?.current,N=w?new j8({...b,element:j}):new Nv(b);N.finished.then(()=>{this.notifyFinished()}).catch(ks),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(),m8()),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 oC(e,t,n,a=0,i=1){const c=Array.from(e).sort((h,g)=>h.sortNodePosition(g)).indexOf(t),u=e.size,f=(u-1)*a;return typeof n=="function"?n(c,u):i===1?c*a:f-c*a}const M8=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function _8(e){const t=M8.exec(e);if(!t)return[,];const[,n,a,i]=t;return[`--${n??a}`,i]}function lC(e,t,n=1){const[a,i]=_8(e);if(!a)return;const c=window.getComputedStyle(t).getPropertyValue(a);if(c){const u=c.trim();return kE(u)?parseFloat(u):u}return vv(i)?lC(i,t,n+1):i}const O8={type:"spring",stiffness:500,damping:25,restSpeed:10},I8=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),D8={type:"keyframes",duration:.8},z8={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},L8=(e,{keyframes:t})=>t.length>2?D8:Do.has(e)?e.startsWith("scale")?I8(t[1]):O8:z8,$8=e=>e!==null;function P8(e,{repeat:t,repeatType:n="loop"},a){const i=e.filter($8),c=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[c]}function cC(e,t){if(e?.inherit&&t){const{inherit:n,...a}=e;return{...t,...a}}return e}function Ev(e,t){const n=e?.[t]??e?.default??e;return n!==e?cC(n,e):n}function U8({when:e,delay:t,delayChildren:n,staggerChildren:a,staggerDirection:i,repeat:c,repeatType:u,repeatDelay:f,from:m,elapsed:h,...g}){return!!Object.keys(g).length}const Cv=(e,t,n,a={},i,c)=>u=>{const f=Ev(a,e)||{},m=f.delay||a.delay||0;let{elapsed:h=0}=a;h=h-$s(m);const g={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...f,delay:-h,onUpdate:b=>{t.set(b),f.onUpdate&&f.onUpdate(b)},onComplete:()=>{u(),f.onComplete&&f.onComplete()},name:e,motionValue:t,element:c?void 0:i};U8(f)||Object.assign(g,L8(e,g)),g.duration&&(g.duration=$s(g.duration)),g.repeatDelay&&(g.repeatDelay=$s(g.repeatDelay)),g.from!==void 0&&(g.keyframes[0]=g.from);let x=!1;if((g.type===!1||g.duration===0&&!g.repeatDelay)&&(mg(g),g.delay===0&&(x=!0)),(Ta.instantAnimations||Ta.skipAnimations||i?.shouldSkipAnimations)&&(x=!0,mg(g),g.delay=0),g.allowFlatten=!f.type&&!f.ease,x&&!c&&t.get()!==void 0){const b=P8(g.keyframes,f);if(b!==void 0){Et.update(()=>{g.onUpdate(b),g.onComplete()});return}}return f.isSync?new Nv(g):new R8(g)};function B1(e){const t=[{},{}];return e?.values.forEach((n,a)=>{t[0][a]=n.get(),t[1][a]=n.getVelocity()}),t}function Tv(e,t,n,a){if(typeof t=="function"){const[i,c]=B1(a);t=t(n!==void 0?n:e.custom,i,c)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,c]=B1(a);t=t(n!==void 0?n:e.custom,i,c)}return t}function bo(e,t,n){const a=e.getProps();return Tv(a,t,n!==void 0?n:a.custom,e)}const uC=new Set(["width","height","top","left","right","bottom",...Io]),V1=30,B8=e=>!isNaN(parseFloat(e));class V8{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=a=>{const i=Ln.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(a),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const c of this.dependents)c.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ln.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=B8(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 mv);const a=this.events[t].add(n);return t==="change"?()=>{a(),Et.read(()=>{this.events.change.getSize()||this.stop()})}:a}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,a){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-a}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=Ln.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>V1)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,V1);return AE(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 Co(e,t){return new V8(e,t)}const pg=e=>Array.isArray(e);function H8(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Co(n))}function Z8(e){return pg(e)?e[e.length-1]||0:e}function F8(e,t){const n=bo(e,t);let{transitionEnd:a={},transition:i={},...c}=n||{};c={...c,...a};for(const u in c){const f=Z8(c[u]);H8(e,u,f)}}const _n=e=>!!(e&&e.getVelocity);function q8(e){return!!(_n(e)&&e.add)}function gg(e,t){const n=e.getValue("willChange");if(q8(n))return n.add(t);if(!n&&Ta.WillChange){const a=new Ta.WillChange("auto");e.addValue("willChange",a),a.add(t)}}function Av(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const Y8="framerAppearId",dC="data-"+Av(Y8);function fC(e){return e.props[dC]}function G8({protectedKeys:e,needsAnimating:t},n){const a=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,a}function hC(e,t,{delay:n=0,transitionOverride:a,type:i}={}){let{transition:c,transitionEnd:u,...f}=t;const m=e.getDefaultTransition();c=c?cC(c,m):m;const h=c?.reduceMotion;a&&(c=a);const g=[],x=i&&e.animationState&&e.animationState.getState()[i];for(const b in f){const w=e.getValue(b,e.latestValues[b]??null),j=f[b];if(j===void 0||x&&G8(x,b))continue;const N={delay:n,...Ev(c||{},b)},T=w.get();if(T!==void 0&&!w.isAnimating&&!Array.isArray(j)&&j===T&&!N.velocity)continue;let k=!1;if(window.MotionHandoffAnimation){const R=fC(e);if(R){const A=window.MotionHandoffAnimation(R,b,Et);A!==null&&(N.startTime=A,k=!0)}}gg(e,b);const C=h??e.shouldReduceMotion;w.start(Cv(b,w,j,C&&uC.has(b)?{type:!1}:N,e,k));const S=w.animation;S&&g.push(S)}if(u){const b=()=>Et.update(()=>{u&&F8(e,u)});g.length?Promise.all(g).then(b):b()}return g}function vg(e,t,n={}){const a=bo(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(i=n.transitionOverride);const c=a?()=>Promise.all(hC(e,a,n)):()=>Promise.resolve(),u=e.variantChildren&&e.variantChildren.size?(m=0)=>{const{delayChildren:h=0,staggerChildren:g,staggerDirection:x}=i;return W8(e,t,m,h,g,x,n)}:()=>Promise.resolve(),{when:f}=i;if(f){const[m,h]=f==="beforeChildren"?[c,u]:[u,c];return m().then(()=>h())}else return Promise.all([c(),u(n.delay)])}function W8(e,t,n=0,a=0,i=0,c=1,u){const f=[];for(const m of e.variantChildren)m.notify("AnimationStart",t),f.push(vg(m,t,{...u,delay:n+(typeof a=="function"?0:a)+oC(e.variantChildren,m,a,i,c)}).then(()=>m.notify("AnimationComplete",t)));return Promise.all(f)}function X8(e,t,n={}){e.notify("AnimationStart",t);let a;if(Array.isArray(t)){const i=t.map(c=>vg(e,c,n));a=Promise.all(i)}else if(typeof t=="string")a=vg(e,t,n);else{const i=typeof t=="function"?bo(e,t,n.custom):t;a=Promise.all(hC(e,i,n))}return a.then(()=>{e.notify("AnimationComplete",t)})}const K8={test:e=>e==="auto",parse:e=>e},mC=e=>t=>t.test(e),pC=[Oo,Ce,ea,tr,E6,k6,K8],H1=e=>pC.find(mC(e));function J8(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||CE(e):!0}const Q8=new Set(["brightness","contrast","saturate","opacity"]);function eU(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[a]=n.match(yv)||[];if(!a)return e;const i=n.replace(a,"");let c=Q8.has(t)?1:0;return a!==n&&(c*=100),t+"("+c+i+")"}const tU=/\b([a-z-]*)\(.*?\)/gu,yg={...Ps,getAnimatableNone:e=>{const t=e.match(tU);return t?t.map(eU).join(" "):e}},xg={...Ps,getAnimatableNone:e=>{const t=Ps.parse(e);return Ps.createTransformer(e)(t.map(a=>typeof a=="number"?0:typeof a=="object"?{...a,alpha:1}:a))}},Z1={...Oo,transform:Math.round},nU={rotate:tr,rotateX:tr,rotateY:tr,rotateZ:tr,scale:Hu,scaleX:Hu,scaleY:Hu,scaleZ:Hu,skew:tr,skewX:tr,skewY:tr,distance:Ce,translateX:Ce,translateY:Ce,translateZ:Ce,x:Ce,y:Ce,z:Ce,perspective:Ce,transformPerspective:Ce,opacity:sc,originX:R1,originY:R1,originZ:Ce},Rv={borderWidth:Ce,borderTopWidth:Ce,borderRightWidth:Ce,borderBottomWidth:Ce,borderLeftWidth:Ce,borderRadius:Ce,borderTopLeftRadius:Ce,borderTopRightRadius:Ce,borderBottomRightRadius:Ce,borderBottomLeftRadius:Ce,width:Ce,maxWidth:Ce,height:Ce,maxHeight:Ce,top:Ce,right:Ce,bottom:Ce,left:Ce,inset:Ce,insetBlock:Ce,insetBlockStart:Ce,insetBlockEnd:Ce,insetInline:Ce,insetInlineStart:Ce,insetInlineEnd:Ce,padding:Ce,paddingTop:Ce,paddingRight:Ce,paddingBottom:Ce,paddingLeft:Ce,paddingBlock:Ce,paddingBlockStart:Ce,paddingBlockEnd:Ce,paddingInline:Ce,paddingInlineStart:Ce,paddingInlineEnd:Ce,margin:Ce,marginTop:Ce,marginRight:Ce,marginBottom:Ce,marginLeft:Ce,marginBlock:Ce,marginBlockStart:Ce,marginBlockEnd:Ce,marginInline:Ce,marginInlineStart:Ce,marginInlineEnd:Ce,fontSize:Ce,backgroundPositionX:Ce,backgroundPositionY:Ce,...nU,zIndex:Z1,fillOpacity:sc,strokeOpacity:sc,numOctaves:Z1},sU={...Rv,color:an,backgroundColor:an,outlineColor:an,fill:an,stroke:an,borderColor:an,borderTopColor:an,borderRightColor:an,borderBottomColor:an,borderLeftColor:an,filter:yg,WebkitFilter:yg,mask:xg,WebkitMask:xg},gC=e=>sU[e],aU=new Set([yg,xg]);function vC(e,t){let n=gC(e);return aU.has(n)||(n=Ps),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const rU=new Set(["auto","none","0"]);function iU(e,t,n){let a=0,i;for(;a<e.length&&!i;){const c=e[a];typeof c=="string"&&!rU.has(c)&&ac(c).values.length&&(i=e[a]),a++}if(i&&n)for(const c of t)e[c]=vC(n,i)}class oU extends kv{constructor(t,n,a,i,c){super(t,n,a,i,c,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:a}=this;if(!n||!n.current)return;super.readKeyframes();for(let g=0;g<t.length;g++){let x=t[g];if(typeof x=="string"&&(x=x.trim(),vv(x))){const b=lC(x,n.current);b!==void 0&&(t[g]=b),g===t.length-1&&(this.finalKeyframe=x)}}if(this.resolveNoneKeyframes(),!uC.has(a)||t.length!==2)return;const[i,c]=t,u=H1(i),f=H1(c),m=A1(i),h=A1(c);if(m!==h&&or[a]){this.needsMeasurement=!0;return}if(u!==f)if($1(u)&&$1(f))for(let g=0;g<t.length;g++){const x=t[g];typeof x=="string"&&(t[g]=parseFloat(x))}else or[a]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,a=[];for(let i=0;i<t.length;i++)(t[i]===null||J8(t[i]))&&a.push(i);a.length&&iU(t,a,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:a}=this;if(!t||!t.current)return;a==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=or[a](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(a,i).jump(i,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:a}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const c=a.length-1,u=a[c];a[c]=or[n](t.measureViewportBox(),window.getComputedStyle(t.current)),u!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=u),this.removedTransforms?.length&&this.removedTransforms.forEach(([f,m])=>{t.getValue(f).set(m)}),this.resolveNoneKeyframes()}}const lU=new Set(["opacity","clipPath","filter","transform"]);function yC(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let a=document;const i=n?.[e]??a.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(a=>a!=null)}const xC=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function bg(e){return EE(e)&&"offsetHeight"in e}const{schedule:Mv}=UE(queueMicrotask,!1),Ls={x:!1,y:!1};function bC(){return Ls.x||Ls.y}function cU(e){return e==="x"||e==="y"?Ls[e]?null:(Ls[e]=!0,()=>{Ls[e]=!1}):Ls.x||Ls.y?null:(Ls.x=Ls.y=!0,()=>{Ls.x=Ls.y=!1})}function wC(e,t){const n=yC(e),a=new AbortController,i={passive:!0,...t,signal:a.signal};return[n,i,()=>a.abort()]}function uU(e){return!(e.pointerType==="touch"||bC())}function dU(e,t,n={}){const[a,i,c]=wC(e,n);return a.forEach(u=>{let f=!1,m=!1,h;const g=()=>{u.removeEventListener("pointerleave",j)},x=T=>{h&&(h(T),h=void 0),g()},b=T=>{f=!1,window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b),m&&(m=!1,x(T))},w=()=>{f=!0,window.addEventListener("pointerup",b,i),window.addEventListener("pointercancel",b,i)},j=T=>{if(T.pointerType!=="touch"){if(f){m=!0;return}x(T)}},N=T=>{if(!uU(T))return;m=!1;const k=t(u,T);typeof k=="function"&&(h=k,u.addEventListener("pointerleave",j,i))};u.addEventListener("pointerenter",N,i),u.addEventListener("pointerdown",w,i)}),c}const SC=(e,t)=>t?e===t?!0:SC(e,t.parentElement):!1,_v=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,fU=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function hU(e){return fU.has(e.tagName)||e.isContentEditable===!0}const mU=new Set(["INPUT","SELECT","TEXTAREA"]);function pU(e){return mU.has(e.tagName)||e.isContentEditable===!0}const fd=new WeakSet;function F1(e){return t=>{t.key==="Enter"&&e(t)}}function op(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const gU=(e,t)=>{const n=e.currentTarget;if(!n)return;const a=F1(()=>{if(fd.has(n))return;op(n,"down");const i=F1(()=>{op(n,"up")}),c=()=>op(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",c,t)});n.addEventListener("keydown",a,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",a),t)};function q1(e){return _v(e)&&!bC()}const Y1=new WeakSet;function vU(e,t,n={}){const[a,i,c]=wC(e,n),u=f=>{const m=f.currentTarget;if(!q1(f)||Y1.has(f))return;fd.add(m),n.stopPropagation&&Y1.add(f);const h=t(m,f),g=(w,j)=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",b),fd.has(m)&&fd.delete(m),q1(w)&&typeof h=="function"&&h(w,{success:j})},x=w=>{g(w,m===window||m===document||n.useGlobalTarget||SC(m,w.target))},b=w=>{g(w,!1)};window.addEventListener("pointerup",x,i),window.addEventListener("pointercancel",b,i)};return a.forEach(f=>{(n.useGlobalTarget?window:f).addEventListener("pointerdown",u,i),bg(f)&&(f.addEventListener("focus",h=>gU(h,i)),!hU(f)&&!f.hasAttribute("tabindex")&&(f.tabIndex=0))}),c}function Ov(e){return EE(e)&&"ownerSVGElement"in e}const hd=new WeakMap;let md;const jC=(e,t,n)=>(a,i)=>i&&i[0]?i[0][e+"Size"]:Ov(a)&&"getBBox"in a?a.getBBox()[t]:a[n],yU=jC("inline","width","offsetWidth"),xU=jC("block","height","offsetHeight");function bU({target:e,borderBoxSize:t}){hd.get(e)?.forEach(n=>{n(e,{get width(){return yU(e,t)},get height(){return xU(e,t)}})})}function wU(e){e.forEach(bU)}function SU(){typeof ResizeObserver>"u"||(md=new ResizeObserver(wU))}function jU(e,t){md||SU();const n=yC(e);return n.forEach(a=>{let i=hd.get(a);i||(i=new Set,hd.set(a,i)),i.add(t),md?.observe(a)}),()=>{n.forEach(a=>{const i=hd.get(a);i?.delete(t),i?.size||md?.unobserve(a)})}}const pd=new Set;let fo;function NU(){fo=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};pd.forEach(t=>t(e))},window.addEventListener("resize",fo)}function kU(e){return pd.add(e),fo||NU(),()=>{pd.delete(e),!pd.size&&typeof fo=="function"&&(window.removeEventListener("resize",fo),fo=void 0)}}function G1(e,t){return typeof e=="function"?kU(e):jU(e,t)}function EU(e){return Ov(e)&&e.tagName==="svg"}const CU=[...pC,an,Ps],TU=e=>CU.find(mC(e)),W1=()=>({translate:0,scale:1,origin:0,originPoint:0}),ho=()=>({x:W1(),y:W1()}),X1=()=>({min:0,max:0}),dn=()=>({x:X1(),y:X1()}),AU=new WeakMap;function gf(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function rc(e){return typeof e=="string"||Array.isArray(e)}const Iv=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Dv=["initial",...Iv];function vf(e){return gf(e.animate)||Dv.some(t=>rc(e[t]))}function NC(e){return!!(vf(e)||e.variants)}function RU(e,t,n){for(const a in t){const i=t[a],c=n[a];if(_n(i))e.addValue(a,i);else if(_n(c))e.addValue(a,Co(i,{owner:e}));else if(c!==i)if(e.hasValue(a)){const u=e.getValue(a);u.liveStyle===!0?u.jump(i):u.hasAnimated||u.set(i)}else{const u=e.getStaticValue(a);e.addValue(a,Co(u!==void 0?u:i,{owner:e}))}}for(const a in n)t[a]===void 0&&e.removeValue(a);return t}const wg={current:null},kC={current:!1},MU=typeof window<"u";function _U(){if(kC.current=!0,!!MU)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>wg.current=e.matches;e.addEventListener("change",t),t()}else wg.current=!1}const K1=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Fd={};function EC(e){Fd=e}function OU(){return Fd}class IU{scrapeMotionValuesFromProps(t,n,a){return{}}constructor({parent:t,props:n,presenceContext:a,reducedMotionConfig:i,skipAnimations:c,blockInitialAnimation:u,visualState:f},m={}){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=kv,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=Ln.now();this.renderScheduledAt<w&&(this.renderScheduledAt=w,Et.render(this.render,!1,!0))};const{latestValues:h,renderState:g}=f;this.latestValues=h,this.baseTarget={...h},this.initialValues=n.initial?{...h}:{},this.renderState=g,this.parent=t,this.props=n,this.presenceContext=a,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=c,this.options=m,this.blockInitialAnimation=!!u,this.isControllingVariants=vf(n),this.isVariantNode=NC(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:x,...b}=this.scrapeMotionValuesFromProps(n,{},this);for(const w in b){const j=b[w];h[w]!==void 0&&_n(j)&&j.set(h[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,AU.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,a)=>this.bindToMotionValue(a,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(kC.current||_U(),this.shouldReduceMotion=wg.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(),mr(this.notifyUpdate),mr(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&&lU.has(t)&&this.current instanceof HTMLElement){const{factory:u,keyframes:f,times:m,ease:h,duration:g}=n.accelerate,x=new rC({element:this.current,name:t,keyframes:f,times:m,ease:h,duration:$s(g)}),b=u(x);this.valueSubscriptions.set(t,()=>{b(),x.cancel()});return}const a=Do.has(t);a&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",u=>{this.latestValues[t]=u,this.props.onUpdate&&Et.preRender(this.notifyUpdate),a&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let c;typeof window<"u"&&window.MotionCheckAppearSync&&(c=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),c&&c(),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 Fd){const n=Fd[t];if(!n)continue;const{isEnabled:a,Feature:i}=n;if(!this.features[t]&&i&&a(this.props)&&(this.features[t]=new i(this)),this.features[t]){const c=this.features[t];c.isMounted?c.update():(c.mount(),c.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):dn()}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 a=0;a<K1.length;a++){const i=K1[a];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const c="on"+i,u=t[c];u&&(this.propEventSubscriptions[i]=this.on(i,u))}this.prevMotionValues=RU(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 a=this.values.get(t);n!==a&&(a&&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 a=this.values.get(t);return a===void 0&&n!==void 0&&(a=Co(n===null?void 0:n,{owner:this}),this.addValue(t,a)),a}readValue(t,n){let a=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return a!=null&&(typeof a=="string"&&(kE(a)||CE(a))?a=parseFloat(a):!TU(a)&&Ps.test(n)&&(a=vC(t,n)),this.setBaseTarget(t,_n(a)?a.get():a)),_n(a)?a.get():a}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let a;if(typeof n=="string"||typeof n=="object"){const c=Tv(this.props,n,this.presenceContext?.custom);c&&(a=c[t])}if(n&&a!==void 0)return a;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!_n(i)?i:this.initialValues[t]!==void 0&&a===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new mv),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Mv.render(this.render)}}class CC extends IU{constructor(){super(...arguments),this.KeyframeResolver=oU}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const a=t.style;return a?a[n]:void 0}removeValueFromRenderState(t,{vars:n,style:a}){delete n[t],delete a[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;_n(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class jr{constructor(t){this.isMounted=!1,this.node=t}update(){}}function TC({top:e,left:t,right:n,bottom:a}){return{x:{min:t,max:n},y:{min:e,max:a}}}function DU({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function zU(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),a=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:a.y,right:a.x}}function lp(e){return e===void 0||e===1}function Sg({scale:e,scaleX:t,scaleY:n}){return!lp(e)||!lp(t)||!lp(n)}function Fr(e){return Sg(e)||AC(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function AC(e){return J1(e.x)||J1(e.y)}function J1(e){return e&&e!=="0%"}function qd(e,t,n){const a=e-n,i=t*a;return n+i}function Q1(e,t,n,a,i){return i!==void 0&&(e=qd(e,i,a)),qd(e,n,a)+t}function jg(e,t=0,n=1,a,i){e.min=Q1(e.min,t,n,a,i),e.max=Q1(e.max,t,n,a,i)}function RC(e,{x:t,y:n}){jg(e.x,t.translate,t.scale,t.originPoint),jg(e.y,n.translate,n.scale,n.originPoint)}const eS=.999999999999,tS=1.0000000000001;function LU(e,t,n,a=!1){const i=n.length;if(!i)return;t.x=t.y=1;let c,u;for(let f=0;f<i;f++){c=n[f],u=c.projectionDelta;const{visualElement:m}=c.options;m&&m.props.style&&m.props.style.display==="contents"||(a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&po(e,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),u&&(t.x*=u.x.scale,t.y*=u.y.scale,RC(e,u)),a&&Fr(c.latestValues)&&po(e,c.latestValues))}t.x<tS&&t.x>eS&&(t.x=1),t.y<tS&&t.y>eS&&(t.y=1)}function mo(e,t){e.min=e.min+t,e.max=e.max+t}function nS(e,t,n,a,i=.5){const c=Vt(e.min,e.max,i);jg(e,t,n,c,a)}function po(e,t){nS(e.x,t.x,t.scaleX,t.scale,t.originX),nS(e.y,t.y,t.scaleY,t.scale,t.originY)}function MC(e,t){return TC(zU(e.getBoundingClientRect(),t))}function $U(e,t,n){const a=MC(e,n),{scroll:i}=t;return i&&(mo(a.x,i.offset.x),mo(a.y,i.offset.y)),a}const PU={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},UU=Io.length;function BU(e,t,n){let a="",i=!0;for(let c=0;c<UU;c++){const u=Io[c],f=e[u];if(f===void 0)continue;let m=!0;if(typeof f=="number")m=f===(u.startsWith("scale")?1:0);else{const h=parseFloat(f);m=u.startsWith("scale")?h===1:h===0}if(!m||n){const h=xC(f,Rv[u]);if(!m){i=!1;const g=PU[u]||u;a+=`${g}(${h}) `}n&&(t[u]=h)}}return a=a.trim(),n?a=n(t,i?"":a):i&&(a="none"),a}function zv(e,t,n){const{style:a,vars:i,transformOrigin:c}=e;let u=!1,f=!1;for(const m in t){const h=t[m];if(Do.has(m)){u=!0;continue}else if(VE(m)){i[m]=h;continue}else{const g=xC(h,Rv[m]);m.startsWith("origin")?(f=!0,c[m]=g):a[m]=g}}if(t.transform||(u||n?a.transform=BU(t,e.transform,n):a.transform&&(a.transform="none")),f){const{originX:m="50%",originY:h="50%",originZ:g=0}=c;a.transformOrigin=`${m} ${h} ${g}`}}function _C(e,{style:t,vars:n},a,i){const c=e.style;let u;for(u in t)c[u]=t[u];i?.applyProjectionStyles(c,a);for(u in n)c.setProperty(u,n[u])}function sS(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Tl={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ce.test(e))e=parseFloat(e);else return e;const n=sS(e,t.target.x),a=sS(e,t.target.y);return`${n}% ${a}%`}},VU={correct:(e,{treeScale:t,projectionDelta:n})=>{const a=e,i=Ps.parse(e);if(i.length>5)return a;const c=Ps.createTransformer(e),u=typeof i[0]!="number"?1:0,f=n.x.scale*t.x,m=n.y.scale*t.y;i[0+u]/=f,i[1+u]/=m;const h=Vt(f,m,.5);return typeof i[2+u]=="number"&&(i[2+u]/=h),typeof i[3+u]=="number"&&(i[3+u]/=h),c(i)}},Ng={borderRadius:{...Tl,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Tl,borderTopRightRadius:Tl,borderBottomLeftRadius:Tl,borderBottomRightRadius:Tl,boxShadow:VU};function OC(e,{layout:t,layoutId:n}){return Do.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Ng[e]||e==="opacity")}function Lv(e,t,n){const a=e.style,i=t?.style,c={};if(!a)return c;for(const u in a)(_n(a[u])||i&&_n(i[u])||OC(u,e)||n?.getValue(u)?.liveStyle!==void 0)&&(c[u]=a[u]);return c}function HU(e){return window.getComputedStyle(e)}class ZU extends CC{constructor(){super(...arguments),this.type="html",this.renderInstance=_C}readValueFromInstance(t,n){if(Do.has(n))return this.projection?.isProjecting?cg(n):c8(t,n);{const a=HU(t),i=(VE(n)?a.getPropertyValue(n):a[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return MC(t,n)}build(t,n,a){zv(t,n,a.transformTemplate)}scrapeMotionValuesFromProps(t,n,a){return Lv(t,n,a)}}const FU={offset:"stroke-dashoffset",array:"stroke-dasharray"},qU={offset:"strokeDashoffset",array:"strokeDasharray"};function YU(e,t,n=1,a=0,i=!0){e.pathLength=1;const c=i?FU:qU;e[c.offset]=`${-a}`,e[c.array]=`${t} ${n}`}const GU=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function IC(e,{attrX:t,attrY:n,attrScale:a,pathLength:i,pathSpacing:c=1,pathOffset:u=0,...f},m,h,g){if(zv(e,f,h),m){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:x,style:b}=e;x.transform&&(b.transform=x.transform,delete x.transform),(b.transform||x.transformOrigin)&&(b.transformOrigin=x.transformOrigin??"50% 50%",delete x.transformOrigin),b.transform&&(b.transformBox=g?.transformBox??"fill-box",delete x.transformBox);for(const w of GU)x[w]!==void 0&&(b[w]=x[w],delete x[w]);t!==void 0&&(x.x=t),n!==void 0&&(x.y=n),a!==void 0&&(x.scale=a),i!==void 0&&YU(x,i,c,u,!1)}const DC=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"]),zC=e=>typeof e=="string"&&e.toLowerCase()==="svg";function WU(e,t,n,a){_C(e,t,void 0,a);for(const i in t.attrs)e.setAttribute(DC.has(i)?i:Av(i),t.attrs[i])}function LC(e,t,n){const a=Lv(e,t,n);for(const i in e)if(_n(e[i])||_n(t[i])){const c=Io.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;a[c]=e[i]}return a}class XU extends CC{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=dn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Do.has(n)){const a=gC(n);return a&&a.default||0}return n=DC.has(n)?n:Av(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,a){return LC(t,n,a)}build(t,n,a){IC(t,n,this.isSVGTag,a.transformTemplate,a.style)}renderInstance(t,n,a,i){WU(t,n,a,i)}mount(t){this.isSVGTag=zC(t.tagName),super.mount(t)}}const KU=Dv.length;function $C(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?$C(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<KU;n++){const a=Dv[n],i=e.props[a];(rc(i)||i===!1)&&(t[a]=i)}return t}function PC(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let a=0;a<n;a++)if(t[a]!==e[a])return!1;return!0}const JU=[...Iv].reverse(),QU=Iv.length;function eB(e){return t=>Promise.all(t.map(({animation:n,options:a})=>X8(e,n,a)))}function tB(e){let t=eB(e),n=aS(),a=!0;const i=m=>(h,g)=>{const x=bo(e,g,m==="exit"?e.presenceContext?.custom:void 0);if(x){const{transition:b,transitionEnd:w,...j}=x;h={...h,...j,...w}}return h};function c(m){t=m(e)}function u(m){const{props:h}=e,g=$C(e.parent)||{},x=[],b=new Set;let w={},j=1/0;for(let T=0;T<QU;T++){const k=JU[T],C=n[k],S=h[k]!==void 0?h[k]:g[k],R=rc(S),A=k===m?C.isActive:null;A===!1&&(j=T);let M=S===g[k]&&S!==h[k]&&R;if(M&&a&&e.manuallyAnimateOnMount&&(M=!1),C.protectedKeys={...w},!C.isActive&&A===null||!S&&!C.prevProp||gf(S)||typeof S=="boolean")continue;if(k==="exit"&&C.isActive&&A!==!0){C.prevResolvedValues&&(w={...w,...C.prevResolvedValues});continue}const O=nB(C.prevProp,S);let V=O||k===m&&C.isActive&&!M&&R||T>j&&R,F=!1;const I=Array.isArray(S)?S:[S];let $=I.reduce(i(k),{});A===!1&&($={});const{prevResolvedValues:L={}}=C,U={...L,...$},Y=P=>{V=!0,b.has(P)&&(F=!0,b.delete(P)),C.needsAnimating[P]=!0;const B=e.getValue(P);B&&(B.liveStyle=!1)};for(const P in U){const B=$[P],G=L[P];if(w.hasOwnProperty(P))continue;let X=!1;pg(B)&&pg(G)?X=!PC(B,G):X=B!==G,X?B!=null?Y(P):b.add(P):B!==void 0&&b.has(P)?Y(P):C.protectedKeys[P]=!0}C.prevProp=S,C.prevResolvedValues=$,C.isActive&&(w={...w,...$}),a&&e.blockInitialAnimation&&(V=!1);const K=M&&O;V&&(!K||F)&&x.push(...I.map(P=>{const B={type:k};if(typeof P=="string"&&a&&!K&&e.manuallyAnimateOnMount&&e.parent){const{parent:G}=e,X=bo(G,P);if(G.enteringChildren&&X){const{delayChildren:z}=X.transition||{};B.delay=oC(G.enteringChildren,e,z)}}return{animation:P,options:B}}))}if(b.size){const T={};if(typeof h.initial!="boolean"){const k=bo(e,Array.isArray(h.initial)?h.initial[0]:h.initial);k&&k.transition&&(T.transition=k.transition)}b.forEach(k=>{const C=e.getBaseTarget(k),S=e.getValue(k);S&&(S.liveStyle=!0),T[k]=C??null}),x.push({animation:T})}let N=!!x.length;return a&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(N=!1),a=!1,N?t(x):Promise.resolve()}function f(m,h){if(n[m].isActive===h)return Promise.resolve();e.variantChildren?.forEach(x=>x.animationState?.setActive(m,h)),n[m].isActive=h;const g=u(m);for(const x in n)n[x].protectedKeys={};return g}return{animateChanges:u,setActive:f,setAnimateFunction:c,getState:()=>n,reset:()=>{n=aS()}}}function nB(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!PC(t,e):!1}function Hr(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function aS(){return{animate:Hr(!0),whileInView:Hr(),whileHover:Hr(),whileTap:Hr(),whileDrag:Hr(),whileFocus:Hr(),exit:Hr()}}function rS(e,t){e.min=t.min,e.max=t.max}function zs(e,t){rS(e.x,t.x),rS(e.y,t.y)}function iS(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const UC=1e-4,sB=1-UC,aB=1+UC,BC=.01,rB=0-BC,iB=0+BC;function $n(e){return e.max-e.min}function oB(e,t,n){return Math.abs(e-t)<=n}function oS(e,t,n,a=.5){e.origin=a,e.originPoint=Vt(t.min,t.max,e.origin),e.scale=$n(n)/$n(t),e.translate=Vt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=sB&&e.scale<=aB||isNaN(e.scale))&&(e.scale=1),(e.translate>=rB&&e.translate<=iB||isNaN(e.translate))&&(e.translate=0)}function ql(e,t,n,a){oS(e.x,t.x,n.x,a?a.originX:void 0),oS(e.y,t.y,n.y,a?a.originY:void 0)}function lS(e,t,n){e.min=n.min+t.min,e.max=e.min+$n(t)}function lB(e,t,n){lS(e.x,t.x,n.x),lS(e.y,t.y,n.y)}function cS(e,t,n){e.min=t.min-n.min,e.max=e.min+$n(t)}function Yd(e,t,n){cS(e.x,t.x,n.x),cS(e.y,t.y,n.y)}function uS(e,t,n,a,i){return e-=t,e=qd(e,1/n,a),i!==void 0&&(e=qd(e,1/i,a)),e}function cB(e,t=0,n=1,a=.5,i,c=e,u=e){if(ea.test(t)&&(t=parseFloat(t),t=Vt(u.min,u.max,t/100)-u.min),typeof t!="number")return;let f=Vt(c.min,c.max,a);e===c&&(f-=t),e.min=uS(e.min,t,n,f,i),e.max=uS(e.max,t,n,f,i)}function dS(e,t,[n,a,i],c,u){cB(e,t[n],t[a],t[i],t.scale,c,u)}const uB=["x","scaleX","originX"],dB=["y","scaleY","originY"];function fS(e,t,n,a){dS(e.x,t,uB,n?n.x:void 0,a?a.x:void 0),dS(e.y,t,dB,n?n.y:void 0,a?a.y:void 0)}function hS(e){return e.translate===0&&e.scale===1}function VC(e){return hS(e.x)&&hS(e.y)}function mS(e,t){return e.min===t.min&&e.max===t.max}function fB(e,t){return mS(e.x,t.x)&&mS(e.y,t.y)}function pS(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function HC(e,t){return pS(e.x,t.x)&&pS(e.y,t.y)}function gS(e){return $n(e.x)/$n(e.y)}function vS(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Ys(e){return[e("x"),e("y")]}function hB(e,t,n){let a="";const i=e.x.translate/t.x,c=e.y.translate/t.y,u=n?.z||0;if((i||c||u)&&(a=`translate3d(${i}px, ${c}px, ${u}px) `),(t.x!==1||t.y!==1)&&(a+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:h,rotate:g,rotateX:x,rotateY:b,skewX:w,skewY:j}=n;h&&(a=`perspective(${h}px) ${a}`),g&&(a+=`rotate(${g}deg) `),x&&(a+=`rotateX(${x}deg) `),b&&(a+=`rotateY(${b}deg) `),w&&(a+=`skewX(${w}deg) `),j&&(a+=`skewY(${j}deg) `)}const f=e.x.scale*t.x,m=e.y.scale*t.y;return(f!==1||m!==1)&&(a+=`scale(${f}, ${m})`),a||"none"}const ZC=["TopLeft","TopRight","BottomLeft","BottomRight"],mB=ZC.length,yS=e=>typeof e=="string"?parseFloat(e):e,xS=e=>typeof e=="number"||Ce.test(e);function pB(e,t,n,a,i,c){i?(e.opacity=Vt(0,n.opacity??1,gB(a)),e.opacityExit=Vt(t.opacity??1,0,vB(a))):c&&(e.opacity=Vt(t.opacity??1,n.opacity??1,a));for(let u=0;u<mB;u++){const f=`border${ZC[u]}Radius`;let m=bS(t,f),h=bS(n,f);if(m===void 0&&h===void 0)continue;m||(m=0),h||(h=0),m===0||h===0||xS(m)===xS(h)?(e[f]=Math.max(Vt(yS(m),yS(h),a),0),(ea.test(h)||ea.test(m))&&(e[f]+="%")):e[f]=h}(t.rotate||n.rotate)&&(e.rotate=Vt(t.rotate||0,n.rotate||0,a))}function bS(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const gB=FC(0,.5,zE),vB=FC(.5,.95,ks);function FC(e,t,n){return a=>a<e?0:a>t?1:n(nc(e,t,a))}function yB(e,t,n){const a=_n(e)?e:Co(e);return a.start(Cv("",a,t,n)),a.animation}function ic(e,t,n,a={passive:!0}){return e.addEventListener(t,n,a),()=>e.removeEventListener(t,n)}const xB=(e,t)=>e.depth-t.depth;class bB{constructor(){this.children=[],this.isDirty=!1}add(t){fv(this.children,t),this.isDirty=!0}remove(t){Bd(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(xB),this.isDirty=!1,this.children.forEach(t)}}function wB(e,t){const n=Ln.now(),a=({timestamp:i})=>{const c=i-n;c>=t&&(mr(a),e(c-t))};return Et.setup(a,!0),()=>mr(a)}function gd(e){return _n(e)?e.get():e}class SB{constructor(){this.members=[]}add(t){fv(this.members,t);for(let n=this.members.length-1;n>=0;n--){const a=this.members[n];if(a===t||a===this.lead||a===this.prevLead)continue;const i=a.instance;i&&i.isConnected===!1&&a.isPresent!==!1&&!a.snapshot&&Bd(this.members,a)}t.scheduleRender()}remove(t){if(Bd(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 a;for(let i=n;i>=0;i--){const c=this.members[i],u=c.instance;if(c.isPresent!==!1&&(!u||u.isConnected!==!1)){a=c;break}}return a?(this.promote(a),!0):!1}promote(t,n){const a=this.lead;if(t!==a&&(this.prevLead=a,this.lead=t,t.show(),a)){a.instance&&a.scheduleRender(),t.scheduleRender();const i=a.options.layoutDependency,c=t.options.layoutDependency;if(!(i!==void 0&&c!==void 0&&i===c)){const m=a.instance;m&&m.isConnected===!1&&!a.snapshot||(t.resumeFrom=a,n&&(t.resumeFrom.preserveOpacity=!0),a.snapshot&&(t.snapshot=a.snapshot,t.snapshot.latestValues=a.animationValues||a.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0))}const{crossfade:f}=t.options;f===!1&&a.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:a}=t;n.onExitComplete&&n.onExitComplete(),a&&a.options.onExitComplete&&a.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const vd={hasAnimatedSinceResize:!0,hasEverUpdated:!1},cp=["","X","Y","Z"],jB=1e3;let NB=0;function up(e,t,n,a){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),a&&(a[e]=0))}function qC(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=fC(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:c}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Et,!(i||c))}const{parent:a}=e;a&&!a.hasCheckedOptimisedAppear&&qC(a)}function YC({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:a,resetTransform:i}){return class{constructor(u={},f=t?.()){this.id=NB++,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(CB),this.nodes.forEach(MB),this.nodes.forEach(_B),this.nodes.forEach(TB)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=u,this.root=f?f.root||f:this,this.path=f?[...f.path,f]:[],this.parent=f,this.depth=f?f.depth+1:0;for(let m=0;m<this.path.length;m++)this.path[m].shouldResetTransform=!0;this.root===this&&(this.nodes=new bB)}addEventListener(u,f){return this.eventHandlers.has(u)||this.eventHandlers.set(u,new mv),this.eventHandlers.get(u).add(f)}notifyListeners(u,...f){const m=this.eventHandlers.get(u);m&&m.notify(...f)}hasListeners(u){return this.eventHandlers.has(u)}mount(u){if(this.instance)return;this.isSVG=Ov(u)&&!EU(u),this.instance=u;const{layoutId:f,layout:m,visualElement:h}=this.options;if(h&&!h.current&&h.mount(u),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(m||f)&&(this.isLayoutDirty=!0),e){let g,x=0;const b=()=>this.root.updateBlockedByResize=!1;Et.read(()=>{x=window.innerWidth}),e(u,()=>{const w=window.innerWidth;w!==x&&(x=w,this.root.updateBlockedByResize=!0,g&&g(),g=wB(b,250),vd.hasAnimatedSinceResize&&(vd.hasAnimatedSinceResize=!1,this.nodes.forEach(jS)))})}f&&this.root.registerSharedNode(f,this),this.options.animate!==!1&&h&&(f||m)&&this.addEventListener("didUpdate",({delta:g,hasLayoutChanged:x,hasRelativeLayoutChanged:b,layout:w})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const j=this.options.transition||h.getDefaultTransition()||LB,{onLayoutAnimationStart:N,onLayoutAnimationComplete:T}=h.getProps(),k=!this.targetLayout||!HC(this.targetLayout,w),C=!x&&b;if(this.options.layoutRoot||this.resumeFrom||C||x&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Ev(j,"layout"),onPlay:N,onComplete:T};(h.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(g,C)}else x||jS(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=w})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const u=this.getStack();u&&u.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),mr(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(OB),this.animationId++)}getTransformTemplate(){const{visualElement:u}=this.options;return u&&u.getProps().transformTemplate}willUpdate(u=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&qC(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let g=0;g<this.path.length;g++){const x=this.path[g];x.shouldResetTransform=!0,x.updateScroll("snapshot"),x.options.layoutRoot&&x.willUpdate(!1)}const{layoutId:f,layout:m}=this.options;if(f===void 0&&!m)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),u&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(wS);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(SS);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(RB),this.nodes.forEach(kB),this.nodes.forEach(EB)):this.nodes.forEach(SS),this.clearAllSnapshots();const f=Ln.now();En.delta=sa(0,1e3/60,f-En.timestamp),En.timestamp=f,En.isProcessing=!0,tp.update.process(En),tp.preRender.process(En),tp.render.process(En),En.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Mv.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(AB),this.sharedNodes.forEach(IB)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Et.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Et.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!$n(this.snapshot.measuredBox.x)&&!$n(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 m=0;m<this.path.length;m++)this.path[m].updateScroll();const u=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=dn(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:f}=this.options;f&&f.notify("LayoutMeasure",this.layout.layoutBox,u?u.layoutBox:void 0)}updateScroll(u="measure"){let f=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===u&&(f=!1),f&&this.instance){const m=a(this.instance);this.scroll={animationId:this.root.animationId,phase:u,isRoot:m,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:m}}}resetTransform(){if(!i)return;const u=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,f=this.projectionDelta&&!VC(this.projectionDelta),m=this.getTransformTemplate(),h=m?m(this.latestValues,""):void 0,g=h!==this.prevTransformTemplateValue;u&&this.instance&&(f||Fr(this.latestValues)||g)&&(i(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(u=!0){const f=this.measurePageBox();let m=this.removeElementScroll(f);return u&&(m=this.removeTransform(m)),$B(m),{animationId:this.root.animationId,measuredBox:f,layoutBox:m,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:u}=this.options;if(!u)return dn();const f=u.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(PB))){const{scroll:h}=this.root;h&&(mo(f.x,h.offset.x),mo(f.y,h.offset.y))}return f}removeElementScroll(u){const f=dn();if(zs(f,u),this.scroll?.wasRoot)return f;for(let m=0;m<this.path.length;m++){const h=this.path[m],{scroll:g,options:x}=h;h!==this.root&&g&&x.layoutScroll&&(g.wasRoot&&zs(f,u),mo(f.x,g.offset.x),mo(f.y,g.offset.y))}return f}applyTransform(u,f=!1){const m=dn();zs(m,u);for(let h=0;h<this.path.length;h++){const g=this.path[h];!f&&g.options.layoutScroll&&g.scroll&&g!==g.root&&po(m,{x:-g.scroll.offset.x,y:-g.scroll.offset.y}),Fr(g.latestValues)&&po(m,g.latestValues)}return Fr(this.latestValues)&&po(m,this.latestValues),m}removeTransform(u){const f=dn();zs(f,u);for(let m=0;m<this.path.length;m++){const h=this.path[m];if(!h.instance||!Fr(h.latestValues))continue;Sg(h.latestValues)&&h.updateSnapshot();const g=dn(),x=h.measurePageBox();zs(g,x),fS(f,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,g)}return Fr(this.latestValues)&&fS(f,this.latestValues),f}setTargetDelta(u){this.targetDelta=u,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(u){this.options={...this.options,...u,crossfade:u.crossfade!==void 0?u.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!==En.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(u=!1){const f=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=f.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=f.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=f.isSharedProjectionDirty);const m=!!this.resumingFrom||this!==f;if(!(u||m&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:g,layoutId:x}=this.options;if(!this.layout||!(g||x))return;this.resolvedRelativeTargetAt=En.timestamp;const b=this.getClosestProjectingParent();b&&this.linkedParentVersion!==b.layoutVersion&&!b.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(b&&b.layout?this.createRelativeTarget(b,this.layout.layoutBox,b.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=dn(),this.targetWithTransforms=dn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),lB(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):zs(this.target,this.layout.layoutBox),RC(this.target,this.targetDelta)):zs(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,b&&!!b.resumingFrom==!!this.resumingFrom&&!b.options.layoutScroll&&b.target&&this.animationProgress!==1?this.createRelativeTarget(b,this.target,b.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Sg(this.parent.latestValues)||AC(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(u,f,m){this.relativeParent=u,this.linkedParentVersion=u.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=dn(),this.relativeTargetOrigin=dn(),Yd(this.relativeTargetOrigin,f,m),zs(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const u=this.getLead(),f=!!this.resumingFrom||this!==u;let m=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(m=!1),f&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(m=!1),this.resolvedRelativeTargetAt===En.timestamp&&(m=!1),m)return;const{layout:h,layoutId:g}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(h||g))return;zs(this.layoutCorrected,this.layout.layoutBox);const x=this.treeScale.x,b=this.treeScale.y;LU(this.layoutCorrected,this.treeScale,this.path,f),u.layout&&!u.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(u.target=u.layout.layoutBox,u.targetWithTransforms=dn());const{target:w}=u;if(!w){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(iS(this.prevProjectionDelta.x,this.projectionDelta.x),iS(this.prevProjectionDelta.y,this.projectionDelta.y)),ql(this.projectionDelta,this.layoutCorrected,w,this.latestValues),(this.treeScale.x!==x||this.treeScale.y!==b||!vS(this.projectionDelta.x,this.prevProjectionDelta.x)||!vS(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",w))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(u=!0){if(this.options.visualElement?.scheduleRender(),u){const f=this.getStack();f&&f.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ho(),this.projectionDelta=ho(),this.projectionDeltaWithTransform=ho()}setAnimationOrigin(u,f=!1){const m=this.snapshot,h=m?m.latestValues:{},g={...this.latestValues},x=ho();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!f;const b=dn(),w=m?m.source:void 0,j=this.layout?this.layout.source:void 0,N=w!==j,T=this.getStack(),k=!T||T.members.length<=1,C=!!(N&&!k&&this.options.crossfade===!0&&!this.path.some(zB));this.animationProgress=0;let S;this.mixTargetDelta=R=>{const A=R/1e3;NS(x.x,u.x,A),NS(x.y,u.y,A),this.setTargetDelta(x),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Yd(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox),DB(this.relativeTarget,this.relativeTargetOrigin,b,A),S&&fB(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=dn()),zs(S,this.relativeTarget)),N&&(this.animationValues=g,pB(g,h,this.latestValues,A,C,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(u){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(mr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Et.update(()=>{vd.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Co(0)),this.motionValue.jump(0,!1),this.currentAnimation=yB(this.motionValue,[0,1e3],{...u,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),u.onUpdate&&u.onUpdate(f)},onStop:()=>{},onComplete:()=>{u.onComplete&&u.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 u=this.getStack();u&&u.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(jB),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const u=this.getLead();let{targetWithTransforms:f,target:m,layout:h,latestValues:g}=u;if(!(!f||!m||!h)){if(this!==u&&this.layout&&h&&GC(this.options.animationType,this.layout.layoutBox,h.layoutBox)){m=this.target||dn();const x=$n(this.layout.layoutBox.x);m.x.min=u.target.x.min,m.x.max=m.x.min+x;const b=$n(this.layout.layoutBox.y);m.y.min=u.target.y.min,m.y.max=m.y.min+b}zs(f,m),po(f,g),ql(this.projectionDeltaWithTransform,this.layoutCorrected,f,g)}}registerSharedNode(u,f){this.sharedNodes.has(u)||this.sharedNodes.set(u,new SB),this.sharedNodes.get(u).add(f);const h=f.options.initialPromotionConfig;f.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(f):void 0})}isLead(){const u=this.getStack();return u?u.lead===this:!0}getLead(){const{layoutId:u}=this.options;return u?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:u}=this.options;return u?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:u}=this.options;if(u)return this.root.sharedNodes.get(u)}promote({needsReset:u,transition:f,preserveFollowOpacity:m}={}){const h=this.getStack();h&&h.promote(this,m),u&&(this.projectionDelta=void 0,this.needsReset=!0),f&&this.setOptions({transition:f})}relegate(){const u=this.getStack();return u?u.relegate(this):!1}resetSkewAndRotation(){const{visualElement:u}=this.options;if(!u)return;let f=!1;const{latestValues:m}=u;if((m.z||m.rotate||m.rotateX||m.rotateY||m.rotateZ||m.skewX||m.skewY)&&(f=!0),!f)return;const h={};m.z&&up("z",u,h,this.animationValues);for(let g=0;g<cp.length;g++)up(`rotate${cp[g]}`,u,h,this.animationValues),up(`skew${cp[g]}`,u,h,this.animationValues);u.render();for(const g in h)u.setStaticValue(g,h[g]),this.animationValues&&(this.animationValues[g]=h[g]);u.scheduleRender()}applyProjectionStyles(u,f){if(!this.instance||this.isSVG)return;if(!this.isVisible){u.visibility="hidden";return}const m=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,u.visibility="",u.opacity="",u.pointerEvents=gd(f?.pointerEvents)||"",u.transform=m?m(this.latestValues,""):"none";return}const h=this.getLead();if(!this.projectionDelta||!this.layout||!h.target){this.options.layoutId&&(u.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,u.pointerEvents=gd(f?.pointerEvents)||""),this.hasProjected&&!Fr(this.latestValues)&&(u.transform=m?m({},""):"none",this.hasProjected=!1);return}u.visibility="";const g=h.animationValues||h.latestValues;this.applyTransformsToTarget();let x=hB(this.projectionDeltaWithTransform,this.treeScale,g);m&&(x=m(g,x)),u.transform=x;const{x:b,y:w}=this.projectionDelta;u.transformOrigin=`${b.origin*100}% ${w.origin*100}% 0`,h.animationValues?u.opacity=h===this?g.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:g.opacityExit:u.opacity=h===this?g.opacity!==void 0?g.opacity:"":g.opacityExit!==void 0?g.opacityExit:0;for(const j in Ng){if(g[j]===void 0)continue;const{correct:N,applyTo:T,isCSSVariable:k}=Ng[j],C=x==="none"?g[j]:N(g[j],h);if(T){const S=T.length;for(let R=0;R<S;R++)u[T[R]]=C}else k?this.options.visualElement.renderState.vars[j]=C:u[j]=C}this.options.layoutId&&(u.pointerEvents=h===this?gd(f?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(u=>u.currentAnimation?.stop()),this.root.nodes.forEach(wS),this.root.sharedNodes.clear()}}}function kB(e){e.updateLayout()}function EB(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:a}=e.layout,{animationType:i}=e.options,c=t.source!==e.layout.source;i==="size"?Ys(g=>{const x=c?t.measuredBox[g]:t.layoutBox[g],b=$n(x);x.min=n[g].min,x.max=x.min+b}):GC(i,t.layoutBox,n)&&Ys(g=>{const x=c?t.measuredBox[g]:t.layoutBox[g],b=$n(n[g]);x.max=x.min+b,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[g].max=e.relativeTarget[g].min+b)});const u=ho();ql(u,n,t.layoutBox);const f=ho();c?ql(f,e.applyTransform(a,!0),t.measuredBox):ql(f,n,t.layoutBox);const m=!VC(u);let h=!1;if(!e.resumeFrom){const g=e.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:x,layout:b}=g;if(x&&b){const w=dn();Yd(w,t.layoutBox,x.layoutBox);const j=dn();Yd(j,n,b.layoutBox),HC(w,j)||(h=!0),g.options.layoutRoot&&(e.relativeTarget=j,e.relativeTargetOrigin=w,e.relativeParent=g)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:f,layoutDelta:u,hasLayoutChanged:m,hasRelativeLayoutChanged:h})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function CB(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 TB(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function AB(e){e.clearSnapshot()}function wS(e){e.clearMeasurements()}function SS(e){e.isLayoutDirty=!1}function RB(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function jS(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function MB(e){e.resolveTargetDelta()}function _B(e){e.calcProjection()}function OB(e){e.resetSkewAndRotation()}function IB(e){e.removeLeadSnapshot()}function NS(e,t,n){e.translate=Vt(t.translate,0,n),e.scale=Vt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function kS(e,t,n,a){e.min=Vt(t.min,n.min,a),e.max=Vt(t.max,n.max,a)}function DB(e,t,n,a){kS(e.x,t.x,n.x,a),kS(e.y,t.y,n.y,a)}function zB(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const LB={duration:.45,ease:[.4,0,.1,1]},ES=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),CS=ES("applewebkit/")&&!ES("chrome/")?Math.round:ks;function TS(e){e.min=CS(e.min),e.max=CS(e.max)}function $B(e){TS(e.x),TS(e.y)}function GC(e,t,n){return e==="position"||e==="preserve-aspect"&&!oB(gS(t),gS(n),.2)}function PB(e){return e!==e.root&&e.scroll?.wasRoot}const UB=YC({attachResizeListener:(e,t)=>ic(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),dp={current:void 0},WC=YC({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!dp.current){const e=new UB({});e.mount(window),e.setOptions({layoutScroll:!0}),dp.current=e}return dp.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),$v=v.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function AS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function BB(...e){return t=>{let n=!1;const a=e.map(i=>{const c=AS(i,t);return!n&&typeof c=="function"&&(n=!0),c});if(n)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():AS(e[i],null)}}}}function VB(...e){return v.useCallback(BB(...e),e)}class HB extends v.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const a=n.offsetParent,i=bg(a)&&a.offsetWidth||0,c=bg(a)&&a.offsetHeight||0,u=this.props.sizeRef.current;u.height=n.offsetHeight||0,u.width=n.offsetWidth||0,u.top=n.offsetTop,u.left=n.offsetLeft,u.right=i-u.width-u.left,u.bottom=c-u.height-u.top}return null}componentDidUpdate(){}render(){return this.props.children}}function ZB({children:e,isPresent:t,anchorX:n,anchorY:a,root:i,pop:c}){const u=v.useId(),f=v.useRef(null),m=v.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:h}=v.useContext($v),g=e.props?.ref??e?.ref,x=VB(f,g);return v.useInsertionEffect(()=>{const{width:b,height:w,top:j,left:N,right:T,bottom:k}=m.current;if(t||c===!1||!f.current||!b||!w)return;const C=n==="left"?`left: ${N}`:`right: ${T}`,S=a==="bottom"?`bottom: ${k}`:`top: ${j}`;f.current.dataset.motionPopId=u;const R=document.createElement("style");h&&(R.nonce=h);const A=i??document.head;return A.appendChild(R),R.sheet&&R.sheet.insertRule(`
|
|
122
|
-
[data-motion-pop-id="${u}"] {
|
|
123
|
-
position: absolute !important;
|
|
124
|
-
width: ${b}px !important;
|
|
125
|
-
height: ${w}px !important;
|
|
126
|
-
${C}px !important;
|
|
127
|
-
${S}px !important;
|
|
128
|
-
}
|
|
129
|
-
`),()=>{A.contains(R)&&A.removeChild(R)}},[t]),o.jsx(HB,{isPresent:t,childRef:f,sizeRef:m,pop:c,children:c===!1?e:v.cloneElement(e,{ref:x})})}const FB=({children:e,initial:t,isPresent:n,onExitComplete:a,custom:i,presenceAffectsLayout:c,mode:u,anchorX:f,anchorY:m,root:h})=>{const g=dv(qB),x=v.useId();let b=!0,w=v.useMemo(()=>(b=!1,{id:x,initial:t,isPresent:n,custom:i,onExitComplete:j=>{g.set(j,!0);for(const N of g.values())if(!N)return;a&&a()},register:j=>(g.set(j,!1),()=>g.delete(j))}),[n,g,a]);return c&&b&&(w={...w}),v.useMemo(()=>{g.forEach((j,N)=>g.set(N,!1))},[n]),v.useEffect(()=>{!n&&!g.size&&a&&a()},[n]),e=o.jsx(ZB,{pop:u==="popLayout",isPresent:n,anchorX:f,anchorY:m,root:h,children:e}),o.jsx(pf.Provider,{value:w,children:e})};function qB(){return new Map}function XC(e=!0){const t=v.useContext(pf);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:a,register:i}=t,c=v.useId();v.useEffect(()=>{if(e)return i(c)},[e]);const u=v.useCallback(()=>e&&a&&a(c),[c,a,e]);return!n&&a?[!1,u]:[!0]}const Zu=e=>e.key||"";function RS(e){const t=[];return v.Children.forEach(e,n=>{v.isValidElement(n)&&t.push(n)}),t}const YB=({children:e,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:i=!0,mode:c="sync",propagate:u=!1,anchorX:f="left",anchorY:m="top",root:h})=>{const[g,x]=XC(u),b=v.useMemo(()=>RS(e),[e]),w=u&&!g?[]:b.map(Zu),j=v.useRef(!0),N=v.useRef(b),T=dv(()=>new Map),k=v.useRef(new Set),[C,S]=v.useState(b),[R,A]=v.useState(b);NE(()=>{j.current=!1,N.current=b;for(let V=0;V<R.length;V++){const F=Zu(R[V]);w.includes(F)?(T.delete(F),k.current.delete(F)):T.get(F)!==!0&&T.set(F,!1)}},[R,w.length,w.join("-")]);const M=[];if(b!==C){let V=[...b];for(let F=0;F<R.length;F++){const I=R[F],$=Zu(I);w.includes($)||(V.splice(F,0,I),M.push(I))}return c==="wait"&&M.length&&(V=M),A(RS(V)),S(b),null}const{forceRender:O}=v.useContext(uv);return o.jsx(o.Fragment,{children:R.map(V=>{const F=Zu(V),I=u&&!g?!1:b===R||w.includes(F),$=()=>{if(k.current.has(F))return;if(k.current.add(F),T.has(F))T.set(F,!0);else return;let L=!0;T.forEach(U=>{U||(L=!1)}),L&&(O?.(),A(N.current),u&&x?.(),a&&a())};return o.jsx(FB,{isPresent:I,initial:!j.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:c,root:h,onExitComplete:I?void 0:$,anchorX:f,anchorY:m,children:V},F)})})},KC=v.createContext({strict:!1}),MS={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 _S=!1;function GB(){if(_S)return;const e={};for(const t in MS)e[t]={isEnabled:n=>MS[t].some(a=>!!n[a])};EC(e),_S=!0}function JC(){return GB(),OU()}function WB(e){const t=JC();for(const n in e)t[n]={...t[n],...e[n]};EC(t)}const XB=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 Gd(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||XB.has(e)}let QC=e=>!Gd(e);function KB(e){typeof e=="function"&&(QC=t=>t.startsWith("on")?!Gd(t):e(t))}try{KB(require("@emotion/is-prop-valid").default)}catch{}function JB(e,t,n){const a={};for(const i in e)i==="values"&&typeof e.values=="object"||(QC(i)||n===!0&&Gd(i)||!t&&!Gd(i)||e.draggable&&i.startsWith("onDrag"))&&(a[i]=e[i]);return a}const yf=v.createContext({});function QB(e,t){if(vf(e)){const{initial:n,animate:a}=e;return{initial:n===!1||rc(n)?n:void 0,animate:rc(a)?a:void 0}}return e.inherit!==!1?t:{}}function e9(e){const{initial:t,animate:n}=QB(e,v.useContext(yf));return v.useMemo(()=>({initial:t,animate:n}),[OS(t),OS(n)])}function OS(e){return Array.isArray(e)?e.join(" "):e}const Pv=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function eT(e,t,n){for(const a in t)!_n(t[a])&&!OC(a,n)&&(e[a]=t[a])}function t9({transformTemplate:e},t){return v.useMemo(()=>{const n=Pv();return zv(n,t,e),Object.assign({},n.vars,n.style)},[t])}function n9(e,t){const n=e.style||{},a={};return eT(a,n,e),Object.assign(a,t9(e,t)),a}function s9(e,t){const n={},a=n9(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.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=a,n}const tT=()=>({...Pv(),attrs:{}});function a9(e,t,n,a){const i=v.useMemo(()=>{const c=tT();return IC(c,t,zC(a),e.transformTemplate,e.style),{...c.attrs,style:{...c.style}}},[t]);if(e.style){const c={};eT(c,e.style,e),i.style={...c,...i.style}}return i}const r9=["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 Uv(e){return typeof e!="string"||e.includes("-")?!1:!!(r9.indexOf(e)>-1||/[A-Z]/u.test(e))}function i9(e,t,n,{latestValues:a},i,c=!1,u){const m=(u??Uv(e)?a9:s9)(t,a,i,e),h=JB(t,typeof e=="string",c),g=e!==v.Fragment?{...h,...m,ref:n}:{},{children:x}=t,b=v.useMemo(()=>_n(x)?x.get():x,[x]);return v.createElement(e,{...g,children:b})}function o9({scrapeMotionValuesFromProps:e,createRenderState:t},n,a,i){return{latestValues:l9(n,a,i,e),renderState:t()}}function l9(e,t,n,a){const i={},c=a(e,{});for(const b in c)i[b]=gd(c[b]);let{initial:u,animate:f}=e;const m=vf(e),h=NC(e);t&&h&&!m&&e.inherit!==!1&&(u===void 0&&(u=t.initial),f===void 0&&(f=t.animate));let g=n?n.initial===!1:!1;g=g||u===!1;const x=g?f:u;if(x&&typeof x!="boolean"&&!gf(x)){const b=Array.isArray(x)?x:[x];for(let w=0;w<b.length;w++){const j=Tv(e,b[w]);if(j){const{transitionEnd:N,transition:T,...k}=j;for(const C in k){let S=k[C];if(Array.isArray(S)){const R=g?S.length-1:0;S=S[R]}S!==null&&(i[C]=S)}for(const C in N)i[C]=N[C]}}}return i}const nT=e=>(t,n)=>{const a=v.useContext(yf),i=v.useContext(pf),c=()=>o9(e,t,a,i);return n?c():dv(c)},c9=nT({scrapeMotionValuesFromProps:Lv,createRenderState:Pv}),u9=nT({scrapeMotionValuesFromProps:LC,createRenderState:tT}),d9=Symbol.for("motionComponentSymbol");function f9(e,t,n){const a=v.useRef(n);v.useInsertionEffect(()=>{a.current=n});const i=v.useRef(null);return v.useCallback(c=>{c&&e.onMount?.(c),t&&(c?t.mount(c):t.unmount());const u=a.current;if(typeof u=="function")if(c){const f=u(c);typeof f=="function"&&(i.current=f)}else i.current?(i.current(),i.current=null):u(c);else u&&(u.current=c)},[t])}const sT=v.createContext({});function so(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function h9(e,t,n,a,i,c){const{visualElement:u}=v.useContext(yf),f=v.useContext(KC),m=v.useContext(pf),h=v.useContext($v),g=h.reducedMotion,x=h.skipAnimations,b=v.useRef(null),w=v.useRef(!1);a=a||f.renderer,!b.current&&a&&(b.current=a(e,{visualState:t,parent:u,props:n,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:g,skipAnimations:x,isSVG:c}),w.current&&b.current&&(b.current.manuallyAnimateOnMount=!0));const j=b.current,N=v.useContext(sT);j&&!j.projection&&i&&(j.type==="html"||j.type==="svg")&&m9(b.current,n,i,N);const T=v.useRef(!1);v.useInsertionEffect(()=>{j&&T.current&&j.update(n,m)});const k=n[dC],C=v.useRef(!!k&&!window.MotionHandoffIsComplete?.(k)&&window.MotionHasOptimisedAnimation?.(k));return NE(()=>{w.current=!0,j&&(T.current=!0,window.MotionIsMounted=!0,j.updateFeatures(),j.scheduleRenderMicrotask(),C.current&&j.animationState&&j.animationState.animateChanges())}),v.useEffect(()=>{j&&(!C.current&&j.animationState&&j.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(k)}),C.current=!1),j.enteringChildren=void 0)}),j}function m9(e,t,n,a){const{layoutId:i,layout:c,drag:u,dragConstraints:f,layoutScroll:m,layoutRoot:h,layoutCrossfade:g}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:aT(e.parent)),e.projection.setOptions({layoutId:i,layout:c,alwaysMeasureLayout:!!u||f&&so(f),visualElement:e,animationType:typeof c=="string"?c:"both",initialPromotionConfig:a,crossfade:g,layoutScroll:m,layoutRoot:h})}function aT(e){if(e)return e.options.allowProjection!==!1?e.projection:aT(e.parent)}function fp(e,{forwardMotionProps:t=!1,type:n}={},a,i){a&&WB(a);const c=n?n==="svg":Uv(e),u=c?u9:c9;function f(h,g){let x;const b={...v.useContext($v),...h,layoutId:p9(h)},{isStatic:w}=b,j=e9(h),N=u(h,w);if(!w&&jE){g9();const T=v9(b);x=T.MeasureLayout,j.visualElement=h9(e,N,b,i,T.ProjectionNode,c)}return o.jsxs(yf.Provider,{value:j,children:[x&&j.visualElement?o.jsx(x,{visualElement:j.visualElement,...b}):null,i9(e,h,f9(N,j.visualElement,g),N,w,t,c)]})}f.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const m=v.forwardRef(f);return m[d9]=e,m}function p9({layoutId:e}){const t=v.useContext(uv).id;return t&&e!==void 0?t+"-"+e:e}function g9(e,t){v.useContext(KC).strict}function v9(e){const t=JC(),{drag:n,layout:a}=t;if(!n&&!a)return{};const i={...n,...a};return{MeasureLayout:n?.isEnabled(e)||a?.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function y9(e,t){if(typeof Proxy>"u")return fp;const n=new Map,a=(c,u)=>fp(c,u,e,t),i=(c,u)=>a(c,u);return new Proxy(i,{get:(c,u)=>u==="create"?a:(n.has(u)||n.set(u,fp(u,void 0,e,t)),n.get(u))})}const x9=(e,t)=>t.isSVG??Uv(e)?new XU(t):new ZU(t,{allowProjection:e!==v.Fragment});class b9 extends jr{constructor(t){super(t),t.animationState||(t.animationState=tB(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();gf(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 w9=0;class S9 extends jr{constructor(){super(...arguments),this.id=w9++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:a}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===a)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 j9={animation:{Feature:b9},exit:{Feature:S9}};function gc(e){return{point:{x:e.pageX,y:e.pageY}}}const N9=e=>t=>_v(t)&&e(t,gc(t));function Yl(e,t,n,a){return ic(e,t,N9(n),a)}const rT=({current:e})=>e?e.ownerDocument.defaultView:null,IS=(e,t)=>Math.abs(e-t);function k9(e,t){const n=IS(e.x,t.x),a=IS(e.y,t.y);return Math.sqrt(n**2+a**2)}const DS=new Set(["auto","scroll"]);class iT{constructor(t,n,{transformPagePoint:a,contextWindow:i=window,dragSnapToOrigin:c=!1,distanceThreshold:u=3,element:f}={}){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=mp(this.lastMoveEventInfo,this.history),j=this.startEvent!==null,N=k9(w.offset,{x:0,y:0})>=this.distanceThreshold;if(!j&&!N)return;const{point:T}=w,{timestamp:k}=En;this.history.push({...T,timestamp:k});const{onStart:C,onMove:S}=this.handlers;j||(C&&C(this.lastMoveEvent,w),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,w)},this.handlePointerMove=(w,j)=>{this.lastMoveEvent=w,this.lastMoveEventInfo=hp(j,this.transformPagePoint),Et.update(this.updatePoint,!0)},this.handlePointerUp=(w,j)=>{this.end();const{onEnd:N,onSessionEnd:T,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=mp(w.type==="pointercancel"?this.lastMoveEventInfo:hp(j,this.transformPagePoint),this.history);this.startEvent&&N&&N(w,C),T&&T(w,C)},!_v(t))return;this.dragSnapToOrigin=c,this.handlers=n,this.transformPagePoint=a,this.distanceThreshold=u,this.contextWindow=i||window;const m=gc(t),h=hp(m,this.transformPagePoint),{point:g}=h,{timestamp:x}=En;this.history=[{...g,timestamp:x}];const{onSessionStart:b}=n;b&&b(t,mp(h,this.history)),this.removeListeners=hc(Yl(this.contextWindow,"pointermove",this.handlePointerMove),Yl(this.contextWindow,"pointerup",this.handlePointerUp),Yl(this.contextWindow,"pointercancel",this.handlePointerUp)),f&&this.startScrollTracking(f)}startScrollTracking(t){let n=t.parentElement;for(;n;){const a=getComputedStyle(n);(DS.has(a.overflowX)||DS.has(a.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 a=t===window,i=a?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},c={x:i.x-n.x,y:i.y-n.y};c.x===0&&c.y===0||(a?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=c.x,this.lastMoveEventInfo.point.y+=c.y):this.history.length>0&&(this.history[0].x-=c.x,this.history[0].y-=c.y),this.scrollPositions.set(t,i),Et.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),mr(this.updatePoint)}}function hp(e,t){return t?{point:t(e.point)}:e}function zS(e,t){return{x:e.x-t.x,y:e.y-t.y}}function mp({point:e},t){return{point:e,delta:zS(e,oT(t)),offset:zS(e,E9(t)),velocity:C9(t,.1)}}function E9(e){return e[0]}function oT(e){return e[e.length-1]}function C9(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,a=null;const i=oT(e);for(;n>=0&&(a=e[n],!(i.timestamp-a.timestamp>$s(t)));)n--;if(!a)return{x:0,y:0};a===e[0]&&e.length>2&&i.timestamp-a.timestamp>$s(t)*2&&(a=e[1]);const c=Ns(i.timestamp-a.timestamp);if(c===0)return{x:0,y:0};const u={x:(i.x-a.x)/c,y:(i.y-a.y)/c};return u.x===1/0&&(u.x=0),u.y===1/0&&(u.y=0),u}function T9(e,{min:t,max:n},a){return t!==void 0&&e<t?e=a?Vt(t,e,a.min):Math.max(e,t):n!==void 0&&e>n&&(e=a?Vt(n,e,a.max):Math.min(e,n)),e}function LS(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 A9(e,{top:t,left:n,bottom:a,right:i}){return{x:LS(e.x,n,i),y:LS(e.y,t,a)}}function $S(e,t){let n=t.min-e.min,a=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,a]=[a,n]),{min:n,max:a}}function R9(e,t){return{x:$S(e.x,t.x),y:$S(e.y,t.y)}}function M9(e,t){let n=.5;const a=$n(e),i=$n(t);return i>a?n=nc(t.min,t.max-a,e.min):a>i&&(n=nc(e.min,e.max-i,t.min)),sa(0,1,n)}function _9(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 kg=.35;function O9(e=kg){return e===!1?e=0:e===!0&&(e=kg),{x:PS(e,"left","right"),y:PS(e,"top","bottom")}}function PS(e,t,n){return{min:US(e,t),max:US(e,n)}}function US(e,t){return typeof e=="number"?e:e[t]||0}const I9=new WeakMap;class D9{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=dn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:a}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const c=x=>{n&&this.snapToCursor(gc(x).point),this.stopAnimation()},u=(x,b)=>{const{drag:w,dragPropagation:j,onDragStart:N}=this.getProps();if(w&&!j&&(this.openDragLock&&this.openDragLock(),this.openDragLock=cU(w),!this.openDragLock))return;this.latestPointerEvent=x,this.latestPanInfo=b,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ys(k=>{let C=this.getAxisMotionValue(k).get()||0;if(ea.test(C)){const{projection:S}=this.visualElement;if(S&&S.layout){const R=S.layout.layoutBox[k];R&&(C=$n(R)*(parseFloat(C)/100))}}this.originPoint[k]=C}),N&&Et.update(()=>N(x,b),!1,!0),gg(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},f=(x,b)=>{this.latestPointerEvent=x,this.latestPanInfo=b;const{dragPropagation:w,dragDirectionLock:j,onDirectionLock:N,onDrag:T}=this.getProps();if(!w&&!this.openDragLock)return;const{offset:k}=b;if(j&&this.currentDirection===null){this.currentDirection=L9(k),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",b.point,k),this.updateAxis("y",b.point,k),this.visualElement.render(),T&&Et.update(()=>T(x,b),!1,!0)},m=(x,b)=>{this.latestPointerEvent=x,this.latestPanInfo=b,this.stop(x,b),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:g}=this.getProps();this.panSession=new iT(t,{onSessionStart:c,onStart:u,onMove:f,onSessionEnd:m,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,distanceThreshold:a,contextWindow:rT(this.visualElement),element:this.visualElement.current})}stop(t,n){const a=t||this.latestPointerEvent,i=n||this.latestPanInfo,c=this.isDragging;if(this.cancel(),!c||!i||!a)return;const{velocity:u}=i;this.startAnimation(u);const{onDragEnd:f}=this.getProps();f&&Et.postRender(()=>f(a,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:a}=this.getProps();!a&&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,a){const{drag:i}=this.getProps();if(!a||!Fu(t,i,this.currentDirection))return;const c=this.getAxisMotionValue(t);let u=this.originPoint[t]+a[t];this.constraints&&this.constraints[t]&&(u=T9(u,this.constraints[t],this.elastic[t])),c.set(u)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;t&&so(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&a?this.constraints=A9(a.layoutBox,t):this.constraints=!1,this.elastic=O9(n),i!==this.constraints&&!so(t)&&a&&this.constraints&&!this.hasMutatedConstraints&&Ys(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=_9(a.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!so(t))return!1;const a=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const c=$U(a,i.root,this.visualElement.getTransformPagePoint());let u=R9(i.layout.layoutBox,c);if(n){const f=n(DU(u));this.hasMutatedConstraints=!!f,f&&(u=TC(f))}return u}startAnimation(t){const{drag:n,dragMomentum:a,dragElastic:i,dragTransition:c,dragSnapToOrigin:u,onDragTransitionEnd:f}=this.getProps(),m=this.constraints||{},h=Ys(g=>{if(!Fu(g,n,this.currentDirection))return;let x=m&&m[g]||{};u&&(x={min:0,max:0});const b=i?200:1e6,w=i?40:1e7,j={type:"inertia",velocity:a?t[g]:0,bounceStiffness:b,bounceDamping:w,timeConstant:750,restDelta:1,restSpeed:10,...c,...x};return this.startAxisValueAnimation(g,j)});return Promise.all(h).then(f)}startAxisValueAnimation(t,n){const a=this.getAxisMotionValue(t);return gg(this.visualElement,t),a.start(Cv(t,a,0,n,this.visualElement,!1))}stopAnimation(){Ys(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,a=this.visualElement.getProps(),i=a[n];return i||this.visualElement.getValue(t,(a.initial?a.initial[t]:void 0)||0)}snapToCursor(t){Ys(n=>{const{drag:a}=this.getProps();if(!Fu(n,a,this.currentDirection))return;const{projection:i}=this.visualElement,c=this.getAxisMotionValue(n);if(i&&i.layout){const{min:u,max:f}=i.layout.layoutBox[n],m=c.get()||0;c.set(t[n]-Vt(u,f,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:a}=this.visualElement;if(!so(n)||!a||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Ys(u=>{const f=this.getAxisMotionValue(u);if(f&&this.constraints!==!1){const m=f.get();i[u]=M9({min:m,max:m},this.constraints[u])}});const{transformTemplate:c}=this.visualElement.getProps();this.visualElement.current.style.transform=c?c({},""):"none",a.root&&a.root.updateScroll(),a.updateLayout(),this.constraints=!1,this.resolveConstraints(),Ys(u=>{if(!Fu(u,t,null))return;const f=this.getAxisMotionValue(u),{min:m,max:h}=this.constraints[u];f.set(Vt(m,h,i[u]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;I9.set(this.visualElement,this);const t=this.visualElement.current,n=Yl(t,"pointerdown",h=>{const{drag:g,dragListener:x=!0}=this.getProps(),b=h.target,w=b!==t&&pU(b);g&&x&&!w&&this.start(h)});let a;const i=()=>{const{dragConstraints:h}=this.getProps();so(h)&&h.current&&(this.constraints=this.resolveRefConstraints(),a||(a=z9(t,h.current,()=>this.scalePositionWithinConstraints())))},{projection:c}=this.visualElement,u=c.addEventListener("measure",i);c&&!c.layout&&(c.root&&c.root.updateScroll(),c.updateLayout()),Et.read(i);const f=ic(window,"resize",()=>this.scalePositionWithinConstraints()),m=c.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:g})=>{this.isDragging&&g&&(Ys(x=>{const b=this.getAxisMotionValue(x);b&&(this.originPoint[x]+=h[x].translate,b.set(b.get()+h[x].translate))}),this.visualElement.render())}));return()=>{f(),n(),u(),m&&m(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:a=!1,dragPropagation:i=!1,dragConstraints:c=!1,dragElastic:u=kg,dragMomentum:f=!0}=t;return{...t,drag:n,dragDirectionLock:a,dragPropagation:i,dragConstraints:c,dragElastic:u,dragMomentum:f}}}function BS(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function z9(e,t,n){const a=G1(e,BS(n)),i=G1(t,BS(n));return()=>{a(),i()}}function Fu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function L9(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class $9 extends jr{constructor(t){super(t),this.removeGroupControls=ks,this.removeListeners=ks,this.controls=new D9(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ks}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 pp=e=>(t,n)=>{e&&Et.update(()=>e(t,n),!1,!0)};class P9 extends jr{constructor(){super(...arguments),this.removePointerDownListener=ks}onPointerDown(t){this.session=new iT(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:rT(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:a,onPanEnd:i}=this.node.getProps();return{onSessionStart:pp(t),onStart:pp(n),onMove:pp(a),onEnd:(c,u)=>{delete this.session,i&&Et.postRender(()=>i(c,u))}}}mount(){this.removePointerDownListener=Yl(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 gp=!1;class U9 extends v.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:a,layoutId:i}=this.props,{projection:c}=t;c&&(n.group&&n.group.add(c),a&&a.register&&i&&a.register(c),gp&&c.root.didUpdate(),c.addEventListener("animationComplete",()=>{this.safeToRemove()}),c.setOptions({...c.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),vd.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:a,drag:i,isPresent:c}=this.props,{projection:u}=a;return u&&(u.isPresent=c,t.layoutDependency!==n&&u.setOptions({...u.options,layoutDependency:n}),gp=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==c?u.willUpdate():this.safeToRemove(),t.isPresent!==c&&(c?u.promote():u.relegate()||Et.postRender(()=>{const f=u.getStack();(!f||!f.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Mv.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:a}=this.props,{projection:i}=t;gp=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),a&&a.deregister&&a.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function lT(e){const[t,n]=XC(),a=v.useContext(uv);return o.jsx(U9,{...e,layoutGroup:a,switchLayoutGroup:v.useContext(sT),isPresent:t,safeToRemove:n})}const B9={pan:{Feature:P9},drag:{Feature:$9,ProjectionNode:WC,MeasureLayout:lT}};function VS(e,t,n){const{props:a}=e;e.animationState&&a.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,c=a[i];c&&Et.postRender(()=>c(t,gc(t)))}class V9 extends jr{mount(){const{current:t}=this.node;t&&(this.unmount=dU(t,(n,a)=>(VS(this.node,a,"Start"),i=>VS(this.node,i,"End"))))}unmount(){}}class H9 extends jr{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=hc(ic(this.node.current,"focus",()=>this.onFocus()),ic(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function HS(e,t,n){const{props:a}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&a.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),c=a[i];c&&Et.postRender(()=>c(t,gc(t)))}class Z9 extends jr{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:a}=this.node.props;this.unmount=vU(t,(i,c)=>(HS(this.node,c,"Start"),(u,{success:f})=>HS(this.node,u,f?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:a?.tap===!1})}unmount(){}}const Eg=new WeakMap,vp=new WeakMap,F9=e=>{const t=Eg.get(e.target);t&&t(e)},q9=e=>{e.forEach(F9)};function Y9({root:e,...t}){const n=e||document;vp.has(n)||vp.set(n,{});const a=vp.get(n),i=JSON.stringify(t);return a[i]||(a[i]=new IntersectionObserver(q9,{root:e,...t})),a[i]}function G9(e,t,n){const a=Y9(t);return Eg.set(e,n),a.observe(e),()=>{Eg.delete(e),a.unobserve(e)}}const W9={some:0,all:1};class X9 extends jr{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:a,amount:i="some",once:c}=t,u={root:n?n.current:void 0,rootMargin:a,threshold:typeof i=="number"?i:W9[i]},f=m=>{const{isIntersecting:h}=m;if(this.isInView===h||(this.isInView=h,c&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:g,onViewportLeave:x}=this.node.getProps(),b=h?g:x;b&&b(m)};return G9(this.node.current,u,f)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(K9(t,n))&&this.startObserver()}unmount(){}}function K9({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const J9={inView:{Feature:X9},tap:{Feature:Z9},focus:{Feature:H9},hover:{Feature:V9}},Q9={layout:{ProjectionNode:WC,MeasureLayout:lT}},eV={...j9,...J9,...B9,...Q9},tV=y9(eV,x9);function nV(e){return"type"in e&&e.type==="separator"}function sV(e){return"type"in e&&e.type==="group"}function ZS({item:e}){return o.jsxs(M3,{disabled:e.disabled,onClick:e.action,className:"flex items-center gap-3 px-3 py-1.5 text-[12px] font-mono text-neutral-300 outline-none select-none data-[highlighted]:bg-neutral-700/50 data-[highlighted]:text-white data-[disabled]:opacity-40 data-[disabled]:pointer-events-none cursor-default",children:[e.icon&&o.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-neutral-400",children:e.icon}),o.jsx("span",{className:"flex-1",children:e.label}),e.shortcut&&o.jsx("span",{className:"text-neutral-400 text-[10px] ml-4 tracking-wider",children:e.shortcut})]})}const cT=io.forwardRef(({items:e},t)=>o.jsx(tV.div,{ref:t,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.1,ease:"easeOut"},children:o.jsx(CP,{className:"bg-neutral-900/95 backdrop-blur-xl border border-neutral-700/60 rounded-lg shadow-2xl py-1 min-w-[180px] z-[200] outline-none",children:e.map((n,a)=>nV(n)?o.jsx(a6,{className:"h-px bg-neutral-700/50 my-1"},`sep-${a}`):sV(n)?o.jsxs(A3,{children:[o.jsx(R3,{className:"px-3 py-1 text-[10px] font-mono uppercase tracking-widest text-neutral-400",children:n.label}),n.items.map(i=>o.jsx(ZS,{item:i},i.id))]},`grp-${a}`):o.jsx(ZS,{item:n},n.id))})}));cT.displayName="PopupContent";function aV({items:e,children:t}){return e.length===0?o.jsx(o.Fragment,{children:t}):o.jsxs(r6,{children:[o.jsx(i6,{render:o.jsx("div",{style:{display:"contents"}}),children:t}),o.jsx(AP,{children:o.jsx(VP,{className:"z-[200]",sideOffset:4,children:o.jsx(YB,{children:o.jsx(cT,{items:e})})})})]})}const FS=()=>{},rV={x:0,y:0},iV=({children:e,hud:t,mode:n="canvas",panOffset:a=rV,scale:i=1,onPan:c=FS,onZoom:u=FS,onPanStart:f,onPanEnd:m,isTransitioning:h=!1,onViewportChange:g,onCanvasClick:x,canvasProps:b,zoomSensitivity:w,zoomControlsRightOffset:j,canvasContextMenuItems:N})=>{const T=v.useRef(null),k=v.useRef(i);k.current=i;const C=v.useRef(u);C.current=u;const S=v.useRef(c);S.current=c;const R=v.useRef(f);R.current=f;const A=v.useRef(m);A.current=m;const M=v.useRef(w);M.current=w;const[O,V]=v.useState(!1),F=v.useRef(!1),[I,$]=v.useState(!1),L=v.useRef(!1),U=v.useRef({x:0,y:0}),Y=v.useRef(D=>{const P=D.target||document.activeElement;if(!P)return!1;const B=P.tagName;return!!(B==="INPUT"||B==="TEXTAREA"||P.isContentEditable||P.closest?.(".xterm"))});v.useEffect(()=>{if(n!=="canvas")return;const D=G=>{G.key!==" "||G.repeat||Y.current(G)||h||(G.preventDefault(),F.current=!0,V(!0))},P=G=>{G.key===" "&&F.current&&(F.current=!1,V(!1),L.current&&(L.current=!1,$(!1),A.current?.()))},B=()=>{F.current&&(F.current=!1,V(!1),L.current&&(L.current=!1,$(!1),A.current?.()))};return window.addEventListener("keydown",D),window.addEventListener("keyup",P),window.addEventListener("blur",B),()=>{window.removeEventListener("keydown",D),window.removeEventListener("keyup",P),window.removeEventListener("blur",B)}},[n,h]);const K=v.useCallback(D=>{D.button===0&&(D.preventDefault(),L.current=!0,$(!0),U.current={x:D.clientX,y:D.clientY},R.current?.())},[]);return v.useEffect(()=>{if(!O)return;const D=B=>{if(!L.current)return;const G=(B.clientX-U.current.x)/k.current,X=(B.clientY-U.current.y)/k.current;U.current={x:B.clientX,y:B.clientY},S.current({x:G,y:X})},P=()=>{L.current&&(L.current=!1,$(!1),A.current?.())};return window.addEventListener("mousemove",D),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",P)}},[O]),v.useEffect(()=>{if(n!=="canvas")return;const D=P=>{if(P.ctrlKey||P.metaKey){P.preventDefault();const B=k.current,G=-P.deltaY*.001*(M.current??1),X=Math.min(Math.max(.2,B+G),3);k.current=X,C.current(X)}};return window.addEventListener("wheel",D,{passive:!1}),()=>window.removeEventListener("wheel",D)},[n]),v.useEffect(()=>{if(!g)return;let D=null;const P=()=>{D&&cancelAnimationFrame(D),D=requestAnimationFrame(()=>{g({width:window.innerWidth,height:window.innerHeight})})};return P(),window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P),D&&cancelAnimationFrame(D)}},[g]),n==="panel"?o.jsxs("div",{ref:T,className:"fixed inset-0 bg-black text-neutral-200 overflow-hidden font-sans select-none z-0",children:[o.jsx("div",{className:"absolute inset-0 z-10 overflow-auto frame-scrollbar",children:e}),o.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]}):o.jsxs("div",{ref:T,className:"fixed inset-0 bg-black text-neutral-200 overflow-hidden font-sans select-none z-0",children:[o.jsx(aV,{items:N??[],children:o.jsx(x4,{panOffset:a,scale:i,onPan:c,onPanStart:f,onPanEnd:m,isPanLocked:h,onClick:x,showGuides:b?.showGuides,onGuidesChange:b?.onGuidesChange,gridOpacity:b?.gridOpacity})}),o.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:"50%",top:"50%",zoom:i},children:o.jsx("div",{style:{position:"absolute",left:a.x,top:a.y},children:e})}),O&&o.jsx("div",{className:`fixed inset-0 z-20 ${I?"cursor-grabbing":"cursor-grab"}`,onMouseDown:K}),o.jsx("div",{className:"fixed bottom-[36px] z-30",style:{right:(j??280)+16},children:o.jsx(b4,{scale:i,onZoom:D=>u(D)})}),o.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]})},Wi=4e3,oV=io.forwardRef(({pan:e,zoom:t,viewportSize:n,height:a,onClick:i,children:c},u)=>{const[f,m]=io.useState(0),h=v.useRef(null),g=io.useCallback(C=>{h.current=C,typeof u=="function"?u(C):u&&(u.current=C)},[u]);io.useEffect(()=>{const C=h.current;if(!C)return;const S=new ResizeObserver(([R])=>m(R.contentRect.width));return S.observe(C),()=>S.disconnect()},[]);const x=f||260,b=n.width/t/Wi*x,w=n.height/t/Wi*a,j=(-e.x+Wi/2)/Wi*x,N=(-e.y+Wi/2)/Wi*a,T=j-b/2,k=N-w/2;return o.jsxs("div",{ref:g,className:"relative cursor-crosshair overflow-hidden",style:{height:`${a}px`},onClick:i,children:[o.jsx("div",{className:"absolute inset-0 opacity-30",style:{backgroundImage:"radial-gradient(circle, #555 0.5px, transparent 0.5px)",backgroundSize:"14px 14px"}}),o.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-neutral-600/40"}),o.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 w-px bg-neutral-600/40"}),o.jsxs("div",{className:"absolute border border-emerald-500/50 bg-emerald-500/5 rounded-[1px] transition-all duration-75 ease-out",style:{left:`${T}px`,top:`${k}px`,width:`${Math.max(b,4)}px`,height:`${Math.max(w,4)}px`},children:[o.jsx("div",{className:"absolute -top-[1px] -left-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),o.jsx("div",{className:"absolute -top-[1px] -right-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),o.jsx("div",{className:"absolute -bottom-[1px] -left-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),o.jsx("div",{className:"absolute -bottom-[1px] -right-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"})]}),c]})});oV.displayName="MinimapCanvas";const lV=({title:e,subtitle:t,center:n,actions:a,onTitleClick:i,search:c})=>{const{dragRegionProps:u,onInteractiveMouseDown:f}=nf(),{navTotalHeight:m}=Yg(),h=c&&c.value&&c.value.length>0;return o.jsx("div",{"data-frame-panel":"navigation",className:"fixed top-0 left-0 right-0 z-50 pointer-events-auto",...u,children:o.jsxs("div",{className:"bg-neutral-950/95 backdrop-blur-xl border-b border-neutral-700/80 shadow-[0_4px_30px_rgba(0,0,0,0.5)] flex items-end px-4",style:{height:m},children:[o.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/8 to-transparent"}),o.jsxs("div",{className:"absolute left-4 bottom-0 h-12 z-10 flex items-center gap-3 select-none",onMouseDown:f,children:[t&&o.jsx("span",{className:"text-neutral-400 flex items-center",children:t}),o.jsx("button",{onClick:i,className:"text-[22px] font-bold text-white tracking-[0.25em] font-mono leading-none bg-transparent border-none cursor-pointer",children:e})]}),n&&o.jsx("div",{className:"flex-1 flex justify-center h-12 items-center",onMouseDown:f,children:n}),o.jsxs("div",{className:"absolute right-4 bottom-0 h-12 z-10 flex items-center gap-3",onMouseDown:f,children:[a,c&&o.jsxs("div",{className:"relative w-[220px] bg-white/[0.06] border border-neutral-600/50 rounded px-2.5 hover:border-neutral-500/60 focus-within:border-neutral-400/50 focus-within:bg-white/[0.08] transition-all duration-200",children:[o.jsx(qg,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-400"}),o.jsx("input",{type:"text",value:c.value,onChange:g=>c.onChange(g.target.value),placeholder:c.placeholder??"Search...",className:`
|
|
130
|
-
w-full h-7 pl-5 pr-6 bg-transparent text-[12px] font-mono tracking-wider
|
|
131
|
-
placeholder:text-neutral-400 text-neutral-200
|
|
132
|
-
focus:outline-none transition-all duration-200
|
|
133
|
-
${h?"text-emerald-400":""}
|
|
134
|
-
`}),h&&o.jsx("button",{onClick:()=>c.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-neutral-400 hover:text-white transition-colors",children:o.jsx(uk,{size:12})})]})]})]})})},qS=({side:e,title:t,icon:n,isCollapsed:a=!1,onToggleCollapse:i,headerActions:c,footer:u,style:f,width:m,onResizeStart:h,children:g})=>{if(a){const k=e==="left"?Lz:Bz;return o.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-neutral-950/95 border border-neutral-700/80 hover:border-emerald-500/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`,title:`Expand ${t||"panel"}`,children:o.jsx(k,{size:14,className:"text-neutral-400 group-hover:text-emerald-400 transition-colors",strokeWidth:1.5})})}const x=e==="left"?Dz:Pz,{panelTopOffset:b}=Yg(),N=`bg-neutral-950/95 backdrop-blur-xl border border-neutral-700/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"}`,T={...f,position:"fixed",top:b,left:e==="left"?0:void 0,right:e==="right"?0:void 0,width:`${m||280}px`};return o.jsxs("div",{"data-frame-panel":e==="left"?"manifest":"inspector",className:`${N} pointer-events-none select-none font-mono text-[11px] flex flex-col`,style:T,children:[h&&o.jsxs("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-[7px] cursor-ew-resize z-50 pointer-events-auto group flex items-center justify-center`,onMouseDown:h,children:[o.jsx("div",{className:`absolute top-0 bottom-0 ${e==="left"?"right-0":"left-0"} w-px bg-neutral-700/80 group-hover:bg-emerald-500/50 transition-colors`}),o.jsxs("div",{className:"flex flex-col gap-[3px] opacity-0 group-hover:opacity-100 transition-opacity",children:[o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"}),o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"}),o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"})]})]}),!h&&o.jsx("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-px bg-neutral-700/80`}),o.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/12 to-transparent z-10"}),o.jsxs("div",{className:"pointer-events-auto flex-1 flex flex-col overflow-hidden",children:[t&&o.jsx("div",{className:"shrink-0 p-4 border-b border-neutral-700/50",children:o.jsxs("div",{className:"flex items-center justify-between text-neutral-200 text-[12px]",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&o.jsx("span",{className:"text-neutral-400",children:n}),o.jsx("span",{className:"tracking-widest font-bold uppercase",children:t})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[c,i&&o.jsx("button",{onClick:i,className:"p-1 hover:bg-white/10 rounded transition-colors text-neutral-400 hover:text-white",title:"Collapse panel",children:o.jsx(x,{size:12})})]})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto frame-scrollbar",children:g}),u&&o.jsx("div",{className:"shrink-0",children:u})]})]})},cV={emerald:{dot:"bg-emerald-500",ping:"bg-emerald-400",text:"text-emerald-500"},amber:{dot:"bg-amber-500",ping:"bg-amber-400",text:"text-amber-500"},red:{dot:"bg-red-500",ping:"bg-red-400",text:"text-red-500"},neutral:{dot:"bg-neutral-500",ping:"bg-neutral-400",text:"text-neutral-400"}},uV=({left:e,viewport:t,right:n,isMinimapCollapsed:a=!1,onExpandMinimap:i,status:c={label:"READY",color:"emerald"},onToggleTerminal:u,isTerminalOpen:f=!1})=>{const[m,h]=v.useState(new Date),[g,x]=v.useState(!1),[b,w]=v.useState(!1);v.useEffect(()=>{w(!0);const T=setInterval(()=>h(new Date),1e3);return()=>clearInterval(T)},[]);const j=cV[c.color],N=async()=>{if(!t)return;const T=`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(T),x(!0),setTimeout(()=>x(!1),1500)}catch{}};return o.jsxs("div",{"data-frame-panel":"status-bar",className:`${y4.statusBar} h-7 flex items-center justify-between px-3 select-none font-mono text-[12px] text-neutral-200 pointer-events-auto`,children:[o.jsxs("div",{className:"flex items-center gap-4",children:[a&&i&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-2 py-0.5 rounded bg-white/5 border border-neutral-800 hover:bg-white/10 transition-colors text-neutral-400 hover:text-white",title:"Expand minimap",children:[o.jsx(Ez,{size:10}),o.jsx("span",{className:"text-[11px] font-bold",children:"MAP"}),o.jsx(lk,{size:8,className:"opacity-60"})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"})]}),o.jsxs("div",{className:`flex items-center gap-2 ${j.text}`,children:[o.jsxs("div",{className:"relative flex h-2 w-2",children:[o.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${j.ping} opacity-75`}),o.jsx("span",{className:`relative inline-flex rounded-full h-2 w-2 ${j.dot}`})]}),o.jsx("span",{className:"font-bold tracking-wider",children:c.label})]}),e&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),e]})]}),t&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 flex items-center gap-3 opacity-70 hover:opacity-100 transition-opacity",children:o.jsxs("button",{onClick:N,className:"flex items-center gap-3 hover:text-neutral-200 transition-colors cursor-pointer",title:"Copy viewport data",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-neutral-400",children:"PAN:"}),o.jsxs("span",{className:`tabular-nums ${g?"text-emerald-500":""}`,children:[t.pan.x.toFixed(0),",",t.pan.y.toFixed(0)]})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-neutral-400",children:"SIZE:"}),o.jsxs("span",{className:`tabular-nums ${g?"text-emerald-500":""}`,children:[t.canvasSize?.w??1024,"x",t.canvasSize?.h??1024]})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-neutral-400",children:"ZOOM:"}),o.jsxs("span",{className:`tabular-nums ${g?"text-emerald-500":""}`,children:[(t.zoom*100).toFixed(0),"%"]})]})]})}),o.jsxs("div",{className:"flex items-center gap-4",children:[n,n&&o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),u&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:u,className:`flex items-center gap-1.5 px-2 py-1 rounded transition-all ${f?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/30":"text-neutral-400 hover:text-neutral-100 hover:bg-white/5 border border-transparent"}`,title:"Toggle Terminal (Ctrl+`)",children:[o.jsxs("span",{className:"text-[12px]",children:[">","_"]}),o.jsx("span",{className:"uppercase text-[11px] font-semibold tracking-wider",children:"Console"})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-200 min-w-[60px] justify-end",children:[o.jsx(wz,{size:11,className:"text-neutral-400"}),o.jsx("span",{children:b?m.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"})]})]})]})},dV=({onOpenCommandPalette:e,extraControls:t})=>o.jsx("div",{className:"select-none font-mono text-[12px] border-t border-neutral-700/50",children:o.jsxs("div",{className:"px-3 py-2 flex items-center justify-between",children:[o.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-neutral-400 hover:text-white transition-colors",children:[o.jsx(qg,{size:10}),o.jsx("span",{className:"tracking-widest font-bold uppercase",children:"Command Palette"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[t,o.jsx("kbd",{className:"text-[11px] text-neutral-400 font-mono",children:"⌘K"})]})]})}),{statusBarHeight:qu}=sf.layout,YS=120,fV=({isOpen:e,onClose:t,onToggleMaximize:n,isMaximized:a=!1,height:i=320,onHeightChange:c,title:u,headerActions:f,children:m})=>{const h=v.useRef(!1),g=v.useRef(null),x=v.useCallback(w=>{if(!c)return;w.preventDefault(),h.current=!0;const j=w.clientY,N=i;g.current&&(g.current.style.transition="none");const T=C=>{const S=j-C.clientY,R=window.innerHeight-qu,A=Math.max(YS,Math.min(R,N+S));g.current&&(g.current.style.height=`${A}px`)},k=C=>{h.current=!1,document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",k),g.current&&(g.current.style.transition="");const S=j-C.clientY,R=window.innerHeight-qu;c(Math.max(YS,Math.min(R,N+S)))};document.addEventListener("mousemove",T),document.addEventListener("mouseup",k)},[i,c]),b=a?`calc(100vh - ${qu}px)`:`${i}px`;return o.jsxs("div",{ref:g,className:`
|
|
135
|
-
fixed left-0 right-0 shadow-[0_-10px_40px_rgba(0,0,0,0.8)] flex flex-col border-t border-neutral-700
|
|
136
|
-
bg-neutral-950/95 backdrop-blur-xl
|
|
137
|
-
${e?"translate-y-0 opacity-100 pointer-events-auto":"translate-y-full opacity-0 pointer-events-none"}
|
|
138
|
-
transition-all duration-300 ease-in-out
|
|
139
|
-
`,style:{bottom:qu,height:b,zIndex:sf.zIndex.drawer},children:[o.jsxs("div",{className:"h-9 bg-neutral-900/70 border-b border-neutral-700 flex items-center justify-between px-3 shrink-0 select-none backdrop-blur-sm",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[u||o.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[o.jsx(Kz,{size:14}),o.jsx("span",{className:"text-xs font-bold tracking-widest font-mono",children:"TERMINAL"})]}),f]}),o.jsx("div",{className:"flex-1 flex items-center justify-center h-full cursor-ns-resize text-neutral-500 hover:text-neutral-300 transition-colors group",title:"Drag to Resize",onMouseDown:x,children:o.jsx("div",{className:"w-16 h-1 rounded-full bg-neutral-700 group-hover:bg-neutral-500 transition-colors"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:n,className:"p-1.5 rounded hover:bg-neutral-700 text-neutral-400 hover:text-white transition-colors",title:a?"Restore":"Maximize",children:a?o.jsx(Mz,{size:14}):o.jsx(lk,{size:14})}),o.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-red-900/20 text-neutral-400 hover:text-red-400 transition-colors",title:"Close",children:o.jsx(uk,{size:14})})]})]}),o.jsx("div",{className:"flex-1 relative overflow-hidden flex flex-col bg-transparent",children:m})]})},hV=({isOpen:e,onClose:t,commands:n})=>{const[a,i]=v.useState(""),[c,u]=v.useState(0),f=v.useRef(null),m=v.useRef(null),h=n.filter(x=>x.label.toLowerCase().includes(a.toLowerCase()));v.useEffect(()=>{e&&(setTimeout(()=>f.current?.focus(),10),i(""),u(0))},[e]),v.useEffect(()=>{u(0)},[a]),v.useEffect(()=>{m.current?.scrollIntoView({behavior:"smooth",block:"nearest"})},[c]);const g=x=>{x.key==="ArrowDown"?(x.preventDefault(),u(b=>(b+1)%h.length)):x.key==="ArrowUp"?(x.preventDefault(),u(b=>(b-1+h.length)%h.length)):x.key==="Enter"?(x.preventDefault(),h[c]&&(h[c].action(),t())):x.key==="Escape"&&t()};return e?o.jsx("div",{className:"fixed inset-0 z-[100] flex items-start justify-center pt-[15vh] bg-black/60 backdrop-blur-[2px] pointer-events-auto",onClick:t,children:o.jsxs("div",{className:"w-[640px] max-w-[90vw] bg-[#161616] border border-neutral-700 shadow-2xl rounded-lg overflow-hidden flex flex-col animate-in fade-in zoom-in-95 duration-100",onClick:x=>x.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-neutral-700 gap-3",children:[o.jsx(qg,{className:"text-neutral-400",size:18}),o.jsx("input",{ref:f,className:"flex-1 bg-transparent border-none outline-none text-neutral-100 placeholder-neutral-500 font-mono text-sm",placeholder:"Type a command or search...",value:a,onChange:x=>i(x.target.value),onKeyDown:g,autoFocus:!0}),o.jsx("div",{className:"px-1.5 py-0.5 rounded bg-neutral-700 border border-neutral-700 text-[12px] text-neutral-200 font-mono",children:"ESC"})]}),o.jsxs("div",{className:"max-h-[300px] overflow-y-auto py-2 relative",children:[o.jsx("div",{className:"pb-2",children:h.length===0?o.jsx("div",{className:"px-4 py-8 text-center text-neutral-400 text-xs font-mono",children:"No matching commands"}):h.map((x,b)=>o.jsxs("div",{ref:b===c?m:null,className:`px-4 py-2.5 flex items-center gap-3 cursor-pointer transition-colors ${b===c?"bg-emerald-900/20 border-l-2 border-emerald-500":"border-l-2 border-transparent hover:bg-white/5"}`,onClick:()=>{x.action(),t()},onMouseEnter:()=>u(b),children:[x.icon&&o.jsx("div",{className:`text-neutral-300 ${b===c?"text-emerald-400":""}`,children:x.icon}),o.jsx("div",{className:"flex-1",children:o.jsx("div",{className:`text-sm ${b===c?"text-emerald-100":"text-neutral-200"}`,children:x.label})}),x.shortcut&&o.jsx("div",{className:"text-[12px] font-mono text-neutral-300 bg-neutral-800 px-1.5 py-0.5 rounded border border-neutral-700",children:x.shortcut}),b===c&&o.jsx(jz,{size:14,className:"text-emerald-500 ml-2"})]},x.id))}),h.length>6&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-[#111] to-transparent pointer-events-none"})]}),o.jsxs("div",{className:"px-4 py-1.5 bg-neutral-800/90 backdrop-blur-sm border-t border-neutral-700 flex justify-between items-center text-[12px] text-neutral-300 font-mono relative z-10",children:[o.jsx("span",{children:"Command Palette"}),o.jsxs("span",{children:[h.length," matches"]})]})]})}):null};async function _e(e,t){const n=await fetch(e,{...t,headers:{...t?.headers??{},...t?.body?{"content-type":"application/json"}:{}}});if(!n.ok){const i=await n.text();let c=i||`HTTP ${n.status}`;try{const u=JSON.parse(i);u?.error&&(c=u.error)}catch{}throw new Error(c)}const a=await n.text();if(a)return JSON.parse(a)}function vc(){return!(typeof window>"u"||new URLSearchParams(window.location.search).has("no-ops"))}function mV(e){switch(e){case"profile":case"observe":case"message":return e;default:return}}function pV(e){const t=new URL(e.toString()),n=t.pathname.replace(/^\/+/,"").split("/").filter(Boolean),a=t.searchParams.get("compose")==="ask"?"ask":void 0,i=mV(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 c=decodeURIComponent(n[1]);return i==="message"?{view:"agents",agentId:c,conversationId:os(c),tab:"message"}:{view:"agents",agentId:c,...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]),...a?{composeMode:a}:{}};if(n[0]==="sessions"&&n[1])return{view:"sessions",sessionId:decodeURIComponent(n[1])};if(n[0]==="sessions")return{view:"sessions"};if(n[0]==="mesh")return{view:"mesh"};if(n[0]==="activity")return{view:"activity"};if(n[0]==="work"&&n[1])return{view:"work",workId:decodeURIComponent(n[1])};if(n[0]==="settings")return{view:"settings"};if(n[0]==="ops"){if(!vc())return{view:"inbox"};const c=n[1];return c==="conductor"||c==="warroom"||c==="plan"||c==="mission"?{view:"ops",mode:c}:{view:"ops"}}return{view:"inbox"}}function yp(){return pV(window.location.href)}function gV(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===os(e.agentId),a=n?"profile":e.conversationId?"message":"profile";n?t.set("tab","message"):e.tab&&e.tab!==a&&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"sessions":return e.sessionId?`/sessions/${encodeURIComponent(e.sessionId)}`:"/sessions";case"mesh":return"/mesh";case"activity":return"/activity";case"work":return`/work/${encodeURIComponent(e.workId)}`;case"settings":return"/settings";case"ops":return e.mode&&e.mode!=="plan"?`/ops/${e.mode}`:"/ops"}}function xp(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"work":return`work:${e.workId}`;case"ops":return`ops:${e.mode??"plan"}`;default:return e.view}}function vV(){const[e,t]=v.useState(yp),n=v.useRef({});v.useEffect(()=>{const i=()=>{const c=yp();t(c),requestAnimationFrame(()=>{window.scrollTo(0,n.current[xp(c)]??0)})};return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const a=v.useCallback(i=>{const c=i.view==="ops"&&!vc()?{view:"inbox"}:i;n.current[xp(yp())]=window.scrollY,window.history.pushState(null,"",gV(c)),t(c),requestAnimationFrame(()=>{window.scrollTo(0,n.current[xp(c)]??0)})},[]);return{route:e,navigate:a}}function uT(e){const t=e.match(/^dm\.operator\.(.+)$/);return t?t[1]:null}function os(e){return`dm.operator.${e}`}const yV=["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"];function xV(e){try{return JSON.parse(e)}catch{return{kind:"unknown"}}}function vn(e){const t=v.useRef(e);t.current=e,v.useEffect(()=>{let n=null,a=null,i=0;function c(){n=new EventSource("/api/events");const u=f=>{t.current(xV(f.data))};n.onopen=()=>{i=0},n.onmessage=u;for(const f of yV)n.addEventListener(f,u);n.onerror=()=>{n?.close(),i++;const f=Math.min(3e3*2**(i-1),6e4);a=setTimeout(c,f)}}return c(),()=>{n?.close(),a&&clearTimeout(a)}},[])}function mt(e){return e==="working"?"working":!e||e==="offline"?"offline":"available"}function ri(e){return mt(e)!=="offline"}function aa(e){switch(mt(e)){case"working":return"Working";case"available":return"Available";default:return"Offline"}}const dT={current:null,setMenu:null};function xf(){return v.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),dT.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function bV({children:e}){const[t,n]=v.useState(null),a=v.useRef(null);dT.setMenu=n;const i=v.useCallback(()=>n(null),[]);return v.useEffect(()=>{if(!t)return;const c=()=>i(),u=m=>{m.key==="Escape"&&i()},f=()=>i();return window.addEventListener("mousedown",c,!0),window.addEventListener("keydown",u),window.addEventListener("scroll",f,!0),window.addEventListener("contextmenu",i,!0),()=>{window.removeEventListener("mousedown",c,!0),window.removeEventListener("keydown",u),window.removeEventListener("scroll",f,!0),window.removeEventListener("contextmenu",i,!0)}},[t,i]),v.useEffect(()=>{if(!t||!a.current)return;const c=a.current,u=c.getBoundingClientRect(),f=window.innerWidth,m=window.innerHeight;let h=t.position.x,g=t.position.y;h+u.width>f-8&&(h=f-u.width-8),g+u.height>m-8&&(g=m-u.height-8),h<8&&(h=8),g<8&&(g=8),c.style.left=`${h}px`,c.style.top=`${g}px`},[t]),t?o.jsxs(o.Fragment,{children:[e,o.jsx("div",{ref:a,className:"s-context-menu",style:{left:t.position.x,top:t.position.y},role:"menu",onMouseDown:c=>c.stopPropagation(),children:t.items.map((c,u)=>c.kind==="separator"?o.jsx("div",{className:"s-context-menu-sep",role:"separator"},u):o.jsxs("button",{type:"button",className:"s-context-menu-item",role:"menuitem",onClick:()=>{c.onSelect(),i()},children:[o.jsx("span",{className:"s-context-menu-label",children:c.label}),c.shortcut&&o.jsx("span",{className:"s-context-menu-shortcut",children:c.shortcut})]},u))})]}):o.jsx(o.Fragment,{children:e})}const wV=[195,125,300,45,355,210];function GS(e){return`oklch(0.80 0.14 ${e})`}function SV(e){return`oklch(0.18 0.08 ${e})`}function Jr({label:e,right:t}){return o.jsxs("div",{className:"s-settings-section-rule",children:[o.jsx("span",{className:"s-settings-section-label",children:e}),o.jsx("span",{className:"s-settings-section-line"}),t&&o.jsx("span",{className:"s-settings-section-right",children:t})]})}function Ss({label:e,hint:t,children:n}){return o.jsxs("div",{className:"s-settings-field",children:[o.jsx("label",{className:"s-settings-field-label",children:e}),n,t&&o.jsx("span",{className:"s-settings-field-hint",children:t})]})}function ao({value:e,onChange:t,mono:n}){return o.jsx("input",{className:`s-settings-input${n?" s-settings-input--mono":""}`,value:e,onChange:a=>t(a.target.value)})}function jV({value:e,onChange:t,rows:n=3}){return o.jsx("textarea",{className:"s-settings-textarea",value:e,onChange:a=>t(a.target.value),rows:n})}function NV({value:e,onChange:t,min:n,max:a,step:i=1,unit:c=""}){return o.jsxs("div",{className:"s-settings-slider-wrap",children:[o.jsx("input",{type:"range",min:n,max:a,step:i,value:e,onChange:u=>t(Number(u.target.value))}),o.jsxs("span",{className:"s-settings-slider-value",children:[e," ",c]})]})}function Yu({value:e,onChange:t,options:n,stacked:a,columns:i}){return o.jsx("div",{className:a?"s-settings-option-stacked":"s-settings-option-grid",style:a?void 0:{gridTemplateColumns:`repeat(${i??n.length}, 1fr)`},children:n.map(c=>o.jsxs("button",{className:`s-settings-option-btn${e===c.id?" s-settings-option-btn--active":""}`,onClick:()=>t(c.id),children:[o.jsx("span",{className:"s-settings-option-label",children:c.label}),o.jsx("span",{className:"s-settings-option-sub",children:c.sub})]},c.id))})}function kV({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(Jr,{label:"Identity",right:"visible to every agent"}),o.jsxs("div",{className:"s-settings-identity-card",children:[o.jsx("span",{className:"s-settings-identity-dot",style:{background:GS(e.hue),color:SV(e.hue)},children:(e.name||"?")[0].toUpperCase()}),o.jsxs("div",{style:{flex:1},children:[o.jsx("div",{className:"s-settings-identity-name",children:e.name||"Unnamed"}),o.jsxs("div",{className:"s-settings-identity-meta",children:[e.handle||"@you"," · ",e.pronouns||"—"," · operator"]})]}),o.jsxs("div",{className:"s-settings-hue-wrap",children:[o.jsx("span",{className:"s-settings-field-label",children:"Identity hue"}),o.jsx("div",{className:"s-settings-hue-row",children:wV.map(n=>o.jsx("button",{onClick:()=>t({hue:n}),className:`s-settings-hue-dot${e.hue===n?" s-settings-hue-dot--active":""}`,style:{background:GS(n)}},n))})]})]}),o.jsx(Ss,{label:"Display name",hint:"Shown when agents address you.",children:o.jsx(ao,{value:e.name,onChange:n=>t({name:n})})}),o.jsx(Ss,{label:"Handle",hint:"Used in @mentions across threads.",children:o.jsx(ao,{value:e.handle,onChange:n=>t({handle:n}),mono:!0})}),o.jsx(Ss,{label:"Pronouns",children:o.jsx(ao,{value:e.pronouns,onChange:n=>t({pronouns:n})})}),o.jsx(Jr,{label:"How agents understand you",right:"shipped as system prompt context"}),o.jsx(Ss,{label:"Operator bio",hint:"How you want to be worked with. Agents read this before asking you things.",children:o.jsx(jV,{value:e.bio,onChange:n=>t({bio:n}),rows:4})}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(Ss,{label:"Timezone",children:o.jsx(ao,{value:e.timezone,onChange:n=>t({timezone:n}),mono:!0})}),o.jsx(Ss,{label:"Working hours",children:o.jsx(ao,{value:e.workingHours,onChange:n=>t({workingHours:n}),mono:!0})})]})]})}function EV({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(Jr,{label:"Interrupt policy"}),o.jsx(Ss,{label:"When agents can ping you directly",hint:"Blocking-only means only asks that truly stall work. Others get batched.",children:o.jsx(Yu,{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"}]})}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(Ss,{label:"Batch window (min)",children:o.jsx(NV,{value:e.batchWindow,min:5,max:60,step:5,onChange:n=>t({batchWindow:n}),unit:"min"})}),o.jsx(Ss,{label:"Quiet hours",children:o.jsx(ao,{value:e.quietHours,onChange:n=>t({quietHours:n}),mono:!0})})]}),o.jsx(Jr,{label:"Where to reach you"}),o.jsx(Ss,{label:"Preferred channel",children:o.jsx(Yu,{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"}]})}),o.jsx(Jr,{label:"Tone calibration",right:"how agents write to you"}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(Ss,{label:"Verbosity",children:o.jsx(Yu,{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"}]})}),o.jsx(Ss,{label:"Tone",children:o.jsx(Yu,{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 CV={desktop:"◻",mobile:"▯",tablet:"▭"};function TV({device:e}){const t=e.status==="this-device"?"var(--accent)":e.status==="online"?"var(--green)":"var(--dim)";return o.jsxs("div",{className:"s-settings-device-row",children:[o.jsx("span",{className:"s-settings-device-icon",children:CV[e.kind]??"□"}),o.jsxs("div",{children:[o.jsx("div",{className:"s-settings-device-name",children:e.name}),o.jsxs("div",{className:"s-settings-device-meta",children:[e.kind," · via ",e.relay," · ",e.lastSeen]})]}),o.jsxs("span",{className:"s-settings-device-status",style:{color:t},children:["●"," ",e.status==="this-device"?"this device":e.status]}),o.jsx("button",{className:"s-btn",disabled:e.status==="this-device",children:e.status==="this-device"?"—":"Unpair"})]})}function AV({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 a=n.fingerprint===e.connectedPeerFingerprint;t.push({id:n.fingerprint,name:n.name??"Paired device",kind:"mobile",status:a?"online":"offline",relay:"tailscale",lastSeen:n.lastSeenLabel??"—"})}return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(Jr,{label:`Paired devices · ${t.length}`}),o.jsx("div",{className:"s-settings-col-gap",style:{gap:10},children:t.map(n=>o.jsx(TV,{device:n},n.id))}),o.jsx(Jr,{label:"Relay"}),o.jsxs("div",{className:"s-settings-relay-card",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"s-settings-relay-title",children:["Relay · ",o.jsxs("span",{className:"s-settings-device-status",style:{color:e?.isRunning?"var(--green)":"var(--dim)"},children:["●"," ",e?.isRunning?"connected":"offline"]})]}),o.jsxs("div",{className:"s-settings-relay-meta",children:[e?.relay??"not configured"," · tailscale"]}),o.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."})]}),o.jsx("button",{className:"s-btn",children:"Configure"})]})]})}const RV=[{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"}],MV={operator:"Operator identity",comms:"Communication",devices:"Paired devices"},_V={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 OV({open:e,onClose:t}){const[n,a]=v.useState("operator"),[i,c]=v.useState(_V),[u,f]=v.useState(null),[m,h]=v.useState(!1),g=v.useRef(null),x=v.useCallback(async()=>{try{const j=_e("/api/user"),N=Promise.race([_e("/api/pairing-state"),new Promise((C,S)=>setTimeout(()=>S(new Error("timeout")),3e3))]),[T,k]=await Promise.allSettled([j,N]);T.status==="fulfilled"&&c(T.value),k.status==="fulfilled"&&f(k.value)}finally{h(!0)}},[]);v.useEffect(()=>{e&&x()},[e,x]),v.useEffect(()=>{if(!e)return;const j=N=>{N.key==="Escape"&&t()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[e,t]);const b=v.useCallback(j=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{_e("/api/user",{method:"POST",body:JSON.stringify(j)})},400)},[]),w=v.useCallback(j=>{c(N=>{const T={...N,...j};return b(T),T})},[b]);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`s-settings-scrim ${e?"s-settings-scrim--open":"s-settings-scrim--closed"}`,onClick:t}),o.jsxs("div",{className:`s-settings-drawer ${e?"s-settings-drawer--open":"s-settings-drawer--closed"}`,children:[o.jsxs("div",{className:"s-settings-header",children:[o.jsxs("div",{className:"s-settings-header-title",children:["⚙"," SETTINGS"]}),o.jsx("span",{className:"s-settings-header-sep",children:"/"}),o.jsx("span",{className:"s-settings-header-section",children:MV[n]}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{className:"s-settings-header-hint",children:"ESC to close"}),o.jsx("button",{className:"s-settings-close",onClick:t,children:"×"})]}),o.jsx("nav",{className:"s-settings-rail",children:RV.map(j=>o.jsxs("button",{onClick:()=>a(j.id),className:`s-settings-rail-btn${n===j.id?" s-settings-rail-btn--active":""}`,children:[o.jsx("span",{className:"s-settings-rail-label",children:j.label}),o.jsx("span",{className:"s-settings-rail-sub",children:j.sub})]},j.id))}),o.jsx("main",{className:"s-settings-content",children:m?o.jsxs(o.Fragment,{children:[n==="operator"&&o.jsx(kV,{profile:i,update:w}),n==="comms"&&o.jsx(EV,{profile:i,update:w}),n==="devices"&&o.jsx(AV,{pairing:u})]}):o.jsx("div",{style:{color:"var(--dim)",fontFamily:"var(--font-mono)",fontSize:12},children:"Loading..."})}),o.jsxs("div",{className:"s-settings-footer",children:[o.jsxs("span",{className:"s-settings-footer-sync",children:["●"," synced"]}),o.jsx("span",{children:"·"}),o.jsx("span",{children:"changes apply instantly to every agent in your fleet"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"s-btn",onClick:t,children:"Done"})]})]})]})}function IV({onOpen:e}){return o.jsxs("button",{className:"s-settings-launcher",onClick:e,children:[o.jsx("span",{className:"s-settings-launcher-icon",children:"⚙"}),o.jsx("span",{children:"settings"})]})}const fT=v.createContext(null),DV={"--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.23 0.010 80 / 0.8)","--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-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-border) 55%, 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"},zV={"--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"};function Ut(){const e=v.useContext(fT);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function LV({children:e,initialTheme:t="dark"}){const{route:n,navigate:a}=vV(),[i,c]=v.useState([]),[u,f]=v.useState([]),[m,h]=v.useState(null),[g,x]=v.useState(!1),b=v.useCallback(()=>x(!0),[]),[w,j]=v.useState(!1),N=v.useCallback(()=>j(!0),[]),T=v.useCallback(()=>j(!1),[]),k=t==="light"?zV:DV,C=v.useCallback(async()=>{const[M,O]=await Promise.allSettled([_e("/api/agents"),_e("/api/messages")]);M.status==="fulfilled"&&c(M.value),O.status==="fulfilled"&&f(O.value)},[]),S=v.useCallback(async()=>{try{const M=await _e("/api/onboarding/state");h(M)}catch{h({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[]);v.useEffect(()=>{C(),S()},[C,S]),vn(C);const R=v.useMemo(()=>i.filter(M=>ri(M.state)).length,[i]),A=v.useMemo(()=>({route:n,navigate:a,agents:i,messages:u,onlineCount:R,reload:C,onboarding:m,refreshOnboarding:S,onboardingSkipped:g,skipOnboarding:b,settingsOpen:w,openSettings:N,closeSettings:T}),[n,a,i,u,R,C,m,S,g,b,w,N,T]);return o.jsx(fT.Provider,{value:A,children:o.jsx("div",{"data-scout-theme":t,"data-scout-theme-mode":t,style:{...k},children:o.jsxs(bV,{children:[e,o.jsx(OV,{open:w,onClose:T})]})})})}function $V(){const{navigate:e,agents:t,reload:n,openSettings:a}=Ut(),i=vc(),c=v.useCallback(async u=>{await _e(`/api/agents/${encodeURIComponent(u)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]);return v.useMemo(()=>{const u=[{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:sessions",label:"Go to Sessions",action:()=>e({view:"sessions"}),shortcut:"Cmd+4"},{id:"nav:activity",label:"Go to Activity",action:()=>e({view:"activity"}),shortcut:"Cmd+5"},{id:"nav:mesh",label:"Go to Mesh",action:()=>e({view:"mesh"}),shortcut:"Cmd+6"},...i?[{id:"nav:ops",label:"Go to Ops",action:()=>e({view:"ops"}),shortcut:"Cmd+7"}]:[],{id:"nav:settings",label:"Open Settings",action:()=>a(),shortcut:"Cmd+,"},{id:"nav:pair",label:"Pair Device",action:()=>a()},{id:"scout:reload",label:"Reload Agents",action:()=>{n()}}];for(const f of t)u.push({id:`scout:open:${f.id}`,label:`Open ${f.name}`,action:()=>e({view:"conversation",conversationId:os(f.id)})}),u.push({id:`scout:send:${f.id}`,label:`Tell ${f.name}`,action:()=>e({view:"conversation",conversationId:os(f.id)})}),u.push({id:`scout:ask:${f.id}`,label:`Ask ${f.name}`,action:()=>e({view:"conversation",conversationId:os(f.id),composeMode:"ask"})}),u.push({id:`scout:interrupt:${f.id}`,label:`Interrupt ${f.name}`,action:()=>{c(f.id)}});return u},[t,c,e,i,n])}function hT(){const{onlineCount:e}=Ut(),[t,n]=v.useState(null),a=v.useRef(0),i=v.useCallback(async()=>{const c=++a.current;try{const u=await _e("/api/mesh");if(c!==a.current)return;n(u)}catch{if(c!==a.current)return;n(null)}},[]);return v.useEffect(()=>{i();const c=setInterval(()=>{i()},15e3);return()=>clearInterval(c)},[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(u=>u.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 PV(){return hT().status}const UV={inbox:"Fleet",conversation:"Conversation","agent-info":"Agent",agents:"Agents",fleet:"Fleet",sessions:"Sessions",activity:"Activity",mesh:"Mesh",settings:"Settings",work:"Work",ops:"Ops"};function BV(){const{route:e,navigate:t}=Ut(),n=vc(),a=[{label:"Fleet",view:"inbox"},{label:"Agents",view:"agents"},{label:"Sessions",view:"sessions"},{label:"Mesh",view:"mesh"},...n?[{label:"Ops",view:"ops"}]:[]],i=e.view==="fleet"||e.view==="activity"?"inbox":e.view==="conversation"||e.view==="agent-info"?"agents":e.view==="work"?n?"ops":"inbox":e.view,c=e.view==="conversation"||e.view==="agent-info"||e.view==="work"?UV[e.view]??e.view:null;return v.createElement("div",{className:"scout-nav-tabs"},a.map(({label:u,view:f})=>v.createElement("button",{key:f,className:`scout-nav-tab${i===f?" active":""}`,onClick:()=>t({view:f})},u)),c&&v.createElement("span",{className:"scout-nav-slash"},"/"),c&&v.createElement("span",{className:"scout-nav-crumb"},c))}function VV(){const{openSettings:e}=Ut();return v.createElement("button",{onClick:()=>e(),className:"scout-nav-action"},"Pair device")}function HV(){const{route:e}=Ut();return e.view==="ops"||e.view==="work"?"focus":"panel"}function ZV(){const{onboarding:e,onboardingSkipped:t,skipOnboarding:n}=Ut();if(!e)return null;if(t)return{active:!1,dismissible:!0};const a=!e.hasLocalConfig,i=!e.hasProjectConfig,c=!e.hasOperatorName;return{active:a||c||i,dismissible:!0,onDismiss:n}}function FV({app:e,assistant:t=!0}){return o.jsx(e.Provider,{children:o.jsx(YV,{app:e,assistantEnabled:t})})}function qV({statusBar:e}){const t=e.mesh.color==="amber"?"text-amber-400":e.mesh.color==="red"?"text-red-400":"text-neutral-100";return o.jsxs("div",{className:"flex items-center gap-3 font-mono text-[12px]",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"text-neutral-500",children:[e.activeAgents.label,":"]}),o.jsx("span",{className:"text-neutral-100",children:e.activeAgents.count})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"text-neutral-500",children:[e.mesh.label,":"]}),o.jsx("span",{className:t,children:e.mesh.value})]})]})}function YV({app:e,assistantEnabled:t}){const{navTotalHeight:n}=Yg(),a=e.hooks.useCommands(),i=e.hooks.useSearch?.()??null,c=e.hooks.useNavCenter?.()??null,u=e.hooks.useNavActions?.()??null,f=e.hooks.useLayoutMode?.()??e.mode,m=e.hooks.useActiveToolHint?.()??null,h=e.hooks.useTakeover?.()??null,g=h?.active===!0,x=g&&h?.dismissible===!0,b=h?.onDismiss,w=e.slots.Takeover,j=hT(),[N,T]=ka(`appshell.${e.id}.left`,!1),[k,C]=ka(`appshell.${e.id}.right`,!1),[S,R]=ka(`appshell.${e.id}.leftW`,260),[A,M]=ka(`appshell.${e.id}.rightW`,280),[O,V]=v.useState({x:0,y:0}),[F,I]=v.useState(1),$=v.useCallback(le=>{V(ge=>({x:ge.x+le.x,y:ge.y+le.y}))},[]),L=v.useCallback(le=>{I(le)},[]),[U,Y]=v.useState(!1),[K,D]=v.useState(!1),[P,B]=ka(`appshell.${e.id}.termH`,320),G=!!e.slots.Terminal,X=v.useMemo(()=>{const le=[];return G&&le.push("terminal"),t&&le.push("assistant"),le},[G,t]),z=X[0]??"terminal",[Z,J]=ka(`appshell.${e.id}.drawerTab`,z),Q=X.includes(Z)?Z:z,[pe,re]=v.useState(!1),[de,fe]=v.useState(new Set),xe=v.useCallback(le=>{fe(ge=>{const ve=new Set(ge);return ve.has(le)?ve.delete(le):ve.add(le),ve})},[]),Re=v.useCallback(le=>ge=>{ge.preventDefault();const ve=ge.clientX,je=le==="left"?S:A,Ne=le==="left"?R:M,Je=le==="left"?1:-1,et=Bt=>{const kt=(Bt.clientX-ve)*Je;Ne(Math.max(200,Math.min(500,je+kt)))},Ge=()=>{document.removeEventListener("mousemove",et),document.removeEventListener("mouseup",Ge)};document.addEventListener("mousemove",et),document.addEventListener("mouseup",Ge)},[S,A,R,M]),he=v.useMemo(()=>{const le=[{id:"shell:toggle-left",label:"Toggle Left Panel",shortcut:"Cmd+[",action:()=>T(ge=>!ge)},{id:"shell:toggle-right",label:"Toggle Right Panel",shortcut:"Cmd+]",action:()=>C(ge=>!ge)},{id:"shell:toggle-terminal",label:"Toggle Terminal",shortcut:"Ctrl+`",action:()=>Y(ge=>!ge)}];return t&&le.push({id:"shell:toggle-assistant",label:"Toggle Assistant",shortcut:"Cmd+J",action:()=>{J("assistant"),Y(ge=>!ge||Z!=="assistant")}}),le},[t,Z,J,T,C]),Me=v.useMemo(()=>[...a,...he],[a,he]);v.useEffect(()=>{const le=ge=>{g||((ge.metaKey||ge.ctrlKey)&&ge.key==="k"&&(ge.preventDefault(),re(!0)),(ge.metaKey||ge.ctrlKey)&&ge.key==="["&&(ge.preventDefault(),T(ve=>!ve)),(ge.metaKey||ge.ctrlKey)&&ge.key==="]"&&(ge.preventDefault(),C(ve=>!ve)),ge.ctrlKey&&ge.key==="`"&&(ge.preventDefault(),Y(ve=>!ve)),t&&(ge.metaKey||ge.ctrlKey)&&ge.key==="j"&&(ge.preventDefault(),J("assistant"),Y(ve=>!(ve&&Q==="assistant"))))};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[t,Q,J,T,C,g]),v.useEffect(()=>{const le=()=>{J("terminal"),Y(!0)};return window.addEventListener("scout:open-terminal",le),()=>window.removeEventListener("scout:open-terminal",le)},[J]);const Se=e.slots.Inspector,Ve=e.slots.RightPanel,Oe=e.tools&&e.tools.length>0,we=o.jsxs(o.Fragment,{children:[Se&&o.jsx(Se,{}),!Se&&Ve&&o.jsx(Ve,{}),Oe&&o.jsx("div",{className:"border-t border-neutral-700/50",children:e.tools.map(le=>{const ge=de.has(le.id);return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>xe(le.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 ${m===le.id?"text-emerald-400":"text-neutral-300"}`,children:[ge?o.jsx(bM,{size:10}):o.jsx(SM,{size:10}),o.jsx("span",{className:"text-neutral-400",children:le.icon}),o.jsx("span",{className:"font-bold",children:le.name})]}),ge&&o.jsx("div",{className:"px-4 pb-3",children:o.jsx(le.Component,{})})]},le.id)})})]}),ke=o.jsxs(o.Fragment,{children:[e.slots.LeftFooter&&o.jsx(e.slots.LeftFooter,{}),o.jsx(dV,{onOpenCommandPalette:()=>re(!0)})]}),Ye=v.useRef(null),Ue=v.useRef(null);v.useEffect(()=>{const le=Ye.current;le&&(g?le.setAttribute("inert",""):le.removeAttribute("inert"))},[g]),v.useEffect(()=>{if(!g)return;const le=Ue.current;if(le&&(le.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")??le).focus(),!x)return;const ge=ve=>{ve.key==="Escape"&&(ve.preventDefault(),b?.())};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[g,x,b]);const He=f==="panel"?{position:"absolute",top:n,bottom:28,left:N?0:S,right:k?0:A,overflow:"auto",transition:"left 200ms ease, right 200ms ease"}:{};return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:Ye,"aria-hidden":g?!0:void 0,style:{display:"contents"},children:o.jsx(iV,{mode:f,panOffset:O,scale:F,onPan:$,onZoom:L,hud:o.jsxs(o.Fragment,{children:[o.jsx(lV,{title:e.name.toUpperCase(),search:i??void 0,center:c,actions:u}),o.jsx(qS,{side:"left",title:e.leftPanel?.title??"Navigation",icon:e.leftPanel?.icon,isCollapsed:N,onToggleCollapse:()=>T(!N),width:S,onResizeStart:Re("left"),footer:ke,headerActions:e.leftPanel?.headerActions&&o.jsx(e.leftPanel.headerActions,{}),children:e.slots.LeftPanel&&o.jsx(e.slots.LeftPanel,{})}),o.jsx(qS,{side:"right",title:e.rightPanel?.title??"Inspector",icon:e.rightPanel?.icon,isCollapsed:k,onToggleCollapse:()=>C(!k),width:A,onResizeStart:Re("right"),headerActions:e.rightPanel?.headerActions&&o.jsx(e.rightPanel.headerActions,{}),children:we}),o.jsx(uV,{status:j.status,left:o.jsx(qV,{statusBar:j}),onToggleTerminal:()=>Y(le=>!le),isTerminalOpen:U}),o.jsx("div",{className:"pointer-events-none",style:{position:"fixed",left:N?0:S,right:k?0:A,bottom:0,top:0,zIndex:45,transition:"left 200ms ease, right 200ms ease",transform:"translateZ(0)"},children:o.jsxs(fV,{isOpen:U,onClose:()=>Y(!1),onToggleMaximize:()=>D(le=>!le),isMaximized:K,height:P,onHeightChange:B,title:o.jsx(GV,{tabs:X,active:Q,onSelect:J}),children:[Q==="terminal"&&(e.slots.Terminal?o.jsx(e.slots.Terminal,{}):o.jsx("div",{className:"p-4 font-mono text-[12px] text-neutral-400",children:"No terminal content"})),Q==="assistant"&&o.jsx(p4,{app:e,commands:a})]})}),o.jsx(hV,{isOpen:pe,onClose:()=>re(!1),commands:Me})]}),children:o.jsx("div",{style:He,className:"frame-scrollbar",children:o.jsx(e.slots.Content,{})})})}),g&&w?o.jsx("div",{ref:Ue,tabIndex:-1,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:80,outline:"none"},children:o.jsx(w,{})}):null]})}function GV({tabs:e,active:t,onSelect:n}){return e.length===0?null:o.jsx("div",{className:"flex items-center gap-0.5",children:e.map(a=>{const i=a===t,c=a==="terminal"?TM:EM,u=a==="terminal"?"TERMINAL":"ASSISTANT",f=a==="terminal"?"text-emerald-400":"text-cyan-400";return o.jsxs("button",{type:"button",onClick:()=>n(a),className:`flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-bold tracking-widest font-mono transition-colors ${i?`${f} bg-white/[0.04]`:"text-neutral-500 hover:text-neutral-300"}`,children:[o.jsx(c,{size:13}),o.jsx("span",{children:u})]},a)})})}const WV={ask_sent:"asked",ask_replied:"replied",ask_failed:"failed",ask_working:"working",flight_created:"task started",flight_updated:"task updated",message_sent:"sent",message_received:"received",agent_online:"online",agent_offline:"offline"};function XV(e){return WV[e]??e.replace(/_/g," ")}const WS=["#6366f1","#8b5cf6","#0ea5e9","#14b8a6","#f59e0b","#ef4444","#ec4899","#10b981"];function dt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return WS[Math.abs(t)%WS.length]}function Aa(e){switch(mt(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const KV={workspace:"workspace",worktree:"workspace",branch:"workspace",profile:"profile",persona:"profile",harness:"harness",runtime:"harness",node:"node",host:"node"};function JV(e){return e.trim().replace(/^@+/,"").replace(/[.,!?;)\]]+$/,"")}function Ks(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const QV="scout";function eH(e){return KV[Ks(e)]??null}function mT(e){const t=Ks(e.definitionId),n=e.workspaceQualifier?Ks(e.workspaceQualifier):void 0,a=e.profile?Ks(e.profile):void 0,i=e.harness?Ks(e.harness):void 0,c=e.nodeQualifier?Ks(e.nodeQualifier):void 0;return t?{definitionId:t,...n?{workspaceQualifier:n}:{},...a?{profile:a}:{},...i?{harness:i}:{},...c?{nodeQualifier:c}:{}}:null}function tH(e){const t=e.split(".").filter(Boolean),n=t.shift();if(!n)return null;const a={definitionId:n},i=[];for(const c of t){if(c.includes(":")){const[u,f=""]=c.split(":",2),m=eH(u),h=Ks(f);if(!m||!h)return null;m==="workspace"?a.workspaceQualifier=h:m==="profile"?a.profile=h:m==="harness"?a.harness=h:m==="node"&&(a.nodeQualifier=h);continue}i.push(c)}if(i.length===1){const c=Ks(i[0]);if(!c)return null;a.workspaceQualifier=c}else if(i.length===2){const c=Ks(i[0]),u=Ks(i[1]);if(!c||!u)return null;a.workspaceQualifier||(a.workspaceQualifier=c),a.nodeQualifier||(a.nodeQualifier=u)}else if(i.length>2)return null;return sH(a,{raw:e})}function nH(e){const t=JV(e);return!t||t.includes("@")||t.includes("#")?null:tH(t)}function XS(e,t={}){const n=mT(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.nodeQualifier&&i.push(`node:${n.nodeQualifier}`),i.join(".")}function sH(e,t={}){const n=mT(e);return n?{raw:t.raw??XS(n,{includeSigil:!1}),label:XS(n),definitionId:n.definitionId,...n.nodeQualifier?{nodeQualifier:n.nodeQualifier}:{},...n.workspaceQualifier?{workspaceQualifier:n.workspaceQualifier}:{},...n.profile?{profile:n.profile}:{},...n.harness?{harness:n.harness}:{}}:null}function aH(e){return rH(e).parsed}function rH(e){const t=Array.from(e.matchAll(/(^|\s)@([a-z0-9][a-z0-9._/:-]*)/gi)),n=new Map,a=[];for(const i of t){const c=i[2]??"",u=nH(c);if(!u){c&&a.push(`@${c}`);continue}n.set(u.label,u)}return{parsed:Array.from(n.values()),unparsed:Array.from(new Set(a))}}function iH(e,t){if(t.length===0)return[{kind:"text",value:e}];const n=new Map;for(const u of t)n.set(u.label.toLowerCase(),u);const a=[];let i=e;const c=/@([a-z0-9][a-z0-9._/:-]*)/i;for(;i.length>0;){const u=c.exec(i);if(!u||u.index===void 0){a.push({kind:"text",value:i});break}u.index>0&&a.push({kind:"text",value:i.slice(0,u.index)});const f=u[0],m=f.toLowerCase(),h=n.get(m);h?a.push({kind:"mention",identity:h}):a.push({kind:"text",value:f}),i=i.slice(u.index+f.length)}return a}function oH(e,t){const n=[],a=/\*\*(.+?)\*\*/g;let i=0,c,u=0;for(;(c=a.exec(e))!==null;)c.index>i&&n.push(o.jsx("span",{children:e.slice(i,c.index)},`${t}-${u++}`)),n.push(o.jsx("strong",{children:c[1]},`${t}-${u++}`)),i=c.index+c[0].length;return i<e.length&&n.push(o.jsx("span",{children:e.slice(i)},`${t}-${u++}`)),n.length>0?n:[o.jsx("span",{children:e},t)]}function ls(e){if(!e)return e??"";const t=aH(e);return iH(e,t).flatMap((a,i)=>{if(a.kind==="text")return oH(a.value,i*100);const{identity:c}=a,f=c.definitionId===QV?"var(--accent)":dt(c.definitionId);return o.jsx("span",{className:"s-mention",style:{"--mention-color":f},children:c.label},i)})}function Pe(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 Wr(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 lH={"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"},cH={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 pT(e){return lH[e]??e.replace(/[._]/g," ")}function uH(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 dH(e){return(e??"system").charAt(0).toUpperCase()}function gT(e){return e.length<=14?e:`${e.slice(0,8)}...${e.slice(-4)}`}function fH(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function hH(e){return`${e.actorName??"system"} ${pT(e.kind)}`}function mH(e){return e.workspaceRoot?`Recorded from ${e.workspaceRoot}.`:e.conversationId?`Linked to thread ${gT(e.conversationId)}.`:"No additional detail was captured for this event."}function pH({navigate:e}){const[t,n]=v.useState([]),[a,i]=v.useState(null),[c,u]=v.useState(!0),[f,m]=v.useState(!1),[h,g]=v.useState(null),[x,b]=v.useState(null),w=v.useRef([]),j=v.useRef(0),N=v.useRef(null),T=xf();v.useEffect(()=>{w.current=t},[t]);const k=v.useCallback(async(M="initial")=>{const O=++j.current;!(w.current.length>0)&&M!=="background"?(u(!0),g(null)):m(!0);try{const F=await _e("/api/activity");if(O!==j.current)return;n(F),g(null),b(Date.now()),i(I=>F.some($=>$.id===I)?I:null)}catch(F){if(O!==j.current)return;g(F instanceof Error?F.message:String(F))}finally{O===j.current&&(u(!1),m(!1))}},[]),C=v.useCallback(()=>{N.current||(N.current=setTimeout(()=>{N.current=null,k("background")},250))},[k]);v.useEffect(()=>(k("initial"),()=>{N.current&&clearTimeout(N.current)}),[k]),vn(C);const S=v.useMemo(()=>{const M=new Set(t.map(V=>V.actorName??"system")),O=new Set(t.map(V=>V.conversationId).filter(V=>!!V));return[{label:"Events",value:`${t.length}`,detail:t.length>0?`Latest ${Pe(t[0].ts)}`:"Waiting for records"},{label:"Actors",value:`${M.size}`,detail:M.size>0?"Distinct event owners":"No actors yet"},{label:"Threads",value:`${O.size}`,detail:O.size>0?"Conversation-linked records":"No linked threads"}]},[t]),R=!c&&t.length===0&&!!h,A=!c&&t.length===0&&!h;return o.jsxs("div",{className:"sys-surface-page",children:[o.jsxs("div",{className:"sys-page-head",children:[o.jsxs("div",{className:"sys-page-title-group",children:[o.jsx("h2",{className:"sys-page-title",children:"Activity"}),o.jsx("p",{className:"sys-page-subtitle",children:"Broker events, task execution, and collaboration handoffs."})]}),o.jsxs("div",{className:"sys-page-actions",children:[o.jsx("div",{className:"sys-sync-note",children:c?"Loading audit ledger...":h&&t.length>0?`Showing last confirmed snapshot from ${x?Pe(x):"earlier"}`:x?`Updated ${Pe(x)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:c||f,onClick:()=>{k("manual")},children:f?"Refreshing...":"Refresh"})]})]}),o.jsx("div",{className:"sys-stat-grid",children:S.map(M=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:M.label}),o.jsx("strong",{className:"sys-stat-value",children:M.value}),o.jsx("span",{className:"sys-stat-detail",children:M.detail})]},M.label))}),h&&t.length>0&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Refresh failed."}),o.jsx("span",{children:h})]}),c&&t.length===0&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"Loading activity"}),o.jsx("p",{className:"sys-state-body",children:"Pulling the latest records from the broker database."})]}),R&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Activity is unavailable"}),o.jsx("p",{className:"sys-state-body",children:h}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{k("manual")},children:"Try again"})})]}),A&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"No activity yet"}),o.jsx("p",{className:"sys-state-body",children:"Events appear here after agents register, send messages, or advance work."})]}),t.length>0&&o.jsx("div",{className:"sys-audit-list",children:t.map(M=>{const O=a===M.id,V=uH(M.kind),F=cH[V],I=fH(M.workspaceRoot),$=M.summary&&M.summary!==M.title?M.summary:mH(M);return o.jsxs("article",{className:`sys-audit-entry${O?" sys-audit-entry-expanded":""}`,onContextMenu:L=>{const U=window.getSelection()?.toString().trim(),Y=[];U&&(Y.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(U)}),Y.push({kind:"separator"}));const K=M.title??M.summary??"";K&&Y.push({kind:"action",label:"Copy Details",onSelect:()=>navigator.clipboard.writeText(K)}),M.actorName&&Y.push({kind:"action",label:"Copy Actor",onSelect:()=>navigator.clipboard.writeText(M.actorName)}),Y.push({kind:"action",label:"Copy Event ID",onSelect:()=>navigator.clipboard.writeText(M.id)}),M.conversationId&&(Y.push({kind:"separator"}),Y.push({kind:"action",label:"Open Thread",onSelect:()=>e({view:"conversation",conversationId:M.conversationId})})),T(L,Y)},children:[o.jsxs("button",{type:"button",className:"sys-audit-toggle","aria-expanded":O,onClick:()=>i(O?null:M.id),children:[o.jsxs("div",{className:"sys-audit-stamp",children:[o.jsx("span",{className:"sys-audit-time",children:Pe(M.ts)}),o.jsx("span",{className:"sys-audit-date",children:Wr(M.ts)})]}),o.jsx("div",{className:`sys-audit-marker sys-audit-marker-${F.tone}`,children:o.jsx("span",{})}),o.jsxs("div",{className:"sys-audit-body",children:[o.jsxs("div",{className:"sys-audit-topline",children:[o.jsx("span",{className:"sys-audit-category",children:F.label}),o.jsx("span",{className:"sys-audit-kind",children:pT(M.kind)})]}),o.jsx("h3",{className:"sys-audit-title",children:ls(M.title??hH(M))}),o.jsx("p",{className:"sys-audit-summary",children:ls($)}),o.jsxs("div",{className:"sys-audit-meta",children:[o.jsxs("span",{className:"sys-audit-meta-item",children:[o.jsx("span",{className:"sys-audit-avatar",style:{background:dt(M.actorName??"system")},children:dH(M.actorName)}),M.actorName??"system"]}),I&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Workspace ",I]}),M.conversationId&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Thread ",gT(M.conversationId)]})]})]}),o.jsx("div",{className:"sys-audit-expand",children:O?"Close":"Details"})]}),O&&o.jsxs("div",{className:"sys-audit-details",children:[o.jsxs("div",{className:"sys-detail-grid",children:[o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Event"}),o.jsx("code",{className:"sys-detail-value",children:M.kind})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Recorded"}),o.jsx("span",{className:"sys-detail-value",children:Wr(M.ts)})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Actor"}),o.jsx("span",{className:"sys-detail-value",children:M.actorName??"system"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Workspace"}),o.jsx("span",{className:"sys-detail-value",children:M.workspaceRoot??"Not attached"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Thread"}),o.jsx("span",{className:"sys-detail-value",children:M.conversationId??"Not attached"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Record id"}),o.jsx("code",{className:"sys-detail-value",children:M.id})]})]}),M.conversationId&&o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>e({view:"conversation",conversationId:M.conversationId}),children:"Open thread"})})]})]},M.id)})})]})}function pr(e){const t=e?.trim();if(!t)return null;const[n]=t.split(".");return n?.trim()||t}function gH(e){const t=e.handle?.trim().replace(/^@+/,"");if(t)return`@${t}`;const n=e.selector?.trim();if(n)return n;const a=pr(e.id);return a?`@${a}`:null}function vH(e){return e.name?.trim()||e.agentName?.trim()||pr(e.id)||e.title?.trim()||"Conversation"}function bp(e){return e?e.replace(/_/g," "):null}function yH({values:e}){return o.jsx("span",{className:"s-agent-token-list",children:e.map(t=>o.jsx("span",{className:"s-agent-token",children:t},t))})}function Gu({title:e,items:t}){return t.length===0?null:o.jsxs("section",{className:"s-agent-profile-card",children:[o.jsx("div",{className:"s-agent-profile-card-header",children:o.jsx("div",{className:"s-agent-profile-card-title",children:e})}),o.jsx("div",{className:"s-agent-meta-card-body",children:t.map(n=>o.jsxs("div",{className:"s-agent-meta-row",children:[o.jsx("span",{className:"s-agent-meta-label",children:n.label}),o.jsx("span",{className:"s-agent-meta-value",children:n.value})]},n.label))})]})}function xH({conversationId:e,navigate:t}){const{agents:n}=Ut(),[a,i]=v.useState(null),[c,u]=v.useState(null),f=uT(e),m=v.useCallback(async()=>{u(null);try{const T=await _e(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);i(T)}catch(T){u(T instanceof Error?T.message:String(T)),i(null)}},[e]);v.useEffect(()=>{m()},[m]),vn(m);const h=a?.agentId??f,g=v.useMemo(()=>h?n.find(T=>T.id===h)??null:null,[n,h]);if(!g)return o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"conversation",conversationId:e}),children:"← Back"}),c&&o.jsx("p",{className:"s-error",children:c}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Agent not found"})})]});const x=gH(g),b=[{label:"System ID",value:g.id},{label:"Class",value:bp(g.agentClass)??"—"},...g.role?[{label:"Role",value:g.role}]:[],...g.selector&&g.selector!==x?[{label:"Selector",value:g.selector}]:[]],w=[...g.project?[{label:"Project",value:g.project}]:[],...g.branch?[{label:"Branch",value:g.branch}]:[],...g.projectRoot?[{label:"Path",value:g.projectRoot}]:[],...g.cwd?[{label:"Working dir",value:g.cwd}]:[]],j=[...g.harness?[{label:"Harness",value:g.harness}]:[],...g.transport?[{label:"Transport",value:bp(g.transport)??g.transport}]:[],...g.wakePolicy?[{label:"Wake policy",value:bp(g.wakePolicy)??g.wakePolicy}]:[],...g.capabilities.length>0?[{label:"Capabilities",value:o.jsx(yH,{values:g.capabilities})}]:[]],N=[{label:"Thread ID",value:e},...a?.workspaceRoot?[{label:"Workspace",value:a.workspaceRoot}]:[],...a?.currentBranch?[{label:"Session branch",value:a.currentBranch}]:[],...a?.messageCount!=null?[{label:"Messages",value:String(a.messageCount)}]:[],...a?.lastMessageAt?[{label:"Last message",value:Wr(a.lastMessageAt)}]:[],...g.harnessSessionId?[{label:"Harness session",value:g.harnessSessionId}]:[],...g.harnessLogPath?[{label:"Harness log",value:g.harnessLogPath}]:[]];return o.jsxs("div",{className:"s-agent-profile-page",children:[o.jsxs("div",{className:"s-agent-profile-page-topbar",children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"conversation",conversationId:e}),children:"← Conversation"}),o.jsx("button",{type:"button",className:"s-btn",onClick:()=>t({view:"agents",agentId:g.id}),children:"Open in Agents"})]}),c&&o.jsx("p",{className:"s-error",children:c}),o.jsxs("section",{className:"s-agent-profile-hero",children:[o.jsx("div",{className:"s-agent-profile-hero-main",children:o.jsxs("div",{className:"s-agent-profile-hero-title-row",children:[o.jsx("div",{className:"s-avatar s-agent-profile-hero-avatar",style:{background:dt(g.name)},children:g.name[0].toUpperCase()}),o.jsxs("div",{className:"s-agent-profile-hero-copy",children:[o.jsxs("div",{className:"s-agent-casefile-title-meta",children:[o.jsx("span",{className:"s-agent-casefile-record",children:x??pr(g.id)??g.id}),o.jsxs("span",{className:`s-agent-state-chip s-agent-state-chip-${mt(g.state)}`,children:[o.jsx("span",{className:"s-dot",style:{background:Aa(g.state)}}),aa(g.state)]})]}),o.jsx("h1",{className:"s-agent-profile-hero-title",children:g.name}),o.jsxs("p",{className:"s-agent-profile-hero-context",children:[a?.title?`Conversation: ${a.title}.`:"Attached to the current conversation.",g.updatedAt?` Updated ${Pe(g.updatedAt)}.`:""]})]})]})}),o.jsx("div",{className:"s-agent-profile-hero-actions",children:o.jsx("button",{type:"button",className:"s-btn s-btn-primary",onClick:()=>t({view:"conversation",conversationId:e}),children:"Open conversation"})})]}),o.jsxs("div",{className:"s-agent-profile-grid",children:[o.jsx(Gu,{title:"Identity",items:b}),o.jsx(Gu,{title:"Workspace",items:w}),o.jsx(Gu,{title:"Runtime",items:j}),o.jsx(Gu,{title:"Conversation context",items:N})]})]})}function bH(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function wH(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 SH(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function KS({items:e,navigate:t,emptyTitle:n,emptyDetail:a}){if(e.length===0){const i=[{titleWidth:"56%",metaWidths:["18%","14%","16%"],summaryWidth:"74%"},{titleWidth:"48%",metaWidths:["16%","20%","12%"],summaryWidth:"62%"}];return o.jsxs("div",{className:"s-work-empty-state",children:[o.jsxs("div",{className:"s-work-empty-copy",children:[o.jsx("p",{className:"s-work-empty-kicker",children:"Quiet for now"}),o.jsx("p",{className:"s-work-empty-title",children:n}),a&&o.jsx("p",{className:"s-work-empty-detail",children:a})]}),o.jsx("div",{className:"s-work-empty-skeleton","aria-hidden":"true",children:i.map((c,u)=>o.jsxs("div",{className:"s-work-empty-row",children:[o.jsxs("div",{className:"s-work-empty-row-header",children:[o.jsx("span",{className:"s-work-empty-line s-work-empty-line-title",style:{width:c.titleWidth}}),o.jsx("span",{className:"s-work-empty-pill"})]}),o.jsx("div",{className:"s-work-empty-row-meta",children:c.metaWidths.map(f=>o.jsx("span",{className:"s-work-empty-line s-work-empty-line-meta",style:{width:f}},f))}),o.jsx("span",{className:"s-work-empty-line s-work-empty-line-summary",style:{width:c.summaryWidth}})]},u))})]})}return o.jsx("div",{className:"s-work-list",children:e.map(i=>{const c=!!i.id||!!i.conversationId,u=SH(i.attention),f=i.ownerName??i.ownerId??"Unassigned",m=i.id?()=>t({view:"work",workId:i.id}):i.conversationId?()=>t({view:"conversation",conversationId:i.conversationId}):void 0;return o.jsxs("div",{className:`s-work-row${c?" s-work-row-clickable":""}`,onClick:m,children:[o.jsxs("div",{className:"s-work-row-header",children:[o.jsxs("div",{className:"s-work-row-title-wrap",children:[o.jsx("span",{className:"s-work-row-title",children:i.title}),i.priority&&o.jsx("span",{className:"s-badge",children:i.priority})]}),o.jsx("span",{className:`s-pill s-pill-${bH(i)}`,children:i.currentPhase})]}),o.jsxs("div",{className:"s-work-row-meta",children:[o.jsx("span",{children:f}),o.jsx("span",{children:wH(i.state)}),i.activeChildWorkCount>0&&o.jsxs("span",{children:[i.activeChildWorkCount," child",i.activeChildWorkCount===1?"":"ren"]}),i.activeFlightCount>0&&o.jsxs("span",{children:[i.activeFlightCount," flight",i.activeFlightCount===1?"":"s"]}),u&&o.jsx("span",{children:u}),o.jsx("span",{children:Pe(i.lastMeaningfulAt)})]}),i.lastMeaningfulSummary&&o.jsx("p",{className:"s-work-row-summary",children:ls(i.lastMeaningfulSummary)})]},i.id)})})}const vT="scout:sessions:lastViewed";function Bv(){if(typeof localStorage>"u")return{};try{const e=localStorage.getItem(vT);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function jH(e,t=Date.now()){const n=Bv();n[e]=t;try{localStorage.setItem(vT,JSON.stringify(n))}catch{}return n}function wp(e,t,n){return e?e>(n[t]??0):!1}async function NH(e){await fetch("/api/terminal/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})}),window.dispatchEvent(new CustomEvent("scout:open-terminal"))}const Cg=new Set(["completed","failed","cancelled"]),kH={direct:"Direct message",channel:"Channel",group_direct:"Group",thread:"Thread"},JS=[{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 yT(e,t){if(t<=0)return!0;const n=e[t-1];return!n||/\s/.test(n)}function EH(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]!=="/"||!yT(e,n))return null;const a=e.slice(n+1,t);return/[^a-zA-Z0-9_-]/.test(a)?null:{start:n,query:a}}function CH(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]!=="@"||!yT(e,n))return null;const a=e.slice(n+1,t);return/[^a-zA-Z0-9._/:-]/.test(a)?null:{start:n,query:a}}function Xn(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:e<1e12?e*1e3:e}function TH(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function AH(e){return e.kind==="direct"&&e.agentName?e.agentName:e.kind==="direct"&&e.agentId?pr(e.agentId)??e.agentId:e.title.replace(/\s*<>\s*/g," · ")}function Sp(e){const t=Xn(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function RH(e,t){const n=Xn(e),a=Xn(t);if(n===null||a===null)return!1;const i=new Date(n),c=new Date(a);return i.getFullYear()===c.getFullYear()&&i.getMonth()===c.getMonth()&&i.getDate()===c.getDate()}function QS(e){const t=Xn(e);if(t===null)return"";const n=new Date(t),a=new Date,i=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),c=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),u=1440*60*1e3;return c===i?"Today":c===i-u?"Yesterday":new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(t)}function MH(e){switch(e){case"status":return"Status";case"system":return"System";case"scout.dispatch":return"Dispatch";default:return null}}function Wu(e){return[...e].sort((t,n)=>(Xn(t.createdAt)??0)-(Xn(n.createdAt)??0))}function _H(e){return e.filter(t=>!Cg.has(t.state)).sort((t,n)=>(Xn(n.startedAt)??0)-(Xn(t.startedAt)??0))[0]??null}function ej(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 OH(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 Tg(e,t){if(e.class==="operator")return!0;const n=e.actorName?.toLowerCase()??"";return n===t.toLowerCase()||n==="operator"||n==="you"}function IH(e,t){return e.reduce((n,a)=>{if(Tg(a,t))return n;const i=Xn(a.createdAt);return i===null?n:n===null||i>n?i:n},null)}function DH(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 zH(e){const{agentName:t,agentState:n,sending:a,currentFlight:i,showWorkingTurn:c}=e;if(a&&!i)return{label:"Sending",detail:`Handing your message to ${t}.`,tone:"pending",showStrip:!0,showTyping:!1};if(i&&c){const u=i.summary?.trim()||DH(t,i.state);switch(i.state){case"queued":return{label:"Queued",detail:u,tone:"pending",showStrip:!0,showTyping:!0};case"waking":return{label:"Coming online",detail:u,tone:"working",showStrip:!0,showTyping:!0};case"waiting":return{label:"Thinking",detail:u,tone:"working",showStrip:!0,showTyping:!0};default:return{label:"Working",detail:u,tone:"working",showStrip:!0,showTyping:!0}}}return ri(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 LH(e,t){switch(e.tone){case"pending":return"var(--accent)";case"working":return"var(--green)";case"offline":return"var(--dim)";default:return Aa(t)}}function $H(){return o.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:[o.jsx("path",{d:"m3 11 18-8-8 18-2.8-7.2L3 11Z"}),o.jsx("path",{d:"M10.2 13.8 21 3"})]})}function PH(){return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:o.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}function UH(e){if(!e)return null;if(e.kind==="direct")return e.agentName??pr(e.agentId)??null;const t=e.participantIds.filter(n=>n!=="operator");return t.length===0?null:t.map(n=>pr(n)??n).join(", ")}function Ag({conversationId:e,initialComposeMode:t,navigate:n,embedded:a}){const{agents:i}=Ut(),[c,u]=v.useState(null),[f,m]=v.useState([]),[h,g]=v.useState(null),[x,b]=v.useState([]),[w,j]=v.useState(null),N=v.useRef(null),T=v.useRef(null),k=v.useRef(new Set),C=v.useRef(null),S=v.useRef(0),R=uT(e),A=c?.agentId??R,M=c?.kind==="direct"||R!==null,O=v.useMemo(()=>A?i.find(ee=>ee.id===A)??null:null,[i,A]),[V,F]=v.useState([]),[I,$]=v.useState(new Set),[L]=v.useState(()=>Bv());v.useEffect(()=>{_e("/api/sessions").then(ee=>F(ee.sort((me,ye)=>(ye.lastMessageAt??0)-(me.lastMessageAt??0)))).catch(()=>{}),_e("/api/fleet").then(ee=>{const me=new Set;for(const ye of ee.needsAttention)ye.conversationId&&me.add(ye.conversationId),ye.agentId&&me.add(ye.agentId);for(const ye of ee.activeAsks)ye.status==="needs_attention"&&ye.conversationId&&me.add(ye.conversationId);$(me)}).catch(()=>{})},[]);const U=v.useCallback(async()=>{j(null);try{const ee=await _e(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);u(ee);const me=ee?.agentId??R,ye=ee?.kind==="direct"&&me&&me.startsWith("local-session-agent-")?os(me):e;if(ye!==e){n({view:"conversation",conversationId:ye,...t?{composeMode:t}:{}});return}const[Be,ze]=await Promise.all([_e(`/api/messages?conversationId=${encodeURIComponent(ye)}&limit=300`),_e(`/api/flights?conversationId=${encodeURIComponent(ye)}`)]);m(Wu(Be)),b(ze),k.current=new Set(ze.map(ut=>ut.invocationId)),g(_H(ze))}catch(ee){j(ee instanceof Error?ee.message:String(ee))}},[e,t,R,n]);v.useEffect(()=>{U()},[U]);const[Y,K]=v.useState(null),[D,P]=v.useState(!1);v.useEffect(()=>{if(!A)return;let ee=!1;return _e(`/api/agents/${encodeURIComponent(A)}/session-catalog`).then(me=>{ee||K(me)}).catch(()=>{}),()=>{ee=!0}},[A]),v.useEffect(()=>{C.current=h},[h]);const[B,G]=v.useState(""),[X,z]=v.useState(!1),[Z,J]=v.useState("operator"),[Q,pe]=v.useState({open:!1,query:"",triggerStart:-1,index:0}),[re,de]=v.useState({open:!1,query:"",triggerStart:-1,index:0}),[fe,xe]=v.useState(null),[Re,he]=v.useState(t==="ask"?"ask":"tell");v.useEffect(()=>{he(M&&t==="ask"?"ask":"tell")},[e,t,M]);const Me=v.useMemo(()=>{const ee=new Set,me=[];for(const ye of i){const Be=ye.handle?.trim().replace(/^@+/,"")??pr(ye.id)??ye.id;if(!Be)continue;const ze=Be.toLowerCase();ee.has(ze)||(ee.add(ze),me.push({id:ye.id,label:Be,name:ye.name??Be,handle:Be}))}return me.sort((ye,Be)=>ye.handle.localeCompare(Be.handle))},[i]),Se=v.useMemo(()=>{if(!Q.open)return[];const ee=Q.query.toLowerCase();return ee?JS.filter(me=>me.command.toLowerCase().startsWith("/"+ee)||me.command.toLowerCase().includes(ee)):JS},[Q.open,Q.query]),Ve=v.useMemo(()=>{if(!re.open)return[];const ee=re.query.toLowerCase();return ee?Me.filter(me=>me.handle.toLowerCase().includes(ee)||me.name.toLowerCase().includes(ee)).slice(0,8):Me.slice(0,8)},[re.open,re.query,Me]),Oe=v.useCallback(()=>{pe(ee=>ee.open?{...ee,open:!1}:ee),de(ee=>ee.open?{...ee,open:!1}:ee)},[]),we=v.useCallback((ee,me)=>{const ye=EH(ee,me);pe(ye?ze=>({open:!0,query:ye.query,triggerStart:ye.start,index:ze.open&&ze.triggerStart===ye.start?ze.index:0}):ze=>ze.open?{...ze,open:!1}:ze);const Be=CH(ee,me);de(Be?ze=>({open:!0,query:Be.query,triggerStart:Be.start,index:ze.open&&ze.triggerStart===Be.start?ze.index:0}):ze=>ze.open?{...ze,open:!1}:ze)},[]),ke=v.useCallback(ee=>{const me=T.current,ye=Q.triggerStart;if(ye<0)return;const Be=me?.selectionStart??B.length,ze=B.slice(0,ye),ut=B.slice(Be),Lt=ee.insert,Ft=`${ze}${Lt}${ut}`;G(Ft),pe(bn=>({...bn,open:!1})),requestAnimationFrame(()=>{const bn=T.current;if(!bn)return;const qt=ze.length+Lt.length;bn.focus(),bn.setSelectionRange(qt,qt)})},[B,Q.triggerStart]),Ye=v.useCallback(ee=>{const me=T.current,ye=re.triggerStart;if(ye<0)return;const Be=me?.selectionStart??B.length,ze=B.slice(0,ye),ut=B.slice(Be),Lt=ut.length===0||!ut.startsWith(" "),Ft=`@${ee.handle}${Lt?" ":""}`,bn=`${ze}${Ft}${ut}`;G(bn),de(qt=>({...qt,open:!1})),requestAnimationFrame(()=>{const qt=T.current;if(!qt)return;const As=ze.length+Ft.length;qt.focus(),qt.setSelectionRange(As,As)})},[B,re.triggerStart]);v.useEffect(()=>{const ee=T.current;if(!ee)return;ee.style.height="0px";const me=Math.min(Math.max(ee.scrollHeight,40),160);ee.style.height=`${me}px`,ee.style.overflowY=ee.scrollHeight>me?"auto":"hidden"},[B]),v.useEffect(()=>{_e("/api/user").then(ee=>J(ee.name)).catch(()=>{})},[]);const Ue=v.useMemo(()=>IH(f,Z),[f,Z]);v.useEffect(()=>{fe===null||Ue===null||Ue>=fe&&xe(null)},[fe,Ue]);const He=v.useMemo(()=>!h||Cg.has(h.state)?!1:(Xn(h.startedAt)??fe??Date.now())>=(Ue??0),[fe,h,Ue]),le=X||fe!==null||He,ge=vH({name:O?.name,agentName:c?.agentName,id:A,title:c?.title}),ve=v.useMemo(()=>zH({agentName:ge,agentState:O?.state??null,sending:X,currentFlight:h,showWorkingTurn:He}),[O?.state,ge,h,X,He]),je=c?AH(c):ge,Ne=c?.kind?kH[c.kind]??c.kind:"Conversation";UH(c);const Je=TH(c?.workspaceRoot),et=c?.lastMessageAt??f[f.length-1]?.createdAt??null,Ge=[Je?{label:Je,title:c?.workspaceRoot??void 0}:null,c?.currentBranch?{label:c.currentBranch,title:c.currentBranch}:null,O?.harness??c?.harness?{label:O?.harness??c?.harness??"",title:void 0}:null].filter(ee=>!!ee),Bt=c?c.participantIds.length:M?2:1,kt=v.useMemo(()=>(!I.has(e)&&!(A&&I.has(A)),null),[e,A,I]);vn(v.useCallback(ee=>{if(ee.kind==="message.posted"){const me=ee.payload?.message;if(!me||me.conversationId!==e)return;const ye=me.actorId===A,Be={id:me.id,conversationId:me.conversationId,actorName:ye?ge:Z,body:me.body,createdAt:me.createdAt,class:ye?me.class:"operator"};if(m(ze=>{if(ze.some(ut=>ut.id===me.id))return ze;if(!ye){const ut=ze.findIndex(Lt=>Lt.id.startsWith("optimistic-")&&Lt.body===me.body&&Math.abs((Xn(Lt.createdAt)??0)-(Xn(me.createdAt)??0))<=6e4);if(ut!==-1){const Lt=[...ze];return Lt[ut]=Be,Wu(Lt)}}return Wu([...ze,Be])}),ye){const ze=Xn(me.createdAt)??Date.now();xe(ut=>ut===null||ze<ut?ut:null),g(ut=>{if(!ut)return ut;const Lt=Xn(ut.startedAt)??0;return ze>=Lt?null:ut})}return}if(ee.kind==="invocation.requested"){const me=ee.payload?.invocation;if(!me||me.targetAgentId!==A||me.conversationId!==e)return;k.current.add(me.id),xe(ye=>ye??Date.now());return}if(ee.kind==="flight.updated"){const me=ee.payload?.flight;if(!me||me.targetAgentId!==A||!(k.current.has(me.invocationId)||C.current?.id===me.id))return;if(Cg.has(me.state)){g(Be=>Be?.id===me.id?null:Be),U();return}k.current.add(me.invocationId),g(ej(me,e,A??""));return}ee.kind!=="agent.endpoint.upserted"&&ee.kind==="unknown"&&U()},[A,ge,e,U,Z])),v.useEffect(()=>{if(!le)return;const ee=setInterval(()=>{U()},5e3);return()=>clearInterval(ee)},[le,U]),v.useEffect(()=>{const ee=()=>{if(document.visibilityState!=="visible")return;const me=Date.now();me-S.current<1e3||(S.current=me,U())};return window.addEventListener("focus",ee),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("focus",ee),document.removeEventListener("visibilitychange",ee)}},[U]);const fn=f.length+(ve.showTyping?1:0),hn=v.useRef(0);v.useEffect(()=>{fn>hn.current&&N.current?.scrollIntoView({behavior:"smooth"}),hn.current=fn},[fn]);const[,on]=v.useState(0);v.useEffect(()=>{const ee=setInterval(()=>on(me=>me+1),15e3);return()=>clearInterval(ee)},[]);const Ie=async(ee,me)=>{const ye=ee.trim();if(!ye||X)return;const Be=me?.forceMode??Re,ze=M?le?"steer":Be:"tell",ut=Date.now(),Lt={id:`optimistic-${ut}`,conversationId:e,actorName:Z,body:ye,createdAt:ut,class:"operator"};z(!0),xe(ut),j(null),m(Ft=>Wu([...Ft,Lt]));try{const Ft=await _e(ze==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:ye,conversationId:e})});Ft.flight&&(k.current.add(Ft.flight.invocationId),g(ej(Ft.flight,e,A??"")))}catch(Ft){m(bn=>bn.filter(qt=>qt.id!==Lt.id)),xe(null),j(Ft instanceof Error?Ft.message:String(Ft))}finally{z(!1)}},tt=async()=>{const ee=B.trim();ee&&(G(""),await Ie(ee))},ct=async()=>{if(A)try{await _e("/api/agents/"+encodeURIComponent(A)+"/interrupt",{method:"POST",body:JSON.stringify({})})}catch{}},xt=ve.tone==="working"||ve.tone==="pending",zt=M?le?"steer":Re:"tell",yn=M?"Reply — or type / to route, @ to mention an agent, ? to ask a question":`Message ${ge}...`,Xt=!B.trim()&&xt,mn=xf(),ln=v.useCallback((ee,me)=>{const ye=window.getSelection()?.toString().trim(),Be=[];ye&&(Be.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(ye)}),Be.push({kind:"separator"})),Be.push({kind:"action",label:"Copy Message",onSelect:()=>navigator.clipboard.writeText(me.body)}),me.actorName&&!Tg(me,Z)&&Be.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(me.actorName??"")}),Be.push({kind:"separator"}),Be.push({kind:"action",label:"Copy Message ID",onSelect:()=>navigator.clipboard.writeText(me.id)}),mn(ee,Be)},[Z,mn]),xn=async(ee,me)=>{const ye=`@${me.agentId} `,Be=B.trim();if(Be){G(""),await Ie(`${ye}${Be}`,{forceMode:"tell"});return}G(ye),T.current?.focus()},Ts=v.useMemo(()=>c?c.participantIds.filter(ee=>ee!=="operator").slice(0,4).map(ee=>{const me=i.find(ye=>ye.id===ee);return{id:ee,name:me?.name??ee}}):[],[c,i]);return o.jsx("div",{className:`s-thread-layout${a?" s-thread-layout--embedded":""}`,children:o.jsxs("div",{className:"s-thread-center",children:[!a&&o.jsxs("div",{className:"s-thread-center-header",onClick:()=>M?n({view:"agent-info",conversationId:e}):void 0,style:M?{cursor:"pointer"}:void 0,onContextMenu:ee=>{const me=[{kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(je)}];A&&me.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(A)}),me.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(e)}),mn(ee,me)},children:[o.jsxs("div",{className:"s-thread-center-header-info",children:[o.jsx("span",{className:"s-thread-center-header-name",children:je}),o.jsxs("div",{className:"s-thread-center-header-eyebrow",children:[o.jsx("span",{className:"s-thread-center-header-kicker",children:Ne}),et&&o.jsx("span",{className:"s-thread-center-header-time",title:Sp(et),children:Pe(et)})]})]}),o.jsxs("div",{className:"s-thread-center-header-right",children:[Ge.length>0&&o.jsx("div",{className:"s-thread-center-header-chips",children:Ge.map((ee,me)=>o.jsx("span",{className:"s-thread-center-chip",title:ee.title,children:ee.label},`${ee.label}-${me}`))}),Ts.length>0&&o.jsxs("div",{className:"s-thread-center-avatars",children:[Ts.map(ee=>o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:dt(ee.name)},title:ee.name,children:ee.name[0]?.toUpperCase()??"?"},ee.id)),o.jsx("span",{className:"s-thread-center-participant-count",children:Bt})]})]})]}),kt&&o.jsxs("div",{className:"s-thread-pinned-ask",children:[o.jsx("div",{className:"s-thread-pinned-ask-label",children:"Pinned ask · Awaiting operator"}),o.jsx("div",{className:"s-thread-pinned-ask-body",children:kt.task}),o.jsxs("div",{className:"s-thread-pinned-ask-routing",children:[o.jsx("span",{children:kt.agentName??pr(kt.agentId)??kt.agentId}),o.jsx("span",{className:"s-thread-pinned-ask-routing-arrow",children:"→"}),o.jsx("span",{children:"You"})]}),o.jsxs("div",{className:"s-thread-pinned-ask-actions",children:[o.jsx("button",{type:"button",className:"s-ops-btn s-ops-btn--primary",onClick:()=>{T.current?.focus()},children:"Answer"}),o.jsx("button",{type:"button",className:"s-ops-btn",children:"Defer"}),o.jsx("button",{type:"button",className:"s-ops-btn",children:"Route"})]}),o.jsx("div",{className:"s-thread-pinned-ask-strip"})]}),ve.showStrip&&o.jsxs("div",{className:`s-thread-status s-thread-status--${ve.tone}`,"aria-live":"polite",children:[o.jsx("span",{className:"s-thread-status-dot",style:{background:LH(ve,O?.state??null)}}),o.jsxs("div",{className:"s-thread-status-copy",children:[o.jsx("span",{className:"s-thread-status-label",children:ve.label}),o.jsx("span",{className:"s-thread-status-detail",children:ve.detail})]})]}),!a&&M&&O&&(O.harnessSessionId||O.harnessLogPath||Y?.activeSessionId)&&o.jsxs("details",{className:"s-thread-meta-disclosure",children:[o.jsx("summary",{className:"s-thread-meta-toggle",children:"Session details"}),o.jsxs("div",{className:"s-thread-meta-block",children:[Y?.activeSessionId&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Session ID"}),o.jsx("span",{className:"s-thread-meta-row-value s-thread-meta-row-value--accent",title:Y.activeSessionId,children:Y.activeSessionId.slice(0,8)})]}),Y?.resumeCommand&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Takeover"}),o.jsx("span",{className:"s-thread-meta-row-value",children:o.jsx("button",{type:"button",className:"s-thread-meta-takeover-btn",title:Y.resumeCommand,onClick:()=>{NH(Y.resumeCommand),P(!0),setTimeout(()=>P(!1),2e3)},children:D?"Sent!":`Takeover — ${Y.resumeCommand}`})})]}),O.harnessSessionId&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Session"}),o.jsx("span",{className:"s-thread-meta-row-value",children:O.harnessSessionId})]}),O.harnessLogPath&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Log"}),o.jsx("span",{className:"s-thread-meta-row-value",children:O.harnessLogPath})]})]})]}),w&&o.jsx("p",{className:"s-thread-error",children:w}),o.jsxs("div",{className:"s-thread-feed",children:[o.jsx("div",{className:"s-thread-feed-spacer"}),f.length===0?o.jsxs("div",{className:"s-thread-empty",children:[o.jsx("p",{children:"No messages yet"}),o.jsx("p",{children:M?"Use Tell for quick coordination or Ask for owned work with a reply.":"Start the thread below."})]}):f.map((ee,me)=>{const ye=Tg(ee,Z),Be=OH(ee),ze=Be?"scout.dispatch":ee.class,ut=MH(ze),Lt=ze==="status",Ft=me===0||!RH(f[me-1]?.createdAt,ee.createdAt),bn=Sp(ee.createdAt),qt=!ye&&ee.actorName?i.find(cn=>cn.name===ee.actorName)??null:null,As=ye?Z.toLowerCase():qt?.handle??null;return o.jsxs("div",{className:["s-thread-feed-block",ye&&"s-thread-feed-block--you",Ft&&"s-thread-feed-block--full-width"].filter(Boolean).join(" "),children:[Ft&&o.jsxs("div",{className:"s-thread-day-divider","aria-label":QS(ee.createdAt),children:[o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"}),o.jsx("span",{className:"s-thread-day-label",children:QS(ee.createdAt)}),o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"})]}),o.jsx("article",{id:`msg-${ee.id}`,className:["s-thread-msg",ye&&"s-thread-msg--you",Lt&&"s-thread-msg--tool"].filter(Boolean).join(" "),"data-class":ze,onContextMenu:cn=>ln(cn,ee),children:o.jsxs("div",{className:"s-thread-msg-card s-thread-msg-card--avatar-row",children:[o.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:dt(ye?Z:ee.actorName??"?")},children:(ye?Z[0]:ee.actorName?.[0]??"?").toUpperCase()}),o.jsxs("div",{className:"s-thread-msg-card-content",children:[o.jsxs("div",{className:"s-thread-msg-header",children:[o.jsxs("div",{className:"s-thread-msg-meta",children:[o.jsx("span",{className:"s-thread-msg-actor",children:ye?Z:ee.actorName}),As&&o.jsxs("span",{className:"s-thread-msg-handle",children:["@",As]}),ut&&o.jsx("span",{className:"s-thread-msg-kind",children:ut})]}),o.jsx("span",{className:"s-thread-msg-time",title:bn,children:Pe(ee.createdAt)}),o.jsx("button",{type:"button",className:"s-thread-msg-permalink","aria-label":"Copy link to message",title:"Copy link to message",onClick:()=>{const cn=`${window.location.origin}${window.location.pathname}#msg-${ee.id}`;navigator.clipboard.writeText(cn)},children:o.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:[o.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"}),o.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"})]})})]}),o.jsx("div",{className:"s-thread-msg-body",title:bn,children:ls(ee.body)}),Be&&Be.candidates.length>0&&o.jsx("div",{className:"s-thread-dispatch",children:Be.candidates.map(cn=>o.jsxs("button",{type:"button",className:"s-thread-dispatch-tile",onClick:()=>{xn(Be,cn)},children:[o.jsxs("span",{className:"s-thread-dispatch-tile-id",children:["@",cn.agentId]}),o.jsx("span",{className:"s-thread-dispatch-tile-state",children:cn.endpointState}),o.jsx("span",{className:"s-thread-dispatch-tile-meta",children:[cn.workspace,cn.node,cn.projectRoot].filter(Boolean).join(" · ")||cn.displayName})]},cn.agentId))})]})]})})]},ee.id)}),ve.showTyping&&o.jsx("div",{className:"s-thread-feed-block",children:o.jsx("div",{className:"s-thread-msg","aria-live":"polite",children:o.jsxs("div",{className:"s-thread-msg-card s-thread-msg-working-card s-thread-msg-card--avatar-row",children:[o.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:dt(ge)},children:ge[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-thread-msg-card-content",children:[o.jsxs("div",{className:"s-thread-msg-header",children:[o.jsxs("div",{className:"s-thread-msg-meta",children:[o.jsx("span",{className:"s-thread-msg-actor",children:ge}),o.jsx("span",{className:"s-thread-msg-kind",children:"Live"})]}),o.jsx("span",{className:"s-thread-msg-time",title:h?.startedAt?Sp(h.startedAt):"now",children:h?.startedAt?Pe(h.startedAt):"now"})]}),o.jsxs("div",{className:"s-thread-msg-working-body",children:[o.jsxs("span",{className:"s-thread-typing-indicator","aria-hidden":"true",children:[o.jsx("span",{className:"s-thread-typing-dot"}),o.jsx("span",{className:"s-thread-typing-dot"}),o.jsx("span",{className:"s-thread-typing-dot"})]}),o.jsx("span",{className:"s-thread-msg-working-copy",children:ve.detail})]})]})]})})}),o.jsx("div",{ref:N})]}),ve.showTyping&&o.jsxs("div",{className:"s-thread-presence-line",children:[o.jsx("div",{className:"s-thread-presence-line-avatars",children:o.jsx("div",{className:"s-ops-avatar",style:{"--size":"20px",background:dt(ge)},children:ge[0]?.toUpperCase()??"?"})}),o.jsxs("span",{className:"s-thread-presence-line-label",children:[ge," is ",ve.label.toLowerCase(),"..."]}),o.jsx("div",{className:"s-thread-presence-strip"})]}),o.jsx("form",{className:"s-thread-compose",onSubmit:ee=>{ee.preventDefault(),tt()},children:o.jsxs("div",{className:"s-thread-compose-shell",children:[Q.open&&Se.length>0&&o.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Slash commands",children:[o.jsx("div",{className:"s-thread-compose-suggest-label",children:"Slash commands"}),Se.map((ee,me)=>o.jsxs("button",{type:"button",role:"option","aria-selected":me===Q.index,className:["s-thread-compose-suggest-item",me===Q.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:ye=>{ye.preventDefault(),ke(ee)},onMouseEnter:()=>pe(ye=>({...ye,index:me})),children:[o.jsx("span",{className:"s-thread-compose-suggest-cmd",children:ee.label}),o.jsx("span",{className:"s-thread-compose-suggest-desc",children:ee.description})]},ee.command))]}),re.open&&Ve.length>0&&o.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Mention agents",children:[o.jsx("div",{className:"s-thread-compose-suggest-label",children:"Mention agent"}),Ve.map((ee,me)=>o.jsxs("button",{type:"button",role:"option","aria-selected":me===re.index,className:["s-thread-compose-suggest-item",me===re.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:ye=>{ye.preventDefault(),Ye(ee)},onMouseEnter:()=>de(ye=>({...ye,index:me})),children:[o.jsx("span",{className:"s-ops-avatar s-thread-compose-suggest-avatar",style:{"--size":"20px",background:dt(ee.name)},children:ee.name[0]?.toUpperCase()??"?"}),o.jsxs("span",{className:"s-thread-compose-suggest-cmd",children:["@",ee.handle]}),o.jsx("span",{className:"s-thread-compose-suggest-desc",children:ee.name})]},ee.id))]}),o.jsxs("div",{className:"s-thread-compose-row",children:[o.jsx("textarea",{ref:T,className:"s-thread-compose-input",placeholder:yn,value:B,onChange:ee=>{const me=ee.target.value;G(me),we(me,ee.target.selectionStart)},onSelect:ee=>{const me=ee.currentTarget;we(me.value,me.selectionStart)},onBlur:()=>{setTimeout(Oe,120)},onKeyDown:ee=>{if(Q.open&&Se.length>0||re.open&&Ve.length>0){if(ee.key==="ArrowDown"){ee.preventDefault(),Q.open?pe(ye=>({...ye,index:(ye.index+1)%Se.length})):re.open&&de(ye=>({...ye,index:(ye.index+1)%Ve.length}));return}if(ee.key==="ArrowUp"){ee.preventDefault(),Q.open?pe(ye=>({...ye,index:(ye.index-1+Se.length)%Se.length})):re.open&&de(ye=>({...ye,index:(ye.index-1+Ve.length)%Ve.length}));return}if(ee.key==="Escape"){ee.preventDefault(),Oe();return}if(ee.key==="Enter"||ee.key==="Tab"){if(ee.shiftKey)return;if(ee.preventDefault(),Q.open){const ye=Se[Q.index]??Se[0];ye&&ke(ye)}else if(re.open){const ye=Ve[re.index]??Ve[0];ye&&Ye(ye)}return}}ee.key!=="Enter"||ee.shiftKey||ee.nativeEvent.isComposing||(ee.preventDefault(),!X&&B.trim()&&tt())},rows:1}),Xt?o.jsx("button",{type:"button",className:"s-thread-compose-send s-thread-compose-send--stop",onClick:()=>{ct()},"aria-label":"Stop agent",children:o.jsx(PH,{})}):o.jsx("button",{type:"submit",className:"s-thread-compose-send",disabled:X||!B.trim(),"aria-label":zt==="ask"?"Ask agent":zt==="steer"?"Steer agent":M?"Tell agent":"Send message",children:o.jsx($H,{})})]})]})})]})})}async function BH(e){await fetch("/api/terminal/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})}),window.dispatchEvent(new CustomEvent("scout:open-terminal"))}const xT={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},VH={read:"◎",edit:"✎",bash:"$",grep:"⌕",write:"✎",think:"∿"},HH=20;function ZH(e){const t=Math.floor(e/60),n=Math.floor(e%60);return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function tj(e,t){return e>=Math.max(0,t-HH)}function FH({event:e}){return o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-think-label",children:"thinking"}),o.jsxs("div",{className:"s-observe-think-text",children:["“",e.text,"”",e.live&&o.jsx("span",{className:"s-observe-cursor"})]})]})}function qH({event:e}){const t=VH[e.tool??""]??"▸",n=!!(e.result||e.diff||e.stream);return o.jsxs("div",{className:"s-observe-tool",children:[o.jsxs("div",{className:`s-observe-tool-header${n?" s-observe-tool-header--has-body":""}`,children:[o.jsx("span",{className:"s-observe-tool-glyph",children:t}),o.jsxs("span",{className:"s-observe-tool-cmd",children:[o.jsx("span",{className:"s-observe-tool-cmd-name",children:e.tool})," ",e.arg]})]}),e.result&&o.jsx("div",{className:"s-observe-tool-result",children:Object.entries(e.result).map(([a,i])=>`${a}: ${i}`).join(" · ")}),e.diff&&o.jsxs("div",{className:"s-observe-tool-diff",children:[o.jsxs("div",{className:"s-observe-tool-diff-stats",children:[o.jsxs("span",{className:"s-observe-tool-diff-add",children:["+",e.diff.add]}),e.diff.del>0&&o.jsxs(o.Fragment,{children:[" ",o.jsxs("span",{className:"s-observe-tool-diff-del",children:["−",e.diff.del]})]})]}),o.jsx("pre",{className:"s-observe-tool-diff-preview",children:e.diff.preview})]}),e.stream&&o.jsx("pre",{className:"s-observe-tool-stream",children:e.stream.join(`
|
|
140
|
-
`)})]})}function YH({event:e}){const t=e.to==="human"?"you":e.to??"?";return o.jsxs("div",{className:"s-observe-ask",children:[o.jsxs("div",{className:"s-observe-ask-label",children:["↗ ask → ",t]}),o.jsxs("div",{className:"s-observe-ask-text",children:["“",e.text,"”"]}),e.answer&&o.jsxs("div",{className:"s-observe-ask-answer",children:[o.jsxs("span",{className:"s-observe-ask-answer-meta",children:["↳ @",e.to??"you"," · +",(e.answerT??e.t)-e.t,"s"]}),o.jsx("div",{className:"s-observe-ask-answer-text",children:e.answer})]})]})}function GH({event:e}){const t=e.to==="human"?"you":e.to??"?";return o.jsxs("div",{children:[o.jsxs("div",{className:"s-observe-message-label",children:["→ message → ",t]}),o.jsx("div",{className:"s-observe-message-text",children:e.text})]})}function WH({event:e}){return o.jsxs("div",{className:"s-observe-note",children:[o.jsx("span",{className:"s-observe-note-icon",children:"✓"}),o.jsx("span",{className:"s-observe-note-text",children:e.text})]})}function XH({event:e}){return o.jsxs("div",{className:"s-observe-system",children:[o.jsx("span",{className:"s-observe-system-arrow",children:"▸ "}),e.text,e.detail&&o.jsx("div",{className:"s-observe-system-detail",children:e.detail})]})}function KH(){return o.jsxs("div",{className:"s-observe-live",children:[o.jsx("span",{className:"s-observe-live-dot"}),o.jsx("span",{className:"s-observe-live-label",children:"LIVE · tailing session"})]})}function JH({liveSession:e,isLive:t}){const n=e?t?"live":"paused":"replay",a=e?t?"LIVE · tail mode on":"LIVE · tail paused":"REPLAY · saved trace";return o.jsxs("div",{className:`s-observe-tail-state s-observe-tail-state--${n}`,children:[o.jsx("span",{className:"s-observe-tail-state-dot"}),o.jsx("span",{className:"s-observe-tail-state-label",children:a})]})}function QH({event:e,prevT:t}){const n=e.t-t,a=xT[e.kind]??"var(--dim)";return o.jsxs("div",{className:"s-observe-row",children:[n>15&&o.jsxs("div",{className:"s-observe-row-gap",children:["+",n,"s"]}),o.jsx("div",{className:"s-observe-row-time",children:ZH(e.t)}),o.jsx("span",{className:"s-observe-row-bead",style:{background:a}}),e.kind==="think"&&o.jsx(FH,{event:e}),e.kind==="tool"&&o.jsx(qH,{event:e}),e.kind==="ask"&&o.jsx(YH,{event:e}),e.kind==="message"&&o.jsx(GH,{event:e}),e.kind==="note"&&o.jsx(WH,{event:e}),(e.kind==="system"||e.kind==="boot")&&o.jsx(XH,{event:e})]})}function e7({events:e,isLive:t}){const n=v.useRef(null);return v.useEffect(()=>{t&&n.current?.scrollIntoView({behavior:"smooth"})},[e.length,t]),o.jsxs("div",{className:"s-observe-stream",children:[o.jsx("div",{className:"s-observe-spine"}),e.map((a,i)=>o.jsx(QH,{event:a,prevT:i>0?e[i-1].t:0},a.id)),o.jsx("div",{ref:n})]})}function t7({data:e,cursor:t}){const i=e.length;if(i<2)return null;const c=276/(i-1),u=e.map((m,h)=>`${h===0?"M":"L"} ${(h*c).toFixed(1)} ${((1-m)*44).toFixed(1)}`).join(" "),f=t*276;return o.jsxs("svg",{viewBox:"0 0 276 44",style:{width:"100%",height:44,display:"block"},children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"observeCtxFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:.25}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:0})]})}),o.jsx("path",{d:`${u} L 276 44 L 0 44 Z`,fill:"url(#observeCtxFill)"}),o.jsx("path",{d:u,fill:"none",stroke:"var(--accent)",strokeWidth:1.2}),o.jsx("line",{x1:f,y1:0,x2:f,y2:44,stroke:"var(--accent)",strokeWidth:1,opacity:.6,strokeDasharray:"2 3"})]})}function n7({state:e}){const t=e==="created"?"var(--green)":e==="modified"?"var(--accent)":"var(--dim)",n=e==="created"?"+":e==="modified"?"~":"◎";return o.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 s7({events:e,duration:t,cursor:n,onCursor:a}){const i=v.useRef(null),c=v.useCallback(u=>{const f=i.current.getBoundingClientRect(),m=u.clientX-f.left;a(Math.max(0,Math.min(t,m/f.width*t)))},[t,a]);return o.jsx("div",{className:"s-observe-track-wrap",children:o.jsxs("div",{ref:i,className:"s-observe-track",onClick:c,children:[e.map(u=>{const f=u.kind==="tool"?6:u.kind==="think"?4:5;return o.jsx("span",{className:"s-observe-track-tick",style:{left:`${u.t/t*100}%`,top:f===6?-2:-1,height:f,background:xT[u.kind]??"var(--dim)"}},u.id)}),o.jsx("div",{className:"s-observe-track-played",style:{width:`${n/t*100}%`}}),o.jsx("span",{className:"s-observe-track-cursor",style:{left:`${n/t*100}%`}})]})})}function nj(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 a7(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 r7({catalog:e,sessionId:t}){const[n,a]=v.useState(!1),i=e.sessions.find(h=>h.id===e.activeSessionId),c=e.sessions.filter(h=>h.id!==e.activeSessionId&&h.endedAt).sort((h,g)=>(g.endedAt??0)-(h.endedAt??0)).slice(0,5),u=e.activeSessionId??t,f=u?u.slice(0,8):null,m=v.useCallback(()=>{e.resumeCommand&&(BH(e.resumeCommand),a(!0),setTimeout(()=>a(!1),2e3))},[e.resumeCommand]);return o.jsxs("div",{className:"s-observe-session-header",children:[o.jsx("div",{className:"s-observe-session-active",children:o.jsxs("div",{className:"s-observe-session-row",children:[f&&o.jsx("span",{className:"s-observe-session-id",title:u??void 0,children:f}),i&&o.jsxs("span",{className:"s-observe-session-time",children:["started ",nj(i.startedAt)]}),e.resumeCommand&&o.jsx("button",{className:"s-observe-takeover-btn",onClick:m,title:e.resumeCommand,children:n?"Sent":"Takeover"})]})}),c.length>0&&o.jsxs("div",{className:"s-observe-session-history",children:[o.jsxs("div",{className:"s-observe-session-history-label",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," total"]}),c.map(h=>o.jsxs("div",{className:"s-observe-session-past",children:[o.jsx("span",{className:"s-observe-session-id",children:h.id.slice(0,8)}),o.jsxs("span",{className:"s-observe-session-time",children:[nj(h.startedAt),h.endedAt?` · ${a7(h.startedAt,h.endedAt)}`:""]})]},h.id))]})]})}const i7={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 bT({data:e,agentId:t,sessionId:n}){const a=e??i7,{events:i,files:c,contextUsage:u}=a,f=a.live===!0,[m,h]=v.useState(null);v.useEffect(()=>{if(!t)return;let F=!1;return _e(`/api/agents/${encodeURIComponent(t)}/session-catalog`).then(I=>{F||h(I)}).catch(()=>{}),()=>{F=!0}},[t]);const g=i.length>0?i[i.length-1].t+30:60,[x,b]=v.useState(g),[w,j]=v.useState(!1),[N,T]=v.useState(1),k=v.useRef(g);v.useEffect(()=>{b(F=>{const I=k.current;k.current=g;const $=tj(F,I);return F>g||$?g:F})},[g]),v.useEffect(()=>{if(!w)return;const F=setInterval(()=>{b(I=>{const $=I+N;return $>=g?(j(!1),g):$})},100);return()=>clearInterval(F)},[w,g,N]);const C=i.filter(F=>F.t<=x),S=f&&tj(x,g),R=f?S?"Following live":"Jump to live ↦":"Jump to end ↦",A=i.filter(F=>F.kind==="tool").length,M=i.filter(F=>F.kind==="think").length,O=i.filter(F=>F.kind==="ask").length,V=i.filter(F=>F.kind==="tool"&&F.tool==="edit").length;return o.jsxs("div",{className:"s-observe",children:[o.jsxs("main",{className:"s-observe-main",children:[S&&o.jsx("div",{className:"s-observe-live-sticky",children:o.jsx(KH,{})}),o.jsx(e7,{events:C,isLive:S})]}),o.jsxs("aside",{className:"s-observe-rail",children:[m&&m.sessions.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Session"}),o.jsx(r7,{catalog:m,sessionId:n??null})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Context window"}),u&&u.length>=2?o.jsxs(o.Fragment,{children:[o.jsx(t7,{data:u,cursor:x/g}),o.jsxs("div",{className:"s-observe-ctx-detail",children:[Math.round((u[u.length-1]??0)*100),"% ·"," ","derived session load"]})]}):o.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-observe-rail-label",children:["Files touched · ",c.length]}),o.jsx("div",{className:"s-observe-files",children:c.map(F=>o.jsxs("div",{className:`s-observe-file${F.lastT<=x?" s-observe-file--visible":" s-observe-file--hidden"}`,children:[o.jsx(n7,{state:F.state}),o.jsx("span",{className:"s-observe-file-path",children:F.path}),o.jsxs("span",{className:"s-observe-file-touches",children:["×",F.touches]})]},F.path))})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Session stats"}),o.jsxs("div",{className:"s-observe-stats",children:[o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Tools"}),o.jsx("div",{className:"s-observe-stat-value",children:A})]}),o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Thinks"}),o.jsx("div",{className:"s-observe-stat-value",children:M})]}),o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Asks"}),o.jsx("div",{className:"s-observe-stat-value",children:O})]}),o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Edits"}),o.jsx("div",{className:"s-observe-stat-value",children:V})]})]})]})]}),o.jsxs("footer",{className:"s-observe-scrubber",children:[o.jsx("button",{className:"s-observe-play-btn",onClick:()=>j(!w),children:w?"❚❚":"▶"}),o.jsx("button",{className:"s-observe-rewind-btn",onClick:()=>{b(0),j(!1)},children:"⏮"}),o.jsx(s7,{events:i,duration:g,cursor:x,onCursor:b}),o.jsx("div",{className:"s-observe-speed-group",children:[.5,1,2,4].map(F=>o.jsxs("button",{className:`s-observe-speed-btn${N===F?" s-observe-speed-btn--active":""}`,onClick:()=>T(F),children:[F,"×"]},F))}),o.jsx(JH,{liveSession:f,isLive:S}),o.jsx("button",{className:`s-observe-jump-btn${S?" s-observe-jump-btn--active":""}`,onClick:()=>b(g),children:R})]})]})}async function o7(e){await fetch("/api/terminal/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})}),window.dispatchEvent(new CustomEvent("scout:open-terminal"))}function l7(e,t){if(t.filter(i=>i.name===e.name).length<=1)return{name:e.name,qualifier:null};const a=e.project??e.branch??e.id.replace(/^.*\./,"");return{name:e.name,qualifier:a}}function sj(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function c7(e){const t=[...e].filter(i=>i.kind==="direct"&&!!i.agentId).sort((i,c)=>(c.lastMessageAt??0)-(i.lastMessageAt??0)),n=new Map,a=new Map;for(const i of t)n.has(i.agentId)||(n.set(i.agentId,i.id),a.set(i.agentId,i));return{conversationByAgentId:n,sessionByAgentId:a}}function u7({catalog:e}){const[t,n]=v.useState(!1),a=e.activeSessionId?.slice(0,8)??null,i=e.sessions.find(u=>u.id===e.activeSessionId),c=()=>{e.resumeCommand&&(o7(e.resumeCommand),n(!0),setTimeout(()=>n(!1),2e3))};return o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Session"}),o.jsxs("div",{className:"s-profile-facet-value s-profile-facet-value--mono",title:e.activeSessionId??void 0,children:[a,e.resumeCommand&&o.jsx("button",{type:"button",className:"s-profile-facet-action",onClick:c,title:e.resumeCommand,children:t?"Sent":"Takeover"})]}),i&&o.jsxs("div",{className:"s-profile-facet-detail",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," · started ",Pe(i.startedAt)]})]})}function d7({agent:e,fleet:t,navigate:n}){const a=v.useMemo(()=>t?t.activity.filter(c=>c.agentId===e.id||c.actorId===e.id).slice(0,6):[],[t,e.id]),i=v.useMemo(()=>t?t.recentCompleted.filter(c=>c.agentId===e.id).slice(0,4):[],[t,e.id]);return a.length===0&&i.length===0?o.jsxs("div",{className:"s-profile-activity-empty",children:[o.jsx("div",{className:"s-profile-activity-empty-title",children:"Quiet for now"}),o.jsx("div",{className:"s-profile-activity-empty-detail",children:"Activity will appear here as this agent works, receives asks, and completes tasks."})]}):o.jsxs("div",{className:"s-profile-activity-feed",children:[i.map(c=>o.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{c.conversationId&&n({view:"agents",agentId:e.id,conversationId:c.conversationId})},children:[o.jsx("div",{className:"s-profile-activity-dot s-profile-activity-dot--done"}),o.jsxs("div",{className:"s-profile-activity-body",children:[o.jsx("div",{className:"s-profile-activity-title",children:c.summary??c.task}),o.jsxs("div",{className:"s-profile-activity-meta",children:[c.status==="completed"?"completed":c.status,c.completedAt&&` · ${Pe(c.completedAt)}`]})]})]},c.invocationId)),a.map(c=>o.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{c.conversationId&&n({view:"agents",agentId:e.id,conversationId:c.conversationId})},children:[o.jsx("div",{className:"s-profile-activity-dot"}),o.jsxs("div",{className:"s-profile-activity-body",children:[o.jsx("div",{className:"s-profile-activity-title",children:c.title??c.summary??c.kind}),o.jsxs("div",{className:"s-profile-activity-meta",children:[c.kind.replace(/_/g," "),c.actorName&&` · ${c.actorName}`,` · ${Pe(c.ts)}`]})]})]},c.id))]})}function zl({label:e,right:t,rightClassName:n}){return o.jsxs("div",{className:"s-profile-section-rule",children:[o.jsx("span",{className:"s-profile-section-rule-label",children:e}),o.jsx("span",{className:"s-profile-section-rule-line"}),t&&o.jsx("span",{className:`s-profile-section-rule-right${n?` ${n}`:""}`,children:t})]})}function f7({messages:e,navigate:t,conversationId:n,agentId:a}){const i=e.slice(-8).reverse();return i.length===0?null:o.jsxs("div",{className:"s-profile-signals",children:[o.jsx(zl,{label:"Recent signal",right:"last 1h"}),o.jsx("div",{className:"s-profile-signal-list",children:i.map(c=>{const f=c.class==="ask"||c.body?.toLowerCase().startsWith("@")?"ASK":"MESSAGE";return o.jsxs("div",{className:"s-profile-signal",onClick:()=>{n&&t({view:"agents",agentId:a,conversationId:n})},children:[o.jsx("div",{className:"s-profile-signal-avatar",style:{background:dt(c.actorName??"?")},children:(c.actorName??"?")[0].toUpperCase()}),o.jsxs("div",{className:"s-profile-signal-body",children:[o.jsxs("div",{className:"s-profile-signal-header",children:[o.jsx("span",{className:"s-profile-signal-kind",children:f}),o.jsx("span",{className:"s-profile-signal-sep",children:"·"}),o.jsx("span",{className:"s-profile-signal-routing",children:c.actorName}),o.jsx("span",{className:"s-profile-signal-time",children:Pe(c.createdAt)})]}),o.jsx("div",{className:"s-profile-signal-text",children:c.body})]})]},c.id)})})]})}function h7({agent:e,allAgents:t,session:n,conversationId:a,navigate:i,activeTab:c}){const{name:u,qualifier:f}=l7(e,t),[m,h]=v.useState([]),[g,x]=v.useState([]),[b,w]=v.useState(null),[j,N]=v.useState(null),[T,k]=v.useState(!1),[C,S]=v.useState(null),R=mt(e.state),A=xf(),M=v.useCallback(async()=>{const[G,X]=await Promise.allSettled([_e(`/api/work?agentId=${encodeURIComponent(e.id)}`),_e("/api/fleet")]);G.status==="fulfilled"&&h(G.value),X.status==="fulfilled"&&w(X.value)},[e.id]),O=v.useCallback(async()=>{if(!a){x([]);return}try{const G=await _e(`/api/messages?conversationId=${encodeURIComponent(a)}&limit=20`);x(G)}catch{x([])}},[a]),V=v.useCallback(async()=>{k(!0);try{const G=await _e(`/api/agents/${encodeURIComponent(e.id)}/observe`);N(G)}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{k(!1)}},[e.id]);v.useEffect(()=>{M(),O(),_e(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(S).catch(()=>{})},[M,O,e.id]),v.useEffect(()=>{N(null),k(!1)},[e.id]),v.useEffect(()=>{c==="observe"&&V()},[c,V]),vn(()=>{M(),O(),c==="observe"&&V()}),v.useEffect(()=>{if(c!=="observe"||!j?.data.live)return;const G=setInterval(()=>{V()},2500);return()=>clearInterval(G)},[c,j?.data.live,V]);const F=m.find(G=>G.state==="working"||G.state==="review"),I=m.filter(G=>G.state==="working"||G.state==="review"||G.state==="waiting"),$=m.filter(G=>G.state==="done").slice(0,5),L=sj(e.role)??sj(e.agentClass),U=e.harness,Y=[L,U].filter(Boolean).filter((G,X,z)=>z.indexOf(G)===X),K=v.useMemo(()=>t.filter(G=>G.project===e.project).length,[t,e.project]),D=F?.currentPhase==="review"?85:F?.currentPhase==="working"?50:20,P=[{key:"profile",label:"Profile"},{key:"observe",label:"Observe"},{key:"message",label:"Message",disabled:!a}],B=G=>{i({view:"agents",agentId:e.id,...a?{conversationId:a}:{},tab:G})};return o.jsxs("div",{className:`s-profile-center${c!=="profile"?" s-profile-center--tabbed":""}`,children:[o.jsx("button",{type:"button",className:"s-back s-profile-mobile-back",onClick:()=>i({view:"agents"}),children:"← All agents"}),o.jsx("section",{className:"s-profile-identity",onContextMenu:G=>{const X=window.getSelection()?.toString().trim(),z=[];X&&(z.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(X)}),z.push({kind:"separator"})),z.push({kind:"action",label:"Copy Agent Name",onSelect:()=>navigator.clipboard.writeText(u)}),z.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(e.id)}),e.handle&&z.push({kind:"action",label:`Copy @${e.handle}`,onSelect:()=>navigator.clipboard.writeText(`@${e.handle}`)}),A(G,z)},children:o.jsxs("div",{className:"s-profile-identity-top",children:[o.jsxs("div",{className:"s-profile-identity-avatar-wrap",children:[o.jsx("div",{className:"s-profile-identity-avatar",style:{background:dt(e.name)},children:e.name[0].toUpperCase()}),o.jsx("span",{className:`s-profile-identity-pulse s-profile-identity-pulse--${R}`,style:{background:Aa(e.state)}})]}),o.jsxs("div",{className:"s-profile-identity-copy",children:[Y.length>0&&o.jsx("div",{className:"s-profile-identity-eyebrow",children:Y.join(" · ")}),o.jsxs("h1",{className:"s-profile-identity-name",children:[u,f&&o.jsx("span",{className:"s-profile-identity-name-qualifier",children:f}),e.handle&&o.jsxs("span",{className:"s-profile-identity-name-handle",children:["@",e.handle]})]}),o.jsx("div",{className:"s-profile-identity-state-row",children:o.jsxs("span",{className:"s-profile-identity-state",children:[o.jsx("span",{className:`s-profile-identity-state-dot${R==="working"?" s-profile-identity-state-dot--pulse":""}`,style:{background:Aa(e.state)}}),o.jsx("span",{className:"s-profile-identity-state-label",children:aa(e.state)}),e.updatedAt&&o.jsxs("span",{className:"s-profile-identity-state-detail",children:["— ",Pe(e.updatedAt)]})]})})]}),o.jsx("nav",{className:"s-profile-tabs",children:P.map(G=>o.jsx("button",{type:"button",className:`s-profile-tab${c===G.key?" s-profile-tab--active":""}`,disabled:G.disabled,onClick:()=>B(G.key),children:G.label},G.key))})]})}),c==="profile"&&o.jsxs("div",{className:"s-profile-tab-content",children:[(e.project||e.branch||e.cwd||C?.activeSessionId)&&o.jsxs("div",{className:"s-profile-facets",children:[e.project&&o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Workspace"}),o.jsx("div",{className:"s-profile-facet-value",children:e.project}),K>1&&o.jsxs("div",{className:"s-profile-facet-detail",children:[K," teammates"]})]}),(e.branch||e.projectRoot)&&o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Repo / Branch"}),o.jsx("div",{className:"s-profile-facet-value",children:e.projectRoot?e.projectRoot.split("/").pop():e.project??"—"}),e.branch&&o.jsxs("div",{className:"s-profile-facet-detail",children:[o.jsx("span",{className:"s-profile-facet-accent",children:"⎇"})," ",e.branch]})]}),e.cwd&&o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Working Dir"}),o.jsx("div",{className:"s-profile-facet-value",children:e.cwd.startsWith("/Users/")?"~/"+e.cwd.split("/").slice(3).join("/"):e.cwd}),e.updatedAt&&o.jsxs("div",{className:"s-profile-facet-detail",children:["uptime ",Pe(e.updatedAt)]})]}),C?.activeSessionId&&o.jsx(u7,{catalog:C})]}),F&&R==="working"&&o.jsxs(o.Fragment,{children:[o.jsx(zl,{label:"Current task",right:`${D}% · live`}),o.jsxs("div",{className:"s-profile-task",children:[o.jsx("div",{className:"s-profile-task-title",children:F.title}),F.lastMeaningfulSummary&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-profile-task-progress",children:o.jsx("div",{className:"s-profile-task-progress-bar",style:{width:`${D}%`}})}),o.jsxs("div",{className:"s-profile-task-action",children:[o.jsx("span",{className:"s-profile-task-action-chevron",children:"›"}),o.jsx("span",{children:F.lastMeaningfulSummary}),o.jsx("span",{className:"s-profile-task-cursor"})]})]}),o.jsxs("div",{className:"s-profile-task-meta",children:[o.jsx("span",{children:F.currentPhase}),o.jsx("span",{children:Pe(F.lastMeaningfulAt)})]})]})]}),I.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(zl,{label:"Active work",right:`${I.length} in flight`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(KS,{items:I,navigate:i,emptyTitle:"Nothing in flight"})})]}),$.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(zl,{label:I.length>0?"Recently completed":"Recent work",right:`${$.length}`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(KS,{items:$,navigate:i,emptyTitle:""})})]}),o.jsx(zl,{label:"Activity"}),o.jsx("div",{className:"s-profile-work",children:o.jsx(d7,{agent:e,fleet:b,navigate:i})}),o.jsx(f7,{messages:g,navigate:i,conversationId:a,agentId:e.id})]}),c==="observe"&&o.jsx("div",{className:"s-profile-tab-conversation",children:T&&!j?o.jsxs("div",{className:"s-profile-activity-empty",children:[o.jsx("div",{className:"s-profile-activity-empty-title",children:"Loading trace"}),o.jsx("div",{className:"s-profile-activity-empty-detail",children:"Resolving the best available live or history-backed session stream for this agent."})]}):o.jsx(bT,{data:j?.data,agentId:e.id,sessionId:j?.sessionId})}),c==="message"&&a&&o.jsx("div",{className:"s-profile-tab-conversation",children:o.jsx(Ag,{conversationId:a,navigate:i,embedded:!0})})]})}function m7({navigate:e,selectedAgentId:t,conversationId:n,tab:a}){const{agents:i}=Ut(),[c,u]=v.useState([]),f=v.useCallback(async()=>{const x=await _e("/api/sessions").catch(()=>null);x&&u(x)},[]);v.useEffect(()=>{f()},[f]),vn(f);const m=t?i.find(x=>x.id===t)??null:null,{conversationByAgentId:h,sessionByAgentId:g}=c7(c);if(m){const x=n??h.get(m.id)??m.conversationId??null,b=a??(n?"message":"profile");return o.jsx(h7,{agent:m,allAgents:i,session:g.get(m.id)??null,conversationId:x,navigate:e,activeTab:b})}return o.jsx("div",{className:"s-profile-center",style:{height:"100%"},children:o.jsxs("div",{className:"s-profile-empty",children:[o.jsx("h2",{className:"s-profile-empty-title",children:"Select an agent"}),o.jsx("p",{className:"s-profile-empty-copy",children:"Pick an agent from the sidebar to view its profile, current work, and session context."})]})})}function p7(e){switch(e){case"queued":case"working":return"working";case"needs_attention":return"updated";case"failed":return"failed";default:return"completed"}}function g7(e){switch(e){case"completed":return"completed";case"failed":case"cancelled":return"failed";case"waiting":return"updated";default:return"working"}}function v7(e){return e.replace(/[_-]/g," ")}function y7(e,t){return e.summary?.trim()||t?.summary?.trim()||t?.task?.trim()||"No flight summary yet."}function x7(e,t){if(typeof e!="number")return"duration unknown";const n=e<1e12?e*1e3:e,a=Math.max(0,t-n),i=Math.floor(a/1e3);if(i<5)return"just started";if(i<60)return`${i}s`;const c=Math.floor(i/60);if(c<60)return`${c}m`;const u=Math.floor(c/60);return u<24?`${u}h ${c%60}m`:`${Math.floor(u/24)}d ${u%24}h`}function b7(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId}}function w7(e){return e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId}}function S7(e){return 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}function j7(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 Al({title:e,detail:t}){return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-dashboard-panel-header",children:o.jsx("div",{children:o.jsx("h3",{children:e})})}),o.jsx("p",{className:"s-dashboard-panel-copy",children:t})]})}function aj({ask:e,navigate:t,section:n}){const a=b7(e),i=e.completedAt?`finished ${Pe(e.completedAt)}`:e.startedAt?`started ${Pe(e.startedAt)}`:`updated ${Pe(e.updatedAt)}`;return o.jsxs("div",{className:`s-work-row s-work-row-clickable s-dashboard-fleet-row s-dashboard-fleet-row-${n}`,"data-status":e.status,onClick:()=>t(a),children:[o.jsxs("div",{className:"s-work-row-header",children:[o.jsxs("div",{className:"s-fleet-row-title-wrap",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:dt(e.agentName??e.agentId)},children:(e.agentName??e.agentId)[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-fleet-row-title-copy",children:[o.jsxs("div",{className:"s-work-row-title-wrap",children:[o.jsx("span",{className:"s-work-row-title",children:e.agentName??e.agentId}),e.harness&&o.jsx("span",{className:"s-badge",children:e.harness})]}),o.jsxs("div",{className:"s-work-row-meta",style:{marginTop:2},children:[o.jsx("span",{className:"s-dot",style:{background:Aa(e.agentState)}}),o.jsx("span",{children:aa(e.agentState)}),o.jsx("span",{children:i})]})]})]}),o.jsx("span",{className:`s-pill s-pill-${p7(e.status)}`,children:e.statusLabel})]}),o.jsx("p",{className:"s-work-row-summary",children:ls(e.task)}),e.summary&&o.jsx("p",{className:"s-work-row-summary",style:{marginTop:8},children:ls(e.summary)})]})}function N7({item:e,navigate:t}){const n=S7(e),a=e.kind==="question"?"question":e.state.replace(/_/g," "),i=e.acceptanceState!=="none"?e.acceptanceState.replace(/_/g," "):e.kind==="question"?"awaiting answer":"your move";return o.jsxs("div",{className:`s-work-row s-dashboard-fleet-row s-dashboard-fleet-attention-row${n?" s-work-row-clickable":""}`,onClick:n?()=>t(n):void 0,children:[o.jsx("div",{className:"s-work-row-header",children:o.jsx("div",{className:"s-work-row-title-wrap",children:o.jsx("span",{className:"s-work-row-title",children:e.title})})}),o.jsxs("div",{className:"s-work-row-meta",children:[e.kind==="work_item"&&o.jsx("span",{children:"work item"}),e.agentName&&o.jsx("span",{children:e.agentName}),o.jsx("span",{children:a}),o.jsx("span",{children:i}),o.jsx("span",{children:Pe(e.updatedAt)})]}),e.summary&&o.jsx("p",{className:"s-work-row-summary",children:ls(e.summary)})]})}function k7({flight:e,navigate:t,nowMs:n,description:a}){const i=w7(e),c=e.agentName??e.agentId,u=v7(e.state),f=x7(e.startedAt,n),m=typeof e.startedAt=="number"&&f!=="just started"?`in flight for ${f}`:f;return o.jsxs("div",{className:"s-work-row s-work-row-clickable s-dashboard-fleet-row s-dashboard-flight-row","data-status":e.state,onClick:()=>t(i),children:[o.jsxs("div",{className:"s-work-row-header",children:[o.jsxs("div",{className:"s-fleet-row-title-wrap",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:dt(c)},children:c[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-fleet-row-title-copy",children:[o.jsx("div",{className:"s-work-row-title-wrap",children:o.jsx("span",{className:"s-work-row-title",children:c})}),o.jsxs("div",{className:"s-work-row-meta",style:{marginTop:2},children:[o.jsx("span",{children:m}),e.conversationId&&o.jsx("span",{children:"conversation linked"}),e.collaborationRecordId&&o.jsx("span",{children:"work linked"})]})]})]}),o.jsx("span",{className:`s-pill s-pill-${g7(e.state)}`,children:u})]}),o.jsx("p",{className:"s-work-row-summary",children:ls(a)})]})}function E7({item:e,navigate:t}){const n=j7(e);return o.jsxs("div",{className:`s-dashboard-activity-row${n?" s-dashboard-activity-row-clickable":""}`,onClick:n?()=>t(n):void 0,children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:dt(e.actorName??e.agentId??"system")},children:(e.actorName??e.agentId??"S")[0]?.toUpperCase()??"S"}),o.jsxs("div",{className:"s-dashboard-activity-body",children:[o.jsxs("div",{className:"s-dashboard-activity-header",children:[o.jsx("span",{className:"s-dashboard-activity-actor",children:e.actorName??"system"}),o.jsx("span",{className:"s-dashboard-activity-kind",children:XV(e.kind)}),o.jsx("span",{className:"s-time",children:Pe(e.ts)})]}),(e.title||e.summary)&&o.jsx("p",{className:"s-dashboard-activity-summary",children:ls(e.title??e.summary??"")}),e.title&&e.summary&&o.jsx("p",{className:"s-dashboard-activity-note",children:ls(e.summary)})]})]})}function C7({navigate:e}){const[t,n]=v.useState(null),[a,i]=v.useState([]),[c,u]=v.useState(()=>Date.now()),f=v.useCallback(async()=>{const[j,N]=await Promise.allSettled([_e("/api/fleet"),_e("/api/flights")]);j.status==="fulfilled"?n(j.value):n(null),N.status==="fulfilled"?i(N.value):i([])},[]);v.useEffect(()=>{f()},[f]),vn(f),v.useEffect(()=>{const j=setInterval(()=>u(Date.now()),15e3);return()=>clearInterval(j)},[]);const m=t?.activeAsks??[],h=t?.recentCompleted??[],g=t?.needsAttention??[],x=t?.activity??[],b=new Map(m.map(j=>[j.invocationId,j])),w=g.length>0?`${g.length} item${g.length===1?" is":"s are"} waiting on you. Clear ${g.length===1?"it":"those"} first, then monitor the rest of the queue.`:a.length>0?`${a.length} flight${a.length===1?" is":"s are"} active across the fleet. The queue is clear of interruptions.`:m.length>0?`${m.length} ask${m.length===1?" is":"s are"} currently in flight. The queue is clear of interruptions.`:h.length>0?"Nothing is actively running right now. Recent finishes are ready for review.":"No asks have moved through the fleet yet. Start work and this becomes the operations board.";return o.jsxs("div",{className:"s-home s-dashboard-screen s-dashboard-fleet",children:[o.jsx("div",{className:"s-dashboard-hero s-dashboard-hero-fleet",children:o.jsxs("div",{className:"s-dashboard-hero-copy",children:[o.jsxs("div",{className:"s-dashboard-hero-head",children:[o.jsx("h2",{children:"Fleet"}),t&&o.jsxs("span",{className:"s-time",children:["Updated ",Pe(t.generatedAt)]})]}),o.jsx("p",{children:w}),o.jsxs("div",{className:"s-dashboard-summary-grid",children:[o.jsxs("div",{className:`s-dashboard-summary-card${(t?.totals.needsAttention??0)>0?" s-dashboard-summary-card-attention":""}`,children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Needs input"}),o.jsx("div",{className:"s-dashboard-summary-value",children:t?.totals.needsAttention??0}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Questions, reviews, or decisions waiting on you"})]}),o.jsxs("div",{className:"s-dashboard-summary-card",children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Active flights"}),o.jsx("div",{className:"s-dashboard-summary-value",children:a.length}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Tasks currently running or queued on agents"})]}),o.jsxs("div",{className:`s-dashboard-summary-card${(t?.totals.recentCompleted??0)>0?" s-dashboard-summary-card-finished":""}`,children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Finished"}),o.jsx("div",{className:"s-dashboard-summary-value",children:t?.totals.recentCompleted??0}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Recent completions and failures to review"})]}),o.jsxs("div",{className:"s-dashboard-summary-card",children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Activity"}),o.jsx("div",{className:"s-dashboard-summary-value",children:t?.totals.activity??0}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Recent events across the fleet"})]})]})]})}),o.jsxs("div",{className:"s-dashboard-fleet-stack",children:[o.jsxs("section",{className:`s-dashboard-panel${g.length>0?" s-dashboard-panel-attention":""}`,children:[o.jsx(Al,{title:"Needs your input",detail:"Handle interruptions, pending answers, and review requests first."}),g.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"Nothing is waiting on you"}),o.jsx("p",{children:"When agents ask a question or a work item needs review, it will land here first."})]}):o.jsx("div",{className:"s-work-list",children:g.map(j=>o.jsx(N7,{item:j,navigate:e},j.recordId))})]}),o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-flights",children:[o.jsx(Al,{title:"In-flight agents",detail:"Agents with active flights right now, including how long each task has been in flight."}),a.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No agents in flight"}),o.jsx("p",{children:"Active flights will appear here as soon as an agent starts, queues, or waits on a task."})]}):o.jsx("div",{className:"s-work-list",children:a.map(j=>o.jsx(k7,{flight:j,navigate:e,nowMs:c,description:y7(j,b.get(j.invocationId))},j.id))})]}),o.jsxs("div",{className:"s-dashboard-fleet-columns",children:[o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-active",children:[o.jsx(Al,{title:"Active asks",detail:"The asks still in flight across the fleet."}),m.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No active asks"}),o.jsx("p",{children:"New agent work will appear here while it is still in progress."})]}):o.jsx("div",{className:"s-work-list",children:m.map(j=>o.jsx(aj,{ask:j,navigate:e,section:"active"},j.invocationId))})]}),o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-finished",children:[o.jsx(Al,{title:"Recent finishes",detail:"Review completions and failures once the active queue is stable."}),h.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No recent finishes"}),o.jsx("p",{children:"Completed asks and failures will show up here once they settle."})]}):o.jsx("div",{className:"s-work-list",children:h.map(j=>o.jsx(aj,{ask:j,navigate:e,section:"finished"},j.invocationId))})]})]}),o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-activity",children:[o.jsx(Al,{title:"Recent activity",detail:"The broader event stream behind the queue."}),x.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No recent fleet activity"}),o.jsx("p",{children:"Messages, asks, and other agent activity will stream here."})]}):o.jsx("div",{className:"s-dashboard-activity-feed",children:x.slice(0,20).map(j=>o.jsx(E7,{item:j,navigate:e},j.id))})]})]})]})}function T7(e){return e<5?"Still up":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}function A7(){return"operator"}function R7({navigate:e}){const{agents:t,messages:n,onlineCount:a}=Ut(),[i,c]=v.useState([]),[u,f]=v.useState([]),[m,h]=v.useState(null),[g,x]=v.useState([]),[b,w]=v.useState("trailing 7d"),[j,N]=v.useState("3h buckets"),T=v.useRef(null),k=v.useCallback(async()=>{const[U,Y,K,D]=await Promise.allSettled([_e("/api/activity"),_e("/api/sessions"),_e("/api/fleet"),_e("/api/heartrate")]);U.status==="fulfilled"&&c(U.value),Y.status==="fulfilled"&&f([...Y.value].sort((P,B)=>(B.lastMessageAt??0)-(P.lastMessageAt??0))),K.status==="fulfilled"&&h(K.value),D.status==="fulfilled"&&(x(D.value.buckets),w(D.value.windowLabel),N(D.value.bucketLabel??""))},[]),C=v.useCallback(()=>{T.current||(T.current=setTimeout(()=>{T.current=null,k()},250))},[k]);v.useEffect(()=>(k(),()=>{T.current&&clearTimeout(T.current)}),[k]),vn(C);const S=v.useMemo(()=>t.filter(U=>mt(U.state)==="working"),[t]),R=v.useMemo(()=>t.filter(U=>mt(U.state)==="available"),[t]),A=v.useMemo(()=>t.filter(U=>mt(U.state)==="offline"),[t]),M=v.useMemo(()=>(m?.activeAsks??[]).filter(U=>U.status==="needs_attention"||U.status==="queued"),[m]),O=v.useMemo(()=>(m?.recentCompleted??[]).slice(0,3),[m]),V=v.useMemo(()=>i.slice(0,8),[i]),F=new Date,I=T7(F.getHours()),$=vc(),L=v.useMemo(()=>{const U=[];return S.length>0&&U.push(`${S.length} agent${S.length===1?" is":"s are"} working now`),M.length>0&&U.push(`${M.length} thing${M.length===1?"":"s"} need${M.length===1?"s":""} you`),O.length>0&&U.push(`${O.length} ask${O.length===1?" was":"s were"} resolved recently`),U.length===0&&t.length>0&&U.push(`${t.length} agent${t.length===1?" is":"s are"} registered`),U.length===0&&U.push("no agents are connected yet"),U},[S,M,O,t]);return o.jsx("div",{className:"s-fleet-home",children:o.jsxs("div",{className:"s-fleet-home-inner",children:[o.jsxs("div",{className:"s-hero",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"s-eyebrow",style:{marginBottom:12},children:["Fleet briefing ·"," ",F.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"})]}),o.jsxs("h1",{className:"s-hero-greeting",children:[I,", ",o.jsxs("em",{children:[A7(),"."]})]}),o.jsxs("p",{className:"s-hero-narrative",children:[L.map((U,Y)=>o.jsxs("span",{children:[Y>0&&", ",U.includes("need")?o.jsx("span",{className:"s-hero-warn",children:U}):o.jsx("strong",{children:U})]},Y)),"."]}),o.jsxs("div",{className:"s-hero-actions",children:[M.length>0&&o.jsxs("button",{className:"s-btn-fleet s-btn-fleet--primary",onClick:()=>e({view:"fleet"}),children:["Answer asks · ",M.length]}),$&&o.jsx("button",{className:"s-btn-fleet",onClick:()=>e({view:"ops"}),children:"Open ops center"}),o.jsx("button",{className:"s-btn-fleet",onClick:()=>e({view:"sessions"}),children:"Jump to thread"})]})]}),o.jsxs("div",{className:"s-heartrate-card",children:[o.jsxs("div",{className:"s-heartrate-header",children:[o.jsx("span",{className:"s-eyebrow",children:"Fleet heart-rate"}),o.jsx("span",{style:{flex:1}}),o.jsxs("span",{className:"s-heartrate-live",children:["● ",b,j?` · ${j}`:""]})]}),o.jsx(_7,{buckets:g}),o.jsxs("div",{className:"s-heartrate-stats",children:[o.jsx(jp,{label:"Active",value:S.length,color:"var(--green)"}),o.jsx(jp,{label:"Waiting",value:R.length,color:"var(--amber)"}),o.jsx(jp,{label:"Done",value:A.length,color:"var(--dim)"})]})]})]}),o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Np,{label:`Needs you · ${M.length}`,right:M.length>0?o.jsxs("span",{style:{color:"var(--amber)"},children:["oldest"," ",Pe(Math.min(...M.map(U=>U.updatedAt)))]}):"clear"}),o.jsxs("div",{className:"s-ask-grid",children:[M.slice(0,4).map(U=>o.jsx(rj,{ask:U,agents:t,navigate:e,pending:!0},U.invocationId)),O.slice(0,Math.max(0,2-M.length)).map(U=>o.jsx(rj,{ask:U,agents:t,navigate:e,pending:!1},U.invocationId)),M.length<2&&O.length===0&&o.jsxs("div",{className:"s-ask-empty",children:[o.jsx("span",{className:"s-eyebrow",children:"No more asks"}),o.jsx("span",{className:"s-ask-empty-detail",children:"Fleet is unblocked on you."})]})]})]}),S.length>0&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Np,{label:`What's moving · ${S.length} active`,right:o.jsx("button",{className:"s-link-btn",onClick:()=>e({view:"mesh"}),children:"open mesh ↗"})}),o.jsx("div",{className:"s-now-grid",style:{gridTemplateColumns:`repeat(${Math.min(S.length,3)}, 1fr)`},children:S.map(U=>o.jsx(O7,{agent:U,navigate:e},U.id))})]}),V.length>0&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Np,{label:"Since you were away",right:`last hour · ${V.length} events`}),o.jsx(I7,{items:V,agents:t,navigate:e})]})]})})}function M7(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 a=e[Math.max(0,n-1)],i=e[n],c=e[n+1],u=e[Math.min(e.length-1,n+2)],f={x:i.x+(c.x-a.x)/6,y:i.y+(c.y-a.y)/6},m={x:c.x-(u.x-i.x)/6,y:c.y-(u.y-i.y)/6};t.push(`C ${f.x.toFixed(1)} ${f.y.toFixed(1)}, ${m.x.toFixed(1)} ${m.y.toFixed(1)}, ${c.x.toFixed(1)} ${c.y.toFixed(1)}`)}return t.join(" ")}function _7({buckets:e}){const u=e.length;if(u<2||e.every(b=>b.count===0))return o.jsxs("svg",{viewBox:"0 0 372 82",style:{width:"100%",height:82,display:"block"},children:[o.jsx("line",{x1:"0",y1:60,x2:372,y2:60,stroke:"var(--border)"}),o.jsx("text",{x:372/2,y:82/2-4,textAnchor:"middle",fill:"var(--dim)",fontSize:"14",letterSpacing:"0.3em",children:"zzz"}),o.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 m=372/(u-1),h=e.map((b,w)=>({x:w*m,y:60-Math.max(0,Math.min(1,b.value))*54})),g=M7(h),x=`${g} L 372 60 L 0 60 Z`;return o.jsxs("svg",{viewBox:"0 0 372 82",style:{width:"100%",height:82,display:"block"},children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"hrFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.28"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),o.jsx("line",{x1:"0",y1:6,x2:372,y2:6,stroke:"var(--border)",opacity:"0.18"}),o.jsx("line",{x1:"0",y1:66/2,x2:372,y2:66/2,stroke:"var(--border)",opacity:"0.25"}),o.jsx("line",{x1:"0",y1:60,x2:372,y2:60,stroke:"var(--border)"}),o.jsx("path",{d:x,fill:"url(#hrFill)"}),o.jsx("path",{d:g,fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round"}),o.jsx("circle",{cx:h[u-1].x,cy:h[u-1].y,r:"3.5",fill:"var(--accent)"}),o.jsx("text",{x:"0",y:77,fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"7d ago"}),o.jsx("text",{x:372/2,y:77,textAnchor:"middle",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"3d"}),o.jsx("text",{x:372,y:77,textAnchor:"end",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"now"})]})}function jp({label:e,value:t,color:n}){return o.jsxs("div",{className:"s-stat",children:[o.jsxs("div",{className:"s-stat-label",children:[o.jsx("span",{className:"s-stat-dot",style:{background:n}}),o.jsx("span",{className:"s-eyebrow",children:e})]}),o.jsx("span",{className:"s-stat-value",children:t})]})}function Np({label:e,right:t}){return o.jsxs("div",{className:"s-section-rule",children:[o.jsx("span",{className:"s-eyebrow",children:e}),o.jsx("span",{className:"s-section-rule-line"}),t&&o.jsx("span",{className:"s-section-rule-right",children:t})]})}function rj({ask:e,agents:t,navigate:n,pending:a}){const c=t.find(f=>f.id===e.agentId)?.name??e.agentName??e.agentId,u=e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId};return o.jsxs("div",{className:`s-ask-block${a?" s-ask-block--pending":""}`,style:{cursor:"pointer"},onClick:()=>n(u),children:[o.jsxs("div",{className:"s-ask-header",children:[o.jsx("span",{className:"s-eyebrow s-ask-label",children:a?"◌ ASK — AWAITING":"● ASK — RESOLVED"}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{className:"s-eyebrow",children:Pe(e.updatedAt)})]}),o.jsxs("div",{className:"s-ask-body",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:dt(c)},children:c[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-ask-body-copy",children:[o.jsxs("div",{className:"s-ask-route",children:[o.jsx("span",{className:"s-ask-route-name",children:c}),o.jsx("span",{children:" → "}),o.jsx("span",{style:{color:"var(--accent)"},children:"operator"})]}),o.jsxs("div",{className:"s-ask-text",children:['"',e.summary??e.task,'"']})]})]}),a&&o.jsxs("div",{className:"s-ask-actions",children:[o.jsx("button",{className:"s-btn-fleet s-btn-fleet--primary",children:"Answer"}),o.jsx("button",{className:"s-btn-fleet",children:"Defer"}),o.jsx("button",{className:"s-btn-fleet",children:"Route…"}),o.jsx("span",{className:"s-ask-thinking",children:o.jsx("span",{className:"s-thinking-strip"})})]})]})}function O7({agent:e,navigate:t}){const n=e.handle?`@${e.handle}`:e.id,a=e.role??e.agentClass,i=e.branch??"main",c=os(e.id);return o.jsxs("div",{className:"s-now-card",onClick:()=>t({view:"agents",agentId:e.id,conversationId:c,tab:"observe"}),children:[o.jsxs("div",{className:"s-now-card-head",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:dt(e.name)},children:e.name[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-now-card-copy",children:[o.jsx("div",{className:"s-now-card-name",children:e.name}),o.jsxs("div",{className:"s-now-card-meta",children:[n," · ",a]})]}),o.jsx("span",{className:"s-now-card-live",children:"● live"})]}),o.jsx("div",{className:"s-now-card-task",children:e.cwd??`Working in ${e.project??"workspace"}`}),o.jsxs("div",{className:"s-now-card-ticker",children:[o.jsx("span",{className:"s-now-card-ticker-prompt",children:"›"}),o.jsx("span",{className:"s-now-card-ticker-text",children:"working…"}),o.jsx("span",{className:"s-now-card-cursor"})]}),o.jsxs("div",{className:"s-now-card-footer",children:[o.jsx("span",{children:e.updatedAt?`updated ${Pe(e.updatedAt)}`:"active"}),o.jsx("span",{children:i})]})]})}function I7({items:e,agents:t,navigate:n}){const a=[...e].sort((u,f)=>f.ts-u.ts),i={"collaboration.ask":"?","message.sent":"·","message.received":"·","flight.started":"⌘","flight.completed":"⌘","agent.online":"→","agent.offline":"→","agent.registered":"→","collaboration.answer":"↳"},c={"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 o.jsxs("div",{className:"s-timeline",children:[o.jsx("div",{className:"s-timeline-spine"}),a.map(u=>{const f=u.actorName??"system",m=c[u.kind]??"var(--dim)",h=i[u.kind]??"·",g=u.kind.split(".").pop()??u.kind,x=u.conversationId?{view:"conversation",conversationId:u.conversationId}:null;return o.jsxs("div",{className:"s-timeline-row",style:{cursor:x?"pointer":void 0},onClick:x?()=>n(x):void 0,children:[o.jsx("div",{className:"s-timeline-bead",style:{background:m}}),o.jsx("span",{className:"s-timeline-time",children:Pe(u.ts)}),o.jsxs("div",{className:"s-timeline-actors",children:[o.jsx("span",{className:"s-timeline-kind-mark",style:{color:m},children:h}),o.jsx("div",{className:"s-avatar",style:{width:18,height:18,fontSize:9,background:dt(f)},children:f[0]?.toUpperCase()??"?"}),o.jsx("span",{className:"s-timeline-handle",children:f})]}),o.jsx("span",{className:"s-timeline-text",children:u.title??u.summary??""}),o.jsx("span",{className:"s-timeline-kind",children:g})]},u.id)})]})}const D7=v.lazy(()=>id(()=>import("./arc.es-Bkj9Bkvx.js"),[]).then(e=>({default:e.ArcDiagram})));function Qr(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.split(".")[0]}function z7(e){const t=e.hostName?.trim();if(t&&t.toLowerCase()!=="localhost")return Qr(t)||t;const n=e.dnsName?.trim().replace(/\.$/,"");return n?Qr(n)||n:Qr(e.name)||e.name}function Rg(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.replace(/\.$/,"").toLowerCase()}function sr(e){const t=Rg(e);return t?t.split(".")[0]??t:""}function L7(e){return e.brokerUrl?Qr(e.brokerUrl):e.hostName?Qr(e.hostName):e.id.slice(0,10)}function $7(e,t){return Math.abs(e)>=Math.abs(t)?e>=0?["right","left"]:["left","right"]:t>=0?["bottom","top"]:["top","bottom"]}function P7(e,t){const n=sr(t.hostName||t.name),a=sr(e.localNode?.hostName||e.localNode?.name);return!!a&&n===a}function U7(e,t){const n=new Set([sr(e.hostName),sr(e.name),...e.addresses.map(i=>Rg(i)),...e.addresses.map(i=>sr(i))].filter(Boolean)),a=new Set([sr(t.hostName),sr(t.name),Rg(t.brokerUrl),sr(t.brokerUrl)].filter(Boolean));for(const i of n)if(a.has(i))return!0;return!1}function B7(e){if(!e.localNode)return null;const t=e.localNode.id,n=Object.values(e.nodes).filter(b=>b.id!==t),a=e.tailscale.peers.filter(b=>!P7(e,b)).filter(b=>!n.some(w=>U7(b,w))),i=[...n.map(b=>({kind:"mesh",peer:b})),...a.map(b=>({kind:"tailnet",peer:b}))],c=800,u=300,f=c/2,m=u/2,h={[t]:{x:f,y:m,size:"m"}},g={[t]:{icon:"Database",name:Qr(e.localNode.hostName)||e.localNode.name||"broker",subtitle:"this node",color:"violet"}},x=[];if(i.length===0)h.__placeholder={x:f+220,y:m,size:"m"},g.__placeholder={icon:"CircleDashed",name:"No peers yet",subtitle:"awaiting discovery",color:"zinc"},x.push({from:t,to:"__placeholder",fromAnchor:"right",toAnchor:"left",style:"pending"});else{const b=i.length,w=Math.min(170,100+b*10);i.forEach(({kind:j,peer:N},T)=>{const k=T/b*Math.PI*2-Math.PI/2,C=Math.round(f+w*Math.cos(k)),S=Math.round(m+w*Math.sin(k)),R=j==="mesh"?N.id:`tailnet:${N.id}`,A=j==="mesh"?Qr(N.hostName)||N.name||"peer":z7(N)||"tailnet",M=j==="mesh"?L7(N):N.online?N.addresses[0]??"tailnet only":"tailnet offline";h[R]={x:C,y:S,size:j==="mesh"?"m":"s"},g[R]={icon:j==="mesh"?"Database":"CircleDashed",name:A,subtitle:M,color:j==="mesh"?N.advertiseScope==="mesh"?"emerald":"zinc":N.online?"sky":"zinc"};const[O,V]=$7(C-f,S-m);x.push({from:t,to:R,fromAnchor:O,toAnchor:V,style:j==="mesh"?N.advertiseScope==="mesh"?"mesh":"local":N.online?"tailnet":"tailnet-offline"})})}return{layout:{width:c,height:u},nodes:h,nodeData:g,connectors:x,connectorStyles:{mesh:{color:"emerald",strokeWidth:2,label:"mesh"},local:{color:"zinc",strokeWidth:1.5},tailnet:{color:"sky",strokeWidth:1.5,dashed:!0,label:"tailnet"},"tailnet-offline":{color:"zinc",strokeWidth:1.25,dashed:!0,label:"tailnet"},pending:{color:"zinc",strokeWidth:1.5,dashed:!0}}}}function V7({mesh:e}){const t=v.useMemo(()=>B7(e),[e]);return t?o.jsx("div",{className:"s-mesh-topology",children:o.jsx(v.Suspense,{fallback:o.jsx("div",{className:"s-mesh-topology-fallback"}),children:o.jsx(D7,{data:t,className:"s-mesh-topology-canvas",mode:"light",theme:"cool",interactive:!0,showArcToggle:!1,defaultZoom:"fit",maxFitZoom:.95,hoverEffects:{dim:!0,lift:!0,glow:!0,highlightEdges:!0}})})}):null}function H7(e){return e.code==="local_only"?"notice":e.severity==="error"?"error":"warning"}function Z7(e){switch(e.code){case"tailscale_stopped":return"Stopped";case"local_only":return"Not discoverable";case"mesh_loopback":return"Wrong address";case"discovery_unconfigured":return"No path";default:return"Offline"}}function F7(e){return e?e.replace(/^https?:\/\//,"").split("/")[0]??e:"Unavailable"}function q7(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 Y7(e){return e==="mesh"?"Announced to mesh":e==="local"?"Local only":e||"Not advertised"}function G7(e){return e.identity.discoverable?"success":e.health.reachable?"warning":"danger"}function W7(e){return e.identity.discoverable?"Discoverable":e.health.reachable?"Not discoverable":"Broker offline"}function X7(e){return!e.health.reachable||e.issues.some(t=>t.severity==="error")?"danger":e.issues.length>0?"warning":"success"}function K7(e){return e.health.reachable?e.issues.some(t=>t.severity==="error")?"Degraded":e.issues.length>0?"Needs attention":"Healthy":"Broker unreachable"}function J7({issue:e}){const t=H7(e);return o.jsxs("article",{className:`sys-issue-card sys-issue-card-${t}`,children:[o.jsxs("div",{className:"sys-issue-head",children:[o.jsx("h3",{className:"sys-issue-title",children:e.title}),o.jsx("span",{className:`sys-chip sys-chip-${t==="error"?"failed":t}`,children:Z7(e)})]}),o.jsx("p",{className:"sys-issue-body",children:e.summary}),(e.action||e.actionCommand)&&o.jsxs("div",{className:"sys-issue-action",children:[e.actionCommand&&o.jsx("code",{className:"sys-code-inline",children:e.actionCommand}),e.action&&o.jsx("span",{children:e.action})]})]})}function Q7({navigate:e}){const[t,n]=v.useState(null),[a,i]=v.useState(!0),[c,u]=v.useState(!1),[f,m]=v.useState(!1),[h,g]=v.useState(!1),[x,b]=v.useState(null),[w,j]=v.useState(null),[N,T]=v.useState(null),[k,C]=v.useState(null),S=v.useRef(null),R=v.useRef(0);v.useEffect(()=>{S.current=t},[t]);const A=v.useCallback(async(P="initial")=>{const B=++R.current;!(S.current!==null)&&P!=="background"?(i(!0),T(null)):u(!0);try{const X=await _e("/api/mesh");if(B!==R.current)return;n(X),T(null),C(Date.now())}catch(X){if(B!==R.current)return;T(X instanceof Error?X.message:String(X))}finally{B===R.current&&(i(!1),u(!1))}},[]);v.useEffect(()=>{A("initial")},[A]),v.useEffect(()=>{const P=setInterval(()=>{A("background")},1e4);return()=>clearInterval(P)},[A]);const M=v.useCallback(async()=>{m(!0),b(null);try{const P=await _e("/api/mesh/announce",{method:"POST",body:"{}"});n(P),S.current=P,T(null),C(Date.now()),b({tone:P.identity.discoverable?"success":"warning",title:P.identity.discoverable?"Mesh updated.":"Mesh updated, but still needs attention.",message:P.identity.discoverable?"This broker is now announced to the mesh.":"Mesh visibility was updated, but this broker still is not peer-reachable."})}catch(P){b({tone:"warning",title:"Could not announce broker.",message:P instanceof Error?P.message:String(P)})}finally{m(!1)}},[]),O=v.useCallback(async()=>{g(!0),j(null);try{const P=await _e("/api/mesh/tailscale",{method:"POST",body:JSON.stringify({action:"open_app"})});n(P),S.current=P,T(null),C(Date.now()),j({tone:P.tailscale.running?"success":"warning",title:P.tailscale.running?"Tailscale is running.":"Tailscale launch requested.",message:P.tailscale.running?"Mesh discovery can resume on this machine.":"Scout asked macOS to open Tailscale. Approve any prompts, then refresh this page in a moment."})}catch(P){j({tone:"warning",title:"Could not open Tailscale.",message:P instanceof Error?P.message:String(P)})}finally{g(!1)}},[]),V=t?X7(t):"warning",F=t?K7(t):"Loading",I=t?Object.values(t.nodes):[],$=t?.localNode?.id,L=t?.localNode?.hostName?.toLowerCase(),U=I.filter(P=>P.id!==$),Y=(t?.tailscale.peers??[]).filter(P=>{const B=P.hostName?.toLowerCase();return!B||B==="localhost"?!0:!(L&&(B===L||B.startsWith(`${L.split(".")[0]}.`)))}),K=t?t.issues.length>0?t.issues:t.warnings.map((P,B)=>({code:`fallback-${B}`,severity:"warning",title:"Mesh notice",summary:P,action:null,actionCommand:null})):[],D=v.useMemo(()=>t?[{label:"Broker",value:t.health.reachable?"Reachable":"Unavailable",detail:t.health.error??F7(t.brokerUrl)},{label:"Discoverable",value:t.identity.discoverable?"Yes":"No",detail:t.identity.modeLabel},{label:"Mesh peers",value:`${U.length}`,detail:U.length>0?"Remote brokers in this mesh":"No remote brokers discovered"},{label:"Tailnet",value:t.tailscale.available?t.tailscale.running?`${Y.filter(P=>P.online).length}/${Y.length}`:"Stopped":"Unavailable",detail:t.tailscale.available?t.tailscale.running?"Online peers / visible peers":`Backend state: ${t.tailscale.backendState??"unknown"}`:"Tailscale was not detected on this machine"}]:[],[Y,t,U.length]);return o.jsxs("div",{className:"sys-surface-page",children:[o.jsxs("div",{className:"sys-page-head",children:[o.jsxs("div",{className:"sys-page-title-group",children:[o.jsx("h2",{className:"sys-page-title",children:"Mesh"}),o.jsx("p",{className:"sys-page-subtitle",children:"Who this broker is, whether peers can discover it, and what the current mesh can see."})]}),o.jsxs("div",{className:"sys-page-actions",children:[o.jsx("span",{className:`sys-chip sys-chip-${V}`,children:F}),t?.tailscale.available&&!t.tailscale.running&&o.jsx("span",{className:"sys-chip sys-chip-warning",children:"Tailnet stopped"}),o.jsx("div",{className:"sys-sync-note",children:a?"Loading system snapshot...":N&&t?`Showing last confirmed snapshot from ${k?Pe(k):"earlier"}`:k?`Confirmed ${Pe(k)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:a||c,onClick:()=>{A("manual")},children:c?"Refreshing...":"Refresh"})]})]}),N&&t&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Mesh refresh failed."}),o.jsx("span",{children:N})]}),a&&!t&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"Loading mesh status"}),o.jsx("p",{className:"sys-state-body",children:"Inspecting broker reachability and peer discovery inputs."})]}),!a&&!t&&N&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Mesh status is unavailable"}),o.jsx("p",{className:"sys-state-body",children:N}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{A("manual")},children:"Try again"})})]}),t&&o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"sys-panel sys-mesh-identity",children:[o.jsxs("div",{className:"sys-section-head",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"This broker"}),o.jsx("p",{className:"sys-section-subtitle",children:"The identity peers will learn if they discover this machine."})]}),o.jsx("span",{className:`sys-chip sys-chip-${G7(t)}`,children:W7(t)})]}),t.tailscale.available&&!t.tailscale.running&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Tailscale is stopped."}),o.jsx("span",{children:t.tailscale.health[0]??"This machine is showing cached Tailnet peers, but the local Tailscale backend is not running."})]}),t.tailscale.available&&!t.tailscale.running&&o.jsxs("div",{className:"sys-inline-actions",children:[o.jsx("button",{type:"button",className:"s-btn",disabled:h,onClick:()=>{O()},children:h?"Opening Tailscale...":"Open Tailscale"}),o.jsx("button",{type:"button",className:"s-btn",disabled:h||c,onClick:()=>{A("manual")},children:c?"Refreshing...":"Refresh status"})]}),o.jsxs("div",{className:"sys-detail-grid",children:[o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Who Am I"}),o.jsx("span",{className:"sys-detail-value",children:t.identity.name??t.localNode?.name??"Unavailable"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Node ID"}),o.jsx("code",{className:"sys-detail-value",children:t.identity.nodeId??"Unavailable"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Mesh"}),o.jsx("code",{className:"sys-detail-value",children:t.identity.meshId??"Unassigned"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Mode"}),o.jsx("span",{className:"sys-detail-value",children:t.identity.modeLabel})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Discoverable"}),o.jsx("span",{className:"sys-detail-value",children:t.identity.discoverable?"Yes":"No"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Announced As"}),o.jsx("code",{className:"sys-detail-value",children:t.identity.announceUrl??"Not announced"})]})]}),o.jsxs("div",{className:`sys-banner ${t.identity.discoverable?"sys-banner-success":"sys-banner-muted"}`,children:[o.jsx("strong",{children:"How peers find you."}),o.jsx("span",{children:t.identity.discoveryDetail})]}),!t.identity.discoverable&&t.health.reachable&&o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",disabled:f,onClick:()=>{M()},children:f?"Announcing...":"Announce on mesh"})}),x&&o.jsxs("div",{className:`sys-banner ${x.tone==="success"?"sys-banner-success":"sys-banner-warning"}`,children:[o.jsx("strong",{children:x.title}),o.jsx("span",{children:x.message})]}),w&&o.jsxs("div",{className:`sys-banner ${w.tone==="success"?"sys-banner-success":"sys-banner-warning"}`,children:[o.jsx("strong",{children:w.title}),o.jsx("span",{children:w.message})]})]}),o.jsx("div",{className:"sys-stat-grid",children:D.map(P=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:P.label}),o.jsx("strong",{className:"sys-stat-value",children:P.value}),o.jsx("span",{className:"sys-stat-detail",children:P.detail})]},P.label))}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Health notices"}),o.jsx("p",{className:"sys-section-subtitle",children:"Warnings and errors from the current broker and discovery snapshot."})]})}),K.length>0?o.jsx("div",{className:"sys-issue-grid",children:K.map((P,B)=>o.jsx(J7,{issue:P},`${P.code}-${B}`))}):o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No active mesh warnings"}),o.jsx("p",{children:"The broker is reachable and discovery inputs look healthy from this page."})]})]}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Topology"}),o.jsx("p",{className:"sys-section-subtitle",children:"Current broker relationships plus visible tailnet peers from this machine."})]})}),t.localNode?o.jsx(V7,{mesh:t}):o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"Topology unavailable"}),o.jsx("p",{children:"A local node record is required before the topology view can render."})]})]}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Discovered peers"}),o.jsxs("p",{className:"sys-section-subtitle",children:["Remote brokers registered in ",t.meshId??"this mesh","."]})]})}),U.length===0?o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No remote brokers discovered"}),o.jsx("p",{children:"This can be normal on a single-node setup. If you expect peers, check the health notices above."})]}):o.jsx("div",{className:"sys-list-grid",children:U.map(P=>o.jsxs("article",{className:"sys-list-card",children:[o.jsxs("div",{className:"sys-list-card-head",children:[o.jsx("h3",{className:"sys-list-card-title",children:P.name}),o.jsx("span",{className:`sys-chip sys-chip-${P.advertiseScope==="mesh"?"success":"neutral"}`,children:Y7(P.advertiseScope)})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Node id"}),o.jsx("code",{className:"sys-detail-value",children:P.id})]}),P.brokerUrl&&o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Broker"}),o.jsx("code",{className:"sys-detail-value",children:P.brokerUrl})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Last seen"}),o.jsx("span",{className:"sys-detail-value",children:P.lastSeenAt?Pe(P.lastSeenAt):"Recently registered"})]})]},P.id))})]}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Tailnet"}),o.jsx("p",{className:"sys-section-subtitle",children:"External Tailscale peers visible from this machine."})]})}),Y.length===0?o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No external tailnet peers"}),o.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 on this machine.":"Tailscale peers were not detected on this machine."})]}):o.jsx("div",{className:"sys-list-grid",children:Y.map(P=>o.jsxs("article",{className:"sys-list-card",children:[o.jsxs("div",{className:"sys-list-card-head",children:[o.jsx("h3",{className:"sys-list-card-title",children:q7(P)}),o.jsx("span",{className:`sys-chip sys-chip-${P.online?"success":"failed"}`,children:P.online?"Online":"Offline"})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Address"}),o.jsx("code",{className:"sys-detail-value",children:P.addresses?.[0]??"Unavailable"})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Platform"}),o.jsx("span",{className:"sys-detail-value",children:P.os??"Unknown"})]})]},P.id))})]})]})]})}const eZ=[[/```[\s\S]*?```/g," "],[/`([^`]+)`/g,"$1"],[/!\[([^\]]*)\]\([^)]+\)/g,"$1"],[/\[([^\]]+)\]\([^)]+\)/g,"$1"],[/\*\*(.+?)\*\*/g,"$1"],[/__(.+?)__/g,"$1"],[new RegExp("(?<!\\*)\\*(?!\\*)([^*\\n]+)\\*(?!\\*)","g"),"$1"],[new RegExp("(?<!_)_(?!_)([^_\\n]+)_(?!_)","g"),"$1"],[/~~(.+?)~~/g,"$1"],[/^#{1,6}\s+/gm,""],[/^>\s?/gm,""],[/^[-*+]\s+/gm,""],[/^\d+\.\s+/gm,""],[/^---+\s*$/gm,""],[/^\s*\|.*\|\s*$/gm,""]];function tZ(e,t=140){if(!e)return"";let n=e;for(const[a,i]of eZ)n=n.replace(a,i);return n=n.replace(/\s+/g," ").trim(),n.length>t&&(n=`${n.slice(0,t-1)}…`),n}function nZ(){const e=window.getSelection();return e!==null&&e.toString().trim().length>0}function sZ(e){nZ()||e()}const ij={direct:"DM",channel:"Channel",group_direct:"Group",thread:"Thread"},aZ=new Set(["all","direct","channel","group_direct","thread"]);function Mg(e){return typeof window>"u"?"":new URLSearchParams(window.location.search).get(e)??""}function rZ(e){if(typeof window>"u")return;const t=new URLSearchParams(window.location.search);for(const[a,i]of Object.entries(e))i===null||i===""?t.delete(a):t.set(a,i);const n=t.toString();window.history.replaceState(null,"",window.location.pathname+(n?`?${n}`:""))}function iZ(){const e=Mg("view");return aZ.has(e)?e:"all"}function oZ(e){return e.kind==="direct"&&e.agentName?e.agentName:e.title.replace(/\s*<>\s*/g," · ")}function lZ(e){return e.trim().toLowerCase()}function cZ(e){return[e.id,e.title,e.preview??"",e.agentName??"",e.harness??"",e.harnessSessionId??"",e.harnessLogPath??"",...e.participantIds]}function oj(e,t){if(!t)return null;const n=e.harnessSessionId?.trim();return n&&n.toLowerCase().includes(t)?n:null}function uZ(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function dZ(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"";const t=e<1e12?e*1e3:e;return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function fZ({navigate:e}){const[t,n]=v.useState([]),[a,i]=v.useState(()=>iZ()),[c,u]=v.useState(()=>Mg("q")),[f,m]=v.useState(()=>Mg("unread")==="1"),[h,g]=v.useState(()=>Bv()),[x,b]=v.useState(0),[w,j]=v.useState(null),N=v.useRef(null),T=v.useRef(null),k=xf(),C=v.useCallback(async()=>{j(null);try{const L=await _e("/api/sessions");n(L.sort((U,Y)=>(Y.lastMessageAt??0)-(U.lastMessageAt??0)))}catch(L){j(L instanceof Error?L.message:String(L))}},[]);v.useEffect(()=>{C()},[C]),vn(C);const[,S]=v.useState(0);v.useEffect(()=>{const L=setInterval(()=>S(U=>U+1),15e3);return()=>clearInterval(L)},[]),v.useEffect(()=>{rZ({view:a==="all"?null:a,q:c.trim()||null,unread:f?"1":null})},[a,c,f]);const R=v.useMemo(()=>Array.from(new Set(t.map(L=>L.kind))),[t]),A=v.useMemo(()=>{const L={all:t.length};for(const U of t)L[U.kind]=(L[U.kind]??0)+1;return L},[t]),M=v.useMemo(()=>lZ(c),[c]),O=v.useMemo(()=>t.filter(L=>wp(L.lastMessageAt,L.id,h)).length,[t,h]),V=v.useMemo(()=>t.filter(L=>!(a!=="all"&&L.kind!==a||f&&!wp(L.lastMessageAt,L.id,h)||M&&!cZ(L).some(Y=>Y.toLowerCase().includes(M)))),[t,a,f,h,M]);v.useEffect(()=>{x>=V.length&&b(Math.max(0,V.length-1))},[V.length,x]);const F=v.useCallback((L,U={})=>{if(g(jH(L.id)),U.observe&&L.agentId){e({view:"agents",agentId:L.agentId,conversationId:L.id,tab:"observe"});return}e({view:"conversation",conversationId:L.id})},[e]);v.useEffect(()=>{function L(U){const Y=U.target,K=Y instanceof HTMLInputElement||Y instanceof HTMLTextAreaElement||Y instanceof HTMLElement&&Y.isContentEditable;if((U.metaKey||U.ctrlKey)&&U.key.toLowerCase()==="k"){U.preventDefault(),N.current?.focus(),N.current?.select();return}if(K){U.key==="Escape"&&Y===N.current&&N.current?.blur();return}if(U.key==="/"){U.preventDefault(),N.current?.focus();return}if(U.key==="j"||U.key==="ArrowDown"){U.preventDefault(),b(D=>Math.min(V.length-1,D+1));return}if(U.key==="k"||U.key==="ArrowUp"){U.preventDefault(),b(D=>Math.max(0,D-1));return}if(U.key==="Enter"||U.key==="o"){const D=V[x];D&&(U.preventDefault(),F(D,{observe:!!oj(D,M)}))}}return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[V,x,F,M]),v.useEffect(()=>{T.current?.querySelector(`[data-idx="${x}"]`)?.scrollIntoView({block:"nearest"})},[x]);const I=R.length>1,$=f?O>0?`${O} unread threads need attention.`:"No unread threads right now.":V.length===t.length?"Recent activity across every conversation.":`${V.length} conversations match the current filters.`;return o.jsxs("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:[o.jsx("section",{className:"s-thread-overview",children:o.jsxs("div",{className:"s-thread-overview-copy",children:[o.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[o.jsx("h2",{className:"s-page-title",children:"Sessions"}),o.jsxs("span",{className:"s-meta s-tabular",children:[V.length," of ",t.length]})]}),o.jsx("p",{className:"s-thread-overview-summary",children:$})]})}),o.jsxs("section",{className:"s-thread-panel s-thread-panel-list",children:[o.jsxs("div",{className:"s-sessions-toolbar",children:[I&&o.jsxs("div",{className:"s-seg",role:"tablist","aria-label":"Session kind",children:[o.jsx(lj,{label:"All",count:A.all,pressed:a==="all",onClick:()=>i("all")}),R.map(L=>o.jsx(lj,{label:ij[L]??L,count:A[L]??0,pressed:a===L,onClick:()=>i(L)},L))]}),o.jsxs("button",{type:"button",className:`s-seg-standalone${f?" is-on":""}`,onClick:()=>m(L=>!L),"aria-pressed":f,title:"Show unread only",children:[o.jsx("span",{className:"s-dot s-dot-sm","aria-hidden":"true"}),o.jsx("span",{children:"Unread"}),O>0&&o.jsx("span",{className:"s-seg-count",children:O})]}),o.jsxs("div",{className:"s-search",children:[o.jsx("input",{ref:N,type:"text",className:"s-search-input",placeholder:"Search conversations or session IDs…",value:c,onChange:L=>u(L.target.value),onKeyDown:L=>{L.key==="Escape"&&(c?u(""):L.target.blur())}}),o.jsx("kbd",{className:"s-search-kbd",children:"⌘K"})]})]}),w&&o.jsx("p",{className:"s-error",children:w}),V.length===0?o.jsxs("div",{className:"s-empty s-thread-empty-state",children:[o.jsx("p",{children:c||f?"No matches":"No conversations"}),o.jsx("p",{children:c?"Try a different search term.":f?"You're all caught up.":"Conversations appear here when agents communicate."})]}):o.jsx("div",{className:"s-inbox",ref:T,role:"listbox","aria-label":"Sessions",children:V.map((L,U)=>{const Y=oZ(L),K=(L.agentName??Y)[0]?.toUpperCase()??"?",D=wp(L.lastMessageAt,L.id,h),P=U===x,B=tZ(L.preview,160),G=ij[L.kind]??L.kind,X=uZ(L.workspaceRoot),z=oj(L,M);return o.jsxs("div",{"data-idx":U,"data-unread":D?"true":"false","data-selected":P?"true":"false",className:"s-inbox-row",role:"option","aria-selected":P,tabIndex:P?0:-1,onClick:()=>{sZ(()=>{b(U),F(L,{observe:!!z})})},onMouseEnter:()=>b(U),onContextMenu:Z=>{const J=window.getSelection()?.toString().trim(),Q=[];J&&(Q.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(J)}),Q.push({kind:"separator"})),Q.push({kind:"action",label:"Open Conversation",onSelect:()=>F(L)}),L.agentId&&Q.push({kind:"action",label:"Open Observe",onSelect:()=>F(L,{observe:!0})}),Q.push({kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(Y)}),L.id&&Q.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(L.id)}),L.harnessSessionId&&Q.push({kind:"action",label:"Copy Harness Session ID",onSelect:()=>navigator.clipboard.writeText(L.harnessSessionId)}),k(Z,Q)},children:[o.jsxs("div",{className:"s-session-avatar-wrap",children:[o.jsx("div",{className:"s-avatar",style:{background:dt(L.agentName??Y)},"aria-hidden":"true",children:K}),D&&o.jsx("span",{className:"s-session-unread-dot","aria-hidden":"true"})]}),o.jsxs("div",{className:"s-inbox-body",children:[o.jsxs("div",{className:"s-inbox-header",children:[o.jsx("div",{className:"s-session-heading",children:o.jsx("span",{className:"s-inbox-name",title:Y,children:Y})}),o.jsx("div",{className:"s-session-trailing",children:L.lastMessageAt&&o.jsx("span",{className:"s-inbox-time s-tabular",title:dZ(L.lastMessageAt),children:Pe(L.lastMessageAt)})})]}),B?o.jsx("p",{className:"s-inbox-preview",children:B}):o.jsx("p",{className:"s-inbox-preview s-inbox-preview-empty",children:"No messages yet"}),o.jsxs("div",{className:"s-session-meta-row","aria-label":"Conversation details",children:[o.jsx("span",{className:"s-session-pill",children:G}),z&&o.jsxs("span",{className:"s-session-pill",title:z,children:["session · ",z]}),X&&o.jsx("span",{className:"s-session-pill",title:L.workspaceRoot??void 0,children:X}),L.currentBranch&&o.jsx("span",{className:"s-session-pill",title:L.currentBranch,children:L.currentBranch})]})]})]},L.id)})})]})]})}function lj({label:e,count:t,pressed:n,onClick:a}){return o.jsxs("button",{type:"button",className:"s-seg-btn","aria-pressed":n,onClick:a,children:[o.jsx("span",{children:e}),o.jsx("span",{className:"s-seg-count",children:t})]})}var qr=(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))(qr||{});const hZ=[0,1],wT=[1,0],ST=[2,3],jT=[3,2],mZ={L:hZ,M:wT,Q:ST,H:jT},pZ=/^\d*$/,gZ=/^[A-Z0-9 $%*+./:-]*$/,kp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Vv=1,Hv=40,cj=3,vZ=3,Xu=40,yZ=10,NT=[[-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]],kT=[[-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 xZ{constructor(t,n,a,i){if(this.version=t,this.ecc=n,t<Vv||t>Hv)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 c=Array.from({length:this.size}).fill(!1);for(let f=0;f<this.size;f++)this.modules.push(c.slice()),this.types.push(c.map(()=>0));this.drawFunctionPatterns();const u=this.addEccAndInterleave(a);if(this.drawCodewords(u),i===-1){let f=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const h=this.getPenaltyScore();h<f&&(i=m,f=h),this.applyMask(m)}}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 a=0;a<this.size;a++)this.setFunctionModule(6,a,a%2===0,qr.Timing),this.setFunctionModule(a,6,a%2===0,qr.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 a=0;a<n;a++)for(let i=0;i<n;i++)a===0&&i===0||a===0&&i===n-1||a===n-1&&i===0||this.drawAlignmentPattern(t[a],t[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let a=n;for(let c=0;c<10;c++)a=a<<1^(a>>>9)*1335;const i=(n<<10|a)^21522;for(let c=0;c<=5;c++)this.setFunctionModule(8,c,Na(i,c));this.setFunctionModule(8,7,Na(i,6)),this.setFunctionModule(8,8,Na(i,7)),this.setFunctionModule(7,8,Na(i,8));for(let c=9;c<15;c++)this.setFunctionModule(14-c,8,Na(i,c));for(let c=0;c<8;c++)this.setFunctionModule(this.size-1-c,8,Na(i,c));for(let c=8;c<15;c++)this.setFunctionModule(8,this.size-15+c,Na(i,c));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let a=0;a<12;a++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let a=0;a<18;a++){const i=Na(n,a),c=this.size-11+a%3,u=Math.floor(a/3);this.setFunctionModule(c,u,i),this.setFunctionModule(u,c,i)}}drawFinderPattern(t,n){for(let a=-4;a<=4;a++)for(let i=-4;i<=4;i++){const c=Math.max(Math.abs(i),Math.abs(a)),u=t+i,f=n+a;u>=0&&u<this.size&&f>=0&&f<this.size&&this.setFunctionModule(u,f,c!==2&&c!==4,qr.Position)}}drawAlignmentPattern(t,n){for(let a=-2;a<=2;a++)for(let i=-2;i<=2;i++)this.setFunctionModule(t+i,n+a,Math.max(Math.abs(i),Math.abs(a))!==1,qr.Alignment)}setFunctionModule(t,n,a,i=qr.Function){this.modules[n][t]=a,this.types[n][t]=i}addEccAndInterleave(t){const n=this.version,a=this.ecc;if(t.length!==yd(n,a))throw new RangeError("Invalid argument");const i=kT[a[0]][n],c=NT[a[0]][n],u=Math.floor(_g(n)/8),f=i-u%i,m=Math.floor(u/i),h=[],g=TZ(c);for(let b=0,w=0;b<i;b++){const j=t.slice(w,w+m-c+(b<f?0:1));w+=j.length;const N=AZ(j,g);b<f&&j.push(0),h.push(j.concat(N))}const x=[];for(let b=0;b<h[0].length;b++)h.forEach((w,j)=>{(b!==m-c||j>=f)&&x.push(w[b])});return x}drawCodewords(t){if(t.length!==Math.floor(_g(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let a=this.size-1;a>=1;a-=2){a===6&&(a=5);for(let i=0;i<this.size;i++)for(let c=0;c<2;c++){const u=a-c,m=(a+1&2)===0?this.size-1-i:i;!this.types[m][u]&&n<t.length*8&&(this.modules[m][u]=Na(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 a=0;a<this.size;a++){let i;switch(t){case 0:i=(a+n)%2===0;break;case 1:i=n%2===0;break;case 2:i=a%3===0;break;case 3:i=(a+n)%3===0;break;case 4:i=(Math.floor(a/3)+Math.floor(n/2))%2===0;break;case 5:i=a*n%2+a*n%3===0;break;case 6:i=(a*n%2+a*n%3)%2===0;break;case 7:i=((a+n)%2+a*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][a]&&i&&(this.modules[n][a]=!this.modules[n][a])}}getPenaltyScore(){let t=0;for(let c=0;c<this.size;c++){let u=!1,f=0;const m=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[c][h]===u?(f++,f===5?t+=cj:f>5&&t++):(this.finderPenaltyAddHistory(f,m),u||(t+=this.finderPenaltyCountPatterns(m)*Xu),u=this.modules[c][h],f=1);t+=this.finderPenaltyTerminateAndCount(u,f,m)*Xu}for(let c=0;c<this.size;c++){let u=!1,f=0;const m=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[h][c]===u?(f++,f===5?t+=cj:f>5&&t++):(this.finderPenaltyAddHistory(f,m),u||(t+=this.finderPenaltyCountPatterns(m)*Xu),u=this.modules[h][c],f=1);t+=this.finderPenaltyTerminateAndCount(u,f,m)*Xu}for(let c=0;c<this.size-1;c++)for(let u=0;u<this.size-1;u++){const f=this.modules[c][u];f===this.modules[c][u+1]&&f===this.modules[c+1][u]&&f===this.modules[c+1][u+1]&&(t+=vZ)}let n=0;for(const c of this.modules)n=c.reduce((u,f)=>u+(f?1:0),n);const a=this.size*this.size,i=Math.ceil(Math.abs(n*20-a*10)/a)-1;return t+=i*yZ,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,a=[6];for(let i=this.size-7;a.length<t;i-=n)a.splice(1,0,i);return a}}finderPenaltyCountPatterns(t){const n=t[1],a=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(a&&t[0]>=n*4&&t[6]>=n?1:0)+(a&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,a){return t&&(this.finderPenaltyAddHistory(n,a),n=0),n+=this.size,this.finderPenaltyAddHistory(n,a),this.finderPenaltyCountPatterns(a)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function Ea(e,t,n){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let a=t-1;a>=0;a--)n.push(e>>>a&1)}function Na(e,t){return(e>>>t&1)!==0}class Zv{constructor(t,n,a){if(this.mode=t,this.numChars=n,this.bitData=a,n<0)throw new RangeError("Invalid argument");this.bitData=a.slice()}getData(){return this.bitData.slice()}}const bZ=[1,10,12,14],wZ=[2,9,11,13],SZ=[4,8,16,16];function ET(e,t){return e[Math.floor((t+7)/17)+1]}function CT(e){const t=[];for(const n of e)Ea(n,8,t);return new Zv(SZ,e.length,t)}function jZ(e){if(!TT(e))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<e.length;){const a=Math.min(e.length-n,3);Ea(Number.parseInt(e.substring(n,n+a),10),a*3+1,t),n+=a}return new Zv(bZ,e.length,t)}function NZ(e){if(!AT(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 a=kp.indexOf(e.charAt(n))*45;a+=kp.indexOf(e.charAt(n+1)),Ea(a,11,t)}return n<e.length&&Ea(kp.indexOf(e.charAt(n)),6,t),new Zv(wZ,e.length,t)}function kZ(e){return e===""?[]:TT(e)?[jZ(e)]:AT(e)?[NZ(e)]:[CT(CZ(e))]}function TT(e){return pZ.test(e)}function AT(e){return gZ.test(e)}function EZ(e,t){let n=0;for(const a of e){const i=ET(a.mode,t);if(a.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+a.bitData.length}return n}function CZ(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 _g(e){if(e<Vv||e>Hv)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 yd(e,t){return Math.floor(_g(e)/8)-NT[t[0]][e]*kT[t[0]][e]}function TZ(e){if(e<1||e>255)throw new RangeError("Degree out of range");const t=[];for(let a=0;a<e-1;a++)t.push(0);t.push(1);let n=1;for(let a=0;a<e;a++){for(let i=0;i<t.length;i++)t[i]=Og(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=Og(n,2)}return t}function AZ(e,t){const n=t.map(a=>0);for(const a of e){const i=a^n.shift();n.push(0),t.forEach((c,u)=>n[u]^=Og(c,i))}return n}function Og(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let a=7;a>=0;a--)n=n<<1^(n>>>7)*285,n^=(t>>>a&1)*e;return n}function RZ(e,t,n=1,a=40,i=-1,c=!0){if(!(Vv<=n&&n<=a&&a<=Hv)||i<-1||i>7)throw new RangeError("Invalid value");let u,f;for(u=n;;u++){const x=yd(u,t)*8,b=EZ(e,u);if(b<=x){f=b;break}if(u>=a)throw new RangeError("Data too long")}for(const x of[wT,ST,jT])c&&f<=yd(u,x)*8&&(t=x);const m=[];for(const x of e){Ea(x.mode[0],4,m),Ea(x.numChars,ET(x.mode,u),m);for(const b of x.getData())m.push(b)}const h=yd(u,t)*8;Ea(0,Math.min(4,h-m.length),m),Ea(0,(8-m.length%8)%8,m);for(let x=236;m.length<h;x^=253)Ea(x,8,m);const g=Array.from({length:Math.ceil(m.length/8)},()=>0);return m.forEach((x,b)=>g[b>>>3]|=x<<7-(b&7)),new xZ(u,t,g,i)}function MZ(e,t){const{ecc:n="L",boostEcc:a=!1,minVersion:i=1,maxVersion:c=40,maskPattern:u=-1,border:f=1}=t||{},m=typeof e=="string"?kZ(e):Array.isArray(e)?[CT(e)]:void 0;if(!m)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const h=RZ(m,mZ[n],i,c,u,a),g=_Z({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},f);return t?.invert&&(g.data=g.data.map(x=>x.map(b=>!b))),t?.onEncoded?.(g),g}function _Z(e,t=1){if(!t)return e;const{size:n}=e,a=n+t*2;e.size=a,e.data.forEach(c=>{for(let u=0;u<t;u++)c.unshift(!1),c.push(!1)});for(let c=0;c<t;c++)e.data.unshift(Array.from({length:a},u=>!1)),e.data.push(Array.from({length:a},u=>!1));const i=qr.Border;e.types.forEach(c=>{for(let u=0;u<t;u++)c.unshift(i),c.push(i)});for(let c=0;c<t;c++)e.types.unshift(Array.from({length:a},u=>i)),e.types.push(Array.from({length:a},u=>i));return e}function uj(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function OZ(e,t={}){const n=MZ(e,t),{pixelSize:a=10,whiteColor:i="white",blackColor:c="black"}=t,u=n.size*a,f=n.size*a;let m=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${f} ${u}">`;const h=[];for(let g=0;g<n.size;g++)for(let x=0;x<n.size;x++){const b=x*a,w=g*a;n.data[g][x]&&h.push(`M${b},${w}h${a}v${a}h-${a}z`)}return m+=`<rect fill="${uj(i)}" width="${f}" height="${u}"/>`,m+=`<path fill="${uj(c)}" d="${h.join("")}"/>`,m+="</svg>",m}function IZ(e){return e?e.replace(/^wss?:\/\//,"").replace(/:\d+$/,""):null}function dj(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-6)}`:null}function DZ(e){return e?e.status==="paired"||e.status==="connected"?"success":e.status==="error"||e.status==="closed"?"danger":"warning":"warning"}function zZ(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 a=Math.floor(n/60),i=n%60;return i>0?`${a}m ${i}s`:`${a}m`}function fj({value:e}){const[t,n]=v.useState(!1),a=v.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},[e]);return o.jsx("button",{type:"button",className:"sys-copy-btn",onClick:a,title:"Copy",children:t?o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}):o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}function LZ({navigate:e}){const[t,n]=v.useState(null),[a,i]=v.useState(""),[c,u]=v.useState(""),[f,m]=v.useState(!0),[h,g]=v.useState(!1),[x,b]=v.useState(!1),[w,j]=v.useState(null),[N,T]=v.useState(null),[k,C]=v.useState(null),[S,R]=v.useState(null),[A,M]=v.useState(()=>Date.now()),[O,V]=v.useState(null),F=v.useRef(null),I=v.useRef(0),$=v.useRef(null);v.useEffect(()=>{F.current=t},[t]),v.useEffect(()=>{$.current=w},[w]);const L=v.useCallback(async(re="initial")=>{if(re==="background"&&$.current)return;const de=++I.current;!(F.current!==null)&&re!=="background"?(m(!0),T(null)):g(!0);try{const xe=await _e(re==="manual"?"/api/pairing-state/refresh":"/api/pairing-state");if(de!==I.current)return;n(xe),T(null),R(Date.now())}catch(xe){if(de!==I.current)return;T(xe instanceof Error?xe.message:String(xe))}finally{de===I.current&&(m(!1),g(!1))}},[]),U=v.useCallback(async()=>{try{const re=await _e("/api/user");u(re.name),i(re.name),C(null)}catch(re){C(re instanceof Error?re.message:String(re))}},[]),Y=v.useRef(!1);v.useEffect(()=>{L("initial"),U()},[L,U]),v.useEffect(()=>{const re=setInterval(()=>{L("background")},1e4);return()=>clearInterval(re)},[L]),v.useEffect(()=>{if(!t?.pairing?.expiresAt)return;M(Date.now());const re=setInterval(()=>{M(Date.now())},1e3);return()=>clearInterval(re)},[t?.pairing?.expiresAt]);const K=v.useCallback(async()=>{b(!0),C(null);try{const re=await _e("/api/user",{method:"POST",body:JSON.stringify({name:a})});u(re.name),i(re.name)}catch(re){C(re instanceof Error?re.message:String(re))}finally{b(!1)}},[a]),D=v.useCallback(async re=>{const de=++I.current;j(re),T(null);try{const fe=await _e("/api/pairing/control",{method:"POST",body:JSON.stringify({action:re})});if(de!==I.current)return;n(fe),R(Date.now())}catch(fe){if(de!==I.current)return;T(fe instanceof Error?fe.message:String(fe))}finally{de===I.current&&j(null)}},[]);v.useEffect(()=>{!t||t.isRunning||Y.current||(Y.current=!0,D("start"))},[t,D]);const P=v.useCallback(async re=>{V(re);try{await _e(`/api/pairing/peers/${encodeURIComponent(re)}`,{method:"DELETE"}),L("manual")}catch{}finally{V(null)}},[L]),B=v.useMemo(()=>{const re=t?.pairing?.qrValue?.trim();return re?OZ(re,{border:2,ecc:"M",pixelSize:8}):null},[t?.pairing?.qrValue]),G=IZ(t?.pairing?.relay??t?.relay??null),X=zZ(t?.pairing?.expiresAt,A),Z=(t?.trustedPeers.find(re=>re.fingerprint===t.connectedPeerFingerprint)??null)?.name??dj(t?.connectedPeerFingerprint??null),J=DZ(t),Q=a.trim()!==c,pe=!f&&!t&&!!N;return o.jsxs("div",{className:"sys-surface-page sys-settings-page",children:[o.jsxs("div",{className:"sys-page-head",children:[o.jsxs("div",{className:"sys-page-title-group",children:[o.jsx("h2",{className:"sys-page-title",children:"Settings"}),o.jsx("p",{className:"sys-page-subtitle",children:"Identity, pairing, and trusted devices."})]}),o.jsxs("div",{className:"sys-page-actions",children:[t&&o.jsx("span",{className:`sys-chip sys-chip-${J}`,children:t.statusLabel}),o.jsx("div",{className:"sys-sync-note",children:f?"Loading...":N&&t?`Snapshot from ${S?Pe(S):"earlier"}`:S?`Updated ${Pe(S)}`:""}),o.jsx("button",{type:"button",className:"s-btn",disabled:f||h||!!w,onClick:()=>{L("manual")},children:h?"Refreshing...":"Refresh"})]})]}),N&&t&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Refresh failed."}),o.jsx("span",{children:N})]}),k&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Identity error."}),o.jsx("span",{children:k})]}),f&&!t&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"Loading settings"}),o.jsx("p",{className:"sys-state-body",children:"Checking relay status and trusted peers."})]}),pe&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Pairing unavailable"}),o.jsx("p",{className:"sys-state-body",children:N}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{L("manual")},children:"Try again"})})]}),o.jsxs("div",{className:"sys-settings-hero",children:[o.jsx("div",{className:"sys-settings-qr-col",children:B?o.jsxs("div",{className:"sys-settings-qr-frame",children:[o.jsx("div",{className:"s-qr",dangerouslySetInnerHTML:{__html:B}}),X&&o.jsxs("span",{className:"sys-settings-qr-expires",children:["Expires in ",X]})]}):o.jsx("div",{className:"sys-settings-qr-empty",children:o.jsx("span",{className:"sys-settings-qr-empty-label",children:"Generating QR..."})})}),o.jsxs("div",{className:"sys-settings-info-col",children:[o.jsxs("div",{className:"sys-input-row",children:[o.jsx("input",{className:"sys-input",type:"text",placeholder:"Your name",value:a,onChange:re=>i(re.target.value),onKeyDown:re=>{re.key==="Enter"&&Q&&!x&&K()}}),o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!Q||x,onClick:()=>{K()},children:x?"Saving...":"Save"})]}),o.jsxs("div",{className:"sys-settings-kv-list",children:[t?.identityFingerprint&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Fingerprint"}),o.jsxs("span",{className:"sys-settings-kv-value",children:[o.jsx("code",{children:t.identityFingerprint}),o.jsx(fj,{value:t.identityFingerprint})]})]}),G&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Relay"}),o.jsxs("span",{className:"sys-settings-kv-value",children:[o.jsx("code",{children:G}),o.jsx(fj,{value:G})]})]}),t?.statusDetail&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Status"}),o.jsx("span",{className:"sys-settings-kv-value sys-settings-kv-nowrap",children:t.statusDetail})]}),Z&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Connected"}),o.jsx("span",{className:"sys-settings-kv-value",children:Z})]}),t?.secure&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Security"}),o.jsx("span",{className:"sys-settings-kv-value",children:o.jsx("span",{className:"sys-chip sys-chip-success",children:"Noise XX"})})]})]}),t&&o.jsx("div",{className:"sys-inline-actions sys-settings-controls",children:t.isRunning?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{D("restart")},children:w==="restart"?"Restarting...":"Restart"}),o.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{D("stop")},children:w==="stop"?"Stopping...":"Stop"})]}):o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!!w,onClick:()=>{D("start")},children:w==="start"?"Starting...":"Start pairing"})})]})]}),t&&o.jsxs("section",{className:"sys-settings-peers",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Trusted peers"}),o.jsxs("p",{className:"sys-section-subtitle",children:[t.trustedPeers.length," device",t.trustedPeers.length!==1?"s":""," paired with this broker."]})]})}),t.trustedPeers.length===0?o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No trusted peers"}),o.jsx("p",{children:"Devices appear here after completing pairing."})]}):o.jsxs("table",{className:"sys-peers-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Device"}),o.jsx("th",{children:"Fingerprint"}),o.jsx("th",{children:"Paired"}),o.jsx("th",{children:"Last seen"}),o.jsx("th",{})]})}),o.jsx("tbody",{children:t.trustedPeers.map(re=>{const de=re.fingerprint===t.connectedPeerFingerprint;return o.jsxs("tr",{className:de?"sys-peers-row-connected":"",children:[o.jsx("td",{children:o.jsxs("span",{className:"sys-peers-name",children:[re.name??dj(re.fingerprint)??"Peer",de&&o.jsx("span",{className:"sys-chip sys-chip-success sys-peers-badge",children:"Connected"})]})}),o.jsx("td",{children:o.jsx("code",{className:"sys-peers-fp",children:re.fingerprint})}),o.jsx("td",{children:re.pairedAtLabel??"—"}),o.jsx("td",{children:re.lastSeenLabel??"—"}),o.jsx("td",{children:o.jsx("button",{type:"button",className:"sys-peers-remove",disabled:O===re.fingerprint,onClick:()=>{P(re.fingerprint)},title:"Remove peer",children:O===re.fingerprint?"...":"Remove"})})]},re.fingerprint)})})]})]})]})}const $Z=2500,PZ=1e4;function RT(e){const[t,n]=v.useState({}),a=v.useRef(!0),i=v.useRef(!1),c=v.useRef(!1),u=e.map(h=>h.id.trim()).filter(h=>h.length>0).join(","),f=e.some(h=>mt(h.state)==="working")?$Z:PZ,m=v.useCallback(async()=>{if(e.length===0){n({});return}if(i.current){c.current=!0;return}i.current=!0;try{const h=u?`?ids=${encodeURIComponent(u)}`:"",g=await _e(`/api/observe/agents${h}`);if(!a.current)return;n(x=>{const b={};for(const w of e)b[w.id]=x[w.id];for(const w of g){const{agentId:j,...N}=w;b[j]=N}return b})}finally{i.current=!1,c.current&&(c.current=!1,m())}},[u,e]);return v.useEffect(()=>{if(a.current=!0,e.length===0)return n({}),()=>{a.current=!1};m();const h=setInterval(()=>{m()},f);return()=>{a.current=!1,clearInterval(h)}},[e.length,m,f]),vn(m),t}function ar(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 Ll=340,Wd=220,Xi=16,UZ=48,BZ=36,hj=28,Ku=40,MT=180,_T=140;function VZ(e){const t=HZ(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.4))),a=[],i=new Array(n).fill(Ku),c=Array.from({length:n},(m,h)=>Ku+h*(Ll*2+Xi+UZ));for(const m of t){const h=i.indexOf(Math.min(...i)),g=c[h],x=i[h],b=Math.min(2,m.agents.length),w=Math.ceil(m.agents.length/b),j=b*Ll+(b-1)*Xi,N=hj+w*Wd+(w-1)*Xi,T=m.agents.map((k,C)=>{const S=C%b,R=Math.floor(C/b);return{agentId:k.id,x:g+S*(Ll+Xi),y:x+hj+R*(Wd+Xi)}});a.push({label:m.label,x:g,y:x,w:j,h:N,tiles:T}),i[h]=x+N+BZ}const u=Math.max(...c.map((m,h)=>m+Ll*2+Xi))+Ku,f=Math.max(...i)+Ku;return{groups:a,canvasW:u,canvasH:f}}function HZ(e){const t={working:0,available:1,offline:2},n=[...e].sort((c,u)=>{const f=t[mt(c.state)]??1,m=t[mt(u.state)]??1;return f!==m?f-m:c.name.localeCompare(u.name)}),a=new Map;for(const c of n){const u=c.project??"unassigned";a.has(u)||a.set(u,[]),a.get(u).push(c)}const i=[];for(const[c,u]of a)i.push({label:c,agents:u});return i.sort((c,u)=>u.agents.length-c.agents.length),i}function ZZ(e){switch(e.kind){case"tool":return`$ ${ar(e)}`;case"think":return`~ ${ar(e)}`;case"ask":return`↗ ${ar(e)}`;case"message":return`→ ${ar(e)}`;case"note":return`+ ${ar(e)}`;case"system":case"boot":return`▸ ${ar(e)}`}}function OT(e,t,n){const a=n?.events.slice(-8).map(ZZ).filter(Boolean)??[];return a.length>0?a:mt(e.state)==="offline"?["No session trace available"]:["Waiting for session trace…",...t?[`task: ${t}`]:[]]}function FZ(e){switch(mt(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}function qZ({color:e,data:t}){const n=t??[];if(n.length<2)return o.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 a=n.map((i,c)=>`${c/(n.length-1)*100},${20-i*18-1}`).join(" ");return o.jsx("svg",{viewBox:"0 0 100 20",preserveAspectRatio:"none",style:{width:80,height:16},children:o.jsx("polyline",{points:a,fill:"none",stroke:e,strokeWidth:"1"})})}function YZ({navigate:e,agents:t}){const[n,a]=v.useState(null),[i,c]=v.useState(null),u=RT(t),f=v.useCallback(async I=>{await _e(`/api/agents/${encodeURIComponent(I)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]),m=v.useRef(null),[h,g]=v.useState({w:0,h:0}),[x,b]=v.useState({x:0,y:0}),[w,j]=v.useState(1),N=v.useRef(!1),T=v.useRef({x:0,y:0,panX:0,panY:0});v.useEffect(()=>{const I=m.current;if(!I)return;const $=new ResizeObserver(([L])=>{const{width:U,height:Y}=L.contentRect;g({w:U,h:Y})});return $.observe(I),()=>$.disconnect()},[]);const k=v.useCallback(async()=>{try{c(await _e("/api/fleet"))}catch{}},[]);v.useEffect(()=>{k()},[k]),vn(k);const C=v.useMemo(()=>{const I={};for(const $ of i?.activeAsks??[])I[$.agentId]={agentId:$.agentId,task:$.task,summary:$.summary??null};return I},[i]),S=v.useMemo(()=>VZ(t),[t]);v.useEffect(()=>{if(S.canvasW===0||h.w===0)return;const I=Math.min(1,h.w/S.canvasW,h.h/S.canvasH),$=Math.max(.15,Math.min(1,I*.92));b({x:(h.w-S.canvasW*$)/2,y:Math.max(8,(h.h-S.canvasH*$)/2)}),j($)},[S,h]);const R=v.useCallback(I=>{I.target.closest(".s-conductor-tile")||(N.current=!0,T.current={x:I.clientX,y:I.clientY,panX:x.x,panY:x.y})},[x]),A=v.useCallback(I=>{N.current&&b({x:T.current.panX+(I.clientX-T.current.x),y:T.current.panY+(I.clientY-T.current.y)})},[]),M=v.useCallback(()=>{N.current=!1},[]);v.useEffect(()=>{const I=m.current;if(!I)return;const $=L=>{L.preventDefault();const U=I.getBoundingClientRect(),Y=L.clientX-U.left,K=L.clientY-U.top,D=L.deltaY>0?.92:1.08,P=Math.max(.2,Math.min(2,w*D)),B=P/w;b(G=>({x:Y-(Y-G.x)*B,y:K-(K-G.y)*B})),j(P)};return I.addEventListener("wheel",$,{passive:!1}),()=>I.removeEventListener("wheel",$)},[w]);const O=n?t.find(I=>I.id===n):null;v.useEffect(()=>{if(!O)return;const I=$=>{$.key==="Escape"&&a(null)};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[O]);const V=v.useCallback(I=>{const $=m.current;if(!$)return;const L=I.currentTarget.getBoundingClientRect(),U=I.clientX-L.left,Y=I.clientY-L.top,K=Math.min(MT/S.canvasW,_T/S.canvasH),D=U/K,P=Y/K,B=$.clientWidth,G=$.clientHeight;b({x:B/2-D*w,y:G/2-P*w})},[S,w]),F=v.useMemo(()=>{const I={};for(const $ of S.groups)for(const L of $.tiles)I[L.agentId]={x:L.x,y:L.y};return I},[S]);return o.jsxs("div",{className:"s-conductor",children:[o.jsxs("div",{className:"s-conductor-bar",children:[o.jsxs("span",{className:"s-conductor-bar-label",children:[t.length," agent",t.length!==1?"s":""," ·"," ",S.groups.length," workspace",S.groups.length!==1?"s":""]}),o.jsxs("div",{className:"s-conductor-hotkeys",children:[o.jsxs("span",{className:"s-conductor-hotkey",children:[o.jsx("kbd",{children:"F"})," Freeze all"]}),o.jsxs("span",{className:"s-conductor-hotkey",children:[o.jsx("kbd",{children:"B"})," Broadcast"]}),o.jsxs("span",{className:"s-conductor-hotkey",children:[o.jsx("kbd",{children:"R"})," Route ask"]})]})]}),o.jsxs("div",{ref:m,className:"s-conductor-viewport",onMouseDown:R,onMouseMove:A,onMouseUp:M,onMouseLeave:M,children:[o.jsxs("div",{className:"s-conductor-canvas",style:{transform:`translate(${x.x}px, ${x.y}px) scale(${w})`},children:[S.groups.map(I=>o.jsx("div",{className:"s-conductor-group-label",style:{left:I.x,top:I.y},children:I.label},I.label)),t.map(I=>{const $=F[I.id];return $?o.jsx(XZ,{agent:I,task:C[I.id]??null,observe:u[I.id]?.data??null,x:$.x,y:$.y,onClick:()=>a(I.id)},I.id):null})]}),o.jsx(GZ,{layout:S,agents:t,pan:x,zoom:w,viewportRef:m,onClick:V})]}),O&&o.jsx(WZ,{agent:O,task:C[O.id]??null,observe:u[O.id]?.data??null,onClose:()=>a(null),onTell:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"tell"})},onAsk:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"ask"})},onFreeze:mt(O.state)==="working"?()=>{a(null),f(O.id)}:void 0,onOpenProfile:()=>{a(null),e({view:"agents",agentId:O.id})}})]})}function GZ({layout:e,agents:t,pan:n,zoom:a,viewportRef:i,onClick:c}){if(e.canvasW===0||t.length===0)return null;const u=Math.min(MT/e.canvasW,_T/e.canvasH),f=e.canvasW*u,m=e.canvasH*u,h=i.current,g=h?.clientWidth??0,x=h?.clientHeight??0,b=-n.x/a*u,w=-n.y/a*u,j=g/a*u,N=x/a*u;return o.jsxs("div",{className:"s-conductor-minimap",style:{width:f,height:m,opacity:.85},onClick:c,children:[e.groups.map(T=>o.jsx("div",{className:"s-conductor-minimap-group",style:{left:T.x*u,top:T.y*u},children:T.label},T.label)),e.groups.flatMap(T=>T.tiles.map(k=>{const C=t.find(S=>S.id===k.agentId);return o.jsx("div",{className:"s-conductor-minimap-tile",style:{left:k.x*u,top:k.y*u,width:Ll*u,height:Wd*u,background:C?dt(C.name):"var(--dim)",opacity:C&&mt(C.state)==="working"?.8:.35}},k.agentId)})),o.jsx("div",{className:"s-conductor-minimap-viewport",style:{left:Math.max(0,b),top:Math.max(0,w),width:Math.min(j,f),height:Math.min(N,m)}})]})}function WZ({agent:e,task:t,observe:n,onClose:a,onTell:i,onAsk:c,onFreeze:u,onOpenProfile:f}){const m=OT(e,t?.summary??null,n);return o.jsx("div",{className:"s-conductor-overlay",onClick:a,children:o.jsxs("div",{className:"s-conductor-overlay-panel",onClick:h=>h.stopPropagation(),children:[o.jsxs("div",{className:"s-conductor-overlay-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"32px",background:dt(e.name)},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:16,fontWeight:500},children:[e.name," ",o.jsx("span",{style:{color:"var(--dim)",fontSize:12},children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-conductor-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"s-ops-btn",onClick:a,children:"ESC"})]}),o.jsxs("div",{className:"s-conductor-overlay-body",children:[o.jsx("div",{className:"s-conductor-overlay-task",children:t?.task??"No active task"}),o.jsxs("div",{className:"s-conductor-overlay-detail",children:["› ",t?.summary??aa(e.state)]}),o.jsxs("div",{className:"s-conductor-terminal",style:{height:"auto",minHeight:160},children:[m.map((h,g)=>o.jsx("div",{className:`s-conductor-terminal-line${h.startsWith("$")?" s-conductor-terminal-line--cmd":""}${h.startsWith("→")||h.startsWith("+")?" s-conductor-terminal-line--result":""}`,children:h},g)),mt(e.state)==="working"&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]})]}),o.jsxs("div",{className:"s-conductor-overlay-footer",children:[o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:i,children:"Send instruction"}),o.jsx("button",{className:"s-ops-btn",onClick:u,disabled:!u,children:"Freeze"}),o.jsx("button",{className:"s-ops-btn",onClick:c,children:"Route ask"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"s-ops-btn",onClick:f,children:"Open profile ↗"})]})]})})}function XZ({agent:e,task:t,observe:n,x:a,y:i,onClick:c}){const u=dt(e.name),f=FZ(e.state),m=aa(e.state).toUpperCase(),h=OT(e,t?.summary??null,n),g=mt(e.state)==="working",x=n?.events[n.events.length-1],b=x?ar(x):t?.summary??aa(e.state);return o.jsxs("div",{className:"s-conductor-tile",style:{left:a,top:i,height:Wd},onClick:w=>{w.stopPropagation(),c()},children:[o.jsxs("div",{className:"s-conductor-tile-identity",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"24px",background:u},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{className:"s-conductor-tile-identity-copy",children:[o.jsxs("div",{className:"s-conductor-tile-name",children:[e.name,o.jsx("span",{className:"s-conductor-tile-handle",children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-conductor-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),o.jsx("span",{className:"s-ops-state-chip",style:{color:f},children:m})]}),o.jsx("div",{className:"s-conductor-tile-task",children:t?.task??"No active task"}),o.jsxs("div",{className:"s-conductor-terminal",children:[h.slice(-4).map((w,j)=>o.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,h.length)},children:w},j)),g&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]}),o.jsxs("div",{className:"s-conductor-tile-footer",children:[o.jsx(qZ,{color:u,data:n?.contextUsage}),o.jsx("span",{className:"s-conductor-tile-detail",children:b}),g&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]})]})}const $l=420,Xd=320,Ki=20,KZ=48,JZ=36,mj=28,Ju=40,IT=180,DT=140,zT="scout_mc_vp";function QZ(e){try{localStorage.setItem(zT,JSON.stringify(e))}catch{}}function eF(){try{const e=localStorage.getItem(zT);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 tF(e){const t=nF(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.2))),a=[],i=new Array(n).fill(Ju),c=Array.from({length:n},(m,h)=>Ju+h*($l*2+Ki+KZ));for(const m of t){const h=i.indexOf(Math.min(...i)),g=c[h],x=i[h],b=Math.min(2,m.agents.length),w=Math.ceil(m.agents.length/b),j=b*$l+(b-1)*Ki,N=mj+w*Xd+(w-1)*Ki,T=m.agents.map((k,C)=>({agentId:k.id,x:g+C%b*($l+Ki),y:x+mj+Math.floor(C/b)*(Xd+Ki)}));a.push({label:m.label,x:g,y:x,w:j,h:N,tiles:T}),i[h]=x+N+JZ}const u=Math.max(...c.map(m=>m+$l*2+Ki))+Ju,f=Math.max(...i)+Ju;return{groups:a,canvasW:u,canvasH:f}}function nF(e){const t={working:0,available:1,offline:2},n=[...e].sort((c,u)=>{const f=t[mt(c.state)]??1,m=t[mt(u.state)]??1;return f!==m?f-m:c.name.localeCompare(u.name)}),a=new Map;for(const c of n){const u=c.project??"unassigned";a.has(u)||a.set(u,[]),a.get(u).push(c)}const i=[];for(const[c,u]of a)i.push({label:c,agents:u});return i.sort((c,u)=>u.agents.length-c.agents.length),i}const sF={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},aF={think:"think",tool:"tool",ask:"ask",message:"msg",note:"note",system:"sys",boot:"boot"};function rF({navigate:e,agents:t}){const[n,a]=v.useState(null),i=RT(t),c=v.useRef(null),[u,f]=v.useState({w:0,h:0}),[m,h]=v.useState({x:0,y:0}),[g,x]=v.useState(1),[b,w]=v.useState(!1),j=v.useRef(!1),N=v.useRef({x:0,y:0,panX:0,panY:0}),T=v.useRef(!1);v.useEffect(()=>{const $=c.current;if(!$)return;const L=new ResizeObserver(([U])=>{f({w:U.contentRect.width,h:U.contentRect.height})});return L.observe($),()=>L.disconnect()},[]);const k=v.useMemo(()=>tF(t),[t]),C=v.useRef([]),S=v.useCallback(($=!0)=>{if(k.canvasW===0||u.w===0)return;C.current.forEach(clearTimeout);const L=Math.min(1,u.w/k.canvasW,u.h/k.canvasH),U=Math.max(.15,Math.min(1,L*.92));w(!1),x(U),h({x:(u.w-k.canvasW*U)/2,y:Math.max(8,(u.h-k.canvasH*U)/2)});const Y=setTimeout(()=>{w(!0);const D=$?eF():null;D?(h(D.pan),x(D.zoom)):(h({x:24,y:24}),x(.55))},700),K=setTimeout(()=>w(!1),1700);C.current=[Y,K]},[k,u]);v.useEffect(()=>{k.canvasW===0||u.w===0||T.current||(T.current=!0,S(!0))},[k,u,S]),v.useEffect(()=>{const $=setInterval(()=>{QZ({pan:m,zoom:g})},3e4);return()=>clearInterval($)},[m,g]);const R=v.useCallback($=>{$.target.closest(".s-mission-tile")||(j.current=!0,N.current={x:$.clientX,y:$.clientY,panX:m.x,panY:m.y})},[m]),A=v.useCallback($=>{j.current&&h({x:N.current.panX+($.clientX-N.current.x),y:N.current.panY+($.clientY-N.current.y)})},[]),M=v.useCallback(()=>{j.current=!1},[]);v.useEffect(()=>{const $=c.current;if(!$)return;const L=U=>{U.preventDefault();const Y=$.getBoundingClientRect(),K=U.clientX-Y.left,D=U.clientY-Y.top,P=U.deltaY>0?.92:1.08,B=Math.max(.2,Math.min(2,g*P)),G=B/g;h(X=>({x:K-(K-X.x)*G,y:D-(D-X.y)*G})),x(B)};return $.addEventListener("wheel",L,{passive:!1}),()=>$.removeEventListener("wheel",L)},[g]);const O=n?t.find($=>$.id===n):null;v.useEffect(()=>{const $=L=>{L.target.tagName==="INPUT"||L.target.tagName==="TEXTAREA"||(L.key==="Escape"&&a(null),(L.key==="h"||L.key==="H")&&S(!1))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[O,S]);const V=v.useCallback($=>{const L=$.currentTarget.getBoundingClientRect(),U=$.clientX-L.left,Y=$.clientY-L.top,K=Math.min(IT/k.canvasW,DT/k.canvasH),D=U/K,P=Y/K,B=c.current;B&&h({x:B.clientWidth/2-D*g,y:B.clientHeight/2-P*g})},[k,g]),F=v.useMemo(()=>{const $={};for(const L of k.groups)for(const U of L.tiles)$[U.agentId]={x:U.x,y:U.y};return $},[k]),I=t.filter($=>mt($.state)==="working").length;return o.jsxs("div",{className:"s-mission",children:[o.jsxs("div",{className:"s-mission-bar",children:[o.jsxs("span",{className:"s-mission-bar-label",children:[t.length," agent",t.length!==1?"s":""," ·"," ",k.groups.length," workspace",k.groups.length!==1?"s":""]}),I>0&&o.jsxs("span",{className:"s-mission-bar-live",children:[o.jsx("span",{className:"s-mission-bar-live-dot"}),I," active"]}),o.jsxs("div",{className:"s-mission-hotkeys",children:[o.jsxs("button",{className:"s-mission-hotkey s-mission-hotkey--btn",onClick:()=>S(!1),title:"Reset to overview",children:[o.jsx("kbd",{children:"H"})," Home"]}),o.jsxs("span",{className:"s-mission-hotkey",children:[o.jsx("kbd",{children:"Esc"})," Close focus"]})]})]}),o.jsxs("div",{ref:c,className:"s-mission-viewport",onMouseDown:R,onMouseMove:A,onMouseUp:M,onMouseLeave:M,children:[t.length===0?o.jsxs("div",{className:"s-mission-empty",children:[o.jsx("div",{className:"s-mission-empty-title",children:"Mission Control"}),o.jsx("div",{className:"s-mission-empty-sub",children:"Connect agents to observe their sessions here."})]}):o.jsxs("div",{className:"s-mission-canvas",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${g})`,transition:b?"transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94)":"none"},children:[k.groups.map($=>o.jsx("div",{className:"s-mission-group-label",style:{left:$.x,top:$.y},children:$.label},$.label)),t.map($=>{const L=F[$.id];if(!L)return null;const U=i[$.id];return o.jsx(iF,{agent:$,observe:U?.data??null,x:L.x,y:L.y,onClick:()=>a($.id)},$.id)})]}),t.length>0&&o.jsx(lF,{layout:k,agents:t,pan:m,zoom:g,viewportRef:c,onClick:V})]}),O&&o.jsx(oF,{agent:O,observe:i[O.id]?.data??null,onClose:()=>a(null),onTell:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"tell"})},onAsk:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"ask"})},onProfile:()=>{a(null),e({view:"agents",agentId:O.id})}})]})}function iF({agent:e,observe:t,x:n,y:a,onClick:i}){const c=v.useRef(null),u=mt(e.state),f=dt(e.name),m=t?.events??[],h=m.slice(-8),g=t?.live===!0,x=m.some(T=>T.kind==="ask"&&!T.answer),b=t?.contextUsage,w=b&&b.length>0?Math.round(b[b.length-1]*100):null,j=m.filter(T=>T.kind==="tool").length,N=m.filter(T=>T.kind==="tool"&&T.tool==="edit").length;return v.useEffect(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight)},[m.length]),o.jsxs("div",{className:`s-mission-tile${u==="working"?" s-mission-tile--working":""}${x?" s-mission-tile--asking":""}`,style:{left:n,top:a,height:Xd},onClick:T=>{T.stopPropagation(),i()},children:[o.jsxs("div",{className:"s-mission-tile-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:f},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{className:"s-mission-tile-identity",children:[o.jsxs("div",{className:"s-mission-tile-name",children:[e.name,o.jsx("span",{className:"s-mission-tile-handle",children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-mission-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),o.jsx("span",{className:"s-ops-state-chip",style:{color:cF(u)},children:aa(e.state).toUpperCase()})]}),o.jsx("div",{className:"s-mission-tile-stream",ref:c,children:h.length===0?o.jsx("div",{className:"s-mission-tile-stream-inner",children:o.jsxs("div",{className:"s-mission-evt",children:[o.jsx("span",{className:"s-mission-evt-bead",style:{background:"var(--dim)"}}),o.jsx("span",{className:"s-mission-evt-text",style:{color:"var(--dim)"},children:u==="offline"?"No session data":"Waiting for events…"})]})}):o.jsx("div",{className:"s-mission-tile-stream-inner",children:h.map(T=>o.jsxs("div",{className:"s-mission-evt",children:[o.jsx("span",{className:"s-mission-evt-bead",style:{background:sF[T.kind]??"var(--dim)"}}),o.jsx("span",{className:"s-mission-evt-kind",children:aF[T.kind]??T.kind}),o.jsxs("span",{className:`s-mission-evt-text s-mission-evt-text--${T.kind}`,children:[ar(T),T.live&&o.jsx("span",{className:"s-observe-cursor"})]})]},T.id))})}),o.jsxs("div",{className:"s-mission-tile-footer",children:[w!==null&&o.jsx("div",{className:"s-mission-tile-ctx",title:`Context: ${w}%`,children:o.jsx("div",{className:"s-mission-tile-ctx-fill",style:{width:`${w}%`}})}),o.jsxs("div",{className:"s-mission-tile-stats",children:[j>0&&o.jsxs("span",{children:[j," tools"]}),N>0&&o.jsxs("span",{children:[N," edits"]})]}),g&&o.jsxs("span",{className:"s-mission-tile-live",children:[o.jsx("span",{className:"s-mission-tile-live-dot"}),"LIVE"]})]})]})}function oF({agent:e,observe:t,onClose:n,onTell:a,onAsk:i,onProfile:c}){const u=dt(e.name);return o.jsx("div",{className:"s-mission-overlay",onClick:n,children:o.jsxs("div",{onClick:f=>f.stopPropagation(),style:{display:"contents"},children:[o.jsxs("div",{className:"s-mission-overlay-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"28px",background:u},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-mission-overlay-name",children:[e.name," ",o.jsx("span",{style:{color:"var(--dim)",fontSize:11},children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-mission-overlay-meta",children:[e.project??"—"," · ",e.branch??"main"," · ",aa(e.state)]})]}),o.jsxs("div",{className:"s-mission-overlay-actions",children:[o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:a,children:"Tell"}),o.jsx("button",{className:"s-ops-btn",onClick:i,children:"Ask"}),o.jsx("button",{className:"s-ops-btn",onClick:c,children:"Profile ↗"}),o.jsx("button",{className:"s-ops-btn",onClick:n,children:"ESC"})]})]}),o.jsx("div",{className:"s-mission-overlay-body",children:o.jsx(bT,{data:t??void 0,agentId:e.id})})]})})}function lF({layout:e,agents:t,pan:n,zoom:a,viewportRef:i,onClick:c}){if(e.canvasW===0)return null;const u=Math.min(IT/e.canvasW,DT/e.canvasH),f=e.canvasW*u,m=e.canvasH*u,h=i.current,g=h?.clientWidth??0,x=h?.clientHeight??0,b=-n.x/a*u,w=-n.y/a*u,j=g/a*u,N=x/a*u;return o.jsxs("div",{className:"s-mission-minimap",style:{width:f,height:m},onClick:c,children:[e.groups.map(T=>o.jsx("div",{className:"s-mission-minimap-group",style:{left:T.x*u,top:T.y*u},children:T.label},T.label)),e.groups.flatMap(T=>T.tiles.map(k=>{const C=t.find(S=>S.id===k.agentId);return o.jsx("div",{className:"s-mission-minimap-tile",style:{left:k.x*u,top:k.y*u,width:$l*u,height:Xd*u,background:C?dt(C.name):"var(--dim)",opacity:C&&mt(C.state)==="working"?.8:.35}},k.agentId)})),o.jsx("div",{className:"s-mission-minimap-viewport",style:{left:Math.max(0,b),top:Math.max(0,w),width:Math.min(j,f),height:Math.min(N,m)}})]})}function cF(e){switch(e){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const LT={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 $T(e){const t=[e];return e.children&&e.children.forEach(n=>t.push(...$T(n))),t}function PT(e,t){if(e.id===t)return e;if(!e.children)return null;for(const n of e.children){const a=PT(n,t);if(a)return a}return null}function pj(e,t){return $T(e).filter(n=>n.kind==="task"&&n.assigneeId===t).length}function bf(e){switch(e){case"done":return 1;case"inflight":return .7;case"committed":return .32;case"stuck":return .18;default:return .1}}function uF(e){return(e.currentPhase||e.state).replace(/\s+/g," ")}function UT(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 BT(e){switch(e.status){case"working":return"inflight";case"completed":return"done";case"needs_attention":case"failed":return"stuck";default:return"committed"}}function gj(e){const t=UT(e);return t==="stuck"?"attention":t==="inflight"?"active":"committed"}function dF(e){const t=BT(e);return t==="stuck"?"attention":t==="inflight"?"active":"committed"}function wf(e,t){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.round((t-e)/6e4))}function Fv(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 VT(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function Ep(e,t){const n=UT(e),a=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:a,why:e.summary??`Current phase: ${uF(e)}`,progress:bf(n),stuckMins:n==="stuck"?wf(e.lastMeaningfulAt,t):null,updatedAt:e.lastMeaningfulAt,route:{view:"work",workId:e.id}}}function fF(e,t){const n=BT(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:bf(n),stuckMins:n==="stuck"?wf(e.updatedAt,t):null,updatedAt:e.updatedAt,route:VT(e)}}function hF(e,t){return{id:`attention:${e.recordId}`,kind:"task",title:e.title,summary:e.summary,state:"stuck",assigneeId:e.agentId,detail:e.summary??e.state.replace(/_/g," "),why:e.kind==="question"?"Operator input is required before this can move again.":"This work item is blocked on a review, decision, or reply.",progress:bf("stuck"),stuckMins:wf(e.updatedAt,t),updatedAt:e.updatedAt,route:Fv(e)}}function Cp(e,t){return(t.updatedAt??0)-(e.updatedAt??0)}function Tp(e,t,n,a,i){return{id:`lane:${e}`,kind:"phase",title:t,summary:n,state:a,assigneeId:null,detail:n,why:n,progress:bf(a),stuckMins:null,updatedAt:i[0]?.updatedAt??null,route:{view:"fleet"},children:i}}function mF(e,t,n,a){return e>0?"Resolve blockers before the queue widens":t>0?"Keep the live queue moving":n>0?"Commit the next slice of work":a>0?"Stand up the next unit of work":"No live operational plan yet"}function pF(e,t,n,a){return e===0&&t===0?a>0?`${a} agent${a===1?" is":"s are"} connected, but no work items or asks are active yet.`:"Bring agents online or dispatch the first ask to light up the plan surface.":`${e} live work item${e===1?"":"s"}, ${t} active ask${t===1?"":"s"}, and ${n} item${n===1?"":"s"} currently need operator awareness.`}function gF(e,t){return`Derived from live collaboration records, active asks, and recent fleet activity. This surface now reflects the current checkout instead of a canned mission narrative. ${e>0?`You have ${e} active work records in play.`:"No work records are active yet."} ${t>0?`${t} recent fleet events are informing the live view.`:"Recent fleet activity is quiet right now."}`}function vF(e,t,n){const a=[];for(const i of e.slice(0,4))a.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(a.length>=4)break;i.attention==="interrupt"&&a.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(a.length>=4)break;i.status==="failed"&&a.push({id:`risk:ask:${i.invocationId}`,title:i.task,detail:i.summary??"The delegated ask reported a failure state.",severity:"high"})}return a}function yF({navigate:e,agents:t}){const[n,a]=v.useState(null),[i,c]=v.useState([]),[u,f]=v.useState(null),[m,h]=v.useState("plan"),[g,x]=v.useState(()=>Date.now()),b=v.useCallback(async()=>{const[k,C]=await Promise.allSettled([_e("/api/fleet"),_e("/api/work")]);k.status==="fulfilled"&&a(k.value),C.status==="fulfilled"&&c(C.value),x(Date.now())},[]);v.useEffect(()=>{b()},[b]),vn(b),v.useEffect(()=>{const k=setInterval(()=>x(Date.now()),15e3);return()=>clearInterval(k)},[]);const w=v.useMemo(()=>Object.fromEntries(t.map(k=>[k.id,k])),[t]),j=v.useMemo(()=>t.filter(k=>mt(k.state)!=="offline").length,[t]),N=v.useMemo(()=>{const k=[],C=[],S=[],R=new Set,A=new Map(i.map($=>[$.id,$]));for(const $ of n?.needsAttention??[]){const L=A.get($.recordId);if(L){const U=Ep(L,g);k.push({...U,state:"stuck",detail:$.summary??U.detail,why:$.summary??U.summary??U.why,stuckMins:wf($.updatedAt,g),updatedAt:$.updatedAt,route:U.route??Fv($)}),R.add(L.id)}else k.push(hF($,g))}for(const $ of n?.activeAsks??[]){const L=$.collaborationRecordId??null,U=L?A.get(L):null;if(!(U&&R.has(U.id)))if(U){const Y=Ep(U,g),K=gj(U);K==="attention"?k.push(Y):K==="active"?C.push(Y):S.push(Y),R.add(U.id)}else{const Y=fF($,g),K=dF($);K==="attention"?k.push(Y):K==="active"?C.push(Y):S.push(Y)}}for(const $ of i){if(R.has($.id))continue;const L=Ep($,g),U=gj($);U==="attention"?k.push(L):U==="active"?C.push(L):S.push(L)}k.sort(Cp),C.sort(Cp),S.sort(Cp);const M=[];k.length>0&&M.push(Tp("attention","Needs input",`${k.length} item${k.length===1?"":"s"} are waiting on an answer, decision, or unblock.`,"stuck",k)),C.length>0&&M.push(Tp("active","In flight",`${C.length} item${C.length===1?"":"s"} are currently moving through the fleet.`,"inflight",C)),S.length>0&&M.push(Tp("committed","Committed next",`${S.length} item${S.length===1?"":"s"} are queued or ready to be picked up next.`,"committed",S));const O=[...k,...C,...S],V={id:"plan:root",kind:"mission",title:mF(k.length,C.length,S.length,j),summary:pF(i.length,n?.activeAsks.length??0,k.length,j),state:k.length>0?"stuck":C.length>0?"inflight":S.length>0?"committed":"proposed",assigneeId:null,detail:null,why:gF(i.length,n?.activity.length??0),progress:O.length>0?O.reduce(($,L)=>$+(L.progress??0),0)/O.length:0,stuckMins:null,updatedAt:n?.generatedAt??null,route:{view:"fleet"},badge:`${O.length} live item${O.length===1?"":"s"}`,children:M},F=vF(n?.needsAttention??[],n?.activeAsks??[],i),I=(n?.recentCompleted??[]).slice(0,4);return{root:V,leafNodes:O,risks:F,recentCompleted:I,pendingAttention:n?.needsAttention??[],counts:{done:I.length,inflight:C.length,stuck:k.length}}},[n,g,j,i]),T=u?PT(N.root,u):null;return v.useEffect(()=>{T||f(N.leafNodes[0]?.id??N.root.id)},[N.leafNodes,N.root.id,T]),o.jsx("div",{className:"s-plan",children:o.jsxs("div",{className:"s-plan-inner",children:[o.jsxs("div",{className:"s-plan-banner",children:[o.jsx("span",{className:"s-plan-banner-badge",children:"◉ Live plan"}),o.jsxs("span",{className:"s-plan-banner-meta",children:[i.length," work item",i.length===1?"":"s"," · ",n?.activeAsks.length??0," active ask",(n?.activeAsks.length??0)===1?"":"s"," · ",N.pendingAttention.length," waiting on you"]}),o.jsx("span",{style:{flex:1}}),n&&o.jsxs("span",{className:"s-plan-banner-meta",children:["updated ",Pe(n.generatedAt)]}),o.jsx("button",{className:"s-ops-btn",onClick:()=>e({view:"fleet"}),children:"Open fleet"}),o.jsx("button",{className:"s-ops-btn",onClick:()=>e({view:"sessions"}),children:"Sessions"})]}),o.jsxs("div",{className:"s-plan-col",children:[o.jsx("div",{className:"s-ops-eyebrow",children:"◇ Mission"}),o.jsx("h1",{className:"s-plan-title",children:N.root.title}),o.jsx("p",{className:"s-plan-goal",children:N.root.summary}),o.jsx("div",{className:"s-ops-eyebrow",children:"Derived from live state"}),o.jsx("p",{className:"s-plan-rationale",children:N.root.why}),o.jsx("div",{className:"s-ops-eyebrow",children:"Risks · watch"}),N.risks.length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No active blockers"}),o.jsx("div",{className:"s-plan-change-why",children:"The queue is clear of explicit questions, failed asks, and blocked work items."})]}):N.risks.map(k=>o.jsx(jF,{risk:k},k.id)),o.jsx("div",{className:"s-ops-eyebrow",style:{marginTop:24},children:"Agents on mission"}),t.filter(k=>pj(N.root,k.id)>0).length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No assigned work yet"}),o.jsx("div",{className:"s-plan-change-why",children:"As soon as asks and work items have clear owners, this roster will show who is carrying what."})]}):t.map(k=>{const C=pj(N.root,k.id);return C===0?null:o.jsxs("div",{className:"s-plan-agent-row",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:dt(k.name)},children:k.name[0]?.toUpperCase()}),o.jsxs("div",{className:"s-plan-agent-row-copy",children:[o.jsx("div",{className:"s-plan-agent-row-name",children:k.name}),o.jsxs("div",{className:"s-plan-agent-row-tasks",children:[C," item",C===1?"":"s"," assigned"]})]})]},k.id)})]}),o.jsxs("div",{className:"s-plan-col",style:{padding:"20px 16px 40px"},children:[o.jsxs("div",{className:"s-plan-tree-header",children:[o.jsx("div",{className:"s-ops-eyebrow",style:{marginBottom:0},children:"◆ Execution tree"}),o.jsxs("span",{className:"s-plan-tree-stats",children:[N.leafNodes.length," items · ",N.counts.done," recent done · ",N.counts.inflight," in flight · ",N.counts.stuck," stuck"]}),o.jsx("div",{className:"s-plan-tree-toggle",children:["plan","live"].map(k=>o.jsx("button",{className:`s-plan-tree-toggle-btn${m===k?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>h(k),children:k},k))})]}),N.root.children&&N.root.children.length>0?o.jsx(HT,{node:N.root,depth:0,mode:m,selected:u??N.root.id,setSelected:f,agentsById:w,nowMs:g}):o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No live plan records yet"}),o.jsx("div",{className:"s-plan-change-why",children:"The execution tree is populated from live work items and active asks. Dispatch work and it will appear here automatically."})]})]}),o.jsxs("div",{className:"s-plan-col",style:{display:"flex",flexDirection:"column",gap:24},children:[o.jsxs("div",{children:[o.jsxs("div",{className:"s-ops-eyebrow",children:["↻ Attention queue · ",N.pendingAttention.length]}),N.pendingAttention.length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"Nothing is waiting on you"}),o.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."})]}):N.pendingAttention.map(k=>o.jsx(wF,{item:k,navigate:e},k.recordId))]}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-ops-eyebrow",children:["✓ Recent finishes · ",N.recentCompleted.length]}),N.recentCompleted.length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No recent completions"}),o.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."})]}):N.recentCompleted.map(k=>o.jsx(SF,{ask:k,navigate:e},k.invocationId))]}),T&&o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-eyebrow",children:"◎ Selected"}),o.jsx(NF,{node:T,agentsById:w,navigate:e})]})]})]})})}function HT({node:e,depth:t,mode:n,selected:a,setSelected:i,agentsById:c,nowMs:u}){const f=e.children&&e.children.length>0;return o.jsxs("div",{children:[o.jsx(xF,{node:e,depth:t,mode:n,selected:a===e.id,onClick:()=>i(e.id),agentsById:c,nowMs:u}),f&&o.jsx("div",{className:t===0?void 0:"s-plan-node-children",children:e.children.map(m=>o.jsx(HT,{node:m,depth:t+1,mode:n,selected:a,setSelected:i,agentsById:c,nowMs:u},m.id))})]})}function xF({node:e,depth:t,mode:n,selected:a,onClick:i,agentsById:c,nowMs:u}){const f=LT[e.state],m=e.assigneeId?c[e.assigneeId]:null,h=e.kind==="mission",g=e.kind==="phase",x=h?"mission":g?"phase":"task";return o.jsxs("div",{className:`s-plan-node s-plan-node--${x}${a?" s-plan-node--selected":""}`,onClick:i,children:[!h&&o.jsx("span",{className:"s-plan-node-icon",style:{color:f.color},children:f.icon}),o.jsxs("div",{className:"s-plan-node-title-wrap",children:[o.jsx("div",{className:"s-plan-node-title-row",style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:o.jsx("span",{className:`s-plan-node-title s-plan-node-title--${x}${e.state==="done"?" s-plan-node-title--done":""}`,children:e.title})}),o.jsx("div",{className:`s-plan-node-payload${n==="live"?" s-plan-node-payload--live":""}`,children:n==="plan"?o.jsx("span",{children:e.why??e.summary??"—"}):o.jsx(bF,{node:e,nowMs:u})})]}),!h&&o.jsx("div",{className:"s-plan-node-assignee",children:m?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:dt(m.name)},children:m.name[0]?.toUpperCase()}),o.jsx("span",{className:"s-plan-node-assignee-handle",children:m.handle?`@${m.handle}`:m.name})]}):o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10.5,color:"var(--dim)"},children:"unassigned"})}),!h&&o.jsxs("div",{className:"s-plan-node-right",children:[o.jsx("div",{className:"s-plan-confidence-bar",children:o.jsx("div",{className:"s-plan-confidence-bar-fill",style:{width:`${(e.progress??0)*100}%`,background:f.color}})}),o.jsx("span",{className:"s-ops-state-chip",style:{color:f.color},children:f.label})]}),h&&o.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:10.5,color:"var(--dim)",letterSpacing:"0.08em"},children:e.badge??"LIVE"})]})}function bF({node:e,nowMs:t}){return e.state==="done"?o.jsxs("span",{style:{opacity:.55},children:["✓ completed ",e.updatedAt?Pe(e.updatedAt):"recently"]}):e.state==="stuck"?o.jsxs("span",{style:{color:"var(--amber)"},children:["▲ ",e.detail??"blocked",e.stuckMins?` · ${e.stuckMins}m`:""]}):e.state==="inflight"?o.jsxs("span",{children:["› ",e.detail??"working",e.updatedAt?` · ${Pe(e.updatedAt)}`:""]}):e.state==="committed"?o.jsxs("span",{children:["◐ ",e.detail??"queued",e.updatedAt?` · ${Pe(e.updatedAt)}`:""]}):o.jsxs("span",{style:{opacity:.55},children:["◌ waiting for first live signal ",e.updatedAt?Pe(e.updatedAt):""]})}function wF({item:e,navigate:t}){const n=Fv(e);return o.jsxs("div",{className:"s-plan-change-card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[o.jsx("span",{className:"s-plan-change-kind",style:{color:"var(--amber)"},children:e.kind==="question"?"question":"work item"}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--dim)"},children:Pe(e.updatedAt)})]}),o.jsx("div",{className:"s-plan-change-summary",children:e.title}),o.jsx("div",{className:"s-plan-change-why",children:e.summary??`${e.state.replace(/_/g," ")} · ${e.acceptanceState.replace(/_/g," ")}`}),n&&o.jsx("div",{className:"s-plan-change-actions",children:o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",style:{flex:1},onClick:()=>t(n),children:"Open item"})})]})}function SF({ask:e,navigate:t}){const n=VT(e);return o.jsxs("div",{className:"s-plan-change-card s-plan-change-card--accepted",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[o.jsx("span",{className:"s-plan-change-kind",style:{color:"var(--green)"},children:e.status}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--dim)"},children:Pe(e.completedAt??e.updatedAt)})]}),o.jsx("div",{className:"s-plan-change-summary",children:e.summary??e.task}),o.jsxs("div",{className:"s-plan-change-why",children:[e.agentName??e.agentId," · ",e.task]}),n&&o.jsx("div",{className:"s-plan-change-actions",children:o.jsx("button",{className:"s-ops-btn",style:{flex:1},onClick:()=>t(n),children:"Open thread"})})]})}function jF({risk:e}){return o.jsxs("div",{className:"s-plan-risk",children:[o.jsx("span",{className:`s-plan-risk-icon s-plan-risk-icon--${e.severity}`,children:"▲"}),o.jsxs("div",{children:[o.jsx("div",{className:"s-plan-risk-title",children:e.title}),o.jsx("div",{className:"s-plan-risk-detail",children:e.detail})]})]})}function NF({node:e,agentsById:t,navigate:n}){const a=LT[e.state],i=e.assigneeId?t[e.assigneeId]:null;return o.jsxs("div",{className:"s-plan-detail",children:[o.jsxs("div",{className:"s-plan-detail-header",children:[o.jsx("span",{style:{color:a.color},children:a.icon}),o.jsx("span",{className:"s-ops-state-chip",style:{color:a.color,fontSize:10},children:a.label})]}),o.jsx("div",{className:"s-plan-detail-title",children:e.title}),(e.summary||e.detail||e.why)&&o.jsx("div",{className:"s-plan-detail-why",children:e.summary??e.detail??e.why}),i&&o.jsxs("div",{className:"s-plan-detail-assignee",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:dt(i.name)},children:i.name[0]?.toUpperCase()}),o.jsxs("div",{style:{flex:1},children:[o.jsx("div",{style:{fontSize:12.5},children:i.name}),o.jsxs("div",{style:{fontSize:10.5,color:"var(--dim)",fontFamily:"var(--font-mono)"},children:[i.project??"—"," · ",i.branch??"main"]})]})]}),o.jsxs("div",{className:"s-plan-detail-actions",children:[e.route&&o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:()=>n(e.route),children:"Open item"}),i&&o.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:os(i.id),composeMode:"tell"}),children:"Tell owner"}),i&&o.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:os(i.id),composeMode:"ask"}),children:"Ask owner"})]})]})}function kF(e){const t=Math.floor(e/3600).toString().padStart(2,"0"),n=Math.floor(e%3600/60).toString().padStart(2,"0"),a=(e%60).toString().padStart(2,"0");return`${t}:${n}:${a}`}function EF(e){return e.replace(/[._]/g," ")}function Ap(e,t=56){const n=(e??"").replace(/\s+/g," ").trim();return n?n.length>t?`${n.slice(0,t-1)}…`:n:"live event"}function vj(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 yj(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function CF(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:null}function TF(e,t,n=60){const a=new Array(n).fill(0),i=60*6e4,c=t-i;for(const f of e){if(f.ts<c||f.ts>t)continue;const m=f.ts-c,h=Math.min(n-1,Math.max(0,Math.floor(m/i*n)));a[h]+=1}const u=Math.max(1,...a);return{raw:a,normalized:a.map(f=>f/u)}}function AF({navigate:e,agents:t}){const[n,a]=v.useState(null),[i,c]=v.useState([]),[u,f]=v.useState([]),[m,h]=v.useState(()=>Date.now()),g=v.useCallback(async()=>{const[I,$,L]=await Promise.allSettled([_e("/api/fleet"),_e("/api/activity"),_e("/api/sessions")]);I.status==="fulfilled"&&a(I.value),$.status==="fulfilled"&&c($.value),L.status==="fulfilled"&&f(L.value),h(Date.now())},[]);v.useEffect(()=>{g()},[g]),vn(g),v.useEffect(()=>{const I=setInterval(()=>h(Date.now()),1e3);return()=>clearInterval(I)},[]);const x=t.filter(I=>mt(I.state)!=="offline").length,b=n?.needsAttention??[],w=n?.activeAsks??[],j=u.length>0?u.length:new Set(i.map(I=>I.conversationId).filter(I=>!!I)).size,N=[...b.map(I=>I.updatedAt),...w.map(I=>I.updatedAt)].filter(I=>typeof I=="number"&&Number.isFinite(I)),T=N.length>0?Math.min(...N):null,k=T?Math.max(0,Math.floor((m-T)/1e3)):0,C=v.useMemo(()=>TF(i,m),[i,m]),S=C.raw.reduce((I,$)=>I+$,0),R=Math.max(0,...C.raw),A=C.raw[C.raw.length-1]??0,M=v.useMemo(()=>i.slice(0,8).map(I=>({key:I.id,agent:I.actorName??"system",tool:EF(I.kind),result:Ap(I.title??I.summary),route:CF(I)})),[i]),O=v.useMemo(()=>{const I=[];for(const $ of b)I.push({key:$.recordId,label:$.title||"Unresolved item",route:vj($),tone:$.kind==="question"?"high":"med"});for(const $ of w)($.status==="failed"||$.status==="needs_attention")&&I.push({key:$.invocationId,label:$.summary??$.task,route:yj($),tone:$.status==="failed"?"high":"med"});return I.slice(0,6)},[w,b]),V=b.length>0?b:[],F=V.length===0?w.slice(0,3):[];return o.jsxs("div",{className:"s-warroom",children:[o.jsxs("div",{className:"s-warroom-topstrip",children:[o.jsx("div",{className:"s-warroom-topstrip-left",children:o.jsx("span",{className:"s-ops-label",children:"▸ War Room"})}),o.jsxs("div",{className:"s-warroom-topstrip-center",children:["OPERATIONS · ",new Date(m).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})]}),o.jsxs("div",{className:"s-warroom-topstrip-right",children:[o.jsx(Qu,{label:"Agents",value:`${x}/${t.length}`}),o.jsx(Qu,{label:"Threads",value:String(j)}),o.jsx(Qu,{label:"Attention",value:String(b.length),warn:b.length>0}),o.jsx(Qu,{label:"Events/h",value:String(S)})]})]}),o.jsxs("div",{className:"s-warroom-grid",children:[o.jsxs("div",{className:"s-warroom-panel",children:[o.jsx("div",{className:"s-ops-label",style:{marginBottom:12},children:"◌ Asks · Awaiting"}),o.jsxs("div",{className:"s-warroom-breach",children:[o.jsx("div",{className:"s-warroom-breach-clock",children:kF(k)}),o.jsxs("div",{className:"s-warroom-breach-sub",children:["Oldest unresolved · ",b[0]?.agentName??w[0]?.agentName??"clear"]})]}),V.length>0?V.slice(0,3).map(I=>{const $=vj(I);return o.jsxs("button",{type:"button",className:"s-warroom-ask-card",style:{textAlign:"left",cursor:$?"pointer":"default"},onClick:$?()=>e($):void 0,children:[o.jsxs("div",{className:"s-warroom-ask-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:dt(I.agentName??"?")},children:(I.agentName??"?")[0]?.toUpperCase()}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--muted)"},children:I.agentName??"unknown"})]}),o.jsx("div",{className:"s-warroom-ask-body",children:Ap(I.title??I.summary,110)})]},I.recordId)}):F.length>0?F.map(I=>{const $=yj(I);return o.jsxs("button",{type:"button",className:"s-warroom-ask-card",style:{textAlign:"left",cursor:$?"pointer":"default"},onClick:$?()=>e($):void 0,children:[o.jsxs("div",{className:"s-warroom-ask-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:dt(I.agentName??I.agentId)},children:(I.agentName??I.agentId)[0]?.toUpperCase()}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--muted)"},children:I.agentName??I.agentId})]}),o.jsx("div",{className:"s-warroom-ask-body",children:Ap(I.summary??I.task,110)})]},I.invocationId)}):o.jsx("div",{className:"s-warroom-ask-card",style:{color:"var(--dim)"},children:"No unresolved asks right now."}),o.jsx("div",{className:"s-ops-label",style:{marginTop:16},children:"○ Blockers"}),o.jsx("div",{className:"s-warroom-blockers",children:O.length===0?o.jsx("div",{style:{color:"var(--dim)"},children:"No blockers"}):O.map(I=>o.jsxs("button",{type:"button",className:I.tone==="high"?"s-warroom-blockers-item--high":"s-warroom-blockers-item--med",style:{textAlign:"left",cursor:I.route?"pointer":"default"},onClick:I.route?()=>e(I.route):void 0,children:[I.tone==="high"?"▲":"•"," ",I.label]},I.key))})]}),o.jsxs("div",{className:"s-warroom-panel s-warroom-mesh",children:[o.jsx("div",{className:"s-warroom-mesh-label",children:o.jsx("span",{className:"s-ops-label",children:"◉ Mesh · Live"})}),o.jsx(MF,{agents:t})]}),o.jsxs("div",{className:"s-warroom-panel",style:{display:"flex",flexDirection:"column",gap:14},children:[o.jsx("div",{className:"s-ops-label",children:"›_ Live stream"}),o.jsx(RF,{items:M,navigate:e}),o.jsx("div",{className:"s-ops-label",children:"Fleet load"}),o.jsxs("div",{className:"s-warroom-burn-grid",children:[o.jsx(ed,{num:String(S),label:"events/h"}),o.jsx(ed,{num:String(w.length),label:"active asks"}),o.jsx(ed,{num:String(b.length),label:"waiting"}),o.jsx(ed,{num:String(x),label:"online"})]})]}),o.jsxs("div",{className:"s-warroom-waveform-panel",children:[o.jsxs("div",{className:"s-warroom-waveform-header",children:[o.jsx("span",{className:"s-ops-label",children:"⌇ Fleet activity · Last 60m"}),o.jsx("span",{className:"s-warroom-waveform-meta",children:"events/min · live"}),o.jsx("span",{style:{flex:1}}),o.jsxs("span",{className:"s-warroom-waveform-meta",children:["peak ",R," · now ",A]})]}),o.jsx(_F,{values:C.normalized})]})]})]})}function Qu({label:e,value:t,warn:n}){return o.jsxs("div",{className:"s-warroom-telemetry",children:[o.jsx("div",{className:"s-warroom-telemetry-label",children:e}),o.jsx("div",{className:`s-warroom-telemetry-value${n?" s-warroom-telemetry-value--warn":""}`,children:t})]})}function RF({items:e,navigate:t}){return e.length===0?o.jsx("div",{className:"s-warroom-ticker",children:o.jsxs("div",{className:"s-warroom-ticker-line",style:{opacity:.5},children:[o.jsx("span",{className:"s-warroom-ticker-agent",children:"system"}),o.jsx("span",{className:"s-warroom-ticker-sep",children:"›"}),o.jsx("span",{className:"s-warroom-ticker-tool",children:"waiting"}),o.jsx("span",{className:"s-warroom-ticker-result",children:"no recent fleet activity"})]})}):o.jsx("div",{className:"s-warroom-ticker",children:e.map((n,a)=>o.jsxs("button",{type:"button",className:"s-warroom-ticker-line",style:{opacity:1-a*.06,textAlign:"left",cursor:n.route?"pointer":"default"},onClick:n.route?()=>t(n.route):void 0,children:[o.jsx("span",{className:"s-warroom-ticker-agent",children:n.agent}),o.jsx("span",{className:"s-warroom-ticker-sep",children:"›"}),o.jsx("span",{className:"s-warroom-ticker-tool",children:n.tool}),o.jsx("span",{className:"s-warroom-ticker-result",children:n.result})]},n.key))})}function ed({num:e,label:t}){return o.jsxs("div",{className:"s-warroom-burn-tile",children:[o.jsx("div",{className:"s-warroom-burn-num",children:e}),o.jsx("div",{className:"s-warroom-burn-label",children:t})]})}function MF({agents:e}){const a=v.useMemo(()=>{if(e.length===0)return{};const i=.5,c=.5,u=.3,f={};return e.forEach((m,h)=>{const g=h/e.length*Math.PI*2-Math.PI/2;f[m.id]={x:i+u*Math.cos(g),y:c+u*Math.sin(g)}}),f},[e]);return o.jsxs("svg",{viewBox:"0 0 800 480",preserveAspectRatio:"xMidYMid meet",style:{width:"100%",height:"100%"},children:[o.jsxs("defs",{children:[o.jsx("pattern",{id:"warGrid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:o.jsx("path",{d:"M 40 0 L 0 0 0 40",fill:"none",stroke:"var(--border)",strokeWidth:"0.5",opacity:"0.4"})}),o.jsxs("radialGradient",{id:"warGlow",cx:"50%",cy:"50%",r:"50%",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.1"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})]}),o.jsx("rect",{width:800,height:480,fill:"url(#warGrid)"}),o.jsx("circle",{cx:800/2,cy:480/2,r:200,fill:"url(#warGlow)"}),e.flatMap((i,c)=>e.slice(c+1).map(u=>{const f=a[i.id],m=a[u.id];return!f||!m?null:o.jsx("line",{x1:f.x*800,y1:f.y*480,x2:m.x*800,y2:m.y*480,stroke:"var(--dim)",strokeWidth:"0.8",opacity:"0.3"},`${i.id}-${u.id}`)})),e.map(i=>{const c=a[i.id];if(!c)return null;const u=c.x*800,f=c.y*480,m=dt(i.name),h=mt(i.state)==="working";return o.jsxs("g",{transform:`translate(${u}, ${f})`,children:[h&&o.jsxs("circle",{r:"18",fill:"none",stroke:m,strokeWidth:"1",opacity:"0.5",children:[o.jsx("animate",{attributeName:"r",values:"18;30;18",dur:"2.5s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"opacity",values:"0.5;0;0.5",dur:"2.5s",repeatCount:"indefinite"})]}),o.jsx("circle",{r:"18",fill:m,stroke:"var(--bg)",strokeWidth:"2"}),o.jsx("text",{textAnchor:"middle",dy:"0.35em",fontFamily:"var(--font-mono)",fontSize:"14",fontWeight:"600",fill:"rgba(0,0,0,0.7)",children:i.name[0]?.toUpperCase()}),o.jsx("text",{textAnchor:"middle",y:36,fontFamily:"var(--font-mono)",fontSize:"10",fill:"var(--muted)",letterSpacing:"0.1em",children:i.name.toUpperCase()}),o.jsxs("text",{textAnchor:"middle",y:48,fontFamily:"var(--font-mono)",fontSize:"8.5",fill:"var(--dim)",letterSpacing:"0.08em",children:[mt(i.state).toUpperCase()," · ",i.project??"—"]})]},i.id)})]})}function _F({values:e}){const a=e.length>1?e:[0,0],i=a.map((c,u)=>`${u/(a.length-1)*1e3},${80-c*72-4}`).join(" ");return o.jsxs("svg",{viewBox:"0 0 1000 80",preserveAspectRatio:"none",style:{width:"100%",height:80,display:"block"},children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"waveFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.35"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),o.jsx("polyline",{points:`0,80 ${i} 1000,80`,fill:"url(#waveFill)"}),o.jsx("polyline",{points:i,fill:"none",stroke:"var(--accent)",strokeWidth:"1.2"})]})}const OF=[{id:"mission",label:"Mission Control"},{id:"plan",label:"Plan"},{id:"conductor",label:"Conductor"},{id:"warroom",label:"War Room"}];function IF({navigate:e,mode:t="mission"}){const{agents:n}=Ut();return o.jsxs("div",{className:"s-ops",children:[o.jsxs("div",{className:"s-ops-header",children:[o.jsx("span",{className:"s-ops-header-title",children:"Ops"}),o.jsx("div",{className:"s-ops-tabs",children:OF.map(a=>o.jsx("button",{className:`s-ops-tab${t===a.id?" s-ops-tab--active":""}`,onClick:()=>e({view:"ops",mode:a.id}),children:a.label},a.id))})]}),o.jsxs("div",{className:"s-ops-body",children:[t==="mission"&&o.jsx(rF,{navigate:e,agents:n}),t==="plan"&&o.jsx(yF,{navigate:e,agents:n}),t==="conductor"&&o.jsx(YZ,{navigate:e,agents:n}),t==="warroom"&&o.jsx(AF,{navigate:e,agents:n})]})]})}function DF(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function Rp(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 zF(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function LF(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 xj(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 Mp({title:e,items:t}){return t.length===0?null:o.jsxs("section",{className:"s-work-fact-card",children:[o.jsx("div",{className:"s-work-fact-card-header",children:o.jsx("div",{className:"s-work-fact-card-title",children:e})}),o.jsx("div",{className:"s-work-fact-card-body",children:t.map(n=>o.jsxs("div",{className:"s-work-fact-row",children:[o.jsx("span",{className:"s-work-fact-label",children:n.label}),o.jsx("span",{className:"s-work-fact-value",children:n.value})]},n.label))})]})}function bj({label:e,value:t,onClick:n}){return o.jsxs("button",{type:"button",className:"s-work-action-row",onClick:n,children:[o.jsx("span",{className:"s-work-action-row-label",children:e}),o.jsx("span",{className:"s-work-action-row-value",children:t})]})}function $F(e){const t=e.split(".");return t[t.length-1]||e}function PF({workId:e,navigate:t}){const[n,a]=v.useState(null),[i,c]=v.useState(null),[u,f]=v.useState(!1),m=v.useCallback(async()=>{c(null);try{const N=await _e(`/api/work/${encodeURIComponent(e)}`);a(N)}catch(N){c(N instanceof Error?N.message:String(N)),a(null)}finally{f(!0)}},[e]);if(v.useEffect(()=>{f(!1),m()},[m]),vn(m),!u)return o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Loading…"})})]});if(!n)return o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),i&&o.jsx("p",{className:"s-error",children:i}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Work item not found"})})]});const h=zF(n.attention),g=n.ownerName??n.ownerId??"Unassigned",x=n.nextMoveOwnerName??n.nextMoveOwnerId??"—",b=[{label:"State",value:Rp(n.state)},{label:"Acceptance",value:n.acceptanceState.replace(/_/g," ")},{label:"Phase",value:n.currentPhase},...h?[{label:"Attention",value:h}]:[]],w=[{label:"Owner",value:g},{label:"Next move",value:x},...n.priority?[{label:"Priority",value:n.priority}]:[],{label:"Conversation",value:n.conversationId?"Attached":"None"}],j=[{label:"Case ID",value:n.id},{label:"Created",value:Wr(n.createdAt)},{label:"Updated",value:Wr(n.updatedAt)},{label:"Last activity",value:Wr(n.lastMeaningfulAt)}];return o.jsxs("div",{className:"s-work-detail s-work-casefile",children:[o.jsxs("div",{className:"s-work-casefile-topbar",children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),o.jsxs("span",{className:"s-work-casefile-record",children:["Case ",$F(n.id)]})]}),i&&o.jsx("p",{className:"s-error",children:i}),o.jsx("section",{className:"s-work-casefile-hero",children:o.jsxs("div",{className:"s-work-casefile-hero-main",children:[o.jsxs("div",{className:"s-work-casefile-title-row",children:[o.jsx("h1",{className:"s-work-casefile-title",children:n.title}),o.jsx("span",{className:`s-pill s-pill-${DF(n)}`,children:n.currentPhase})]}),n.lastMeaningfulSummary&&o.jsx("div",{className:"s-work-casefile-summary",children:ls(n.lastMeaningfulSummary)}),o.jsxs("div",{className:"s-work-casefile-meta",children:[o.jsxs("span",{children:["Updated ",Pe(n.updatedAt)]}),o.jsx("span",{children:g}),o.jsx("span",{children:Rp(n.state)}),h&&o.jsx("span",{children:h}),n.priority&&o.jsxs("span",{children:["Priority ",n.priority]})]})]})}),o.jsxs("div",{className:"s-work-casefile-layout",children:[o.jsxs("div",{className:"s-work-casefile-main",children:[o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Case facts"})}),o.jsxs("div",{className:"s-work-fact-grid",children:[o.jsx(Mp,{title:"Status",items:b}),o.jsx(Mp,{title:"Assignment",items:w})]})]}),n.activeFlights.length>0&&o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Flights"})}),o.jsx("div",{className:"s-work-flight-list",children:n.activeFlights.map(N=>o.jsxs("button",{type:"button",className:"s-work-flight-card",onClick:N.conversationId?()=>t({view:"conversation",conversationId:N.conversationId}):void 0,disabled:!N.conversationId,children:[o.jsxs("div",{className:"s-work-flight-card-header",children:[o.jsx("span",{className:"s-work-flight-card-title",children:N.agentName??N.agentId}),o.jsx("span",{className:"s-pill s-pill-working",children:N.state})]}),o.jsxs("div",{className:"s-work-flight-card-meta",children:[o.jsx("span",{children:N.startedAt?`Started ${Pe(N.startedAt)}`:"Start time unavailable"}),N.completedAt&&o.jsxs("span",{children:["Completed ",Pe(N.completedAt)]})]}),N.summary&&o.jsx("div",{className:"s-work-flight-card-copy",children:N.summary})]},N.id))})]}),n.childWork.length>0&&o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Child work"})}),o.jsx("div",{className:"s-work-related-list",children:n.childWork.map(N=>o.jsxs("button",{type:"button",className:"s-work-related-card",onClick:()=>t({view:"work",workId:N.id}),children:[o.jsxs("div",{className:"s-work-related-card-header",children:[o.jsx("span",{className:"s-work-related-card-title",children:N.title}),o.jsx("span",{className:`s-pill s-pill-${N.attention==="interrupt"?"failed":"updated"}`,children:N.currentPhase})]}),o.jsxs("div",{className:"s-work-related-card-meta",children:[o.jsx("span",{children:N.ownerName??N.ownerId??"Unassigned"}),o.jsx("span",{children:Rp(N.state)}),o.jsx("span",{children:Pe(N.lastMeaningfulAt)})]}),N.lastMeaningfulSummary&&o.jsx("div",{className:"s-work-related-card-copy",children:ls(N.lastMeaningfulSummary)})]},N.id))})]}),o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Timeline"})}),n.timeline.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No activity yet."}),o.jsx("p",{children:"Timeline events will appear once the case receives messages or coordination updates."})]}):o.jsx("div",{className:"s-work-timeline",children:n.timeline.map(N=>o.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:[o.jsx("span",{className:`s-work-timeline-marker s-work-timeline-marker-${xj(N)}`}),o.jsxs("div",{className:"s-work-timeline-content",children:[o.jsxs("div",{className:"s-work-timeline-header",children:[o.jsx("span",{className:"s-work-timeline-time",children:Pe(N.at)}),o.jsx("span",{className:`s-work-timeline-kind s-work-timeline-kind-${xj(N)}`,children:LF(N)})]}),o.jsx("div",{className:"s-work-timeline-actor",children:N.actorName??"system"}),N.title&&o.jsx("div",{className:"s-work-timeline-title",children:N.title}),N.summary&&o.jsx("div",{className:"s-work-timeline-summary",children:ls(N.summary)}),o.jsx("div",{className:"s-work-timeline-stamp",children:Wr(N.at)})]})]},N.id))})]})]}),o.jsxs("aside",{className:"s-work-casefile-side",children:[o.jsx(Mp,{title:"Record",items:j}),o.jsxs("section",{className:"s-work-fact-card",children:[o.jsx("div",{className:"s-work-fact-card-header",children:o.jsx("div",{className:"s-work-fact-card-title",children:"Links"})}),o.jsxs("div",{className:"s-work-action-list",children:[n.conversationId?o.jsx(bj,{label:"Conversation",value:"Open thread",onClick:()=>t({view:"conversation",conversationId:n.conversationId})}):o.jsx("div",{className:"s-work-action-list-empty",children:"No conversation attached."}),n.parentId&&n.parentTitle?o.jsx(bj,{label:"Parent",value:n.parentTitle,onClick:()=>t({view:"work",workId:n.parentId})}):o.jsx("div",{className:"s-work-action-list-empty",children:"No parent work item."})]})]})]})]})]})}function UF(){const{route:e,navigate:t}=Ut();return o.jsx(BF,{children:VF(e,t)})}function BF({children:e}){return o.jsx("div",{style:{background:"var(--bg)",color:"var(--ink)",minHeight:"100%",height:"100%",display:"flex",flexDirection:"column"},children:e})}function VF(e,t){switch(e.view){case"conversation":return o.jsx(Ag,{conversationId:e.conversationId,initialComposeMode:e.composeMode,navigate:t});case"agent-info":return o.jsx(xH,{conversationId:e.conversationId,navigate:t});case"settings":return o.jsx(LZ,{navigate:t});case"agents":return o.jsx(m7,{navigate:t,selectedAgentId:e.agentId,conversationId:e.conversationId,tab:e.tab});case"fleet":return o.jsx(C7,{navigate:t});case"sessions":return e.sessionId?o.jsx(Ag,{conversationId:e.sessionId,navigate:t}):o.jsx(fZ,{navigate:t});case"mesh":return o.jsx(Q7,{navigate:t});case"activity":return o.jsx(pH,{navigate:t});case"ops":return o.jsx(IF,{navigate:t,mode:e.mode});case"work":return o.jsx(PF,{workId:e.workId,navigate:t});default:return o.jsx(R7,{navigate:t})}}function HF(){const{route:e,agents:t,navigate:n}=Ut();if(e.view!=="agents")return null;const a=e.agentId?t.find(i=>i.id===e.agentId)??null:null;if(!a){const i=t.filter(c=>ri(c.state)).length;return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsx(Ws,{label:"Total",value:`${t.length}`}),o.jsx(Ws,{label:"Working",value:`${i}`}),o.jsx(Ws,{label:"Available",value:`${t.length-i}`}),o.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 o.jsx(ZF,{agent:a,agents:t,navigate:n})}function ZF({agent:e,agents:t,navigate:n}){const a=ri(e.state),[i,c]=v.useState(null),u=v.useCallback(async()=>{const f=await _e("/api/fleet").catch(()=>null);f&&c(f)},[]);return v.useEffect(()=>{u()},[u]),vn(u),o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[o.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:dt(e.name)},children:[e.name[0]?.toUpperCase()??"?",a&&o.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:Aa(e.state),opacity:mt(e.state)==="working"?.85:.6}})]}),o.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[o.jsx("span",{className:"truncate text-[13px] text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&o.jsxs("span",{className:"text-[10px] font-mono text-cyan-400/70",children:["@",e.handle]})]})]}),o.jsxs(ro,{label:"State",children:[o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:Aa(e.state),opacity:a?1:.4}}),o.jsx("span",{className:"text-[12px] capitalize text-[var(--scout-chrome-ink)]",children:aa(e.state)})]}),e.updatedAt&&o.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Updated ",Pe(e.updatedAt)]})]}),o.jsx(ro,{label:"Presence",children:o.jsx(FF,{focusAgent:e,agents:t,navigate:n})}),i&&o.jsx(qF,{asks:i.activeAsks,agentId:e.id,navigate:n}),o.jsxs(ro,{label:"Identity",children:[o.jsx(Ws,{label:"Class",value:e.agentClass}),e.role&&o.jsx(Ws,{label:"Role",value:e.role}),e.harness&&o.jsx(Ws,{label:"Harness",value:e.harness}),e.transport&&o.jsx(Ws,{label:"Transport",value:e.transport})]}),(e.project||e.branch||e.cwd)&&o.jsxs(ro,{label:"Project",children:[e.project&&o.jsx(Ws,{label:"Name",value:e.project}),e.branch&&o.jsx(Ws,{label:"Branch",value:e.branch}),e.cwd&&o.jsx(Ws,{label:"Cwd",value:e.cwd})]}),e.capabilities.length>0&&o.jsx(ro,{label:`Capabilities · ${e.capabilities.length}`,children:o.jsx("div",{className:"flex flex-wrap gap-1",children:e.capabilities.map(f=>o.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:f},f))})})]})}function FF({focusAgent:e,agents:t,navigate:n}){const m=t.filter(g=>g.id!==e.id).slice(0,8),h=v.useMemo(()=>{const g=[{agent:e,x:120,y:90,focused:!0}];return m.forEach((x,b)=>{const w=2*Math.PI*b/Math.max(m.length,1)-Math.PI/2;g.push({agent:x,x:120+68*Math.cos(w),y:90+68*Math.sin(w),focused:!1})}),g},[e,m,120,90,68]);return o.jsxs("svg",{viewBox:"0 0 240 180",className:"w-full block",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("defs",{children:o.jsxs("radialGradient",{id:"inspMeshGlow",cx:"50%",cy:"50%",r:"50%",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.06"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),o.jsx("circle",{cx:120,cy:90,r:82,fill:"url(#inspMeshGlow)"}),o.jsx("circle",{cx:120,cy:90,r:68,fill:"none",stroke:"var(--border)",strokeDasharray:"2 4"}),h.slice(1).map((g,x)=>o.jsxs("g",{children:[o.jsx("line",{x1:120,y1:90,x2:g.x,y2:g.y,stroke:"var(--accent)",strokeWidth:1,opacity:.6}),o.jsx("circle",{r:2,fill:"var(--accent)",children:o.jsx("animateMotion",{dur:`${2+x*.3}s`,repeatCount:"indefinite",path:`M 120,90 L ${g.x},${g.y}`})})]},`e-${g.agent.id}`)),h.map(g=>{const x=mt(g.agent.state),b=x==="working"||x==="available",w=g.focused?14:9;return o.jsxs("g",{style:{cursor:"pointer"},onClick:()=>n({view:"agents",agentId:g.agent.id}),children:[b&&o.jsxs("circle",{cx:g.x,cy:g.y,r:w+5,fill:"none",stroke:dt(g.agent.name),strokeWidth:.8,opacity:.3,children:[o.jsx("animate",{attributeName:"r",values:`${w};${w+8};${w}`,dur:"2.5s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"opacity",values:"0.3;0;0.3",dur:"2.5s",repeatCount:"indefinite"})]}),o.jsx("circle",{cx:g.x,cy:g.y,r:w,fill:dt(g.agent.name),stroke:g.focused?"var(--accent)":"var(--surface)",strokeWidth:g.focused?1.5:1}),o.jsx("text",{x:g.x,y:g.y,dy:"0.35em",textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:g.focused?10:8,fontWeight:600,fill:"var(--scout-chrome-avatar-ink)",children:g.agent.name[0].toUpperCase()}),o.jsx("text",{x:g.x,y:g.y+w+10,textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:8,fill:"var(--dim)",letterSpacing:"0.04em",children:g.agent.name.length>9?g.agent.name.slice(0,8)+"...":g.agent.name})]},g.agent.id)})]})}function qF({asks:e,agentId:t,navigate:n}){const a=e.filter(i=>i.agentId===t&&(i.status==="needs_attention"||i.status==="queued"));return a.length===0?null:o.jsx(ro,{label:`Incoming asks · ${a.length}`,children:o.jsx("div",{className:"flex flex-col gap-2",children:a.map(i=>o.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:[o.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.12em] text-amber-500/80 mb-1",children:"awaiting"}),o.jsx("div",{className:"line-clamp-2 text-[11px] leading-relaxed text-[var(--scout-chrome-ink)]",children:i.summary??i.task}),o.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 ro({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Ws({label:e,value:t}){return o.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[o.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function YF(){const[e,t]=v.useState(null),n=v.useCallback(async()=>{try{t(await _e("/api/fleet"))}catch{}},[]);if(v.useEffect(()=>{n()},[n]),vn(n),!e)return o.jsx("div",{className:"flex h-full items-center justify-center text-[11px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-ghost)]",children:"Loading fleet…"});const a=e.totals;return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:["Updated ",Pe(e.generatedAt)]}),o.jsx(td,{label:"Needs Input",value:a.needsAttention,emphasis:a.needsAttention>0?"warn":"muted"}),o.jsx(td,{label:"Active Asks",value:a.active}),o.jsx(td,{label:"Recent Finished",value:a.recentCompleted,emphasis:a.recentCompleted>0?"good":"muted"}),o.jsx(td,{label:"Activity",value:a.activity})]})}function td({label:e,value:t,emphasis:n}){const a=n==="good"?"text-emerald-300/90":n==="warn"?"text-amber-300/90":n==="muted"?"text-[var(--scout-chrome-ink-faint)]":"text-[var(--scout-chrome-ink)]";return o.jsxs("div",{className:"flex flex-col border-b border-[var(--scout-chrome-border-soft)] pb-3 last:border-b-0",children:[o.jsx("span",{className:`text-[24px] font-mono tabular-nums leading-none ${a}`,children:t}),o.jsx("span",{className:"mt-1 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e})]})}function GF(){const{agents:e,navigate:t}=Ut();if(e.length===0)return o.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:[o.jsx("div",{className:"mb-1 uppercase tracking-[0.15em]",children:"No agents"}),o.jsx("div",{children:"Connect an agent to see your roster here."})]});const n=e.filter(i=>ri(i.state)),a=e.filter(i=>!ri(i.state));return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[n.length>0&&o.jsx(wj,{label:"Online",count:n.length,children:n.map(i=>o.jsx(Sj,{agent:i,navigate:t},i.id))}),a.length>0&&o.jsx(wj,{label:"Standby",count:a.length,children:a.map(i=>o.jsx(Sj,{agent:i,navigate:t,dim:!0},i.id))})]})}function wj({label:e,count:t,children:n}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[o.jsx("span",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:t})]}),o.jsx("div",{className:"flex flex-col gap-0.5",children:n})]})}function Sj({agent:e,navigate:t,dim:n}){const a=ri(e.state);return o.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:[o.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:dt(e.name)},children:[e.name[0]?.toUpperCase()??"?",a&&o.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)]"})]}),o.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[o.jsx("span",{className:"truncate text-[12px] text-[var(--scout-chrome-ink)] transition-colors group-hover:text-[var(--scout-chrome-ink-strong)]",children:e.name}),o.jsx("span",{className:"truncate text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:aa(e.state)})]}),e.updatedAt&&o.jsx("span",{className:"shrink-0 text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:Pe(e.updatedAt)})]})}function WF(){const{route:e}=Ut(),[t,n]=v.useState([]),a=v.useCallback(async()=>{try{n(await _e("/api/sessions"))}catch{}},[]);if(v.useEffect(()=>{a()},[a]),vn(a),e.view!=="sessions")return null;const i=e.sessionId?t.find(c=>c.id===e.sessionId)??null:null;if(!i){const c=new Set(t.map(f=>f.kind)),u=t.filter(f=>f.currentBranch).length;return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsx(Fs,{label:"Total",value:`${t.length}`}),o.jsx(Fs,{label:"Kinds",value:`${c.size}`}),o.jsx(Fs,{label:"Branched",value:`${u}`}),o.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 o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[o.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:i.title}),o.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-cyan-400/70 mt-1",children:i.kind})]}),i.agentName&&o.jsxs(nd,{label:"Agent",children:[o.jsx(Fs,{label:"Name",value:i.agentName}),i.harness&&o.jsx(Fs,{label:"Harness",value:i.harness})]}),(i.currentBranch||i.workspaceRoot)&&o.jsxs(nd,{label:"Workspace",children:[i.currentBranch&&o.jsx(Fs,{label:"Branch",value:i.currentBranch}),i.workspaceRoot&&o.jsx(Fs,{label:"Root",value:i.workspaceRoot})]}),o.jsxs(nd,{label:"Activity",children:[o.jsx(Fs,{label:"Messages",value:`${i.messageCount}`}),i.lastMessageAt&&o.jsx(Fs,{label:"Last",value:Pe(i.lastMessageAt)}),i.participantIds.length>0&&o.jsx(Fs,{label:"Participants",value:`${i.participantIds.length}`})]}),i.preview&&o.jsx(nd,{label:"Preview",children:o.jsxs("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:['"',i.preview,'"']})})]})}function nd({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Fs({label:e,value:t}){return o.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[o.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function XF(){const{route:e}=Ut(),t=e.view==="work"?e.workId:null,[n,a]=v.useState(null),i=v.useCallback(async()=>{if(!t){a(null);return}try{a(await _e(`/api/work/${encodeURIComponent(t)}`))}catch{a(null)}},[t]);if(v.useEffect(()=>{i()},[i]),vn(i),e.view!=="work")return null;if(!n)return o.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-[11px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-ghost)]",children:"Loading work item…"});const c=JF(n.state);return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[o.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-cyan-400/70 mb-1",children:["Case ",KF(n.id)]}),o.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:n.title})]}),o.jsxs(sd,{label:"State",children:[o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`}),o.jsx("span",{className:`text-[12px] capitalize ${c.text}`,children:n.state.replace(/_/g," ")})]}),o.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Phase · ",n.currentPhase]})]}),o.jsxs(sd,{label:"Ownership",children:[n.ownerName&&o.jsx(Ji,{label:"Owner",value:n.ownerName}),n.nextMoveOwnerName&&o.jsx(Ji,{label:"Next move",value:n.nextMoveOwnerName}),n.priority&&o.jsx(Ji,{label:"Priority",value:n.priority})]}),o.jsxs(sd,{label:"Activity",children:[o.jsx(Ji,{label:"Children",value:`${n.activeChildWorkCount}`}),o.jsx(Ji,{label:"Flights",value:`${n.activeFlightCount}`}),n.lastMeaningfulAt&&o.jsx(Ji,{label:"Last update",value:Pe(n.lastMeaningfulAt)})]}),n.attention!=="silent"&&o.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&&o.jsx(sd,{label:"Latest",children:o.jsx("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:n.lastMeaningfulSummary})})]})}function KF(e){return e.length>10?`${e.slice(0,8)}…`:e}function JF(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 sd({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Ji({label:e,value:t}){return o.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[o.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function QF(){const{route:e}=Ut();switch(e.view){case"inbox":return o.jsx(GF,{});case"agents":case"agent-info":return o.jsx(HF,{});case"fleet":return o.jsx(YF,{});case"sessions":case"conversation":return o.jsx(WF,{});case"work":return o.jsx(XF,{});case"ops":return null;default:return null}}function eq(){const{openSettings:e}=Ut();return o.jsx(IV,{onOpen:e})}const Qi={working:0,available:1,offline:2};function tq(e){return e.project?e.project.toLowerCase():"other"}function nq(e){const t=new Map;for(const a of e){const i=tq(a),c=t.get(i);c?c.push(a):t.set(i,[a])}const n=[];for(const[a,i]of t){i.sort((f,m)=>{const h=(Qi[mt(f.state)]??9)-(Qi[mt(m.state)]??9);return h!==0?h:(m.updatedAt??0)-(f.updatedAt??0)});const c=i.reduce((f,m)=>{const h=mt(m.state);return(Qi[h]??9)<(Qi[f]??9)?h:f},"offline"),u=Math.max(...i.map(f=>f.updatedAt??0));n.push({key:a,label:a,agents:i,bestState:c,latestUpdate:u})}return n.sort((a,i)=>{const c=(Qi[a.bestState]??9)-(Qi[i.bestState]??9);return c!==0?c:i.latestUpdate-a.latestUpdate}),n}function sq(e){return e.trim().toLowerCase()}function aq(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 rq(e,t){return t?aq(e).some(n=>n.toLowerCase().includes(t)):!0}function eo(e,t){return t?[e.harnessSessionId,e.conversationId].find(a=>a?.toLowerCase().includes(t))??null:null}function _p(e,t,n={}){e({view:"agents",agentId:t.id,...n.observe?{conversationId:t.conversationId,tab:"observe"}:{}})}function iq(){const{agents:e,route:t,navigate:n}=Ut(),[a,i]=v.useState(()=>new Set),[c,u]=v.useState(""),f=sq(c),m=f.length>0,h=v.useMemo(()=>e.filter(j=>rq(j,f)),[e,f]),g=v.useMemo(()=>nq(h),[h]),x=h[0]??null,b=t.view==="agents"?t.agentId:void 0,w=j=>{i(N=>{const T=new Set(N);return T.has(j)?T.delete(j):T.add(j),T})};return o.jsxs("div",{className:"s-left-roster",children:[o.jsx("div",{className:"s-left-roster-search s-search",children:o.jsx("input",{type:"text",className:"s-search-input",placeholder:"Search agents or session IDs…",value:c,onChange:j=>u(j.target.value),onKeyDown:j=>{j.key==="Escape"&&(c?u(""):j.target.blur()),j.key==="Enter"&&x&&_p(n,x,{observe:!!eo(x,f)})}})}),o.jsx("div",{style:{flex:1,overflow:"auto"},children:e.length===0?o.jsx("div",{className:"s-left-roster-empty",children:"No agents registered"}):h.length===0?o.jsx("div",{className:"s-left-roster-empty",children:"No agents match this session or agent search."}):g.map(j=>{const N=j.agents.length===1,T=m||a.has(j.key),k=N?j.agents[0]:null,C=j.agents.some(R=>R.id===b),S=k?eo(k,f):null;return o.jsxs("div",{className:"s-left-roster-parent",children:[o.jsxs("button",{className:`s-left-roster-row${C&&(N||!T)?" s-left-roster-row--active":""}`,onClick:()=>{N?_p(n,k,{observe:!!S}):w(j.key)},children:[o.jsxs("span",{className:"s-left-roster-avatar-wrap",children:[o.jsx("span",{className:"s-left-roster-avatar",style:{background:dt(j.label)},children:j.label[0].toUpperCase()}),o.jsx("span",{className:`s-left-roster-dot s-left-roster-dot--${j.bestState}`,style:{background:Aa(j.bestState==="working"?"working":j.bestState==="available"?"available":null)}})]}),o.jsxs("span",{className:"s-left-roster-body",children:[o.jsx("span",{className:"s-left-roster-name",children:j.label}),N&&S?o.jsxs("span",{className:"s-left-roster-sub",title:S,children:["session · ",S]}):N&&(k.project||k.branch)&&o.jsxs("span",{className:"s-left-roster-sub",children:[k.name,k.branch?` · ${k.branch}`:""]}),!N&&!T&&o.jsxs("span",{className:"s-left-roster-sub",children:[j.agents.length," agents"]})]}),!N&&o.jsx("span",{className:"s-left-roster-ct",children:T?"▾":"▸"}),N&&k.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:Pe(k.updatedAt)})]}),!N&&T&&o.jsx("div",{className:"s-left-roster-instances",children:j.agents.map(R=>o.jsxs("button",{className:`s-left-roster-instance${R.id===b?" s-left-roster-instance--active":""}`,onClick:()=>_p(n,R,{observe:!!eo(R,f)}),title:eo(R,f)??void 0,children:[o.jsx("span",{className:`s-left-roster-instance-dot s-left-roster-dot--${mt(R.state)}`,style:{background:Aa(R.state)}}),o.jsxs("span",{className:"s-left-roster-instance-label",children:[R.name,R.branch?` · ${R.branch}`:"",eo(R,f)?` · ${eo(R,f)}`:""]}),R.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:Pe(R.updatedAt)})]},R.id))})]},j.key)})})]})}function oq(){const{onboarding:e}=Ut();return e?e.hasLocalConfig?e.hasOperatorName?e.hasProjectConfig?null:o.jsx(Op,{children:o.jsx(uq,{})}):o.jsx(Op,{children:o.jsx(cq,{})}):o.jsx(Op,{children:o.jsx(lq,{})}):null}function Op({children:e}){return o.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"auto",background:"var(--bg)",color:"var(--ink)"},children:o.jsx("div",{style:{width:"100%",maxWidth:720,padding:"80px 72px",display:"flex",flexDirection:"column",gap:40},children:e})})}function qv({eyebrow:e,title:t,description:n}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsx("div",{style:dq,children:e}),o.jsx("div",{style:fq,children:t}),o.jsx("div",{style:hq,children:n})]})}function Yv({primary:e,onPrimary:t,primaryDisabled:n,busy:a}){const{skipOnboarding:i}=Ut();return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24,paddingTop:8},children:[o.jsx("button",{type:"button",onClick:t,disabled:n||a,style:{...pq,opacity:n||a?.5:1,cursor:n||a?"default":"pointer"},children:a?"Working…":e}),o.jsx("button",{type:"button",onClick:i,style:gq,onMouseEnter:c=>{c.currentTarget.style.color="rgba(255,255,255,0.8)"},onMouseLeave:c=>{c.currentTarget.style.color="rgba(255,255,255,0.45)"},children:"Skip for now"})]})}function Gv({message:e}){return e?o.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 lq(){const{onboarding:e,refreshOnboarding:t}=Ut(),[n,a]=v.useState(!1),[i,c]=v.useState(null),u=async()=>{a(!0),c(null);try{await _e("/api/onboarding/init",{method:"POST",body:"{}"}),await t()}catch(f){c(f instanceof Error?f.message:String(f))}finally{a(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(qv,{eyebrow:"First-run setup",title:"Welcome to Scout",description:o.jsxs(o.Fragment,{children:["Scout needs a local config before it can talk to the broker, the web app, and paired devices. This writes"," ",o.jsx("code",{style:Dg,children:"~/.openscout/config.json"})," with sensible defaults — you can edit it any time."]})}),o.jsxs("ul",{style:vq,children:[o.jsx(jj,{label:"Local config (~/.openscout/config.json)",done:!1,hint:"missing"}),o.jsx(jj,{label:".openscout/project.json in a repo",done:!!e?.hasProjectConfig,hint:e?.hasProjectConfig?e.projectRoot??void 0:"checked after setup"})]}),o.jsx(Gv,{message:i}),o.jsx(Yv,{primary:"Initialize Scout",onPrimary:()=>{u()},busy:n})]})}function cq(){const{onboarding:e,refreshOnboarding:t}=Ut(),n=e?.operatorNameSuggestion??"",[a,i]=v.useState(n),[c,u]=v.useState(!1),[f,m]=v.useState(null);v.useEffect(()=>{!a&&n&&i(n)},[n,a]);const h=async()=>{const g=a.trim();if(!g){m("Name is required.");return}u(!0),m(null);try{await _e("/api/user",{method:"POST",body:JSON.stringify({name:g})}),await t()}catch(x){m(x instanceof Error?x.message:String(x))}finally{u(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(qv,{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."}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsx("label",{style:xd,children:"Your name"}),o.jsx("input",{autoFocus:!0,value:a,onChange:g=>{i(g.target.value),m(null)},onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:n||"Operator",style:Ig}),n?o.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontFamily:"var(--hud-font-mono)"},children:"Prefilled from your machine."}):null]}),o.jsx(Gv,{message:f}),o.jsx(Yv,{primary:"Continue",onPrimary:()=>{h()},busy:c,primaryDisabled:!a.trim()})]})}function uq(){const{onboarding:e,refreshOnboarding:t}=Ut(),n=e?.currentDirectory??"",[a,i]=v.useState([n||"~/dev"]),[c,u]=v.useState(n),[f,m]=v.useState("claude"),[h,g]=v.useState(!1),[x,b]=v.useState(null),w=(k,C)=>{i(S=>S.map((R,A)=>A===k?C:R))},j=()=>i(k=>[...k,""]),N=k=>i(C=>C.filter((S,R)=>R!==k)),T=async()=>{const k=a.map(S=>S.trim()).filter(Boolean),C=c.trim();if(!C){b("Pick where Scout should anchor this context.");return}g(!0),b(null);try{await _e("/api/onboarding/project",{method:"POST",body:JSON.stringify({contextRoot:C,sourceRoots:k,defaultHarness:f})}),await t()}catch(S){b(S instanceof Error?S.message:String(S))}finally{g(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(qv,{eyebrow:"Step 2 of 2",title:"Where do your repos live?",description:o.jsxs(o.Fragment,{children:["Scout scans these folders for projects and anchors this context at"," ",o.jsx("code",{style:Dg,children:"<context>/.openscout/project.json"}),"."]})}),o.jsxs("div",{style:Ip,children:[o.jsx("label",{style:xd,children:"Scan folders"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.map((k,C)=>o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("input",{value:k,onChange:S=>w(C,S.target.value),placeholder:C===0?"~/dev":"Add another folder",style:{...Ig,flex:1}}),o.jsx("button",{type:"button",onClick:()=>N(C),disabled:a.length<=1,style:{...Nj,opacity:a.length<=1?.4:1,cursor:a.length<=1?"default":"pointer"},"aria-label":`Remove folder ${C+1}`,children:"−"})]},C)),o.jsx("button",{type:"button",onClick:j,style:{...Nj,alignSelf:"flex-start"},children:"+ Add folder"})]})]}),o.jsxs("div",{style:Ip,children:[o.jsx("label",{style:xd,children:"Context root"}),o.jsx("input",{value:c,onChange:k=>u(k.target.value),placeholder:"~/dev",style:Ig}),o.jsxs("div",{style:mq,children:["Scout writes ",o.jsx("code",{style:Dg,children:".openscout/project.json"})," ","inside this folder."]})]}),o.jsxs("div",{style:Ip,children:[o.jsx("label",{style:xd,children:"Default harness"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:["claude","codex"].map(k=>{const C=f===k;return o.jsxs("button",{type:"button",onClick:()=>m(k),style:{...yq,borderColor:C?"var(--accent, #2dd4bf)":"rgba(255,255,255,0.12)",backgroundColor:C?"rgba(45,212,191,0.08)":"rgba(255,255,255,0.02)"},children:[o.jsx("div",{style:{fontSize:15,fontWeight:600,textTransform:"capitalize"},children:k}),o.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",marginTop:6,lineHeight:1.5},children:k==="claude"?"Anthropic Claude Code — local CLI agent.":"OpenAI Codex — cloud agentic sandbox."})]},k)})})]}),o.jsx(Gv,{message:x}),o.jsx(Yv,{primary:"Create project",onPrimary:()=>{T()},busy:h,primaryDisabled:!c.trim()})]})}function jj({label:e,done:t,hint:n}){return o.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:16},children:[o.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?"✓":"•"}),o.jsxs("div",{style:{minWidth:0},children:[o.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?o.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 dq={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.18em",color:"rgba(255,255,255,0.4)"},fq={fontSize:36,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1.15},hq={fontSize:15,lineHeight:1.75,color:"rgba(255,255,255,0.6)",maxWidth:580},Ip={display:"flex",flexDirection:"column",gap:10},xd={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.5)"},Ig={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"},mq={fontSize:12,color:"rgba(255,255,255,0.45)",lineHeight:1.6},Dg={fontFamily:"var(--hud-font-mono)",fontSize:12,padding:"2px 6px",borderRadius:4,backgroundColor:"rgba(255,255,255,0.06)"},pq={fontSize:13,fontWeight:600,padding:"12px 24px",borderRadius:10,backgroundColor:"var(--accent, #2dd4bf)",color:"#0b0d12",border:"none",transition:"opacity 0.15s ease"},Nj={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"},gq={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"},vq={display:"flex",flexDirection:"column",gap:20,margin:0,padding:0,listStyle:"none"},yq={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"},xq=[{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: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:activity",title:"Go to Activity",description:"Navigate to the activity feed showing recent events",category:"navigation",keywords:["activity","feed","events","log"],shortcut:"Cmd+5"},{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+6"},{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 ZT(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:v.createElement(NM,{size:14,strokeWidth:1.2}),Provider:({children:n})=>v.createElement(LV,{initialTheme:t},n),leftPanel:{title:"Agents"},rightPanel:{title:"Context"},slots:{Content:UF,LeftPanel:iq,LeftFooter:eq,Inspector:QF,Takeover:oq},intents:xq,hooks:{useCommands:$V,useStatus:PV,useNavCenter:BV,useNavActions:VV,useLayoutMode:HV,useTakeover:ZV}}}ZT();function kj(e){return e==="dark"||e==="light"?e:null}function bq(){if(typeof window>"u")return"dark";const e=kj(window.__OPENSCOUT_WEB_BOOTSTRAP__?.theme);if(e)return e;const t=kj(new URLSearchParams(window.location.search).get("theme"));return t||"dark"}function wq(e){typeof document>"u"||(document.documentElement.dataset.scoutThemeMode=e,document.documentElement.style.colorScheme=e)}const FT=document.getElementById("root");if(!FT)throw new Error("missing #root");const qT=bq();wq(qT);hM.createRoot(FT).render(o.jsx(v.StrictMode,{children:o.jsx(FV,{app:ZT({initialTheme:qT})})}));export{Cj as F,io as f,o as j,v as r};
|