@markus-global/cli 0.4.13 → 0.4.14

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.
@@ -1,63 +0,0 @@
1
- (function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const d of o)if(d.type==="childList")for(const c of d.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&l(c)}).observe(document,{childList:!0,subtree:!0});function s(o){const d={};return o.integrity&&(d.integrity=o.integrity),o.referrerPolicy&&(d.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?d.credentials="include":o.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(o){if(o.ep)return;o.ep=!0;const d=s(o);fetch(o.href,d)}})();function Xd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var hh={exports:{}},ro={};var cb;function z2(){if(cb)return ro;cb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(l,o,d){var c=null;if(d!==void 0&&(c=""+d),o.key!==void 0&&(c=""+o.key),"key"in o){d={};for(var h in o)h!=="key"&&(d[h]=o[h])}else d=o;return o=d.ref,{$$typeof:e,type:l,key:c,ref:o!==void 0?o:null,props:d}}return ro.Fragment=n,ro.jsx=s,ro.jsxs=s,ro}var db;function $2(){return db||(db=1,hh.exports=z2()),hh.exports}var t=$2(),mh={exports:{}},Ot={};var ub;function B2(){if(ub)return Ot;ub=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),p=Symbol.iterator;function y(F){return F===null||typeof F!="object"?null:(F=p&&F[p]||F["@@iterator"],typeof F=="function"?F:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,C={};function _(F,X,I){this.props=F,this.context=X,this.refs=C,this.updater=I||w}_.prototype.isReactComponent={},_.prototype.setState=function(F,X){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,X,"setState")},_.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function O(){}O.prototype=_.prototype;function k(F,X,I){this.props=F,this.context=X,this.refs=C,this.updater=I||w}var S=k.prototype=new O;S.constructor=k,N(S,_.prototype),S.isPureReactComponent=!0;var R=Array.isArray;function D(){}var Y={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function K(F,X,I){var M=I.ref;return{$$typeof:e,type:F,key:X,ref:M!==void 0?M:null,props:I}}function U(F,X){return K(F.type,X,F.props)}function G(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function V(F){var X={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(I){return X[I]})}var E=/\/+/g;function T(F,X){return typeof F=="object"&&F!==null&&F.key!=null?V(""+F.key):X.toString(36)}function L(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(D,D):(F.status="pending",F.then(function(X){F.status==="pending"&&(F.status="fulfilled",F.value=X)},function(X){F.status==="pending"&&(F.status="rejected",F.reason=X)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function A(F,X,I,M,H){var Z=typeof F;(Z==="undefined"||Z==="boolean")&&(F=null);var ee=!1;if(F===null)ee=!0;else switch(Z){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(F.$$typeof){case e:case n:ee=!0;break;case g:return ee=F._init,A(ee(F._payload),X,I,M,H)}}if(ee)return H=H(F),ee=M===""?"."+T(F,0):M,R(H)?(I="",ee!=null&&(I=ee.replace(E,"$&/")+"/"),A(H,X,I,"",function(he){return he})):H!=null&&(G(H)&&(H=U(H,I+(H.key==null||F&&F.key===H.key?"":(""+H.key).replace(E,"$&/")+"/")+ee)),X.push(H)),1;ee=0;var ne=M===""?".":M+":";if(R(F))for(var ae=0;ae<F.length;ae++)M=F[ae],Z=ne+T(M,ae),ee+=A(M,X,I,Z,H);else if(ae=y(F),typeof ae=="function")for(F=ae.call(F),ae=0;!(M=F.next()).done;)M=M.value,Z=ne+T(M,ae++),ee+=A(M,X,I,Z,H);else if(Z==="object"){if(typeof F.then=="function")return A(L(F),X,I,M,H);throw X=String(F),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return ee}function P(F,X,I){if(F==null)return F;var M=[],H=0;return A(F,M,"","",function(Z){return X.call(I,Z,H++)}),M}function q(F){if(F._status===-1){var X=F._result;X=X(),X.then(function(I){(F._status===0||F._status===-1)&&(F._status=1,F._result=I)},function(I){(F._status===0||F._status===-1)&&(F._status=2,F._result=I)}),F._status===-1&&(F._status=0,F._result=X)}if(F._status===1)return F._result.default;throw F._result}var W=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},B={map:P,forEach:function(F,X,I){P(F,function(){X.apply(this,arguments)},I)},count:function(F){var X=0;return P(F,function(){X++}),X},toArray:function(F){return P(F,function(X){return X})||[]},only:function(F){if(!G(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return Ot.Activity=x,Ot.Children=B,Ot.Component=_,Ot.Fragment=s,Ot.Profiler=o,Ot.PureComponent=k,Ot.StrictMode=l,Ot.Suspense=m,Ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Y,Ot.__COMPILER_RUNTIME={__proto__:null,c:function(F){return Y.H.useMemoCache(F)}},Ot.cache=function(F){return function(){return F.apply(null,arguments)}},Ot.cacheSignal=function(){return null},Ot.cloneElement=function(F,X,I){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var M=N({},F.props),H=F.key;if(X!=null)for(Z in X.key!==void 0&&(H=""+X.key),X)!z.call(X,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&X.ref===void 0||(M[Z]=X[Z]);var Z=arguments.length-2;if(Z===1)M.children=I;else if(1<Z){for(var ee=Array(Z),ne=0;ne<Z;ne++)ee[ne]=arguments[ne+2];M.children=ee}return K(F.type,H,M)},Ot.createContext=function(F){return F={$$typeof:c,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:d,_context:F},F},Ot.createElement=function(F,X,I){var M,H={},Z=null;if(X!=null)for(M in X.key!==void 0&&(Z=""+X.key),X)z.call(X,M)&&M!=="key"&&M!=="__self"&&M!=="__source"&&(H[M]=X[M]);var ee=arguments.length-2;if(ee===1)H.children=I;else if(1<ee){for(var ne=Array(ee),ae=0;ae<ee;ae++)ne[ae]=arguments[ae+2];H.children=ne}if(F&&F.defaultProps)for(M in ee=F.defaultProps,ee)H[M]===void 0&&(H[M]=ee[M]);return K(F,Z,H)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(F){return{$$typeof:h,render:F}},Ot.isValidElement=G,Ot.lazy=function(F){return{$$typeof:g,_payload:{_status:-1,_result:F},_init:q}},Ot.memo=function(F,X){return{$$typeof:f,type:F,compare:X===void 0?null:X}},Ot.startTransition=function(F){var X=Y.T,I={};Y.T=I;try{var M=F(),H=Y.S;H!==null&&H(I,M),typeof M=="object"&&M!==null&&typeof M.then=="function"&&M.then(D,W)}catch(Z){W(Z)}finally{X!==null&&I.types!==null&&(X.types=I.types),Y.T=X}},Ot.unstable_useCacheRefresh=function(){return Y.H.useCacheRefresh()},Ot.use=function(F){return Y.H.use(F)},Ot.useActionState=function(F,X,I){return Y.H.useActionState(F,X,I)},Ot.useCallback=function(F,X){return Y.H.useCallback(F,X)},Ot.useContext=function(F){return Y.H.useContext(F)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(F,X){return Y.H.useDeferredValue(F,X)},Ot.useEffect=function(F,X){return Y.H.useEffect(F,X)},Ot.useEffectEvent=function(F){return Y.H.useEffectEvent(F)},Ot.useId=function(){return Y.H.useId()},Ot.useImperativeHandle=function(F,X,I){return Y.H.useImperativeHandle(F,X,I)},Ot.useInsertionEffect=function(F,X){return Y.H.useInsertionEffect(F,X)},Ot.useLayoutEffect=function(F,X){return Y.H.useLayoutEffect(F,X)},Ot.useMemo=function(F,X){return Y.H.useMemo(F,X)},Ot.useOptimistic=function(F,X){return Y.H.useOptimistic(F,X)},Ot.useReducer=function(F,X,I){return Y.H.useReducer(F,X,I)},Ot.useRef=function(F){return Y.H.useRef(F)},Ot.useState=function(F){return Y.H.useState(F)},Ot.useSyncExternalStore=function(F,X,I){return Y.H.useSyncExternalStore(F,X,I)},Ot.useTransition=function(){return Y.H.useTransition()},Ot.version="19.2.4",Ot}var fb;function Po(){return fb||(fb=1,mh.exports=B2()),mh.exports}var v=Po();const H2=Xd(v);var xh={exports:{}},so={},gh={exports:{}},ph={};var hb;function P2(){return hb||(hb=1,(function(e){function n(A,P){var q=A.length;A.push(P);e:for(;0<q;){var W=q-1>>>1,B=A[W];if(0<o(B,P))A[W]=P,A[q]=B,q=W;else break e}}function s(A){return A.length===0?null:A[0]}function l(A){if(A.length===0)return null;var P=A[0],q=A.pop();if(q!==P){A[0]=q;e:for(var W=0,B=A.length,F=B>>>1;W<F;){var X=2*(W+1)-1,I=A[X],M=X+1,H=A[M];if(0>o(I,q))M<B&&0>o(H,I)?(A[W]=H,A[M]=q,W=M):(A[W]=I,A[X]=q,W=X);else if(M<B&&0>o(H,q))A[W]=H,A[M]=q,W=M;else break e}}return P}function o(A,P){var q=A.sortIndex-P.sortIndex;return q!==0?q:A.id-P.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;e.unstable_now=function(){return d.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var m=[],f=[],g=1,x=null,p=3,y=!1,w=!1,N=!1,C=!1,_=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function S(A){for(var P=s(f);P!==null;){if(P.callback===null)l(f);else if(P.startTime<=A)l(f),P.sortIndex=P.expirationTime,n(m,P);else break;P=s(f)}}function R(A){if(N=!1,S(A),!w)if(s(m)!==null)w=!0,D||(D=!0,V());else{var P=s(f);P!==null&&L(R,P.startTime-A)}}var D=!1,Y=-1,z=5,K=-1;function U(){return C?!0:!(e.unstable_now()-K<z)}function G(){if(C=!1,D){var A=e.unstable_now();K=A;var P=!0;try{e:{w=!1,N&&(N=!1,O(Y),Y=-1),y=!0;var q=p;try{t:{for(S(A),x=s(m);x!==null&&!(x.expirationTime>A&&U());){var W=x.callback;if(typeof W=="function"){x.callback=null,p=x.priorityLevel;var B=W(x.expirationTime<=A);if(A=e.unstable_now(),typeof B=="function"){x.callback=B,S(A),P=!0;break t}x===s(m)&&l(m),S(A)}else l(m);x=s(m)}if(x!==null)P=!0;else{var F=s(f);F!==null&&L(R,F.startTime-A),P=!1}}break e}finally{x=null,p=q,y=!1}P=void 0}}finally{P?V():D=!1}}}var V;if(typeof k=="function")V=function(){k(G)};else if(typeof MessageChannel<"u"){var E=new MessageChannel,T=E.port2;E.port1.onmessage=G,V=function(){T.postMessage(null)}}else V=function(){_(G,0)};function L(A,P){Y=_(function(){A(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(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_next=function(A){switch(p){case 1:case 2:case 3:var P=3;break;default:P=p}var q=p;p=P;try{return A()}finally{p=q}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(A,P){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var q=p;p=A;try{return P()}finally{p=q}},e.unstable_scheduleCallback=function(A,P,q){var W=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?W+q:W):q=W,A){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=q+B,A={id:g++,callback:P,priorityLevel:A,startTime:q,expirationTime:B,sortIndex:-1},q>W?(A.sortIndex=q,n(f,A),s(m)===null&&A===s(f)&&(N?(O(Y),Y=-1):N=!0,L(R,q-W))):(A.sortIndex=B,n(m,A),w||y||(w=!0,D||(D=!0,V()))),A},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(A){var P=p;return function(){var q=p;p=P;try{return A.apply(this,arguments)}finally{p=q}}}})(ph)),ph}var mb;function U2(){return mb||(mb=1,gh.exports=P2()),gh.exports}var bh={exports:{}},hr={};var xb;function q2(){if(xb)return hr;xb=1;var e=Po();function n(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)f+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var l={d:{f:s,r:function(){throw Error(n(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");function d(m,f,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:x==null?null:""+x,children:m,containerInfo:f,implementation:g}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return hr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,hr.createPortal=function(m,f){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(n(299));return d(m,f,null,g)},hr.flushSync=function(m){var f=c.T,g=l.p;try{if(c.T=null,l.p=2,m)return m()}finally{c.T=f,l.p=g,l.d.f()}},hr.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,l.d.C(m,f))},hr.prefetchDNS=function(m){typeof m=="string"&&l.d.D(m)},hr.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var g=f.as,x=h(g,f.crossOrigin),p=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;g==="style"?l.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:x,integrity:p,fetchPriority:y}):g==="script"&&l.d.X(m,{crossOrigin:x,integrity:p,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},hr.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var g=h(f.as,f.crossOrigin);l.d.M(m,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&l.d.M(m)},hr.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var g=f.as,x=h(g,f.crossOrigin);l.d.L(m,g,{crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},hr.preloadModule=function(m,f){if(typeof m=="string")if(f){var g=h(f.as,f.crossOrigin);l.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else l.d.m(m)},hr.requestFormReset=function(m){l.d.r(m)},hr.unstable_batchedUpdates=function(m,f){return m(f)},hr.useFormState=function(m,f,g){return c.H.useFormState(m,f,g)},hr.useFormStatus=function(){return c.H.useHostTransitionStatus()},hr.version="19.2.4",hr}var gb;function d1(){if(gb)return bh.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(n){console.error(n)}}return e(),bh.exports=q2(),bh.exports}var pb;function V2(){if(pb)return so;pb=1;var e=U2(),n=Po(),s=d1();function l(r){var a="https://react.dev/errors/"+r;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)a+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+r+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function d(r){var a=r,i=r;if(r.alternate)for(;a.return;)a=a.return;else{r=a;do a=r,(a.flags&4098)!==0&&(i=a.return),r=a.return;while(r)}return a.tag===3?i:null}function c(r){if(r.tag===13){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function h(r){if(r.tag===31){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function m(r){if(d(r)!==r)throw Error(l(188))}function f(r){var a=r.alternate;if(!a){if(a=d(r),a===null)throw Error(l(188));return a!==r?null:r}for(var i=r,u=a;;){var b=i.return;if(b===null)break;var j=b.alternate;if(j===null){if(u=b.return,u!==null){i=u;continue}break}if(b.child===j.child){for(j=b.child;j;){if(j===i)return m(b),r;if(j===u)return m(b),a;j=j.sibling}throw Error(l(188))}if(i.return!==u.return)i=b,u=j;else{for(var $=!1,Q=b.child;Q;){if(Q===i){$=!0,i=b,u=j;break}if(Q===u){$=!0,u=b,i=j;break}Q=Q.sibling}if(!$){for(Q=j.child;Q;){if(Q===i){$=!0,i=j,u=b;break}if(Q===u){$=!0,u=j,i=b;break}Q=Q.sibling}if(!$)throw Error(l(189))}}if(i.alternate!==u)throw Error(l(190))}if(i.tag!==3)throw Error(l(188));return i.stateNode.current===i?r:a}function g(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r;for(r=r.child;r!==null;){if(a=g(r),a!==null)return a;r=r.sibling}return null}var x=Object.assign,p=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),k=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function V(r){return r===null||typeof r!="object"?null:(r=G&&r[G]||r["@@iterator"],typeof r=="function"?r:null)}var E=Symbol.for("react.client.reference");function T(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===E?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case N:return"Fragment";case _:return"Profiler";case C:return"StrictMode";case R:return"Suspense";case D:return"SuspenseList";case K:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case k:return r.displayName||"Context";case O:return(r._context.displayName||"Context")+".Consumer";case S:var a=r.render;return r=r.displayName,r||(r=a.displayName||a.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Y:return a=r.displayName||null,a!==null?a:T(r.type)||"Memo";case z:a=r._payload,r=r._init;try{return T(r(a))}catch{}}return null}var L=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q={pending:!1,data:null,method:null,action:null},W=[],B=-1;function F(r){return{current:r}}function X(r){0>B||(r.current=W[B],W[B]=null,B--)}function I(r,a){B++,W[B]=r.current,r.current=a}var M=F(null),H=F(null),Z=F(null),ee=F(null);function ne(r,a){switch(I(Z,a),I(H,r),I(M,null),a.nodeType){case 9:case 11:r=(r=a.documentElement)&&(r=r.namespaceURI)?O0(r):0;break;default:if(r=a.tagName,a=a.namespaceURI)a=O0(a),r=R0(a,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}X(M),I(M,r)}function ae(){X(M),X(H),X(Z)}function he(r){r.memoizedState!==null&&I(ee,r);var a=M.current,i=R0(a,r.type);a!==i&&(I(H,r),I(M,i))}function Ne(r){H.current===r&&(X(M),X(H)),ee.current===r&&(X(ee),Ji._currentValue=q)}var Le,ye;function je(r){if(Le===void 0)try{throw Error()}catch(i){var a=i.stack.trim().match(/\n( *(at )?)/);Le=a&&a[1]||"",ye=-1<i.stack.indexOf(`
2
- at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+Le+r+ye}var Ae=!1;function $e(r,a){if(!r||Ae)return"";Ae=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(a){var Re=function(){throw Error()};if(Object.defineProperty(Re.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Re,[])}catch(Se){var be=Se}Reflect.construct(r,[],Re)}else{try{Re.call()}catch(Se){be=Se}r.call(Re.prototype)}}else{try{throw Error()}catch(Se){be=Se}(Re=r())&&typeof Re.catch=="function"&&Re.catch(function(){})}}catch(Se){if(Se&&be&&typeof Se.stack=="string")return[Se.stack,be.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=u.DetermineComponentFrameRoot(),$=j[0],Q=j[1];if($&&Q){var le=$.split(`
4
- `),xe=Q.split(`
5
- `);for(b=u=0;u<le.length&&!le[u].includes("DetermineComponentFrameRoot");)u++;for(;b<xe.length&&!xe[b].includes("DetermineComponentFrameRoot");)b++;if(u===le.length||b===xe.length)for(u=le.length-1,b=xe.length-1;1<=u&&0<=b&&le[u]!==xe[b];)b--;for(;1<=u&&0<=b;u--,b--)if(le[u]!==xe[b]){if(u!==1||b!==1)do if(u--,b--,0>b||le[u]!==xe[b]){var _e=`
6
- `+le[u].replace(" at new "," at ");return r.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",r.displayName)),_e}while(1<=u&&0<=b);break}}}finally{Ae=!1,Error.prepareStackTrace=i}return(i=r?r.displayName||r.name:"")?je(i):""}function Xe(r,a){switch(r.tag){case 26:case 27:case 5:return je(r.type);case 16:return je("Lazy");case 13:return r.child!==a&&a!==null?je("Suspense Fallback"):je("Suspense");case 19:return je("SuspenseList");case 0:case 15:return $e(r.type,!1);case 11:return $e(r.type.render,!1);case 1:return $e(r.type,!0);case 31:return je("Activity");default:return""}}function tt(r){try{var a="",i=null;do a+=Xe(r,i),i=r,r=r.return;while(r);return a}catch(u){return`
7
- Error generating stack: `+u.message+`
8
- `+u.stack}}var et=Object.prototype.hasOwnProperty,_t=e.unstable_scheduleCallback,se=e.unstable_cancelCallback,Te=e.unstable_shouldYield,nt=e.unstable_requestPaint,yt=e.unstable_now,Xt=e.unstable_getCurrentPriorityLevel,we=e.unstable_ImmediatePriority,De=e.unstable_UserBlockingPriority,Pe=e.unstable_NormalPriority,Ze=e.unstable_LowPriority,mt=e.unstable_IdlePriority,Kt=e.log,ln=e.unstable_setDisableYieldValue,Ht=null,Lt=null;function At(r){if(typeof Kt=="function"&&ln(r),Lt&&typeof Lt.setStrictMode=="function")try{Lt.setStrictMode(Ht,r)}catch{}}var St=Math.clz32?Math.clz32:ve,en=Math.log,tn=Math.LN2;function ve(r){return r>>>=0,r===0?32:31-(en(r)/tn|0)|0}var Ve=256,Rt=262144,Pt=4194304;function vt(r){var a=r&42;if(a!==0)return a;switch(r&-r){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 r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function sn(r,a,i){var u=r.pendingLanes;if(u===0)return 0;var b=0,j=r.suspendedLanes,$=r.pingedLanes;r=r.warmLanes;var Q=u&134217727;return Q!==0?(u=Q&~j,u!==0?b=vt(u):($&=Q,$!==0?b=vt($):i||(i=Q&~r,i!==0&&(b=vt(i))))):(Q=u&~j,Q!==0?b=vt(Q):$!==0?b=vt($):i||(i=u&~r,i!==0&&(b=vt(i)))),b===0?0:a!==0&&a!==b&&(a&j)===0&&(j=b&-b,i=a&-a,j>=i||j===32&&(i&4194048)!==0)?a:b}function gn(r,a){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&a)===0}function rt(r,a){switch(r){case 1:case 2:case 4:case 8:case 64:return a+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 a+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 Wt(){var r=Pt;return Pt<<=1,(Pt&62914560)===0&&(Pt=4194304),r}function Mn(r){for(var a=[],i=0;31>i;i++)a.push(r);return a}function Mt(r,a){r.pendingLanes|=a,a!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function yn(r,a,i,u,b,j){var $=r.pendingLanes;r.pendingLanes=i,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=i,r.entangledLanes&=i,r.errorRecoveryDisabledLanes&=i,r.shellSuspendCounter=0;var Q=r.entanglements,le=r.expirationTimes,xe=r.hiddenUpdates;for(i=$&~i;0<i;){var _e=31-St(i),Re=1<<_e;Q[_e]=0,le[_e]=-1;var be=xe[_e];if(be!==null)for(xe[_e]=null,_e=0;_e<be.length;_e++){var Se=be[_e];Se!==null&&(Se.lane&=-536870913)}i&=~Re}u!==0&&Nn(r,u,0),j!==0&&b===0&&r.tag!==0&&(r.suspendedLanes|=j&~($&~a))}function Nn(r,a,i){r.pendingLanes|=a,r.suspendedLanes&=~a;var u=31-St(a);r.entangledLanes|=a,r.entanglements[u]=r.entanglements[u]|1073741824|i&261930}function ie(r,a){var i=r.entangledLanes|=a;for(r=r.entanglements;i;){var u=31-St(i),b=1<<u;b&a|r[u]&a&&(r[u]|=a),i&=~b}}function qe(r,a){var i=a&-a;return i=(i&42)!==0?1:ze(i),(i&(r.suspendedLanes|a))!==0?0:i}function ze(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=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:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function We(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function lt(){var r=P.p;return r!==0?r:(r=window.event,r===void 0?32:nb(r.type))}function Ct(r,a){var i=P.p;try{return P.p=r,a()}finally{P.p=i}}var dt=Math.random().toString(36).slice(2),zt="__reactFiber$"+dt,pt="__reactProps$"+dt,on="__reactContainer$"+dt,de="__reactEvents$"+dt,Fe="__reactListeners$"+dt,ht="__reactHandles$"+dt,Tt="__reactResources$"+dt,Rn="__reactMarker$"+dt;function gr(r){delete r[zt],delete r[pt],delete r[de],delete r[Fe],delete r[ht]}function pr(r){var a=r[zt];if(a)return a;for(var i=r.parentNode;i;){if(a=i[on]||i[zt]){if(i=a.alternate,a.child!==null||i!==null&&i.child!==null)for(r=H0(r);r!==null;){if(i=r[zt])return i;r=H0(r)}return a}r=i,i=r.parentNode}return null}function nr(r){if(r=r[zt]||r[on]){var a=r.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return r}return null}function dr(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r.stateNode;throw Error(l(33))}function ur(r){var a=r[Tt];return a||(a=r[Tt]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function vn(r){r[Rn]=!0}var gs=new Set,qr={};function fr(r,a){rr(r,a),rr(r+"Capture",a)}function rr(r,a){for(qr[r]=a,r=0;r<a.length;r++)gs.add(a[r])}var Vr=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]*$"),oe={},ke={};function Be(r){return et.call(ke,r)?!0:et.call(oe,r)?!1:Vr.test(r)?ke[r]=!0:(oe[r]=!0,!1)}function Dt(r,a,i){if(Be(a))if(i===null)r.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":r.removeAttribute(a);return;case"boolean":var u=a.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){r.removeAttribute(a);return}}r.setAttribute(a,""+i)}}function Jn(r,a,i){if(i===null)r.removeAttribute(a);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(a);return}r.setAttribute(a,""+i)}}function Dn(r,a,i,u){if(u===null)r.removeAttribute(i);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(i);return}r.setAttributeNS(a,i,""+u)}}function En(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function ss(r){var a=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Os(r,a,i){var u=Object.getOwnPropertyDescriptor(r.constructor.prototype,a);if(!r.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var b=u.get,j=u.set;return Object.defineProperty(r,a,{configurable:!0,get:function(){return b.call(this)},set:function($){i=""+$,j.call(this,$)}}),Object.defineProperty(r,a,{enumerable:u.enumerable}),{getValue:function(){return i},setValue:function($){i=""+$},stopTracking:function(){r._valueTracker=null,delete r[a]}}}}function as(r){if(!r._valueTracker){var a=ss(r)?"checked":"value";r._valueTracker=Os(r,a,""+r[a])}}function Fr(r){if(!r)return!1;var a=r._valueTracker;if(!a)return!0;var i=a.getValue(),u="";return r&&(u=ss(r)?r.checked?"true":"false":r.value),r=u,r!==i?(a.setValue(r),!0):!1}function Un(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var Rs=/[\n"\\]/g;function Ln(r){return r.replace(Rs,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Yr(r,a,i,u,b,j,$,Q){r.name="",$!=null&&typeof $!="function"&&typeof $!="symbol"&&typeof $!="boolean"?r.type=$:r.removeAttribute("type"),a!=null?$==="number"?(a===0&&r.value===""||r.value!=a)&&(r.value=""+En(a)):r.value!==""+En(a)&&(r.value=""+En(a)):$!=="submit"&&$!=="reset"||r.removeAttribute("value"),a!=null?Mr(r,$,En(a)):i!=null?Mr(r,$,En(i)):u!=null&&r.removeAttribute("value"),b==null&&j!=null&&(r.defaultChecked=!!j),b!=null&&(r.checked=b&&typeof b!="function"&&typeof b!="symbol"),Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"?r.name=""+En(Q):r.removeAttribute("name")}function br(r,a,i,u,b,j,$,Q){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.type=j),a!=null||i!=null){if(!(j!=="submit"&&j!=="reset"||a!=null)){as(r);return}i=i!=null?""+En(i):"",a=a!=null?""+En(a):i,Q||a===r.value||(r.value=a),r.defaultValue=a}u=u??b,u=typeof u!="function"&&typeof u!="symbol"&&!!u,r.checked=Q?r.checked:!!u,r.defaultChecked=!!u,$!=null&&typeof $!="function"&&typeof $!="symbol"&&typeof $!="boolean"&&(r.name=$),as(r)}function Mr(r,a,i){a==="number"&&Un(r.ownerDocument)===r||r.defaultValue===""+i||(r.defaultValue=""+i)}function sr(r,a,i,u){if(r=r.options,a){a={};for(var b=0;b<i.length;b++)a["$"+i[b]]=!0;for(i=0;i<r.length;i++)b=a.hasOwnProperty("$"+r[i].value),r[i].selected!==b&&(r[i].selected=b),b&&u&&(r[i].defaultSelected=!0)}else{for(i=""+En(i),a=null,b=0;b<r.length;b++){if(r[b].value===i){r[b].selected=!0,u&&(r[b].defaultSelected=!0);return}a!==null||r[b].disabled||(a=r[b])}a!==null&&(a.selected=!0)}}function Gr(r,a,i){if(a!=null&&(a=""+En(a),a!==r.value&&(r.value=a),i==null)){r.defaultValue!==a&&(r.defaultValue=a);return}r.defaultValue=i!=null?""+En(i):""}function te(r,a,i,u){if(a==null){if(u!=null){if(i!=null)throw Error(l(92));if(L(u)){if(1<u.length)throw Error(l(93));u=u[0]}i=u}i==null&&(i=""),a=i}i=En(a),r.defaultValue=i,u=r.textContent,u===i&&u!==""&&u!==null&&(r.value=u),as(r)}function Ie(r,a){if(a){var i=r.firstChild;if(i&&i===r.lastChild&&i.nodeType===3){i.nodeValue=a;return}}r.textContent=a}var Ye=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 J(r,a,i){var u=a.indexOf("--")===0;i==null||typeof i=="boolean"||i===""?u?r.setProperty(a,""):a==="float"?r.cssFloat="":r[a]="":u?r.setProperty(a,i):typeof i!="number"||i===0||Ye.has(a)?a==="float"?r.cssFloat=i:r[a]=(""+i).trim():r[a]=i+"px"}function pe(r,a,i){if(a!=null&&typeof a!="object")throw Error(l(62));if(r=r.style,i!=null){for(var u in i)!i.hasOwnProperty(u)||a!=null&&a.hasOwnProperty(u)||(u.indexOf("--")===0?r.setProperty(u,""):u==="float"?r.cssFloat="":r[u]="");for(var b in a)u=a[b],a.hasOwnProperty(b)&&i[b]!==u&&J(r,b,u)}else for(var j in a)a.hasOwnProperty(j)&&J(r,j,a[j])}function Ee(r){if(r.indexOf("-")===-1)return!1;switch(r){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 Me=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"]]),Ce=/^[\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 Ge(r){return Ce.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Ue(){}var Nt=null;function ut(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var st=null,Et=null;function Ut(r){var a=nr(r);if(a&&(r=a.stateNode)){var i=r[pt]||null;e:switch(r=a.stateNode,a.type){case"input":if(Yr(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name),a=i.name,i.type==="radio"&&a!=null){for(i=r;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll('input[name="'+Ln(""+a)+'"][type="radio"]'),a=0;a<i.length;a++){var u=i[a];if(u!==r&&u.form===r.form){var b=u[pt]||null;if(!b)throw Error(l(90));Yr(u,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name)}}for(a=0;a<i.length;a++)u=i[a],u.form===r.form&&Fr(u)}break e;case"textarea":Gr(r,i.value,i.defaultValue);break e;case"select":a=i.value,a!=null&&sr(r,!!i.multiple,a,!1)}}}var jn=!1;function $n(r,a,i){if(jn)return r(a,i);jn=!0;try{var u=r(a);return u}finally{if(jn=!1,(st!==null||Et!==null)&&(Lc(),st&&(a=st,r=Et,Et=st=null,Ut(a),r)))for(a=0;a<r.length;a++)Ut(r[a])}}function jt(r,a){var i=r.stateNode;if(i===null)return null;var u=i[pt]||null;if(u===null)return null;i=u[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(r=r.type,u=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!u;break e;default:r=!1}if(r)return null;if(i&&typeof i!="function")throw Error(l(231,a,typeof i));return i}var it=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bt=!1;if(it)try{var Qe={};Object.defineProperty(Qe,"passive",{get:function(){bt=!0}}),window.addEventListener("test",Qe,Qe),window.removeEventListener("test",Qe,Qe)}catch{bt=!1}var Ke=null,ot=null,ct=null;function On(){if(ct)return ct;var r,a=ot,i=a.length,u,b="value"in Ke?Ke.value:Ke.textContent,j=b.length;for(r=0;r<i&&a[r]===b[r];r++);var $=i-r;for(u=1;u<=$&&a[i-u]===b[j-u];u++);return ct=b.slice(r,1<u?1-u:void 0)}function ar(r){var a=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&a===13&&(r=13)):r=a,r===10&&(r=13),32<=r||r===13?r:0}function sa(){return!0}function Wo(){return!1}function jr(r){function a(i,u,b,j,$){this._reactName=i,this._targetInst=b,this.type=u,this.nativeEvent=j,this.target=$,this.currentTarget=null;for(var Q in r)r.hasOwnProperty(Q)&&(i=r[Q],this[Q]=i?i(j):j[Q]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?sa:Wo,this.isPropagationStopped=Wo,this}return x(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=sa)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=sa)},persist:function(){},isPersistent:sa}),a}var Ha={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qo=jr(Ha),bi=x({},Ha,{view:0,detail:0}),LN=jr(bi),mu,xu,yi,Jo=x({},bi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pu,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==yi&&(yi&&r.type==="mousemove"?(mu=r.screenX-yi.screenX,xu=r.screenY-yi.screenY):xu=mu=0,yi=r),mu)},movementY:function(r){return"movementY"in r?r.movementY:xu}}),Lx=jr(Jo),IN=x({},Jo,{dataTransfer:0}),zN=jr(IN),$N=x({},bi,{relatedTarget:0}),gu=jr($N),BN=x({},Ha,{animationName:0,elapsedTime:0,pseudoElement:0}),HN=jr(BN),PN=x({},Ha,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),UN=jr(PN),qN=x({},Ha,{data:0}),Ix=jr(qN),VN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},FN={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"},YN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function GN(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=YN[r])?!!a[r]:!1}function pu(){return GN}var XN=x({},bi,{key:function(r){if(r.key){var a=VN[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=ar(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?FN[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pu,charCode:function(r){return r.type==="keypress"?ar(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?ar(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),KN=jr(XN),ZN=x({},Jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zx=jr(ZN),WN=x({},bi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pu}),QN=jr(WN),JN=x({},Ha,{propertyName:0,elapsedTime:0,pseudoElement:0}),e5=jr(JN),t5=x({},Jo,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),n5=jr(t5),r5=x({},Ha,{newState:0,oldState:0}),s5=jr(r5),a5=[9,13,27,32],bu=it&&"CompositionEvent"in window,vi=null;it&&"documentMode"in document&&(vi=document.documentMode);var l5=it&&"TextEvent"in window&&!vi,$x=it&&(!bu||vi&&8<vi&&11>=vi),Bx=" ",Hx=!1;function Px(r,a){switch(r){case"keyup":return a5.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ux(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var pl=!1;function i5(r,a){switch(r){case"compositionend":return Ux(a);case"keypress":return a.which!==32?null:(Hx=!0,Bx);case"textInput":return r=a.data,r===Bx&&Hx?null:r;default:return null}}function o5(r,a){if(pl)return r==="compositionend"||!bu&&Px(r,a)?(r=On(),ct=ot=Ke=null,pl=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return $x&&a.locale!=="ko"?null:a.data;default:return null}}var c5={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 qx(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!c5[r.type]:a==="textarea"}function Vx(r,a,i,u){st?Et?Et.push(u):Et=[u]:st=u,a=Uc(a,"onChange"),0<a.length&&(i=new Qo("onChange","change",null,i,u),r.push({event:i,listeners:a}))}var ji=null,wi=null;function d5(r){C0(r,0)}function ec(r){var a=dr(r);if(Fr(a))return r}function Fx(r,a){if(r==="change")return a}var Yx=!1;if(it){var yu;if(it){var vu="oninput"in document;if(!vu){var Gx=document.createElement("div");Gx.setAttribute("oninput","return;"),vu=typeof Gx.oninput=="function"}yu=vu}else yu=!1;Yx=yu&&(!document.documentMode||9<document.documentMode)}function Xx(){ji&&(ji.detachEvent("onpropertychange",Kx),wi=ji=null)}function Kx(r){if(r.propertyName==="value"&&ec(wi)){var a=[];Vx(a,wi,r,ut(r)),$n(d5,a)}}function u5(r,a,i){r==="focusin"?(Xx(),ji=a,wi=i,ji.attachEvent("onpropertychange",Kx)):r==="focusout"&&Xx()}function f5(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return ec(wi)}function h5(r,a){if(r==="click")return ec(a)}function m5(r,a){if(r==="input"||r==="change")return ec(a)}function x5(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Or=typeof Object.is=="function"?Object.is:x5;function Ni(r,a){if(Or(r,a))return!0;if(typeof r!="object"||r===null||typeof a!="object"||a===null)return!1;var i=Object.keys(r),u=Object.keys(a);if(i.length!==u.length)return!1;for(u=0;u<i.length;u++){var b=i[u];if(!et.call(a,b)||!Or(r[b],a[b]))return!1}return!0}function Zx(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Wx(r,a){var i=Zx(r);r=0;for(var u;i;){if(i.nodeType===3){if(u=r+i.textContent.length,r<=a&&u>=a)return{node:i,offset:a-r};r=u}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Zx(i)}}function Qx(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?Qx(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function Jx(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var a=Un(r.document);a instanceof r.HTMLIFrameElement;){try{var i=typeof a.contentWindow.location.href=="string"}catch{i=!1}if(i)r=a.contentWindow;else break;a=Un(r.document)}return a}function ju(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a&&(a==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||a==="textarea"||r.contentEditable==="true")}var g5=it&&"documentMode"in document&&11>=document.documentMode,bl=null,wu=null,ki=null,Nu=!1;function eg(r,a,i){var u=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Nu||bl==null||bl!==Un(u)||(u=bl,"selectionStart"in u&&ju(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ki&&Ni(ki,u)||(ki=u,u=Uc(wu,"onSelect"),0<u.length&&(a=new Qo("onSelect","select",null,a,i),r.push({event:a,listeners:u}),a.target=bl)))}function Pa(r,a){var i={};return i[r.toLowerCase()]=a.toLowerCase(),i["Webkit"+r]="webkit"+a,i["Moz"+r]="moz"+a,i}var yl={animationend:Pa("Animation","AnimationEnd"),animationiteration:Pa("Animation","AnimationIteration"),animationstart:Pa("Animation","AnimationStart"),transitionrun:Pa("Transition","TransitionRun"),transitionstart:Pa("Transition","TransitionStart"),transitioncancel:Pa("Transition","TransitionCancel"),transitionend:Pa("Transition","TransitionEnd")},ku={},tg={};it&&(tg=document.createElement("div").style,"AnimationEvent"in window||(delete yl.animationend.animation,delete yl.animationiteration.animation,delete yl.animationstart.animation),"TransitionEvent"in window||delete yl.transitionend.transition);function Ua(r){if(ku[r])return ku[r];if(!yl[r])return r;var a=yl[r],i;for(i in a)if(a.hasOwnProperty(i)&&i in tg)return ku[r]=a[i];return r}var ng=Ua("animationend"),rg=Ua("animationiteration"),sg=Ua("animationstart"),p5=Ua("transitionrun"),b5=Ua("transitionstart"),y5=Ua("transitioncancel"),ag=Ua("transitionend"),lg=new Map,Su="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(" ");Su.push("scrollEnd");function ls(r,a){lg.set(r,a),fr(a,[r])}var tc=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},Xr=[],vl=0,Cu=0;function nc(){for(var r=vl,a=Cu=vl=0;a<r;){var i=Xr[a];Xr[a++]=null;var u=Xr[a];Xr[a++]=null;var b=Xr[a];Xr[a++]=null;var j=Xr[a];if(Xr[a++]=null,u!==null&&b!==null){var $=u.pending;$===null?b.next=b:(b.next=$.next,$.next=b),u.pending=b}j!==0&&ig(i,b,j)}}function rc(r,a,i,u){Xr[vl++]=r,Xr[vl++]=a,Xr[vl++]=i,Xr[vl++]=u,Cu|=u,r.lanes|=u,r=r.alternate,r!==null&&(r.lanes|=u)}function Eu(r,a,i,u){return rc(r,a,i,u),sc(r)}function qa(r,a){return rc(r,null,null,a),sc(r)}function ig(r,a,i){r.lanes|=i;var u=r.alternate;u!==null&&(u.lanes|=i);for(var b=!1,j=r.return;j!==null;)j.childLanes|=i,u=j.alternate,u!==null&&(u.childLanes|=i),j.tag===22&&(r=j.stateNode,r===null||r._visibility&1||(b=!0)),r=j,j=j.return;return r.tag===3?(j=r.stateNode,b&&a!==null&&(b=31-St(i),r=j.hiddenUpdates,u=r[b],u===null?r[b]=[a]:u.push(a),a.lane=i|536870912),j):null}function sc(r){if(50<Yi)throw Yi=0,zf=null,Error(l(185));for(var a=r.return;a!==null;)r=a,a=r.return;return r.tag===3?r.stateNode:null}var jl={};function v5(r,a,i,u){this.tag=r,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Rr(r,a,i,u){return new v5(r,a,i,u)}function Tu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Ds(r,a){var i=r.alternate;return i===null?(i=Rr(r.tag,a,r.key,r.mode),i.elementType=r.elementType,i.type=r.type,i.stateNode=r.stateNode,i.alternate=r,r.alternate=i):(i.pendingProps=a,i.type=r.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=r.flags&65011712,i.childLanes=r.childLanes,i.lanes=r.lanes,i.child=r.child,i.memoizedProps=r.memoizedProps,i.memoizedState=r.memoizedState,i.updateQueue=r.updateQueue,a=r.dependencies,i.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},i.sibling=r.sibling,i.index=r.index,i.ref=r.ref,i.refCleanup=r.refCleanup,i}function og(r,a){r.flags&=65011714;var i=r.alternate;return i===null?(r.childLanes=0,r.lanes=a,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=i.childLanes,r.lanes=i.lanes,r.child=i.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=i.memoizedProps,r.memoizedState=i.memoizedState,r.updateQueue=i.updateQueue,r.type=i.type,a=i.dependencies,r.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),r}function ac(r,a,i,u,b,j){var $=0;if(u=r,typeof r=="function")Tu(r)&&($=1);else if(typeof r=="string")$=S2(r,i,M.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case K:return r=Rr(31,i,a,b),r.elementType=K,r.lanes=j,r;case N:return Va(i.children,b,j,a);case C:$=8,b|=24;break;case _:return r=Rr(12,i,a,b|2),r.elementType=_,r.lanes=j,r;case R:return r=Rr(13,i,a,b),r.elementType=R,r.lanes=j,r;case D:return r=Rr(19,i,a,b),r.elementType=D,r.lanes=j,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case k:$=10;break e;case O:$=9;break e;case S:$=11;break e;case Y:$=14;break e;case z:$=16,u=null;break e}$=29,i=Error(l(130,r===null?"null":typeof r,"")),u=null}return a=Rr($,i,a,b),a.elementType=r,a.type=u,a.lanes=j,a}function Va(r,a,i,u){return r=Rr(7,r,u,a),r.lanes=i,r}function Au(r,a,i){return r=Rr(6,r,null,a),r.lanes=i,r}function cg(r){var a=Rr(18,null,null,0);return a.stateNode=r,a}function _u(r,a,i){return a=Rr(4,r.children!==null?r.children:[],r.key,a),a.lanes=i,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}var dg=new WeakMap;function Kr(r,a){if(typeof r=="object"&&r!==null){var i=dg.get(r);return i!==void 0?i:(a={value:r,source:a,stack:tt(a)},dg.set(r,a),a)}return{value:r,source:a,stack:tt(a)}}var wl=[],Nl=0,lc=null,Si=0,Zr=[],Wr=0,aa=null,ps=1,bs="";function Ls(r,a){wl[Nl++]=Si,wl[Nl++]=lc,lc=r,Si=a}function ug(r,a,i){Zr[Wr++]=ps,Zr[Wr++]=bs,Zr[Wr++]=aa,aa=r;var u=ps;r=bs;var b=32-St(u)-1;u&=~(1<<b),i+=1;var j=32-St(a)+b;if(30<j){var $=b-b%5;j=(u&(1<<$)-1).toString(32),u>>=$,b-=$,ps=1<<32-St(a)+b|i<<b|u,bs=j+r}else ps=1<<j|i<<b|u,bs=r}function Mu(r){r.return!==null&&(Ls(r,1),ug(r,1,0))}function Ou(r){for(;r===lc;)lc=wl[--Nl],wl[Nl]=null,Si=wl[--Nl],wl[Nl]=null;for(;r===aa;)aa=Zr[--Wr],Zr[Wr]=null,bs=Zr[--Wr],Zr[Wr]=null,ps=Zr[--Wr],Zr[Wr]=null}function fg(r,a){Zr[Wr++]=ps,Zr[Wr++]=bs,Zr[Wr++]=aa,ps=a.id,bs=a.overflow,aa=r}var lr=null,kn=null,Zt=!1,la=null,Qr=!1,Ru=Error(l(519));function ia(r){var a=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ci(Kr(a,r)),Ru}function hg(r){var a=r.stateNode,i=r.type,u=r.memoizedProps;switch(a[zt]=r,a[pt]=u,i){case"dialog":Vt("cancel",a),Vt("close",a);break;case"iframe":case"object":case"embed":Vt("load",a);break;case"video":case"audio":for(i=0;i<Xi.length;i++)Vt(Xi[i],a);break;case"source":Vt("error",a);break;case"img":case"image":case"link":Vt("error",a),Vt("load",a);break;case"details":Vt("toggle",a);break;case"input":Vt("invalid",a),br(a,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":Vt("invalid",a);break;case"textarea":Vt("invalid",a),te(a,u.value,u.defaultValue,u.children)}i=u.children,typeof i!="string"&&typeof i!="number"&&typeof i!="bigint"||a.textContent===""+i||u.suppressHydrationWarning===!0||_0(a.textContent,i)?(u.popover!=null&&(Vt("beforetoggle",a),Vt("toggle",a)),u.onScroll!=null&&Vt("scroll",a),u.onScrollEnd!=null&&Vt("scrollend",a),u.onClick!=null&&(a.onclick=Ue),a=!0):a=!1,a||ia(r,!0)}function mg(r){for(lr=r.return;lr;)switch(lr.tag){case 5:case 31:case 13:Qr=!1;return;case 27:case 3:Qr=!0;return;default:lr=lr.return}}function kl(r){if(r!==lr)return!1;if(!Zt)return mg(r),Zt=!0,!1;var a=r.tag,i;if((i=a!==3&&a!==27)&&((i=a===5)&&(i=r.type,i=!(i!=="form"&&i!=="button")||Qf(r.type,r.memoizedProps)),i=!i),i&&kn&&ia(r),mg(r),a===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(317));kn=B0(r)}else if(a===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(317));kn=B0(r)}else a===27?(a=kn,ja(r.type)?(r=rh,rh=null,kn=r):kn=a):kn=lr?es(r.stateNode.nextSibling):null;return!0}function Fa(){kn=lr=null,Zt=!1}function Du(){var r=la;return r!==null&&(Sr===null?Sr=r:Sr.push.apply(Sr,r),la=null),r}function Ci(r){la===null?la=[r]:la.push(r)}var Lu=F(null),Ya=null,Is=null;function oa(r,a,i){I(Lu,a._currentValue),a._currentValue=i}function zs(r){r._currentValue=Lu.current,X(Lu)}function Iu(r,a,i){for(;r!==null;){var u=r.alternate;if((r.childLanes&a)!==a?(r.childLanes|=a,u!==null&&(u.childLanes|=a)):u!==null&&(u.childLanes&a)!==a&&(u.childLanes|=a),r===i)break;r=r.return}}function zu(r,a,i,u){var b=r.child;for(b!==null&&(b.return=r);b!==null;){var j=b.dependencies;if(j!==null){var $=b.child;j=j.firstContext;e:for(;j!==null;){var Q=j;j=b;for(var le=0;le<a.length;le++)if(Q.context===a[le]){j.lanes|=i,Q=j.alternate,Q!==null&&(Q.lanes|=i),Iu(j.return,i,r),u||($=null);break e}j=Q.next}}else if(b.tag===18){if($=b.return,$===null)throw Error(l(341));$.lanes|=i,j=$.alternate,j!==null&&(j.lanes|=i),Iu($,i,r),$=null}else $=b.child;if($!==null)$.return=b;else for($=b;$!==null;){if($===r){$=null;break}if(b=$.sibling,b!==null){b.return=$.return,$=b;break}$=$.return}b=$}}function Sl(r,a,i,u){r=null;for(var b=a,j=!1;b!==null;){if(!j){if((b.flags&524288)!==0)j=!0;else if((b.flags&262144)!==0)break}if(b.tag===10){var $=b.alternate;if($===null)throw Error(l(387));if($=$.memoizedProps,$!==null){var Q=b.type;Or(b.pendingProps.value,$.value)||(r!==null?r.push(Q):r=[Q])}}else if(b===ee.current){if($=b.alternate,$===null)throw Error(l(387));$.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(r!==null?r.push(Ji):r=[Ji])}b=b.return}r!==null&&zu(a,r,i,u),a.flags|=262144}function ic(r){for(r=r.firstContext;r!==null;){if(!Or(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Ga(r){Ya=r,Is=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function ir(r){return xg(Ya,r)}function oc(r,a){return Ya===null&&Ga(r),xg(r,a)}function xg(r,a){var i=a._currentValue;if(a={context:a,memoizedValue:i,next:null},Is===null){if(r===null)throw Error(l(308));Is=a,r.dependencies={lanes:0,firstContext:a},r.flags|=524288}else Is=Is.next=a;return i}var j5=typeof AbortController<"u"?AbortController:function(){var r=[],a=this.signal={aborted:!1,addEventListener:function(i,u){r.push(u)}};this.abort=function(){a.aborted=!0,r.forEach(function(i){return i()})}},w5=e.unstable_scheduleCallback,N5=e.unstable_NormalPriority,qn={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function $u(){return{controller:new j5,data:new Map,refCount:0}}function Ei(r){r.refCount--,r.refCount===0&&w5(N5,function(){r.controller.abort()})}var Ti=null,Bu=0,Cl=0,El=null;function k5(r,a){if(Ti===null){var i=Ti=[];Bu=0,Cl=qf(),El={status:"pending",value:void 0,then:function(u){i.push(u)}}}return Bu++,a.then(gg,gg),a}function gg(){if(--Bu===0&&Ti!==null){El!==null&&(El.status="fulfilled");var r=Ti;Ti=null,Cl=0,El=null;for(var a=0;a<r.length;a++)(0,r[a])()}}function S5(r,a){var i=[],u={status:"pending",value:null,reason:null,then:function(b){i.push(b)}};return r.then(function(){u.status="fulfilled",u.value=a;for(var b=0;b<i.length;b++)(0,i[b])(a)},function(b){for(u.status="rejected",u.reason=b,b=0;b<i.length;b++)(0,i[b])(void 0)}),u}var pg=A.S;A.S=function(r,a){e0=yt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&k5(r,a),pg!==null&&pg(r,a)};var Xa=F(null);function Hu(){var r=Xa.current;return r!==null?r:pn.pooledCache}function cc(r,a){a===null?I(Xa,Xa.current):I(Xa,a.pool)}function bg(){var r=Hu();return r===null?null:{parent:qn._currentValue,pool:r}}var Tl=Error(l(460)),Pu=Error(l(474)),dc=Error(l(542)),uc={then:function(){}};function yg(r){return r=r.status,r==="fulfilled"||r==="rejected"}function vg(r,a,i){switch(i=r[i],i===void 0?r.push(a):i!==a&&(a.then(Ue,Ue),a=i),a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,wg(r),r;default:if(typeof a.status=="string")a.then(Ue,Ue);else{if(r=pn,r!==null&&100<r.shellSuspendCounter)throw Error(l(482));r=a,r.status="pending",r.then(function(u){if(a.status==="pending"){var b=a;b.status="fulfilled",b.value=u}},function(u){if(a.status==="pending"){var b=a;b.status="rejected",b.reason=u}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,wg(r),r}throw Za=a,Tl}}function Ka(r){try{var a=r._init;return a(r._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(Za=i,Tl):i}}var Za=null;function jg(){if(Za===null)throw Error(l(459));var r=Za;return Za=null,r}function wg(r){if(r===Tl||r===dc)throw Error(l(483))}var Al=null,Ai=0;function fc(r){var a=Ai;return Ai+=1,Al===null&&(Al=[]),vg(Al,r,a)}function _i(r,a){a=a.props.ref,r.ref=a!==void 0?a:null}function hc(r,a){throw a.$$typeof===p?Error(l(525)):(r=Object.prototype.toString.call(a),Error(l(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r)))}function Ng(r){function a(ue,ce){if(r){var me=ue.deletions;me===null?(ue.deletions=[ce],ue.flags|=16):me.push(ce)}}function i(ue,ce){if(!r)return null;for(;ce!==null;)a(ue,ce),ce=ce.sibling;return null}function u(ue){for(var ce=new Map;ue!==null;)ue.key!==null?ce.set(ue.key,ue):ce.set(ue.index,ue),ue=ue.sibling;return ce}function b(ue,ce){return ue=Ds(ue,ce),ue.index=0,ue.sibling=null,ue}function j(ue,ce,me){return ue.index=me,r?(me=ue.alternate,me!==null?(me=me.index,me<ce?(ue.flags|=67108866,ce):me):(ue.flags|=67108866,ce)):(ue.flags|=1048576,ce)}function $(ue){return r&&ue.alternate===null&&(ue.flags|=67108866),ue}function Q(ue,ce,me,Oe){return ce===null||ce.tag!==6?(ce=Au(me,ue.mode,Oe),ce.return=ue,ce):(ce=b(ce,me),ce.return=ue,ce)}function le(ue,ce,me,Oe){var xt=me.type;return xt===N?_e(ue,ce,me.props.children,Oe,me.key):ce!==null&&(ce.elementType===xt||typeof xt=="object"&&xt!==null&&xt.$$typeof===z&&Ka(xt)===ce.type)?(ce=b(ce,me.props),_i(ce,me),ce.return=ue,ce):(ce=ac(me.type,me.key,me.props,null,ue.mode,Oe),_i(ce,me),ce.return=ue,ce)}function xe(ue,ce,me,Oe){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==me.containerInfo||ce.stateNode.implementation!==me.implementation?(ce=_u(me,ue.mode,Oe),ce.return=ue,ce):(ce=b(ce,me.children||[]),ce.return=ue,ce)}function _e(ue,ce,me,Oe,xt){return ce===null||ce.tag!==7?(ce=Va(me,ue.mode,Oe,xt),ce.return=ue,ce):(ce=b(ce,me),ce.return=ue,ce)}function Re(ue,ce,me){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=Au(""+ce,ue.mode,me),ce.return=ue,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case y:return me=ac(ce.type,ce.key,ce.props,null,ue.mode,me),_i(me,ce),me.return=ue,me;case w:return ce=_u(ce,ue.mode,me),ce.return=ue,ce;case z:return ce=Ka(ce),Re(ue,ce,me)}if(L(ce)||V(ce))return ce=Va(ce,ue.mode,me,null),ce.return=ue,ce;if(typeof ce.then=="function")return Re(ue,fc(ce),me);if(ce.$$typeof===k)return Re(ue,oc(ue,ce),me);hc(ue,ce)}return null}function be(ue,ce,me,Oe){var xt=ce!==null?ce.key:null;if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return xt!==null?null:Q(ue,ce,""+me,Oe);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case y:return me.key===xt?le(ue,ce,me,Oe):null;case w:return me.key===xt?xe(ue,ce,me,Oe):null;case z:return me=Ka(me),be(ue,ce,me,Oe)}if(L(me)||V(me))return xt!==null?null:_e(ue,ce,me,Oe,null);if(typeof me.then=="function")return be(ue,ce,fc(me),Oe);if(me.$$typeof===k)return be(ue,ce,oc(ue,me),Oe);hc(ue,me)}return null}function Se(ue,ce,me,Oe,xt){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number"||typeof Oe=="bigint")return ue=ue.get(me)||null,Q(ce,ue,""+Oe,xt);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case y:return ue=ue.get(Oe.key===null?me:Oe.key)||null,le(ce,ue,Oe,xt);case w:return ue=ue.get(Oe.key===null?me:Oe.key)||null,xe(ce,ue,Oe,xt);case z:return Oe=Ka(Oe),Se(ue,ce,me,Oe,xt)}if(L(Oe)||V(Oe))return ue=ue.get(me)||null,_e(ce,ue,Oe,xt,null);if(typeof Oe.then=="function")return Se(ue,ce,me,fc(Oe),xt);if(Oe.$$typeof===k)return Se(ue,ce,me,oc(ce,Oe),xt);hc(ce,Oe)}return null}function Je(ue,ce,me,Oe){for(var xt=null,nn=null,at=ce,$t=ce=0,Gt=null;at!==null&&$t<me.length;$t++){at.index>$t?(Gt=at,at=null):Gt=at.sibling;var rn=be(ue,at,me[$t],Oe);if(rn===null){at===null&&(at=Gt);break}r&&at&&rn.alternate===null&&a(ue,at),ce=j(rn,ce,$t),nn===null?xt=rn:nn.sibling=rn,nn=rn,at=Gt}if($t===me.length)return i(ue,at),Zt&&Ls(ue,$t),xt;if(at===null){for(;$t<me.length;$t++)at=Re(ue,me[$t],Oe),at!==null&&(ce=j(at,ce,$t),nn===null?xt=at:nn.sibling=at,nn=at);return Zt&&Ls(ue,$t),xt}for(at=u(at);$t<me.length;$t++)Gt=Se(at,ue,$t,me[$t],Oe),Gt!==null&&(r&&Gt.alternate!==null&&at.delete(Gt.key===null?$t:Gt.key),ce=j(Gt,ce,$t),nn===null?xt=Gt:nn.sibling=Gt,nn=Gt);return r&&at.forEach(function(Ca){return a(ue,Ca)}),Zt&&Ls(ue,$t),xt}function kt(ue,ce,me,Oe){if(me==null)throw Error(l(151));for(var xt=null,nn=null,at=ce,$t=ce=0,Gt=null,rn=me.next();at!==null&&!rn.done;$t++,rn=me.next()){at.index>$t?(Gt=at,at=null):Gt=at.sibling;var Ca=be(ue,at,rn.value,Oe);if(Ca===null){at===null&&(at=Gt);break}r&&at&&Ca.alternate===null&&a(ue,at),ce=j(Ca,ce,$t),nn===null?xt=Ca:nn.sibling=Ca,nn=Ca,at=Gt}if(rn.done)return i(ue,at),Zt&&Ls(ue,$t),xt;if(at===null){for(;!rn.done;$t++,rn=me.next())rn=Re(ue,rn.value,Oe),rn!==null&&(ce=j(rn,ce,$t),nn===null?xt=rn:nn.sibling=rn,nn=rn);return Zt&&Ls(ue,$t),xt}for(at=u(at);!rn.done;$t++,rn=me.next())rn=Se(at,ue,$t,rn.value,Oe),rn!==null&&(r&&rn.alternate!==null&&at.delete(rn.key===null?$t:rn.key),ce=j(rn,ce,$t),nn===null?xt=rn:nn.sibling=rn,nn=rn);return r&&at.forEach(function(I2){return a(ue,I2)}),Zt&&Ls(ue,$t),xt}function mn(ue,ce,me,Oe){if(typeof me=="object"&&me!==null&&me.type===N&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case y:e:{for(var xt=me.key;ce!==null;){if(ce.key===xt){if(xt=me.type,xt===N){if(ce.tag===7){i(ue,ce.sibling),Oe=b(ce,me.props.children),Oe.return=ue,ue=Oe;break e}}else if(ce.elementType===xt||typeof xt=="object"&&xt!==null&&xt.$$typeof===z&&Ka(xt)===ce.type){i(ue,ce.sibling),Oe=b(ce,me.props),_i(Oe,me),Oe.return=ue,ue=Oe;break e}i(ue,ce);break}else a(ue,ce);ce=ce.sibling}me.type===N?(Oe=Va(me.props.children,ue.mode,Oe,me.key),Oe.return=ue,ue=Oe):(Oe=ac(me.type,me.key,me.props,null,ue.mode,Oe),_i(Oe,me),Oe.return=ue,ue=Oe)}return $(ue);case w:e:{for(xt=me.key;ce!==null;){if(ce.key===xt)if(ce.tag===4&&ce.stateNode.containerInfo===me.containerInfo&&ce.stateNode.implementation===me.implementation){i(ue,ce.sibling),Oe=b(ce,me.children||[]),Oe.return=ue,ue=Oe;break e}else{i(ue,ce);break}else a(ue,ce);ce=ce.sibling}Oe=_u(me,ue.mode,Oe),Oe.return=ue,ue=Oe}return $(ue);case z:return me=Ka(me),mn(ue,ce,me,Oe)}if(L(me))return Je(ue,ce,me,Oe);if(V(me)){if(xt=V(me),typeof xt!="function")throw Error(l(150));return me=xt.call(me),kt(ue,ce,me,Oe)}if(typeof me.then=="function")return mn(ue,ce,fc(me),Oe);if(me.$$typeof===k)return mn(ue,ce,oc(ue,me),Oe);hc(ue,me)}return typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint"?(me=""+me,ce!==null&&ce.tag===6?(i(ue,ce.sibling),Oe=b(ce,me),Oe.return=ue,ue=Oe):(i(ue,ce),Oe=Au(me,ue.mode,Oe),Oe.return=ue,ue=Oe),$(ue)):i(ue,ce)}return function(ue,ce,me,Oe){try{Ai=0;var xt=mn(ue,ce,me,Oe);return Al=null,xt}catch(at){if(at===Tl||at===dc)throw at;var nn=Rr(29,at,null,ue.mode);return nn.lanes=Oe,nn.return=ue,nn}}}var Wa=Ng(!0),kg=Ng(!1),ca=!1;function Uu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qu(r,a){r=r.updateQueue,a.updateQueue===r&&(a.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function da(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function ua(r,a,i){var u=r.updateQueue;if(u===null)return null;if(u=u.shared,(an&2)!==0){var b=u.pending;return b===null?a.next=a:(a.next=b.next,b.next=a),u.pending=a,a=sc(r),ig(r,null,i),a}return rc(r,u,a,i),sc(r)}function Mi(r,a,i){if(a=a.updateQueue,a!==null&&(a=a.shared,(i&4194048)!==0)){var u=a.lanes;u&=r.pendingLanes,i|=u,a.lanes=i,ie(r,i)}}function Vu(r,a){var i=r.updateQueue,u=r.alternate;if(u!==null&&(u=u.updateQueue,i===u)){var b=null,j=null;if(i=i.firstBaseUpdate,i!==null){do{var $={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};j===null?b=j=$:j=j.next=$,i=i.next}while(i!==null);j===null?b=j=a:j=j.next=a}else b=j=a;i={baseState:u.baseState,firstBaseUpdate:b,lastBaseUpdate:j,shared:u.shared,callbacks:u.callbacks},r.updateQueue=i;return}r=i.lastBaseUpdate,r===null?i.firstBaseUpdate=a:r.next=a,i.lastBaseUpdate=a}var Fu=!1;function Oi(){if(Fu){var r=El;if(r!==null)throw r}}function Ri(r,a,i,u){Fu=!1;var b=r.updateQueue;ca=!1;var j=b.firstBaseUpdate,$=b.lastBaseUpdate,Q=b.shared.pending;if(Q!==null){b.shared.pending=null;var le=Q,xe=le.next;le.next=null,$===null?j=xe:$.next=xe,$=le;var _e=r.alternate;_e!==null&&(_e=_e.updateQueue,Q=_e.lastBaseUpdate,Q!==$&&(Q===null?_e.firstBaseUpdate=xe:Q.next=xe,_e.lastBaseUpdate=le))}if(j!==null){var Re=b.baseState;$=0,_e=xe=le=null,Q=j;do{var be=Q.lane&-536870913,Se=be!==Q.lane;if(Se?(Yt&be)===be:(u&be)===be){be!==0&&be===Cl&&(Fu=!0),_e!==null&&(_e=_e.next={lane:0,tag:Q.tag,payload:Q.payload,callback:null,next:null});e:{var Je=r,kt=Q;be=a;var mn=i;switch(kt.tag){case 1:if(Je=kt.payload,typeof Je=="function"){Re=Je.call(mn,Re,be);break e}Re=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=kt.payload,be=typeof Je=="function"?Je.call(mn,Re,be):Je,be==null)break e;Re=x({},Re,be);break e;case 2:ca=!0}}be=Q.callback,be!==null&&(r.flags|=64,Se&&(r.flags|=8192),Se=b.callbacks,Se===null?b.callbacks=[be]:Se.push(be))}else Se={lane:be,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},_e===null?(xe=_e=Se,le=Re):_e=_e.next=Se,$|=be;if(Q=Q.next,Q===null){if(Q=b.shared.pending,Q===null)break;Se=Q,Q=Se.next,Se.next=null,b.lastBaseUpdate=Se,b.shared.pending=null}}while(!0);_e===null&&(le=Re),b.baseState=le,b.firstBaseUpdate=xe,b.lastBaseUpdate=_e,j===null&&(b.shared.lanes=0),ga|=$,r.lanes=$,r.memoizedState=Re}}function Sg(r,a){if(typeof r!="function")throw Error(l(191,r));r.call(a)}function Cg(r,a){var i=r.callbacks;if(i!==null)for(r.callbacks=null,r=0;r<i.length;r++)Sg(i[r],a)}var _l=F(null),mc=F(0);function Eg(r,a){r=Ys,I(mc,r),I(_l,a),Ys=r|a.baseLanes}function Yu(){I(mc,Ys),I(_l,_l.current)}function Gu(){Ys=mc.current,X(_l),X(mc)}var Dr=F(null),Jr=null;function fa(r){var a=r.alternate;I(Bn,Bn.current&1),I(Dr,r),Jr===null&&(a===null||_l.current!==null||a.memoizedState!==null)&&(Jr=r)}function Xu(r){I(Bn,Bn.current),I(Dr,r),Jr===null&&(Jr=r)}function Tg(r){r.tag===22?(I(Bn,Bn.current),I(Dr,r),Jr===null&&(Jr=r)):ha()}function ha(){I(Bn,Bn.current),I(Dr,Dr.current)}function Lr(r){X(Dr),Jr===r&&(Jr=null),X(Bn)}var Bn=F(0);function xc(r){for(var a=r;a!==null;){if(a.tag===13){var i=a.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||th(i)||nh(i)))return a}else if(a.tag===19&&(a.memoizedProps.revealOrder==="forwards"||a.memoizedProps.revealOrder==="backwards"||a.memoizedProps.revealOrder==="unstable_legacy-backwards"||a.memoizedProps.revealOrder==="together")){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var $s=0,It=null,fn=null,Vn=null,gc=!1,Ml=!1,Qa=!1,pc=0,Di=0,Ol=null,C5=0;function In(){throw Error(l(321))}function Ku(r,a){if(a===null)return!1;for(var i=0;i<a.length&&i<r.length;i++)if(!Or(r[i],a[i]))return!1;return!0}function Zu(r,a,i,u,b,j){return $s=j,It=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,A.H=r===null||r.memoizedState===null?up:ff,Qa=!1,j=i(u,b),Qa=!1,Ml&&(j=_g(a,i,u,b)),Ag(r),j}function Ag(r){A.H=zi;var a=fn!==null&&fn.next!==null;if($s=0,Vn=fn=It=null,gc=!1,Di=0,Ol=null,a)throw Error(l(300));r===null||Fn||(r=r.dependencies,r!==null&&ic(r)&&(Fn=!0))}function _g(r,a,i,u){It=r;var b=0;do{if(Ml&&(Ol=null),Di=0,Ml=!1,25<=b)throw Error(l(301));if(b+=1,Vn=fn=null,r.updateQueue!=null){var j=r.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}A.H=fp,j=a(i,u)}while(Ml);return j}function E5(){var r=A.H,a=r.useState()[0];return a=typeof a.then=="function"?Li(a):a,r=r.useState()[0],(fn!==null?fn.memoizedState:null)!==r&&(It.flags|=1024),a}function Wu(){var r=pc!==0;return pc=0,r}function Qu(r,a,i){a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~i}function Ju(r){if(gc){for(r=r.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}gc=!1}$s=0,Vn=fn=It=null,Ml=!1,Di=pc=0,Ol=null}function yr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vn===null?It.memoizedState=Vn=r:Vn=Vn.next=r,Vn}function Hn(){if(fn===null){var r=It.alternate;r=r!==null?r.memoizedState:null}else r=fn.next;var a=Vn===null?It.memoizedState:Vn.next;if(a!==null)Vn=a,fn=r;else{if(r===null)throw It.alternate===null?Error(l(467)):Error(l(310));fn=r,r={memoizedState:fn.memoizedState,baseState:fn.baseState,baseQueue:fn.baseQueue,queue:fn.queue,next:null},Vn===null?It.memoizedState=Vn=r:Vn=Vn.next=r}return Vn}function bc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Li(r){var a=Di;return Di+=1,Ol===null&&(Ol=[]),r=vg(Ol,r,a),a=It,(Vn===null?a.memoizedState:Vn.next)===null&&(a=a.alternate,A.H=a===null||a.memoizedState===null?up:ff),r}function yc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Li(r);if(r.$$typeof===k)return ir(r)}throw Error(l(438,String(r)))}function ef(r){var a=null,i=It.updateQueue;if(i!==null&&(a=i.memoCache),a==null){var u=It.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(a={data:u.data.map(function(b){return b.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),i===null&&(i=bc(),It.updateQueue=i),i.memoCache=a,i=a.data[a.index],i===void 0)for(i=a.data[a.index]=Array(r),u=0;u<r;u++)i[u]=U;return a.index++,i}function Bs(r,a){return typeof a=="function"?a(r):a}function vc(r){var a=Hn();return tf(a,fn,r)}function tf(r,a,i){var u=r.queue;if(u===null)throw Error(l(311));u.lastRenderedReducer=i;var b=r.baseQueue,j=u.pending;if(j!==null){if(b!==null){var $=b.next;b.next=j.next,j.next=$}a.baseQueue=b=j,u.pending=null}if(j=r.baseState,b===null)r.memoizedState=j;else{a=b.next;var Q=$=null,le=null,xe=a,_e=!1;do{var Re=xe.lane&-536870913;if(Re!==xe.lane?(Yt&Re)===Re:($s&Re)===Re){var be=xe.revertLane;if(be===0)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null}),Re===Cl&&(_e=!0);else if(($s&be)===be){xe=xe.next,be===Cl&&(_e=!0);continue}else Re={lane:0,revertLane:xe.revertLane,gesture:null,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null},le===null?(Q=le=Re,$=j):le=le.next=Re,It.lanes|=be,ga|=be;Re=xe.action,Qa&&i(j,Re),j=xe.hasEagerState?xe.eagerState:i(j,Re)}else be={lane:Re,revertLane:xe.revertLane,gesture:xe.gesture,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null},le===null?(Q=le=be,$=j):le=le.next=be,It.lanes|=Re,ga|=Re;xe=xe.next}while(xe!==null&&xe!==a);if(le===null?$=j:le.next=Q,!Or(j,r.memoizedState)&&(Fn=!0,_e&&(i=El,i!==null)))throw i;r.memoizedState=j,r.baseState=$,r.baseQueue=le,u.lastRenderedState=j}return b===null&&(u.lanes=0),[r.memoizedState,u.dispatch]}function nf(r){var a=Hn(),i=a.queue;if(i===null)throw Error(l(311));i.lastRenderedReducer=r;var u=i.dispatch,b=i.pending,j=a.memoizedState;if(b!==null){i.pending=null;var $=b=b.next;do j=r(j,$.action),$=$.next;while($!==b);Or(j,a.memoizedState)||(Fn=!0),a.memoizedState=j,a.baseQueue===null&&(a.baseState=j),i.lastRenderedState=j}return[j,u]}function Mg(r,a,i){var u=It,b=Hn(),j=Zt;if(j){if(i===void 0)throw Error(l(407));i=i()}else i=a();var $=!Or((fn||b).memoizedState,i);if($&&(b.memoizedState=i,Fn=!0),b=b.queue,af(Dg.bind(null,u,b,r),[r]),b.getSnapshot!==a||$||Vn!==null&&Vn.memoizedState.tag&1){if(u.flags|=2048,Rl(9,{destroy:void 0},Rg.bind(null,u,b,i,a),null),pn===null)throw Error(l(349));j||($s&127)!==0||Og(u,a,i)}return i}function Og(r,a,i){r.flags|=16384,r={getSnapshot:a,value:i},a=It.updateQueue,a===null?(a=bc(),It.updateQueue=a,a.stores=[r]):(i=a.stores,i===null?a.stores=[r]:i.push(r))}function Rg(r,a,i,u){a.value=i,a.getSnapshot=u,Lg(a)&&Ig(r)}function Dg(r,a,i){return i(function(){Lg(a)&&Ig(r)})}function Lg(r){var a=r.getSnapshot;r=r.value;try{var i=a();return!Or(r,i)}catch{return!0}}function Ig(r){var a=qa(r,2);a!==null&&Cr(a,r,2)}function rf(r){var a=yr();if(typeof r=="function"){var i=r;if(r=i(),Qa){At(!0);try{i()}finally{At(!1)}}}return a.memoizedState=a.baseState=r,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:r},a}function zg(r,a,i,u){return r.baseState=i,tf(r,fn,typeof u=="function"?u:Bs)}function T5(r,a,i,u,b){if(Nc(r))throw Error(l(485));if(r=a.action,r!==null){var j={payload:b,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function($){j.listeners.push($)}};A.T!==null?i(!0):j.isTransition=!1,u(j),i=a.pending,i===null?(j.next=a.pending=j,$g(a,j)):(j.next=i.next,a.pending=i.next=j)}}function $g(r,a){var i=a.action,u=a.payload,b=r.state;if(a.isTransition){var j=A.T,$={};A.T=$;try{var Q=i(b,u),le=A.S;le!==null&&le($,Q),Bg(r,a,Q)}catch(xe){sf(r,a,xe)}finally{j!==null&&$.types!==null&&(j.types=$.types),A.T=j}}else try{j=i(b,u),Bg(r,a,j)}catch(xe){sf(r,a,xe)}}function Bg(r,a,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(u){Hg(r,a,u)},function(u){return sf(r,a,u)}):Hg(r,a,i)}function Hg(r,a,i){a.status="fulfilled",a.value=i,Pg(a),r.state=i,a=r.pending,a!==null&&(i=a.next,i===a?r.pending=null:(i=i.next,a.next=i,$g(r,i)))}function sf(r,a,i){var u=r.pending;if(r.pending=null,u!==null){u=u.next;do a.status="rejected",a.reason=i,Pg(a),a=a.next;while(a!==u)}r.action=null}function Pg(r){r=r.listeners;for(var a=0;a<r.length;a++)(0,r[a])()}function Ug(r,a){return a}function qg(r,a){if(Zt){var i=pn.formState;if(i!==null){e:{var u=It;if(Zt){if(kn){t:{for(var b=kn,j=Qr;b.nodeType!==8;){if(!j){b=null;break t}if(b=es(b.nextSibling),b===null){b=null;break t}}j=b.data,b=j==="F!"||j==="F"?b:null}if(b){kn=es(b.nextSibling),u=b.data==="F!";break e}}ia(u)}u=!1}u&&(a=i[0])}}return i=yr(),i.memoizedState=i.baseState=a,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ug,lastRenderedState:a},i.queue=u,i=op.bind(null,It,u),u.dispatch=i,u=rf(!1),j=uf.bind(null,It,!1,u.queue),u=yr(),b={state:a,dispatch:null,action:r,pending:null},u.queue=b,i=T5.bind(null,It,b,j,i),b.dispatch=i,u.memoizedState=r,[a,i,!1]}function Vg(r){var a=Hn();return Fg(a,fn,r)}function Fg(r,a,i){if(a=tf(r,a,Ug)[0],r=vc(Bs)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var u=Li(a)}catch($){throw $===Tl?dc:$}else u=a;a=Hn();var b=a.queue,j=b.dispatch;return i!==a.memoizedState&&(It.flags|=2048,Rl(9,{destroy:void 0},A5.bind(null,b,i),null)),[u,j,r]}function A5(r,a){r.action=a}function Yg(r){var a=Hn(),i=fn;if(i!==null)return Fg(a,i,r);Hn(),a=a.memoizedState,i=Hn();var u=i.queue.dispatch;return i.memoizedState=r,[a,u,!1]}function Rl(r,a,i,u){return r={tag:r,create:i,deps:u,inst:a,next:null},a=It.updateQueue,a===null&&(a=bc(),It.updateQueue=a),i=a.lastEffect,i===null?a.lastEffect=r.next=r:(u=i.next,i.next=r,r.next=u,a.lastEffect=r),r}function Gg(){return Hn().memoizedState}function jc(r,a,i,u){var b=yr();It.flags|=r,b.memoizedState=Rl(1|a,{destroy:void 0},i,u===void 0?null:u)}function wc(r,a,i,u){var b=Hn();u=u===void 0?null:u;var j=b.memoizedState.inst;fn!==null&&u!==null&&Ku(u,fn.memoizedState.deps)?b.memoizedState=Rl(a,j,i,u):(It.flags|=r,b.memoizedState=Rl(1|a,j,i,u))}function Xg(r,a){jc(8390656,8,r,a)}function af(r,a){wc(2048,8,r,a)}function _5(r){It.flags|=4;var a=It.updateQueue;if(a===null)a=bc(),It.updateQueue=a,a.events=[r];else{var i=a.events;i===null?a.events=[r]:i.push(r)}}function Kg(r){var a=Hn().memoizedState;return _5({ref:a,nextImpl:r}),function(){if((an&2)!==0)throw Error(l(440));return a.impl.apply(void 0,arguments)}}function Zg(r,a){return wc(4,2,r,a)}function Wg(r,a){return wc(4,4,r,a)}function Qg(r,a){if(typeof a=="function"){r=r();var i=a(r);return function(){typeof i=="function"?i():a(null)}}if(a!=null)return r=r(),a.current=r,function(){a.current=null}}function Jg(r,a,i){i=i!=null?i.concat([r]):null,wc(4,4,Qg.bind(null,a,r),i)}function lf(){}function ep(r,a){var i=Hn();a=a===void 0?null:a;var u=i.memoizedState;return a!==null&&Ku(a,u[1])?u[0]:(i.memoizedState=[r,a],r)}function tp(r,a){var i=Hn();a=a===void 0?null:a;var u=i.memoizedState;if(a!==null&&Ku(a,u[1]))return u[0];if(u=r(),Qa){At(!0);try{r()}finally{At(!1)}}return i.memoizedState=[u,a],u}function of(r,a,i){return i===void 0||($s&1073741824)!==0&&(Yt&261930)===0?r.memoizedState=a:(r.memoizedState=i,r=n0(),It.lanes|=r,ga|=r,i)}function np(r,a,i,u){return Or(i,a)?i:_l.current!==null?(r=of(r,i,u),Or(r,a)||(Fn=!0),r):($s&42)===0||($s&1073741824)!==0&&(Yt&261930)===0?(Fn=!0,r.memoizedState=i):(r=n0(),It.lanes|=r,ga|=r,a)}function rp(r,a,i,u,b){var j=P.p;P.p=j!==0&&8>j?j:8;var $=A.T,Q={};A.T=Q,uf(r,!1,a,i);try{var le=b(),xe=A.S;if(xe!==null&&xe(Q,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var _e=S5(le,u);Ii(r,a,_e,$r(r))}else Ii(r,a,u,$r(r))}catch(Re){Ii(r,a,{then:function(){},status:"rejected",reason:Re},$r())}finally{P.p=j,$!==null&&Q.types!==null&&($.types=Q.types),A.T=$}}function M5(){}function cf(r,a,i,u){if(r.tag!==5)throw Error(l(476));var b=sp(r).queue;rp(r,b,a,q,i===null?M5:function(){return ap(r),i(u)})}function sp(r){var a=r.memoizedState;if(a!==null)return a;a={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:q},next:null};var i={};return a.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:i},next:null},r.memoizedState=a,r=r.alternate,r!==null&&(r.memoizedState=a),a}function ap(r){var a=sp(r);a.next===null&&(a=r.alternate.memoizedState),Ii(r,a.next.queue,{},$r())}function df(){return ir(Ji)}function lp(){return Hn().memoizedState}function ip(){return Hn().memoizedState}function O5(r){for(var a=r.return;a!==null;){switch(a.tag){case 24:case 3:var i=$r();r=da(i);var u=ua(a,r,i);u!==null&&(Cr(u,a,i),Mi(u,a,i)),a={cache:$u()},r.payload=a;return}a=a.return}}function R5(r,a,i){var u=$r();i={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Nc(r)?cp(a,i):(i=Eu(r,a,i,u),i!==null&&(Cr(i,r,u),dp(i,a,u)))}function op(r,a,i){var u=$r();Ii(r,a,i,u)}function Ii(r,a,i,u){var b={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Nc(r))cp(a,b);else{var j=r.alternate;if(r.lanes===0&&(j===null||j.lanes===0)&&(j=a.lastRenderedReducer,j!==null))try{var $=a.lastRenderedState,Q=j($,i);if(b.hasEagerState=!0,b.eagerState=Q,Or(Q,$))return rc(r,a,b,0),pn===null&&nc(),!1}catch{}if(i=Eu(r,a,b,u),i!==null)return Cr(i,r,u),dp(i,a,u),!0}return!1}function uf(r,a,i,u){if(u={lane:2,revertLane:qf(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Nc(r)){if(a)throw Error(l(479))}else a=Eu(r,i,u,2),a!==null&&Cr(a,r,2)}function Nc(r){var a=r.alternate;return r===It||a!==null&&a===It}function cp(r,a){Ml=gc=!0;var i=r.pending;i===null?a.next=a:(a.next=i.next,i.next=a),r.pending=a}function dp(r,a,i){if((i&4194048)!==0){var u=a.lanes;u&=r.pendingLanes,i|=u,a.lanes=i,ie(r,i)}}var zi={readContext:ir,use:yc,useCallback:In,useContext:In,useEffect:In,useImperativeHandle:In,useLayoutEffect:In,useInsertionEffect:In,useMemo:In,useReducer:In,useRef:In,useState:In,useDebugValue:In,useDeferredValue:In,useTransition:In,useSyncExternalStore:In,useId:In,useHostTransitionStatus:In,useFormState:In,useActionState:In,useOptimistic:In,useMemoCache:In,useCacheRefresh:In};zi.useEffectEvent=In;var up={readContext:ir,use:yc,useCallback:function(r,a){return yr().memoizedState=[r,a===void 0?null:a],r},useContext:ir,useEffect:Xg,useImperativeHandle:function(r,a,i){i=i!=null?i.concat([r]):null,jc(4194308,4,Qg.bind(null,a,r),i)},useLayoutEffect:function(r,a){return jc(4194308,4,r,a)},useInsertionEffect:function(r,a){jc(4,2,r,a)},useMemo:function(r,a){var i=yr();a=a===void 0?null:a;var u=r();if(Qa){At(!0);try{r()}finally{At(!1)}}return i.memoizedState=[u,a],u},useReducer:function(r,a,i){var u=yr();if(i!==void 0){var b=i(a);if(Qa){At(!0);try{i(a)}finally{At(!1)}}}else b=a;return u.memoizedState=u.baseState=b,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:b},u.queue=r,r=r.dispatch=R5.bind(null,It,r),[u.memoizedState,r]},useRef:function(r){var a=yr();return r={current:r},a.memoizedState=r},useState:function(r){r=rf(r);var a=r.queue,i=op.bind(null,It,a);return a.dispatch=i,[r.memoizedState,i]},useDebugValue:lf,useDeferredValue:function(r,a){var i=yr();return of(i,r,a)},useTransition:function(){var r=rf(!1);return r=rp.bind(null,It,r.queue,!0,!1),yr().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,a,i){var u=It,b=yr();if(Zt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=a(),pn===null)throw Error(l(349));(Yt&127)!==0||Og(u,a,i)}b.memoizedState=i;var j={value:i,getSnapshot:a};return b.queue=j,Xg(Dg.bind(null,u,j,r),[r]),u.flags|=2048,Rl(9,{destroy:void 0},Rg.bind(null,u,j,i,a),null),i},useId:function(){var r=yr(),a=pn.identifierPrefix;if(Zt){var i=bs,u=ps;i=(u&~(1<<32-St(u)-1)).toString(32)+i,a="_"+a+"R_"+i,i=pc++,0<i&&(a+="H"+i.toString(32)),a+="_"}else i=C5++,a="_"+a+"r_"+i.toString(32)+"_";return r.memoizedState=a},useHostTransitionStatus:df,useFormState:qg,useActionState:qg,useOptimistic:function(r){var a=yr();a.memoizedState=a.baseState=r;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=i,a=uf.bind(null,It,!0,i),i.dispatch=a,[r,a]},useMemoCache:ef,useCacheRefresh:function(){return yr().memoizedState=O5.bind(null,It)},useEffectEvent:function(r){var a=yr(),i={impl:r};return a.memoizedState=i,function(){if((an&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},ff={readContext:ir,use:yc,useCallback:ep,useContext:ir,useEffect:af,useImperativeHandle:Jg,useInsertionEffect:Zg,useLayoutEffect:Wg,useMemo:tp,useReducer:vc,useRef:Gg,useState:function(){return vc(Bs)},useDebugValue:lf,useDeferredValue:function(r,a){var i=Hn();return np(i,fn.memoizedState,r,a)},useTransition:function(){var r=vc(Bs)[0],a=Hn().memoizedState;return[typeof r=="boolean"?r:Li(r),a]},useSyncExternalStore:Mg,useId:lp,useHostTransitionStatus:df,useFormState:Vg,useActionState:Vg,useOptimistic:function(r,a){var i=Hn();return zg(i,fn,r,a)},useMemoCache:ef,useCacheRefresh:ip};ff.useEffectEvent=Kg;var fp={readContext:ir,use:yc,useCallback:ep,useContext:ir,useEffect:af,useImperativeHandle:Jg,useInsertionEffect:Zg,useLayoutEffect:Wg,useMemo:tp,useReducer:nf,useRef:Gg,useState:function(){return nf(Bs)},useDebugValue:lf,useDeferredValue:function(r,a){var i=Hn();return fn===null?of(i,r,a):np(i,fn.memoizedState,r,a)},useTransition:function(){var r=nf(Bs)[0],a=Hn().memoizedState;return[typeof r=="boolean"?r:Li(r),a]},useSyncExternalStore:Mg,useId:lp,useHostTransitionStatus:df,useFormState:Yg,useActionState:Yg,useOptimistic:function(r,a){var i=Hn();return fn!==null?zg(i,fn,r,a):(i.baseState=r,[r,i.queue.dispatch])},useMemoCache:ef,useCacheRefresh:ip};fp.useEffectEvent=Kg;function hf(r,a,i,u){a=r.memoizedState,i=i(u,a),i=i==null?a:x({},a,i),r.memoizedState=i,r.lanes===0&&(r.updateQueue.baseState=i)}var mf={enqueueSetState:function(r,a,i){r=r._reactInternals;var u=$r(),b=da(u);b.payload=a,i!=null&&(b.callback=i),a=ua(r,b,u),a!==null&&(Cr(a,r,u),Mi(a,r,u))},enqueueReplaceState:function(r,a,i){r=r._reactInternals;var u=$r(),b=da(u);b.tag=1,b.payload=a,i!=null&&(b.callback=i),a=ua(r,b,u),a!==null&&(Cr(a,r,u),Mi(a,r,u))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var i=$r(),u=da(i);u.tag=2,a!=null&&(u.callback=a),a=ua(r,u,i),a!==null&&(Cr(a,r,i),Mi(a,r,i))}};function hp(r,a,i,u,b,j,$){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(u,j,$):a.prototype&&a.prototype.isPureReactComponent?!Ni(i,u)||!Ni(b,j):!0}function mp(r,a,i,u){r=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(i,u),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(i,u),a.state!==r&&mf.enqueueReplaceState(a,a.state,null)}function Ja(r,a){var i=a;if("ref"in a){i={};for(var u in a)u!=="ref"&&(i[u]=a[u])}if(r=r.defaultProps){i===a&&(i=x({},i));for(var b in r)i[b]===void 0&&(i[b]=r[b])}return i}function xp(r){tc(r)}function gp(r){console.error(r)}function pp(r){tc(r)}function kc(r,a){try{var i=r.onUncaughtError;i(a.value,{componentStack:a.stack})}catch(u){setTimeout(function(){throw u})}}function bp(r,a,i){try{var u=r.onCaughtError;u(i.value,{componentStack:i.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function xf(r,a,i){return i=da(i),i.tag=3,i.payload={element:null},i.callback=function(){kc(r,a)},i}function yp(r){return r=da(r),r.tag=3,r}function vp(r,a,i,u){var b=i.type.getDerivedStateFromError;if(typeof b=="function"){var j=u.value;r.payload=function(){return b(j)},r.callback=function(){bp(a,i,u)}}var $=i.stateNode;$!==null&&typeof $.componentDidCatch=="function"&&(r.callback=function(){bp(a,i,u),typeof b!="function"&&(pa===null?pa=new Set([this]):pa.add(this));var Q=u.stack;this.componentDidCatch(u.value,{componentStack:Q!==null?Q:""})})}function D5(r,a,i,u,b){if(i.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(a=i.alternate,a!==null&&Sl(a,i,b,!0),i=Dr.current,i!==null){switch(i.tag){case 31:case 13:return Jr===null?Ic():i.alternate===null&&zn===0&&(zn=3),i.flags&=-257,i.flags|=65536,i.lanes=b,u===uc?i.flags|=16384:(a=i.updateQueue,a===null?i.updateQueue=new Set([u]):a.add(u),Hf(r,u,b)),!1;case 22:return i.flags|=65536,u===uc?i.flags|=16384:(a=i.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([u])},i.updateQueue=a):(i=a.retryQueue,i===null?a.retryQueue=new Set([u]):i.add(u)),Hf(r,u,b)),!1}throw Error(l(435,i.tag))}return Hf(r,u,b),Ic(),!1}if(Zt)return a=Dr.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=b,u!==Ru&&(r=Error(l(422),{cause:u}),Ci(Kr(r,i)))):(u!==Ru&&(a=Error(l(423),{cause:u}),Ci(Kr(a,i))),r=r.current.alternate,r.flags|=65536,b&=-b,r.lanes|=b,u=Kr(u,i),b=xf(r.stateNode,u,b),Vu(r,b),zn!==4&&(zn=2)),!1;var j=Error(l(520),{cause:u});if(j=Kr(j,i),Fi===null?Fi=[j]:Fi.push(j),zn!==4&&(zn=2),a===null)return!0;u=Kr(u,i),i=a;do{switch(i.tag){case 3:return i.flags|=65536,r=b&-b,i.lanes|=r,r=xf(i.stateNode,u,r),Vu(i,r),!1;case 1:if(a=i.type,j=i.stateNode,(i.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(pa===null||!pa.has(j))))return i.flags|=65536,b&=-b,i.lanes|=b,b=yp(b),vp(b,r,i,u),Vu(i,b),!1}i=i.return}while(i!==null);return!1}var gf=Error(l(461)),Fn=!1;function or(r,a,i,u){a.child=r===null?kg(a,null,i,u):Wa(a,r.child,i,u)}function jp(r,a,i,u,b){i=i.render;var j=a.ref;if("ref"in u){var $={};for(var Q in u)Q!=="ref"&&($[Q]=u[Q])}else $=u;return Ga(a),u=Zu(r,a,i,$,j,b),Q=Wu(),r!==null&&!Fn?(Qu(r,a,b),Hs(r,a,b)):(Zt&&Q&&Mu(a),a.flags|=1,or(r,a,u,b),a.child)}function wp(r,a,i,u,b){if(r===null){var j=i.type;return typeof j=="function"&&!Tu(j)&&j.defaultProps===void 0&&i.compare===null?(a.tag=15,a.type=j,Np(r,a,j,u,b)):(r=ac(i.type,null,u,a,a.mode,b),r.ref=a.ref,r.return=a,a.child=r)}if(j=r.child,!kf(r,b)){var $=j.memoizedProps;if(i=i.compare,i=i!==null?i:Ni,i($,u)&&r.ref===a.ref)return Hs(r,a,b)}return a.flags|=1,r=Ds(j,u),r.ref=a.ref,r.return=a,a.child=r}function Np(r,a,i,u,b){if(r!==null){var j=r.memoizedProps;if(Ni(j,u)&&r.ref===a.ref)if(Fn=!1,a.pendingProps=u=j,kf(r,b))(r.flags&131072)!==0&&(Fn=!0);else return a.lanes=r.lanes,Hs(r,a,b)}return pf(r,a,i,u,b)}function kp(r,a,i,u){var b=u.children,j=r!==null?r.memoizedState:null;if(r===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((a.flags&128)!==0){if(j=j!==null?j.baseLanes|i:i,r!==null){for(u=a.child=r.child,b=0;u!==null;)b=b|u.lanes|u.childLanes,u=u.sibling;u=b&~j}else u=0,a.child=null;return Sp(r,a,j,i,u)}if((i&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},r!==null&&cc(a,j!==null?j.cachePool:null),j!==null?Eg(a,j):Yu(),Tg(a);else return u=a.lanes=536870912,Sp(r,a,j!==null?j.baseLanes|i:i,i,u)}else j!==null?(cc(a,j.cachePool),Eg(a,j),ha(),a.memoizedState=null):(r!==null&&cc(a,null),Yu(),ha());return or(r,a,b,i),a.child}function $i(r,a){return r!==null&&r.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Sp(r,a,i,u,b){var j=Hu();return j=j===null?null:{parent:qn._currentValue,pool:j},a.memoizedState={baseLanes:i,cachePool:j},r!==null&&cc(a,null),Yu(),Tg(a),r!==null&&Sl(r,a,u,!0),a.childLanes=b,null}function Sc(r,a){return a=Ec({mode:a.mode,children:a.children},r.mode),a.ref=r.ref,r.child=a,a.return=r,a}function Cp(r,a,i){return Wa(a,r.child,null,i),r=Sc(a,a.pendingProps),r.flags|=2,Lr(a),a.memoizedState=null,r}function L5(r,a,i){var u=a.pendingProps,b=(a.flags&128)!==0;if(a.flags&=-129,r===null){if(Zt){if(u.mode==="hidden")return r=Sc(a,u),a.lanes=536870912,$i(null,r);if(Xu(a),(r=kn)?(r=$0(r,Qr),r=r!==null&&r.data==="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:aa!==null?{id:ps,overflow:bs}:null,retryLane:536870912,hydrationErrors:null},i=cg(r),i.return=a,a.child=i,lr=a,kn=null)):r=null,r===null)throw ia(a);return a.lanes=536870912,null}return Sc(a,u)}var j=r.memoizedState;if(j!==null){var $=j.dehydrated;if(Xu(a),b)if(a.flags&256)a.flags&=-257,a=Cp(r,a,i);else if(a.memoizedState!==null)a.child=r.child,a.flags|=128,a=null;else throw Error(l(558));else if(Fn||Sl(r,a,i,!1),b=(i&r.childLanes)!==0,Fn||b){if(u=pn,u!==null&&($=qe(u,i),$!==0&&$!==j.retryLane))throw j.retryLane=$,qa(r,$),Cr(u,r,$),gf;Ic(),a=Cp(r,a,i)}else r=j.treeContext,kn=es($.nextSibling),lr=a,Zt=!0,la=null,Qr=!1,r!==null&&fg(a,r),a=Sc(a,u),a.flags|=4096;return a}return r=Ds(r.child,{mode:u.mode,children:u.children}),r.ref=a.ref,a.child=r,r.return=a,r}function Cc(r,a){var i=a.ref;if(i===null)r!==null&&r.ref!==null&&(a.flags|=4194816);else{if(typeof i!="function"&&typeof i!="object")throw Error(l(284));(r===null||r.ref!==i)&&(a.flags|=4194816)}}function pf(r,a,i,u,b){return Ga(a),i=Zu(r,a,i,u,void 0,b),u=Wu(),r!==null&&!Fn?(Qu(r,a,b),Hs(r,a,b)):(Zt&&u&&Mu(a),a.flags|=1,or(r,a,i,b),a.child)}function Ep(r,a,i,u,b,j){return Ga(a),a.updateQueue=null,i=_g(a,u,i,b),Ag(r),u=Wu(),r!==null&&!Fn?(Qu(r,a,j),Hs(r,a,j)):(Zt&&u&&Mu(a),a.flags|=1,or(r,a,i,j),a.child)}function Tp(r,a,i,u,b){if(Ga(a),a.stateNode===null){var j=jl,$=i.contextType;typeof $=="object"&&$!==null&&(j=ir($)),j=new i(u,j),a.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=mf,a.stateNode=j,j._reactInternals=a,j=a.stateNode,j.props=u,j.state=a.memoizedState,j.refs={},Uu(a),$=i.contextType,j.context=typeof $=="object"&&$!==null?ir($):jl,j.state=a.memoizedState,$=i.getDerivedStateFromProps,typeof $=="function"&&(hf(a,i,$,u),j.state=a.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||($=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),$!==j.state&&mf.enqueueReplaceState(j,j.state,null),Ri(a,u,j,b),Oi(),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!0}else if(r===null){j=a.stateNode;var Q=a.memoizedProps,le=Ja(i,Q);j.props=le;var xe=j.context,_e=i.contextType;$=jl,typeof _e=="object"&&_e!==null&&($=ir(_e));var Re=i.getDerivedStateFromProps;_e=typeof Re=="function"||typeof j.getSnapshotBeforeUpdate=="function",Q=a.pendingProps!==Q,_e||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(Q||xe!==$)&&mp(a,j,u,$),ca=!1;var be=a.memoizedState;j.state=be,Ri(a,u,j,b),Oi(),xe=a.memoizedState,Q||be!==xe||ca?(typeof Re=="function"&&(hf(a,i,Re,u),xe=a.memoizedState),(le=ca||hp(a,i,le,u,be,xe,$))?(_e||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(a.flags|=4194308)):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=u,a.memoizedState=xe),j.props=u,j.state=xe,j.context=$,u=le):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!1)}else{j=a.stateNode,qu(r,a),$=a.memoizedProps,_e=Ja(i,$),j.props=_e,Re=a.pendingProps,be=j.context,xe=i.contextType,le=jl,typeof xe=="object"&&xe!==null&&(le=ir(xe)),Q=i.getDerivedStateFromProps,(xe=typeof Q=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||($!==Re||be!==le)&&mp(a,j,u,le),ca=!1,be=a.memoizedState,j.state=be,Ri(a,u,j,b),Oi();var Se=a.memoizedState;$!==Re||be!==Se||ca||r!==null&&r.dependencies!==null&&ic(r.dependencies)?(typeof Q=="function"&&(hf(a,i,Q,u),Se=a.memoizedState),(_e=ca||hp(a,i,_e,u,be,Se,le)||r!==null&&r.dependencies!==null&&ic(r.dependencies))?(xe||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(u,Se,le),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(u,Se,le)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||$===r.memoizedProps&&be===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||$===r.memoizedProps&&be===r.memoizedState||(a.flags|=1024),a.memoizedProps=u,a.memoizedState=Se),j.props=u,j.state=Se,j.context=le,u=_e):(typeof j.componentDidUpdate!="function"||$===r.memoizedProps&&be===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||$===r.memoizedProps&&be===r.memoizedState||(a.flags|=1024),u=!1)}return j=u,Cc(r,a),u=(a.flags&128)!==0,j||u?(j=a.stateNode,i=u&&typeof i.getDerivedStateFromError!="function"?null:j.render(),a.flags|=1,r!==null&&u?(a.child=Wa(a,r.child,null,b),a.child=Wa(a,null,i,b)):or(r,a,i,b),a.memoizedState=j.state,r=a.child):r=Hs(r,a,b),r}function Ap(r,a,i,u){return Fa(),a.flags|=256,or(r,a,i,u),a.child}var bf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function yf(r){return{baseLanes:r,cachePool:bg()}}function vf(r,a,i){return r=r!==null?r.childLanes&~i:0,a&&(r|=zr),r}function _p(r,a,i){var u=a.pendingProps,b=!1,j=(a.flags&128)!==0,$;if(($=j)||($=r!==null&&r.memoizedState===null?!1:(Bn.current&2)!==0),$&&(b=!0,a.flags&=-129),$=(a.flags&32)!==0,a.flags&=-33,r===null){if(Zt){if(b?fa(a):ha(),(r=kn)?(r=$0(r,Qr),r=r!==null&&r.data!=="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:aa!==null?{id:ps,overflow:bs}:null,retryLane:536870912,hydrationErrors:null},i=cg(r),i.return=a,a.child=i,lr=a,kn=null)):r=null,r===null)throw ia(a);return nh(r)?a.lanes=32:a.lanes=536870912,null}var Q=u.children;return u=u.fallback,b?(ha(),b=a.mode,Q=Ec({mode:"hidden",children:Q},b),u=Va(u,b,i,null),Q.return=a,u.return=a,Q.sibling=u,a.child=Q,u=a.child,u.memoizedState=yf(i),u.childLanes=vf(r,$,i),a.memoizedState=bf,$i(null,u)):(fa(a),jf(a,Q))}var le=r.memoizedState;if(le!==null&&(Q=le.dehydrated,Q!==null)){if(j)a.flags&256?(fa(a),a.flags&=-257,a=wf(r,a,i)):a.memoizedState!==null?(ha(),a.child=r.child,a.flags|=128,a=null):(ha(),Q=u.fallback,b=a.mode,u=Ec({mode:"visible",children:u.children},b),Q=Va(Q,b,i,null),Q.flags|=2,u.return=a,Q.return=a,u.sibling=Q,a.child=u,Wa(a,r.child,null,i),u=a.child,u.memoizedState=yf(i),u.childLanes=vf(r,$,i),a.memoizedState=bf,a=$i(null,u));else if(fa(a),nh(Q)){if($=Q.nextSibling&&Q.nextSibling.dataset,$)var xe=$.dgst;$=xe,u=Error(l(419)),u.stack="",u.digest=$,Ci({value:u,source:null,stack:null}),a=wf(r,a,i)}else if(Fn||Sl(r,a,i,!1),$=(i&r.childLanes)!==0,Fn||$){if($=pn,$!==null&&(u=qe($,i),u!==0&&u!==le.retryLane))throw le.retryLane=u,qa(r,u),Cr($,r,u),gf;th(Q)||Ic(),a=wf(r,a,i)}else th(Q)?(a.flags|=192,a.child=r.child,a=null):(r=le.treeContext,kn=es(Q.nextSibling),lr=a,Zt=!0,la=null,Qr=!1,r!==null&&fg(a,r),a=jf(a,u.children),a.flags|=4096);return a}return b?(ha(),Q=u.fallback,b=a.mode,le=r.child,xe=le.sibling,u=Ds(le,{mode:"hidden",children:u.children}),u.subtreeFlags=le.subtreeFlags&65011712,xe!==null?Q=Ds(xe,Q):(Q=Va(Q,b,i,null),Q.flags|=2),Q.return=a,u.return=a,u.sibling=Q,a.child=u,$i(null,u),u=a.child,Q=r.child.memoizedState,Q===null?Q=yf(i):(b=Q.cachePool,b!==null?(le=qn._currentValue,b=b.parent!==le?{parent:le,pool:le}:b):b=bg(),Q={baseLanes:Q.baseLanes|i,cachePool:b}),u.memoizedState=Q,u.childLanes=vf(r,$,i),a.memoizedState=bf,$i(r.child,u)):(fa(a),i=r.child,r=i.sibling,i=Ds(i,{mode:"visible",children:u.children}),i.return=a,i.sibling=null,r!==null&&($=a.deletions,$===null?(a.deletions=[r],a.flags|=16):$.push(r)),a.child=i,a.memoizedState=null,i)}function jf(r,a){return a=Ec({mode:"visible",children:a},r.mode),a.return=r,r.child=a}function Ec(r,a){return r=Rr(22,r,null,a),r.lanes=0,r}function wf(r,a,i){return Wa(a,r.child,null,i),r=jf(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function Mp(r,a,i){r.lanes|=a;var u=r.alternate;u!==null&&(u.lanes|=a),Iu(r.return,a,i)}function Nf(r,a,i,u,b,j){var $=r.memoizedState;$===null?r.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:u,tail:i,tailMode:b,treeForkCount:j}:($.isBackwards=a,$.rendering=null,$.renderingStartTime=0,$.last=u,$.tail=i,$.tailMode=b,$.treeForkCount=j)}function Op(r,a,i){var u=a.pendingProps,b=u.revealOrder,j=u.tail;u=u.children;var $=Bn.current,Q=($&2)!==0;if(Q?($=$&1|2,a.flags|=128):$&=1,I(Bn,$),or(r,a,u,i),u=Zt?Si:0,!Q&&r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Mp(r,i,a);else if(r.tag===19)Mp(r,i,a);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===a)break e;for(;r.sibling===null;){if(r.return===null||r.return===a)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(b){case"forwards":for(i=a.child,b=null;i!==null;)r=i.alternate,r!==null&&xc(r)===null&&(b=i),i=i.sibling;i=b,i===null?(b=a.child,a.child=null):(b=i.sibling,i.sibling=null),Nf(a,!1,b,i,j,u);break;case"backwards":case"unstable_legacy-backwards":for(i=null,b=a.child,a.child=null;b!==null;){if(r=b.alternate,r!==null&&xc(r)===null){a.child=b;break}r=b.sibling,b.sibling=i,i=b,b=r}Nf(a,!0,i,null,j,u);break;case"together":Nf(a,!1,null,null,void 0,u);break;default:a.memoizedState=null}return a.child}function Hs(r,a,i){if(r!==null&&(a.dependencies=r.dependencies),ga|=a.lanes,(i&a.childLanes)===0)if(r!==null){if(Sl(r,a,i,!1),(i&a.childLanes)===0)return null}else return null;if(r!==null&&a.child!==r.child)throw Error(l(153));if(a.child!==null){for(r=a.child,i=Ds(r,r.pendingProps),a.child=i,i.return=a;r.sibling!==null;)r=r.sibling,i=i.sibling=Ds(r,r.pendingProps),i.return=a;i.sibling=null}return a.child}function kf(r,a){return(r.lanes&a)!==0?!0:(r=r.dependencies,!!(r!==null&&ic(r)))}function I5(r,a,i){switch(a.tag){case 3:ne(a,a.stateNode.containerInfo),oa(a,qn,r.memoizedState.cache),Fa();break;case 27:case 5:he(a);break;case 4:ne(a,a.stateNode.containerInfo);break;case 10:oa(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Xu(a),null;break;case 13:var u=a.memoizedState;if(u!==null)return u.dehydrated!==null?(fa(a),a.flags|=128,null):(i&a.child.childLanes)!==0?_p(r,a,i):(fa(a),r=Hs(r,a,i),r!==null?r.sibling:null);fa(a);break;case 19:var b=(r.flags&128)!==0;if(u=(i&a.childLanes)!==0,u||(Sl(r,a,i,!1),u=(i&a.childLanes)!==0),b){if(u)return Op(r,a,i);a.flags|=128}if(b=a.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),I(Bn,Bn.current),u)break;return null;case 22:return a.lanes=0,kp(r,a,i,a.pendingProps);case 24:oa(a,qn,r.memoizedState.cache)}return Hs(r,a,i)}function Rp(r,a,i){if(r!==null)if(r.memoizedProps!==a.pendingProps)Fn=!0;else{if(!kf(r,i)&&(a.flags&128)===0)return Fn=!1,I5(r,a,i);Fn=(r.flags&131072)!==0}else Fn=!1,Zt&&(a.flags&1048576)!==0&&ug(a,Si,a.index);switch(a.lanes=0,a.tag){case 16:e:{var u=a.pendingProps;if(r=Ka(a.elementType),a.type=r,typeof r=="function")Tu(r)?(u=Ja(r,u),a.tag=1,a=Tp(null,a,r,u,i)):(a.tag=0,a=pf(null,a,r,u,i));else{if(r!=null){var b=r.$$typeof;if(b===S){a.tag=11,a=jp(null,a,r,u,i);break e}else if(b===Y){a.tag=14,a=wp(null,a,r,u,i);break e}}throw a=T(r)||r,Error(l(306,a,""))}}return a;case 0:return pf(r,a,a.type,a.pendingProps,i);case 1:return u=a.type,b=Ja(u,a.pendingProps),Tp(r,a,u,b,i);case 3:e:{if(ne(a,a.stateNode.containerInfo),r===null)throw Error(l(387));u=a.pendingProps;var j=a.memoizedState;b=j.element,qu(r,a),Ri(a,u,null,i);var $=a.memoizedState;if(u=$.cache,oa(a,qn,u),u!==j.cache&&zu(a,[qn],i,!0),Oi(),u=$.element,j.isDehydrated)if(j={element:u,isDehydrated:!1,cache:$.cache},a.updateQueue.baseState=j,a.memoizedState=j,a.flags&256){a=Ap(r,a,u,i);break e}else if(u!==b){b=Kr(Error(l(424)),a),Ci(b),a=Ap(r,a,u,i);break e}else for(r=a.stateNode.containerInfo,r.nodeType===9?r=r.body:r=r.nodeName==="HTML"?r.ownerDocument.body:r,kn=es(r.firstChild),lr=a,Zt=!0,la=null,Qr=!0,i=kg(a,null,u,i),a.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Fa(),u===b){a=Hs(r,a,i);break e}or(r,a,u,i)}a=a.child}return a;case 26:return Cc(r,a),r===null?(i=V0(a.type,null,a.pendingProps,null))?a.memoizedState=i:Zt||(i=a.type,r=a.pendingProps,u=qc(Z.current).createElement(i),u[zt]=a,u[pt]=r,cr(u,i,r),vn(u),a.stateNode=u):a.memoizedState=V0(a.type,r.memoizedProps,a.pendingProps,r.memoizedState),null;case 27:return he(a),r===null&&Zt&&(u=a.stateNode=P0(a.type,a.pendingProps,Z.current),lr=a,Qr=!0,b=kn,ja(a.type)?(rh=b,kn=es(u.firstChild)):kn=b),or(r,a,a.pendingProps.children,i),Cc(r,a),r===null&&(a.flags|=4194304),a.child;case 5:return r===null&&Zt&&((b=u=kn)&&(u=f2(u,a.type,a.pendingProps,Qr),u!==null?(a.stateNode=u,lr=a,kn=es(u.firstChild),Qr=!1,b=!0):b=!1),b||ia(a)),he(a),b=a.type,j=a.pendingProps,$=r!==null?r.memoizedProps:null,u=j.children,Qf(b,j)?u=null:$!==null&&Qf(b,$)&&(a.flags|=32),a.memoizedState!==null&&(b=Zu(r,a,E5,null,null,i),Ji._currentValue=b),Cc(r,a),or(r,a,u,i),a.child;case 6:return r===null&&Zt&&((r=i=kn)&&(i=h2(i,a.pendingProps,Qr),i!==null?(a.stateNode=i,lr=a,kn=null,r=!0):r=!1),r||ia(a)),null;case 13:return _p(r,a,i);case 4:return ne(a,a.stateNode.containerInfo),u=a.pendingProps,r===null?a.child=Wa(a,null,u,i):or(r,a,u,i),a.child;case 11:return jp(r,a,a.type,a.pendingProps,i);case 7:return or(r,a,a.pendingProps,i),a.child;case 8:return or(r,a,a.pendingProps.children,i),a.child;case 12:return or(r,a,a.pendingProps.children,i),a.child;case 10:return u=a.pendingProps,oa(a,a.type,u.value),or(r,a,u.children,i),a.child;case 9:return b=a.type._context,u=a.pendingProps.children,Ga(a),b=ir(b),u=u(b),a.flags|=1,or(r,a,u,i),a.child;case 14:return wp(r,a,a.type,a.pendingProps,i);case 15:return Np(r,a,a.type,a.pendingProps,i);case 19:return Op(r,a,i);case 31:return L5(r,a,i);case 22:return kp(r,a,i,a.pendingProps);case 24:return Ga(a),u=ir(qn),r===null?(b=Hu(),b===null&&(b=pn,j=$u(),b.pooledCache=j,j.refCount++,j!==null&&(b.pooledCacheLanes|=i),b=j),a.memoizedState={parent:u,cache:b},Uu(a),oa(a,qn,b)):((r.lanes&i)!==0&&(qu(r,a),Ri(a,null,null,i),Oi()),b=r.memoizedState,j=a.memoizedState,b.parent!==u?(b={parent:u,cache:u},a.memoizedState=b,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=b),oa(a,qn,u)):(u=j.cache,oa(a,qn,u),u!==b.cache&&zu(a,[qn],i,!0))),or(r,a,a.pendingProps.children,i),a.child;case 29:throw a.pendingProps}throw Error(l(156,a.tag))}function Ps(r){r.flags|=4}function Sf(r,a,i,u,b){if((a=(r.mode&32)!==0)&&(a=!1),a){if(r.flags|=16777216,(b&335544128)===b)if(r.stateNode.complete)r.flags|=8192;else if(l0())r.flags|=8192;else throw Za=uc,Pu}else r.flags&=-16777217}function Dp(r,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!K0(a))if(l0())r.flags|=8192;else throw Za=uc,Pu}function Tc(r,a){a!==null&&(r.flags|=4),r.flags&16384&&(a=r.tag!==22?Wt():536870912,r.lanes|=a,zl|=a)}function Bi(r,a){if(!Zt)switch(r.tailMode){case"hidden":a=r.tail;for(var i=null;a!==null;)a.alternate!==null&&(i=a),a=a.sibling;i===null?r.tail=null:i.sibling=null;break;case"collapsed":i=r.tail;for(var u=null;i!==null;)i.alternate!==null&&(u=i),i=i.sibling;u===null?a||r.tail===null?r.tail=null:r.tail.sibling=null:u.sibling=null}}function Sn(r){var a=r.alternate!==null&&r.alternate.child===r.child,i=0,u=0;if(a)for(var b=r.child;b!==null;)i|=b.lanes|b.childLanes,u|=b.subtreeFlags&65011712,u|=b.flags&65011712,b.return=r,b=b.sibling;else for(b=r.child;b!==null;)i|=b.lanes|b.childLanes,u|=b.subtreeFlags,u|=b.flags,b.return=r,b=b.sibling;return r.subtreeFlags|=u,r.childLanes=i,a}function z5(r,a,i){var u=a.pendingProps;switch(Ou(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sn(a),null;case 1:return Sn(a),null;case 3:return i=a.stateNode,u=null,r!==null&&(u=r.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),zs(qn),ae(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(r===null||r.child===null)&&(kl(a)?Ps(a):r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Du())),Sn(a),null;case 26:var b=a.type,j=a.memoizedState;return r===null?(Ps(a),j!==null?(Sn(a),Dp(a,j)):(Sn(a),Sf(a,b,null,u,i))):j?j!==r.memoizedState?(Ps(a),Sn(a),Dp(a,j)):(Sn(a),a.flags&=-16777217):(r=r.memoizedProps,r!==u&&Ps(a),Sn(a),Sf(a,b,r,u,i)),null;case 27:if(Ne(a),i=Z.current,b=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Ps(a);else{if(!u){if(a.stateNode===null)throw Error(l(166));return Sn(a),null}r=M.current,kl(a)?hg(a):(r=P0(b,u,i),a.stateNode=r,Ps(a))}return Sn(a),null;case 5:if(Ne(a),b=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Ps(a);else{if(!u){if(a.stateNode===null)throw Error(l(166));return Sn(a),null}if(j=M.current,kl(a))hg(a);else{var $=qc(Z.current);switch(j){case 1:j=$.createElementNS("http://www.w3.org/2000/svg",b);break;case 2:j=$.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;default:switch(b){case"svg":j=$.createElementNS("http://www.w3.org/2000/svg",b);break;case"math":j=$.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;case"script":j=$.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof u.is=="string"?$.createElement("select",{is:u.is}):$.createElement("select"),u.multiple?j.multiple=!0:u.size&&(j.size=u.size);break;default:j=typeof u.is=="string"?$.createElement(b,{is:u.is}):$.createElement(b)}}j[zt]=a,j[pt]=u;e:for($=a.child;$!==null;){if($.tag===5||$.tag===6)j.appendChild($.stateNode);else if($.tag!==4&&$.tag!==27&&$.child!==null){$.child.return=$,$=$.child;continue}if($===a)break e;for(;$.sibling===null;){if($.return===null||$.return===a)break e;$=$.return}$.sibling.return=$.return,$=$.sibling}a.stateNode=j;e:switch(cr(j,b,u),b){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Ps(a)}}return Sn(a),Sf(a,a.type,r===null?null:r.memoizedProps,a.pendingProps,i),null;case 6:if(r&&a.stateNode!=null)r.memoizedProps!==u&&Ps(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(l(166));if(r=Z.current,kl(a)){if(r=a.stateNode,i=a.memoizedProps,u=null,b=lr,b!==null)switch(b.tag){case 27:case 5:u=b.memoizedProps}r[zt]=a,r=!!(r.nodeValue===i||u!==null&&u.suppressHydrationWarning===!0||_0(r.nodeValue,i)),r||ia(a,!0)}else r=qc(r).createTextNode(u),r[zt]=a,a.stateNode=r}return Sn(a),null;case 31:if(i=a.memoizedState,r===null||r.memoizedState!==null){if(u=kl(a),i!==null){if(r===null){if(!u)throw Error(l(318));if(r=a.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(557));r[zt]=a}else Fa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Sn(a),r=!1}else i=Du(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=i),r=!0;if(!r)return a.flags&256?(Lr(a),a):(Lr(a),null);if((a.flags&128)!==0)throw Error(l(558))}return Sn(a),null;case 13:if(u=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(b=kl(a),u!==null&&u.dehydrated!==null){if(r===null){if(!b)throw Error(l(318));if(b=a.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(l(317));b[zt]=a}else Fa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Sn(a),b=!1}else b=Du(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=b),b=!0;if(!b)return a.flags&256?(Lr(a),a):(Lr(a),null)}return Lr(a),(a.flags&128)!==0?(a.lanes=i,a):(i=u!==null,r=r!==null&&r.memoizedState!==null,i&&(u=a.child,b=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(b=u.alternate.memoizedState.cachePool.pool),j=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(j=u.memoizedState.cachePool.pool),j!==b&&(u.flags|=2048)),i!==r&&i&&(a.child.flags|=8192),Tc(a,a.updateQueue),Sn(a),null);case 4:return ae(),r===null&&Gf(a.stateNode.containerInfo),Sn(a),null;case 10:return zs(a.type),Sn(a),null;case 19:if(X(Bn),u=a.memoizedState,u===null)return Sn(a),null;if(b=(a.flags&128)!==0,j=u.rendering,j===null)if(b)Bi(u,!1);else{if(zn!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(j=xc(r),j!==null){for(a.flags|=128,Bi(u,!1),r=j.updateQueue,a.updateQueue=r,Tc(a,r),a.subtreeFlags=0,r=i,i=a.child;i!==null;)og(i,r),i=i.sibling;return I(Bn,Bn.current&1|2),Zt&&Ls(a,u.treeForkCount),a.child}r=r.sibling}u.tail!==null&&yt()>Rc&&(a.flags|=128,b=!0,Bi(u,!1),a.lanes=4194304)}else{if(!b)if(r=xc(j),r!==null){if(a.flags|=128,b=!0,r=r.updateQueue,a.updateQueue=r,Tc(a,r),Bi(u,!0),u.tail===null&&u.tailMode==="hidden"&&!j.alternate&&!Zt)return Sn(a),null}else 2*yt()-u.renderingStartTime>Rc&&i!==536870912&&(a.flags|=128,b=!0,Bi(u,!1),a.lanes=4194304);u.isBackwards?(j.sibling=a.child,a.child=j):(r=u.last,r!==null?r.sibling=j:a.child=j,u.last=j)}return u.tail!==null?(r=u.tail,u.rendering=r,u.tail=r.sibling,u.renderingStartTime=yt(),r.sibling=null,i=Bn.current,I(Bn,b?i&1|2:i&1),Zt&&Ls(a,u.treeForkCount),r):(Sn(a),null);case 22:case 23:return Lr(a),Gu(),u=a.memoizedState!==null,r!==null?r.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(i&536870912)!==0&&(a.flags&128)===0&&(Sn(a),a.subtreeFlags&6&&(a.flags|=8192)):Sn(a),i=a.updateQueue,i!==null&&Tc(a,i.retryQueue),i=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==i&&(a.flags|=2048),r!==null&&X(Xa),null;case 24:return i=null,r!==null&&(i=r.memoizedState.cache),a.memoizedState.cache!==i&&(a.flags|=2048),zs(qn),Sn(a),null;case 25:return null;case 30:return null}throw Error(l(156,a.tag))}function $5(r,a){switch(Ou(a),a.tag){case 1:return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return zs(qn),ae(),r=a.flags,(r&65536)!==0&&(r&128)===0?(a.flags=r&-65537|128,a):null;case 26:case 27:case 5:return Ne(a),null;case 31:if(a.memoizedState!==null){if(Lr(a),a.alternate===null)throw Error(l(340));Fa()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 13:if(Lr(a),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(l(340));Fa()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return X(Bn),null;case 4:return ae(),null;case 10:return zs(a.type),null;case 22:case 23:return Lr(a),Gu(),r!==null&&X(Xa),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 24:return zs(qn),null;case 25:return null;default:return null}}function Lp(r,a){switch(Ou(a),a.tag){case 3:zs(qn),ae();break;case 26:case 27:case 5:Ne(a);break;case 4:ae();break;case 31:a.memoizedState!==null&&Lr(a);break;case 13:Lr(a);break;case 19:X(Bn);break;case 10:zs(a.type);break;case 22:case 23:Lr(a),Gu(),r!==null&&X(Xa);break;case 24:zs(qn)}}function Hi(r,a){try{var i=a.updateQueue,u=i!==null?i.lastEffect:null;if(u!==null){var b=u.next;i=b;do{if((i.tag&r)===r){u=void 0;var j=i.create,$=i.inst;u=j(),$.destroy=u}i=i.next}while(i!==b)}}catch(Q){dn(a,a.return,Q)}}function ma(r,a,i){try{var u=a.updateQueue,b=u!==null?u.lastEffect:null;if(b!==null){var j=b.next;u=j;do{if((u.tag&r)===r){var $=u.inst,Q=$.destroy;if(Q!==void 0){$.destroy=void 0,b=a;var le=i,xe=Q;try{xe()}catch(_e){dn(b,le,_e)}}}u=u.next}while(u!==j)}}catch(_e){dn(a,a.return,_e)}}function Ip(r){var a=r.updateQueue;if(a!==null){var i=r.stateNode;try{Cg(a,i)}catch(u){dn(r,r.return,u)}}}function zp(r,a,i){i.props=Ja(r.type,r.memoizedProps),i.state=r.memoizedState;try{i.componentWillUnmount()}catch(u){dn(r,a,u)}}function Pi(r,a){try{var i=r.ref;if(i!==null){switch(r.tag){case 26:case 27:case 5:var u=r.stateNode;break;case 30:u=r.stateNode;break;default:u=r.stateNode}typeof i=="function"?r.refCleanup=i(u):i.current=u}}catch(b){dn(r,a,b)}}function ys(r,a){var i=r.ref,u=r.refCleanup;if(i!==null)if(typeof u=="function")try{u()}catch(b){dn(r,a,b)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(b){dn(r,a,b)}else i.current=null}function $p(r){var a=r.type,i=r.memoizedProps,u=r.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":i.autoFocus&&u.focus();break e;case"img":i.src?u.src=i.src:i.srcSet&&(u.srcset=i.srcSet)}}catch(b){dn(r,r.return,b)}}function Cf(r,a,i){try{var u=r.stateNode;l2(u,r.type,i,a),u[pt]=a}catch(b){dn(r,r.return,b)}}function Bp(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&ja(r.type)||r.tag===4}function Ef(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Bp(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&ja(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Tf(r,a,i){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(r,a):(a=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.appendChild(r),i=i._reactRootContainer,i!=null||a.onclick!==null||(a.onclick=Ue));else if(u!==4&&(u===27&&ja(r.type)&&(i=r.stateNode,a=null),r=r.child,r!==null))for(Tf(r,a,i),r=r.sibling;r!==null;)Tf(r,a,i),r=r.sibling}function Ac(r,a,i){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?i.insertBefore(r,a):i.appendChild(r);else if(u!==4&&(u===27&&ja(r.type)&&(i=r.stateNode),r=r.child,r!==null))for(Ac(r,a,i),r=r.sibling;r!==null;)Ac(r,a,i),r=r.sibling}function Hp(r){var a=r.stateNode,i=r.memoizedProps;try{for(var u=r.type,b=a.attributes;b.length;)a.removeAttributeNode(b[0]);cr(a,u,i),a[zt]=r,a[pt]=i}catch(j){dn(r,r.return,j)}}var Us=!1,Yn=!1,Af=!1,Pp=typeof WeakSet=="function"?WeakSet:Set,er=null;function B5(r,a){if(r=r.containerInfo,Zf=Zc,r=Jx(r),ju(r)){if("selectionStart"in r)var i={start:r.selectionStart,end:r.selectionEnd};else e:{i=(i=r.ownerDocument)&&i.defaultView||window;var u=i.getSelection&&i.getSelection();if(u&&u.rangeCount!==0){i=u.anchorNode;var b=u.anchorOffset,j=u.focusNode;u=u.focusOffset;try{i.nodeType,j.nodeType}catch{i=null;break e}var $=0,Q=-1,le=-1,xe=0,_e=0,Re=r,be=null;t:for(;;){for(var Se;Re!==i||b!==0&&Re.nodeType!==3||(Q=$+b),Re!==j||u!==0&&Re.nodeType!==3||(le=$+u),Re.nodeType===3&&($+=Re.nodeValue.length),(Se=Re.firstChild)!==null;)be=Re,Re=Se;for(;;){if(Re===r)break t;if(be===i&&++xe===b&&(Q=$),be===j&&++_e===u&&(le=$),(Se=Re.nextSibling)!==null)break;Re=be,be=Re.parentNode}Re=Se}i=Q===-1||le===-1?null:{start:Q,end:le}}else i=null}i=i||{start:0,end:0}}else i=null;for(Wf={focusedElem:r,selectionRange:i},Zc=!1,er=a;er!==null;)if(a=er,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,er=r;else for(;er!==null;){switch(a=er,j=a.alternate,r=a.flags,a.tag){case 0:if((r&4)!==0&&(r=a.updateQueue,r=r!==null?r.events:null,r!==null))for(i=0;i<r.length;i++)b=r[i],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&j!==null){r=void 0,i=a,b=j.memoizedProps,j=j.memoizedState,u=i.stateNode;try{var Je=Ja(i.type,b);r=u.getSnapshotBeforeUpdate(Je,j),u.__reactInternalSnapshotBeforeUpdate=r}catch(kt){dn(i,i.return,kt)}}break;case 3:if((r&1024)!==0){if(r=a.stateNode.containerInfo,i=r.nodeType,i===9)eh(r);else if(i===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":eh(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(l(163))}if(r=a.sibling,r!==null){r.return=a.return,er=r;break}er=a.return}}function Up(r,a,i){var u=i.flags;switch(i.tag){case 0:case 11:case 15:Vs(r,i),u&4&&Hi(5,i);break;case 1:if(Vs(r,i),u&4)if(r=i.stateNode,a===null)try{r.componentDidMount()}catch($){dn(i,i.return,$)}else{var b=Ja(i.type,a.memoizedProps);a=a.memoizedState;try{r.componentDidUpdate(b,a,r.__reactInternalSnapshotBeforeUpdate)}catch($){dn(i,i.return,$)}}u&64&&Ip(i),u&512&&Pi(i,i.return);break;case 3:if(Vs(r,i),u&64&&(r=i.updateQueue,r!==null)){if(a=null,i.child!==null)switch(i.child.tag){case 27:case 5:a=i.child.stateNode;break;case 1:a=i.child.stateNode}try{Cg(r,a)}catch($){dn(i,i.return,$)}}break;case 27:a===null&&u&4&&Hp(i);case 26:case 5:Vs(r,i),a===null&&u&4&&$p(i),u&512&&Pi(i,i.return);break;case 12:Vs(r,i);break;case 31:Vs(r,i),u&4&&Fp(r,i);break;case 13:Vs(r,i),u&4&&Yp(r,i),u&64&&(r=i.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(i=X5.bind(null,i),m2(r,i))));break;case 22:if(u=i.memoizedState!==null||Us,!u){a=a!==null&&a.memoizedState!==null||Yn,b=Us;var j=Yn;Us=u,(Yn=a)&&!j?Fs(r,i,(i.subtreeFlags&8772)!==0):Vs(r,i),Us=b,Yn=j}break;case 30:break;default:Vs(r,i)}}function qp(r){var a=r.alternate;a!==null&&(r.alternate=null,qp(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&gr(a)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var Tn=null,wr=!1;function qs(r,a,i){for(i=i.child;i!==null;)Vp(r,a,i),i=i.sibling}function Vp(r,a,i){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(Ht,i)}catch{}switch(i.tag){case 26:Yn||ys(i,a),qs(r,a,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Yn||ys(i,a);var u=Tn,b=wr;ja(i.type)&&(Tn=i.stateNode,wr=!1),qs(r,a,i),Zi(i.stateNode),Tn=u,wr=b;break;case 5:Yn||ys(i,a);case 6:if(u=Tn,b=wr,Tn=null,qs(r,a,i),Tn=u,wr=b,Tn!==null)if(wr)try{(Tn.nodeType===9?Tn.body:Tn.nodeName==="HTML"?Tn.ownerDocument.body:Tn).removeChild(i.stateNode)}catch(j){dn(i,a,j)}else try{Tn.removeChild(i.stateNode)}catch(j){dn(i,a,j)}break;case 18:Tn!==null&&(wr?(r=Tn,I0(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,i.stateNode),Fl(r)):I0(Tn,i.stateNode));break;case 4:u=Tn,b=wr,Tn=i.stateNode.containerInfo,wr=!0,qs(r,a,i),Tn=u,wr=b;break;case 0:case 11:case 14:case 15:ma(2,i,a),Yn||ma(4,i,a),qs(r,a,i);break;case 1:Yn||(ys(i,a),u=i.stateNode,typeof u.componentWillUnmount=="function"&&zp(i,a,u)),qs(r,a,i);break;case 21:qs(r,a,i);break;case 22:Yn=(u=Yn)||i.memoizedState!==null,qs(r,a,i),Yn=u;break;default:qs(r,a,i)}}function Fp(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{Fl(r)}catch(i){dn(a,a.return,i)}}}function Yp(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{Fl(r)}catch(i){dn(a,a.return,i)}}function H5(r){switch(r.tag){case 31:case 13:case 19:var a=r.stateNode;return a===null&&(a=r.stateNode=new Pp),a;case 22:return r=r.stateNode,a=r._retryCache,a===null&&(a=r._retryCache=new Pp),a;default:throw Error(l(435,r.tag))}}function _c(r,a){var i=H5(r);a.forEach(function(u){if(!i.has(u)){i.add(u);var b=K5.bind(null,r,u);u.then(b,b)}})}function Nr(r,a){var i=a.deletions;if(i!==null)for(var u=0;u<i.length;u++){var b=i[u],j=r,$=a,Q=$;e:for(;Q!==null;){switch(Q.tag){case 27:if(ja(Q.type)){Tn=Q.stateNode,wr=!1;break e}break;case 5:Tn=Q.stateNode,wr=!1;break e;case 3:case 4:Tn=Q.stateNode.containerInfo,wr=!0;break e}Q=Q.return}if(Tn===null)throw Error(l(160));Vp(j,$,b),Tn=null,wr=!1,j=b.alternate,j!==null&&(j.return=null),b.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)Gp(a,r),a=a.sibling}var is=null;function Gp(r,a){var i=r.alternate,u=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Nr(a,r),kr(r),u&4&&(ma(3,r,r.return),Hi(3,r),ma(5,r,r.return));break;case 1:Nr(a,r),kr(r),u&512&&(Yn||i===null||ys(i,i.return)),u&64&&Us&&(r=r.updateQueue,r!==null&&(u=r.callbacks,u!==null&&(i=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=i===null?u:i.concat(u))));break;case 26:var b=is;if(Nr(a,r),kr(r),u&512&&(Yn||i===null||ys(i,i.return)),u&4){var j=i!==null?i.memoizedState:null;if(u=r.memoizedState,i===null)if(u===null)if(r.stateNode===null){e:{u=r.type,i=r.memoizedProps,b=b.ownerDocument||b;t:switch(u){case"title":j=b.getElementsByTagName("title")[0],(!j||j[Rn]||j[zt]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=b.createElement(u),b.head.insertBefore(j,b.querySelector("head > title"))),cr(j,u,i),j[zt]=r,vn(j),u=j;break e;case"link":var $=G0("link","href",b).get(u+(i.href||""));if($){for(var Q=0;Q<$.length;Q++)if(j=$[Q],j.getAttribute("href")===(i.href==null||i.href===""?null:i.href)&&j.getAttribute("rel")===(i.rel==null?null:i.rel)&&j.getAttribute("title")===(i.title==null?null:i.title)&&j.getAttribute("crossorigin")===(i.crossOrigin==null?null:i.crossOrigin)){$.splice(Q,1);break t}}j=b.createElement(u),cr(j,u,i),b.head.appendChild(j);break;case"meta":if($=G0("meta","content",b).get(u+(i.content||""))){for(Q=0;Q<$.length;Q++)if(j=$[Q],j.getAttribute("content")===(i.content==null?null:""+i.content)&&j.getAttribute("name")===(i.name==null?null:i.name)&&j.getAttribute("property")===(i.property==null?null:i.property)&&j.getAttribute("http-equiv")===(i.httpEquiv==null?null:i.httpEquiv)&&j.getAttribute("charset")===(i.charSet==null?null:i.charSet)){$.splice(Q,1);break t}}j=b.createElement(u),cr(j,u,i),b.head.appendChild(j);break;default:throw Error(l(468,u))}j[zt]=r,vn(j),u=j}r.stateNode=u}else X0(b,r.type,r.stateNode);else r.stateNode=Y0(b,u,r.memoizedProps);else j!==u?(j===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):j.count--,u===null?X0(b,r.type,r.stateNode):Y0(b,u,r.memoizedProps)):u===null&&r.stateNode!==null&&Cf(r,r.memoizedProps,i.memoizedProps)}break;case 27:Nr(a,r),kr(r),u&512&&(Yn||i===null||ys(i,i.return)),i!==null&&u&4&&Cf(r,r.memoizedProps,i.memoizedProps);break;case 5:if(Nr(a,r),kr(r),u&512&&(Yn||i===null||ys(i,i.return)),r.flags&32){b=r.stateNode;try{Ie(b,"")}catch(Je){dn(r,r.return,Je)}}u&4&&r.stateNode!=null&&(b=r.memoizedProps,Cf(r,b,i!==null?i.memoizedProps:b)),u&1024&&(Af=!0);break;case 6:if(Nr(a,r),kr(r),u&4){if(r.stateNode===null)throw Error(l(162));u=r.memoizedProps,i=r.stateNode;try{i.nodeValue=u}catch(Je){dn(r,r.return,Je)}}break;case 3:if(Yc=null,b=is,is=Vc(a.containerInfo),Nr(a,r),is=b,kr(r),u&4&&i!==null&&i.memoizedState.isDehydrated)try{Fl(a.containerInfo)}catch(Je){dn(r,r.return,Je)}Af&&(Af=!1,Xp(r));break;case 4:u=is,is=Vc(r.stateNode.containerInfo),Nr(a,r),kr(r),is=u;break;case 12:Nr(a,r),kr(r);break;case 31:Nr(a,r),kr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,_c(r,u)));break;case 13:Nr(a,r),kr(r),r.child.flags&8192&&r.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(Oc=yt()),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,_c(r,u)));break;case 22:b=r.memoizedState!==null;var le=i!==null&&i.memoizedState!==null,xe=Us,_e=Yn;if(Us=xe||b,Yn=_e||le,Nr(a,r),Yn=_e,Us=xe,kr(r),u&8192)e:for(a=r.stateNode,a._visibility=b?a._visibility&-2:a._visibility|1,b&&(i===null||le||Us||Yn||el(r)),i=null,a=r;;){if(a.tag===5||a.tag===26){if(i===null){le=i=a;try{if(j=le.stateNode,b)$=j.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none";else{Q=le.stateNode;var Re=le.memoizedProps.style,be=Re!=null&&Re.hasOwnProperty("display")?Re.display:null;Q.style.display=be==null||typeof be=="boolean"?"":(""+be).trim()}}catch(Je){dn(le,le.return,Je)}}}else if(a.tag===6){if(i===null){le=a;try{le.stateNode.nodeValue=b?"":le.memoizedProps}catch(Je){dn(le,le.return,Je)}}}else if(a.tag===18){if(i===null){le=a;try{var Se=le.stateNode;b?z0(Se,!0):z0(le.stateNode,!1)}catch(Je){dn(le,le.return,Je)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===r)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break e;for(;a.sibling===null;){if(a.return===null||a.return===r)break e;i===a&&(i=null),a=a.return}i===a&&(i=null),a.sibling.return=a.return,a=a.sibling}u&4&&(u=r.updateQueue,u!==null&&(i=u.retryQueue,i!==null&&(u.retryQueue=null,_c(r,i))));break;case 19:Nr(a,r),kr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,_c(r,u)));break;case 30:break;case 21:break;default:Nr(a,r),kr(r)}}function kr(r){var a=r.flags;if(a&2){try{for(var i,u=r.return;u!==null;){if(Bp(u)){i=u;break}u=u.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var b=i.stateNode,j=Ef(r);Ac(r,j,b);break;case 5:var $=i.stateNode;i.flags&32&&(Ie($,""),i.flags&=-33);var Q=Ef(r);Ac(r,Q,$);break;case 3:case 4:var le=i.stateNode.containerInfo,xe=Ef(r);Tf(r,xe,le);break;default:throw Error(l(161))}}catch(_e){dn(r,r.return,_e)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function Xp(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var a=r;Xp(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),r=r.sibling}}function Vs(r,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)Up(r,a.alternate,a),a=a.sibling}function el(r){for(r=r.child;r!==null;){var a=r;switch(a.tag){case 0:case 11:case 14:case 15:ma(4,a,a.return),el(a);break;case 1:ys(a,a.return);var i=a.stateNode;typeof i.componentWillUnmount=="function"&&zp(a,a.return,i),el(a);break;case 27:Zi(a.stateNode);case 26:case 5:ys(a,a.return),el(a);break;case 22:a.memoizedState===null&&el(a);break;case 30:el(a);break;default:el(a)}r=r.sibling}}function Fs(r,a,i){for(i=i&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var u=a.alternate,b=r,j=a,$=j.flags;switch(j.tag){case 0:case 11:case 15:Fs(b,j,i),Hi(4,j);break;case 1:if(Fs(b,j,i),u=j,b=u.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(xe){dn(u,u.return,xe)}if(u=j,b=u.updateQueue,b!==null){var Q=u.stateNode;try{var le=b.shared.hiddenCallbacks;if(le!==null)for(b.shared.hiddenCallbacks=null,b=0;b<le.length;b++)Sg(le[b],Q)}catch(xe){dn(u,u.return,xe)}}i&&$&64&&Ip(j),Pi(j,j.return);break;case 27:Hp(j);case 26:case 5:Fs(b,j,i),i&&u===null&&$&4&&$p(j),Pi(j,j.return);break;case 12:Fs(b,j,i);break;case 31:Fs(b,j,i),i&&$&4&&Fp(b,j);break;case 13:Fs(b,j,i),i&&$&4&&Yp(b,j);break;case 22:j.memoizedState===null&&Fs(b,j,i),Pi(j,j.return);break;case 30:break;default:Fs(b,j,i)}a=a.sibling}}function _f(r,a){var i=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),r=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(r=a.memoizedState.cachePool.pool),r!==i&&(r!=null&&r.refCount++,i!=null&&Ei(i))}function Mf(r,a){r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Ei(r))}function os(r,a,i,u){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)Kp(r,a,i,u),a=a.sibling}function Kp(r,a,i,u){var b=a.flags;switch(a.tag){case 0:case 11:case 15:os(r,a,i,u),b&2048&&Hi(9,a);break;case 1:os(r,a,i,u);break;case 3:os(r,a,i,u),b&2048&&(r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Ei(r)));break;case 12:if(b&2048){os(r,a,i,u),r=a.stateNode;try{var j=a.memoizedProps,$=j.id,Q=j.onPostCommit;typeof Q=="function"&&Q($,a.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(le){dn(a,a.return,le)}}else os(r,a,i,u);break;case 31:os(r,a,i,u);break;case 13:os(r,a,i,u);break;case 23:break;case 22:j=a.stateNode,$=a.alternate,a.memoizedState!==null?j._visibility&2?os(r,a,i,u):Ui(r,a):j._visibility&2?os(r,a,i,u):(j._visibility|=2,Dl(r,a,i,u,(a.subtreeFlags&10256)!==0||!1)),b&2048&&_f($,a);break;case 24:os(r,a,i,u),b&2048&&Mf(a.alternate,a);break;default:os(r,a,i,u)}}function Dl(r,a,i,u,b){for(b=b&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var j=r,$=a,Q=i,le=u,xe=$.flags;switch($.tag){case 0:case 11:case 15:Dl(j,$,Q,le,b),Hi(8,$);break;case 23:break;case 22:var _e=$.stateNode;$.memoizedState!==null?_e._visibility&2?Dl(j,$,Q,le,b):Ui(j,$):(_e._visibility|=2,Dl(j,$,Q,le,b)),b&&xe&2048&&_f($.alternate,$);break;case 24:Dl(j,$,Q,le,b),b&&xe&2048&&Mf($.alternate,$);break;default:Dl(j,$,Q,le,b)}a=a.sibling}}function Ui(r,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var i=r,u=a,b=u.flags;switch(u.tag){case 22:Ui(i,u),b&2048&&_f(u.alternate,u);break;case 24:Ui(i,u),b&2048&&Mf(u.alternate,u);break;default:Ui(i,u)}a=a.sibling}}var qi=8192;function Ll(r,a,i){if(r.subtreeFlags&qi)for(r=r.child;r!==null;)Zp(r,a,i),r=r.sibling}function Zp(r,a,i){switch(r.tag){case 26:Ll(r,a,i),r.flags&qi&&r.memoizedState!==null&&C2(i,is,r.memoizedState,r.memoizedProps);break;case 5:Ll(r,a,i);break;case 3:case 4:var u=is;is=Vc(r.stateNode.containerInfo),Ll(r,a,i),is=u;break;case 22:r.memoizedState===null&&(u=r.alternate,u!==null&&u.memoizedState!==null?(u=qi,qi=16777216,Ll(r,a,i),qi=u):Ll(r,a,i));break;default:Ll(r,a,i)}}function Wp(r){var a=r.alternate;if(a!==null&&(r=a.child,r!==null)){a.child=null;do a=r.sibling,r.sibling=null,r=a;while(r!==null)}}function Vi(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var u=a[i];er=u,Jp(u,r)}Wp(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Qp(r),r=r.sibling}function Qp(r){switch(r.tag){case 0:case 11:case 15:Vi(r),r.flags&2048&&ma(9,r,r.return);break;case 3:Vi(r);break;case 12:Vi(r);break;case 22:var a=r.stateNode;r.memoizedState!==null&&a._visibility&2&&(r.return===null||r.return.tag!==13)?(a._visibility&=-3,Mc(r)):Vi(r);break;default:Vi(r)}}function Mc(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var i=0;i<a.length;i++){var u=a[i];er=u,Jp(u,r)}Wp(r)}for(r=r.child;r!==null;){switch(a=r,a.tag){case 0:case 11:case 15:ma(8,a,a.return),Mc(a);break;case 22:i=a.stateNode,i._visibility&2&&(i._visibility&=-3,Mc(a));break;default:Mc(a)}r=r.sibling}}function Jp(r,a){for(;er!==null;){var i=er;switch(i.tag){case 0:case 11:case 15:ma(8,i,a);break;case 23:case 22:if(i.memoizedState!==null&&i.memoizedState.cachePool!==null){var u=i.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Ei(i.memoizedState.cache)}if(u=i.child,u!==null)u.return=i,er=u;else e:for(i=r;er!==null;){u=er;var b=u.sibling,j=u.return;if(qp(u),u===i){er=null;break e}if(b!==null){b.return=j,er=b;break e}er=j}}}var P5={getCacheForType:function(r){var a=ir(qn),i=a.data.get(r);return i===void 0&&(i=r(),a.data.set(r,i)),i},cacheSignal:function(){return ir(qn).controller.signal}},U5=typeof WeakMap=="function"?WeakMap:Map,an=0,pn=null,qt=null,Yt=0,cn=0,Ir=null,xa=!1,Il=!1,Of=!1,Ys=0,zn=0,ga=0,tl=0,Rf=0,zr=0,zl=0,Fi=null,Sr=null,Df=!1,Oc=0,e0=0,Rc=1/0,Dc=null,pa=null,Wn=0,ba=null,$l=null,Gs=0,Lf=0,If=null,t0=null,Yi=0,zf=null;function $r(){return(an&2)!==0&&Yt!==0?Yt&-Yt:A.T!==null?qf():lt()}function n0(){if(zr===0)if((Yt&536870912)===0||Zt){var r=Rt;Rt<<=1,(Rt&3932160)===0&&(Rt=262144),zr=r}else zr=536870912;return r=Dr.current,r!==null&&(r.flags|=32),zr}function Cr(r,a,i){(r===pn&&(cn===2||cn===9)||r.cancelPendingCommit!==null)&&(Bl(r,0),ya(r,Yt,zr,!1)),Mt(r,i),((an&2)===0||r!==pn)&&(r===pn&&((an&2)===0&&(tl|=i),zn===4&&ya(r,Yt,zr,!1)),vs(r))}function r0(r,a,i){if((an&6)!==0)throw Error(l(327));var u=!i&&(a&127)===0&&(a&r.expiredLanes)===0||gn(r,a),b=u?F5(r,a):Bf(r,a,!0),j=u;do{if(b===0){Il&&!u&&ya(r,a,0,!1);break}else{if(i=r.current.alternate,j&&!q5(i)){b=Bf(r,a,!1),j=!1;continue}if(b===2){if(j=a,r.errorRecoveryDisabledLanes&j)var $=0;else $=r.pendingLanes&-536870913,$=$!==0?$:$&536870912?536870912:0;if($!==0){a=$;e:{var Q=r;b=Fi;var le=Q.current.memoizedState.isDehydrated;if(le&&(Bl(Q,$).flags|=256),$=Bf(Q,$,!1),$!==2){if(Of&&!le){Q.errorRecoveryDisabledLanes|=j,tl|=j,b=4;break e}j=Sr,Sr=b,j!==null&&(Sr===null?Sr=j:Sr.push.apply(Sr,j))}b=$}if(j=!1,b!==2)continue}}if(b===1){Bl(r,0),ya(r,a,0,!0);break}e:{switch(u=r,j=b,j){case 0:case 1:throw Error(l(345));case 4:if((a&4194048)!==a)break;case 6:ya(u,a,zr,!xa);break e;case 2:Sr=null;break;case 3:case 5:break;default:throw Error(l(329))}if((a&62914560)===a&&(b=Oc+300-yt(),10<b)){if(ya(u,a,zr,!xa),sn(u,0,!0)!==0)break e;Gs=a,u.timeoutHandle=D0(s0.bind(null,u,i,Sr,Dc,Df,a,zr,tl,zl,xa,j,"Throttled",-0,0),b);break e}s0(u,i,Sr,Dc,Df,a,zr,tl,zl,xa,j,null,-0,0)}}break}while(!0);vs(r)}function s0(r,a,i,u,b,j,$,Q,le,xe,_e,Re,be,Se){if(r.timeoutHandle=-1,Re=a.subtreeFlags,Re&8192||(Re&16785408)===16785408){Re={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ue},Zp(a,j,Re);var Je=(j&62914560)===j?Oc-yt():(j&4194048)===j?e0-yt():0;if(Je=E2(Re,Je),Je!==null){Gs=j,r.cancelPendingCommit=Je(f0.bind(null,r,a,j,i,u,b,$,Q,le,_e,Re,null,be,Se)),ya(r,j,$,!xe);return}}f0(r,a,j,i,u,b,$,Q,le)}function q5(r){for(var a=r;;){var i=a.tag;if((i===0||i===11||i===15)&&a.flags&16384&&(i=a.updateQueue,i!==null&&(i=i.stores,i!==null)))for(var u=0;u<i.length;u++){var b=i[u],j=b.getSnapshot;b=b.value;try{if(!Or(j(),b))return!1}catch{return!1}}if(i=a.child,a.subtreeFlags&16384&&i!==null)i.return=a,a=i;else{if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function ya(r,a,i,u){a&=~Rf,a&=~tl,r.suspendedLanes|=a,r.pingedLanes&=~a,u&&(r.warmLanes|=a),u=r.expirationTimes;for(var b=a;0<b;){var j=31-St(b),$=1<<j;u[j]=-1,b&=~$}i!==0&&Nn(r,i,a)}function Lc(){return(an&6)===0?(Gi(0),!1):!0}function $f(){if(qt!==null){if(cn===0)var r=qt.return;else r=qt,Is=Ya=null,Ju(r),Al=null,Ai=0,r=qt;for(;r!==null;)Lp(r.alternate,r),r=r.return;qt=null}}function Bl(r,a){var i=r.timeoutHandle;i!==-1&&(r.timeoutHandle=-1,c2(i)),i=r.cancelPendingCommit,i!==null&&(r.cancelPendingCommit=null,i()),Gs=0,$f(),pn=r,qt=i=Ds(r.current,null),Yt=a,cn=0,Ir=null,xa=!1,Il=gn(r,a),Of=!1,zl=zr=Rf=tl=ga=zn=0,Sr=Fi=null,Df=!1,(a&8)!==0&&(a|=a&32);var u=r.entangledLanes;if(u!==0)for(r=r.entanglements,u&=a;0<u;){var b=31-St(u),j=1<<b;a|=r[b],u&=~j}return Ys=a,nc(),i}function a0(r,a){It=null,A.H=zi,a===Tl||a===dc?(a=jg(),cn=3):a===Pu?(a=jg(),cn=4):cn=a===gf?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Ir=a,qt===null&&(zn=1,kc(r,Kr(a,r.current)))}function l0(){var r=Dr.current;return r===null?!0:(Yt&4194048)===Yt?Jr===null:(Yt&62914560)===Yt||(Yt&536870912)!==0?r===Jr:!1}function i0(){var r=A.H;return A.H=zi,r===null?zi:r}function o0(){var r=A.A;return A.A=P5,r}function Ic(){zn=4,xa||(Yt&4194048)!==Yt&&Dr.current!==null||(Il=!0),(ga&134217727)===0&&(tl&134217727)===0||pn===null||ya(pn,Yt,zr,!1)}function Bf(r,a,i){var u=an;an|=2;var b=i0(),j=o0();(pn!==r||Yt!==a)&&(Dc=null,Bl(r,a)),a=!1;var $=zn;e:do try{if(cn!==0&&qt!==null){var Q=qt,le=Ir;switch(cn){case 8:$f(),$=6;break e;case 3:case 2:case 9:case 6:Dr.current===null&&(a=!0);var xe=cn;if(cn=0,Ir=null,Hl(r,Q,le,xe),i&&Il){$=0;break e}break;default:xe=cn,cn=0,Ir=null,Hl(r,Q,le,xe)}}V5(),$=zn;break}catch(_e){a0(r,_e)}while(!0);return a&&r.shellSuspendCounter++,Is=Ya=null,an=u,A.H=b,A.A=j,qt===null&&(pn=null,Yt=0,nc()),$}function V5(){for(;qt!==null;)c0(qt)}function F5(r,a){var i=an;an|=2;var u=i0(),b=o0();pn!==r||Yt!==a?(Dc=null,Rc=yt()+500,Bl(r,a)):Il=gn(r,a);e:do try{if(cn!==0&&qt!==null){a=qt;var j=Ir;t:switch(cn){case 1:cn=0,Ir=null,Hl(r,a,j,1);break;case 2:case 9:if(yg(j)){cn=0,Ir=null,d0(a);break}a=function(){cn!==2&&cn!==9||pn!==r||(cn=7),vs(r)},j.then(a,a);break e;case 3:cn=7;break e;case 4:cn=5;break e;case 7:yg(j)?(cn=0,Ir=null,d0(a)):(cn=0,Ir=null,Hl(r,a,j,7));break;case 5:var $=null;switch(qt.tag){case 26:$=qt.memoizedState;case 5:case 27:var Q=qt;if($?K0($):Q.stateNode.complete){cn=0,Ir=null;var le=Q.sibling;if(le!==null)qt=le;else{var xe=Q.return;xe!==null?(qt=xe,zc(xe)):qt=null}break t}}cn=0,Ir=null,Hl(r,a,j,5);break;case 6:cn=0,Ir=null,Hl(r,a,j,6);break;case 8:$f(),zn=6;break e;default:throw Error(l(462))}}Y5();break}catch(_e){a0(r,_e)}while(!0);return Is=Ya=null,A.H=u,A.A=b,an=i,qt!==null?0:(pn=null,Yt=0,nc(),zn)}function Y5(){for(;qt!==null&&!Te();)c0(qt)}function c0(r){var a=Rp(r.alternate,r,Ys);r.memoizedProps=r.pendingProps,a===null?zc(r):qt=a}function d0(r){var a=r,i=a.alternate;switch(a.tag){case 15:case 0:a=Ep(i,a,a.pendingProps,a.type,void 0,Yt);break;case 11:a=Ep(i,a,a.pendingProps,a.type.render,a.ref,Yt);break;case 5:Ju(a);default:Lp(i,a),a=qt=og(a,Ys),a=Rp(i,a,Ys)}r.memoizedProps=r.pendingProps,a===null?zc(r):qt=a}function Hl(r,a,i,u){Is=Ya=null,Ju(a),Al=null,Ai=0;var b=a.return;try{if(D5(r,b,a,i,Yt)){zn=1,kc(r,Kr(i,r.current)),qt=null;return}}catch(j){if(b!==null)throw qt=b,j;zn=1,kc(r,Kr(i,r.current)),qt=null;return}a.flags&32768?(Zt||u===1?r=!0:Il||(Yt&536870912)!==0?r=!1:(xa=r=!0,(u===2||u===9||u===3||u===6)&&(u=Dr.current,u!==null&&u.tag===13&&(u.flags|=16384))),u0(a,r)):zc(a)}function zc(r){var a=r;do{if((a.flags&32768)!==0){u0(a,xa);return}r=a.return;var i=z5(a.alternate,a,Ys);if(i!==null){qt=i;return}if(a=a.sibling,a!==null){qt=a;return}qt=a=r}while(a!==null);zn===0&&(zn=5)}function u0(r,a){do{var i=$5(r.alternate,r);if(i!==null){i.flags&=32767,qt=i;return}if(i=r.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!a&&(r=r.sibling,r!==null)){qt=r;return}qt=r=i}while(r!==null);zn=6,qt=null}function f0(r,a,i,u,b,j,$,Q,le){r.cancelPendingCommit=null;do $c();while(Wn!==0);if((an&6)!==0)throw Error(l(327));if(a!==null){if(a===r.current)throw Error(l(177));if(j=a.lanes|a.childLanes,j|=Cu,yn(r,i,j,$,Q,le),r===pn&&(qt=pn=null,Yt=0),$l=a,ba=r,Gs=i,Lf=j,If=b,t0=u,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,Z5(Pe,function(){return p0(),null})):(r.callbackNode=null,r.callbackPriority=0),u=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||u){u=A.T,A.T=null,b=P.p,P.p=2,$=an,an|=4;try{B5(r,a,i)}finally{an=$,P.p=b,A.T=u}}Wn=1,h0(),m0(),x0()}}function h0(){if(Wn===1){Wn=0;var r=ba,a=$l,i=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||i){i=A.T,A.T=null;var u=P.p;P.p=2;var b=an;an|=4;try{Gp(a,r);var j=Wf,$=Jx(r.containerInfo),Q=j.focusedElem,le=j.selectionRange;if($!==Q&&Q&&Q.ownerDocument&&Qx(Q.ownerDocument.documentElement,Q)){if(le!==null&&ju(Q)){var xe=le.start,_e=le.end;if(_e===void 0&&(_e=xe),"selectionStart"in Q)Q.selectionStart=xe,Q.selectionEnd=Math.min(_e,Q.value.length);else{var Re=Q.ownerDocument||document,be=Re&&Re.defaultView||window;if(be.getSelection){var Se=be.getSelection(),Je=Q.textContent.length,kt=Math.min(le.start,Je),mn=le.end===void 0?kt:Math.min(le.end,Je);!Se.extend&&kt>mn&&($=mn,mn=kt,kt=$);var ue=Wx(Q,kt),ce=Wx(Q,mn);if(ue&&ce&&(Se.rangeCount!==1||Se.anchorNode!==ue.node||Se.anchorOffset!==ue.offset||Se.focusNode!==ce.node||Se.focusOffset!==ce.offset)){var me=Re.createRange();me.setStart(ue.node,ue.offset),Se.removeAllRanges(),kt>mn?(Se.addRange(me),Se.extend(ce.node,ce.offset)):(me.setEnd(ce.node,ce.offset),Se.addRange(me))}}}}for(Re=[],Se=Q;Se=Se.parentNode;)Se.nodeType===1&&Re.push({element:Se,left:Se.scrollLeft,top:Se.scrollTop});for(typeof Q.focus=="function"&&Q.focus(),Q=0;Q<Re.length;Q++){var Oe=Re[Q];Oe.element.scrollLeft=Oe.left,Oe.element.scrollTop=Oe.top}}Zc=!!Zf,Wf=Zf=null}finally{an=b,P.p=u,A.T=i}}r.current=a,Wn=2}}function m0(){if(Wn===2){Wn=0;var r=ba,a=$l,i=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||i){i=A.T,A.T=null;var u=P.p;P.p=2;var b=an;an|=4;try{Up(r,a.alternate,a)}finally{an=b,P.p=u,A.T=i}}Wn=3}}function x0(){if(Wn===4||Wn===3){Wn=0,nt();var r=ba,a=$l,i=Gs,u=t0;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Wn=5:(Wn=0,$l=ba=null,g0(r,r.pendingLanes));var b=r.pendingLanes;if(b===0&&(pa=null),We(i),a=a.stateNode,Lt&&typeof Lt.onCommitFiberRoot=="function")try{Lt.onCommitFiberRoot(Ht,a,void 0,(a.current.flags&128)===128)}catch{}if(u!==null){a=A.T,b=P.p,P.p=2,A.T=null;try{for(var j=r.onRecoverableError,$=0;$<u.length;$++){var Q=u[$];j(Q.value,{componentStack:Q.stack})}}finally{A.T=a,P.p=b}}(Gs&3)!==0&&$c(),vs(r),b=r.pendingLanes,(i&261930)!==0&&(b&42)!==0?r===zf?Yi++:(Yi=0,zf=r):Yi=0,Gi(0)}}function g0(r,a){(r.pooledCacheLanes&=a)===0&&(a=r.pooledCache,a!=null&&(r.pooledCache=null,Ei(a)))}function $c(){return h0(),m0(),x0(),p0()}function p0(){if(Wn!==5)return!1;var r=ba,a=Lf;Lf=0;var i=We(Gs),u=A.T,b=P.p;try{P.p=32>i?32:i,A.T=null,i=If,If=null;var j=ba,$=Gs;if(Wn=0,$l=ba=null,Gs=0,(an&6)!==0)throw Error(l(331));var Q=an;if(an|=4,Qp(j.current),Kp(j,j.current,$,i),an=Q,Gi(0,!1),Lt&&typeof Lt.onPostCommitFiberRoot=="function")try{Lt.onPostCommitFiberRoot(Ht,j)}catch{}return!0}finally{P.p=b,A.T=u,g0(r,a)}}function b0(r,a,i){a=Kr(i,a),a=xf(r.stateNode,a,2),r=ua(r,a,2),r!==null&&(Mt(r,2),vs(r))}function dn(r,a,i){if(r.tag===3)b0(r,r,i);else for(;a!==null;){if(a.tag===3){b0(a,r,i);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(pa===null||!pa.has(u))){r=Kr(i,r),i=yp(2),u=ua(a,i,2),u!==null&&(vp(i,u,a,r),Mt(u,2),vs(u));break}}a=a.return}}function Hf(r,a,i){var u=r.pingCache;if(u===null){u=r.pingCache=new U5;var b=new Set;u.set(a,b)}else b=u.get(a),b===void 0&&(b=new Set,u.set(a,b));b.has(i)||(Of=!0,b.add(i),r=G5.bind(null,r,a,i),a.then(r,r))}function G5(r,a,i){var u=r.pingCache;u!==null&&u.delete(a),r.pingedLanes|=r.suspendedLanes&i,r.warmLanes&=~i,pn===r&&(Yt&i)===i&&(zn===4||zn===3&&(Yt&62914560)===Yt&&300>yt()-Oc?(an&2)===0&&Bl(r,0):Rf|=i,zl===Yt&&(zl=0)),vs(r)}function y0(r,a){a===0&&(a=Wt()),r=qa(r,a),r!==null&&(Mt(r,a),vs(r))}function X5(r){var a=r.memoizedState,i=0;a!==null&&(i=a.retryLane),y0(r,i)}function K5(r,a){var i=0;switch(r.tag){case 31:case 13:var u=r.stateNode,b=r.memoizedState;b!==null&&(i=b.retryLane);break;case 19:u=r.stateNode;break;case 22:u=r.stateNode._retryCache;break;default:throw Error(l(314))}u!==null&&u.delete(a),y0(r,i)}function Z5(r,a){return _t(r,a)}var Bc=null,Pl=null,Pf=!1,Hc=!1,Uf=!1,va=0;function vs(r){r!==Pl&&r.next===null&&(Pl===null?Bc=Pl=r:Pl=Pl.next=r),Hc=!0,Pf||(Pf=!0,Q5())}function Gi(r,a){if(!Uf&&Hc){Uf=!0;do for(var i=!1,u=Bc;u!==null;){if(r!==0){var b=u.pendingLanes;if(b===0)var j=0;else{var $=u.suspendedLanes,Q=u.pingedLanes;j=(1<<31-St(42|r)+1)-1,j&=b&~($&~Q),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(i=!0,N0(u,j))}else j=Yt,j=sn(u,u===pn?j:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(j&3)===0||gn(u,j)||(i=!0,N0(u,j));u=u.next}while(i);Uf=!1}}function W5(){v0()}function v0(){Hc=Pf=!1;var r=0;va!==0&&o2()&&(r=va);for(var a=yt(),i=null,u=Bc;u!==null;){var b=u.next,j=j0(u,a);j===0?(u.next=null,i===null?Bc=b:i.next=b,b===null&&(Pl=i)):(i=u,(r!==0||(j&3)!==0)&&(Hc=!0)),u=b}Wn!==0&&Wn!==5||Gi(r),va!==0&&(va=0)}function j0(r,a){for(var i=r.suspendedLanes,u=r.pingedLanes,b=r.expirationTimes,j=r.pendingLanes&-62914561;0<j;){var $=31-St(j),Q=1<<$,le=b[$];le===-1?((Q&i)===0||(Q&u)!==0)&&(b[$]=rt(Q,a)):le<=a&&(r.expiredLanes|=Q),j&=~Q}if(a=pn,i=Yt,i=sn(r,r===a?i:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u=r.callbackNode,i===0||r===a&&(cn===2||cn===9)||r.cancelPendingCommit!==null)return u!==null&&u!==null&&se(u),r.callbackNode=null,r.callbackPriority=0;if((i&3)===0||gn(r,i)){if(a=i&-i,a===r.callbackPriority)return a;switch(u!==null&&se(u),We(i)){case 2:case 8:i=De;break;case 32:i=Pe;break;case 268435456:i=mt;break;default:i=Pe}return u=w0.bind(null,r),i=_t(i,u),r.callbackPriority=a,r.callbackNode=i,a}return u!==null&&u!==null&&se(u),r.callbackPriority=2,r.callbackNode=null,2}function w0(r,a){if(Wn!==0&&Wn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var i=r.callbackNode;if($c()&&r.callbackNode!==i)return null;var u=Yt;return u=sn(r,r===pn?u:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u===0?null:(r0(r,u,a),j0(r,yt()),r.callbackNode!=null&&r.callbackNode===i?w0.bind(null,r):null)}function N0(r,a){if($c())return null;r0(r,a,!0)}function Q5(){d2(function(){(an&6)!==0?_t(we,W5):v0()})}function qf(){if(va===0){var r=Cl;r===0&&(r=Ve,Ve<<=1,(Ve&261888)===0&&(Ve=256)),va=r}return va}function k0(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Ge(""+r)}function S0(r,a){var i=a.ownerDocument.createElement("input");return i.name=a.name,i.value=a.value,r.id&&i.setAttribute("form",r.id),a.parentNode.insertBefore(i,a),r=new FormData(r),i.parentNode.removeChild(i),r}function J5(r,a,i,u,b){if(a==="submit"&&i&&i.stateNode===b){var j=k0((b[pt]||null).action),$=u.submitter;$&&(a=(a=$[pt]||null)?k0(a.formAction):$.getAttribute("formAction"),a!==null&&(j=a,$=null));var Q=new Qo("action","action",null,u,b);r.push({event:Q,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(va!==0){var le=$?S0(b,$):new FormData(b);cf(i,{pending:!0,data:le,method:b.method,action:j},null,le)}}else typeof j=="function"&&(Q.preventDefault(),le=$?S0(b,$):new FormData(b),cf(i,{pending:!0,data:le,method:b.method,action:j},j,le))},currentTarget:b}]})}}for(var Vf=0;Vf<Su.length;Vf++){var Ff=Su[Vf],e2=Ff.toLowerCase(),t2=Ff[0].toUpperCase()+Ff.slice(1);ls(e2,"on"+t2)}ls(ng,"onAnimationEnd"),ls(rg,"onAnimationIteration"),ls(sg,"onAnimationStart"),ls("dblclick","onDoubleClick"),ls("focusin","onFocus"),ls("focusout","onBlur"),ls(p5,"onTransitionRun"),ls(b5,"onTransitionStart"),ls(y5,"onTransitionCancel"),ls(ag,"onTransitionEnd"),rr("onMouseEnter",["mouseout","mouseover"]),rr("onMouseLeave",["mouseout","mouseover"]),rr("onPointerEnter",["pointerout","pointerover"]),rr("onPointerLeave",["pointerout","pointerover"]),fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),fr("onBeforeInput",["compositionend","keypress","textInput","paste"]),fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xi="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(" "),n2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xi));function C0(r,a){a=(a&4)!==0;for(var i=0;i<r.length;i++){var u=r[i],b=u.event;u=u.listeners;e:{var j=void 0;if(a)for(var $=u.length-1;0<=$;$--){var Q=u[$],le=Q.instance,xe=Q.currentTarget;if(Q=Q.listener,le!==j&&b.isPropagationStopped())break e;j=Q,b.currentTarget=xe;try{j(b)}catch(_e){tc(_e)}b.currentTarget=null,j=le}else for($=0;$<u.length;$++){if(Q=u[$],le=Q.instance,xe=Q.currentTarget,Q=Q.listener,le!==j&&b.isPropagationStopped())break e;j=Q,b.currentTarget=xe;try{j(b)}catch(_e){tc(_e)}b.currentTarget=null,j=le}}}}function Vt(r,a){var i=a[de];i===void 0&&(i=a[de]=new Set);var u=r+"__bubble";i.has(u)||(E0(a,r,2,!1),i.add(u))}function Yf(r,a,i){var u=0;a&&(u|=4),E0(i,r,u,a)}var Pc="_reactListening"+Math.random().toString(36).slice(2);function Gf(r){if(!r[Pc]){r[Pc]=!0,gs.forEach(function(i){i!=="selectionchange"&&(n2.has(i)||Yf(i,!1,r),Yf(i,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[Pc]||(a[Pc]=!0,Yf("selectionchange",!1,a))}}function E0(r,a,i,u){switch(nb(a)){case 2:var b=_2;break;case 8:b=M2;break;default:b=oh}i=b.bind(null,a,i,r),b=void 0,!bt||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(b=!0),u?b!==void 0?r.addEventListener(a,i,{capture:!0,passive:b}):r.addEventListener(a,i,!0):b!==void 0?r.addEventListener(a,i,{passive:b}):r.addEventListener(a,i,!1)}function Xf(r,a,i,u,b){var j=u;if((a&1)===0&&(a&2)===0&&u!==null)e:for(;;){if(u===null)return;var $=u.tag;if($===3||$===4){var Q=u.stateNode.containerInfo;if(Q===b)break;if($===4)for($=u.return;$!==null;){var le=$.tag;if((le===3||le===4)&&$.stateNode.containerInfo===b)return;$=$.return}for(;Q!==null;){if($=pr(Q),$===null)return;if(le=$.tag,le===5||le===6||le===26||le===27){u=j=$;continue e}Q=Q.parentNode}}u=u.return}$n(function(){var xe=j,_e=ut(i),Re=[];e:{var be=lg.get(r);if(be!==void 0){var Se=Qo,Je=r;switch(r){case"keypress":if(ar(i)===0)break e;case"keydown":case"keyup":Se=KN;break;case"focusin":Je="focus",Se=gu;break;case"focusout":Je="blur",Se=gu;break;case"beforeblur":case"afterblur":Se=gu;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Se=Lx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=zN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=QN;break;case ng:case rg:case sg:Se=HN;break;case ag:Se=e5;break;case"scroll":case"scrollend":Se=LN;break;case"wheel":Se=n5;break;case"copy":case"cut":case"paste":Se=UN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=zx;break;case"toggle":case"beforetoggle":Se=s5}var kt=(a&4)!==0,mn=!kt&&(r==="scroll"||r==="scrollend"),ue=kt?be!==null?be+"Capture":null:be;kt=[];for(var ce=xe,me;ce!==null;){var Oe=ce;if(me=Oe.stateNode,Oe=Oe.tag,Oe!==5&&Oe!==26&&Oe!==27||me===null||ue===null||(Oe=jt(ce,ue),Oe!=null&&kt.push(Ki(ce,Oe,me))),mn)break;ce=ce.return}0<kt.length&&(be=new Se(be,Je,null,i,_e),Re.push({event:be,listeners:kt}))}}if((a&7)===0){e:{if(be=r==="mouseover"||r==="pointerover",Se=r==="mouseout"||r==="pointerout",be&&i!==Nt&&(Je=i.relatedTarget||i.fromElement)&&(pr(Je)||Je[on]))break e;if((Se||be)&&(be=_e.window===_e?_e:(be=_e.ownerDocument)?be.defaultView||be.parentWindow:window,Se?(Je=i.relatedTarget||i.toElement,Se=xe,Je=Je?pr(Je):null,Je!==null&&(mn=d(Je),kt=Je.tag,Je!==mn||kt!==5&&kt!==27&&kt!==6)&&(Je=null)):(Se=null,Je=xe),Se!==Je)){if(kt=Lx,Oe="onMouseLeave",ue="onMouseEnter",ce="mouse",(r==="pointerout"||r==="pointerover")&&(kt=zx,Oe="onPointerLeave",ue="onPointerEnter",ce="pointer"),mn=Se==null?be:dr(Se),me=Je==null?be:dr(Je),be=new kt(Oe,ce+"leave",Se,i,_e),be.target=mn,be.relatedTarget=me,Oe=null,pr(_e)===xe&&(kt=new kt(ue,ce+"enter",Je,i,_e),kt.target=me,kt.relatedTarget=mn,Oe=kt),mn=Oe,Se&&Je)t:{for(kt=r2,ue=Se,ce=Je,me=0,Oe=ue;Oe;Oe=kt(Oe))me++;Oe=0;for(var xt=ce;xt;xt=kt(xt))Oe++;for(;0<me-Oe;)ue=kt(ue),me--;for(;0<Oe-me;)ce=kt(ce),Oe--;for(;me--;){if(ue===ce||ce!==null&&ue===ce.alternate){kt=ue;break t}ue=kt(ue),ce=kt(ce)}kt=null}else kt=null;Se!==null&&T0(Re,be,Se,kt,!1),Je!==null&&mn!==null&&T0(Re,mn,Je,kt,!0)}}e:{if(be=xe?dr(xe):window,Se=be.nodeName&&be.nodeName.toLowerCase(),Se==="select"||Se==="input"&&be.type==="file")var nn=Fx;else if(qx(be))if(Yx)nn=m5;else{nn=f5;var at=u5}else Se=be.nodeName,!Se||Se.toLowerCase()!=="input"||be.type!=="checkbox"&&be.type!=="radio"?xe&&Ee(xe.elementType)&&(nn=Fx):nn=h5;if(nn&&(nn=nn(r,xe))){Vx(Re,nn,i,_e);break e}at&&at(r,be,xe),r==="focusout"&&xe&&be.type==="number"&&xe.memoizedProps.value!=null&&Mr(be,"number",be.value)}switch(at=xe?dr(xe):window,r){case"focusin":(qx(at)||at.contentEditable==="true")&&(bl=at,wu=xe,ki=null);break;case"focusout":ki=wu=bl=null;break;case"mousedown":Nu=!0;break;case"contextmenu":case"mouseup":case"dragend":Nu=!1,eg(Re,i,_e);break;case"selectionchange":if(g5)break;case"keydown":case"keyup":eg(Re,i,_e)}var $t;if(bu)e:{switch(r){case"compositionstart":var Gt="onCompositionStart";break e;case"compositionend":Gt="onCompositionEnd";break e;case"compositionupdate":Gt="onCompositionUpdate";break e}Gt=void 0}else pl?Px(r,i)&&(Gt="onCompositionEnd"):r==="keydown"&&i.keyCode===229&&(Gt="onCompositionStart");Gt&&($x&&i.locale!=="ko"&&(pl||Gt!=="onCompositionStart"?Gt==="onCompositionEnd"&&pl&&($t=On()):(Ke=_e,ot="value"in Ke?Ke.value:Ke.textContent,pl=!0)),at=Uc(xe,Gt),0<at.length&&(Gt=new Ix(Gt,r,null,i,_e),Re.push({event:Gt,listeners:at}),$t?Gt.data=$t:($t=Ux(i),$t!==null&&(Gt.data=$t)))),($t=l5?i5(r,i):o5(r,i))&&(Gt=Uc(xe,"onBeforeInput"),0<Gt.length&&(at=new Ix("onBeforeInput","beforeinput",null,i,_e),Re.push({event:at,listeners:Gt}),at.data=$t)),J5(Re,r,xe,i,_e)}C0(Re,a)})}function Ki(r,a,i){return{instance:r,listener:a,currentTarget:i}}function Uc(r,a){for(var i=a+"Capture",u=[];r!==null;){var b=r,j=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||j===null||(b=jt(r,i),b!=null&&u.unshift(Ki(r,b,j)),b=jt(r,a),b!=null&&u.push(Ki(r,b,j))),r.tag===3)return u;r=r.return}return[]}function r2(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function T0(r,a,i,u,b){for(var j=a._reactName,$=[];i!==null&&i!==u;){var Q=i,le=Q.alternate,xe=Q.stateNode;if(Q=Q.tag,le!==null&&le===u)break;Q!==5&&Q!==26&&Q!==27||xe===null||(le=xe,b?(xe=jt(i,j),xe!=null&&$.unshift(Ki(i,xe,le))):b||(xe=jt(i,j),xe!=null&&$.push(Ki(i,xe,le)))),i=i.return}$.length!==0&&r.push({event:a,listeners:$})}var s2=/\r\n?/g,a2=/\u0000|\uFFFD/g;function A0(r){return(typeof r=="string"?r:""+r).replace(s2,`
9
- `).replace(a2,"")}function _0(r,a){return a=A0(a),A0(r)===a}function hn(r,a,i,u,b,j){switch(i){case"children":typeof u=="string"?a==="body"||a==="textarea"&&u===""||Ie(r,u):(typeof u=="number"||typeof u=="bigint")&&a!=="body"&&Ie(r,""+u);break;case"className":Jn(r,"class",u);break;case"tabIndex":Jn(r,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Jn(r,i,u);break;case"style":pe(r,u,j);break;case"data":if(a!=="object"){Jn(r,"data",u);break}case"src":case"href":if(u===""&&(a!=="a"||i!=="href")){r.removeAttribute(i);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(i);break}u=Ge(""+u),r.setAttribute(i,u);break;case"action":case"formAction":if(typeof u=="function"){r.setAttribute(i,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof j=="function"&&(i==="formAction"?(a!=="input"&&hn(r,a,"name",b.name,b,null),hn(r,a,"formEncType",b.formEncType,b,null),hn(r,a,"formMethod",b.formMethod,b,null),hn(r,a,"formTarget",b.formTarget,b,null)):(hn(r,a,"encType",b.encType,b,null),hn(r,a,"method",b.method,b,null),hn(r,a,"target",b.target,b,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(i);break}u=Ge(""+u),r.setAttribute(i,u);break;case"onClick":u!=null&&(r.onclick=Ue);break;case"onScroll":u!=null&&Vt("scroll",r);break;case"onScrollEnd":u!=null&&Vt("scrollend",r);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(l(61));if(i=u.__html,i!=null){if(b.children!=null)throw Error(l(60));r.innerHTML=i}}break;case"multiple":r.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":r.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){r.removeAttribute("xlink:href");break}i=Ge(""+u),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(i,""+u):r.removeAttribute(i);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":u&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(i,""):r.removeAttribute(i);break;case"capture":case"download":u===!0?r.setAttribute(i,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(i,u):r.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?r.setAttribute(i,u):r.removeAttribute(i);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?r.removeAttribute(i):r.setAttribute(i,u);break;case"popover":Vt("beforetoggle",r),Vt("toggle",r),Dt(r,"popover",u);break;case"xlinkActuate":Dn(r,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":Dn(r,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":Dn(r,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":Dn(r,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":Dn(r,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":Dn(r,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":Dn(r,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":Dn(r,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":Dn(r,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Dt(r,"is",u);break;case"innerText":case"textContent":break;default:(!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(i=Me.get(i)||i,Dt(r,i,u))}}function Kf(r,a,i,u,b,j){switch(i){case"style":pe(r,u,j);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(l(61));if(i=u.__html,i!=null){if(b.children!=null)throw Error(l(60));r.innerHTML=i}}break;case"children":typeof u=="string"?Ie(r,u):(typeof u=="number"||typeof u=="bigint")&&Ie(r,""+u);break;case"onScroll":u!=null&&Vt("scroll",r);break;case"onScrollEnd":u!=null&&Vt("scrollend",r);break;case"onClick":u!=null&&(r.onclick=Ue);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!qr.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(b=i.endsWith("Capture"),a=i.slice(2,b?i.length-7:void 0),j=r[pt]||null,j=j!=null?j[i]:null,typeof j=="function"&&r.removeEventListener(a,j,b),typeof u=="function")){typeof j!="function"&&j!==null&&(i in r?r[i]=null:r.hasAttribute(i)&&r.removeAttribute(i)),r.addEventListener(a,u,b);break e}i in r?r[i]=u:u===!0?r.setAttribute(i,""):Dt(r,i,u)}}}function cr(r,a,i){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Vt("error",r),Vt("load",r);var u=!1,b=!1,j;for(j in i)if(i.hasOwnProperty(j)){var $=i[j];if($!=null)switch(j){case"src":u=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,a));default:hn(r,a,j,$,i,null)}}b&&hn(r,a,"srcSet",i.srcSet,i,null),u&&hn(r,a,"src",i.src,i,null);return;case"input":Vt("invalid",r);var Q=j=$=b=null,le=null,xe=null;for(u in i)if(i.hasOwnProperty(u)){var _e=i[u];if(_e!=null)switch(u){case"name":b=_e;break;case"type":$=_e;break;case"checked":le=_e;break;case"defaultChecked":xe=_e;break;case"value":j=_e;break;case"defaultValue":Q=_e;break;case"children":case"dangerouslySetInnerHTML":if(_e!=null)throw Error(l(137,a));break;default:hn(r,a,u,_e,i,null)}}br(r,j,Q,le,xe,$,b,!1);return;case"select":Vt("invalid",r),u=$=j=null;for(b in i)if(i.hasOwnProperty(b)&&(Q=i[b],Q!=null))switch(b){case"value":j=Q;break;case"defaultValue":$=Q;break;case"multiple":u=Q;default:hn(r,a,b,Q,i,null)}a=j,i=$,r.multiple=!!u,a!=null?sr(r,!!u,a,!1):i!=null&&sr(r,!!u,i,!0);return;case"textarea":Vt("invalid",r),j=b=u=null;for($ in i)if(i.hasOwnProperty($)&&(Q=i[$],Q!=null))switch($){case"value":u=Q;break;case"defaultValue":b=Q;break;case"children":j=Q;break;case"dangerouslySetInnerHTML":if(Q!=null)throw Error(l(91));break;default:hn(r,a,$,Q,i,null)}te(r,u,b,j);return;case"option":for(le in i)i.hasOwnProperty(le)&&(u=i[le],u!=null)&&(le==="selected"?r.selected=u&&typeof u!="function"&&typeof u!="symbol":hn(r,a,le,u,i,null));return;case"dialog":Vt("beforetoggle",r),Vt("toggle",r),Vt("cancel",r),Vt("close",r);break;case"iframe":case"object":Vt("load",r);break;case"video":case"audio":for(u=0;u<Xi.length;u++)Vt(Xi[u],r);break;case"image":Vt("error",r),Vt("load",r);break;case"details":Vt("toggle",r);break;case"embed":case"source":case"link":Vt("error",r),Vt("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(xe in i)if(i.hasOwnProperty(xe)&&(u=i[xe],u!=null))switch(xe){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,a));default:hn(r,a,xe,u,i,null)}return;default:if(Ee(a)){for(_e in i)i.hasOwnProperty(_e)&&(u=i[_e],u!==void 0&&Kf(r,a,_e,u,i,void 0));return}}for(Q in i)i.hasOwnProperty(Q)&&(u=i[Q],u!=null&&hn(r,a,Q,u,i,null))}function l2(r,a,i,u){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var b=null,j=null,$=null,Q=null,le=null,xe=null,_e=null;for(Se in i){var Re=i[Se];if(i.hasOwnProperty(Se)&&Re!=null)switch(Se){case"checked":break;case"value":break;case"defaultValue":le=Re;default:u.hasOwnProperty(Se)||hn(r,a,Se,null,u,Re)}}for(var be in u){var Se=u[be];if(Re=i[be],u.hasOwnProperty(be)&&(Se!=null||Re!=null))switch(be){case"type":j=Se;break;case"name":b=Se;break;case"checked":xe=Se;break;case"defaultChecked":_e=Se;break;case"value":$=Se;break;case"defaultValue":Q=Se;break;case"children":case"dangerouslySetInnerHTML":if(Se!=null)throw Error(l(137,a));break;default:Se!==Re&&hn(r,a,be,Se,u,Re)}}Yr(r,$,Q,le,xe,_e,j,b);return;case"select":Se=$=Q=be=null;for(j in i)if(le=i[j],i.hasOwnProperty(j)&&le!=null)switch(j){case"value":break;case"multiple":Se=le;default:u.hasOwnProperty(j)||hn(r,a,j,null,u,le)}for(b in u)if(j=u[b],le=i[b],u.hasOwnProperty(b)&&(j!=null||le!=null))switch(b){case"value":be=j;break;case"defaultValue":Q=j;break;case"multiple":$=j;default:j!==le&&hn(r,a,b,j,u,le)}a=Q,i=$,u=Se,be!=null?sr(r,!!i,be,!1):!!u!=!!i&&(a!=null?sr(r,!!i,a,!0):sr(r,!!i,i?[]:"",!1));return;case"textarea":Se=be=null;for(Q in i)if(b=i[Q],i.hasOwnProperty(Q)&&b!=null&&!u.hasOwnProperty(Q))switch(Q){case"value":break;case"children":break;default:hn(r,a,Q,null,u,b)}for($ in u)if(b=u[$],j=i[$],u.hasOwnProperty($)&&(b!=null||j!=null))switch($){case"value":be=b;break;case"defaultValue":Se=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(l(91));break;default:b!==j&&hn(r,a,$,b,u,j)}Gr(r,be,Se);return;case"option":for(var Je in i)be=i[Je],i.hasOwnProperty(Je)&&be!=null&&!u.hasOwnProperty(Je)&&(Je==="selected"?r.selected=!1:hn(r,a,Je,null,u,be));for(le in u)be=u[le],Se=i[le],u.hasOwnProperty(le)&&be!==Se&&(be!=null||Se!=null)&&(le==="selected"?r.selected=be&&typeof be!="function"&&typeof be!="symbol":hn(r,a,le,be,u,Se));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 kt in i)be=i[kt],i.hasOwnProperty(kt)&&be!=null&&!u.hasOwnProperty(kt)&&hn(r,a,kt,null,u,be);for(xe in u)if(be=u[xe],Se=i[xe],u.hasOwnProperty(xe)&&be!==Se&&(be!=null||Se!=null))switch(xe){case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(l(137,a));break;default:hn(r,a,xe,be,u,Se)}return;default:if(Ee(a)){for(var mn in i)be=i[mn],i.hasOwnProperty(mn)&&be!==void 0&&!u.hasOwnProperty(mn)&&Kf(r,a,mn,void 0,u,be);for(_e in u)be=u[_e],Se=i[_e],!u.hasOwnProperty(_e)||be===Se||be===void 0&&Se===void 0||Kf(r,a,_e,be,u,Se);return}}for(var ue in i)be=i[ue],i.hasOwnProperty(ue)&&be!=null&&!u.hasOwnProperty(ue)&&hn(r,a,ue,null,u,be);for(Re in u)be=u[Re],Se=i[Re],!u.hasOwnProperty(Re)||be===Se||be==null&&Se==null||hn(r,a,Re,be,u,Se)}function M0(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function i2(){if(typeof performance.getEntriesByType=="function"){for(var r=0,a=0,i=performance.getEntriesByType("resource"),u=0;u<i.length;u++){var b=i[u],j=b.transferSize,$=b.initiatorType,Q=b.duration;if(j&&Q&&M0($)){for($=0,Q=b.responseEnd,u+=1;u<i.length;u++){var le=i[u],xe=le.startTime;if(xe>Q)break;var _e=le.transferSize,Re=le.initiatorType;_e&&M0(Re)&&(le=le.responseEnd,$+=_e*(le<Q?1:(Q-xe)/(le-xe)))}if(--u,a+=8*(j+$)/(b.duration/1e3),r++,10<r)break}}if(0<r)return a/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var Zf=null,Wf=null;function qc(r){return r.nodeType===9?r:r.ownerDocument}function O0(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function R0(r,a){if(r===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&a==="foreignObject"?0:r}function Qf(r,a){return r==="textarea"||r==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Jf=null;function o2(){var r=window.event;return r&&r.type==="popstate"?r===Jf?!1:(Jf=r,!0):(Jf=null,!1)}var D0=typeof setTimeout=="function"?setTimeout:void 0,c2=typeof clearTimeout=="function"?clearTimeout:void 0,L0=typeof Promise=="function"?Promise:void 0,d2=typeof queueMicrotask=="function"?queueMicrotask:typeof L0<"u"?function(r){return L0.resolve(null).then(r).catch(u2)}:D0;function u2(r){setTimeout(function(){throw r})}function ja(r){return r==="head"}function I0(r,a){var i=a,u=0;do{var b=i.nextSibling;if(r.removeChild(i),b&&b.nodeType===8)if(i=b.data,i==="/$"||i==="/&"){if(u===0){r.removeChild(b),Fl(a);return}u--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")u++;else if(i==="html")Zi(r.ownerDocument.documentElement);else if(i==="head"){i=r.ownerDocument.head,Zi(i);for(var j=i.firstChild;j;){var $=j.nextSibling,Q=j.nodeName;j[Rn]||Q==="SCRIPT"||Q==="STYLE"||Q==="LINK"&&j.rel.toLowerCase()==="stylesheet"||i.removeChild(j),j=$}}else i==="body"&&Zi(r.ownerDocument.body);i=b}while(i);Fl(a)}function z0(r,a){var i=r;r=0;do{var u=i.nextSibling;if(i.nodeType===1?a?(i._stashedDisplay=i.style.display,i.style.display="none"):(i.style.display=i._stashedDisplay||"",i.getAttribute("style")===""&&i.removeAttribute("style")):i.nodeType===3&&(a?(i._stashedText=i.nodeValue,i.nodeValue=""):i.nodeValue=i._stashedText||""),u&&u.nodeType===8)if(i=u.data,i==="/$"){if(r===0)break;r--}else i!=="$"&&i!=="$?"&&i!=="$~"&&i!=="$!"||r++;i=u}while(i)}function eh(r){var a=r.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var i=a;switch(a=a.nextSibling,i.nodeName){case"HTML":case"HEAD":case"BODY":eh(i),gr(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}r.removeChild(i)}}function f2(r,a,i,u){for(;r.nodeType===1;){var b=i;if(r.nodeName.toLowerCase()!==a.toLowerCase()){if(!u&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(u){if(!r[Rn])switch(a){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(j=r.getAttribute("rel"),j==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(j!==b.rel||r.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||r.getAttribute("title")!==(b.title==null?null:b.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(j=r.getAttribute("src"),(j!==(b.src==null?null:b.src)||r.getAttribute("type")!==(b.type==null?null:b.type)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&j&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(a==="input"&&r.type==="hidden"){var j=b.name==null?null:""+b.name;if(b.type==="hidden"&&r.getAttribute("name")===j)return r}else return r;if(r=es(r.nextSibling),r===null)break}return null}function h2(r,a,i){if(a==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!i||(r=es(r.nextSibling),r===null))return null;return r}function $0(r,a){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!a||(r=es(r.nextSibling),r===null))return null;return r}function th(r){return r.data==="$?"||r.data==="$~"}function nh(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function m2(r,a){var i=r.ownerDocument;if(r.data==="$~")r._reactRetry=a;else if(r.data!=="$?"||i.readyState!=="loading")a();else{var u=function(){a(),i.removeEventListener("DOMContentLoaded",u)};i.addEventListener("DOMContentLoaded",u),r._reactRetry=u}}function es(r){for(;r!=null;r=r.nextSibling){var a=r.nodeType;if(a===1||a===3)break;if(a===8){if(a=r.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return r}var rh=null;function B0(r){r=r.nextSibling;for(var a=0;r;){if(r.nodeType===8){var i=r.data;if(i==="/$"||i==="/&"){if(a===0)return es(r.nextSibling);a--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||a++}r=r.nextSibling}return null}function H0(r){r=r.previousSibling;for(var a=0;r;){if(r.nodeType===8){var i=r.data;if(i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"){if(a===0)return r;a--}else i!=="/$"&&i!=="/&"||a++}r=r.previousSibling}return null}function P0(r,a,i){switch(a=qc(i),r){case"html":if(r=a.documentElement,!r)throw Error(l(452));return r;case"head":if(r=a.head,!r)throw Error(l(453));return r;case"body":if(r=a.body,!r)throw Error(l(454));return r;default:throw Error(l(451))}}function Zi(r){for(var a=r.attributes;a.length;)r.removeAttributeNode(a[0]);gr(r)}var ts=new Map,U0=new Set;function Vc(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var Xs=P.d;P.d={f:x2,r:g2,D:p2,C:b2,L:y2,m:v2,X:w2,S:j2,M:N2};function x2(){var r=Xs.f(),a=Lc();return r||a}function g2(r){var a=nr(r);a!==null&&a.tag===5&&a.type==="form"?ap(a):Xs.r(r)}var Ul=typeof document>"u"?null:document;function q0(r,a,i){var u=Ul;if(u&&typeof a=="string"&&a){var b=Ln(a);b='link[rel="'+r+'"][href="'+b+'"]',typeof i=="string"&&(b+='[crossorigin="'+i+'"]'),U0.has(b)||(U0.add(b),r={rel:r,crossOrigin:i,href:a},u.querySelector(b)===null&&(a=u.createElement("link"),cr(a,"link",r),vn(a),u.head.appendChild(a)))}}function p2(r){Xs.D(r),q0("dns-prefetch",r,null)}function b2(r,a){Xs.C(r,a),q0("preconnect",r,a)}function y2(r,a,i){Xs.L(r,a,i);var u=Ul;if(u&&r&&a){var b='link[rel="preload"][as="'+Ln(a)+'"]';a==="image"&&i&&i.imageSrcSet?(b+='[imagesrcset="'+Ln(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(b+='[imagesizes="'+Ln(i.imageSizes)+'"]')):b+='[href="'+Ln(r)+'"]';var j=b;switch(a){case"style":j=ql(r);break;case"script":j=Vl(r)}ts.has(j)||(r=x({rel:"preload",href:a==="image"&&i&&i.imageSrcSet?void 0:r,as:a},i),ts.set(j,r),u.querySelector(b)!==null||a==="style"&&u.querySelector(Wi(j))||a==="script"&&u.querySelector(Qi(j))||(a=u.createElement("link"),cr(a,"link",r),vn(a),u.head.appendChild(a)))}}function v2(r,a){Xs.m(r,a);var i=Ul;if(i&&r){var u=a&&typeof a.as=="string"?a.as:"script",b='link[rel="modulepreload"][as="'+Ln(u)+'"][href="'+Ln(r)+'"]',j=b;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Vl(r)}if(!ts.has(j)&&(r=x({rel:"modulepreload",href:r},a),ts.set(j,r),i.querySelector(b)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(Qi(j)))return}u=i.createElement("link"),cr(u,"link",r),vn(u),i.head.appendChild(u)}}}function j2(r,a,i){Xs.S(r,a,i);var u=Ul;if(u&&r){var b=ur(u).hoistableStyles,j=ql(r);a=a||"default";var $=b.get(j);if(!$){var Q={loading:0,preload:null};if($=u.querySelector(Wi(j)))Q.loading=5;else{r=x({rel:"stylesheet",href:r,"data-precedence":a},i),(i=ts.get(j))&&sh(r,i);var le=$=u.createElement("link");vn(le),cr(le,"link",r),le._p=new Promise(function(xe,_e){le.onload=xe,le.onerror=_e}),le.addEventListener("load",function(){Q.loading|=1}),le.addEventListener("error",function(){Q.loading|=2}),Q.loading|=4,Fc($,a,u)}$={type:"stylesheet",instance:$,count:1,state:Q},b.set(j,$)}}}function w2(r,a){Xs.X(r,a);var i=Ul;if(i&&r){var u=ur(i).hoistableScripts,b=Vl(r),j=u.get(b);j||(j=i.querySelector(Qi(b)),j||(r=x({src:r,async:!0},a),(a=ts.get(b))&&ah(r,a),j=i.createElement("script"),vn(j),cr(j,"link",r),i.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function N2(r,a){Xs.M(r,a);var i=Ul;if(i&&r){var u=ur(i).hoistableScripts,b=Vl(r),j=u.get(b);j||(j=i.querySelector(Qi(b)),j||(r=x({src:r,async:!0,type:"module"},a),(a=ts.get(b))&&ah(r,a),j=i.createElement("script"),vn(j),cr(j,"link",r),i.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function V0(r,a,i,u){var b=(b=Z.current)?Vc(b):null;if(!b)throw Error(l(446));switch(r){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(a=ql(i.href),i=ur(b).hoistableStyles,u=i.get(a),u||(u={type:"style",instance:null,count:0,state:null},i.set(a,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){r=ql(i.href);var j=ur(b).hoistableStyles,$=j.get(r);if($||(b=b.ownerDocument||b,$={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(r,$),(j=b.querySelector(Wi(r)))&&!j._p&&($.instance=j,$.state.loading=5),ts.has(r)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},ts.set(r,i),j||k2(b,r,i,$.state))),a&&u===null)throw Error(l(528,""));return $}if(a&&u!==null)throw Error(l(529,""));return null;case"script":return a=i.async,i=i.src,typeof i=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Vl(i),i=ur(b).hoistableScripts,u=i.get(a),u||(u={type:"script",instance:null,count:0,state:null},i.set(a,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,r))}}function ql(r){return'href="'+Ln(r)+'"'}function Wi(r){return'link[rel="stylesheet"]['+r+"]"}function F0(r){return x({},r,{"data-precedence":r.precedence,precedence:null})}function k2(r,a,i,u){r.querySelector('link[rel="preload"][as="style"]['+a+"]")?u.loading=1:(a=r.createElement("link"),u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2}),cr(a,"link",i),vn(a),r.head.appendChild(a))}function Vl(r){return'[src="'+Ln(r)+'"]'}function Qi(r){return"script[async]"+r}function Y0(r,a,i){if(a.count++,a.instance===null)switch(a.type){case"style":var u=r.querySelector('style[data-href~="'+Ln(i.href)+'"]');if(u)return a.instance=u,vn(u),u;var b=x({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return u=(r.ownerDocument||r).createElement("style"),vn(u),cr(u,"style",b),Fc(u,i.precedence,r),a.instance=u;case"stylesheet":b=ql(i.href);var j=r.querySelector(Wi(b));if(j)return a.state.loading|=4,a.instance=j,vn(j),j;u=F0(i),(b=ts.get(b))&&sh(u,b),j=(r.ownerDocument||r).createElement("link"),vn(j);var $=j;return $._p=new Promise(function(Q,le){$.onload=Q,$.onerror=le}),cr(j,"link",u),a.state.loading|=4,Fc(j,i.precedence,r),a.instance=j;case"script":return j=Vl(i.src),(b=r.querySelector(Qi(j)))?(a.instance=b,vn(b),b):(u=i,(b=ts.get(j))&&(u=x({},i),ah(u,b)),r=r.ownerDocument||r,b=r.createElement("script"),vn(b),cr(b,"link",u),r.head.appendChild(b),a.instance=b);case"void":return null;default:throw Error(l(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,Fc(u,i.precedence,r));return a.instance}function Fc(r,a,i){for(var u=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=u.length?u[u.length-1]:null,j=b,$=0;$<u.length;$++){var Q=u[$];if(Q.dataset.precedence===a)j=Q;else if(j!==b)break}j?j.parentNode.insertBefore(r,j.nextSibling):(a=i.nodeType===9?i.head:i,a.insertBefore(r,a.firstChild))}function sh(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.title==null&&(r.title=a.title)}function ah(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.integrity==null&&(r.integrity=a.integrity)}var Yc=null;function G0(r,a,i){if(Yc===null){var u=new Map,b=Yc=new Map;b.set(i,u)}else b=Yc,u=b.get(i),u||(u=new Map,b.set(i,u));if(u.has(r))return u;for(u.set(r,null),i=i.getElementsByTagName(r),b=0;b<i.length;b++){var j=i[b];if(!(j[Rn]||j[zt]||r==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var $=j.getAttribute(a)||"";$=r+$;var Q=u.get($);Q?Q.push(j):u.set($,[j])}}return u}function X0(r,a,i){r=r.ownerDocument||r,r.head.insertBefore(i,a==="title"?r.querySelector("head > title"):null)}function S2(r,a,i){if(i===1||a.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(r=a.disabled,typeof a.precedence=="string"&&r==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function K0(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function C2(r,a,i,u){if(i.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var b=ql(u.href),j=a.querySelector(Wi(b));if(j){a=j._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(r.count++,r=Gc.bind(r),a.then(r,r)),i.state.loading|=4,i.instance=j,vn(j);return}j=a.ownerDocument||a,u=F0(u),(b=ts.get(b))&&sh(u,b),j=j.createElement("link"),vn(j);var $=j;$._p=new Promise(function(Q,le){$.onload=Q,$.onerror=le}),cr(j,"link",u),i.instance=j}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(i,a),(a=i.state.preload)&&(i.state.loading&3)===0&&(r.count++,i=Gc.bind(r),a.addEventListener("load",i),a.addEventListener("error",i))}}var lh=0;function E2(r,a){return r.stylesheets&&r.count===0&&Kc(r,r.stylesheets),0<r.count||0<r.imgCount?function(i){var u=setTimeout(function(){if(r.stylesheets&&Kc(r,r.stylesheets),r.unsuspend){var j=r.unsuspend;r.unsuspend=null,j()}},6e4+a);0<r.imgBytes&&lh===0&&(lh=62500*i2());var b=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&Kc(r,r.stylesheets),r.unsuspend)){var j=r.unsuspend;r.unsuspend=null,j()}},(r.imgBytes>lh?50:800)+a);return r.unsuspend=i,function(){r.unsuspend=null,clearTimeout(u),clearTimeout(b)}}:null}function Gc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Kc(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var Xc=null;function Kc(r,a){r.stylesheets=null,r.unsuspend!==null&&(r.count++,Xc=new Map,a.forEach(T2,r),Xc=null,Gc.call(r))}function T2(r,a){if(!(a.state.loading&4)){var i=Xc.get(r);if(i)var u=i.get(null);else{i=new Map,Xc.set(r,i);for(var b=r.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<b.length;j++){var $=b[j];($.nodeName==="LINK"||$.getAttribute("media")!=="not all")&&(i.set($.dataset.precedence,$),u=$)}u&&i.set(null,u)}b=a.instance,$=b.getAttribute("data-precedence"),j=i.get($)||u,j===u&&i.set(null,b),i.set($,b),this.count++,u=Gc.bind(this),b.addEventListener("load",u),b.addEventListener("error",u),j?j.parentNode.insertBefore(b,j.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(b,r.firstChild)),a.state.loading|=4}}var Ji={$$typeof:k,Provider:null,Consumer:null,_currentValue:q,_currentValue2:q,_threadCount:0};function A2(r,a,i,u,b,j,$,Q,le){this.tag=1,this.containerInfo=r,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=Mn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mn(0),this.hiddenUpdates=Mn(null),this.identifierPrefix=u,this.onUncaughtError=b,this.onCaughtError=j,this.onRecoverableError=$,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=le,this.incompleteTransitions=new Map}function Z0(r,a,i,u,b,j,$,Q,le,xe,_e,Re){return r=new A2(r,a,i,$,le,xe,_e,Re,Q),a=1,j===!0&&(a|=24),j=Rr(3,null,null,a),r.current=j,j.stateNode=r,a=$u(),a.refCount++,r.pooledCache=a,a.refCount++,j.memoizedState={element:u,isDehydrated:i,cache:a},Uu(j),r}function W0(r){return r?(r=jl,r):jl}function Q0(r,a,i,u,b,j){b=W0(b),u.context===null?u.context=b:u.pendingContext=b,u=da(a),u.payload={element:i},j=j===void 0?null:j,j!==null&&(u.callback=j),i=ua(r,u,a),i!==null&&(Cr(i,r,a),Mi(i,r,a))}function J0(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var i=r.retryLane;r.retryLane=i!==0&&i<a?i:a}}function ih(r,a){J0(r,a),(r=r.alternate)&&J0(r,a)}function eb(r){if(r.tag===13||r.tag===31){var a=qa(r,67108864);a!==null&&Cr(a,r,67108864),ih(r,67108864)}}function tb(r){if(r.tag===13||r.tag===31){var a=$r();a=ze(a);var i=qa(r,a);i!==null&&Cr(i,r,a),ih(r,a)}}var Zc=!0;function _2(r,a,i,u){var b=A.T;A.T=null;var j=P.p;try{P.p=2,oh(r,a,i,u)}finally{P.p=j,A.T=b}}function M2(r,a,i,u){var b=A.T;A.T=null;var j=P.p;try{P.p=8,oh(r,a,i,u)}finally{P.p=j,A.T=b}}function oh(r,a,i,u){if(Zc){var b=ch(u);if(b===null)Xf(r,a,u,Wc,i),rb(r,u);else if(R2(b,r,a,i,u))u.stopPropagation();else if(rb(r,u),a&4&&-1<O2.indexOf(r)){for(;b!==null;){var j=nr(b);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var $=vt(j.pendingLanes);if($!==0){var Q=j;for(Q.pendingLanes|=2,Q.entangledLanes|=2;$;){var le=1<<31-St($);Q.entanglements[1]|=le,$&=~le}vs(j),(an&6)===0&&(Rc=yt()+500,Gi(0))}}break;case 31:case 13:Q=qa(j,2),Q!==null&&Cr(Q,j,2),Lc(),ih(j,2)}if(j=ch(u),j===null&&Xf(r,a,u,Wc,i),j===b)break;b=j}b!==null&&u.stopPropagation()}else Xf(r,a,u,null,i)}}function ch(r){return r=ut(r),dh(r)}var Wc=null;function dh(r){if(Wc=null,r=pr(r),r!==null){var a=d(r);if(a===null)r=null;else{var i=a.tag;if(i===13){if(r=c(a),r!==null)return r;r=null}else if(i===31){if(r=h(a),r!==null)return r;r=null}else if(i===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;r=null}else a!==r&&(r=null)}}return Wc=r,null}function nb(r){switch(r){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(Xt()){case we:return 2;case De:return 8;case Pe:case Ze:return 32;case mt:return 268435456;default:return 32}default:return 32}}var uh=!1,wa=null,Na=null,ka=null,eo=new Map,to=new Map,Sa=[],O2="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 rb(r,a){switch(r){case"focusin":case"focusout":wa=null;break;case"dragenter":case"dragleave":Na=null;break;case"mouseover":case"mouseout":ka=null;break;case"pointerover":case"pointerout":eo.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":to.delete(a.pointerId)}}function no(r,a,i,u,b,j){return r===null||r.nativeEvent!==j?(r={blockedOn:a,domEventName:i,eventSystemFlags:u,nativeEvent:j,targetContainers:[b]},a!==null&&(a=nr(a),a!==null&&eb(a)),r):(r.eventSystemFlags|=u,a=r.targetContainers,b!==null&&a.indexOf(b)===-1&&a.push(b),r)}function R2(r,a,i,u,b){switch(a){case"focusin":return wa=no(wa,r,a,i,u,b),!0;case"dragenter":return Na=no(Na,r,a,i,u,b),!0;case"mouseover":return ka=no(ka,r,a,i,u,b),!0;case"pointerover":var j=b.pointerId;return eo.set(j,no(eo.get(j)||null,r,a,i,u,b)),!0;case"gotpointercapture":return j=b.pointerId,to.set(j,no(to.get(j)||null,r,a,i,u,b)),!0}return!1}function sb(r){var a=pr(r.target);if(a!==null){var i=d(a);if(i!==null){if(a=i.tag,a===13){if(a=c(i),a!==null){r.blockedOn=a,Ct(r.priority,function(){tb(i)});return}}else if(a===31){if(a=h(i),a!==null){r.blockedOn=a,Ct(r.priority,function(){tb(i)});return}}else if(a===3&&i.stateNode.current.memoizedState.isDehydrated){r.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Qc(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var i=ch(r.nativeEvent);if(i===null){i=r.nativeEvent;var u=new i.constructor(i.type,i);Nt=u,i.target.dispatchEvent(u),Nt=null}else return a=nr(i),a!==null&&eb(a),r.blockedOn=i,!1;a.shift()}return!0}function ab(r,a,i){Qc(r)&&i.delete(a)}function D2(){uh=!1,wa!==null&&Qc(wa)&&(wa=null),Na!==null&&Qc(Na)&&(Na=null),ka!==null&&Qc(ka)&&(ka=null),eo.forEach(ab),to.forEach(ab)}function Jc(r,a){r.blockedOn===a&&(r.blockedOn=null,uh||(uh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,D2)))}var ed=null;function lb(r){ed!==r&&(ed=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ed===r&&(ed=null);for(var a=0;a<r.length;a+=3){var i=r[a],u=r[a+1],b=r[a+2];if(typeof u!="function"){if(dh(u||i)===null)continue;break}var j=nr(i);j!==null&&(r.splice(a,3),a-=3,cf(j,{pending:!0,data:b,method:i.method,action:u},u,b))}}))}function Fl(r){function a(le){return Jc(le,r)}wa!==null&&Jc(wa,r),Na!==null&&Jc(Na,r),ka!==null&&Jc(ka,r),eo.forEach(a),to.forEach(a);for(var i=0;i<Sa.length;i++){var u=Sa[i];u.blockedOn===r&&(u.blockedOn=null)}for(;0<Sa.length&&(i=Sa[0],i.blockedOn===null);)sb(i),i.blockedOn===null&&Sa.shift();if(i=(r.ownerDocument||r).$$reactFormReplay,i!=null)for(u=0;u<i.length;u+=3){var b=i[u],j=i[u+1],$=b[pt]||null;if(typeof j=="function")$||lb(i);else if($){var Q=null;if(j&&j.hasAttribute("formAction")){if(b=j,$=j[pt]||null)Q=$.formAction;else if(dh(b)!==null)continue}else Q=$.action;typeof Q=="function"?i[u+1]=Q:(i.splice(u,3),u-=3),lb(i)}}}function ib(){function r(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function($){return b=$})},focusReset:"manual",scroll:"manual"})}function a(){b!==null&&(b(),b=null),u||setTimeout(i,20)}function i(){if(!u&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,b=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(i,100),function(){u=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),b!==null&&(b(),b=null)}}}function fh(r){this._internalRoot=r}td.prototype.render=fh.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(l(409));var i=a.current,u=$r();Q0(i,u,r,a,null,null)},td.prototype.unmount=fh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;Q0(r.current,2,null,r,null,null),Lc(),a[on]=null}};function td(r){this._internalRoot=r}td.prototype.unstable_scheduleHydration=function(r){if(r){var a=lt();r={blockedOn:null,target:r,priority:a};for(var i=0;i<Sa.length&&a!==0&&a<Sa[i].priority;i++);Sa.splice(i,0,r),i===0&&sb(r)}};var ob=n.version;if(ob!=="19.2.4")throw Error(l(527,ob,"19.2.4"));P.findDOMNode=function(r){var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(l(188)):(r=Object.keys(r).join(","),Error(l(268,r)));return r=f(a),r=r!==null?g(r):null,r=r===null?null:r.stateNode,r};var L2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var nd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nd.isDisabled&&nd.supportsFiber)try{Ht=nd.inject(L2),Lt=nd}catch{}}return so.createRoot=function(r,a){if(!o(r))throw Error(l(299));var i=!1,u="",b=xp,j=gp,$=pp;return a!=null&&(a.unstable_strictMode===!0&&(i=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(b=a.onUncaughtError),a.onCaughtError!==void 0&&(j=a.onCaughtError),a.onRecoverableError!==void 0&&($=a.onRecoverableError)),a=Z0(r,1,!1,null,null,i,u,null,b,j,$,ib),r[on]=a.current,Gf(r),new fh(a)},so.hydrateRoot=function(r,a,i){if(!o(r))throw Error(l(299));var u=!1,b="",j=xp,$=gp,Q=pp,le=null;return i!=null&&(i.unstable_strictMode===!0&&(u=!0),i.identifierPrefix!==void 0&&(b=i.identifierPrefix),i.onUncaughtError!==void 0&&(j=i.onUncaughtError),i.onCaughtError!==void 0&&($=i.onCaughtError),i.onRecoverableError!==void 0&&(Q=i.onRecoverableError),i.formState!==void 0&&(le=i.formState)),a=Z0(r,1,!0,a,i??null,u,b,le,j,$,Q,ib),a.context=W0(null),i=a.current,u=$r(),u=ze(u),b=da(u),b.callback=null,ua(i,b,u),i=u,a.current.lanes=i,Mt(a,i),vs(a),r[on]=a.current,Gf(r),new td(a)},so.version="19.2.4",so}var bb;function F2(){if(bb)return xh.exports;bb=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(n){console.error(n)}}return e(),xh.exports=V2(),xh.exports}var Y2=F2();const ge={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",REPORTS:"reports",SETTINGS:"settings"},G2=new Set(Object.values(ge)),X2={dashboard:ge.HOME,overview:ge.HOME,chat:ge.TEAM,projects:ge.WORK,tasks:ge.WORK,usage:ge.REPORTS,prompts:ge.BUILDER,templates:ge.STORE,agents:ge.STORE,skills:ge.STORE,teams:ge.STORE,knowledge:ge.DELIVERABLES,governance:ge.SETTINGS};function Ia(e){return G2.has(e)?e:X2[e]??ge.HOME}function rd(){const e=window.location.hash.slice(1).split("/")[0];return Ia(e)}function im(e,n){return n?`#${e}/${n}`:`#${e}`}const K2={[ge.STORE]:ge.BUILDER,[ge.REPORTS]:ge.SETTINGS},Wl={[ge.HOME]:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",[ge.WORK]:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",[ge.TEAM]:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",[ge.REPORTS]:"M18 20V10 M12 20V4 M6 20v-6",[ge.DELIVERABLES]:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z",[ge.BUILDER]:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",[ge.STORE]:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",[ge.SETTINGS]:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"},Z2=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],W2=[{id:ge.HOME,label:"Home",section:"workspace"},{id:ge.TEAM,label:"Team",section:"workspace"},{id:ge.DELIVERABLES,label:"Deliverables",section:"workspace"},{id:ge.BUILDER,label:"Builder",section:"build"},{id:ge.STORE,label:"Store",section:"build"},{id:ge.REPORTS,label:"Reports",section:"system"},{id:ge.SETTINGS,label:"Settings",section:"system"}],Q2=[{id:ge.HOME,label:"Home",group:[ge.HOME]},{id:ge.TEAM,label:"Team",group:[ge.TEAM]},{id:ge.WORK,label:"Work",group:[ge.WORK]},{id:ge.DELIVERABLES,label:"Deliverables",group:[ge.DELIVERABLES]},{id:ge.BUILDER,label:"Builder",group:[ge.BUILDER,ge.STORE]},{id:ge.SETTINGS,label:"Settings",group:[ge.SETTINGS,ge.REPORTS]}],u1="/api";async function fe(e,n){const s=await fetch(`${u1}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...n,body:n?.body?typeof n.body=="string"?n.body:JSON.stringify(n.body):void 0});if(!s.ok){let l="";try{const o=await s.json();l=o.error??o.message??""}catch{}throw new Error(l||`API error: ${s.status}`)}return s.json()}const re={agents:{list:()=>fe("/agents"),get:e=>fe(`/agents/${e}`),create:(e,n,s,l)=>fe("/agents",{method:"POST",body:JSON.stringify({name:e,roleName:n,agentRole:s,teamId:l})}),start:e=>fe(`/agents/${e}/start`,{method:"POST"}),stop:e=>fe(`/agents/${e}/stop`,{method:"POST"}),remove:(e,n)=>fe(`/agents/${e}${n?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,n)=>fe(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(n)}),getMemory:e=>fe(`/agents/${e}/memory`),getMemorySession:(e,n)=>fe(`/agents/${e}/memory/sessions/${encodeURIComponent(n)}`),updateDailyMemory:(e,n)=>fe(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:n})}),updateLongTermMemory:(e,n,s)=>fe(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:n,content:s})}),getFiles:e=>fe(`/agents/${e}/files`),getFilesMap:e=>fe(`/agents/${e}/files`),updateFile:(e,n,s)=>fe(`/agents/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,n)=>fe(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:n})}),roleStatus:e=>fe(`/agents/${e}/role-status`),roleDiff:(e,n="ROLE.md")=>fe(`/agents/${e}/role-diff?file=${encodeURIComponent(n)}`),roleSync:(e,n)=>fe(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(n?{files:n}:{})}),roleUpdates:()=>fe("/agents/role-updates"),addSkill:(e,n)=>fe(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:n})}),removeSkill:(e,n)=>fe(`/agents/${e}/skills/${encodeURIComponent(n)}`,{method:"DELETE"}),getHeartbeat:e=>fe(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>fe(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),getRecentActivities:e=>fe(`/agents/${e}/recent-activities`),getActivityLogs:(e,n)=>fe(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(n)}`),getActivities:(e,n)=>{const s=new URLSearchParams;n?.type&&s.set("type",n.type),n?.limit&&s.set("limit",String(n.limit)),n?.before&&s.set("before",n.before);const l=s.toString();return fe(`/agents/${e}/activities${l?"?"+l:""}`)},getMindState:e=>fe(`/agents/${e}/mind`),getMailbox:(e,n)=>{const s=new URLSearchParams;n?.limit&&s.set("limit",String(n.limit)),n?.offset&&s.set("offset",String(n.offset)),n?.category&&s.set("category",n.category),n?.sourceType&&s.set("sourceType",n.sourceType);const l=s.toString();return fe(`/agents/${e}/mailbox${l?"?"+l:""}`)},getDecisions:(e,n=50)=>fe(`/agents/${e}/decisions?limit=${n}`),message:(e,n,s,l)=>fe(`/agents/${e}/message`,{method:"POST",body:JSON.stringify({text:n,images:s,sessionId:l??void 0})}),messageStream:(e,n,s,l,o,d,c)=>new Promise(async(h,m)=>{let f="",g;try{const x=await fetch(`${u1}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:n,stream:!0,images:d,sessionId:c??void 0}),signal:o});if(!x.ok){m(new Error(`API error: ${x.status}`));return}const p=x.body?.getReader();if(!p){m(new Error("No reader"));return}const y=new TextDecoder;let w="";for(;;){const{done:N,value:C}=await p.read();if(N)break;w+=y.decode(C,{stream:!0});const _=w.split(`
10
- `);w=_.pop()??"";for(const O of _){const k=O.trim();if(k.startsWith("data: "))try{const S=JSON.parse(k.slice(6));if(S.type==="text_delta"&&S.text)f+=S.text,s(S.text);else if(S.type==="thinking_delta"&&S.thinking)s?.(`<think>${S.thinking}</think>`);else if(S.type==="done")f=S.content??f,S.sessionId&&(g=S.sessionId);else if(S.type==="error"){const R=S;R.sessionId&&(g=R.sessionId);const D=new Error(R.message??R.error??"Unknown stream error");D.sessionId=R.sessionId,m(D),p.cancel().catch(()=>{});return}else S.type==="tool_call_start"&&S.toolCall?.name?l?.({tool:S.toolCall.name,phase:"start"}):S.type==="agent_tool"&&S.tool&&S.phase?S.phase==="start"?l?.({tool:S.tool,phase:"start",arguments:S.arguments}):S.phase==="end"&&l?.({tool:S.tool,phase:"end",success:S.success,arguments:S.arguments,result:S.result,error:S.error,durationMs:S.durationMs}):S.type==="tool_output"&&S.tool?l?.({tool:S.tool,phase:"output",output:S.text}):S.type==="subagent_progress"&&S.tool&&l?.({tool:S.tool,phase:"subagent_progress",subagentEvent:S.subagentEvent})}catch{}}}h({content:f,sessionId:g})}catch(x){x instanceof Error&&x.name==="AbortError"?h({content:f,sessionId:g}):m(x)}})},roles:{list:()=>fe("/roles")},teams:{list:e=>fe(`/teams?orgId=${e??"default"}`),create:(e,n)=>fe("/teams",{method:"POST",body:JSON.stringify({name:e,description:n})}),update:(e,n)=>fe(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(n)}),delete:(e,n,s)=>fe(`/teams/${e}?deleteMembers=${n?"true":"false"}${s?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,n,s)=>fe(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:n,memberType:s})}),removeMember:(e,n)=>fe(`/teams/${e}/members/${n}`,{method:"DELETE"}),startAll:e=>fe(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>fe(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,n)=>fe(`/teams/${e}/pause`,{method:"POST",body:JSON.stringify({reason:n})}),resumeAll:e=>fe(`/teams/${e}/resume`,{method:"POST"}),status:e=>fe(`/teams/${e}/status`),getFiles:e=>fe(`/teams/${e}/files`),getFile:(e,n)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`),updateFile:(e,n,s)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),exportTeam:e=>fe(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>fe(`/teams/${e}/export`)},externalAgents:{list:e=>fe(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const n=new URLSearchParams;e?.assignedAgentId&&n.set("assignedAgentId",e.assignedAgentId),e?.status&&n.set("status",e.status),e?.projectId&&n.set("projectId",e.projectId),e?.requirementId&&n.set("requirementId",e.requirementId),e?.priority&&n.set("priority",e.priority),e?.search&&n.set("search",e.search),e?.sortBy&&n.set("sortBy",e.sortBy),e?.sortOrder&&n.set("sortOrder",e.sortOrder),e?.page!==null&&e?.page!==void 0&&n.set("page",String(e.page)),e?.pageSize!==null&&e?.pageSize!==void 0&&n.set("pageSize",String(e.pageSize));const s=n.toString();return fe(`/tasks${s?`?${s}`:""}`)},get:e=>fe(`/tasks/${e}`),create:(e,n,s,l,o,d,c,h,m,f)=>fe("/tasks",{method:"POST",body:JSON.stringify({title:e,description:n,assignedAgentId:s,reviewerAgentId:l,priority:o,projectId:d,blockedBy:c,requirementId:h,taskType:m,scheduleConfig:f})}),update:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:n})}),assign:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:n})}),approve:e=>fe(`/tasks/${e}/approve`,{method:"POST"}),reject:e=>fe(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,n=!1)=>fe(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:n})}),getDependentCount:e=>fe(`/tasks/${e}/dependents`),board:e=>{const n=new URLSearchParams;e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return fe(`/taskboard${s?`?${s}`:""}`)},listSubtasks:e=>fe(`/tasks/${e}/subtasks`),createSubtask:(e,n)=>fe(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:n})}),completeSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}/complete`,{method:"POST"}),cancelSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}/cancel`,{method:"POST"}),deleteSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}`,{method:"DELETE"}),run:e=>fe(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,n)=>fe(`/tasks/${e}/logs${n!=null?`?round=${n}`:""}`),getLogsSummary:e=>fe(`/tasks/${e}/logs/summary`),accept:(e,n)=>fe(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerAgentId:n??"human"})}),revision:(e,n,s)=>fe(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:n,reviewerAgentId:s??"human"})}),archive:e=>fe(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>fe(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>fe(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>fe(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>fe(`/tasks/${e}/comments`),addComment:(e,n,s,l,o,d,c)=>fe(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:o??"human",authorName:s??"User",authorType:"human",attachments:l,mentions:d,replyTo:c})}),pauseSchedule:e=>fe(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>fe(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>fe(`/tasks/${e}/schedule/run-now`,{method:"POST"}),deliverables:e=>{const n=e?`?projectId=${encodeURIComponent(e)}`:"";return fe(`/tasks/deliverables${n}`)}},files:{preview:e=>fe(`/files/preview?path=${encodeURIComponent(e)}`),reveal:e=>fe("/files/reveal",{method:"POST",body:JSON.stringify({path:e})})},requirements:{list:e=>{const n=new URLSearchParams;e?.orgId&&n.set("orgId",e.orgId),e?.status&&n.set("status",e.status),e?.source&&n.set("source",e.source),e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return fe(`/requirements${s?`?${s}`:""}`)},get:e=>fe(`/requirements/${e}`),create:e=>fe("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>fe(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:n})}),approve:e=>fe(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,n)=>fe(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:n})}),cancel:e=>fe(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>fe(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>fe(`/requirements/${e}/comments`),addComment:(e,n,s,l,o,d)=>fe(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:l??"human",authorName:s??"User",authorType:"human",mentions:o,replyTo:d})})},users:{list:e=>fe(`/users?orgId=${e??"default"}`),create:(e,n,s,l,o,d)=>fe("/users",{method:"POST",body:JSON.stringify({name:e,role:n,orgId:s,email:l,password:o,teamId:d})}),remove:e=>fe(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const n=e?`?q=${encodeURIComponent(e)}`:"";return fe(`/team-templates${n}`)},get:e=>fe(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>fe(`/ops/dashboard?period=${e}`)},agentMetrics:(e,n="24h")=>fe(`/agents/${e}/metrics?period=${n}`),usage:{summary:(e="default",n)=>{const s=new URLSearchParams({orgId:e});return n&&s.set("period",n),fe(`/usage?${s}`)},agents:(e="default")=>fe(`/usage/agents?orgId=${e}`)},health:()=>fe("/health"),system:{openPath:e=>fe("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>fe("/system/storage"),orphans:()=>fe("/system/storage/orphans"),purgeOrphans:e=>fe("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},settings:{getLlm:()=>fe("/settings/llm"),getAgent:()=>fe("/settings/agent"),updateAgent:e=>fe("/settings/agent",{method:"POST",body:JSON.stringify(e)})},skills:{list:()=>fe("/skills"),builtin:()=>fe("/skills/builtin"),registry:e=>fe(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const n=new URLSearchParams;e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit)),e?.sort&&n.set("sort",e.sort);const s=n.toString();return fe(`/skills/registry/skillhub${s?`?${s}`:""}`)},registrySkillssh:e=>fe(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,n,s,l)=>fe("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:n,description:s,category:l})}),install:e=>fe("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>fe(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>fe(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>fe("/builder/artifacts"),get:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`),save:(e,n)=>fe("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:n})}),import:(e,n,s,l)=>fe("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:n,files:s,source:l})}),install:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/install`,{method:"POST"}),uninstall:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/uninstall`,{method:"POST"}),delete:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`,{method:"DELETE"}),installed:()=>fe("/builder/artifacts/installed")}},auth:{login:(e,n)=>fe("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})}),logout:()=>fe("/auth/logout",{method:"POST"}),me:()=>fe("/auth/me"),changePassword:(e,n)=>fe("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:n})})},sessions:{listByAgent:(e,n=20)=>fe(`/agents/${e}/sessions?limit=${n}`),getMessages:(e,n=50,s)=>fe(`/sessions/${e}/messages?limit=${n}${s?`&before=${s}`:""}`),delete:e=>fe(`/sessions/${e}`,{method:"DELETE"})},channels:{getMessages:(e,n=50,s)=>fe(`/channels/${encodeURIComponent(e)}/messages?limit=${n}${s?`&before=${s}`:""}`),sendMessage:(e,n)=>fe(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})},governance:{getSystemStatus:()=>fe("/system/status"),pauseAll:e=>fe("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>fe("/system/resume-all",{method:"POST"}),emergencyStop:e=>fe("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>fe("/system/announcements"),createAnnouncement:e=>fe("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>fe("/governance/policy"),setPolicy:e=>fe("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const n=e?`?status=${e}`:"";return fe(`/approvals${n}`)},respond:(e,n,s)=>fe(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:n,respondedBy:s})})},notifications:{list:(e,n,s)=>{const l=new URLSearchParams;return e&&l.set("userId",e),n&&l.set("unread","true"),s?.type&&l.set("type",s.type),s?.limit&&l.set("limit",String(s.limit)),s?.offset&&l.set("offset",String(s.offset)),fe(`/notifications?${l}`)},markRead:e=>fe(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>fe("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},projects:{list:e=>{const n=e?`?orgId=${e}`:"";return fe(`/projects${n}`)},get:e=>fe(`/projects/${e}`),create:e=>fe("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/projects/${e}`,{method:"PUT",body:JSON.stringify(n)}),delete:e=>fe(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,n,s)=>{const l=new URLSearchParams;return e&&l.set("query",e),n&&l.set("scope",n),s&&l.set("category",s),fe(`/knowledge/search?${l}`)},contribute:e=>fe("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,n)=>fe(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:n})}),verify:e=>fe(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>fe(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const n=new URLSearchParams;return e?.q&&n.set("q",e.q),e?.projectId&&n.set("projectId",e.projectId),e?.agentId&&n.set("agentId",e.agentId),e?.taskId&&n.set("taskId",e.taskId),e?.type&&n.set("type",e.type),e?.status&&n.set("status",e.status),e?.artifactType&&n.set("artifactType",e.artifactType),e?.offset&&n.set("offset",String(e.offset)),e?.limit&&n.set("limit",String(e.limit)),fe(`/deliverables?${n}`)},create:e=>fe("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(n)}),remove:e=>fe(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})})},codeReviews:{list:(e,n=20)=>{const s=new URLSearchParams;return e&&s.set("taskId",e),s.set("limit",String(n)),fe(`/reviews?${s}`)},get:e=>fe(`/reviews/${e}`),run:e=>fe("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>fe("/reports"),get:e=>fe(`/reports/${e}`),generate:e=>fe("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,n)=>fe(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(n)}),rejectPlan:(e,n)=>fe(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(n)}),addFeedback:(e,n)=>fe(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(n)}),getFeedback:e=>fe(`/reports/${e}/feedback`)},executionLogs:{get:(e,n)=>fe(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(n)}`)}};function om(e){return{id:e.id,sourceType:"task",sourceId:e.taskId,agentId:e.agentId,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,executionRound:e.executionRound,createdAt:e.createdAt}}function J2(e,n,s){return e.type==="llm_request"?null:{id:`alog_${n}_${e.seq}`,sourceType:"activity",sourceId:n,agentId:s,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class ek{ws=null;handlers=new Map;reconnectTimer=null;intentionalClose=!1;connect(){if(this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))return;this.intentionalClose=!1;const s=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`,l=new WebSocket(s);this.ws=l,l.onmessage=o=>{if(this.ws===l)try{const d=JSON.parse(o.data),c=this.handlers.get(d.type);if(c)for(const m of c)m(d);const h=this.handlers.get("*");if(h)for(const m of h)m(d)}catch{}},l.onclose=()=>{this.intentionalClose||(this.reconnectTimer=setTimeout(()=>this.connect(),3e3))},l.onerror=()=>{l.close()}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(n,s){return this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n).add(s),()=>this.handlers.get(n)?.delete(s)}}const xn=new ek;let Eo=window.__MARKUS_HUB_URL__??"https://markus.global";fe("/settings/hub").then(e=>{e.hubUrl&&(Eo=e.hubUrl);const n=localStorage.getItem("markus_hub_token");n&&fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:n})}).catch(()=>{})}).catch(()=>{});const Vm="markus_hub_token",Fm="markus_hub_user";function Da(){return localStorage.getItem(Vm)}function tk(){try{const e=localStorage.getItem(Fm);return e?JSON.parse(e):null}catch{return null}}function f1(){localStorage.removeItem(Vm),localStorage.removeItem(Fm),h1(null)}function cm(e,n){localStorage.setItem(Vm,e),localStorage.setItem(Fm,JSON.stringify(n)),h1(e)}function h1(e){fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}let ao=null;function Ea(){if(Da())return Promise.resolve();if(ao)return ao;const e=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`;return ao=new Promise((n,s)=>{const l=`${Eo}/auth/connect?session=${encodeURIComponent(e)}`,o=460,d=580,c=Math.round(window.screenX+(window.outerWidth-o)/2),h=Math.round(window.screenY+(window.outerHeight-d)/2),m=window.open(l,"markus_hub_auth",`popup=yes,width=${o},height=${d},left=${c},top=${h}`);let f=!1;const g=()=>{clearInterval(x),clearInterval(p),ao=null},x=setInterval(async()=>{if(!f)try{const w=await(await fetch(`${Eo}/api/auth/connect-status?session=${encodeURIComponent(e)}`)).json();w.ready&&w.token&&w.user&&(f=!0,cm(w.token,w.user),g(),m?.close(),n())}catch{}},1500),p=setInterval(()=>{f||m?.closed&&(f=!0,g(),Da()?n():s(new Error("Hub login cancelled")))},500)}),ao}async function ns(e,n){const s=Da(),l={"Content-Type":"application/json",...n?.headers};s&&(l.Authorization=`Bearer ${s}`);const o=await fetch(`${Eo}/api${e}`,{...n,headers:l}),d=await o.json();if(o.status===401&&s&&f1(),!o.ok)throw new Error(d.error??`Hub HTTP ${o.status}`);return d}const Xn={getUrl:()=>Eo,isAuthenticated:()=>!!Da(),getUser:tk,logout:()=>{f1()},ensureAuth:Ea,login:async(e,n)=>{const s=await ns("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})});return cm(s.token,s.user),s},register:async(e,n,s)=>{const l=await ns("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:n,password:s})});return cm(l.token,l.user),l},search:e=>{const n=new URLSearchParams;e?.type&&n.set("type",e.type),e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.sort&&n.set("sort",e.sort),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit));const s=n.toString();return ns(`/items${s?`?${s}`:""}`)},getItem:e=>ns(`/items/${e}`),download:async e=>{await Ea();try{return await ns(`/items/${e}/download`,{method:"POST"})}catch(n){if(!Da())return await Ea(),ns(`/items/${e}/download`,{method:"POST"});throw n}},publish:async e=>{await Ea();try{return await ns("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!Da())return await Ea(),ns("/items",{method:"POST",body:JSON.stringify(e)});throw n}},publishViaProxy:async e=>{await Ea();try{return await ns("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!Da())return await Ea(),ns("/items",{method:"POST",body:JSON.stringify(e)});throw n}},myItems:async()=>Da()?ns("/items/mine"):{items:[]},deleteItem:async e=>(await Ea(),ns(`/items/${e}`,{method:"DELETE"}))};let yb=null;const gt={setHandler(e){yb=e},navigate(e,n){n&&Object.entries(n).forEach(([s,l])=>localStorage.setItem(`markus_nav_${s}`,l)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:n}})),yb?.(e,n)}};function vb(){const[e,n]=v.useState([]),[s,l]=v.useState([]),[o,d]=v.useState({}),[c,h]=v.useState(null),m="7d",[f,g]=v.useState([]),[x,p]=v.useState(null),y=()=>{re.agents.list().then(z=>n(z.agents)).catch(()=>{}),re.teams.list().then(z=>l(z.teams)).catch(()=>{}),re.tasks.board().then(z=>d(z.board)).catch(()=>{}),re.ops.dashboard(m).then(h).catch(()=>{}),re.requirements.list({source:"agent"}).then(z=>{g(z.requirements.filter(K=>K.status==="pending"))}).catch(()=>{}),re.system.storage().then(p).catch(()=>{})};v.useEffect(()=>{y();const z=setInterval(y,3e4),K=()=>y();return window.addEventListener("markus:data-changed",K),()=>{clearInterval(z),window.removeEventListener("markus:data-changed",K)}},[m]);const w=z=>z,N={};for(const[z,K]of Object.entries(o)){const U=w(K).length;U>0&&(N[z]=U)}const C=N.pending??0,_=N.in_progress??0,O=N.completed??0;N.failed;const k=Object.values(N).reduce((z,K)=>z+K,0),S=e.filter(z=>z.status==="idle"||z.status==="working").length,R=e.filter(z=>z.status==="working").length,D=e.reduce((z,K)=>z+(K.mailboxDepth??0),0),Y=v.useMemo(()=>{const z=new Map(e.map(K=>[K.id,K]));return s.map(K=>{const U=K.members.filter(E=>E.type==="agent").map(E=>z.get(E.id)).filter(E=>!!E),G=U.filter(E=>E.status==="working").length,V=U.filter(E=>E.status==="idle"||E.status==="working").length;return{team:K,agents:U,working:G,active:V,total:U.length}})},[s,e]);return t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between px-6 h-14 border-b border-border-default bg-surface-secondary",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Overview"}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:()=>gt.navigate(ge.STORE,{storeTab:"agents"}),className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-lg transition-colors",children:"+ Hire Agent"})})]}),t.jsxs("div",{className:"p-7 space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(sd,{label:"Active Agents",value:S,total:e.length,color:"indigo",onClick:()=>gt.navigate(ge.TEAM)}),t.jsx(sd,{label:"Tasks In Progress",value:_,color:"blue",onClick:()=>gt.navigate(ge.WORK)}),t.jsx(sd,{label:"Pending Queue",value:C,color:"amber",onClick:()=>gt.navigate(ge.WORK)}),t.jsx(sd,{label:"Completed",value:O,total:k>0?k:void 0,color:"green",onClick:()=>gt.navigate(ge.WORK)})]}),k===0&&(!c||c.taskKPI.recentActivity.length===0)&&t.jsxs("div",{className:"bg-surface-secondary border border-brand-500/20 rounded-xl p-6",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:"Your AI workforce is ready"}),t.jsx("p",{className:"text-xs text-fg-secondary mb-4",children:"Get started in under a minute — describe what you need and let your team take it from here."}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[{label:"Describe Your Goal",desc:"Chat with the Secretary — it will assemble a team and break down tasks",page:ge.TEAM},{label:"Hire Agents",desc:"Browse templates: developers, researchers, writers, analysts, and more",page:ge.STORE},{label:"Create a Project",desc:"Set up requirements and let agents plan, execute, and deliver",page:ge.WORK}].map(z=>t.jsxs("button",{onClick:()=>gt.navigate(z.page),className:"text-left bg-surface-elevated/50 hover:bg-surface-elevated border border-border-default/50 hover:border-brand-500/30 rounded-lg p-4 transition-colors",children:[t.jsx("div",{className:"text-xs font-medium text-fg-primary",children:z.label}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1",children:z.desc})]},z.label))})]}),R>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Agent Focus"}),D>0&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[D," total queued"]})]}),t.jsx("div",{className:"space-y-1.5",children:e.filter(z=>z.status==="working").map(z=>t.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer transition-colors",onClick:()=>gt.navigate(ge.TEAM,{agentId:z.id,profileTab:"mind"}),children:[t.jsx("div",{className:"w-5 h-5 rounded-full bg-brand-600/30 flex items-center justify-center text-[9px] font-bold text-brand-400 shrink-0",children:z.name.charAt(0)}),t.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:z.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate flex-1",children:z.currentActivity?.label??"Working..."}),(z.mailboxDepth??0)>0&&t.jsxs("span",{className:"text-[9px] bg-amber-500/20 text-amber-400 rounded-full px-1.5 shrink-0",children:[z.mailboxDepth," queued"]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${z.attentionState==="focused"?"bg-brand-400 animate-pulse":z.attentionState==="deciding"?"bg-amber-400 animate-pulse":"bg-green-400"}`})]},z.id))})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[k>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 cursor-pointer hover:border-gray-600 transition-colors",onClick:()=>gt.navigate(ge.WORK),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"Task Distribution"}),t.jsx(rk,{statusCounts:N,total:k}),(N.blocked??0)>0&&t.jsxs("div",{className:"mt-3 text-xs text-amber-600 flex items-center gap-1.5",children:[t.jsx("span",{className:"w-1.5 h-1.5 bg-amber-400 rounded-full"}),N.blocked," blocked — needs attention"]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Team Status"}),t.jsx("button",{onClick:()=>gt.navigate(ge.TEAM),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),Y.length===0&&e.length===0?t.jsx("div",{className:"text-sm text-fg-tertiary py-4 text-center cursor-pointer",onClick:()=>gt.navigate(ge.TEAM),children:"No teams yet. Create a team or hire agents to get started."}):t.jsxs("div",{className:"space-y-4",children:[Y.map(z=>t.jsxs("div",{className:"bg-surface-elevated/30 border border-border-default/30 rounded-lg p-4 hover:border-brand-500/20 transition-colors cursor-pointer",onClick:()=>gt.navigate(ge.TEAM),children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-600/30 flex items-center justify-center text-xs font-bold text-brand-500",children:z.team.name.charAt(0)}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:z.team.name}),z.team.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate max-w-[200px]",children:z.team.description})]})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[t.jsxs("span",{children:[z.total," members"]}),z.working>0&&t.jsxs("span",{className:"text-brand-500",children:[z.working," working"]}),t.jsxs("span",{className:z.active===z.total?"text-green-600":"",children:[z.active," active"]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[z.agents.slice(0,6).map(K=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30",onClick:U=>{U.stopPropagation(),gt.navigate(ge.TEAM,{selectAgent:K.id})},children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${K.status==="idle"?"bg-green-400":K.status==="working"?"bg-brand-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:K.name})]},K.id)),z.agents.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",z.agents.length-6," more"]})]})]},z.team.id)),(()=>{const z=new Set(s.flatMap(U=>U.members.filter(G=>G.type==="agent").map(G=>G.id))),K=e.filter(U=>!z.has(U.id));return K.length===0?null:t.jsxs("div",{className:"bg-surface-elevated/20 border border-border-default/20 rounded-lg p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:"Unassigned Agents"}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[K.length," agents"]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[K.slice(0,6).map(U=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30 cursor-pointer",onClick:()=>gt.navigate(ge.TEAM,{selectAgent:U.id}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${U.status==="idle"?"bg-green-400":U.status==="working"?"bg-brand-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:U.name})]},U.id)),K.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",K.length-6," more"]})]})]})})()]})]})]}),t.jsxs("div",{className:"space-y-6",children:[f.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-amber-500/30 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse"}),t.jsx("h3",{className:"text-xs font-semibold text-amber-600 uppercase tracking-wider",children:"Pending Reviews"})]}),t.jsx("button",{onClick:()=>gt.navigate(ge.WORK),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"Review →"})]}),t.jsxs("div",{className:"space-y-2",children:[f.slice(0,5).map(z=>t.jsxs("div",{className:"flex items-start gap-2.5 py-2 px-2.5 rounded-lg bg-surface-elevated/40 hover:bg-surface-elevated/60 transition-colors cursor-pointer",onClick:()=>gt.navigate(ge.WORK),children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:z.title}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:["proposed by ",z.createdBy," · ",z.priority]})]}),t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded-full shrink-0",children:z.source==="agent"?"Agent":"User"})]},z.id)),f.length>5&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary text-center pt-1",children:["+",f.length-5," more"]})]}),t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-3",children:["Agents proposed ",f.length," requirement",f.length>1?"s":""," — review to authorize work."]})]}),c&&c.taskKPI.recentActivity.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Recent Activity"}),t.jsx("button",{onClick:()=>gt.navigate(ge.WORK),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:c.taskKPI.recentActivity.slice(0,8).map(z=>t.jsxs("div",{className:"flex items-center gap-2.5 py-1.5 px-2 rounded-lg hover:bg-surface-elevated/40 transition-colors cursor-pointer",onClick:()=>gt.navigate(ge.WORK,{openTask:z.taskId}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${dm[z.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:z.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(z.updatedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},z.taskId))})]}),c&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"System Health"}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(lo,{label:"Health Score",value:c.systemHealth.overallScore,max:100,unit:"%",color:c.systemHealth.overallScore>=80?"green":c.systemHealth.overallScore>=50?"amber":"red"}),t.jsx(lo,{label:"Success Rate",value:c.taskKPI.successRate,max:100,unit:"%",color:c.taskKPI.successRate>=80?"green":"amber"}),t.jsx(lo,{label:"Active / Total",value:S,max:e.length||1,unit:`/${e.length}`,color:"brand"}),t.jsx(lo,{label:"Token Cost",value:parseFloat(c.systemHealth.totalTokenCost.toFixed(2)),max:Math.max(1,Math.ceil(c.systemHealth.totalTokenCost*2)),unit:"$",color:"brand",raw:!0}),t.jsx(lo,{label:"Working Now",value:R,max:e.length||1,unit:`/${e.length}`,color:"blue"})]}),c.systemHealth.criticalAgents.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500 flex-wrap",children:[t.jsx("span",{className:"w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Needs attention:",c.systemHealth.criticalAgents.map(z=>t.jsxs("span",{className:"px-2 py-0.5 bg-red-500/10 rounded text-red-500 cursor-pointer hover:bg-red-500/20",onClick:()=>gt.navigate(ge.TEAM,{selectAgent:z.id}),children:[z.name," (",z.score,"%)"]},z.id))]})})]}),x&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>gt.navigate(ge.SETTINGS),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:"Storage"}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-2xl font-bold text-fg-primary",children:jb(x.totalSize)}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:"total"})]}),t.jsxs("div",{className:"mt-2 flex gap-4 text-xs text-fg-tertiary",children:[t.jsxs("span",{children:["DB: ",jb(x.database.size)]}),t.jsxs("span",{children:["Agents: ",x.agents.length]})]}),t.jsx("div",{className:"mt-2 text-[10px] text-fg-tertiary",children:"Click to view details in Settings"})]})]})]})]})]})}const dm={pending:"bg-amber-500",in_progress:"bg-brand-500",blocked:"bg-red-500",review:"bg-blue-500",completed:"bg-green-500",failed:"bg-red-500",rejected:"bg-red-500",cancelled:"bg-gray-600"},nk={pending:"text-amber-600",in_progress:"text-brand-500",blocked:"text-red-500",review:"text-blue-600",completed:"text-green-600",failed:"text-red-500",rejected:"text-red-500",cancelled:"text-fg-tertiary"};function rk({statusCounts:e,total:n}){const s=Object.entries(e).filter(([,l])=>l>0).sort(([,l],[,o])=>o-l);return t.jsxs("div",{children:[t.jsx("div",{className:"flex h-4 rounded-full overflow-hidden gap-0.5 mb-4",children:s.map(([l,o])=>t.jsx("div",{className:`${dm[l]??"bg-gray-600"} transition-all`,style:{width:`${o/n*100}%`},title:`${l}: ${o}`},l))}),t.jsx("div",{className:"flex gap-4 flex-wrap",children:s.map(([l,o])=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-sm ${dm[l]??"bg-gray-600"}`}),t.jsx("span",{className:"text-xs text-fg-secondary capitalize",children:l.replace(/_/g," ")}),t.jsx("span",{className:`text-xs font-semibold ${nk[l]??"text-fg-secondary"}`,children:o})]},l))})]})}function sd({label:e,value:n,total:s,color:l,onClick:o}){const d={indigo:{text:"text-brand-500",border:"border-l-brand-500"},blue:{text:"text-blue-600",border:"border-l-blue-500"},amber:{text:"text-amber-600",border:"border-l-amber-500"},green:{text:"text-green-600",border:"border-l-green-500"}},c=d[l]??d.indigo;return t.jsxs("div",{onClick:o,className:`bg-surface-secondary border border-border-default ${c.border} border-l-2 rounded-xl p-5 cursor-pointer hover:bg-surface-elevated transition-all`,children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2",children:e}),t.jsxs("div",{className:`text-3xl font-bold ${c.text}`,children:[n,s!==void 0&&t.jsxs("span",{className:"text-base font-normal text-fg-muted",children:["/",s]})]})]})}function lo({label:e,value:n,max:s,unit:l,color:o,raw:d}){const c=s>0?Math.min(n/s*100,100):0,h={green:"bg-green-400",amber:"bg-amber-400",red:"bg-red-400",brand:"bg-brand-400",blue:"bg-blue-400"},m={green:"text-green-600",amber:"text-amber-600",red:"text-red-500",brand:"text-brand-500",blue:"text-blue-600"},f=h[o]??"bg-gray-400",g=m[o]??"text-fg-secondary";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-sm font-semibold ${g}`,children:d?`${l}${n}`:t.jsxs(t.Fragment,{children:[n,t.jsx("span",{className:"text-[10px] font-normal text-fg-tertiary",children:l})]})})]}),t.jsx("div",{className:"w-full h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${f} transition-all`,style:{width:`${c}%`}})})]})}function jb(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${n[s]}`}function sk(e,n){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const ak=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ik={};function wb(e,n){return(ik.jsx?lk:ak).test(e)}const ok=/[ \t\n\f\r]/g;function ck(e){return typeof e=="object"?e.type==="text"?Nb(e.value):!1:Nb(e)}function Nb(e){return e.replace(ok,"")===""}class Uo{constructor(n,s,l){this.normal=s,this.property=n,l&&(this.space=l)}}Uo.prototype.normal={};Uo.prototype.property={};Uo.prototype.space=void 0;function m1(e,n){const s={},l={};for(const o of e)Object.assign(s,o.property),Object.assign(l,o.normal);return new Uo(s,l,n)}function um(e){return e.toLowerCase()}class _r{constructor(n,s){this.attribute=s,this.property=n}}_r.prototype.attribute="";_r.prototype.booleanish=!1;_r.prototype.boolean=!1;_r.prototype.commaOrSpaceSeparated=!1;_r.prototype.commaSeparated=!1;_r.prototype.defined=!1;_r.prototype.mustUseProperty=!1;_r.prototype.number=!1;_r.prototype.overloadedBoolean=!1;_r.prototype.property="";_r.prototype.spaceSeparated=!1;_r.prototype.space=void 0;let dk=0;const Bt=gl(),Gn=gl(),fm=gl(),He=gl(),wn=gl(),ri=gl(),Br=gl();function gl(){return 2**++dk}const hm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Bt,booleanish:Gn,commaOrSpaceSeparated:Br,commaSeparated:ri,number:He,overloadedBoolean:fm,spaceSeparated:wn},Symbol.toStringTag,{value:"Module"})),yh=Object.keys(hm);class Ym extends _r{constructor(n,s,l,o){let d=-1;if(super(n,s),kb(this,"space",o),typeof l=="number")for(;++d<yh.length;){const c=yh[d];kb(this,yh[d],(l&hm[c])===hm[c])}}}Ym.prototype.defined=!0;function kb(e,n,s){s&&(e[n]=s)}function gi(e){const n={},s={};for(const[l,o]of Object.entries(e.properties)){const d=new Ym(l,e.transform(e.attributes||{},l),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(l)&&(d.mustUseProperty=!0),n[l]=d,s[um(l)]=l,s[um(d.attribute)]=l}return new Uo(n,s,e.space)}const x1=gi({properties:{ariaActiveDescendant:null,ariaAtomic:Gn,ariaAutoComplete:null,ariaBusy:Gn,ariaChecked:Gn,ariaColCount:He,ariaColIndex:He,ariaColSpan:He,ariaControls:wn,ariaCurrent:null,ariaDescribedBy:wn,ariaDetails:null,ariaDisabled:Gn,ariaDropEffect:wn,ariaErrorMessage:null,ariaExpanded:Gn,ariaFlowTo:wn,ariaGrabbed:Gn,ariaHasPopup:null,ariaHidden:Gn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wn,ariaLevel:He,ariaLive:null,ariaModal:Gn,ariaMultiLine:Gn,ariaMultiSelectable:Gn,ariaOrientation:null,ariaOwns:wn,ariaPlaceholder:null,ariaPosInSet:He,ariaPressed:Gn,ariaReadOnly:Gn,ariaRelevant:null,ariaRequired:Gn,ariaRoleDescription:wn,ariaRowCount:He,ariaRowIndex:He,ariaRowSpan:He,ariaSelected:Gn,ariaSetSize:He,ariaSort:null,ariaValueMax:He,ariaValueMin:He,ariaValueNow:He,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function g1(e,n){return n in e?e[n]:n}function p1(e,n){return g1(e,n.toLowerCase())}const uk=gi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ri,acceptCharset:wn,accessKey:wn,action:null,allow:null,allowFullScreen:Bt,allowPaymentRequest:Bt,allowUserMedia:Bt,alt:null,as:null,async:Bt,autoCapitalize:null,autoComplete:wn,autoFocus:Bt,autoPlay:Bt,blocking:wn,capture:null,charSet:null,checked:Bt,cite:null,className:wn,cols:He,colSpan:null,content:null,contentEditable:Gn,controls:Bt,controlsList:wn,coords:He|ri,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Bt,defer:Bt,dir:null,dirName:null,disabled:Bt,download:fm,draggable:Gn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Bt,formTarget:null,headers:wn,height:He,hidden:fm,high:He,href:null,hrefLang:null,htmlFor:wn,httpEquiv:wn,id:null,imageSizes:null,imageSrcSet:null,inert:Bt,inputMode:null,integrity:null,is:null,isMap:Bt,itemId:null,itemProp:wn,itemRef:wn,itemScope:Bt,itemType:wn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Bt,low:He,manifest:null,max:null,maxLength:He,media:null,method:null,min:null,minLength:He,multiple:Bt,muted:Bt,name:null,nonce:null,noModule:Bt,noValidate:Bt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Bt,optimum:He,pattern:null,ping:wn,placeholder:null,playsInline:Bt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Bt,referrerPolicy:null,rel:wn,required:Bt,reversed:Bt,rows:He,rowSpan:He,sandbox:wn,scope:null,scoped:Bt,seamless:Bt,selected:Bt,shadowRootClonable:Bt,shadowRootDelegatesFocus:Bt,shadowRootMode:null,shape:null,size:He,sizes:null,slot:null,span:He,spellCheck:Gn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:He,step:null,style:null,tabIndex:He,target:null,title:null,translate:null,type:null,typeMustMatch:Bt,useMap:null,value:Gn,width:He,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wn,axis:null,background:null,bgColor:null,border:He,borderColor:null,bottomMargin:He,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Bt,declare:Bt,event:null,face:null,frame:null,frameBorder:null,hSpace:He,leftMargin:He,link:null,longDesc:null,lowSrc:null,marginHeight:He,marginWidth:He,noResize:Bt,noHref:Bt,noShade:Bt,noWrap:Bt,object:null,profile:null,prompt:null,rev:null,rightMargin:He,rules:null,scheme:null,scrolling:Gn,standby:null,summary:null,text:null,topMargin:He,valueType:null,version:null,vAlign:null,vLink:null,vSpace:He,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Bt,disableRemotePlayback:Bt,prefix:null,property:null,results:He,security:null,unselectable:null},space:"html",transform:p1}),fk=gi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Br,accentHeight:He,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:He,amplitude:He,arabicForm:null,ascent:He,attributeName:null,attributeType:null,azimuth:He,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:He,by:null,calcMode:null,capHeight:He,className:wn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:He,diffuseConstant:He,direction:null,display:null,dur:null,divisor:He,dominantBaseline:null,download:Bt,dx:null,dy:null,edgeMode:null,editable:null,elevation:He,enableBackground:null,end:null,event:null,exponent:He,externalResourcesRequired:null,fill:null,fillOpacity:He,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ri,g2:ri,glyphName:ri,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:He,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:He,horizOriginX:He,horizOriginY:He,id:null,ideographic:He,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:He,k:He,k1:He,k2:He,k3:He,k4:He,kernelMatrix:Br,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:He,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:He,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:He,overlineThickness:He,paintOrder:null,panose1:null,path:null,pathLength:He,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:He,pointsAtY:He,pointsAtZ:He,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Br,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Br,rev:Br,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Br,requiredFeatures:Br,requiredFonts:Br,requiredFormats:Br,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:He,specularExponent:He,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:He,strikethroughThickness:He,string:null,stroke:null,strokeDashArray:Br,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:He,strokeOpacity:He,strokeWidth:null,style:null,surfaceScale:He,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Br,tabIndex:He,tableValues:null,target:null,targetX:He,targetY:He,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Br,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:He,underlineThickness:He,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:He,values:null,vAlphabetic:He,vMathematical:He,vectorEffect:null,vHanging:He,vIdeographic:He,version:null,vertAdvY:He,vertOriginX:He,vertOriginY:He,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:He,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:g1}),b1=gi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),y1=gi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:p1}),v1=gi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),hk={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},mk=/[A-Z]/g,Sb=/-[a-z]/g,xk=/^data[-\w.:]+$/i;function gk(e,n){const s=um(n);let l=n,o=_r;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&xk.test(n)){if(n.charAt(4)==="-"){const d=n.slice(5).replace(Sb,bk);l="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=n.slice(4);if(!Sb.test(d)){let c=d.replace(mk,pk);c.charAt(0)!=="-"&&(c="-"+c),n="data"+c}}o=Ym}return new o(l,n)}function pk(e){return"-"+e.toLowerCase()}function bk(e){return e.charAt(1).toUpperCase()}const yk=m1([x1,uk,b1,y1,v1],"html"),Gm=m1([x1,fk,b1,y1,v1],"svg");function vk(e){return e.join(" ").trim()}var Yl={},vh,Cb;function jk(){if(Cb)return vh;Cb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,s=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,d=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,m=`
11
- `,f="/",g="*",x="",p="comment",y="declaration";function w(C,_){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];_=_||{};var O=1,k=1;function S(T){var L=T.match(n);L&&(O+=L.length);var A=T.lastIndexOf(m);k=~A?T.length-A:k+T.length}function R(){var T={line:O,column:k};return function(L){return L.position=new D(T),K(),L}}function D(T){this.start=T,this.end={line:O,column:k},this.source=_.source}D.prototype.content=C;function Y(T){var L=new Error(_.source+":"+O+":"+k+": "+T);if(L.reason=T,L.filename=_.source,L.line=O,L.column=k,L.source=C,!_.silent)throw L}function z(T){var L=T.exec(C);if(L){var A=L[0];return S(A),C=C.slice(A.length),L}}function K(){z(s)}function U(T){var L;for(T=T||[];L=G();)L!==!1&&T.push(L);return T}function G(){var T=R();if(!(f!=C.charAt(0)||g!=C.charAt(1))){for(var L=2;x!=C.charAt(L)&&(g!=C.charAt(L)||f!=C.charAt(L+1));)++L;if(L+=2,x===C.charAt(L-1))return Y("End of comment missing");var A=C.slice(2,L-2);return k+=2,S(A),C=C.slice(L),k+=2,T({type:p,comment:A})}}function V(){var T=R(),L=z(l);if(L){if(G(),!z(o))return Y("property missing ':'");var A=z(d),P=T({type:y,property:N(L[0].replace(e,x)),value:A?N(A[0].replace(e,x)):x});return z(c),P}}function E(){var T=[];U(T);for(var L;L=V();)L!==!1&&(T.push(L),U(T));return T}return K(),E()}function N(C){return C?C.replace(h,x):x}return vh=w,vh}var Eb;function wk(){if(Eb)return Yl;Eb=1;var e=Yl&&Yl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Yl,"__esModule",{value:!0}),Yl.default=s;const n=e(jk());function s(l,o){let d=null;if(!l||typeof l!="string")return d;const c=(0,n.default)(l),h=typeof o=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:g}=m;h?o(f,g,m):g&&(d=d||{},d[f]=g)}),d}return Yl}var io={},Tb;function Nk(){if(Tb)return io;Tb=1,Object.defineProperty(io,"__esModule",{value:!0}),io.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,s=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,d=function(f){return!f||s.test(f)||e.test(f)},c=function(f,g){return g.toUpperCase()},h=function(f,g){return"".concat(g,"-")},m=function(f,g){return g===void 0&&(g={}),d(f)?f:(f=f.toLowerCase(),g.reactCompat?f=f.replace(o,h):f=f.replace(l,h),f.replace(n,c))};return io.camelCase=m,io}var oo,Ab;function kk(){if(Ab)return oo;Ab=1;var e=oo&&oo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(wk()),s=Nk();function l(o,d){var c={};return!o||typeof o!="string"||(0,n.default)(o,function(h,m){h&&m&&(c[(0,s.camelCase)(h,d)]=m)}),c}return l.default=l,oo=l,oo}var Sk=kk();const Ck=Xd(Sk),j1=w1("end"),Xm=w1("start");function w1(e){return n;function n(s){const l=s&&s.position&&s.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function Ek(e){const n=Xm(e),s=j1(e);if(n&&s)return{start:n,end:s}}function jo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?_b(e.position):"start"in e||"end"in e?_b(e):"line"in e||"column"in e?mm(e):""}function mm(e){return Mb(e&&e.line)+":"+Mb(e&&e.column)}function _b(e){return mm(e&&e.start)+"-"+mm(e&&e.end)}function Mb(e){return e&&typeof e=="number"?e:1}class xr extends Error{constructor(n,s,l){super(),typeof s=="string"&&(l=s,s=void 0);let o="",d={},c=!1;if(s&&("line"in s&&"column"in s?d={place:s}:"start"in s&&"end"in s?d={place:s}:"type"in s?d={ancestors:[s],place:s.position}:d={...s}),typeof n=="string"?o=n:!d.cause&&n&&(c=!0,o=n.message,d.cause=n),!d.ruleId&&!d.source&&typeof l=="string"){const m=l.indexOf(":");m===-1?d.ruleId=l:(d.source=l.slice(0,m),d.ruleId=l.slice(m+1))}if(!d.place&&d.ancestors&&d.ancestors){const m=d.ancestors[d.ancestors.length-1];m&&(d.place=m.position)}const h=d.place&&"start"in d.place?d.place.start:d.place;this.ancestors=d.ancestors||void 0,this.cause=d.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=h?h.line:void 0,this.name=jo(d.place)||"1:1",this.place=d.place||void 0,this.reason=this.message,this.ruleId=d.ruleId||void 0,this.source=d.source||void 0,this.stack=c&&d.cause&&typeof d.cause.stack=="string"?d.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}xr.prototype.file="";xr.prototype.name="";xr.prototype.reason="";xr.prototype.message="";xr.prototype.stack="";xr.prototype.column=void 0;xr.prototype.line=void 0;xr.prototype.ancestors=void 0;xr.prototype.cause=void 0;xr.prototype.fatal=void 0;xr.prototype.place=void 0;xr.prototype.ruleId=void 0;xr.prototype.source=void 0;const Km={}.hasOwnProperty,Tk=new Map,Ak=/[A-Z]/g,_k=new Set(["table","tbody","thead","tfoot","tr"]),Mk=new Set(["td","th"]),N1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Ok(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=n.filePath||void 0;let l;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=Hk(s,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=Bk(s,n.jsx,n.jsxs)}const o={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:l,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Gm:yk,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},d=k1(o,e,void 0);return d&&typeof d!="string"?d:o.create(e,o.Fragment,{children:d||void 0},void 0)}function k1(e,n,s){if(n.type==="element")return Rk(e,n,s);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Dk(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Ik(e,n,s);if(n.type==="mdxjsEsm")return Lk(e,n);if(n.type==="root")return zk(e,n,s);if(n.type==="text")return $k(e,n)}function Rk(e,n,s){const l=e.schema;let o=l;n.tagName.toLowerCase()==="svg"&&l.space==="html"&&(o=Gm,e.schema=o),e.ancestors.push(n);const d=C1(e,n.tagName,!1),c=Pk(e,n);let h=Wm(e,n);return _k.has(n.tagName)&&(h=h.filter(function(m){return typeof m=="string"?!ck(m):!0})),S1(e,c,d,n),Zm(c,h),e.ancestors.pop(),e.schema=l,e.create(n,d,c,s)}function Dk(e,n){if(n.data&&n.data.estree&&e.evaluater){const l=n.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}To(e,n.position)}function Lk(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);To(e,n.position)}function Ik(e,n,s){const l=e.schema;let o=l;n.name==="svg"&&l.space==="html"&&(o=Gm,e.schema=o),e.ancestors.push(n);const d=n.name===null?e.Fragment:C1(e,n.name,!0),c=Uk(e,n),h=Wm(e,n);return S1(e,c,d,n),Zm(c,h),e.ancestors.pop(),e.schema=l,e.create(n,d,c,s)}function zk(e,n,s){const l={};return Zm(l,Wm(e,n)),e.create(n,e.Fragment,l,s)}function $k(e,n){return n.value}function S1(e,n,s,l){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(n.node=l)}function Zm(e,n){if(n.length>0){const s=n.length>1?n:n[0];s&&(e.children=s)}}function Bk(e,n,s){return l;function l(o,d,c,h){const f=Array.isArray(c.children)?s:n;return h?f(d,c,h):f(d,c)}}function Hk(e,n){return s;function s(l,o,d,c){const h=Array.isArray(d.children),m=Xm(l);return n(o,d,c,h,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function Pk(e,n){const s={};let l,o;for(o in n.properties)if(o!=="children"&&Km.call(n.properties,o)){const d=qk(e,o,n.properties[o]);if(d){const[c,h]=d;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&Mk.has(n.tagName)?l=h:s[c]=h}}if(l){const d=s.style||(s.style={});d[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return s}function Uk(e,n){const s={};for(const l of n.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const d=l.data.estree.body[0];d.type;const c=d.expression;c.type;const h=c.properties[0];h.type,Object.assign(s,e.evaluater.evaluateExpression(h.argument))}else To(e,n.position);else{const o=l.name;let d;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const h=l.value.data.estree.body[0];h.type,d=e.evaluater.evaluateExpression(h.expression)}else To(e,n.position);else d=l.value===null?!0:l.value;s[o]=d}return s}function Wm(e,n){const s=[];let l=-1;const o=e.passKeys?new Map:Tk;for(;++l<n.children.length;){const d=n.children[l];let c;if(e.passKeys){const m=d.type==="element"?d.tagName:d.type==="mdxJsxFlowElement"||d.type==="mdxJsxTextElement"?d.name:void 0;if(m){const f=o.get(m)||0;c=m+"-"+f,o.set(m,f+1)}}const h=k1(e,d,c);h!==void 0&&s.push(h)}return s}function qk(e,n,s){const l=gk(e.schema,n);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=l.commaSeparated?sk(s):vk(s)),l.property==="style"){let o=typeof s=="object"?s:Vk(e,String(s));return e.stylePropertyNameCase==="css"&&(o=Fk(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&l.space?hk[l.property]||l.property:l.attribute,s]}}function Vk(e,n){try{return Ck(n,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const l=s,o=new xr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:l,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=N1+"#cannot-parse-style-attribute",o}}function C1(e,n,s){let l;if(!s)l={type:"Literal",value:n};else if(n.includes(".")){const o=n.split(".");let d=-1,c;for(;++d<o.length;){const h=wb(o[d])?{type:"Identifier",name:o[d]}:{type:"Literal",value:o[d]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(d&&h.type==="Literal"),optional:!1}:h}l=c}else l=wb(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(l.type==="Literal"){const o=l.value;return Km.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(l);To(e)}function To(e,n){const s=new xr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=N1+"#cannot-handle-mdx-estrees-without-createevaluater",s}function Fk(e){const n={};let s;for(s in e)Km.call(e,s)&&(n[Yk(s)]=e[s]);return n}function Yk(e){let n=e.replace(Ak,Gk);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function Gk(e){return"-"+e.toLowerCase()}const jh={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Xk={};function Qm(e,n){const s=Xk,l=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,o=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return E1(e,l,o)}function E1(e,n,s){if(Kk(e)){if("value"in e)return e.type==="html"&&!s?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Ob(e.children,n,s)}return Array.isArray(e)?Ob(e,n,s):""}function Ob(e,n,s){const l=[];let o=-1;for(;++o<e.length;)l[o]=E1(e[o],n,s);return l.join("")}function Kk(e){return!!(e&&typeof e=="object")}const Rb=document.createElement("i");function Jm(e){const n="&"+e+";";Rb.innerHTML=n;const s=Rb.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===n?!1:s}function Pr(e,n,s,l){const o=e.length;let d=0,c;if(n<0?n=-n>o?0:o+n:n=n>o?o:n,s=s>0?s:0,l.length<1e4)c=Array.from(l),c.unshift(n,s),e.splice(...c);else for(s&&e.splice(n,s);d<l.length;)c=l.slice(d,d+1e4),c.unshift(n,0),e.splice(...c),d+=1e4,n+=1e4}function rs(e,n){return e.length>0?(Pr(e,e.length,0,n),e):n}const Db={}.hasOwnProperty;function T1(e){const n={};let s=-1;for(;++s<e.length;)Zk(n,e[s]);return n}function Zk(e,n){let s;for(s in n){const o=(Db.call(e,s)?e[s]:void 0)||(e[s]={}),d=n[s];let c;if(d)for(c in d){Db.call(o,c)||(o[c]=[]);const h=d[c];Wk(o[c],Array.isArray(h)?h:h?[h]:[])}}}function Wk(e,n){let s=-1;const l=[];for(;++s<n.length;)(n[s].add==="after"?e:l).push(n[s]);Pr(e,0,0,l)}function A1(e,n){const s=Number.parseInt(e,n);return s<9||s===11||s>13&&s<32||s>126&&s<160||s>55295&&s<57344||s>64975&&s<65008||(s&65535)===65535||(s&65535)===65534||s>1114111?"�":String.fromCodePoint(s)}function hs(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const vr=Ba(/[A-Za-z]/),mr=Ba(/[\dA-Za-z]/),Qk=Ba(/[#-'*+\--9=?A-Z^-~]/);function Cd(e){return e!==null&&(e<32||e===127)}const xm=Ba(/\d/),Jk=Ba(/[\dA-Fa-f]/),eS=Ba(/[!-/:-@[-`{-~]/);function wt(e){return e!==null&&e<-2}function bn(e){return e!==null&&(e<0||e===32)}function Ft(e){return e===-2||e===-1||e===32}const Kd=Ba(new RegExp("\\p{P}|\\p{S}","u")),dl=Ba(/\s/);function Ba(e){return n;function n(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function pi(e){const n=[];let s=-1,l=0,o=0;for(;++s<e.length;){const d=e.charCodeAt(s);let c="";if(d===37&&mr(e.charCodeAt(s+1))&&mr(e.charCodeAt(s+2)))o=2;else if(d<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(d))||(c=String.fromCharCode(d));else if(d>55295&&d<57344){const h=e.charCodeAt(s+1);d<56320&&h>56319&&h<57344?(c=String.fromCharCode(d,h),o=1):c="�"}else c=String.fromCharCode(d);c&&(n.push(e.slice(l,s),encodeURIComponent(c)),l=s+o+1,c=""),o&&(s+=o,o=0)}return n.join("")+e.slice(l)}function Qt(e,n,s,l){const o=l?l-1:Number.POSITIVE_INFINITY;let d=0;return c;function c(m){return Ft(m)?(e.enter(s),h(m)):n(m)}function h(m){return Ft(m)&&d++<o?(e.consume(m),h):(e.exit(s),n(m))}}const tS={tokenize:nS};function nS(e){const n=e.attempt(this.parser.constructs.contentInitial,l,o);let s;return n;function l(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Qt(e,n,"linePrefix")}function o(h){return e.enter("paragraph"),d(h)}function d(h){const m=e.enter("chunkText",{contentType:"text",previous:s});return s&&(s.next=m),s=m,c(h)}function c(h){if(h===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(h);return}return wt(h)?(e.consume(h),e.exit("chunkText"),d):(e.consume(h),c)}}const rS={tokenize:sS},Lb={tokenize:aS};function sS(e){const n=this,s=[];let l=0,o,d,c;return h;function h(k){if(l<s.length){const S=s[l];return n.containerState=S[1],e.attempt(S[0].continuation,m,f)(k)}return f(k)}function m(k){if(l++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&O();const S=n.events.length;let R=S,D;for(;R--;)if(n.events[R][0]==="exit"&&n.events[R][1].type==="chunkFlow"){D=n.events[R][1].end;break}_(l);let Y=S;for(;Y<n.events.length;)n.events[Y][1].end={...D},Y++;return Pr(n.events,R+1,0,n.events.slice(S)),n.events.length=Y,f(k)}return h(k)}function f(k){if(l===s.length){if(!o)return p(k);if(o.currentConstruct&&o.currentConstruct.concrete)return w(k);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Lb,g,x)(k)}function g(k){return o&&O(),_(l),p(k)}function x(k){return n.parser.lazy[n.now().line]=l!==s.length,c=n.now().offset,w(k)}function p(k){return n.containerState={},e.attempt(Lb,y,w)(k)}function y(k){return l++,s.push([n.currentConstruct,n.containerState]),p(k)}function w(k){if(k===null){o&&O(),_(0),e.consume(k);return}return o=o||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:d}),N(k)}function N(k){if(k===null){C(e.exit("chunkFlow"),!0),_(0),e.consume(k);return}return wt(k)?(e.consume(k),C(e.exit("chunkFlow")),l=0,n.interrupt=void 0,h):(e.consume(k),N)}function C(k,S){const R=n.sliceStream(k);if(S&&R.push(null),k.previous=d,d&&(d.next=k),d=k,o.defineSkip(k.start),o.write(R),n.parser.lazy[k.start.line]){let D=o.events.length;for(;D--;)if(o.events[D][1].start.offset<c&&(!o.events[D][1].end||o.events[D][1].end.offset>c))return;const Y=n.events.length;let z=Y,K,U;for(;z--;)if(n.events[z][0]==="exit"&&n.events[z][1].type==="chunkFlow"){if(K){U=n.events[z][1].end;break}K=!0}for(_(l),D=Y;D<n.events.length;)n.events[D][1].end={...U},D++;Pr(n.events,z+1,0,n.events.slice(Y)),n.events.length=D}}function _(k){let S=s.length;for(;S-- >k;){const R=s[S];n.containerState=R[1],R[0].exit.call(n,e)}s.length=k}function O(){o.write([null]),d=void 0,o=void 0,n.containerState._closeFlow=void 0}}function aS(e,n,s){return Qt(e,e.attempt(this.parser.constructs.document,n,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function li(e){if(e===null||bn(e)||dl(e))return 1;if(Kd(e))return 2}function Zd(e,n,s){const l=[];let o=-1;for(;++o<e.length;){const d=e[o].resolveAll;d&&!l.includes(d)&&(n=d(n,s),l.push(d))}return n}const gm={name:"attention",resolveAll:lS,tokenize:iS};function lS(e,n){let s=-1,l,o,d,c,h,m,f,g;for(;++s<e.length;)if(e[s][0]==="enter"&&e[s][1].type==="attentionSequence"&&e[s][1]._close){for(l=s;l--;)if(e[l][0]==="exit"&&e[l][1].type==="attentionSequence"&&e[l][1]._open&&n.sliceSerialize(e[l][1]).charCodeAt(0)===n.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[l][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[l][1].end.offset-e[l][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;m=e[l][1].end.offset-e[l][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const x={...e[l][1].end},p={...e[s][1].start};Ib(x,-m),Ib(p,m),c={type:m>1?"strongSequence":"emphasisSequence",start:x,end:{...e[l][1].end}},h={type:m>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:p},d={type:m>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[s][1].start}},o={type:m>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},e[l][1].end={...c.start},e[s][1].start={...h.end},f=[],e[l][1].end.offset-e[l][1].start.offset&&(f=rs(f,[["enter",e[l][1],n],["exit",e[l][1],n]])),f=rs(f,[["enter",o,n],["enter",c,n],["exit",c,n],["enter",d,n]]),f=rs(f,Zd(n.parser.constructs.insideSpan.null,e.slice(l+1,s),n)),f=rs(f,[["exit",d,n],["enter",h,n],["exit",h,n],["exit",o,n]]),e[s][1].end.offset-e[s][1].start.offset?(g=2,f=rs(f,[["enter",e[s][1],n],["exit",e[s][1],n]])):g=0,Pr(e,l-1,s-l+3,f),s=l+f.length-g-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function iS(e,n){const s=this.parser.constructs.attentionMarkers.null,l=this.previous,o=li(l);let d;return c;function c(m){return d=m,e.enter("attentionSequence"),h(m)}function h(m){if(m===d)return e.consume(m),h;const f=e.exit("attentionSequence"),g=li(m),x=!g||g===2&&o||s.includes(m),p=!o||o===2&&g||s.includes(l);return f._open=!!(d===42?x:x&&(o||!p)),f._close=!!(d===42?p:p&&(g||!x)),n(m)}}function Ib(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const oS={name:"autolink",tokenize:cS};function cS(e,n,s){let l=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),d}function d(y){return vr(y)?(e.consume(y),c):y===64?s(y):f(y)}function c(y){return y===43||y===45||y===46||mr(y)?(l=1,h(y)):f(y)}function h(y){return y===58?(e.consume(y),l=0,m):(y===43||y===45||y===46||mr(y))&&l++<32?(e.consume(y),h):(l=0,f(y))}function m(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),n):y===null||y===32||y===60||Cd(y)?s(y):(e.consume(y),m)}function f(y){return y===64?(e.consume(y),g):Qk(y)?(e.consume(y),f):s(y)}function g(y){return mr(y)?x(y):s(y)}function x(y){return y===46?(e.consume(y),l=0,g):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),n):p(y)}function p(y){if((y===45||mr(y))&&l++<63){const w=y===45?p:x;return e.consume(y),w}return s(y)}}const qo={partial:!0,tokenize:dS};function dS(e,n,s){return l;function l(d){return Ft(d)?Qt(e,o,"linePrefix")(d):o(d)}function o(d){return d===null||wt(d)?n(d):s(d)}}const _1={continuation:{tokenize:fS},exit:hS,name:"blockQuote",tokenize:uS};function uS(e,n,s){const l=this;return o;function o(c){if(c===62){const h=l.containerState;return h.open||(e.enter("blockQuote",{_container:!0}),h.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),d}return s(c)}function d(c){return Ft(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(c))}}function fS(e,n,s){const l=this;return o;function o(c){return Ft(c)?Qt(e,d,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):d(c)}function d(c){return e.attempt(_1,n,s)(c)}}function hS(e){e.exit("blockQuote")}const M1={name:"characterEscape",tokenize:mS};function mS(e,n,s){return l;function l(d){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(d),e.exit("escapeMarker"),o}function o(d){return eS(d)?(e.enter("characterEscapeValue"),e.consume(d),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):s(d)}}const O1={name:"characterReference",tokenize:xS};function xS(e,n,s){const l=this;let o=0,d,c;return h;function h(x){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),m}function m(x){return x===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(x),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),d=31,c=mr,g(x))}function f(x){return x===88||x===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(x),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),d=6,c=Jk,g):(e.enter("characterReferenceValue"),d=7,c=xm,g(x))}function g(x){if(x===59&&o){const p=e.exit("characterReferenceValue");return c===mr&&!Jm(l.sliceSerialize(p))?s(x):(e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return c(x)&&o++<d?(e.consume(x),g):s(x)}}const zb={partial:!0,tokenize:pS},$b={concrete:!0,name:"codeFenced",tokenize:gS};function gS(e,n,s){const l=this,o={partial:!0,tokenize:R};let d=0,c=0,h;return m;function m(D){return f(D)}function f(D){const Y=l.events[l.events.length-1];return d=Y&&Y[1].type==="linePrefix"?Y[2].sliceSerialize(Y[1],!0).length:0,h=D,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(D)}function g(D){return D===h?(c++,e.consume(D),g):c<3?s(D):(e.exit("codeFencedFenceSequence"),Ft(D)?Qt(e,x,"whitespace")(D):x(D))}function x(D){return D===null||wt(D)?(e.exit("codeFencedFence"),l.interrupt?n(D):e.check(zb,N,S)(D)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(D))}function p(D){return D===null||wt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),x(D)):Ft(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Qt(e,y,"whitespace")(D)):D===96&&D===h?s(D):(e.consume(D),p)}function y(D){return D===null||wt(D)?x(D):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(D))}function w(D){return D===null||wt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),x(D)):D===96&&D===h?s(D):(e.consume(D),w)}function N(D){return e.attempt(o,S,C)(D)}function C(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),_}function _(D){return d>0&&Ft(D)?Qt(e,O,"linePrefix",d+1)(D):O(D)}function O(D){return D===null||wt(D)?e.check(zb,N,S)(D):(e.enter("codeFlowValue"),k(D))}function k(D){return D===null||wt(D)?(e.exit("codeFlowValue"),O(D)):(e.consume(D),k)}function S(D){return e.exit("codeFenced"),n(D)}function R(D,Y,z){let K=0;return U;function U(L){return D.enter("lineEnding"),D.consume(L),D.exit("lineEnding"),G}function G(L){return D.enter("codeFencedFence"),Ft(L)?Qt(D,V,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):V(L)}function V(L){return L===h?(D.enter("codeFencedFenceSequence"),E(L)):z(L)}function E(L){return L===h?(K++,D.consume(L),E):K>=c?(D.exit("codeFencedFenceSequence"),Ft(L)?Qt(D,T,"whitespace")(L):T(L)):z(L)}function T(L){return L===null||wt(L)?(D.exit("codeFencedFence"),Y(L)):z(L)}}}function pS(e,n,s){const l=this;return o;function o(c){return c===null?s(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d)}function d(c){return l.parser.lazy[l.now().line]?s(c):n(c)}}const wh={name:"codeIndented",tokenize:yS},bS={partial:!0,tokenize:vS};function yS(e,n,s){const l=this;return o;function o(f){return e.enter("codeIndented"),Qt(e,d,"linePrefix",5)(f)}function d(f){const g=l.events[l.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(f):s(f)}function c(f){return f===null?m(f):wt(f)?e.attempt(bS,c,m)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||wt(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),h)}function m(f){return e.exit("codeIndented"),n(f)}}function vS(e,n,s){const l=this;return o;function o(c){return l.parser.lazy[l.now().line]?s(c):wt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):Qt(e,d,"linePrefix",5)(c)}function d(c){const h=l.events[l.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(c):wt(c)?o(c):s(c)}}const jS={name:"codeText",previous:NS,resolve:wS,tokenize:kS};function wS(e){let n=e.length-4,s=3,l,o;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(l=s;++l<n;)if(e[l][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[n][1].type="codeTextPadding",s+=2,n-=2;break}}for(l=s-1,n++;++l<=n;)o===void 0?l!==n&&e[l][1].type!=="lineEnding"&&(o=l):(l===n||e[l][1].type==="lineEnding")&&(e[o][1].type="codeTextData",l!==o+2&&(e[o][1].end=e[l-1][1].end,e.splice(o+2,l-o-2),n-=l-o-2,l=o+2),o=void 0);return e}function NS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function kS(e,n,s){let l=0,o,d;return c;function c(x){return e.enter("codeText"),e.enter("codeTextSequence"),h(x)}function h(x){return x===96?(e.consume(x),l++,h):(e.exit("codeTextSequence"),m(x))}function m(x){return x===null?s(x):x===32?(e.enter("space"),e.consume(x),e.exit("space"),m):x===96?(d=e.enter("codeTextSequence"),o=0,g(x)):wt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(x))}function f(x){return x===null||x===32||x===96||wt(x)?(e.exit("codeTextData"),m(x)):(e.consume(x),f)}function g(x){return x===96?(e.consume(x),o++,g):o===l?(e.exit("codeTextSequence"),e.exit("codeText"),n(x)):(d.type="codeTextData",f(x))}}class SS{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,s){const l=s??Number.POSITIVE_INFINITY;return l<this.left.length?this.left.slice(n,l):n>this.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(n,s,l){const o=s||0;this.setCursor(Math.trunc(n));const d=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return l&&co(this.left,l),d.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),co(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),co(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const s=this.left.splice(n,Number.POSITIVE_INFINITY);co(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);co(this.left,s.reverse())}}}function co(e,n){let s=0;if(n.length<1e4)e.push(...n);else for(;s<n.length;)e.push(...n.slice(s,s+1e4)),s+=1e4}function R1(e){const n={};let s=-1,l,o,d,c,h,m,f;const g=new SS(e);for(;++s<g.length;){for(;s in n;)s=n[s];if(l=g.get(s),s&&l[1].type==="chunkFlow"&&g.get(s-1)[1].type==="listItemPrefix"&&(m=l[1]._tokenizer.events,d=0,d<m.length&&m[d][1].type==="lineEndingBlank"&&(d+=2),d<m.length&&m[d][1].type==="content"))for(;++d<m.length&&m[d][1].type!=="content";)m[d][1].type==="chunkText"&&(m[d][1]._isInFirstContentOfListItem=!0,d++);if(l[0]==="enter")l[1].contentType&&(Object.assign(n,CS(g,s)),s=n[s],f=!0);else if(l[1]._container){for(d=s,o=void 0;d--;)if(c=g.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(g.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=d);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(l[1].end={...g.get(o)[1].start},h=g.slice(o,s),h.unshift(l),g.splice(o,s-o+1,h))}}return Pr(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!f}function CS(e,n){const s=e.get(n)[1],l=e.get(n)[2];let o=n-1;const d=[];let c=s._tokenizer;c||(c=l.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,m=[],f={};let g,x,p=-1,y=s,w=0,N=0;const C=[N];for(;y;){for(;e.get(++o)[1]!==y;);d.push(o),y._tokenizer||(g=l.sliceStream(y),y.next||g.push(null),x&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(g),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),x=y,y=y.next}for(y=s;++p<h.length;)h[p][0]==="exit"&&h[p-1][0]==="enter"&&h[p][1].type===h[p-1][1].type&&h[p][1].start.line!==h[p][1].end.line&&(N=p+1,C.push(N),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(c.events=[],y?(y._tokenizer=void 0,y.previous=void 0):C.pop(),p=C.length;p--;){const _=h.slice(C[p],C[p+1]),O=d.pop();m.push([O,O+_.length-1]),e.splice(O,2,_)}for(m.reverse(),p=-1;++p<m.length;)f[w+m[p][0]]=w+m[p][1],w+=m[p][1]-m[p][0]-1;return f}const ES={resolve:AS,tokenize:_S},TS={partial:!0,tokenize:MS};function AS(e){return R1(e),e}function _S(e,n){let s;return l;function l(h){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),o(h)}function o(h){return h===null?d(h):wt(h)?e.check(TS,c,d)(h):(e.consume(h),o)}function d(h){return e.exit("chunkContent"),e.exit("content"),n(h)}function c(h){return e.consume(h),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,o}}function MS(e,n,s){const l=this;return o;function o(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Qt(e,d,"linePrefix")}function d(c){if(c===null||wt(c))return s(c);const h=l.events[l.events.length-1];return!l.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?n(c):e.interrupt(l.parser.constructs.flow,s,n)(c)}}function D1(e,n,s,l,o,d,c,h,m){const f=m||Number.POSITIVE_INFINITY;let g=0;return x;function x(_){return _===60?(e.enter(l),e.enter(o),e.enter(d),e.consume(_),e.exit(d),p):_===null||_===32||_===41||Cd(_)?s(_):(e.enter(l),e.enter(c),e.enter(h),e.enter("chunkString",{contentType:"string"}),N(_))}function p(_){return _===62?(e.enter(d),e.consume(_),e.exit(d),e.exit(o),e.exit(l),n):(e.enter(h),e.enter("chunkString",{contentType:"string"}),y(_))}function y(_){return _===62?(e.exit("chunkString"),e.exit(h),p(_)):_===null||_===60||wt(_)?s(_):(e.consume(_),_===92?w:y)}function w(_){return _===60||_===62||_===92?(e.consume(_),y):y(_)}function N(_){return!g&&(_===null||_===41||bn(_))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(l),n(_)):g<f&&_===40?(e.consume(_),g++,N):_===41?(e.consume(_),g--,N):_===null||_===32||_===40||Cd(_)?s(_):(e.consume(_),_===92?C:N)}function C(_){return _===40||_===41||_===92?(e.consume(_),N):N(_)}}function L1(e,n,s,l,o,d){const c=this;let h=0,m;return f;function f(y){return e.enter(l),e.enter(o),e.consume(y),e.exit(o),e.enter(d),g}function g(y){return h>999||y===null||y===91||y===93&&!m||y===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?s(y):y===93?(e.exit(d),e.enter(o),e.consume(y),e.exit(o),e.exit(l),n):wt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),x(y))}function x(y){return y===null||y===91||y===93||wt(y)||h++>999?(e.exit("chunkString"),g(y)):(e.consume(y),m||(m=!Ft(y)),y===92?p:x)}function p(y){return y===91||y===92||y===93?(e.consume(y),h++,x):x(y)}}function I1(e,n,s,l,o,d){let c;return h;function h(p){return p===34||p===39||p===40?(e.enter(l),e.enter(o),e.consume(p),e.exit(o),c=p===40?41:p,m):s(p)}function m(p){return p===c?(e.enter(o),e.consume(p),e.exit(o),e.exit(l),n):(e.enter(d),f(p))}function f(p){return p===c?(e.exit(d),m(c)):p===null?s(p):wt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Qt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(p))}function g(p){return p===c||p===null||wt(p)?(e.exit("chunkString"),f(p)):(e.consume(p),p===92?x:g)}function x(p){return p===c||p===92?(e.consume(p),g):g(p)}}function wo(e,n){let s;return l;function l(o){return wt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s=!0,l):Ft(o)?Qt(e,l,s?"linePrefix":"lineSuffix")(o):n(o)}}const OS={name:"definition",tokenize:DS},RS={partial:!0,tokenize:LS};function DS(e,n,s){const l=this;let o;return d;function d(y){return e.enter("definition"),c(y)}function c(y){return L1.call(l,e,h,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function h(y){return o=hs(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),m):s(y)}function m(y){return bn(y)?wo(e,f)(y):f(y)}function f(y){return D1(e,g,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function g(y){return e.attempt(RS,x,x)(y)}function x(y){return Ft(y)?Qt(e,p,"whitespace")(y):p(y)}function p(y){return y===null||wt(y)?(e.exit("definition"),l.parser.defined.push(o),n(y)):s(y)}}function LS(e,n,s){return l;function l(h){return bn(h)?wo(e,o)(h):s(h)}function o(h){return I1(e,d,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function d(h){return Ft(h)?Qt(e,c,"whitespace")(h):c(h)}function c(h){return h===null||wt(h)?n(h):s(h)}}const IS={name:"hardBreakEscape",tokenize:zS};function zS(e,n,s){return l;function l(d){return e.enter("hardBreakEscape"),e.consume(d),o}function o(d){return wt(d)?(e.exit("hardBreakEscape"),n(d)):s(d)}}const $S={name:"headingAtx",resolve:BS,tokenize:HS};function BS(e,n){let s=e.length-2,l=3,o,d;return e[l][1].type==="whitespace"&&(l+=2),s-2>l&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(l===s-1||s-4>l&&e[s-2][1].type==="whitespace")&&(s-=l+1===s?2:4),s>l&&(o={type:"atxHeadingText",start:e[l][1].start,end:e[s][1].end},d={type:"chunkText",start:e[l][1].start,end:e[s][1].end,contentType:"text"},Pr(e,l,s-l+1,[["enter",o,n],["enter",d,n],["exit",d,n],["exit",o,n]])),e}function HS(e,n,s){let l=0;return o;function o(g){return e.enter("atxHeading"),d(g)}function d(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&l++<6?(e.consume(g),c):g===null||bn(g)?(e.exit("atxHeadingSequence"),h(g)):s(g)}function h(g){return g===35?(e.enter("atxHeadingSequence"),m(g)):g===null||wt(g)?(e.exit("atxHeading"),n(g)):Ft(g)?Qt(e,h,"whitespace")(g):(e.enter("atxHeadingText"),f(g))}function m(g){return g===35?(e.consume(g),m):(e.exit("atxHeadingSequence"),h(g))}function f(g){return g===null||g===35||bn(g)?(e.exit("atxHeadingText"),h(g)):(e.consume(g),f)}}const PS=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Bb=["pre","script","style","textarea"],US={concrete:!0,name:"htmlFlow",resolveTo:FS,tokenize:YS},qS={partial:!0,tokenize:XS},VS={partial:!0,tokenize:GS};function FS(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function YS(e,n,s){const l=this;let o,d,c,h,m;return f;function f(I){return g(I)}function g(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),x}function x(I){return I===33?(e.consume(I),p):I===47?(e.consume(I),d=!0,N):I===63?(e.consume(I),o=3,l.interrupt?n:B):vr(I)?(e.consume(I),c=String.fromCharCode(I),C):s(I)}function p(I){return I===45?(e.consume(I),o=2,y):I===91?(e.consume(I),o=5,h=0,w):vr(I)?(e.consume(I),o=4,l.interrupt?n:B):s(I)}function y(I){return I===45?(e.consume(I),l.interrupt?n:B):s(I)}function w(I){const M="CDATA[";return I===M.charCodeAt(h++)?(e.consume(I),h===M.length?l.interrupt?n:V:w):s(I)}function N(I){return vr(I)?(e.consume(I),c=String.fromCharCode(I),C):s(I)}function C(I){if(I===null||I===47||I===62||bn(I)){const M=I===47,H=c.toLowerCase();return!M&&!d&&Bb.includes(H)?(o=1,l.interrupt?n(I):V(I)):PS.includes(c.toLowerCase())?(o=6,M?(e.consume(I),_):l.interrupt?n(I):V(I)):(o=7,l.interrupt&&!l.parser.lazy[l.now().line]?s(I):d?O(I):k(I))}return I===45||mr(I)?(e.consume(I),c+=String.fromCharCode(I),C):s(I)}function _(I){return I===62?(e.consume(I),l.interrupt?n:V):s(I)}function O(I){return Ft(I)?(e.consume(I),O):U(I)}function k(I){return I===47?(e.consume(I),U):I===58||I===95||vr(I)?(e.consume(I),S):Ft(I)?(e.consume(I),k):U(I)}function S(I){return I===45||I===46||I===58||I===95||mr(I)?(e.consume(I),S):R(I)}function R(I){return I===61?(e.consume(I),D):Ft(I)?(e.consume(I),R):k(I)}function D(I){return I===null||I===60||I===61||I===62||I===96?s(I):I===34||I===39?(e.consume(I),m=I,Y):Ft(I)?(e.consume(I),D):z(I)}function Y(I){return I===m?(e.consume(I),m=null,K):I===null||wt(I)?s(I):(e.consume(I),Y)}function z(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||bn(I)?R(I):(e.consume(I),z)}function K(I){return I===47||I===62||Ft(I)?k(I):s(I)}function U(I){return I===62?(e.consume(I),G):s(I)}function G(I){return I===null||wt(I)?V(I):Ft(I)?(e.consume(I),G):s(I)}function V(I){return I===45&&o===2?(e.consume(I),A):I===60&&o===1?(e.consume(I),P):I===62&&o===4?(e.consume(I),F):I===63&&o===3?(e.consume(I),B):I===93&&o===5?(e.consume(I),W):wt(I)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(qS,X,E)(I)):I===null||wt(I)?(e.exit("htmlFlowData"),E(I)):(e.consume(I),V)}function E(I){return e.check(VS,T,X)(I)}function T(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),L}function L(I){return I===null||wt(I)?E(I):(e.enter("htmlFlowData"),V(I))}function A(I){return I===45?(e.consume(I),B):V(I)}function P(I){return I===47?(e.consume(I),c="",q):V(I)}function q(I){if(I===62){const M=c.toLowerCase();return Bb.includes(M)?(e.consume(I),F):V(I)}return vr(I)&&c.length<8?(e.consume(I),c+=String.fromCharCode(I),q):V(I)}function W(I){return I===93?(e.consume(I),B):V(I)}function B(I){return I===62?(e.consume(I),F):I===45&&o===2?(e.consume(I),B):V(I)}function F(I){return I===null||wt(I)?(e.exit("htmlFlowData"),X(I)):(e.consume(I),F)}function X(I){return e.exit("htmlFlow"),n(I)}}function GS(e,n,s){const l=this;return o;function o(c){return wt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d):s(c)}function d(c){return l.parser.lazy[l.now().line]?s(c):n(c)}}function XS(e,n,s){return l;function l(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(qo,n,s)}}const KS={name:"htmlText",tokenize:ZS};function ZS(e,n,s){const l=this;let o,d,c;return h;function h(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),f):B===47?(e.consume(B),R):B===63?(e.consume(B),k):vr(B)?(e.consume(B),z):s(B)}function f(B){return B===45?(e.consume(B),g):B===91?(e.consume(B),d=0,w):vr(B)?(e.consume(B),O):s(B)}function g(B){return B===45?(e.consume(B),y):s(B)}function x(B){return B===null?s(B):B===45?(e.consume(B),p):wt(B)?(c=x,P(B)):(e.consume(B),x)}function p(B){return B===45?(e.consume(B),y):x(B)}function y(B){return B===62?A(B):B===45?p(B):x(B)}function w(B){const F="CDATA[";return B===F.charCodeAt(d++)?(e.consume(B),d===F.length?N:w):s(B)}function N(B){return B===null?s(B):B===93?(e.consume(B),C):wt(B)?(c=N,P(B)):(e.consume(B),N)}function C(B){return B===93?(e.consume(B),_):N(B)}function _(B){return B===62?A(B):B===93?(e.consume(B),_):N(B)}function O(B){return B===null||B===62?A(B):wt(B)?(c=O,P(B)):(e.consume(B),O)}function k(B){return B===null?s(B):B===63?(e.consume(B),S):wt(B)?(c=k,P(B)):(e.consume(B),k)}function S(B){return B===62?A(B):k(B)}function R(B){return vr(B)?(e.consume(B),D):s(B)}function D(B){return B===45||mr(B)?(e.consume(B),D):Y(B)}function Y(B){return wt(B)?(c=Y,P(B)):Ft(B)?(e.consume(B),Y):A(B)}function z(B){return B===45||mr(B)?(e.consume(B),z):B===47||B===62||bn(B)?K(B):s(B)}function K(B){return B===47?(e.consume(B),A):B===58||B===95||vr(B)?(e.consume(B),U):wt(B)?(c=K,P(B)):Ft(B)?(e.consume(B),K):A(B)}function U(B){return B===45||B===46||B===58||B===95||mr(B)?(e.consume(B),U):G(B)}function G(B){return B===61?(e.consume(B),V):wt(B)?(c=G,P(B)):Ft(B)?(e.consume(B),G):K(B)}function V(B){return B===null||B===60||B===61||B===62||B===96?s(B):B===34||B===39?(e.consume(B),o=B,E):wt(B)?(c=V,P(B)):Ft(B)?(e.consume(B),V):(e.consume(B),T)}function E(B){return B===o?(e.consume(B),o=void 0,L):B===null?s(B):wt(B)?(c=E,P(B)):(e.consume(B),E)}function T(B){return B===null||B===34||B===39||B===60||B===61||B===96?s(B):B===47||B===62||bn(B)?K(B):(e.consume(B),T)}function L(B){return B===47||B===62||bn(B)?K(B):s(B)}function A(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),n):s(B)}function P(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),q}function q(B){return Ft(B)?Qt(e,W,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):W(B)}function W(B){return e.enter("htmlTextData"),c(B)}}const ex={name:"labelEnd",resolveAll:eC,resolveTo:tC,tokenize:nC},WS={tokenize:rC},QS={tokenize:sC},JS={tokenize:aC};function eC(e){let n=-1;const s=[];for(;++n<e.length;){const l=e[n][1];if(s.push(e[n]),l.type==="labelImage"||l.type==="labelLink"||l.type==="labelEnd"){const o=l.type==="labelImage"?4:2;l.type="data",n+=o}}return e.length!==s.length&&Pr(e,0,e.length,s),e}function tC(e,n){let s=e.length,l=0,o,d,c,h;for(;s--;)if(o=e[s][1],d){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[s][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(e[s][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(d=s,o.type!=="labelLink")){l=2;break}}else o.type==="labelEnd"&&(c=s);const m={type:e[d][1].type==="labelLink"?"link":"image",start:{...e[d][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[d][1].start},end:{...e[c][1].end}},g={type:"labelText",start:{...e[d+l+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",m,n],["enter",f,n]],h=rs(h,e.slice(d+1,d+l+3)),h=rs(h,[["enter",g,n]]),h=rs(h,Zd(n.parser.constructs.insideSpan.null,e.slice(d+l+4,c-3),n)),h=rs(h,[["exit",g,n],e[c-2],e[c-1],["exit",f,n]]),h=rs(h,e.slice(c+1)),h=rs(h,[["exit",m,n]]),Pr(e,d,e.length,h),e}function nC(e,n,s){const l=this;let o=l.events.length,d,c;for(;o--;)if((l.events[o][1].type==="labelImage"||l.events[o][1].type==="labelLink")&&!l.events[o][1]._balanced){d=l.events[o][1];break}return h;function h(p){return d?d._inactive?x(p):(c=l.parser.defined.includes(hs(l.sliceSerialize({start:d.end,end:l.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),m):s(p)}function m(p){return p===40?e.attempt(WS,g,c?g:x)(p):p===91?e.attempt(QS,g,c?f:x)(p):c?g(p):x(p)}function f(p){return e.attempt(JS,g,x)(p)}function g(p){return n(p)}function x(p){return d._balanced=!0,s(p)}}function rC(e,n,s){return l;function l(x){return e.enter("resource"),e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),o}function o(x){return bn(x)?wo(e,d)(x):d(x)}function d(x){return x===41?g(x):D1(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(x)}function c(x){return bn(x)?wo(e,m)(x):g(x)}function h(x){return s(x)}function m(x){return x===34||x===39||x===40?I1(e,f,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(x):g(x)}function f(x){return bn(x)?wo(e,g)(x):g(x)}function g(x){return x===41?(e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),e.exit("resource"),n):s(x)}}function sC(e,n,s){const l=this;return o;function o(h){return L1.call(l,e,d,c,"reference","referenceMarker","referenceString")(h)}function d(h){return l.parser.defined.includes(hs(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)))?n(h):s(h)}function c(h){return s(h)}}function aC(e,n,s){return l;function l(d){return e.enter("reference"),e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),o}function o(d){return d===93?(e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),e.exit("reference"),n):s(d)}}const lC={name:"labelStartImage",resolveAll:ex.resolveAll,tokenize:iC};function iC(e,n,s){const l=this;return o;function o(h){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(h),e.exit("labelImageMarker"),d}function d(h){return h===91?(e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelImage"),c):s(h)}function c(h){return h===94&&"_hiddenFootnoteSupport"in l.parser.constructs?s(h):n(h)}}const oC={name:"labelStartLink",resolveAll:ex.resolveAll,tokenize:cC};function cC(e,n,s){const l=this;return o;function o(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),d}function d(c){return c===94&&"_hiddenFootnoteSupport"in l.parser.constructs?s(c):n(c)}}const Nh={name:"lineEnding",tokenize:dC};function dC(e,n){return s;function s(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Qt(e,n,"linePrefix")}}const yd={name:"thematicBreak",tokenize:uC};function uC(e,n,s){let l=0,o;return d;function d(f){return e.enter("thematicBreak"),c(f)}function c(f){return o=f,h(f)}function h(f){return f===o?(e.enter("thematicBreakSequence"),m(f)):l>=3&&(f===null||wt(f))?(e.exit("thematicBreak"),n(f)):s(f)}function m(f){return f===o?(e.consume(f),l++,m):(e.exit("thematicBreakSequence"),Ft(f)?Qt(e,h,"whitespace")(f):h(f))}}const Er={continuation:{tokenize:xC},exit:pC,name:"list",tokenize:mC},fC={partial:!0,tokenize:bC},hC={partial:!0,tokenize:gC};function mC(e,n,s){const l=this,o=l.events[l.events.length-1];let d=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return h;function h(y){const w=l.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||y===l.containerState.marker:xm(y)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(yd,s,f)(y):f(y);if(!l.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(y)}return s(y)}function m(y){return xm(y)&&++c<10?(e.consume(y),m):(!l.interrupt||c<2)&&(l.containerState.marker?y===l.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):s(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||y,e.check(qo,l.interrupt?s:g,e.attempt(fC,p,x))}function g(y){return l.containerState.initialBlankLine=!0,d++,p(y)}function x(y){return Ft(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),p):s(y)}function p(y){return l.containerState.size=d+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(y)}}function xC(e,n,s){const l=this;return l.containerState._closeFlow=void 0,e.check(qo,o,d);function o(h){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Qt(e,n,"listItemIndent",l.containerState.size+1)(h)}function d(h){return l.containerState.furtherBlankLines||!Ft(h)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,c(h)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(hC,n,c)(h))}function c(h){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qt(e,e.attempt(Er,n,s),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function gC(e,n,s){const l=this;return Qt(e,o,"listItemIndent",l.containerState.size+1);function o(d){const c=l.events[l.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===l.containerState.size?n(d):s(d)}}function pC(e){e.exit(this.containerState.type)}function bC(e,n,s){const l=this;return Qt(e,o,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(d){const c=l.events[l.events.length-1];return!Ft(d)&&c&&c[1].type==="listItemPrefixWhitespace"?n(d):s(d)}}const Hb={name:"setextUnderline",resolveTo:yC,tokenize:vC};function yC(e,n){let s=e.length,l,o,d;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){l=s;break}e[s][1].type==="paragraph"&&(o=s)}else e[s][1].type==="content"&&e.splice(s,1),!d&&e[s][1].type==="definition"&&(d=s);const c={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",d?(e.splice(o,0,["enter",c,n]),e.splice(d+1,0,["exit",e[l][1],n]),e[l][1].end={...e[d][1].end}):e[l][1]=c,e.push(["exit",c,n]),e}function vC(e,n,s){const l=this;let o;return d;function d(f){let g=l.events.length,x;for(;g--;)if(l.events[g][1].type!=="lineEnding"&&l.events[g][1].type!=="linePrefix"&&l.events[g][1].type!=="content"){x=l.events[g][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||x)?(e.enter("setextHeadingLine"),o=f,c(f)):s(f)}function c(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===o?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),Ft(f)?Qt(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||wt(f)?(e.exit("setextHeadingLine"),n(f)):s(f)}}const jC={tokenize:wC};function wC(e){const n=this,s=e.attempt(qo,l,e.attempt(this.parser.constructs.flowInitial,o,Qt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(ES,o)),"linePrefix")));return s;function l(d){if(d===null){e.consume(d);return}return e.enter("lineEndingBlank"),e.consume(d),e.exit("lineEndingBlank"),n.currentConstruct=void 0,s}function o(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),n.currentConstruct=void 0,s}}const NC={resolveAll:$1()},kC=z1("string"),SC=z1("text");function z1(e){return{resolveAll:$1(e==="text"?CC:void 0),tokenize:n};function n(s){const l=this,o=this.parser.constructs[e],d=s.attempt(o,c,h);return c;function c(g){return f(g)?d(g):h(g)}function h(g){if(g===null){s.consume(g);return}return s.enter("data"),s.consume(g),m}function m(g){return f(g)?(s.exit("data"),d(g)):(s.consume(g),m)}function f(g){if(g===null)return!0;const x=o[g];let p=-1;if(x)for(;++p<x.length;){const y=x[p];if(!y.previous||y.previous.call(l,l.previous))return!0}return!1}}}function $1(e){return n;function n(s,l){let o=-1,d;for(;++o<=s.length;)d===void 0?s[o]&&s[o][1].type==="data"&&(d=o,o++):(!s[o]||s[o][1].type!=="data")&&(o!==d+2&&(s[d][1].end=s[o-1][1].end,s.splice(d+2,o-d-2),o=d+2),d=void 0);return e?e(s,l):s}}function CC(e,n){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const l=e[s-1][1],o=n.sliceStream(l);let d=o.length,c=-1,h=0,m;for(;d--;){const f=o[d];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(f===-2)m=!0,h++;else if(f!==-1){d++;break}}if(n._contentTypeTextTrailing&&s===e.length&&(h=0),h){const f={type:s===e.length||m||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:d?c:l.start._bufferIndex+c,_index:l.start._index+d,line:l.end.line,column:l.end.column-h,offset:l.end.offset-h},end:{...l.end}};l.end={...f.start},l.start.offset===l.end.offset?Object.assign(l,f):(e.splice(s,0,["enter",f,n],["exit",f,n]),s+=2)}s++}return e}const EC={42:Er,43:Er,45:Er,48:Er,49:Er,50:Er,51:Er,52:Er,53:Er,54:Er,55:Er,56:Er,57:Er,62:_1},TC={91:OS},AC={[-2]:wh,[-1]:wh,32:wh},_C={35:$S,42:yd,45:[Hb,yd],60:US,61:Hb,95:yd,96:$b,126:$b},MC={38:O1,92:M1},OC={[-5]:Nh,[-4]:Nh,[-3]:Nh,33:lC,38:O1,42:gm,60:[oS,KS],91:oC,92:[IS,M1],93:ex,95:gm,96:jS},RC={null:[gm,NC]},DC={null:[42,95]},LC={null:[]},IC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:DC,contentInitial:TC,disable:LC,document:EC,flow:_C,flowInitial:AC,insideSpan:RC,string:MC,text:OC},Symbol.toStringTag,{value:"Module"}));function zC(e,n,s){let l={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const o={},d=[];let c=[],h=[];const m={attempt:Y(R),check:Y(D),consume:O,enter:k,exit:S,interrupt:Y(D,{interrupt:!0})},f={code:null,containerState:{},defineSkip:N,events:[],now:w,parser:e,previous:null,sliceSerialize:p,sliceStream:y,write:x};let g=n.tokenize.call(f,m);return n.resolveAll&&d.push(n),f;function x(G){return c=rs(c,G),C(),c[c.length-1]!==null?[]:(z(n,0),f.events=Zd(d,f.events,f),f.events)}function p(G,V){return BC(y(G),V)}function y(G){return $C(c,G)}function w(){const{_bufferIndex:G,_index:V,line:E,column:T,offset:L}=l;return{_bufferIndex:G,_index:V,line:E,column:T,offset:L}}function N(G){o[G.line]=G.column,U()}function C(){let G;for(;l._index<c.length;){const V=c[l._index];if(typeof V=="string")for(G=l._index,l._bufferIndex<0&&(l._bufferIndex=0);l._index===G&&l._bufferIndex<V.length;)_(V.charCodeAt(l._bufferIndex));else _(V)}}function _(G){g=g(G)}function O(G){wt(G)?(l.line++,l.column=1,l.offset+=G===-3?2:1,U()):G!==-1&&(l.column++,l.offset++),l._bufferIndex<0?l._index++:(l._bufferIndex++,l._bufferIndex===c[l._index].length&&(l._bufferIndex=-1,l._index++)),f.previous=G}function k(G,V){const E=V||{};return E.type=G,E.start=w(),f.events.push(["enter",E,f]),h.push(E),E}function S(G){const V=h.pop();return V.end=w(),f.events.push(["exit",V,f]),V}function R(G,V){z(G,V.from)}function D(G,V){V.restore()}function Y(G,V){return E;function E(T,L,A){let P,q,W,B;return Array.isArray(T)?X(T):"tokenize"in T?X([T]):F(T);function F(Z){return ee;function ee(ne){const ae=ne!==null&&Z[ne],he=ne!==null&&Z.null,Ne=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(he)?he:he?[he]:[]];return X(Ne)(ne)}}function X(Z){return P=Z,q=0,Z.length===0?A:I(Z[q])}function I(Z){return ee;function ee(ne){return B=K(),W=Z,Z.partial||(f.currentConstruct=Z),Z.name&&f.parser.constructs.disable.null.includes(Z.name)?H():Z.tokenize.call(V?Object.assign(Object.create(f),V):f,m,M,H)(ne)}}function M(Z){return G(W,B),L}function H(Z){return B.restore(),++q<P.length?I(P[q]):A}}}function z(G,V){G.resolveAll&&!d.includes(G)&&d.push(G),G.resolve&&Pr(f.events,V,f.events.length-V,G.resolve(f.events.slice(V),f)),G.resolveTo&&(f.events=G.resolveTo(f.events,f))}function K(){const G=w(),V=f.previous,E=f.currentConstruct,T=f.events.length,L=Array.from(h);return{from:T,restore:A};function A(){l=G,f.previous=V,f.currentConstruct=E,f.events.length=T,h=L,U()}}function U(){l.line in o&&l.column<2&&(l.column=o[l.line],l.offset+=o[l.line]-1)}}function $C(e,n){const s=n.start._index,l=n.start._bufferIndex,o=n.end._index,d=n.end._bufferIndex;let c;if(s===o)c=[e[s].slice(l,d)];else{if(c=e.slice(s,o),l>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(l):c.shift()}d>0&&c.push(e[o].slice(0,d))}return c}function BC(e,n){let s=-1;const l=[];let o;for(;++s<e.length;){const d=e[s];let c;if(typeof d=="string")c=d;else switch(d){case-5:{c="\r";break}case-4:{c=`
12
- `;break}case-3:{c=`\r
13
- `;break}case-2:{c=n?" ":" ";break}case-1:{if(!n&&o)continue;c=" ";break}default:c=String.fromCharCode(d)}o=d===-2,l.push(c)}return l.join("")}function HC(e){const l={constructs:T1([IC,...(e||{}).extensions||[]]),content:o(tS),defined:[],document:o(rS),flow:o(jC),lazy:{},string:o(kC),text:o(SC)};return l;function o(d){return c;function c(h){return zC(l,d,h)}}}function PC(e){for(;!R1(e););return e}const Pb=/[\0\t\n\r]/g;function UC(){let e=1,n="",s=!0,l;return o;function o(d,c,h){const m=[];let f,g,x,p,y;for(d=n+(typeof d=="string"?d.toString():new TextDecoder(c||void 0).decode(d)),x=0,n="",s&&(d.charCodeAt(0)===65279&&x++,s=void 0);x<d.length;){if(Pb.lastIndex=x,f=Pb.exec(d),p=f&&f.index!==void 0?f.index:d.length,y=d.charCodeAt(p),!f){n=d.slice(x);break}if(y===10&&x===p&&l)m.push(-3),l=void 0;else switch(l&&(m.push(-5),l=void 0),x<p&&(m.push(d.slice(x,p)),e+=p-x),y){case 0:{m.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,m.push(-2);e++<g;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:l=!0,e=1}x=p+1}return h&&(l&&m.push(-5),n&&m.push(n),m.push(null)),m}}const qC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function VC(e){return e.replace(qC,FC)}function FC(e,n,s){if(n)return n;if(s.charCodeAt(0)===35){const o=s.charCodeAt(1),d=o===120||o===88;return A1(s.slice(d?2:1),d?16:10)}return Jm(s)||e}const B1={}.hasOwnProperty;function YC(e,n,s){return n&&typeof n=="object"&&(s=n,n=void 0),GC(s)(PC(HC(s).document().write(UC()(e,n,!0))))}function GC(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(et),autolinkProtocol:K,autolinkEmail:K,atxHeading:d(Ae),blockQuote:d(he),characterEscape:K,characterReference:K,codeFenced:d(Ne),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:d(Ne,c),codeText:d(Le,c),codeTextData:K,data:K,codeFlowValue:K,definition:d(ye),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:d(je),hardBreakEscape:d($e),hardBreakTrailing:d($e),htmlFlow:d(Xe,c),htmlFlowData:K,htmlText:d(Xe,c),htmlTextData:K,image:d(tt),label:c,link:d(et),listItem:d(se),listItemValue:p,listOrdered:d(_t,x),listUnordered:d(_t),paragraph:d(Te),reference:I,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(Ae),strong:d(nt),thematicBreak:d(Xt)},exit:{atxHeading:m(),atxHeadingSequence:R,autolink:m(),autolinkEmail:ae,autolinkProtocol:ne,blockQuote:m(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:H,characterReferenceMarkerNumeric:H,characterReferenceValue:Z,characterReference:ee,codeFenced:m(C),codeFencedFence:N,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:U,codeIndented:m(_),codeText:m(L),codeTextData:U,data:U,definition:m(),definitionDestinationString:S,definitionLabelString:O,definitionTitleString:k,emphasis:m(),hardBreakEscape:m(V),hardBreakTrailing:m(V),htmlFlow:m(E),htmlFlowData:U,htmlText:m(T),htmlTextData:U,image:m(P),label:W,labelText:q,lineEnding:G,link:m(A),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:M,resourceDestinationString:B,resourceTitleString:F,resource:X,setextHeading:m(z),setextHeadingLineSequence:Y,setextHeadingText:D,strong:m(),thematicBreak:m()}};H1(n,(e||{}).mdastExtensions||[]);const s={};return l;function l(we){let De={type:"root",children:[]};const Pe={stack:[De],tokenStack:[],config:n,enter:h,exit:f,buffer:c,resume:g,data:s},Ze=[];let mt=-1;for(;++mt<we.length;)if(we[mt][1].type==="listOrdered"||we[mt][1].type==="listUnordered")if(we[mt][0]==="enter")Ze.push(mt);else{const Kt=Ze.pop();mt=o(we,Kt,mt)}for(mt=-1;++mt<we.length;){const Kt=n[we[mt][0]];B1.call(Kt,we[mt][1].type)&&Kt[we[mt][1].type].call(Object.assign({sliceSerialize:we[mt][2].sliceSerialize},Pe),we[mt][1])}if(Pe.tokenStack.length>0){const Kt=Pe.tokenStack[Pe.tokenStack.length-1];(Kt[1]||Ub).call(Pe,void 0,Kt[0])}for(De.position={start:Ta(we.length>0?we[0][1].start:{line:1,column:1,offset:0}),end:Ta(we.length>0?we[we.length-2][1].end:{line:1,column:1,offset:0})},mt=-1;++mt<n.transforms.length;)De=n.transforms[mt](De)||De;return De}function o(we,De,Pe){let Ze=De-1,mt=-1,Kt=!1,ln,Ht,Lt,At;for(;++Ze<=Pe;){const St=we[Ze];switch(St[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{St[0]==="enter"?mt++:mt--,At=void 0;break}case"lineEndingBlank":{St[0]==="enter"&&(ln&&!At&&!mt&&!Lt&&(Lt=Ze),At=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:At=void 0}if(!mt&&St[0]==="enter"&&St[1].type==="listItemPrefix"||mt===-1&&St[0]==="exit"&&(St[1].type==="listUnordered"||St[1].type==="listOrdered")){if(ln){let en=Ze;for(Ht=void 0;en--;){const tn=we[en];if(tn[1].type==="lineEnding"||tn[1].type==="lineEndingBlank"){if(tn[0]==="exit")continue;Ht&&(we[Ht][1].type="lineEndingBlank",Kt=!0),tn[1].type="lineEnding",Ht=en}else if(!(tn[1].type==="linePrefix"||tn[1].type==="blockQuotePrefix"||tn[1].type==="blockQuotePrefixWhitespace"||tn[1].type==="blockQuoteMarker"||tn[1].type==="listItemIndent"))break}Lt&&(!Ht||Lt<Ht)&&(ln._spread=!0),ln.end=Object.assign({},Ht?we[Ht][1].start:St[1].end),we.splice(Ht||Ze,0,["exit",ln,St[2]]),Ze++,Pe++}if(St[1].type==="listItemPrefix"){const en={type:"listItem",_spread:!1,start:Object.assign({},St[1].start),end:void 0};ln=en,we.splice(Ze,0,["enter",en,St[2]]),Ze++,Pe++,Lt=void 0,At=!0}}}return we[De][1]._spread=Kt,Pe}function d(we,De){return Pe;function Pe(Ze){h.call(this,we(Ze),Ze),De&&De.call(this,Ze)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(we,De,Pe){this.stack[this.stack.length-1].children.push(we),this.stack.push(we),this.tokenStack.push([De,Pe||void 0]),we.position={start:Ta(De.start),end:void 0}}function m(we){return De;function De(Pe){we&&we.call(this,Pe),f.call(this,Pe)}}function f(we,De){const Pe=this.stack.pop(),Ze=this.tokenStack.pop();if(Ze)Ze[0].type!==we.type&&(De?De.call(this,we,Ze[0]):(Ze[1]||Ub).call(this,we,Ze[0]));else throw new Error("Cannot close `"+we.type+"` ("+jo({start:we.start,end:we.end})+"): it’s not open");Pe.position.end=Ta(we.end)}function g(){return Qm(this.stack.pop())}function x(){this.data.expectingFirstListItemValue=!0}function p(we){if(this.data.expectingFirstListItemValue){const De=this.stack[this.stack.length-2];De.start=Number.parseInt(this.sliceSerialize(we),10),this.data.expectingFirstListItemValue=void 0}}function y(){const we=this.resume(),De=this.stack[this.stack.length-1];De.lang=we}function w(){const we=this.resume(),De=this.stack[this.stack.length-1];De.meta=we}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const we=this.resume(),De=this.stack[this.stack.length-1];De.value=we.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const we=this.resume(),De=this.stack[this.stack.length-1];De.value=we.replace(/(\r?\n|\r)$/g,"")}function O(we){const De=this.resume(),Pe=this.stack[this.stack.length-1];Pe.label=De,Pe.identifier=hs(this.sliceSerialize(we)).toLowerCase()}function k(){const we=this.resume(),De=this.stack[this.stack.length-1];De.title=we}function S(){const we=this.resume(),De=this.stack[this.stack.length-1];De.url=we}function R(we){const De=this.stack[this.stack.length-1];if(!De.depth){const Pe=this.sliceSerialize(we).length;De.depth=Pe}}function D(){this.data.setextHeadingSlurpLineEnding=!0}function Y(we){const De=this.stack[this.stack.length-1];De.depth=this.sliceSerialize(we).codePointAt(0)===61?1:2}function z(){this.data.setextHeadingSlurpLineEnding=void 0}function K(we){const Pe=this.stack[this.stack.length-1].children;let Ze=Pe[Pe.length-1];(!Ze||Ze.type!=="text")&&(Ze=yt(),Ze.position={start:Ta(we.start),end:void 0},Pe.push(Ze)),this.stack.push(Ze)}function U(we){const De=this.stack.pop();De.value+=this.sliceSerialize(we),De.position.end=Ta(we.end)}function G(we){const De=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Pe=De.children[De.children.length-1];Pe.position.end=Ta(we.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(De.type)&&(K.call(this,we),U.call(this,we))}function V(){this.data.atHardBreak=!0}function E(){const we=this.resume(),De=this.stack[this.stack.length-1];De.value=we}function T(){const we=this.resume(),De=this.stack[this.stack.length-1];De.value=we}function L(){const we=this.resume(),De=this.stack[this.stack.length-1];De.value=we}function A(){const we=this.stack[this.stack.length-1];if(this.data.inReference){const De=this.data.referenceType||"shortcut";we.type+="Reference",we.referenceType=De,delete we.url,delete we.title}else delete we.identifier,delete we.label;this.data.referenceType=void 0}function P(){const we=this.stack[this.stack.length-1];if(this.data.inReference){const De=this.data.referenceType||"shortcut";we.type+="Reference",we.referenceType=De,delete we.url,delete we.title}else delete we.identifier,delete we.label;this.data.referenceType=void 0}function q(we){const De=this.sliceSerialize(we),Pe=this.stack[this.stack.length-2];Pe.label=VC(De),Pe.identifier=hs(De).toLowerCase()}function W(){const we=this.stack[this.stack.length-1],De=this.resume(),Pe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Pe.type==="link"){const Ze=we.children;Pe.children=Ze}else Pe.alt=De}function B(){const we=this.resume(),De=this.stack[this.stack.length-1];De.url=we}function F(){const we=this.resume(),De=this.stack[this.stack.length-1];De.title=we}function X(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function M(we){const De=this.resume(),Pe=this.stack[this.stack.length-1];Pe.label=De,Pe.identifier=hs(this.sliceSerialize(we)).toLowerCase(),this.data.referenceType="full"}function H(we){this.data.characterReferenceType=we.type}function Z(we){const De=this.sliceSerialize(we),Pe=this.data.characterReferenceType;let Ze;Pe?(Ze=A1(De,Pe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ze=Jm(De);const mt=this.stack[this.stack.length-1];mt.value+=Ze}function ee(we){const De=this.stack.pop();De.position.end=Ta(we.end)}function ne(we){U.call(this,we);const De=this.stack[this.stack.length-1];De.url=this.sliceSerialize(we)}function ae(we){U.call(this,we);const De=this.stack[this.stack.length-1];De.url="mailto:"+this.sliceSerialize(we)}function he(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function Le(){return{type:"inlineCode",value:""}}function ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function je(){return{type:"emphasis",children:[]}}function Ae(){return{type:"heading",depth:0,children:[]}}function $e(){return{type:"break"}}function Xe(){return{type:"html",value:""}}function tt(){return{type:"image",title:null,url:"",alt:null}}function et(){return{type:"link",title:null,url:"",children:[]}}function _t(we){return{type:"list",ordered:we.type==="listOrdered",start:null,spread:we._spread,children:[]}}function se(we){return{type:"listItem",spread:we._spread,checked:null,children:[]}}function Te(){return{type:"paragraph",children:[]}}function nt(){return{type:"strong",children:[]}}function yt(){return{type:"text",value:""}}function Xt(){return{type:"thematicBreak"}}}function Ta(e){return{line:e.line,column:e.column,offset:e.offset}}function H1(e,n){let s=-1;for(;++s<n.length;){const l=n[s];Array.isArray(l)?H1(e,l):XC(e,l)}}function XC(e,n){let s;for(s in n)if(B1.call(n,s))switch(s){case"canContainEols":{const l=n[s];l&&e[s].push(...l);break}case"transforms":{const l=n[s];l&&e[s].push(...l);break}case"enter":case"exit":{const l=n[s];l&&Object.assign(e[s],l);break}}}function Ub(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+jo({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+jo({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+jo({start:n.start,end:n.end})+") is still open")}function KC(e){const n=this;n.parser=s;function s(l){return YC(l,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function ZC(e,n){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,s),e.applyData(n,s)}function WC(e,n){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,s),[e.applyData(n,s),{type:"text",value:`
14
- `}]}function QC(e,n){const s=n.value?n.value+`
15
- `:"",l={},o=n.lang?n.lang.split(/\s+/):[];o.length>0&&(l.className=["language-"+o[0]]);let d={type:"element",tagName:"code",properties:l,children:[{type:"text",value:s}]};return n.meta&&(d.data={meta:n.meta}),e.patch(n,d),d=e.applyData(n,d),d={type:"element",tagName:"pre",properties:{},children:[d]},e.patch(n,d),d}function JC(e,n){const s={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function eE(e,n){const s={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function tE(e,n){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(n.identifier).toUpperCase(),o=pi(l.toLowerCase()),d=e.footnoteOrder.indexOf(l);let c,h=e.footnoteCounts.get(l);h===void 0?(h=0,e.footnoteOrder.push(l),c=e.footnoteOrder.length):c=d+1,h+=1,e.footnoteCounts.set(l,h);const m={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(n,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(n,f),e.applyData(n,f)}function nE(e,n){const s={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function rE(e,n){if(e.options.allowDangerousHtml){const s={type:"raw",value:n.value};return e.patch(n,s),e.applyData(n,s)}}function P1(e,n){const s=n.referenceType;let l="]";if(s==="collapsed"?l+="[]":s==="full"&&(l+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+l}];const o=e.all(n),d=o[0];d&&d.type==="text"?d.value="["+d.value:o.unshift({type:"text",value:"["});const c=o[o.length-1];return c&&c.type==="text"?c.value+=l:o.push({type:"text",value:l}),o}function sE(e,n){const s=String(n.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return P1(e,n);const o={src:pi(l.url||""),alt:n.alt};l.title!==null&&l.title!==void 0&&(o.title=l.title);const d={type:"element",tagName:"img",properties:o,children:[]};return e.patch(n,d),e.applyData(n,d)}function aE(e,n){const s={src:pi(n.url)};n.alt!==null&&n.alt!==void 0&&(s.alt=n.alt),n.title!==null&&n.title!==void 0&&(s.title=n.title);const l={type:"element",tagName:"img",properties:s,children:[]};return e.patch(n,l),e.applyData(n,l)}function lE(e,n){const s={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,s);const l={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(n,l),e.applyData(n,l)}function iE(e,n){const s=String(n.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return P1(e,n);const o={href:pi(l.url||"")};l.title!==null&&l.title!==void 0&&(o.title=l.title);const d={type:"element",tagName:"a",properties:o,children:e.all(n)};return e.patch(n,d),e.applyData(n,d)}function oE(e,n){const s={href:pi(n.url)};n.title!==null&&n.title!==void 0&&(s.title=n.title);const l={type:"element",tagName:"a",properties:s,children:e.all(n)};return e.patch(n,l),e.applyData(n,l)}function cE(e,n,s){const l=e.all(n),o=s?dE(s):U1(n),d={},c=[];if(typeof n.checked=="boolean"){const g=l[0];let x;g&&g.type==="element"&&g.tagName==="p"?x=g:(x={type:"element",tagName:"p",properties:{},children:[]},l.unshift(x)),x.children.length>0&&x.children.unshift({type:"text",value:" "}),x.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),d.className=["task-list-item"]}let h=-1;for(;++h<l.length;){const g=l[h];(o||h!==0||g.type!=="element"||g.tagName!=="p")&&c.push({type:"text",value:`
16
- `}),g.type==="element"&&g.tagName==="p"&&!o?c.push(...g.children):c.push(g)}const m=l[l.length-1];m&&(o||m.type!=="element"||m.tagName!=="p")&&c.push({type:"text",value:`
17
- `});const f={type:"element",tagName:"li",properties:d,children:c};return e.patch(n,f),e.applyData(n,f)}function dE(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const s=e.children;let l=-1;for(;!n&&++l<s.length;)n=U1(s[l])}return n}function U1(e){const n=e.spread;return n??e.children.length>1}function uE(e,n){const s={},l=e.all(n);let o=-1;for(typeof n.start=="number"&&n.start!==1&&(s.start=n.start);++o<l.length;){const c=l[o];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const d={type:"element",tagName:n.ordered?"ol":"ul",properties:s,children:e.wrap(l,!0)};return e.patch(n,d),e.applyData(n,d)}function fE(e,n){const s={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function hE(e,n){const s={type:"root",children:e.wrap(e.all(n))};return e.patch(n,s),e.applyData(n,s)}function mE(e,n){const s={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function xE(e,n){const s=e.all(n),l=s.shift(),o=[];if(l){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([l],!0)};e.patch(n.children[0],c),o.push(c)}if(s.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},h=Xm(n.children[1]),m=j1(n.children[n.children.length-1]);h&&m&&(c.position={start:h,end:m}),o.push(c)}const d={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(n,d),e.applyData(n,d)}function gE(e,n,s){const l=s?s.children:void 0,d=(l?l.indexOf(n):1)===0?"th":"td",c=s&&s.type==="table"?s.align:void 0,h=c?c.length:n.children.length;let m=-1;const f=[];for(;++m<h;){const x=n.children[m],p={},y=c?c[m]:void 0;y&&(p.align=y);let w={type:"element",tagName:d,properties:p,children:[]};x&&(w.children=e.all(x),e.patch(x,w),w=e.applyData(x,w)),f.push(w)}const g={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(n,g),e.applyData(n,g)}function pE(e,n){const s={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}const qb=9,Vb=32;function bE(e){const n=String(e),s=/\r?\n|\r/g;let l=s.exec(n),o=0;const d=[];for(;l;)d.push(Fb(n.slice(o,l.index),o>0,!0),l[0]),o=l.index+l[0].length,l=s.exec(n);return d.push(Fb(n.slice(o),o>0,!1)),d.join("")}function Fb(e,n,s){let l=0,o=e.length;if(n){let d=e.codePointAt(l);for(;d===qb||d===Vb;)l++,d=e.codePointAt(l)}if(s){let d=e.codePointAt(o-1);for(;d===qb||d===Vb;)o--,d=e.codePointAt(o-1)}return o>l?e.slice(l,o):""}function yE(e,n){const s={type:"text",value:bE(String(n.value))};return e.patch(n,s),e.applyData(n,s)}function vE(e,n){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,s),e.applyData(n,s)}const jE={blockquote:ZC,break:WC,code:QC,delete:JC,emphasis:eE,footnoteReference:tE,heading:nE,html:rE,imageReference:sE,image:aE,inlineCode:lE,linkReference:iE,link:oE,listItem:cE,list:uE,paragraph:fE,root:hE,strong:mE,table:xE,tableCell:pE,tableRow:gE,text:yE,thematicBreak:vE,toml:ad,yaml:ad,definition:ad,footnoteDefinition:ad};function ad(){}const q1=-1,Wd=0,No=1,Ed=2,tx=3,nx=4,rx=5,sx=6,V1=7,F1=8,Yb=typeof self=="object"?self:globalThis,wE=(e,n)=>{const s=(o,d)=>(e.set(d,o),o),l=o=>{if(e.has(o))return e.get(o);const[d,c]=n[o];switch(d){case Wd:case q1:return s(c,o);case No:{const h=s([],o);for(const m of c)h.push(l(m));return h}case Ed:{const h=s({},o);for(const[m,f]of c)h[l(m)]=l(f);return h}case tx:return s(new Date(c),o);case nx:{const{source:h,flags:m}=c;return s(new RegExp(h,m),o)}case rx:{const h=s(new Map,o);for(const[m,f]of c)h.set(l(m),l(f));return h}case sx:{const h=s(new Set,o);for(const m of c)h.add(l(m));return h}case V1:{const{name:h,message:m}=c;return s(new Yb[h](m),o)}case F1:return s(BigInt(c),o);case"BigInt":return s(Object(BigInt(c)),o);case"ArrayBuffer":return s(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:h}=new Uint8Array(c);return s(new DataView(h),c)}}return s(new Yb[d](c),o)};return l},Gb=e=>wE(new Map,e)(0),Gl="",{toString:NE}={},{keys:kE}=Object,uo=e=>{const n=typeof e;if(n!=="object"||!e)return[Wd,n];const s=NE.call(e).slice(8,-1);switch(s){case"Array":return[No,Gl];case"Object":return[Ed,Gl];case"Date":return[tx,Gl];case"RegExp":return[nx,Gl];case"Map":return[rx,Gl];case"Set":return[sx,Gl];case"DataView":return[No,s]}return s.includes("Array")?[No,s]:s.includes("Error")?[V1,s]:[Ed,s]},ld=([e,n])=>e===Wd&&(n==="function"||n==="symbol"),SE=(e,n,s,l)=>{const o=(c,h)=>{const m=l.push(c)-1;return s.set(h,m),m},d=c=>{if(s.has(c))return s.get(c);let[h,m]=uo(c);switch(h){case Wd:{let g=c;switch(m){case"bigint":h=F1,g=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);g=null;break;case"undefined":return o([q1],c)}return o([h,g],c)}case No:{if(m){let p=c;return m==="DataView"?p=new Uint8Array(c.buffer):m==="ArrayBuffer"&&(p=new Uint8Array(c)),o([m,[...p]],c)}const g=[],x=o([h,g],c);for(const p of c)g.push(d(p));return x}case Ed:{if(m)switch(m){case"BigInt":return o([m,c.toString()],c);case"Boolean":case"Number":case"String":return o([m,c.valueOf()],c)}if(n&&"toJSON"in c)return d(c.toJSON());const g=[],x=o([h,g],c);for(const p of kE(c))(e||!ld(uo(c[p])))&&g.push([d(p),d(c[p])]);return x}case tx:return o([h,c.toISOString()],c);case nx:{const{source:g,flags:x}=c;return o([h,{source:g,flags:x}],c)}case rx:{const g=[],x=o([h,g],c);for(const[p,y]of c)(e||!(ld(uo(p))||ld(uo(y))))&&g.push([d(p),d(y)]);return x}case sx:{const g=[],x=o([h,g],c);for(const p of c)(e||!ld(uo(p)))&&g.push(d(p));return x}}const{message:f}=c;return o([h,{name:m,message:f}],c)};return d},Xb=(e,{json:n,lossy:s}={})=>{const l=[];return SE(!(n||s),!!n,new Map,l)(e),l},Td=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?Gb(Xb(e,n)):structuredClone(e):(e,n)=>Gb(Xb(e,n));function CE(e,n){const s=[{type:"text",value:"↩"}];return n>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),s}function EE(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function TE(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||CE,l=e.options.footnoteBackLabel||EE,o=e.options.footnoteLabel||"Footnotes",d=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let m=-1;for(;++m<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[m]);if(!f)continue;const g=e.all(f),x=String(f.identifier).toUpperCase(),p=pi(x.toLowerCase());let y=0;const w=[],N=e.footnoteCounts.get(x);for(;N!==void 0&&++y<=N;){w.length>0&&w.push({type:"text",value:" "});let O=typeof s=="string"?s:s(m,y);typeof O=="string"&&(O={type:"text",value:O}),w.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+p+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(m,y),className:["data-footnote-backref"]},children:Array.isArray(O)?O:[O]})}const C=g[g.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const O=C.children[C.children.length-1];O&&O.type==="text"?O.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...w)}else g.push(...w);const _={type:"element",tagName:"li",properties:{id:n+"fn-"+p},children:e.wrap(g,!0)};e.patch(f,_),h.push(_)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:d,properties:{...Td(c),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
18
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
19
- `}]}}const Qd=(function(e){if(e==null)return OE;if(typeof e=="function")return Jd(e);if(typeof e=="object")return Array.isArray(e)?AE(e):_E(e);if(typeof e=="string")return ME(e);throw new Error("Expected function, string, or object as test")});function AE(e){const n=[];let s=-1;for(;++s<e.length;)n[s]=Qd(e[s]);return Jd(l);function l(...o){let d=-1;for(;++d<n.length;)if(n[d].apply(this,o))return!0;return!1}}function _E(e){const n=e;return Jd(s);function s(l){const o=l;let d;for(d in e)if(o[d]!==n[d])return!1;return!0}}function ME(e){return Jd(n);function n(s){return s&&s.type===e}}function Jd(e){return n;function n(s,l,o){return!!(RE(s)&&e.call(this,s,typeof l=="number"?l:void 0,o||void 0))}}function OE(){return!0}function RE(e){return e!==null&&typeof e=="object"&&"type"in e}const Y1=[],DE=!0,pm=!1,LE="skip";function G1(e,n,s,l){let o;typeof n=="function"&&typeof s!="function"?(l=s,s=n):o=n;const d=Qd(o),c=l?-1:1;h(e,void 0,[])();function h(m,f,g){const x=m&&typeof m=="object"?m:{};if(typeof x.type=="string"){const y=typeof x.tagName=="string"?x.tagName:typeof x.name=="string"?x.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(m.type+(y?"<"+y+">":""))+")"})}return p;function p(){let y=Y1,w,N,C;if((!n||d(m,f,g[g.length-1]||void 0))&&(y=IE(s(m,g)),y[0]===pm))return y;if("children"in m&&m.children){const _=m;if(_.children&&y[0]!==LE)for(N=(l?_.children.length:-1)+c,C=g.concat(_);N>-1&&N<_.children.length;){const O=_.children[N];if(w=h(O,N,C)(),w[0]===pm)return w;N=typeof w[1]=="number"?w[1]:N+c}}return y}}}function IE(e){return Array.isArray(e)?e:typeof e=="number"?[DE,e]:e==null?Y1:[e]}function ax(e,n,s,l){let o,d,c;typeof n=="function"&&typeof s!="function"?(d=void 0,c=n,o=s):(d=n,c=s,o=l),G1(e,d,h,o);function h(m,f){const g=f[f.length-1],x=g?g.children.indexOf(m):void 0;return c(m,x,g)}}const bm={}.hasOwnProperty,zE={};function $E(e,n){const s=n||zE,l=new Map,o=new Map,d=new Map,c={...jE,...s.handlers},h={all:f,applyData:HE,definitionById:l,footnoteById:o,footnoteCounts:d,footnoteOrder:[],handlers:c,one:m,options:s,patch:BE,wrap:UE};return ax(e,function(g){if(g.type==="definition"||g.type==="footnoteDefinition"){const x=g.type==="definition"?l:o,p=String(g.identifier).toUpperCase();x.has(p)||x.set(p,g)}}),h;function m(g,x){const p=g.type,y=h.handlers[p];if(bm.call(h.handlers,p)&&y)return y(h,g,x);if(h.options.passThrough&&h.options.passThrough.includes(p)){if("children"in g){const{children:N,...C}=g,_=Td(C);return _.children=h.all(g),_}return Td(g)}return(h.options.unknownHandler||PE)(h,g,x)}function f(g){const x=[];if("children"in g){const p=g.children;let y=-1;for(;++y<p.length;){const w=h.one(p[y],g);if(w){if(y&&p[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Kb(w.value)),!Array.isArray(w)&&w.type==="element")){const N=w.children[0];N&&N.type==="text"&&(N.value=Kb(N.value))}Array.isArray(w)?x.push(...w):x.push(w)}}}return x}}function BE(e,n){e.position&&(n.position=Ek(e))}function HE(e,n){let s=n;if(e&&e.data){const l=e.data.hName,o=e.data.hChildren,d=e.data.hProperties;if(typeof l=="string")if(s.type==="element")s.tagName=l;else{const c="children"in s?s.children:[s];s={type:"element",tagName:l,properties:{},children:c}}s.type==="element"&&d&&Object.assign(s.properties,Td(d)),"children"in s&&s.children&&o!==null&&o!==void 0&&(s.children=o)}return s}function PE(e,n){const s=n.data||{},l="value"in n&&!(bm.call(s,"hProperties")||bm.call(s,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,l),e.applyData(n,l)}function UE(e,n){const s=[];let l=-1;for(n&&s.push({type:"text",value:`
20
- `});++l<e.length;)l&&s.push({type:"text",value:`
21
- `}),s.push(e[l]);return n&&e.length>0&&s.push({type:"text",value:`
22
- `}),s}function Kb(e){let n=0,s=e.charCodeAt(n);for(;s===9||s===32;)n++,s=e.charCodeAt(n);return e.slice(n)}function Zb(e,n){const s=$E(e,n),l=s.one(e,void 0),o=TE(s),d=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&d.children.push({type:"text",value:`
23
- `},o),d}function qE(e,n){return e&&"run"in e?async function(s,l){const o=Zb(s,{file:l,...n});await e.run(o,l)}:function(s,l){return Zb(s,{file:l,...e||n})}}function Wb(e){if(e)throw e}var kh,Qb;function VE(){if(Qb)return kh;Qb=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,s=Object.defineProperty,l=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):n.call(f)==="[object Array]"},d=function(f){if(!f||n.call(f)!=="[object Object]")return!1;var g=e.call(f,"constructor"),x=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!g&&!x)return!1;var p;for(p in f);return typeof p>"u"||e.call(f,p)},c=function(f,g){s&&g.name==="__proto__"?s(f,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):f[g.name]=g.newValue},h=function(f,g){if(g==="__proto__")if(e.call(f,g)){if(l)return l(f,g).value}else return;return f[g]};return kh=function m(){var f,g,x,p,y,w,N=arguments[0],C=1,_=arguments.length,O=!1;for(typeof N=="boolean"&&(O=N,N=arguments[1]||{},C=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});C<_;++C)if(f=arguments[C],f!=null)for(g in f)x=h(N,g),p=h(f,g),N!==p&&(O&&p&&(d(p)||(y=o(p)))?(y?(y=!1,w=x&&o(x)?x:[]):w=x&&d(x)?x:{},c(N,{name:g,newValue:m(O,w,p)})):typeof p<"u"&&c(N,{name:g,newValue:p}));return N},kh}var FE=VE();const Sh=Xd(FE);function ym(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function YE(){const e=[],n={run:s,use:l};return n;function s(...o){let d=-1;const c=o.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...o);function h(m,...f){const g=e[++d];let x=-1;if(m){c(m);return}for(;++x<o.length;)(f[x]===null||f[x]===void 0)&&(f[x]=o[x]);o=f,g?GE(g,h)(...f):c(null,...f)}}function l(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),n}}function GE(e,n){let s;return l;function l(...c){const h=e.length>c.length;let m;h&&c.push(o);try{m=e.apply(this,c)}catch(f){const g=f;if(h&&s)throw g;return o(g)}h||(m&&m.then&&typeof m.then=="function"?m.then(d,o):m instanceof Error?o(m):d(m))}function o(c,...h){s||(s=!0,n(c,...h))}function d(c){o(null,c)}}const ks={basename:XE,dirname:KE,extname:ZE,join:WE,sep:"/"};function XE(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Vo(e);let s=0,l=-1,o=e.length,d;if(n===void 0||n.length===0||n.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(d){s=o+1;break}}else l<0&&(d=!0,l=o+1);return l<0?"":e.slice(s,l)}if(n===e)return"";let c=-1,h=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(d){s=o+1;break}}else c<0&&(d=!0,c=o+1),h>-1&&(e.codePointAt(o)===n.codePointAt(h--)?h<0&&(l=o):(h=-1,l=c));return s===l?l=c:l<0&&(l=e.length),e.slice(s,l)}function KE(e){if(Vo(e),e.length===0)return".";let n=-1,s=e.length,l;for(;--s;)if(e.codePointAt(s)===47){if(l){n=s;break}}else l||(l=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function ZE(e){Vo(e);let n=e.length,s=-1,l=0,o=-1,d=0,c;for(;n--;){const h=e.codePointAt(n);if(h===47){if(c){l=n+1;break}continue}s<0&&(c=!0,s=n+1),h===46?o<0?o=n:d!==1&&(d=1):o>-1&&(d=-1)}return o<0||s<0||d===0||d===1&&o===s-1&&o===l+1?"":e.slice(o,s)}function WE(...e){let n=-1,s;for(;++n<e.length;)Vo(e[n]),e[n]&&(s=s===void 0?e[n]:s+"/"+e[n]);return s===void 0?".":QE(s)}function QE(e){Vo(e);const n=e.codePointAt(0)===47;let s=JE(e,!n);return s.length===0&&!n&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),n?"/"+s:s}function JE(e,n){let s="",l=0,o=-1,d=0,c=-1,h,m;for(;++c<=e.length;){if(c<e.length)h=e.codePointAt(c);else{if(h===47)break;h=47}if(h===47){if(!(o===c-1||d===1))if(o!==c-1&&d===2){if(s.length<2||l!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(m=s.lastIndexOf("/"),m!==s.length-1){m<0?(s="",l=0):(s=s.slice(0,m),l=s.length-1-s.lastIndexOf("/")),o=c,d=0;continue}}else if(s.length>0){s="",l=0,o=c,d=0;continue}}n&&(s=s.length>0?s+"/..":"..",l=2)}else s.length>0?s+="/"+e.slice(o+1,c):s=e.slice(o+1,c),l=c-o-1;o=c,d=0}else h===46&&d>-1?d++:d=-1}return s}function Vo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const e3={cwd:t3};function t3(){return"/"}function vm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function n3(e){if(typeof e=="string")e=new URL(e);else if(!vm(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return r3(e)}function r3(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const n=e.pathname;let s=-1;for(;++s<n.length;)if(n.codePointAt(s)===37&&n.codePointAt(s+1)===50){const l=n.codePointAt(s+2);if(l===70||l===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(n)}const Ch=["history","path","basename","stem","extname","dirname"];class X1{constructor(n){let s;n?vm(n)?s={path:n}:typeof n=="string"||s3(n)?s={value:n}:s=n:s={},this.cwd="cwd"in s?"":e3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Ch.length;){const d=Ch[l];d in s&&s[d]!==void 0&&s[d]!==null&&(this[d]=d==="history"?[...s[d]]:s[d])}let o;for(o in s)Ch.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?ks.basename(this.path):void 0}set basename(n){Th(n,"basename"),Eh(n,"basename"),this.path=ks.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ks.dirname(this.path):void 0}set dirname(n){Jb(this.basename,"dirname"),this.path=ks.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ks.extname(this.path):void 0}set extname(n){if(Eh(n,"extname"),Jb(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ks.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){vm(n)&&(n=n3(n)),Th(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ks.basename(this.path,this.extname):void 0}set stem(n){Th(n,"stem"),Eh(n,"stem"),this.path=ks.join(this.dirname||"",n+(this.extname||""))}fail(n,s,l){const o=this.message(n,s,l);throw o.fatal=!0,o}info(n,s,l){const o=this.message(n,s,l);return o.fatal=void 0,o}message(n,s,l){const o=new xr(n,s,l);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function Eh(e,n){if(e&&e.includes(ks.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ks.sep+"`")}function Th(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function Jb(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function s3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const a3=(function(e){const l=this.constructor.prototype,o=l[e],d=function(){return o.apply(d,arguments)};return Object.setPrototypeOf(d,l),d}),l3={}.hasOwnProperty;class lx extends a3{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=YE()}copy(){const n=new lx;let s=-1;for(;++s<this.attachers.length;){const l=this.attachers[s];n.use(...l)}return n.data(Sh(!0,{},this.namespace)),n}data(n,s){return typeof n=="string"?arguments.length===2?(Mh("data",this.frozen),this.namespace[n]=s,this):l3.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Mh("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const o=s.call(n,...l);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const s=id(n),l=this.parser||this.Parser;return Ah("parse",l),l(String(s),s)}process(n,s){const l=this;return this.freeze(),Ah("process",this.parser||this.Parser),_h("process",this.compiler||this.Compiler),s?o(void 0,s):new Promise(o);function o(d,c){const h=id(n),m=l.parse(h);l.run(m,h,function(g,x,p){if(g||!x||!p)return f(g);const y=x,w=l.stringify(y,p);c3(w)?p.value=w:p.result=w,f(g,p)});function f(g,x){g||!x?c(g):d?d(x):s(void 0,x)}}}processSync(n){let s=!1,l;return this.freeze(),Ah("processSync",this.parser||this.Parser),_h("processSync",this.compiler||this.Compiler),this.process(n,o),ty("processSync","process",s),l;function o(d,c){s=!0,Wb(d),l=c}}run(n,s,l){ey(n),this.freeze();const o=this.transformers;return!l&&typeof s=="function"&&(l=s,s=void 0),l?d(void 0,l):new Promise(d);function d(c,h){const m=id(s);o.run(n,m,f);function f(g,x,p){const y=x||n;g?h(g):c?c(y):l(void 0,y,p)}}}runSync(n,s){let l=!1,o;return this.run(n,s,d),ty("runSync","run",l),o;function d(c,h){Wb(c),o=h,l=!0}}stringify(n,s){this.freeze();const l=id(s),o=this.compiler||this.Compiler;return _h("stringify",o),ey(n),o(n,l)}use(n,...s){const l=this.attachers,o=this.namespace;if(Mh("use",this.frozen),n!=null)if(typeof n=="function")m(n,s);else if(typeof n=="object")Array.isArray(n)?h(n):c(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function d(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[g,...x]=f;m(g,x)}else c(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function c(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(f.plugins),f.settings&&(o.settings=Sh(!0,o.settings,f.settings))}function h(f){let g=-1;if(f!=null)if(Array.isArray(f))for(;++g<f.length;){const x=f[g];d(x)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,g){let x=-1,p=-1;for(;++x<l.length;)if(l[x][0]===f){p=x;break}if(p===-1)l.push([f,...g]);else if(g.length>0){let[y,...w]=g;const N=l[p][1];ym(N)&&ym(y)&&(y=Sh(!0,N,y)),l[p]=[f,y,...w]}}}}const i3=new lx().freeze();function Ah(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function _h(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Mh(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ey(e){if(!ym(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ty(e,n,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function id(e){return o3(e)?e:new X1(e)}function o3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function c3(e){return typeof e=="string"||d3(e)}function d3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const u3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",ny=[],ry={allowDangerousHtml:!0},f3=/^(https?|ircs?|mailto|xmpp)$/i,h3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function sy(e){const n=m3(e),s=x3(e);return g3(n.runSync(n.parse(s),s),e)}function m3(e){const n=e.rehypePlugins||ny,s=e.remarkPlugins||ny,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ry}:ry;return i3().use(KC).use(s).use(qE,l).use(n)}function x3(e){const n=e.children||"",s=new X1;return typeof n=="string"&&(s.value=n),s}function g3(e,n){const s=n.allowedElements,l=n.allowElement,o=n.components,d=n.disallowedElements,c=n.skipHtml,h=n.unwrapDisallowed,m=n.urlTransform||p3;for(const g of h3)Object.hasOwn(n,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+u3+g.id,void 0);return ax(e,f),Ok(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(g,x,p){if(g.type==="raw"&&p&&typeof x=="number")return c?p.children.splice(x,1):p.children[x]={type:"text",value:g.value},x;if(g.type==="element"){let y;for(y in jh)if(Object.hasOwn(jh,y)&&Object.hasOwn(g.properties,y)){const w=g.properties[y],N=jh[y];(N===null||N.includes(g.tagName))&&(g.properties[y]=m(String(w||""),y,g))}}if(g.type==="element"){let y=s?!s.includes(g.tagName):d?d.includes(g.tagName):!1;if(!y&&l&&typeof x=="number"&&(y=!l(g,x,p)),y&&p&&typeof x=="number")return h&&g.children?p.children.splice(x,1,...g.children):p.children.splice(x,1),x}}}function p3(e){const n=e.indexOf(":"),s=e.indexOf("?"),l=e.indexOf("#"),o=e.indexOf("/");return n===-1||o!==-1&&n>o||s!==-1&&n>s||l!==-1&&n>l||f3.test(e.slice(0,n))?e:""}function ay(e,n){const s=String(e);if(typeof n!="string")throw new TypeError("Expected character");let l=0,o=s.indexOf(n);for(;o!==-1;)l++,o=s.indexOf(n,o+n.length);return l}function b3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function y3(e,n,s){const o=Qd((s||{}).ignore||[]),d=v3(n);let c=-1;for(;++c<d.length;)G1(e,"text",h);function h(f,g){let x=-1,p;for(;++x<g.length;){const y=g[x],w=p?p.children:void 0;if(o(y,w?w.indexOf(y):void 0,p))return;p=y}if(p)return m(f,g)}function m(f,g){const x=g[g.length-1],p=d[c][0],y=d[c][1];let w=0;const C=x.children.indexOf(f);let _=!1,O=[];p.lastIndex=0;let k=p.exec(f.value);for(;k;){const S=k.index,R={index:k.index,input:k.input,stack:[...g,f]};let D=y(...k,R);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?p.lastIndex=S+1:(w!==S&&O.push({type:"text",value:f.value.slice(w,S)}),Array.isArray(D)?O.push(...D):D&&O.push(D),w=S+k[0].length,_=!0),!p.global)break;k=p.exec(f.value)}return _?(w<f.value.length&&O.push({type:"text",value:f.value.slice(w)}),x.children.splice(C,1,...O)):O=[f],C+O.length}}function v3(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const s=!e[0]||Array.isArray(e[0])?e:[e];let l=-1;for(;++l<s.length;){const o=s[l];n.push([j3(o[0]),w3(o[1])])}return n}function j3(e){return typeof e=="string"?new RegExp(b3(e),"g"):e}function w3(e){return typeof e=="function"?e:function(){return e}}const Oh="phrasing",Rh=["autolink","link","image","label"];function N3(){return{transforms:[_3],enter:{literalAutolink:S3,literalAutolinkEmail:Dh,literalAutolinkHttp:Dh,literalAutolinkWww:Dh},exit:{literalAutolink:A3,literalAutolinkEmail:T3,literalAutolinkHttp:C3,literalAutolinkWww:E3}}}function k3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Oh,notInConstruct:Rh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Oh,notInConstruct:Rh},{character:":",before:"[ps]",after:"\\/",inConstruct:Oh,notInConstruct:Rh}]}}function S3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Dh(e){this.config.enter.autolinkProtocol.call(this,e)}function C3(e){this.config.exit.autolinkProtocol.call(this,e)}function E3(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function T3(e){this.config.exit.autolinkEmail.call(this,e)}function A3(e){this.exit(e)}function _3(e){y3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,M3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),O3]],{ignore:["link","linkReference"]})}function M3(e,n,s,l,o){let d="";if(!K1(o)||(/^w/i.test(n)&&(s=n+s,n="",d="http://"),!R3(s)))return!1;const c=D3(s+l);if(!c[0])return!1;const h={type:"link",title:null,url:d+n+c[0],children:[{type:"text",value:n+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function O3(e,n,s,l){return!K1(l,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+s,children:[{type:"text",value:n+"@"+s}]}}function R3(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function D3(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let s=n[0],l=s.indexOf(")");const o=ay(e,"(");let d=ay(e,")");for(;l!==-1&&o>d;)e+=s.slice(0,l+1),s=s.slice(l+1),l=s.indexOf(")"),d++;return[e,s]}function K1(e,n){const s=e.input.charCodeAt(e.index-1);return(e.index===0||dl(s)||Kd(s))&&(!n||s!==47)}Z1.peek=q3;function L3(){this.buffer()}function I3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function z3(){this.buffer()}function $3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function B3(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=hs(this.sliceSerialize(e)).toLowerCase(),s.label=n}function H3(e){this.exit(e)}function P3(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=hs(this.sliceSerialize(e)).toLowerCase(),s.label=n}function U3(e){this.exit(e)}function q3(){return"["}function Z1(e,n,s,l){const o=s.createTracker(l);let d=o.move("[^");const c=s.enter("footnoteReference"),h=s.enter("reference");return d+=o.move(s.safe(s.associationId(e),{after:"]",before:d})),h(),c(),d+=o.move("]"),d}function V3(){return{enter:{gfmFootnoteCallString:L3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:z3,gfmFootnoteDefinition:$3},exit:{gfmFootnoteCallString:B3,gfmFootnoteCall:H3,gfmFootnoteDefinitionLabelString:P3,gfmFootnoteDefinition:U3}}}function F3(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:s,footnoteReference:Z1},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(l,o,d,c){const h=d.createTracker(c);let m=h.move("[^");const f=d.enter("footnoteDefinition"),g=d.enter("label");return m+=h.move(d.safe(d.associationId(l),{before:m,after:"]"})),g(),m+=h.move("]:"),l.children&&l.children.length>0&&(h.shift(4),m+=h.move((n?`
24
- `:" ")+d.indentLines(d.containerFlow(l,h.current()),n?W1:Y3))),f(),m}}function Y3(e,n,s){return n===0?e:W1(e,n,s)}function W1(e,n,s){return(s?"":" ")+e}const G3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Q1.peek=Q3;function X3(){return{canContainEols:["delete"],enter:{strikethrough:Z3},exit:{strikethrough:W3}}}function K3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:G3}],handlers:{delete:Q1}}}function Z3(e){this.enter({type:"delete",children:[]},e)}function W3(e){this.exit(e)}function Q1(e,n,s,l){const o=s.createTracker(l),d=s.enter("strikethrough");let c=o.move("~~");return c+=s.containerPhrasing(e,{...o.current(),before:c,after:"~"}),c+=o.move("~~"),d(),c}function Q3(){return"~"}function J3(e){return e.length}function e4(e,n){const s=n||{},l=(s.align||[]).concat(),o=s.stringLength||J3,d=[],c=[],h=[],m=[];let f=0,g=-1;for(;++g<e.length;){const N=[],C=[];let _=-1;for(e[g].length>f&&(f=e[g].length);++_<e[g].length;){const O=t4(e[g][_]);if(s.alignDelimiters!==!1){const k=o(O);C[_]=k,(m[_]===void 0||k>m[_])&&(m[_]=k)}N.push(O)}c[g]=N,h[g]=C}let x=-1;if(typeof l=="object"&&"length"in l)for(;++x<f;)d[x]=ly(l[x]);else{const N=ly(l);for(;++x<f;)d[x]=N}x=-1;const p=[],y=[];for(;++x<f;){const N=d[x];let C="",_="";N===99?(C=":",_=":"):N===108?C=":":N===114&&(_=":");let O=s.alignDelimiters===!1?1:Math.max(1,m[x]-C.length-_.length);const k=C+"-".repeat(O)+_;s.alignDelimiters!==!1&&(O=C.length+O+_.length,O>m[x]&&(m[x]=O),y[x]=O),p[x]=k}c.splice(1,0,p),h.splice(1,0,y),g=-1;const w=[];for(;++g<c.length;){const N=c[g],C=h[g];x=-1;const _=[];for(;++x<f;){const O=N[x]||"";let k="",S="";if(s.alignDelimiters!==!1){const R=m[x]-(C[x]||0),D=d[x];D===114?k=" ".repeat(R):D===99?R%2?(k=" ".repeat(R/2+.5),S=" ".repeat(R/2-.5)):(k=" ".repeat(R/2),S=k):S=" ".repeat(R)}s.delimiterStart!==!1&&!x&&_.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&O==="")&&(s.delimiterStart!==!1||x)&&_.push(" "),s.alignDelimiters!==!1&&_.push(k),_.push(O),s.alignDelimiters!==!1&&_.push(S),s.padding!==!1&&_.push(" "),(s.delimiterEnd!==!1||x!==f-1)&&_.push("|")}w.push(s.delimiterEnd===!1?_.join("").replace(/ +$/,""):_.join(""))}return w.join(`
25
- `)}function t4(e){return e==null?"":String(e)}function ly(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function n4(e,n,s,l){const o=s.enter("blockquote"),d=s.createTracker(l);d.move("> "),d.shift(2);const c=s.indentLines(s.containerFlow(e,d.current()),r4);return o(),c}function r4(e,n,s){return">"+(s?"":" ")+e}function s4(e,n){return iy(e,n.inConstruct,!0)&&!iy(e,n.notInConstruct,!1)}function iy(e,n,s){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return s;let l=-1;for(;++l<n.length;)if(e.includes(n[l]))return!0;return!1}function oy(e,n,s,l){let o=-1;for(;++o<s.unsafe.length;)if(s.unsafe[o].character===`
26
- `&&s4(s.stack,s.unsafe[o]))return/[ \t]/.test(l.before)?"":" ";return`\\
27
- `}function a4(e,n){const s=String(e);let l=s.indexOf(n),o=l,d=0,c=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;l!==-1;)l===o?++d>c&&(c=d):d=1,o=l+n.length,l=s.indexOf(n,o);return c}function l4(e,n){return!!(n.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function i4(e){const n=e.options.fence||"`";if(n!=="`"&&n!=="~")throw new Error("Cannot serialize code with `"+n+"` for `options.fence`, expected `` ` `` or `~`");return n}function o4(e,n,s,l){const o=i4(s),d=e.value||"",c=o==="`"?"GraveAccent":"Tilde";if(l4(e,s)){const x=s.enter("codeIndented"),p=s.indentLines(d,c4);return x(),p}const h=s.createTracker(l),m=o.repeat(Math.max(a4(d,o)+1,3)),f=s.enter("codeFenced");let g=h.move(m);if(e.lang){const x=s.enter(`codeFencedLang${c}`);g+=h.move(s.safe(e.lang,{before:g,after:" ",encode:["`"],...h.current()})),x()}if(e.lang&&e.meta){const x=s.enter(`codeFencedMeta${c}`);g+=h.move(" "),g+=h.move(s.safe(e.meta,{before:g,after:`
28
- `,encode:["`"],...h.current()})),x()}return g+=h.move(`
29
- `),d&&(g+=h.move(d+`
30
- `)),g+=h.move(m),f(),g}function c4(e,n,s){return(s?"":" ")+e}function ix(e){const n=e.options.quote||'"';if(n!=='"'&&n!=="'")throw new Error("Cannot serialize title with `"+n+"` for `options.quote`, expected `\"`, or `'`");return n}function d4(e,n,s,l){const o=ix(s),d=o==='"'?"Quote":"Apostrophe",c=s.enter("definition");let h=s.enter("label");const m=s.createTracker(l);let f=m.move("[");return f+=m.move(s.safe(s.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=s.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(s.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=s.enter("destinationRaw"),f+=m.move(s.safe(e.url,{before:f,after:e.title?" ":`
31
- `,...m.current()}))),h(),e.title&&(h=s.enter(`title${d}`),f+=m.move(" "+o),f+=m.move(s.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),c(),f}function u4(e){const n=e.options.emphasis||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize emphasis with `"+n+"` for `options.emphasis`, expected `*`, or `_`");return n}function Ao(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ad(e,n,s){const l=li(e),o=li(n);return l===void 0?o===void 0?s==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}J1.peek=f4;function J1(e,n,s,l){const o=u4(s),d=s.enter("emphasis"),c=s.createTracker(l),h=c.move(o);let m=c.move(s.containerPhrasing(e,{after:o,before:h,...c.current()}));const f=m.charCodeAt(0),g=Ad(l.before.charCodeAt(l.before.length-1),f,o);g.inside&&(m=Ao(f)+m.slice(1));const x=m.charCodeAt(m.length-1),p=Ad(l.after.charCodeAt(0),x,o);p.inside&&(m=m.slice(0,-1)+Ao(x));const y=c.move(o);return d(),s.attentionEncodeSurroundingInfo={after:p.outside,before:g.outside},h+m+y}function f4(e,n,s){return s.options.emphasis||"*"}function h4(e,n){let s=!1;return ax(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return s=!0,pm}),!!((!e.depth||e.depth<3)&&Qm(e)&&(n.options.setext||s))}function m4(e,n,s,l){const o=Math.max(Math.min(6,e.depth||1),1),d=s.createTracker(l);if(h4(e,s)){const g=s.enter("headingSetext"),x=s.enter("phrasing"),p=s.containerPhrasing(e,{...d.current(),before:`
32
- `,after:`
33
- `});return x(),g(),p+`
34
- `+(o===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
35
- `))+1))}const c="#".repeat(o),h=s.enter("headingAtx"),m=s.enter("phrasing");d.move(c+" ");let f=s.containerPhrasing(e,{before:"# ",after:`
36
- `,...d.current()});return/^[\t ]/.test(f)&&(f=Ao(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,s.options.closeAtx&&(f+=" "+c),m(),h(),f}ej.peek=x4;function ej(e){return e.value||""}function x4(){return"<"}tj.peek=g4;function tj(e,n,s,l){const o=ix(s),d=o==='"'?"Quote":"Apostrophe",c=s.enter("image");let h=s.enter("label");const m=s.createTracker(l);let f=m.move("![");return f+=m.move(s.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=s.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(s.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(h=s.enter("destinationRaw"),f+=m.move(s.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),h(),e.title&&(h=s.enter(`title${d}`),f+=m.move(" "+o),f+=m.move(s.safe(e.title,{before:f,after:o,...m.current()})),f+=m.move(o),h()),f+=m.move(")"),c(),f}function g4(){return"!"}nj.peek=p4;function nj(e,n,s,l){const o=e.referenceType,d=s.enter("imageReference");let c=s.enter("label");const h=s.createTracker(l);let m=h.move("![");const f=s.safe(e.alt,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),c();const g=s.stack;s.stack=[],c=s.enter("reference");const x=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=g,d(),o==="full"||!f||f!==x?m+=h.move(x+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function p4(){return"!"}rj.peek=b4;function rj(e,n,s){let l=e.value||"",o="`",d=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++d<s.unsafe.length;){const c=s.unsafe[d],h=s.compilePattern(c);let m;if(c.atBreak)for(;m=h.exec(l);){let f=m.index;l.charCodeAt(f)===10&&l.charCodeAt(f-1)===13&&f--,l=l.slice(0,f)+" "+l.slice(m.index+1)}}return o+l+o}function b4(){return"`"}function sj(e,n){const s=Qm(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(s===e.url||"mailto:"+s===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}aj.peek=y4;function aj(e,n,s,l){const o=ix(s),d=o==='"'?"Quote":"Apostrophe",c=s.createTracker(l);let h,m;if(sj(e,s)){const g=s.stack;s.stack=[],h=s.enter("autolink");let x=c.move("<");return x+=c.move(s.containerPhrasing(e,{before:x,after:">",...c.current()})),x+=c.move(">"),h(),s.stack=g,x}h=s.enter("link"),m=s.enter("label");let f=c.move("[");return f+=c.move(s.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=s.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(s.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(m=s.enter("destinationRaw"),f+=c.move(s.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),m(),e.title&&(m=s.enter(`title${d}`),f+=c.move(" "+o),f+=c.move(s.safe(e.title,{before:f,after:o,...c.current()})),f+=c.move(o),m()),f+=c.move(")"),h(),f}function y4(e,n,s){return sj(e,s)?"<":"["}lj.peek=v4;function lj(e,n,s,l){const o=e.referenceType,d=s.enter("linkReference");let c=s.enter("label");const h=s.createTracker(l);let m=h.move("[");const f=s.containerPhrasing(e,{before:m,after:"]",...h.current()});m+=h.move(f+"]["),c();const g=s.stack;s.stack=[],c=s.enter("reference");const x=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=g,d(),o==="full"||!f||f!==x?m+=h.move(x+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function v4(){return"["}function ox(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function j4(e){const n=ox(e),s=e.options.bulletOther;if(!s)return n==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+s+"`) to be different");return s}function w4(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function ij(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function N4(e,n,s,l){const o=s.enter("list"),d=s.bulletCurrent;let c=e.ordered?w4(s):ox(s);const h=e.ordered?c==="."?")":".":j4(s);let m=n&&s.bulletLastUsed?c===s.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&g&&(!g.children||!g.children[0])&&s.stack[s.stack.length-1]==="list"&&s.stack[s.stack.length-2]==="listItem"&&s.stack[s.stack.length-3]==="list"&&s.stack[s.stack.length-4]==="listItem"&&s.indexStack[s.indexStack.length-1]===0&&s.indexStack[s.indexStack.length-2]===0&&s.indexStack[s.indexStack.length-3]===0&&(m=!0),ij(s)===c&&g){let x=-1;for(;++x<e.children.length;){const p=e.children[x];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=h),s.bulletCurrent=c;const f=s.containerFlow(e,l);return s.bulletLastUsed=c,s.bulletCurrent=d,o(),f}function k4(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function S4(e,n,s,l){const o=k4(s);let d=s.bulletCurrent||ox(s);n&&n.type==="list"&&n.ordered&&(d=(typeof n.start=="number"&&n.start>-1?n.start:1)+(s.options.incrementListMarker===!1?0:n.children.indexOf(e))+d);let c=d.length+1;(o==="tab"||o==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(c=Math.ceil(c/4)*4);const h=s.createTracker(l);h.move(d+" ".repeat(c-d.length)),h.shift(c);const m=s.enter("listItem"),f=s.indentLines(s.containerFlow(e,h.current()),g);return m(),f;function g(x,p,y){return p?(y?"":" ".repeat(c))+x:(y?d:d+" ".repeat(c-d.length))+x}}function C4(e,n,s,l){const o=s.enter("paragraph"),d=s.enter("phrasing"),c=s.containerPhrasing(e,l);return d(),o(),c}const E4=Qd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function T4(e,n,s,l){return(e.children.some(function(c){return E4(c)})?s.containerPhrasing:s.containerFlow).call(s,e,l)}function A4(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}oj.peek=_4;function oj(e,n,s,l){const o=A4(s),d=s.enter("strong"),c=s.createTracker(l),h=c.move(o+o);let m=c.move(s.containerPhrasing(e,{after:o,before:h,...c.current()}));const f=m.charCodeAt(0),g=Ad(l.before.charCodeAt(l.before.length-1),f,o);g.inside&&(m=Ao(f)+m.slice(1));const x=m.charCodeAt(m.length-1),p=Ad(l.after.charCodeAt(0),x,o);p.inside&&(m=m.slice(0,-1)+Ao(x));const y=c.move(o+o);return d(),s.attentionEncodeSurroundingInfo={after:p.outside,before:g.outside},h+m+y}function _4(e,n,s){return s.options.strong||"*"}function M4(e,n,s,l){return s.safe(e.value,l)}function O4(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function R4(e,n,s){const l=(ij(s)+(s.options.ruleSpaces?" ":"")).repeat(O4(s));return s.options.ruleSpaces?l.slice(0,-1):l}const cj={blockquote:n4,break:oy,code:o4,definition:d4,emphasis:J1,hardBreak:oy,heading:m4,html:ej,image:tj,imageReference:nj,inlineCode:rj,link:aj,linkReference:lj,list:N4,listItem:S4,paragraph:C4,root:T4,strong:oj,text:M4,thematicBreak:R4};function D4(){return{enter:{table:L4,tableData:cy,tableHeader:cy,tableRow:z4},exit:{codeText:$4,table:I4,tableData:Lh,tableHeader:Lh,tableRow:Lh}}}function L4(e){const n=e._align;this.enter({type:"table",align:n.map(function(s){return s==="none"?null:s}),children:[]},e),this.data.inTable=!0}function I4(e){this.exit(e),this.data.inTable=void 0}function z4(e){this.enter({type:"tableRow",children:[]},e)}function Lh(e){this.exit(e)}function cy(e){this.enter({type:"tableCell",children:[]},e)}function $4(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,B4));const s=this.stack[this.stack.length-1];s.type,s.value=n,this.exit(e)}function B4(e,n){return n==="|"?n:e}function H4(e){const n=e||{},s=n.tableCellPadding,l=n.tablePipeAlign,o=n.stringLength,d=s?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
37
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:c,tableCell:m,tableRow:h}};function c(y,w,N,C){return f(g(y,N,C),y.align)}function h(y,w,N,C){const _=x(y,N,C),O=f([_]);return O.slice(0,O.indexOf(`
38
- `))}function m(y,w,N,C){const _=N.enter("tableCell"),O=N.enter("phrasing"),k=N.containerPhrasing(y,{...C,before:d,after:d});return O(),_(),k}function f(y,w){return e4(y,{align:w,alignDelimiters:l,padding:s,stringLength:o})}function g(y,w,N){const C=y.children;let _=-1;const O=[],k=w.enter("table");for(;++_<C.length;)O[_]=x(C[_],w,N);return k(),O}function x(y,w,N){const C=y.children;let _=-1;const O=[],k=w.enter("tableRow");for(;++_<C.length;)O[_]=m(C[_],y,w,N);return k(),O}function p(y,w,N){let C=cj.inlineCode(y,w,N);return N.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function P4(){return{exit:{taskListCheckValueChecked:dy,taskListCheckValueUnchecked:dy,paragraph:q4}}}function U4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:V4}}}function dy(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function q4(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const l=s.children[0];if(l&&l.type==="text"){const o=n.children;let d=-1,c;for(;++d<o.length;){const h=o[d];if(h.type==="paragraph"){c=h;break}}c===s&&(l.value=l.value.slice(1),l.value.length===0?s.children.shift():s.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,s.position.start=Object.assign({},l.position.start)))}}this.exit(e)}function V4(e,n,s,l){const o=e.children[0],d=typeof e.checked=="boolean"&&o&&o.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",h=s.createTracker(l);d&&h.move(c);let m=cj.listItem(e,n,s,{...l,...h.current()});return d&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(g){return g+c}}function F4(){return[N3(),V3(),X3(),D4(),P4()]}function Y4(e){return{extensions:[k3(),F3(e),K3(),H4(e),U4()]}}const G4={tokenize:J4,partial:!0},dj={tokenize:eT,partial:!0},uj={tokenize:tT,partial:!0},fj={tokenize:nT,partial:!0},X4={tokenize:rT,partial:!0},hj={name:"wwwAutolink",tokenize:W4,previous:xj},mj={name:"protocolAutolink",tokenize:Q4,previous:gj},na={name:"emailAutolink",tokenize:Z4,previous:pj},As={};function K4(){return{text:As}}let nl=48;for(;nl<123;)As[nl]=na,nl++,nl===58?nl=65:nl===91&&(nl=97);As[43]=na;As[45]=na;As[46]=na;As[95]=na;As[72]=[na,mj];As[104]=[na,mj];As[87]=[na,hj];As[119]=[na,hj];function Z4(e,n,s){const l=this;let o,d;return c;function c(x){return!jm(x)||!pj.call(l,l.previous)||cx(l.events)?s(x):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(x))}function h(x){return jm(x)?(e.consume(x),h):x===64?(e.consume(x),m):s(x)}function m(x){return x===46?e.check(X4,g,f)(x):x===45||x===95||mr(x)?(d=!0,e.consume(x),m):g(x)}function f(x){return e.consume(x),o=!0,m}function g(x){return d&&o&&vr(l.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(x)):s(x)}}function W4(e,n,s){const l=this;return o;function o(c){return c!==87&&c!==119||!xj.call(l,l.previous)||cx(l.events)?s(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(G4,e.attempt(dj,e.attempt(uj,d),s),s)(c))}function d(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function Q4(e,n,s){const l=this;let o="",d=!1;return c;function c(x){return(x===72||x===104)&&gj.call(l,l.previous)&&!cx(l.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(x),e.consume(x),h):s(x)}function h(x){if(vr(x)&&o.length<5)return o+=String.fromCodePoint(x),e.consume(x),h;if(x===58){const p=o.toLowerCase();if(p==="http"||p==="https")return e.consume(x),m}return s(x)}function m(x){return x===47?(e.consume(x),d?f:(d=!0,m)):s(x)}function f(x){return x===null||Cd(x)||bn(x)||dl(x)||Kd(x)?s(x):e.attempt(dj,e.attempt(uj,g),s)(x)}function g(x){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(x)}}function J4(e,n,s){let l=0;return o;function o(c){return(c===87||c===119)&&l<3?(l++,e.consume(c),o):c===46&&l===3?(e.consume(c),d):s(c)}function d(c){return c===null?s(c):n(c)}}function eT(e,n,s){let l,o,d;return c;function c(f){return f===46||f===95?e.check(fj,m,h)(f):f===null||bn(f)||dl(f)||f!==45&&Kd(f)?m(f):(d=!0,e.consume(f),c)}function h(f){return f===95?l=!0:(o=l,l=void 0),e.consume(f),c}function m(f){return o||l||!d?s(f):n(f)}}function tT(e,n){let s=0,l=0;return o;function o(c){return c===40?(s++,e.consume(c),o):c===41&&l<s?d(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(fj,n,d)(c):c===null||bn(c)||dl(c)?n(c):(e.consume(c),o)}function d(c){return c===41&&l++,e.consume(c),o}}function nT(e,n,s){return l;function l(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(e.consume(h),l):h===38?(e.consume(h),d):h===93?(e.consume(h),o):h===60||h===null||bn(h)||dl(h)?n(h):s(h)}function o(h){return h===null||h===40||h===91||bn(h)||dl(h)?n(h):l(h)}function d(h){return vr(h)?c(h):s(h)}function c(h){return h===59?(e.consume(h),l):vr(h)?(e.consume(h),c):s(h)}}function rT(e,n,s){return l;function l(d){return e.consume(d),o}function o(d){return mr(d)?s(d):n(d)}}function xj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||bn(e)}function gj(e){return!vr(e)}function pj(e){return!(e===47||jm(e))}function jm(e){return e===43||e===45||e===46||e===95||mr(e)}function cx(e){let n=e.length,s=!1;for(;n--;){const l=e[n][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){s=!0;break}if(l._gfmAutolinkLiteralWalkedInto){s=!1;break}}return e.length>0&&!s&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const sT={tokenize:fT,partial:!0};function aT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:cT,continuation:{tokenize:dT},exit:uT}},text:{91:{name:"gfmFootnoteCall",tokenize:oT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:lT,resolveTo:iT}}}}function lT(e,n,s){const l=this;let o=l.events.length;const d=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c;for(;o--;){const m=l.events[o][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return h;function h(m){if(!c||!c._balanced)return s(m);const f=hs(l.sliceSerialize({start:c.end,end:l.now()}));return f.codePointAt(0)!==94||!d.includes(f.slice(1))?s(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function iT(e,n){let s=e.length;for(;s--;)if(e[s][1].type==="labelImage"&&e[s][0]==="enter"){e[s][1];break}e[s+1][1].type="data",e[s+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[s+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[s+3][1].end),end:Object.assign({},e[s+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const d={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},d.start),end:Object.assign({},d.end)},h=[e[s+1],e[s+2],["enter",l,n],e[s+3],e[s+4],["enter",o,n],["exit",o,n],["enter",d,n],["enter",c,n],["exit",c,n],["exit",d,n],e[e.length-2],e[e.length-1],["exit",l,n]];return e.splice(s,e.length-s+1,...h),e}function oT(e,n,s){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d=0,c;return h;function h(x){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),m}function m(x){return x!==94?s(x):(e.enter("gfmFootnoteCallMarker"),e.consume(x),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(x){if(d>999||x===93&&!c||x===null||x===91||bn(x))return s(x);if(x===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return o.includes(hs(l.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):s(x)}return bn(x)||(c=!0),d++,e.consume(x),x===92?g:f}function g(x){return x===91||x===92||x===93?(e.consume(x),d++,f):f(x)}}function cT(e,n,s){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d,c=0,h;return m;function m(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):s(w)}function g(w){if(c>999||w===93&&!h||w===null||w===91||bn(w))return s(w);if(w===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return d=hs(l.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return bn(w)||(h=!0),c++,e.consume(w),w===92?x:g}function x(w){return w===91||w===92||w===93?(e.consume(w),c++,g):g(w)}function p(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),o.includes(d)||o.push(d),Qt(e,y,"gfmFootnoteDefinitionWhitespace")):s(w)}function y(w){return n(w)}}function dT(e,n,s){return e.check(qo,n,e.attempt(sT,n,s))}function uT(e){e.exit("gfmFootnoteDefinition")}function fT(e,n,s){const l=this;return Qt(e,o,"gfmFootnoteDefinitionIndent",5);function o(d){const c=l.events[l.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(d):s(d)}}function hT(e){let s=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:d,resolveAll:o};return s==null&&(s=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(c,h){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let f=m;for(;f--;)if(c[f][0]==="exit"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[f][1].end.offset-c[f][1].start.offset){c[m][1].type="strikethroughSequence",c[f][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},c[f][1].start),end:Object.assign({},c[m][1].end)},x={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[m][1].start)},p=[["enter",g,h],["enter",c[f][1],h],["exit",c[f][1],h],["enter",x,h]],y=h.parser.constructs.insideSpan.null;y&&Pr(p,p.length,0,Zd(y,c.slice(f+1,m),h)),Pr(p,p.length,0,[["exit",x,h],["enter",c[m][1],h],["exit",c[m][1],h],["exit",g,h]]),Pr(c,f-1,m-f+3,p),m=f+p.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function d(c,h,m){const f=this.previous,g=this.events;let x=0;return p;function p(w){return f===126&&g[g.length-1][1].type!=="characterEscape"?m(w):(c.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const N=li(f);if(w===126)return x>1?m(w):(c.consume(w),x++,y);if(x<2&&!s)return m(w);const C=c.exit("strikethroughSequenceTemporary"),_=li(w);return C._open=!_||_===2&&!!N,C._close=!N||N===2&&!!_,h(w)}}}class mT{constructor(){this.map=[]}add(n,s,l){xT(this,n,s,l)}consume(n){if(this.map.sort(function(d,c){return d[0]-c[0]}),this.map.length===0)return;let s=this.map.length;const l=[];for(;s>0;)s-=1,l.push(n.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),n.length=this.map[s][0];l.push(n.slice()),n.length=0;let o=l.pop();for(;o;){for(const d of o)n.push(d);o=l.pop()}this.map.length=0}}function xT(e,n,s,l){let o=0;if(!(s===0&&l.length===0)){for(;o<e.map.length;){if(e.map[o][0]===n){e.map[o][1]+=s,e.map[o][2].push(...l);return}o+=1}e.map.push([n,s,l])}}function gT(e,n){let s=!1;const l=[];for(;n<e.length;){const o=e[n];if(s){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const d=l.length-1;l[d]=l[d]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(s=!0);n+=1}return l}function pT(){return{flow:{null:{name:"table",tokenize:bT,resolveAll:yT}}}}function bT(e,n,s){const l=this;let o=0,d=0,c;return h;function h(U){let G=l.events.length-1;for(;G>-1;){const T=l.events[G][1].type;if(T==="lineEnding"||T==="linePrefix")G--;else break}const V=G>-1?l.events[G][1].type:null,E=V==="tableHead"||V==="tableRow"?D:m;return E===D&&l.parser.lazy[l.now().line]?s(U):E(U)}function m(U){return e.enter("tableHead"),e.enter("tableRow"),f(U)}function f(U){return U===124||(c=!0,d+=1),g(U)}function g(U){return U===null?s(U):wt(U)?d>1?(d=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),y):s(U):Ft(U)?Qt(e,g,"whitespace")(U):(d+=1,c&&(c=!1,o+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,g):(e.enter("data"),x(U)))}function x(U){return U===null||U===124||bn(U)?(e.exit("data"),g(U)):(e.consume(U),U===92?p:x)}function p(U){return U===92||U===124?(e.consume(U),x):x(U)}function y(U){return l.interrupt=!1,l.parser.lazy[l.now().line]?s(U):(e.enter("tableDelimiterRow"),c=!1,Ft(U)?Qt(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):w(U))}function w(U){return U===45||U===58?C(U):U===124?(c=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),N):R(U)}function N(U){return Ft(U)?Qt(e,C,"whitespace")(U):C(U)}function C(U){return U===58?(d+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),_):U===45?(d+=1,_(U)):U===null||wt(U)?S(U):R(U)}function _(U){return U===45?(e.enter("tableDelimiterFiller"),O(U)):R(U)}function O(U){return U===45?(e.consume(U),O):U===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(U))}function k(U){return Ft(U)?Qt(e,S,"whitespace")(U):S(U)}function S(U){return U===124?w(U):U===null||wt(U)?!c||o!==d?R(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(U)):R(U)}function R(U){return s(U)}function D(U){return e.enter("tableRow"),Y(U)}function Y(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),Y):U===null||wt(U)?(e.exit("tableRow"),n(U)):Ft(U)?Qt(e,Y,"whitespace")(U):(e.enter("data"),z(U))}function z(U){return U===null||U===124||bn(U)?(e.exit("data"),Y(U)):(e.consume(U),U===92?K:z)}function K(U){return U===92||U===124?(e.consume(U),z):z(U)}}function yT(e,n){let s=-1,l=!0,o=0,d=[0,0,0,0],c=[0,0,0,0],h=!1,m=0,f,g,x;const p=new mT;for(;++s<e.length;){const y=e[s],w=y[1];y[0]==="enter"?w.type==="tableHead"?(h=!1,m!==0&&(uy(p,n,m,f,g),g=void 0,m=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},p.add(s,0,[["enter",f,n]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(l=!0,x=void 0,d=[0,0,0,0],c=[0,s+1,0,0],h&&(h=!1,g={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},p.add(s,0,[["enter",g,n]])),o=w.type==="tableDelimiterRow"?2:g?3:1):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(l=!1,c[2]===0&&(d[1]!==0&&(c[0]=c[1],x=od(p,n,d,o,void 0,x),d=[0,0,0,0]),c[2]=s)):w.type==="tableCellDivider"&&(l?l=!1:(d[1]!==0&&(c[0]=c[1],x=od(p,n,d,o,void 0,x)),d=c,c=[d[1],s,0,0])):w.type==="tableHead"?(h=!0,m=s):w.type==="tableRow"||w.type==="tableDelimiterRow"?(m=s,d[1]!==0?(c[0]=c[1],x=od(p,n,d,o,s,x)):c[1]!==0&&(x=od(p,n,c,o,s,x)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=s)}for(m!==0&&uy(p,n,m,f,g),p.consume(n.events),s=-1;++s<n.events.length;){const y=n.events[s];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=gT(n.events,s))}return e}function od(e,n,s,l,o,d){const c=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",h="tableContent";s[0]!==0&&(d.end=Object.assign({},Ql(n.events,s[0])),e.add(s[0],0,[["exit",d,n]]));const m=Ql(n.events,s[1]);if(d={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(s[1],0,[["enter",d,n]]),s[2]!==0){const f=Ql(n.events,s[2]),g=Ql(n.events,s[3]),x={type:h,start:Object.assign({},f),end:Object.assign({},g)};if(e.add(s[2],0,[["enter",x,n]]),l!==2){const p=n.events[s[2]],y=n.events[s[3]];if(p[1].end=Object.assign({},y[1].end),p[1].type="chunkText",p[1].contentType="text",s[3]>s[2]+1){const w=s[2]+1,N=s[3]-s[2]-1;e.add(w,N,[])}}e.add(s[3]+1,0,[["exit",x,n]])}return o!==void 0&&(d.end=Object.assign({},Ql(n.events,o)),e.add(o,0,[["exit",d,n]]),d=void 0),d}function uy(e,n,s,l,o){const d=[],c=Ql(n.events,s);o&&(o.end=Object.assign({},c),d.push(["exit",o,n])),l.end=Object.assign({},c),d.push(["exit",l,n]),e.add(s+1,0,d)}function Ql(e,n){const s=e[n],l=s[0]==="enter"?"start":"end";return s[1][l]}const vT={name:"tasklistCheck",tokenize:wT};function jT(){return{text:{91:vT}}}function wT(e,n,s){const l=this;return o;function o(m){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?s(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),d)}function d(m){return bn(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):s(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),h):s(m)}function h(m){return wt(m)?n(m):Ft(m)?e.check({tokenize:NT},n,s)(m):s(m)}}function NT(e,n,s){return Qt(e,l,"whitespace");function l(o){return o===null?s(o):n(o)}}function kT(e){return T1([K4(),aT(),hT(e),pT(),jT()])}const ST={};function fy(e){const n=this,s=e||ST,l=n.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),d=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),c=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(kT(s)),d.push(F4()),c.push(Y4(s))}const CT=/<think>([\s\S]*?)<\/think>/g;function ET(e){const n=[],s=e.replace(CT,(l,o)=>{const d=o.trim();return d&&n.push(d),""});return{thinking:n,rest:s.trim()}}const wm="#mention:";function TT(e){return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(n,s,l)=>{const o=s??l;return`[@${o}](${wm}${encodeURIComponent(o)})`})}const Ih={p:({children:e})=>t.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",children:e}),h1:({children:e})=>t.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0",children:e}),h2:({children:e})=>t.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0",children:e}),h3:({children:e})=>t.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0",children:e}),ul:({children:e})=>t.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e})=>t.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:e}),li:({children:e})=>t.jsx("li",{className:"leading-relaxed",children:e}),code:({children:e,className:n})=>n?.includes("language-")?t.jsx("code",{className:"text-fg-secondary font-mono",children:e}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e}),pre:({children:e})=>t.jsx("pre",{className:"bg-surface-secondary rounded-lg p-3 overflow-x-auto my-2 text-xs [&>code]:bg-transparent [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:e}),strong:({children:e})=>t.jsx("strong",{className:"font-semibold text-fg-primary",children:e}),em:({children:e})=>t.jsx("em",{className:"italic text-fg-secondary",children:e}),blockquote:({children:e})=>t.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:n})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:n}),hr:()=>t.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>t.jsx("div",{className:"overflow-x-auto my-2",children:t.jsx("table",{className:"min-w-full text-xs border-collapse border border-border-default",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-surface-elevated",children:e}),tbody:({children:e})=>t.jsx("tbody",{className:"divide-y divide-gray-700/50",children:e}),tr:({children:e})=>t.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>t.jsx("th",{className:"px-3 py-1.5 text-left text-xs font-semibold text-fg-secondary border border-border-default",children:e}),td:({children:e})=>t.jsx("td",{className:"px-3 py-1.5 text-xs text-fg-secondary border border-border-default",children:e})};function tr({content:e,className:n="",onMentionClick:s}){const{thinking:l,rest:o}=ET(e),d=v.useMemo(()=>s?TT(o):o,[o,s]),c=v.useMemo(()=>s?{...Ih,a:({href:h,children:m})=>{if(h?.startsWith(wm)){const f=decodeURIComponent(h.slice(wm.length));return t.jsx("span",{className:"text-brand-500 font-medium cursor-pointer hover:underline",onClick:g=>{g.preventDefault(),g.stopPropagation(),s(f,g)},title:f,children:m})}return t.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:m})}}:Ih,[s]);return t.jsxs("div",{className:`prose prose-sm max-w-none break-words ${n}`,children:[l.length>0&&(()=>{const h=l.join(`
39
-
40
- `),m=h.split(`
41
- `)[0]??"",f=m.length>80?m.slice(0,80)+"…":m;return t.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[t.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),t.jsx("span",{className:"shrink-0",children:"思考过程"}),t.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:f})]}),t.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:t.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:t.jsx(sy,{remarkPlugins:[fy],components:Ih,children:h})})})]})})(),t.jsx(sy,{remarkPlugins:[fy],components:c,children:d})]})}const hy={shell_execute:{label:"Running command",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},file_list:{label:"Listing files",icon:"📂"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},code_search:{label:"Searching code",icon:"🔍"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"}};function ul(e){const n=e.includes("__")?e.split("__").pop():e;return hy[n]??hy[e]??{label:n.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function dx(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function AT(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0"),o=String(n.getHours()).padStart(2,"0"),d=String(n.getMinutes()).padStart(2,"0"),c=String(n.getSeconds()).padStart(2,"0");return`${s}-${l} ${o}:${d}:${c}`}function Nm(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function my(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function _T(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,l])=>({key:s,value:typeof l=="string"?l:JSON.stringify(l,null,2)}))}function MT(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const n=e.args.command;return typeof n=="string"?n:null}function _d(e){const n=new Set;for(let s=0;s<e.length;s++){const l=e[s];if(l.type==="tool"&&(l.info.status==="done"||l.info.status==="error"))for(let o=s-1;o>=0;o--){const d=e[o];if(d.type==="tool"&&d.info.status==="running"&&d.info.tool===l.info.tool&&!n.has(o)){n.add(o);break}}}return e.filter((s,l)=>!n.has(l))}function Md(e){const n=AT(e.createdAt),s=e.createdAt,l=e.metadata;switch(e.type){case"text":return l?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const o=l?.action;return o&&["chat","chat_stream","task_execution","respond_in_session"].includes(o)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:l?.arguments}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:l?.success===!1?"error":"done",args:l?.arguments,result:l?.result,error:l?.error,durationMs:l?.durationMs}};default:return null}}function bj(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const s=JSON.parse(n);if(!s.task)return null;const l=s.task;return{taskId:l.id,title:l.title,description:l.description,assignedAgentId:l.assignedAgentId,priority:l.priority}}catch{return null}}function yj(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const l=s.requirement;return l.status!=="pending"?null:{requirementId:l.id,title:l.title,description:l.description,priority:l.priority}}catch{return null}}function OT(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const l=`${s.tool}_${s.ts}`;n.push({key:l,tool:s.tool,status:"running"})}else for(let l=n.length-1;l>=0;l--)if(n[l].tool===s.tool&&n[l].status==="running"){n[l]={...n[l],status:s.success===!1?"error":"done"};break}}return n}function vj(){return t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function RT(){return t.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function xy({item:e,idx:n,total:s}){const l=ul(e.tool);return t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[n>0&&t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:`w-2.5 h-2.5 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":"border-gray-600 bg-surface-elevated text-fg-tertiary"}`,children:e.status==="done"?"✓":e.status==="error"?"✗":""}),n<s-1&&t.jsx("div",{className:"w-px flex-1 bg-surface-overlay mt-0.5"})]}),t.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500 opacity-60":"text-fg-tertiary"}`,children:[t.jsx("span",{className:"opacity-70",children:l.icon}),t.jsxs("span",{children:[l.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(vj,{})]})]})}function DT({activities:e,isActive:n,persistent:s}){const l=OT(e),[o,d]=v.useState(!1),[c,h]=v.useState(!1),m=v.useRef(null);if(v.useEffect(()=>(s||n||e.length>0?(d(!0),m.current&&clearTimeout(m.current)):m.current=setTimeout(()=>d(!1),800),()=>{m.current&&clearTimeout(m.current)}),[s,n,e.length]),!o)return null;const f=l.length>0,g=f&&l.every(y=>y.status!=="running"),x=n&&!f,p=n&&f&&g;if(s&&g){const y=l.filter(N=>N.status==="error").length,w=l.filter(N=>N.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>h(N=>!N),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[t.jsx("span",{className:`transition-transform duration-150 ${c?"rotate-90":""}`,children:"▶"}),t.jsxs("span",{className:"font-medium",children:[w," step",w!==1?"s":""]}),y>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",y," failed"]}),!c&&t.jsxs("span",{className:"ml-1 flex gap-0.5",children:[l.slice(0,5).map(N=>t.jsx("span",{className:"text-[10px] opacity-60",title:ul(N.tool).label,children:ul(N.tool).icon},N.key)),l.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",l.length-5]})]})]}),c&&t.jsx("div",{className:"mt-2 space-y-0.5",children:l.map((N,C)=>t.jsx(xy,{item:N,idx:C,total:l.length},N.key))})]})}return t.jsxs("div",{className:"mb-2 space-y-0.5",children:[l.map((y,w)=>t.jsx(xy,{item:y,idx:w,total:l.length},y.key)),x&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-fg-secondary py-0.5",children:[t.jsx("span",{className:"mr-0.5",children:"Thinking"}),t.jsx(RT,{})]}),p&&t.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-brand-500 bg-brand-500/15 shrink-0"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-brand-500",children:[t.jsx(vj,{}),t.jsx("span",{children:"Writing response…"})]})]})]})}function km({label:e="Thinking"}){return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-fg-secondary py-0.5",children:[t.jsx("span",{children:e}),t.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(n=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}function Sm({content:e,className:n}){return t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[t.jsx(tr,{content:e,className:n??"text-sm text-fg-secondary break-words"}),t.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}function LT({info:e,onClose:n}){const s=ul(e.tool),l=_T(e.args),o=e.status!=="error";return v.useEffect(()=>{const d=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[n]),t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:n,children:[t.jsx("div",{className:"absolute inset-0 bg-black/60"}),t.jsxs("div",{className:"relative bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[560px] max-w-[92vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:d=>d.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-3 border-b border-border-default flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"opacity-60 text-sm",children:s.icon}),t.jsx("span",{className:`text-sm font-semibold ${o?"text-fg-primary":"text-red-500"}`,children:s.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:o?"Success":"Failed"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[e.durationMs!=null&&t.jsx("span",{className:"text-xs text-fg-tertiary",children:dx(e.durationMs)}),t.jsx("button",{onClick:n,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Arguments"}),t.jsx("div",{className:"space-y-2",children:l.map(({key:d,value:c})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:d}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:c})]},d))})]}),e.result&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Result"}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto overflow-y-auto max-h-[60vh] whitespace-pre-wrap break-all font-mono",children:my(e.result)})]}),e.error&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-red-500 uppercase tracking-wider mb-2",children:"Error"}),t.jsx("pre",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2 overflow-x-auto max-h-40 whitespace-pre-wrap break-all font-mono",children:my(String(e.error))})]}),!l.length&&!e.result&&!e.error&&t.jsx("div",{className:"text-sm text-fg-tertiary italic py-4 text-center",children:"No detailed data recorded for this tool call."})]})]})]})}const jj={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},gy={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",cancelled:"cancelled",archived:"archived"},py={pending:{icon:"⏳",label:"Pending Approval",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},approving:{icon:"⏳",label:"Approving…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},rejecting:{icon:"⏳",label:"Rejecting…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},in_progress:{icon:"▶",label:"In Progress",borderClass:"border-blue-500/40",bgClass:"bg-blue-500/5",badgeClass:"bg-blue-500/15 text-blue-500",textClass:"text-blue-500"},completed:{icon:"✅",label:"Completed",borderClass:"border-green-500/30",bgClass:"bg-green-500/5",badgeClass:"bg-green-500/15 text-green-500",textClass:"text-green-500"},review:{icon:"👀",label:"In Review",borderClass:"border-purple-500/40",bgClass:"bg-purple-500/5",badgeClass:"bg-purple-500/15 text-purple-500",textClass:"text-purple-500"},blocked:{icon:"🚫",label:"Blocked",borderClass:"border-orange-500/40",bgClass:"bg-orange-500/5",badgeClass:"bg-orange-500/15 text-orange-500",textClass:"text-orange-500"},failed:{icon:"❌",label:"Failed",borderClass:"border-red-500/30",bgClass:"bg-red-500/5",badgeClass:"bg-red-500/15 text-red-500",textClass:"text-red-500"},cancelled:{icon:"⊘",label:"Cancelled",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},archived:{icon:"📦",label:"Archived",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},loading:{icon:"⏳",label:"Loading…",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:""}};function wj({info:e}){const[n,s]=v.useState("loading");v.useEffect(()=>{let m=!1;return re.tasks.get(e.taskId).then(({task:f})=>{m||s(gy[f.status]??"pending")}).catch(()=>{m||s("pending")}),()=>{m=!0}},[e.taskId]),v.useEffect(()=>xn.on("task:update",m=>{const f=m.payload;f.taskId===e.taskId&&f.status&&s(gy[f.status]??"pending")}),[e.taskId]);const l=async()=>{s("approving");try{await re.tasks.approve(e.taskId),s("in_progress")}catch{s("pending")}},o=async()=>{s("rejecting");try{await re.tasks.reject(e.taskId),s("cancelled")}catch{s("pending")}},d=n==="pending"||n==="approving"||n==="rejecting",c=py[n]??py.loading,h=()=>gt.navigate(ge.WORK,{openTask:e.taskId});return t.jsxs("div",{className:`my-2 rounded-lg border ${c.borderClass} ${c.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:h,onKeyDown:m=>m.key==="Enter"&&h(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:c.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${c.badgeClass}`,children:"Task"}),!d&&n!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${c.textClass}`,children:c.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!d&&n!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:jj[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.taskId.slice(0,8),"..."]})]})]})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:l,disabled:n!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:o,disabled:n!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="rejecting"?"Rejecting…":"Reject"})]})]})}const by={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},yy={pending:{icon:"📋",label:"Pending Approval",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},approving:{icon:"⏳",label:"Approving…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},rejecting:{icon:"⏳",label:"Rejecting…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},in_progress:{icon:"▶",label:"In Progress",borderClass:"border-blue-500/40",bgClass:"bg-blue-500/5",badgeClass:"bg-blue-500/15 text-blue-500",textClass:"text-blue-500"},completed:{icon:"✅",label:"Completed",borderClass:"border-green-500/30",bgClass:"bg-green-500/5",badgeClass:"bg-green-500/15 text-green-500",textClass:"text-green-500"},rejected:{icon:"❌",label:"Rejected",borderClass:"border-red-500/30",bgClass:"bg-red-500/5",badgeClass:"bg-red-500/15 text-red-500",textClass:"text-red-500"},cancelled:{icon:"⊘",label:"Cancelled",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},archived:{icon:"📦",label:"Archived",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},loading:{icon:"⏳",label:"Loading…",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:""}},IT=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function Nj({info:e}){const[n,s]=v.useState("loading"),[l,o]=v.useState(""),[d,c]=v.useState(!1);v.useEffect(()=>{let x=!1;return re.requirements.get(e.requirementId).then(({requirement:p})=>{x||s(by[p.status]??"pending")}).catch(()=>{x||s("pending")}),()=>{x=!0}},[e.requirementId]),v.useEffect(()=>{const x=IT.map(p=>xn.on(p,y=>{const w=y.payload;w.id===e.requirementId&&w.status&&s(by[w.status]??"pending")}));return()=>x.forEach(p=>p())},[e.requirementId]);const h=async()=>{s("approving");try{await re.requirements.approve(e.requirementId),s("in_progress")}catch{s("pending")}},m=async()=>{if(!d){c(!0);return}if(l.trim()){s("rejecting");try{await re.requirements.reject(e.requirementId,l.trim()),s("rejected")}catch{s("pending")}}},f=n==="pending"||n==="approving"||n==="rejecting",g=yy[n]??yy.loading;return t.jsxs("div",{className:`my-2 rounded-lg border ${g.borderClass} ${g.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[t.jsx("span",{className:"text-sm mt-0.5",children:g.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${g.badgeClass}`,children:"REQ"}),!f&&n!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${g.textClass}`,children:g.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 ${!f&&n!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:jj[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.requirementId.slice(0,8),"..."]})]})]})]}),f&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default/30 space-y-2",children:[d&&t.jsx("input",{type:"text",value:l,onChange:x=>o(x.target.value),placeholder:"Rejection reason...",className:"w-full px-2 py-1.5 text-xs rounded-md bg-surface-secondary border border-border-default text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500",onKeyDown:x=>x.key==="Enter"&&m(),autoFocus:!0}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:h,disabled:n!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:m,disabled:n!=="pending"||d&&!l.trim(),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="rejecting"?"Rejecting…":"Reject"})]})]})]})}function zT({info:e,showTime:n,time:s,isLast:l}){const o=ul(e.tool),[d,c]=v.useState(!1),h=e.status!=="running",m=e.status==="stopped",g=(e.tool==="spawn_subagent"||e.tool==="spawn_subagents")&&e.subagentLogs&&e.subagentLogs.length>0,x=h||g,p=MT(e),y=v.useRef(null);return v.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[e.liveOutput]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`relative flex items-start gap-2 py-0.5 min-w-0 ${l?"":"border-b border-border-default/30 pb-1.5 mb-0.5"} ${x?"cursor-pointer rounded hover:bg-surface-elevated/30 transition-colors":""}`,onClick:()=>h&&c(!0),children:[n&&s&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-0.5 hidden md:inline",children:s}),t.jsx("div",{className:"flex flex-col items-center shrink-0 mt-0.5",style:{width:14},children:t.jsx("div",{className:`w-3 h-3 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15 animate-pulse":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":m?"border-gray-500 bg-surface-secondary text-fg-tertiary":"border-green-500 bg-green-500/15 text-green-500"}`,children:e.status==="done"?"✓":e.status==="error"?"✗":m?"■":""})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:`flex items-center gap-1 text-xs leading-snug ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500 line-through opacity-50":m?"text-fg-tertiary opacity-60":"text-fg-tertiary"}`,children:[t.jsx("span",{className:"opacity-60",children:o.icon}),t.jsxs("span",{children:[o.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsxs("svg",{className:"w-3 h-3 animate-spin ml-0.5 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.durationMs!=null&&e.status!=="running"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-0.5",children:dx(e.durationMs)}),g&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary ml-0.5 opacity-60",children:["(",e.subagentLogs.filter(w=>w.eventType==="tool_end").length," steps)"]})]}),p&&t.jsxs("div",{className:`mt-0.5 font-mono text-[11px] truncate max-w-full ${e.status==="running"?"text-fg-secondary":"text-fg-tertiary"}`,title:p,children:[t.jsx("span",{className:"text-fg-tertiary select-none",children:"$ "}),Nm(p,120)]}),e.liveOutput&&e.status==="running"&&t.jsx("pre",{ref:y,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput})]})]}),d&&t.jsx(LT,{info:e,onClose:()=>c(!1)}),h&&(()=>{const w=bj(e.tool,e.result);if(w)return t.jsx(wj,{info:w});const N=yj(e.tool,e.result);return N?t.jsx(Nj,{info:N}):null})()]})}function $T({content:e,time:n,showTime:s}){const[l,o]=v.useState(!1);return t.jsxs("div",{className:"flex items-start gap-2",children:[s&&n&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2.5 hidden md:inline",children:n}),t.jsxs("div",{className:"flex-1 min-w-0 my-1 overflow-hidden",children:[t.jsxs("button",{onClick:()=>o(!l),className:"flex items-center gap-1.5 text-xs text-purple-400 hover:text-purple-300 transition-colors",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400/60 shrink-0"}),t.jsx("span",{children:"Thinking"}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:["(",e.length," chars)"]}),t.jsx("svg",{className:`w-3 h-3 transition-transform ${l?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l&&t.jsx("div",{className:"mt-1.5 bg-purple-500/[0.06] border border-purple-500/15 rounded-lg px-3 py-2.5 overflow-hidden",children:t.jsx(tr,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})]})}const Od=v.memo(kj);function kj({entry:e,showTime:n,isLast:s}){if(e.type==="tool")return t.jsx(zT,{info:e.info,showTime:n,time:e.time,isLast:s},e.key);if(e.type==="thinking")return t.jsx($T,{content:e.content,time:e.time,showTime:n});if(e.type==="text")return t.jsxs("div",{className:"flex items-start gap-2 ",children:[n&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2.5 hidden md:inline",children:e.time}),t.jsx("div",{className:"flex-1 min-w-0 bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 overflow-hidden",children:t.jsx(tr,{content:e.content,className:"text-sm text-fg-secondary break-words"})})]});if(e.type==="status"){const l=e.content==="completed"||e.content==="execution_finished",o=e.content==="started",d=e.content==="resumed",c=l?"text-green-600":o?"text-blue-600":d?"text-amber-600":"text-fg-tertiary",h=l?"bg-green-400":o?"bg-blue-400":d?"bg-amber-400":"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 py-0.5 px-1",children:[n&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums hidden md:inline",children:e.time}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h}`}),t.jsx("span",{className:`text-xs capitalize ${c}`,children:e.content})]})}return e.type==="error"?t.jsxs("div",{className:"flex items-start gap-2 ",children:[n&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2 hidden md:inline",children:e.time}),t.jsxs("div",{className:"flex-1 min-w-0 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded px-2.5 py-2 my-1 leading-relaxed break-words overflow-hidden",children:[t.jsx("span",{className:"font-medium",children:"Error:"})," ",e.content]})]}):null}function ux({entries:e,streamingText:n,isActive:s,onExpand:l,showRounds:o,embedded:d}){const c=e.length>0?e[e.length-1]:null,h=e.filter(k=>k.type==="tool_end").length,m=e.filter(k=>k.type==="error").length,f=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),g=c?new Date(c.createdAt).getTime():Date.now(),x=s?Date.now()-f:g-f,p=new Set(e.filter(k=>k.executionRound!=null).map(k=>k.executionRound)),y=p.size>0?Math.max(...p):void 0,w=o&&p.size>1;let N,C,_=null;if(!s)m>0&&c?.type==="error"?(N="❌",C="Failed"):(N="✅",C="Completed");else if(n)N="✍",C="Writing response...",_=Nm(n.split(`
42
- `).pop()??"",80);else if(c?.type==="tool_start"){const k=ul(c.content);N=k.icon,C=`${k.label}...`;const S=c.metadata?.arguments&&typeof c.metadata.arguments=="object"?c.metadata.arguments.command:void 0;S&&(_=`$ ${Nm(S,80)}`)}else if(c?.type==="tool_end"){const k=ul(c.content);N=k.icon,C=k.label}else N="💭",C="Thinking...";const O=dx(x);return t.jsx("div",{onClick:l,className:`overflow-hidden transition-all cursor-pointer min-w-0 ${d?"hover:bg-surface-elevated/20":`rounded-lg border hover:brightness-110 ${s?"border-2 exec-card-active":"border border-border-default bg-surface-elevated/30 hover:border-brand-500/40"}`}`,children:t.jsxs("div",{className:d?"py-2":"px-3 py-2.5 bg-surface-primary/80",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s?t.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):t.jsx("span",{className:"text-sm shrink-0",children:N}),t.jsx("span",{className:`text-xs font-medium truncate ${s?"text-fg-primary":"text-fg-secondary"}`,children:C})]}),O&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:O})]}),n?t.jsx("div",{className:"mt-1.5 ml-5.5 text-xs text-fg-secondary max-h-32 overflow-y-auto whitespace-pre-wrap break-words leading-relaxed",children:t.jsx(tr,{content:n,className:"text-xs"})}):_?t.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:_}):null,t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[h>0&&t.jsxs("span",{children:["🔧 ",h," tool",h!==1?"s":""]}),e.some(k=>k.type==="text"&&!k.metadata?.isThinking)&&t.jsx("span",{children:"💬 text"}),e.some(k=>k.type==="text"&&k.metadata?.isThinking)&&t.jsx("span",{className:"text-purple-400",children:"💭 thinking"}),w&&y!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"opacity-30",children:"·"}),t.jsxs("span",{children:["Round #",y]}),t.jsx("span",{className:"opacity-30",children:"·"}),t.jsxs("span",{children:[p.size," rounds"]})]})]}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:["Show Full Log",t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]})]})})}function BT(e){const n=new Map;for(const s of e){const l=s.executionRound??1;n.has(l)||n.set(l,[]);const o=Md(s);o&&n.get(l).push(o)}return Array.from(n.entries()).sort(([s],[l])=>s-l).map(([s,l])=>({round:s,entries:l}))}function fx({entries:e,streamingText:n,isActive:s,onCollapse:l,showRounds:o,embedded:d}){const c=v.useRef(null),[h,m]=v.useState(new Set),f=BT(e),g=o&&f.length>1;v.useEffect(()=>{f.length>0&&m(w=>{const N=new Set(w);return N.add(f[f.length-1].round),N})},[f.length]),v.useEffect(()=>{d||!c.current||!s||(c.current.scrollTop=c.current.scrollHeight)},[e.length,n,s,d]);const x=w=>{m(N=>{const C=new Set(N);return C.has(w)?C.delete(w):C.add(w),C})},p=g?null:e.map(Md).filter(w=>w!==null),y=p?_d(p):null;return t.jsxs("div",{className:`min-w-0 overflow-hidden ${d?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[t.jsxs("div",{onClick:l,className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${d?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:"Execution Log"}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:["Collapse",t.jsx("svg",{className:"w-3 h-3 rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),t.jsxs("div",{ref:d?void 0:c,className:`space-y-0.5 min-w-0 overflow-x-hidden ${d?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[g?f.map(w=>{const N=h.has(w.round),C=_d(w.entries),_=w.entries.filter(O=>O.type==="tool"&&O.info?.status!=="running").length;return t.jsxs("div",{className:"border border-border-default/50 rounded-lg mb-2 overflow-hidden",children:[t.jsxs("button",{onClick:()=>x(w.round),className:"w-full flex items-center justify-between px-3 py-1.5 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",w.round]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[_," tool",_!==1?"s":""]}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${N?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),N&&t.jsx("div",{className:"px-3 py-1.5 space-y-0.5",children:C.map((O,k)=>t.jsx(Od,{entry:O,showTime:!0,isLast:k===C.length-1},k))})]},w.round)}):y&&y.map((w,N)=>t.jsx(Od,{entry:w,showTime:!0,isLast:N===y.length-1},N)),s&&n&&t.jsx(Sm,{content:n}),s&&!n&&t.jsx(km,{})]})]})}var hx=d1();function HT({agents:e,filter:n,anchorRef:s,onSelect:l,selectedIndex:o,onIndexChange:d}){const[c,h]=v.useState(null),m=v.useRef(null),f=e.filter(g=>g.name.toLowerCase().includes(n));return v.useEffect(()=>{const g=s.current;if(!g)return;const x=g.getBoundingClientRect();h({top:x.top+window.scrollY-4,left:x.left+window.scrollX+8})},[s,n]),v.useEffect(()=>{if(!m.current||!c)return;if(m.current.getBoundingClientRect().top<8){const x=s.current;if(!x)return;const p=x.getBoundingClientRect();h({top:p.bottom+window.scrollY+4,left:c.left})}},[c,s]),v.useEffect(()=>{o>=f.length&&d(Math.max(0,f.length-1))},[f.length,o,d]),v.useEffect(()=>{if(!m.current)return;m.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[o]),!c||f.length===0?null:hx.createPortal(t.jsxs("div",{ref:m,style:{position:"absolute",top:c.top,left:c.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:"Mention an agent"}),f.map((g,x)=>t.jsxs("button",{"data-selected":x===o,onMouseDown:p=>{p.preventDefault(),l(g)},onMouseEnter:()=>d(x),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${x===o?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 flex items-center justify-center text-[10px] font-bold text-brand-500 shrink-0",children:g.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:g.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:g.role})]}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${g.status==="idle"||g.status==="working"?"bg-green-400":"bg-gray-500"}`})]},g.id))]}),document.body)}function PT(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Rd=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function UT(e){const n=[];let s;for(Rd.lastIndex=0;(s=Rd.exec(e))!==null;)n.push(s[1]??s[2]);return n}function vy(e,n,s){const l=[],o=new RegExp(Rd.source,Rd.flags);let d=0,c,h=0;for(;(c=o.exec(e))!==null;){c.index>d&&l.push(t.jsx("span",{children:e.slice(d,c.index)},h++));const m=c[1]??c[2],f=n.find(g=>g.name.toLowerCase()===m.toLowerCase());l.push(t.jsxs("span",{className:"text-brand-500 font-medium ",onClick:void 0,title:f?`${f.name} (${f.role})`:void 0,children:["@",m]},h++)),d=c.index+c[0].length}return d<e.length&&l.push(t.jsx("span",{children:e.slice(d)},h++)),l.length>0?l:[t.jsx("span",{children:e},0)]}function Sj({agents:e,onSubmit:n,placeholder:s,replyTo:l,onCancelReply:o}){const[d,c]=v.useState(""),[h,m]=v.useState(!1),[f,g]=v.useState(null),[x,p]=v.useState(!1),[y,w]=v.useState(""),[N,C]=v.useState([]),[_,O]=v.useState(0),k=v.useRef(null),S=v.useRef(null),R=e.filter(V=>V.name.toLowerCase().includes(y)),D=async()=>{if(d.trim()){m(!0),g(null),S.current={content:d,mentions:[...N]};try{await n(d,N,l?.id),c(""),C([]),S.current=null,o?.()}catch(V){g(String(V instanceof Error?V.message:V)||"Failed to send comment")}m(!1)}},Y=async()=>{if(!S.current)return;const{content:V,mentions:E}=S.current;m(!0),g(null);try{await n(V,E),c(""),C([]),S.current=null}catch(T){g(String(T instanceof Error?T.message:T)||"Failed to send comment")}m(!1)},z=v.useCallback(V=>{c(E=>{const T=E.lastIndexOf("@"),L=PT(V.name);return T>=0?E.slice(0,T)+L+" ":E+L+" "}),N.includes(V.id)||C(E=>[...E,V.id]),p(!1),w(""),O(0),k.current?.focus()},[N]),K=V=>{c(V),g(null);const E=V.lastIndexOf("@");if(E>=0&&(E===0||V[E-1]===" ")){const L=V.slice(E+1).toLowerCase();if(e.some(P=>P.name.toLowerCase().includes(L))){w(L),p(!0),O(0);return}}p(!1)},U=V=>{if(x&&R.length>0){const E=V.key==="ArrowUp"||V.ctrlKey&&V.key==="p",T=V.key==="ArrowDown"||V.ctrlKey&&V.key==="n",L=V.key==="Enter"||V.key==="Tab",A=V.key==="Escape";if(E){V.preventDefault(),O(P=>(P-1+R.length)%R.length);return}if(T){V.preventDefault(),O(P=>(P+1)%R.length);return}if(L){V.preventDefault();const P=R[_];P&&z(P);return}if(A){V.preventDefault(),p(!1);return}}V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),D())},G=v.useCallback(()=>{setTimeout(()=>p(!1),200)},[]);return t.jsxs("div",{className:"relative",children:[x&&t.jsx(HT,{agents:e,filter:y,anchorRef:k,onSelect:z,selectedIndex:_,onIndexChange:O}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[l&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:l.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:l.content})]}),t.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),N.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:N.map(V=>{const E=e.find(T=>T.id===V);return t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded-full",children:["@",E?.name??V,t.jsx("button",{onClick:()=>C(T=>T.filter(L=>L!==V)),className:"hover:text-red-400",children:"×"})]},V)})}),t.jsx("textarea",{ref:k,value:d,onChange:V=>K(V.target.value),onKeyDown:U,onBlur:G,placeholder:s??"Add a comment… (type @ to mention an agent)",rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:f}),t.jsxs("button",{onClick:Y,disabled:h,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Retry"]})]}),t.jsx("div",{className:"flex justify-end px-2.5 pb-2",children:t.jsx("button",{onClick:D,disabled:!d.trim()||h,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:h?"Sending…":"Comment"})})]})]})}const qT="(max-width: 767px)";let zh=null;function Cj(){return zh||(zh=window.matchMedia(qT)),zh}function VT(e){const n=Cj();return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function FT(){return Cj().matches}function YT(){return!1}function _s(){return v.useSyncExternalStore(VT,FT,YT)}function Ej({title:e,message:n,confirmLabel:s="Confirm",checkboxes:l,onConfirm:o,onCancel:d}){const[c,h]=v.useState(()=>{const m={};for(const f of l??[])m[f.id]=f.defaultChecked??!1;return m});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:d,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] shadow-2xl",onClick:m=>m.stopPropagation(),children:[t.jsx("h3",{className:"font-semibold text-base mb-2",children:e}),t.jsx("p",{className:"text-sm text-fg-secondary mb-4 leading-relaxed",children:n}),l&&l.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:l.map(m=>t.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:c[m.id]??!1,onChange:f=>h(g=>({...g,[m.id]:f.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),m.label]},m.id))}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:d,className:"px-4 py-1.5 text-sm border border-border-default rounded-lg hover:bg-surface-elevated transition-colors",children:"Cancel"}),t.jsx("button",{onClick:()=>o(l?c:void 0),className:"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:s})]})]})})}function eu({children:e,onClose:n,title:s,width:l="w-[440px]"}){return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${l} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:o=>o.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:s}),e]})})}function Js({label:e,children:n}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:e}),n]})}function GT({onClose:e,onCreate:n}){const[s,l]=v.useState(""),[o,d]=v.useState("");return t.jsx(eu,{onClose:e,title:"Create a New Team",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Js,{label:"Team Name",children:t.jsx("input",{value:s,onChange:c=>l(c.target.value),placeholder:"e.g. Engineering, Marketing, Support",className:"input",autoFocus:!0,onKeyDown:c=>{c.key==="Enter"&&s.trim()&&n(s.trim(),o.trim()||void 0)}})}),t.jsx(Js,{label:"Description (optional)",children:t.jsx("textarea",{value:o,onChange:c=>d(c.target.value),placeholder:"What does this team work on?",className:"input",rows:2})}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"You can add human and AI members to this team after creating it."}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:()=>s.trim()&&n(s.trim(),o.trim()||void 0),disabled:!s.trim(),className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:"Create Team"})]})]})})}function XT({teamId:e,teams:n,onClose:s,onAdd:l}){const[o,d]=v.useState(""),[c,h]=v.useState("member"),[m,f]=v.useState(""),[g,x]=v.useState(""),[p,y]=v.useState(""),[w,N]=v.useState(e??""),[C,_]=v.useState(""),O=()=>{if(_(""),!o.trim()){_("Name is required");return}if(g&&g!==p){_("Passwords do not match");return}l(o.trim(),c,m||void 0,g||void 0,w||void 0)};return t.jsx(eu,{onClose:s,title:"Add Human Team Member",width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Js,{label:"Name *",children:t.jsx("input",{value:o,onChange:k=>d(k.target.value),placeholder:"Full name",className:"input",autoFocus:!0})}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Js,{label:"Role",children:t.jsxs("select",{value:c,onChange:k=>h(k.target.value),className:"input",children:[t.jsx("option",{value:"owner",children:"Owner"}),t.jsx("option",{value:"admin",children:"Admin"}),t.jsx("option",{value:"member",children:"Member"}),t.jsx("option",{value:"guest",children:"Guest"})]})}),t.jsx(Js,{label:"Assign to Team",children:t.jsxs("select",{value:w,onChange:k=>N(k.target.value),className:"input",children:[t.jsx("option",{value:"",children:"No team"}),n.map(k=>t.jsx("option",{value:k.id,children:k.name},k.id))]})})]}),t.jsx(Js,{label:"Email",children:t.jsx("input",{value:m,onChange:k=>f(k.target.value),type:"email",placeholder:"Optional (required for login)",className:"input"})}),t.jsxs("div",{className:"border-t border-border-default pt-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:"Set a password to allow this person to log in."}),t.jsx(Js,{label:"Password",children:t.jsx("input",{value:g,onChange:k=>x(k.target.value),type:"password",placeholder:"Leave blank for no login access",className:"input"})}),g&&t.jsx("div",{className:"mt-3",children:t.jsx(Js,{label:"Confirm Password",children:t.jsx("input",{value:p,onChange:k=>y(k.target.value),type:"password",placeholder:"Repeat password",className:"input"})})})]}),C&&t.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:C}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:O,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 rounded-lg text-white",children:"Add Member"})]})]})})}function KT({teamId:e,ungrouped:n,onClose:s,onAdd:l}){return t.jsx(eu,{onClose:s,title:"Add Existing Member to Team",children:t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Select an ungrouped member to add to this team."}),n.length===0?t.jsx("div",{className:"text-center py-8 text-sm text-fg-tertiary",children:"All members are already in a team."}):t.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:n.map(o=>t.jsxs("button",{onClick:()=>l(o.id,o.type),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:border-brand-500 hover:bg-brand-500/10 text-left transition-all",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold text-white ${o.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:o.name.charAt(0)}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-sm",children:o.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[o.role," · ",o.type==="agent"?"AI":"Human"]})]}),o.status&&t.jsx("span",{className:`w-2 h-2 rounded-full ${o.status==="idle"?"bg-green-400":o.status==="working"?"bg-brand-400":"bg-gray-600"}`})]},o.id))}),t.jsx("div",{className:"flex justify-end pt-2",children:t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Close"})})]})})}function ZT({onClose:e,onConnected:n}){const[s,l]=v.useState(""),[o,d]=v.useState(""),[c,h]=v.useState(!1),[m,f]=v.useState(null),[g,x]=v.useState(null),p=async()=>{if(!s.trim()){d("Agent name is required");return}const w=s.trim().toLowerCase().replace(/\s+/g,"-");h(!0),d("");try{const N=await fetch("/api/external-agents/register",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({externalAgentId:w,agentName:s.trim(),orgId:"default",capabilities:["general"]})});if(!N.ok){const _=await N.json().catch(()=>({}));throw new Error(_.error??`HTTP ${N.status}`)}const C=await N.json();f({externalAgentId:w,markusAgentId:C.registration?.markusAgentId,token:C.token,gatewayUrl:C.gatewayUrl})}catch(N){d(String(N))}h(!1)},y=(w,N)=>{navigator.clipboard.writeText(w),x(N),setTimeout(()=>x(null),2e3)};return t.jsx(eu,{onClose:e,title:"Import OpenClaw Agent",width:"w-[560px]",children:m?(()=>{const w=m.gatewayUrl??`${window.location.origin}/api/gateway`,N=`Connect to the Markus AI platform as an external agent.
43
-
44
- Gateway URL: ${w}
45
- Agent ID: ${m.externalAgentId}
46
- ${m.token?`Bearer Token: ${m.token}`:""}
47
-
48
- Step 1: Read the integration handbook at GET ${w}/manual (set header Authorization: Bearer <token above>). It describes the full Markus concept model, API endpoints, and collaboration patterns.
49
- Step 2: Start a sync loop — call POST ${w}/sync every 30 seconds with your status. The response includes assigned tasks, inbox messages, team context (colleagues), and project context (requirements).
50
- Step 3: Accept and execute tasks, report progress, and communicate with teammates via the sync message system.`;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"text-3xl mb-3 text-green-600",children:"✓"}),t.jsx("div",{className:"text-base text-green-600 font-medium mb-1",children:"Agent registered"}),t.jsx("div",{className:"text-sm text-fg-secondary mt-1",children:t.jsx("strong",{children:s})})]}),t.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/30 rounded-xl p-4",children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-3",children:"Copy this prompt and paste it into your OpenClaw agent, Cursor, or any AI assistant."}),t.jsx("button",{onClick:()=>y(N,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${g==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:g==="prompt"?"Copied!":"Copy Connection Prompt"})]}),t.jsx("div",{className:"flex justify-end pt-5",children:t.jsx("button",{onClick:()=>{n()},className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:"Done"})})]})})():t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-4",children:"Register an OpenClaw agent to join your Markus organization. After registration, you'll get a ready-to-use connection config."}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Js,{label:"Agent Name *",children:t.jsx("input",{className:"input",placeholder:"e.g. Alice",value:s,onChange:w=>l(w.target.value),autoFocus:!0})}),o&&t.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:o}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:p,disabled:c,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-white disabled:opacity-50",children:c?"Connecting...":"Import Agent"})]})]})]})})}let jy=new Map;function WT(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function QT({authUser:e,agents:n,teams:s,humans:l,tasks:o,externalAgents:d,groupChats:c,chatMode:h,selectedAgent:m,activeChannel:f,activeDmUserId:g,onSelectAgent:x,onSelectChannel:p,onSelectDm:y,onRefreshTeams:w,onRefreshAgents:N,onViewProfile:C,width:_,onResizeStart:O,hidden:k}){const S=_s(),R=e?.role==="owner"||e?.role==="admin",D=v.useMemo(()=>new Set(d.map(ie=>ie.markusAgentId).filter(Boolean)),[d]),[Y,z]=v.useState([]),[K,U]=v.useState(new Set),[G,V]=v.useState(!1),[E,T]=v.useState(null),[L,A]=v.useState(null),[P,q]=v.useState(!1),[W,B]=v.useState(null),[F,X]=v.useState(null),[I,M]=v.useState(null),[H,Z]=v.useState(!1),ee=v.useRef(null),[ne,ae]=v.useState(null),he=(ie,qe="success")=>{ae({message:ie,type:qe}),setTimeout(()=>ae(null),3e3)},[Ne,Le]=v.useState(!1),[ye,je]=v.useState(!1);v.useEffect(()=>{re.governance.getSystemStatus().then(ie=>Le(ie.globalPaused)).catch(()=>{})},[]);const Ae=v.useCallback(()=>{Xe({title:Ne?"Resume All Agents":"Pause All Agents",message:Ne?"All agents will resume processing events from their mailbox.":"All agents will be paused. Events will still enter the mailbox but will not be processed. In-progress tasks will be blocked.",confirmLabel:Ne?"Resume":"Pause",onConfirm:async()=>{je(!0);try{Ne?(await re.governance.resumeAll(),Le(!1)):(await re.governance.pauseAll(),Le(!0))}catch{}je(!1)}})},[Ne]),[$e,Xe]=v.useState(null),tt=(ie,qe,ze,We,lt)=>{Xe({title:ie,message:qe,onConfirm:ze,confirmLabel:We,checkboxes:lt})},[et,_t]=v.useState(null),[se,Te]=v.useState(null),nt=v.useRef(null),yt=v.useRef(null),[Xt,we]=v.useState(!1),[De,Pe]=v.useState(null),[Ze,mt]=v.useState(""),Kt=v.useCallback(ie=>{if(!ie)return;const qe=ie.getBoundingClientRect(),ze=8;qe.bottom>window.innerHeight&&(ie.style.top=`${Math.max(ze,window.innerHeight-qe.height-ze)}px`),qe.right>window.innerWidth&&(ie.style.left=`${Math.max(ze,window.innerWidth-qe.width-ze)}px`)},[]),[ln,Ht]=v.useState(jy),Lt=v.useMemo(()=>n.map(ie=>ie.id).sort().join(","),[n]);v.useEffect(()=>{if(!n.length)return;let ie=!1;const qe=async()=>{const We=[];if(await Promise.allSettled(n.map(async lt=>{try{const{sessions:Ct}=await re.sessions.listByAgent(lt.id,1);if(!Ct.length)return;const{messages:dt}=await re.sessions.getMessages(Ct[0].id,1);if(dt.length){const zt=dt[0],pt=zt.metadata?.segments;let on=zt.content;if(pt&&pt.length>0){const Fe=[...pt].reverse().find(ht=>ht.type==="text");Fe&&Fe.type==="text"&&(on=Fe.content)}const de=on.replace(/<think>[\s\S]*?<\/think>/g,"").replace(/\n+/g," ").trim().slice(0,80);de&&We.push([lt.id,de])}}catch{}})),!ie){const lt=new Map(We);jy=lt,Ht(lt)}};qe();const ze=setInterval(qe,3e4);return()=>{ie=!0,clearInterval(ze)}},[Lt]);const At=v.useCallback(()=>{re.teams.list().then(ie=>z(ie.ungrouped)).catch(()=>{})},[]);v.useEffect(()=>{At()},[At]),v.useEffect(()=>xn.on("*",At),[At]),v.useEffect(()=>{if(!W&&!F&&!H)return;const ie=qe=>{B(null),X(null),Z(!1)};return setTimeout(()=>document.addEventListener("click",ie),0),()=>document.removeEventListener("click",ie)},[W,F,H]);const St=(ie,qe)=>{tt(`Delete "${qe}"?`,"This team will be removed from the database. Check options below to also delete members and disk files.",async ze=>{const We=ze?.deleteMembers??!0,lt=ze?.purgeFiles??!1;await re.teams.delete(ie,We,{purgeFiles:lt}),w(),At(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Delete Team",[{id:"deleteMembers",label:"Also delete all members in this team",defaultChecked:!0},{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},en=async(ie,qe)=>{try{const We=await(qe==="start"?re.teams.startAll:qe==="stop"?re.teams.stopAll:qe==="pause"?re.teams.pauseAll:re.teams.resumeAll)(ie),lt=We.success?.length??0,Ct=We.failed?.length??0,dt={start:"started",stop:"stopped",pause:"paused",resume:"resumed"};Ct>0?he(`${qe}: ${lt} succeeded, ${Ct} failed`,"error"):lt>0&&he(`${lt} agent${lt>1?"s":""} ${dt[qe]}`,"success"),N()}catch(ze){he(`Failed to ${qe}: ${ze instanceof Error?ze.message:String(ze)}`,"error")}},tn=async(ie,qe,ze)=>{await re.teams.update(ie,{managerId:qe,managerType:ze}),w()},ve=async ie=>{if(!Ze.trim()){Pe(null);return}await re.teams.update(ie,{name:Ze.trim()}),Pe(null),w()},Ve=async(ie,qe)=>{qe==="offline"?await re.agents.start(ie):await re.agents.stop(ie),N()},Rt=(ie,qe)=>{tt("Remove from team?","This member will be moved to Ungrouped.",async()=>{await re.teams.removeMember(ie,qe),w(),At()},"Remove")},Pt=(ie,qe,ze)=>{tt(`Remove "${qe}"?`,"This agent will be removed from the database. Check the option below to also delete its workspace, memory, and other files from disk.",async We=>{{const lt=We?.purgeFiles??!1;await re.agents.remove(ie,{purgeFiles:lt})}N(),w(),At(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Remove",[{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},vt=(ie,qe,ze)=>{yt.current={x:ie.clientX,y:ie.clientY},nt.current=setTimeout(()=>{_t({agentId:qe,fromTeamId:ze}),we(!0)},200)},sn=ie=>{if(!yt.current||!nt.current)return;const qe=Math.abs(ie.clientX-yt.current.x),ze=Math.abs(ie.clientY-yt.current.y);(qe>5||ze>5)&&(Xt||(clearTimeout(nt.current),nt.current=null))},gn=async()=>{if(nt.current&&(clearTimeout(nt.current),nt.current=null),yt.current=null,Xt&&et&&se){const ie=se==="_ungrouped"?void 0:se;try{if(et.fromTeamId&&et.fromTeamId!==ie&&await re.teams.removeMember(et.fromTeamId,et.agentId),ie&&ie!==et.fromTeamId){const qe=n.find(ze=>ze.id===et.agentId);await re.teams.addMember(ie,et.agentId,"agent")}w(),N(),At()}catch(qe){he(`Move failed: ${qe instanceof Error?qe.message:String(qe)}`,"error")}}_t(null),Te(null),we(!1)},rt=v.useMemo(()=>new Map(s.map(ie=>[ie.id,ie])),[s]),Wt=v.useMemo(()=>{const ie=new Map,qe=[];for(const ze of n)if(ze.teamId&&rt.has(ze.teamId)){const We=ie.get(ze.teamId)??[];We.push(ze),ie.set(ze.teamId,We)}else qe.push(ze);return{byTeam:ie,ungrouped:qe}},[n,rt]);s.filter(ie=>Wt.byTeam.has(ie.id)||ie.members?.length>0).map(ie=>ie.id);const Mn=ie=>U(qe=>{const ze=new Set(qe);return ze.has(ie)?ze.delete(ie):ze.add(ie),ze}),Mt=(ie,qe)=>{const ze=h==="direct"&&m===ie.id,We=D.has(ie.id),lt=ie.status==="idle"?"bg-green-500":ie.status==="working"?"bg-blue-500 animate-pulse":ie.status==="error"?"bg-red-500":ie.status==="paused"?"bg-amber-500":"bg-gray-600",dt=(qe?rt.get(qe):void 0)?.managerId===ie.id,zt=ie.role?.toLowerCase().replace(/[-_]/g," ").trim(),pt=ie.name.toLowerCase().trim(),on=zt&&zt!==pt,de=ln.get(ie.id)||ie.currentActivity?.label?.slice(0,60)||"",Fe=ie.status==="idle"?"Online":ie.status==="working"?"Working":ie.status==="error"?"Error":ie.status==="paused"?"Paused":"Offline";return t.jsx("div",{className:`relative mb-0.5 ${Xt&&et?.agentId===ie.id?"opacity-40":""}`,onPointerDown:ht=>vt(ht,ie.id,qe),onPointerMove:sn,onPointerUp:gn,children:t.jsxs("button",{onClick:()=>{Xt||x(ie.id)},onContextMenu:ht=>{R&&(ht.preventDefault(),X({agentId:ie.id,teamId:qe,x:ht.clientX,y:ht.clientY}))},className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs transition-colors select-none ${S?"":"touch-none"} ${ze?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${ze?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:WT(ie.name)}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight",children:ie.name}),on&&t.jsxs("span",{className:"text-[9px] text-fg-tertiary shrink-0 truncate max-w-[60px]",children:["(",ie.role,")"]}),dt&&t.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-600 shrink-0",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),We&&t.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-brand-500/20 text-brand-500 font-medium shrink-0 leading-relaxed",children:"EXT"})]}),t.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-tertiary",children:de||" "})]}),t.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[ie.mailboxDepth!=null&&ie.mailboxDepth>0&&t.jsx("span",{className:"text-[8px] text-fg-tertiary bg-surface-overlay rounded-full px-1 leading-relaxed",children:ie.mailboxDepth}),t.jsx("span",{title:Fe,onClick:ht=>{ht.stopPropagation(),C(ie.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${lt}`})]})]})},ie.id)},yn=(ie,qe,ze,We)=>{const lt=K.has(ie),Ct=Xt&&se===ie&&et?.fromTeamId!==ie,dt=ie!=="_ungrouped"?(Nn.byTeam.get(ie)??[])[0]:void 0,zt=dt&&h==="channel"&&f===dt.channelKey;return t.jsxs("div",{className:`mb-1 rounded-lg transition-colors ${Ct?"ring-1 ring-brand-500/50 bg-brand-500/5":""}`,onPointerEnter:()=>{Xt&&Te(ie)},onPointerLeave:()=>{Xt&&se===ie&&Te(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{dt?p(dt.channelKey):Mn(ie)},onContextMenu:pt=>{!R||!qe||(pt.preventDefault(),B({teamId:ie,x:pt.clientX,y:pt.clientY}))},className:`flex-1 flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors min-w-0 ${zt?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center shrink-0 ${zt?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[De===ie?t.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-secondary text-[11px] font-medium outline-none w-full",value:Ze,onChange:pt=>mt(pt.target.value),onBlur:()=>ve(ie),onKeyDown:pt=>{pt.key==="Enter"&&ve(ie),pt.key==="Escape"&&Pe(null)},onClick:pt=>pt.stopPropagation(),autoFocus:!0}):t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:We}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:[ze.length," members"]})]})]}),t.jsx("button",{onClick:()=>Mn(ie),className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors shrink-0 opacity-60 hover:opacity-100",title:lt?"Expand":"Collapse",children:t.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${lt?"":"rotate-90"}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})}),R&&qe&&t.jsx("button",{onClick:pt=>{pt.stopPropagation(),B({teamId:ie,x:pt.clientX,y:pt.clientY})},className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors shrink-0 opacity-0 group-hover/teamhdr:opacity-100",title:"More options",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"1"}),t.jsx("circle",{cx:"12",cy:"5",r:"1"}),t.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]}),Ct&&Xt&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:"Drop here"}),!lt&&t.jsx("div",{className:"ml-1",children:ze.map(pt=>Mt(pt,ie==="_ungrouped"?void 0:ie))})]},ie)},Nn=v.useMemo(()=>{const ie=new Map,qe=[];for(const ze of c)if(ze.teamId){const We=ie.get(ze.teamId)??[];We.push(ze),ie.set(ze.teamId,We)}else{const We=s.find(lt=>ze.name.toLowerCase().includes(lt.name.toLowerCase())||lt.name.toLowerCase().includes(ze.name.toLowerCase()));if(We){const lt=ie.get(We.id)??[];lt.push(ze),ie.set(We.id,lt)}else qe.push(ze)}return{byTeam:ie,unmatched:qe}},[c,s]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`bg-surface-secondary/60 border-r border-border-default flex flex-col ${_!=null?"shrink-0":"flex-1 min-w-0"}`,style:k?{display:"none"}:_!=null?{width:_}:void 0,children:[t.jsxs("div",{className:"px-4 h-14 flex items-center border-b border-border-default shrink-0",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Chat"}),t.jsx("div",{className:"ml-auto",children:t.jsx("button",{onClick:Ae,disabled:ye,title:Ne?"Resume all agents":"Pause all agents",className:`flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border transition-colors ${Ne?"bg-green-500/10 border-green-500/30 text-green-500 hover:bg-green-500/20":"bg-amber-500/10 border-amber-500/30 text-amber-600 hover:bg-amber-500/20"} disabled:opacity-50`,children:Ne?t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})," Resume"]}):t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),t.jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]})," Pause"]})})})]}),R&&t.jsx("div",{className:"px-3 pt-2 pb-1 flex items-center gap-1.5",ref:ee,children:t.jsxs("div",{className:"relative flex-1",children:[t.jsxs("button",{onClick:()=>Z(!H),className:"w-full flex items-center justify-center gap-1 px-2 py-1.5 text-[10px] font-medium text-fg-secondary hover:text-fg-primary bg-surface-elevated/60 hover:bg-surface-elevated rounded-lg transition-colors",children:[t.jsx("span",{className:"text-brand-500",children:"+"})," Manage",t.jsx("svg",{className:`w-2.5 h-2.5 ml-auto transition-transform ${H?"rotate-180":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),H&&t.jsxs("div",{className:"absolute left-0 top-full mt-1 w-48 bg-surface-secondary border border-border-default rounded-lg shadow-xl z-30 overflow-hidden",children:[t.jsxs("button",{onClick:()=>{Z(!1),V(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"New Team"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Create an empty team"})]}),t.jsxs("button",{onClick:()=>{Z(!1),gt.navigate(ge.STORE)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),t.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Add Agent"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Create from templates"})]}),t.jsxs("button",{onClick:()=>{Z(!1),q(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-brand-500 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 12a9 9 0 0 1-9 9m9-9a9 9 0 0 0-9-9m9 9H3m9 9a9 9 0 0 1-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 0 1 9-9"})}),"Import OpenClaw"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Connect an external agent"})]}),t.jsxs("button",{onClick:()=>{Z(!1),T({})},className:"w-full text-left px-4 py-2.5 text-xs text-green-600 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),t.jsx("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]}),"Add Human"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Add a human team member"})]})]})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[n.length===0&&s.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:"No agents yet"}),Nn.unmatched.map(ie=>t.jsxs("button",{onClick:()=>p(ie.channelKey),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${h==="channel"&&f===ie.channelKey?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center shrink-0 ${h==="channel"&&f===ie.channelKey?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:ie.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:"Group Chat"})]}),ie.memberCount!==void 0&&ie.memberCount>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary shrink-0",children:ie.memberCount})]},ie.id)),s.map(ie=>{const qe=Wt.byTeam.get(ie.id)??[];return qe.length===0&&(!ie.members||ie.members.length===0)?null:yn(ie.id,ie,qe,ie.name)}),s.filter(ie=>(Wt.byTeam.get(ie.id)??[]).length===0&&ie.members&&ie.members.length>0).map(ie=>yn(ie.id,ie,[],ie.name)),Wt.ungrouped.length>0&&yn("_ungrouped",null,Wt.ungrouped,"Other"),s.length===0&&n.length>0&&n.map(ie=>Mt(ie)),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default/60",children:[t.jsx("p",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"People"}),e&&t.jsxs("button",{onClick:()=>y(e.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${h==="dm"&&(g===e.id||!g)?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${h==="dm"&&(g===e.id||!g)?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-500"}`,children:e.name[0]?.toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[11px] leading-tight",children:e.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:"My Notes"})]}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),l.filter(ie=>ie.id!==e?.id).map(ie=>t.jsxs("button",{onClick:()=>y(ie.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${h==="dm"&&g===ie.id?"bg-green-500/10 text-green-600":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${h==="dm"&&g===ie.id?"bg-green-600 text-white":"bg-green-500/10 text-green-600"}`,children:ie.name[0]?.toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[11px] leading-tight",children:ie.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:ie.email||ie.role})]}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shrink-0"})]},ie.id))]})]})]}),O&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative",onMouseDown:O,children:t.jsx("div",{className:"absolute inset-y-0 -left-0.5 -right-0.5 group-hover:bg-brand-500/30 group-active:bg-brand-500/50 transition-colors"})}),W&&(()=>{const ie=Wt.byTeam.get(W.teamId)??[],qe=ie.some(Ct=>Ct.status==="offline"),ze=ie.some(Ct=>Ct.status==="idle"||Ct.status==="working"),We=ie.some(Ct=>Ct.status==="paused"),lt=ie.some(Ct=>Ct.status!=="offline");return t.jsxs("div",{ref:Kt,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:W.x,top:W.y},onClick:Ct=>Ct.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{const Ct=rt.get(W.teamId);Ct&&(Pe(W.teamId),mt(Ct.name)),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Rename Team"]}),qe&&t.jsxs("button",{onClick:()=>{en(W.teamId,"start"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Start All"]}),lt&&t.jsxs("button",{onClick:()=>{en(W.teamId,"stop"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),"Stop All"]}),ze&&t.jsxs("button",{onClick:()=>{en(W.teamId,"pause"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),t.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}),"Pause All"]}),We&&t.jsxs("button",{onClick:()=>{en(W.teamId,"resume"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-blue-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume All"]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:()=>{B(null),gt.navigate(ge.STORE)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Agent"]}),t.jsxs("button",{onClick:()=>{B(null),T({teamId:W.teamId})},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),t.jsx("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]}),"Add Human"]}),Y.length>0&&t.jsxs("button",{onClick:()=>{B(null),A(W.teamId)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("polyline",{points:"17 11 19 13 23 9"})]}),"Add Existing"]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:()=>{const Ct=rt.get(W.teamId);Ct&&St(W.teamId,Ct.name),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Delete Team"]})]})})(),F&&(()=>{const ie=n.find(lt=>lt.id===F.agentId);if(!ie)return null;const ze=(F.teamId?rt.get(F.teamId):void 0)?.managerId===ie.id,We=ie.id===e?.id;return t.jsxs("div",{ref:Kt,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:F.x,top:F.y},onClick:lt=>lt.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{X(null),C(ie.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"View Profile"]}),ie.status==="offline"?t.jsxs("button",{onClick:()=>{Ve(ie.id,"offline"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Start"]}):t.jsxs("button",{onClick:()=>{Ve(ie.id,ie.status??"idle"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),"Stop"]}),F.teamId&&!ze&&t.jsxs("button",{onClick:()=>{tn(F.teamId,ie.id,"agent"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Set as Manager"]}),F.teamId&&t.jsxs("button",{onClick:()=>{Rt(F.teamId,ie.id),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"9 14 4 9 9 4"}),t.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),"Remove from team"]}),s.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary uppercase flex items-center gap-1.5",children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 12h14"}),t.jsx("path",{d:"M12 5l7 7-7 7"})]}),"Move to"]}),s.filter(lt=>lt.id!==F.teamId).map(lt=>t.jsx("button",{onClick:async()=>{F.teamId&&await re.teams.removeMember(F.teamId,ie.id),await re.teams.addMember(lt.id,ie.id,"agent"),w(),N(),At(),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:lt.name},lt.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!We&&t.jsxs("button",{onClick:()=>{Pt(ie.id,ie.name),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Remove from org"]})]})})(),G&&t.jsx(GT,{onClose:()=>V(!1),onCreate:async(ie,qe)=>{await re.teams.create(ie,qe),V(!1),w()}}),E!==null&&t.jsx(XT,{teamId:E.teamId,teams:s,onClose:()=>T(null),onAdd:async(ie,qe,ze,We,lt)=>{await re.users.create(ie,qe,void 0,ze,We,lt),T(null),w()}}),L!==null&&t.jsx(KT,{teamId:L,ungrouped:Y,onClose:()=>A(null),onAdd:async(ie,qe)=>{await re.teams.addMember(L,ie,qe),A(null),w(),At()}}),P&&t.jsx(ZT,{onClose:()=>q(!1),onConnected:()=>{q(!1),N(),w()}}),$e&&t.jsx(Ej,{title:$e.title,message:$e.message,confirmLabel:$e.confirmLabel,checkboxes:$e.checkboxes,onConfirm:ie=>{$e.onConfirm(ie),Xe(null)},onCancel:()=>Xe(null)}),ne&&t.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2.5 rounded-lg shadow-xl text-sm font-medium ${ne.type==="error"?"bg-red-500/10 text-red-500 border border-red-500/30":"bg-surface-elevated/95 text-fg-primary border border-border-default/50"}`,children:ne.message})]})}const JT=[{key:"overview",label:"Overview",icon:"▦"},{key:"mind",label:"Mind",icon:"🔮"},{key:"files",label:"Files",icon:"📄"},{key:"tools",label:"Tools",icon:"⚒"},{key:"skills",label:"Skills",icon:"◆"},{key:"memory",label:"Memory",icon:"🧠"},{key:"heartbeat",label:"Heartbeat",icon:"♡"}],eA={idle:"bg-green-400",working:"bg-brand-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function vd(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function tA({agentId:e,onBack:n,inline:s,defaultTab:l}){const[o,d]=v.useState(null),[c,h]=v.useState(l??"overview"),[m,f]=v.useState(null),g=v.useCallback(()=>{re.agents.get(e).then(d).catch(()=>{})},[e]);if(v.useEffect(()=>(h(l??"overview"),f(null),g(),re.externalAgents.list().then(y=>{const w=y.agents.find(N=>N.markusAgentId===e);f(w??null)}).catch(()=>{}),xn.on("agent:update",y=>{y.payload.agentId===e&&g()})),[e,g]),!o)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading agent..."});const x=eA[o.state.status]??"bg-gray-500";return t.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[t.jsxs("div",{className:"px-5 py-3.5 border-b border-border-default bg-surface-secondary sticky top-0 z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-white flex items-center justify-center text-lg font-bold shrink-0",children:o.name.charAt(0)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h2",{className:"text-base font-semibold",children:o.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${x}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:o.state.status}),m&&t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:"External"}),o.agentRole==="manager"&&t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[o.role,o.roleDescription?` — ${o.roleDescription}`:""]})]}),t.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[t.jsxs("button",{onClick:()=>gt.navigate(ge.TEAM,{agentId:e}),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors flex items-center gap-1",children:[t.jsx("span",{children:"◈"})," Chat"]}),t.jsxs("button",{onClick:async()=>{if(o)try{const{filesMap:p}=await re.agents.getFilesMap(e),y={type:"agent",name:o.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||o.name,displayName:o.name,version:"1.0.0",description:o.roleDescription??o.role,author:"",category:"general",tags:[],agent:{roleName:o.role,agentRole:o.agentRole},dependencies:{skills:o.skills??[]}};await Xn.publishViaProxy({itemType:"agent",name:o.name,description:y.description,category:"general",config:y,files:p}),alert(`Published "${o.name}" to Markus Hub`)}catch(p){alert(`Failed to publish: ${p}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:n,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:JT.filter(p=>!m||["overview","mind"].includes(p.key)).map(p=>t.jsxs("button",{onClick:()=>h(p.key),className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${c===p.key?"bg-surface-primary text-fg-primary border-border-default":"text-fg-tertiary border-transparent hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[t.jsx("span",{className:"mr-1",children:p.icon}),p.label]},p.key))})]}),t.jsxs("div",{className:"p-5",children:[c==="overview"&&t.jsx(nA,{agent:o,onUpdate:g,externalInfo:m}),c==="mind"&&t.jsx(mA,{agentId:e}),c==="files"&&t.jsx(rA,{agentId:e}),c==="tools"&&t.jsx(lA,{tools:o.tools??[]}),c==="skills"&&t.jsx(iA,{agent:o}),c==="memory"&&t.jsx(oA,{agentId:e}),c==="heartbeat"&&t.jsx(cA,{agentId:e,initialData:o.heartbeat})]})]})}function nA({agent:e,onUpdate:n,externalInfo:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(e.name),[h,m]=v.useState(e.agentRole),[f,g]=v.useState(e.config?.llmConfig?.modelMode??"default"),[x,p]=v.useState(e.config?.llmConfig.primary??""),[y,w]=v.useState(e.config?.llmConfig.fallback??""),[N,C]=v.useState(!1),[_,O]=v.useState({}),[k,S]=v.useState(""),[R,D]=v.useState([]),[Y,z]=v.useState(null),[K,U]=v.useState(null),[G,V]=v.useState([]),[E,T]=v.useState(null),[L,A]=v.useState(null),[P,q]=v.useState("");v.useEffect(()=>{re.settings.getLlm().then(M=>{O(M.providers),S(M.defaultProvider)}).catch(()=>{}),re.tasks.list({assignedAgentId:e.id}).then(M=>D(M.tasks.slice(0,5))).catch(()=>{}),re.usage.agents().then(M=>{const H=M.agents.find(Z=>Z.agentId===e.id);H&&z(H)}).catch(()=>{}),re.agents.getRecentActivities(e.id).then(M=>V(M.activities)).catch(()=>{}),re.system.storage().then(M=>{q(M.dataDir+"/agents/"+e.id);const H=M.agents.find(Z=>Z.id===e.id);H&&A(H)}).catch(()=>{})},[e.id]);const W=Object.entries(_).filter(([,M])=>M.configured).map(([M])=>M),B=e.config?.llmConfig?.modelMode??"default",F=async()=>{C(!0);try{await re.agents.updateConfig(e.id,{name:d,agentRole:h,llmConfig:{modelMode:f,primary:f==="custom"?x:k,fallback:y||void 0}}),n(),o(!1)}catch{}C(!1)},X=()=>{e.state.status==="offline"?re.agents.start(e.id).then(n):re.agents.stop(e.id).then(n)},I={pending:"bg-gray-400",assigned:"bg-blue-400",in_progress:"bg-brand-400",completed:"bg-green-400",failed:"bg-red-400",cancelled:"bg-gray-600"};if(s){const M=[{method:"POST",path:"/api/gateway/sync",desc:"Exchange status, tasks, messages, team & project context"},{method:"GET",path:"/api/gateway/manual",desc:"Download integration handbook (dynamic, includes colleagues & projects)"},{method:"GET",path:"/api/gateway/team",desc:"Query team members, roles, and manager"},{method:"GET",path:"/api/gateway/projects",desc:"List projects with governance"},{method:"GET",path:"/api/gateway/requirements",desc:"Query requirements (filter by project/status)"}],H=[{field:"assignedTasks",desc:"Tasks with requirement & project traceability"},{field:"inboxMessages",desc:"Messages from teammates"},{field:"teamContext",desc:"Colleagues (id, name, role, status) + manager"},{field:"projectContext",desc:"Projects and active requirements"}];return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Cn,{title:"Identity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Pn,{label:"Name",children:e.name}),t.jsx(Pn,{label:"Agent Role",children:t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx(Pn,{label:"Role Template",children:e.role}),t.jsx(Pn,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx(Pn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Pn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsx(Cn,{title:"Connection Status",children:t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Qn,{label:"Connection",value:s.connected?"Online":"Offline",color:s.connected?"green":"gray"}),t.jsx(Qn,{label:"Platform",value:"OpenClaw"}),t.jsx(Qn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Qn,{label:"Last Sync",value:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleTimeString():"Never"})]})}),t.jsx(Cn,{title:"External Agent Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Pn,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx(Pn,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx(Pn,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx(Pn,{label:"Last Heartbeat",children:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleString():"Never"})]})}),t.jsx(Cn,{title:"Sync Context (received every sync cycle)",children:t.jsx("div",{className:"space-y-1.5",children:H.map(Z=>t.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("span",{className:"font-mono text-[10px] text-brand-500 shrink-0 pt-0.5",children:Z.field}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Z.desc})]},Z.field))})}),t.jsx(Cn,{title:"Gateway API Endpoints",children:t.jsx("div",{className:"space-y-1.5",children:M.map(Z=>t.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("span",{className:`text-[10px] font-semibold shrink-0 pt-0.5 ${Z.method==="POST"?"text-amber-600":"text-green-600"}`,children:Z.method}),t.jsx("span",{className:"font-mono text-[10px] text-fg-secondary shrink-0 pt-0.5",children:Z.path}),t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:Z.desc})]},Z.path))})}),R.length>0&&t.jsx(Cn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>gt.navigate(ge.WORK),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:R.map(Z=>t.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-2.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${I[Z.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:Z.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:Z.status.replace(/_/g," ")})]},Z.id))})})]})}return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Cn,{title:"Identity",action:l?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>o(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:F,disabled:N,className:"text-xs text-brand-500 hover:text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>{o(!0),c(e.name),m(e.agentRole),g(e.config?.llmConfig?.modelMode??"default"),p(e.config?.llmConfig.primary??""),w(e.config?.llmConfig.fallback??"")},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Pn,{label:"Name",children:l?t.jsx("input",{className:"input-sm",value:d,onChange:M=>c(M.target.value)}):e.name}),t.jsx(Pn,{label:"Agent Role",children:l?t.jsx("div",{className:"flex gap-1.5",children:["worker","manager"].map(M=>t.jsx("button",{onClick:()=>m(M),className:`px-2 py-1 text-[10px] rounded border transition-colors capitalize ${h===M?M==="manager"?"bg-amber-500/15 text-amber-600 border-amber-500/30":"bg-blue-500/15 text-blue-600 border-blue-500/30":"bg-surface-elevated text-fg-tertiary border-border-default"}`,children:M},M))}):t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx(Pn,{label:"Role Template",children:e.role}),t.jsx(Pn,{label:"Agent ID",mono:!0,children:e.id}),t.jsx(Pn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Pn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsxs(Cn,{title:"Runtime Status",children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Qn,{label:"Status",value:e.state.status,color:e.state.status==="idle"?"green":e.state.status==="working"?"indigo":e.state.status==="error"?"red":"gray"}),t.jsx(Qn,{label:"Tokens Today",value:String(e.state.tokensUsedToday)}),t.jsx(Qn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Qn,{label:"Last Heartbeat",value:e.state.lastHeartbeat?new Date(e.state.lastHeartbeat).toLocaleTimeString():"Never"})]}),e.state.status==="error"&&t.jsxs("div",{className:"mt-3 bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),t.jsx("span",{className:"text-xs font-medium text-red-500",children:"Error Details"}),e.state.lastErrorAt&&t.jsx("span",{className:"text-[10px] text-red-500/50 ml-auto",children:new Date(e.state.lastErrorAt).toLocaleString()})]}),t.jsx("pre",{className:"text-[11px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono bg-red-500/5 rounded p-2",children:e.state.lastError||"Agent encountered an error. Check logs for more details."})]}),e.state.status==="working"&&(e.state.activeTaskIds?.length??0)>0&&t.jsxs("div",{className:"mt-3 bg-brand-500/10 border border-brand-500/20 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-brand-400 animate-pulse"}),t.jsx("span",{className:"text-xs font-medium text-brand-500",children:"Currently Working"}),t.jsxs("span",{className:"text-[10px] text-brand-500/50 ml-auto",children:[e.state.activeTaskIds.length," active task",e.state.activeTaskIds.length>1?"s":""]})]}),t.jsx("div",{className:"space-y-1",children:R.filter(M=>e.state.activeTaskIds?.includes(M.id)).map(M=>t.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),t.jsx("span",{className:"text-fg-secondary truncate flex-1",children:M.title}),t.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:M.status.replace(/_/g," ")})]},M.id))})]}),t.jsx("div",{className:"flex gap-2 mt-4 pt-3 border-t border-border-default/50",children:t.jsx("button",{onClick:X,className:"px-3 py-1.5 text-xs border border-border-default rounded-lg hover:border-brand-500 transition-colors",children:e.state.status==="offline"?"▶ Start":"⏹ Stop"})})]}),Y&&t.jsx(Cn,{title:"Usage",children:t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Qn,{label:"Total Tokens",value:vd(Y.totalTokens)}),t.jsx(Qn,{label:"Requests",value:String(Y.requestCount)}),t.jsx(Qn,{label:"Tool Calls",value:String(Y.toolCalls)}),t.jsx(Qn,{label:"Prompt Tokens",value:vd(Y.promptTokens)}),t.jsx(Qn,{label:"Completion Tokens",value:vd(Y.completionTokens)}),t.jsx(Qn,{label:"Est. Cost",value:`$${Y.estimatedCost<.01?Y.estimatedCost.toFixed(4):Y.estimatedCost.toFixed(2)}`})]})}),L&&t.jsxs(Cn,{title:"Storage",action:t.jsx("button",{onClick:()=>{re.system.openPath(P)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Open folder →"}),children:[t.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[t.jsx("span",{className:"text-lg font-bold text-fg-primary",children:wy(L.size)}),t.jsx("span",{className:"text-xs text-fg-tertiary font-mono truncate",children:P})]}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:L.subItems.filter(M=>M.size>0).map(M=>t.jsx(Qn,{label:M.name,value:wy(M.size)},M.name))})]}),t.jsx(Cn,{title:"LLM Configuration",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Pn,{label:"Model Mode",children:l?t.jsx("div",{className:"flex gap-1.5",children:["default","custom"].map(M=>t.jsx("button",{onClick:()=>g(M),className:`px-2.5 py-1 text-[10px] rounded border transition-colors capitalize ${f===M?M==="default"?"bg-brand-500/15 text-brand-500 border-brand-500/30":"bg-amber-500/15 text-amber-600 border-amber-500/30":"bg-surface-elevated text-fg-tertiary border-border-default"}`,children:M==="default"?"System Default":"Custom"},M))}):t.jsx("span",{className:`text-xs ${B==="custom"?"text-amber-600":"text-brand-500"}`,children:B==="custom"?"⚙ Custom":"◎ System Default"})}),t.jsx(Pn,{label:"Primary Model",children:l?f==="custom"?t.jsxs("select",{className:"input-sm",value:x,onChange:M=>p(M.target.value),children:[W.map(M=>t.jsxs("option",{value:M,children:[M," (",_[M]?.model,")"]},M)),!W.includes(x)&&x&&t.jsx("option",{value:x,children:x})]}):t.jsxs("span",{className:"text-xs text-fg-secondary italic",children:["follows system default (",k||"...",")"]}):t.jsx("span",{className:"font-mono text-xs",children:B==="custom"?e.config?.llmConfig.primary??"—":t.jsxs("span",{className:"text-fg-secondary",children:[k||e.config?.llmConfig.primary||"—"," ",t.jsx("span",{className:"text-fg-tertiary",children:"(system default)"})]})})}),t.jsx(Pn,{label:"Fallback",children:l?t.jsxs("select",{className:"input-sm",value:y,onChange:M=>w(M.target.value),children:[t.jsx("option",{value:"",children:"none"}),W.map(M=>t.jsx("option",{value:M,children:M},M))]}):t.jsx("span",{className:"font-mono text-xs",children:e.config?.llmConfig.fallback??"none"})}),t.jsx(Pn,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx(Pn,{label:"Max Tokens/Day",children:e.config?.llmConfig.maxTokensPerDay??"unlimited"})]})}),R.length>0&&t.jsx(Cn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>gt.navigate(ge.WORK),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:R.map(M=>{const H=K===M.id,Z=["in_progress","failed","completed","review"].includes(M.status);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>Z?U(H?null:M.id):void 0,className:`w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors ${Z?"hover:bg-surface-elevated/40 cursor-pointer":"cursor-default"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${I[M.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:M.status.replace(/_/g," ")}),Z&&t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:H?"▲":"▼"})]}),H&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(Tj,{taskId:M.id,isLive:M.status==="in_progress"})})]},M.id)})})}),G.filter(M=>M.type==="heartbeat").length>0&&t.jsx(Cn,{title:"Recent Heartbeats",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[G.filter(M=>M.type==="heartbeat").length," runs"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:G.filter(M=>M.type==="heartbeat").map(M=>{const H=E===M.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>T(H?null:M.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-green-400"}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(M.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:H?"▲":"▼"})]}),H&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(Dd,{agentId:e.id,activityId:M.id})})]},M.id)})})}),G.filter(M=>M.type==="chat").length>0&&t.jsx(Cn,{title:"Recent A2A Communications",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[G.filter(M=>M.type==="chat").length," conversations"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:G.filter(M=>M.type==="chat").map(M=>{const H=E===M.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>T(H?null:M.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-blue-400"}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(M.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:H?"▲":"▼"})]}),H&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(Dd,{agentId:e.id,activityId:M.id})})]},M.id)})})})]})}function rA({agentId:e}){const[n,s]=v.useState([]),[l,o]=v.useState(!0),[d,c]=v.useState(null),[h,m]=v.useState(""),[f,g]=v.useState(!1),[x,p]=v.useState(!1),[y,w]=v.useState(null),[N,C]=v.useState(!1),[_,O]=v.useState(null),k=v.useCallback(()=>{o(!0),Promise.all([re.agents.getFiles(e),re.agents.roleStatus(e).catch(()=>null)]).then(([V,E])=>{s(V.files),w(E),V.files.length>0&&!d&&(c(V.files[0].name),m(V.files[0].content))}).catch(()=>{}).finally(()=>o(!1))},[e]);v.useEffect(()=>{k()},[k]);const S=V=>{const E=n.find(T=>T.name===V);E&&(c(V),m(E.content),p(!1),O(null))},R=async()=>{if(d){g(!0);try{await re.agents.updateFile(e,d,h),s(V=>V.map(E=>E.name===d?{...E,content:h}:E)),p(!1),d==="ROLE.md"&&await re.agents.updateSystemPrompt(e,h)}catch{}g(!1)}},D=async V=>{C(!0);try{await re.agents.roleSync(e,V?[V]:void 0),O(null),p(!1),k()}catch{}C(!1)},Y=async V=>{if(_?.file===V){O(null);return}try{const E=await re.agents.roleDiff(e,V);E.agentContent!=null&&E.templateContent!=null&&O({file:V,agent:E.agentContent,template:E.templateContent})}catch{}};if(l)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading files..."});const z={"ROLE.md":"System Prompt / Role Definition","HEARTBEAT.md":"Heartbeat Tasks","POLICIES.md":"Policies & Guardrails","CONTEXT.md":"Context & Instructions"},K=y?.files.filter(V=>V.status==="modified"||V.status==="added_in_template")??[],U=y?.hasTemplate&&!y.isUpToDate,G=d?K.some(V=>V.file===d):!1;return t.jsxs("div",{className:"space-y-4",children:[U&&t.jsxs("div",{className:"bg-amber-500/8 border border-amber-500/25 rounded-xl p-4 flex items-start gap-3",children:[t.jsx("span",{className:"text-amber-600 text-sm mt-0.5",children:"↻"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-amber-600 font-medium",children:"Template Update Available"}),t.jsxs("div",{className:"text-[11px] text-amber-600/70 mt-0.5",children:[K.length," file",K.length>1?"s":""," differ from the ",t.jsx("code",{className:"px-1 py-0.5 bg-amber-500/10 rounded text-amber-600",children:y.templateId})," template:"," ",K.map(V=>V.file).join(", ")]})]}),t.jsx("button",{onClick:()=>D(),disabled:N,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors shrink-0 disabled:opacity-50",children:N?"Syncing...":"Sync All"})]}),t.jsxs(Cn,{title:"Agent Configuration Files",action:y?.hasTemplate?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${y.isUpToDate?"bg-green-400":"bg-amber-400"}`}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["Template: ",t.jsx("span",{className:"text-fg-secondary",children:y.templateId}),y.isUpToDate?" (up to date)":" (updates available)"]})]}):t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Custom agent — no linked template"}),children:[t.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:n.map(V=>{const E=K.some(T=>T.file===V.name);return t.jsxs("button",{onClick:()=>S(V.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${d===V.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[V.name,E&&t.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},V.name)})}),d&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary",children:z[d]??d}),t.jsxs("div",{className:"flex gap-2 items-center",children:[G&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>Y(d),className:"px-2.5 py-1 text-[11px] text-amber-600 hover:text-amber-600 border border-amber-500/30 hover:border-amber-500/50 rounded-lg transition-colors",children:_?.file===d?"Hide Diff":"View Diff"}),t.jsx("button",{onClick:()=>D(d),disabled:N,className:"px-2.5 py-1 text-[11px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:N?"Syncing...":"Sync This File"})]}),x&&t.jsx("span",{className:"text-[10px] text-amber-600",children:"unsaved"}),t.jsx("button",{onClick:R,disabled:f||!x,className:`px-3 py-1 text-xs rounded-lg transition-colors ${x?"bg-brand-600 hover:bg-brand-500 text-white":"bg-surface-elevated text-fg-tertiary cursor-default"}`,children:f?"Saving...":"Save"})]})]}),_?.file===d&&t.jsxs("div",{className:"mb-3 border border-border-default rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"grid grid-cols-2 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-elevated/80",children:[t.jsx("div",{className:"px-3 py-2 border-r border-border-default",children:"Current (Agent)"}),t.jsxs("div",{className:"px-3 py-2",children:["Template (",y?.templateId,")"]})]}),t.jsxs("div",{className:"grid grid-cols-2 max-h-60 overflow-y-auto",children:[t.jsx("pre",{className:"px-3 py-2 text-[11px] font-mono text-red-500/70 bg-red-500/5 border-r border-border-default whitespace-pre-wrap break-words overflow-x-hidden",children:_.agent}),t.jsx("pre",{className:"px-3 py-2 text-[11px] font-mono text-green-600/70 bg-green-500/5 whitespace-pre-wrap break-words overflow-x-hidden",children:_.template})]})]}),t.jsx("textarea",{value:h,onChange:V=>{m(V.target.value),p(!0)},className:"w-full h-80 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none",spellCheck:!1}),d==="ROLE.md"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-2",children:"Changes to ROLE.md will update the agent's runtime system prompt immediately."})]}),n.length===0&&t.jsx(ei,{text:"No configuration files found for this role"})]})]})}const sA={Files:["file_read","file_write","file_edit","apply_patch"],Search:["grep_search","glob_find","list_directory"],Runtime:["shell_execute","background_exec","process"],Web:["web_search","web_fetch","web_extract"],Tasks:["task_create","task_list","task_update","task_get","task_assign","task_note","task_comment","task_submit_review","subtask_create","subtask_complete","subtask_list","task_check_duplicates","task_cleanup_duplicates","task_board_health"],Requirements:["requirement_propose","requirement_list","requirement_update_status","requirement_comment"],Projects:["list_projects","get_project","project_info"],Deliverables:["deliverable_create","deliverable_search","deliverable_list","deliverable_update"],Communication:["agent_send_message","agent_list_colleagues","agent_send_group_message","agent_create_group_chat","agent_list_group_chats","agent_broadcast_status","agent_delegate_task"],Memory:["memory_save","memory_search","memory_list","memory_update_longterm"],Planning:["todo_write","todo_read"],"Team (Manager)":["team_list","team_status","delegate_message","create_task"],Subagents:["spawn_subagent","spawn_subagents"],LLM:["llm_list_providers","llm_switch_model","llm_switch_default_provider","llm_add_provider","llm_edit_provider","llm_add_model"]};function aA(e){const n=new Map,s=new Set;for(const[d,c]of Object.entries(sA)){const h=e.filter(m=>c.some(f=>m.name.startsWith(f)));h.length>0&&(n.set(d,h),h.forEach(m=>s.add(m.name)))}const l=e.filter(d=>!s.has(d.name));for(const d of l){const c=d.name.indexOf("__");if(c>0){const m=`MCP: ${d.name.slice(0,c)}`;n.has(m)||n.set(m,[]),n.get(m).push(d),s.add(d.name)}}const o=e.filter(d=>!s.has(d.name));return o.length>0&&n.set("Other",o),[...n.entries()].map(([d,c])=>({category:d,tools:c}))}function lA({tools:e}){const n=aA(e);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[e.length," tools registered"]}),n.map(s=>t.jsx(Cn,{title:s.category,children:t.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.tools.map(l=>t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium font-mono",children:l.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:l.description})]})]},l.name))})},s.category)),e.length===0&&t.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:"No tools registered"})]})}function iA({agent:e}){const n=e.proficiency??{},[s,l]=v.useState(null),[o,d]=v.useState(null),[c,h]=v.useState(!1),m=e.availableSkills??[],f=new Map;for(const N of m){const C=N.category||"custom";f.has(C)||f.set(C,[]),f.get(C).push(N)}const g=async N=>{if(s===N){l(null),d(null);return}l(N),h(!0);try{const C=await fetch(`/api/skills/${encodeURIComponent(N)}`);if(C.ok){const _=await C.json();d(_.skill)}else d(null)}catch{d(null)}h(!1)},x={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",productivity:"bg-amber-500/15 text-amber-600",browser:"bg-blue-500/15 text-blue-600",custom:"bg-gray-500/15 text-fg-secondary",platform:"bg-purple-500/15 text-purple-500"},p=N=>{const C=n[N.name],_=C&&C.uses>0?Math.round(C.successes/C.uses*100):null,O=s===N.name;return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-lg border cursor-pointer transition-all ${O?"bg-brand-500/10 border-brand-500/40":"bg-surface-elevated/30 border-border-default/30 hover:border-gray-600/50"}`,onClick:()=>g(N.name),children:[t.jsx("span",{className:`text-sm transition-transform ${O?"rotate-90":""}`,children:"▶"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:N.name}),N.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-green-500/15 text-green-500",children:"always-on"}),N.builtIn&&!N.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-surface-overlay/40 text-fg-tertiary",children:"built-in"}),!N.builtIn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-brand-500/15 text-brand-400",children:"installed"})]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 truncate",children:N.description}),C&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[C.uses," uses · ",C.successes," successes",C.lastUsed&&` · last ${new Date(C.lastUsed).toLocaleDateString()}`]})]}),_!==null&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx("div",{className:"w-16 h-1.5 bg-surface-overlay rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${_>=80?"bg-green-400":_>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${_}%`}})}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[_,"%"]})]})]}),O&&t.jsx("div",{className:"ml-6 mt-1 mb-2 p-4 bg-surface-elevated/30 rounded-lg border border-border-default/20 space-y-3",children:c?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading skill details…"}):o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${x[o.category]??x.custom}`,children:o.category}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",o.version]}),o.author&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",o.author]}),o.requiredPermissions?.map(k=>t.jsx("span",{className:"px-1.5 py-0.5 bg-amber-500/10 text-amber-600 text-[10px] rounded",children:k},k))]}),o.description&&t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:o.description}),o.tags&&o.tags.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:o.tags.map(k=>t.jsxs("span",{className:"px-1.5 py-0.5 bg-surface-overlay/40 text-fg-tertiary text-[10px] rounded",children:["#",k]},k))}),(o.toolDetails??o.tools??[]).length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"text-[10px] text-fg-tertiary font-semibold uppercase tracking-wider mb-2",children:["Tools (",(o.toolDetails??o.tools??[]).length,")"]}),t.jsx("div",{className:"space-y-1.5",children:(o.toolDetails??o.tools??[]).map(k=>t.jsxs("div",{className:"px-3 py-2 bg-surface-secondary/50 rounded border border-border-default/20",children:[t.jsx("div",{className:"text-xs font-medium text-brand-500",children:k.name}),k.description&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:k.description})]},k.name))})]})]}):t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Skill details not available (skill may not be registered in the store)"})})]},N.name)},y=["development","productivity","browser","communication","devops","data","platform","custom"],w=[...f.entries()].sort((N,C)=>{const _=y.indexOf(N[0]),O=y.indexOf(C[0]);return(_===-1?999:_)-(O===-1?999:O)});return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[m.length," skills installed — descriptions auto-injected into agent context"]})}),w.map(([N,C])=>t.jsx(Cn,{title:t.jsxs("span",{className:"capitalize",children:[N," ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",C.length,")"]})]}),children:t.jsx("div",{className:"space-y-2",children:C.map(_=>p(_))})},N)),m.length===0&&t.jsx(ei,{text:"No skills installed"})]})}function oA({agentId:e}){const[n,s]=v.useState(null),[l,o]=v.useState(!0),[d,c]=v.useState("entries"),[h,m]=v.useState(!1),[f,g]=v.useState(""),[x,p]=v.useState(!1),[y,w]=v.useState(""),[N,C]=v.useState(!1),[_,O]=v.useState(null),[k,S]=v.useState(null),[R,D]=v.useState([]),[Y,z]=v.useState(!1),K=v.useCallback(()=>{o(!0),re.agents.getMemory(e).then(E=>{s(E),g(E.recentDailyLogs??""),w(E.longTermMemory??"")}).catch(()=>{}).finally(()=>o(!1))},[e]);v.useEffect(()=>{K()},[K]);const U=async()=>{C(!0),await re.agents.updateDailyMemory(e,f).catch(()=>{}),C(!1),m(!1),K()},G=async()=>{C(!0),await re.agents.updateLongTermMemory(e,"User-edited",y).catch(()=>{}),C(!1),p(!1),K()};if(l)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading memory..."});if(!n)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Failed to load memory data"});const V=[{key:"entries",label:`Recent (${n.entries.length})`},{key:"sessions",label:`Sessions (${n.sessions.length})`},{key:"daily",label:"Daily Logs"},{key:"longterm",label:"Long-term"}];return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex gap-2",children:V.map(E=>t.jsx("button",{onClick:()=>c(E.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${d===E.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:E.label},E.key))}),d==="entries"&&t.jsx(Cn,{title:"Recent Memory Entries",children:n.entries.length===0?t.jsx(ei,{text:"No memory entries"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.entries.map((E,T)=>{const L=_===T;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>O(L?null:T),className:"w-full flex gap-2 px-3 py-2 rounded-lg bg-surface-elevated/20 text-xs text-left hover:bg-surface-elevated/40 transition-colors cursor-pointer",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 ${E.type==="fact"?"bg-blue-500/15 text-blue-600":E.type==="task"?"bg-green-500/15 text-green-600":E.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:E.type}),t.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${L?"":"line-clamp-2"}`,children:E.content}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[E.importance!=null&&t.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${E.importance>=7?"bg-red-500/15 text-red-500":E.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",E.importance]}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date(E.timestamp).toLocaleTimeString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:L?"▲":"▼"})]})]}),L&&t.jsxs("div",{className:"mx-3 mt-1 mb-2 p-3 bg-surface-elevated/30 rounded-lg border border-border-default/20",children:[t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed break-words",children:E.content}),t.jsxs("div",{className:"flex gap-3 mt-2 pt-2 border-t border-border-default/30 text-[10px] text-fg-tertiary",children:[t.jsxs("span",{children:["Type: ",E.type]}),E.importance!=null&&t.jsxs("span",{children:["Importance: ",E.importance]}),t.jsx("span",{children:new Date(E.timestamp).toLocaleString()})]})]})]},T)})})}),d==="sessions"&&t.jsx(Cn,{title:"Chat Sessions",children:n.sessions.length===0?t.jsx(ei,{text:"No sessions"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.sessions.map(E=>{const T=k===E.id,L=async()=>{if(T){S(null),D([]);return}S(E.id),z(!0);try{const A=await re.agents.getMemorySession(e,E.id);D(A.messages)}catch{D([])}z(!1)};return t.jsxs("div",{children:[t.jsxs("button",{onClick:L,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg bg-surface-elevated/20 hover:bg-surface-elevated/40 transition-colors cursor-pointer text-left",children:[t.jsx("div",{className:"text-xs text-fg-secondary font-mono flex-1 truncate",children:E.id}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[E.messageCount," msgs"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(E.updatedAt).toLocaleDateString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:T?"▲":"▼"})]}),T&&t.jsx("div",{className:"mx-3 mt-1 mb-2 bg-surface-elevated/30 rounded-lg border border-border-default/20 max-h-96 overflow-y-auto",children:Y?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading messages..."}):R.length===0?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"No messages in this session"}):(()=>{const A=new Map;for(const P of R)P.role==="tool"&&P.toolCallId&&A.set(P.toolCallId,P.content);return t.jsx("div",{className:"divide-y divide-gray-700/30",children:R.filter(P=>P.role!=="tool").map((P,q)=>t.jsxs("div",{className:"px-3 py-2",children:[(P.role==="user"||P.role==="system")&&t.jsxs("div",{children:[t.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 ${P.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:P.role}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(tr,{content:P.content,className:"text-xs text-fg-secondary"})})]}),P.role==="assistant"&&t.jsxs("div",{className:"space-y-1",children:[P.content&&t.jsxs("div",{children:[t.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 bg-green-500/15 text-green-600",children:"assistant"}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(tr,{content:P.content,className:"text-xs text-fg-secondary"})})]}),P.toolCalls&&P.toolCalls.length>0&&t.jsx("div",{className:"space-y-0.5",children:P.toolCalls.map(W=>{let B;try{B=JSON.parse(W.arguments)}catch{}const F={tool:W.name,status:"done",args:B,result:A.get(W.id)};return t.jsx(kj,{entry:{type:"tool",info:F}},W.id)})})]})]},q))})})()})]},E.id)})})}),d==="daily"&&t.jsx(Cn,{title:"Daily Logs",action:h?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>m(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:U,disabled:N,className:"text-xs text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>m(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:h?t.jsx("textarea",{value:f,onChange:E=>g(E.target.value),className:"w-full h-64 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none"}):n.recentDailyLogs?t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed bg-surface-elevated/30 rounded-lg p-4 max-h-96 overflow-y-auto",children:n.recentDailyLogs}):t.jsx(ei,{text:"No daily logs"})}),d==="longterm"&&t.jsx(Cn,{title:"Long-term Memory",action:x?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>p(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:G,disabled:N,className:"text-xs text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>p(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:x?t.jsx("textarea",{value:y,onChange:E=>w(E.target.value),className:"w-full h-64 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none"}):n.longTermMemory?t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed bg-surface-elevated/30 rounded-lg p-4 max-h-96 overflow-y-auto",children:n.longTermMemory}):t.jsx(ei,{text:"No long-term memory stored"})})]})}function cA({agentId:e,initialData:n}){const[s,l]=v.useState(n??null),[o,d]=v.useState(!n),[c,h]=v.useState([]),[m,f]=v.useState(null),[g,x]=v.useState(!1),[p,y]=v.useState(null),w=v.useCallback(()=>{re.agents.getHeartbeat(e).then(l).catch(()=>{}),re.agents.getRecentActivities(e).then(O=>{h(O.activities.filter(k=>k.type==="heartbeat"))}).catch(()=>{})},[e]);v.useEffect(()=>{d(!0),w(),d(!1)},[w]),v.useEffect(()=>xn.on("agent:update",k=>{k.payload?.agentId===e&&w()}),[e,w]);const N=async()=>{x(!0),y(null);try{const O=await re.agents.triggerHeartbeat(e);y(O.message),setTimeout(()=>y(null),4e3),setTimeout(w,2e3)}catch(O){y(String(O).replace("Error: ",""))}x(!1)};if(o)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading heartbeat data..."});if(!s)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"No heartbeat data available"});const C=O=>O?O<1e3?`${O}ms`:O<6e4?`${(O/1e3).toFixed(1)}s`:`${(O/6e4).toFixed(1)}m`:null,_=O=>{if(!O)return null;const k=Date.now()-new Date(O).getTime();if(k<0){const S=Math.abs(k);return S<6e4?`in ${Math.ceil(S/1e3)}s`:S<36e5?`in ${Math.ceil(S/6e4)}m`:`in ${(S/36e5).toFixed(1)}h`}return k<6e4?`${Math.floor(k/1e3)}s ago`:k<36e5?`${Math.floor(k/6e4)}m ago`:`${(k/36e5).toFixed(1)}h ago`};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(Cn,{title:"Heartbeat Scheduler",action:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:w,className:"text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Refresh"}),t.jsx("button",{onClick:N,disabled:g||!s.running,className:"text-[10px] px-2.5 py-1 rounded-md bg-blue-600/20 text-blue-600 hover:bg-blue-600/30 border border-blue-500/30 transition-colors disabled:opacity-40",children:g?"Triggering...":"Trigger Now"})]}),children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Qn,{label:"Status",value:s.running?"Running":"Stopped",color:s.running?"green":"gray"}),t.jsx(Qn,{label:"Interval",value:C(s.intervalMs)??"—"}),t.jsx(Qn,{label:"Last Run",value:s.lastHeartbeat?_(s.lastHeartbeat)??"—":"Never"}),t.jsx(Qn,{label:"Next Run",value:s.nextRunAt?_(s.nextRunAt)??"—":s.running?"Pending":"—"})]}),p&&t.jsx("div",{className:"mt-3 text-[11px] text-blue-600 bg-blue-500/10 border border-blue-500/20 rounded-lg px-3 py-2",children:p})]}),s.lastSummary&&t.jsx(Cn,{title:"Last Heartbeat Summary",action:s.lastSummaryAt?t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(s.lastSummaryAt).toLocaleString()}):void 0,children:t.jsx("div",{className:"bg-surface-primary/50 rounded-lg px-4 py-3",children:t.jsx(tr,{content:s.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),c.length>0?t.jsx(Cn,{title:"Recent Runs",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[c.length," runs this session"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:[...c].reverse().map(O=>{const k=m===O.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>f(k?null:O.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-blue-400"}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:O.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:[O.logCount," actions"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(O.startedAt).toLocaleString()}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary shrink-0 transition-transform ${k?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 4.5l3 3 3-3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})]}),k&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(Dd,{agentId:e,activityId:O.id})})]},O.id)})})}):s.lastHeartbeat?null:t.jsx(Cn,{title:"Recent Runs",children:t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx("div",{className:"text-xl mb-2 opacity-40",children:"♡"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No heartbeat runs yet this session."}),t.jsx("p",{className:"text-[10px] text-fg-tertiary mt-1",children:s.running?`First heartbeat will trigger in ~${C(s.intervalMs-s.uptimeMs%s.intervalMs)??"soon"}.`:"Heartbeat scheduler is stopped."}),s.running&&t.jsx("button",{onClick:N,disabled:g,className:"mt-3 text-[10px] px-3 py-1.5 rounded-md bg-blue-600/15 text-blue-600 hover:bg-blue-600/25 border border-blue-500/25 transition-colors disabled:opacity-40",children:g?"Triggering...":"Run First Heartbeat Now"})]})})]})}function Tj({taskId:e,isLive:n}){const[s,l]=v.useState([]),[o,d]=v.useState(""),[c,h]=v.useState(!0),[m,f]=v.useState("compact");if(v.useEffect(()=>{h(!0),d(""),re.tasks.getLogs(e).then(p=>{l(p.logs),h(!1)}).catch(()=>h(!1))},[e]),v.useEffect(()=>{if(!n)return;const p=xn.on("task:log",w=>{const N=w.payload;if(N.taskId!==e)return;const C={id:N.id,taskId:N.taskId,agentId:N.agentId,seq:N.seq,type:N.logType,content:N.content,metadata:N.metadata,createdAt:N.createdAt};l(_=>C.id&&_.some(O=>O.id===C.id)?_:[..._,C]),C.type==="text"&&d("")}),y=xn.on("task:log:delta",w=>{const N=w.payload;N.taskId===e&&d(C=>C+N.text)});return()=>{p(),y()}},[e,n]),c)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0&&!o)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No execution logs yet."});const g=s.map(p=>om(p)),x=new Set(g.filter(p=>p.executionRound!=null).map(p=>p.executionRound)).size>1;return t.jsx("div",{className:"px-3 py-2",children:m==="compact"?t.jsx(ux,{entries:g,streamingText:o,isActive:n,onExpand:()=>f("full"),showRounds:x}):t.jsx(fx,{entries:g,streamingText:o,isActive:n,onCollapse:()=>f("compact"),showRounds:x})})}function Dd({agentId:e,activityId:n}){const[s,l]=v.useState([]),[o,d]=v.useState(!0),[c,h]=v.useState("compact");if(v.useEffect(()=>{d(!0),re.agents.getActivityLogs(e,n).then(f=>{l(f.logs),d(!1)}).catch(()=>d(!1))},[e,n]),o)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No activity logs available."});const m=s.map(f=>J2(f,n,e)).filter(f=>f!==null);return t.jsx("div",{className:"px-3 py-2",children:c==="compact"?t.jsx(ux,{entries:m,isActive:!1,onExpand:()=>h("full")}):t.jsx(fx,{entries:m,isActive:!1,onCollapse:()=>h("compact")})})}function Cn({title:e,action:n,children:s}){return t.jsxs("div",{className:"bg-surface-secondary/60 border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:e}),n]}),s]})}function Pn({label:e,mono:n,children:s}){return t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-xs text-fg-secondary ${n?"font-mono text-[10px]":""}`,children:s})]})}function Qn({label:e,value:n,color:s}){const l=s==="green"?"text-green-600":s==="indigo"?"text-brand-500":s==="red"?"text-red-500":"text-fg-secondary";return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-lg font-semibold ${l}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function ei({text:e}){return t.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:e})}function wy(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${n[s]}`}const Ny={0:"Critical",1:"High",2:"Normal",3:"Low",4:"Background"},ky={0:"text-red-400",1:"text-amber-400",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},dA={pick:"bg-brand-500/20 text-brand-300",continue:"bg-gray-500/20 text-gray-300",preempt:"bg-amber-500/20 text-amber-300",merge:"bg-blue-500/20 text-blue-300",defer:"bg-purple-500/20 text-purple-300",delegate:"bg-green-500/20 text-green-300",drop:"bg-red-500/20 text-red-300"},uA={idle:"bg-green-500/20 text-green-300",focused:"bg-brand-500/20 text-brand-300",deciding:"bg-amber-500/20 text-amber-300"},$h={system_event:"⚙",human_chat:"💬",task_assignment:"☑",task_comment:"💬",mention:"@",session_reply:"↩",task_status_update:"📋",a2a_message:"🔗",review_request:"👀",requirement_update:"📝",daily_report:"📊",heartbeat:"♡",memory_consolidation:"🧠"},fA=[{key:"all",label:"All"},{key:"interaction",label:"Interaction"},{key:"task",label:"Task"},{key:"notification",label:"Notification"},{key:"system",label:"System"}],hA={completed:"bg-green-500",processing:"bg-brand-400 animate-pulse",deferred:"bg-purple-400",merged:"bg-blue-400",queued:"bg-amber-400",dropped:"bg-red-500"};function mA({agentId:e}){const[n,s]=v.useState(null),[l,o]=v.useState(null),[d,c]=v.useState(!0),[h,m]=v.useState("all"),[f,g]=v.useState(null),[x,p]=v.useState(!0),y=50,w=v.useCallback(async(C=!0)=>{C&&c(!0);try{const _=h==="all"?void 0:h,[O,k]=await Promise.all([re.agents.getMindState(e),re.agents.getMailbox(e,{limit:y,category:_})]);s(O),o(k),p((k.history?.length??0)>=y)}catch{}c(!1)},[e,h]),N=v.useCallback(async()=>{if(!l)return;const C=h==="all"?void 0:h;try{const _=await re.agents.getMailbox(e,{limit:y,offset:l.history.length,category:C});o(O=>O?{...O,history:[...O.history,..._.history]}:_),p((_.history?.length??0)>=y)}catch{}},[e,l,h]);return v.useEffect(()=>{g(null),w()},[w]),v.useEffect(()=>{const C=xn.on("agent:mailbox",k=>{k.payload.agentId===e&&w(!1)}),_=xn.on("agent:decision",k=>{k.payload.agentId===e&&w(!1)}),O=xn.on("agent:attention",k=>{k.payload.agentId===e&&w(!1)});return()=>{C(),_(),O()}},[e,w]),d&&!n?t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:"Loading agent mind state..."}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsx("span",{className:`px-2.5 py-1 text-xs font-medium rounded-full ${uA[n?.attentionState??"idle"]??"bg-gray-500/20 text-gray-300"}`,children:(n?.attentionState??"idle").toUpperCase()}),n?.currentFocus?t.jsxs("span",{className:"text-sm text-fg-secondary",children:[$h[n.currentFocus.type]??"●"," ",t.jsx("span",{className:"text-fg-primary font-medium",children:n.currentFocus.label}),t.jsxs("span",{className:"text-fg-tertiary ml-2 text-xs",children:["since ",new Date(n.currentFocus.startedAt).toLocaleTimeString()]})]}):t.jsx("span",{className:"text-sm text-fg-tertiary",children:"Idle — waiting for new mail"}),t.jsx("button",{onClick:()=>w(),className:"ml-auto text-xs text-fg-tertiary hover:text-fg-secondary",children:"↻ Refresh"})]}),(n?.queuedItems?.length??0)>0&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("h4",{className:"text-xs font-medium text-amber-400 uppercase tracking-wider mb-1.5",children:["Queue (",n.queuedItems.length,")"]}),t.jsx("div",{className:"space-y-1",children:n.queuedItems.map((C,_)=>t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded bg-amber-500/5 border border-amber-500/20 text-sm",children:[t.jsx("span",{className:"text-fg-tertiary w-4 text-right text-xs",children:_+1}),t.jsx("span",{className:"text-sm",children:$h[C.sourceType]??"●"}),t.jsx("span",{className:`text-[10px] ${ky[C.priority]??"text-fg-tertiary"}`,children:Ny[C.priority]??`P${C.priority}`}),t.jsx("span",{className:"text-fg-secondary truncate flex-1 text-xs",children:C.summary}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(C.queuedAt).toLocaleTimeString()})]},C.id))})]})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:"Mailbox History"}),t.jsx("div",{className:"flex gap-1 ml-auto flex-wrap",children:fA.map(C=>t.jsx("button",{onClick:()=>m(C.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors ${h===C.key?"bg-brand-500/20 border-brand-500/40 text-brand-300":"bg-surface-2 border-border-subtle text-fg-secondary hover:bg-surface-3"}`,children:C.label},C.key))})]}),(!l?.history||l.history.length===0)&&!d&&t.jsx("div",{className:"text-center text-fg-tertiary text-sm py-8",children:"No mailbox history yet"}),t.jsx("div",{className:"space-y-1",children:l?.history?.map(C=>{const _=f===C.id,O=$h[C.sourceType]??"●",k=C.payload?.summary??C.id,S=C.payload?.content,R=C.metadata?.senderName,D=C.metadata?.senderRole;return t.jsxs("div",{className:"bg-surface-2 rounded-lg border border-border-subtle",children:[t.jsxs("button",{className:"w-full px-3 py-2.5 flex items-start gap-2 text-left hover:bg-surface-3/50 transition-colors rounded-lg",onClick:()=>g(_?null:C.id),children:[t.jsx("span",{className:"text-xs mt-0.5 text-fg-tertiary",children:_?"▾":"▸"}),t.jsx("span",{className:`w-2 h-2 mt-1.5 rounded-full shrink-0 ${hA[C.status]??"bg-gray-400"}`}),t.jsx("span",{className:"text-sm",children:O}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`text-xs font-medium text-fg-primary ${_?"":"truncate"}`,children:k}),t.jsx("span",{className:`text-[10px] shrink-0 ${ky[C.priority]??"text-fg-tertiary"}`,children:Ny[C.priority]??""})]}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2 flex-wrap",children:[t.jsx("span",{children:new Date(C.queuedAt).toLocaleString()}),C.completedAt&&t.jsxs("span",{children:["→ ",new Date(C.completedAt).toLocaleTimeString()]}),C.activity&&t.jsxs(t.Fragment,{children:[C.activity.totalTokens>0&&t.jsxs("span",{children:[vd(C.activity.totalTokens)," tokens"]}),C.activity.totalTools>0&&t.jsxs("span",{children:[C.activity.totalTools," tools"]})]})]})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-3 px-1.5 py-0.5 rounded shrink-0",children:C.sourceType})]}),_&&t.jsxs("div",{className:"border-t border-border-subtle px-3 py-3 space-y-3",children:[(S||R)&&t.jsxs("div",{className:"space-y-1.5",children:[R&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:["From: ",t.jsx("span",{className:"text-fg-secondary",children:R}),D&&t.jsxs("span",{className:"text-fg-tertiary",children:[" (",D,")"]})]}),S&&S!==k&&t.jsx("div",{className:"text-xs text-fg-secondary bg-surface-primary/50 rounded-md p-2.5 whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:S})]}),C.decisions&&C.decisions.length>0&&t.jsxs("div",{children:[t.jsx("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:"Decisions"}),t.jsx("div",{className:"space-y-1",children:C.decisions.map(Y=>t.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded shrink-0 ${dA[Y.decisionType]??"bg-gray-500/20 text-gray-300"}`,children:Y.decisionType}),t.jsx("span",{className:"text-fg-secondary flex-1",children:Y.reasoning}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:new Date(Y.createdAt).toLocaleTimeString()})]},Y.id))})]}),C.activity?t.jsxs("div",{children:[t.jsxs("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:["Activity — ",C.activity.label,t.jsx("span",{className:`ml-2 inline-block px-1 py-0 rounded text-[9px] ${C.activity.success?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:C.activity.success?"✓ Success":"✗ Failed"})]}),C.activity.type==="task"&&C.payload?.taskId?t.jsx(Tj,{taskId:C.payload.taskId,isLive:!C.activity.endedAt}):t.jsx(Dd,{agentId:e,activityId:C.activity.id})]}):C.status==="processing"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2 animate-pulse",children:"Processing..."}):C.status==="completed"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2",children:"No activity log recorded"}):null]})]},C.id)})}),x&&(l?.history?.length??0)>0&&t.jsx("div",{className:"text-center mt-3",children:t.jsx("button",{onClick:N,className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:"Load Earlier..."})})]})]})}const xA=[{key:"overview",label:"Overview",icon:"▦"},{key:"members",label:"Members",icon:"◉"},{key:"announcements",label:"Announcements",icon:"◈"},{key:"norms",label:"Norms",icon:"☰"},{key:"settings",label:"Settings",icon:"⚙"}],Sy={idle:"bg-green-400",working:"bg-brand-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function gA({teamId:e,onBack:n,inline:s}){const[l,o]=v.useState(null),[d,c]=v.useState("overview"),[h,m]=v.useState(""),[f,g]=v.useState(""),[x,p]=v.useState(!1),[y,w]=v.useState(!1),[N,C]=v.useState(""),[_,O]=v.useState(""),[k,S]=v.useState(!1),[R,D]=v.useState(!1),[Y,z]=v.useState(""),[K,U]=v.useState(""),[G,V]=v.useState(!1),[E,T]=v.useState([]),L=v.useRef(null),A=v.useCallback(async()=>{try{const M=(await re.teams.list()).teams.find(Z=>Z.id===e);M&&o(M);const H=await re.teams.status(e);T(H.agents)}catch{}},[e]),P=v.useCallback(async()=>{try{const I=await re.teams.getFile(e,"ANNOUNCEMENT.md");m(I.content)}catch{m("")}try{const I=await re.teams.getFile(e,"NORMS.md");g(I.content)}catch{g("")}},[e]);v.useEffect(()=>{c("overview"),A(),P()},[e,A,P]);const q=async(I,M)=>{S(!0);try{await re.teams.updateFile(e,I,M),I==="ANNOUNCEMENT.md"?(m(M),p(!1)):(g(M),w(!1))}catch{}S(!1)},W=async()=>{Y.trim()&&(await re.teams.update(e,{name:Y.trim()}),D(!1),A())},B=async()=>{await re.teams.update(e,{description:K}),V(!1),A()};if(!l)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading team..."});const F=l.members.find(I=>I.agentRole==="manager"),X=E.filter(I=>I.status!=="offline").length;return t.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[t.jsxs("div",{className:"px-5 py-3.5 border-b border-border-default bg-surface-secondary sticky top-0 z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-white flex items-center justify-center text-lg font-bold shrink-0",children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h2",{className:"text-base font-semibold",children:l.name}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:[l.members.length," members"]}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-green-500/15 text-green-600 rounded font-medium",children:[X," online"]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:l.description||"No description"})]}),t.jsxs("button",{onClick:async()=>{if(l)try{const{files:I}=await re.teams.getFilesMap(l.id),M=l.members.filter(Z=>Z.type==="agent"),H={type:"team",name:l.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||l.name,displayName:l.name,version:"1.0.0",description:l.description??"",author:"",category:"general",tags:[],team:{members:M.map(Z=>({name:Z.name,roleName:Z.role,role:Z.agentRole??"worker",count:1,skills:[]}))}};await Xn.publishViaProxy({itemType:"team",name:l.name,description:l.description??"",category:"general",config:H,files:I}),alert(`Published "${l.name}" to Markus Hub`)}catch(I){alert(`Failed to publish: ${I}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:n,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]}),t.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:xA.map(I=>t.jsxs("button",{onClick:()=>c(I.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${d===I.key?"bg-surface-primary text-fg-primary border border-border-default border-b-gray-950":"text-fg-tertiary hover:text-fg-secondary"}`,children:[I.icon," ",I.label]},I.key))})]}),t.jsxs("div",{className:"p-5",children:[d==="overview"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Manager"}),t.jsx("div",{className:"text-sm font-medium",children:F?.name??l.managerName??"None"})]}),t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team ID"}),t.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:l.id})]})]}),h.trim()&&t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Latest Announcement"}),t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[h.slice(0,500),h.length>500?"...":""]})]}),t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Members"}),t.jsx("div",{className:"space-y-2",children:l.members.map(I=>{const M=E.find(Z=>Z.id===I.id),H=Sy[M?.status??"offline"]??"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${H}`}),t.jsx("span",{className:"font-medium",children:I.name}),t.jsx("span",{className:"text-fg-tertiary",children:I.role}),I.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-amber-500/15 text-amber-600 rounded",children:"Manager"})]},I.id)})})]})]}),d==="members"&&t.jsxs("div",{className:"space-y-3",children:[l.members.map(I=>{const M=E.find(Z=>Z.id===I.id),H=Sy[M?.status??"offline"]??"bg-gray-500";return t.jsxs("div",{className:"p-3 bg-surface-secondary rounded-xl border border-border-default flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-surface-elevated flex items-center justify-center text-sm font-bold shrink-0",children:I.name.charAt(0)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:I.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${H}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:M?.status??"offline"}),I.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I.role," · ",I.type]})]})]},I.id)}),l.members.length===0&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]}),d==="announcements"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Announcements"}),!x&&t.jsx("button",{onClick:()=>{C(h),p(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),x?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:N,onChange:I=>C(I.target.value),className:"w-full h-64 bg-surface-secondary border border-border-default rounded-xl p-3 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500 font-mono",placeholder:"Write team announcements here (Markdown supported)..."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>q("ANNOUNCEMENT.md",N),disabled:k,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:k?"Saving...":"Save"}),t.jsx("button",{onClick:()=>p(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsx("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default min-h-[120px]",children:h.trim()?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:h}):t.jsx("div",{className:"text-sm text-fg-tertiary italic",children:"No announcements yet. Click Edit to add."})})]}),d==="norms"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Working Norms"}),!y&&t.jsx("button",{onClick:()=>{O(f),w(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),y?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:_,onChange:I=>O(I.target.value),className:"w-full h-64 bg-surface-secondary border border-border-default rounded-xl p-3 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500 font-mono",placeholder:"Define team norms and working agreements (Markdown supported)..."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>q("NORMS.md",_),disabled:k,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:k?"Saving...":"Save"}),t.jsx("button",{onClick:()=>w(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsx("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default min-h-[120px]",children:f.trim()?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:f}):t.jsx("div",{className:"text-sm text-fg-tertiary italic",children:"No norms defined yet. Click Edit to add."})})]}),d==="settings"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team Name"}),R?t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("input",{ref:L,value:Y,onChange:I=>z(I.target.value),onKeyDown:I=>I.key==="Enter"&&W(),className:"flex-1 bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary focus:outline-none focus:border-brand-500",autoFocus:!0}),t.jsx("button",{onClick:W,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),t.jsx("button",{onClick:()=>D(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm",children:l.name}),t.jsx("button",{onClick:()=>{z(l.name),D(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Description"}),G?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:K,onChange:I=>U(I.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500",rows:3,autoFocus:!0}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:B,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),t.jsx("button",{onClick:()=>V(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-fg-secondary",children:l.description||"No description"}),t.jsx("button",{onClick:()=>{U(l.description??""),V(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(pA,{teamId:e,teamName:l.name,onDeleted:n})]})]})]})}function pA({teamId:e,teamName:n,onDeleted:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(!1),[h,m]=v.useState(!1),[f,g]=v.useState(!1);return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-red-900/30 space-y-3",children:[t.jsx("div",{className:"text-sm font-medium text-red-500",children:"Danger Zone"}),l?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',n,'"? This removes the team record from the database.']}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:h,onChange:x=>m(x.target.checked),className:"rounded"}),"Also delete all members in this team"]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:d,onChange:x=>c(x.target.checked),className:"rounded"}),"Also delete disk files (workspace, memory, logs)"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:f,onClick:async()=>{g(!0);try{await re.teams.delete(e,h,{purgeFiles:d}),window.dispatchEvent(new CustomEvent("markus:data-changed")),s()}catch{g(!1)}},className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50",children:f?"Deleting...":"Confirm Delete"}),t.jsx("button",{onClick:()=>o(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors border border-border-default",children:"Cancel"})]})]}):t.jsx("button",{onClick:()=>o(!0),className:"px-4 py-1.5 text-xs bg-red-600/20 hover:bg-red-600/30 text-red-500 rounded-lg transition-colors border border-red-500/30",children:"Delete Team"})]})}function tu({side:e,defaultWidth:n,minWidth:s,maxWidth:l,collapsedWidth:o=0,storageKey:d}){const[c,h]=v.useState(()=>{try{const y=localStorage.getItem(`${d}_w`);if(y)return Math.max(s,Math.min(l,parseInt(y,10)))}catch{}return n}),[m,f]=v.useState(()=>{try{return localStorage.getItem(`${d}_c`)==="1"}catch{return!1}}),g=v.useRef(!1);v.useEffect(()=>{try{localStorage.setItem(`${d}_w`,String(c))}catch{}},[c,d]),v.useEffect(()=>{try{localStorage.setItem(`${d}_c`,m?"1":"0")}catch{}},[m,d]);const x=v.useCallback(y=>{y.preventDefault(),g.current=!0;const w=y.clientX,N=c,C=O=>{if(!g.current)return;const k=e==="left"?O.clientX-w:w-O.clientX;h(Math.max(s,Math.min(l,N+k)))},_=()=>{g.current=!1,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",_),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",C),document.addEventListener("mouseup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e,s,l]),p=v.useCallback(()=>f(y=>!y),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:p,setCollapsed:f,onResizeStart:x}}function Cy(e){const n={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:new Date(e.createdAt).toLocaleTimeString(),agentId:e.role!=="user"?e.agentId:void 0};return e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(n.segments=e.metadata.segments.map((s,l)=>s.type==="tool"?{type:"tool",key:`${s.tool}_${l}`,tool:s.tool,status:s.status,args:s.arguments,result:s.result,error:s.error,durationMs:s.durationMs}:{type:"text",content:s.content})),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(n.isError=!0),e.metadata?.isStopped&&(n.isStopped=!0),e.metadata?.images?.length&&(n.images=e.metadata.images),n}function fo(e){const n=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),s={id:e.id,sender:e.senderType==="human"?"user":"agent",text:e.text,time:new Date(e.createdAt).toLocaleTimeString(),agentName:e.senderType!=="human"?e.senderName:void 0,agentId:e.senderType!=="human"?e.senderId:void 0,isError:n};if(e.metadata&&e.senderType==="agent"){const l=[],o=e.metadata;if(o.thinking?.length&&l.push({type:"text",content:"",thinking:o.thinking.join(`
51
-
52
- `)}),o.toolCalls?.length)for(let d=0;d<o.toolCalls.length;d++){const c=o.toolCalls[d];l.push({type:"tool",key:`${c.tool}_${d}`,tool:c.tool,status:c.status==="error"?"error":"done",args:c.arguments,result:c.result,durationMs:c.durationMs})}l.length>0&&(l.push({type:"text",content:e.text}),s.segments=l)}return s}function Aj(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function bA({name:e,agentId:n,agents:s,onViewProfile:l}){const[o,d]=v.useState(!1),c=v.useRef(null),h=n?s.find(m=>m.id===n):s.find(m=>m.name===e);return v.useEffect(()=>{if(!o)return;const m=f=>{c.current&&!c.current.contains(f.target)&&d(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),h?t.jsxs("span",{ref:c,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>d(!o),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),o&&t.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600",children:Aj(h.name)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:h.name}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[h.role," · ",h.agentRole??"worker"]})]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${h.status==="working"?"bg-blue-400 animate-pulse":h.status==="error"?"bg-red-400":"bg-green-400"}`})]}),t.jsx("button",{onClick:()=>{d(!1),l?.(h.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:"View Profile →"})]})]}):t.jsx("span",{children:e})}function yA({agent:e,anchorRect:n,onClose:s,onViewProfile:l}){const o=v.useRef(null);v.useEffect(()=>{const h=m=>{o.current&&!o.current.contains(m.target)&&s()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]);const d=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",c=e.status==="idle"?"Online":e.status==="working"?"Working":e.status==="error"?"Error":e.status==="paused"?"Paused":"Offline";return t.jsxs("div",{ref:o,className:"fixed z-50 w-64 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:n.top+40,left:n.left},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-brand-500/15 flex items-center justify-center text-sm font-bold text-brand-600",children:Aj(e.name)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${d}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:c}),e.agentRole&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),t.jsx("button",{onClick:()=>{s(),l(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:"View Profile →"})]})}function Ey(e){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let s="";const l=n.match(/\{[\s\S]*\}/);if(l)try{const o=JSON.parse(l[0]);s=o.error?.message??o.message??""}catch{}if(!s){const o=n.lastIndexOf(": ");o>=0&&(s=n.slice(o+2).trim())}return n.includes("402")||/insufficient.?balance/i.test(n)?`⚠ AI service error: ${s||"Insufficient credits"}. Please top up the API balance or contact your administrator.`:n.includes("401")||/unauthorized|invalid.?api.?key/i.test(n)?`⚠ AI service authentication failed: ${s||"Invalid API key"}. Please check the configuration.`:n.includes("429")||/rate.?limit/i.test(n)?`⚠ Rate limit exceeded: ${s||"Too many requests"}. Please wait a moment and try again.`:n.includes("503")||/service.?unavailable/i.test(n)?`⚠ AI service unavailable: ${s||"Service temporarily down"}. Please try again later.`:`⚠ AI service error: ${s||n.slice(0,120)}`}function Ty({msg:e,onCopy:n,onRetry:s,onReply:l,isCopied:o}){const d=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),c=e.isStopped;return t.jsxs("div",{className:"flex items-center gap-0.5 mt-1",children:[t.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:"Copy",children:[o?t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),o?"Copied":"Copy"]}),c&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:"Re-ask",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Re-ask"]}),d&&!c&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:"Retry",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Retry"]}),l&&t.jsxs("button",{onClick:()=>l(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:"Reply",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"9 17 4 12 9 7"}),t.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),"Reply"]})]})}function vA(e,n){if(!e)return[];const s=[];let l=0;const o=new Date().toISOString(),d=n??"";for(const c of e)c.type==="tool"?(s.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:d,seq:l++,type:"tool_start",content:c.tool,metadata:{arguments:c.args},createdAt:o}),c.status!=="running"&&s.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:d,seq:l++,type:"tool_end",content:c.tool,metadata:{arguments:c.args,result:c.result,error:c.error,durationMs:c.durationMs,success:c.status!=="error"},createdAt:o})):c.content&&s.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:d,seq:l++,type:"text",content:c.content,createdAt:o});return s}function jA({msg:e,isStreaming:n,liveActivities:s,onViewModeChange:l}){const o=e.segments,d=e.isStopped,[c,h]=v.useState("compact"),m=v.useCallback(g=>{h(g),l?.(g)},[l]);if(o!==void 0){const g=o.some(O=>O.type==="tool"),x=vA(o,e.agentId),p=n?o.filter(O=>O.type==="text").map(O=>O.content).join("").slice(-200):void 0,y=o.filter(O=>O.type==="text"),w=n?null:y.map(O=>O.content).join(""),N=!n&&y.length>0?y[y.length-1].content:null,C=c==="compact"?N:w,_=[];if(c==="compact")for(const O of o){if(O.type!=="tool")continue;const k=bj(O.tool,O.result);if(k){_.push({key:`task-${k.taskId}`,kind:"task",info:k});continue}const S=yj(O.tool,O.result);S&&_.push({key:`req-${S.requirementId}`,kind:"req",info:S})}return t.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-hidden",children:[(g||n)&&(c==="compact"?t.jsx(ux,{entries:x,streamingText:p,isActive:n,onExpand:()=>m("full"),embedded:!0}):t.jsx(fx,{entries:x,streamingText:p,isActive:n,onCollapse:()=>m("compact"),embedded:!0})),c==="compact"&&_.map(O=>O.kind==="task"?t.jsx(wj,{info:O.info},O.key):t.jsx(Nj,{info:O.info},O.key)),c==="compact"&&C&&t.jsx(tr,{content:C}),d&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:"Stopped"})]})]})}const f=(e.activities?.length??0)>0;return t.jsxs(t.Fragment,{children:[(n||f)&&t.jsx(DT,{activities:n?s:e.activities??[],isActive:n,persistent:!n&&f}),e.text?t.jsx(tr,{content:e.text}):null,d&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:"Stopped"})]})]})}const Cm=new Set;function wA(){return window.location.hash}function NA(e){return Cm.add(e),()=>{Cm.delete(e)}}typeof window<"u"&&window.addEventListener("hashchange",()=>Cm.forEach(e=>e()));function Ay({initialAgentId:e,authUser:n}={}){const[s,l]=v.useState([]),[o,d]=v.useState([]),c=_s(),h=v.useSyncExternalStore(NA,wA),m=c&&(h.startsWith(`#${ge.TEAM}/`)||h.startsWith("#chat/")),f=v.useCallback(()=>{window.location.hash=`${ge.TEAM}/d`},[]);v.useEffect(()=>{if(!c)return;const J=()=>{p.current==="profile"&&x("chat")};return window.addEventListener("popstate",J),()=>window.removeEventListener("popstate",J)},[c]);const[g,x]=v.useState("chat"),p=v.useRef("chat");p.current=g;const y=tu({side:"left",defaultWidth:224,minWidth:160,maxWidth:360,storageKey:"markus_chat_sidebar"}),[w,N]=v.useState(null),[C,_]=v.useState(),O=v.useCallback(J=>{_(J),x("profile"),c&&history.pushState({mobileProfile:!0},"",window.location.hash)},[c]),k=v.useCallback((J,pe)=>{R("direct"),Y(J),O(pe?.tab),N(null)},[O]),[S,R]=v.useState(()=>e?"direct":localStorage.getItem("markus_chat_mode")??"direct"),[D,Y]=v.useState(()=>e??localStorage.getItem("markus_chat_agent")??""),[z,K]=v.useState(()=>localStorage.getItem("markus_chat_channel")??"#general"),[U,G]=v.useState(""),V=v.useRef(new Map),E=v.useRef(new Map),T=v.useRef(new Set),L=v.useRef(""),[A,P]=v.useState([]),[q,W]=v.useState(""),[B,F]=v.useState(null),[X,I]=v.useState(!1),[M,H]=v.useState([]),[Z,ee]=v.useState(!1),[ne,ae]=v.useState(!1),[he,Ne]=v.useState([]),Le=v.useRef(null),ye=v.useRef(null),je="__new_chat__",[Ae,$e]=v.useState([]),[Xe,tt]=v.useState(null),[et,_t]=v.useState(!1),[se,Te]=v.useState([]),nt=v.useRef(new Map),yt=v.useRef(new Map),Xt=v.useRef(null),we=v.useRef(null),De=v.useRef(null),Pe=v.useRef(null),[Ze,mt]=v.useState([]),[Kt,ln]=v.useState([]),[Ht,Lt]=v.useState([]),[At,St]=v.useState([]),[en,tn]=v.useState(null),[ve,Ve]=v.useState(!1),[Rt,Pt]=v.useState(""),[vt,sn]=v.useState(!1),[gn,rt]=v.useState(""),[Wt,Mn]=v.useState(0),Mt=S==="channel"?Ze.find(J=>J.channelKey===z)?.teamId:void 0,yn=v.useRef(null),Nn=v.useRef(null),ie=v.useRef(null),qe=v.useRef(void 0),ze=v.useRef(!1),We=v.useRef(!0);v.useEffect(()=>{if(!et)return;const J=pe=>{we.current&&!we.current.contains(pe.target)&&Xt.current&&!Xt.current.contains(pe.target)&&_t(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[et]);const lt=(J,pe)=>{if(!pe||J===pe)return`notes:${J}`;const[Ee,Me]=[J,pe].sort();return`dm:${Ee}:${Me}`},Ct=(J,pe,Ee,Me)=>J==="channel"?`ch:${Ee}`:J==="dm"?`dm:${Me??""}`:pe||"_direct",dt=v.useCallback((J,pe)=>{const Ee=pe(V.current.get(J)??[]);V.current.set(J,Ee),L.current===J&&P(Ee)},[]),zt=(J,pe)=>{const Ee=[...E.current.get(J)??[],pe];E.current.set(J,Ee),L.current===J&&H(Ee)};v.useEffect(()=>{localStorage.setItem("markus_chat_mode",S)},[S]),v.useEffect(()=>{localStorage.setItem("markus_chat_agent",D)},[D]),v.useEffect(()=>{localStorage.setItem("markus_chat_channel",z)},[z]);const pt=v.useCallback(()=>re.agents.list().then(J=>l(J.agents)).catch(()=>{}),[]),on=v.useCallback(()=>re.teams.list().then(J=>ln(J.teams)).catch(()=>{}),[]);v.useEffect(()=>{pt(),re.users.list().then(Ue=>d(Ue.users)).catch(()=>{}),re.tasks.list().then(Ue=>St(Ue.tasks)).catch(()=>{}),on(),re.externalAgents.list().then(Ue=>Lt(Ue.agents)).catch(()=>{}),fetch("/api/group-chats").then(Ue=>Ue.json()).then(Ue=>mt(Ue.chats)).catch(()=>{});const J=setInterval(pt,8e3),pe=setInterval(on,15e3),Ee=xn.on("agent:update",pt),Me=xn.on("*",on),Ce=xn.on("chat:group_created",()=>{fetch("/api/group-chats").then(Ue=>Ue.json()).then(Ue=>mt(Ue.chats)).catch(()=>{})}),Ge=()=>{pt(),on()};return window.addEventListener("markus:data-changed",Ge),()=>{clearInterval(J),clearInterval(pe),Ee(),Me(),Ce(),window.removeEventListener("markus:data-changed",Ge)}},[]),v.useEffect(()=>{const J=Me=>{const Ce=Me.detail;if(Ia(Ce.page)===ge.TEAM){if(Ce.params?.agentId){if(Ce.params.profileTab)k(Ce.params.agentId,{tab:Ce.params.profileTab});else if(R("direct"),Y(Ce.params.agentId),Ce.params.sessionId){const Ge=Ce.params.sessionId;setTimeout(async()=>{try{const{sessions:Ue}=await re.sessions.listByAgent(Ce.params.agentId,20),Nt=Ue.find(ut=>ut.id===Ge);Nt&&Vr(Nt)}catch{}},300)}}Ce.params?.selectAgent&&k(Ce.params.selectAgent),Ce.params?.openHire}},pe=localStorage.getItem("markus_nav_agentId");if(pe){localStorage.removeItem("markus_nav_agentId");const Me=localStorage.getItem("markus_nav_profileTab");Me?(localStorage.removeItem("markus_nav_profileTab"),k(pe,{tab:Me})):(R("direct"),Y(pe))}const Ee=localStorage.getItem("markus_nav_selectAgent");return Ee&&(localStorage.removeItem("markus_nav_selectAgent"),k(Ee)),window.addEventListener("markus:navigate",J),()=>window.removeEventListener("markus:navigate",J)},[]);const de=v.useRef(!1);v.useEffect(()=>{const J=Nn.current;if(!J)return;const pe=()=>J.scrollHeight-J.scrollTop-J.clientHeight<80,Ee=()=>{de.current=!0},Me=()=>{de.current&&pe()?(de.current=!1,We.current=!0):de.current&&(We.current=!1)};return J.addEventListener("wheel",Ee,{passive:!0}),J.addEventListener("touchmove",Ee,{passive:!0}),J.addEventListener("scroll",Me,{passive:!0}),()=>{J.removeEventListener("wheel",Ee),J.removeEventListener("touchmove",Ee),J.removeEventListener("scroll",Me)}},[]),v.useLayoutEffect(()=>{if(ze.current){ze.current=!1;return}We.current&&yn.current?.scrollIntoView({behavior:"instant"})},[A,M]);const Fe=v.useCallback(async J=>{const pe=`ch:${J}`;try{const Ee=await re.channels.getMessages(J,50),Me=Ee.messages.map(fo);V.current.set(pe,Me),L.current===pe&&(P(Me),ee(Ee.hasMore),De.current=Ee.messages[0]?new Date(Ee.messages[0].createdAt).toISOString():null)}catch{L.current===pe&&(P([]),ee(!1))}},[]),ht=v.useCallback(async(J,pe)=>{Pe.current=J;try{const Ee=await re.sessions.getMessages(J,50),Me=Ee.messages.map(Cy);V.current.set(pe,Me),L.current===pe&&Pe.current===J&&(P(Me),ee(Ee.hasMore),De.current=Ee.messages[0]?new Date(Ee.messages[0].createdAt).toISOString():null)}catch{L.current===pe&&Pe.current===J&&(P([]),ee(!1),De.current=null)}},[]),Tt=v.useCallback(async J=>{if(!J)return $e([]),[];try{const{sessions:pe}=await re.sessions.listByAgent(J,10);return $e(pe),pe}catch{return $e([]),[]}},[]),Rn=v.useCallback(async()=>{if(!(ne||!Z||!De.current)){ae(!0);try{const J=L.current;if(S==="channel"||S==="dm"){const pe=S==="dm"?lt(n?.id??"",U):z,Ee=await re.channels.getMessages(pe,50,De.current),Me=Ee.messages.map(fo);ze.current=!0,P(Ce=>{const Ge=[...Me,...Ce];return V.current.set(J,Ge),Ge}),ee(Ee.hasMore),Ee.messages[0]&&(De.current=new Date(Ee.messages[0].createdAt).toISOString())}else if(Xe){const pe=await re.sessions.getMessages(Xe,50,De.current),Ee=pe.messages.map(Cy);ze.current=!0,P(Me=>{const Ce=[...Ee,...Me];return V.current.set(J,Ce),Ce}),ee(pe.hasMore),pe.messages[0]&&(De.current=new Date(pe.messages[0].createdAt).toISOString())}}catch{}finally{ae(!1)}}},[ne,Z,S,z,Xe,n?.id,U]);v.useEffect(()=>{const J=Ct(S,D,z,U),pe=L.current;L.current=J,pe&&pe!==J&&(nt.current.set(pe,se),yt.current.set(pe,Xe));const Ee=V.current.get(J),Me=E.current.get(J)??[],Ce=T.current.has(J);H(Me),I(Ce),S==="direct"&&D&&Tt(D);const Ge=nt.current.get(J),Ue=yt.current.get(J);if(Ge&&Ge.length>0&&Te(Ge),_t(!1),Ee!==void 0)P(Ee),ee(!1),Ue!==void 0&&tt(Ue),(!Ge||Ge.length===0)&&Te([]);else if(P([]),ee(!1),De.current=null,S==="channel"||S==="dm"){const Nt=S==="dm"?lt(n?.id??"",U):z;Fe(Nt),(!Ge||Ge.length===0)&&Te([])}else S==="direct"&&D&&Tt(D).then(Nt=>{if(L.current===J)if(Nt.length>0){const ut=Ge&&Ge.length>0?Ge:Nt.slice(0,5),st=Ue!==void 0?Ue:ut[0].id,Et=st&&ut.some(Ut=>Ut.id===st)?st:ut[0].id;tt(Et),Te(ut),ht(Et,J)}else{tt(null),(!Ge||Ge.length===0)&&Te([]);const ut=(()=>{const st=(navigator.language||"").toLowerCase();return st.startsWith("zh")?"介绍一下你自己":st.startsWith("ja")?"自己紹介をしてください":st.startsWith("ko")?"자기소개를 해주세요":st.startsWith("fr")?"Présentez-vous":st.startsWith("de")?"Stell dich vor":st.startsWith("es")?"Preséntate":st.startsWith("pt")?"Apresente-se":st.startsWith("ru")?"Представьтесь":"Introduce yourself"})();setTimeout(()=>qe.current?.(ut),150)}})},[S,D,z,U]),v.useEffect(()=>S!=="channel"?void 0:xn.on("chat:message",pe=>{const Ee=pe.payload,Me=Ee.channel??"";if(!Me||Me!==z)return;const Ce=Ee.senderType??"agent",Ge=Ee.text??Ee.message??"",Ue=Ee.senderId??Ee.agentId??"",Nt=Ee.senderName??Ee.agentId??"Agent",ut=Ee.metadata,st={id:`ws_${Date.now()}_${Ue}`,sender:Ce==="human"?"user":"agent",text:Ge,time:new Date().toLocaleTimeString(),agentName:Ce==="agent"?Nt:void 0,agentId:Ce==="agent"?Ue:void 0};if(ut&&Ce==="agent"){const Ut=[];if(ut.thinking?.length&&Ut.push({type:"text",content:"",thinking:ut.thinking.join(`
53
-
54
- `)}),ut.toolCalls?.length)for(let jn=0;jn<ut.toolCalls.length;jn++){const $n=ut.toolCalls[jn];Ut.push({type:"tool",key:`${$n.tool}_${jn}`,tool:$n.tool,status:$n.status==="error"?"error":"done",args:$n.arguments,result:$n.result,durationMs:$n.durationMs})}Ut.length>0&&(Ut.push({type:"text",content:Ge}),st.segments=Ut)}const Et=Ct("channel",D,z,U);dt(Et,Ut=>[...Ut,st])}),[S,z,D,U,dt]),v.useEffect(()=>xn.on("chat:proactive_message",pe=>{const Ee=pe.payload,Me=Ee.agentId??"",Ce=Ee.agentName??"Agent",Ge=Ee.message??"",Ue=Ee.sessionId??"";if(!(!Me||!Ge)&&S==="direct"&&D===Me){const Nt={id:`proactive_${Date.now()}`,sender:"agent",text:Ge,time:new Date().toLocaleTimeString(),agentName:Ce,agentId:Me},ut=Ct("direct",Me,z,U);dt(ut,st=>[...st,Nt]),Ue&&Xe!==Ue&&tt(Ue)}}),[S,D,z,U,Xe,dt]),At.find(J=>J.id===en),v.useEffect(()=>{tn(null)},[D]);const gr=J=>UT(J),pr=()=>{ie.current?.abort(),ie.current=null;const J=L.current;T.current.delete(J),E.current.delete(J),I(!1),H([])},nr=async J=>{const pe=(J??q).trim();if(!pe&&he.length===0||S==="direct"&&!D)return;if(We.current=!0,de.current=!1,X){ie.current?.abort(),ie.current=null;const Ue=L.current;T.current.delete(Ue),E.current.delete(Ue),dt(Ue,Nt=>{const ut=[...Nt];for(let st=ut.length-1;st>=0;st--)if(ut[st].sender==="agent"&&!ut[st].isStopped&&!ut[st].isError){const Et=ut[st],Ut=(Et.segments??[]).map(jn=>jn.type==="tool"&&jn.status==="running"?{...jn,status:"stopped"}:jn);ut[st]={...Et,isStopped:!0,segments:Ut};break}return ut}),I(!1),H([]),await new Promise(Nt=>setTimeout(Nt,50))}const Ee=he.length>0?he.map(Ue=>Ue.dataUrl):void 0,Me=Ct(S,D,z,U),Ce=B;J||(W(""),ye.current&&(ye.current.style.height="auto")),Ne([]),sn(!1),F(null);const Ge=S==="dm";if(T.current.add(Me),E.current.set(Me,[]),L.current===Me&&!Ge&&(I(!0),H([])),S==="dm"){const Ue=lt(n?.id??"",U),Nt=`opt_${Date.now()}`,ut={id:Nt,sender:"user",text:pe,time:new Date().toLocaleTimeString()};Ce&&(ut.replyToId=Ce.id,ut.replyToSender=Ce.sender,ut.replyToText=Ce.text),dt(Me,st=>[...st,ut]);try{const st=await re.channels.sendMessage(Ue,{text:pe,senderName:n?.name??"You",senderId:n?.id,mentions:[],orgId:"default",humanOnly:!0});dt(Me,Et=>{const Ut=Et.filter($n=>$n.id!==Nt),jn=[];return st.userMessage&&jn.push(fo(st.userMessage)),jn.length>0?[...Ut,...jn]:Et})}catch(st){dt(Me,Et=>[...Et,{id:`err_${Date.now()}`,sender:"agent",text:`Error: ${String(st)}`,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}T.current.delete(Me),L.current===Me&&I(!1)}else if(S==="channel"){const Ue=`opt_${Date.now()}`,Nt={id:Ue,sender:"user",text:pe,time:new Date().toLocaleTimeString()};Ce&&(Nt.replyToId=Ce.id,Nt.replyToSender=Ce.sender,Nt.replyToText=Ce.text),dt(Me,ut=>[...ut,Nt]);try{const ut=gr(pe),st=ut.length>0?s.find(Ut=>Ut.name.toLowerCase()===ut[0].toLowerCase()):null,Et=await re.channels.sendMessage(z,{text:pe,senderName:n?.name??"You",mentions:ut,senderId:n?.id,targetAgentId:st?.id,orgId:"default"});dt(Me,Ut=>{const jn=Ut.filter(jt=>jt.id!==Ue),$n=[];return Et.userMessage&&$n.push(fo(Et.userMessage)),Et.agentMessage&&$n.push(fo(Et.agentMessage)),$n.length>0?[...jn,...$n]:Ut})}catch(ut){const st=Ey(ut)||`Error: ${String(ut)}`;dt(Me,Et=>[...Et,{id:`err_${Date.now()}`,sender:"agent",text:st,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}T.current.delete(Me),L.current===Me&&I(!1)}else{const Ue=`a_${Date.now()}`,Nt={id:`u_${Date.now()}`,sender:"user",text:pe,time:new Date().toLocaleTimeString()};Ee?.length&&(Nt.images=Ee),Ce&&(Nt.replyToId=Ce.id,Nt.replyToSender=Ce.sender,Nt.replyToText=Ce.text),dt(Me,jt=>[...jt,Nt,{id:Ue,sender:"agent",text:"",time:new Date().toLocaleTimeString(),segments:[]}]);const ut=jt=>{dt(Me,it=>{const bt=[...it],Qe=bt.findIndex(Wo=>Wo.id===Ue);if(Qe<0)return it;const Ke=bt[Qe].segments??[],ot=Ke[Ke.length-1];let ct,On=jt;const ar=jt.match(/<think>([\s\S]*?)<\/think>/);ar&&(ct=(ot?.type==="text"?ot.thinking??"":"")+ar[1],On=jt.replace(/<think>[\s\S]*?<\/think>/,""));const sa=ot?.type==="text"?[...Ke.slice(0,-1),{type:"text",content:ot.content+On,thinking:ct??ot.thinking}]:[...Ke,{type:"text",content:On,thinking:ct}];return bt[Qe]={...bt[Qe],text:bt[Qe].text+On,segments:sa},bt})},st=jt=>{(jt.phase==="start"||jt.phase==="end")&&zt(Me,{...jt,phase:jt.phase,ts:Date.now()}),jt.phase==="start"?dt(Me,it=>{const bt=[...it],Qe=bt.findIndex(ct=>ct.id===Ue);if(Qe<0)return it;const Ke=[...bt[Qe].segments??[]];let ot=!1;if(jt.arguments)for(let ct=Ke.length-1;ct>=0;ct--){const On=Ke[ct];if(On.type==="tool"&&On.tool===jt.tool&&On.status==="running"){Ke[ct]={...On,args:jt.arguments},ot=!0;break}}if(!ot){const ct=`${jt.tool}_${Date.now()}`;Ke.push({type:"tool",key:ct,tool:jt.tool,status:"running",args:jt.arguments})}return bt[Qe]={...bt[Qe],segments:Ke},bt}):jt.phase==="output"?dt(Me,it=>{const bt=[...it],Qe=bt.findIndex(ot=>ot.id===Ue);if(Qe<0)return it;const Ke=[...bt[Qe].segments??[]];for(let ot=Ke.length-1;ot>=0;ot--){const ct=Ke[ot];if(ct.type==="tool"&&ct.tool===jt.tool&&ct.status==="running"){Ke[ot]={...ct,liveOutput:(ct.liveOutput??"")+(jt.output??"")};break}}return bt[Qe]={...bt[Qe],segments:Ke},bt}):jt.phase==="subagent_progress"&&jt.subagentEvent?dt(Me,it=>{const bt=[...it],Qe=bt.findIndex(ot=>ot.id===Ue);if(Qe<0)return it;const Ke=[...bt[Qe].segments??[]];for(let ot=Ke.length-1;ot>=0;ot--){const ct=Ke[ot];if(ct.type==="tool"&&(ct.tool==="spawn_subagent"||ct.tool==="spawn_subagents")&&ct.status==="running"){Ke[ot]={...ct,subagentLogs:[...ct.subagentLogs??[],jt.subagentEvent]};break}}return bt[Qe]={...bt[Qe],segments:Ke},bt}):dt(Me,it=>{const bt=[...it],Qe=bt.findIndex(ot=>ot.id===Ue);if(Qe<0)return it;const Ke=[...bt[Qe].segments??[]];for(let ot=Ke.length-1;ot>=0;ot--){const ct=Ke[ot];if(ct.type==="tool"&&ct.tool===jt.tool&&ct.status==="running"){Ke[ot]={...ct,status:jt.success===!1?"error":"done",args:jt.arguments,result:jt.result,error:jt.error,durationMs:jt.durationMs,liveOutput:void 0};break}}return bt[Qe]={...bt[Qe],segments:Ke},bt})},Et=new AbortController;ie.current=Et;try{const jt=Xe===je?null:Xe,it=await re.agents.messageStream(D,pe,ut,st,Et.signal,Ee,jt);L.current===Me&&(it.sessionId&&(tt(it.sessionId),Te(bt=>bt.map(Qe=>Qe.id===je?{...Qe,id:it.sessionId}:Qe))),Tt(D).then(bt=>{if(L.current===Me&&($e(bt),it.sessionId)){const Qe=bt.find(Ke=>Ke.id===it.sessionId);Qe&&Te(Ke=>Ke.some(ct=>ct.id===Qe.id)?Ke.map(ct=>ct.id===Qe.id?Qe:ct):[Qe,...Ke.filter(ct=>ct.id!==je)])}}))}catch(jt){const it=jt?.sessionId;it&&S==="direct"&&L.current===Me&&(tt(it),Te(Qe=>Qe.map(Ke=>Ke.id===je?{...Ke,id:it}:Ke)),Tt(D).then(Qe=>{if(L.current!==Me)return;$e(Qe);const Ke=Qe.find(ot=>ot.id===it);Ke&&Te(ot=>ot.some(On=>On.id===Ke.id)?ot.map(On=>On.id===Ke.id?Ke:On):[Ke,...ot])}));const bt=Ey(jt);bt?dt(Me,Qe=>{const Ke=[...Qe],ot=Ke.findIndex(ct=>ct.id===Ue);if(ot>=0){const ct=Ke[ot].segments??[];Ke[ot]={...Ke[ot],text:bt,isError:!0,segments:[...ct,{type:"text",content:bt}]}}return Ke}):dt(Me,Qe=>{const Ke=[...Qe],ot=Ke.findIndex(ct=>ct.id===Ue);if(ot>=0){const ct=Ke[ot];if(!(ct.text||ct.segments&&ct.segments.length>0&&ct.segments.some(ar=>ar.type==="text"&&ar.content||ar.type==="tool")))return Qe.filter(ar=>ar.id!==Ue);Ke[ot]={...ct,isStopped:!0}}return Ke})}dt(Me,jt=>{const it=[...jt],bt=it.findIndex(Qe=>Qe.id===Ue);if(bt>=0){const Qe=(it[bt].segments??[]).map(Ke=>Ke.type==="tool"&&Ke.status==="running"?{...Ke,status:"stopped"}:Ke);it[bt]={...it[bt],segments:Qe}}return it}),Et.signal.aborted&&dt(Me,jt=>{const it=[...jt],bt=it.findIndex(Qe=>Qe.id===Ue);if(bt>=0){const Qe=it[bt];if(!(Qe.text||Qe.segments&&Qe.segments.length>0&&Qe.segments.some(ot=>ot.type==="text"&&ot.content||ot.type==="tool")))return jt.filter(ot=>ot.id!==Ue);it[bt]={...Qe,isStopped:!0}}return it});const jn=(V.current.get(Me)??[]).find(jt=>jt.id===Ue),$n=Xe&&Xe!==je?Xe:null;jn&&!jn.text&&S==="direct"&&$n&&!Et.signal.aborted&&(async(it,bt)=>{for(let Qe=0;Qe<it;Qe++){await new Promise(Ke=>setTimeout(Ke,bt));try{const ot=(await re.sessions.getMessages($n,2)).messages.find(ct=>ct.role==="assistant");if(ot?.content){dt(Me,ct=>{const On=[...ct],ar=On.findIndex(sa=>sa.id===Ue);return ar>=0&&(On[ar]={...On[ar],text:ot.content,segments:[{type:"text",content:ot.content}]}),On});return}}catch{}}})(5,3e3)}ie.current=null,T.current.delete(Me),E.current.delete(Me),L.current===Me&&(I(!1),H([]))};qe.current=nr;const[dr,ur]=v.useState(null),[vn,gs]=v.useState(new Set),qr=v.useCallback(J=>{const pe=J.segments?J.segments.filter(Ee=>Ee.type==="text").map(Ee=>Ee.content).join(`
55
- `):J.text;navigator.clipboard.writeText(pe),ur(J.id),setTimeout(()=>ur(Ee=>Ee===J.id?null:Ee),2e3)},[]),fr=v.useCallback(J=>{const pe=L.current,Ee=V.current.get(pe)??A,Me=Ee.findIndex(Ue=>Ue.id===J.id);if(Me<0)return;const Ce=Me>0&&Ee[Me-1]?.sender==="user"?Ee[Me-1]:null,Ge=Ce?.text??"";Ge&&(dt(pe,Ue=>Ue.filter(Nt=>Nt.id!==J.id&&(Ce?Nt.id!==Ce.id:!0))),nr(Ge))},[A,dt]),rr=v.useCallback(J=>{F({id:J.id,sender:J.sender==="user"?n?.name??"You":J.agentName??"Agent",text:J.text.slice(0,120)}),ye.current?.focus()},[n?.name]),Vr=async J=>{tt(J.id),_t(!1),ee(!1),De.current=null;const pe=L.current;V.current.delete(pe),P([]),Te(Ee=>Ee.some(Me=>Me.id===J.id)?Ee:[...Ee,J]),await ht(J.id,pe)},oe=J=>{if(Te(pe=>pe.filter(Ee=>Ee.id!==J)),Xe===J){const pe=se.filter(Ee=>Ee.id!==J);pe.length>0?Vr(pe[pe.length-1]):ke()}},ke=()=>{tt(je);const J=L.current;V.current.delete(J),P([]),ee(!1),De.current=null,_t(!1),Te(pe=>{const Ee=pe.filter(Me=>Me.id!==je);return[{id:je,agentId:D??"",userId:null,title:"New Chat",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...Ee]})},Be=J=>{if(W(J),S!=="channel"){sn(!1);return}const pe=J.lastIndexOf("@");if(pe>=0&&(pe===0||J[pe-1]===" ")){const Me=J.slice(pe+1).toLowerCase();if(s.some(Ge=>Ge.name.toLowerCase().includes(Me))){sn(!0),rt(Me),Mn(0);return}}sn(!1)},Dt=J=>{const pe=q.lastIndexOf("@"),Ee=J.includes(" ")?`@[${J}]`:`@${J}`;W(q.slice(0,pe)+Ee+" "),sn(!1),Mn(0)},Jn=4*1024*1024,Dn=5,En=v.useCallback(J=>{const pe=Array.from(J).filter(Ee=>Ee.type.startsWith("image/"));if(pe.length!==0)for(const Ee of pe){if(Ee.size>Jn)continue;const Me=new FileReader;Me.onload=()=>{const Ce=Me.result;Ne(Ge=>Ge.length>=Dn||Ge.some(Ue=>Ue.dataUrl===Ce)?Ge:[...Ge,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:Ce,name:Ee.name}])},Me.readAsDataURL(Ee)}},[]),ss=v.useCallback(J=>{Ne(pe=>pe.filter(Ee=>Ee.id!==J))},[]),Os=v.useCallback(J=>{const pe=J.clipboardData?.files;if(pe&&pe.length>0){const Ee=Array.from(pe).filter(Me=>Me.type.startsWith("image/"));Ee.length>0&&(J.preventDefault(),En(Ee))}},[En]),as=v.useCallback(J=>{J.preventDefault();const pe=J.dataTransfer?.files;pe&&pe.length>0&&En(Array.from(pe).filter(Ee=>Ee.type.startsWith("image/")))},[En]),Fr=v.useCallback(J=>{J.preventDefault()},[]),Un=s.find(J=>J.id===D),Rs=n?.name??"You",Ln=A[A.length-1],Yr=X&&Ln?.sender==="agent",br=s.filter(J=>J.name.toLowerCase().includes(gn)),Mr=o.find(J=>J.id===U),sr=U===n?.id||!U,Gr=Ze.find(J=>J.channelKey===z),te=S==="channel"?Gr?.name??z:S==="direct"?Un?.name??"Select Agent":S==="dm"?sr?"My Notes":Mr?.name??"Direct Message":"Chat",Ie=S==="channel"?Gr?`Message ${Gr.name}…`:`Message ${z}… (use @name to mention)`:S==="dm"?sr?"Write a note to yourself…":`Message ${Mr?.name??""}…`:D?"Type a message…":"Select an agent to start chatting",Ye=c&&m;return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx(QT,{authUser:n,agents:s,teams:Kt,humans:o,tasks:At,externalAgents:Ht,groupChats:Ze,chatMode:S,selectedAgent:D,activeChannel:z,activeDmUserId:U,onSelectAgent:J=>{R("direct"),Y(J),x("chat"),c&&f()},onSelectChannel:J=>{R("channel"),K(J),x("chat"),c&&f()},onSelectDm:J=>{R("dm"),G(J),x("chat"),c&&f()},onRefreshTeams:on,onRefreshAgents:pt,onViewProfile:k,width:c?void 0:y.width,onResizeStart:c?void 0:y.onResizeStart,hidden:c&&m}),(!c||Ye)&&t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[t.jsxs("div",{className:"border-b border-border-default bg-surface-secondary shrink-0 relative",children:[c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center px-3 h-11 gap-2",children:[t.jsx("button",{onClick:()=>{window.location.hash=ge.TEAM},className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"font-semibold text-sm truncate min-w-0 flex-1",children:te}),S==="direct"&&Un&&t.jsx(_y,{agent:Un,tasks:At,onViewProfile:k})]}),t.jsxs("div",{className:"flex items-center px-3 h-9 gap-1 border-t border-border-default/40",children:[t.jsx("button",{onClick:()=>{g==="profile"?history.back():x("chat")},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${g==="chat"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>{g!=="profile"&&O()},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${g==="profile"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:S==="channel"?"Team":"Profile"}),t.jsx("div",{className:"flex-1"}),S==="direct"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:ke,className:"text-[11px] text-brand-500 px-2 py-1 rounded-md bg-brand-500/10 font-medium shrink-0",children:"+ New"}),t.jsx("button",{ref:Xt,onClick:()=>_t(!et),className:`p-1 rounded-md transition-colors shrink-0 ${et?"bg-surface-overlay text-fg-primary":"text-fg-tertiary"}`,children:t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})]})]}):t.jsxs("div",{className:"flex items-center px-6 h-14 gap-3",children:[t.jsx("span",{className:"font-semibold text-sm truncate",children:te}),S==="direct"&&Un&&t.jsx(_y,{agent:Un,tasks:At,onViewProfile:k}),(S==="channel"||S==="dm")&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[A.length," messages"]}),S==="dm"&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-1",children:sr?"· Private notepad":`· Direct message with ${Mr?.name??""}`}),(S==="direct"&&D||S==="channel"&&Mt)&&t.jsxs("div",{className:"flex items-center gap-0.5 ml-4 -mb-px",children:[t.jsx("button",{onClick:()=>x("chat"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${g==="chat"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>x("profile"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${g==="profile"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:S==="channel"?"Team":"Profile"})]}),t.jsx("div",{className:"ml-auto flex items-center gap-2",children:S==="direct"&&Un&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("button",{onClick:ke,className:"text-xs text-brand-500 hover:text-brand-500 px-2.5 py-1 rounded-md hover:bg-brand-500/10 border border-brand-500/20 transition-colors flex items-center gap-1",children:"+ New Chat"}),t.jsx("button",{ref:Xt,onClick:()=>_t(!et),className:`p-1.5 rounded-md transition-colors ${et?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:"History",children:t.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})})]}),S==="direct"&&D&&g==="chat"&&se.length>0&&t.jsx("div",{className:"flex items-center gap-0 px-3 overflow-x-auto scrollbar-hide border-t border-border-default/50",children:se.map(J=>t.jsxs("div",{className:`group flex items-center gap-1.5 px-3 py-1.5 text-xs cursor-pointer border-b-2 transition-colors shrink-0 max-w-[180px] ${J.id===Xe?"border-brand-500 text-brand-500 bg-brand-500/5":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,onClick:()=>{if(J.id===je){tt(je);const pe=L.current;V.current.delete(pe),P([])}else Vr(J)},children:[t.jsx("span",{className:"truncate",children:J.id===je?"New Chat":J.title||"Conversation"}),t.jsx("button",{onClick:pe=>{pe.stopPropagation(),oe(J.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},J.id))}),S==="direct"&&D&&et&&t.jsxs("div",{ref:we,className:"absolute right-4 top-full mt-1 w-72 max-h-[420px] bg-surface-secondary border border-border-default rounded-xl shadow-2xl shadow-black/40 z-50 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 border-b border-border-default flex items-center justify-between",children:[t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:"History"}),t.jsx("button",{onClick:()=>_t(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[Ae.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No conversations yet"}),(()=>{const J=new Date,pe=new Date(J.getFullYear(),J.getMonth(),J.getDate()).getTime(),Ee=pe-864e5,Me=pe-7*864e5,Ce=[],Ge=[],Ue=[],Nt=[],ut=[];for(const st of Ae){const Et=new Date(st.lastMessageAt).getTime();Et>=pe?Ge.push(st):Et>=Ee?Ue.push(st):Et>=Me?Nt.push(st):ut.push(st)}return Ge.length>0&&Ce.push({label:"Today",items:Ge}),Ue.length>0&&Ce.push({label:"Yesterday",items:Ue}),Nt.length>0&&Ce.push({label:"Previous 7 days",items:Nt}),ut.length>0&&Ce.push({label:"Older",items:ut}),Ce.map(st=>t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider px-3 py-1.5",children:st.label}),st.items.map(Et=>t.jsxs("button",{onClick:()=>{Vr(Et)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${Et.id===Xe?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:"truncate font-medium",children:Et.title||"Conversation"}),t.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(Et.lastMessageAt).toLocaleString()})]},Et.id))]},st.label))})()]})]})]}),g==="profile"&&S==="direct"&&D&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(tA,{agentId:D,onBack:()=>x("chat"),inline:!0,defaultTab:C})}),g==="profile"&&S==="channel"&&Mt&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(gA,{teamId:Mt,onBack:()=>x("chat"),inline:!0})}),t.jsxs("div",{ref:Nn,className:`flex-1 overflow-y-auto space-y-3 ${c?"p-2.5":"p-5"} ${g!=="chat"?"hidden":""}`,children:[Z&&t.jsx("div",{className:"flex justify-center py-2",children:t.jsx("button",{onClick:()=>{Rn()},disabled:ne,className:"text-xs text-brand-500 hover:text-brand-500 disabled:opacity-50 px-4 py-1.5 border border-brand-500/30 rounded-lg",children:ne?"Loading…":"↑ Load earlier messages"})}),A.length===0&&!X&&t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-fg-tertiary text-sm space-y-2",children:[t.jsx("div",{className:"opacity-20",children:t.jsx("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:S==="channel"?t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H6l-4 4V6c0-1.1.9-2 2-2z"}),t.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),t.jsx("line",{x1:"8",y1:"14",x2:"13",y2:"14"})]}):t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),S==="channel"&&t.jsxs("div",{children:["No messages in ",Gr?.name??z," yet."]}),S==="direct"&&!D&&t.jsx("div",{children:"Select an agent from the sidebar to start."}),S==="direct"&&D&&t.jsxs("div",{children:["Start a new conversation with ",Un?.name,"."]})]}),S==="channel"?A.map(J=>t.jsxs("div",{id:`msg-${J.id}`,className:"group/msg flex gap-3 transition-colors rounded-lg",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 cursor-pointer ${J.sender==="user"?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-600 hover:ring-1 hover:ring-brand-500/40"}`,onClick:pe=>{if(J.sender==="agent"&&J.agentId){const Ee=pe.currentTarget.getBoundingClientRect();N({agentId:J.agentId,top:Ee.top,left:Ee.right+8})}},children:J.sender==="user"?Rs?.[0]??"Y":J.agentName?.[0]??"A"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:J.sender==="user"?Rs??"You":J.agentName??"Agent"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:J.time})]}),J.replyToId&&J.replyToSender&&t.jsxs("button",{onClick:()=>{const pe=document.getElementById(`msg-${J.replyToId}`);pe&&(pe.scrollIntoView({behavior:"smooth",block:"center"}),pe.classList.add("bg-brand-500/10"),setTimeout(()=>pe.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mt-0.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:J.replyToSender}),t.jsx("span",{className:"truncate max-w-[250px]",children:J.replyToText??"..."})]}),t.jsx("div",{className:J.isError||J.sender==="agent"&&J.text.startsWith("⚠")?"mt-0.5 px-3 py-2 rounded-lg border-b-2 border-red-500/60":"mt-0.5",children:J.sender==="agent"?t.jsx(tr,{content:J.text,className:"text-sm text-fg-secondary"}):t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[J.images&&J.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:J.images.map((pe,Ee)=>t.jsx("img",{src:pe,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(pe,"_blank")},Ee))}),vy(J.text,s)]})}),t.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity",children:t.jsx(Ty,{msg:J,onCopy:qr,onRetry:fr,onReply:rr,isCopied:dr===J.id})})]})]},J.id)):A.map((J,pe)=>{const Me=Yr&&pe===A.length-1&&X,Ce=!Me||J.isStopped;return t.jsx("div",{id:`msg-${J.id}`,className:`group/msg flex transition-colors rounded-lg ${J.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:J.sender==="agent"&&vn.has(J.id)?"max-w-full w-full":c?"max-w-[95%]":"max-w-[75%]",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:[J.sender==="user"?Rs??"You":t.jsx(bA,{name:J.agentName??(S==="direct"?Un?.name??"Agent":"Agent"),agentId:J.agentId??(S==="direct"?Un?.id:void 0),agents:s,onViewProfile:k})," · ",J.time]}),J.replyToId&&J.replyToSender&&t.jsxs("button",{onClick:()=>{const Ge=document.getElementById(`msg-${J.replyToId}`);Ge&&(Ge.scrollIntoView({behavior:"smooth",block:"center"}),Ge.classList.add("bg-brand-500/10"),setTimeout(()=>Ge.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:J.replyToSender}),t.jsx("span",{className:"truncate max-w-[200px]",children:J.replyToText??"..."})]}),t.jsx("div",{className:`rounded-2xl text-sm ${c?"px-3 py-2":"px-4 py-3"} ${J.sender==="user"?"bg-brand-600 text-white rounded-br-sm":J.isError||J.sender==="agent"&&J.text.startsWith("⚠")?"bg-surface-chat-bubble text-fg-primary rounded-bl-sm border-b-2 border-red-500/60":"bg-surface-chat-bubble text-fg-primary rounded-bl-sm"}`,children:J.sender==="user"?t.jsxs(t.Fragment,{children:[J.images&&J.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:J.images.map((Ge,Ue)=>t.jsx("img",{src:Ge,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(Ge,"_blank")},Ue))}),J.text&&t.jsx("span",{className:"whitespace-pre-wrap leading-relaxed",children:vy(J.text,s)})]}):t.jsx(jA,{msg:J,isStreaming:Me,liveActivities:Me?M:[],onViewModeChange:Ge=>gs(Ue=>{const Nt=new Set(Ue);return Ge==="full"?Nt.add(J.id):Nt.delete(J.id),Nt})})}),Ce&&t.jsx("div",{className:`transition-opacity ${J.isStopped?"opacity-100":"opacity-0 group-hover/msg:opacity-100"} ${J.sender==="user"?"flex justify-end":""}`,children:t.jsx(Ty,{msg:J,onCopy:qr,onRetry:fr,onReply:rr,isCopied:dr===J.id})})]})},J.id)}),S==="channel"&&X&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse ml-11",children:"Agent is thinking…"}),t.jsx("div",{ref:yn})]}),w&&(()=>{const J=s.find(pe=>pe.id===w.agentId);return J?t.jsx(yA,{agent:J,anchorRect:{top:w.top,left:w.left},onClose:()=>N(null),onViewProfile:k}):null})(),t.jsxs("div",{className:`p-4 border-t border-border-default bg-surface-secondary relative shrink-0 ${g!=="chat"?"hidden":""}`,onDrop:as,onDragOver:Fr,children:[vt&&br.length>0&&t.jsxs("div",{className:"absolute bottom-full left-4 mb-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden z-10 max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:"Mention an agent"}),br.map((J,pe)=>t.jsxs("button",{onClick:()=>Dt(J.name),onMouseEnter:()=>Mn(pe),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${pe===Wt?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 flex items-center justify-center text-[10px] font-bold text-brand-500 shrink-0",children:J.name.slice(0,2).toUpperCase()}),t.jsx("span",{className:"flex-1 min-w-0",children:J.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:J.role})]},J.id))]}),he.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[he.map(J=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:J.dataUrl,alt:J.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>ss(J.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-xs opacity-0 group-hover/img:opacity-100 transition-opacity",children:"×"})]},J.id)),he.length<Dn&&t.jsx("button",{onClick:()=>Le.current?.click(),className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:"Add more images",children:t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),t.jsx("input",{ref:Le,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:J=>{J.target.files&&En(J.target.files),J.target.value=""}}),B&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:B.sender}),t.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:B.text})]}),t.jsx("button",{onClick:()=>F(null),className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("button",{onClick:()=>Le.current?.click(),disabled:S==="direct"&&!D,className:"px-2.5 py-2.5 text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated",title:"Attach images",children:t.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),t.jsx("textarea",{ref:ye,value:q,onChange:J=>{Be(J.target.value),J.target.style.height="auto";const pe=Math.min(J.target.scrollHeight,120);J.target.style.height=`${pe}px`,J.target.style.overflowY=pe>=120?"auto":"hidden"},onKeyDown:J=>{if(vt&&br.length>0){const pe=J.key==="ArrowUp"||J.ctrlKey&&J.key==="p",Ee=J.key==="ArrowDown"||J.ctrlKey&&J.key==="n",Me=J.key==="Enter"||J.key==="Tab",Ce=J.key==="Escape";if(pe){J.preventDefault(),Mn(Ge=>(Ge-1+br.length)%br.length);return}if(Ee){J.preventDefault(),Mn(Ge=>(Ge+1)%br.length);return}if(Me){J.preventDefault();const Ge=br[Wt];Ge&&Dt(Ge.name);return}if(Ce){J.preventDefault(),sn(!1);return}}J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),nr())},onPaste:Os,placeholder:Ie,disabled:S==="direct"&&!D,rows:1,className:"flex-1 px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm focus:border-brand-500 outline-none disabled:opacity-40 transition-colors resize-none overflow-hidden leading-5",style:{maxHeight:"120px"}}),X&&S!=="dm"&&t.jsx("button",{onClick:pr,className:"px-3 py-2.5 bg-red-600 hover:bg-red-500 text-white text-sm rounded-xl transition-colors flex items-center gap-1.5",title:"Stop agent",children:t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),t.jsx("button",{onClick:()=>{nr()},disabled:S==="direct"&&!D||!q.trim()&&he.length===0,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:"Send"})]})]})]})]})}function _y({agent:e,tasks:n,onViewProfile:s}){const[l,o]=v.useState(!1),d=v.useRef(null),c=e.status==="working",h=e.status==="error",m=c?n.find(y=>y.assignedAgentId===e.id&&y.status==="in_progress"):null,f=e.currentActivity;v.useEffect(()=>{if(!l)return;const y=w=>{d.current&&!d.current.contains(w.target)&&o(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[l]);const g=h?"bg-red-400 animate-pulse":c?"bg-blue-400 animate-pulse":"bg-green-400",x=h?"error":c?"working":"idle",p=f?f.type==="heartbeat"?`Heartbeat: ${f.heartbeatName??f.label}`:f.type==="chat"?f.label:f.type==="task"?`Task: ${f.label}`:f.label:"Processing...";return t.jsxs("div",{className:"relative",ref:d,children:[t.jsxs("button",{onClick:()=>o(y=>!y),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${c?"bg-amber-500/10 border border-amber-500/20 hover:bg-amber-500/20":h?"bg-red-500/10 border border-red-500/20 hover:bg-red-500/20":"bg-green-500/10 border border-green-500/20 hover:bg-green-500/20"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${g}`}),t.jsx("span",{className:`text-xs ${h?"text-red-500":c?"text-amber-600":"text-green-600"}`,children:x}),e.mailboxDepth!=null&&e.mailboxDepth>0&&t.jsx("span",{className:"text-[9px] bg-fg-tertiary/20 text-fg-tertiary rounded-full px-1.5",children:e.mailboxDepth})]}),l&&h&&t.jsxs("div",{className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-red-500/30 rounded-xl shadow-2xl z-30 w-80 p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] text-red-500 uppercase font-semibold",children:"Error Details"}),t.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-2.5",children:[t.jsx("pre",{className:"text-[10px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono line-clamp-6",children:e.lastError||"Agent encountered an error. Check profile for details."}),e.lastErrorAt&&t.jsx("div",{className:"text-[9px] text-red-500/50 mt-1.5 border-t border-red-500/10 pt-1",children:new Date(e.lastErrorAt).toLocaleString()})]}),t.jsx("button",{onClick:()=>{o(!1),s?.(e.id)},className:"w-full text-center text-[10px] text-red-500 hover:text-red-500 border border-red-500/30 hover:border-red-500/50 rounded-lg py-1 transition-colors",children:"View Agent Profile →"})]}),l&&c&&t.jsxs("div",{className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:"Current Activity"}),m?t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-brand-500/10 border border-brand-500/30 cursor-pointer hover:bg-brand-500/10 transition-colors",onClick:()=>{o(!1),gt.navigate(ge.WORK,{openTask:m.id})},children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-brand-500 truncate",children:m.title}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Working on task · Click to view"})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"→"})]}):t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-surface-elevated/50",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${f?.type==="heartbeat"||f?.type==="chat","bg-blue-400 animate-pulse"}`}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-secondary",children:p}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:f?.type==="heartbeat"?"Periodic check-in task":f?.type==="chat"?"Responding to conversation":"Agent is thinking or communicating"})]})]}),t.jsx("button",{onClick:()=>{o(!1),s?.(e.id,{tab:"mind"})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1.5 transition-colors",children:"View Mind →"})]})]})}function _j({theme:e,onThemeChange:n}={}){const[s,l]=v.useState(null),[o,d]=v.useState(null),[c,h]=v.useState(""),[m,f]=v.useState(!1),[g,x]=v.useState(null),[p,y]=v.useState(null),[w,N]=v.useState(null),[C,_]=v.useState(null),[O,k]=v.useState(!1),[S,R]=v.useState(null),[D,Y]=v.useState(null),[z,K]=v.useState(!1),[U,G]=v.useState(null),[V,E]=v.useState({}),[T,L]=v.useState(!1),[A,P]=v.useState([]),[q,W]=v.useState([]),[B,F]=v.useState(null),[X,I]=v.useState(null),[M,H]=v.useState(""),[Z,ee]=v.useState(null),ne=v.useRef(null),ae=v.useRef(!1),[he,Ne]=v.useState(!1),[Le,ye]=v.useState(200),[je,Ae]=v.useState(!1),[$e,Xe]=v.useState(null),[tt,et]=v.useState(null),[_t,se]=v.useState(!1),[Te,nt]=v.useState(new Set),[yt,Xt]=v.useState(null),[we,De]=v.useState(!1),Pe=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`}),Ze=v.useCallback(()=>{re.health().then(l).catch(()=>{}),fetch("/api/settings/llm").then(oe=>oe.ok?oe.json():Promise.reject(oe.status)).then(oe=>{oe&&typeof oe=="object"&&"providers"in oe&&(d(oe),h(oe.defaultProvider))}).catch(()=>{})},[]),mt=v.useCallback(()=>{fetch("/api/settings/oauth/providers").then(oe=>oe.ok?oe.json():Promise.reject(oe.status)).then(oe=>P(oe.providers??[])).catch(()=>{})},[]),Kt=v.useCallback(()=>{fetch("/api/settings/oauth/profiles",{headers:Pe()}).then(oe=>oe.ok?oe.json():Promise.reject(oe.status)).then(oe=>W(oe.profiles??[])).catch(()=>{})},[]),ln=v.useCallback(()=>{re.settings.getAgent().then(oe=>{oe&&typeof oe.maxToolIterations=="number"&&ye(oe.maxToolIterations)}).catch(()=>{})},[]),Ht=v.useCallback(()=>{se(!0),re.system.storage().then(et).catch(()=>{}).finally(()=>se(!1)),re.system.orphans().then(Xt).catch(()=>{})},[]);v.useEffect(()=>{Ze(),mt(),Kt(),ln(),Ht()},[Ze,mt,Kt,ln,Ht]),v.useEffect(()=>{const oe=()=>Ht();return window.addEventListener("markus:data-changed",oe),()=>window.removeEventListener("markus:data-changed",oe)},[Ht]);const Lt=v.useCallback(async()=>{K(!0),G(null),Y(null),E({});try{const oe=await fetch("/api/settings/env-models",{headers:Pe()});if(!oe.ok){G({type:"err",text:`Detection failed (HTTP ${oe.status})`});return}const ke=await oe.json();if(Y(ke),ke.detected.length===0)G({type:"err",text:"No model API keys found in environment variables"});else{const Be={};for(const Dt of ke.detected)Be[Dt.provider]=!0;E(Be)}}catch{G({type:"err",text:"Failed to detect environment variables"})}finally{K(!1)}},[]),At=o?Object.values(o.providers).some(oe=>oe.configured):!1;v.useEffect(()=>{o&&!At&&!ae.current&&(ae.current=!0,Lt())},[o,At,Lt]);const St=async()=>{if(!(!c||c===o?.defaultProvider)){f(!0),x(null);try{const oe=await fetch("/api/settings/llm",{method:"POST",headers:Pe(),body:JSON.stringify({defaultProvider:c})}),ke=await oe.json();oe.ok?(d(ke),x({type:"ok",text:`Default provider updated to ${ke.defaultProvider}`})):x({type:"err",text:ke.error??"Save failed"})}catch{x({type:"err",text:"Network error"})}finally{f(!1)}}},en=async(oe,ke)=>{N(oe);try{const Be=await fetch(`/api/settings/llm/providers/${oe}/toggle`,{method:"POST",headers:Pe(),body:JSON.stringify({enabled:ke})});if(Be.ok){const Dt=await Be.json();d(Dt)}}catch{}finally{N(null)}},tn=async()=>{k(!0),R(null);try{const ke=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Pe(),body:JSON.stringify({preview:!0})})).json();"error"in ke?R({type:"err",text:ke.error}):_(ke)}catch{R({type:"err",text:"Detection failed"})}finally{k(!1)}},ve=async()=>{k(!0),R(null);try{const ke=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Pe(),body:JSON.stringify({preview:!1})})).json();"error"in ke?R({type:"err",text:ke.error}):(R({type:"ok",text:`Imported ${ke.appliedModels} model configs from OpenClaw`}),Ze())}catch{R({type:"err",text:"Import failed"})}finally{k(!1)}},Ve=async()=>{if(!D)return;const oe=D.detected.filter(ke=>V[ke.provider]);if(oe.length===0){G({type:"err",text:"Select at least one provider to apply"});return}L(!0),G(null);try{const ke=await fetch("/api/settings/env-models",{method:"POST",headers:Pe(),body:JSON.stringify({providers:oe.map(Dt=>({provider:Dt.provider,model:Dt.model,baseUrl:Dt.baseUrl,enabled:!0}))})});if(!ke.ok){G({type:"err",text:`Apply failed (HTTP ${ke.status})`});return}const Be=await ke.json();G({type:"ok",text:Be.message}),Y(null),E({}),Ze()}catch{G({type:"err",text:"Failed to apply environment configs"})}finally{L(!1)}},Rt=async oe=>{F(oe),I(null);try{const ke=await fetch("/api/settings/oauth/login",{method:"POST",headers:Pe(),body:JSON.stringify({provider:oe})}),Be=await ke.json();if(!ke.ok||Be.error){I({type:"err",text:Be.error??"Login failed"});return}Be.authorizeUrl&&(window.open(Be.authorizeUrl,"_blank","noopener"),ee(oe),I({type:"ok",text:"Browser opened for authorization. Complete the login in the browser window..."}),ne.current&&clearInterval(ne.current),ne.current=setInterval(async()=>{try{const Jn=await(await fetch(`/api/settings/oauth/status?provider=${oe}`,{headers:Pe()})).json();!Jn.pending&&Jn.profiles.some(Dn=>Dn.provider===oe&&Dn.hasOAuth)&&(ne.current&&clearInterval(ne.current),ne.current=null,ee(null),W(Jn.profiles),I({type:"ok",text:`Connected to ${oe} via OAuth`}),Ze())}catch{}},2e3))}catch{I({type:"err",text:"Network error during OAuth login"})}finally{F(null)}},Pt=async()=>{if(M.trim()){F("manual"),I(null);try{const oe=await fetch("/api/settings/oauth/callback",{method:"POST",headers:Pe(),body:JSON.stringify({callbackUrl:M})}),ke=await oe.json();if(!oe.ok||ke.error){I({type:"err",text:ke.error??"Callback failed"});return}I({type:"ok",text:`Connected to ${ke.profile?.provider??"provider"} via OAuth`}),H(""),ee(null),ne.current&&(clearInterval(ne.current),ne.current=null),Kt(),Ze()}catch{I({type:"err",text:"Network error"})}finally{F(null)}}},vt=async oe=>{try{(await fetch(`/api/settings/oauth/profiles/${encodeURIComponent(oe)}`,{method:"DELETE",headers:Pe()})).ok&&(Kt(),Ze(),I({type:"ok",text:"Auth profile deleted"}))}catch{}};v.useEffect(()=>()=>{ne.current&&clearInterval(ne.current)},[]);const[sn,gn]=v.useState(!1),[rt,Wt]=v.useState({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),[Mn,Mt]=v.useState(!1),[yn,Nn]=v.useState(null),[ie,qe]=v.useState(null),[ze,We]=v.useState({apiKey:"",baseUrl:"",model:"",contextWindow:0,maxOutputTokens:0,costInput:0,costOutput:0}),[lt,Ct]=v.useState(!1),[dt,zt]=v.useState(null),[pt,on]=v.useState(null),[de,Fe]=v.useState({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1}),[ht,Tt]=v.useState(!1),Rn=async()=>{if(!(!rt.name||!rt.model)){Mt(!0),Nn(null);try{const oe=await fetch("/api/settings/llm/providers",{method:"POST",headers:Pe(),body:JSON.stringify({name:rt.name,apiKey:rt.apiKey||void 0,baseUrl:rt.baseUrl||void 0,model:rt.model,contextWindow:rt.contextWindow||void 0,maxOutputTokens:rt.maxOutputTokens||void 0,cost:rt.costInput||rt.costOutput?{input:rt.costInput,output:rt.costOutput}:void 0})}),ke=await oe.json();oe.ok?(d(ke),gn(!1),Wt({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),Nn({type:"ok",text:`Provider ${rt.name} added`})):Nn({type:"err",text:ke.error??"Failed to add"})}catch{Nn({type:"err",text:"Network error"})}finally{Mt(!1)}}},gr=(oe,ke)=>{qe(oe),We({apiKey:"",baseUrl:ke.baseUrl??"",model:ke.model,contextWindow:ke.contextWindow??0,maxOutputTokens:ke.maxOutputTokens??0,costInput:ke.cost?.input??0,costOutput:ke.cost?.output??0})},pr=async oe=>{Ct(!0);try{const ke={};ze.apiKey&&(ke.apiKey=ze.apiKey),ze.baseUrl!==void 0&&(ke.baseUrl=ze.baseUrl),ze.model&&(ke.model=ze.model),ze.contextWindow&&(ke.contextWindow=ze.contextWindow),ze.maxOutputTokens&&(ke.maxOutputTokens=ze.maxOutputTokens),(ze.costInput||ze.costOutput)&&(ke.cost={input:ze.costInput,output:ze.costOutput});const Be=await fetch(`/api/settings/llm/providers/${oe}`,{method:"PUT",headers:Pe(),body:JSON.stringify(ke)});if(Be.ok){const Dt=await Be.json();d(Dt),qe(null)}}catch{}finally{Ct(!1)}},nr=async oe=>{zt(oe);try{const ke=await fetch(`/api/settings/llm/providers/${oe}`,{method:"DELETE",headers:Pe()});if(ke.ok){const Be=await ke.json();d(Be),h(Be.defaultProvider)}}catch{}finally{zt(null)}},dr=async oe=>{if(!(!de.id||!de.name)){Tt(!0);try{const ke=await fetch(`/api/settings/llm/providers/${oe}/models`,{method:"POST",headers:Pe(),body:JSON.stringify({id:de.id,name:de.name,contextWindow:de.contextWindow,maxOutputTokens:de.maxOutputTokens,cost:{input:de.costInput,output:de.costOutput},reasoning:de.reasoning||void 0,inputTypes:de.vision?["text","image"]:["text"]})});if(ke.ok){const Be=await ke.json();d(Be),on(null),Fe({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})}}catch{}finally{Tt(!1)}}},ur=async(oe,ke)=>{try{const Be=await fetch(`/api/settings/llm/providers/${oe}/models/${encodeURIComponent(ke)}`,{method:"DELETE",headers:Pe()});if(Be.ok){const Dt=await Be.json();d(Dt)}}catch{}},vn=new Set(["claude-opus-4-6","claude-sonnet-4-20250514","claude-3-5-haiku-20241022","gpt-5.4","gpt-4o","o4-mini","gemini-3-1-pro","gemini-2.5-flash","MiniMax-M2.7","MiniMax-M2.5","xiaomi/mimo-v2-pro","anthropic/claude-opus-4-6","openai/gpt-5.4","google/gemini-3-1-pro"]),[gs,qr]=v.useState(null),fr=async(oe,ke)=>{qr(`${oe}:${ke}`);try{const Be=await fetch(`/api/settings/llm/providers/${oe}/model`,{method:"POST",headers:Pe(),body:JSON.stringify({model:ke})});if(Be.ok){const Dt=await Be.json();d(Dt)}}catch{}finally{qr(null)}},rr=o?.providers?Object.entries(o.providers).filter(([,oe])=>oe.configured&&oe.enabled).map(([oe])=>oe):[],Vr=o&&!At&&!he;return t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Settings"})}),t.jsxs("div",{className:"p-7 space-y-10 max-w-4xl",children:[t.jsx(Ks,{title:"Appearance",children:t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Theme"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Choose light, dark, or follow your system preference"})]}),t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[["system","System"],["light","Light"],["dark","Dark"]].map(([oe,ke])=>t.jsx("button",{onClick:()=>n?.(oe),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${e===oe?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:ke},oe))})]})})}),Vr&&t.jsxs("div",{className:"relative bg-gradient-to-br from-brand-500/10 to-surface-secondary border border-brand-500/20 rounded-2xl p-6 space-y-5",children:[t.jsx("button",{onClick:()=>Ne(!0),className:"absolute top-4 right-4 text-fg-tertiary hover:text-fg-secondary text-xs",children:"Skip"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Welcome — Configure Your LLM"}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1",children:"Markus needs at least one LLM provider to work. Choose a way to get started:"})]}),t.jsxs(Bh,{step:"1",title:"From Environment Variables",description:"Automatically detected API keys from .env or system environment.",active:!!(D&&D.detected.length>0),children:[z&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Detecting..."}),D&&D.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[D.detected.map(oe=>t.jsxs("label",{className:"flex items-center gap-3 bg-surface-elevated/30 rounded-lg px-3 py-2 cursor-pointer hover:bg-surface-elevated/50 transition-colors",children:[t.jsx("input",{type:"checkbox",checked:V[oe.provider]??!1,onChange:ke=>E({...V,[oe.provider]:ke.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:oe.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:oe.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:oe.apiKeyPreview})]},oe.provider)),t.jsx("button",{onClick:()=>{Ve()},disabled:T||Object.values(V).filter(Boolean).length===0,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:T?"Applying...":`Apply ${Object.values(V).filter(Boolean).length} Provider(s)`})]}),D&&D.detected.length===0&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["No API keys found. Set environment variables like ",t.jsx("code",{className:"text-fg-secondary",children:"ANTHROPIC_API_KEY"})," or ",t.jsx("code",{className:"text-fg-secondary",children:"OPENAI_API_KEY"})," and restart the server."]}),U&&t.jsx(Aa,{type:U.type,text:U.text})]}),t.jsxs(Bh,{step:"2",title:"From OpenClaw Config",description:"Import model configs from an existing OpenClaw installation.",children:[C?C.found?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found: ",t.jsx("code",{className:"text-fg-secondary",children:C.summary.configPath})]}),C.summary.models&&t.jsxs("div",{className:"text-xs text-fg-secondary",children:[C.summary.models.providerCount," providers, ",C.summary.models.providers.reduce((oe,ke)=>oe+ke.modelCount,0)," models"]}),t.jsx("button",{onClick:()=>{ve()},disabled:O,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:O?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{tn()},disabled:O,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors",children:O?"Detecting...":"Detect OpenClaw"}),S&&t.jsx(Aa,{type:S.type,text:S.text})]}),t.jsx(Bh,{step:"3",title:"Manual Configuration",description:t.jsxs(t.Fragment,{children:["Edit ",t.jsx("code",{className:"text-fg-secondary",children:"~/.markus/markus.json"})," directly, then restart the server."]})})]}),t.jsx(Ks,{title:"System Status",children:s?t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Hh,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx(Hh,{label:"Version",value:s.version,color:"indigo"}),t.jsx(Hh,{label:"Active Agents",value:String(s.agents),color:"purple"})]}):t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Loading..."})}),t.jsx(Ks,{title:"Default LLM Provider",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Primary Provider"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Used for all agent interactions unless overridden"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[o?t.jsx("select",{value:c,onChange:oe=>{h(oe.target.value),x(null)},className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-48 focus:border-brand-500 outline-none",children:rr.length>0?rr.map(oe=>t.jsx("option",{value:oe,children:o.providers[oe]?.displayName??oe},oe)):t.jsx("option",{value:"",children:"No providers configured"})}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading..."}),c!==o?.defaultProvider&&t.jsx("button",{onClick:()=>{St()},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded-lg transition-colors",children:m?"Saving...":"Save"})]})]}),g&&t.jsx(Aa,{type:g.type,text:g.text})]})}),A.length>0&&t.jsx(Ks,{title:"OAuth Authentication",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Connect to LLM providers using your existing subscription via OAuth. No API key required."}),t.jsx("div",{className:"space-y-3",children:A.map(oe=>{const ke=q.find(Dt=>Dt.provider===oe.name&&Dt.hasOAuth),Be=Z===oe.name;return t.jsxs("div",{className:"flex items-center justify-between bg-surface-elevated/30 rounded-lg px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${ke?"bg-green-400":"bg-gray-600"}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:oe.displayName}),ke&&t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[ke.accountId&&t.jsxs("span",{children:["Account: ",ke.accountId]}),ke.oauthExpired&&t.jsx("span",{className:"text-amber-500 ml-2",children:"Token expired"}),!ke.oauthExpired&&t.jsx("span",{className:"text-green-600 ml-2",children:"Connected"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[ke&&t.jsx("button",{onClick:()=>{vt(ke.id)},className:"px-2 py-1 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded transition-colors",title:"Disconnect",children:"Disconnect"}),t.jsx("button",{onClick:()=>{Rt(oe.name)},disabled:B===oe.name||Be,className:`px-4 py-1.5 text-xs rounded-lg transition-colors ${ke?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-white"} disabled:opacity-40`,children:B===oe.name?"Starting...":Be?"Waiting...":ke?"Reconnect":"Connect"})]})]},oe.name)})}),Z&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"If the browser didn't open or you're on a remote machine, paste the redirect URL here:"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:M,onChange:oe=>H(oe.target.value),placeholder:"http://localhost:1455/auth/callback?code=...&state=...",className:"flex-1 px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("button",{onClick:()=>{Pt()},disabled:!M.trim()||B==="manual",className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-xs rounded-lg transition-colors",children:B==="manual"?"Processing...":"Submit"})]})]}),q.length>0&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-2",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Auth Profiles"}),q.map(oe=>t.jsxs("div",{className:"flex items-center justify-between text-xs px-3 py-2 bg-surface-elevated/20 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${oe.hasOAuth&&!oe.oauthExpired?"bg-green-400":oe.oauthExpired?"bg-amber-400":"bg-gray-500"}`}),t.jsx("span",{className:"text-fg-secondary",children:oe.label??oe.id}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-overlay text-fg-tertiary",children:oe.authType})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[oe.accountId&&t.jsx("span",{className:"text-fg-tertiary",children:oe.accountId}),t.jsx("span",{className:"text-fg-tertiary",children:new Date(oe.updatedAt).toLocaleDateString()}),t.jsx("button",{onClick:()=>{vt(oe.id)},className:"text-red-400 hover:text-red-300 transition-colors",title:"Delete",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},oe.id))]}),X&&t.jsx(Aa,{type:X.type,text:X.text})]})}),t.jsxs(Ks,{title:"Model Providers & Pricing",children:[t.jsx("div",{className:"space-y-3",children:o&&Object.entries(o.providers).map(([oe,ke])=>t.jsxs("div",{className:`bg-surface-secondary border rounded-xl overflow-hidden transition-colors ${ke.configured?"border-border-default hover:border-gray-600":"border-border-default/50 opacity-60"}`,children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 cursor-pointer",onClick:()=>y(p===oe?null:oe),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${ke.configured&&ke.enabled?"bg-green-400":ke.configured?"bg-amber-400":"bg-gray-600"}`}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:ke.displayName??oe}),oe===o.defaultProvider&&t.jsx("span",{className:"text-[10px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"default"}),ke.configured&&!ke.enabled&&t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded",children:"disabled"}),ke.oauthConnected&&t.jsx("span",{className:"text-[10px] bg-green-500/15 text-green-600 px-1.5 py-0.5 rounded",children:"OAuth"})]}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:ke.model||"Not configured"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[ke.configured&&t.jsx("button",{onClick:Be=>{Be.stopPropagation(),en(oe,!ke.enabled)},disabled:w===oe,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${ke.enabled?"bg-green-500":"bg-gray-600"} ${w===oe?"opacity-50":""}`,title:ke.enabled?"Click to disable":"Click to enable",children:t.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${ke.enabled?"translate-x-4":"translate-x-1"}`})}),ke.contextWindow&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[(ke.contextWindow/1e3).toFixed(0),"K ctx"]}),ke.cost&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["$",ke.cost.input,"/",ke.cost.output," per 1M"]}),t.jsx("span",{className:"text-fg-tertiary text-xs",children:p===oe?"▲":"▼"})]})]}),p===oe&&t.jsxs("div",{className:"px-5 pb-4 border-t border-border-default pt-4 space-y-4",children:[ke.configured&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(_a,{label:"Model",value:ke.model}),t.jsx(_a,{label:"Context Window",value:ke.contextWindow?`${(ke.contextWindow/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(_a,{label:"Max Output",value:ke.maxOutputTokens?`${(ke.maxOutputTokens/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(_a,{label:"Base URL",value:ke.baseUrl??"Default"})]}),ie===oe?t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-4 space-y-3",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Edit Provider"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"API Key"}),t.jsx("input",{type:"password",value:ze.apiKey,onChange:Be=>We({...ze,apiKey:Be.target.value}),placeholder:"Leave blank to keep current",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Base URL"}),t.jsx("input",{type:"text",value:ze.baseUrl,onChange:Be=>We({...ze,baseUrl:Be.target.value}),placeholder:"Default",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Model"}),t.jsx("input",{type:"text",value:ze.model,onChange:Be=>We({...ze,model:Be.target.value}),className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Context Window"}),t.jsx("input",{type:"number",value:ze.contextWindow||"",onChange:Be=>We({...ze,contextWindow:Number(Be.target.value)}),placeholder:"e.g. 128000",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Max Output Tokens"}),t.jsx("input",{type:"number",value:ze.maxOutputTokens||"",onChange:Be=>We({...ze,maxOutputTokens:Number(Be.target.value)}),placeholder:"e.g. 16384",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Input"}),t.jsx("input",{type:"number",step:"0.01",value:ze.costInput||"",onChange:Be=>We({...ze,costInput:Number(Be.target.value)}),placeholder:"e.g. 1",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Output"}),t.jsx("input",{type:"number",step:"0.01",value:ze.costOutput||"",onChange:Be=>We({...ze,costOutput:Number(Be.target.value)}),placeholder:"e.g. 5",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{pr(oe)},disabled:lt,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded-lg transition-colors",children:lt?"Saving...":"Save"}),t.jsx("button",{onClick:()=>qe(null),className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:Be=>{Be.stopPropagation(),gr(oe,ke)},className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Edit"}),t.jsx("button",{onClick:Be=>{Be.stopPropagation(),confirm(`Delete provider "${ke.displayName??oe}"?`)&&nr(oe)},disabled:dt===oe,className:"px-3 py-1.5 text-xs border border-red-500/30 text-red-400 hover:bg-red-500/10 rounded-lg transition-colors disabled:opacity-40",children:dt===oe?"Deleting...":"Delete"})]})]}),ke.cost&&t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-3",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider mb-2",children:"Pricing (per 1M tokens)"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(_a,{label:"Input",value:`$${ke.cost.input}`}),t.jsx(_a,{label:"Output",value:`$${ke.cost.output}`}),ke.cost.cacheRead!=null&&t.jsx(_a,{label:"Cache Read",value:`$${ke.cost.cacheRead}`}),ke.cost.cacheWrite!=null&&t.jsx(_a,{label:"Cache Write",value:`$${ke.cost.cacheWrite}`})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Available Models"}),ke.configured&&pt!==oe&&t.jsx("button",{onClick:()=>{on(oe),Fe({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})},className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:"+ Add Model"})]}),pt===oe&&t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-3 mb-2 space-y-2",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsx("input",{type:"text",placeholder:"Model ID",value:de.id,onChange:Be=>Fe({...de,id:Be.target.value}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"text",placeholder:"Display Name",value:de.name,onChange:Be=>Fe({...de,name:Be.target.value}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"number",placeholder:"Context (tokens)",value:de.contextWindow,onChange:Be=>Fe({...de,contextWindow:Number(Be.target.value)}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"number",placeholder:"Max Output",value:de.maxOutputTokens,onChange:Be=>Fe({...de,maxOutputTokens:Number(Be.target.value)}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"$/1M in:"}),t.jsx("input",{type:"number",step:"0.01",value:de.costInput,onChange:Be=>Fe({...de,costInput:Number(Be.target.value)}),className:"w-16 px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"out:"}),t.jsx("input",{type:"number",step:"0.01",value:de.costOutput,onChange:Be=>Fe({...de,costOutput:Number(Be.target.value)}),className:"w-16 px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-fg-tertiary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:de.reasoning,onChange:Be=>Fe({...de,reasoning:Be.target.checked}),className:"rounded"}),"reasoning"]}),t.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-fg-tertiary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:de.vision,onChange:Be=>Fe({...de,vision:Be.target.checked}),className:"rounded"}),"vision"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>{dr(oe)},disabled:ht||!de.id||!de.name,className:"px-2 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded transition-colors",children:ht?"Adding...":"Add"}),t.jsx("button",{onClick:()=>on(null),className:"px-2 py-1 text-[10px] border border-border-default text-fg-secondary hover:bg-surface-elevated rounded transition-colors",children:"Cancel"})]})]}),ke.models&&ke.models.length>0&&t.jsx("div",{className:"space-y-1.5",children:ke.models.map(Be=>{const Dt=Be.id===ke.model,Jn=gs===`${oe}:${Be.id}`,Dn=!vn.has(Be.id);return t.jsxs("div",{className:`flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-colors ${Dt?"bg-brand-500/15 border border-brand-500/30":ke.configured?"bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer":"bg-surface-elevated/30"}`,onClick:()=>{!Dt&&ke.configured&&!Jn&&fr(oe,Be.id)},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[Dt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0"}),t.jsx("span",{className:Dt?"text-brand-500 font-medium":"text-fg-secondary",children:Be.name}),Be.reasoning&&t.jsx("span",{className:"text-[9px] bg-amber-500/15 text-amber-600 px-1 py-0.5 rounded",children:"reasoning"}),Be.inputTypes?.includes("image")&&t.jsx("span",{className:"text-[9px] bg-blue-500/15 text-blue-600 px-1 py-0.5 rounded",children:"vision"}),Dn&&t.jsx("span",{className:"text-[9px] bg-purple-500/15 text-purple-400 px-1 py-0.5 rounded",children:"custom"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-fg-tertiary",children:[t.jsxs("span",{children:[(Be.contextWindow/1e3).toFixed(0),"K ctx"]}),t.jsxs("span",{children:["$",Be.cost.input,"/$",Be.cost.output]}),ke.configured&&!Dt&&t.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded transition-colors ${Jn?"bg-brand-500/30 text-brand-400":"bg-surface-overlay text-fg-tertiary hover:bg-brand-500/20 hover:text-brand-500"}`,children:Jn?"Switching...":"Use"}),Dt&&t.jsx("span",{className:"text-[9px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"active"}),Dn&&!Dt&&t.jsx("button",{onClick:En=>{En.stopPropagation(),ur(oe,Be.id)},className:"text-red-400 hover:text-red-300 transition-colors",title:"Delete custom model",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},Be.id)})})]}),!ke.configured&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:'Not configured. Use the "Add Provider" button below, or set API keys in environment variables.'})]})]},oe))}),sn?t.jsxs("div",{className:"mt-3 bg-surface-secondary border border-brand-500/30 rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Add New Provider"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Provider Name"}),t.jsx("input",{type:"text",value:rt.name,onChange:oe=>Wt({...rt,name:oe.target.value}),placeholder:"e.g. deepseek, openrouter, my-provider",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-1",children:"Use anthropic, openai, google, ollama for first-party; any other name uses OpenAI-compatible API"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"API Key"}),t.jsx("input",{type:"password",value:rt.apiKey,onChange:oe=>Wt({...rt,apiKey:oe.target.value}),placeholder:"sk-...",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Base URL (optional)"}),t.jsx("input",{type:"text",value:rt.baseUrl,onChange:oe=>Wt({...rt,baseUrl:oe.target.value}),placeholder:"https://api.example.com/v1",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Default Model"}),t.jsx("input",{type:"text",value:rt.model,onChange:oe=>Wt({...rt,model:oe.target.value}),placeholder:"e.g. deepseek-chat, gpt-4o",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Context Window"}),t.jsx("input",{type:"number",value:rt.contextWindow,onChange:oe=>Wt({...rt,contextWindow:Number(oe.target.value)}),placeholder:"128000",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Max Output Tokens"}),t.jsx("input",{type:"number",value:rt.maxOutputTokens,onChange:oe=>Wt({...rt,maxOutputTokens:Number(oe.target.value)}),placeholder:"16384",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Input"}),t.jsx("input",{type:"number",step:"0.01",value:rt.costInput,onChange:oe=>Wt({...rt,costInput:Number(oe.target.value)}),placeholder:"1",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Output"}),t.jsx("input",{type:"number",step:"0.01",value:rt.costOutput,onChange:oe=>Wt({...rt,costOutput:Number(oe.target.value)}),placeholder:"5",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{Rn()},disabled:Mn||!rt.name||!rt.model,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded-lg transition-colors",children:Mn?"Adding...":"Add Provider"}),t.jsx("button",{onClick:()=>{gn(!1),Nn(null)},className:"px-4 py-2 text-sm border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Cancel"})]}),yn&&t.jsx(Aa,{type:yn.type,text:yn.text})]}):t.jsx("button",{onClick:()=>gn(!0),className:"w-full mt-3 px-4 py-3 border border-dashed border-border-default hover:border-brand-500/50 hover:bg-brand-500/5 rounded-xl text-sm text-fg-tertiary hover:text-brand-500 transition-colors",children:"+ Add Provider"})]}),t.jsx("div",{className:"border-t border-border-default"}),t.jsx(Ks,{title:"Environment Variable Configuration",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Detect model API keys from environment variables and write them to the config file."}),t.jsxs("button",{onClick:()=>{Lt()},disabled:z,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors flex items-center gap-2",children:[t.jsx("svg",{className:`w-4 h-4 ${z?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),z?"Detecting...":"Refresh Environment Variables"]}),D&&D.detected.length>0&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:"Detected Providers — select to apply:"}),D.detected.map(oe=>t.jsxs("label",{className:"flex items-center justify-between bg-surface-elevated/30 rounded-lg px-4 py-3 cursor-pointer hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",checked:V[oe.provider]??!1,onChange:ke=>E({...V,[oe.provider]:ke.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm text-fg-primary font-medium",children:oe.displayName}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["Key: ",t.jsx("code",{className:"text-fg-secondary",children:oe.apiKeyPreview})," / ","Model: ",t.jsx("code",{className:"text-fg-secondary",children:oe.model}),oe.baseUrl&&t.jsxs(t.Fragment,{children:[" / ","URL: ",t.jsx("code",{className:"text-fg-secondary",children:oe.baseUrl})]})]})]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:Object.keys(oe.envVars).map(ke=>t.jsx("div",{children:t.jsx("code",{children:ke})},ke))})]},oe.provider)),D.timeoutMs&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["LLM Timeout: ",t.jsxs("code",{className:"text-fg-secondary",children:[D.timeoutMs,"ms"]})," (from ",t.jsx("code",{children:"LLM_TIMEOUT_MS"}),")"]}),t.jsx("button",{onClick:()=>{Ve()},disabled:T||Object.values(V).filter(Boolean).length===0,className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:T?"Applying...":`Apply ${Object.values(V).filter(Boolean).length} Provider(s) to Config`})]}),U&&t.jsx(Aa,{type:U.type,text:U.text})]})}),t.jsx(Ks,{title:"Import from OpenClaw",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Detect and import LLM configurations from an existing OpenClaw installation."}),t.jsx("div",{className:"flex gap-3",children:t.jsx("button",{onClick:()=>{tn()},disabled:O,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors",children:O?"Detecting...":"Detect OpenClaw Config"})}),C&&C.found&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found OpenClaw config at: ",t.jsx("code",{className:"text-fg-secondary",children:C.summary.configPath})]}),C.summary.models&&t.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg p-3",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-2",children:[C.summary.models.providerCount," model providers found:"]}),t.jsx("div",{className:"space-y-1",children:C.summary.models.providers.map(oe=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:oe.name}),t.jsxs("span",{className:"text-fg-tertiary",children:[oe.modelCount," models ",oe.baseUrl?`(${oe.baseUrl})`:""]})]},oe.name))})]}),C.summary.channels&&C.summary.channels.length>0&&t.jsx("div",{className:"bg-surface-elevated/30 rounded-lg p-3",children:t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:["Channels: ",C.summary.channels.join(", ")]})}),t.jsx("button",{onClick:()=>{ve()},disabled:O,className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:O?"Importing...":"Import Model Configs"})]}),S&&t.jsx(Aa,{type:S.type,text:S.text})]})}),t.jsx(Ks,{title:"Agent Execution",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Max Tool Iterations"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Safety cap on tool call loops per agent turn (0 = unlimited, applies to all agents and subagents)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",min:0,value:Le,onChange:oe=>{ye(Number(oe.target.value)),Xe(null)},className:"w-24 px-3 py-1.5 text-sm border border-border-default rounded-lg bg-surface-primary text-fg-primary text-right"}),t.jsx("button",{disabled:je,onClick:async()=>{Ae(!0),Xe(null);try{const oe=await re.settings.updateAgent({maxToolIterations:Le});ye(oe.maxToolIterations),Xe({type:"ok",text:"Saved"})}catch{Xe({type:"err",text:"Failed to save"})}Ae(!1)},className:"px-3 py-1.5 text-xs bg-brand-500 text-white rounded-lg hover:bg-brand-600 transition-colors disabled:opacity-40",children:je?"Saving…":"Save"})]})]}),$e&&t.jsx(Aa,{type:$e.type,text:$e.text})]})}),t.jsx(Ks,{title:"Data & Storage",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[_t&&!tt&&t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Scanning storage..."}),tt&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-lg font-semibold text-fg-primary",children:Ss(tt.totalSize)}),t.jsx("div",{className:"text-xs text-fg-tertiary font-mono mt-0.5",children:tt.dataDir})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>Ht(),disabled:_t,className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary transition-colors disabled:opacity-40",children:_t?"Scanning...":"Refresh"}),t.jsx("button",{onClick:()=>{re.system.openPath(tt.dataDir)},className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary transition-colors",children:"Open in Finder"})]})]}),t.jsxs("div",{className:"border-t border-border-default pt-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Storage Breakdown"}),t.jsx("div",{className:"space-y-1.5",children:tt.breakdown.filter(oe=>oe.size>0).map(oe=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 rounded-lg bg-surface-elevated/40",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:oe.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:oe.description})]}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Ss(oe.size)})]},oe.name))})]}),tt.agents.length>0&&t.jsxs("div",{className:"border-t border-border-default pt-4",children:[t.jsxs("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Agent Storage (",tt.agents.length,")"]}),t.jsx("div",{className:"space-y-1",children:tt.agents.map(oe=>{const ke=Te.has(oe.id);return t.jsxs("div",{className:"rounded-lg bg-surface-elevated/40 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between py-2 px-3 cursor-pointer hover:bg-surface-elevated/70",onClick:()=>nt(Be=>{const Dt=new Set(Be);return Dt.has(oe.id)?Dt.delete(oe.id):Dt.add(oe.id),Dt}),children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:ke?"▼":"▶"}),t.jsx("button",{onClick:Be=>{Be.stopPropagation(),gt.navigate(ge.TEAM,{agentId:oe.id})},className:"text-sm text-brand-500 hover:text-brand-400 truncate",children:oe.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:oe.id})]}),t.jsx("span",{className:"text-xs font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Ss(oe.size)})]}),ke&&t.jsxs("div",{className:"px-3 pb-2 pt-0.5 space-y-0.5",children:[oe.subItems.filter(Be=>Be.size>0).map(Be=>t.jsxs("div",{className:"flex items-center justify-between text-xs py-0.5 pl-5",children:[t.jsx("span",{className:"text-fg-tertiary",children:Be.name}),t.jsx("span",{className:"text-fg-secondary tabular-nums",children:Ss(Be.size)})]},Be.name)),t.jsx("div",{className:"pl-5 pt-1",children:t.jsx("button",{onClick:()=>{re.system.openPath(tt.dataDir+"/agents/"+oe.id)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary underline",children:"Open folder"})})]})]},oe.id)})})]}),yt&&(yt.orphanAgents.length>0||yt.orphanTeams.length>0)&&t.jsx(kA,{orphanInfo:yt,dataDir:tt.dataDir,onPurged:Ht})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function Bh({step:e,title:n,description:s,active:l,children:o}){return t.jsxs("div",{className:`rounded-xl border p-4 space-y-3 transition-colors ${l?"border-brand-500/60 bg-brand-500/10":"border-border-default bg-surface-secondary/60"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"flex-none w-6 h-6 rounded-full bg-surface-overlay flex items-center justify-center text-xs font-bold text-fg-secondary",children:e}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s})]})]}),o&&t.jsx("div",{className:"pl-9",children:o})]})}function Aa({type:e,text:n}){return t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${e==="ok"?"bg-green-500/10 text-green-600 border border-green-500/30":"bg-red-500/10 text-red-500 border border-red-500/30"}`,children:n})}function Ks({title:e,children:n}){return t.jsxs("section",{children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary uppercase tracking-wider mb-4",children:e}),t.jsx("div",{className:"space-y-4",children:n})]})}function Hh({label:e,value:n,color:s}){const l=s==="green"?"bg-green-500/10 text-green-600":"bg-brand-500/10 text-brand-500";return t.jsxs("div",{className:`rounded-xl px-5 py-4 ${l}`,children:[t.jsx("div",{className:"text-2xl font-bold",children:n}),t.jsx("div",{className:"text-xs mt-1 opacity-70",children:e})]})}function _a({label:e,value:n}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase",children:e}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 truncate",children:n})]})}function Ss(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${n[s]}`}function kA({orphanInfo:e,dataDir:n,onPurged:s}){const l=[...e.orphanAgents.map(N=>({...N,kind:"agent"})),...e.orphanTeams.map(N=>({...N,kind:"team"}))],[o,d]=v.useState(new Set),[c,h]=v.useState(!1),[m,f]=v.useState(null),g=N=>d(C=>{const _=new Set(C);return _.has(N)?_.delete(N):_.add(N),_}),x=o.size===l.length&&l.length>0,p=()=>d(x?new Set:new Set(l.map(N=>N.id))),y=l.filter(N=>o.has(N.id)).reduce((N,C)=>N+C.size,0),w=async N=>{h(!0),f(null);try{const C=await re.system.purgeOrphans(N),_=C.purgedAgents.length+C.purgedTeams.length;f(`Cleaned ${_} dir${_!==1?"s":""}, freed ${Ss(C.freedBytes)}${C.failures.length?` (${C.failures.length} failed)`:""}`),d(new Set),s()}catch{f("Cleanup failed")}finally{h(!1)}};return t.jsxs("div",{className:"border-t border-border-default pt-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-amber-500 mb-2",children:"Orphaned Directories"}),t.jsxs("p",{className:"text-xs text-fg-tertiary mb-3",children:["These directories have no matching database record and were likely left behind when agents or teams were deleted. Total: ",Ss(e.totalOrphanSize)," across ",l.length," director",l.length===1?"y":"ies","."]}),t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:x,onChange:p,className:"rounded"}),"Select all"]}),o.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[o.size," selected (",Ss(y),")"]})]}),t.jsx("div",{className:"space-y-0.5 mb-3 max-h-52 overflow-y-auto",children:l.map(N=>t.jsxs("div",{className:`flex items-center gap-2 text-xs py-1.5 px-2 rounded transition-colors ${o.has(N.id)?"bg-amber-500/10":"bg-surface-elevated/30 hover:bg-surface-elevated/50"}`,children:[t.jsx("input",{type:"checkbox",checked:o.has(N.id),onChange:()=>g(N.id),className:"rounded shrink-0"}),N.kind==="team"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:"team"}),t.jsx("span",{className:"text-fg-tertiary font-mono truncate min-w-0 flex-1",children:N.id}),t.jsx("span",{className:"text-fg-secondary tabular-nums shrink-0",children:Ss(N.size)}),t.jsx("button",{onClick:()=>{re.system.openPath(N.path)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary shrink-0 underline",children:"Open"})]},N.id))}),t.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[o.size>0&&t.jsx("button",{disabled:c,onClick:()=>{w([...o])},className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:c?"Cleaning...":`Clean Selected (${Ss(y)})`}),t.jsx("button",{disabled:c,onClick:()=>{w()},className:"px-3 py-1.5 text-xs border border-amber-600/50 hover:bg-amber-600/10 text-amber-500 rounded-lg transition-colors disabled:opacity-50",children:c?"Cleaning...":`Clean All (${Ss(e.totalOrphanSize)})`})]}),m&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-2",children:m})]})}const Ld=new Map;function rl(e,n){Ld.has(e)||Ld.set(e,n().catch(()=>{}))}function ll(e){const n=Ld.get(e);return Ld.delete(e),n}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function Mj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function SA(e,n){const s=e.split(".").map(Number),l=n.split(".").map(Number);for(let o=0;o<Math.max(s.length,l.length);o++){const d=s[o]??0,c=l[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}const mx={development:"{ }",devops:"⚙",management:"◎",productivity:"⚡",general:"◆"},xx={development:"bg-blue-500/15 text-blue-600 border-blue-500/20",devops:"bg-amber-500/15 text-amber-600 border-amber-500/20",management:"bg-brand-500/15 text-brand-500 border-brand-500/20",productivity:"bg-green-500/15 text-green-600 border-green-500/20",general:"bg-gray-500/15 text-fg-secondary border-gray-500/20"},Oj={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function Rj({authUser:e}={}){const[n,s]=v.useState("all"),[l,o]=v.useState(""),[d,c]=v.useState([]),[h,m]=v.useState([]),[f,g]=v.useState(null),[x,p]=v.useState(!1),[y,w]=v.useState(!0),[N,C]=v.useState(new Map),_=v.useCallback(async()=>{try{const[S,R]=await Promise.all([re.builder.artifacts.list().catch(()=>({artifacts:[]})),re.builder.artifacts.installed().catch(()=>({installed:{}}))]),D=new Map;for(const Y of S.artifacts){if(Y.type!=="agent")continue;const z=!!R.installed[`agent/${Y.name}`];D.set(Y.name,{installed:z,localVersion:Y.meta.version||void 0,localUpdatedAt:Y.updatedAt})}C(D)}catch{}},[]),O=v.useCallback(async()=>{w(!0);try{if(n==="hub"){const S=l?Xn.search({type:"agent",q:l,limit:50}):ll(Tr.hubAgents)??Xn.search({type:"agent",limit:50}),[R]=await Promise.all([S.catch(()=>({items:[],total:0})),_()]);m(R?.items??[]),c([])}else{m([]);const S=new URLSearchParams;l&&S.set("q",l);const R=await fetch("/api/templates?"+S.toString()).then(D=>D.json()).catch(()=>({templates:[]}));c(Array.isArray(R.templates)?R.templates:[])}}catch{c([]),m([])}finally{w(!1)}},[n,l,_]);v.useEffect(()=>{O()},[O]);const k=async(S,R,D)=>{try{const Y=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:S,name:R,orgId:"default",teamId:D})});if(!Y.ok)throw new Error(`Failed: ${Y.status}`);p(!1),g(null)}catch(Y){alert(`Failed to create agent: ${Y}`)}};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary shrink-0",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Agent Store"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 py-2 border-b border-border-default/50 bg-surface-secondary/50 shrink-0",children:[t.jsx("div",{className:"flex gap-1",children:[{id:"all",label:"Built-in"},{id:"hub",label:"Markus Hub"}].map(S=>t.jsx("button",{onClick:()=>{s(S.id),g(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${n===S.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:S.label},S.id))}),n==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[d.length," agent",d.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search agents...",value:l,onChange:S=>o(S.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children:y?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading agents..."}):n==="hub"?h.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx("div",{className:"text-fg-tertiary text-3xl mb-3",children:"🏪"}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No agents found on Markus Hub"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Hub may be offline or empty. Start the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(S=>t.jsx(CA,{item:S,localInfo:N.get(Mj(S.name)),onStatusChange:_},S.id))}):d.length===0?t.jsxs("div",{className:"text-center py-20",children:[t.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),t.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?`No agents match "${l}"`:"No agents found"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:l?"Try different search terms.":"Agents come from the built-in registry."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d.map(S=>t.jsx(EA,{template:S,isSelected:f?.id===S.id,onSelect:()=>g(f?.id===S.id?null:S)},S.id))})}),f&&n==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-72 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-lg ${xx[f.category]??"bg-surface-overlay text-fg-secondary"}`,children:mx[f.category]??"?"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children:f.name}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:f.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>p(!0),className:"px-5 py-2 bg-brand-600 text-white text-sm rounded-lg hover:bg-brand-500 transition-colors font-medium",children:"Hire Agent"}),t.jsx("button",{onClick:()=>g(null),className:"text-fg-tertiary hover:text-fg-secondary text-lg px-2",children:"×"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Skills"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[f.skills.map(S=>t.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:S},S)),f.skills.length===0&&t.jsx("span",{className:"text-xs text-fg-tertiary italic",children:"No required skills"})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Role Configuration"}),t.jsxs("div",{className:"space-y-1.5 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-16",children:"Role:"}),t.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:f.roleId})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-16",children:"Position:"}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${Oj[f.agentRole]??""}`,children:f.agentRole})]})]})]}),f.starterTasks&&f.starterTasks.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Starter Tasks"}),t.jsx("div",{className:"space-y-1.5",children:f.starterTasks.map((S,R)=>t.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[t.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${S.priority==="high"?"bg-red-400":S.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),S.title]},R))})]})]})]})}),x&&f&&t.jsx(TA,{template:f,onClose:()=>p(!1),onHire:k})]})}function CA({item:e,localInfo:n,onStatusChange:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(""),h=n?.installed??!1,m=h&&e.version&&n?.localVersion&&SA(e.version,n.localVersion),f=async g=>{if(g.stopPropagation(),!l){o(!0),c("");try{const x=await Xn.download(e.id),p=x.name||e.name,y=Mj(p),w=x.itemType==="team"?"team":x.itemType==="skill"?"skill":"agent",N={type:"hub",hubItemId:e.id};if(x.files&&Object.keys(x.files).length>0)await re.builder.artifacts.import(w,y,x.files,N);else{const C={...x.config,name:p,description:e.description,source:N};await re.builder.artifacts.save(w,C)}await re.builder.artifacts.install(w,y),c(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-lg",children:"🤖"}),t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[m?t.jsx("button",{onClick:g=>{f(g)},disabled:l,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Upgrading...":`Upgrade → v${e.version}`}):h?t.jsxs("span",{className:"px-3 py-1 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",n?.localVersion?` (v${n.localVersion})`:""]}):t.jsx("button",{onClick:g=>{f(g)},disabled:l,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Installing...":"Install"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})}function EA({template:e,isSelected:n,onSelect:s}){return t.jsxs("div",{onClick:s,className:`bg-surface-secondary border rounded-xl p-5 cursor-pointer transition-all hover:shadow-lg hover:shadow-black/20 ${n?"border-brand-500 ring-1 ring-brand-500/30":"border-border-default hover:border-gray-600"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm shrink-0 border ${xx[e.category]??"bg-surface-overlay text-fg-secondary"}`,children:mx[e.category]??"?"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 bg-brand-500/20 text-brand-500",children:["v",e.version]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",e.author]})]})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-3",children:[e.skills.slice(0,4).map(l=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-brand-500/10 text-brand-500/80 rounded-full border border-brand-500/10",children:l},l)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-tertiary",children:["+",e.skills.length-4," more"]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default flex items-center gap-2 text-xs text-fg-tertiary",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-[10px] font-medium capitalize ${Oj[e.agentRole]??"bg-surface-overlay text-fg-secondary"}`,children:e.agentRole}),e.tags.length>0&&t.jsx("span",{className:"text-fg-tertiary",children:e.tags.slice(0,2).join(", ")})]})]})}function TA({template:e,onClose:n,onHire:s}){const[l,o]=v.useState(`${e.name} Agent`),[d,c]=v.useState(""),[h,m]=v.useState([]),[f,g]=v.useState(!1);v.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(p=>p.json()).then(p=>m(p.teams??[])).catch(()=>{})},[]);const x=async()=>{if(l.trim()){g(!0);try{await s(e.id,l.trim(),d||void 0)}finally{g(!1)}}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:p=>p.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm ${xx[e.category]??"bg-surface-overlay text-fg-secondary"}`,children:mx[e.category]??"?"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Hire Agent"}),t.jsxs("p",{className:"text-xs text-fg-tertiary",children:['Creating agent from "',e.name,'"']})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Agent Name"}),t.jsx("input",{type:"text",value:l,onChange:p=>o(p.target.value),className:"input-field",autoFocus:!0})]}),h.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Assign to Team (optional)"}),t.jsxs("select",{value:d,onChange:p=>c(p.target.value),className:"input-field",children:[t.jsx("option",{value:"",children:"No team"}),h.map(p=>t.jsx("option",{value:p.id,children:p.name},p.id))]})]}),t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Agent Configuration"}),t.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[t.jsx("div",{className:"text-fg-tertiary",children:"Role:"}),t.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),t.jsx("div",{className:"text-fg-tertiary",children:"Position:"}),t.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),t.jsx("div",{className:"text-fg-tertiary",children:"Skills:"}),t.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||"None"})]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:n,className:"btn-secondary",children:"Cancel"}),t.jsx("button",{onClick:x,disabled:!l.trim()||f,className:"btn-primary",children:f?"Creating...":"Create Agent"})]})]})})}const Dj={development:"{ }",review:"⊘",operations:"⚙",general:"◎"},Id={development:"bg-blue-500/15 text-blue-600 border-blue-500/20",review:"bg-brand-500/15 text-brand-500 border-brand-500/20",operations:"bg-amber-500/15 text-amber-600 border-amber-500/20",general:"bg-gray-500/15 text-fg-secondary border-gray-500/20"};function Lj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function AA(e,n){const s=e.split(".").map(Number),l=n.split(".").map(Number);for(let o=0;o<Math.max(s.length,l.length);o++){const d=s[o]??0,c=l[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}function Ij(){const[e,n]=v.useState("all"),[s,l]=v.useState(""),[o,d]=v.useState([]),[c,h]=v.useState([]),[m,f]=v.useState(null),[g,x]=v.useState(!0),[p,y]=v.useState(!1),[w,N]=v.useState(null),[C,_]=v.useState(new Map),O=v.useCallback(async()=>{try{const[R,D]=await Promise.all([re.builder.artifacts.list().catch(()=>({artifacts:[]})),re.builder.artifacts.installed().catch(()=>({installed:{}}))]),Y=new Map;for(const z of R.artifacts){if(z.type!=="team")continue;const K=!!D.installed[`team/${z.name}`];Y.set(z.name,{installed:K,localVersion:z.meta.version||void 0,localUpdatedAt:z.updatedAt})}_(Y)}catch{}},[]),k=v.useCallback(async()=>{x(!0);try{if(e==="hub"){const R=s?Xn.search({type:"team",q:s,limit:50}):ll(Tr.hubTeams)??Xn.search({type:"team",limit:50}),[D]=await Promise.all([R.catch(()=>({items:[],total:0})),O()]);h(D?.items??[]),d([])}else{h([]);const R=await re.teamTemplates.list(s||void 0);d(R?.templates??[])}}catch{d([]),h([])}finally{x(!1)}},[e,s,O]);v.useEffect(()=>{k()},[k]);const S=async R=>{y(!0),N(null);try{const Y=(await re.teams.create(R.name,R.description)).team.id;let z,K=0;const U=[];for(const V of R.members){const E=V.count??1;for(let T=0;T<E;T++){const L=V.name??`${R.name} Agent ${T+1}`,A=E>1?`${L} ${T+1}`:L,P=V.roleName??V.templateId??"developer";try{const q=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:A,roleName:P,orgId:"default",teamId:Y,agentRole:V.role??"worker",skills:V.skills??[]})});if(q.ok){K++;const W=await q.json();V.role==="manager"&&!z&&(z=W.agent?.id)}else{const W=await q.json().catch(()=>({error:`HTTP ${q.status}`}));U.push(`${A}: ${W.error??q.statusText}`)}}catch(q){U.push(`${A}: ${String(q)}`)}}}z&&await re.teams.update(Y,{managerId:z,managerType:"agent"}).catch(()=>{});const G=U.length>0?` (${U.length} failed: ${U[0]})`:"";N({ok:K>0,message:`Team "${R.name}" deployed with ${K} agent(s)${G}`})}catch(D){N({ok:!1,message:`Failed: ${D}`})}finally{y(!1)}};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary shrink-0",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Team Store"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 py-2 border-b border-border-default/50 bg-surface-secondary/50 shrink-0",children:[t.jsx("div",{className:"flex gap-1",children:[{id:"all",label:"Built-in"},{id:"hub",label:"Markus Hub"}].map(R=>t.jsx("button",{onClick:()=>{n(R.id),f(null),N(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${e===R.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:R.label},R.id))}),e==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[o.length," team",o.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search teams...",value:s,onChange:R=>l(R.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children:g?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading teams..."}):e==="hub"?c.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx("div",{className:"text-fg-tertiary text-3xl mb-3",children:"🏪"}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No teams found on Markus Hub"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Hub may be offline or empty. Start the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:c.map(R=>t.jsx(_A,{item:R,localInfo:C.get(Lj(R.name)),onStatusChange:O},R.id))}):o.length===0?t.jsxs("div",{className:"text-center py-20",children:[t.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),t.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:s?`No teams match "${s}"`:"No teams available"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:s?"Try different search terms.":"Go to the Builder page to create a team."})]}):t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:o.map(R=>t.jsx(MA,{template:R,isSelected:m?.id===R.id,onSelect:()=>f(m?.id===R.id?null:R)},R.id))})}),m&&e==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-80 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-lg border ${Id[m.category??"general"]??Id.general}`,children:Dj[m.category??"general"]??"◎"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children:m.name}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:m.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>S(m),disabled:p,className:"px-5 py-2 bg-brand-600 text-white text-sm rounded-lg hover:bg-brand-500 transition-colors font-medium disabled:opacity-50",children:p?"Deploying...":"Deploy Team"}),t.jsx("button",{onClick:()=>{f(null),N(null)},className:"text-fg-tertiary hover:text-fg-secondary text-lg px-2",children:"×"})]})]}),w&&t.jsx("div",{className:`mb-4 px-4 py-2.5 rounded-lg text-sm ${w.ok?"bg-green-500/10 text-green-600 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,children:w.message}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:"Team Composition"}),t.jsx("div",{className:"space-y-2",children:m.members.map((R,D)=>t.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 ${R.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:R.role==="manager"?"★":D+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-fg-primary",children:R.name??R.roleName??R.templateId}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono",children:R.roleName??R.templateId}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize ${R.role==="manager"?"bg-brand-500/15 text-brand-500":"bg-blue-500/15 text-blue-600"}`,children:R.role??"worker"}),(R.count??1)>1&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",R.count]})]})]})]},D))})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:"Details"}),t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20",children:"Version:"}),t.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:m.version})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20",children:"Author:"}),t.jsx("span",{className:"text-fg-secondary",children:m.author})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20",children:"Members:"}),t.jsxs("span",{className:"text-fg-secondary",children:[m.members.reduce((R,D)=>R+(D.count??1),0)," agents"]})]}),m.tags&&m.tags.length>0&&t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-20 pt-0.5",children:"Tags:"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.tags.map(R=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-secondary rounded-full border border-border-default",children:R},R))})]})]})]})]})]})})]})}function _A({item:e,localInfo:n,onStatusChange:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(""),h=n?.installed??!1,m=h&&e.version&&n?.localVersion&&AA(e.version,n.localVersion),f=async g=>{if(g.stopPropagation(),!l){o(!0),c("");try{const x=await Xn.download(e.id),p=x.name||e.name,y=Lj(p),w={type:"hub",hubItemId:e.id};if(x.files&&Object.keys(x.files).length>0)await re.builder.artifacts.import("team",y,x.files,w);else{const N={...x.config,name:p,description:e.description,source:w};await re.builder.artifacts.save("team",N)}await re.builder.artifacts.install("team",y),c(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-lg",children:"👥"}),t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[m?t.jsx("button",{onClick:g=>{f(g)},disabled:l,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Upgrading...":`Upgrade → v${e.version}`}):h?t.jsxs("span",{className:"px-3 py-1 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",n?.localVersion?` (v${n.localVersion})`:""]}):t.jsx("button",{onClick:g=>{f(g)},disabled:l,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Installing...":"Install"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})}function MA({template:e,isSelected:n,onSelect:s}){const l=e.members.reduce((c,h)=>c+(h.count??1),0),o=e.members.some(c=>c.role==="manager"),d=e.category??"general";return t.jsxs("div",{onClick:s,className:`bg-surface-secondary border rounded-xl p-5 cursor-pointer transition-all hover:shadow-lg hover:shadow-black/20 ${n?"border-brand-500 ring-1 ring-brand-500/30":"border-border-default hover:border-gray-600"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm shrink-0 border ${Id[d]??Id.general}`,children:Dj[d]??"◎"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 bg-brand-500/20 text-brand-500",children:["v",e.version]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",e.author]})]})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:e.members.map((c,h)=>t.jsxs("span",{className:`px-2 py-0.5 text-[10px] rounded-full border ${c.role==="manager"?"bg-brand-500/10 text-brand-500 border-brand-500/15":"bg-blue-500/10 text-blue-600 border-blue-500/15"}`,children:[c.name??c.roleName??c.templateId,(c.count??1)>1?` x${c.count}`:""]},h))}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{children:[l," agent",l!==1?"s":""]}),o&&t.jsx("span",{className:"text-brand-500/60",children:"has manager"}),e.tags&&e.tags.length>0&&t.jsx("span",{className:"text-fg-tertiary",children:e.tags.slice(0,3).join(", ")})]})]})}function zj(e,n){const s=e.split(".").map(Number),l=n.split(".").map(Number);for(let o=0;o<Math.max(s.length,l.length);o++){const d=s[o]??0,c=l[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}const Ph={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",productivity:"bg-green-500/15 text-green-600",custom:"bg-gray-500/15 text-fg-secondary",browser:"bg-brand-500/15 text-brand-500",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500","AI 智能":"bg-brand-500/15 text-brand-500",开发工具:"bg-blue-500/15 text-blue-600",效率提升:"bg-green-500/15 text-green-600",数据分析:"bg-brand-500/15 text-brand-500",内容创作:"bg-brand-500/15 text-brand-500",安全合规:"bg-red-500/15 text-red-500",通讯协作:"bg-green-500/15 text-green-600"},OA=[{id:"installed",label:"Installed"},{id:"builtin",label:"Built-in"},{id:"skillhub",label:"SkillHub"},{id:"skillssh",label:"skills.sh"},{id:"markus-hub",label:"Markus Hub"}];function RA({item:e,installedSkills:n,onMsg:s,onRefresh:l}){const[o,d]=v.useState(!1),c=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",h=n.find(x=>x.name===e.name||x.name===c),m=!!h,f=m&&e.version&&h?.version&&zj(e.version,h.version),g=async()=>{if(!o){d(!0);try{const x=await Xn.download(e.id),p=x.name||e.name,y=p.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",w={type:"hub",hubItemId:e.id};if(x.files&&Object.keys(x.files).length>0)await re.builder.artifacts.import("skill",y,x.files,w);else{const N={...x.config,name:p,description:e.description,source:w};await re.builder.artifacts.save("skill",N)}await re.builder.artifacts.install("skill",y),s(f?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),l(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{s("Install failed","error")}finally{d(!1)}}};return f?t.jsx("button",{onClick:()=>{g()},disabled:o,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:o?"Upgrading...":`Upgrade → v${e.version}`}):m?t.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",h?.version?` (v${h.version})`:""]}):t.jsx("button",{onClick:()=>{g()},disabled:o,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:o?"Installing...":"Install"})}function $j(){const e=_s(),[n,s]=v.useState("installed"),[l,o]=v.useState(null),[d,c]=v.useState(new Set),[h,m]=v.useState([]),[f,g]=v.useState(!0),[x,p]=v.useState(""),[y,w]=v.useState([]),[N,C]=v.useState(0),[_,O]=v.useState(1),[k,S]=v.useState([]),[R,D]=v.useState(""),[Y,z]=v.useState("score"),[K,U]=v.useState(""),[G,V]=v.useState(!1),[E,T]=v.useState([]),[L,A]=v.useState(!1),[P,q]=v.useState([]),[W,B]=v.useState(""),[F,X]=v.useState(!1),[I,M]=v.useState([]),[H,Z]=v.useState(!1),[ee,ne]=v.useState(""),ae=(se,Te="success")=>{o({text:se,type:Te}),setTimeout(()=>o(null),Te==="error"?1e4:4e3)},he=v.useCallback(async()=>{g(!0);try{const se=await re.skills.list();m(se.skills)}catch{}g(!1)},[]),Ne=v.useCallback(async()=>{A(!0);try{const se=await re.skills.builtin();T(se.skills)}catch{}A(!1)},[]),Le=v.useCallback(async se=>{V(!0);try{const Te=await re.skills.registrySkillhub({q:se?.q,category:se?.category,page:se?.page??1,limit:24,sort:se?.sort??Y});w(Te.skills),C(Te.total),Te.categories?.length&&S(Te.categories)}catch{}V(!1)},[Y]),ye=v.useCallback(async se=>{X(!0);try{const Te=await re.skills.registrySkillssh(se);q(Te.skills)}catch{}X(!1)},[]),je=v.useCallback(async se=>{Z(!0);try{const nt=await(se?Xn.search({type:"skill",q:se,limit:50}):ll(Tr.hubSkills)??Xn.search({type:"skill",limit:50}));M(nt?.items??[])}catch{}Z(!1)},[]);v.useEffect(()=>{he(),Ne(),Le(),ye()},[]),v.useEffect(()=>{n==="markus-hub"&&je(ee)},[n,ee,je]);const Ae=async se=>{c(Te=>new Set(Te).add(se.name));try{const Te=await re.skills.install({name:se.name,source:"skillhub",slug:se.slug,sourceUrl:se.homepage,description:se.description_zh??se.description,category:"custom",version:se.version});await he(),ae(`"${se.name}" installed (${Te.method}) → ${Te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${se.name}". You can try manually from: ${se.homepage}`,"error")}c(Te=>{const nt=new Set(Te);return nt.delete(se.name),nt})},$e=async se=>{c(Te=>new Set(Te).add(se.name));try{const Te=await re.skills.install({name:se.name,source:"skillssh",sourceUrl:se.url,githubRepo:`${se.author}/${se.repo}`,githubSkillPath:se.name});await he(),ae(`"${se.name}" installed (${Te.method}) → ${Te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${se.name}". You can try manually from: ${se.url}`,"error")}c(Te=>{const nt=new Set(Te);return nt.delete(se.name),nt})},Xe=async se=>{c(Te=>new Set(Te).add(se.name));try{const Te=await re.skills.install({name:se.name,source:"builtin"});await he(),await Ne(),ae(`"${se.name}" installed (${Te.method}) → ${Te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Te){ae(`Install failed for "${se.name}": ${Te}`,"error")}c(Te=>{const nt=new Set(Te);return nt.delete(se.name),nt})},tt=async se=>{if(confirm(`Uninstall "${se}"? This will delete the skill files from ~/.markus/skills/.`))try{await re.skills.uninstall(se),await he(),ae(`"${se}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Te){ae(`Uninstall failed: ${Te}`,"error")}},et=h.filter(se=>{if(!x)return!0;const Te=x.toLowerCase();return se.name.toLowerCase().includes(Te)||se.description?.toLowerCase().includes(Te)}),_t=P.filter(se=>{if(!W)return!0;const Te=W.toLowerCase();return se.name.toLowerCase().includes(Te)||se.repo.toLowerCase().includes(Te)});return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:`${e?"px-4":"px-6"} border-b border-border-default bg-surface-secondary shrink-0`,children:[t.jsx("div",{className:"flex items-center h-14",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Skill Store"})}),t.jsx("div",{className:`flex ${e?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:OA.map(se=>t.jsx("button",{onClick:()=>s(se.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${n===se.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:se.label},se.id))})]}),l&&t.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${l.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:l.text}),n==="installed"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("input",{value:x,onChange:se=>p(se.target.value),placeholder:"Search installed skills...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),t.jsxs("span",{className:"text-xs text-fg-tertiary shrink-0",children:[et.length," skill",et.length!==1?"s":""]})]}),f?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:"Loading..."}):et.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◆"}),t.jsx("div",{children:"No installed skills found."}),t.jsx("div",{className:"text-xs mt-1",children:"Browse SkillHub or skills.sh to discover and install skills."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:et.map(se=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:se.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] shrink-0 ${se.type==="builtin"?"bg-blue-500/15 text-blue-600":se.type==="filesystem"?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:se.type==="builtin"?"built-in":se.type==="filesystem"?"local":"imported"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[se.author?`by ${se.author} · `:"",se.version?`v${se.version}`:"",se.sourcePath&&t.jsxs("span",{className:"ml-1 text-fg-tertiary",title:se.sourcePath,children:["📁 ",se.sourcePath.replace(/^.*\/\.([^/]+)\/skills\//,"~/.$1/skills/")]})]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Ph[se.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:se.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:se.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:se.tags?.slice(0,3).map(Te=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Te},Te))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[se.tools&&se.tools.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[se.tools.length," tool",se.tools.length!==1?"s":""]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Auto-discovered by agents"})]}),se.type!=="builtin"&&t.jsx("button",{onClick:()=>{tt(se.name)},className:"px-2 py-0.5 text-[10px] text-red-500 hover:text-red-500 hover:bg-red-500/10 rounded transition-colors",children:"Uninstall"})]})]},se.name))})]}),n==="builtin"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[E.length," built-in skill",E.length!==1?"s":""," available"]}),t.jsx("button",{onClick:()=>{Ne()},className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"Refresh"})]}),L?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading built-in skills..."})}):E.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),t.jsx("div",{children:"No built-in skills found."}),t.jsx("div",{className:"text-xs mt-1",children:"Built-in skills are provided in templates/skills/."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:E.map(se=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:se.name}),se.hasMcpServers&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] bg-blue-500/15 text-blue-600 shrink-0",children:"MCP"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[se.author?`by ${se.author} · `:"","v",se.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Ph[se.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:se.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:se.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:se.tags.slice(0,4).map(Te=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Te},Te))}),se.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:se.requiredPermissions.map(Te=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:Te},Te))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[se.installed&&se.installedVersion?t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",se.installedVersion]}):t.jsx("span",{}),se.installed&&se.installedVersion&&zj(se.version,se.installedVersion)?t.jsx("button",{onClick:()=>{Xe(se)},disabled:d.has(se.name),className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:d.has(se.name)?"Upgrading...":`Upgrade → v${se.version}`}):se.installed?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{Xe(se)},disabled:d.has(se.name),className:"px-2.5 py-1 text-[10px] bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:d.has(se.name)?"Installing...":"Install"})]})]},se.name))})]}),n==="skillhub"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsxs("select",{value:R,onChange:se=>{D(se.target.value),O(1),Le({q:K||void 0,category:se.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[t.jsx("option",{value:"",children:"全部分类"}),k.map(se=>t.jsx("option",{value:se,children:se},se))]}),t.jsxs("select",{value:Y,onChange:se=>{z(se.target.value),O(1),Le({q:K||void 0,category:R||void 0,page:1,sort:se.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[t.jsx("option",{value:"score",children:"综合排序"}),t.jsx("option",{value:"downloads",children:"下载量"}),t.jsx("option",{value:"stars",children:"收藏数"}),t.jsx("option",{value:"installs",children:"安装量"})]}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:t.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:"Visit site →"})})]}),t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("input",{value:K,onChange:se=>U(se.target.value),onKeyDown:se=>{se.key==="Enter"&&(O(1),Le({q:K||void 0,category:R||void 0,page:1}))},placeholder:"搜索 SkillHub 技能...",className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),t.jsx("button",{onClick:()=>{O(1),Le({q:K||void 0,category:R||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),G?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"正在加载 SkillHub 技能..."})}):y.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),t.jsx("div",{children:"未找到匹配的技能"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-3",children:["共 ",N.toLocaleString()," 个技能"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(se=>{const Te=h.some(nt=>nt.name===se.name||nt.name===se.slug);return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:se.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["v",se.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ml-2 ${se.tags?.[0]?Ph[se.tags[0]]??"bg-brand-500/15 text-brand-500":"bg-brand-500/15 text-brand-500"}`,children:se.tags?.[0]??"SkillHub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:se.description_zh??se.description??"No description"}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[se.stars>0&&t.jsxs("span",{className:"text-[10px] text-amber-600",children:["★ ",se.stars.toLocaleString()]}),se.downloads>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[se.downloads>=1e4?`${(se.downloads/1e4).toFixed(1)}万`:se.downloads.toLocaleString()," 下载"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:se.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Te?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{Ae(se)},disabled:d.has(se.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:d.has(se.name)?"...":"Install"})]})]})]},se.slug)})}),N>24&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[t.jsx("button",{disabled:_<=1,onClick:()=>{const se=_-1;O(se),Le({q:K||void 0,category:R||void 0,page:se})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"← 上一页"}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:["第 ",_," / ",Math.ceil(N/24)," 页"]}),t.jsx("button",{disabled:_>=Math.ceil(N/24),onClick:()=>{const se=_+1;O(se),Le({q:K||void 0,category:R||void 0,page:se})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"下一页 →"})]})]})]}),n==="skillssh"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:`flex ${e?"flex-wrap":""} items-center gap-2 mb-5`,children:[t.jsx("input",{value:W,onChange:se=>B(se.target.value),onKeyDown:se=>{se.key==="Enter"&&W.trim()&&ye(W)},placeholder:"Search skills.sh...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),t.jsx("button",{onClick:()=>{W.trim()&&ye(W)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:t.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:"Visit site →"})})]}),F?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Searching skills.sh..."})}):_t.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),t.jsx("div",{children:"Browse 84,000+ skills on skills.sh"}),t.jsx("div",{className:"text-xs mt-1",children:"Top skills are loaded automatically. Search for specific skills above."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:_t.map(se=>{const Te=h.some(nt=>nt.name===se.name);return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:se.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[se.author," / ",se.repo]})]}),t.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-gray-500/15 text-fg-secondary shrink-0 ml-2",children:"skills.sh"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:se.description||"No description"}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-3",children:se.installs&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[se.installs," installs"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:se.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Te?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{$e(se)},disabled:d.has(se.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:d.has(se.name)?"...":"Install"})]})]})]},`${se.author}-${se.name}`)})})]}),n==="markus-hub"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("input",{value:ee,onChange:se=>ne(se.target.value),placeholder:"Search Markus Hub skills...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:"Community skills from Markus Hub"})]}),H?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading from Hub..."})}):I.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3",children:"🏪"}),t.jsx("div",{children:"No skills found on Markus Hub"}),t.jsx("div",{className:"text-xs mt-1",children:"Hub may be offline or empty. Run the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:I.map(se=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:se.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",se.author?.displayName??se.author?.username]})]}),t.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-green-500/15 text-green-600 shrink-0 ml-2",children:"Hub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:se.description}),t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["★".repeat(Math.round(parseFloat(se.avgRating))),"☆".repeat(5-Math.round(parseFloat(se.avgRating))),t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",se.ratingCount,") · ↓ ",se.downloadCount]})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-end gap-2",children:t.jsx(RA,{item:se,installedSkills:h,onMsg:ae,onRefresh:()=>{he()}})})]},se.id))})]})]})}const DA=50,LA=30;function gx(e,n,s){const l=v.useRef(0),o=v.useRef(0),d=v.useCallback(h=>{l.current=h.touches[0].clientX,o.current=h.touches[0].clientY},[]),c=v.useCallback(h=>{const m=h.changedTouches[0].clientX-l.current,f=h.changedTouches[0].clientY-o.current,g=Math.abs(m),x=Math.abs(f);if(g<DA||Math.atan2(x,g)*(180/Math.PI)>LA)return;const y=e.findIndex(w=>w.id===n);m<0&&y<e.length-1?s(e[y+1].id):m>0&&y>0&&s(e[y-1].id)},[e,n,s]);return{onTouchStart:d,onTouchEnd:c}}const My=[{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function IA(){const e=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_storeTab"),e==="agents"||e==="teams"||e==="skills"?e:"agents"}function zA({authUser:e}){const[n,s]=v.useState(IA),l=gx(My,n,s);return v.useEffect(()=>{const o=d=>{if(d.detail.page==="store"){const h=localStorage.getItem("markus_nav_storeTab");h&&(localStorage.removeItem("markus_nav_storeTab"),(h==="agents"||h==="teams"||h==="skills")&&s(h))}};return window.addEventListener("markus:navigate",o),()=>window.removeEventListener("markus:navigate",o)},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:l.onTouchStart,onTouchEnd:l.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0",children:My.map(o=>t.jsx("button",{onClick:()=>s(o.id),className:`flex-1 min-w-0 px-4 py-3 text-sm font-medium text-center whitespace-nowrap transition-colors border-b-2 ${n===o.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:o.label},o.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx(Rj,{authUser:e}),n==="teams"&&t.jsx(Ij,{}),n==="skills"&&t.jsx($j,{})]})]})}function $A(e){const n=e.indexOf(".markus/builder-artifacts/");return n>=0?"~/"+e.slice(n):e}const Uh=[{roleId:"agent-father",roleName:"Agent Father",icon:"✦",color:"from-brand-500 to-purple-600",borderColor:"border-brand-500/30 hover:border-brand-400/50",bgColor:"bg-brand-500/10",desc:"AI Agent Architect",detail:"Design and create powerful AI agents through natural conversation. Describe the agent you need and Agent Father will configure it with the right role, skills, tools, and system prompt.",examples:["A senior full-stack developer who specializes in React and Node.js","A DevOps engineer for CI/CD pipeline management","A code reviewer who enforces best practices"]},{roleId:"team-factory",roleName:"Team Factory",icon:"◈",color:"from-blue-500 to-blue-600",borderColor:"border-blue-500/30 hover:border-blue-400/50",bgColor:"bg-blue-500/10",desc:"AI Team Composer",detail:"Compose optimal agent teams for any project. Describe your goal and Team Factory will design the lineup with the right mix of managers, developers, reviewers, and specialists.",examples:["A web development team with PM, developers, and QA","A content team for a tech blog","A data engineering squad"]},{roleId:"skill-architect",roleName:"Skill Architect",icon:"⬡",color:"from-green-500 to-green-600",borderColor:"border-green-500/30 hover:border-green-400/50",bgColor:"bg-green-500/10",desc:"AI Skill Designer",detail:"Create new agent skills and tool definitions. Describe the capability you want and Skill Architect will design the complete skill manifest with tools, schemas, and permissions.",examples:["A skill that analyzes Git repos and generates changelogs","A web scraping skill for extracting structured data","A database migration tool with rollback support"]}],Oy={agent:{icon:"✦",color:"text-brand-500",bg:"bg-brand-500/10"},team:{icon:"◈",color:"text-blue-600",bg:"bg-blue-500/10"},skill:{icon:"⬡",color:"text-green-600",bg:"bg-green-500/10"}};function Ry({message:e,onConfirm:n,onCancel:s}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:l=>l.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),t.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Confirm Delete"}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:e})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:s,className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:"Cancel"}),t.jsx("button",{onClick:n,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:"Delete"})]})]})})}function Bj(){const e=_s(),[n,s]=v.useState([]),[l,o]=v.useState([]),[d,c]=v.useState(!1),[h,m]=v.useState("all"),[f,g]=v.useState(null),[x,p]=v.useState(new Map),[y,w]=v.useState(null),[N,C]=v.useState(new Map),[_,O]=v.useState(null),[k,S]=v.useState(null);new Set(Uh.map(E=>E.roleName));const R=v.useCallback(()=>{c(!0),Promise.all([(ll(Tr.builderArtifacts)??re.builder.artifacts.list()).then(E=>E?.artifacts??[]).catch(()=>[]),(ll(Tr.builderAgents)??re.agents.list()).then(E=>E?.agents??[]).catch(()=>[]),(ll(Tr.builderHubMyItems)??Xn.myItems()).then(E=>E?.items??[]).catch(()=>[]),(ll(Tr.builderInstalled)??re.builder.artifacts.installed()).then(E=>E?.installed??{}).catch(()=>({}))]).then(([E,T,L,A])=>{if(o(E),s(T),L.length>0){const q=new Map;for(const W of L){const B=W.itemType==="agent"?"agent":W.itemType==="team"?"team":"skill";for(const F of E)F.type===B&&(W.slug===F.name||W.name===(F.meta.displayName||F.meta.name||F.name))&&q.set(`${F.type}/${F.name}`,{id:W.id,name:W.name,slug:W.slug||F.name})}q.size>0&&C(W=>{const B=new Map(W);for(const[F,X]of q)B.set(F,X);return B})}const P=new Map;for(const q of E){const W=`${q.type}/${q.name}`,B=A[W];B&&P.set(W,{agentId:B.agentId,agentIds:B.agentIds,teamId:B.teamId})}p(P)}).finally(()=>c(!1))},[]);v.useEffect(()=>{R();const E=T=>{T.detail?.page===ge.BUILDER&&R()};return window.addEventListener("markus:navigate",E),()=>window.removeEventListener("markus:navigate",E)},[R]);const D=(E,T)=>{const L=n.find(A=>A.role===T||A.name===T);L?gt.navigate(ge.TEAM,{agentId:L.id}):gt.navigate(ge.TEAM)},Y=async E=>{const T=`${E.type}/${E.name}`;if(!x.has(T)){g(T);try{const L=await re.builder.artifacts.install(E.type,E.name),A={};L.agent&&typeof L.agent=="object"&&(A.agentId=L.agent.id),L.team&&typeof L.team=="object"&&(A.teamId=L.team.id),Array.isArray(L.agents)&&(A.agentIds=L.agents.map(P=>P.id)),p(P=>new Map(P).set(T,A)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Install failed:",L),alert(`Install failed: ${L}`)}finally{g(null)}}},z=async E=>{const T=`${E.type}/${E.name}`;if(x.has(T)){g(T);try{await re.builder.artifacts.uninstall(E.type,E.name),p(L=>{const A=new Map(L);return A.delete(T),A}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Uninstall failed:",L),alert(`Uninstall failed: ${L}`)}finally{g(null)}}},K=async E=>{const T=`${E.type}/${E.name}`;if(!N.has(T)){g(T);try{const L=await re.builder.artifacts.get(E.type,E.name),A=E.meta.displayName||E.meta.name||E.name,P=E.meta.description||"",q=E.meta.category||"general",W=Array.isArray(E.meta.tags)?E.meta.tags:[],B=E.name,F=await Xn.publishViaProxy({itemType:E.type==="team"?"team":E.type==="skill"?"skill":"agent",name:A,slug:B,description:P,category:q,tags:W,config:E.meta,files:L.files&&Object.keys(L.files).length>0?L.files:void 0});F.id&&C(X=>{const I=new Map(X);return I.set(T,{id:F.id,name:A,slug:F.slug??B}),I})}catch(L){console.error("Share failed:",L),alert(`Share failed: ${L}`)}finally{g(null)}}},U=async()=>{if(!_)return;const{key:E}=_,T=N.get(E);if(O(null),!T)return;const L=T.id;g(E);try{await Xn.deleteItem(L),C(A=>{const P=new Map(A);return P.delete(E),P})}catch(A){console.error("Hub delete failed:",A),alert(`Failed to remove from Hub: ${A}`)}finally{g(null)}},G=async()=>{if(!y)return;const E=y,T=`${E.type}/${E.name}`;w(null),g(T);try{await re.builder.artifacts.delete(E.type,E.name),o(L=>L.filter(A=>!(A.type===E.type&&A.name===E.name))),p(L=>{const A=new Map(L);return A.delete(T),A}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Delete failed:",L)}finally{g(null)}},V=h==="all"?l:l.filter(E=>E.type===h);return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:`max-w-4xl ${e?"px-4 py-5":"px-6 py-10"}`,children:[t.jsxs("div",{className:"mb-10",children:[t.jsx("h1",{className:"text-2xl font-bold text-fg-primary",children:"Builder"}),t.jsx("p",{className:"text-sm text-fg-tertiary mt-2",children:"Create agents, teams, and skills through AI-powered conversations. Choose a builder to get started."})]}),t.jsx("div",{className:"grid gap-5",children:Uh.map(E=>t.jsx("button",{onClick:()=>D(E.roleId,E.roleName),className:`group text-left w-full rounded-xl border ${E.borderColor} bg-surface-secondary/60 ${e?"p-4":"p-6"} transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:t.jsxs("div",{className:`flex items-start ${e?"gap-3":"gap-5"}`,children:[t.jsx("div",{className:`${e?"w-10 h-10 text-xl":"w-14 h-14 text-2xl"} rounded-xl ${E.bgColor} flex items-center justify-center shrink-0`,children:E.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("h3",{className:`${e?"text-base":"text-lg"} font-semibold bg-gradient-to-r ${E.color} bg-clip-text text-transparent`,children:E.roleName}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:E.desc}),n.find(T=>T.role===E.roleName||T.name===E.roleName)&&t.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0",title:"Agent online"})]}),t.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:E.detail}),t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:E.examples.map((T,L)=>t.jsxs("span",{className:"text-[11px] text-fg-tertiary bg-surface-elevated/60 rounded-full px-3 py-1 border border-border-default",children:["“",T,"”"]},L))})]}),t.jsx("svg",{className:"w-5 h-5 text-fg-muted group-hover:text-fg-secondary transition-colors shrink-0 mt-1",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})]})},E.roleId))}),n.length>0&&!n.some(E=>Uh.some(T=>E.role===T.roleName||E.name===T.roleName))&&t.jsx("div",{className:"mt-8 p-4 rounded-lg border border-amber-500/30 bg-amber-500/10 text-amber-600 text-xs",children:"Builder agents have not been created yet. They will be automatically seeded on next server restart."}),t.jsxs("div",{className:"mt-14 mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary",children:"My Creations"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Saved builder artifacts — install to deploy, or share to Markus Hub."})]}),t.jsx("button",{onClick:R,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:"Refresh"})]}),t.jsx("div",{className:"flex gap-2 mt-4",children:["all","agent","team","skill"].map(E=>t.jsx("button",{onClick:()=>m(E),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${h===E?"border-gray-600 bg-surface-elevated text-fg-primary":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:E==="all"?"All":E.charAt(0).toUpperCase()+E.slice(1)+"s"},E))})]}),d&&l.length===0?t.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:"Loading artifacts..."}):V.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("div",{className:"text-fg-tertiary text-sm",children:"No artifacts found."}),t.jsx("div",{className:"text-fg-muted text-xs mt-1",children:"Use a builder above to create agents, teams, or skills."})]}):t.jsx("div",{className:"grid gap-3",children:V.map(E=>{const T=Oy[E.type]??Oy.agent,L=E.meta.displayName||E.meta.name||E.name,A=E.meta.description||"",P=`${E.type}/${E.name}`,q=f===P,W=t.jsxs("div",{className:`flex items-center gap-1.5 ${e?"flex-wrap":"shrink-0"}`,children:[x.has(P)?t.jsx("button",{onClick:()=>z(E),disabled:q,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:bg-red-500/10 hover:text-red-500 hover:border-red-500/30 transition-colors disabled:opacity-50",children:q?"Uninstalling...":"Uninstall"}):t.jsx("button",{onClick:()=>Y(E),disabled:q,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:q?"Installing...":"Install"}),N.has(P)?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>O({key:P,name:E.meta.displayName||E.meta.name||E.name}),disabled:q,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:text-red-500 hover:border-red-500/30 hover:bg-red-500/10 transition-colors disabled:opacity-50",title:"Remove from Markus Hub",children:"Shared"}),t.jsx("button",{onClick:()=>{const B=N.get(P),F=Xn.getUser();if(!B||!F)return;const X=`${Xn.getUrl()}/${encodeURIComponent(F.username)}/${encodeURIComponent(B.slug)}`;navigator.clipboard.writeText(X).then(()=>{S(P),setTimeout(()=>S(I=>I===P?null:I),2e3)}).catch(()=>{})},className:"text-xs px-2 py-1.5 rounded-lg border border-green-600/20 text-green-500 hover:text-green-600 hover:border-green-500/40 transition-colors",title:"Copy Hub link",children:k===P?t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),t.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})]}):t.jsx("button",{onClick:()=>K(E),disabled:q,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50",children:q?"Sharing...":"Share"}),t.jsx("button",{onClick:()=>w(E),disabled:q,className:"text-xs px-2 py-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",title:"Delete",children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]});return t.jsxs("div",{className:"group rounded-lg border border-border-default bg-surface-secondary/60 p-4 hover:border-gray-600 transition-all overflow-hidden",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("div",{className:`w-9 h-9 rounded-lg ${T.bg} flex items-center justify-center text-lg shrink-0`,children:T.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:L}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${T.color}`,children:E.type})]}),A&&t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2",children:A}),t.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-fg-tertiary min-w-0",children:[t.jsx("button",{onClick:B=>{B.stopPropagation(),re.system.openPath(E.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:E.path,children:$A(E.path)}),t.jsx("span",{className:"shrink-0",children:new Date(E.updatedAt).toLocaleDateString()})]})]}),!e&&W]}),e&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-default/50",children:W})]},P)})}),y&&t.jsx(Ry,{message:`Delete "${y.meta.displayName||y.meta.name||y.name}"? This cannot be undone.`,onConfirm:G,onCancel:()=>w(null)}),_&&t.jsx(Ry,{message:`Remove "${_.name}" from Markus Hub? It will no longer be available for others to download.`,onConfirm:()=>{U()},onCancel:()=>O(null)})]})})}function Zn(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let s=0,l;s<e.length;s++)(l=Zn(e[s]))!==""&&(n+=(n&&" ")+l);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}var BA={value:()=>{}};function nu(){for(var e=0,n=arguments.length,s={},l;e<n;++e){if(!(l=arguments[e]+"")||l in s||/[\s.]/.test(l))throw new Error("illegal type: "+l);s[l]=[]}return new jd(s)}function jd(e){this._=e}function HA(e,n){return e.trim().split(/^|\s+/).map(function(s){var l="",o=s.indexOf(".");if(o>=0&&(l=s.slice(o+1),s=s.slice(0,o)),s&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:l}})}jd.prototype=nu.prototype={constructor:jd,on:function(e,n){var s=this._,l=HA(e+"",s),o,d=-1,c=l.length;if(arguments.length<2){for(;++d<c;)if((o=(e=l[d]).type)&&(o=PA(s[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++d<c;)if(o=(e=l[d]).type)s[o]=Dy(s[o],e.name,n);else if(n==null)for(o in s)s[o]=Dy(s[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var s in n)e[s]=n[s].slice();return new jd(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var s=new Array(o),l=0,o,d;l<o;++l)s[l]=arguments[l+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(d=this._[e],l=0,o=d.length;l<o;++l)d[l].value.apply(n,s)},apply:function(e,n,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var l=this._[e],o=0,d=l.length;o<d;++o)l[o].value.apply(n,s)}};function PA(e,n){for(var s=0,l=e.length,o;s<l;++s)if((o=e[s]).name===n)return o.value}function Dy(e,n,s){for(var l=0,o=e.length;l<o;++l)if(e[l].name===n){e[l]=BA,e=e.slice(0,l).concat(e.slice(l+1));break}return s!=null&&e.push({name:n,value:s}),e}var Em="http://www.w3.org/1999/xhtml";const Ly={svg:"http://www.w3.org/2000/svg",xhtml:Em,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ru(e){var n=e+="",s=n.indexOf(":");return s>=0&&(n=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),Ly.hasOwnProperty(n)?{space:Ly[n],local:e}:e}function UA(e){return function(){var n=this.ownerDocument,s=this.namespaceURI;return s===Em&&n.documentElement.namespaceURI===Em?n.createElement(e):n.createElementNS(s,e)}}function qA(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hj(e){var n=ru(e);return(n.local?qA:UA)(n)}function VA(){}function px(e){return e==null?VA:function(){return this.querySelector(e)}}function FA(e){typeof e!="function"&&(e=px(e));for(var n=this._groups,s=n.length,l=new Array(s),o=0;o<s;++o)for(var d=n[o],c=d.length,h=l[o]=new Array(c),m,f,g=0;g<c;++g)(m=d[g])&&(f=e.call(m,m.__data__,g,d))&&("__data__"in m&&(f.__data__=m.__data__),h[g]=f);return new Ur(l,this._parents)}function YA(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function GA(){return[]}function Pj(e){return e==null?GA:function(){return this.querySelectorAll(e)}}function XA(e){return function(){return YA(e.apply(this,arguments))}}function KA(e){typeof e=="function"?e=XA(e):e=Pj(e);for(var n=this._groups,s=n.length,l=[],o=[],d=0;d<s;++d)for(var c=n[d],h=c.length,m,f=0;f<h;++f)(m=c[f])&&(l.push(e.call(m,m.__data__,f,c)),o.push(m));return new Ur(l,o)}function Uj(e){return function(){return this.matches(e)}}function qj(e){return function(n){return n.matches(e)}}var ZA=Array.prototype.find;function WA(e){return function(){return ZA.call(this.children,e)}}function QA(){return this.firstElementChild}function JA(e){return this.select(e==null?QA:WA(typeof e=="function"?e:qj(e)))}var e_=Array.prototype.filter;function t_(){return Array.from(this.children)}function n_(e){return function(){return e_.call(this.children,e)}}function r_(e){return this.selectAll(e==null?t_:n_(typeof e=="function"?e:qj(e)))}function s_(e){typeof e!="function"&&(e=Uj(e));for(var n=this._groups,s=n.length,l=new Array(s),o=0;o<s;++o)for(var d=n[o],c=d.length,h=l[o]=[],m,f=0;f<c;++f)(m=d[f])&&e.call(m,m.__data__,f,d)&&h.push(m);return new Ur(l,this._parents)}function Vj(e){return new Array(e.length)}function a_(){return new Ur(this._enter||this._groups.map(Vj),this._parents)}function zd(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}zd.prototype={constructor:zd,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function l_(e){return function(){return e}}function i_(e,n,s,l,o,d){for(var c=0,h,m=n.length,f=d.length;c<f;++c)(h=n[c])?(h.__data__=d[c],l[c]=h):s[c]=new zd(e,d[c]);for(;c<m;++c)(h=n[c])&&(o[c]=h)}function o_(e,n,s,l,o,d,c){var h,m,f=new Map,g=n.length,x=d.length,p=new Array(g),y;for(h=0;h<g;++h)(m=n[h])&&(p[h]=y=c.call(m,m.__data__,h,n)+"",f.has(y)?o[h]=m:f.set(y,m));for(h=0;h<x;++h)y=c.call(e,d[h],h,d)+"",(m=f.get(y))?(l[h]=m,m.__data__=d[h],f.delete(y)):s[h]=new zd(e,d[h]);for(h=0;h<g;++h)(m=n[h])&&f.get(p[h])===m&&(o[h]=m)}function c_(e){return e.__data__}function d_(e,n){if(!arguments.length)return Array.from(this,c_);var s=n?o_:i_,l=this._parents,o=this._groups;typeof e!="function"&&(e=l_(e));for(var d=o.length,c=new Array(d),h=new Array(d),m=new Array(d),f=0;f<d;++f){var g=l[f],x=o[f],p=x.length,y=u_(e.call(g,g&&g.__data__,f,l)),w=y.length,N=h[f]=new Array(w),C=c[f]=new Array(w),_=m[f]=new Array(p);s(g,x,N,C,_,y,n);for(var O=0,k=0,S,R;O<w;++O)if(S=N[O]){for(O>=k&&(k=O+1);!(R=C[k])&&++k<w;);S._next=R||null}}return c=new Ur(c,l),c._enter=h,c._exit=m,c}function u_(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function f_(){return new Ur(this._exit||this._groups.map(Vj),this._parents)}function h_(e,n,s){var l=this.enter(),o=this,d=this.exit();return typeof e=="function"?(l=e(l),l&&(l=l.selection())):l=l.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),s==null?d.remove():s(d),l&&o?l.merge(o).order():o}function m_(e){for(var n=e.selection?e.selection():e,s=this._groups,l=n._groups,o=s.length,d=l.length,c=Math.min(o,d),h=new Array(o),m=0;m<c;++m)for(var f=s[m],g=l[m],x=f.length,p=h[m]=new Array(x),y,w=0;w<x;++w)(y=f[w]||g[w])&&(p[w]=y);for(;m<o;++m)h[m]=s[m];return new Ur(h,this._parents)}function x_(){for(var e=this._groups,n=-1,s=e.length;++n<s;)for(var l=e[n],o=l.length-1,d=l[o],c;--o>=0;)(c=l[o])&&(d&&c.compareDocumentPosition(d)^4&&d.parentNode.insertBefore(c,d),d=c);return this}function g_(e){e||(e=p_);function n(x,p){return x&&p?e(x.__data__,p.__data__):!x-!p}for(var s=this._groups,l=s.length,o=new Array(l),d=0;d<l;++d){for(var c=s[d],h=c.length,m=o[d]=new Array(h),f,g=0;g<h;++g)(f=c[g])&&(m[g]=f);m.sort(n)}return new Ur(o,this._parents).order()}function p_(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function b_(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function y_(){return Array.from(this)}function v_(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var l=e[n],o=0,d=l.length;o<d;++o){var c=l[o];if(c)return c}return null}function j_(){let e=0;for(const n of this)++e;return e}function w_(){return!this.node()}function N_(e){for(var n=this._groups,s=0,l=n.length;s<l;++s)for(var o=n[s],d=0,c=o.length,h;d<c;++d)(h=o[d])&&e.call(h,h.__data__,d,o);return this}function k_(e){return function(){this.removeAttribute(e)}}function S_(e){return function(){this.removeAttributeNS(e.space,e.local)}}function C_(e,n){return function(){this.setAttribute(e,n)}}function E_(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function T_(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function A_(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,s)}}function __(e,n){var s=ru(e);if(arguments.length<2){var l=this.node();return s.local?l.getAttributeNS(s.space,s.local):l.getAttribute(s)}return this.each((n==null?s.local?S_:k_:typeof n=="function"?s.local?A_:T_:s.local?E_:C_)(s,n))}function Fj(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function M_(e){return function(){this.style.removeProperty(e)}}function O_(e,n,s){return function(){this.style.setProperty(e,n,s)}}function R_(e,n,s){return function(){var l=n.apply(this,arguments);l==null?this.style.removeProperty(e):this.style.setProperty(e,l,s)}}function D_(e,n,s){return arguments.length>1?this.each((n==null?M_:typeof n=="function"?R_:O_)(e,n,s??"")):ii(this.node(),e)}function ii(e,n){return e.style.getPropertyValue(n)||Fj(e).getComputedStyle(e,null).getPropertyValue(n)}function L_(e){return function(){delete this[e]}}function I_(e,n){return function(){this[e]=n}}function z_(e,n){return function(){var s=n.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function $_(e,n){return arguments.length>1?this.each((n==null?L_:typeof n=="function"?z_:I_)(e,n)):this.node()[e]}function Yj(e){return e.trim().split(/^|\s+/)}function bx(e){return e.classList||new Gj(e)}function Gj(e){this._node=e,this._names=Yj(e.getAttribute("class")||"")}Gj.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Xj(e,n){for(var s=bx(e),l=-1,o=n.length;++l<o;)s.add(n[l])}function Kj(e,n){for(var s=bx(e),l=-1,o=n.length;++l<o;)s.remove(n[l])}function B_(e){return function(){Xj(this,e)}}function H_(e){return function(){Kj(this,e)}}function P_(e,n){return function(){(n.apply(this,arguments)?Xj:Kj)(this,e)}}function U_(e,n){var s=Yj(e+"");if(arguments.length<2){for(var l=bx(this.node()),o=-1,d=s.length;++o<d;)if(!l.contains(s[o]))return!1;return!0}return this.each((typeof n=="function"?P_:n?B_:H_)(s,n))}function q_(){this.textContent=""}function V_(e){return function(){this.textContent=e}}function F_(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function Y_(e){return arguments.length?this.each(e==null?q_:(typeof e=="function"?F_:V_)(e)):this.node().textContent}function G_(){this.innerHTML=""}function X_(e){return function(){this.innerHTML=e}}function K_(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function Z_(e){return arguments.length?this.each(e==null?G_:(typeof e=="function"?K_:X_)(e)):this.node().innerHTML}function W_(){this.nextSibling&&this.parentNode.appendChild(this)}function Q_(){return this.each(W_)}function J_(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function eM(){return this.each(J_)}function tM(e){var n=typeof e=="function"?e:Hj(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function nM(){return null}function rM(e,n){var s=typeof e=="function"?e:Hj(e),l=n==null?nM:typeof n=="function"?n:px(n);return this.select(function(){return this.insertBefore(s.apply(this,arguments),l.apply(this,arguments)||null)})}function sM(){var e=this.parentNode;e&&e.removeChild(this)}function aM(){return this.each(sM)}function lM(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function iM(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function oM(e){return this.select(e?iM:lM)}function cM(e){return arguments.length?this.property("__data__",e):this.node().__data__}function dM(e){return function(n){e.call(this,n,this.__data__)}}function uM(e){return e.trim().split(/^|\s+/).map(function(n){var s="",l=n.indexOf(".");return l>=0&&(s=n.slice(l+1),n=n.slice(0,l)),{type:n,name:s}})}function fM(e){return function(){var n=this.__on;if(n){for(var s=0,l=-1,o=n.length,d;s<o;++s)d=n[s],(!e.type||d.type===e.type)&&d.name===e.name?this.removeEventListener(d.type,d.listener,d.options):n[++l]=d;++l?n.length=l:delete this.__on}}}function hM(e,n,s){return function(){var l=this.__on,o,d=dM(n);if(l){for(var c=0,h=l.length;c<h;++c)if((o=l[c]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=d,o.options=s),o.value=n;return}}this.addEventListener(e.type,d,s),o={type:e.type,name:e.name,value:n,listener:d,options:s},l?l.push(o):this.__on=[o]}}function mM(e,n,s){var l=uM(e+""),o,d=l.length,c;if(arguments.length<2){var h=this.node().__on;if(h){for(var m=0,f=h.length,g;m<f;++m)for(o=0,g=h[m];o<d;++o)if((c=l[o]).type===g.type&&c.name===g.name)return g.value}return}for(h=n?hM:fM,o=0;o<d;++o)this.each(h(l[o],n,s));return this}function Zj(e,n,s){var l=Fj(e),o=l.CustomEvent;typeof o=="function"?o=new o(n,s):(o=l.document.createEvent("Event"),s?(o.initEvent(n,s.bubbles,s.cancelable),o.detail=s.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function xM(e,n){return function(){return Zj(this,e,n)}}function gM(e,n){return function(){return Zj(this,e,n.apply(this,arguments))}}function pM(e,n){return this.each((typeof n=="function"?gM:xM)(e,n))}function*bM(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var l=e[n],o=0,d=l.length,c;o<d;++o)(c=l[o])&&(yield c)}var Wj=[null];function Ur(e,n){this._groups=e,this._parents=n}function Fo(){return new Ur([[document.documentElement]],Wj)}function yM(){return this}Ur.prototype=Fo.prototype={constructor:Ur,select:FA,selectAll:KA,selectChild:JA,selectChildren:r_,filter:s_,data:d_,enter:a_,exit:f_,join:h_,merge:m_,selection:yM,order:x_,sort:g_,call:b_,nodes:y_,node:v_,size:j_,empty:w_,each:N_,attr:__,style:D_,property:$_,classed:U_,text:Y_,html:Z_,raise:Q_,lower:eM,append:tM,insert:rM,remove:aM,clone:oM,datum:cM,on:mM,dispatch:pM,[Symbol.iterator]:bM};function Hr(e){return typeof e=="string"?new Ur([[document.querySelector(e)]],[document.documentElement]):new Ur([[e]],Wj)}function vM(e){let n;for(;n=e.sourceEvent;)e=n;return e}function cs(e,n){if(e=vM(e),n===void 0&&(n=e.currentTarget),n){var s=n.ownerSVGElement||n;if(s.createSVGPoint){var l=s.createSVGPoint();return l.x=e.clientX,l.y=e.clientY,l=l.matrixTransform(n.getScreenCTM().inverse()),[l.x,l.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const jM={passive:!1},_o={capture:!0,passive:!1};function qh(e){e.stopImmediatePropagation()}function si(e){e.preventDefault(),e.stopImmediatePropagation()}function Qj(e){var n=e.document.documentElement,s=Hr(e).on("dragstart.drag",si,_o);"onselectstart"in n?s.on("selectstart.drag",si,_o):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Jj(e,n){var s=e.document.documentElement,l=Hr(e).on("dragstart.drag",null);n&&(l.on("click.drag",si,_o),setTimeout(function(){l.on("click.drag",null)},0)),"onselectstart"in s?l.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const cd=e=>()=>e;function Tm(e,{sourceEvent:n,subject:s,target:l,identifier:o,active:d,x:c,y:h,dx:m,dy:f,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:d,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:m,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:g}})}Tm.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function wM(e){return!e.ctrlKey&&!e.button}function NM(){return this.parentNode}function kM(e,n){return n??{x:e.x,y:e.y}}function SM(){return navigator.maxTouchPoints||"ontouchstart"in this}function ew(){var e=wM,n=NM,s=kM,l=SM,o={},d=nu("start","drag","end"),c=0,h,m,f,g,x=0;function p(S){S.on("mousedown.drag",y).filter(l).on("touchstart.drag",C).on("touchmove.drag",_,jM).on("touchend.drag touchcancel.drag",O).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(S,R){if(!(g||!e.call(this,S,R))){var D=k(this,n.call(this,S,R),S,R,"mouse");D&&(Hr(S.view).on("mousemove.drag",w,_o).on("mouseup.drag",N,_o),Qj(S.view),qh(S),f=!1,h=S.clientX,m=S.clientY,D("start",S))}}function w(S){if(si(S),!f){var R=S.clientX-h,D=S.clientY-m;f=R*R+D*D>x}o.mouse("drag",S)}function N(S){Hr(S.view).on("mousemove.drag mouseup.drag",null),Jj(S.view,f),si(S),o.mouse("end",S)}function C(S,R){if(e.call(this,S,R)){var D=S.changedTouches,Y=n.call(this,S,R),z=D.length,K,U;for(K=0;K<z;++K)(U=k(this,Y,S,R,D[K].identifier,D[K]))&&(qh(S),U("start",S,D[K]))}}function _(S){var R=S.changedTouches,D=R.length,Y,z;for(Y=0;Y<D;++Y)(z=o[R[Y].identifier])&&(si(S),z("drag",S,R[Y]))}function O(S){var R=S.changedTouches,D=R.length,Y,z;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),Y=0;Y<D;++Y)(z=o[R[Y].identifier])&&(qh(S),z("end",S,R[Y]))}function k(S,R,D,Y,z,K){var U=d.copy(),G=cs(K||D,R),V,E,T;if((T=s.call(S,new Tm("beforestart",{sourceEvent:D,target:p,identifier:z,active:c,x:G[0],y:G[1],dx:0,dy:0,dispatch:U}),Y))!=null)return V=T.x-G[0]||0,E=T.y-G[1]||0,function L(A,P,q){var W=G,B;switch(A){case"start":o[z]=L,B=c++;break;case"end":delete o[z],--c;case"drag":G=cs(q||P,R),B=c;break}U.call(A,S,new Tm(A,{sourceEvent:P,subject:T,target:p,identifier:z,active:B,x:G[0]+V,y:G[1]+E,dx:G[0]-W[0],dy:G[1]-W[1],dispatch:U}),Y)}}return p.filter=function(S){return arguments.length?(e=typeof S=="function"?S:cd(!!S),p):e},p.container=function(S){return arguments.length?(n=typeof S=="function"?S:cd(S),p):n},p.subject=function(S){return arguments.length?(s=typeof S=="function"?S:cd(S),p):s},p.touchable=function(S){return arguments.length?(l=typeof S=="function"?S:cd(!!S),p):l},p.on=function(){var S=d.on.apply(d,arguments);return S===d?p:S},p.clickDistance=function(S){return arguments.length?(x=(S=+S)*S,p):Math.sqrt(x)},p}function yx(e,n,s){e.prototype=n.prototype=s,s.constructor=e}function tw(e,n){var s=Object.create(e.prototype);for(var l in n)s[l]=n[l];return s}function Yo(){}var Mo=.7,$d=1/Mo,ai="\\s*([+-]?\\d+)\\s*",Oo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Es="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",CM=/^#([0-9a-f]{3,8})$/,EM=new RegExp(`^rgb\\(${ai},${ai},${ai}\\)$`),TM=new RegExp(`^rgb\\(${Es},${Es},${Es}\\)$`),AM=new RegExp(`^rgba\\(${ai},${ai},${ai},${Oo}\\)$`),_M=new RegExp(`^rgba\\(${Es},${Es},${Es},${Oo}\\)$`),MM=new RegExp(`^hsl\\(${Oo},${Es},${Es}\\)$`),OM=new RegExp(`^hsla\\(${Oo},${Es},${Es},${Oo}\\)$`),Iy={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};yx(Yo,fl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:zy,formatHex:zy,formatHex8:RM,formatHsl:DM,formatRgb:$y,toString:$y});function zy(){return this.rgb().formatHex()}function RM(){return this.rgb().formatHex8()}function DM(){return nw(this).formatHsl()}function $y(){return this.rgb().formatRgb()}function fl(e){var n,s;return e=(e+"").trim().toLowerCase(),(n=CM.exec(e))?(s=n[1].length,n=parseInt(n[1],16),s===6?By(n):s===3?new Ar(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):s===8?dd(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):s===4?dd(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=EM.exec(e))?new Ar(n[1],n[2],n[3],1):(n=TM.exec(e))?new Ar(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=AM.exec(e))?dd(n[1],n[2],n[3],n[4]):(n=_M.exec(e))?dd(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=MM.exec(e))?Uy(n[1],n[2]/100,n[3]/100,1):(n=OM.exec(e))?Uy(n[1],n[2]/100,n[3]/100,n[4]):Iy.hasOwnProperty(e)?By(Iy[e]):e==="transparent"?new Ar(NaN,NaN,NaN,0):null}function By(e){return new Ar(e>>16&255,e>>8&255,e&255,1)}function dd(e,n,s,l){return l<=0&&(e=n=s=NaN),new Ar(e,n,s,l)}function LM(e){return e instanceof Yo||(e=fl(e)),e?(e=e.rgb(),new Ar(e.r,e.g,e.b,e.opacity)):new Ar}function Am(e,n,s,l){return arguments.length===1?LM(e):new Ar(e,n,s,l??1)}function Ar(e,n,s,l){this.r=+e,this.g=+n,this.b=+s,this.opacity=+l}yx(Ar,Am,tw(Yo,{brighter(e){return e=e==null?$d:Math.pow($d,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Mo:Math.pow(Mo,e),new Ar(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ar(ol(this.r),ol(this.g),ol(this.b),Bd(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hy,formatHex:Hy,formatHex8:IM,formatRgb:Py,toString:Py}));function Hy(){return`#${il(this.r)}${il(this.g)}${il(this.b)}`}function IM(){return`#${il(this.r)}${il(this.g)}${il(this.b)}${il((isNaN(this.opacity)?1:this.opacity)*255)}`}function Py(){const e=Bd(this.opacity);return`${e===1?"rgb(":"rgba("}${ol(this.r)}, ${ol(this.g)}, ${ol(this.b)}${e===1?")":`, ${e})`}`}function Bd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ol(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function il(e){return e=ol(e),(e<16?"0":"")+e.toString(16)}function Uy(e,n,s,l){return l<=0?e=n=s=NaN:s<=0||s>=1?e=n=NaN:n<=0&&(e=NaN),new ds(e,n,s,l)}function nw(e){if(e instanceof ds)return new ds(e.h,e.s,e.l,e.opacity);if(e instanceof Yo||(e=fl(e)),!e)return new ds;if(e instanceof ds)return e;e=e.rgb();var n=e.r/255,s=e.g/255,l=e.b/255,o=Math.min(n,s,l),d=Math.max(n,s,l),c=NaN,h=d-o,m=(d+o)/2;return h?(n===d?c=(s-l)/h+(s<l)*6:s===d?c=(l-n)/h+2:c=(n-s)/h+4,h/=m<.5?d+o:2-d-o,c*=60):h=m>0&&m<1?0:c,new ds(c,h,m,e.opacity)}function zM(e,n,s,l){return arguments.length===1?nw(e):new ds(e,n,s,l??1)}function ds(e,n,s,l){this.h=+e,this.s=+n,this.l=+s,this.opacity=+l}yx(ds,zM,tw(Yo,{brighter(e){return e=e==null?$d:Math.pow($d,e),new ds(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Mo:Math.pow(Mo,e),new ds(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,l=s+(s<.5?s:1-s)*n,o=2*s-l;return new Ar(Vh(e>=240?e-240:e+120,o,l),Vh(e,o,l),Vh(e<120?e+240:e-120,o,l),this.opacity)},clamp(){return new ds(qy(this.h),ud(this.s),ud(this.l),Bd(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Bd(this.opacity);return`${e===1?"hsl(":"hsla("}${qy(this.h)}, ${ud(this.s)*100}%, ${ud(this.l)*100}%${e===1?")":`, ${e})`}`}}));function qy(e){return e=(e||0)%360,e<0?e+360:e}function ud(e){return Math.max(0,Math.min(1,e||0))}function Vh(e,n,s){return(e<60?n+(s-n)*e/60:e<180?s:e<240?n+(s-n)*(240-e)/60:n)*255}const vx=e=>()=>e;function $M(e,n){return function(s){return e+s*n}}function BM(e,n,s){return e=Math.pow(e,s),n=Math.pow(n,s)-e,s=1/s,function(l){return Math.pow(e+l*n,s)}}function HM(e){return(e=+e)==1?rw:function(n,s){return s-n?BM(n,s,e):vx(isNaN(n)?s:n)}}function rw(e,n){var s=n-e;return s?$M(e,s):vx(isNaN(e)?n:e)}const Hd=(function e(n){var s=HM(n);function l(o,d){var c=s((o=Am(o)).r,(d=Am(d)).r),h=s(o.g,d.g),m=s(o.b,d.b),f=rw(o.opacity,d.opacity);return function(g){return o.r=c(g),o.g=h(g),o.b=m(g),o.opacity=f(g),o+""}}return l.gamma=e,l})(1);function PM(e,n){n||(n=[]);var s=e?Math.min(n.length,e.length):0,l=n.slice(),o;return function(d){for(o=0;o<s;++o)l[o]=e[o]*(1-d)+n[o]*d;return l}}function UM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function qM(e,n){var s=n?n.length:0,l=e?Math.min(s,e.length):0,o=new Array(l),d=new Array(s),c;for(c=0;c<l;++c)o[c]=ko(e[c],n[c]);for(;c<s;++c)d[c]=n[c];return function(h){for(c=0;c<l;++c)d[c]=o[c](h);return d}}function VM(e,n){var s=new Date;return e=+e,n=+n,function(l){return s.setTime(e*(1-l)+n*l),s}}function Cs(e,n){return e=+e,n=+n,function(s){return e*(1-s)+n*s}}function FM(e,n){var s={},l={},o;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(o in n)o in e?s[o]=ko(e[o],n[o]):l[o]=n[o];return function(d){for(o in s)l[o]=s[o](d);return l}}var _m=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fh=new RegExp(_m.source,"g");function YM(e){return function(){return e}}function GM(e){return function(n){return e(n)+""}}function sw(e,n){var s=_m.lastIndex=Fh.lastIndex=0,l,o,d,c=-1,h=[],m=[];for(e=e+"",n=n+"";(l=_m.exec(e))&&(o=Fh.exec(n));)(d=o.index)>s&&(d=n.slice(s,d),h[c]?h[c]+=d:h[++c]=d),(l=l[0])===(o=o[0])?h[c]?h[c]+=o:h[++c]=o:(h[++c]=null,m.push({i:c,x:Cs(l,o)})),s=Fh.lastIndex;return s<n.length&&(d=n.slice(s),h[c]?h[c]+=d:h[++c]=d),h.length<2?m[0]?GM(m[0].x):YM(n):(n=m.length,function(f){for(var g=0,x;g<n;++g)h[(x=m[g]).i]=x.x(f);return h.join("")})}function ko(e,n){var s=typeof n,l;return n==null||s==="boolean"?vx(n):(s==="number"?Cs:s==="string"?(l=fl(n))?(n=l,Hd):sw:n instanceof fl?Hd:n instanceof Date?VM:UM(n)?PM:Array.isArray(n)?qM:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?FM:Cs)(e,n)}var Vy=180/Math.PI,Mm={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function aw(e,n,s,l,o,d){var c,h,m;return(c=Math.sqrt(e*e+n*n))&&(e/=c,n/=c),(m=e*s+n*l)&&(s-=e*m,l-=n*m),(h=Math.sqrt(s*s+l*l))&&(s/=h,l/=h,m/=h),e*l<n*s&&(e=-e,n=-n,m=-m,c=-c),{translateX:o,translateY:d,rotate:Math.atan2(n,e)*Vy,skewX:Math.atan(m)*Vy,scaleX:c,scaleY:h}}var fd;function XM(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Mm:aw(n.a,n.b,n.c,n.d,n.e,n.f)}function KM(e){return e==null||(fd||(fd=document.createElementNS("http://www.w3.org/2000/svg","g")),fd.setAttribute("transform",e),!(e=fd.transform.baseVal.consolidate()))?Mm:(e=e.matrix,aw(e.a,e.b,e.c,e.d,e.e,e.f))}function lw(e,n,s,l){function o(f){return f.length?f.pop()+" ":""}function d(f,g,x,p,y,w){if(f!==x||g!==p){var N=y.push("translate(",null,n,null,s);w.push({i:N-4,x:Cs(f,x)},{i:N-2,x:Cs(g,p)})}else(x||p)&&y.push("translate("+x+n+p+s)}function c(f,g,x,p){f!==g?(f-g>180?g+=360:g-f>180&&(f+=360),p.push({i:x.push(o(x)+"rotate(",null,l)-2,x:Cs(f,g)})):g&&x.push(o(x)+"rotate("+g+l)}function h(f,g,x,p){f!==g?p.push({i:x.push(o(x)+"skewX(",null,l)-2,x:Cs(f,g)}):g&&x.push(o(x)+"skewX("+g+l)}function m(f,g,x,p,y,w){if(f!==x||g!==p){var N=y.push(o(y)+"scale(",null,",",null,")");w.push({i:N-4,x:Cs(f,x)},{i:N-2,x:Cs(g,p)})}else(x!==1||p!==1)&&y.push(o(y)+"scale("+x+","+p+")")}return function(f,g){var x=[],p=[];return f=e(f),g=e(g),d(f.translateX,f.translateY,g.translateX,g.translateY,x,p),c(f.rotate,g.rotate,x,p),h(f.skewX,g.skewX,x,p),m(f.scaleX,f.scaleY,g.scaleX,g.scaleY,x,p),f=g=null,function(y){for(var w=-1,N=p.length,C;++w<N;)x[(C=p[w]).i]=C.x(y);return x.join("")}}}var ZM=lw(XM,"px, ","px)","deg)"),WM=lw(KM,", ",")",")"),QM=1e-12;function Fy(e){return((e=Math.exp(e))+1/e)/2}function JM(e){return((e=Math.exp(e))-1/e)/2}function e6(e){return((e=Math.exp(2*e))-1)/(e+1)}const wd=(function e(n,s,l){function o(d,c){var h=d[0],m=d[1],f=d[2],g=c[0],x=c[1],p=c[2],y=g-h,w=x-m,N=y*y+w*w,C,_;if(N<QM)_=Math.log(p/f)/n,C=function(Y){return[h+Y*y,m+Y*w,f*Math.exp(n*Y*_)]};else{var O=Math.sqrt(N),k=(p*p-f*f+l*N)/(2*f*s*O),S=(p*p-f*f-l*N)/(2*p*s*O),R=Math.log(Math.sqrt(k*k+1)-k),D=Math.log(Math.sqrt(S*S+1)-S);_=(D-R)/n,C=function(Y){var z=Y*_,K=Fy(R),U=f/(s*O)*(K*e6(n*z+R)-JM(R));return[h+U*y,m+U*w,f*K/Fy(n*z+R)]}}return C.duration=_*1e3*n/Math.SQRT2,C}return o.rho=function(d){var c=Math.max(.001,+d),h=c*c,m=h*h;return e(c,h,m)},o})(Math.SQRT2,2,4);var oi=0,bo=0,ho=0,iw=1e3,Pd,yo,Ud=0,hl=0,su=0,Ro=typeof performance=="object"&&performance.now?performance:Date,ow=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function jx(){return hl||(ow(t6),hl=Ro.now()+su)}function t6(){hl=0}function qd(){this._call=this._time=this._next=null}qd.prototype=cw.prototype={constructor:qd,restart:function(e,n,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?jx():+s)+(n==null?0:+n),!this._next&&yo!==this&&(yo?yo._next=this:Pd=this,yo=this),this._call=e,this._time=s,Om()},stop:function(){this._call&&(this._call=null,this._time=1/0,Om())}};function cw(e,n,s){var l=new qd;return l.restart(e,n,s),l}function n6(){jx(),++oi;for(var e=Pd,n;e;)(n=hl-e._time)>=0&&e._call.call(void 0,n),e=e._next;--oi}function Yy(){hl=(Ud=Ro.now())+su,oi=bo=0;try{n6()}finally{oi=0,s6(),hl=0}}function r6(){var e=Ro.now(),n=e-Ud;n>iw&&(su-=n,Ud=e)}function s6(){for(var e,n=Pd,s,l=1/0;n;)n._call?(l>n._time&&(l=n._time),e=n,n=n._next):(s=n._next,n._next=null,n=e?e._next=s:Pd=s);yo=e,Om(l)}function Om(e){if(!oi){bo&&(bo=clearTimeout(bo));var n=e-hl;n>24?(e<1/0&&(bo=setTimeout(Yy,e-Ro.now()-su)),ho&&(ho=clearInterval(ho))):(ho||(Ud=Ro.now(),ho=setInterval(r6,iw)),oi=1,ow(Yy))}}function Gy(e,n,s){var l=new qd;return n=n==null?0:+n,l.restart(o=>{l.stop(),e(o+n)},n,s),l}var a6=nu("start","end","cancel","interrupt"),l6=[],dw=0,Xy=1,Rm=2,Nd=3,Ky=4,Dm=5,kd=6;function au(e,n,s,l,o,d){var c=e.__transition;if(!c)e.__transition={};else if(s in c)return;i6(e,s,{name:n,index:l,group:o,on:a6,tween:l6,time:d.time,delay:d.delay,duration:d.duration,ease:d.ease,timer:null,state:dw})}function wx(e,n){var s=xs(e,n);if(s.state>dw)throw new Error("too late; already scheduled");return s}function Ms(e,n){var s=xs(e,n);if(s.state>Nd)throw new Error("too late; already running");return s}function xs(e,n){var s=e.__transition;if(!s||!(s=s[n]))throw new Error("transition not found");return s}function i6(e,n,s){var l=e.__transition,o;l[n]=s,s.timer=cw(d,0,s.time);function d(f){s.state=Xy,s.timer.restart(c,s.delay,s.time),s.delay<=f&&c(f-s.delay)}function c(f){var g,x,p,y;if(s.state!==Xy)return m();for(g in l)if(y=l[g],y.name===s.name){if(y.state===Nd)return Gy(c);y.state===Ky?(y.state=kd,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete l[g]):+g<n&&(y.state=kd,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete l[g])}if(Gy(function(){s.state===Nd&&(s.state=Ky,s.timer.restart(h,s.delay,s.time),h(f))}),s.state=Rm,s.on.call("start",e,e.__data__,s.index,s.group),s.state===Rm){for(s.state=Nd,o=new Array(p=s.tween.length),g=0,x=-1;g<p;++g)(y=s.tween[g].value.call(e,e.__data__,s.index,s.group))&&(o[++x]=y);o.length=x+1}}function h(f){for(var g=f<s.duration?s.ease.call(null,f/s.duration):(s.timer.restart(m),s.state=Dm,1),x=-1,p=o.length;++x<p;)o[x].call(e,g);s.state===Dm&&(s.on.call("end",e,e.__data__,s.index,s.group),m())}function m(){s.state=kd,s.timer.stop(),delete l[n];for(var f in l)return;delete e.__transition}}function Sd(e,n){var s=e.__transition,l,o,d=!0,c;if(s){n=n==null?null:n+"";for(c in s){if((l=s[c]).name!==n){d=!1;continue}o=l.state>Rm&&l.state<Dm,l.state=kd,l.timer.stop(),l.on.call(o?"interrupt":"cancel",e,e.__data__,l.index,l.group),delete s[c]}d&&delete e.__transition}}function o6(e){return this.each(function(){Sd(this,e)})}function c6(e,n){var s,l;return function(){var o=Ms(this,e),d=o.tween;if(d!==s){l=s=d;for(var c=0,h=l.length;c<h;++c)if(l[c].name===n){l=l.slice(),l.splice(c,1);break}}o.tween=l}}function d6(e,n,s){var l,o;if(typeof s!="function")throw new Error;return function(){var d=Ms(this,e),c=d.tween;if(c!==l){o=(l=c).slice();for(var h={name:n,value:s},m=0,f=o.length;m<f;++m)if(o[m].name===n){o[m]=h;break}m===f&&o.push(h)}d.tween=o}}function u6(e,n){var s=this._id;if(e+="",arguments.length<2){for(var l=xs(this.node(),s).tween,o=0,d=l.length,c;o<d;++o)if((c=l[o]).name===e)return c.value;return null}return this.each((n==null?c6:d6)(s,e,n))}function Nx(e,n,s){var l=e._id;return e.each(function(){var o=Ms(this,l);(o.value||(o.value={}))[n]=s.apply(this,arguments)}),function(o){return xs(o,l).value[n]}}function uw(e,n){var s;return(typeof n=="number"?Cs:n instanceof fl?Hd:(s=fl(n))?(n=s,Hd):sw)(e,n)}function f6(e){return function(){this.removeAttribute(e)}}function h6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function m6(e,n,s){var l,o=s+"",d;return function(){var c=this.getAttribute(e);return c===o?null:c===l?d:d=n(l=c,s)}}function x6(e,n,s){var l,o=s+"",d;return function(){var c=this.getAttributeNS(e.space,e.local);return c===o?null:c===l?d:d=n(l=c,s)}}function g6(e,n,s){var l,o,d;return function(){var c,h=s(this),m;return h==null?void this.removeAttribute(e):(c=this.getAttribute(e),m=h+"",c===m?null:c===l&&m===o?d:(o=m,d=n(l=c,h)))}}function p6(e,n,s){var l,o,d;return function(){var c,h=s(this),m;return h==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),m=h+"",c===m?null:c===l&&m===o?d:(o=m,d=n(l=c,h)))}}function b6(e,n){var s=ru(e),l=s==="transform"?WM:uw;return this.attrTween(e,typeof n=="function"?(s.local?p6:g6)(s,l,Nx(this,"attr."+e,n)):n==null?(s.local?h6:f6)(s):(s.local?x6:m6)(s,l,n))}function y6(e,n){return function(s){this.setAttribute(e,n.call(this,s))}}function v6(e,n){return function(s){this.setAttributeNS(e.space,e.local,n.call(this,s))}}function j6(e,n){var s,l;function o(){var d=n.apply(this,arguments);return d!==l&&(s=(l=d)&&v6(e,d)),s}return o._value=n,o}function w6(e,n){var s,l;function o(){var d=n.apply(this,arguments);return d!==l&&(s=(l=d)&&y6(e,d)),s}return o._value=n,o}function N6(e,n){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;var l=ru(e);return this.tween(s,(l.local?j6:w6)(l,n))}function k6(e,n){return function(){wx(this,e).delay=+n.apply(this,arguments)}}function S6(e,n){return n=+n,function(){wx(this,e).delay=n}}function C6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?k6:S6)(n,e)):xs(this.node(),n).delay}function E6(e,n){return function(){Ms(this,e).duration=+n.apply(this,arguments)}}function T6(e,n){return n=+n,function(){Ms(this,e).duration=n}}function A6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?E6:T6)(n,e)):xs(this.node(),n).duration}function _6(e,n){if(typeof n!="function")throw new Error;return function(){Ms(this,e).ease=n}}function M6(e){var n=this._id;return arguments.length?this.each(_6(n,e)):xs(this.node(),n).ease}function O6(e,n){return function(){var s=n.apply(this,arguments);if(typeof s!="function")throw new Error;Ms(this,e).ease=s}}function R6(e){if(typeof e!="function")throw new Error;return this.each(O6(this._id,e))}function D6(e){typeof e!="function"&&(e=Uj(e));for(var n=this._groups,s=n.length,l=new Array(s),o=0;o<s;++o)for(var d=n[o],c=d.length,h=l[o]=[],m,f=0;f<c;++f)(m=d[f])&&e.call(m,m.__data__,f,d)&&h.push(m);return new ta(l,this._parents,this._name,this._id)}function L6(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,s=e._groups,l=n.length,o=s.length,d=Math.min(l,o),c=new Array(l),h=0;h<d;++h)for(var m=n[h],f=s[h],g=m.length,x=c[h]=new Array(g),p,y=0;y<g;++y)(p=m[y]||f[y])&&(x[y]=p);for(;h<l;++h)c[h]=n[h];return new ta(c,this._parents,this._name,this._id)}function I6(e){return(e+"").trim().split(/^|\s+/).every(function(n){var s=n.indexOf(".");return s>=0&&(n=n.slice(0,s)),!n||n==="start"})}function z6(e,n,s){var l,o,d=I6(n)?wx:Ms;return function(){var c=d(this,e),h=c.on;h!==l&&(o=(l=h).copy()).on(n,s),c.on=o}}function $6(e,n){var s=this._id;return arguments.length<2?xs(this.node(),s).on.on(e):this.each(z6(s,e,n))}function B6(e){return function(){var n=this.parentNode;for(var s in this.__transition)if(+s!==e)return;n&&n.removeChild(this)}}function H6(){return this.on("end.remove",B6(this._id))}function P6(e){var n=this._name,s=this._id;typeof e!="function"&&(e=px(e));for(var l=this._groups,o=l.length,d=new Array(o),c=0;c<o;++c)for(var h=l[c],m=h.length,f=d[c]=new Array(m),g,x,p=0;p<m;++p)(g=h[p])&&(x=e.call(g,g.__data__,p,h))&&("__data__"in g&&(x.__data__=g.__data__),f[p]=x,au(f[p],n,s,p,f,xs(g,s)));return new ta(d,this._parents,n,s)}function U6(e){var n=this._name,s=this._id;typeof e!="function"&&(e=Pj(e));for(var l=this._groups,o=l.length,d=[],c=[],h=0;h<o;++h)for(var m=l[h],f=m.length,g,x=0;x<f;++x)if(g=m[x]){for(var p=e.call(g,g.__data__,x,m),y,w=xs(g,s),N=0,C=p.length;N<C;++N)(y=p[N])&&au(y,n,s,N,p,w);d.push(p),c.push(g)}return new ta(d,c,n,s)}var q6=Fo.prototype.constructor;function V6(){return new q6(this._groups,this._parents)}function F6(e,n){var s,l,o;return function(){var d=ii(this,e),c=(this.style.removeProperty(e),ii(this,e));return d===c?null:d===s&&c===l?o:o=n(s=d,l=c)}}function fw(e){return function(){this.style.removeProperty(e)}}function Y6(e,n,s){var l,o=s+"",d;return function(){var c=ii(this,e);return c===o?null:c===l?d:d=n(l=c,s)}}function G6(e,n,s){var l,o,d;return function(){var c=ii(this,e),h=s(this),m=h+"";return h==null&&(m=h=(this.style.removeProperty(e),ii(this,e))),c===m?null:c===l&&m===o?d:(o=m,d=n(l=c,h))}}function X6(e,n){var s,l,o,d="style."+n,c="end."+d,h;return function(){var m=Ms(this,e),f=m.on,g=m.value[d]==null?h||(h=fw(n)):void 0;(f!==s||o!==g)&&(l=(s=f).copy()).on(c,o=g),m.on=l}}function K6(e,n,s){var l=(e+="")=="transform"?ZM:uw;return n==null?this.styleTween(e,F6(e,l)).on("end.style."+e,fw(e)):typeof n=="function"?this.styleTween(e,G6(e,l,Nx(this,"style."+e,n))).each(X6(this._id,e)):this.styleTween(e,Y6(e,l,n),s).on("end.style."+e,null)}function Z6(e,n,s){return function(l){this.style.setProperty(e,n.call(this,l),s)}}function W6(e,n,s){var l,o;function d(){var c=n.apply(this,arguments);return c!==o&&(l=(o=c)&&Z6(e,c,s)),l}return d._value=n,d}function Q6(e,n,s){var l="style."+(e+="");if(arguments.length<2)return(l=this.tween(l))&&l._value;if(n==null)return this.tween(l,null);if(typeof n!="function")throw new Error;return this.tween(l,W6(e,n,s??""))}function J6(e){return function(){this.textContent=e}}function eO(e){return function(){var n=e(this);this.textContent=n??""}}function tO(e){return this.tween("text",typeof e=="function"?eO(Nx(this,"text",e)):J6(e==null?"":e+""))}function nO(e){return function(n){this.textContent=e.call(this,n)}}function rO(e){var n,s;function l(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&nO(o)),n}return l._value=e,l}function sO(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,rO(e))}function aO(){for(var e=this._name,n=this._id,s=hw(),l=this._groups,o=l.length,d=0;d<o;++d)for(var c=l[d],h=c.length,m,f=0;f<h;++f)if(m=c[f]){var g=xs(m,n);au(m,e,s,f,c,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new ta(l,this._parents,e,s)}function lO(){var e,n,s=this,l=s._id,o=s.size();return new Promise(function(d,c){var h={value:c},m={value:function(){--o===0&&d()}};s.each(function(){var f=Ms(this,l),g=f.on;g!==e&&(n=(e=g).copy(),n._.cancel.push(h),n._.interrupt.push(h),n._.end.push(m)),f.on=n}),o===0&&d()})}var iO=0;function ta(e,n,s,l){this._groups=e,this._parents=n,this._name=s,this._id=l}function hw(){return++iO}var Zs=Fo.prototype;ta.prototype={constructor:ta,select:P6,selectAll:U6,selectChild:Zs.selectChild,selectChildren:Zs.selectChildren,filter:D6,merge:L6,selection:V6,transition:aO,call:Zs.call,nodes:Zs.nodes,node:Zs.node,size:Zs.size,empty:Zs.empty,each:Zs.each,on:$6,attr:b6,attrTween:N6,style:K6,styleTween:Q6,text:tO,textTween:sO,remove:H6,tween:u6,delay:C6,duration:A6,ease:M6,easeVarying:R6,end:lO,[Symbol.iterator]:Zs[Symbol.iterator]};function oO(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var cO={time:null,delay:0,duration:250,ease:oO};function dO(e,n){for(var s;!(s=e.__transition)||!(s=s[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return s}function uO(e){var n,s;e instanceof ta?(n=e._id,e=e._name):(n=hw(),(s=cO).time=jx(),e=e==null?null:e+"");for(var l=this._groups,o=l.length,d=0;d<o;++d)for(var c=l[d],h=c.length,m,f=0;f<h;++f)(m=c[f])&&au(m,e,n,f,c,s||dO(m,n));return new ta(l,this._parents,e,n)}Fo.prototype.interrupt=o6;Fo.prototype.transition=uO;const hd=e=>()=>e;function fO(e,{sourceEvent:n,target:s,transform:l,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:o}})}function ea(e,n,s){this.k=e,this.x=n,this.y=s}ea.prototype={constructor:ea,scale:function(e){return e===1?this:new ea(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new ea(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var lu=new ea(1,0,0);mw.prototype=ea.prototype;function mw(e){for(;!e.__zoom;)if(!(e=e.parentNode))return lu;return e.__zoom}function Yh(e){e.stopImmediatePropagation()}function mo(e){e.preventDefault(),e.stopImmediatePropagation()}function hO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function mO(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Zy(){return this.__zoom||lu}function xO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function gO(){return navigator.maxTouchPoints||"ontouchstart"in this}function pO(e,n,s){var l=e.invertX(n[0][0])-s[0][0],o=e.invertX(n[1][0])-s[1][0],d=e.invertY(n[0][1])-s[0][1],c=e.invertY(n[1][1])-s[1][1];return e.translate(o>l?(l+o)/2:Math.min(0,l)||Math.max(0,o),c>d?(d+c)/2:Math.min(0,d)||Math.max(0,c))}function xw(){var e=hO,n=mO,s=pO,l=xO,o=gO,d=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,m=wd,f=nu("start","zoom","end"),g,x,p,y=500,w=150,N=0,C=10;function _(T){T.property("__zoom",Zy).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",U).filter(o).on("touchstart.zoom",G).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(T,L,A,P){var q=T.selection?T.selection():T;q.property("__zoom",Zy),T!==q?R(T,L,A,P):q.interrupt().each(function(){D(this,arguments).event(P).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},_.scaleBy=function(T,L,A,P){_.scaleTo(T,function(){var q=this.__zoom.k,W=typeof L=="function"?L.apply(this,arguments):L;return q*W},A,P)},_.scaleTo=function(T,L,A,P){_.transform(T,function(){var q=n.apply(this,arguments),W=this.__zoom,B=A==null?S(q):typeof A=="function"?A.apply(this,arguments):A,F=W.invert(B),X=typeof L=="function"?L.apply(this,arguments):L;return s(k(O(W,X),B,F),q,c)},A,P)},_.translateBy=function(T,L,A,P){_.transform(T,function(){return s(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof A=="function"?A.apply(this,arguments):A),n.apply(this,arguments),c)},null,P)},_.translateTo=function(T,L,A,P,q){_.transform(T,function(){var W=n.apply(this,arguments),B=this.__zoom,F=P==null?S(W):typeof P=="function"?P.apply(this,arguments):P;return s(lu.translate(F[0],F[1]).scale(B.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof A=="function"?-A.apply(this,arguments):-A),W,c)},P,q)};function O(T,L){return L=Math.max(d[0],Math.min(d[1],L)),L===T.k?T:new ea(L,T.x,T.y)}function k(T,L,A){var P=L[0]-A[0]*T.k,q=L[1]-A[1]*T.k;return P===T.x&&q===T.y?T:new ea(T.k,P,q)}function S(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function R(T,L,A,P){T.on("start.zoom",function(){D(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(P).end()}).tween("zoom",function(){var q=this,W=arguments,B=D(q,W).event(P),F=n.apply(q,W),X=A==null?S(F):typeof A=="function"?A.apply(q,W):A,I=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),M=q.__zoom,H=typeof L=="function"?L.apply(q,W):L,Z=m(M.invert(X).concat(I/M.k),H.invert(X).concat(I/H.k));return function(ee){if(ee===1)ee=H;else{var ne=Z(ee),ae=I/ne[2];ee=new ea(ae,X[0]-ne[0]*ae,X[1]-ne[1]*ae)}B.zoom(null,ee)}})}function D(T,L,A){return!A&&T.__zooming||new Y(T,L)}function Y(T,L){this.that=T,this.args=L,this.active=0,this.sourceEvent=null,this.extent=n.apply(T,L),this.taps=0}Y.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,L){return this.mouse&&T!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var L=Hr(this.that).datum();f.call(T,this.that,new fO(T,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:f}),L)}};function z(T,...L){if(!e.apply(this,arguments))return;var A=D(this,L).event(T),P=this.__zoom,q=Math.max(d[0],Math.min(d[1],P.k*Math.pow(2,l.apply(this,arguments)))),W=cs(T);if(A.wheel)(A.mouse[0][0]!==W[0]||A.mouse[0][1]!==W[1])&&(A.mouse[1]=P.invert(A.mouse[0]=W)),clearTimeout(A.wheel);else{if(P.k===q)return;A.mouse=[W,P.invert(W)],Sd(this),A.start()}mo(T),A.wheel=setTimeout(B,w),A.zoom("mouse",s(k(O(P,q),A.mouse[0],A.mouse[1]),A.extent,c));function B(){A.wheel=null,A.end()}}function K(T,...L){if(p||!e.apply(this,arguments))return;var A=T.currentTarget,P=D(this,L,!0).event(T),q=Hr(T.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",I,!0),W=cs(T,A),B=T.clientX,F=T.clientY;Qj(T.view),Yh(T),P.mouse=[W,this.__zoom.invert(W)],Sd(this),P.start();function X(M){if(mo(M),!P.moved){var H=M.clientX-B,Z=M.clientY-F;P.moved=H*H+Z*Z>N}P.event(M).zoom("mouse",s(k(P.that.__zoom,P.mouse[0]=cs(M,A),P.mouse[1]),P.extent,c))}function I(M){q.on("mousemove.zoom mouseup.zoom",null),Jj(M.view,P.moved),mo(M),P.event(M).end()}}function U(T,...L){if(e.apply(this,arguments)){var A=this.__zoom,P=cs(T.changedTouches?T.changedTouches[0]:T,this),q=A.invert(P),W=A.k*(T.shiftKey?.5:2),B=s(k(O(A,W),P,q),n.apply(this,L),c);mo(T),h>0?Hr(this).transition().duration(h).call(R,B,P,T):Hr(this).call(_.transform,B,P,T)}}function G(T,...L){if(e.apply(this,arguments)){var A=T.touches,P=A.length,q=D(this,L,T.changedTouches.length===P).event(T),W,B,F,X;for(Yh(T),B=0;B<P;++B)F=A[B],X=cs(F,this),X=[X,this.__zoom.invert(X),F.identifier],q.touch0?!q.touch1&&q.touch0[2]!==X[2]&&(q.touch1=X,q.taps=0):(q.touch0=X,W=!0,q.taps=1+!!g);g&&(g=clearTimeout(g)),W&&(q.taps<2&&(x=X[0],g=setTimeout(function(){g=null},y)),Sd(this),q.start())}}function V(T,...L){if(this.__zooming){var A=D(this,L).event(T),P=T.changedTouches,q=P.length,W,B,F,X;for(mo(T),W=0;W<q;++W)B=P[W],F=cs(B,this),A.touch0&&A.touch0[2]===B.identifier?A.touch0[0]=F:A.touch1&&A.touch1[2]===B.identifier&&(A.touch1[0]=F);if(B=A.that.__zoom,A.touch1){var I=A.touch0[0],M=A.touch0[1],H=A.touch1[0],Z=A.touch1[1],ee=(ee=H[0]-I[0])*ee+(ee=H[1]-I[1])*ee,ne=(ne=Z[0]-M[0])*ne+(ne=Z[1]-M[1])*ne;B=O(B,Math.sqrt(ee/ne)),F=[(I[0]+H[0])/2,(I[1]+H[1])/2],X=[(M[0]+Z[0])/2,(M[1]+Z[1])/2]}else if(A.touch0)F=A.touch0[0],X=A.touch0[1];else return;A.zoom("touch",s(k(B,F,X),A.extent,c))}}function E(T,...L){if(this.__zooming){var A=D(this,L).event(T),P=T.changedTouches,q=P.length,W,B;for(Yh(T),p&&clearTimeout(p),p=setTimeout(function(){p=null},y),W=0;W<q;++W)B=P[W],A.touch0&&A.touch0[2]===B.identifier?delete A.touch0:A.touch1&&A.touch1[2]===B.identifier&&delete A.touch1;if(A.touch1&&!A.touch0&&(A.touch0=A.touch1,delete A.touch1),A.touch0)A.touch0[1]=this.__zoom.invert(A.touch0[0]);else if(A.end(),A.taps===2&&(B=cs(B,this),Math.hypot(x[0]-B[0],x[1]-B[1])<C)){var F=Hr(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return _.wheelDelta=function(T){return arguments.length?(l=typeof T=="function"?T:hd(+T),_):l},_.filter=function(T){return arguments.length?(e=typeof T=="function"?T:hd(!!T),_):e},_.touchable=function(T){return arguments.length?(o=typeof T=="function"?T:hd(!!T),_):o},_.extent=function(T){return arguments.length?(n=typeof T=="function"?T:hd([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),_):n},_.scaleExtent=function(T){return arguments.length?(d[0]=+T[0],d[1]=+T[1],_):[d[0],d[1]]},_.translateExtent=function(T){return arguments.length?(c[0][0]=+T[0][0],c[1][0]=+T[1][0],c[0][1]=+T[0][1],c[1][1]=+T[1][1],_):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},_.constrain=function(T){return arguments.length?(s=T,_):s},_.duration=function(T){return arguments.length?(h=+T,_):h},_.interpolate=function(T){return arguments.length?(m=T,_):m},_.on=function(){var T=f.on.apply(f,arguments);return T===f?_:T},_.clickDistance=function(T){return arguments.length?(N=(T=+T)*T,_):Math.sqrt(N)},_.tapDistance=function(T){return arguments.length?(C=+T,_):C},_}const Ts={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:s,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:l}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Do=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],gw=["Enter"," ","Escape"],pw={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:s})=>`Moved selected node ${e}. New position, x: ${n}, y: ${s}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ci;(function(e){e.Strict="strict",e.Loose="loose"})(ci||(ci={}));var cl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(cl||(cl={}));var Lo;(function(e){e.Partial="partial",e.Full="full"})(Lo||(Lo={}));const bw={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var La;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(La||(La={}));var di;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(di||(di={}));var ft;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ft||(ft={}));const Wy={[ft.Left]:ft.Right,[ft.Right]:ft.Left,[ft.Top]:ft.Bottom,[ft.Bottom]:ft.Top};function yw(e){return e===null?null:e?"valid":"invalid"}const vw=e=>"id"in e&&"source"in e&&"target"in e,bO=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),kx=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Go=(e,n=[0,0])=>{const{width:s,height:l}=ra(e),o=e.origin??n,d=s*o[0],c=l*o[1];return{x:e.position.x-d,y:e.position.y-c}},yO=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((l,o)=>{const d=typeof o=="string";let c=!n.nodeLookup&&!d?o:void 0;n.nodeLookup&&(c=d?n.nodeLookup.get(o):kx(o)?o:n.nodeLookup.get(o.id));const h=c?Vd(c,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return iu(l,h)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ou(s)},Xo=(e,n={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(o=>{(n.filter===void 0||n.filter(o))&&(s=iu(s,Vd(o)),l=!0)}),l?ou(s):{x:0,y:0,width:0,height:0}},Sx=(e,n,[s,l,o]=[0,0,1],d=!1,c=!1)=>{const h={...Zo(n,[s,l,o]),width:n.width/o,height:n.height/o},m=[];for(const f of e.values()){const{measured:g,selectable:x=!0,hidden:p=!1}=f;if(c&&!x||p)continue;const y=g.width??f.width??f.initialWidth??null,w=g.height??f.height??f.initialHeight??null,N=Io(h,fi(f)),C=(y??0)*(w??0),_=d&&N>0;(!f.internals.handleBounds||_||N>=C||f.dragging)&&m.push(f)}return m},vO=(e,n)=>{const s=new Set;return e.forEach(l=>{s.add(l.id)}),n.filter(l=>s.has(l.source)||s.has(l.target))};function jO(e,n){const s=new Map,l=n?.nodes?new Set(n.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(n?.includeHiddenNodes||!o.hidden)&&(!l||l.has(o.id))&&s.set(o.id,o)}),s}async function wO({nodes:e,width:n,height:s,panZoom:l,minZoom:o,maxZoom:d},c){if(e.size===0)return Promise.resolve(!0);const h=jO(e,c),m=Xo(h),f=Cx(m,n,s,c?.minZoom??o,c?.maxZoom??d,c?.padding??.1);return await l.setViewport(f,{duration:c?.duration,ease:c?.ease,interpolate:c?.interpolate}),Promise.resolve(!0)}function jw({nodeId:e,nextPosition:n,nodeLookup:s,nodeOrigin:l=[0,0],nodeExtent:o,onError:d}){const c=s.get(e),h=c.parentId?s.get(c.parentId):void 0,{x:m,y:f}=h?h.internals.positionAbsolute:{x:0,y:0},g=c.origin??l;let x=c.extent||o;if(c.extent==="parent"&&!c.expandParent)if(!h)d?.("005",Ts.error005());else{const y=h.measured.width,w=h.measured.height;y&&w&&(x=[[m,f],[m+y,f+w]])}else h&&hi(c.extent)&&(x=[[c.extent[0][0]+m,c.extent[0][1]+f],[c.extent[1][0]+m,c.extent[1][1]+f]]);const p=hi(x)?ml(n,x,c.measured):n;return(c.measured.width===void 0||c.measured.height===void 0)&&d?.("015",Ts.error015()),{position:{x:p.x-m+(c.measured.width??0)*g[0],y:p.y-f+(c.measured.height??0)*g[1]},positionAbsolute:p}}async function NO({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:l,onBeforeDelete:o}){const d=new Set(e.map(p=>p.id)),c=[];for(const p of s){if(p.deletable===!1)continue;const y=d.has(p.id),w=!y&&p.parentId&&c.find(N=>N.id===p.parentId);(y||w)&&c.push(p)}const h=new Set(n.map(p=>p.id)),m=l.filter(p=>p.deletable!==!1),g=vO(c,m);for(const p of m)h.has(p.id)&&!g.find(w=>w.id===p.id)&&g.push(p);if(!o)return{edges:g,nodes:c};const x=await o({nodes:c,edges:g});return typeof x=="boolean"?x?{edges:g,nodes:c}:{edges:[],nodes:[]}:x}const ui=(e,n=0,s=1)=>Math.min(Math.max(e,n),s),ml=(e={x:0,y:0},n,s)=>({x:ui(e.x,n[0][0],n[1][0]-(s?.width??0)),y:ui(e.y,n[0][1],n[1][1]-(s?.height??0))});function ww(e,n,s){const{width:l,height:o}=ra(s),{x:d,y:c}=s.internals.positionAbsolute;return ml(e,[[d,c],[d+l,c+o]],n)}const Qy=(e,n,s)=>e<n?ui(Math.abs(e-n),1,n)/n:e>s?-ui(Math.abs(e-s),1,n)/n:0,Nw=(e,n,s=15,l=40)=>{const o=Qy(e.x,l,n.width-l)*s,d=Qy(e.y,l,n.height-l)*s;return[o,d]},iu=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),Lm=({x:e,y:n,width:s,height:l})=>({x:e,y:n,x2:e+s,y2:n+l}),ou=({x:e,y:n,x2:s,y2:l})=>({x:e,y:n,width:s-e,height:l-n}),fi=(e,n=[0,0])=>{const{x:s,y:l}=kx(e)?e.internals.positionAbsolute:Go(e,n);return{x:s,y:l,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Vd=(e,n=[0,0])=>{const{x:s,y:l}=kx(e)?e.internals.positionAbsolute:Go(e,n);return{x:s,y:l,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:l+(e.measured?.height??e.height??e.initialHeight??0)}},kw=(e,n)=>ou(iu(Lm(e),Lm(n))),Io=(e,n)=>{const s=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),l=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(s*l)},Jy=e=>us(e.width)&&us(e.height)&&us(e.x)&&us(e.y),us=e=>!isNaN(e)&&isFinite(e),kO=(e,n)=>{},Ko=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),Zo=({x:e,y:n},[s,l,o],d=!1,c=[1,1])=>{const h={x:(e-s)/o,y:(n-l)/o};return d?Ko(h,c):h},Fd=({x:e,y:n},[s,l,o])=>({x:e*o+s,y:n*o+l});function Xl(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(s)}if(typeof e=="string"&&e.endsWith("%")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(n*s*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function SO(e,n,s){if(typeof e=="string"||typeof e=="number"){const l=Xl(e,s),o=Xl(e,n);return{top:l,right:o,bottom:l,left:o,x:o*2,y:l*2}}if(typeof e=="object"){const l=Xl(e.top??e.y??0,s),o=Xl(e.bottom??e.y??0,s),d=Xl(e.left??e.x??0,n),c=Xl(e.right??e.x??0,n);return{top:l,right:c,bottom:o,left:d,x:d+c,y:l+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function CO(e,n,s,l,o,d){const{x:c,y:h}=Fd(e,[n,s,l]),{x:m,y:f}=Fd({x:e.x+e.width,y:e.y+e.height},[n,s,l]),g=o-m,x=d-f;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(g),bottom:Math.floor(x)}}const Cx=(e,n,s,l,o,d)=>{const c=SO(d,n,s),h=(n-c.x)/e.width,m=(s-c.y)/e.height,f=Math.min(h,m),g=ui(f,l,o),x=e.x+e.width/2,p=e.y+e.height/2,y=n/2-x*g,w=s/2-p*g,N=CO(e,y,w,g,n,s),C={left:Math.min(N.left-c.left,0),top:Math.min(N.top-c.top,0),right:Math.min(N.right-c.right,0),bottom:Math.min(N.bottom-c.bottom,0)};return{x:y-C.left+C.right,y:w-C.top+C.bottom,zoom:g}},zo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function hi(e){return e!=null&&e!=="parent"}function ra(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Sw(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Cw(e,n={width:0,height:0},s,l,o){const d={...e},c=l.get(s);if(c){const h=c.origin||o;d.x+=c.internals.positionAbsolute.x-(n.width??0)*h[0],d.y+=c.internals.positionAbsolute.y-(n.height??0)*h[1]}return d}function ev(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function EO(){let e,n;return{promise:new Promise((l,o)=>{e=l,n=o}),resolve:e,reject:n}}function TO(e){return{...pw,...e||{}}}function So(e,{snapGrid:n=[0,0],snapToGrid:s=!1,transform:l,containerBounds:o}){const{x:d,y:c}=fs(e),h=Zo({x:d-(o?.left??0),y:c-(o?.top??0)},l),{x:m,y:f}=s?Ko(h,n):h;return{xSnapped:m,ySnapped:f,...h}}const Ex=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ew=e=>e?.getRootNode?.()||window?.document,AO=["INPUT","SELECT","TEXTAREA"];function Tw(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:AO.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const Aw=e=>"clientX"in e,fs=(e,n)=>{const s=Aw(e),l=s?e.clientX:e.touches?.[0].clientX,o=s?e.clientY:e.touches?.[0].clientY;return{x:l-(n?.left??0),y:o-(n?.top??0)}},tv=(e,n,s,l,o)=>{const d=n.querySelectorAll(`.${e}`);return!d||!d.length?null:Array.from(d).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:o,position:c.getAttribute("data-handlepos"),x:(h.left-s.left)/l,y:(h.top-s.top)/l,...Ex(c)}})};function _w({sourceX:e,sourceY:n,targetX:s,targetY:l,sourceControlX:o,sourceControlY:d,targetControlX:c,targetControlY:h}){const m=e*.125+o*.375+c*.375+s*.125,f=n*.125+d*.375+h*.375+l*.125,g=Math.abs(m-e),x=Math.abs(f-n);return[m,f,g,x]}function md(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function nv({pos:e,x1:n,y1:s,x2:l,y2:o,c:d}){switch(e){case ft.Left:return[n-md(n-l,d),s];case ft.Right:return[n+md(l-n,d),s];case ft.Top:return[n,s-md(s-o,d)];case ft.Bottom:return[n,s+md(o-s,d)]}}function Mw({sourceX:e,sourceY:n,sourcePosition:s=ft.Bottom,targetX:l,targetY:o,targetPosition:d=ft.Top,curvature:c=.25}){const[h,m]=nv({pos:s,x1:e,y1:n,x2:l,y2:o,c}),[f,g]=nv({pos:d,x1:l,y1:o,x2:e,y2:n,c}),[x,p,y,w]=_w({sourceX:e,sourceY:n,targetX:l,targetY:o,sourceControlX:h,sourceControlY:m,targetControlX:f,targetControlY:g});return[`M${e},${n} C${h},${m} ${f},${g} ${l},${o}`,x,p,y,w]}function Ow({sourceX:e,sourceY:n,targetX:s,targetY:l}){const o=Math.abs(s-e)/2,d=s<e?s+o:s-o,c=Math.abs(l-n)/2,h=l<n?l+c:l-c;return[d,h,o,c]}function _O({sourceNode:e,targetNode:n,selected:s=!1,zIndex:l=0,elevateOnSelect:o=!1,zIndexMode:d="basic"}){if(d==="manual")return l;const c=o&&s?l+1e3:l,h=Math.max(e.parentId||o&&e.selected?e.internals.z:0,n.parentId||o&&n.selected?n.internals.z:0);return c+h}function MO({sourceNode:e,targetNode:n,width:s,height:l,transform:o}){const d=iu(Vd(e),Vd(n));d.x===d.x2&&(d.x2+=1),d.y===d.y2&&(d.y2+=1);const c={x:-o[0]/o[2],y:-o[1]/o[2],width:s/o[2],height:l/o[2]};return Io(c,ou(d))>0}const OO=({source:e,sourceHandle:n,target:s,targetHandle:l})=>`xy-edge__${e}${n||""}-${s}${l||""}`,RO=(e,n)=>n.some(s=>s.source===e.source&&s.target===e.target&&(s.sourceHandle===e.sourceHandle||!s.sourceHandle&&!e.sourceHandle)&&(s.targetHandle===e.targetHandle||!s.targetHandle&&!e.targetHandle)),DO=(e,n,s={})=>{if(!e.source||!e.target)return n;const l=s.getEdgeId||OO;let o;return vw(e)?o={...e}:o={...e,id:l(e)},RO(o,n)?n:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,n.concat(o))};function Rw({sourceX:e,sourceY:n,targetX:s,targetY:l}){const[o,d,c,h]=Ow({sourceX:e,sourceY:n,targetX:s,targetY:l});return[`M ${e},${n}L ${s},${l}`,o,d,c,h]}const rv={[ft.Left]:{x:-1,y:0},[ft.Right]:{x:1,y:0},[ft.Top]:{x:0,y:-1},[ft.Bottom]:{x:0,y:1}},LO=({source:e,sourcePosition:n=ft.Bottom,target:s})=>n===ft.Left||n===ft.Right?e.x<s.x?{x:1,y:0}:{x:-1,y:0}:e.y<s.y?{x:0,y:1}:{x:0,y:-1},sv=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function IO({source:e,sourcePosition:n=ft.Bottom,target:s,targetPosition:l=ft.Top,center:o,offset:d,stepPosition:c}){const h=rv[n],m=rv[l],f={x:e.x+h.x*d,y:e.y+h.y*d},g={x:s.x+m.x*d,y:s.y+m.y*d},x=LO({source:f,sourcePosition:n,target:g}),p=x.x!==0?"x":"y",y=x[p];let w=[],N,C;const _={x:0,y:0},O={x:0,y:0},[,,k,S]=Ow({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(h[p]*m[p]===-1){p==="x"?(N=o.x??f.x+(g.x-f.x)*c,C=o.y??(f.y+g.y)/2):(N=o.x??(f.x+g.x)/2,C=o.y??f.y+(g.y-f.y)*c);const D=[{x:N,y:f.y},{x:N,y:g.y}],Y=[{x:f.x,y:C},{x:g.x,y:C}];h[p]===y?w=p==="x"?D:Y:w=p==="x"?Y:D}else{const D=[{x:f.x,y:g.y}],Y=[{x:g.x,y:f.y}];if(p==="x"?w=h.x===y?Y:D:w=h.y===y?D:Y,n===l){const V=Math.abs(e[p]-s[p]);if(V<=d){const E=Math.min(d-1,d-V);h[p]===y?_[p]=(f[p]>e[p]?-1:1)*E:O[p]=(g[p]>s[p]?-1:1)*E}}if(n!==l){const V=p==="x"?"y":"x",E=h[p]===m[V],T=f[V]>g[V],L=f[V]<g[V];(h[p]===1&&(!E&&T||E&&L)||h[p]!==1&&(!E&&L||E&&T))&&(w=p==="x"?D:Y)}const z={x:f.x+_.x,y:f.y+_.y},K={x:g.x+O.x,y:g.y+O.y},U=Math.max(Math.abs(z.x-w[0].x),Math.abs(K.x-w[0].x)),G=Math.max(Math.abs(z.y-w[0].y),Math.abs(K.y-w[0].y));U>=G?(N=(z.x+K.x)/2,C=w[0].y):(N=w[0].x,C=(z.y+K.y)/2)}return[[e,{x:f.x+_.x,y:f.y+_.y},...w,{x:g.x+O.x,y:g.y+O.y},s],N,C,k,S]}function zO(e,n,s,l){const o=Math.min(sv(e,n)/2,sv(n,s)/2,l),{x:d,y:c}=n;if(e.x===d&&d===s.x||e.y===c&&c===s.y)return`L${d} ${c}`;if(e.y===c){const f=e.x<s.x?-1:1,g=e.y<s.y?1:-1;return`L ${d+o*f},${c}Q ${d},${c} ${d},${c+o*g}`}const h=e.x<s.x?1:-1,m=e.y<s.y?-1:1;return`L ${d},${c+o*m}Q ${d},${c} ${d+o*h},${c}`}function Im({sourceX:e,sourceY:n,sourcePosition:s=ft.Bottom,targetX:l,targetY:o,targetPosition:d=ft.Top,borderRadius:c=5,centerX:h,centerY:m,offset:f=20,stepPosition:g=.5}){const[x,p,y,w,N]=IO({source:{x:e,y:n},sourcePosition:s,target:{x:l,y:o},targetPosition:d,center:{x:h,y:m},offset:f,stepPosition:g});return[x.reduce((_,O,k)=>{let S="";return k>0&&k<x.length-1?S=zO(x[k-1],O,x[k+1],c):S=`${k===0?"M":"L"}${O.x} ${O.y}`,_+=S,_},""),p,y,w,N]}function av(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function $O(e){const{sourceNode:n,targetNode:s}=e;if(!av(n)||!av(s))return null;const l=n.internals.handleBounds||lv(n.handles),o=s.internals.handleBounds||lv(s.handles),d=iv(l?.source??[],e.sourceHandle),c=iv(e.connectionMode===ci.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!d||!c)return e.onError?.("008",Ts.error008(d?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const h=d?.position||ft.Bottom,m=c?.position||ft.Top,f=xl(n,d,h),g=xl(s,c,m);return{sourceX:f.x,sourceY:f.y,targetX:g.x,targetY:g.y,sourcePosition:h,targetPosition:m}}function lv(e){if(!e)return null;const n=[],s=[];for(const l of e)l.width=l.width??1,l.height=l.height??1,l.type==="source"?n.push(l):l.type==="target"&&s.push(l);return{source:n,target:s}}function xl(e,n,s=ft.Left,l=!1){const o=(n?.x??0)+e.internals.positionAbsolute.x,d=(n?.y??0)+e.internals.positionAbsolute.y,{width:c,height:h}=n??ra(e);if(l)return{x:o+c/2,y:d+h/2};switch(n?.position??s){case ft.Top:return{x:o+c/2,y:d};case ft.Right:return{x:o+c,y:d+h/2};case ft.Bottom:return{x:o+c/2,y:d+h};case ft.Left:return{x:o,y:d+h/2}}}function iv(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function zm(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function BO(e,{id:n,defaultColor:s,defaultMarkerStart:l,defaultMarkerEnd:o}){const d=new Set;return e.reduce((c,h)=>([h.markerStart||l,h.markerEnd||o].forEach(m=>{if(m&&typeof m=="object"){const f=zm(m,n);d.has(f)||(c.push({id:f,color:m.color||s,...m}),d.add(f))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Dw=1e3,HO=10,Tx={nodeOrigin:[0,0],nodeExtent:Do,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},PO={...Tx,checkEquality:!0};function Ax(e,n){const s={...e};for(const l in n)n[l]!==void 0&&(s[l]=n[l]);return s}function UO(e,n,s){const l=Ax(Tx,s);for(const o of e.values())if(o.parentId)Mx(o,e,n,l);else{const d=Go(o,l.nodeOrigin),c=hi(o.extent)?o.extent:l.nodeExtent,h=ml(d,c,ra(o));o.internals.positionAbsolute=h}}function qO(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const s=[],l=[];for(const o of e.handles){const d={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?s.push(d):o.type==="target"&&l.push(d)}return{source:s,target:l}}function _x(e){return e==="manual"}function $m(e,n,s,l={}){const o=Ax(PO,l),d={i:0},c=new Map(n),h=o?.elevateNodesOnSelect&&!_x(o.zIndexMode)?Dw:0;let m=e.length>0;n.clear(),s.clear();for(const f of e){let g=c.get(f.id);if(o.checkEquality&&f===g?.internals.userNode)n.set(f.id,g);else{const x=Go(f,o.nodeOrigin),p=hi(f.extent)?f.extent:o.nodeExtent,y=ml(x,p,ra(f));g={...o.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:y,handleBounds:qO(f,g),z:Lw(f,h,o.zIndexMode),userNode:f}},n.set(f.id,g)}(g.measured===void 0||g.measured.width===void 0||g.measured.height===void 0)&&!g.hidden&&(m=!1),f.parentId&&Mx(g,n,s,l,d)}return m}function VO(e,n){if(!e.parentId)return;const s=n.get(e.parentId);s?s.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function Mx(e,n,s,l,o){const{elevateNodesOnSelect:d,nodeOrigin:c,nodeExtent:h,zIndexMode:m}=Ax(Tx,l),f=e.parentId,g=n.get(f);if(!g){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}VO(e,s),o&&!g.parentId&&g.internals.rootParentIndex===void 0&&m==="auto"&&(g.internals.rootParentIndex=++o.i,g.internals.z=g.internals.z+o.i*HO),o&&g.internals.rootParentIndex!==void 0&&(o.i=g.internals.rootParentIndex);const x=d&&!_x(m)?Dw:0,{x:p,y,z:w}=FO(e,g,c,h,x,m),{positionAbsolute:N}=e.internals,C=p!==N.x||y!==N.y;(C||w!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:p,y}:N,z:w}})}function Lw(e,n,s){const l=us(e.zIndex)?e.zIndex:0;return _x(s)?l:l+(e.selected?n:0)}function FO(e,n,s,l,o,d){const{x:c,y:h}=n.internals.positionAbsolute,m=ra(e),f=Go(e,s),g=hi(e.extent)?ml(f,e.extent,m):f;let x=ml({x:c+g.x,y:h+g.y},l,m);e.extent==="parent"&&(x=ww(x,m,n));const p=Lw(e,o,d),y=n.internals.z??0;return{x:x.x,y:x.y,z:y>=p?y+1:p}}function Ox(e,n,s,l=[0,0]){const o=[],d=new Map;for(const c of e){const h=n.get(c.parentId);if(!h)continue;const m=d.get(c.parentId)?.expandedRect??fi(h),f=kw(m,c.rect);d.set(c.parentId,{expandedRect:f,parent:h})}return d.size>0&&d.forEach(({expandedRect:c,parent:h},m)=>{const f=h.internals.positionAbsolute,g=ra(h),x=h.origin??l,p=c.x<f.x?Math.round(Math.abs(f.x-c.x)):0,y=c.y<f.y?Math.round(Math.abs(f.y-c.y)):0,w=Math.max(g.width,Math.round(c.width)),N=Math.max(g.height,Math.round(c.height)),C=(w-g.width)*x[0],_=(N-g.height)*x[1];(p>0||y>0||C||_)&&(o.push({id:m,type:"position",position:{x:h.position.x-p+C,y:h.position.y-y+_}}),s.get(m)?.forEach(O=>{e.some(k=>k.id===O.id)||o.push({id:O.id,type:"position",position:{x:O.position.x+p,y:O.position.y+y}})})),(g.width<c.width||g.height<c.height||p||y)&&o.push({id:m,type:"dimensions",setAttributes:!0,dimensions:{width:w+(p?x[0]*p-C:0),height:N+(y?x[1]*y-_:0)}})}),o}function YO(e,n,s,l,o,d,c){const h=l?.querySelector(".xyflow__viewport");let m=!1;if(!h)return{changes:[],updatedInternals:m};const f=[],g=window.getComputedStyle(h),{m22:x}=new window.DOMMatrixReadOnly(g.transform),p=[];for(const y of e.values()){const w=n.get(y.id);if(!w)continue;if(w.hidden){n.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),m=!0;continue}const N=Ex(y.nodeElement),C=w.measured.width!==N.width||w.measured.height!==N.height;if(!!(N.width&&N.height&&(C||!w.internals.handleBounds||y.force))){const O=y.nodeElement.getBoundingClientRect(),k=hi(w.extent)?w.extent:d;let{positionAbsolute:S}=w.internals;w.parentId&&w.extent==="parent"?S=ww(S,N,n.get(w.parentId)):k&&(S=ml(S,k,N));const R={...w,measured:N,internals:{...w.internals,positionAbsolute:S,handleBounds:{source:tv("source",y.nodeElement,O,x,w.id),target:tv("target",y.nodeElement,O,x,w.id)}}};n.set(w.id,R),w.parentId&&Mx(R,n,s,{nodeOrigin:o,zIndexMode:c}),m=!0,C&&(f.push({id:w.id,type:"dimensions",dimensions:N}),w.expandParent&&w.parentId&&p.push({id:w.id,parentId:w.parentId,rect:fi(R,o)}))}}if(p.length>0){const y=Ox(p,n,s,o);f.push(...y)}return{changes:f,updatedInternals:m}}async function GO({delta:e,panZoom:n,transform:s,translateExtent:l,width:o,height:d}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const c=await n.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[o,d]],l),h=!!c&&(c.x!==s[0]||c.y!==s[1]||c.k!==s[2]);return Promise.resolve(h)}function ov(e,n,s,l,o,d){let c=o;const h=l.get(c)||new Map;l.set(c,h.set(s,n)),c=`${o}-${e}`;const m=l.get(c)||new Map;if(l.set(c,m.set(s,n)),d){c=`${o}-${e}-${d}`;const f=l.get(c)||new Map;l.set(c,f.set(s,n))}}function Iw(e,n,s){e.clear(),n.clear();for(const l of s){const{source:o,target:d,sourceHandle:c=null,targetHandle:h=null}=l,m={edgeId:l.id,source:o,target:d,sourceHandle:c,targetHandle:h},f=`${o}-${c}--${d}-${h}`,g=`${d}-${h}--${o}-${c}`;ov("source",m,g,e,o,c),ov("target",m,f,e,d,h),n.set(l.id,l)}}function zw(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:zw(s,n):!1}function cv(e,n,s){let l=e;do{if(l?.matches?.(n))return!0;if(l===s)return!1;l=l?.parentElement}while(l);return!1}function XO(e,n,s,l){const o=new Map;for(const[d,c]of e)if((c.selected||c.id===l)&&(!c.parentId||!zw(c,e))&&(c.draggable||n&&typeof c.draggable>"u")){const h=e.get(d);h&&o.set(d,{id:d,position:h.position||{x:0,y:0},distance:{x:s.x-h.internals.positionAbsolute.x,y:s.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return o}function Gh({nodeId:e,dragItems:n,nodeLookup:s,dragging:l=!0}){const o=[];for(const[c,h]of n){const m=s.get(c)?.internals.userNode;m&&o.push({...m,position:h.position,dragging:l})}if(!e)return[o[0],o];const d=s.get(e)?.internals.userNode;return[d?{...d,position:n.get(e)?.position||d.position,dragging:l}:o[0],o]}function KO({dragItems:e,snapGrid:n,x:s,y:l}){const o=e.values().next().value;if(!o)return null;const d={x:s-o.distance.x,y:l-o.distance.y},c=Ko(d,n);return{x:c.x-d.x,y:c.y-d.y}}function ZO({onNodeMouseDown:e,getStoreItems:n,onDragStart:s,onDrag:l,onDragStop:o}){let d={x:null,y:null},c=0,h=new Map,m=!1,f={x:0,y:0},g=null,x=!1,p=null,y=!1,w=!1,N=null;function C({noDragClassName:O,handleSelector:k,domNode:S,isSelectable:R,nodeId:D,nodeClickDistance:Y=0}){p=Hr(S);function z({x:V,y:E}){const{nodeLookup:T,nodeExtent:L,snapGrid:A,snapToGrid:P,nodeOrigin:q,onNodeDrag:W,onSelectionDrag:B,onError:F,updateNodePositions:X}=n();d={x:V,y:E};let I=!1;const M=h.size>1,H=M&&L?Lm(Xo(h)):null,Z=M&&P?KO({dragItems:h,snapGrid:A,x:V,y:E}):null;for(const[ee,ne]of h){if(!T.has(ee))continue;let ae={x:V-ne.distance.x,y:E-ne.distance.y};P&&(ae=Z?{x:Math.round(ae.x+Z.x),y:Math.round(ae.y+Z.y)}:Ko(ae,A));let he=null;if(M&&L&&!ne.extent&&H){const{positionAbsolute:ye}=ne.internals,je=ye.x-H.x+L[0][0],Ae=ye.x+ne.measured.width-H.x2+L[1][0],$e=ye.y-H.y+L[0][1],Xe=ye.y+ne.measured.height-H.y2+L[1][1];he=[[je,$e],[Ae,Xe]]}const{position:Ne,positionAbsolute:Le}=jw({nodeId:ee,nextPosition:ae,nodeLookup:T,nodeExtent:he||L,nodeOrigin:q,onError:F});I=I||ne.position.x!==Ne.x||ne.position.y!==Ne.y,ne.position=Ne,ne.internals.positionAbsolute=Le}if(w=w||I,!!I&&(X(h,!0),N&&(l||W||!D&&B))){const[ee,ne]=Gh({nodeId:D,dragItems:h,nodeLookup:T});l?.(N,h,ee,ne),W?.(N,ee,ne),D||B?.(N,ne)}}async function K(){if(!g)return;const{transform:V,panBy:E,autoPanSpeed:T,autoPanOnNodeDrag:L}=n();if(!L){m=!1,cancelAnimationFrame(c);return}const[A,P]=Nw(f,g,T);(A!==0||P!==0)&&(d.x=(d.x??0)-A/V[2],d.y=(d.y??0)-P/V[2],await E({x:A,y:P})&&z(d)),c=requestAnimationFrame(K)}function U(V){const{nodeLookup:E,multiSelectionActive:T,nodesDraggable:L,transform:A,snapGrid:P,snapToGrid:q,selectNodesOnDrag:W,onNodeDragStart:B,onSelectionDragStart:F,unselectNodesAndEdges:X}=n();x=!0,(!W||!R)&&!T&&D&&(E.get(D)?.selected||X()),R&&W&&D&&e?.(D);const I=So(V.sourceEvent,{transform:A,snapGrid:P,snapToGrid:q,containerBounds:g});if(d=I,h=XO(E,L,I,D),h.size>0&&(s||B||!D&&F)){const[M,H]=Gh({nodeId:D,dragItems:h,nodeLookup:E});s?.(V.sourceEvent,h,M,H),B?.(V.sourceEvent,M,H),D||F?.(V.sourceEvent,H)}}const G=ew().clickDistance(Y).on("start",V=>{const{domNode:E,nodeDragThreshold:T,transform:L,snapGrid:A,snapToGrid:P}=n();g=E?.getBoundingClientRect()||null,y=!1,w=!1,N=V.sourceEvent,T===0&&U(V),d=So(V.sourceEvent,{transform:L,snapGrid:A,snapToGrid:P,containerBounds:g}),f=fs(V.sourceEvent,g)}).on("drag",V=>{const{autoPanOnNodeDrag:E,transform:T,snapGrid:L,snapToGrid:A,nodeDragThreshold:P,nodeLookup:q}=n(),W=So(V.sourceEvent,{transform:T,snapGrid:L,snapToGrid:A,containerBounds:g});if(N=V.sourceEvent,(V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1||D&&!q.has(D))&&(y=!0),!y){if(!m&&E&&x&&(m=!0,K()),!x){const B=fs(V.sourceEvent,g),F=B.x-f.x,X=B.y-f.y;Math.sqrt(F*F+X*X)>P&&U(V)}(d.x!==W.xSnapped||d.y!==W.ySnapped)&&h&&x&&(f=fs(V.sourceEvent,g),z(W))}}).on("end",V=>{if(!(!x||y)&&(m=!1,x=!1,cancelAnimationFrame(c),h.size>0)){const{nodeLookup:E,updateNodePositions:T,onNodeDragStop:L,onSelectionDragStop:A}=n();if(w&&(T(h,!1),w=!1),o||L||!D&&A){const[P,q]=Gh({nodeId:D,dragItems:h,nodeLookup:E,dragging:!1});o?.(V.sourceEvent,h,P,q),L?.(V.sourceEvent,P,q),D||A?.(V.sourceEvent,q)}}}).filter(V=>{const E=V.target;return!V.button&&(!O||!cv(E,`.${O}`,S))&&(!k||cv(E,k,S))});p.call(G)}function _(){p?.on(".drag",null)}return{update:C,destroy:_}}function WO(e,n,s){const l=[],o={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const d of n.values())Io(o,fi(d))>0&&l.push(d);return l}const QO=250;function JO(e,n,s,l){let o=[],d=1/0;const c=WO(e,s,n+QO);for(const h of c){const m=[...h.internals.handleBounds?.source??[],...h.internals.handleBounds?.target??[]];for(const f of m){if(l.nodeId===f.nodeId&&l.type===f.type&&l.id===f.id)continue;const{x:g,y:x}=xl(h,f,f.position,!0),p=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));p>n||(p<d?(o=[{...f,x:g,y:x}],d=p):p===d&&o.push({...f,x:g,y:x}))}}if(!o.length)return null;if(o.length>1){const h=l.type==="source"?"target":"source";return o.find(m=>m.type===h)??o[0]}return o[0]}function $w(e,n,s,l,o,d=!1){const c=l.get(e);if(!c)return null;const h=o==="strict"?c.internals.handleBounds?.[n]:[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]],m=(s?h?.find(f=>f.id===s):h?.[0])??null;return m&&d?{...m,...xl(c,m,m.position,!0)}:m}function Bw(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function eR(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const Hw=()=>!0;function tR(e,{connectionMode:n,connectionRadius:s,handleId:l,nodeId:o,edgeUpdaterType:d,isTarget:c,domNode:h,nodeLookup:m,lib:f,autoPanOnConnect:g,flowId:x,panBy:p,cancelConnection:y,onConnectStart:w,onConnect:N,onConnectEnd:C,isValidConnection:_=Hw,onReconnectEnd:O,updateConnection:k,getTransform:S,getFromHandle:R,autoPanSpeed:D,dragThreshold:Y=1,handleDomNode:z}){const K=Ew(e.target);let U=0,G;const{x:V,y:E}=fs(e),T=Bw(d,z),L=h?.getBoundingClientRect();let A=!1;if(!L||!T)return;const P=$w(o,T,l,m,n);if(!P)return;let q=fs(e,L),W=!1,B=null,F=!1,X=null;function I(){if(!g||!L)return;const[Ne,Le]=Nw(q,L,D);p({x:Ne,y:Le}),U=requestAnimationFrame(I)}const M={...P,nodeId:o,type:T,position:P.position},H=m.get(o);let ee={inProgress:!0,isValid:null,from:xl(H,M,ft.Left,!0),fromHandle:M,fromPosition:M.position,fromNode:H,to:q,toHandle:null,toPosition:Wy[M.position],toNode:null,pointer:q};function ne(){A=!0,k(ee),w?.(e,{nodeId:o,handleId:l,handleType:T})}Y===0&&ne();function ae(Ne){if(!A){const{x:Xe,y:tt}=fs(Ne),et=Xe-V,_t=tt-E;if(!(et*et+_t*_t>Y*Y))return;ne()}if(!R()||!M){he(Ne);return}const Le=S();q=fs(Ne,L),G=JO(Zo(q,Le,!1,[1,1]),s,m,M),W||(I(),W=!0);const ye=Pw(Ne,{handle:G,connectionMode:n,fromNodeId:o,fromHandleId:l,fromType:c?"target":"source",isValidConnection:_,doc:K,lib:f,flowId:x,nodeLookup:m});X=ye.handleDomNode,B=ye.connection,F=eR(!!G,ye.isValid);const je=m.get(o),Ae=je?xl(je,M,ft.Left,!0):ee.from,$e={...ee,from:Ae,isValid:F,to:ye.toHandle&&F?Fd({x:ye.toHandle.x,y:ye.toHandle.y},Le):q,toHandle:ye.toHandle,toPosition:F&&ye.toHandle?ye.toHandle.position:Wy[M.position],toNode:ye.toHandle?m.get(ye.toHandle.nodeId):null,pointer:q};k($e),ee=$e}function he(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(A){(G||X)&&B&&F&&N?.(B);const{inProgress:Le,...ye}=ee,je={...ye,toPosition:ee.toHandle?ee.toPosition:null};C?.(Ne,je),d&&O?.(Ne,je)}y(),cancelAnimationFrame(U),W=!1,F=!1,B=null,X=null,K.removeEventListener("mousemove",ae),K.removeEventListener("mouseup",he),K.removeEventListener("touchmove",ae),K.removeEventListener("touchend",he)}}K.addEventListener("mousemove",ae),K.addEventListener("mouseup",he),K.addEventListener("touchmove",ae),K.addEventListener("touchend",he)}function Pw(e,{handle:n,connectionMode:s,fromNodeId:l,fromHandleId:o,fromType:d,doc:c,lib:h,flowId:m,isValidConnection:f=Hw,nodeLookup:g}){const x=d==="target",p=n?c.querySelector(`.${h}-flow__handle[data-id="${m}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:y,y:w}=fs(e),N=c.elementFromPoint(y,w),C=N?.classList.contains(`${h}-flow__handle`)?N:p,_={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const O=Bw(void 0,C),k=C.getAttribute("data-nodeid"),S=C.getAttribute("data-handleid"),R=C.classList.contains("connectable"),D=C.classList.contains("connectableend");if(!k||!O)return _;const Y={source:x?k:l,sourceHandle:x?S:o,target:x?l:k,targetHandle:x?o:S};_.connection=Y;const K=R&&D&&(s===ci.Strict?x&&O==="source"||!x&&O==="target":k!==l||S!==o);_.isValid=K&&f(Y),_.toHandle=$w(k,O,S,g,s,!0)}return _}const Bm={onPointerDown:tR,isValid:Pw};function nR({domNode:e,panZoom:n,getTransform:s,getViewScale:l}){const o=Hr(e);function d({translateExtent:h,width:m,height:f,zoomStep:g=1,pannable:x=!0,zoomable:p=!0,inversePan:y=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!n)return;const S=s(),R=k.sourceEvent.ctrlKey&&zo()?10:1,D=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*g,Y=S[2]*Math.pow(2,D*R);n.scaleTo(Y)};let N=[0,0];const C=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(N=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},_=k=>{const S=s();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!n)return;const R=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],D=[R[0]-N[0],R[1]-N[1]];N=R;const Y=l()*Math.max(S[2],Math.log(S[2]))*(y?-1:1),z={x:S[0]-D[0]*Y,y:S[1]-D[1]*Y},K=[[0,0],[m,f]];n.setViewportConstrained({x:z.x,y:z.y,zoom:S[2]},K,h)},O=xw().on("start",C).on("zoom",x?_:null).on("zoom.wheel",p?w:null);o.call(O,{})}function c(){o.on("zoom",null)}return{update:d,destroy:c,pointer:cs}}const cu=e=>({x:e.x,y:e.y,zoom:e.k}),Xh=({x:e,y:n,zoom:s})=>lu.translate(e,n).scale(s),ti=(e,n)=>e.target.closest(`.${n}`),Uw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),rR=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Kh=(e,n=0,s=rR,l=()=>{})=>{const o=typeof n=="number"&&n>0;return o||l(),o?e.transition().duration(n).ease(s).on("end",l):e},qw=e=>{const n=e.ctrlKey&&zo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function sR({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:l,panOnScrollMode:o,panOnScrollSpeed:d,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:m,onPanZoomEnd:f}){return g=>{if(ti(g,n))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const x=s.property("__zoom").k||1;if(g.ctrlKey&&c){const C=cs(g),_=qw(g),O=x*Math.pow(2,_);l.scaleTo(s,O,C,g);return}const p=g.deltaMode===1?20:1;let y=o===cl.Vertical?0:g.deltaX*p,w=o===cl.Horizontal?0:g.deltaY*p;!zo()&&g.shiftKey&&o!==cl.Vertical&&(y=g.deltaY*p,w=0),l.translateBy(s,-(y/x)*d,-(w/x)*d,{internal:!0});const N=cu(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(m?.(g,N),e.panScrollTimeout=setTimeout(()=>{f?.(g,N),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,h?.(g,N))}}function aR({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:s}){return function(l,o){const d=l.type==="wheel",c=!n&&d&&!l.ctrlKey,h=ti(l,e);if(l.ctrlKey&&d&&h&&l.preventDefault(),c||h)return null;l.preventDefault(),s.call(this,l,o)}}function lR({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return l=>{if(l.sourceEvent?.internal)return;const o=cu(l.transform);e.mouseButton=l.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,l.sourceEvent?.type==="mousedown"&&n(!0),s&&s?.(l.sourceEvent,o)}}function iR({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:l,onPanZoom:o}){return d=>{e.usedRightMouseButton=!!(s&&Uw(n,e.mouseButton??0)),d.sourceEvent?.sync||l([d.transform.x,d.transform.y,d.transform.k]),o&&!d.sourceEvent?.internal&&o?.(d.sourceEvent,cu(d.transform))}}function oR({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:l,onPanZoomEnd:o,onPaneContextMenu:d}){return c=>{if(!c.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,d&&Uw(n,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&d(c.sourceEvent),e.usedRightMouseButton=!1,l(!1),o)){const h=cu(c.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(c.sourceEvent,h)},s?150:0)}}}function cR({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:l,panOnScroll:o,zoomOnDoubleClick:d,userSelectionActive:c,noWheelClassName:h,noPanClassName:m,lib:f,connectionInProgress:g}){return x=>{const p=e||n,y=s&&x.ctrlKey,w=x.type==="wheel";if(x.button===1&&x.type==="mousedown"&&(ti(x,`${f}-flow__node`)||ti(x,`${f}-flow__edge`)))return!0;if(!l&&!p&&!o&&!d&&!s||c||g&&!w||ti(x,h)&&w||ti(x,m)&&(!w||o&&w&&!e)||!s&&x.ctrlKey&&w)return!1;if(!s&&x.type==="touchstart"&&x.touches?.length>1)return x.preventDefault(),!1;if(!p&&!o&&!y&&w||!l&&(x.type==="mousedown"||x.type==="touchstart")||Array.isArray(l)&&!l.includes(x.button)&&x.type==="mousedown")return!1;const N=Array.isArray(l)&&l.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||w)&&N}}function dR({domNode:e,minZoom:n,maxZoom:s,translateExtent:l,viewport:o,onPanZoom:d,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:m}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=e.getBoundingClientRect(),x=xw().scaleExtent([n,s]).translateExtent(l),p=Hr(e).call(x);O({x:o.x,y:o.y,zoom:ui(o.zoom,n,s)},[[0,0],[g.width,g.height]],l);const y=p.on("wheel.zoom"),w=p.on("dblclick.zoom");x.wheelDelta(qw);function N(G,V){return p?new Promise(E=>{x?.interpolate(V?.interpolate==="linear"?ko:wd).transform(Kh(p,V?.duration,V?.ease,()=>E(!0)),G)}):Promise.resolve(!1)}function C({noWheelClassName:G,noPanClassName:V,onPaneContextMenu:E,userSelectionActive:T,panOnScroll:L,panOnDrag:A,panOnScrollMode:P,panOnScrollSpeed:q,preventScrolling:W,zoomOnPinch:B,zoomOnScroll:F,zoomOnDoubleClick:X,zoomActivationKeyPressed:I,lib:M,onTransformChange:H,connectionInProgress:Z,paneClickDistance:ee,selectionOnDrag:ne}){T&&!f.isZoomingOrPanning&&_();const ae=L&&!I&&!T;x.clickDistance(ne?1/0:!us(ee)||ee<0?0:ee);const he=ae?sR({zoomPanValues:f,noWheelClassName:G,d3Selection:p,d3Zoom:x,panOnScrollMode:P,panOnScrollSpeed:q,zoomOnPinch:B,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:h}):aR({noWheelClassName:G,preventScrolling:W,d3ZoomHandler:y});if(p.on("wheel.zoom",he,{passive:!1}),!T){const Le=lR({zoomPanValues:f,onDraggingChange:m,onPanZoomStart:c});x.on("start",Le);const ye=iR({zoomPanValues:f,panOnDrag:A,onPaneContextMenu:!!E,onPanZoom:d,onTransformChange:H});x.on("zoom",ye);const je=oR({zoomPanValues:f,panOnDrag:A,panOnScroll:L,onPaneContextMenu:E,onPanZoomEnd:h,onDraggingChange:m});x.on("end",je)}const Ne=cR({zoomActivationKeyPressed:I,panOnDrag:A,zoomOnScroll:F,panOnScroll:L,zoomOnDoubleClick:X,zoomOnPinch:B,userSelectionActive:T,noPanClassName:V,noWheelClassName:G,lib:M,connectionInProgress:Z});x.filter(Ne),X?p.on("dblclick.zoom",w):p.on("dblclick.zoom",null)}function _(){x.on("zoom",null)}async function O(G,V,E){const T=Xh(G),L=x?.constrain()(T,V,E);return L&&await N(L),new Promise(A=>A(L))}async function k(G,V){const E=Xh(G);return await N(E,V),new Promise(T=>T(E))}function S(G){if(p){const V=Xh(G),E=p.property("__zoom");(E.k!==G.zoom||E.x!==G.x||E.y!==G.y)&&x?.transform(p,V,null,{sync:!0})}}function R(){const G=p?mw(p.node()):{x:0,y:0,k:1};return{x:G.x,y:G.y,zoom:G.k}}function D(G,V){return p?new Promise(E=>{x?.interpolate(V?.interpolate==="linear"?ko:wd).scaleTo(Kh(p,V?.duration,V?.ease,()=>E(!0)),G)}):Promise.resolve(!1)}function Y(G,V){return p?new Promise(E=>{x?.interpolate(V?.interpolate==="linear"?ko:wd).scaleBy(Kh(p,V?.duration,V?.ease,()=>E(!0)),G)}):Promise.resolve(!1)}function z(G){x?.scaleExtent(G)}function K(G){x?.translateExtent(G)}function U(G){const V=!us(G)||G<0?0:G;x?.clickDistance(V)}return{update:C,destroy:_,setViewport:k,setViewportConstrained:O,getViewport:R,scaleTo:D,scaleBy:Y,setScaleExtent:z,setTranslateExtent:K,syncViewport:S,setClickDistance:U}}var mi;(function(e){e.Line="line",e.Handle="handle"})(mi||(mi={}));function uR({width:e,prevWidth:n,height:s,prevHeight:l,affectsX:o,affectsY:d}){const c=e-n,h=s-l,m=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&o&&(m[0]=m[0]*-1),h&&d&&(m[1]=m[1]*-1),m}function dv(e){const n=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),l=e.includes("left"),o=e.includes("top");return{isHorizontal:n,isVertical:s,affectsX:l,affectsY:o}}function Ma(e,n){return Math.max(0,n-e)}function Oa(e,n){return Math.max(0,e-n)}function xd(e,n,s){return Math.max(0,n-e,e-s)}function uv(e,n){return e?!n:n}function fR(e,n,s,l,o,d,c,h){let{affectsX:m,affectsY:f}=n;const{isHorizontal:g,isVertical:x}=n,p=g&&x,{xSnapped:y,ySnapped:w}=s,{minWidth:N,maxWidth:C,minHeight:_,maxHeight:O}=l,{x:k,y:S,width:R,height:D,aspectRatio:Y}=e;let z=Math.floor(g?y-e.pointerX:0),K=Math.floor(x?w-e.pointerY:0);const U=R+(m?-z:z),G=D+(f?-K:K),V=-d[0]*R,E=-d[1]*D;let T=xd(U,N,C),L=xd(G,_,O);if(c){let q=0,W=0;m&&z<0?q=Ma(k+z+V,c[0][0]):!m&&z>0&&(q=Oa(k+U+V,c[1][0])),f&&K<0?W=Ma(S+K+E,c[0][1]):!f&&K>0&&(W=Oa(S+G+E,c[1][1])),T=Math.max(T,q),L=Math.max(L,W)}if(h){let q=0,W=0;m&&z>0?q=Oa(k+z,h[0][0]):!m&&z<0&&(q=Ma(k+U,h[1][0])),f&&K>0?W=Oa(S+K,h[0][1]):!f&&K<0&&(W=Ma(S+G,h[1][1])),T=Math.max(T,q),L=Math.max(L,W)}if(o){if(g){const q=xd(U/Y,_,O)*Y;if(T=Math.max(T,q),c){let W=0;!m&&!f||m&&!f&&p?W=Oa(S+E+U/Y,c[1][1])*Y:W=Ma(S+E+(m?z:-z)/Y,c[0][1])*Y,T=Math.max(T,W)}if(h){let W=0;!m&&!f||m&&!f&&p?W=Ma(S+U/Y,h[1][1])*Y:W=Oa(S+(m?z:-z)/Y,h[0][1])*Y,T=Math.max(T,W)}}if(x){const q=xd(G*Y,N,C)/Y;if(L=Math.max(L,q),c){let W=0;!m&&!f||f&&!m&&p?W=Oa(k+G*Y+V,c[1][0])/Y:W=Ma(k+(f?K:-K)*Y+V,c[0][0])/Y,L=Math.max(L,W)}if(h){let W=0;!m&&!f||f&&!m&&p?W=Ma(k+G*Y,h[1][0])/Y:W=Oa(k+(f?K:-K)*Y,h[0][0])/Y,L=Math.max(L,W)}}}K=K+(K<0?L:-L),z=z+(z<0?T:-T),o&&(p?U>G*Y?K=(uv(m,f)?-z:z)/Y:z=(uv(m,f)?-K:K)*Y:g?(K=z/Y,f=m):(z=K*Y,m=f));const A=m?k+z:k,P=f?S+K:S;return{width:R+(m?-z:z),height:D+(f?-K:K),x:d[0]*z*(m?-1:1)+A,y:d[1]*K*(f?-1:1)+P}}const Vw={width:0,height:0,x:0,y:0},hR={...Vw,pointerX:0,pointerY:0,aspectRatio:1};function mR(e){return[[0,0],[e.measured.width,e.measured.height]]}function xR(e,n,s){const l=n.position.x+e.position.x,o=n.position.y+e.position.y,d=e.measured.width??0,c=e.measured.height??0,h=s[0]*d,m=s[1]*c;return[[l-h,o-m],[l+d-h,o+c-m]]}function gR({domNode:e,nodeId:n,getStoreItems:s,onChange:l,onEnd:o}){const d=Hr(e);let c={controlDirection:dv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:f,boundaries:g,keepAspectRatio:x,resizeDirection:p,onResizeStart:y,onResize:w,onResizeEnd:N,shouldResize:C}){let _={...Vw},O={...hR};c={boundaries:g,resizeDirection:p,keepAspectRatio:x,controlDirection:dv(f)};let k,S=null,R=[],D,Y,z,K=!1;const U=ew().on("start",G=>{const{nodeLookup:V,transform:E,snapGrid:T,snapToGrid:L,nodeOrigin:A,paneDomNode:P}=s();if(k=V.get(n),!k)return;S=P?.getBoundingClientRect()??null;const{xSnapped:q,ySnapped:W}=So(G.sourceEvent,{transform:E,snapGrid:T,snapToGrid:L,containerBounds:S});_={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},O={..._,pointerX:q,pointerY:W,aspectRatio:_.width/_.height},D=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(D=V.get(k.parentId),Y=D&&k.extent==="parent"?mR(D):void 0),R=[],z=void 0;for(const[B,F]of V)if(F.parentId===n&&(R.push({id:B,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const X=xR(F,k,F.origin??A);z?z=[[Math.min(X[0][0],z[0][0]),Math.min(X[0][1],z[0][1])],[Math.max(X[1][0],z[1][0]),Math.max(X[1][1],z[1][1])]]:z=X}y?.(G,{..._})}).on("drag",G=>{const{transform:V,snapGrid:E,snapToGrid:T,nodeOrigin:L}=s(),A=So(G.sourceEvent,{transform:V,snapGrid:E,snapToGrid:T,containerBounds:S}),P=[];if(!k)return;const{x:q,y:W,width:B,height:F}=_,X={},I=k.origin??L,{width:M,height:H,x:Z,y:ee}=fR(O,c.controlDirection,A,c.boundaries,c.keepAspectRatio,I,Y,z),ne=M!==B,ae=H!==F,he=Z!==q&&ne,Ne=ee!==W&&ae;if(!he&&!Ne&&!ne&&!ae)return;if((he||Ne||I[0]===1||I[1]===1)&&(X.x=he?Z:_.x,X.y=Ne?ee:_.y,_.x=X.x,_.y=X.y,R.length>0)){const Ae=Z-q,$e=ee-W;for(const Xe of R)Xe.position={x:Xe.position.x-Ae+I[0]*(M-B),y:Xe.position.y-$e+I[1]*(H-F)},P.push(Xe)}if((ne||ae)&&(X.width=ne&&(!c.resizeDirection||c.resizeDirection==="horizontal")?M:_.width,X.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?H:_.height,_.width=X.width,_.height=X.height),D&&k.expandParent){const Ae=I[0]*(X.width??0);X.x&&X.x<Ae&&(_.x=Ae,O.x=O.x-(X.x-Ae));const $e=I[1]*(X.height??0);X.y&&X.y<$e&&(_.y=$e,O.y=O.y-(X.y-$e))}const Le=uR({width:_.width,prevWidth:B,height:_.height,prevHeight:F,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),ye={..._,direction:Le};C?.(G,ye)!==!1&&(K=!0,w?.(G,ye),l(X,P))}).on("end",G=>{K&&(N?.(G,{..._}),o?.({..._}),K=!1)});d.call(U)}function m(){d.on(".drag",null)}return{update:h,destroy:m}}var Zh={exports:{}},Wh={},Qh={exports:{}},Jh={};var fv;function pR(){if(fv)return Jh;fv=1;var e=Po();function n(x,p){return x===p&&(x!==0||1/x===1/p)||x!==x&&p!==p}var s=typeof Object.is=="function"?Object.is:n,l=e.useState,o=e.useEffect,d=e.useLayoutEffect,c=e.useDebugValue;function h(x,p){var y=p(),w=l({inst:{value:y,getSnapshot:p}}),N=w[0].inst,C=w[1];return d(function(){N.value=y,N.getSnapshot=p,m(N)&&C({inst:N})},[x,y,p]),o(function(){return m(N)&&C({inst:N}),x(function(){m(N)&&C({inst:N})})},[x]),c(y),y}function m(x){var p=x.getSnapshot;x=x.value;try{var y=p();return!s(x,y)}catch{return!0}}function f(x,p){return p()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:h;return Jh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Jh}var hv;function bR(){return hv||(hv=1,Qh.exports=pR()),Qh.exports}var mv;function yR(){if(mv)return Wh;mv=1;var e=Po(),n=bR();function s(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var l=typeof Object.is=="function"?Object.is:s,o=n.useSyncExternalStore,d=e.useRef,c=e.useEffect,h=e.useMemo,m=e.useDebugValue;return Wh.useSyncExternalStoreWithSelector=function(f,g,x,p,y){var w=d(null);if(w.current===null){var N={hasValue:!1,value:null};w.current=N}else N=w.current;w=h(function(){function _(D){if(!O){if(O=!0,k=D,D=p(D),y!==void 0&&N.hasValue){var Y=N.value;if(y(Y,D))return S=Y}return S=D}if(Y=S,l(k,D))return Y;var z=p(D);return y!==void 0&&y(Y,z)?(k=D,Y):(k=D,S=z)}var O=!1,k,S,R=x===void 0?null:x;return[function(){return _(g())},R===null?void 0:function(){return _(R())}]},[g,x,p,y]);var C=o(f,w[0],w[1]);return c(function(){N.hasValue=!0,N.value=C},[C]),m(C),C},Wh}var xv;function vR(){return xv||(xv=1,Zh.exports=yR()),Zh.exports}var jR=vR();const wR=Xd(jR),NR={},gv=e=>{let n;const s=new Set,l=(g,x)=>{const p=typeof g=="function"?g(n):g;if(!Object.is(p,n)){const y=n;n=x??(typeof p!="object"||p===null)?p:Object.assign({},n,p),s.forEach(w=>w(n,y))}},o=()=>n,m={setState:l,getState:o,getInitialState:()=>f,subscribe:g=>(s.add(g),()=>s.delete(g)),destroy:()=>{(NR?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),s.clear()}},f=n=e(l,o,m);return m},kR=e=>e?gv(e):gv,{useDebugValue:SR}=H2,{useSyncExternalStoreWithSelector:CR}=wR,ER=e=>e;function Fw(e,n=ER,s){const l=CR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return SR(l),l}const pv=(e,n)=>{const s=kR(e),l=(o,d=n)=>Fw(s,o,d);return Object.assign(l,s),l},TR=(e,n)=>e?pv(e,n):pv;function An(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[l,o]of e)if(!Object.is(o,n.get(l)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const l of e)if(!n.has(l))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(n).length)return!1;for(const l of s)if(!Object.prototype.hasOwnProperty.call(n,l)||!Object.is(e[l],n[l]))return!1;return!0}const du=v.createContext(null),AR=du.Provider,Yw=Ts.error001();function Jt(e,n){const s=v.useContext(du);if(s===null)throw new Error(Yw);return Fw(s,e,n)}function _n(){const e=v.useContext(du);if(e===null)throw new Error(Yw);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const bv={display:"none"},_R={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Gw="react-flow__node-desc",Xw="react-flow__edge-desc",MR="react-flow__aria-live",OR=e=>e.ariaLiveMessage,RR=e=>e.ariaLabelConfig;function DR({rfId:e}){const n=Jt(OR);return t.jsx("div",{id:`${MR}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:_R,children:n})}function LR({rfId:e,disableKeyboardA11y:n}){const s=Jt(RR);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${Gw}-${e}`,style:bv,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${Xw}-${e}`,style:bv,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(DR,{rfId:e})]})}const uu=v.forwardRef(({position:e="top-left",children:n,className:s,style:l,...o},d)=>{const c=`${e}`.split("-");return t.jsx("div",{className:Zn(["react-flow__panel",s,...c]),style:l,ref:d,...o,children:n})});uu.displayName="Panel";function IR({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(uu,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const zR=e=>{const n=[],s=[];for(const[,l]of e.nodeLookup)l.selected&&n.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&s.push(l);return{selectedNodes:n,selectedEdges:s}},gd=e=>e.id;function $R(e,n){return An(e.selectedNodes.map(gd),n.selectedNodes.map(gd))&&An(e.selectedEdges.map(gd),n.selectedEdges.map(gd))}function BR({onSelectionChange:e}){const n=_n(),{selectedNodes:s,selectedEdges:l}=Jt(zR,$R);return v.useEffect(()=>{const o={nodes:s,edges:l};e?.(o),n.getState().onSelectionChangeHandlers.forEach(d=>d(o))},[s,l,e]),null}const HR=e=>!!e.onSelectionChangeHandlers;function PR({onSelectionChange:e}){const n=Jt(HR);return e||n?t.jsx(BR,{onSelectionChange:e}):null}const Kw=[0,0],UR={x:0,y:0,zoom:1},qR=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],yv=[...qR,"rfId"],VR=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),vv={translateExtent:Do,nodeOrigin:Kw,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function FR(e){const{setNodes:n,setEdges:s,setMinZoom:l,setMaxZoom:o,setTranslateExtent:d,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:m}=Jt(VR,An),f=_n();v.useEffect(()=>(m(e.defaultNodes,e.defaultEdges),()=>{g.current=vv,h()}),[]);const g=v.useRef(vv);return v.useEffect(()=>{for(const x of yv){const p=e[x],y=g.current[x];p!==y&&(typeof e[x]>"u"||(x==="nodes"?n(p):x==="edges"?s(p):x==="minZoom"?l(p):x==="maxZoom"?o(p):x==="translateExtent"?d(p):x==="nodeExtent"?c(p):x==="ariaLabelConfig"?f.setState({ariaLabelConfig:TO(p)}):x==="fitView"?f.setState({fitViewQueued:p}):x==="fitViewOptions"?f.setState({fitViewOptions:p}):f.setState({[x]:p})))}g.current=e},yv.map(x=>e[x])),null}function jv(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function YR(e){const[n,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const l=jv(),o=()=>s(l?.matches?"dark":"light");return o(),l?.addEventListener("change",o),()=>{l?.removeEventListener("change",o)}},[e]),n!==null?n:jv()?.matches?"dark":"light"}const wv=typeof document<"u"?document:null;function $o(e=null,n={target:wv,actInsideInputWithModifier:!0}){const[s,l]=v.useState(!1),o=v.useRef(!1),d=v.useRef(new Set([])),[c,h]=v.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(x=>typeof x=="string").map(x=>x.replace("+",`
56
- `).replace(`
57
-
58
- `,`
59
- +`).split(`
60
- `)),g=f.reduce((x,p)=>x.concat(...p),[]);return[f,g]}return[[],[]]},[e]);return v.useEffect(()=>{const m=n?.target??wv,f=n?.actInsideInputWithModifier??!0;if(e!==null){const g=y=>{if(o.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!o.current||o.current&&!f)&&Tw(y))return!1;const N=kv(y.code,h);if(d.current.add(y[N]),Nv(c,d.current,!1)){const C=y.composedPath?.()?.[0]||y.target,_=C?.nodeName==="BUTTON"||C?.nodeName==="A";n.preventDefault!==!1&&(o.current||!_)&&y.preventDefault(),l(!0)}},x=y=>{const w=kv(y.code,h);Nv(c,d.current,!0)?(l(!1),d.current.clear()):d.current.delete(y[w]),y.key==="Meta"&&d.current.clear(),o.current=!1},p=()=>{d.current.clear(),l(!1)};return m?.addEventListener("keydown",g),m?.addEventListener("keyup",x),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{m?.removeEventListener("keydown",g),m?.removeEventListener("keyup",x),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,l]),s}function Nv(e,n,s){return e.filter(l=>s||l.length===n.size).some(l=>l.every(o=>n.has(o)))}function kv(e,n){return n.includes(e)?"code":"key"}const GR=()=>{const e=_n();return v.useMemo(()=>({zoomIn:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomOut:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1/1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomTo:(n,s)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(n,{duration:s?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,s)=>{const{transform:[l,o,d],panZoom:c}=e.getState();return c?(await c.setViewport({x:n.x??l,y:n.y??o,zoom:n.zoom??d},s),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,s,l]=e.getState().transform;return{x:n,y:s,zoom:l}},setCenter:async(n,s,l)=>e.getState().setCenter(n,s,l),fitBounds:async(n,s)=>{const{width:l,height:o,minZoom:d,maxZoom:c,panZoom:h}=e.getState(),m=Cx(n,l,o,d,c,s?.padding??.1);return h?(await h.setViewport(m,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(n,s={})=>{const{transform:l,snapGrid:o,snapToGrid:d,domNode:c}=e.getState();if(!c)return n;const{x:h,y:m}=c.getBoundingClientRect(),f={x:n.x-h,y:n.y-m},g=s.snapGrid??o,x=s.snapToGrid??d;return Zo(f,l,x,g)},flowToScreenPosition:n=>{const{transform:s,domNode:l}=e.getState();if(!l)return n;const{x:o,y:d}=l.getBoundingClientRect(),c=Fd(n,s);return{x:c.x+o,y:c.y+d}}}),[])};function Zw(e,n){const s=[],l=new Map,o=[];for(const d of e)if(d.type==="add"){o.push(d);continue}else if(d.type==="remove"||d.type==="replace")l.set(d.id,[d]);else{const c=l.get(d.id);c?c.push(d):l.set(d.id,[d])}for(const d of n){const c=l.get(d.id);if(!c){s.push(d);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){s.push({...c[0].item});continue}const h={...d};for(const m of c)XR(m,h);s.push(h)}return o.length&&o.forEach(d=>{d.index!==void 0?s.splice(d.index,0,{...d.item}):s.push({...d.item})}),s}function XR(e,n){switch(e.type){case"select":{n.selected=e.selected;break}case"position":{typeof e.position<"u"&&(n.position=e.position),typeof e.dragging<"u"&&(n.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(n.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(n.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(n.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(n.resizing=e.resizing);break}}}function Ww(e,n){return Zw(e,n)}function Qw(e,n){return Zw(e,n)}function al(e,n){return{id:e,type:"select",selected:n}}function ni(e,n=new Set,s=!1){const l=[];for(const[o,d]of e){const c=n.has(o);!(d.selected===void 0&&!c)&&d.selected!==c&&(s&&(d.selected=c),l.push(al(d.id,c)))}return l}function Sv({items:e=[],lookup:n}){const s=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,d]of e.entries()){const c=n.get(d.id),h=c?.internals?.userNode??c;h!==void 0&&h!==d&&s.push({id:d.id,item:d,type:"replace"}),h===void 0&&s.push({item:d,type:"add",index:o})}for(const[o]of n)l.get(o)===void 0&&s.push({id:o,type:"remove"});return s}function Cv(e){return{id:e.id,type:"remove"}}const Ev=e=>bO(e),KR=e=>vw(e);function Jw(e){return v.forwardRef(e)}const ZR=typeof window<"u"?v.useLayoutEffect:v.useEffect;function Tv(e){const[n,s]=v.useState(BigInt(0)),[l]=v.useState(()=>WR(()=>s(o=>o+BigInt(1))));return ZR(()=>{const o=l.get();o.length&&(e(o),l.reset())},[n]),l}function WR(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:s=>{n.push(s),e()}}}const eN=v.createContext(null);function QR({children:e}){const n=_n(),s=v.useCallback(h=>{const{nodes:m=[],setNodes:f,hasDefaultNodes:g,onNodesChange:x,nodeLookup:p,fitViewQueued:y,onNodesChangeMiddlewareMap:w}=n.getState();let N=m;for(const _ of h)N=typeof _=="function"?_(N):_;let C=Sv({items:N,lookup:p});for(const _ of w.values())C=_(C);g&&f(N),C.length>0?x?.(C):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:O,setNodes:k}=n.getState();_&&k(O)})},[]),l=Tv(s),o=v.useCallback(h=>{const{edges:m=[],setEdges:f,hasDefaultEdges:g,onEdgesChange:x,edgeLookup:p}=n.getState();let y=m;for(const w of h)y=typeof w=="function"?w(y):w;g?f(y):x&&x(Sv({items:y,lookup:p}))},[]),d=Tv(o),c=v.useMemo(()=>({nodeQueue:l,edgeQueue:d}),[]);return t.jsx(eN.Provider,{value:c,children:e})}function JR(){const e=v.useContext(eN);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const eD=e=>!!e.panZoom;function Rx(){const e=GR(),n=_n(),s=JR(),l=Jt(eD),o=v.useMemo(()=>{const d=x=>n.getState().nodeLookup.get(x),c=x=>{s.nodeQueue.push(x)},h=x=>{s.edgeQueue.push(x)},m=x=>{const{nodeLookup:p,nodeOrigin:y}=n.getState(),w=Ev(x)?x:p.get(x.id),N=w.parentId?Cw(w.position,w.measured,w.parentId,p,y):w.position,C={...w,position:N,width:w.measured?.width??w.width,height:w.measured?.height??w.height};return fi(C)},f=(x,p,y={replace:!1})=>{c(w=>w.map(N=>{if(N.id===x){const C=typeof p=="function"?p(N):p;return y.replace&&Ev(C)?C:{...N,...C}}return N}))},g=(x,p,y={replace:!1})=>{h(w=>w.map(N=>{if(N.id===x){const C=typeof p=="function"?p(N):p;return y.replace&&KR(C)?C:{...N,...C}}return N}))};return{getNodes:()=>n.getState().nodes.map(x=>({...x})),getNode:x=>d(x)?.internals.userNode,getInternalNode:d,getEdges:()=>{const{edges:x=[]}=n.getState();return x.map(p=>({...p}))},getEdge:x=>n.getState().edgeLookup.get(x),setNodes:c,setEdges:h,addNodes:x=>{const p=Array.isArray(x)?x:[x];s.nodeQueue.push(y=>[...y,...p])},addEdges:x=>{const p=Array.isArray(x)?x:[x];s.edgeQueue.push(y=>[...y,...p])},toObject:()=>{const{nodes:x=[],edges:p=[],transform:y}=n.getState(),[w,N,C]=y;return{nodes:x.map(_=>({..._})),edges:p.map(_=>({..._})),viewport:{x:w,y:N,zoom:C}}},deleteElements:async({nodes:x=[],edges:p=[]})=>{const{nodes:y,edges:w,onNodesDelete:N,onEdgesDelete:C,triggerNodeChanges:_,triggerEdgeChanges:O,onDelete:k,onBeforeDelete:S}=n.getState(),{nodes:R,edges:D}=await NO({nodesToRemove:x,edgesToRemove:p,nodes:y,edges:w,onBeforeDelete:S}),Y=D.length>0,z=R.length>0;if(Y){const K=D.map(Cv);C?.(D),O(K)}if(z){const K=R.map(Cv);N?.(R),_(K)}return(z||Y)&&k?.({nodes:R,edges:D}),{deletedNodes:R,deletedEdges:D}},getIntersectingNodes:(x,p=!0,y)=>{const w=Jy(x),N=w?x:m(x),C=y!==void 0;return N?(y||n.getState().nodes).filter(_=>{const O=n.getState().nodeLookup.get(_.id);if(O&&!w&&(_.id===x.id||!O.internals.positionAbsolute))return!1;const k=fi(C?_:O),S=Io(k,N);return p&&S>0||S>=k.width*k.height||S>=N.width*N.height}):[]},isNodeIntersecting:(x,p,y=!0)=>{const N=Jy(x)?x:m(x);if(!N)return!1;const C=Io(N,p);return y&&C>0||C>=p.width*p.height||C>=N.width*N.height},updateNode:f,updateNodeData:(x,p,y={replace:!1})=>{f(x,w=>{const N=typeof p=="function"?p(w):p;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},updateEdge:g,updateEdgeData:(x,p,y={replace:!1})=>{g(x,w=>{const N=typeof p=="function"?p(w):p;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},getNodesBounds:x=>{const{nodeLookup:p,nodeOrigin:y}=n.getState();return yO(x,{nodeLookup:p,nodeOrigin:y})},getHandleConnections:({type:x,id:p,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}-${x}${p?`-${p}`:""}`)?.values()??[]),getNodeConnections:({type:x,handleId:p,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}${x?p?`-${x}-${p}`:`-${x}`:""}`)?.values()??[]),fitView:async x=>{const p=n.getState().fitViewResolver??EO();return n.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:p}),s.nodeQueue.push(y=>[...y]),p.promise}}},[]);return v.useMemo(()=>({...o,...e,viewportInitialized:l}),[l])}const Av=e=>e.selected,tD=typeof window<"u"?window:void 0;function nD({deleteKeyCode:e,multiSelectionKeyCode:n}){const s=_n(),{deleteElements:l}=Rx(),o=$o(e,{actInsideInputWithModifier:!1}),d=$o(n,{target:tD});v.useEffect(()=>{if(o){const{edges:c,nodes:h}=s.getState();l({nodes:h.filter(Av),edges:c.filter(Av)}),s.setState({nodesSelectionActive:!1})}},[o]),v.useEffect(()=>{s.setState({multiSelectionActive:d})},[d])}function rD(e){const n=_n();v.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const l=Ex(e.current);(l.height===0||l.width===0)&&n.getState().onError?.("004",Ts.error004()),n.setState({width:l.width||500,height:l.height||500})};if(e.current){s(),window.addEventListener("resize",s);const l=new ResizeObserver(()=>s());return l.observe(e.current),()=>{window.removeEventListener("resize",s),l&&e.current&&l.unobserve(e.current)}}},[])}const fu={position:"absolute",width:"100%",height:"100%",top:0,left:0},sD=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function aD({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:s=!0,panOnScroll:l=!1,panOnScrollSpeed:o=.5,panOnScrollMode:d=cl.Free,zoomOnDoubleClick:c=!0,panOnDrag:h=!0,defaultViewport:m,translateExtent:f,minZoom:g,maxZoom:x,zoomActivationKeyCode:p,preventScrolling:y=!0,children:w,noWheelClassName:N,noPanClassName:C,onViewportChange:_,isControlledViewport:O,paneClickDistance:k,selectionOnDrag:S}){const R=_n(),D=v.useRef(null),{userSelectionActive:Y,lib:z,connectionInProgress:K}=Jt(sD,An),U=$o(p),G=v.useRef();rD(D);const V=v.useCallback(E=>{_?.({x:E[0],y:E[1],zoom:E[2]}),O||R.setState({transform:E})},[_,O]);return v.useEffect(()=>{if(D.current){G.current=dR({domNode:D.current,minZoom:g,maxZoom:x,translateExtent:f,viewport:m,onDraggingChange:A=>R.setState(P=>P.paneDragging===A?P:{paneDragging:A}),onPanZoomStart:(A,P)=>{const{onViewportChangeStart:q,onMoveStart:W}=R.getState();W?.(A,P),q?.(P)},onPanZoom:(A,P)=>{const{onViewportChange:q,onMove:W}=R.getState();W?.(A,P),q?.(P)},onPanZoomEnd:(A,P)=>{const{onViewportChangeEnd:q,onMoveEnd:W}=R.getState();W?.(A,P),q?.(P)}});const{x:E,y:T,zoom:L}=G.current.getViewport();return R.setState({panZoom:G.current,transform:[E,T,L],domNode:D.current.closest(".react-flow")}),()=>{G.current?.destroy()}}},[]),v.useEffect(()=>{G.current?.update({onPaneContextMenu:e,zoomOnScroll:n,zoomOnPinch:s,panOnScroll:l,panOnScrollSpeed:o,panOnScrollMode:d,zoomOnDoubleClick:c,panOnDrag:h,zoomActivationKeyPressed:U,preventScrolling:y,noPanClassName:C,userSelectionActive:Y,noWheelClassName:N,lib:z,onTransformChange:V,connectionInProgress:K,selectionOnDrag:S,paneClickDistance:k})},[e,n,s,l,o,d,c,h,U,y,C,Y,N,z,V,K,S,k]),t.jsx("div",{className:"react-flow__renderer",ref:D,style:fu,children:w})}const lD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function iD(){const{userSelectionActive:e,userSelectionRect:n}=Jt(lD,An);return e&&n?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const em=(e,n)=>s=>{s.target===n.current&&e?.(s)},oD=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function cD({isSelecting:e,selectionKeyPressed:n,selectionMode:s=Lo.Full,panOnDrag:l,paneClickDistance:o,selectionOnDrag:d,onSelectionStart:c,onSelectionEnd:h,onPaneClick:m,onPaneContextMenu:f,onPaneScroll:g,onPaneMouseEnter:x,onPaneMouseMove:p,onPaneMouseLeave:y,children:w}){const N=_n(),{userSelectionActive:C,elementsSelectable:_,dragging:O,connectionInProgress:k}=Jt(oD,An),S=_&&(e||C),R=v.useRef(null),D=v.useRef(),Y=v.useRef(new Set),z=v.useRef(new Set),K=v.useRef(!1),U=q=>{if(K.current||k){K.current=!1;return}m?.(q),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},G=q=>{if(Array.isArray(l)&&l?.includes(2)){q.preventDefault();return}f?.(q)},V=g?q=>g(q):void 0,E=q=>{K.current&&(q.stopPropagation(),K.current=!1)},T=q=>{const{domNode:W}=N.getState();if(D.current=W?.getBoundingClientRect(),!D.current)return;const B=q.target===R.current;if(!B&&!!q.target.closest(".nokey")||!e||!(d&&B||n)||q.button!==0||!q.isPrimary)return;q.target?.setPointerCapture?.(q.pointerId),K.current=!1;const{x:I,y:M}=fs(q.nativeEvent,D.current);N.setState({userSelectionRect:{width:0,height:0,startX:I,startY:M,x:I,y:M}}),B||(q.stopPropagation(),q.preventDefault())},L=q=>{const{userSelectionRect:W,transform:B,nodeLookup:F,edgeLookup:X,connectionLookup:I,triggerNodeChanges:M,triggerEdgeChanges:H,defaultEdgeOptions:Z,resetSelectedElements:ee}=N.getState();if(!D.current||!W)return;const{x:ne,y:ae}=fs(q.nativeEvent,D.current),{startX:he,startY:Ne}=W;if(!K.current){const $e=n?0:o;if(Math.hypot(ne-he,ae-Ne)<=$e)return;ee(),c?.(q)}K.current=!0;const Le={startX:he,startY:Ne,x:ne<he?ne:he,y:ae<Ne?ae:Ne,width:Math.abs(ne-he),height:Math.abs(ae-Ne)},ye=Y.current,je=z.current;Y.current=new Set(Sx(F,Le,B,s===Lo.Partial,!0).map($e=>$e.id)),z.current=new Set;const Ae=Z?.selectable??!0;for(const $e of Y.current){const Xe=I.get($e);if(Xe)for(const{edgeId:tt}of Xe.values()){const et=X.get(tt);et&&(et.selectable??Ae)&&z.current.add(tt)}}if(!ev(ye,Y.current)){const $e=ni(F,Y.current,!0);M($e)}if(!ev(je,z.current)){const $e=ni(X,z.current);H($e)}N.setState({userSelectionRect:Le,userSelectionActive:!0,nodesSelectionActive:!1})},A=q=>{q.button===0&&(q.target?.releasePointerCapture?.(q.pointerId),!C&&q.target===R.current&&N.getState().userSelectionRect&&U?.(q),N.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(h?.(q),N.setState({nodesSelectionActive:Y.current.size>0})))},P=l===!0||Array.isArray(l)&&l.includes(0);return t.jsxs("div",{className:Zn(["react-flow__pane",{draggable:P,dragging:O,selection:e}]),onClick:S?void 0:em(U,R),onContextMenu:em(G,R),onWheel:em(V,R),onPointerEnter:S?void 0:x,onPointerMove:S?L:p,onPointerUp:S?A:void 0,onPointerDownCapture:S?T:void 0,onClickCapture:S?E:void 0,onPointerLeave:y,ref:R,style:fu,children:[w,t.jsx(iD,{})]})}function Hm({id:e,store:n,unselect:s=!1,nodeRef:l}){const{addSelectedNodes:o,unselectNodesAndEdges:d,multiSelectionActive:c,nodeLookup:h,onError:m}=n.getState(),f=h.get(e);if(!f){m?.("012",Ts.error012(e));return}n.setState({nodesSelectionActive:!1}),f.selected?(s||f.selected&&c)&&(d({nodes:[f],edges:[]}),requestAnimationFrame(()=>l?.current?.blur())):o([e])}function tN({nodeRef:e,disabled:n=!1,noDragClassName:s,handleSelector:l,nodeId:o,isSelectable:d,nodeClickDistance:c}){const h=_n(),[m,f]=v.useState(!1),g=v.useRef();return v.useEffect(()=>{g.current=ZO({getStoreItems:()=>h.getState(),onNodeMouseDown:x=>{Hm({id:x,store:h,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),v.useEffect(()=>{if(!(n||!e.current||!g.current))return g.current.update({noDragClassName:s,handleSelector:l,domNode:e.current,isSelectable:d,nodeId:o,nodeClickDistance:c}),()=>{g.current?.destroy()}},[s,l,n,d,e,o,c]),m}const dD=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function nN(){const e=_n();return v.useCallback(s=>{const{nodeExtent:l,snapToGrid:o,snapGrid:d,nodesDraggable:c,onError:h,updateNodePositions:m,nodeLookup:f,nodeOrigin:g}=e.getState(),x=new Map,p=dD(c),y=o?d[0]:5,w=o?d[1]:5,N=s.direction.x*y*s.factor,C=s.direction.y*w*s.factor;for(const[,_]of f){if(!p(_))continue;let O={x:_.internals.positionAbsolute.x+N,y:_.internals.positionAbsolute.y+C};o&&(O=Ko(O,d));const{position:k,positionAbsolute:S}=jw({nodeId:_.id,nextPosition:O,nodeLookup:f,nodeExtent:l,nodeOrigin:g,onError:h});_.position=k,_.internals.positionAbsolute=S,x.set(_.id,_)}m(x)},[])}const Dx=v.createContext(null),uD=Dx.Provider;Dx.Consumer;const rN=()=>v.useContext(Dx),fD=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),hD=(e,n,s)=>l=>{const{connectionClickStartHandle:o,connectionMode:d,connection:c}=l,{fromHandle:h,toHandle:m,isValid:f}=c,g=m?.nodeId===e&&m?.id===n&&m?.type===s;return{connectingFrom:h?.nodeId===e&&h?.id===n&&h?.type===s,connectingTo:g,clickConnecting:o?.nodeId===e&&o?.id===n&&o?.type===s,isPossibleEndHandle:d===ci.Strict?h?.type!==s:e!==h?.nodeId||n!==h?.id,connectionInProcess:!!h,clickConnectionInProcess:!!o,valid:g&&f}};function mD({type:e="source",position:n=ft.Top,isValidConnection:s,isConnectable:l=!0,isConnectableStart:o=!0,isConnectableEnd:d=!0,id:c,onConnect:h,children:m,className:f,onMouseDown:g,onTouchStart:x,...p},y){const w=c||null,N=e==="target",C=_n(),_=rN(),{connectOnClick:O,noPanClassName:k,rfId:S}=Jt(fD,An),{connectingFrom:R,connectingTo:D,clickConnecting:Y,isPossibleEndHandle:z,connectionInProcess:K,clickConnectionInProcess:U,valid:G}=Jt(hD(_,w,e),An);_||C.getState().onError?.("010",Ts.error010());const V=L=>{const{defaultEdgeOptions:A,onConnect:P,hasDefaultEdges:q}=C.getState(),W={...A,...L};if(q){const{edges:B,setEdges:F}=C.getState();F(DO(W,B))}P?.(W),h?.(W)},E=L=>{if(!_)return;const A=Aw(L.nativeEvent);if(o&&(A&&L.button===0||!A)){const P=C.getState();Bm.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:P.autoPanOnConnect,connectionMode:P.connectionMode,connectionRadius:P.connectionRadius,domNode:P.domNode,nodeLookup:P.nodeLookup,lib:P.lib,isTarget:N,handleId:w,nodeId:_,flowId:P.rfId,panBy:P.panBy,cancelConnection:P.cancelConnection,onConnectStart:P.onConnectStart,onConnectEnd:(...q)=>C.getState().onConnectEnd?.(...q),updateConnection:P.updateConnection,onConnect:V,isValidConnection:s||((...q)=>C.getState().isValidConnection?.(...q)??!0),getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:P.autoPanSpeed,dragThreshold:P.connectionDragThreshold})}A?g?.(L):x?.(L)},T=L=>{const{onClickConnectStart:A,onClickConnectEnd:P,connectionClickStartHandle:q,connectionMode:W,isValidConnection:B,lib:F,rfId:X,nodeLookup:I,connection:M}=C.getState();if(!_||!q&&!o)return;if(!q){A?.(L.nativeEvent,{nodeId:_,handleId:w,handleType:e}),C.setState({connectionClickStartHandle:{nodeId:_,type:e,id:w}});return}const H=Ew(L.target),Z=s||B,{connection:ee,isValid:ne}=Bm.isValid(L.nativeEvent,{handle:{nodeId:_,id:w,type:e},connectionMode:W,fromNodeId:q.nodeId,fromHandleId:q.id||null,fromType:q.type,isValidConnection:Z,flowId:X,doc:H,lib:F,nodeLookup:I});ne&&ee&&V(ee);const ae=structuredClone(M);delete ae.inProgress,ae.toPosition=ae.toHandle?ae.toHandle.position:null,P?.(L,ae),C.setState({connectionClickStartHandle:null})};return t.jsx("div",{"data-handleid":w,"data-nodeid":_,"data-handlepos":n,"data-id":`${S}-${_}-${w}-${e}`,className:Zn(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",k,f,{source:!N,target:N,connectable:l,connectablestart:o,connectableend:d,clickconnecting:Y,connectingfrom:R,connectingto:D,valid:G,connectionindicator:l&&(!K||z)&&(K||U?d:o)}]),onMouseDown:E,onTouchStart:E,onClick:O?T:void 0,ref:y,...p,children:m})}const $a=v.memo(Jw(mD));function xD({data:e,isConnectable:n,sourcePosition:s=ft.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx($a,{type:"source",position:s,isConnectable:n})]})}function gD({data:e,isConnectable:n,targetPosition:s=ft.Top,sourcePosition:l=ft.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx($a,{type:"target",position:s,isConnectable:n}),e?.label,t.jsx($a,{type:"source",position:l,isConnectable:n})]})}function pD(){return null}function bD({data:e,isConnectable:n,targetPosition:s=ft.Top}){return t.jsxs(t.Fragment,{children:[t.jsx($a,{type:"target",position:s,isConnectable:n}),e?.label]})}const Yd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},_v={input:xD,default:gD,output:bD,group:pD};function yD(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const vD=e=>{const{width:n,height:s,x:l,y:o}=Xo(e.nodeLookup,{filter:d=>!!d.selected});return{width:us(n)?n:null,height:us(s)?s:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${o}px)`}};function jD({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:s}){const l=_n(),{width:o,height:d,transformString:c,userSelectionActive:h}=Jt(vD,An),m=nN(),f=v.useRef(null);v.useEffect(()=>{s||f.current?.focus({preventScroll:!0})},[s]);const g=!h&&o!==null&&d!==null;if(tN({nodeRef:f,disabled:!g}),!g)return null;const x=e?y=>{const w=l.getState().nodes.filter(N=>N.selected);e(y,w)}:void 0,p=y=>{Object.prototype.hasOwnProperty.call(Yd,y.key)&&(y.preventDefault(),m({direction:Yd[y.key],factor:y.shiftKey?4:1}))};return t.jsx("div",{className:Zn(["react-flow__nodesselection","react-flow__container",n]),style:{transform:c},children:t.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:s?void 0:-1,onKeyDown:s?void 0:p,style:{width:o,height:d}})})}const Mv=typeof window<"u"?window:void 0,wD=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function sN({children:e,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:l,onPaneMouseLeave:o,onPaneContextMenu:d,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:m,selectionKeyCode:f,selectionOnDrag:g,selectionMode:x,onSelectionStart:p,onSelectionEnd:y,multiSelectionKeyCode:w,panActivationKeyCode:N,zoomActivationKeyCode:C,elementsSelectable:_,zoomOnScroll:O,zoomOnPinch:k,panOnScroll:S,panOnScrollSpeed:R,panOnScrollMode:D,zoomOnDoubleClick:Y,panOnDrag:z,defaultViewport:K,translateExtent:U,minZoom:G,maxZoom:V,preventScrolling:E,onSelectionContextMenu:T,noWheelClassName:L,noPanClassName:A,disableKeyboardA11y:P,onViewportChange:q,isControlledViewport:W}){const{nodesSelectionActive:B,userSelectionActive:F}=Jt(wD,An),X=$o(f,{target:Mv}),I=$o(N,{target:Mv}),M=I||z,H=I||S,Z=g&&M!==!0,ee=X||F||Z;return nD({deleteKeyCode:m,multiSelectionKeyCode:w}),t.jsx(aD,{onPaneContextMenu:d,elementsSelectable:_,zoomOnScroll:O,zoomOnPinch:k,panOnScroll:H,panOnScrollSpeed:R,panOnScrollMode:D,zoomOnDoubleClick:Y,panOnDrag:!X&&M,defaultViewport:K,translateExtent:U,minZoom:G,maxZoom:V,zoomActivationKeyCode:C,preventScrolling:E,noWheelClassName:L,noPanClassName:A,onViewportChange:q,isControlledViewport:W,paneClickDistance:h,selectionOnDrag:Z,children:t.jsxs(cD,{onSelectionStart:p,onSelectionEnd:y,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:l,onPaneMouseLeave:o,onPaneContextMenu:d,onPaneScroll:c,panOnDrag:M,isSelecting:!!ee,selectionMode:x,selectionKeyPressed:X,paneClickDistance:h,selectionOnDrag:Z,children:[e,B&&t.jsx(jD,{onSelectionContextMenu:T,noPanClassName:A,disableKeyboardA11y:P})]})})}sN.displayName="FlowRenderer";const ND=v.memo(sN),kD=e=>n=>e?Sx(n.nodeLookup,{x:0,y:0,width:n.width,height:n.height},n.transform,!0).map(s=>s.id):Array.from(n.nodeLookup.keys());function SD(e){return Jt(v.useCallback(kD(e),[e]),An)}const CD=e=>e.updateNodeInternals;function ED(){const e=Jt(CD),[n]=v.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const l=new Map;s.forEach(o=>{const d=o.target.getAttribute("data-id");l.set(d,{id:d,nodeElement:o.target,force:!0})}),e(l)}));return v.useEffect(()=>()=>{n?.disconnect()},[n]),n}function TD({node:e,nodeType:n,hasDimensions:s,resizeObserver:l}){const o=_n(),d=v.useRef(null),c=v.useRef(null),h=v.useRef(e.sourcePosition),m=v.useRef(e.targetPosition),f=v.useRef(n),g=s&&!!e.internals.handleBounds;return v.useEffect(()=>{d.current&&!e.hidden&&(!g||c.current!==d.current)&&(c.current&&l?.unobserve(c.current),l?.observe(d.current),c.current=d.current)},[g,e.hidden]),v.useEffect(()=>()=>{c.current&&(l?.unobserve(c.current),c.current=null)},[]),v.useEffect(()=>{if(d.current){const x=f.current!==n,p=h.current!==e.sourcePosition,y=m.current!==e.targetPosition;(x||p||y)&&(f.current=n,h.current=e.sourcePosition,m.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:d.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),d}function AD({id:e,onClick:n,onMouseEnter:s,onMouseMove:l,onMouseLeave:o,onContextMenu:d,onDoubleClick:c,nodesDraggable:h,elementsSelectable:m,nodesConnectable:f,nodesFocusable:g,resizeObserver:x,noDragClassName:p,noPanClassName:y,disableKeyboardA11y:w,rfId:N,nodeTypes:C,nodeClickDistance:_,onError:O}){const{node:k,internals:S,isParent:R}=Jt(ne=>{const ae=ne.nodeLookup.get(e),he=ne.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:he}},An);let D=k.type||"default",Y=C?.[D]||_v[D];Y===void 0&&(O?.("003",Ts.error003(D)),D="default",Y=C?.default||_v.default);const z=!!(k.draggable||h&&typeof k.draggable>"u"),K=!!(k.selectable||m&&typeof k.selectable>"u"),U=!!(k.connectable||f&&typeof k.connectable>"u"),G=!!(k.focusable||g&&typeof k.focusable>"u"),V=_n(),E=Sw(k),T=TD({node:k,nodeType:D,hasDimensions:E,resizeObserver:x}),L=tN({nodeRef:T,disabled:k.hidden||!z,noDragClassName:p,handleSelector:k.dragHandle,nodeId:e,isSelectable:K,nodeClickDistance:_}),A=nN();if(k.hidden)return null;const P=ra(k),q=yD(k),W=K||z||n||s||l||o,B=s?ne=>s(ne,{...S.userNode}):void 0,F=l?ne=>l(ne,{...S.userNode}):void 0,X=o?ne=>o(ne,{...S.userNode}):void 0,I=d?ne=>d(ne,{...S.userNode}):void 0,M=c?ne=>c(ne,{...S.userNode}):void 0,H=ne=>{const{selectNodesOnDrag:ae,nodeDragThreshold:he}=V.getState();K&&(!ae||!z||he>0)&&Hm({id:e,store:V,nodeRef:T}),n&&n(ne,{...S.userNode})},Z=ne=>{if(!(Tw(ne.nativeEvent)||w)){if(gw.includes(ne.key)&&K){const ae=ne.key==="Escape";Hm({id:e,store:V,unselect:ae,nodeRef:T})}else if(z&&k.selected&&Object.prototype.hasOwnProperty.call(Yd,ne.key)){ne.preventDefault();const{ariaLabelConfig:ae}=V.getState();V.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:ne.key.replace("Arrow","").toLowerCase(),x:~~S.positionAbsolute.x,y:~~S.positionAbsolute.y})}),A({direction:Yd[ne.key],factor:ne.shiftKey?4:1})}}},ee=()=>{if(w||!T.current?.matches(":focus-visible"))return;const{transform:ne,width:ae,height:he,autoPanOnNodeFocus:Ne,setCenter:Le}=V.getState();if(!Ne)return;Sx(new Map([[e,k]]),{x:0,y:0,width:ae,height:he},ne,!0).length>0||Le(k.position.x+P.width/2,k.position.y+P.height/2,{zoom:ne[2]})};return t.jsx("div",{className:Zn(["react-flow__node",`react-flow__node-${D}`,{[y]:z},k.className,{selected:k.selected,selectable:K,parent:R,draggable:z,dragging:L}]),ref:T,style:{zIndex:S.z,transform:`translate(${S.positionAbsolute.x}px,${S.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:E?"visible":"hidden",...k.style,...q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:F,onMouseLeave:X,onContextMenu:I,onClick:H,onDoubleClick:M,onKeyDown:G?Z:void 0,tabIndex:G?0:void 0,onFocus:G?ee:void 0,role:k.ariaRole??(G?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Gw}-${N}`,"aria-label":k.ariaLabel,...k.domAttributes,children:t.jsx(uD,{value:e,children:t.jsx(Y,{id:e,data:k.data,type:D,positionAbsoluteX:S.positionAbsolute.x,positionAbsoluteY:S.positionAbsolute.y,selected:k.selected??!1,selectable:K,draggable:z,deletable:k.deletable??!0,isConnectable:U,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:L,dragHandle:k.dragHandle,zIndex:S.z,parentId:k.parentId,...P})})})}var _D=v.memo(AD);const MD=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function aN(e){const{nodesDraggable:n,nodesConnectable:s,nodesFocusable:l,elementsSelectable:o,onError:d}=Jt(MD,An),c=SD(e.onlyRenderVisibleElements),h=ED();return t.jsx("div",{className:"react-flow__nodes",style:fu,children:c.map(m=>t.jsx(_D,{id:m,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:h,nodesDraggable:n,nodesConnectable:s,nodesFocusable:l,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:d},m))})}aN.displayName="NodeRenderer";const OD=v.memo(aN);function RD(e){return Jt(v.useCallback(s=>{if(!e)return s.edges.map(o=>o.id);const l=[];if(s.width&&s.height)for(const o of s.edges){const d=s.nodeLookup.get(o.source),c=s.nodeLookup.get(o.target);d&&c&&MO({sourceNode:d,targetNode:c,width:s.width,height:s.height,transform:s.transform})&&l.push(o.id)}return l},[e]),An)}const DD=({color:e="none",strokeWidth:n=1})=>{const s={strokeWidth:n,...e&&{stroke:e}};return t.jsx("polyline",{className:"arrow",style:s,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},LD=({color:e="none",strokeWidth:n=1})=>{const s={strokeWidth:n,...e&&{stroke:e,fill:e}};return t.jsx("polyline",{className:"arrowclosed",style:s,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Ov={[di.Arrow]:DD,[di.ArrowClosed]:LD};function ID(e){const n=_n();return v.useMemo(()=>Object.prototype.hasOwnProperty.call(Ov,e)?Ov[e]:(n.getState().onError?.("009",Ts.error009(e)),null),[e])}const zD=({id:e,type:n,color:s,width:l=12.5,height:o=12.5,markerUnits:d="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const m=ID(n);return m?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:d,orient:h,refX:"0",refY:"0",children:t.jsx(m,{color:s,strokeWidth:c})}):null},lN=({defaultColor:e,rfId:n})=>{const s=Jt(d=>d.edges),l=Jt(d=>d.defaultEdgeOptions),o=v.useMemo(()=>BO(s,{id:n,defaultColor:e,defaultMarkerStart:l?.markerStart,defaultMarkerEnd:l?.markerEnd}),[s,l,n,e]);return o.length?t.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:t.jsx("defs",{children:o.map(d=>t.jsx(zD,{id:d.id,type:d.type,color:d.color,width:d.width,height:d.height,markerUnits:d.markerUnits,strokeWidth:d.strokeWidth,orient:d.orient},d.id))})}):null};lN.displayName="MarkerDefinitions";var $D=v.memo(lN);function iN({x:e,y:n,label:s,labelStyle:l,labelShowBg:o=!0,labelBgStyle:d,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:m,className:f,...g}){const[x,p]=v.useState({x:1,y:0,width:0,height:0}),y=Zn(["react-flow__edge-textwrapper",f]),w=v.useRef(null);return v.useEffect(()=>{if(w.current){const N=w.current.getBBox();p({x:N.x,y:N.y,width:N.width,height:N.height})}},[s]),s?t.jsxs("g",{transform:`translate(${e-x.width/2} ${n-x.height/2})`,className:y,visibility:x.width?"visible":"hidden",...g,children:[o&&t.jsx("rect",{width:x.width+2*c[0],x:-c[0],y:-c[1],height:x.height+2*c[1],className:"react-flow__edge-textbg",style:d,rx:h,ry:h}),t.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:w,style:l,children:s}),m]}):null}iN.displayName="EdgeText";const BD=v.memo(iN);function hu({path:e,labelX:n,labelY:s,label:l,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:m,interactionWidth:f=20,...g}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{...g,d:e,fill:"none",className:Zn(["react-flow__edge-path",g.className])}),f?t.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,l&&us(n)&&us(s)?t.jsx(BD,{x:n,y:s,label:l,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:m}):null]})}function Rv({pos:e,x1:n,y1:s,x2:l,y2:o}){return e===ft.Left||e===ft.Right?[.5*(n+l),s]:[n,.5*(s+o)]}function oN({sourceX:e,sourceY:n,sourcePosition:s=ft.Bottom,targetX:l,targetY:o,targetPosition:d=ft.Top}){const[c,h]=Rv({pos:s,x1:e,y1:n,x2:l,y2:o}),[m,f]=Rv({pos:d,x1:l,y1:o,x2:e,y2:n}),[g,x,p,y]=_w({sourceX:e,sourceY:n,targetX:l,targetY:o,sourceControlX:c,sourceControlY:h,targetControlX:m,targetControlY:f});return[`M${e},${n} C${c},${h} ${m},${f} ${l},${o}`,g,x,p,y]}function cN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,label:m,labelStyle:f,labelShowBg:g,labelBgStyle:x,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,interactionWidth:_})=>{const[O,k,S]=oN({sourceX:s,sourceY:l,sourcePosition:c,targetX:o,targetY:d,targetPosition:h}),R=e.isInternal?void 0:n;return t.jsx(hu,{id:R,path:O,labelX:k,labelY:S,label:m,labelStyle:f,labelShowBg:g,labelBgStyle:x,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,interactionWidth:_})})}const HD=cN({isInternal:!1}),dN=cN({isInternal:!0});HD.displayName="SimpleBezierEdge";dN.displayName="SimpleBezierEdgeInternal";function uN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:x,style:p,sourcePosition:y=ft.Bottom,targetPosition:w=ft.Top,markerEnd:N,markerStart:C,pathOptions:_,interactionWidth:O})=>{const[k,S,R]=Im({sourceX:s,sourceY:l,sourcePosition:y,targetX:o,targetY:d,targetPosition:w,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),D=e.isInternal?void 0:n;return t.jsx(hu,{id:D,path:k,labelX:S,labelY:R,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:x,style:p,markerEnd:N,markerStart:C,interactionWidth:O})})}const fN=uN({isInternal:!1}),hN=uN({isInternal:!0});fN.displayName="SmoothStepEdge";hN.displayName="SmoothStepEdgeInternal";function mN(e){return v.memo(({id:n,...s})=>{const l=e.isInternal?void 0:n;return t.jsx(fN,{...s,id:l,pathOptions:v.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const PD=mN({isInternal:!1}),xN=mN({isInternal:!0});PD.displayName="StepEdge";xN.displayName="StepEdgeInternal";function gN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:x,style:p,markerEnd:y,markerStart:w,interactionWidth:N})=>{const[C,_,O]=Rw({sourceX:s,sourceY:l,targetX:o,targetY:d}),k=e.isInternal?void 0:n;return t.jsx(hu,{id:k,path:C,labelX:_,labelY:O,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:x,style:p,markerEnd:y,markerStart:w,interactionWidth:N})})}const UD=gN({isInternal:!1}),pN=gN({isInternal:!0});UD.displayName="StraightEdge";pN.displayName="StraightEdgeInternal";function bN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,sourcePosition:c=ft.Bottom,targetPosition:h=ft.Top,label:m,labelStyle:f,labelShowBg:g,labelBgStyle:x,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,pathOptions:_,interactionWidth:O})=>{const[k,S,R]=Mw({sourceX:s,sourceY:l,sourcePosition:c,targetX:o,targetY:d,targetPosition:h,curvature:_?.curvature}),D=e.isInternal?void 0:n;return t.jsx(hu,{id:D,path:k,labelX:S,labelY:R,label:m,labelStyle:f,labelShowBg:g,labelBgStyle:x,labelBgPadding:p,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,interactionWidth:O})})}const qD=bN({isInternal:!1}),yN=bN({isInternal:!0});qD.displayName="BezierEdge";yN.displayName="BezierEdgeInternal";const Dv={default:yN,straight:pN,step:xN,smoothstep:hN,simplebezier:dN},Lv={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},VD=(e,n,s)=>s===ft.Left?e-n:s===ft.Right?e+n:e,FD=(e,n,s)=>s===ft.Top?e-n:s===ft.Bottom?e+n:e,Iv="react-flow__edgeupdater";function zv({position:e,centerX:n,centerY:s,radius:l=10,onMouseDown:o,onMouseEnter:d,onMouseOut:c,type:h}){return t.jsx("circle",{onMouseDown:o,onMouseEnter:d,onMouseOut:c,className:Zn([Iv,`${Iv}-${h}`]),cx:VD(n,l,e),cy:FD(s,l,e),r:l,stroke:"transparent",fill:"transparent"})}function YD({isReconnectable:e,reconnectRadius:n,edge:s,sourceX:l,sourceY:o,targetX:d,targetY:c,sourcePosition:h,targetPosition:m,onReconnect:f,onReconnectStart:g,onReconnectEnd:x,setReconnecting:p,setUpdateHover:y}){const w=_n(),N=(S,R)=>{if(S.button!==0)return;const{autoPanOnConnect:D,domNode:Y,connectionMode:z,connectionRadius:K,lib:U,onConnectStart:G,cancelConnection:V,nodeLookup:E,rfId:T,panBy:L,updateConnection:A}=w.getState(),P=R.type==="target",q=(F,X)=>{p(!1),x?.(F,s,R.type,X)},W=F=>f?.(s,F),B=(F,X)=>{p(!0),g?.(S,s,R.type),G?.(F,X)};Bm.onPointerDown(S.nativeEvent,{autoPanOnConnect:D,connectionMode:z,connectionRadius:K,domNode:Y,handleId:R.id,nodeId:R.nodeId,nodeLookup:E,isTarget:P,edgeUpdaterType:R.type,lib:U,flowId:T,cancelConnection:V,panBy:L,isValidConnection:(...F)=>w.getState().isValidConnection?.(...F)??!0,onConnect:W,onConnectStart:B,onConnectEnd:(...F)=>w.getState().onConnectEnd?.(...F),onReconnectEnd:q,updateConnection:A,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:S.currentTarget})},C=S=>N(S,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),_=S=>N(S,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),O=()=>y(!0),k=()=>y(!1);return t.jsxs(t.Fragment,{children:[(e===!0||e==="source")&&t.jsx(zv,{position:h,centerX:l,centerY:o,radius:n,onMouseDown:C,onMouseEnter:O,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&t.jsx(zv,{position:m,centerX:d,centerY:c,radius:n,onMouseDown:_,onMouseEnter:O,onMouseOut:k,type:"target"})]})}function GD({id:e,edgesFocusable:n,edgesReconnectable:s,elementsSelectable:l,onClick:o,onDoubleClick:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,reconnectRadius:g,onReconnect:x,onReconnectStart:p,onReconnectEnd:y,rfId:w,edgeTypes:N,noPanClassName:C,onError:_,disableKeyboardA11y:O}){let k=Jt(Le=>Le.edgeLookup.get(e));const S=Jt(Le=>Le.defaultEdgeOptions);k=S?{...S,...k}:k;let R=k.type||"default",D=N?.[R]||Dv[R];D===void 0&&(_?.("011",Ts.error011(R)),R="default",D=N?.default||Dv.default);const Y=!!(k.focusable||n&&typeof k.focusable>"u"),z=typeof x<"u"&&(k.reconnectable||s&&typeof k.reconnectable>"u"),K=!!(k.selectable||l&&typeof k.selectable>"u"),U=v.useRef(null),[G,V]=v.useState(!1),[E,T]=v.useState(!1),L=_n(),{zIndex:A,sourceX:P,sourceY:q,targetX:W,targetY:B,sourcePosition:F,targetPosition:X}=Jt(v.useCallback(Le=>{const ye=Le.nodeLookup.get(k.source),je=Le.nodeLookup.get(k.target);if(!ye||!je)return{zIndex:k.zIndex,...Lv};const Ae=$O({id:e,sourceNode:ye,targetNode:je,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:Le.connectionMode,onError:_});return{zIndex:_O({selected:k.selected,zIndex:k.zIndex,sourceNode:ye,targetNode:je,elevateOnSelect:Le.elevateEdgesOnSelect,zIndexMode:Le.zIndexMode}),...Ae||Lv}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),An),I=v.useMemo(()=>k.markerStart?`url('#${zm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),M=v.useMemo(()=>k.markerEnd?`url('#${zm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||P===null||q===null||W===null||B===null)return null;const H=Le=>{const{addSelectedEdges:ye,unselectNodesAndEdges:je,multiSelectionActive:Ae}=L.getState();K&&(L.setState({nodesSelectionActive:!1}),k.selected&&Ae?(je({nodes:[],edges:[k]}),U.current?.blur()):ye([e])),o&&o(Le,k)},Z=d?Le=>{d(Le,{...k})}:void 0,ee=c?Le=>{c(Le,{...k})}:void 0,ne=h?Le=>{h(Le,{...k})}:void 0,ae=m?Le=>{m(Le,{...k})}:void 0,he=f?Le=>{f(Le,{...k})}:void 0,Ne=Le=>{if(!O&&gw.includes(Le.key)&&K){const{unselectNodesAndEdges:ye,addSelectedEdges:je}=L.getState();Le.key==="Escape"?(U.current?.blur(),ye({edges:[k]})):je([e])}};return t.jsx("svg",{style:{zIndex:A},children:t.jsxs("g",{className:Zn(["react-flow__edge",`react-flow__edge-${R}`,k.className,C,{selected:k.selected,animated:k.animated,inactive:!K&&!o,updating:G,selectable:K}]),onClick:H,onDoubleClick:Z,onContextMenu:ee,onMouseEnter:ne,onMouseMove:ae,onMouseLeave:he,onKeyDown:Y?Ne:void 0,tabIndex:Y?0:void 0,role:k.ariaRole??(Y?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":Y?`${Xw}-${w}`:void 0,ref:U,...k.domAttributes,children:[!E&&t.jsx(D,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:K,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:P,sourceY:q,targetX:W,targetY:B,sourcePosition:F,targetPosition:X,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:I,markerEnd:M,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),z&&t.jsx(YD,{edge:k,isReconnectable:z,reconnectRadius:g,onReconnect:x,onReconnectStart:p,onReconnectEnd:y,sourceX:P,sourceY:q,targetX:W,targetY:B,sourcePosition:F,targetPosition:X,setUpdateHover:V,setReconnecting:T})]})})}var XD=v.memo(GD);const KD=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function vN({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:s,edgeTypes:l,noPanClassName:o,onReconnect:d,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:m,onEdgeMouseLeave:f,onEdgeClick:g,reconnectRadius:x,onEdgeDoubleClick:p,onReconnectStart:y,onReconnectEnd:w,disableKeyboardA11y:N}){const{edgesFocusable:C,edgesReconnectable:_,elementsSelectable:O,onError:k}=Jt(KD,An),S=RD(n);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx($D,{defaultColor:e,rfId:s}),S.map(R=>t.jsx(XD,{id:R,edgesFocusable:C,edgesReconnectable:_,elementsSelectable:O,noPanClassName:o,onReconnect:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,onClick:g,reconnectRadius:x,onDoubleClick:p,onReconnectStart:y,onReconnectEnd:w,rfId:s,onError:k,edgeTypes:l,disableKeyboardA11y:N},R))]})}vN.displayName="EdgeRenderer";const ZD=v.memo(vN),WD=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function QD({children:e}){const n=Jt(WD);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function JD(e){const n=Rx(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),s.current=!0)},[e,n.viewportInitialized])}const eL=e=>e.panZoom?.syncViewport;function tL(e){const n=Jt(eL),s=_n();return v.useEffect(()=>{e&&(n?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function nL(e){return e.connection.inProgress?{...e.connection,to:Zo(e.connection.to,e.transform)}:{...e.connection}}function rL(e){return nL}function sL(e){const n=rL();return Jt(n,An)}const aL=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function lL({containerStyle:e,style:n,type:s,component:l}){const{nodesConnectable:o,width:d,height:c,isValid:h,inProgress:m}=Jt(aL,An);return!(d&&o&&m)?null:t.jsx("svg",{style:e,width:d,height:c,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:Zn(["react-flow__connection",yw(h)]),children:t.jsx(jN,{style:n,type:s,CustomComponent:l,isValid:h})})})}const jN=({style:e,type:n=La.Bezier,CustomComponent:s,isValid:l})=>{const{inProgress:o,from:d,fromNode:c,fromHandle:h,fromPosition:m,to:f,toNode:g,toHandle:x,toPosition:p,pointer:y}=sL();if(!o)return;if(s)return t.jsx(s,{connectionLineType:n,connectionLineStyle:e,fromNode:c,fromHandle:h,fromX:d.x,fromY:d.y,toX:f.x,toY:f.y,fromPosition:m,toPosition:p,connectionStatus:yw(l),toNode:g,toHandle:x,pointer:y});let w="";const N={sourceX:d.x,sourceY:d.y,sourcePosition:m,targetX:f.x,targetY:f.y,targetPosition:p};switch(n){case La.Bezier:[w]=Mw(N);break;case La.SimpleBezier:[w]=oN(N);break;case La.Step:[w]=Im({...N,borderRadius:0});break;case La.SmoothStep:[w]=Im(N);break;default:[w]=Rw(N)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};jN.displayName="ConnectionLine";const iL={};function $v(e=iL){v.useRef(e),_n(),v.useEffect(()=>{},[e])}function oL(){_n(),v.useRef(!1),v.useEffect(()=>{},[])}function wN({nodeTypes:e,edgeTypes:n,onInit:s,onNodeClick:l,onEdgeClick:o,onNodeDoubleClick:d,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:g,onSelectionContextMenu:x,onSelectionStart:p,onSelectionEnd:y,connectionLineType:w,connectionLineStyle:N,connectionLineComponent:C,connectionLineContainerStyle:_,selectionKeyCode:O,selectionOnDrag:k,selectionMode:S,multiSelectionKeyCode:R,panActivationKeyCode:D,zoomActivationKeyCode:Y,deleteKeyCode:z,onlyRenderVisibleElements:K,elementsSelectable:U,defaultViewport:G,translateExtent:V,minZoom:E,maxZoom:T,preventScrolling:L,defaultMarkerColor:A,zoomOnScroll:P,zoomOnPinch:q,panOnScroll:W,panOnScrollSpeed:B,panOnScrollMode:F,zoomOnDoubleClick:X,panOnDrag:I,onPaneClick:M,onPaneMouseEnter:H,onPaneMouseMove:Z,onPaneMouseLeave:ee,onPaneScroll:ne,onPaneContextMenu:ae,paneClickDistance:he,nodeClickDistance:Ne,onEdgeContextMenu:Le,onEdgeMouseEnter:ye,onEdgeMouseMove:je,onEdgeMouseLeave:Ae,reconnectRadius:$e,onReconnect:Xe,onReconnectStart:tt,onReconnectEnd:et,noDragClassName:_t,noWheelClassName:se,noPanClassName:Te,disableKeyboardA11y:nt,nodeExtent:yt,rfId:Xt,viewport:we,onViewportChange:De}){return $v(e),$v(n),oL(),JD(s),tL(we),t.jsx(ND,{onPaneClick:M,onPaneMouseEnter:H,onPaneMouseMove:Z,onPaneMouseLeave:ee,onPaneContextMenu:ae,onPaneScroll:ne,paneClickDistance:he,deleteKeyCode:z,selectionKeyCode:O,selectionOnDrag:k,selectionMode:S,onSelectionStart:p,onSelectionEnd:y,multiSelectionKeyCode:R,panActivationKeyCode:D,zoomActivationKeyCode:Y,elementsSelectable:U,zoomOnScroll:P,zoomOnPinch:q,zoomOnDoubleClick:X,panOnScroll:W,panOnScrollSpeed:B,panOnScrollMode:F,panOnDrag:I,defaultViewport:G,translateExtent:V,minZoom:E,maxZoom:T,onSelectionContextMenu:x,preventScrolling:L,noDragClassName:_t,noWheelClassName:se,noPanClassName:Te,disableKeyboardA11y:nt,onViewportChange:De,isControlledViewport:!!we,children:t.jsxs(QD,{children:[t.jsx(ZD,{edgeTypes:n,onEdgeClick:o,onEdgeDoubleClick:c,onReconnect:Xe,onReconnectStart:tt,onReconnectEnd:et,onlyRenderVisibleElements:K,onEdgeContextMenu:Le,onEdgeMouseEnter:ye,onEdgeMouseMove:je,onEdgeMouseLeave:Ae,reconnectRadius:$e,defaultMarkerColor:A,noPanClassName:Te,disableKeyboardA11y:nt,rfId:Xt}),t.jsx(lL,{style:N,type:w,component:C,containerStyle:_}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(OD,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:g,nodeClickDistance:Ne,onlyRenderVisibleElements:K,noPanClassName:Te,noDragClassName:_t,disableKeyboardA11y:nt,nodeExtent:yt,rfId:Xt}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}wN.displayName="GraphView";const cL=v.memo(wN),Bv=({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m=.5,maxZoom:f=2,nodeOrigin:g,nodeExtent:x,zIndexMode:p="basic"}={})=>{const y=new Map,w=new Map,N=new Map,C=new Map,_=l??n??[],O=s??e??[],k=g??[0,0],S=x??Do;Iw(N,C,_);const R=$m(O,y,w,{nodeOrigin:k,nodeExtent:S,zIndexMode:p});let D=[0,0,1];if(c&&o&&d){const Y=Xo(y,{filter:G=>!!((G.width||G.initialWidth)&&(G.height||G.initialHeight))}),{x:z,y:K,zoom:U}=Cx(Y,o,d,m,f,h?.padding??.1);D=[z,K,U]}return{rfId:"1",width:o??0,height:d??0,transform:D,nodes:O,nodesInitialized:R,nodeLookup:y,parentLookup:w,edges:_,edgeLookup:C,connectionLookup:N,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:m,maxZoom:f,translateExtent:Do,nodeExtent:S,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ci.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...bw},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:kO,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:pw,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},dL=({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:g,nodeExtent:x,zIndexMode:p})=>TR((y,w)=>{async function N(){const{nodeLookup:C,panZoom:_,fitViewOptions:O,fitViewResolver:k,width:S,height:R,minZoom:D,maxZoom:Y}=w();_&&(await wO({nodes:C,width:S,height:R,panZoom:_,minZoom:D,maxZoom:Y},O),k?.resolve(!0),y({fitViewResolver:null}))}return{...Bv({nodes:e,edges:n,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:g,nodeExtent:x,defaultNodes:s,defaultEdges:l,zIndexMode:p}),setNodes:C=>{const{nodeLookup:_,parentLookup:O,nodeOrigin:k,elevateNodesOnSelect:S,fitViewQueued:R,zIndexMode:D}=w(),Y=$m(C,_,O,{nodeOrigin:k,nodeExtent:x,elevateNodesOnSelect:S,checkEquality:!0,zIndexMode:D});R&&Y?(N(),y({nodes:C,nodesInitialized:Y,fitViewQueued:!1,fitViewOptions:void 0})):y({nodes:C,nodesInitialized:Y})},setEdges:C=>{const{connectionLookup:_,edgeLookup:O}=w();Iw(_,O,C),y({edges:C})},setDefaultNodesAndEdges:(C,_)=>{if(C){const{setNodes:O}=w();O(C),y({hasDefaultNodes:!0})}if(_){const{setEdges:O}=w();O(_),y({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:_,nodeLookup:O,parentLookup:k,domNode:S,nodeOrigin:R,nodeExtent:D,debug:Y,fitViewQueued:z,zIndexMode:K}=w(),{changes:U,updatedInternals:G}=YO(C,O,k,S,R,D,K);G&&(UO(O,k,{nodeOrigin:R,nodeExtent:D,zIndexMode:K}),z?(N(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),U?.length>0&&(Y&&console.log("React Flow: trigger node changes",U),_?.(U)))},updateNodePositions:(C,_=!1)=>{const O=[];let k=[];const{nodeLookup:S,triggerNodeChanges:R,connection:D,updateConnection:Y,onNodesChangeMiddlewareMap:z}=w();for(const[K,U]of C){const G=S.get(K),V=!!(G?.expandParent&&G?.parentId&&U?.position),E={id:K,type:"position",position:V?{x:Math.max(0,U.position.x),y:Math.max(0,U.position.y)}:U.position,dragging:_};if(G&&D.inProgress&&D.fromNode.id===G.id){const T=xl(G,D.fromHandle,ft.Left,!0);Y({...D,from:T})}V&&G.parentId&&O.push({id:K,parentId:G.parentId,rect:{...U.internals.positionAbsolute,width:U.measured.width??0,height:U.measured.height??0}}),k.push(E)}if(O.length>0){const{parentLookup:K,nodeOrigin:U}=w(),G=Ox(O,S,K,U);k.push(...G)}for(const K of z.values())k=K(k);R(k)},triggerNodeChanges:C=>{const{onNodesChange:_,setNodes:O,nodes:k,hasDefaultNodes:S,debug:R}=w();if(C?.length){if(S){const D=Ww(C,k);O(D)}R&&console.log("React Flow: trigger node changes",C),_?.(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:_,setEdges:O,edges:k,hasDefaultEdges:S,debug:R}=w();if(C?.length){if(S){const D=Qw(C,k);O(D)}R&&console.log("React Flow: trigger edge changes",C),_?.(C)}},addSelectedNodes:C=>{const{multiSelectionActive:_,edgeLookup:O,nodeLookup:k,triggerNodeChanges:S,triggerEdgeChanges:R}=w();if(_){const D=C.map(Y=>al(Y,!0));S(D);return}S(ni(k,new Set([...C]),!0)),R(ni(O))},addSelectedEdges:C=>{const{multiSelectionActive:_,edgeLookup:O,nodeLookup:k,triggerNodeChanges:S,triggerEdgeChanges:R}=w();if(_){const D=C.map(Y=>al(Y,!0));R(D);return}R(ni(O,new Set([...C]))),S(ni(k,new Set,!0))},unselectNodesAndEdges:({nodes:C,edges:_}={})=>{const{edges:O,nodes:k,nodeLookup:S,triggerNodeChanges:R,triggerEdgeChanges:D}=w(),Y=C||k,z=_||O,K=[];for(const G of Y){if(!G.selected)continue;const V=S.get(G.id);V&&(V.selected=!1),K.push(al(G.id,!1))}const U=[];for(const G of z)G.selected&&U.push(al(G.id,!1));R(K),D(U)},setMinZoom:C=>{const{panZoom:_,maxZoom:O}=w();_?.setScaleExtent([C,O]),y({minZoom:C})},setMaxZoom:C=>{const{panZoom:_,minZoom:O}=w();_?.setScaleExtent([O,C]),y({maxZoom:C})},setTranslateExtent:C=>{w().panZoom?.setTranslateExtent(C),y({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:_,triggerNodeChanges:O,triggerEdgeChanges:k,elementsSelectable:S}=w();if(!S)return;const R=_.reduce((Y,z)=>z.selected?[...Y,al(z.id,!1)]:Y,[]),D=C.reduce((Y,z)=>z.selected?[...Y,al(z.id,!1)]:Y,[]);O(R),k(D)},setNodeExtent:C=>{const{nodes:_,nodeLookup:O,parentLookup:k,nodeOrigin:S,elevateNodesOnSelect:R,nodeExtent:D,zIndexMode:Y}=w();C[0][0]===D[0][0]&&C[0][1]===D[0][1]&&C[1][0]===D[1][0]&&C[1][1]===D[1][1]||($m(_,O,k,{nodeOrigin:S,nodeExtent:C,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:Y}),y({nodeExtent:C}))},panBy:C=>{const{transform:_,width:O,height:k,panZoom:S,translateExtent:R}=w();return GO({delta:C,panZoom:S,transform:_,translateExtent:R,width:O,height:k})},setCenter:async(C,_,O)=>{const{width:k,height:S,maxZoom:R,panZoom:D}=w();if(!D)return Promise.resolve(!1);const Y=typeof O?.zoom<"u"?O.zoom:R;return await D.setViewport({x:k/2-C*Y,y:S/2-_*Y,zoom:Y},{duration:O?.duration,ease:O?.ease,interpolate:O?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...bw}})},updateConnection:C=>{y({connection:C})},reset:()=>y({...Bv()})}},Object.is);function uL({initialNodes:e,initialEdges:n,defaultNodes:s,defaultEdges:l,initialWidth:o,initialHeight:d,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:m,fitView:f,nodeOrigin:g,nodeExtent:x,zIndexMode:p,children:y}){const[w]=v.useState(()=>dL({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:f,minZoom:c,maxZoom:h,fitViewOptions:m,nodeOrigin:g,nodeExtent:x,zIndexMode:p}));return t.jsx(AR,{value:w,children:t.jsx(QR,{children:y})})}function fL({children:e,nodes:n,edges:s,defaultNodes:l,defaultEdges:o,width:d,height:c,fitView:h,fitViewOptions:m,minZoom:f,maxZoom:g,nodeOrigin:x,nodeExtent:p,zIndexMode:y}){return v.useContext(du)?t.jsx(t.Fragment,{children:e}):t.jsx(uL,{initialNodes:n,initialEdges:s,defaultNodes:l,defaultEdges:o,initialWidth:d,initialHeight:c,fitView:h,initialFitViewOptions:m,initialMinZoom:f,initialMaxZoom:g,nodeOrigin:x,nodeExtent:p,zIndexMode:y,children:e})}const hL={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function mL({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,className:o,nodeTypes:d,edgeTypes:c,onNodeClick:h,onEdgeClick:m,onInit:f,onMove:g,onMoveStart:x,onMoveEnd:p,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:C,onClickConnectEnd:_,onNodeMouseEnter:O,onNodeMouseMove:k,onNodeMouseLeave:S,onNodeContextMenu:R,onNodeDoubleClick:D,onNodeDragStart:Y,onNodeDrag:z,onNodeDragStop:K,onNodesDelete:U,onEdgesDelete:G,onDelete:V,onSelectionChange:E,onSelectionDragStart:T,onSelectionDrag:L,onSelectionDragStop:A,onSelectionContextMenu:P,onSelectionStart:q,onSelectionEnd:W,onBeforeDelete:B,connectionMode:F,connectionLineType:X=La.Bezier,connectionLineStyle:I,connectionLineComponent:M,connectionLineContainerStyle:H,deleteKeyCode:Z="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:ne=!1,selectionMode:ae=Lo.Full,panActivationKeyCode:he="Space",multiSelectionKeyCode:Ne=zo()?"Meta":"Control",zoomActivationKeyCode:Le=zo()?"Meta":"Control",snapToGrid:ye,snapGrid:je,onlyRenderVisibleElements:Ae=!1,selectNodesOnDrag:$e,nodesDraggable:Xe,autoPanOnNodeFocus:tt,nodesConnectable:et,nodesFocusable:_t,nodeOrigin:se=Kw,edgesFocusable:Te,edgesReconnectable:nt,elementsSelectable:yt=!0,defaultViewport:Xt=UR,minZoom:we=.5,maxZoom:De=2,translateExtent:Pe=Do,preventScrolling:Ze=!0,nodeExtent:mt,defaultMarkerColor:Kt="#b1b1b7",zoomOnScroll:ln=!0,zoomOnPinch:Ht=!0,panOnScroll:Lt=!1,panOnScrollSpeed:At=.5,panOnScrollMode:St=cl.Free,zoomOnDoubleClick:en=!0,panOnDrag:tn=!0,onPaneClick:ve,onPaneMouseEnter:Ve,onPaneMouseMove:Rt,onPaneMouseLeave:Pt,onPaneScroll:vt,onPaneContextMenu:sn,paneClickDistance:gn=1,nodeClickDistance:rt=0,children:Wt,onReconnect:Mn,onReconnectStart:Mt,onReconnectEnd:yn,onEdgeContextMenu:Nn,onEdgeDoubleClick:ie,onEdgeMouseEnter:qe,onEdgeMouseMove:ze,onEdgeMouseLeave:We,reconnectRadius:lt=10,onNodesChange:Ct,onEdgesChange:dt,noDragClassName:zt="nodrag",noWheelClassName:pt="nowheel",noPanClassName:on="nopan",fitView:de,fitViewOptions:Fe,connectOnClick:ht,attributionPosition:Tt,proOptions:Rn,defaultEdgeOptions:gr,elevateNodesOnSelect:pr=!0,elevateEdgesOnSelect:nr=!1,disableKeyboardA11y:dr=!1,autoPanOnConnect:ur,autoPanOnNodeDrag:vn,autoPanSpeed:gs,connectionRadius:qr,isValidConnection:fr,onError:rr,style:Vr,id:oe,nodeDragThreshold:ke,connectionDragThreshold:Be,viewport:Dt,onViewportChange:Jn,width:Dn,height:En,colorMode:ss="light",debug:Os,onScroll:as,ariaLabelConfig:Fr,zIndexMode:Un="basic",...Rs},Ln){const Yr=oe||"1",br=YR(ss),Mr=v.useCallback(sr=>{sr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),as?.(sr)},[as]);return t.jsx("div",{"data-testid":"rf__wrapper",...Rs,onScroll:Mr,style:{...Vr,...hL},ref:Ln,className:Zn(["react-flow",o,br]),id:oe,role:"application",children:t.jsxs(fL,{nodes:e,edges:n,width:Dn,height:En,fitView:de,fitViewOptions:Fe,minZoom:we,maxZoom:De,nodeOrigin:se,nodeExtent:mt,zIndexMode:Un,children:[t.jsx(cL,{onInit:f,onNodeClick:h,onEdgeClick:m,onNodeMouseEnter:O,onNodeMouseMove:k,onNodeMouseLeave:S,onNodeContextMenu:R,onNodeDoubleClick:D,nodeTypes:d,edgeTypes:c,connectionLineType:X,connectionLineStyle:I,connectionLineComponent:M,connectionLineContainerStyle:H,selectionKeyCode:ee,selectionOnDrag:ne,selectionMode:ae,deleteKeyCode:Z,multiSelectionKeyCode:Ne,panActivationKeyCode:he,zoomActivationKeyCode:Le,onlyRenderVisibleElements:Ae,defaultViewport:Xt,translateExtent:Pe,minZoom:we,maxZoom:De,preventScrolling:Ze,zoomOnScroll:ln,zoomOnPinch:Ht,zoomOnDoubleClick:en,panOnScroll:Lt,panOnScrollSpeed:At,panOnScrollMode:St,panOnDrag:tn,onPaneClick:ve,onPaneMouseEnter:Ve,onPaneMouseMove:Rt,onPaneMouseLeave:Pt,onPaneScroll:vt,onPaneContextMenu:sn,paneClickDistance:gn,nodeClickDistance:rt,onSelectionContextMenu:P,onSelectionStart:q,onSelectionEnd:W,onReconnect:Mn,onReconnectStart:Mt,onReconnectEnd:yn,onEdgeContextMenu:Nn,onEdgeDoubleClick:ie,onEdgeMouseEnter:qe,onEdgeMouseMove:ze,onEdgeMouseLeave:We,reconnectRadius:lt,defaultMarkerColor:Kt,noDragClassName:zt,noWheelClassName:pt,noPanClassName:on,rfId:Yr,disableKeyboardA11y:dr,nodeExtent:mt,viewport:Dt,onViewportChange:Jn}),t.jsx(FR,{nodes:e,edges:n,defaultNodes:s,defaultEdges:l,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:C,onClickConnectEnd:_,nodesDraggable:Xe,autoPanOnNodeFocus:tt,nodesConnectable:et,nodesFocusable:_t,edgesFocusable:Te,edgesReconnectable:nt,elementsSelectable:yt,elevateNodesOnSelect:pr,elevateEdgesOnSelect:nr,minZoom:we,maxZoom:De,nodeExtent:mt,onNodesChange:Ct,onEdgesChange:dt,snapToGrid:ye,snapGrid:je,connectionMode:F,translateExtent:Pe,connectOnClick:ht,defaultEdgeOptions:gr,fitView:de,fitViewOptions:Fe,onNodesDelete:U,onEdgesDelete:G,onDelete:V,onNodeDragStart:Y,onNodeDrag:z,onNodeDragStop:K,onSelectionDrag:L,onSelectionDragStart:T,onSelectionDragStop:A,onMove:g,onMoveStart:x,onMoveEnd:p,noPanClassName:on,nodeOrigin:se,rfId:Yr,autoPanOnConnect:ur,autoPanOnNodeDrag:vn,autoPanSpeed:gs,onError:rr,connectionRadius:qr,isValidConnection:fr,selectNodesOnDrag:$e,nodeDragThreshold:ke,connectionDragThreshold:Be,onBeforeDelete:B,debug:Os,ariaLabelConfig:Fr,zIndexMode:Un}),t.jsx(PR,{onSelectionChange:E}),Wt,t.jsx(IR,{proOptions:Rn,position:Tt}),t.jsx(LR,{rfId:Yr,disableKeyboardA11y:dr})]})})}var xL=Jw(mL);function gL(e){const[n,s]=v.useState(e),l=v.useCallback(o=>s(d=>Ww(o,d)),[]);return[n,s,l]}function pL(e){const[n,s]=v.useState(e),l=v.useCallback(o=>s(d=>Qw(o,d)),[]);return[n,s,l]}function bL({dimensions:e,lineWidth:n,variant:s,className:l}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Zn(["react-flow__background-pattern",s,l])})}function yL({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:Zn(["react-flow__background-pattern","dots",n])})}var za;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(za||(za={}));const vL={[za.Dots]:1,[za.Lines]:1,[za.Cross]:6},jL=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function NN({id:e,variant:n=za.Dots,gap:s=20,size:l,lineWidth:o=1,offset:d=0,color:c,bgColor:h,style:m,className:f,patternClassName:g}){const x=v.useRef(null),{transform:p,patternId:y}=Jt(jL,An),w=l||vL[n],N=n===za.Dots,C=n===za.Cross,_=Array.isArray(s)?s:[s,s],O=[_[0]*p[2]||1,_[1]*p[2]||1],k=w*p[2],S=Array.isArray(d)?d:[d,d],R=C?[k,k]:O,D=[S[0]*p[2]||1+R[0]/2,S[1]*p[2]||1+R[1]/2],Y=`${y}${e||""}`;return t.jsxs("svg",{className:Zn(["react-flow__background",f]),style:{...m,...fu,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:x,"data-testid":"rf__background",children:[t.jsx("pattern",{id:Y,x:p[0]%O[0],y:p[1]%O[1],width:O[0],height:O[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:N?t.jsx(yL,{radius:k/2,className:g}):t.jsx(bL,{dimensions:R,lineWidth:o,variant:n,className:g})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${Y})`})]})}NN.displayName="Background";const wL=v.memo(NN);function NL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:t.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function kL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:t.jsx("path",{d:"M0 0h32v4.2H0z"})})}function SL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:t.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function CL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function EL(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function pd({children:e,className:n,...s}){return t.jsx("button",{type:"button",className:Zn(["react-flow__controls-button",n]),...s,children:e})}const TL=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function kN({style:e,showZoom:n=!0,showFitView:s=!0,showInteractive:l=!0,fitViewOptions:o,onZoomIn:d,onZoomOut:c,onFitView:h,onInteractiveChange:m,className:f,children:g,position:x="bottom-left",orientation:p="vertical","aria-label":y}){const w=_n(),{isInteractive:N,minZoomReached:C,maxZoomReached:_,ariaLabelConfig:O}=Jt(TL,An),{zoomIn:k,zoomOut:S,fitView:R}=Rx(),D=()=>{k(),d?.()},Y=()=>{S(),c?.()},z=()=>{R(o),h?.()},K=()=>{w.setState({nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N}),m?.(!N)},U=p==="horizontal"?"horizontal":"vertical";return t.jsxs(uu,{className:Zn(["react-flow__controls",U,f]),position:x,style:e,"data-testid":"rf__controls","aria-label":y??O["controls.ariaLabel"],children:[n&&t.jsxs(t.Fragment,{children:[t.jsx(pd,{onClick:D,className:"react-flow__controls-zoomin",title:O["controls.zoomIn.ariaLabel"],"aria-label":O["controls.zoomIn.ariaLabel"],disabled:_,children:t.jsx(NL,{})}),t.jsx(pd,{onClick:Y,className:"react-flow__controls-zoomout",title:O["controls.zoomOut.ariaLabel"],"aria-label":O["controls.zoomOut.ariaLabel"],disabled:C,children:t.jsx(kL,{})})]}),s&&t.jsx(pd,{className:"react-flow__controls-fitview",onClick:z,title:O["controls.fitView.ariaLabel"],"aria-label":O["controls.fitView.ariaLabel"],children:t.jsx(SL,{})}),l&&t.jsx(pd,{className:"react-flow__controls-interactive",onClick:K,title:O["controls.interactive.ariaLabel"],"aria-label":O["controls.interactive.ariaLabel"],children:N?t.jsx(EL,{}):t.jsx(CL,{})}),g]})}kN.displayName="Controls";const AL=v.memo(kN);function _L({id:e,x:n,y:s,width:l,height:o,style:d,color:c,strokeColor:h,strokeWidth:m,className:f,borderRadius:g,shapeRendering:x,selected:p,onClick:y}){const{background:w,backgroundColor:N}=d||{},C=c||w||N;return t.jsx("rect",{className:Zn(["react-flow__minimap-node",{selected:p},f]),x:n,y:s,rx:g,ry:g,width:l,height:o,style:{fill:C,stroke:h,strokeWidth:m},shapeRendering:x,onClick:y?_=>y(_,e):void 0})}const ML=v.memo(_L),OL=e=>e.nodes.map(n=>n.id),tm=e=>e instanceof Function?e:()=>e;function RL({nodeStrokeColor:e,nodeColor:n,nodeClassName:s="",nodeBorderRadius:l=5,nodeStrokeWidth:o,nodeComponent:d=ML,onClick:c}){const h=Jt(OL,An),m=tm(n),f=tm(e),g=tm(s),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:h.map(p=>t.jsx(LL,{id:p,nodeColorFunc:m,nodeStrokeColorFunc:f,nodeClassNameFunc:g,nodeBorderRadius:l,nodeStrokeWidth:o,NodeComponent:d,onClick:c,shapeRendering:x},p))})}function DL({id:e,nodeColorFunc:n,nodeStrokeColorFunc:s,nodeClassNameFunc:l,nodeBorderRadius:o,nodeStrokeWidth:d,shapeRendering:c,NodeComponent:h,onClick:m}){const{node:f,x:g,y:x,width:p,height:y}=Jt(w=>{const N=w.nodeLookup.get(e);if(!N)return{node:void 0,x:0,y:0,width:0,height:0};const C=N.internals.userNode,{x:_,y:O}=N.internals.positionAbsolute,{width:k,height:S}=ra(C);return{node:C,x:_,y:O,width:k,height:S}},An);return!f||f.hidden||!Sw(f)?null:t.jsx(h,{x:g,y:x,width:p,height:y,style:f.style,selected:!!f.selected,className:l(f),color:n(f),borderRadius:o,strokeColor:s(f),strokeWidth:d,shapeRendering:c,onClick:m,id:f.id})}const LL=v.memo(DL);var IL=v.memo(RL);const zL=200,$L=150,BL=e=>!e.hidden,HL=e=>{const n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:e.nodeLookup.size>0?kw(Xo(e.nodeLookup,{filter:BL}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},PL="react-flow__minimap-desc";function SN({style:e,className:n,nodeStrokeColor:s,nodeColor:l,nodeClassName:o="",nodeBorderRadius:d=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:m,maskColor:f,maskStrokeColor:g,maskStrokeWidth:x,position:p="bottom-right",onClick:y,onNodeClick:w,pannable:N=!1,zoomable:C=!1,ariaLabel:_,inversePan:O,zoomStep:k=1,offsetScale:S=5}){const R=_n(),D=v.useRef(null),{boundingRect:Y,viewBB:z,rfId:K,panZoom:U,translateExtent:G,flowWidth:V,flowHeight:E,ariaLabelConfig:T}=Jt(HL,An),L=e?.width??zL,A=e?.height??$L,P=Y.width/L,q=Y.height/A,W=Math.max(P,q),B=W*L,F=W*A,X=S*W,I=Y.x-(B-Y.width)/2-X,M=Y.y-(F-Y.height)/2-X,H=B+X*2,Z=F+X*2,ee=`${PL}-${K}`,ne=v.useRef(0),ae=v.useRef();ne.current=W,v.useEffect(()=>{if(D.current&&U)return ae.current=nR({domNode:D.current,panZoom:U,getTransform:()=>R.getState().transform,getViewScale:()=>ne.current}),()=>{ae.current?.destroy()}},[U]),v.useEffect(()=>{ae.current?.update({translateExtent:G,width:V,height:E,inversePan:O,pannable:N,zoomStep:k,zoomable:C})},[N,C,O,k,G,V,E]);const he=y?ye=>{const[je,Ae]=ae.current?.pointer(ye)||[0,0];y(ye,{x:je,y:Ae})}:void 0,Ne=w?v.useCallback((ye,je)=>{const Ae=R.getState().nodeLookup.get(je).internals.userNode;w(ye,Ae)},[]):void 0,Le=_??T["minimap.ariaLabel"];return t.jsx(uu,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*W:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:Zn(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:L,height:A,viewBox:`${I} ${M} ${H} ${Z}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:D,onClick:he,children:[Le&&t.jsx("title",{id:ee,children:Le}),t.jsx(IL,{onClick:Ne,nodeColor:l,nodeStrokeColor:s,nodeBorderRadius:d,nodeClassName:o,nodeStrokeWidth:c,nodeComponent:h}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${I-X},${M-X}h${H+X*2}v${Z+X*2}h${-H-X*2}z
61
- M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}SN.displayName="MiniMap";const UL=v.memo(SN),qL=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,VL={[mi.Line]:"right",[mi.Handle]:"bottom-right"};function FL({nodeId:e,position:n,variant:s=mi.Handle,className:l,style:o=void 0,children:d,color:c,minWidth:h=10,minHeight:m=10,maxWidth:f=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:p,autoScale:y=!0,shouldResize:w,onResizeStart:N,onResize:C,onResizeEnd:_}){const O=rN(),k=typeof e=="string"?e:O,S=_n(),R=v.useRef(null),D=s===mi.Handle,Y=Jt(v.useCallback(qL(D&&y),[D,y]),An),z=v.useRef(null),K=n??VL[s];v.useEffect(()=>{if(!(!R.current||!k))return z.current||(z.current=gR({domNode:R.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:G,transform:V,snapGrid:E,snapToGrid:T,nodeOrigin:L,domNode:A}=S.getState();return{nodeLookup:G,transform:V,snapGrid:E,snapToGrid:T,nodeOrigin:L,paneDomNode:A}},onChange:(G,V)=>{const{triggerNodeChanges:E,nodeLookup:T,parentLookup:L,nodeOrigin:A}=S.getState(),P=[],q={x:G.x,y:G.y},W=T.get(k);if(W&&W.expandParent&&W.parentId){const B=W.origin??A,F=G.width??W.measured.width??0,X=G.height??W.measured.height??0,I={id:W.id,parentId:W.parentId,rect:{width:F,height:X,...Cw({x:G.x??W.position.x,y:G.y??W.position.y},{width:F,height:X},W.parentId,T,B)}},M=Ox([I],T,L,A);P.push(...M),q.x=G.x?Math.max(B[0]*F,G.x):void 0,q.y=G.y?Math.max(B[1]*X,G.y):void 0}if(q.x!==void 0&&q.y!==void 0){const B={id:k,type:"position",position:{...q}};P.push(B)}if(G.width!==void 0&&G.height!==void 0){const F={id:k,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:G.width,height:G.height}};P.push(F)}for(const B of V){const F={...B,type:"position"};P.push(F)}E(P)},onEnd:({width:G,height:V})=>{const E={id:k,type:"dimensions",resizing:!1,dimensions:{width:G,height:V}};S.getState().triggerNodeChanges([E])}})),z.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:m,maxWidth:f,maxHeight:g},keepAspectRatio:x,resizeDirection:p,onResizeStart:N,onResize:C,onResizeEnd:_,shouldResize:w}),()=>{z.current?.destroy()}},[K,h,m,f,g,x,N,C,_,w]);const U=K.split("-");return t.jsx("div",{className:Zn(["react-flow__resize-control","nodrag",...U,s,l]),ref:R,style:{...o,scale:Y,...c&&{[D?"backgroundColor":"borderColor"]:c}},children:d})}v.memo(FL);var un=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ms=un((e,n)=>{var s=Object.defineProperty,l=(E,T,L)=>T in E?s(E,T,{enumerable:!0,configurable:!0,writable:!0,value:L}):E[T]=L,o=(E,T)=>()=>(T||E((T={exports:{}}).exports,T),T.exports),d=(E,T,L)=>l(E,typeof T!="symbol"?T+"":T,L),c=o((E,T)=>{var L="\0",A="\0",P="",q=class{constructor(M){d(this,"_isDirected",!0),d(this,"_isMultigraph",!1),d(this,"_isCompound",!1),d(this,"_label"),d(this,"_defaultNodeLabelFn",()=>{}),d(this,"_defaultEdgeLabelFn",()=>{}),d(this,"_nodes",{}),d(this,"_in",{}),d(this,"_preds",{}),d(this,"_out",{}),d(this,"_sucs",{}),d(this,"_edgeObjs",{}),d(this,"_edgeLabels",{}),d(this,"_nodeCount",0),d(this,"_edgeCount",0),d(this,"_parent"),d(this,"_children"),M&&(this._isDirected=Object.hasOwn(M,"directed")?M.directed:!0,this._isMultigraph=Object.hasOwn(M,"multigraph")?M.multigraph:!1,this._isCompound=Object.hasOwn(M,"compound")?M.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[A]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(M){return this._label=M,this}graph(){return this._label}setDefaultNodeLabel(M){return this._defaultNodeLabelFn=M,typeof M!="function"&&(this._defaultNodeLabelFn=()=>M),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var M=this;return this.nodes().filter(H=>Object.keys(M._in[H]).length===0)}sinks(){var M=this;return this.nodes().filter(H=>Object.keys(M._out[H]).length===0)}setNodes(M,H){var Z=arguments,ee=this;return M.forEach(function(ne){Z.length>1?ee.setNode(ne,H):ee.setNode(ne)}),this}setNode(M,H){return Object.hasOwn(this._nodes,M)?(arguments.length>1&&(this._nodes[M]=H),this):(this._nodes[M]=arguments.length>1?H:this._defaultNodeLabelFn(M),this._isCompound&&(this._parent[M]=A,this._children[M]={},this._children[A][M]=!0),this._in[M]={},this._preds[M]={},this._out[M]={},this._sucs[M]={},++this._nodeCount,this)}node(M){return this._nodes[M]}hasNode(M){return Object.hasOwn(this._nodes,M)}removeNode(M){var H=this;if(Object.hasOwn(this._nodes,M)){var Z=ee=>H.removeEdge(H._edgeObjs[ee]);delete this._nodes[M],this._isCompound&&(this._removeFromParentsChildList(M),delete this._parent[M],this.children(M).forEach(function(ee){H.setParent(ee)}),delete this._children[M]),Object.keys(this._in[M]).forEach(Z),delete this._in[M],delete this._preds[M],Object.keys(this._out[M]).forEach(Z),delete this._out[M],delete this._sucs[M],--this._nodeCount}return this}setParent(M,H){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(H===void 0)H=A;else{H+="";for(var Z=H;Z!==void 0;Z=this.parent(Z))if(Z===M)throw new Error("Setting "+H+" as parent of "+M+" would create a cycle");this.setNode(H)}return this.setNode(M),this._removeFromParentsChildList(M),this._parent[M]=H,this._children[H][M]=!0,this}_removeFromParentsChildList(M){delete this._children[this._parent[M]][M]}parent(M){if(this._isCompound){var H=this._parent[M];if(H!==A)return H}}children(M=A){if(this._isCompound){var H=this._children[M];if(H)return Object.keys(H)}else{if(M===A)return this.nodes();if(this.hasNode(M))return[]}}predecessors(M){var H=this._preds[M];if(H)return Object.keys(H)}successors(M){var H=this._sucs[M];if(H)return Object.keys(H)}neighbors(M){var H=this.predecessors(M);if(H){let ee=new Set(H);for(var Z of this.successors(M))ee.add(Z);return Array.from(ee.values())}}isLeaf(M){var H;return this.isDirected()?H=this.successors(M):H=this.neighbors(M),H.length===0}filterNodes(M){var H=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});H.setGraph(this.graph());var Z=this;Object.entries(this._nodes).forEach(function([ae,he]){M(ae)&&H.setNode(ae,he)}),Object.values(this._edgeObjs).forEach(function(ae){H.hasNode(ae.v)&&H.hasNode(ae.w)&&H.setEdge(ae,Z.edge(ae))});var ee={};function ne(ae){var he=Z.parent(ae);return he===void 0||H.hasNode(he)?(ee[ae]=he,he):he in ee?ee[he]:ne(he)}return this._isCompound&&H.nodes().forEach(ae=>H.setParent(ae,ne(ae))),H}setDefaultEdgeLabel(M){return this._defaultEdgeLabelFn=M,typeof M!="function"&&(this._defaultEdgeLabelFn=()=>M),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(M,H){var Z=this,ee=arguments;return M.reduce(function(ne,ae){return ee.length>1?Z.setEdge(ne,ae,H):Z.setEdge(ne,ae),ae}),this}setEdge(){var M,H,Z,ee,ne=!1,ae=arguments[0];typeof ae=="object"&&ae!==null&&"v"in ae?(M=ae.v,H=ae.w,Z=ae.name,arguments.length===2&&(ee=arguments[1],ne=!0)):(M=ae,H=arguments[1],Z=arguments[3],arguments.length>2&&(ee=arguments[2],ne=!0)),M=""+M,H=""+H,Z!==void 0&&(Z=""+Z);var he=F(this._isDirected,M,H,Z);if(Object.hasOwn(this._edgeLabels,he))return ne&&(this._edgeLabels[he]=ee),this;if(Z!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(M),this.setNode(H),this._edgeLabels[he]=ne?ee:this._defaultEdgeLabelFn(M,H,Z);var Ne=X(this._isDirected,M,H,Z);return M=Ne.v,H=Ne.w,Object.freeze(Ne),this._edgeObjs[he]=Ne,W(this._preds[H],M),W(this._sucs[M],H),this._in[H][he]=Ne,this._out[M][he]=Ne,this._edgeCount++,this}edge(M,H,Z){var ee=arguments.length===1?I(this._isDirected,arguments[0]):F(this._isDirected,M,H,Z);return this._edgeLabels[ee]}edgeAsObj(){let M=this.edge(...arguments);return typeof M!="object"?{label:M}:M}hasEdge(M,H,Z){var ee=arguments.length===1?I(this._isDirected,arguments[0]):F(this._isDirected,M,H,Z);return Object.hasOwn(this._edgeLabels,ee)}removeEdge(M,H,Z){var ee=arguments.length===1?I(this._isDirected,arguments[0]):F(this._isDirected,M,H,Z),ne=this._edgeObjs[ee];return ne&&(M=ne.v,H=ne.w,delete this._edgeLabels[ee],delete this._edgeObjs[ee],B(this._preds[H],M),B(this._sucs[M],H),delete this._in[H][ee],delete this._out[M][ee],this._edgeCount--),this}inEdges(M,H){return this.isDirected()?this.filterEdges(this._in[M],M,H):this.nodeEdges(M,H)}outEdges(M,H){return this.isDirected()?this.filterEdges(this._out[M],M,H):this.nodeEdges(M,H)}nodeEdges(M,H){if(M in this._nodes)return this.filterEdges({...this._in[M],...this._out[M]},M,H)}filterEdges(M,H,Z){if(M){var ee=Object.values(M);return Z?ee.filter(function(ne){return ne.v===H&&ne.w===Z||ne.v===Z&&ne.w===H}):ee}}};function W(M,H){M[H]?M[H]++:M[H]=1}function B(M,H){--M[H]||delete M[H]}function F(M,H,Z,ee){var ne=""+H,ae=""+Z;if(!M&&ne>ae){var he=ne;ne=ae,ae=he}return ne+P+ae+P+(ee===void 0?L:ee)}function X(M,H,Z,ee){var ne=""+H,ae=""+Z;if(!M&&ne>ae){var he=ne;ne=ae,ae=he}var Ne={v:ne,w:ae};return ee&&(Ne.name=ee),Ne}function I(M,H){return F(M,H.v,H.w,H.name)}T.exports=q}),h=o((E,T)=>{T.exports="3.0.2"}),m=o((E,T)=>{T.exports={Graph:c(),version:h()}}),f=o((E,T)=>{var L=c();T.exports={write:A,read:W};function A(B){var F={options:{directed:B.isDirected(),multigraph:B.isMultigraph(),compound:B.isCompound()},nodes:P(B),edges:q(B)};return B.graph()!==void 0&&(F.value=structuredClone(B.graph())),F}function P(B){return B.nodes().map(function(F){var X=B.node(F),I=B.parent(F),M={v:F};return X!==void 0&&(M.value=X),I!==void 0&&(M.parent=I),M})}function q(B){return B.edges().map(function(F){var X=B.edge(F),I={v:F.v,w:F.w};return F.name!==void 0&&(I.name=F.name),X!==void 0&&(I.value=X),I})}function W(B){var F=new L(B.options).setGraph(B.value);return B.nodes.forEach(function(X){F.setNode(X.v,X.value),X.parent&&F.setParent(X.v,X.parent)}),B.edges.forEach(function(X){F.setEdge({v:X.v,w:X.w,name:X.name},X.value)}),F}}),g=o((E,T)=>{T.exports=A;var L=()=>1;function A(q,W,B,F){return P(q,String(W),B||L,F||function(X){return q.outEdges(X)})}function P(q,W,B,F){var X={},I=!0,M=0,H=q.nodes(),Z=function(he){var Ne=B(he);X[he.v].distance+Ne<X[he.w].distance&&(X[he.w]={distance:X[he.v].distance+Ne,predecessor:he.v},I=!0)},ee=function(){H.forEach(function(he){F(he).forEach(function(Ne){var Le=Ne.v===he?Ne.v:Ne.w,ye=Le===Ne.v?Ne.w:Ne.v;Z({v:Le,w:ye})})})};H.forEach(function(he){var Ne=he===W?0:Number.POSITIVE_INFINITY;X[he]={distance:Ne}});for(var ne=H.length,ae=1;ae<ne&&(I=!1,M++,ee(),!!I);ae++);if(M===ne-1&&(I=!1,ee(),I))throw new Error("The graph contains a negative weight cycle");return X}}),x=o((E,T)=>{T.exports=L;function L(A){var P={},q=[],W;function B(F){Object.hasOwn(P,F)||(P[F]=!0,W.push(F),A.successors(F).forEach(B),A.predecessors(F).forEach(B))}return A.nodes().forEach(function(F){W=[],B(F),W.length&&q.push(W)}),q}}),p=o((E,T)=>{var L=class{constructor(){d(this,"_arr",[]),d(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(A){return A.key})}has(A){return Object.hasOwn(this._keyIndices,A)}priority(A){var P=this._keyIndices[A];if(P!==void 0)return this._arr[P].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(A,P){var q=this._keyIndices;if(A=String(A),!Object.hasOwn(q,A)){var W=this._arr,B=W.length;return q[A]=B,W.push({key:A,priority:P}),this._decrease(B),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var A=this._arr.pop();return delete this._keyIndices[A.key],this._heapify(0),A.key}decrease(A,P){var q=this._keyIndices[A];if(P>this._arr[q].priority)throw new Error("New priority is greater than current priority. Key: "+A+" Old: "+this._arr[q].priority+" New: "+P);this._arr[q].priority=P,this._decrease(q)}_heapify(A){var P=this._arr,q=2*A,W=q+1,B=A;q<P.length&&(B=P[q].priority<P[B].priority?q:B,W<P.length&&(B=P[W].priority<P[B].priority?W:B),B!==A&&(this._swap(A,B),this._heapify(B)))}_decrease(A){for(var P=this._arr,q=P[A].priority,W;A!==0&&(W=A>>1,!(P[W].priority<q));)this._swap(A,W),A=W}_swap(A,P){var q=this._arr,W=this._keyIndices,B=q[A],F=q[P];q[A]=F,q[P]=B,W[F.key]=A,W[B.key]=P}};T.exports=L}),y=o((E,T)=>{var L=p();T.exports=P;var A=()=>1;function P(W,B,F,X){var I=function(M){return W.outEdges(M)};return q(W,String(B),F||A,X||I)}function q(W,B,F,X){var I={},M=new L,H,Z,ee=function(ne){var ae=ne.v!==H?ne.v:ne.w,he=I[ae],Ne=F(ne),Le=Z.distance+Ne;if(Ne<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+ne+" Weight: "+Ne);Le<he.distance&&(he.distance=Le,he.predecessor=H,M.decrease(ae,Le))};for(W.nodes().forEach(function(ne){var ae=ne===B?0:Number.POSITIVE_INFINITY;I[ne]={distance:ae},M.add(ne,ae)});M.size()>0&&(H=M.removeMin(),Z=I[H],Z.distance!==Number.POSITIVE_INFINITY);)X(H).forEach(ee);return I}}),w=o((E,T)=>{var L=y();T.exports=A;function A(P,q,W){return P.nodes().reduce(function(B,F){return B[F]=L(P,F,q,W),B},{})}}),N=o((E,T)=>{T.exports=L;function L(P,q,W){if(P[q].predecessor!==void 0)throw new Error("Invalid source vertex");if(P[W].predecessor===void 0&&W!==q)throw new Error("Invalid destination vertex");return{weight:P[W].distance,path:A(P,q,W)}}function A(P,q,W){for(var B=[],F=W;F!==q;)B.push(F),F=P[F].predecessor;return B.push(q),B.reverse()}}),C=o((E,T)=>{T.exports=L;function L(A){var P=0,q=[],W={},B=[];function F(X){var I=W[X]={onStack:!0,lowlink:P,index:P++};if(q.push(X),A.successors(X).forEach(function(Z){Object.hasOwn(W,Z)?W[Z].onStack&&(I.lowlink=Math.min(I.lowlink,W[Z].index)):(F(Z),I.lowlink=Math.min(I.lowlink,W[Z].lowlink))}),I.lowlink===I.index){var M=[],H;do H=q.pop(),W[H].onStack=!1,M.push(H);while(X!==H);B.push(M)}}return A.nodes().forEach(function(X){Object.hasOwn(W,X)||F(X)}),B}}),_=o((E,T)=>{var L=C();T.exports=A;function A(P){return L(P).filter(function(q){return q.length>1||q.length===1&&P.hasEdge(q[0],q[0])})}}),O=o((E,T)=>{T.exports=A;var L=()=>1;function A(q,W,B){return P(q,W||L,B||function(F){return q.outEdges(F)})}function P(q,W,B){var F={},X=q.nodes();return X.forEach(function(I){F[I]={},F[I][I]={distance:0},X.forEach(function(M){I!==M&&(F[I][M]={distance:Number.POSITIVE_INFINITY})}),B(I).forEach(function(M){var H=M.v===I?M.w:M.v,Z=W(M);F[I][H]={distance:Z,predecessor:I}})}),X.forEach(function(I){var M=F[I];X.forEach(function(H){var Z=F[H];X.forEach(function(ee){var ne=Z[I],ae=M[ee],he=Z[ee],Ne=ne.distance+ae.distance;Ne<he.distance&&(he.distance=Ne,he.predecessor=ae.predecessor)})})}),F}}),k=o((E,T)=>{function L(P){var q={},W={},B=[];function F(X){if(Object.hasOwn(W,X))throw new A;Object.hasOwn(q,X)||(W[X]=!0,q[X]=!0,P.predecessors(X).forEach(F),delete W[X],B.push(X))}if(P.sinks().forEach(F),Object.keys(q).length!==P.nodeCount())throw new A;return B}var A=class extends Error{constructor(){super(...arguments)}};T.exports=L,L.CycleException=A}),S=o((E,T)=>{var L=k();T.exports=A;function A(P){try{L(P)}catch(q){if(q instanceof L.CycleException)return!1;throw q}return!0}}),R=o((E,T)=>{T.exports=L;function L(P,q,W,B,F){Array.isArray(q)||(q=[q]);var X=(P.isDirected()?P.successors:P.neighbors).bind(P),I={};return q.forEach(function(M){if(!P.hasNode(M))throw new Error("Graph does not have node: "+M);F=A(P,M,W==="post",I,X,B,F)}),F}function A(P,q,W,B,F,X,I){return Object.hasOwn(B,q)||(B[q]=!0,W||(I=X(I,q)),F(q).forEach(function(M){I=A(P,M,W,B,F,X,I)}),W&&(I=X(I,q))),I}}),D=o((E,T)=>{var L=R();T.exports=A;function A(P,q,W){return L(P,q,W,function(B,F){return B.push(F),B},[])}}),Y=o((E,T)=>{var L=D();T.exports=A;function A(P,q){return L(P,q,"post")}}),z=o((E,T)=>{var L=D();T.exports=A;function A(P,q){return L(P,q,"pre")}}),K=o((E,T)=>{var L=c(),A=p();T.exports=P;function P(q,W){var B=new L,F={},X=new A,I;function M(Z){var ee=Z.v===I?Z.w:Z.v,ne=X.priority(ee);if(ne!==void 0){var ae=W(Z);ae<ne&&(F[ee]=I,X.decrease(ee,ae))}}if(q.nodeCount()===0)return B;q.nodes().forEach(function(Z){X.add(Z,Number.POSITIVE_INFINITY),B.setNode(Z)}),X.decrease(q.nodes()[0],0);for(var H=!1;X.size()>0;){if(I=X.removeMin(),Object.hasOwn(F,I))B.setEdge(I,F[I]);else{if(H)throw new Error("Input graph is not connected: "+q);H=!0}q.nodeEdges(I).forEach(M)}return B}}),U=o((E,T)=>{var L=y(),A=g();T.exports=P;function P(W,B,F,X){return q(W,B,F,X||function(I){return W.outEdges(I)})}function q(W,B,F,X){if(F===void 0)return L(W,B,F,X);for(var I=!1,M=W.nodes(),H=0;H<M.length;H++){for(var Z=X(M[H]),ee=0;ee<Z.length;ee++){var ne=Z[ee],ae=ne.v===M[H]?ne.v:ne.w,he=ae===ne.v?ne.w:ne.v;F({v:ae,w:he})<0&&(I=!0)}if(I)return A(W,B,F,X)}return L(W,B,F,X)}}),G=o((E,T)=>{T.exports={bellmanFord:g(),components:x(),dijkstra:y(),dijkstraAll:w(),extractPath:N(),findCycles:_(),floydWarshall:O(),isAcyclic:S(),postorder:Y(),preorder:z(),prim:K(),shortestPaths:U(),reduce:R(),tarjan:C(),topsort:k()}}),V=m();n.exports={Graph:V.Graph,json:f(),alg:G(),version:V.version}}),YL=un((e,n)=>{var s=class{constructor(){let d={};d._next=d._prev=d,this._sentinel=d}dequeue(){let d=this._sentinel,c=d._prev;if(c!==d)return l(c),c}enqueue(d){let c=this._sentinel;d._prev&&d._next&&l(d),d._next=c._next,c._next._prev=d,c._next=d,d._prev=c}toString(){let d=[],c=this._sentinel,h=c._prev;for(;h!==c;)d.push(JSON.stringify(h,o)),h=h._prev;return"["+d.join(", ")+"]"}};function l(d){d._prev._next=d._next,d._next._prev=d._prev,delete d._next,delete d._prev}function o(d,c){if(d!=="_next"&&d!=="_prev")return c}n.exports=s}),GL=un((e,n)=>{var s=ms().Graph,l=YL();n.exports=d;var o=()=>1;function d(x,p){if(x.nodeCount()<=1)return[];let y=m(x,p||o);return c(y.graph,y.buckets,y.zeroIdx).flatMap(w=>x.outEdges(w.v,w.w))}function c(x,p,y){let w=[],N=p[p.length-1],C=p[0],_;for(;x.nodeCount();){for(;_=C.dequeue();)h(x,p,y,_);for(;_=N.dequeue();)h(x,p,y,_);if(x.nodeCount()){for(let O=p.length-2;O>0;--O)if(_=p[O].dequeue(),_){w=w.concat(h(x,p,y,_,!0));break}}}return w}function h(x,p,y,w,N){let C=N?[]:void 0;return x.inEdges(w.v).forEach(_=>{let O=x.edge(_),k=x.node(_.v);N&&C.push({v:_.v,w:_.w}),k.out-=O,f(p,y,k)}),x.outEdges(w.v).forEach(_=>{let O=x.edge(_),k=_.w,S=x.node(k);S.in-=O,f(p,y,S)}),x.removeNode(w.v),C}function m(x,p){let y=new s,w=0,N=0;x.nodes().forEach(O=>{y.setNode(O,{v:O,in:0,out:0})}),x.edges().forEach(O=>{let k=y.edge(O.v,O.w)||0,S=p(O),R=k+S;y.setEdge(O.v,O.w,R),N=Math.max(N,y.node(O.v).out+=S),w=Math.max(w,y.node(O.w).in+=S)});let C=g(N+w+3).map(()=>new l),_=w+1;return y.nodes().forEach(O=>{f(C,_,y.node(O))}),{graph:y,buckets:C,zeroIdx:_}}function f(x,p,y){y.out?y.in?x[y.out-y.in+p].enqueue(y):x[x.length-1].enqueue(y):x[0].enqueue(y)}function g(x){let p=[];for(let y=0;y<x;y++)p.push(y);return p}}),Kn=un((e,n)=>{var s=ms().Graph;n.exports={addBorderNode:p,addDummyNode:l,applyWithChunking:N,asNonCompoundGraph:d,buildLayerMatrix:f,intersectRect:m,mapValues:z,maxRank:C,normalizeRanks:g,notime:k,partition:_,pick:Y,predecessorWeights:h,range:D,removeEmptyRanks:x,simplify:o,successorWeights:c,time:O,uniqueId:R,zipObject:K};function l(U,G,V,E){for(var T=E;U.hasNode(T);)T=R(E);return V.dummy=G,U.setNode(T,V),T}function o(U){let G=new s().setGraph(U.graph());return U.nodes().forEach(V=>G.setNode(V,U.node(V))),U.edges().forEach(V=>{let E=G.edge(V.v,V.w)||{weight:0,minlen:1},T=U.edge(V);G.setEdge(V.v,V.w,{weight:E.weight+T.weight,minlen:Math.max(E.minlen,T.minlen)})}),G}function d(U){let G=new s({multigraph:U.isMultigraph()}).setGraph(U.graph());return U.nodes().forEach(V=>{U.children(V).length||G.setNode(V,U.node(V))}),U.edges().forEach(V=>{G.setEdge(V,U.edge(V))}),G}function c(U){let G=U.nodes().map(V=>{let E={};return U.outEdges(V).forEach(T=>{E[T.w]=(E[T.w]||0)+U.edge(T).weight}),E});return K(U.nodes(),G)}function h(U){let G=U.nodes().map(V=>{let E={};return U.inEdges(V).forEach(T=>{E[T.v]=(E[T.v]||0)+U.edge(T).weight}),E});return K(U.nodes(),G)}function m(U,G){let V=U.x,E=U.y,T=G.x-V,L=G.y-E,A=U.width/2,P=U.height/2;if(!T&&!L)throw new Error("Not possible to find intersection inside of the rectangle");let q,W;return Math.abs(L)*A>Math.abs(T)*P?(L<0&&(P=-P),q=P*T/L,W=P):(T<0&&(A=-A),q=A,W=A*L/T),{x:V+q,y:E+W}}function f(U){let G=D(C(U)+1).map(()=>[]);return U.nodes().forEach(V=>{let E=U.node(V),T=E.rank;T!==void 0&&(G[T][E.order]=V)}),G}function g(U){let G=U.nodes().map(E=>{let T=U.node(E).rank;return T===void 0?Number.MAX_VALUE:T}),V=N(Math.min,G);U.nodes().forEach(E=>{let T=U.node(E);Object.hasOwn(T,"rank")&&(T.rank-=V)})}function x(U){let G=U.nodes().map(A=>U.node(A).rank).filter(A=>A!==void 0),V=N(Math.min,G),E=[];U.nodes().forEach(A=>{let P=U.node(A).rank-V;E[P]||(E[P]=[]),E[P].push(A)});let T=0,L=U.graph().nodeRankFactor;Array.from(E).forEach((A,P)=>{A===void 0&&P%L!==0?--T:A!==void 0&&T&&A.forEach(q=>U.node(q).rank+=T)})}function p(U,G,V,E){let T={width:0,height:0};return arguments.length>=4&&(T.rank=V,T.order=E),l(U,"border",T,G)}function y(U,G=w){let V=[];for(let E=0;E<U.length;E+=G){let T=U.slice(E,E+G);V.push(T)}return V}var w=65535;function N(U,G){if(G.length>w){let V=y(G);return U.apply(null,V.map(E=>U.apply(null,E)))}else return U.apply(null,G)}function C(U){let G=U.nodes().map(V=>{let E=U.node(V).rank;return E===void 0?Number.MIN_VALUE:E});return N(Math.max,G)}function _(U,G){let V={lhs:[],rhs:[]};return U.forEach(E=>{G(E)?V.lhs.push(E):V.rhs.push(E)}),V}function O(U,G){let V=Date.now();try{return G()}finally{console.log(U+" time: "+(Date.now()-V)+"ms")}}function k(U,G){return G()}var S=0;function R(U){var G=++S;return U+(""+G)}function D(U,G,V=1){G==null&&(G=U,U=0);let E=L=>L<G;V<0&&(E=L=>G<L);let T=[];for(let L=U;E(L);L+=V)T.push(L);return T}function Y(U,G){let V={};for(let E of G)U[E]!==void 0&&(V[E]=U[E]);return V}function z(U,G){let V=G;return typeof G=="string"&&(V=E=>E[G]),Object.entries(U).reduce((E,[T,L])=>(E[T]=V(L,T),E),{})}function K(U,G){return U.reduce((V,E,T)=>(V[E]=G[T],V),{})}}),XL=un((e,n)=>{var s=GL(),l=Kn().uniqueId;n.exports={run:o,undo:c};function o(h){(h.graph().acyclicer==="greedy"?s(h,m(h)):d(h)).forEach(f=>{let g=h.edge(f);h.removeEdge(f),g.forwardName=f.name,g.reversed=!0,h.setEdge(f.w,f.v,g,l("rev"))});function m(f){return g=>f.edge(g).weight}}function d(h){let m=[],f={},g={};function x(p){Object.hasOwn(g,p)||(g[p]=!0,f[p]=!0,h.outEdges(p).forEach(y=>{Object.hasOwn(f,y.w)?m.push(y):x(y.w)}),delete f[p])}return h.nodes().forEach(x),m}function c(h){h.edges().forEach(m=>{let f=h.edge(m);if(f.reversed){h.removeEdge(m);let g=f.forwardName;delete f.reversed,delete f.forwardName,h.setEdge(m.w,m.v,f,g)}})}}),KL=un((e,n)=>{var s=Kn();n.exports={run:l,undo:d};function l(c){c.graph().dummyChains=[],c.edges().forEach(h=>o(c,h))}function o(c,h){let m=h.v,f=c.node(m).rank,g=h.w,x=c.node(g).rank,p=h.name,y=c.edge(h),w=y.labelRank;if(x===f+1)return;c.removeEdge(h);let N,C,_;for(_=0,++f;f<x;++_,++f)y.points=[],C={width:0,height:0,edgeLabel:y,edgeObj:h,rank:f},N=s.addDummyNode(c,"edge",C,"_d"),f===w&&(C.width=y.width,C.height=y.height,C.dummy="edge-label",C.labelpos=y.labelpos),c.setEdge(m,N,{weight:y.weight},p),_===0&&c.graph().dummyChains.push(N),m=N;c.setEdge(m,g,{weight:y.weight},p)}function d(c){c.graph().dummyChains.forEach(h=>{let m=c.node(h),f=m.edgeLabel,g;for(c.setEdge(m.edgeObj,f);m.dummy;)g=c.successors(h)[0],c.removeNode(h),f.points.push({x:m.x,y:m.y}),m.dummy==="edge-label"&&(f.x=m.x,f.y=m.y,f.width=m.width,f.height=m.height),h=g,m=c.node(h)})}}),Gd=un((e,n)=>{var{applyWithChunking:s}=Kn();n.exports={longestPath:l,slack:o};function l(d){var c={};function h(m){var f=d.node(m);if(Object.hasOwn(c,m))return f.rank;c[m]=!0;let g=d.outEdges(m).map(p=>p==null?Number.POSITIVE_INFINITY:h(p.w)-d.edge(p).minlen);var x=s(Math.min,g);return x===Number.POSITIVE_INFINITY&&(x=0),f.rank=x}d.sources().forEach(h)}function o(d,c){return d.node(c.w).rank-d.node(c.v).rank-d.edge(c).minlen}}),CN=un((e,n)=>{var s=ms().Graph,l=Gd().slack;n.exports=o;function o(m){var f=new s({directed:!1}),g=m.nodes()[0],x=m.nodeCount();f.setNode(g,{});for(var p,y;d(f,m)<x;)p=c(f,m),y=f.hasNode(p.v)?l(m,p):-l(m,p),h(f,m,y);return f}function d(m,f){function g(x){f.nodeEdges(x).forEach(p=>{var y=p.v,w=x===y?p.w:y;!m.hasNode(w)&&!l(f,p)&&(m.setNode(w,{}),m.setEdge(x,w,{}),g(w))})}return m.nodes().forEach(g),m.nodeCount()}function c(m,f){return f.edges().reduce((g,x)=>{let p=Number.POSITIVE_INFINITY;return m.hasNode(x.v)!==m.hasNode(x.w)&&(p=l(f,x)),p<g[0]?[p,x]:g},[Number.POSITIVE_INFINITY,null])[1]}function h(m,f,g){m.nodes().forEach(x=>f.node(x).rank+=g)}}),ZL=un((e,n)=>{var s=CN(),l=Gd().slack,o=Gd().longestPath,d=ms().alg.preorder,c=ms().alg.postorder,h=Kn().simplify;n.exports=m,m.initLowLimValues=p,m.initCutValues=f,m.calcCutValue=x,m.leaveEdge=w,m.enterEdge=N,m.exchangeEdges=C;function m(S){S=h(S),o(S);var R=s(S);p(R),f(R,S);for(var D,Y;D=w(R);)Y=N(R,S,D),C(R,S,D,Y)}function f(S,R){var D=c(S,S.nodes());D=D.slice(0,D.length-1),D.forEach(Y=>g(S,R,Y))}function g(S,R,D){var Y=S.node(D),z=Y.parent;S.edge(D,z).cutvalue=x(S,R,D)}function x(S,R,D){var Y=S.node(D),z=Y.parent,K=!0,U=R.edge(D,z),G=0;return U||(K=!1,U=R.edge(z,D)),G=U.weight,R.nodeEdges(D).forEach(V=>{var E=V.v===D,T=E?V.w:V.v;if(T!==z){var L=E===K,A=R.edge(V).weight;if(G+=L?A:-A,O(S,D,T)){var P=S.edge(D,T).cutvalue;G+=L?-P:P}}}),G}function p(S,R){arguments.length<2&&(R=S.nodes()[0]),y(S,{},1,R)}function y(S,R,D,Y,z){var K=D,U=S.node(Y);return R[Y]=!0,S.neighbors(Y).forEach(G=>{Object.hasOwn(R,G)||(D=y(S,R,D,G,Y))}),U.low=K,U.lim=D++,z?U.parent=z:delete U.parent,D}function w(S){return S.edges().find(R=>S.edge(R).cutvalue<0)}function N(S,R,D){var Y=D.v,z=D.w;R.hasEdge(Y,z)||(Y=D.w,z=D.v);var K=S.node(Y),U=S.node(z),G=K,V=!1;K.lim>U.lim&&(G=U,V=!0);var E=R.edges().filter(T=>V===k(S,S.node(T.v),G)&&V!==k(S,S.node(T.w),G));return E.reduce((T,L)=>l(R,L)<l(R,T)?L:T)}function C(S,R,D,Y){var z=D.v,K=D.w;S.removeEdge(z,K),S.setEdge(Y.v,Y.w,{}),p(S),f(S,R),_(S,R)}function _(S,R){var D=S.nodes().find(z=>!R.node(z).parent),Y=d(S,D);Y=Y.slice(1),Y.forEach(z=>{var K=S.node(z).parent,U=R.edge(z,K),G=!1;U||(U=R.edge(K,z),G=!0),R.node(z).rank=R.node(K).rank+(G?U.minlen:-U.minlen)})}function O(S,R,D){return S.hasEdge(R,D)}function k(S,R,D){return D.low<=R.lim&&R.lim<=D.lim}}),WL=un((e,n)=>{var s=Gd(),l=s.longestPath,o=CN(),d=ZL();n.exports=c;function c(g){var x=g.graph().ranker;if(x instanceof Function)return x(g);switch(g.graph().ranker){case"network-simplex":f(g);break;case"tight-tree":m(g);break;case"longest-path":h(g);break;case"none":break;default:f(g)}}var h=l;function m(g){l(g),o(g)}function f(g){d(g)}}),QL=un((e,n)=>{n.exports=s;function s(d){let c=o(d);d.graph().dummyChains.forEach(h=>{let m=d.node(h),f=m.edgeObj,g=l(d,c,f.v,f.w),x=g.path,p=g.lca,y=0,w=x[y],N=!0;for(;h!==f.w;){if(m=d.node(h),N){for(;(w=x[y])!==p&&d.node(w).maxRank<m.rank;)y++;w===p&&(N=!1)}if(!N){for(;y<x.length-1&&d.node(w=x[y+1]).minRank<=m.rank;)y++;w=x[y]}d.setParent(h,w),h=d.successors(h)[0]}})}function l(d,c,h,m){let f=[],g=[],x=Math.min(c[h].low,c[m].low),p=Math.max(c[h].lim,c[m].lim),y,w;y=h;do y=d.parent(y),f.push(y);while(y&&(c[y].low>x||p>c[y].lim));for(w=y,y=m;(y=d.parent(y))!==w;)g.push(y);return{path:f.concat(g.reverse()),lca:w}}function o(d){let c={},h=0;function m(f){let g=h;d.children(f).forEach(m),c[f]={low:g,lim:h++}}return d.children().forEach(m),c}}),JL=un((e,n)=>{var s=Kn();n.exports={run:l,cleanup:h};function l(m){let f=s.addDummyNode(m,"root",{},"_root"),g=d(m),x=Object.values(g),p=s.applyWithChunking(Math.max,x)-1,y=2*p+1;m.graph().nestingRoot=f,m.edges().forEach(N=>m.edge(N).minlen*=y);let w=c(m)+1;m.children().forEach(N=>o(m,f,y,w,p,g,N)),m.graph().nodeRankFactor=y}function o(m,f,g,x,p,y,w){let N=m.children(w);if(!N.length){w!==f&&m.setEdge(f,w,{weight:0,minlen:g});return}let C=s.addBorderNode(m,"_bt"),_=s.addBorderNode(m,"_bb"),O=m.node(w);m.setParent(C,w),O.borderTop=C,m.setParent(_,w),O.borderBottom=_,N.forEach(k=>{o(m,f,g,x,p,y,k);let S=m.node(k),R=S.borderTop?S.borderTop:k,D=S.borderBottom?S.borderBottom:k,Y=S.borderTop?x:2*x,z=R!==D?1:p-y[w]+1;m.setEdge(C,R,{weight:Y,minlen:z,nestingEdge:!0}),m.setEdge(D,_,{weight:Y,minlen:z,nestingEdge:!0})}),m.parent(w)||m.setEdge(f,C,{weight:0,minlen:p+y[w]})}function d(m){var f={};function g(x,p){var y=m.children(x);y&&y.length&&y.forEach(w=>g(w,p+1)),f[x]=p}return m.children().forEach(x=>g(x,1)),f}function c(m){return m.edges().reduce((f,g)=>f+m.edge(g).weight,0)}function h(m){var f=m.graph();m.removeNode(f.nestingRoot),delete f.nestingRoot,m.edges().forEach(g=>{var x=m.edge(g);x.nestingEdge&&m.removeEdge(g)})}}),eI=un((e,n)=>{var s=Kn();n.exports=l;function l(d){function c(h){let m=d.children(h),f=d.node(h);if(m.length&&m.forEach(c),Object.hasOwn(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(let g=f.minRank,x=f.maxRank+1;g<x;++g)o(d,"borderLeft","_bl",h,f,g),o(d,"borderRight","_br",h,f,g)}}d.children().forEach(c)}function o(d,c,h,m,f,g){let x={width:0,height:0,rank:g,borderType:c},p=f[c][g-1],y=s.addDummyNode(d,"border",x,h);f[c][g]=y,d.setParent(y,m),p&&d.setEdge(p,y,{weight:1})}}),tI=un((e,n)=>{n.exports={adjust:s,undo:l};function s(g){let x=g.graph().rankdir.toLowerCase();(x==="lr"||x==="rl")&&o(g)}function l(g){let x=g.graph().rankdir.toLowerCase();(x==="bt"||x==="rl")&&c(g),(x==="lr"||x==="rl")&&(m(g),o(g))}function o(g){g.nodes().forEach(x=>d(g.node(x))),g.edges().forEach(x=>d(g.edge(x)))}function d(g){let x=g.width;g.width=g.height,g.height=x}function c(g){g.nodes().forEach(x=>h(g.node(x))),g.edges().forEach(x=>{let p=g.edge(x);p.points.forEach(h),Object.hasOwn(p,"y")&&h(p)})}function h(g){g.y=-g.y}function m(g){g.nodes().forEach(x=>f(g.node(x))),g.edges().forEach(x=>{let p=g.edge(x);p.points.forEach(f),Object.hasOwn(p,"x")&&f(p)})}function f(g){let x=g.x;g.x=g.y,g.y=x}}),nI=un((e,n)=>{var s=Kn();n.exports=l;function l(o){let d={},c=o.nodes().filter(x=>!o.children(x).length),h=c.map(x=>o.node(x).rank),m=s.applyWithChunking(Math.max,h),f=s.range(m+1).map(()=>[]);function g(x){if(d[x])return;d[x]=!0;let p=o.node(x);f[p.rank].push(x),o.successors(x).forEach(g)}return c.sort((x,p)=>o.node(x).rank-o.node(p).rank).forEach(g),f}}),rI=un((e,n)=>{var s=Kn().zipObject;n.exports=l;function l(d,c){let h=0;for(let m=1;m<c.length;++m)h+=o(d,c[m-1],c[m]);return h}function o(d,c,h){let m=s(h,h.map((w,N)=>N)),f=c.flatMap(w=>d.outEdges(w).map(N=>({pos:m[N.w],weight:d.edge(N).weight})).sort((N,C)=>N.pos-C.pos)),g=1;for(;g<h.length;)g<<=1;let x=2*g-1;g-=1;let p=new Array(x).fill(0),y=0;return f.forEach(w=>{let N=w.pos+g;p[N]+=w.weight;let C=0;for(;N>0;)N%2&&(C+=p[N+1]),N=N-1>>1,p[N]+=w.weight;y+=w.weight*C}),y}}),sI=un((e,n)=>{n.exports=s;function s(l,o=[]){return o.map(d=>{let c=l.inEdges(d);if(c.length){let h=c.reduce((m,f)=>{let g=l.edge(f),x=l.node(f.v);return{sum:m.sum+g.weight*x.order,weight:m.weight+g.weight}},{sum:0,weight:0});return{v:d,barycenter:h.sum/h.weight,weight:h.weight}}else return{v:d}})}}),aI=un((e,n)=>{var s=Kn();n.exports=l;function l(c,h){let m={};c.forEach((g,x)=>{let p=m[g.v]={indegree:0,in:[],out:[],vs:[g.v],i:x};g.barycenter!==void 0&&(p.barycenter=g.barycenter,p.weight=g.weight)}),h.edges().forEach(g=>{let x=m[g.v],p=m[g.w];x!==void 0&&p!==void 0&&(p.indegree++,x.out.push(m[g.w]))});let f=Object.values(m).filter(g=>!g.indegree);return o(f)}function o(c){let h=[];function m(g){return x=>{x.merged||(x.barycenter===void 0||g.barycenter===void 0||x.barycenter>=g.barycenter)&&d(g,x)}}function f(g){return x=>{x.in.push(g),--x.indegree===0&&c.push(x)}}for(;c.length;){let g=c.pop();h.push(g),g.in.reverse().forEach(m(g)),g.out.forEach(f(g))}return h.filter(g=>!g.merged).map(g=>s.pick(g,["vs","i","barycenter","weight"]))}function d(c,h){let m=0,f=0;c.weight&&(m+=c.barycenter*c.weight,f+=c.weight),h.weight&&(m+=h.barycenter*h.weight,f+=h.weight),c.vs=h.vs.concat(c.vs),c.barycenter=m/f,c.weight=f,c.i=Math.min(h.i,c.i),h.merged=!0}}),lI=un((e,n)=>{var s=Kn();n.exports=l;function l(c,h){let m=s.partition(c,C=>Object.hasOwn(C,"barycenter")),f=m.lhs,g=m.rhs.sort((C,_)=>_.i-C.i),x=[],p=0,y=0,w=0;f.sort(d(!!h)),w=o(x,g,w),f.forEach(C=>{w+=C.vs.length,x.push(C.vs),p+=C.barycenter*C.weight,y+=C.weight,w=o(x,g,w)});let N={vs:x.flat(!0)};return y&&(N.barycenter=p/y,N.weight=y),N}function o(c,h,m){let f;for(;h.length&&(f=h[h.length-1]).i<=m;)h.pop(),c.push(f.vs),m++;return m}function d(c){return(h,m)=>h.barycenter<m.barycenter?-1:h.barycenter>m.barycenter?1:c?m.i-h.i:h.i-m.i}}),iI=un((e,n)=>{var s=sI(),l=aI(),o=lI();n.exports=d;function d(m,f,g,x){let p=m.children(f),y=m.node(f),w=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,C={};w&&(p=p.filter(S=>S!==w&&S!==N));let _=s(m,p);_.forEach(S=>{if(m.children(S.v).length){let R=d(m,S.v,g,x);C[S.v]=R,Object.hasOwn(R,"barycenter")&&h(S,R)}});let O=l(_,g);c(O,C);let k=o(O,x);if(w&&(k.vs=[w,k.vs,N].flat(!0),m.predecessors(w).length)){let S=m.node(m.predecessors(w)[0]),R=m.node(m.predecessors(N)[0]);Object.hasOwn(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+S.order+R.order)/(k.weight+2),k.weight+=2}return k}function c(m,f){m.forEach(g=>{g.vs=g.vs.flatMap(x=>f[x]?f[x].vs:x)})}function h(m,f){m.barycenter!==void 0?(m.barycenter=(m.barycenter*m.weight+f.barycenter*f.weight)/(m.weight+f.weight),m.weight+=f.weight):(m.barycenter=f.barycenter,m.weight=f.weight)}}),oI=un((e,n)=>{var s=ms().Graph,l=Kn();n.exports=o;function o(c,h,m,f){f||(f=c.nodes());let g=d(c),x=new s({compound:!0}).setGraph({root:g}).setDefaultNodeLabel(p=>c.node(p));return f.forEach(p=>{let y=c.node(p),w=c.parent(p);(y.rank===h||y.minRank<=h&&h<=y.maxRank)&&(x.setNode(p),x.setParent(p,w||g),c[m](p).forEach(N=>{let C=N.v===p?N.w:N.v,_=x.edge(C,p),O=_!==void 0?_.weight:0;x.setEdge(C,p,{weight:c.edge(N).weight+O})}),Object.hasOwn(y,"minRank")&&x.setNode(p,{borderLeft:y.borderLeft[h],borderRight:y.borderRight[h]}))}),x}function d(c){for(var h;c.hasNode(h=l.uniqueId("_root")););return h}}),cI=un((e,n)=>{n.exports=s;function s(l,o,d){let c={},h;d.forEach(m=>{let f=l.parent(m),g,x;for(;f;){if(g=l.parent(f),g?(x=c[g],c[g]=f):(x=h,h=f),x&&x!==f){o.setEdge(x,f);return}f=g}})}}),dI=un((e,n)=>{var s=nI(),l=rI(),o=iI(),d=oI(),c=cI(),h=ms().Graph,m=Kn();n.exports=f;function f(y,w={}){if(typeof w.customOrder=="function"){w.customOrder(y,f);return}let N=m.maxRank(y),C=g(y,m.range(1,N+1),"inEdges"),_=g(y,m.range(N-1,-1,-1),"outEdges"),O=s(y);if(p(y,O),w.disableOptimalOrderHeuristic)return;let k=Number.POSITIVE_INFINITY,S,R=w.constraints||[];for(let D=0,Y=0;Y<4;++D,++Y){x(D%2?C:_,D%4>=2,R),O=m.buildLayerMatrix(y);let z=l(y,O);z<k?(Y=0,S=Object.assign({},O),k=z):z===k&&(S=structuredClone(O))}p(y,S)}function g(y,w,N){let C=new Map,_=(O,k)=>{C.has(O)||C.set(O,[]),C.get(O).push(k)};for(let O of y.nodes()){let k=y.node(O);if(typeof k.rank=="number"&&_(k.rank,O),typeof k.minRank=="number"&&typeof k.maxRank=="number")for(let S=k.minRank;S<=k.maxRank;S++)S!==k.rank&&_(S,O)}return w.map(function(O){return d(y,O,N,C.get(O)||[])})}function x(y,w,N){let C=new h;y.forEach(function(_){N.forEach(S=>C.setEdge(S.left,S.right));let O=_.graph().root,k=o(_,O,C,w);k.vs.forEach((S,R)=>_.node(S).order=R),c(_,C,k.vs)})}function p(y,w){Object.values(w).forEach(N=>N.forEach((C,_)=>y.node(C).order=_))}}),uI=un((e,n)=>{var s=ms().Graph,l=Kn();n.exports={positionX:N,findType1Conflicts:o,findType2Conflicts:d,addConflict:h,hasConflict:m,verticalAlignment:f,horizontalCompaction:g,alignCoordinates:y,findSmallestWidthAlignment:p,balance:w};function o(O,k){let S={};function R(D,Y){let z=0,K=0,U=D.length,G=Y[Y.length-1];return Y.forEach((V,E)=>{let T=c(O,V),L=T?O.node(T).order:U;(T||V===G)&&(Y.slice(K,E+1).forEach(A=>{O.predecessors(A).forEach(P=>{let q=O.node(P),W=q.order;(W<z||L<W)&&!(q.dummy&&O.node(A).dummy)&&h(S,P,A)})}),K=E+1,z=L)}),Y}return k.length&&k.reduce(R),S}function d(O,k){let S={};function R(Y,z,K,U,G){let V;l.range(z,K).forEach(E=>{V=Y[E],O.node(V).dummy&&O.predecessors(V).forEach(T=>{let L=O.node(T);L.dummy&&(L.order<U||L.order>G)&&h(S,T,V)})})}function D(Y,z){let K=-1,U,G=0;return z.forEach((V,E)=>{if(O.node(V).dummy==="border"){let T=O.predecessors(V);T.length&&(U=O.node(T[0]).order,R(z,G,E,K,U),G=E,K=U)}R(z,G,z.length,U,Y.length)}),z}return k.length&&k.reduce(D),S}function c(O,k){if(O.node(k).dummy)return O.predecessors(k).find(S=>O.node(S).dummy)}function h(O,k,S){if(k>S){let D=k;k=S,S=D}let R=O[k];R||(O[k]=R={}),R[S]=!0}function m(O,k,S){if(k>S){let R=k;k=S,S=R}return!!O[k]&&Object.hasOwn(O[k],S)}function f(O,k,S,R){let D={},Y={},z={};return k.forEach(K=>{K.forEach((U,G)=>{D[U]=U,Y[U]=U,z[U]=G})}),k.forEach(K=>{let U=-1;K.forEach(G=>{let V=R(G);if(V.length){V=V.sort((T,L)=>z[T]-z[L]);let E=(V.length-1)/2;for(let T=Math.floor(E),L=Math.ceil(E);T<=L;++T){let A=V[T];Y[G]===G&&U<z[A]&&!m(S,G,A)&&(Y[A]=G,Y[G]=D[G]=D[A],U=z[A])}}})}),{root:D,align:Y}}function g(O,k,S,R,D){let Y={},z=x(O,k,S,D),K=D?"borderLeft":"borderRight";function U(E,T){let L=z.nodes().slice(),A={},P=L.pop();for(;P;){if(A[P])E(P);else{A[P]=!0,L.push(P);for(let q of T(P))L.push(q)}P=L.pop()}}function G(E){Y[E]=z.inEdges(E).reduce((T,L)=>Math.max(T,Y[L.v]+z.edge(L)),0)}function V(E){let T=z.outEdges(E).reduce((A,P)=>Math.min(A,Y[P.w]-z.edge(P)),Number.POSITIVE_INFINITY),L=O.node(E);T!==Number.POSITIVE_INFINITY&&L.borderType!==K&&(Y[E]=Math.max(Y[E],T))}return U(G,z.predecessors.bind(z)),U(V,z.successors.bind(z)),Object.keys(R).forEach(E=>Y[E]=Y[S[E]]),Y}function x(O,k,S,R){let D=new s,Y=O.graph(),z=C(Y.nodesep,Y.edgesep,R);return k.forEach(K=>{let U;K.forEach(G=>{let V=S[G];if(D.setNode(V),U){var E=S[U],T=D.edge(E,V);D.setEdge(E,V,Math.max(z(O,G,U),T||0))}U=G})}),D}function p(O,k){return Object.values(k).reduce((S,R)=>{let D=Number.NEGATIVE_INFINITY,Y=Number.POSITIVE_INFINITY;Object.entries(R).forEach(([K,U])=>{let G=_(O,K)/2;D=Math.max(U+G,D),Y=Math.min(U-G,Y)});let z=D-Y;return z<S[0]&&(S=[z,R]),S},[Number.POSITIVE_INFINITY,null])[1]}function y(O,k){let S=Object.values(k),R=l.applyWithChunking(Math.min,S),D=l.applyWithChunking(Math.max,S);["u","d"].forEach(Y=>{["l","r"].forEach(z=>{let K=Y+z,U=O[K];if(U===k)return;let G=Object.values(U),V=R-l.applyWithChunking(Math.min,G);z!=="l"&&(V=D-l.applyWithChunking(Math.max,G)),V&&(O[K]=l.mapValues(U,E=>E+V))})})}function w(O,k){return l.mapValues(O.ul,(S,R)=>{if(k)return O[k.toLowerCase()][R];{let D=Object.values(O).map(Y=>Y[R]).sort((Y,z)=>Y-z);return(D[1]+D[2])/2}})}function N(O){let k=l.buildLayerMatrix(O),S=Object.assign(o(O,k),d(O,k)),R={},D;["u","d"].forEach(z=>{D=z==="u"?k:Object.values(k).reverse(),["l","r"].forEach(K=>{K==="r"&&(D=D.map(E=>Object.values(E).reverse()));let U=(z==="u"?O.predecessors:O.successors).bind(O),G=f(O,D,S,U),V=g(O,D,G.root,G.align,K==="r");K==="r"&&(V=l.mapValues(V,E=>-E)),R[z+K]=V})});let Y=p(O,R);return y(R,Y),w(R,O.graph().align)}function C(O,k,S){return(R,D,Y)=>{let z=R.node(D),K=R.node(Y),U=0,G;if(U+=z.width/2,Object.hasOwn(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":G=-z.width/2;break;case"r":G=z.width/2;break}if(G&&(U+=S?G:-G),G=0,U+=(z.dummy?k:O)/2,U+=(K.dummy?k:O)/2,U+=K.width/2,Object.hasOwn(K,"labelpos"))switch(K.labelpos.toLowerCase()){case"l":G=K.width/2;break;case"r":G=-K.width/2;break}return G&&(U+=S?G:-G),G=0,U}}function _(O,k){return O.node(k).width}}),fI=un((e,n)=>{var s=Kn(),l=uI().positionX;n.exports=o;function o(c){c=s.asNonCompoundGraph(c),d(c),Object.entries(l(c)).forEach(([h,m])=>c.node(h).x=m)}function d(c){let h=s.buildLayerMatrix(c),m=c.graph().ranksep,f=c.graph().rankalign,g=0;h.forEach(x=>{let p=x.reduce((y,w)=>{let N=c.node(w).height;return y>N?y:N},0);x.forEach(y=>{let w=c.node(y);f==="top"?w.y=g+w.height/2:f==="bottom"?w.y=g+p-w.height/2:w.y=g+p/2}),g+=p+m})}}),hI=un((e,n)=>{var s=XL(),l=KL(),o=WL(),d=Kn().normalizeRanks,c=QL(),h=Kn().removeEmptyRanks,m=JL(),f=eI(),g=tI(),x=dI(),p=fI(),y=Kn(),w=ms().Graph;n.exports=N;function N(H,Z={}){let ee=Z.debugTiming?y.time:y.notime;return ee("layout",()=>{let ne=ee(" buildLayoutGraph",()=>U(H));return ee(" runLayout",()=>C(ne,ee,Z)),ee(" updateInputGraph",()=>_(H,ne)),ne})}function C(H,Z,ee){Z(" makeSpaceForEdgeLabels",()=>G(H)),Z(" removeSelfEdges",()=>B(H)),Z(" acyclic",()=>s.run(H)),Z(" nestingGraph.run",()=>m.run(H)),Z(" rank",()=>o(y.asNonCompoundGraph(H))),Z(" injectEdgeLabelProxies",()=>V(H)),Z(" removeEmptyRanks",()=>h(H)),Z(" nestingGraph.cleanup",()=>m.cleanup(H)),Z(" normalizeRanks",()=>d(H)),Z(" assignRankMinMax",()=>E(H)),Z(" removeEdgeLabelProxies",()=>T(H)),Z(" normalize.run",()=>l.run(H)),Z(" parentDummyChains",()=>c(H)),Z(" addBorderSegments",()=>f(H)),Z(" order",()=>x(H,ee)),Z(" insertSelfEdges",()=>F(H)),Z(" adjustCoordinateSystem",()=>g.adjust(H)),Z(" position",()=>p(H)),Z(" positionSelfEdges",()=>X(H)),Z(" removeBorderNodes",()=>W(H)),Z(" normalize.undo",()=>l.undo(H)),Z(" fixupEdgeLabelCoords",()=>P(H)),Z(" undoCoordinateSystem",()=>g.undo(H)),Z(" translateGraph",()=>L(H)),Z(" assignNodeIntersects",()=>A(H)),Z(" reversePoints",()=>q(H)),Z(" acyclic.undo",()=>s.undo(H))}function _(H,Z){H.nodes().forEach(ee=>{let ne=H.node(ee),ae=Z.node(ee);ne&&(ne.x=ae.x,ne.y=ae.y,ne.order=ae.order,ne.rank=ae.rank,Z.children(ee).length&&(ne.width=ae.width,ne.height=ae.height))}),H.edges().forEach(ee=>{let ne=H.edge(ee),ae=Z.edge(ee);ne.points=ae.points,Object.hasOwn(ae,"x")&&(ne.x=ae.x,ne.y=ae.y)}),H.graph().width=Z.graph().width,H.graph().height=Z.graph().height}var O=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},S=["acyclicer","ranker","rankdir","align","rankalign"],R=["width","height","rank"],D={width:0,height:0},Y=["minlen","weight","width","height","labeloffset"],z={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},K=["labelpos"];function U(H){let Z=new w({multigraph:!0,compound:!0}),ee=M(H.graph());return Z.setGraph(Object.assign({},k,I(ee,O),y.pick(ee,S))),H.nodes().forEach(ne=>{let ae=M(H.node(ne)),he=I(ae,R);Object.keys(D).forEach(Ne=>{he[Ne]===void 0&&(he[Ne]=D[Ne])}),Z.setNode(ne,he),Z.setParent(ne,H.parent(ne))}),H.edges().forEach(ne=>{let ae=M(H.edge(ne));Z.setEdge(ne,Object.assign({},z,I(ae,Y),y.pick(ae,K)))}),Z}function G(H){let Z=H.graph();Z.ranksep/=2,H.edges().forEach(ee=>{let ne=H.edge(ee);ne.minlen*=2,ne.labelpos.toLowerCase()!=="c"&&(Z.rankdir==="TB"||Z.rankdir==="BT"?ne.width+=ne.labeloffset:ne.height+=ne.labeloffset)})}function V(H){H.edges().forEach(Z=>{let ee=H.edge(Z);if(ee.width&&ee.height){let ne=H.node(Z.v),ae={rank:(H.node(Z.w).rank-ne.rank)/2+ne.rank,e:Z};y.addDummyNode(H,"edge-proxy",ae,"_ep")}})}function E(H){let Z=0;H.nodes().forEach(ee=>{let ne=H.node(ee);ne.borderTop&&(ne.minRank=H.node(ne.borderTop).rank,ne.maxRank=H.node(ne.borderBottom).rank,Z=Math.max(Z,ne.maxRank))}),H.graph().maxRank=Z}function T(H){H.nodes().forEach(Z=>{let ee=H.node(Z);ee.dummy==="edge-proxy"&&(H.edge(ee.e).labelRank=ee.rank,H.removeNode(Z))})}function L(H){let Z=Number.POSITIVE_INFINITY,ee=0,ne=Number.POSITIVE_INFINITY,ae=0,he=H.graph(),Ne=he.marginx||0,Le=he.marginy||0;function ye(je){let Ae=je.x,$e=je.y,Xe=je.width,tt=je.height;Z=Math.min(Z,Ae-Xe/2),ee=Math.max(ee,Ae+Xe/2),ne=Math.min(ne,$e-tt/2),ae=Math.max(ae,$e+tt/2)}H.nodes().forEach(je=>ye(H.node(je))),H.edges().forEach(je=>{let Ae=H.edge(je);Object.hasOwn(Ae,"x")&&ye(Ae)}),Z-=Ne,ne-=Le,H.nodes().forEach(je=>{let Ae=H.node(je);Ae.x-=Z,Ae.y-=ne}),H.edges().forEach(je=>{let Ae=H.edge(je);Ae.points.forEach($e=>{$e.x-=Z,$e.y-=ne}),Object.hasOwn(Ae,"x")&&(Ae.x-=Z),Object.hasOwn(Ae,"y")&&(Ae.y-=ne)}),he.width=ee-Z+Ne,he.height=ae-ne+Le}function A(H){H.edges().forEach(Z=>{let ee=H.edge(Z),ne=H.node(Z.v),ae=H.node(Z.w),he,Ne;ee.points?(he=ee.points[0],Ne=ee.points[ee.points.length-1]):(ee.points=[],he=ae,Ne=ne),ee.points.unshift(y.intersectRect(ne,he)),ee.points.push(y.intersectRect(ae,Ne))})}function P(H){H.edges().forEach(Z=>{let ee=H.edge(Z);if(Object.hasOwn(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function q(H){H.edges().forEach(Z=>{let ee=H.edge(Z);ee.reversed&&ee.points.reverse()})}function W(H){H.nodes().forEach(Z=>{if(H.children(Z).length){let ee=H.node(Z),ne=H.node(ee.borderTop),ae=H.node(ee.borderBottom),he=H.node(ee.borderLeft[ee.borderLeft.length-1]),Ne=H.node(ee.borderRight[ee.borderRight.length-1]);ee.width=Math.abs(Ne.x-he.x),ee.height=Math.abs(ae.y-ne.y),ee.x=he.x+ee.width/2,ee.y=ne.y+ee.height/2}}),H.nodes().forEach(Z=>{H.node(Z).dummy==="border"&&H.removeNode(Z)})}function B(H){H.edges().forEach(Z=>{if(Z.v===Z.w){var ee=H.node(Z.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Z,label:H.edge(Z)}),H.removeEdge(Z)}})}function F(H){var Z=y.buildLayerMatrix(H);Z.forEach(ee=>{var ne=0;ee.forEach((ae,he)=>{var Ne=H.node(ae);Ne.order=he+ne,(Ne.selfEdges||[]).forEach(Le=>{y.addDummyNode(H,"selfedge",{width:Le.label.width,height:Le.label.height,rank:Ne.rank,order:he+ ++ne,e:Le.e,label:Le.label},"_se")}),delete Ne.selfEdges})})}function X(H){H.nodes().forEach(Z=>{var ee=H.node(Z);if(ee.dummy==="selfedge"){var ne=H.node(ee.e.v),ae=ne.x+ne.width/2,he=ne.y,Ne=ee.x-ae,Le=ne.height/2;H.setEdge(ee.e,ee.label),H.removeNode(Z),ee.label.points=[{x:ae+2*Ne/3,y:he-Le},{x:ae+5*Ne/6,y:he-Le},{x:ae+Ne,y:he},{x:ae+5*Ne/6,y:he+Le},{x:ae+2*Ne/3,y:he+Le}],ee.label.x=ee.x,ee.label.y=ee.y}})}function I(H,Z){return y.mapValues(y.pick(H,Z),Number)}function M(H){var Z={};return H&&Object.entries(H).forEach(([ee,ne])=>{typeof ee=="string"&&(ee=ee.toLowerCase()),Z[ee]=ne}),Z}}),mI=un((e,n)=>{var s=Kn(),l=ms().Graph;n.exports={debugOrdering:o};function o(d){let c=s.buildLayerMatrix(d),h=new l({compound:!0,multigraph:!0}).setGraph({});return d.nodes().forEach(m=>{h.setNode(m,{label:m}),h.setParent(m,"layer"+d.node(m).rank)}),d.edges().forEach(m=>h.setEdge(m.v,m.w,{},m.name)),c.forEach((m,f)=>{let g="layer"+f;h.setNode(g,{rank:"same"}),m.reduce((x,p)=>(h.setEdge(x,p,{style:"invis"}),p))}),h}}),xI=un((e,n)=>{n.exports="2.0.4"}),gI=un((e,n)=>{n.exports={graphlib:ms(),layout:hI(),debug:mI(),util:{time:Kn().time,notime:Kn().notime},version:xI()}});const Hv=gI();const Pv={pending:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"},in_progress:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},blocked:{bg:"bg-red-500/8",border:"border-red-500/25",text:"text-red-500"},review:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"},completed:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"},failed:{bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-500"},rejected:{bg:"bg-red-500/8",border:"border-red-500/25",text:"text-red-500"},cancelled:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-tertiary"},archived:{bg:"bg-gray-500/5",border:"border-gray-500/15",text:"text-fg-tertiary"}},pI={critical:"bg-red-500",high:"bg-amber-500",medium:"bg-amber-500",low:"bg-blue-500"};function bI({data:e}){const{task:n,agentName:s,selected:l}=e,o=Pv[n.status]??Pv.pending,d=n.taskType==="scheduled"&&!!n.scheduleConfig,c=d?n.scheduleConfig.every?`Every ${n.scheduleConfig.every}`:n.scheduleConfig.cron?"Cron":"":"";return t.jsxs("div",{className:`rounded-lg border px-3 py-2 min-w-[180px] max-w-[220px] shadow-md backdrop-blur-sm ${d?`${o.bg} border-blue-500/40 ring-1 ring-blue-500/20`:`${o.bg} ${o.border}`} ${l?"ring-2 ring-brand-500 shadow-brand-500/25 shadow-lg":""}`,children:[t.jsx($a,{type:"target",position:ft.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${pI[n.priority]??"bg-gray-500"}`}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${o.text}`,children:n.status.replace("_"," ")}),d&&t.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/15 text-blue-600 ml-auto whitespace-nowrap inline-flex items-center gap-0.5",children:[t.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})}),c]})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:n.title}),s&&t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:s}),n.blockedBy&&n.blockedBy.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[n.blockedBy.length," dep",n.blockedBy.length>1?"s":""]}),t.jsx($a,{type:"source",position:ft.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const Uv={pending:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},in_progress:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"},completed:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"},rejected:{bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-500"},cancelled:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-tertiary"}},qv={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done"};function yI({data:e}){const{req:n,selected:s}=e,l=Uv[n.status]??Uv.pending;return t.jsxs("div",{className:`rounded-lg border-2 border-dashed px-3 py-2 min-w-[180px] max-w-[220px] shadow-lg ${l.bg} ${l.border} ${s?"ring-2 ring-brand-500 shadow-brand-500/25":""}`,children:[t.jsx($a,{type:"target",position:ft.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded font-semibold bg-amber-500/15 text-amber-600",children:"REQ"}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${l.text}`,children:n.status.replace("_"," ")})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:n.title}),n.taskIds.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[n.taskIds.length," task",n.taskIds.length>1?"s":""]}),t.jsx($a,{type:"source",position:ft.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const vI={task:bI,requirement:yI},jI=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,wI=e=>{const n=new MutationObserver(e);n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const s=window.matchMedia("(prefers-color-scheme: light)");return s.addEventListener("change",e),()=>{n.disconnect(),s.removeEventListener("change",e)}};function NI(){return v.useSyncExternalStore(wI,jI,()=>!1)}const Pm=200,Um=80;function Vv(e,n,s="TB"){const l=new Hv.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const o of e)l.setNode(o.id,{width:Pm,height:Um});for(const o of n)l.setEdge(o.source,o.target);return Hv.layout(l),e.map(o=>{const d=l.node(o.id);return{...o,position:{x:(d?.x??0)-Pm/2,y:(d?.y??0)-Um/2}}})}function kI(e,n){const s=new Map,l=new Map;for(const c of e)l.set(c.id,c),s.set(c.id,new Set);for(const c of n)s.get(c.source)?.add(c.target),s.get(c.target)?.add(c.source);const o=new Set,d=[];for(const c of e){if(o.has(c.id))continue;const h=new Set,m=[c.id];for(;m.length>0;){const f=m.pop();if(!o.has(f)){o.add(f),h.add(f);for(const g of s.get(f)??[])o.has(g)||m.push(g)}}d.push({nodes:e.filter(f=>h.has(f.id)),edges:n.filter(f=>h.has(f.source)&&h.has(f.target))})}return d}function SI(e,n){if(e.length===0)return[];const s=kI(e,n);if(s.length===1)return Vv(e,n);const l=s.map(x=>{const p=Vv(x.nodes,x.edges);let y=1/0,w=-1/0,N=1/0,C=-1/0;for(const _ of p)y=Math.min(y,_.position.x),w=Math.max(w,_.position.x+Pm),N=Math.min(N,_.position.y),C=Math.max(C,_.position.y+Um);for(const _ of p)_.position.x-=y,_.position.y-=N;return{nodes:p,w:w-y,h:C-N}});l.sort((x,p)=>p.h-x.h);const o=60,d=l.reduce((x,p)=>x+(p.w+o)*(p.h+o),0),c=Math.sqrt(d)*1.1,h=[];let m=0,f=0,g=0;for(const x of l){m>0&&m+x.w>c&&(m=0,f+=g+o,g=0);for(const p of x.nodes)h.push({...p,position:{x:p.position.x+m,y:p.position.y+f}});m+=x.w+o,g=Math.max(g,x.h)}return h}function CI(e,n,s){const l=new Set,o=[n];for(;o.length>0;){const d=o.pop();if(d===s)return!0;if(l.has(d))continue;l.add(d);const c=e.get(d);if(c?.blockedBy)for(const h of c.blockedBy)o.push(h)}return!1}const vo=[{id:"todo",label:"To Do",statuses:new Set(["pending"]),color:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"}},{id:"in_progress",label:"In Progress",statuses:new Set(["in_progress","blocked"]),color:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"}},{id:"review",label:"In Review",statuses:new Set(["review"]),color:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"}},{id:"done",label:"Done",statuses:new Set(["completed","failed","rejected","cancelled"]),color:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"}}],nm=new Set(vo.map(e=>e.id)),EI=1440*60*1e3,Fv=e=>e.status==="completed"&&e.updatedAt&&Date.now()-new Date(e.updatedAt).getTime()>EI;function TI({tasks:e,requirements:n=[],agents:s,showArchived:l,onShowArchivedChange:o,onTaskClick:d,onReqClick:c,onDependencyChange:h,selectedTaskId:m,selectedReqId:f}){const g=NI(),[x,p]=v.useState(null),[y,w]=v.useState(null),[N,C]=v.useState(new Set(nm)),[_,O]=v.useState(l??!1),k=l??_,S=v.useCallback(ye=>{const je=typeof ye=="function"?ye(k):ye;O(je),o?.(je)},[k,o]);v.useEffect(()=>{l!==void 0&&O(l)},[l]);const R=v.useMemo(()=>e.filter(ye=>Fv(ye)).length,[e]),D=v.useMemo(()=>{const ye=new Set;for(const je of vo)if(N.has(je.id))for(const Ae of je.statuses)ye.add(Ae);return ye},[N]),Y=v.useMemo(()=>{const ye=new Set;for(const je of e)for(const Ae of vo)if(Ae.statuses.has(je.status)){ye.add(Ae.id);break}for(const je of n){const Ae=qv[je.status];Ae&&ye.add(Ae)}return vo.filter(je=>ye.has(je.id))},[e,n]),z=v.useCallback(ye=>{C(je=>{const Ae=new Set(je);return Ae.has(ye)?Ae.delete(ye):Ae.add(ye),Ae})},[]),K=v.useCallback((ye,je="success")=>{p({msg:ye,type:je}),setTimeout(()=>p(null),2500)},[]),U=v.useMemo(()=>{const ye=new Map;for(const je of s)ye.set(je.id,je.name);return ye},[s]),G=v.useMemo(()=>{const ye=new Map;for(const je of e)ye.set(je.id,je);return ye},[e]),V=v.useMemo(()=>{const ye=new Map;for(const je of n)ye.set(je.id,je);return ye},[n]),E=g?"#94a3b8":"#6b7280",T=v.useCallback((ye,je,Ae)=>({id:`${ye}->${je}`,source:ye,target:je,animated:Ae==="blocked",markerEnd:{type:di.ArrowClosed,width:14,height:14,color:Ae==="blocked"?"#ef4444":E},style:{stroke:Ae==="blocked"?"#ef4444":E,strokeWidth:1.5,cursor:"pointer"}}),[E]),{initialNodes:L,initialEdges:A}=v.useMemo(()=>{const ye=e.filter(Te=>D.has(Te.status)&&(k||!Fv(Te))),je=ye.map(Te=>({id:Te.id,type:"task",data:{task:Te,agentName:Te.assignedAgentId?U.get(Te.assignedAgentId):void 0,selected:Te.id===m},position:{x:0,y:0}})),Ae=new Set(je.map(Te=>Te.id)),$e=new Set;for(const Te of vo)N.has(Te.id)&&$e.add(Te.id);const Xe=n.filter(Te=>{const nt=qv[Te.status];return nt&&$e.has(nt)});for(const Te of Xe){const nt=`req-${Te.id}`;je.push({id:nt,type:"requirement",data:{req:Te,selected:Te.id===f},position:{x:0,y:0}}),Ae.add(nt)}const tt=[];for(const Te of ye)if(Te.blockedBy)for(const nt of Te.blockedBy)Ae.has(nt)&&tt.push(T(nt,Te.id,Te.status));const et=new Set,_t=(Te,nt)=>{const yt=`${Te}->${nt}`;et.has(yt)||(et.add(yt),tt.push({id:yt,source:Te,target:nt,markerEnd:{type:di.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const Te of Xe){const nt=`req-${Te.id}`;for(const yt of Te.taskIds)Ae.has(yt)&&_t(nt,yt)}for(const Te of ye)if(Te.requirementId){const nt=`req-${Te.requirementId}`;Ae.has(nt)&&_t(nt,Te.id)}return{initialNodes:SI(je,tt),initialEdges:tt}},[e,n,U,G,T,D,N,k,m,f]),[P,q,W]=gL(L),[B,F,X]=pL(A),I=v.useRef(null),M=v.useRef(!1),H=v.useRef({groupFilter:N,showArchived:k});v.useEffect(()=>{const ye=H.current;(ye.groupFilter!==N||ye.showArchived!==k)&&(M.current=!1,H.current={groupFilter:N,showArchived:k})},[N,k]),v.useEffect(()=>{q(L),F(A),M.current||requestAnimationFrame(()=>{I.current?.fitView({padding:.2,duration:300})})},[L,A,q,F]);const Z=v.useCallback(ye=>{ye&&(M.current=!0)},[]),ee=v.useCallback((ye,je)=>{if(je.id.startsWith("req-")){const Ae=V.get(je.id.slice(4));Ae&&c&&c(Ae)}else{const Ae=G.get(je.id);Ae&&d&&d(Ae)}},[G,V,d,c]),ne=v.useCallback(async ye=>{const{source:je,target:Ae}=ye;if(!je||!Ae||je===Ae)return;const $e=G.get(Ae);if(!$e)return;if($e.blockedBy?.includes(je)){K("Dependency already exists","error");return}if(CI(G,je,Ae)){K("Cannot add: would create a cycle","error");return}const Xe=[...$e.blockedBy??[],je];try{await re.tasks.update(Ae,{blockedBy:Xe}),K("Dependency added"),h?.()}catch(tt){K(`Failed: ${tt instanceof Error?tt.message:String(tt)}`,"error")}},[G,K,h]),ae=v.useCallback((ye,je)=>{w(je)},[]),he=v.useCallback(async()=>{if(!y)return;const ye=G.get(y.target);if(!ye){w(null);return}const je=(ye.blockedBy??[]).filter(Ae=>Ae!==y.source);try{await re.tasks.update(y.target,{blockedBy:je}),K("Dependency removed"),h?.()}catch(Ae){K(`Failed: ${Ae instanceof Error?Ae.message:String(Ae)}`,"error")}w(null)},[y,G,K,h]);if(e.length===0)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"No tasks to display"});const Ne=y?G.get(y.source):null,Le=y?G.get(y.target):null;return t.jsxs("div",{className:"flex-1 min-h-0 relative",style:{height:"100%"},children:[t.jsxs(xL,{nodes:P,edges:B,onNodesChange:W,onEdgesChange:X,onNodeClick:ee,onConnect:ne,onEdgeClick:ae,onMoveEnd:Z,onInit:ye=>{I.current=ye},nodeTypes:vI,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(wL,{color:g?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(AL,{showInteractive:!1,className:"!bg-surface-secondary !border-border-default !shadow-xl [&>button]:!bg-surface-elevated [&>button]:!border-border-default [&>button]:!text-fg-secondary [&>button:hover]:!bg-surface-overlay"}),t.jsx(UL,{nodeColor:ye=>{const je=ye.data?.task,Ae=je?.status;return je?.taskType==="scheduled"?"#06b6d4":Ae==="completed"||Ae==="accepted"?"#10b981":Ae==="in_progress"?"#f59e0b":Ae==="blocked"||Ae==="failed"?"#ef4444":g?"#94a3b8":"#6b7280"},maskColor:g?"rgba(255,255,255,0.7)":"rgba(0,0,0,0.7)",className:"!bg-surface-secondary !border-border-default"})]}),t.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-surface-secondary/90 border border-border-default rounded-lg backdrop-blur-sm z-10 flex flex-col items-center gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-center",children:[Y.map(ye=>{const je=N.has(ye.id);return t.jsx("button",{onClick:()=>z(ye.id),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${je?`${ye.color.bg} ${ye.color.border} ${ye.color.text}`:"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:ye.label},ye.id)}),R>0&&t.jsxs("button",{onClick:()=>S(ye=>!ye),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${k?"bg-surface-overlay/60 border-gray-500/50 text-fg-secondary":"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:["Archived ",R]}),N.size<nm.size&&t.jsx("button",{onClick:()=>{C(new Set(nm)),S(!1)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary px-1",children:"Reset"})]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary select-none",children:"Drag to add dependency · Click edge to remove"})]}),x&&t.jsx("div",{className:`absolute bottom-4 left-1/2 -translate-x-1/2 px-4 py-2 rounded-lg text-xs font-medium shadow-xl border backdrop-blur-sm transition-opacity ${x.type==="success"?"bg-green-500/15 border-green-500/30 text-green-600":"bg-red-500/15 border-red-500/30 text-red-600"}`,children:x.msg}),y&&t.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center z-50 backdrop-blur-[2px]",onClick:()=>w(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 shadow-2xl max-w-sm",onClick:ye=>ye.stopPropagation(),children:[t.jsx("h4",{className:"text-sm font-semibold text-fg-primary mb-2",children:"Remove dependency?"}),t.jsxs("p",{className:"text-xs text-fg-secondary mb-4 leading-relaxed",children:[t.jsx("span",{className:"text-fg-secondary font-medium",children:Le?.title??y.target.slice(-8)})," ","will no longer be blocked by"," ",t.jsx("span",{className:"text-fg-secondary font-medium",children:Ne?.title??y.source.slice(-8)}),"."]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>w(null),className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary bg-surface-elevated rounded-lg border border-border-default hover:border-gray-600 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:he,className:"px-3 py-1.5 text-xs text-red-500 bg-red-600/20 hover:bg-red-600/30 rounded-lg border border-red-500/40 hover:border-red-500/60 transition-colors",children:"Remove"})]})]})})]})}function EN({orgId:e,onCreated:n,onClose:s}){const[l,o]=v.useState(""),[d,c]=v.useState(""),[h,m]=v.useState(""),[f,g]=v.useState("main"),[x,p]=v.useState([]),[y,w]=v.useState([]),[N,C]=v.useState(!1),[_,O]=v.useState(""),[k,S]=v.useState(!1),R=_s();v.useEffect(()=>{re.teams.list().then(z=>w(z.teams)).catch(()=>{})},[]);const D=v.useCallback(async z=>{if(z?.preventDefault(),S(!0),!(!l.trim()||N)){C(!0),O("");try{const K=h.trim()?[{url:h.trim(),defaultBranch:f.trim()||"main"}]:[],U=await re.projects.create({name:l.trim(),description:d.trim()||void 0,repositories:K.length>0?K:void 0,teamIds:x.length>0?x:void 0,orgId:e??"default"});n(U.project)}catch(K){O(K instanceof Error?K.message:"Failed to create project")}C(!1)}},[l,d,h,f,x,e,N,n]),Y=k&&!l.trim();return hx.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-3",onClick:s,children:t.jsxs("form",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 shadow-2xl max-h-[90dvh] overflow-y-auto ${R?"w-full":"w-[520px]"}`,onClick:z=>z.stopPropagation(),onSubmit:D,children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:"New Project"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Project Name *"}),t.jsx("input",{value:l,onChange:z=>{o(z.target.value),O("")},onBlur:()=>S(!0),placeholder:"e.g. Mobile App, Website Redesign",className:`input ${Y?"!border-red-500 focus:!ring-red-500/25":""}`,autoFocus:!R}),Y&&t.jsx("p",{className:"text-[11px] text-red-400 mt-1",children:"Project name is required"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Description"}),t.jsx("textarea",{value:d,onChange:z=>c(z.target.value),placeholder:"What is this project about?",className:"input",rows:3})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Assign Teams"}),y.length===0?t.jsx("div",{className:"text-[11px] text-fg-tertiary py-2",children:"No teams available"}):t.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:y.map(z=>{const K=x.includes(z.id);return t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer hover:text-fg-primary py-0.5",children:[t.jsx("input",{type:"checkbox",checked:K,onChange:()=>p(U=>K?U.filter(G=>G!==z.id):[...U,z.id]),className:"accent-brand-500"}),t.jsx("span",{className:"truncate",children:z.name})]},z.id)})})]}),t.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Repository URL"}),t.jsx("input",{value:h,onChange:z=>m(z.target.value),placeholder:"https://github.com/org/repo (optional)",className:"input"})]}),h.trim()&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Branch"}),t.jsx("input",{value:f,onChange:z=>g(z.target.value),placeholder:"main",className:"input !w-24"})]})]}),_&&t.jsx("div",{className:"text-xs text-red-400 bg-red-500/10 rounded-lg px-3 py-2",children:_}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:!l.trim()||N,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:N?"Creating...":"Create Project"})]})]})]})}),document.body)}function xi(e,n,s){if(!e)return null;const l=n.find(d=>d.id===e);if(l)return l.name;const o=s.find(d=>d.id===e);return o?o.name:e==="anonymous"?"Admin":null}function AI({value:e,onSave:n,className:s,placeholder:l}){const[o,d]=v.useState(!1),[c,h]=v.useState(e),m=v.useRef(null);v.useEffect(()=>{h(e)},[e]),v.useEffect(()=>{o&&m.current?.focus()},[o]);const f=async()=>{d(!1);const g=c.trim();if(g&&g!==e)try{await n(g)}catch{h(e)}else h(e)};return o?t.jsx("input",{ref:m,value:c,onChange:g=>h(g.target.value),onBlur:()=>{f()},onKeyDown:g=>{g.key==="Enter"&&f(),g.key==="Escape"&&(h(e),d(!1))},className:`bg-transparent border-b border-brand-500/50 outline-none ${s??""}`,placeholder:l}):t.jsx("span",{onClick:()=>d(!0),className:`cursor-pointer hover:border-b hover:border-gray-600 transition-colors ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:l??"Click to edit"})})}function _I({value:e,onSave:n,className:s,placeholder:l}){const[o,d]=v.useState(!1),[c,h]=v.useState(e),m=v.useRef(null);v.useEffect(()=>{h(e)},[e]),v.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.style.height="auto",m.current.style.height=m.current.scrollHeight+"px")},[o]);const f=async()=>{d(!1);const g=c.trim();if(g!==e)try{await n(g)}catch{h(e)}else h(e)};return o?t.jsx("textarea",{ref:m,value:c,onChange:g=>{h(g.target.value),g.target.style.height="auto",g.target.style.height=g.target.scrollHeight+"px"},onBlur:()=>{f()},onKeyDown:g=>{g.key==="Escape"&&(h(e),d(!1))},className:`bg-transparent border border-brand-500/30 rounded-lg p-2 outline-none resize-none w-full ${s??""}`,placeholder:l,rows:2}):t.jsx("p",{onClick:()=>d(!0),className:`cursor-pointer hover:bg-surface-elevated/50 rounded-lg transition-colors px-2 py-1 -mx-2 -my-1 ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:l??"Add a description…"})})}const MI=/^\[([^\]]+?)(?:\s+by\s+([^\]]+))?\]\s*([\s\S]*)$/;function TN(e){const n=e.match(MI);return n?{timestamp:n[1].trim(),author:n[2]?.trim()??"System",content:n[3].trim()}:{timestamp:"",author:"",content:e}}function OI(e){if(!e)return"";const n=e.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);if(!n)return e;const s=new Date,l=+n[1],o=+n[2]-1,d=+n[3],c=+n[4],h=+n[5],m=new Date(l,o,d,c,h),f=s.getTime()-m.getTime();return f<6e4?"just now":f<36e5?`${Math.floor(f/6e4)}m ago`:f<864e5?`${Math.floor(f/36e5)}h ago`:f<6048e5?`${Math.floor(f/864e5)}d ago`:`${l}-${String(o+1).padStart(2,"0")}-${String(d).padStart(2,"0")}`}const Yv=[{bg:"bg-brand-600/30",text:"text-brand-500",border:"border-brand-500/30"},{bg:"bg-blue-600/30",text:"text-blue-400",border:"border-blue-500/30"},{bg:"bg-green-600/30",text:"text-green-400",border:"border-green-500/30"},{bg:"bg-amber-600/30",text:"text-amber-400",border:"border-amber-500/30"},{bg:"bg-purple-600/30",text:"text-purple-400",border:"border-purple-500/30"},{bg:"bg-pink-600/30",text:"text-pink-400",border:"border-pink-500/30"}];function RI(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s)|0;return Yv[Math.abs(n)%Yv.length]}function DI({note:e,compact:n}){const s=TN(e),l=RI(s.author||"System"),o=s.author?s.author.split(/[\s_-]+/).map(h=>h[0]).join("").slice(0,2).toUpperCase():"SY",d=OI(s.timestamp),c=!s.author||s.author==="System";return n?t.jsxs("div",{className:"flex gap-2.5 group",children:[t.jsx("div",{className:`w-6 h-6 rounded-full ${l.bg} flex items-center justify-center text-[9px] font-bold ${l.text} shrink-0 mt-0.5`,children:o}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium ${c?"text-fg-tertiary":l.text}`,children:s.author||"System"}),d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d})]}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(tr,{content:s.content,className:"text-xs text-fg-secondary"})})]})]}):t.jsxs("div",{className:"flex gap-3 group",children:[t.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[t.jsx("div",{className:`w-7 h-7 rounded-full ${l.bg} flex items-center justify-center text-[10px] font-bold ${l.text}`,children:o}),t.jsx("div",{className:"w-px flex-1 bg-border-default/60 mt-1.5"})]}),t.jsx("div",{className:"flex-1 min-w-0 pb-4",children:t.jsxs("div",{className:`border ${l.border} rounded-lg overflow-hidden`,children:[t.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 ${l.bg} border-b ${l.border}`,children:[t.jsx("span",{className:`text-[11px] font-medium ${c?"text-fg-secondary":l.text}`,children:s.author||"System"}),d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d})]}),t.jsx("div",{className:"px-3 py-2.5",children:t.jsx(tr,{content:s.content,className:"text-xs text-fg-secondary"})})]})})]})}const Bo=[{id:"failed",label:"Failed",statuses:["failed"],accent:"border-t-red-500",dropStatus:"failed"},{id:"todo",label:"To Do",statuses:["pending"],accent:"border-t-amber-500",dropStatus:"pending"},{id:"in_progress",label:"In Progress",statuses:["in_progress","blocked"],accent:"border-t-brand-500",dropStatus:"in_progress"},{id:"review",label:"In Review",statuses:["review"],accent:"border-t-purple-500",dropStatus:"review"},{id:"done",label:"Done",statuses:["completed"],accent:"border-t-green-500",dropStatus:"completed"},{id:"closed",label:"Closed",statuses:["rejected","cancelled"],accent:"border-t-gray-500",dropStatus:"cancelled"}],AN={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},blocked:{label:"Blocked",cls:"bg-amber-500/15 text-amber-600"},failed:{label:"Failed",cls:"bg-red-500/15 text-red-500"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"}},qm={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},in_progress:{label:"In Progress",cls:"bg-blue-500/15 text-blue-500"},blocked:{label:"Blocked",cls:"bg-orange-500/15 text-orange-500"},review:{label:"In Review",cls:"bg-purple-500/15 text-purple-500"},completed:{label:"Completed",cls:"bg-green-500/15 text-green-600"},failed:{label:"Failed",cls:"bg-red-500/15 text-red-500"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"},cancelled:{label:"Cancelled",cls:"bg-gray-500/15 text-fg-tertiary"},archived:{label:"Archived",cls:"bg-gray-500/15 text-fg-tertiary"}},LI={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},Gv={low:{label:"Low",cls:"bg-gray-500/15 text-fg-tertiary"},medium:{label:"Medium",cls:"bg-blue-500/15 text-blue-500"},high:{label:"High",cls:"bg-amber-500/15 text-amber-600"},urgent:{label:"Urgent",cls:"bg-red-500/15 text-red-500"}},II=["low","medium","high","urgent"],zI=["pending","in_progress","blocked","review","completed","failed","rejected","cancelled"],$I=["pending","in_progress","completed","rejected","cancelled"],_N={pending:"bg-amber-400",in_progress:"bg-brand-400",blocked:"bg-amber-400",review:"bg-brand-400",completed:"bg-green-400",failed:"bg-red-400",rejected:"bg-red-400",cancelled:"bg-gray-600",archived:"bg-surface-overlay"};function BI({agent:e,anchorRect:n,onClose:s}){const l=v.useRef(null);v.useEffect(()=>{const c=h=>{l.current&&!l.current.contains(h.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const o=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?"Online":e.status==="working"?"Working":e.status==="error"?"Error":e.status==="paused"?"Paused":"Offline";return t.jsxs("div",{ref:l,className:"fixed z-50 w-56 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-3 space-y-2",style:{top:n.top+4,left:n.left},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600 shrink-0",children:e.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:d})]})]})]}),t.jsx("button",{onClick:()=>{s(),gt.navigate(ge.TEAM,{selectAgent:e.id})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:"View Profile →"})]})}function Co({comment:e,agents:n,onReply:s}){const l=e.authorType==="agent"||e.authorType==="system",o=new Date(e.createdAt),d=o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),c=o.toLocaleDateString([],{month:"short",day:"numeric"}),[h,m]=v.useState(null),f=v.useCallback((x,p)=>{const y=n.find(w=>w.name.toLowerCase()===x.toLowerCase());if(y){const w=p.target.getBoundingClientRect();m({agent:y,top:w.bottom,left:w.left})}},[n]),g=v.useCallback(x=>{const p=n.find(y=>y.name.toLowerCase()===e.authorName.toLowerCase());if(p){const y=x.currentTarget.getBoundingClientRect();m({agent:p,top:y.bottom,left:y.left})}},[n,e.authorName]);return t.jsxs("div",{className:"flex gap-2.5 group py-1",id:`comment-${e.id}`,children:[t.jsx("div",{onClick:g,className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-[10px] mt-0.5 cursor-pointer transition-all hover:ring-1 hover:ring-brand-500/40 ${l?"bg-indigo-500/20 text-indigo-400":"bg-blue-500/20 text-blue-400"}`,children:e.authorName.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium cursor-pointer hover:underline ${l?"text-indigo-400":"text-blue-400"}`,onClick:g,children:e.authorName}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:[c," ",d]}),s&&t.jsx("button",{onClick:()=>s(e),className:"text-fg-tertiary hover:text-fg-secondary text-[10px] opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:"Reply"})]}),e.replyTo&&e.replyToAuthor&&t.jsxs("button",{onClick:()=>{const x=document.getElementById(`comment-${e.replyTo}`);x&&(x.scrollIntoView({behavior:"smooth",block:"center"}),x.classList.add("bg-brand-500/10"),setTimeout(()=>x.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:e.replyToAuthor}),t.jsx("span",{className:"truncate max-w-[200px]",children:e.replyToContent??"..."})]}),t.jsx(tr,{content:e.content,className:"text-xs text-fg-primary",onMentionClick:f}),e.attachments?.map((x,p)=>x.type==="image"?t.jsx("img",{src:x.url,alt:x.name,className:"mt-1 max-w-[200px] rounded"},p):null)]}),h&&t.jsx(BI,{agent:h.agent,anchorRect:{top:h.top,left:h.left},onClose:()=>m(null)})]})}function HI({task:e,agents:n,users:s,authUser:l}){const[o,d]=v.useState([]);v.useEffect(()=>{re.tasks.getComments(e.id).then(x=>d(x.comments)).catch(()=>{})},[e.id]),v.useEffect(()=>xn.on("task:comment",p=>{p.payload?.taskId===e.id&&p.payload.comment&&d(y=>y.some(w=>w.id===p.payload.comment.id)?y:[...y,p.payload.comment])}),[e.id]);const c=v.useMemo(()=>{const x=[];for(const p of e.notes??[]){const y=TN(p);let w;if(y.timestamp){const N=y.timestamp.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);w=N?new Date(+N[1],+N[2]-1,+N[3],+N[4],+N[5],+(N[6]??0)):new Date(0)}else w=new Date(0);x.push({type:"note",note:p,ts:w})}for(const p of o)x.push({type:"comment",comment:p,ts:new Date(p.createdAt)});return x.sort((p,y)=>p.ts.getTime()-y.ts.getTime()),x},[e.notes,o]),[h,m]=v.useState(null),f=async(x,p,y)=>{await re.tasks.addComment(e.id,x,l?.name,void 0,l?.id,p.length>0?p:void 0,y)},g=v.useCallback(x=>{m({id:x.id,authorName:x.authorName,content:x.content.slice(0,100)})},[]);return t.jsxs("div",{className:"mt-5",children:[t.jsx("p",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:"Activity & Comments"}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[c.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No activity yet. Post the first comment below."}),c.map((x,p)=>x.type==="note"?t.jsx(DI,{note:x.note,compact:!0},`n-${p}`):t.jsx(Co,{comment:x.comment,agents:n,onReply:g},`c-${x.comment.id}`))]}),t.jsx(Sj,{agents:n,onSubmit:f,replyTo:h,onCancelReply:()=>m(null)})]})}function PI({taskId:e,isRunning:n,authUser:s,agents:l}){const[o,d]=v.useState([]),[c,h]=v.useState(new Map),[m,f]=v.useState(new Set),[g,x]=v.useState([]),[p,y]=v.useState(""),[w,N]=v.useState(n),[C,_]=v.useState(!0),[O,k]=v.useState(new Set),[S,R]=v.useState(""),[D,Y]=v.useState(!1),[z,K]=v.useState([]),U=v.useRef(null),G=v.useRef(null);v.useEffect(()=>{N(n)},[n]),v.useEffect(()=>{_(!0),Promise.all([re.tasks.getLogsSummary(e).catch(()=>({rounds:[]})),re.tasks.getComments(e).catch(()=>({comments:[]}))]).then(([X,I])=>{const M=X.rounds;if(d(M),x(I.comments),M.length===0){_(!1);return}const H=M[M.length-1].round;k(new Set([H])),re.tasks.getLogs(e,H).catch(()=>({logs:[]})).then(Z=>{h(new Map([[H,Z.logs]])),_(!1)})})},[e]);const V=v.useCallback(X=>{c.has(X)||m.has(X)||(f(I=>new Set(I).add(X)),re.tasks.getLogs(e,X).catch(()=>({logs:[]})).then(I=>{h(M=>new Map(M).set(X,I.logs)),f(M=>{const H=new Set(M);return H.delete(X),H})}))},[e,c,m]),E=v.useCallback(X=>{k(I=>{const M=new Set(I);return M.has(X)?M.delete(X):(M.add(X),c.has(X)||V(X)),M})},[c,V]);v.useEffect(()=>{const X=xn.on("task:log",H=>{const Z=H.payload;if(Z.taskId!==e)return;const ee={id:Z.id,taskId:Z.taskId,agentId:Z.agentId,seq:Z.seq,type:Z.logType,content:Z.content,metadata:Z.metadata,executionRound:Z.executionRound,createdAt:Z.createdAt},ne=ee.executionRound??1;d(ae=>ae.find(Ne=>Ne.round===ne)?ae:[...ae,{round:ne,logCount:0,toolCount:0,firstAt:ee.createdAt,lastAt:ee.createdAt,status:"running"}]),k(ae=>ae.has(ne)?ae:new Set(ae).add(ne)),h(ae=>{const he=ae.get(ne)??[];return ee.id&&he.some(Ne=>Ne.id===ee.id)?ae:new Map(ae).set(ne,[...he,ee])}),ee.type==="text"&&y(""),ee.type==="status"&&(ee.content==="started"||ee.content==="resumed"?N(!0):["completed","failed","cancelled","execution_finished"].includes(ee.content)&&(N(!1),d(ae=>ae.map(he=>he.round===ne?{...he,status:ee.content}:he)))),ee.type==="error"&&N(!1)}),I=xn.on("task:log:delta",H=>{const Z=H.payload;Z.taskId===e&&y(ee=>ee+Z.text)}),M=xn.on("task:comment",H=>{const Z=H.payload;if(Z.taskId!==e)return;const ee=Z.comment;x(ne=>ne.some(ae=>ae.id===ee.id)?ne:[...ne,ee])});return()=>{X(),I(),M()}},[e]);const T=v.useMemo(()=>{const X=[];for(const[,I]of c)X.push(...I);return X.sort((I,M)=>I.seq-M.seq),X},[c]),L=v.useMemo(()=>T.map(X=>om(X)),[T]),A=o.length>1,P=X=>{const I=X.target.files;if(I){for(const M of Array.from(I)){if(!M.type.startsWith("image/"))continue;const H=new FileReader;H.onload=()=>{K(Z=>[...Z,{type:"image",url:H.result,name:M.name}])},H.readAsDataURL(M)}X.target.value=""}},q=async()=>{if(!(!S.trim()&&z.length===0)){Y(!0);try{const X=await re.tasks.addComment(e,S,s?.name,z.length>0?z:void 0,s?.id);X.comment&&x(I=>I.some(M=>M.id===X.comment.id)?I:[...I,X.comment]),R(""),K([])}catch{}Y(!1)}},W=t.jsxs("div",{className:"border-t border-border-default px-4 py-3 sticky bottom-0 bg-surface-secondary z-10",children:[z.length>0&&t.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:z.map((X,I)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:X.url,alt:X.name,className:"w-16 h-16 object-cover rounded-lg border border-border-default"}),t.jsx("button",{onClick:()=>K(M=>M.filter((H,Z)=>Z!==I)),className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-600 text-white text-[10px] flex items-center justify-center opacity-0 group-hover:opacity-100",children:"×"})]},I))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:S,onChange:X=>R(X.target.value),onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),q())},placeholder:"Add a comment or instruction…",className:"flex-1 px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-blue-500 outline-none text-fg-primary placeholder-gray-600"}),t.jsx("input",{type:"file",ref:U,accept:"image/*",multiple:!0,onChange:P,className:"hidden"}),t.jsx("button",{onClick:()=>U.current?.click(),className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-fg-secondary hover:text-fg-primary text-sm",title:"Attach image",children:"📎"}),t.jsx("button",{onClick:()=>{q()},disabled:D||!S.trim()&&z.length===0,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 rounded-lg text-white text-xs disabled:opacity-50",children:"Send"})]})]});if(C)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-fg-tertiary",children:"Loading logs…"});if(o.length===0&&!p)return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-fg-tertiary",children:[t.jsx("div",{className:"text-2xl mb-2",children:"📋"}),t.jsxs("div",{className:"text-xs",children:["No execution logs yet.",t.jsx("br",{}),'Click "Run with Agent" to start.']})]})}),W]});if(!A){const X=L.map(H=>Md(H)).filter(H=>H!==null),I=_d(X),M=[...I.map(H=>({kind:"entry",entry:H,ts:H.timestamp?new Date(H.timestamp).getTime():0})),...g.map(H=>({kind:"comment",comment:H,ts:new Date(H.createdAt).getTime()}))];return M.sort((H,Z)=>H.ts-Z.ts),t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-0.5",children:[M.map((H,Z)=>H.kind==="comment"?t.jsx(Co,{comment:H.comment,agents:l},`c-${H.comment.id}`):t.jsx(Od,{entry:H.entry,showTime:!0,isLast:Z===M.length-1},`e-${Z}`)),w&&p&&t.jsx(Sm,{content:p}),w&&!p&&I.length>0&&t.jsx(km,{})]}),W]})}const B=(X,I)=>{const M=X.firstAt?new Date(X.firstAt).getTime():0,H=I?.firstAt?new Date(I.firstAt).getTime():1/0;return g.filter(Z=>{const ee=new Date(Z.createdAt).getTime();return ee>=M&&ee<H})},F=o.length>0?g.filter(X=>new Date(X.createdAt).getTime()<new Date(o[0].firstAt).getTime()):[];return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{ref:G}),t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-2",children:[F.length>0&&t.jsx("div",{className:"space-y-0.5",children:F.map(X=>t.jsx(Co,{comment:X,agents:l},X.id))}),o.map((X,I)=>{const M=O.has(X.round),H=X.round===o[o.length-1].round,Z=c.get(X.round),ee=m.has(X.round),ne=B(X,o[I+1]),ae=X.status==="completed"||X.status==="execution_finished"?"✅":X.status==="failed"?"❌":X.status==="cancelled"?"⏹":"🔄",he=X.lastAt&&X.firstAt?Math.max(0,new Date(X.lastAt).getTime()-new Date(X.firstAt).getTime()):0,Ne=he>=6e4?`${Math.floor(he/6e4)}m ${Math.floor(he%6e4/1e3)}s`:he>=1e3?`${Math.floor(he/1e3)}s`:"";return t.jsxs("div",{className:"border border-border-default/50 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>E(X.round),className:"w-full flex items-center justify-between px-3 py-2 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm",children:ae}),t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",X.round]}),ne.length>0&&t.jsxs("span",{className:"text-[10px] text-blue-400",children:["💬 ",ne.length]}),H&&w&&t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[X.toolCount," tool",X.toolCount!==1?"s":""]}),Ne&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Ne}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${M?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),M&&t.jsxs("div",{className:"px-3 py-1.5 space-y-0.5",children:[ee&&t.jsxs("div",{className:"text-xs text-fg-tertiary py-2 text-center",children:["Loading round #",X.round,"…"]}),Z&&(()=>{const ye=Z.map($e=>om($e)).map($e=>Md($e)).filter($e=>$e!==null),Ae=[..._d(ye).map($e=>({kind:"entry",entry:$e,ts:$e.timestamp?new Date($e.timestamp).getTime():0})),...ne.map($e=>({kind:"comment",comment:$e,ts:new Date($e.createdAt).getTime()}))];return Ae.sort(($e,Xe)=>$e.ts-Xe.ts),Ae.map(($e,Xe)=>$e.kind==="comment"?t.jsx(Co,{comment:$e.comment,agents:l},`c-${$e.comment.id}`):t.jsx(Od,{entry:$e.entry,showTime:!0,isLast:Xe===Ae.length-1},`e-${Xe}`))})(),H&&w&&p&&t.jsx(Sm,{content:p}),H&&w&&!p&&!ee&&t.jsx(km,{})]})]},X.round)})]}),W]})}function UI({filePath:e,onClose:n}){const[s,l]=v.useState(null),[o,d]=v.useState(null),[c,h]=v.useState(!0);v.useEffect(()=>{h(!0),d(null),re.files.preview(e).then(f=>l(f)).catch(f=>d(String(f))).finally(()=>h(!1))},[e]);const m=e.split("/").pop()??e;return t.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[720px] max-w-[92vw] max-h-[85vh] flex flex-col shadow-2xl",onClick:f=>f.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-default shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t.jsx("path",{d:"M3 1h7l4 4v10H3V1zm7 1H4v12h10V5.5L10 2z"}),t.jsx("path",{d:"M10 1v4h4",fill:"none",stroke:"currentColor",strokeWidth:"1"})]}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:m})]}),t.jsx("button",{onClick:n,className:"text-fg-tertiary hover:text-fg-secondary text-lg shrink-0 ml-3",children:"×"})]}),t.jsx("div",{className:"px-4 py-1 border-b border-border-default/60",children:t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:e})}),t.jsxs("div",{className:"flex-1 overflow-auto min-h-0 p-5",children:[c&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"Loading..."}),o&&t.jsx("div",{className:"text-sm text-red-500 text-center py-8",children:o}),s&&s.type==="image"&&t.jsx("div",{className:"flex justify-center",children:t.jsx("img",{src:`data:${s.mimeType};base64,${s.content}`,alt:s.name,className:"max-w-full max-h-[60vh] rounded-lg"})}),s&&s.type==="markdown"&&t.jsx(tr,{content:s.content,className:"text-sm text-fg-secondary leading-relaxed"}),s&&s.type==="text"&&t.jsx("pre",{className:"text-xs text-fg-secondary font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed",children:s.content})]})]})})}function qI({task:e,agents:n,projects:s,requirements:l,allTasks:o,users:d,onClose:c,onRefresh:h,authUser:m}){const[f,g]=v.useState([]),[x,p]=v.useState(""),[y,w]=v.useState(!1),[N,C]=v.useState(!1),[_,O]=v.useState(null),[k,S]=v.useState(null),[R,D]=v.useState(!1),[Y,z]=v.useState("details"),K=v.useRef(null),[U,G]=v.useState("none"),V=v.useCallback(ve=>{z(ve),requestAnimationFrame(()=>{K.current?.scrollTo({top:0,behavior:"instant"})})},[]);v.useEffect(()=>{const ve=K.current;if(!ve)return;const Ve=()=>{const{scrollTop:Pt,scrollHeight:vt,clientHeight:sn}=ve;if(!(vt>sn+50)){G("none");return}const rt=Pt<30,Wt=Pt+sn>=vt-30;G(rt?"top":Wt?"bottom":"middle")};Ve(),ve.addEventListener("scroll",Ve,{passive:!0});const Rt=new ResizeObserver(Ve);return Rt.observe(ve),()=>{ve.removeEventListener("scroll",Ve),Rt.disconnect()}},[Y]);const[E,T]=v.useState(!1),[L,A]=v.useState(null),[P,q]=v.useState(null),[W,B]=v.useState(!1),[F,X]=v.useState(e.description),[I,M]=v.useState(!1),[H,Z]=v.useState(""),[ee,ne]=v.useState(1),[ae,he]=v.useState(!1),Ne=_s(),Le=20,ye=v.useCallback(async()=>{try{const ve=await re.tasks.listSubtasks(e.id);g(ve.subtasks)}catch{}},[e.id]);v.useEffect(()=>{ye()},[ye]);const je=async ve=>{if(!R){D(!0);try{await ve(),h(),await ye()}catch(Ve){A(String(Ve).replace("Error: ",""))}finally{D(!1)}}},Ae=ve=>je(()=>re.tasks.update(e.id,{priority:ve})),$e=ve=>je(()=>re.tasks.assign(e.id,ve||null)),Xe=ve=>je(()=>re.tasks.update(e.id,{projectId:ve||null})),tt=async()=>{if(!R){D(!0);try{await re.tasks.pause(e.id),h()}finally{D(!1)}}},et=async()=>{if(!E){T(!0),A(null),V("logs");try{await re.tasks.resume(e.id),h()}catch(ve){A(String(ve).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{T(!1)}}},_t=async()=>{x.trim()&&(await re.tasks.createSubtask(e.id,x.trim()),p(""),w(!1),ye(),h())},se=async ve=>{ve.status==="completed"?await re.tasks.cancelSubtask(e.id,ve.id):await re.tasks.completeSubtask(e.id,ve.id),ye(),h()},Te=async ve=>{await re.tasks.deleteSubtask(e.id,ve.id),O(null),ye(),h()},nt=async()=>{if(!R){D(!0);try{await re.tasks.updateStatus(e.id,"pending"),h()}finally{D(!1)}}},yt=async()=>{if(!R){D(!0),A(null),V("logs");try{await re.tasks.retry(e.id),h()}catch(ve){A(String(ve).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{D(!1)}}},Xt=async()=>{if(!E){T(!0),A(null),V("logs");try{await re.tasks.runNow(e.id),h()}catch(ve){A(String(ve).replace("Error: API error: 400","Server error").replace("Error: ","")),h()}finally{T(!1)}}},we=v.useRef(h);we.current=h,v.useEffect(()=>xn.on("task:update",Ve=>{Ve.payload.taskId===e.id&&(ye(),we.current())}),[e.id,ye]);const De=f.filter(ve=>ve.status==="completed").length,Pe=e.status==="in_progress",Ze=e.status==="blocked",mt=e.status==="completed",Kt=e.status==="failed",ln=e.status==="cancelled",Ht=e.status==="archived",Lt=mt||Kt||ln||Ht,At=e.taskType==="scheduled"&&!!e.scheduleConfig,St=At&&!!e.scheduleConfig?.paused,en=s.find(ve=>ve.id===e.projectId),tn=l.find(ve=>ve.id===e.requirementId);return n.find(ve=>ve.id===e.assignedAgentId),t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3 border-b border-border-default shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 pr-4",children:[Ne&&t.jsx("button",{onClick:c,className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold leading-snug truncate",children:e.title}),(()=>{const ve=qm[e.status];return ve?t.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium whitespace-nowrap ${ve.cls}`,children:ve.label}):t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium bg-gray-500/15 text-fg-tertiary whitespace-nowrap",children:e.status.replace(/_/g," ")})})()]})]}),!Ne&&t.jsx("button",{onClick:c,className:"text-fg-tertiary hover:text-fg-secondary text-lg shrink-0",children:"×"})]}),t.jsxs("div",{className:"flex gap-1 px-6 pt-2 pb-0 border-b border-border-default shrink-0 bg-surface-secondary",children:[t.jsx("button",{onClick:()=>V("details"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors ${Y==="details"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Details"}),t.jsxs("button",{onClick:()=>V("logs"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${Y==="logs"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Execution Log",Pe&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse"})]}),t.jsxs("button",{onClick:()=>V("deliverables"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${Y==="deliverables"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Deliverables",(()=>{const ve=(e.deliverables??[]).filter(Ve=>Ve.type!=="branch"&&typeof Ve.reference=="string"&&Ve.reference.length>0).length;return ve>0?t.jsx("span",{className:"text-[10px] text-fg-tertiary font-normal",children:ve}):null})()]})]}),t.jsxs("div",{className:"flex-1 min-h-0 relative",children:[t.jsxs("div",{ref:K,className:"h-full overflow-y-auto",children:[Y==="logs"&&t.jsxs("div",{className:"overflow-x-hidden min-w-0",children:[L&&t.jsxs("div",{className:"mx-4 mt-3 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:[t.jsx("span",{className:"font-medium",children:"Failed to start:"})," ",L]}),t.jsx(PI,{taskId:e.id,isRunning:e.status==="in_progress",authUser:m,agents:n})]}),Y==="details"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-6 pt-4 pb-3 border-b border-border-default",children:W?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:F,onChange:ve=>X(ve.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-y min-h-[80px]",rows:4,placeholder:"Add a description…"}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{B(!1),X(e.description)},className:"px-2.5 py-1 text-xs border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:()=>{je(()=>re.tasks.update(e.id,{description:F})),B(!1)},disabled:R,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Save"})]})]}):t.jsxs("div",{className:"group relative",children:[e.description?t.jsxs("div",{children:[t.jsx("div",{className:Ne&&!ae?"line-clamp-3":"",children:t.jsx(tr,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})}),Ne&&e.description.length>150&&t.jsx("button",{onClick:()=>he(!ae),className:"text-[11px] text-brand-500 mt-1 font-medium",children:ae?"Collapse":"Show more"})]}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),t.jsx("button",{onClick:()=>{X(e.description),B(!0)},className:"absolute top-0 right-0 text-[10px] text-fg-tertiary hover:text-brand-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Edit"})]})}),(en||tn)&&t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default flex flex-wrap items-center gap-2",children:[en&&t.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-2 py-0.5 bg-brand-500/10 text-brand-500 rounded-full",children:[t.jsx("span",{className:"text-[9px] text-brand-500/60",children:"Project"}),en.name]}),tn&&t.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-2 py-0.5 bg-brand-500/10 text-brand-500 rounded-full",children:[t.jsx("span",{className:"text-[9px] text-brand-500/60",children:"Req"}),tn.title.length>40?tn.title.slice(0,40)+"…":tn.title]})]}),t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default",children:[t.jsx("div",{className:"flex items-center justify-between mb-1.5",children:t.jsx("span",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:"Dependencies"})}),e.blockedBy&&e.blockedBy.length>0?t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:e.blockedBy.map(ve=>{const Ve=o.find(Pt=>Pt.id===ve),Rt=Ve&&(Ve.status==="completed"||Ve.status==="cancelled");return t.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-full ${Rt?"bg-green-500/10 text-green-600":"bg-amber-500/10 text-amber-600"}`,children:[t.jsx("span",{className:"text-[9px]",children:Rt?"✓":"⏳"}),t.jsx("span",{className:`font-mono ${Rt?"line-through opacity-60":""}`,children:Ve?Ve.title.slice(0,30):ve.slice(-8)}),!Lt&&t.jsx("button",{onClick:async()=>{const Pt=(e.blockedBy??[]).filter(vt=>vt!==ve);await re.tasks.update(e.id,{blockedBy:Pt}),h()},className:"ml-0.5 text-current opacity-40 hover:opacity-100 transition-opacity",title:"Remove dependency",children:"×"})]},ve)})}):t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-2",children:"No dependencies"}),!Lt&&t.jsxs("select",{value:"",onChange:async ve=>{const Ve=ve.target.value;if(!Ve)return;const Rt=[...e.blockedBy??[],Ve];await re.tasks.update(e.id,{blockedBy:Rt}),h()},className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-[11px] text-fg-secondary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"+ Add dependency…"}),o.filter(ve=>ve.id!==e.id&&!(e.blockedBy??[]).includes(ve.id)).map(ve=>t.jsx("option",{value:ve.id,children:ve.title},ve.id))]})]}),t.jsxs("div",{className:"px-6 py-4 border-b border-border-default/60 space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Project"}),t.jsxs("select",{value:e.projectId??"",onChange:ve=>{Xe(ve.target.value)},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"No Project"}),s.map(ve=>t.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Requirement"}),t.jsxs("select",{value:e.requirementId??"",onChange:ve=>je(()=>re.tasks.update(e.id,{requirementId:ve.target.value||null})),disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"No Requirement"}),l.filter(ve=>!e.projectId||ve.projectId===e.projectId).map(ve=>t.jsx("option",{value:ve.id,children:ve.title},ve.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Assignee"}),t.jsxs("select",{value:e.assignedAgentId??"",onChange:ve=>{$e(ve.target.value)},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"Unassigned"}),n.map(ve=>t.jsxs("option",{value:ve.id,children:[ve.name," (",ve.status,")"]},ve.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Reviewer"}),t.jsx("select",{value:e.reviewerAgentId??"",onChange:ve=>{ve.target.value&&ve.target.value!==e.reviewerAgentId&&je(()=>re.tasks.update(e.id,{reviewerAgentId:ve.target.value}))},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:n.map(ve=>t.jsx("option",{value:ve.id,children:ve.name},ve.id))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Priority"}),t.jsxs("select",{value:e.priority,onChange:ve=>{Ae(ve.target.value)},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]})]})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-border-default/60 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[11px] text-fg-tertiary",children:[e.createdBy&&t.jsxs("span",{children:["Created by ",t.jsx("span",{className:"text-fg-secondary",children:xi(e.createdBy,n,d)??e.createdBy})]}),e.updatedBy&&t.jsxs("span",{children:["Updated by ",t.jsx("span",{className:"text-fg-secondary",children:xi(e.updatedBy,n,d)??e.updatedBy})]}),e.createdAt&&t.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()}),e.startedAt&&t.jsxs("span",{children:["Started ",new Date(e.startedAt).toLocaleDateString()]}),e.updatedAt&&t.jsxs("span",{children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]}),e.projectId&&t.jsxs("span",{className:"font-mono text-blue-600/70",children:["task/",e.id]}),(e.executionRound??1)>1&&t.jsxs("span",{className:"text-amber-600",children:["Round ",e.executionRound]})]}),t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:["Subtasks ",f.length>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal normal-case",children:[De,"/",f.length," done"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[De>0&&t.jsx("button",{onClick:()=>C(ve=>!ve),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${N?"bg-brand-500/15 text-brand-500 border-brand-500/30":"text-fg-tertiary border-border-default hover:text-fg-secondary"}`,children:N?"Hide completed":`Show completed (${De})`}),t.jsx("button",{onClick:()=>w(!0),className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"+ Add subtask"})]})]}),(()=>{const ve=N?f:f.filter(Ve=>Ve.status!=="completed");return ve.length>0?t.jsx("div",{className:"space-y-1.5 mb-3",children:ve.map(Ve=>t.jsxs("div",{className:"group flex items-center gap-2.5 py-1.5 px-2 rounded-lg hover:bg-surface-elevated/50 transition-colors",children:[t.jsx("button",{onClick:()=>{se(Ve)},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${Ve.status==="completed"?"bg-green-600 border-green-600 text-white":"border-gray-600 hover:border-brand-500"}`,children:Ve.status==="completed"&&t.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M2 6l3 3 5-5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t.jsx("span",{className:`flex-1 text-sm ${Ve.status==="completed"?"line-through text-fg-tertiary":"text-fg-secondary"}`,children:Ve.title}),t.jsx("button",{onClick:()=>O(Ve),className:"shrink-0 opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-red-500 transition-all text-xs",children:"✕"})]},Ve.id))}):null})(),f.length===0&&!y&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:"No subtasks yet."}),y&&t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("input",{autoFocus:!0,value:x,onChange:ve=>p(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&_t(),ve.key==="Escape"&&(w(!1),p(""))},placeholder:"Subtask title...",className:"flex-1 px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none"}),t.jsx("button",{onClick:()=>{_t()},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg",children:"Add"}),t.jsx("button",{onClick:()=>{w(!1),p("")},className:"px-3 py-1.5 border border-border-default text-xs rounded-lg hover:bg-surface-elevated",children:"Cancel"})]}),(()=>{const ve=(e.deliverables??[]).filter(Pt=>Pt.type!=="branch"&&typeof Pt.reference=="string"&&Pt.reference.length>0);if(ve.length===0)return null;const Ve={file:"bg-blue-500/15 text-blue-600",document:"bg-blue-500/15 text-blue-600",report:"bg-brand-500/15 text-brand-500",directory:"bg-green-500/15 text-green-600",url:"bg-brand-500/15 text-brand-500",text:"bg-gray-500/15 text-fg-secondary"},Rt=ve.slice(0,3);return t.jsxs("div",{className:"mt-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("p",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:["Deliverables ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",ve.length,")"]})]}),ve.length>3&&t.jsx("button",{onClick:()=>V("deliverables"),className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:Rt.map((Pt,vt)=>{const sn=Pt.reference.split("/").pop()??Pt.reference;return t.jsxs("div",{className:"flex items-start gap-2.5 bg-surface-elevated/60 rounded-lg px-3 py-2 group hover:bg-surface-elevated/80 transition-colors",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium shrink-0 mt-0.5 ${Ve[Pt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:Pt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>q(Pt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:Pt.reference,children:sn}),Pt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:Pt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:Pt.reference})]})]},vt)})})]})})(),t.jsx(HI,{task:e,agents:n,users:d,authUser:m})]})]}),Y==="deliverables"&&t.jsx("div",{className:"px-6 py-4",children:(()=>{const ve=(e.deliverables??[]).filter(vt=>vt.type!=="branch"&&typeof vt.reference=="string"&&vt.reference.length>0);if(ve.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12 text-xs text-fg-tertiary",children:"No deliverables yet."});const Ve={file:"bg-blue-500/15 text-blue-600",document:"bg-blue-500/15 text-blue-600",report:"bg-brand-500/15 text-brand-500",directory:"bg-green-500/15 text-green-600",url:"bg-brand-500/15 text-brand-500",text:"bg-gray-500/15 text-fg-secondary"},Rt=Math.ceil(ve.length/Le),Pt=ve.slice((ee-1)*Le,ee*Le);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("p",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:["Deliverables ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",ve.length,")"]})]}),Rt>1&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:ee<=1,onClick:()=>ne(vt=>vt-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"‹"}),t.jsxs("span",{children:[ee,"/",Rt]}),t.jsx("button",{disabled:ee>=Rt,onClick:()=>ne(vt=>vt+1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"›"})]})]}),t.jsx("div",{className:"space-y-1.5",children:Pt.map((vt,sn)=>{const gn=vt.reference.split("/").pop()??vt.reference;return t.jsxs("div",{className:"flex items-start gap-2.5 bg-surface-elevated/60 rounded-lg px-3 py-2 group hover:bg-surface-elevated/80 transition-colors",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium shrink-0 mt-0.5 ${Ve[vt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:vt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>q(vt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:vt.reference,children:gn}),vt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:vt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:vt.reference})]})]},sn)})})]})})()})]}),U!=="none"&&t.jsxs("div",{className:"absolute bottom-3 right-3 flex flex-col gap-1.5 z-10",children:[U!=="top"&&t.jsx("button",{onClick:()=>K.current?.scrollTo({top:0,behavior:"smooth"}),className:"w-8 h-8 rounded-full bg-surface-overlay/90 border border-border-default shadow-lg flex items-center justify-center text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated transition-colors backdrop-blur-sm",title:"Scroll to top",children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M14.77 12.79a.75.75 0 01-1.06-.02L10 8.832l-3.71 3.938a.75.75 0 11-1.08-1.04l4.25-4.5a.75.75 0 011.08 0l4.25 4.5a.75.75 0 01-.02 1.06z",clipRule:"evenodd"})})}),U!=="bottom"&&t.jsx("button",{onClick:()=>{const ve=K.current;ve&&ve.scrollTo({top:ve.scrollHeight,behavior:"smooth"})},className:"w-8 h-8 rounded-full bg-surface-overlay/90 border border-border-default shadow-lg flex items-center justify-center text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated transition-colors backdrop-blur-sm",title:"Scroll to bottom",children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})})]})]}),At&&e.scheduleConfig&&t.jsxs("div",{className:`mx-6 mt-3 mb-0 px-4 py-2.5 rounded-lg border text-xs ${St?"bg-amber-500/5 border-amber-500/20":"bg-brand-500/5 border-brand-500/20"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:St?"text-amber-600":"text-brand-500",children:St?"⏸ Schedule Paused":t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3.5 h-3.5 inline -mt-0.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})," Scheduled"]})}),t.jsx("span",{className:"text-fg-tertiary",children:"·"}),t.jsx("span",{className:"text-fg-secondary",children:e.scheduleConfig.every?`Every ${e.scheduleConfig.every}`:e.scheduleConfig.cron?`Cron: ${e.scheduleConfig.cron}`:e.scheduleConfig.runAt?"One-shot":"N/A"}),!St&&e.scheduleConfig.nextRunAt&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-fg-tertiary",children:"·"}),t.jsxs("span",{className:"text-fg-secondary",children:["Next: ",(()=>{const ve=new Date(e.scheduleConfig.nextRunAt).getTime()-Date.now();if(ve<=0)return"due now";const Ve=Math.floor(ve/6e4);if(Ve<60)return`in ${Ve}m`;const Rt=Math.floor(Ve/60);return Rt<24?`in ${Rt}h ${Ve%60}m`:`in ${Math.floor(Rt/24)}d ${Rt%24}h`})()]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-1 text-fg-tertiary",children:[t.jsxs("span",{children:["Runs: ",e.scheduleConfig.currentRuns??0,e.scheduleConfig.maxRuns!=null?` / ${e.scheduleConfig.maxRuns}`:""]}),e.scheduleConfig.lastRunAt&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"·"}),t.jsxs("span",{children:["Last: ",(()=>{const ve=Date.now()-new Date(e.scheduleConfig.lastRunAt).getTime(),Ve=Math.floor(ve/6e4);if(Ve<1)return"just now";if(Ve<60)return`${Ve}m ago`;const Rt=Math.floor(Ve/60);return Rt<24?`${Rt}h ${Ve%60}m ago`:`${Math.floor(Rt/24)}d ago`})()]})]})]})]}),t.jsx("div",{className:"px-6 py-4 border-t border-border-default flex items-center justify-between gap-2",children:t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.status==="pending"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>je(()=>re.tasks.approve(e.id)),disabled:R,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"Approve"}),t.jsx("button",{onClick:()=>je(()=>re.tasks.reject(e.id)),disabled:R,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 rounded-lg hover:bg-red-500/10 disabled:opacity-50",children:"Reject"})]}),e.status==="review"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{je(()=>re.tasks.accept(e.id,m?.id))},disabled:R,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"✓ Approve"}),I?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"text",value:H,onChange:ve=>Z(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&H.trim()&&(je(()=>re.tasks.revision(e.id,H.trim(),m?.id)),M(!1),Z(""))},placeholder:"Revision reason…",autoFocus:!0,className:"px-2 py-1 text-xs bg-surface-elevated border border-amber-500/40 rounded-lg text-fg-primary focus:border-amber-400 outline-none w-48"}),t.jsx("button",{onClick:()=>{je(()=>re.tasks.revision(e.id,H.trim()||"Revisions needed",m?.id)),M(!1),Z("")},disabled:R,className:"px-2.5 py-1 text-xs bg-amber-600 hover:bg-amber-500 rounded-lg text-white disabled:opacity-50",children:"Send"}),t.jsx("button",{onClick:()=>{M(!1),Z("")},className:"px-1.5 py-1 text-xs text-fg-secondary hover:text-fg-primary",children:"✕"})]}):t.jsx("button",{onClick:()=>M(!0),disabled:R,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 rounded-lg text-white disabled:opacity-50",children:"↻ Request Revision"})]}),Pe&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>{tt()},disabled:R,className:"px-3 py-1.5 text-xs border border-amber-500/30 text-amber-600 rounded-lg hover:bg-amber-500/10 disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:[t.jsx("rect",{x:"2",y:"1.5",width:"3",height:"9",rx:"0.5"}),t.jsx("rect",{x:"7",y:"1.5",width:"3",height:"9",rx:"0.5"})]}),"Pause"]}),t.jsxs("button",{onClick:()=>{yt()},disabled:R,className:"px-3 py-1.5 text-xs border border-blue-500/30 text-blue-600 rounded-lg hover:bg-blue-500/10 disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("path",{d:"M1.5 6a4.5 4.5 0 1 1 1.3 3.2",strokeLinecap:"round"}),t.jsx("path",{d:"M1 3.5V6h2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Retry"]})]}),Ze&&t.jsx("button",{onClick:()=>{et()},disabled:E,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1",children:E?t.jsx(t.Fragment,{children:"Resuming…"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 1.5v9l7-4.5-7-4.5z"})}),"Resume"]})}),Kt&&t.jsxs("button",{onClick:()=>{yt()},disabled:R,className:"px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("path",{d:"M1.5 6a4.5 4.5 0 1 1 1.3 3.2",strokeLinecap:"round"}),t.jsx("path",{d:"M1 3.5V6h2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Retry"]}),At&&(mt||Kt)&&t.jsx("button",{onClick:()=>{Xt()},disabled:E,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1.5",children:E?t.jsx(t.Fragment,{children:"Running…"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 1.5v9l7-4.5-7-4.5z"})}),"Run Now"]})}),At&&!Pe&&(St?t.jsx("button",{onClick:()=>{je(()=>re.tasks.resumeSchedule(e.id))},disabled:R,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"▶ Resume Schedule"}):t.jsx("button",{onClick:()=>{je(()=>re.tasks.pauseSchedule(e.id))},disabled:R,className:"px-3 py-1.5 text-xs border border-amber-500/30 text-amber-600 rounded-lg hover:bg-amber-500/10 disabled:opacity-50",children:"⏸ Pause Schedule"})),mt&&t.jsx("button",{onClick:()=>je(()=>re.tasks.archive(e.id)),disabled:R,className:"px-3 py-1.5 text-xs bg-gray-600 hover:bg-gray-500 rounded-lg text-white disabled:opacity-50",children:"Archive"}),Lt&&t.jsx("button",{onClick:()=>{nt()},disabled:R,className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary disabled:opacity-50",children:"Reopen"}),!Lt&&e.status!=="pending"&&t.jsx("button",{onClick:async()=>{const{count:ve}=await re.tasks.getDependentCount(e.id);ve>0?S({dependentCount:ve}):je(()=>re.tasks.cancel(e.id))},disabled:R,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 rounded-lg hover:bg-red-500/10 disabled:opacity-50",children:"Cancel"})]})}),_&&t.jsx(Ej,{title:`Delete subtask "${_.title}"?`,message:"This subtask will be permanently deleted.",confirmLabel:"Delete",onConfirm:()=>{Te(_)},onCancel:()=>O(null)}),k&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>S(null),children:t.jsxs("div",{className:"bg-surface-default border border-border-default rounded-xl p-6 max-w-md w-full shadow-2xl",onClick:ve=>ve.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:"Cancel Task"}),t.jsxs("p",{className:"text-sm text-fg-secondary mb-4",children:["This task has ",t.jsx("span",{className:"text-amber-600 font-medium",children:k.dependentCount})," dependent task",k.dependentCount>1?"s":""," that ",k.dependentCount>1?"are":"is"," currently blocked by it."]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{onClick:()=>{S(null),je(()=>re.tasks.cancel(e.id,!1))},className:"w-full px-4 py-2.5 text-sm bg-surface-elevated border border-border-default rounded-lg hover:bg-surface-overlay text-fg-primary text-left",children:[t.jsx("span",{className:"font-medium",children:"Cancel this task only"}),t.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5",children:"Dependent tasks will start if they have no other blockers"})]}),t.jsxs("button",{onClick:()=>{S(null),je(()=>re.tasks.cancel(e.id,!0))},className:"w-full px-4 py-2.5 text-sm bg-red-500/10 border border-red-500/30 rounded-lg hover:bg-red-500/20 text-red-500 text-left",children:[t.jsx("span",{className:"font-medium",children:"Cancel with all dependents"}),t.jsxs("span",{className:"block text-xs text-red-500/70 mt-0.5",children:["Also cancels ",k.dependentCount," blocked task",k.dependentCount>1?"s":""]})]}),t.jsx("button",{onClick:()=>S(null),className:"w-full px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary",children:"Keep task running"})]})]})}),P&&t.jsx(UI,{filePath:P,onClose:()=>q(null)})]})}function VI({project:e,tasks:n,requirements:s,agents:l,onDeleteProject:o,onUpdateProject:d,onRefresh:c}){const h=v.useMemo(()=>n.filter(z=>z.projectId===e.id),[n,e.id]),m=v.useMemo(()=>s.filter(z=>z.projectId===e.id),[s,e.id]),f=v.useMemo(()=>{const z={total:h.length,completed:0,inProgress:0,inReview:0,blocked:0,pending:0,failed:0,reqs:m.length,reqsDone:0};for(const K of h)K.status==="completed"||K.status==="accepted"?z.completed++:K.status==="in_progress"?z.inProgress++:K.status==="review"||K.status==="revision"?z.inReview++:K.status==="blocked"?z.blocked++:K.status==="failed"?z.failed++:z.pending++;for(const K of m)K.status==="completed"&&z.reqsDone++;return z},[h,m]),g=v.useMemo(()=>new Set(h.map(z=>z.assignedAgentId).filter(Boolean)),[h]),x=v.useMemo(()=>l.filter(z=>g.has(z.id)),[l,g]),[p,y]=v.useState(!1),[w,N]=v.useState(""),[C,_]=v.useState("main"),[O,k]=v.useState(!1),S=[{value:"active",label:"Active",desc:"Work is ongoing"},{value:"paused",label:"Paused",desc:"Temporarily on hold"},{value:"archived",label:"Archived",desc:"No longer active"}],R=async z=>{if(z!==e.status){k(!0);try{await d({status:z}),c()}finally{k(!1)}}},D=async()=>{const z=w.trim();if(!z)return;const K=[...e.repositories??[],{url:"",localPath:z,defaultBranch:C||"main"}];await d({repositories:K}),N(""),_("main"),y(!1),c()},Y=async z=>{const K=(e.repositories??[]).filter((U,G)=>G!==z);await d({repositories:K}),c()};return t.jsxs("div",{className:"p-5 space-y-5 max-w-3xl",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(_I,{value:e.description??"",onSave:async z=>{await d({description:z}),c()},className:"text-sm text-fg-secondary",placeholder:"Add a project description…"}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[e.createdAt&&t.jsxs("span",{children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),e.updatedAt&&t.jsxs("span",{children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Project Status"}),t.jsx("div",{className:"flex gap-2",children:S.map(z=>t.jsxs("button",{disabled:O,onClick:()=>R(z.value),className:`flex-1 px-3 py-2 rounded-lg text-xs font-medium transition-all ${e.status===z.value?z.value==="active"?"bg-green-500/15 text-green-600 ring-1 ring-green-500/30":z.value==="paused"?"bg-amber-500/15 text-amber-600 ring-1 ring-amber-500/30":"bg-gray-500/15 text-fg-tertiary ring-1 ring-gray-500/30":"bg-surface-elevated text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"} ${O?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[t.jsx("div",{children:z.label}),t.jsx("div",{className:"text-[10px] opacity-70 mt-0.5",children:z.desc})]},z.value))})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Overview"}),t.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-3",children:[t.jsx(Ws,{label:"Total",value:f.total,color:"text-fg-primary"}),t.jsx(Ws,{label:"Completed",value:f.completed,color:"text-green-600"}),t.jsx(Ws,{label:"In Progress",value:f.inProgress,color:"text-brand-500"}),t.jsx(Ws,{label:"In Review",value:f.inReview,color:"text-brand-500"}),t.jsx(Ws,{label:"Blocked",value:f.blocked,color:"text-amber-600"}),t.jsx(Ws,{label:"Failed",value:f.failed,color:"text-red-500"})]}),f.total>0&&t.jsxs("div",{className:"mt-3 flex h-2 rounded-full overflow-hidden bg-surface-elevated",children:[f.completed>0&&t.jsx("div",{className:"bg-green-500",style:{width:`${f.completed/f.total*100}%`}}),f.inProgress>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${f.inProgress/f.total*100}%`}}),f.inReview>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${f.inReview/f.total*100}%`}}),f.blocked>0&&t.jsx("div",{className:"bg-amber-500",style:{width:`${f.blocked/f.total*100}%`}}),f.pending>0&&t.jsx("div",{className:"bg-blue-500/40",style:{width:`${f.pending/f.total*100}%`}}),f.failed>0&&t.jsx("div",{className:"bg-red-500",style:{width:`${f.failed/f.total*100}%`}})]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Requirements"}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsx(Ws,{label:"Total",value:f.reqs,color:"text-fg-primary"}),t.jsx(Ws,{label:"Completed",value:f.reqsDone,color:"text-green-600"}),t.jsx(Ws,{label:"Active",value:f.reqs-f.reqsDone,color:"text-brand-500"})]})]}),x.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsxs("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Agents (",x.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(z=>{const K=h.filter(G=>G.assignedAgentId===z.id),U=K.filter(G=>!["completed","failed","cancelled","archived"].includes(G.status));return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-surface-elevated/60 rounded-lg",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${z.status==="working"?"bg-blue-500":z.status==="idle"?"bg-green-500":"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary",children:z.name}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[U.length," active / ",K.length," total"]})]},z.id)})})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary",children:"Repositories"}),t.jsx("button",{onClick:()=>y(!p),className:"text-[10px] text-brand-500 hover:text-brand-500",children:p?"Cancel":"+ Add"})]}),(e.repositories??[]).length===0&&!p&&t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No repositories linked."}),(e.repositories??[]).map((z,K)=>t.jsxs("div",{className:"flex items-center gap-2 py-1.5 group",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:[t.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),t.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 min-w-0 truncate",children:z.url||z.localPath}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:z.defaultBranch}),t.jsx("button",{onClick:()=>Y(K),className:"text-fg-tertiary hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",title:"Remove repository",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},K)),p&&t.jsxs("div",{className:"mt-2 space-y-2 p-3 bg-surface-elevated rounded-lg border border-border-default",children:[t.jsx("input",{value:w,onChange:z=>N(z.target.value),placeholder:"Local path (e.g. /Users/me/project)",className:"w-full px-2.5 py-1.5 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:C,onChange:z=>_(z.target.value),placeholder:"Branch (default: main)",className:"flex-1 px-2.5 py-1.5 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary"}),t.jsx("button",{onClick:D,disabled:!w.trim(),className:"px-3 py-1.5 text-xs bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Add"})]})]})]}),t.jsxs("div",{className:"border border-red-500/20 rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-red-500/80 mb-2",children:"Danger Zone"}),t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-3",children:"Deleting a project is permanent and cannot be undone. Tasks and requirements will be unlinked."}),t.jsx("button",{onClick:o,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 hover:bg-red-500/10 rounded-lg transition-colors",children:"Delete Project"})]})]})}function Ws({label:e,value:n,color:s}){return t.jsxs("div",{className:"text-center py-2",children:[t.jsx("div",{className:`text-xl font-bold ${s}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}const Ho={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},in_progress:{label:"Active",cls:"bg-brand-500/15 text-brand-500"},completed:{label:"Done",cls:"bg-green-500/15 text-green-600"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"},cancelled:{label:"Cancelled",cls:"bg-gray-600/15 text-fg-tertiary"}},MN={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed"},ON={failed:"rejected",todo:"pending",in_progress:"in_progress",review:"in_progress",done:"completed",closed:"cancelled"},FI={urgent:0,high:1,medium:2,low:3},Xv={failed:0,todo:1,in_progress:2,review:3,done:4,closed:5},YI={failed:"border-l-red-500 bg-red-500/5",todo:"border-l-blue-500 bg-blue-500/5",in_progress:"border-l-brand-500 bg-brand-500/5",review:"border-l-purple-500 bg-brand-500/5",done:"border-l-green-500 bg-green-500/5",closed:"border-l-gray-500 bg-gray-500/5"},GI={failed:"border-l-red-500 text-red-500",todo:"border-l-blue-500 text-blue-600",in_progress:"border-l-brand-500 text-brand-500",review:"border-l-purple-500 text-brand-500",done:"border-l-green-500 text-green-600",closed:"border-l-gray-500 text-fg-tertiary"},XI=["pending","in_progress","completed","rejected","cancelled"];function KI(e){for(const n of Bo)if(n.statuses.includes(e))return n.id;return"closed"}function ZI(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const l=Math.floor(s/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Kv({value:e,options:n,onSelect:s}){const[l,o]=v.useState(!1),d=v.useRef(null),c=v.useRef(null),h=n.find(m=>m.value===e);return v.useEffect(()=>{if(!l)return;const m=f=>{c.current&&!c.current.contains(f.target)&&d.current&&!d.current.contains(f.target)&&o(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:d,onClick:()=>o(m=>!m),className:`text-[11px] px-2 py-0.5 rounded-full font-medium transition-colors cursor-pointer hover:ring-1 hover:ring-current/30 ${h?.cls??"bg-gray-500/15 text-fg-tertiary"}`,children:h?.label??e}),l&&t.jsx("div",{ref:c,className:"absolute top-full left-0 mt-1 w-40 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-50 py-1 max-h-64 overflow-y-auto",children:n.map(m=>t.jsxs("button",{onClick:()=>{m.value!==e&&s(m.value),o(!1)},className:`w-full text-left px-3 py-1.5 text-[11px] flex items-center gap-2 transition-colors ${m.value===e?"bg-surface-elevated":"hover:bg-surface-elevated/60"}`,children:[t.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 ${m.cls.split(" ")[0]}`}),t.jsx("span",{className:`font-medium ${m.value===e?"text-fg-primary":"text-fg-secondary"}`,children:m.label}),m.value===e&&t.jsx("svg",{className:"w-3 h-3 ml-auto text-brand-500",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M2 6l3 3 5-5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},m.value))})]})}function Zv({row:e,idx:n,dragIdx:s,agentMap:l,projMap:o,onTaskClick:d,onReqClick:c,onRowDragStart:h,onRowDragEnd:m,handleStatusChange:f,handlePriorityChange:g,selected:x}){const p=e.data.status,y=e.data.priority,w=e.kind==="task"?l.get(e.data.assignedAgentId??""):void 0,N=o.get((e.kind==="task",e.data.projectId??""));return t.jsxs("div",{draggable:!0,onDragStart:C=>h(C,n),onDragEnd:m,onClick:()=>e.kind==="task"?d(e.data):c(e.data),className:`flex items-center gap-2 px-6 py-2 border-b border-border-default/40 cursor-pointer transition-colors border-l-2 ${YI[e.group]??"border-l-gray-700"} ${s===n?"opacity-40":""} ${x?"bg-brand-500/10 border-l-brand-500 hover:bg-brand-500/15":"hover:bg-surface-elevated/50"}`,children:[t.jsx("div",{className:"w-12 shrink-0",children:e.kind==="req"?t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded font-semibold bg-amber-500/15 text-amber-600",children:"REQ"}):e.data.taskType==="scheduled"?t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded font-semibold bg-blue-500/15 text-blue-600 inline-flex items-center gap-0.5",title:"Scheduled task",children:"SCHED"}):t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded font-semibold bg-gray-500/15 text-fg-secondary",children:"TASK"})}),t.jsx("div",{className:"flex-1 min-w-[200px] text-sm text-fg-primary truncate",children:e.data.title}),t.jsx("div",{className:"w-[130px] shrink-0",onClick:C=>C.stopPropagation(),children:t.jsx(Kv,{value:p,options:e.kind==="task"?zI.map(C=>({value:C,label:qm[C]?.label??C,cls:qm[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})):$I.map(C=>({value:C,label:Ho[C]?.label??C,cls:Ho[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:C=>{f(e,C)}})}),t.jsx("div",{className:"w-[100px] shrink-0",onClick:C=>C.stopPropagation(),children:t.jsx(Kv,{value:y,options:II.map(C=>({value:C,label:Gv[C]?.label??C,cls:Gv[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:C=>{g(e,C)}})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] text-fg-secondary truncate",children:w?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${_N[w.status]??"bg-gray-500"}`}),w.name]}):t.jsx("span",{className:"text-fg-tertiary",children:"—"})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] text-fg-tertiary truncate",children:N?.name??t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[90px] shrink-0 text-[10px] text-fg-tertiary text-right",children:ZI(e.data.updatedAt??"")})]})}function WI({tasks:e,requirements:n,agents:s,projects:l,onTaskClick:o,onReqClick:d,onRefresh:c,selectedTaskId:h,selectedReqId:m}){const[f,g]=v.useState("status"),[x,p]=v.useState(null),[y,w]=v.useState(null),N=v.useMemo(()=>{const E=[];for(const T of e){const L=KI(T.status);E.push({kind:"task",data:T,group:L,groupOrder:Xv[L]??5})}for(const T of n){const L=MN[T.status]??"todo";E.push({kind:"req",data:T,group:L,groupOrder:Xv[L]??5})}if(f==="status")E.sort((T,L)=>{if(T.groupOrder!==L.groupOrder)return T.groupOrder-L.groupOrder;const A=new Date(T.data.updatedAt??0).getTime();return new Date(L.data.updatedAt??0).getTime()-A});else{const T=L=>FI[L.data.priority]??2;E.sort((L,A)=>{const P=T(L),q=T(A);return P!==q?P-q:new Date(A.data.updatedAt??0).getTime()-new Date(L.data.updatedAt??0).getTime()})}return E},[e,n,f]),C=async(E,T)=>{try{E.kind==="task"?await re.tasks.updateStatus(E.data.id,T):await re.requirements.updateStatus(E.data.id,T),c()}catch{}},_=async(E,T)=>{try{E.kind==="task"?await re.tasks.update(E.data.id,{priority:T}):await re.requirements.update(E.data.id,{priority:T}),c()}catch{}},O=(E,T)=>{p(T),E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("text/plain",String(T)),E.currentTarget.style.opacity="0.4"},k=E=>{E.currentTarget.style.opacity="1",p(null),w(null)},S=(E,T)=>{E.preventDefault(),E.dataTransfer.dropEffect="move",y!==T&&w(T)},R=async(E,T)=>{if(E.preventDefault(),w(null),x==null)return;const L=N[x];if(!L||L.group===T)return;const A=Bo.find(P=>P.id===T);if(A){try{if(L.kind==="task"){if(L.data.status==="pending")return;await re.tasks.updateStatus(L.data.id,A.dropStatus)}else{const P=ON[T];P&&await re.requirements.updateStatus(L.data.id,P)}c()}catch{}p(null)}},D=v.useMemo(()=>new Map(s.map(E=>[E.id,E])),[s]),Y=v.useMemo(()=>new Map(l.map(E=>[E.id,E])),[l]),z=["todo","in_progress","review","done"],K=v.useMemo(()=>{const E={};for(const T of N)E[T.group]=(E[T.group]??0)+1;return E},[N]),{rowsByGroup:U,rowIndexMap:G}=v.useMemo(()=>{const E=new Map,T=new Map;for(let L=0;L<N.length;L++){const A=N[L];T.set(A,L);const P=E.get(A.group)??[];P.push(A),E.set(A.group,P)}return{rowsByGroup:E,rowIndexMap:T}},[N]),V=v.useMemo(()=>{if(f!=="status")return null;const E=new Set(N.map(A=>A.group)),T=[],L=new Set;E.has("failed")&&(T.push("failed"),L.add("failed"));for(const A of z)T.push(A),L.add(A);for(const A of N)L.has(A.group)||(T.push(A.group),L.add(A.group));return T},[N,f]);return t.jsx("div",{className:"flex-1 min-h-0 overflow-auto bg-surface-secondary",children:t.jsxs("div",{className:"w-fit min-w-full",children:[t.jsxs("div",{className:"flex items-center gap-2 px-6 py-2 border-b border-border-default text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider sticky top-0 z-20 bg-surface-secondary",children:[t.jsx("div",{className:"w-12 shrink-0 text-fg-muted normal-case font-normal",children:N.length}),t.jsx("div",{className:"flex-1 min-w-[200px]",children:"Title"}),t.jsxs("button",{onClick:()=>g("status"),className:`w-[130px] shrink-0 text-left flex items-center gap-1 transition-colors ${f==="status"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Status ",f==="status"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsxs("button",{onClick:()=>g("priority"),className:`w-[100px] shrink-0 text-left flex items-center gap-1 transition-colors ${f==="priority"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Priority ",f==="priority"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsx("div",{className:"w-[120px] shrink-0",children:"Assignee"}),t.jsx("div",{className:"w-[120px] shrink-0",children:"Project"}),t.jsx("div",{className:"w-[90px] shrink-0 text-right",children:"Updated"})]}),t.jsxs("div",{children:[f==="status"&&V?V.map(E=>{const T=Bo.find(A=>A.id===E),L=U.get(E)??[];return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-2 px-6 py-2 border-l-2 bg-surface-secondary/60 sticky top-0 z-10 ${GI[E]??""} ${y===E?"ring-1 ring-brand-500/40":""}`,onDragOver:A=>S(A,E),onDragLeave:()=>w(null),onDrop:A=>{R(A,E)},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",children:T?.label??E}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:K[E]??0})]}),L.map(A=>t.jsx(Zv,{row:A,idx:G.get(A)??0,dragIdx:x,agentMap:D,projMap:Y,onTaskClick:o,onReqClick:d,onRowDragStart:O,onRowDragEnd:k,handleStatusChange:C,handlePriorityChange:_,selected:A.kind==="task"?A.data.id===h:A.data.id===m},`${A.kind}-${A.data.id}`))]},E)}):N.map((E,T)=>t.jsx(Zv,{row:E,idx:T,dragIdx:x,agentMap:D,projMap:Y,onTaskClick:o,onReqClick:d,onRowDragStart:O,onRowDragEnd:k,handleStatusChange:C,handlePriorityChange:_,selected:E.kind==="task"?E.data.id===h:E.data.id===m},`${E.kind}-${E.data.id}`)),N.length===0&&t.jsx("div",{className:"flex items-center justify-center py-16 text-sm text-fg-tertiary",children:"No items"})]})]})})}function Wv({authUser:e}){const n=_s(),s=tu({side:"right",defaultWidth:Math.round(window.innerWidth*2/3),minWidth:380,maxWidth:Math.round(window.innerWidth*.8),storageKey:"markus_projects_detail_v3"}),[l,o]=v.useState(!1),d=v.useRef(l);d.current=l;const[c,h]=v.useState([]),[m,f]=v.useState("all"),[g,x]=v.useState(null),[p,y]=v.useState({}),[w,N]=v.useState([]),[C,_]=v.useState([]),[O,k]=v.useState([]),[S,R]=v.useState(!0),[D,Y]=v.useState(""),[z,K]=v.useState(!1),U=v.useCallback(()=>{sn(g??""),St(!0)},[g]),[G,V]=v.useState(!1),[E,T]=v.useState(!1),[L,A]=v.useState(""),[P,q]=v.useState(""),[W,B]=v.useState("medium"),[F,X]=v.useState(""),[I,M]=v.useState(""),[H,Z]=v.useState(""),[ee,ne]=v.useState(""),[ae,he]=v.useState([]),[Ne,Le]=v.useState("standard"),[ye,je]=v.useState("4h"),[Ae,$e]=v.useState(null),[Xe,tt]=v.useState(null),[et,_t]=v.useState(new Set),[se,Te]=v.useState(new Set),nt=v.useRef(new Set),yt=v.useRef(new Set),[Xt,we]=v.useState(null),[De,Pe]=v.useState("backlog"),[Ze,mt]=v.useState(!1),[Kt,ln]=v.useState(!1),Ht=v.useRef(null),Lt=v.useRef(null),[At,St]=v.useState(!1),[en,tn]=v.useState(""),[ve,Ve]=v.useState(""),[Rt,Pt]=v.useState("medium"),[vt,sn]=v.useState(""),[gn,rt]=v.useState(null),[Wt,Mn]=v.useState(""),Mt=te=>{Y(te),setTimeout(()=>Y(""),3e3)},yn=c.find(te=>te.id===g)??null;v.useEffect(()=>{yt.current=se},[se]);const Nn=v.useCallback(async()=>{try{const{projects:te}=await re.projects.list();h(te)}catch{}},[]),ie=v.useCallback(async()=>{const te={};m==="project"&&g&&(te.projectId=g);try{const{board:Ie}=await re.tasks.board(te);y(Ie)}catch{}},[m,g]),qe=v.useCallback(async()=>{try{const{agents:te}=await re.agents.list();N(te)}catch{}},[]),ze=v.useCallback(async()=>{try{const{users:te}=await re.users.list(e?.orgId);_(te)}catch{}},[e?.orgId]),We=v.useCallback(async()=>{try{const{requirements:te}=await re.requirements.list({});k(te)}catch{}},[]),lt=v.useCallback(async()=>{await Promise.all([Nn(),ie(),qe(),ze(),We()]),R(!1)},[Nn,ie,qe,ze,We]);v.useEffect(()=>{lt()},[lt]);const Ct=v.useCallback(te=>{$e(Ie=>Ie?.id===te.id?(n&&d.current&&o(!1),null):(n&&(o(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash)),te)),tt(null)},[n]),dt=v.useCallback(te=>{tt(Ie=>Ie?.id===te.id?(n&&d.current&&o(!1),null):(n&&(o(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash)),te)),$e(null)},[n]),zt=v.useCallback(()=>{$e(null),tt(null),n&&d.current&&o(!1)},[n]);v.useEffect(()=>{if(!n)return;const te=()=>{d.current&&(o(!1),$e(null),tt(null))};return window.addEventListener("popstate",te),()=>window.removeEventListener("popstate",te)},[n]);const pt=v.useRef(Ae);pt.current=Ae,v.useEffect(()=>{const Ie=setInterval(()=>{ie(),qe(),We()},Ae?6e4:15e3),Ye=xn.on("task:update",Me=>{pt.current||(ie(),We());const Ce=Me?.payload;Ce?.taskId&&$e(Ge=>{if(!Ge||Ge.id!==Ce.taskId)return Ge;const Ue={};return typeof Ce.status=="string"&&(Ue.status=Ce.status),Array.isArray(Ce.deliverables)&&(Ue.deliverables=Ce.deliverables),Array.isArray(Ce.notes)&&(Ue.notes=Ce.notes),Ce.result!==void 0&&(Ue.result=Ce.result),{...Ge,...Ue}})}),J=xn.on("task:create",()=>{ie()}),Ee=["requirement:created","requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"].map(Me=>xn.on(Me,()=>{We()}));return()=>{clearInterval(Ie),Ye(),J(),Ee.forEach(Me=>Me())}},[ie,qe,We,Ae]);const on=v.useRef(p);on.current=p;const de=v.useRef(O);de.current=O;const Fe=v.useCallback(te=>{if(!te)return;const Ie=yt.current;Ie.size>0&&!Ie.has(te)&&Te(Ye=>new Set([...Ye,te]))},[]);v.useEffect(()=>{const te=localStorage.getItem("markus_nav_openTask");if(!te)return;const Ye=Object.values(p).flat().find(J=>J.id===te);Ye&&(Fe(Ye.projectId),Ct(Ye),localStorage.removeItem("markus_nav_openTask"))},[p,Ct,Fe]),v.useEffect(()=>{const te=window.location.hash.slice(1).split("/");if(Ia(te[0])===ge.WORK&&te[1])ht(te[1]);else{const Ie=localStorage.getItem("markus_nav_projectId");Ie&&(localStorage.removeItem("markus_nav_projectId"),ht(Ie))}},[]),v.useEffect(()=>{const te=()=>{const Ye=window.location.hash.slice(1).split("/");Ia(Ye[0])===ge.WORK&&Ye[1]?ht(Ye[1]):Ia(Ye[0])===ge.WORK&&Tt()},Ie=Ye=>{const J=Ye.detail;if(Ia(J.page)===ge.WORK){if(J.params?.openTask){const Ee=Object.values(on.current).flat().find(Me=>Me.id===J.params.openTask);Ee&&(Fe(Ee.projectId),Ct(Ee),localStorage.removeItem("markus_nav_openTask"))}if(J.params?.openRequirement){const pe=de.current.find(Ee=>Ee.id===J.params.openRequirement);pe&&(Fe(pe.projectId),dt(pe))}J.params?.projectId&&ht(J.params.projectId),!J.params?.projectId&&!J.params?.openTask&&!J.params?.openRequirement&&Tt()}};return window.addEventListener("markus:navigate",Ie),window.addEventListener("hashchange",te),()=>{window.removeEventListener("markus:navigate",Ie),window.removeEventListener("hashchange",te)}},[]);const ht=te=>{yt.current.size>0&&(nt.current=new Set(yt.current)),Te(new Set),x(te),f("project"),K(!1),history.replaceState(null,"",im(ge.WORK,te))},Tt=()=>{Te(nt.current),x(null),f("all"),K(!1),history.replaceState(null,"",im(ge.WORK))},Rn=()=>{V(!1),Mt("Project created"),Nn()},gr=async te=>{if(confirm("Delete this project and unlink all its tasks?"))try{await re.projects.delete(te),g===te&&Tt(),Mt("Project deleted"),Nn(),ie()}catch(Ie){Mt(`Error: ${Ie}`)}},pr=async()=>{if(!L||!F||!I)return;if(F===I){Mt("Assigned agent and reviewer must be different");return}const te=H||void 0,Ie=ee||void 0;try{await re.tasks.create(L,P,F,I,W,te,ae.length>0?ae:void 0,Ie,Ne!=="standard"?Ne:void 0,Ne==="scheduled"?{every:ye}:void 0),A(""),q(""),he([]),ne(""),Le("standard"),je("4h"),T(!1),ie()}catch(Ye){Mt(`Error creating task: ${Ye}`)}},nr=()=>{ie(),Ae&&setTimeout(()=>{const te={};m==="project"&&g&&(te.projectId=g),re.tasks.board(te).then(Ie=>{const J=Object.values(Ie.board).flat().find(pe=>pe.id===Ae.id);$e(J||null)}).catch(()=>{})},150)},dr=async()=>{if(!en.trim()){Mt("Please enter a title for this requirement");return}if(!ve.trim()){Mt("Please enter a description for this requirement");return}if(!vt){Mt("Please select a project for this requirement");return}try{await re.requirements.create({title:en.trim(),description:ve.trim(),priority:Rt,projectId:vt}),Mt("Requirement created"),tn(""),Ve(""),St(!1),We()}catch(te){Mt(`Error: ${te}`)}},ur=async te=>{try{await re.requirements.approve(te),Mt("Requirement approved"),We(),ie()}catch(Ie){Mt(`Error: ${Ie}`)}},vn=async()=>{if(gn)try{await re.requirements.reject(gn,Wt),Mt("Requirement rejected"),rt(null),Mn(""),We()}catch(te){Mt(`Error: ${te}`)}},gs=async te=>{try{await re.requirements.cancel(te),Mt("Requirement cancelled"),We()}catch(Ie){Mt(`Error: ${Ie}`)}},qr=(te,Ie)=>{Ht.current=Ie,Lt.current=null,te.dataTransfer.effectAllowed="move",te.dataTransfer.setData("text/plain",`task:${Ie.id}`),te.currentTarget.style.opacity="0.4"},fr=(te,Ie)=>{Lt.current=Ie,Ht.current=null,te.dataTransfer.effectAllowed="move",te.dataTransfer.setData("text/plain",`req:${Ie.id}`),te.currentTarget.style.opacity="0.4"},rr=te=>{te.currentTarget.style.opacity="1",Ht.current=null,Lt.current=null,we(null)},Vr=(te,Ie)=>{te.preventDefault(),te.dataTransfer.dropEffect="move",Xt!==Ie&&we(Ie)},oe=(te,Ie)=>{const Ye=te.currentTarget.getBoundingClientRect(),{clientX:J,clientY:pe}=te;(J<Ye.left||J>Ye.right||pe<Ye.top||pe>Ye.bottom)&&Xt===Ie&&we(null)},ke=async(te,Ie)=>{te.preventDefault(),we(null);const Ye=Ht.current,J=Lt.current;if(Ye){const pe=Bo.find(Me=>Me.id===Ie);if(!pe)return;const Ee=pe.dropStatus;if(Ye.status===Ee||Ye.status==="pending")return;try{await re.tasks.updateStatus(Ye.id,Ee),ie()}catch{}}else if(J){const pe=ON[Ie];if(!pe||J.status===pe)return;try{await re.requirements.updateStatus(J.id,pe),We()}catch{}}},Be=te=>{_t(Ie=>{const Ye=new Set(Ie);return Ye.has(te)?Ye.delete(te):Ye.add(te),Ye})},Dt=te=>{Te(Ie=>{const Ye=new Set(Ie);return Ye.has(te)?Ye.delete(te):Ye.add(te),Ye})},Jn=1440*60*1e3,Dn=Date.now(),En=te=>te.updatedAt&&Dn-new Date(te.updatedAt).getTime()>Jn,ss=te=>(te.status==="completed"||te.status==="cancelled")&&En(te),Os=(te,Ie=!1)=>{let Ye=te.filter(J=>Ze||Ie||!ss(J));return m==="project"&&g&&(Ye=Ye.filter(J=>J.projectId===g)),se.size>0&&(Ye=Ye.filter(J=>J.projectId&&se.has(J.projectId))),et.size>0&&(Ye=Ye.filter(J=>J.assignedAgentId&&et.has(J.assignedAgentId))),Ye},as=te=>te.statuses.flatMap(Ie=>Os(p[Ie]??[])),Fr=v.useMemo(()=>{let te=O;return Ze||(te=te.filter(Ie=>!ss(Ie))),m==="project"&&g&&(te=te.filter(Ie=>Ie.projectId===g)),se.size>0&&(te=te.filter(Ie=>Ie.projectId&&se.has(Ie.projectId))),et.size>0&&(te=te.filter(Ie=>et.has(Ie.createdBy))),te},[O,Ze,m,g,se,et]),Un=v.useCallback(te=>Fr.filter(Ie=>MN[Ie.status]===te.id),[Fr]),Rs=Bo.filter(te=>{if(te.id==="failed"||te.id==="closed"){const Ie=as(te),Ye=Un(te);return Ie.length+Ye.length>0}return!0}),Ln=Object.values(p).flat().filter(te=>ss(te)).length+O.filter(te=>ss(te)).length,Yr=v.useMemo(()=>{const te=new Set(["completed","failed","cancelled","archived"]),Ie=Object.values(p).flat(),Ye=new Set;for(const J of Ie)J.assignedAgentId&&!te.has(J.status)&&(!g||J.projectId===g)&&Ye.add(J.assignedAgentId);return[...w].sort((J,pe)=>{const Ee=Ye.has(J.id)?0:1,Me=Ye.has(pe.id)?0:1;return Ee-Me})},[w,p,g]),br=v.useMemo(()=>{const te=new Set(["completed","failed","cancelled","archived"]),Ie=Object.values(p).flat(),Ye=new Set;for(const J of Ie)J.projectId&&!te.has(J.status)&&Ye.add(J.projectId);return[...c].sort((J,pe)=>{const Ee=Ye.has(J.id)?0:1,Me=Ye.has(pe.id)?0:1;return Ee-Me})},[c,p]),Mr=v.useMemo(()=>{const te={};for(const Ie of Object.values(p))for(const Ye of Ie){const J=Ye.projectId??"__none__";te[J]=(te[J]??0)+1}return te},[p]),sr=Object.values(Mr).reduce((te,Ie)=>te+Ie,0);if(S)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"});const Gr=!!(Ae||Xe);return t.jsxs("div",{className:"flex-1 overflow-hidden flex bg-surface-secondary",children:[t.jsxs("div",{className:`${n?"flex-1 min-w-0":Gr?"shrink-0":"flex-1"} overflow-hidden flex flex-col bg-surface-secondary`,style:n?l?{display:"none"}:void 0:Gr?{width:`calc(100% - ${s.width}px - 4px)`}:void 0,children:[D&&t.jsx("div",{className:"mx-6 mt-2 px-3 py-1.5 bg-green-500/15 text-green-600 text-xs rounded-lg",children:D}),n?t.jsxs("div",{className:"border-b border-border-default bg-surface-secondary/80 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 h-11",children:[yn?t.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-semibold text-fg-primary truncate",children:yn.name}),t.jsx("button",{onClick:()=>K(!z),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors shrink-0 ${z?"bg-surface-overlay text-fg-primary":"text-fg-tertiary"}`,children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]}):t.jsx("h2",{className:"text-sm font-semibold text-fg-primary min-w-0 flex-1 truncate",children:c.length===1?c[0].name:`${c.length} Projects`}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx("button",{onClick:()=>V(!0),className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Project"}),t.jsx("button",{onClick:U,className:"px-2 py-1 text-[11px] bg-brand-600 text-white rounded-md",children:"+ Req"}),t.jsx("button",{onClick:()=>{Z(g??""),T(!0)},className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Task"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 px-3 h-9 border-t border-border-default/40",children:[t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(te=>t.jsx("button",{onClick:()=>Pe(te),className:`px-2 py-0.5 text-[10px] font-medium transition-colors ${De===te?"bg-brand-600/25 text-brand-500":"text-fg-tertiary"}`,children:te==="backlog"?"Backlog":te==="kanban"?"Kanban":"DAG"},te))}),Ln>0&&t.jsx("button",{onClick:()=>mt(te=>!te),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Ze?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary"}`,children:Ze?"Hide archived":`${Ln} archived`}),t.jsx("div",{className:"flex-1"}),(se.size>0||et.size>0||c.length>1||w.length>0)&&t.jsxs("button",{onClick:()=>ln(!0),className:`px-2 py-1 text-[11px] rounded-md font-medium transition-colors flex items-center gap-1 ${se.size>0||et.size>0?"bg-brand-600/20 text-brand-500 ring-1 ring-brand-500/30":"border border-border-default text-fg-secondary"}`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),"Filter",se.size+et.size>0?` (${se.size+et.size})`:""]})]})]}):t.jsxs("div",{className:"flex items-center gap-3 px-6 h-14 border-b border-border-default bg-surface-secondary/80 shrink-0",children:[yn?t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(AI,{value:yn.name,onSave:async te=>{await re.projects.update(yn.id,{name:te}),Nn()},className:"text-sm font-semibold text-fg-primary"}),t.jsx("button",{onClick:()=>K(!z),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors ${z?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:"Project settings",children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]}):t.jsx("h2",{className:"text-sm font-semibold text-fg-primary shrink-0",children:c.length===1?c[0].name:`${c.length} Projects`}),Ln>0&&t.jsx("button",{onClick:()=>mt(te=>!te),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Ze?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary hover:text-fg-secondary"}`,children:Ze?`Hide ${Ln} archived`:`${Ln} archived`}),t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(te=>t.jsx("button",{onClick:()=>Pe(te),className:`px-2.5 py-1 text-[10px] font-medium transition-colors ${De===te?"bg-brand-600/25 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:te==="backlog"?"Backlog":te==="kanban"?"Kanban":"DAG"},te))}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("button",{onClick:U,className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg font-medium transition-colors",children:"+ Requirement"}),t.jsx("button",{onClick:()=>{Z(g??""),T(!0)},className:"px-3 py-1.5 border border-border-default hover:bg-surface-elevated text-fg-secondary text-xs rounded-lg font-medium transition-colors",children:"+ Task"})]}),t.jsx("div",{className:"flex-1"})]}),!n&&c.length>1&&!g&&!z&&(sr>0||O.length>0)&&t.jsxs("div",{className:"px-6 py-1.5 border-b border-border-default/60 flex items-center gap-1.5 overflow-x-auto scrollbar-hide shrink-0",children:[t.jsx("button",{onClick:()=>Te(new Set),className:`text-[10px] text-fg-tertiary hover:text-fg-secondary px-2 py-1 rounded-md bg-surface-elevated/60 hover:bg-surface-overlay shrink-0 transition-all ${se.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),br.map(te=>{const Ie=se.has(te.id),Ye=Mr[te.id]??0;return t.jsxs("button",{onClick:()=>Dt(te.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${Ie?"bg-brand-500/15 text-brand-600 ring-1 ring-brand-500/30":"text-fg-tertiary hover:bg-surface-elevated hover:text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-sm flex items-center justify-center text-[9px] font-bold shrink-0 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:te.name[0]?.toUpperCase()}),te.name,Ye>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary ml-0.5",children:Ye})]},te.id)})]}),!n&&w.length>0&&!z&&(sr>0||O.length>0)&&t.jsxs("div",{className:"px-6 py-1.5 border-b border-border-default/60 flex items-center gap-1.5 overflow-x-auto scrollbar-hide shrink-0",children:[t.jsx("button",{onClick:()=>_t(new Set),className:`text-[10px] text-fg-tertiary hover:text-fg-secondary px-2 py-1 rounded-md bg-surface-elevated/60 hover:bg-surface-overlay shrink-0 transition-all ${et.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),Yr.map(te=>{const Ie=et.has(te.id);return t.jsxs("button",{onClick:()=>Be(te.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${Ie?"bg-brand-600/20 text-brand-500 ring-1 ring-brand-500/40":"text-fg-tertiary hover:bg-surface-elevated hover:text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-full flex items-center justify-center text-[9px] font-bold shrink-0 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:te.name[0]?.toUpperCase()}),te.name]},te.id)})]}),z&&yn?t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(VI,{project:yn,tasks:Object.values(p).flat(),requirements:O,agents:w,onDeleteProject:()=>gr(yn.id),onUpdateProject:async te=>{await re.projects.update(yn.id,te)},onRefresh:()=>{Nn()}})}):sr===0&&Fr.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:t.jsxs("div",{className:"max-w-sm w-full text-center space-y-3",children:[t.jsx("div",{className:"w-10 h-10 mx-auto rounded-lg bg-surface-elevated flex items-center justify-center",children:t.jsx("span",{className:"text-fg-tertiary text-lg",children:"☐"})}),t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"No items yet"}),t.jsxs("p",{className:"text-xs text-fg-tertiary leading-relaxed",children:["Create a requirement to tell agents what you need.",t.jsx("br",{}),"Once approved, tasks will appear here automatically."]}),t.jsx("button",{onClick:U,className:"text-xs text-brand-500 hover:text-brand-500 font-medium",children:"+ Create a requirement"})]})}):De==="backlog"?t.jsx(WI,{tasks:Os(Object.values(p).flat()),requirements:Fr,agents:w,projects:c,onTaskClick:te=>Ct(te),onReqClick:te=>dt(te),onRefresh:()=>{ie(),We()},selectedTaskId:Ae?.id,selectedReqId:Xe?.id}):De==="dag"?t.jsx(TI,{tasks:Os(Object.values(p).flat(),!0),requirements:Fr,agents:w,showArchived:Ze,onShowArchivedChange:mt,onTaskClick:te=>Ct(te),onReqClick:te=>dt(te),onDependencyChange:ie,selectedTaskId:Ae?.id,selectedReqId:Xe?.id}):t.jsx("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden px-4 py-5",children:t.jsx("div",{className:"flex gap-3 h-full",children:Rs.map(te=>{const Ie=as(te),Ye=Un(te),J=Ie.length+Ye.length,pe=Xt===te.id;return t.jsxs("div",{className:`w-[280px] shrink-0 rounded-xl flex flex-col h-full transition-colors ${pe?"bg-surface-elevated/60 ring-1 ring-brand-500/30":"bg-surface-secondary/50"}`,onDragOver:Ee=>Vr(Ee,te.id),onDragLeave:Ee=>oe(Ee,te.id),onDrop:Ee=>{ke(Ee,te.id)},children:[t.jsxs("div",{className:"flex justify-between items-center px-3 py-2.5 shrink-0 border-b border-border-default/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${te.accent.replace("border-t-","bg-")}`}),t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:te.label})]}),t.jsx("span",{className:"text-[11px] text-fg-tertiary font-medium tabular-nums",children:J})]}),t.jsx("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto scrollbar-thin px-2 py-2",children:(()=>{const Ee=[...Ye.map(Me=>({kind:"req",data:Me,time:new Date(Me.updatedAt??Me.createdAt).getTime()})),...Ie.map(Me=>({kind:"task",data:Me,time:new Date(Me.updatedAt??Me.createdAt??0).getTime()}))];return Ee.sort((Me,Ce)=>Ce.time-Me.time),Ee.map(Me=>{if(Me.kind==="req"){const Ce=Me.data,Ge=Ho[Ce.status]??{label:Ce.status,cls:"bg-gray-500/15 text-fg-secondary"},Nt=Ce.source==="agent"&&Ce.status==="pending",ut=m==="all"&&Ce.projectId?c.find(Ut=>Ut.id===Ce.projectId):null,st=xi(Ce.createdBy,w,C)??Ce.createdBy.slice(0,10),Et=Xe?.id===Ce.id;return t.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:Ut=>fr(Ut,Ce),onDragEnd:rr,onClick:()=>dt(Ce),onKeyDown:Ut=>Ut.key==="Enter"&&dt(Ce),className:`group rounded-lg p-2.5 border border-transparent transition-all cursor-grab active:cursor-grabbing
62
- ${Nt?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15":"bg-surface-elevated/80 hover:bg-surface-elevated border-border-default/50 hover:border-brand-400/40"}
63
- ${Et?"ring-2 ring-brand-500/50 border-brand-500/40":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:"w-1 h-1 rounded-full bg-purple-500 shrink-0"}),t.jsx("span",{className:"text-[10px] font-semibold text-purple-500 uppercase tracking-wide shrink-0",children:"REQ"}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md shrink-0 ml-auto ${Ge.cls}`,children:Ge.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:Ce.title}),Ce.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Ce.description}),t.jsxs("div",{className:"flex items-center justify-between mt-auto pt-1.5 border-t border-border-default/20",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[ut&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded truncate max-w-[90px]",title:ut.name,children:ut.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Ce.priority}),t.jsxs("span",{className:"text-[10px] text-fg-quaternary",children:["by ",st]})]}),t.jsx("div",{className:"flex items-center gap-1",children:Ce.taskIds.length>0&&t.jsxs("span",{className:"text-[10px] text-brand-500/70 bg-brand-500/8 px-1.5 py-0.5 rounded-md",children:["📋 ",Ce.taskIds.length]})})]}),Nt&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-amber-500/15",children:[t.jsx("button",{onClick:Ut=>{Ut.stopPropagation(),ur(Ce.id)},className:"flex-1 py-1 bg-green-600 hover:bg-green-500 text-white text-[10px] rounded-md font-medium transition-colors",children:"Approve"}),t.jsx("button",{onClick:Ut=>{Ut.stopPropagation(),rt(Ce.id)},className:"flex-1 py-1 border border-red-500/30 hover:bg-red-500/10 text-red-500 text-[10px] rounded-md font-medium transition-colors",children:"Reject"})]})]},`req-${Ce.id}`)}else{const Ce=Me.data,Ge=Ce.subtasks?.length??0,Ue=AN[Ce.status],Nt=Ce.status==="pending",ut=Ce.taskType==="scheduled"&&!!Ce.scheduleConfig,st=ut?Ce.scheduleConfig.every?`Every ${Ce.scheduleConfig.every}`:Ce.scheduleConfig.cron?"Cron":"Scheduled":null,Et=m==="all"&&Ce.projectId?c.find(it=>it.id===Ce.projectId)?.name:null,Ut=Ce.requirementId?O.find(it=>it.id===Ce.requirementId)?.title:null,jn=Ce.createdBy?xi(Ce.createdBy,w,C)??Ce.createdBy:null,$n=Ae?.id===Ce.id,jt={urgent:"bg-red-500",high:"bg-amber-500",medium:"bg-blue-500",low:"bg-gray-400"};return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":Ce.title,draggable:!Nt,onDragStart:it=>!Nt&&qr(it,Ce),onDragEnd:rr,onClick:()=>Ct(Ce),onKeyDown:it=>it.key==="Enter"&&Ct(Ce),className:`group rounded-lg p-2.5 border border-transparent transition-all ${Nt?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15 cursor-pointer":ut?"bg-blue-500/[0.04] border-blue-500/20 hover:border-blue-400/40 cursor-pointer":"bg-surface-elevated/80 hover:bg-surface-elevated border-border-default/50 hover:border-brand-400/40 cursor-grab active:cursor-grabbing"} ${$n?"ring-2 ring-brand-500/50 border-brand-500/40":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${jt[Ce.priority]??"bg-gray-400"}`,title:Ce.priority}),ut&&t.jsx("span",{className:"text-blue-500 shrink-0",title:st??"Scheduled",children:t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})}),ut&&st&&t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-blue-500/10 text-blue-500 whitespace-nowrap",children:st}),Ue&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md ml-auto shrink-0 ${Ue.cls}`,children:Ue.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:Ce.title}),Ce.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Ce.description}),(Et||Ut||Ce.blockedBy&&Ce.blockedBy.length>0)&&t.jsxs("div",{className:"flex flex-wrap gap-1 mb-1.5",children:[Et&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded-md truncate max-w-[100px]",title:Et,children:Et}),Ut&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/8 text-brand-500 rounded-md truncate max-w-[110px]",title:Ut,children:["# ",Ut]}),Ce.blockedBy&&Ce.blockedBy.length>0&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/10 text-amber-600 rounded-md",children:["⏳ ",Ce.blockedBy.length," dep",Ce.blockedBy.length>1?"s":""]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-auto pt-1.5 border-t border-border-default/20",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:jn&&t.jsxs("span",{className:"text-[10px] text-fg-quaternary",title:`by ${jn}`,children:["by ",jn]})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[Ge>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["⋮ ",Ge]}),Ce.notes&&Ce.notes.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["📝 ",Ce.notes.length]}),Ce.assignedAgentId&&t.jsxs("span",{className:"text-[10px] text-brand-500 bg-brand-500/8 px-1.5 py-0.5 rounded-md flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${_N[w.find(it=>it.id===Ce.assignedAgentId)?.status??""]??"bg-gray-500"}`}),w.find(it=>it.id===Ce.assignedAgentId)?.name??Ce.assignedAgentId.slice(0,8)]})]})]})]},Ce.id)}})})()}),pe&&t.jsx("div",{className:"mx-2 mb-2 border-2 border-dashed border-brand-500/25 rounded-lg h-10 flex items-center justify-center shrink-0",children:t.jsx("span",{className:"text-[11px] text-brand-500/50",children:"Drop here"})})]},te.id)})})})]}),!n&&Gr&&t.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-border-default/40 hover:bg-brand-500/30 active:bg-brand-500/50 transition-colors",onMouseDown:s.onResizeStart}),(!n||l)&&Gr&&t.jsx("div",{className:`${n?"flex-1":"shrink-0"} overflow-hidden min-w-0 border-l border-border-default`,style:n?void 0:{width:s.width},children:Ae?t.jsx(qI,{task:Ae,agents:w,projects:c,requirements:O,allTasks:Object.values(p).flat(),users:C,onClose:zt,onRefresh:nr,authUser:e}):Xe?t.jsx(JI,{req:Xe,agents:w,projects:c,allTasks:Object.values(p).flat(),users:C,onClose:zt,onApprove:te=>{ur(te),zt()},onReject:te=>{rt(te),zt()},onCancel:te=>{gs(te),zt()},onStatusChange:async(te,Ie)=>{try{await re.requirements.updateStatus(te,Ie),Mt(`Requirement status → ${Ie}`),We(),ie()}catch(Ye){Mt(`Error: ${Ye}`)}},onRefresh:We,authUser:e}):null}),G&&t.jsx(EN,{orgId:e?.orgId,onCreated:Rn,onClose:()=>V(!1)}),E&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>T(!1),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 max-h-[90dvh] overflow-y-auto ${n?"w-full":"w-[28rem]"}`,onClick:te=>te.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"New Task"}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Project"}),t.jsxs("select",{value:H,onChange:te=>Z(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"No Project"}),c.map(te=>t.jsx("option",{value:te.id,children:te.name},te.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Requirement"}),t.jsxs("select",{value:ee,onChange:te=>ne(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a requirement…"}),O.filter(te=>te.status==="in_progress"&&(!H||te.projectId===H)).map(te=>t.jsx("option",{value:te.id,children:te.title},te.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{autoFocus:!n,value:L,onChange:te=>A(te.target.value),onKeyDown:te=>{te.key==="Enter"&&pr()},className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:P,onChange:te=>q(te.target.value),rows:2,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none resize-none"})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Priority"}),t.jsxs("select",{value:W,onChange:te=>B(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-fg-secondary mb-1.5",children:["Assign to ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:F,onChange:te=>X(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select agent…"}),w.map(te=>t.jsx("option",{value:te.id,children:te.name},te.id))]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-fg-secondary mb-1.5",children:["Reviewer ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:I,onChange:te=>M(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select reviewer…"}),w.filter(te=>te.id!==F).map(te=>t.jsx("option",{value:te.id,children:te.name},te.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Task Type"}),t.jsxs("select",{value:Ne,onChange:te=>Le(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"standard",children:"Standard"}),t.jsx("option",{value:"scheduled",children:"Scheduled (recurring)"})]})]}),Ne==="scheduled"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Frequency"}),t.jsxs("select",{value:ye,onChange:te=>je(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"30m",children:"Every 30 min"}),t.jsx("option",{value:"1h",children:"Every 1 hour"}),t.jsx("option",{value:"2h",children:"Every 2 hours"}),t.jsx("option",{value:"4h",children:"Every 4 hours"}),t.jsx("option",{value:"8h",children:"Every 8 hours"}),t.jsx("option",{value:"12h",children:"Every 12 hours"}),t.jsx("option",{value:"1d",children:"Every day"}),t.jsx("option",{value:"1w",children:"Every week"})]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Blocked By (dependencies)"}),t.jsxs("select",{value:"",onChange:te=>{const Ie=te.target.value;Ie&&!ae.includes(Ie)&&he([...ae,Ie])},className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a task to depend on…"}),Object.values(p).flat().filter(te=>te.status!=="completed"&&te.status!=="cancelled"&&!ae.includes(te.id)).map(te=>t.jsx("option",{value:te.id,children:te.title},te.id))]}),ae.length>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ae.map(te=>{const Ie=Object.values(p).flat().find(Ye=>Ye.id===te);return t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-2 py-1 bg-amber-500/10 text-amber-600 rounded-full",children:["⏳ ",Ie?Ie.title.slice(0,30):te.slice(-8),t.jsx("button",{onClick:()=>he(ae.filter(Ye=>Ye!==te)),className:"ml-0.5 text-amber-600/60 hover:text-amber-600",children:"×"})]},te)})})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:()=>{pr()},disabled:!F||!I,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Create"})]})]})}),At&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>{St(!1),tn(""),Ve("")},children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 max-h-[90dvh] overflow-y-auto ${n?"w-full":"w-[28rem]"}`,onClick:te=>te.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"New Requirement"}),t.jsx("p",{className:"text-xs text-fg-tertiary -mt-2",children:"Describe what you need. Agents will break approved requirements into tasks."}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Project"}),t.jsxs("select",{value:vt,onChange:te=>sn(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a project…"}),c.map(te=>t.jsx("option",{value:te.id,children:te.name},te.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{value:en,onChange:te=>tn(te.target.value),placeholder:"e.g. Add user authentication",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",autoFocus:!n,onKeyDown:te=>{te.key==="Enter"&&en.trim()&&dr()}})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:ve,onChange:te=>Ve(te.target.value),placeholder:"What is needed and why...",rows:3,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Priority"}),t.jsxs("select",{value:Rt,onChange:te=>Pt(te.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>{St(!1),tn(""),Ve("")},className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:()=>{dr()},disabled:!en.trim()||!ve.trim()||!vt,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-40 disabled:cursor-not-allowed",children:"Create"})]})]})}),gn&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>rt(null),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 ${n?"w-full":"w-96"}`,onClick:te=>te.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Reject Requirement"}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Reason"}),t.jsx("textarea",{value:Wt,onChange:te=>Mn(te.target.value),placeholder:"Why is this being rejected...",rows:3,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-red-500 outline-none resize-none",autoFocus:!n})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>rt(null),className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:()=>{vn()},className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 rounded-lg text-white",children:"Reject"})]})]})}),Kt&&t.jsxs("div",{className:"fixed inset-0 z-[60] flex flex-col justify-end",onClick:()=>ln(!1),children:[t.jsx("div",{className:"absolute inset-0 bg-black/50"}),t.jsxs("div",{className:"relative bg-surface-secondary rounded-t-2xl border-t border-border-default max-h-[70vh] overflow-y-auto pb-16",onClick:te=>te.stopPropagation(),children:[t.jsxs("div",{className:"sticky top-0 bg-surface-secondary z-10 px-4 pt-3 pb-2 flex items-center justify-between border-b border-border-default/60",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:"Filters"}),t.jsxs("div",{className:"flex items-center gap-2",children:[(se.size>0||et.size>0)&&t.jsx("button",{onClick:()=>{Te(new Set),_t(new Set)},className:"text-[11px] text-brand-500 font-medium",children:"Clear all"}),t.jsx("button",{onClick:()=>ln(!1),className:"w-7 h-7 flex items-center justify-center rounded-full bg-surface-elevated text-fg-tertiary",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),c.length>1&&t.jsxs("div",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-[11px] text-fg-tertiary font-medium uppercase tracking-wider mb-2",children:"Projects"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:br.map(te=>{const Ie=se.has(te.id),Ye=Mr[te.id]??0;return t.jsxs("button",{onClick:()=>Dt(te.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${Ie?"bg-brand-500/15 text-brand-600 ring-1 ring-brand-500/30":"bg-surface-elevated text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-sm flex items-center justify-center text-[9px] font-bold shrink-0 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:te.name[0]?.toUpperCase()}),te.name,Ye>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary",children:Ye})]},te.id)})})]}),w.length>0&&t.jsxs("div",{className:"px-4 py-3 border-t border-border-default/40",children:[t.jsx("div",{className:"text-[11px] text-fg-tertiary font-medium uppercase tracking-wider mb-2",children:"Agents"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Yr.map(te=>{const Ie=et.has(te.id);return t.jsxs("button",{onClick:()=>Be(te.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${Ie?"bg-brand-600/20 text-brand-500 ring-1 ring-brand-500/40":"bg-surface-elevated text-fg-secondary"}`,children:[t.jsx("span",{className:`w-4 h-4 rounded-full flex items-center justify-center text-[9px] font-bold shrink-0 ${Ie?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:te.name[0]?.toUpperCase()}),te.name]},te.id)})})]}),t.jsx("div",{className:"h-[env(safe-area-inset-bottom,0px)]"})]})]})]})}function QI({requirementId:e,agents:n,authUser:s}){const[l,o]=v.useState([]);v.useEffect(()=>{re.requirements.getComments(e).then(f=>o(f.comments)).catch(()=>{})},[e]),v.useEffect(()=>xn.on("requirement:comment",g=>{g.payload?.requirementId===e&&g.payload.comment&&o(x=>x.some(p=>p.id===g.payload.comment.id)?x:[...x,g.payload.comment])}),[e]);const[d,c]=v.useState(null),h=async(f,g,x)=>{await re.requirements.addComment(e,f,s?.name,s?.id,g.length>0?g:void 0,x)},m=v.useCallback(f=>{c({id:f.id,authorName:f.authorName,content:f.content.slice(0,100)})},[]);return t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 block",children:["Comments ",l.length>0&&t.jsxs("span",{className:"font-normal",children:["(",l.length,")"]})]}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[l.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary text-center py-4",children:"No comments yet."}),l.map(f=>t.jsx(Co,{comment:f,agents:n,onReply:m},f.id))]}),t.jsx(Sj,{agents:n,onSubmit:h,replyTo:d,onCancelReply:()=>c(null)})]})}function JI({req:e,agents:n,projects:s,allTasks:l,users:o,onClose:d,onApprove:c,onReject:h,onCancel:m,onStatusChange:f,onRefresh:g,authUser:x}){const p=_s(),[y,w]=v.useState(!1),[N,C]=v.useState(e.description),[_,O]=v.useState(!1),k=Ho[e.status]??{label:e.status,cls:"bg-gray-500/15 text-fg-secondary"},S=e.source==="agent",R=S&&e.status==="pending",D=e.status==="pending"||e.status==="in_progress",Y=e.status==="completed"||e.status==="rejected"||e.status==="cancelled",z=e.projectId?s.find(G=>G.id===e.projectId):null,K=xi(e.createdBy,n,o)??e.createdBy.slice(0,12),U=l.filter(G=>e.taskIds.includes(G.id));return v.useEffect(()=>{C(e.description),w(!1)},[e.id,e.description]),t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 p-5 pb-0 border-b border-border-default",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[p&&t.jsx("button",{onClick:d,className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{className:"flex-1 min-w-0 pb-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-[10px] font-bold text-brand-500 bg-brand-500/15 px-2 py-0.5 rounded",children:"REQ"}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full font-medium ${k.cls}`,children:k.label}),e.priority==="high"||e.priority==="urgent"?t.jsx("span",{className:`text-[10px] font-medium ${e.priority==="urgent"?"text-red-500":"text-amber-600"}`,children:e.priority}):t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.priority})]}),t.jsx("h2",{className:"text-lg font-semibold text-fg-primary leading-snug",children:e.title})]})]}),!p&&t.jsx("button",{onClick:d,className:"text-fg-tertiary hover:text-fg-secondary text-xl leading-none shrink-0 mt-1",children:"×"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1 block",children:"Description"}),y?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:N,onChange:G=>C(G.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-y min-h-[80px]",rows:4,autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{w(!1),C(e.description)},className:"px-2.5 py-1 text-xs border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:async()=>{O(!0);try{await re.requirements.update(e.id,{description:N}),w(!1),g?.()}catch{}finally{O(!1)}},disabled:_,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Save"})]})]}):t.jsxs("div",{className:"group relative",children:[e.description?t.jsx(tr,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),!Y&&t.jsx("button",{onClick:()=>{C(e.description),w(!0)},className:"absolute top-0 right-0 text-[10px] text-fg-tertiary hover:text-brand-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Edit"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Created by"}),t.jsx("span",{className:"text-fg-secondary",children:K}),S&&t.jsx("span",{className:"text-[10px] text-brand-500 ml-1.5",children:"(Agent)"})]}),t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Created"}),t.jsx("span",{className:"text-fg-secondary",children:new Date(e.createdAt).toLocaleString()})]}),z&&t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Project"}),t.jsx("span",{className:"text-fg-secondary",children:z.name})]}),e.approvedBy&&t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Approved by"}),t.jsx("span",{className:"text-fg-secondary",children:xi(e.approvedBy,n,o)??e.approvedBy.slice(0,12)}),e.approvedAt&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-1",children:new Date(e.approvedAt).toLocaleDateString()})]})]}),e.rejectedReason&&t.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsx("span",{className:"text-[10px] font-semibold text-red-500 uppercase tracking-wider block mb-1",children:"Rejection Reason"}),t.jsx("p",{className:"text-sm text-red-500/80",children:e.rejectedReason})]}),Array.isArray(e.tags)&&e.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(G=>t.jsxs("span",{className:"text-[10px] bg-surface-elevated text-fg-secondary px-2 py-0.5 rounded-full",children:["#",G]},G))}),U.length>0&&t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 block",children:["Linked Tasks (",U.length,")"]}),t.jsx("div",{className:"space-y-1.5",children:U.map(G=>{const V=AN[G.status];return t.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated/60 rounded-lg px-3 py-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${LI[G.priority]?.replace("border-l-","bg-")??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:G.title}),V&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${V.cls}`,children:V.label})]},G.id)})})]}),t.jsx(QI,{requirementId:e.id,agents:n,authUser:x})]}),t.jsxs("div",{className:"flex items-center gap-2 p-5 pt-3 border-t border-border-default",children:[R&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>c(e.id),className:"px-4 py-2 bg-green-600 hover:bg-green-500 text-white text-sm rounded-lg font-medium transition-colors",children:"Approve"}),t.jsx("button",{onClick:()=>h(e.id),className:"px-4 py-2 border border-red-500/30 hover:bg-red-500/10 text-red-500 text-sm rounded-lg font-medium transition-colors",children:"Reject"})]}),!R&&f&&!Y&&t.jsx("select",{value:e.status,onChange:G=>{G.target.value!==e.status&&f(e.id,G.target.value)},className:"px-2 py-1.5 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-secondary cursor-pointer hover:border-gray-500 transition-colors",children:XI.map(G=>{const V=Ho[G];return t.jsx("option",{value:G,children:V?.label??G},G)})}),Y&&f&&t.jsx("button",{onClick:()=>f(e.id,"in_progress"),className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary transition-colors",children:"Reopen"}),t.jsx("div",{className:"flex-1"}),D&&!R&&t.jsx("button",{onClick:()=>m(e.id),className:"px-3 py-1.5 text-xs text-red-500/70 hover:text-red-500 hover:bg-red-500/10 border border-transparent hover:border-red-500/20 rounded-lg transition-colors",children:"Cancel Requirement"})]})]})}function js(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"&&e?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function ez(e){return e.files&&typeof e.files=="object"&&!Array.isArray(e.files)?e.files:null}function sl({label:e,value:n}){return n?t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:e}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:n})]}):null}function Kl({label:e,value:n,color:s}){if(!n)return null;const l={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:e}),t.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${l[s]??l.gray} capitalize inline-block`,children:n})]})}function rm({files:e}){const[n,s]=v.useState(Object.keys(e)[0]??""),l=Object.keys(e);return l.length===0?null:t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Files (",l.length,")"]}),t.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[t.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:l.map(o=>t.jsx("button",{onClick:()=>s(o),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${n===o?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o},o))}),n&&e[n]!=null&&t.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:e[n]})]})]})}function tz({artifact:e,mode:n}){const s=ez(e),l=e.agent,o=e.team,d=e.dependencies,c=e.displayName??e.name;if(n==="agent"){const h=l?.roleName,m=l?.agentRole,f=l?.llmProvider,g=l?.llmModel,x=js(d?.env),p=js(d?.skills);return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(sl,{label:"Name",value:c}),t.jsx(sl,{label:"Description",value:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Kl,{label:"Role Template",value:h,color:"indigo"}),t.jsx(Kl,{label:"Agent Role",value:m,color:m==="manager"?"purple":"cyan"})]}),js(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:js(e.tags).map(y=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:y},y))}),(f||g)&&t.jsxs("div",{className:"flex gap-2",children:[f&&t.jsx(Kl,{label:"LLM Provider",value:f,color:"gray"}),g&&t.jsx(Kl,{label:"LLM Model",value:g,color:"gray"})]}),x.length>0&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Required Env"}),t.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:x.map(y=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:y},y))})]}),p.length>0&&t.jsx(sl,{label:"Skills",value:p.join(", ")}),s&&t.jsx(rm,{files:s})]})}if(n==="team"){const m=o?.members??[];return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(sl,{label:"Name",value:c}),t.jsx(sl,{label:"Description",value:e.description}),t.jsx("div",{className:"flex flex-wrap gap-2",children:t.jsx(Kl,{label:"Category",value:e.category,color:"indigo"})}),js(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:js(e.tags).map(f=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:f},f))}),s&&t.jsx(rm,{files:s}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Members (",m.length,")"]}),t.jsx("div",{className:"mt-1.5 space-y-1.5",children:m.map((f,g)=>t.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${f.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:f.role==="manager"?"★":g+1}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:f.name}),typeof f.roleName=="string"&&f.roleName&&t.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:f.roleName}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(f.count??1)]})]}),js(f.skills).length>0&&t.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:js(f.skills).map(x=>t.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:x},x))})]},g))})]})]})}return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(sl,{label:"Name",value:c}),t.jsx(sl,{label:"Description",value:e.description}),t.jsx("div",{className:"flex gap-2",children:t.jsx(Kl,{label:"Category",value:e.category,color:"indigo"})}),s&&t.jsx(rm,{files:s}),js(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:js(e.tags).map(h=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:h},h))})]})}const xo={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Qv={active:{label:"Active",color:"text-green-600 bg-green-500/10"},verified:{label:"Verified",color:"text-blue-600 bg-blue-500/10"},outdated:{label:"Outdated",color:"text-red-500 bg-red-500/10"}},Jv=["file","directory"],ws={agent:{icon:"✦",label:"Agent",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",label:"Team",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",label:"Skill",color:"bg-amber-500/10 text-amber-600"}};function e1(){const e=_s(),n=tu({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[s,l]=v.useState(!1),o=v.useRef(s);o.current=s,v.useEffect(()=>{if(!e)return;const de=()=>{o.current&&l(!1)};return window.addEventListener("popstate",de),()=>window.removeEventListener("popstate",de)},[e]);const d=100,[c,h]=v.useState([]),[m,f]=v.useState(0),[g,x]=v.useState(!1),[p,y]=v.useState([]),[w,N]=v.useState([]),[C,_]=v.useState(!0),[O,k]=v.useState(""),[S,R]=v.useState(""),[D,Y]=v.useState(""),[z,K]=v.useState(""),[U,G]=v.useState(""),[V,E]=v.useState(""),[T,L]=v.useState(""),[A,P]=v.useState("date"),[q,W]=v.useState(null),[B,F]=v.useState(null),[X,I]=v.useState(""),[M,H]=v.useState(!1),[Z,ee]=v.useState(!1),[ne,ae]=v.useState(new Set),he=v.useRef(null),[Ne,Le]=v.useState("file"),[ye,je]=v.useState(""),[Ae,$e]=v.useState(""),[Xe,tt]=v.useState(""),[et,_t]=v.useState(""),[se,Te]=v.useState(""),[nt,yt]=v.useState(null),[Xt,we]=v.useState(null),[De,Pe]=v.useState(!1),[Ze,mt]=v.useState(!1),[Kt,ln]=v.useState(!1),[Ht,Lt]=v.useState(!1),At=v.useRef(null),St=v.useRef(null),[en,tn]=v.useState(""),ve=v.useRef(void 0),Ve=(de,Fe)=>{F({type:de,text:Fe}),setTimeout(()=>F(null),3e3)},Rt=async de=>{try{return await navigator.clipboard.writeText(de),!0}catch{try{const Fe=document.createElement("textarea");Fe.value=de,Fe.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(Fe),Fe.select();const ht=document.execCommand("copy");return document.body.removeChild(Fe),ht}catch{return!1}}},Pt=async de=>{await Rt(de)?(Lt(!0),setTimeout(()=>Lt(!1),1500)):Ve("error","Copy failed — try long-pressing to copy manually")},vt=v.useMemo(()=>new Map(w.map(de=>[de.id,de])),[w]),sn=v.useMemo(()=>new Map(p.map(de=>[de.id,de])),[p]);v.useEffect(()=>{re.projects.list().then(de=>y(de.projects)).catch(()=>{}),re.agents.list().then(de=>N(de.agents??[])).catch(()=>{}),re.system.storage().then(de=>tn(de.dataDir+"/shared")).catch(()=>{})},[]),v.useEffect(()=>(ve.current=setTimeout(()=>R(O),300),()=>clearTimeout(ve.current)),[O]);const gn=v.useMemo(()=>({q:S||void 0,projectId:z||void 0,agentId:U||void 0,type:D||void 0,status:V||void 0,artifactType:T||void 0}),[S,z,U,D,V,T]),rt=v.useCallback(async()=>{_(!0);try{const{results:de,total:Fe}=await re.deliverables.search({...gn,offset:0,limit:d});h(de),f(Fe)}catch{h([]),f(0)}_(!1)},[gn]),Wt=v.useCallback(async()=>{if(!(g||c.length>=m)){x(!0);try{const{results:de,total:Fe}=await re.deliverables.search({...gn,offset:c.length,limit:d});h(ht=>[...ht,...de]),f(Fe)}catch{}x(!1)}},[gn,c.length,m,g]);v.useEffect(()=>{rt()},[rt]),v.useEffect(()=>xn.on("deliverable:created",()=>rt()),[rt]);const Mn=v.useCallback(()=>{const de=he.current;!de||C||g||c.length>=m||de.scrollHeight<=de.clientHeight+100&&Wt()},[C,g,c.length,m,Wt]);v.useEffect(()=>{const de=he.current;if(!de)return;const Fe=()=>{de.scrollTop+de.clientHeight>=de.scrollHeight-100&&Wt()};return de.addEventListener("scroll",Fe,{passive:!0}),()=>de.removeEventListener("scroll",Fe)},[Wt]),v.useEffect(()=>{Mn()},[Mn,ne]);const Mt=v.useMemo(()=>{const de=new Map;for(const ht of c){let Tt,Rn;if(A==="project")Tt=ht.projectId??"_none",Rn=ht.projectId?sn.get(ht.projectId)?.name??ht.projectId:"No Project";else if(A==="agent")Tt=ht.agentId??"_none",Rn=ht.agentId?vt.get(ht.agentId)?.name??ht.agentId:"Unknown";else if(A==="type")Tt=ht.type,Rn=ht.type.charAt(0).toUpperCase()+ht.type.slice(1);else{const gr=new Date(ht.updatedAt);Tt=`${gr.getFullYear()}-${String(gr.getMonth()+1).padStart(2,"0")}-${String(gr.getDate()).padStart(2,"0")}`,Rn=Tt}de.has(Tt)||de.set(Tt,{label:Rn,items:[]}),de.get(Tt).items.push(ht)}const Fe=[...de.entries()];return A==="date"?Fe.sort((ht,Tt)=>Tt[0].localeCompare(ht[0])):Fe.sort((ht,Tt)=>ht[1].label.localeCompare(Tt[1].label)),Fe},[c,A,sn,vt]),yn=async()=>{if(!(!ye.trim()||!Ae.trim())){ee(!0);try{await re.deliverables.create({type:Ne,title:ye,summary:Ae,reference:Xe,projectId:et||void 0,tags:se.split(",").map(de=>de.trim()).filter(Boolean)}),H(!1),Ve("success","Deliverable created"),rt()}catch(de){Ve("error",`Error: ${de}`)}ee(!1)}},Nn=async de=>{I("verify");try{await re.deliverables.verify(de.id),Ve("success","Verified"),W({...de,status:"verified"}),rt()}catch(Fe){Ve("error",`Error: ${Fe}`)}I("")},ie=async de=>{I("flag");try{await re.deliverables.update(de.id,{status:"outdated"}),Ve("success","Flagged as outdated"),W({...de,status:"outdated"}),rt()}catch(Fe){Ve("error",`Error: ${Fe}`)}I("")},qe=async de=>{I("remove");try{await re.deliverables.remove(de.id),Ve("success","Removed"),W(null),rt()}catch(Fe){Ve("error",`Error: ${Fe}`)}I("")},ze=()=>{gt.navigate(ge.BUILDER)},We=async de=>{if(de.reference){if(de.type==="directory"){mt(!0);return}Pe(!0);try{const Fe=await re.files.preview(de.reference);Fe.type==="image"&&Fe.mimeType?we({src:`data:${Fe.mimeType};base64,${Fe.content}`,name:Fe.name}):yt(Fe.content)}catch{yt(null),de.type==="file"&&mt(!0)}Pe(!1)}};v.useEffect(()=>{yt(null),we(null),mt(!1),ln(!1),q&&We(q)},[q?.id]),v.useEffect(()=>{if(!Kt)return;const de=Fe=>{St.current&&!St.current.contains(Fe.target)&&ln(!1)};return document.addEventListener("mousedown",de),()=>document.removeEventListener("mousedown",de)},[Kt]);const lt=async(de,Fe)=>{const ht=At.current?.firstElementChild;if(!ht)return;const Tt=nz(ht,de);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([Tt],{type:"text/html"}),"text/plain":new Blob([Fe],{type:"text/plain"})})]),Ve("success",de==="light"?"HTML (light) copied":"HTML (dark) copied")}catch{const Rn=await Rt(Fe);Ve(Rn?"success":"error",Rn?"Text copied (HTML not supported)":"Copy failed")}ln(!1)},Ct=de=>t.jsxs("div",{className:"relative group/preview",children:[t.jsxs("div",{className:"absolute -top-1 -right-1 z-10",ref:St,children:[t.jsx("button",{onClick:()=>ln(Fe=>!Fe),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:"Copy content",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),Kt&&t.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:[t.jsxs("button",{onClick:async()=>{const Fe=await Rt(de);Ve(Fe?"success":"error",Fe?"Markdown source copied":"Copy failed"),ln(!1)},className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:"Md"}),"Copy Markdown Source"]}),t.jsxs("button",{onClick:()=>lt("light",de),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0",children:"☀️"}),"Copy HTML (Light)"]}),t.jsxs("button",{onClick:()=>lt("dark",de),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0",children:"🌙"}),"Copy HTML (Dark)"]})]})]}),t.jsx("div",{ref:At,children:t.jsx(tr,{content:de,className:"text-fg-secondary text-sm"})})]}),dt=v.useCallback(de=>{ae(Fe=>{const ht=new Set(Fe);return ht.has(de)?ht.delete(de):ht.add(de),ht})},[]),zt=v.useCallback(()=>{ne.size===Mt.length?ae(new Set):ae(new Set(Mt.map(([de])=>de)))},[ne.size,Mt]),pt=()=>{je(""),$e(""),tt(""),Te(""),Le("file"),p.length>0&&_t(p[0].id),H(!0)},on=de=>{W(de),e&&(l(!0),history.pushState({mobileDetail:ge.DELIVERABLES},"",window.location.hash))};return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${e?"flex-1 min-w-0":"shrink-0"} border-r border-border-default flex flex-col bg-surface-primary`,style:e?s?{display:"none"}:void 0:{width:n.width},children:[t.jsxs("div",{className:"p-4 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary",children:["Deliverables",m>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",m,")"]})]}),t.jsx("button",{onClick:pt,className:"text-xs px-2.5 py-1 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create"})]}),t.jsx("input",{value:O,onChange:de=>k(de.target.value),placeholder:"Search deliverables...",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),en&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated/50 border border-border-default rounded-lg text-[10px] text-fg-tertiary",children:[t.jsx("span",{className:"truncate font-mono",children:en}),t.jsx("button",{onClick:()=>{re.system.openPath(en)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:"Open"})]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Ra,{label:"All types",value:"",current:D||T||"",onClick:()=>{Y(""),L("")}}),Jv.map(de=>t.jsx(Ra,{label:`${xo[de]?.icon??""} ${de}`,value:de,current:D,onClick:Fe=>{Y(Fe),L("")}},de)),["agent","team","skill"].map(de=>t.jsx(Ra,{label:`${ws[de].icon} ${ws[de].label}`,value:de,current:T,onClick:Fe=>{L(Fe),Y("")}},de))]}),p.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Ra,{label:"All projects",value:"",current:z,onClick:K}),p.map(de=>t.jsx(Ra,{label:de.name,value:de.id,current:z,onClick:K},de.id))]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Ra,{label:"Active",value:"",current:V,onClick:E}),t.jsx(Ra,{label:"Verified",value:"verified",current:V,onClick:E}),t.jsx(Ra,{label:"Outdated",value:"outdated",current:V,onClick:E})]}),t.jsxs("div",{className:"flex gap-1.5 items-center",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Group:"}),["date","project","agent","type"].map(de=>t.jsx("button",{onClick:()=>{P(de),ae(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${A===de?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:de.charAt(0).toUpperCase()+de.slice(1)},de)),Mt.length>1&&t.jsx("button",{onClick:zt,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:ne.size===Mt.length?"Expand all":"Collapse all",children:ne.size===Mt.length?"▶ Expand":"▼ Collapse"})]})]}),B&&t.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${B.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:B.text}),t.jsxs("div",{ref:he,className:"flex-1 overflow-y-auto p-2 space-y-1",children:[C?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(de=>t.jsxs("div",{className:"animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),t.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},de))}):c.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[t.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),t.jsx("p",{className:"text-sm text-fg-secondary",children:"No deliverables yet"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:"Deliverables are created when tasks complete or manually"}),t.jsx("button",{onClick:pt,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create first"})]}):Mt.map(([de,Fe])=>{const ht=ne.has(de);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>dt(de),className:"w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md hover:bg-surface-elevated/50 transition-colors group/header",children:[t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${ht?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider truncate",children:Fe.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",Fe.items.length,")"]})]}),!ht&&Fe.items.map(Tt=>t.jsxs("button",{onClick:()=>on(Tt),className:`w-full text-left p-3 rounded-lg transition-colors ${q?.id===Tt.id?"bg-brand-600/20 border border-brand-500/30":"hover:bg-surface-elevated/60 border border-transparent"}`,children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:Tt.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[Tt.artifactType&&ws[Tt.artifactType]?t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${ws[Tt.artifactType].color}`,children:[ws[Tt.artifactType].icon," ",ws[Tt.artifactType].label]}):t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium uppercase ${xo[Tt.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:Tt.type}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Qv[Tt.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:Tt.status}),Tt.agentId&&t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:vt.get(Tt.agentId)?.name??"Agent"})]})]},Tt.id))]},de)}),g&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(sm,{})," ",t.jsx("span",{className:"text-[10px]",children:"Loading more..."})]}),!C&&c.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:c.length<m?`${c.length} / ${m} deliverables`:`${m} deliverables`})]})]}),!e&&t.jsx("div",{className:"w-1 shrink-0 cursor-col-resize hover:bg-brand-500/30 active:bg-brand-500/50 transition-colors",onMouseDown:n.onResizeStart}),(!e||s)&&t.jsxs("div",{className:"flex-1 overflow-y-auto min-w-0",children:[e&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary border-b border-border-default px-4 py-2.5 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"text-sm font-medium truncate",children:q?.title??"Details"})]}),q?t.jsxs("div",{className:"p-6 space-y-5",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:q.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[q.status!=="verified"&&t.jsx("button",{onClick:()=>Nn(q),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-green-600/20 text-green-600 hover:bg-green-600/30 disabled:opacity-50 transition-colors",children:X==="verify"?"Verifying...":"Verify"}),q.status!=="outdated"&&t.jsx("button",{onClick:()=>ie(q),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-amber-600/20 text-amber-600 hover:bg-amber-600/30 disabled:opacity-50 transition-colors",children:X==="flag"?"Flagging...":"Flag Outdated"}),t.jsx("button",{onClick:()=>qe(q),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-red-600/20 text-red-500 hover:bg-red-600/30 disabled:opacity-50 transition-colors",children:X==="remove"?"Removing...":"Remove"})]}),t.jsxs("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${xo[q.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[xo[q.type]?.icon??""," ",q.type]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${Qv[q.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:q.status}),q.artifactType&&ws[q.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${ws[q.artifactType].color}`,children:[ws[q.artifactType].icon," Builder ",ws[q.artifactType].label]})]}),q.reference&&(q.type==="file"||q.type==="directory")&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 bg-surface-secondary/60 border border-border-default rounded-lg px-3 py-2",children:[t.jsx("button",{onClick:()=>{re.files.reveal(q.reference).catch(()=>Ve("error","Failed to open file browser"))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:"Open in file browser",children:q.reference}),t.jsx("button",{onClick:()=>{re.files.reveal(q.reference).catch(()=>Ve("error","Failed to open file browser"))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:"Reveal in Finder",children:"Open"}),t.jsx("button",{onClick:()=>Pt(q.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Ht?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:"Copy path to clipboard",children:Ht?"Copied!":"Copy"})]}),q.reference&&q.type!=="file"&&q.type!=="directory"&&t.jsx("div",{className:"mt-2",children:t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:q.reference})})]}),q.artifactType&&q.artifactData?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(tz,{artifact:q.artifactData,mode:q.artifactType})}),q.reference&&t.jsxs("div",{className:"px-3 py-2 bg-surface-secondary/50 border border-border-default rounded-lg",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:"Artifact Directory"}),t.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:q.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:ze,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:"Open in Builder"})}),q.summary&&t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(tr,{content:q.summary,className:"text-fg-secondary text-sm"})})]}):t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:De?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(sm,{})," Loading preview..."]}):Xt?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Xt.src,alt:Xt.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Xt.name})]}):nt?Ct(nt):Ze?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-fg-secondary",children:["This ",q.type," cannot be previewed in the browser."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{re.files.reveal(q.reference).catch(()=>Ve("error","Failed to open"))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:"Open in file browser",children:q.reference}),t.jsx("button",{onClick:()=>{re.files.reveal(q.reference).catch(()=>Ve("error","Failed to open"))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:"Open"}),t.jsx("button",{onClick:()=>Pt(q.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Ht?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:Ht?"Copied!":"Copy"})]})]}):q.summary?Ct(q.summary):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No content"})}),(q.diffStats||q.testResults)&&t.jsxs("div",{className:"flex gap-4 flex-wrap",children:[q.diffStats&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-lg px-4 py-3 text-xs space-y-1",children:[t.jsx("div",{className:"text-fg-tertiary font-medium",children:"Diff Stats"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("span",{className:"text-fg-secondary",children:[q.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-600",children:["+",q.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",q.diffStats.deletions]})]})]}),q.testResults&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-lg px-4 py-3 text-xs space-y-1",children:[t.jsx("div",{className:"text-fg-tertiary font-medium",children:"Tests"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("span",{className:"text-green-600",children:[q.testResults.passed," passed"]}),t.jsxs("span",{className:"text-red-500",children:[q.testResults.failed," failed"]}),t.jsxs("span",{className:"text-fg-secondary",children:[q.testResults.skipped," skipped"]})]})]})]}),q.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:q.tags.map(de=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:de},de))}),t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:"Links"}),t.jsxs("div",{className:"flex gap-3 flex-wrap",children:[q.taskId&&t.jsxs("button",{onClick:()=>gt.navigate(ge.WORK,{openTask:q.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2.5 py-1 rounded",children:["Task: ",q.taskId.slice(0,12),"..."]}),q.agentId&&t.jsxs("button",{onClick:()=>gt.navigate(ge.TEAM,{selectAgent:q.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Agent: ",vt.get(q.agentId)?.name??q.agentId.slice(0,12)]}),q.projectId&&t.jsxs("button",{onClick:()=>gt.navigate(ge.WORK,{projectId:q.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Project: ",sn.get(q.projectId)?.name??q.projectId.slice(0,12)]})]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary space-y-1 border-t border-border-default pt-4",children:[t.jsxs("div",{className:"flex gap-6 flex-wrap",children:[t.jsxs("span",{children:["Created: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(q.createdAt).toLocaleString()})]}),t.jsxs("span",{children:["Updated: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(q.updatedAt).toLocaleString()})]}),t.jsxs("span",{children:["Accessed: ",t.jsxs("span",{className:"text-fg-secondary",children:[q.accessCount,"x"]})]})]}),t.jsxs("div",{className:"text-fg-muted select-all",children:["ID: ",q.id]})]})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center text-fg-tertiary space-y-2",children:[t.jsx("svg",{className:"w-12 h-12 mx-auto text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),t.jsx("p",{className:"text-sm",children:"Select a deliverable to view details"})]})})]}),M&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!Z&&H(!1),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[36rem] space-y-4",onClick:de=>de.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Create Deliverable"}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Type"}),t.jsx("select",{value:Ne,onChange:de=>Le(de.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:Jv.map(de=>t.jsxs("option",{value:de,children:[xo[de]?.icon??""," ",de]},de))})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Title ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{value:ye,onChange:de=>je(de.target.value),placeholder:"Clear, searchable title",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Reference ",t.jsx("span",{className:"text-fg-tertiary",children:"(file path, URL, branch name)"})]}),t.jsx("input",{value:Xe,onChange:de=>tt(de.target.value),placeholder:"/path/to/file or https://...",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors font-mono"})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Summary ",t.jsx("span",{className:"text-red-500",children:"*"})," ",t.jsx("span",{className:"text-fg-tertiary",children:"(Markdown)"})]}),t.jsx("textarea",{value:Ae,onChange:de=>$e(de.target.value),placeholder:"Describe the deliverable...",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary h-36 resize-none focus:border-brand-500 focus:outline-none transition-colors font-mono"})]}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary block mb-1",children:["Tags ",t.jsx("span",{className:"text-fg-tertiary",children:"(comma separated)"})]}),t.jsx("input",{value:se,onChange:de=>Te(de.target.value),placeholder:"react, api, docs",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Project"}),t.jsxs("select",{value:et,onChange:de=>_t(de.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:[t.jsx("option",{value:"",children:"None"}),p.map(de=>t.jsx("option",{value:de.id,children:de.name},de.id))]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1 border-t border-border-default",children:[t.jsx("button",{onClick:()=>H(!1),disabled:Z,className:"text-sm text-fg-tertiary hover:text-fg-secondary disabled:opacity-50 transition-colors py-2",children:"Cancel"}),t.jsxs("button",{onClick:yn,disabled:Z||!ye.trim()||!Ae.trim(),className:"bg-brand-600 hover:bg-brand-500 text-white text-sm px-4 py-2 rounded-lg disabled:opacity-50 flex items-center gap-2 transition-colors",children:[Z&&t.jsx(sm,{}),Z?"Creating...":"Create"]})]})]})})]})}function nz(e,n){const s=e.cloneNode(!0),l=n==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},o={p:`margin:0 0 10px;color:${l.text};line-height:1.7;`,h1:`font-size:1.6em;font-weight:700;color:${l.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${l.border};padding-bottom:6px;`,h2:`font-size:1.35em;font-weight:700;color:${l.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:1.15em;font-weight:600;color:${l.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:1em;font-weight:600;color:${l.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${l.strong};`,em:"font-style:italic;",a:`color:${l.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${l.text};`,blockquote:`border-left:3px solid ${l.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${l.blockquoteText};`,hr:`border:none;border-top:1px solid ${l.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${l.tableHeaderBg};`,th:`border:1px solid ${l.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${l.tableHeaderText};`,td:`border:1px solid ${l.tableBorder};padding:8px 12px;color:${l.text};`,img:"max-width:100%;height:auto;"};function d(c){c.removeAttribute("class");const h=c.tagName.toLowerCase();if(h==="pre"){c.setAttribute("style",`background:${l.preBg};color:${l.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${l.preBorder};`);const m=c.querySelector("code");m&&(m.removeAttribute("class"),m.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}h==="code"?c.setAttribute("style",`background:${l.codeBg};color:${l.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):o[h]&&c.setAttribute("style",o[h]),Array.from(c.children).forEach(d)}return s.removeAttribute("class"),Array.from(s.children).forEach(c=>d(c)),`<div style="background:${l.bg};color:${l.text};padding:20px 24px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.7;max-width:800px;">${s.innerHTML}</div>`}function Ra({label:e,value:n,current:s,onClick:l}){return t.jsx("button",{onClick:()=>l(s===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${s===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function sm(){return t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function Qs(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Jl(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function rz(e){return e>=1024*1024*1024?`${(e/(1024*1024*1024)).toFixed(1)} GB`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function RN({authUser:e}){const[n,s]=v.useState("weekly"),[l,o]=v.useState(null),[d,c]=v.useState(!0),[h,m]=v.useState(""),[f,g]=v.useState(null),[x,p]=v.useState([]),[y,w]=v.useState("totalTokens"),[N,C]=v.useState(!0),[_,O]=v.useState("generate"),[k,S]=v.useState([]),[R,D]=v.useState(null),[Y,z]=v.useState([]),[K,U]=v.useState(""),[G,V]=v.useState(""),E=M=>{V(M),setTimeout(()=>V(""),3e3)},T=v.useCallback(async M=>{c(!0),m("");try{const{report:H}=await re.reports.generate({period:M,scope:"org",orgId:"default"});o(H)}catch(H){m(String(H)),o(null)}c(!1)},[]),L=v.useCallback(()=>{re.usage.summary().then(M=>g(M.usage)).catch(()=>{}),re.usage.agents().then(M=>p(M.agents)).catch(()=>{})},[]),A=v.useCallback(async()=>{try{const{reports:M}=await re.reports.list();S(M)}catch{}},[]),P=v.useCallback(async M=>{D(M);try{const{feedback:H}=await re.reports.getFeedback(M.id);z(H)}catch{z([])}},[]);v.useEffect(()=>{T(n)},[n,T]),v.useEffect(()=>{L();const M=setInterval(L,3e4);return()=>clearInterval(M)},[L]),v.useEffect(()=>{_==="history"&&A()},[_,A]);const q=v.useMemo(()=>[...x].sort((M,H)=>{const Z=M[y],ee=H[y];return N?ee-Z:Z-ee}),[x,y,N]),W=x.reduce((M,H)=>M+H.estimatedCost,0),B=x.reduce((M,H)=>M+H.tokensUsedToday,0),F=Math.max(1,...x.map(M=>M.totalTokens)),X=M=>{y===M?C(!N):(w(M),C(!0))},I={daily:"Today",weekly:"This Week",monthly:"This Month"};return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl p-6 space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:"Reports"}),t.jsxs("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[t.jsx("button",{onClick:()=>O("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${_==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Generate"}),t.jsxs("button",{onClick:()=>O("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${_==="history"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:["History",k.length>0?` (${k.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[G&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:G}),_==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(M=>t.jsx("button",{onClick:()=>s(M),className:`px-3 py-1.5 text-xs rounded-md transition-colors capitalize ${n===M?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:M},M))})]})]}),_==="history"&&!R&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:k.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:"No reports generated yet. Use the Generate tab to create one."}):t.jsx("div",{className:"divide-y divide-border-default/50",children:k.map(M=>t.jsxs("button",{onClick:()=>P(M),className:"w-full text-left px-5 py-3 flex items-center gap-4 hover:bg-surface-elevated/30 transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm font-medium text-fg-primary",children:[M.type," Report"]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(M.periodStart).toLocaleDateString()," — ",new Date(M.periodEnd).toLocaleDateString()]})]}),M.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${M.plan.status==="approved"?"bg-green-500/10 text-green-600":M.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:M.plan.status==="pending"?"Plan pending":`Plan ${M.plan.status}`}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(M.generatedAt).toLocaleDateString()})]},M.id))})}),_==="history"&&R&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{D(null),z([])},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"← Back to list"}),t.jsxs("span",{className:"text-sm font-medium text-fg-primary",children:[R.type," Report"]}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(R.periodStart).toLocaleDateString()," — ",new Date(R.periodEnd).toLocaleDateString()]})]}),R.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Ns,{label:"Completed",value:R.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Ns,{label:"In Progress",value:R.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Ns,{label:"Created",value:R.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Ns,{label:"Blocked",value:R.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Ns,{label:"Failed",value:R.metrics.tasksFailed,color:"text-red-500"})]})]}),R.costSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Cost Overview"}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:R.costSummary.totalTokens.toLocaleString()}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Total Tokens"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Jl(R.costSummary.totalEstimatedCost)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Estimated Cost"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:`text-2xl font-bold ${R.costSummary.trend==="decreasing"?"text-green-600":R.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[R.costSummary.trend==="decreasing"?"↓":R.costSummary.trend==="increasing"?"↑":"→"," ",R.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Trend"})]})]}),R.costSummary.byAgent&&R.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:R.costSummary.byAgent.map((M,H)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:M.agentId}),t.jsxs("span",{className:"text-fg-tertiary tabular-nums",children:[Qs(M.tokens)," tokens · ",Jl(M.cost)]})]},H))})]}),R.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4",children:[R.taskSummary.completed.length>0&&t.jsx(Zl,{title:`Completed (${R.taskSummary.completed.length})`,color:"emerald",items:R.taskSummary.completed.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),R.taskSummary.inProgress.length>0&&t.jsx(Zl,{title:`In Progress (${R.taskSummary.inProgress.length})`,color:"indigo",items:R.taskSummary.inProgress.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),R.taskSummary.blocked.length>0&&t.jsx(Zl,{title:`Blocked (${R.taskSummary.blocked.length})`,color:"amber",items:R.taskSummary.blocked.map(M=>({id:M.id,label:M.title,sub:M.reason||M.agent}))}),R.taskSummary.completed.length===0&&R.taskSummary.inProgress.length===0&&R.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]}),R.highlights&&R.highlights.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-2",children:"Highlights"}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:R.highlights.map((M,H)=>t.jsx("li",{children:M},H))})]}),R.blockers&&R.blockers.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-amber-500/20 rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-amber-600 mb-2",children:"Blockers"}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:R.blockers.map((M,H)=>t.jsx("li",{children:M},H))})]}),R.plan&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary",children:["Upcoming Plan",t.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${R.plan.status==="approved"?"bg-green-500/10 text-green-600":R.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:R.plan.status})]}),R.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:M}=await re.reports.approvePlan(R.id,{approvedBy:e?.id??"admin"});D(M),E("Plan approved"),A()}catch(M){E(`Error: ${M}`)}},className:"px-3 py-1.5 text-xs font-medium bg-green-600 text-white rounded-lg hover:bg-green-500 transition-colors",children:"Approve Plan"}),t.jsx("button",{onClick:async()=>{const M=prompt("Rejection reason:");if(M)try{const{report:H}=await re.reports.rejectPlan(R.id,{rejectedBy:e?.id??"admin",reason:M});D(H),E("Plan rejected"),A()}catch(H){E(`Error: ${H}`)}},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-lg hover:bg-surface-overlay transition-colors",children:"Reject Plan"})]})]}),R.plan.items&&R.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:R.plan.items.map((M,H)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-secondary",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${M.priority==="high"?"bg-red-500/10 text-red-500":M.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:M.priority}),t.jsx("span",{children:M.title}),M.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:M.assignee})]},H))})]}),!R.metrics&&!R.taskSummary&&!R.costSummary&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:"This report does not contain detailed metrics data."})}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Feedback (",Y.length,")"]}),Y.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:Y.map(M=>t.jsxs("div",{className:"p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary mb-1",children:[t.jsx("span",{className:"font-medium text-fg-secondary",children:M.authorName}),t.jsx("span",{children:M.type}),t.jsx("span",{children:new Date(M.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:M.content})]},M.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:K,onChange:M=>U(M.target.value),placeholder:"Add feedback or instructions…",className:"flex-1 px-3 py-2 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary",onKeyDown:M=>{M.key==="Enter"&&K.trim()&&re.reports.addFeedback(R.id,{author:e?.id??"admin",type:"comment",content:K.trim()}).then(({feedback:H})=>{z(Z=>[...Z,H]),U(""),E("Feedback added")}).catch(H=>E(`Error: ${H}`))}}),t.jsx("button",{onClick:()=>{K.trim()&&re.reports.addFeedback(R.id,{author:e?.id??"admin",type:"comment",content:K.trim()}).then(({feedback:M})=>{z(H=>[...H,M]),U(""),E("Feedback added")}).catch(M=>E(`Error: ${M}`))},disabled:!K.trim(),className:"px-3 py-2 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Send"})]})]})]}),_==="generate"&&f&&t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(bd,{label:"LLM Tokens (this month)",value:Qs(f.llmTokens),color:"text-brand-500"}),t.jsx(bd,{label:"Tool Calls (today)",value:Qs(f.toolCalls),color:"text-blue-600"}),t.jsx(bd,{label:"Messages (today)",value:Qs(f.messages),color:"text-green-600"}),t.jsx(bd,{label:"Storage",value:rz(f.storageBytes),color:"text-amber-600"})]}),_==="generate"&&(d?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:"Loading…"}):h?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:h}):l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I[n]," · ",new Date(l.periodStart).toLocaleDateString()," — ",new Date(l.periodEnd).toLocaleDateString()]}),l.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Ns,{label:"Completed",value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Ns,{label:"In Progress",value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Ns,{label:"Created",value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Ns,{label:"Blocked",value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Ns,{label:"Failed",value:l.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Cost Overview"}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Jl(W)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Est. Cost (all time)"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Qs(B)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Tokens Today"})]}),l.costSummary&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:l.costSummary.totalTokens.toLocaleString()}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Tokens (",I[n],")"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Jl(l.costSummary.totalEstimatedCost)}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Cost (",I[n],")"]})]})]})]})]}),l.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4",children:[l.taskSummary.completed.length>0&&t.jsx(Zl,{title:`Completed (${l.taskSummary.completed.length})`,color:"emerald",items:l.taskSummary.completed.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),l.taskSummary.inProgress.length>0&&t.jsx(Zl,{title:`In Progress (${l.taskSummary.inProgress.length})`,color:"indigo",items:l.taskSummary.inProgress.map(M=>({id:M.id,label:M.title,sub:M.agent}))}),l.taskSummary.blocked.length>0&&t.jsx(Zl,{title:`Blocked (${l.taskSummary.blocked.length})`,color:"amber",items:l.taskSummary.blocked.map(M=>({id:M.id,label:M.title,sub:M.reason||M.agent}))}),l.taskSummary.completed.length===0&&l.taskSummary.inProgress.length===0&&l.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]})]}):null),_==="generate"&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"Per-Agent Usage"})}),x.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:"No agent usage data yet."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium",children:"Agent"}),t.jsx(go,{label:"Total Tokens",col:"totalTokens",current:y,desc:N,onSort:X}),t.jsx(go,{label:"Today",col:"tokensUsedToday",current:y,desc:N,onSort:X}),t.jsx(go,{label:"Requests",col:"requestCount",current:y,desc:N,onSort:X}),t.jsx(go,{label:"Tool Calls",col:"toolCalls",current:y,desc:N,onSort:X}),t.jsx(go,{label:"Est. Cost",col:"estimatedCost",current:y,desc:N,onSort:X,align:"right"})]})}),t.jsx("tbody",{children:q.map(M=>t.jsx(sz,{agent:M,maxTokens:F},M.agentId))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[t.jsxs("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary",children:["Total (",x.length," agents)"]}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Qs(x.reduce((M,H)=>M+H.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Qs(B)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:x.reduce((M,H)=>M+H.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:x.reduce((M,H)=>M+H.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:Jl(W)})]})})]})})]})]})})}function Ns({label:e,value:n,color:s}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${s}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function Zl({title:e,color:n,items:s}){return t.jsxs("div",{children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1",children:s.map((l,o)=>t.jsxs("div",{className:`text-sm text-fg-secondary flex items-center gap-2 ${l.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:l.id?()=>gt.navigate(ge.WORK,{openTask:l.id}):void 0,children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate ${l.id?"group-hover:text-brand-500 transition-colors":""}`,children:l.label}),l.sub&&l.sub!=="unassigned"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:l.sub})]},l.id??o))})]})}function bd({label:e,value:n,color:s}){return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary mb-2",children:e}),t.jsx("div",{className:`text-2xl font-bold ${s}`,children:n})]})}function go({label:e,col:n,current:s,desc:l,onSort:o,align:d}){const c=s===n?l?"↓":"↑":"↕",h=s===n?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${d==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>o(n),children:[e,t.jsx("span",{className:`ml-1 ${h}`,children:c})]})}function sz({agent:e,maxTokens:n}){const s=n>0?Math.min(100,e.totalTokens/n*100):0,l=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="paused"?"bg-amber-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>gt.navigate(ge.TEAM,{selectAgent:e.agentId}),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${l}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${s}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:Qs(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:Qs(e.tokensUsedToday)}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.requestCount}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.toolCalls}),t.jsx("td",{className:"px-4 py-3 text-sm text-right text-fg-secondary tabular-nums",children:Jl(e.estimatedCost)})]})}const t1={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},am={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_status_changed:"M23 4v6h-6 M1 20v-6h6 M3.51 9a9 9 0 0 1 14.85-3.36L23 10 M1 14l4.64 4.36A9 9 0 0 0 20.49 15",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z M12 9v4 M12 17h.01",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",agent_chat_request:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",agent_escalation:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z M12 9v4 M12 17h.01",bounty_posted:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z M19 10v2a7 7 0 0 1-14 0v-2",mention:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M12.5 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0z M20 8v6 M23 11h-6",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"};function n1(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const l=Math.floor(s/60);return l<24?`${l}h`:`${Math.floor(l/24)}d`}function r1(e){const n=e.actionType;if(n==="open_chat")return"Open chat →";if(n==="navigate")return"View details →";const s=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":case"task_status_changed":return s.taskId?"View task →":null;case"requirement_created":case"requirement_decision":return s.requirementId?"View requirement →":null;case"agent_chat_request":return"Open chat →";case"agent_alert":case"agent_escalation":case"agent_notification":return s.agentId?"View agent →":null;case"approval_request":return"View approval →";default:return s.taskId?"View task →":s.requirementId?"View requirement →":s.agentId?"View agent →":null}}function s1({collapsed:e,userId:n}){const[s,l]=v.useState(!1),[o,d]=v.useState("approvals"),[c,h]=v.useState([]),[m,f]=v.useState([]),[g,x]=v.useState(null),[p,y]=v.useState(0),w=v.useRef(null),N=v.useRef(null),[C,_]=v.useState({top:0,left:0}),O=v.useCallback(async()=>{try{const[E,T]=await Promise.all([re.notifications.list(n,!1),re.approvals.list()]);h(E.notifications),y(E.unreadCount??E.notifications.filter(L=>!L.read).length),f(T.approvals)}catch{}},[n]);v.useEffect(()=>{O();const E=setInterval(O,15e3),T=()=>O();return window.addEventListener("markus:notifications-changed",T),()=>{clearInterval(E),window.removeEventListener("markus:notifications-changed",T)}},[O]),v.useLayoutEffect(()=>{if(!s||!w.current)return;const E=w.current.getBoundingClientRect();_({top:E.top,left:E.right+8})},[s]),v.useEffect(()=>{if(!s)return;const E=T=>{w.current?.contains(T.target)||N.current?.contains(T.target)||l(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[s]);const k=new Set(m.map(E=>E.id)),S=c.filter(E=>!(E.type==="approval_request"&&E.metadata?.approvalId&&k.has(E.metadata.approvalId))),R=m.filter(E=>E.status==="pending").length,D=p+R,Y=async E=>{await re.notifications.markRead(E),h(T=>T.map(L=>L.id===E?{...L,read:!0}:L)),y(T=>Math.max(0,T-1))},z=E=>{const T=E.metadata??{},L=E.actionType,A=E.actionTarget;if(L==="open_chat"&&A)try{const P=typeof A=="string"?JSON.parse(A):A;if(P.agentId){const q={agentId:P.agentId};P.sessionId&&(q.sessionId=P.sessionId),gt.navigate(ge.TEAM,q);return}}catch{}if(L==="navigate"&&A)try{const P=typeof A=="string"?JSON.parse(A):A;if(P.path&&P.path.startsWith("/work")){const q={},W=new URLSearchParams(P.path.split("?")[1]||"");for(const[B,F]of W.entries())q[B]=F;gt.navigate(ge.WORK,q);return}}catch{}switch(E.type){case"approval_request":{const P=T.approvalId,W=(P?m.find(B=>B.id===P):void 0)?.details?.taskId??T.taskId;W?gt.navigate(ge.WORK,{openTask:W}):gt.navigate(ge.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":case"task_status_changed":T.taskId?gt.navigate(ge.WORK,{openTask:T.taskId}):gt.navigate(ge.WORK);break;case"requirement_created":case"requirement_decision":T.requirementId?gt.navigate(ge.WORK,{openRequirement:T.requirementId}):gt.navigate(ge.WORK);break;case"agent_chat_request":{const P={};T.agentId&&(P.agentId=T.agentId),T.sessionId&&(P.sessionId=T.sessionId),gt.navigate(ge.TEAM,Object.keys(P).length>0?P:void 0);break}case"agent_notification":case"agent_alert":case"agent_escalation":T.agentId?gt.navigate(ge.TEAM,{selectAgent:T.agentId}):gt.navigate(ge.TEAM);break;case"bounty_posted":gt.navigate(ge.SETTINGS);break;default:T.taskId?gt.navigate(ge.WORK,{openTask:T.taskId}):T.requirementId?gt.navigate(ge.WORK,{openRequirement:T.requirementId}):T.projectId?gt.navigate(ge.WORK,{projectId:T.projectId}):T.agentId&&gt.navigate(ge.TEAM,{selectAgent:T.agentId});break}},K=async E=>{E.read||Y(E.id),z(E)},U=async(E,T)=>{x(E);try{const{approval:L}=await re.approvals.respond(E,T,n);f(P=>P.map(q=>q.id===E?L:q));const A=c.find(P=>P.type==="approval_request"&&P.metadata?.approvalId===E);A&&!A.read&&(re.notifications.markRead(A.id),h(P=>P.map(q=>q.id===A.id?{...q,read:!0}:q))),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}x(null)},G=async()=>{try{await re.notifications.markAllRead(n??"default"),h(E=>E.map(T=>({...T,read:!0}))),y(0)}catch{const E=S.filter(T=>!T.read);await Promise.all(E.map(T=>re.notifications.markRead(T.id))),h(T=>T.map(L=>({...L,read:!0}))),y(0)}},V=E=>{const T=E.details?.taskId;T?gt.navigate(ge.WORK,{openTask:T}):gt.navigate(ge.WORK)};return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:w,onClick:()=>{l(!s),s||O()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${s?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:"Notifications",children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),D>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:D>99?"99+":D})]}),s&&hx.createPortal(t.jsxs("div",{ref:N,className:"fixed w-80 max-h-[28rem] bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:C.top,left:C.left},children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>d("approvals"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${o==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Approvals",R>0?` (${R})`:""]}),t.jsxs("button",{onClick:()=>d("notifications"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${o==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Notifications",p>0?` (${p})`:""]}),t.jsx("button",{onClick:()=>l(!1),className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:"Close",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),o==="notifications"&&p>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:G,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:"Mark all read"})}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o==="approvals"&&(m.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:"No approval requests"}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[m.filter(E=>E.status==="pending").map(E=>t.jsxs("div",{className:"px-3 py-3 space-y-2",children:[t.jsxs("button",{onClick:()=>V(E),className:"w-full text-left flex items-start gap-2 hover:bg-surface-overlay rounded transition-colors",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:am.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium",children:E.title}),t.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[E.agentName," · ",n1(E.requestedAt)]}),t.jsx("p",{className:"text-[11px] text-fg-secondary mt-1 line-clamp-3",children:E.description})]})]}),t.jsxs("div",{className:"flex gap-2 pl-5",children:[t.jsx("button",{disabled:g===E.id,onClick:()=>U(E.id,!0),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:"Approve"}),t.jsx("button",{disabled:g===E.id,onClick:()=>U(E.id,!1),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:"Reject"})]})]},E.id)),m.filter(E=>E.status!=="pending").slice(0,20).map(E=>t.jsx("button",{onClick:()=>V(E),className:"w-full text-left px-3 py-2.5 opacity-50 hover:opacity-70 transition-colors",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${E.status==="approved"?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:E.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:E.status})]})},E.id))]})),o==="notifications"&&(S.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:"No notifications"}):t.jsx("div",{className:"divide-y divide-border-default/50",children:S.slice(0,50).map(E=>t.jsxs("button",{onClick:()=>K(E),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${E.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:E.type==="agent_chat_request"?"text-brand-500":"text-fg-tertiary",children:t.jsx("path",{d:am[E.type]??am.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!E.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${t1[E.priority]??t1.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:E.title})]}),t.jsx("p",{className:"text-[11px] text-fg-tertiary line-clamp-2 mt-0.5",children:E.body}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:n1(E.createdAt)}),r1(E)&&t.jsx("span",{className:`text-[10px] font-medium ${E.type==="agent_chat_request"?"text-brand-500":"text-fg-tertiary"}`,children:r1(E)})]})]})]},E.id))}))]})]}),document.body)]})}function po({d:e,size:n=18}){return t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:e})})}const az={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"},a1=5;function lz({currentPage:e,onNavigate:n,authUser:s,onLogout:l,collapsed:o,onToggleCollapse:d}){const[c,h]=v.useState([]),[m,f]=v.useState(!1),[g,x]=v.useState(null),[p,y]=v.useState(!1),w=v.useCallback(()=>{re.projects.list().then(O=>h(O.projects)).catch(()=>{})},[]);v.useEffect(()=>{w();const O=setInterval(w,3e4);return()=>clearInterval(O)},[w]),v.useEffect(()=>{if(e!==ge.WORK){x(null);return}const k=window.location.hash.slice(1).split("/");Ia(k[0])===ge.WORK&&k[1]&&x(k[1])},[e]);const N=async()=>{try{await re.auth.logout()}catch{}l?.()},C=m?c:c.slice(0,a1),_=c.length>a1;return t.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden border-r border-border-subtle",children:[t.jsx("div",{className:`flex items-center ${o?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:o?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("button",{onClick:d,title:"Expand sidebar",className:"group",children:t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg group-hover:ring-2 group-hover:ring-brand-500/40 transition-all"})}),t.jsx(s1,{collapsed:!0,userId:s?.id})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:d,className:"flex items-center gap-2.5 min-w-0 group",title:"Collapse sidebar",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shadow-md shadow-black/30 shrink-0 group-hover:ring-2 group-hover:ring-brand-500/40 transition-all"}),t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(s1,{userId:s?.id}),t.jsx("button",{onClick:d,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1 rounded-md hover:bg-surface-overlay",title:"Collapse sidebar",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"11 17 6 12 11 7"}),t.jsx("polyline",{points:"18 17 13 12 18 7"})]})})]})]})}),t.jsx("nav",{className:`${o?"p-1.5":"p-3"} flex-1 overflow-y-auto`,children:Z2.map((O,k)=>t.jsx("div",{children:t.jsxs("div",{className:"mb-3",children:[!o&&t.jsx("div",{className:"px-3 py-1.5 text-[11px] font-semibold text-fg-tertiary uppercase tracking-widest",children:O.label}),o&&k>0&&t.jsx("div",{className:"my-2 mx-1"}),W2.filter(S=>S.section===O.key&&!(O.key==="workspace"&&S.id===ge.DELIVERABLES)).map(S=>{const R=e===S.id;return t.jsxs("button",{onClick:()=>n(S.id),title:o?S.label:void 0,className:`w-full flex items-center ${o?"justify-center px-2 py-2":"gap-3 px-3 py-2"} rounded-lg text-sm mb-0.5 transition-all ${R?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":"text-fg-primary hover:bg-surface-overlay"}`,children:[t.jsx(po,{d:Wl[S.id]??""}),!o&&S.label]},S.id)}),O.key==="workspace"&&o&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{x(null),n(ge.WORK)},title:"Work",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-all ${e===ge.WORK&&!g?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":e===ge.WORK?"bg-brand-600/15 text-fg-primary":"text-fg-primary hover:bg-surface-overlay"}`,children:t.jsx(po,{d:Wl[ge.WORK]})}),t.jsx("button",{onClick:()=>n(ge.DELIVERABLES),title:"Deliverables",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===ge.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(po,{d:Wl[ge.DELIVERABLES]})})]}),O.key==="workspace"&&!o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center mb-0.5",children:[t.jsxs("button",{onClick:()=>{x(null),window.location.hash=ge.WORK,n(ge.WORK)},className:`flex-1 flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${e===ge.WORK&&!g?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(po,{d:Wl[ge.WORK]}),"Work"]}),t.jsx("button",{onClick:()=>y(!0),className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1.5 rounded hover:bg-surface-elevated shrink-0",title:"New Project",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),c.length===0&&t.jsxs("button",{onClick:()=>y(!0),className:"w-full flex items-center gap-2 pl-9 pr-3 py-1.5 text-xs text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50 rounded-lg transition-colors",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create your first project"]}),C.map(S=>{const R=e===ge.WORK&&g===S.id;return t.jsxs("button",{onClick:()=>{x(S.id),e!==ge.WORK&&n(ge.WORK),window.location.hash=im(ge.WORK,S.id).slice(1)},className:`w-full flex items-center gap-2.5 pl-9 pr-3 py-1.5 rounded-lg text-sm mb-0.5 transition-colors ${R?"bg-brand-600 text-white":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${az[S.status]??"bg-gray-600"}`}),t.jsx("span",{className:"truncate text-xs",children:S.name})]},S.id)}),_&&!m&&t.jsxs("button",{onClick:()=>f(!0),className:"w-full pl-9 pr-3 py-1 text-[11px] text-fg-tertiary hover:text-fg-secondary transition-colors text-left",children:["Show all ",c.length," projects..."]}),t.jsxs("button",{onClick:()=>n(ge.DELIVERABLES),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===ge.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(po,{d:Wl[ge.DELIVERABLES]}),"Deliverables"]})]})]})},O.key))}),t.jsxs("div",{className:`${o?"p-2 flex flex-col items-center gap-2":"px-4 py-3 space-y-2"}`,children:[s&&(o?t.jsx("button",{onClick:N,title:`${s.name??s.email} — Sign out`,className:"w-7 h-7 rounded-full bg-brand-600 flex items-center justify-center text-white text-xs font-bold shrink-0 hover:ring-2 hover:ring-brand-500/50 transition-all",children:s.name?.[0]?.toUpperCase()??"A"}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-600 flex items-center justify-center text-white text-xs font-bold shrink-0",children:s.name?.[0]?.toUpperCase()??"A"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-secondary truncate",children:s.name??s.email}),t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate",children:s.email??s.role?.[0]?.toUpperCase()+s.role?.slice(1)})]}),t.jsx("button",{onClick:N,title:"Sign out",className:"text-fg-tertiary hover:text-fg-secondary transition-colors text-sm",children:"⇥"})]})),!o&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["v","0.4.13"]})]}),p&&t.jsx(EN,{orgId:s?.orgId,onCreated:()=>{y(!1),w()},onClose:()=>y(!1)})]})}function iz({currentPage:e,onNavigate:n}){return t.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary border-t border-border-default flex items-stretch h-14 safe-area-bottom",children:Q2.map(s=>{const l=s.group.includes(e);return t.jsxs("button",{onClick:()=>n(s.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${l?"text-brand-500":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:l?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:Wl[s.id]})}),t.jsx("span",{className:`text-[10px] leading-tight ${l?"font-semibold":""}`,children:s.label})]},s.id)})})}const l1=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function oz({authUser:e}){const[n,s]=v.useState("builder"),l=gx(l1,n,s);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:l.onTouchStart,onTouchEnd:l.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:l1.map(o=>t.jsx("button",{onClick:()=>s(o.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${n===o.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:o.label},o.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="builder"&&t.jsx(Bj,{}),n==="agents"&&t.jsx(Rj,{authUser:e}),n==="teams"&&t.jsx(Ij,{}),n==="skills"&&t.jsx($j,{})]})]})}const i1=[{id:"settings",label:"Settings"},{id:"reports",label:"Reports"}];function cz({theme:e,onThemeChange:n}){const[s,l]=v.useState("settings"),o=gx(i1,s,l);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:o.onTouchStart,onTouchEnd:o.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:i1.map(d=>t.jsx("button",{onClick:()=>l(d.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===d.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:d.label},d.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="settings"&&t.jsx(_j,{theme:e,onThemeChange:n}),s==="reports"&&t.jsx(RN,{})]})]})}const o1=2;function dz({onComplete:e,theme:n,onThemeChange:s}){const[l,o]=v.useState(0),[d,c]=v.useState(null),[h,m]=v.useState(!1),[f,g]=v.useState({}),[x,p]=v.useState(!1),[y,w]=v.useState(null),[N,C]=v.useState(!1),[_,O]=v.useState(!1),[k,S]=v.useState(null),R=v.useRef(!1),D=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`});v.useEffect(()=>{fetch("/api/settings/llm").then(L=>L.ok?L.json():null).then(L=>{L?.providers&&Object.values(L.providers).some(A=>A.configured)&&O(!0)}).catch(()=>{})},[]),v.useEffect(()=>{l===o1&&!R.current&&!_&&(R.current=!0,Y())},[l,_]);const Y=async()=>{m(!0);try{const L=await fetch("/api/settings/env-models",{headers:D()});if(L.ok){const A=await L.json();if(c(A),A.detected.length>0){const P={};for(const q of A.detected)P[q.provider]=!0;g(P)}}}catch{}finally{m(!1)}},z=async()=>{if(!d)return;const L=d.detected.filter(A=>f[A.provider]);if(L.length!==0){p(!0),S(null);try{const A=await fetch("/api/settings/env-models",{method:"POST",headers:D(),body:JSON.stringify({providers:L.map(P=>({provider:P.provider,model:P.model,baseUrl:P.baseUrl,enabled:!0}))})});if(A.ok){const P=await A.json();S({type:"ok",text:P.message}),O(!0)}else S({type:"err",text:"Failed to apply"})}catch{S({type:"err",text:"Network error"})}finally{p(!1)}}},K=async()=>{C(!0);try{const A=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:D(),body:JSON.stringify({preview:!0})})).json();"error"in A||w(A)}catch{}finally{C(!1)}},U=async()=>{C(!0),S(null);try{const A=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:D(),body:JSON.stringify({preview:!1})})).json();"error"in A?S({type:"err",text:A.error}):(S({type:"ok",text:`Imported ${A.appliedModels} model configs`}),O(!0))}catch{S({type:"err",text:"Import failed"})}finally{C(!1)}},G=[{value:"system",label:"System",icon:"💻",desc:"Follow your OS setting"},{value:"light",label:"Light",icon:"☀️",desc:"Always light background"},{value:"dark",label:"Dark",icon:"🌙",desc:"Always dark background"}],V=[{title:"Welcome to Markus",subtitle:"Your AI workforce, ready in minutes",content:t.jsxs("div",{className:"space-y-4 text-fg-secondary text-sm leading-relaxed",children:[t.jsxs("p",{children:["Markus runs ",t.jsx("strong",{className:"text-fg-primary",children:"complete AI teams"})," — developers, researchers, writers, analysts that work autonomously, collaborate with each other, and deliver results around the clock."]}),t.jsx("div",{className:"grid grid-cols-2 gap-3 mt-6",children:[["24/7 Operation","Agents work while you sleep via heartbeat"],["Team Collaboration","Agents delegate, review, and coordinate"],["Persistent Memory","Five memory layers survive restarts"],["Any LLM Provider","Anthropic, OpenAI, Google, Ollama & more"]].map(([L,A])=>t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:L}),t.jsx("div",{className:"text-fg-secondary text-xs mt-1",children:A})]},L))})]})},{title:"Choose Your Theme",subtitle:"You can change this anytime in Settings",content:t.jsx("div",{className:"grid grid-cols-3 gap-3",children:G.map(L=>t.jsxs("button",{onClick:()=>s(L.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===L.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:L.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:L.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:L.desc})]},L.value))})},{title:"Configure LLM",subtitle:"Agents need an LLM to think and act",content:_?t.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[t.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-green-600",children:"LLM provider configured"}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:"You can manage providers anytime in Settings."})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary uppercase tracking-wider",children:"From Environment Variables"}),h&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse",children:"Detecting API keys..."}),d&&d.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[d.detected.map(L=>t.jsxs("label",{className:"flex items-center gap-3 bg-surface-elevated/40 rounded-lg px-3 py-2.5 cursor-pointer hover:bg-surface-elevated/60 transition-colors",children:[t.jsx("input",{type:"checkbox",checked:f[L.provider]??!1,onChange:A=>g({...f,[L.provider]:A.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:L.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:L.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:L.apiKeyPreview})]},L.provider)),t.jsx("button",{onClick:()=>{z()},disabled:x||Object.values(f).filter(Boolean).length===0,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:x?"Applying...":`Apply ${Object.values(f).filter(Boolean).length} Provider(s)`})]}),d&&d.detected.length===0&&!h&&t.jsxs("div",{className:"text-xs text-fg-tertiary bg-surface-elevated/30 rounded-lg p-3",children:["No API keys found. Set ",t.jsx("code",{className:"text-fg-secondary",children:"ANTHROPIC_API_KEY"}),", ",t.jsx("code",{className:"text-fg-secondary",children:"OPENAI_API_KEY"}),", etc. in your ",t.jsx("code",{className:"text-fg-secondary",children:".env"})," file and restart."]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 h-px bg-border-default"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:"or"}),t.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary uppercase tracking-wider",children:"From OpenClaw"}),y?y.found?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found: ",t.jsx("code",{className:"text-fg-secondary",children:y.summary.configPath}),y.summary.models&&t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",y.summary.models.providerCount," providers)"]})]}),t.jsx("button",{onClick:()=>{U()},disabled:N,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:N?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary bg-surface-elevated/30 rounded-lg p-3",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{K()},disabled:N,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors w-full",children:N?"Detecting...":"Detect OpenClaw Config"})]}),k&&t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${k.type==="ok"?"bg-green-500/10 text-green-600 border border-green-500/30":"bg-red-500/10 text-red-500 border border-red-500/30"}`,children:k.text})]})},{title:"You're All Set",subtitle:"Start building your AI workforce",content:t.jsx("div",{className:"space-y-2 text-fg-secondary text-sm",children:[["Chat","Talk to agents or use Smart Route to auto-delegate tasks"],["Projects","Create projects with requirements, tasks, and deliverables"],["Builder","Hire new agents from templates or build custom roles"],["Settings","Manage LLM providers, integrations, and governance"]].map(([L,A])=>t.jsxs("div",{className:"flex gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"text-brand-500 mt-0.5 shrink-0",children:"→"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:L}),t.jsx("div",{className:"text-fg-secondary text-xs",children:A})]})]},L))})}],E=()=>{l<V.length-1?o(l+1):e()},T=V[l];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:V.map((L,A)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${A<=l?"bg-brand-500":"bg-surface-elevated"}`},A))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:T.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:T.subtitle}),T.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[l>0?t.jsx("button",{onClick:()=>o(l-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:"Back"}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip"}),t.jsxs("div",{className:"flex items-center gap-3",children:[l===o1&&!_&&t.jsx("button",{onClick:E,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),t.jsx("button",{onClick:E,className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-xl transition-colors",children:l===V.length-1?"Get Started":"Next"})]})]})]})})})}const uz="markus123";function fz({onLogin:e}){const[n,s]=v.useState("admin@markus.local"),[l,o]=v.useState(""),[d,c]=v.useState(""),[h,m]=v.useState(!1),f=async g=>{if(g.preventDefault(),!(!n.trim()||!l)){c(""),m(!0);try{const{user:x}=await re.auth.login(n.trim(),l);e(x,l===uz)}catch{c("Invalid email or password")}finally{m(!1)}}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:"AI Digital Employee Platform"})]}),t.jsxs("form",{onSubmit:f,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:"Sign in"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Email"}),t.jsx("input",{type:"email",value:n,onChange:g=>s(g.target.value),autoComplete:"email",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Password"}),t.jsx("input",{type:"password",value:l,onChange:g=>o(g.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),d&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:d}),t.jsx("button",{type:"submit",disabled:h||!n||!l,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:h?"Signing in…":"Sign in"}),t.jsx("p",{className:"text-center text-xs text-fg-tertiary",children:"Default: admin@markus.local / markus123"})]})]})]})}function hz({onComplete:e,isFirstTime:n}){const[s,l]=v.useState(""),[o,d]=v.useState(""),[c,h]=v.useState(""),[m,f]=v.useState(""),[g,x]=v.useState(!1),p=async y=>{if(y.preventDefault(),f(""),o.length<6){f("Password must be at least 6 characters");return}if(o!==c){f("Passwords do not match");return}x(!0);try{await re.auth.changePassword(s,o),e()}catch{f("Failed to change password. Check your current password.")}finally{x(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:"AI Digital Employee Platform"})]}),t.jsxs("form",{onSubmit:p,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n?"Set Your Password":"Change Password"}),n&&t.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:"You're using the default password. Please set a new one before continuing."})]}),!n&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Current Password"}),t.jsx("input",{type:"password",value:s,onChange:y=>l(y.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"New Password"}),t.jsx("input",{type:"password",value:o,onChange:y=>d(y.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Confirm New Password"}),t.jsx("input",{type:"password",value:c,onChange:y=>h(y.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:g||!o||!c,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:g?"Saving…":n?"Set Password & Continue":"Change Password"})]})]})]})}const DN="markus-theme";function c1(e){const n=document.documentElement;n.classList.remove("light","dark"),e==="light"?n.classList.add("light"):e==="dark"&&n.classList.add("dark")}function mz(){try{const e=localStorage.getItem(DN);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"system"}function xz(){const[e,n]=v.useState(mz),s=v.useCallback(l=>{n(l);try{localStorage.setItem(DN,l)}catch{}c1(l)},[]);return v.useEffect(()=>{c1(e)},[e]),{mode:e,setMode:s}}const lm={};function gz(){const[e,n]=v.useState(rd),[s,l]=v.useState(()=>!localStorage.getItem("markus_onboarded")),[o,d]=v.useState(!0),c=_s(),h=xz(),m=tu({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[f,g]=v.useState(()=>new Set([rd()])),[x,p]=v.useState("loading"),[y,w]=v.useState(!1),[N,C]=v.useState(null),[_,O]=v.useState(!1),k=v.useCallback(Y=>{let z=Ia(Y);c&&(z=K2[z]??z);const K=rd(),U=window.location.hash.slice(1);U!==K?lm[K]=U:delete lm[K];const G=lm[z];G&&G!==z?(history.pushState(null,"","#"+z),history.pushState(null,"","#"+G)):history.pushState(null,"","#"+z),window.dispatchEvent(new HashChangeEvent("hashchange")),n(z),g(V=>V.has(z)?V:new Set([...V,z]))},[c]);v.useEffect(()=>{gt.setHandler(Y=>k(Y))},[k]);const S=v.useCallback(()=>{fetch("/api/settings/llm").then(Y=>Y.ok?Y.json():null).then(Y=>{if(Y?.providers){const z=Object.values(Y.providers).some(K=>K.configured);C(z)}}).catch(()=>{})},[]);v.useEffect(()=>{re.auth.me().then(({user:K})=>{p(K),S(),rl(Tr.builderArtifacts,()=>re.builder.artifacts.list()),rl(Tr.builderAgents,()=>re.agents.list()),rl(Tr.builderHubMyItems,()=>Xn.myItems()),rl(Tr.builderInstalled,()=>re.builder.artifacts.installed()),rl(Tr.hubAgents,()=>Xn.search({type:"agent",limit:50})),rl(Tr.hubTeams,()=>Xn.search({type:"team",limit:50})),rl(Tr.hubSkills,()=>Xn.search({type:"skill",limit:50}))}).catch(()=>p(null)),xn.connect();const Y=xn.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),z=()=>{const K=rd();n(K),g(U=>U.has(K)?U:new Set([...U,K]))};return window.addEventListener("hashchange",z),()=>{Y(),xn.disconnect(),window.removeEventListener("hashchange",z)}},[]);const R=x!=="loading"&&x!==null?x:void 0,D=v.useMemo(()=>c?{[ge.HOME]:t.jsx(vb,{}),[ge.TEAM]:t.jsx(Ay,{authUser:R}),[ge.BUILDER]:t.jsx(oz,{authUser:R}),[ge.SETTINGS]:t.jsx(cz,{theme:h.mode,onThemeChange:h.setMode}),[ge.WORK]:t.jsx(Wv,{authUser:R}),[ge.DELIVERABLES]:t.jsx(e1,{})}:{[ge.HOME]:t.jsx(vb,{}),[ge.TEAM]:t.jsx(Ay,{authUser:R}),[ge.SETTINGS]:t.jsx(_j,{theme:h.mode,onThemeChange:h.setMode}),[ge.STORE]:t.jsx(zA,{authUser:R}),[ge.BUILDER]:t.jsx(Bj,{}),[ge.WORK]:t.jsx(Wv,{authUser:R}),[ge.DELIVERABLES]:t.jsx(e1,{}),[ge.REPORTS]:t.jsx(RN,{authUser:R})},[R?.id,h.mode,c]);return x==="loading"?t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:"Loading…"})}):x===null?t.jsx(fz,{onLogin:(Y,z)=>{p(Y),z&&w(!0)}}):y?t.jsx(hz,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(dz,{theme:h.mode,onThemeChange:h.setMode,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),l(!1),S()}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary ${c?"flex-col":""}`,children:[!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:m.width},children:t.jsx(lz,{currentPage:e,onNavigate:Y=>{k(Y),d(!1)},authUser:x,onLogout:()=>p(null),collapsed:m.collapsed,onToggleCollapse:m.toggle})}),!m.collapsed&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative z-10",onMouseDown:m.onResizeStart,children:t.jsx("div",{className:"absolute inset-y-0 -left-0.5 -right-0.5 group-hover:bg-brand-500/30 group-active:bg-brand-500/50 transition-colors"})})]}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${c?"pb-14":""}`,children:[N===!1&&!_&&e!==ge.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:"No LLM provider configured — agents cannot process requests."}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{k(ge.SETTINGS)},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:"Go to Settings"}),t.jsx("button",{onClick:()=>O(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:"Dismiss"})]})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col",children:Object.keys(D).map(Y=>f.has(Y)?t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:{display:Y===e?"flex":"none"},children:D[Y]},Y):null)})]}),c&&t.jsx(iz,{currentPage:e,onNavigate:k})]})}Y2.createRoot(document.getElementById("root")).render(t.jsx(v.StrictMode,{children:t.jsx(gz,{})}));