@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.
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/markus.mjs +1 -8
- package/dist/web-ui/assets/index-Ch2rpF4A.css +1 -0
- package/dist/web-ui/assets/index-D8LAgMk8.js +63 -0
- package/dist/web-ui/index.html +3 -3
- package/package.json +1 -1
- package/dist/web-ui/assets/index-OE34_qh_.css +0 -1
- package/dist/web-ui/assets/index-nuQoO_K8.js +0 -63
|
@@ -0,0 +1,63 @@
|
|
|
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 Gd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fh={exports:{}},ro={};var db;function R2(){if(db)return ro;db=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 ub;function D2(){return ub||(ub=1,fh.exports=R2()),fh.exports}var t=D2(),hh={exports:{}},Ot={};var fb;function L2(){if(fb)return Ot;fb=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"),p=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),g=Symbol.iterator;function y(F){return F===null||typeof F!="object"?null:(F=g&&F[g]||F["@@iterator"],typeof F=="function"?F:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,C={};function A(F,X,I){this.props=F,this.context=X,this.refs=C,this.updater=I||w}A.prototype.isReactComponent={},A.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")},A.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function O(){}O.prototype=A.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,A.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 q(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?q(""+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 _(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 p:return ee=F._init,_(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,"$&/")+"/"),_(H,X,I,"",function(fe){return fe})):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+=_(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+=_(M,X,I,Z,H);else if(Z==="object"){if(typeof F.then=="function")return _(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 _(F,M,"","",function(Z){return X.call(I,Z,H++)}),M}function V(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=A,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:p,_payload:{_status:-1,_result:F},_init:V}},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 hb;function Po(){return hb||(hb=1,hh.exports=L2()),hh.exports}var v=Po();const I2=Gd(v);var mh={exports:{}},so={},xh={exports:{}},ph={};var mb;function z2(){return mb||(mb=1,(function(e){function n(_,P){var V=_.length;_.push(P);e:for(;0<V;){var W=V-1>>>1,B=_[W];if(0<o(B,P))_[W]=P,_[V]=B,V=W;else break e}}function s(_){return _.length===0?null:_[0]}function l(_){if(_.length===0)return null;var P=_[0],V=_.pop();if(V!==P){_[0]=V;e:for(var W=0,B=_.length,F=B>>>1;W<F;){var X=2*(W+1)-1,I=_[X],M=X+1,H=_[M];if(0>o(I,V))M<B&&0>o(H,I)?(_[W]=H,_[M]=V,W=M):(_[W]=I,_[X]=V,W=X);else if(M<B&&0>o(H,V))_[W]=H,_[M]=V,W=M;else break e}}return P}function o(_,P){var V=_.sortIndex-P.sortIndex;return V!==0?V:_.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=[],p=1,x=null,g=3,y=!1,w=!1,N=!1,C=!1,A=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function S(_){for(var P=s(f);P!==null;){if(P.callback===null)l(f);else if(P.startTime<=_)l(f),P.sortIndex=P.expirationTime,n(m,P);else break;P=s(f)}}function R(_){if(N=!1,S(_),!w)if(s(m)!==null)w=!0,D||(D=!0,q());else{var P=s(f);P!==null&&L(R,P.startTime-_)}}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 _=e.unstable_now();K=_;var P=!0;try{e:{w=!1,N&&(N=!1,O(Y),Y=-1),y=!0;var V=g;try{t:{for(S(_),x=s(m);x!==null&&!(x.expirationTime>_&&U());){var W=x.callback;if(typeof W=="function"){x.callback=null,g=x.priorityLevel;var B=W(x.expirationTime<=_);if(_=e.unstable_now(),typeof B=="function"){x.callback=B,S(_),P=!0;break t}x===s(m)&&l(m),S(_)}else l(m);x=s(m)}if(x!==null)P=!0;else{var F=s(f);F!==null&&L(R,F.startTime-_),P=!1}}break e}finally{x=null,g=V,y=!1}P=void 0}}finally{P?q():D=!1}}}var q;if(typeof k=="function")q=function(){k(G)};else if(typeof MessageChannel<"u"){var E=new MessageChannel,T=E.port2;E.port1.onmessage=G,q=function(){T.postMessage(null)}}else q=function(){A(G,0)};function L(_,P){Y=A(function(){_(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(_){_.callback=null},e.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(_){switch(g){case 1:case 2:case 3:var P=3;break;default:P=g}var V=g;g=P;try{return _()}finally{g=V}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(_,P){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var V=g;g=_;try{return P()}finally{g=V}},e.unstable_scheduleCallback=function(_,P,V){var W=e.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?W+V:W):V=W,_){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=V+B,_={id:p++,callback:P,priorityLevel:_,startTime:V,expirationTime:B,sortIndex:-1},V>W?(_.sortIndex=V,n(f,_),s(m)===null&&_===s(f)&&(N?(O(Y),Y=-1):N=!0,L(R,V-W))):(_.sortIndex=B,n(m,_),w||y||(w=!0,D||(D=!0,q()))),_},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(_){var P=g;return function(){var V=g;g=P;try{return _.apply(this,arguments)}finally{g=V}}}})(ph)),ph}var xb;function $2(){return xb||(xb=1,xh.exports=z2()),xh.exports}var gh={exports:{}},dr={};var pb;function B2(){if(pb)return dr;pb=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 p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}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,p){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:p}}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 dr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,dr.createPortal=function(m,f){var p=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,p)},dr.flushSync=function(m){var f=c.T,p=l.p;try{if(c.T=null,l.p=2,m)return m()}finally{c.T=f,l.p=p,l.d.f()}},dr.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))},dr.prefetchDNS=function(m){typeof m=="string"&&l.d.D(m)},dr.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var p=f.as,x=h(p,f.crossOrigin),g=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?l.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:x,integrity:g,fetchPriority:y}):p==="script"&&l.d.X(m,{crossOrigin:x,integrity:g,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},dr.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var p=h(f.as,f.crossOrigin);l.d.M(m,{crossOrigin:p,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)},dr.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,x=h(p,f.crossOrigin);l.d.L(m,p,{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})}},dr.preloadModule=function(m,f){if(typeof m=="string")if(f){var p=h(f.as,f.crossOrigin);l.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else l.d.m(m)},dr.requestFormReset=function(m){l.d.r(m)},dr.unstable_batchedUpdates=function(m,f){return m(f)},dr.useFormState=function(m,f,p){return c.H.useFormState(m,f,p)},dr.useFormStatus=function(){return c.H.useHostTransitionStatus()},dr.version="19.2.4",dr}var gb;function d1(){if(gb)return gh.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(),gh.exports=B2(),gh.exports}var bb;function H2(){if(bb)return so;bb=1;var e=$2(),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 p(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r;for(r=r.child;r!==null;){if(a=p(r),a!==null)return a;r=r.sibling}return null}var x=Object.assign,g=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"),A=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 q(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 A: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,_=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,V={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)?R0(r):0;break;default:if(r=a.tagName,a=a.namespaceURI)a=R0(a),r=D0(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 fe(r){r.memoizedState!==null&&I(ee,r);var a=M.current,i=D0(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=V)}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 Te=!1;function ze(r,a){if(!r||Te)return"";Te=!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(ke){var be=ke}Reflect.construct(r,[],Re)}else{try{Re.call()}catch(ke){be=ke}r.call(Re.prototype)}}else{try{throw Error()}catch(ke){be=ke}(Re=r())&&typeof Re.catch=="function"&&Re.catch(function(){})}}catch(ke){if(ke&&be&&typeof ke.stack=="string")return[ke.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
|
+
`),me=Q.split(`
|
|
5
|
+
`);for(b=u=0;u<le.length&&!le[u].includes("DetermineComponentFrameRoot");)u++;for(;b<me.length&&!me[b].includes("DetermineComponentFrameRoot");)b++;if(u===le.length||b===me.length)for(u=le.length-1,b=me.length-1;1<=u&&0<=b&&le[u]!==me[b];)b--;for(;1<=u&&0<=b;u--,b--)if(le[u]!==me[b]){if(u!==1||b!==1)do if(u--,b--,0>b||le[u]!==me[b]){var Ae=`
|
|
6
|
+
`+le[u].replace(" at new "," at ");return r.displayName&&Ae.includes("<anonymous>")&&(Ae=Ae.replace("<anonymous>",r.displayName)),Ae}while(1<=u&&0<=b);break}}}finally{Te=!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 ze(r.type,!1);case 11:return ze(r.type.render,!1);case 1:return ze(r.type,!0);case 31:return je("Activity");default:return""}}function nt(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 tt=Object.prototype.hasOwnProperty,Mt=e.unstable_scheduleCallback,se=e.unstable_cancelCallback,Ee=e.unstable_shouldYield,rt=e.unstable_requestPaint,vt=e.unstable_now,Kt=e.unstable_getCurrentPriorityLevel,we=e.unstable_ImmediatePriority,De=e.unstable_UserBlockingPriority,Ue=e.unstable_NormalPriority,Je=e.unstable_LowPriority,pt=e.unstable_IdlePriority,Jt=e.log,ln=e.unstable_setDisableYieldValue,Ht=null,Lt=null;function _t(r){if(typeof Jt=="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 qe=256,Rt=262144,zt=4194304;function Ve(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 Pt(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=Ve(u):($&=Q,$!==0?b=Ve($):i||(i=Q&~r,i!==0&&(b=Ve(i))))):(Q=u&~j,Q!==0?b=Ve(Q):$!==0?b=Ve($):i||(i=u&~r,i!==0&&(b=Ve(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 yn(r,a){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&a)===0}function nn(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 un(){var r=zt;return zt<<=1,(zt&62914560)===0&&(zt=4194304),r}function vn(r){for(var a=[],i=0;31>i;i++)a.push(r);return a}function Dt(r,a){r.pendingLanes|=a,a!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function jn(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,me=r.hiddenUpdates;for(i=$&~i;0<i;){var Ae=31-St(i),Re=1<<Ae;Q[Ae]=0,le[Ae]=-1;var be=me[Ae];if(be!==null)for(me[Ae]=null,Ae=0;Ae<be.length;Ae++){var ke=be[Ae];ke!==null&&(ke.lane&=-536870913)}i&=~Re}u!==0&&Et(r,u,0),j!==0&&b===0&&r.tag!==0&&(r.suspendedLanes|=j&~($&~a))}function Et(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 Pe(r,a){var i=a&-a;return i=(i&42)!==0?1:Fe(i),(i&(r.suspendedLanes|a))!==0?0:i}function Fe(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 st(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function ot(){var r=P.p;return r!==0?r:(r=window.event,r===void 0?32:rb(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),Qe="__reactFiber$"+dt,at="__reactProps$"+dt,fn="__reactContainer$"+dt,xe="__reactEvents$"+dt,Ke="__reactListeners$"+dt,xt="__reactHandles$"+dt,At="__reactResources$"+dt,On="__reactMarker$"+dt;function hr(r){delete r[Qe],delete r[at],delete r[xe],delete r[Ke],delete r[xt]}function mr(r){var a=r[Qe];if(a)return a;for(var i=r.parentNode;i;){if(a=i[fn]||i[Qe]){if(i=a.alternate,a.child!==null||i!==null&&i.child!==null)for(r=P0(r);r!==null;){if(i=r[Qe])return i;r=P0(r)}return a}r=i,i=r.parentNode}return null}function er(r){if(r=r[Qe]||r[fn]){var a=r.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return r}return null}function or(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r.stateNode;throw Error(l(33))}function tr(r){var a=r[At];return a||(a=r[At]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function wn(r){r[On]=!0}var ts=new Set,ns={};function ce(r,a){_e(r,a),_e(r+"Capture",a)}function _e(r,a){for(ns[r]=a,r=0;r<a.length;r++)ts.add(a[r])}var $e=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]*$"),Yt={},br={};function rs(r){return tt.call(br,r)?!0:tt.call(Yt,r)?!1:$e.test(r)?br[r]=!0:(Yt[r]=!0,!1)}function yr(r,a,i){if(rs(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 gs(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 cr(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 Rn(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 Ur(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 Pn(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 Dn(r){return r.replace(Rs,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function qr(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=""+Rn(a)):r.value!==""+Rn(a)&&(r.value=""+Rn(a)):$!=="submit"&&$!=="reset"||r.removeAttribute("value"),a!=null?Ar(r,$,Rn(a)):i!=null?Ar(r,$,Rn(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=""+Rn(Q):r.removeAttribute("name")}function xr(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?""+Rn(i):"",a=a!=null?""+Rn(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 Ar(r,a,i){a==="number"&&Pn(r.ownerDocument)===r||r.defaultValue===""+i||(r.defaultValue=""+i)}function nr(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=""+Rn(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 Vr(r,a,i){if(a!=null&&(a=""+Rn(a),a!==r.value&&(r.value=a),i==null)){r.defaultValue!==a&&(r.defaultValue=a);return}r.defaultValue=i!=null?""+Rn(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=Rn(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 ge(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 Ce(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"]]),Se=/^[\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 Se.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function He(){}var Nt=null;function ht(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var lt=null,Tt=null;function Ut(r){var a=er(r);if(a&&(r=a.stateNode)){var i=r[at]||null;e:switch(r=a.stateNode,a.type){case"input":if(qr(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="'+Dn(""+a)+'"][type="radio"]'),a=0;a<i.length;a++){var u=i[a];if(u!==r&&u.form===r.form){var b=u[at]||null;if(!b)throw Error(l(90));qr(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&&Ur(u)}break e;case"textarea":Vr(r,i.value,i.defaultValue);break e;case"select":a=i.value,a!=null&&nr(r,!!i.multiple,a,!1)}}}var Nn=!1;function zn(r,a,i){if(Nn)return r(a,i);Nn=!0;try{var u=r(a);return u}finally{if(Nn=!1,(lt!==null||Tt!==null)&&(Lc(),lt&&(a=lt,r=Tt,Tt=lt=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[at]||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 ct=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),yt=!1;if(ct)try{var We={};Object.defineProperty(We,"passive",{get:function(){yt=!0}}),window.addEventListener("test",We,We),window.removeEventListener("test",We,We)}catch{yt=!1}var Ze=null,ut=null,ft=null;function Mn(){if(ft)return ft;var r,a=ut,i=a.length,u,b="value"in Ze?Ze.value:Ze.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 ft=b.slice(r,1<u?1-u:void 0)}function rr(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 ra(){return!0}function Qo(){return!1}function vr(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)?ra:Qo,this.isPropagationStopped=Qo,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=ra)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=ra)},persist:function(){},isPersistent:ra}),a}var Ba={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Wo=vr(Ba),bi=x({},Ba,{view:0,detail:0}),MN=vr(bi),hu,mu,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"?(hu=r.screenX-yi.screenX,mu=r.screenY-yi.screenY):mu=hu=0,yi=r),hu)},movementY:function(r){return"movementY"in r?r.movementY:mu}}),Ix=vr(Jo),ON=x({},Jo,{dataTransfer:0}),RN=vr(ON),DN=x({},bi,{relatedTarget:0}),xu=vr(DN),LN=x({},Ba,{animationName:0,elapsedTime:0,pseudoElement:0}),IN=vr(LN),zN=x({},Ba,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),$N=vr(zN),BN=x({},Ba,{data:0}),zx=vr(BN),HN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},PN={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"},UN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qN(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=UN[r])?!!a[r]:!1}function pu(){return qN}var VN=x({},bi,{key:function(r){if(r.key){var a=HN[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=rr(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?PN[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"?rr(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?rr(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),FN=vr(VN),YN=x({},Jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$x=vr(YN),GN=x({},bi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pu}),XN=vr(GN),KN=x({},Ba,{propertyName:0,elapsedTime:0,pseudoElement:0}),ZN=vr(KN),QN=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}),WN=vr(QN),JN=x({},Ba,{newState:0,oldState:0}),e5=vr(JN),t5=[9,13,27,32],gu=ct&&"CompositionEvent"in window,vi=null;ct&&"documentMode"in document&&(vi=document.documentMode);var n5=ct&&"TextEvent"in window&&!vi,Bx=ct&&(!gu||vi&&8<vi&&11>=vi),Hx=" ",Px=!1;function Ux(r,a){switch(r){case"keyup":return t5.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qx(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var gl=!1;function r5(r,a){switch(r){case"compositionend":return qx(a);case"keypress":return a.which!==32?null:(Px=!0,Hx);case"textInput":return r=a.data,r===Hx&&Px?null:r;default:return null}}function s5(r,a){if(gl)return r==="compositionend"||!gu&&Ux(r,a)?(r=Mn(),ft=ut=Ze=null,gl=!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 Bx&&a.locale!=="ko"?null:a.data;default:return null}}var a5={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 Vx(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!a5[r.type]:a==="textarea"}function Fx(r,a,i,u){lt?Tt?Tt.push(u):Tt=[u]:lt=u,a=Uc(a,"onChange"),0<a.length&&(i=new Wo("onChange","change",null,i,u),r.push({event:i,listeners:a}))}var ji=null,wi=null;function l5(r){E0(r,0)}function ec(r){var a=or(r);if(Ur(a))return r}function Yx(r,a){if(r==="change")return a}var Gx=!1;if(ct){var bu;if(ct){var yu="oninput"in document;if(!yu){var Xx=document.createElement("div");Xx.setAttribute("oninput","return;"),yu=typeof Xx.oninput=="function"}bu=yu}else bu=!1;Gx=bu&&(!document.documentMode||9<document.documentMode)}function Kx(){ji&&(ji.detachEvent("onpropertychange",Zx),wi=ji=null)}function Zx(r){if(r.propertyName==="value"&&ec(wi)){var a=[];Fx(a,wi,r,ht(r)),zn(l5,a)}}function i5(r,a,i){r==="focusin"?(Kx(),ji=a,wi=i,ji.attachEvent("onpropertychange",Zx)):r==="focusout"&&Kx()}function o5(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return ec(wi)}function c5(r,a){if(r==="click")return ec(a)}function d5(r,a){if(r==="input"||r==="change")return ec(a)}function u5(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Mr=typeof Object.is=="function"?Object.is:u5;function Ni(r,a){if(Mr(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(!tt.call(a,b)||!Mr(r[b],a[b]))return!1}return!0}function Qx(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Wx(r,a){var i=Qx(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=Qx(i)}}function Jx(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?Jx(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function ep(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var a=Pn(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=Pn(r.document)}return a}function vu(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 f5=ct&&"documentMode"in document&&11>=document.documentMode,bl=null,ju=null,ki=null,wu=!1;function tp(r,a,i){var u=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;wu||bl==null||bl!==Pn(u)||(u=bl,"selectionStart"in u&&vu(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(ju,"onSelect"),0<u.length&&(a=new Wo("onSelect","select",null,a,i),r.push({event:a,listeners:u}),a.target=bl)))}function Ha(r,a){var i={};return i[r.toLowerCase()]=a.toLowerCase(),i["Webkit"+r]="webkit"+a,i["Moz"+r]="moz"+a,i}var yl={animationend:Ha("Animation","AnimationEnd"),animationiteration:Ha("Animation","AnimationIteration"),animationstart:Ha("Animation","AnimationStart"),transitionrun:Ha("Transition","TransitionRun"),transitionstart:Ha("Transition","TransitionStart"),transitioncancel:Ha("Transition","TransitionCancel"),transitionend:Ha("Transition","TransitionEnd")},Nu={},np={};ct&&(np=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 Pa(r){if(Nu[r])return Nu[r];if(!yl[r])return r;var a=yl[r],i;for(i in a)if(a.hasOwnProperty(i)&&i in np)return Nu[r]=a[i];return r}var rp=Pa("animationend"),sp=Pa("animationiteration"),ap=Pa("animationstart"),h5=Pa("transitionrun"),m5=Pa("transitionstart"),x5=Pa("transitioncancel"),lp=Pa("transitionend"),ip=new Map,ku="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(" ");ku.push("scrollEnd");function ls(r,a){ip.set(r,a),ce(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)},Fr=[],vl=0,Su=0;function nc(){for(var r=vl,a=Su=vl=0;a<r;){var i=Fr[a];Fr[a++]=null;var u=Fr[a];Fr[a++]=null;var b=Fr[a];Fr[a++]=null;var j=Fr[a];if(Fr[a++]=null,u!==null&&b!==null){var $=u.pending;$===null?b.next=b:(b.next=$.next,$.next=b),u.pending=b}j!==0&&op(i,b,j)}}function rc(r,a,i,u){Fr[vl++]=r,Fr[vl++]=a,Fr[vl++]=i,Fr[vl++]=u,Su|=u,r.lanes|=u,r=r.alternate,r!==null&&(r.lanes|=u)}function Cu(r,a,i,u){return rc(r,a,i,u),sc(r)}function Ua(r,a){return rc(r,null,null,a),sc(r)}function op(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,If=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 p5(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 Or(r,a,i,u){return new p5(r,a,i,u)}function Eu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Ds(r,a){var i=r.alternate;return i===null?(i=Or(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 cp(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")Eu(r)&&($=1);else if(typeof r=="string")$=j2(r,i,M.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case K:return r=Or(31,i,a,b),r.elementType=K,r.lanes=j,r;case N:return qa(i.children,b,j,a);case C:$=8,b|=24;break;case A:return r=Or(12,i,a,b|2),r.elementType=A,r.lanes=j,r;case R:return r=Or(13,i,a,b),r.elementType=R,r.lanes=j,r;case D:return r=Or(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=Or($,i,a,b),a.elementType=r,a.type=u,a.lanes=j,a}function qa(r,a,i,u){return r=Or(7,r,u,a),r.lanes=i,r}function Tu(r,a,i){return r=Or(6,r,null,a),r.lanes=i,r}function dp(r){var a=Or(18,null,null,0);return a.stateNode=r,a}function _u(r,a,i){return a=Or(4,r.children!==null?r.children:[],r.key,a),a.lanes=i,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}var up=new WeakMap;function Yr(r,a){if(typeof r=="object"&&r!==null){var i=up.get(r);return i!==void 0?i:(a={value:r,source:a,stack:nt(a)},up.set(r,a),a)}return{value:r,source:a,stack:nt(a)}}var wl=[],Nl=0,lc=null,Si=0,Gr=[],Xr=0,sa=null,bs=1,ys="";function Ls(r,a){wl[Nl++]=Si,wl[Nl++]=lc,lc=r,Si=a}function fp(r,a,i){Gr[Xr++]=bs,Gr[Xr++]=ys,Gr[Xr++]=sa,sa=r;var u=bs;r=ys;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-=$,bs=1<<32-St(a)+b|i<<b|u,ys=j+r}else bs=1<<j|i<<b|u,ys=r}function Au(r){r.return!==null&&(Ls(r,1),fp(r,1,0))}function Mu(r){for(;r===lc;)lc=wl[--Nl],wl[Nl]=null,Si=wl[--Nl],wl[Nl]=null;for(;r===sa;)sa=Gr[--Xr],Gr[Xr]=null,ys=Gr[--Xr],Gr[Xr]=null,bs=Gr[--Xr],Gr[Xr]=null}function hp(r,a){Gr[Xr++]=bs,Gr[Xr++]=ys,Gr[Xr++]=sa,bs=a.id,ys=a.overflow,sa=r}var sr=null,Sn=null,Zt=!1,aa=null,Kr=!1,Ou=Error(l(519));function la(r){var a=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ci(Yr(a,r)),Ou}function mp(r){var a=r.stateNode,i=r.type,u=r.memoizedProps;switch(a[Qe]=r,a[at]=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),xr(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||M0(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=He),a=!0):a=!1,a||la(r,!0)}function xp(r){for(sr=r.return;sr;)switch(sr.tag){case 5:case 31:case 13:Kr=!1;return;case 27:case 3:Kr=!0;return;default:sr=sr.return}}function kl(r){if(r!==sr)return!1;if(!Zt)return xp(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&&Sn&&la(r),xp(r),a===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(317));Sn=H0(r)}else if(a===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(317));Sn=H0(r)}else a===27?(a=Sn,va(r.type)?(r=nh,nh=null,Sn=r):Sn=a):Sn=sr?Qr(r.stateNode.nextSibling):null;return!0}function Va(){Sn=sr=null,Zt=!1}function Ru(){var r=aa;return r!==null&&(kr===null?kr=r:kr.push.apply(kr,r),aa=null),r}function Ci(r){aa===null?aa=[r]:aa.push(r)}var Du=F(null),Fa=null,Is=null;function ia(r,a,i){I(Du,a._currentValue),a._currentValue=i}function zs(r){r._currentValue=Du.current,X(Du)}function Lu(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 Iu(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),Lu(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),Lu($,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;Mr(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&&Iu(a,r,i,u),a.flags|=262144}function ic(r){for(r=r.firstContext;r!==null;){if(!Mr(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Ya(r){Fa=r,Is=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function ar(r){return pp(Fa,r)}function oc(r,a){return Fa===null&&Ya(r),pp(r,a)}function pp(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 g5=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()})}},b5=e.unstable_scheduleCallback,y5=e.unstable_NormalPriority,Un={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function zu(){return{controller:new g5,data:new Map,refCount:0}}function Ei(r){r.refCount--,r.refCount===0&&b5(y5,function(){r.controller.abort()})}var Ti=null,$u=0,Cl=0,El=null;function v5(r,a){if(Ti===null){var i=Ti=[];$u=0,Cl=Uf(),El={status:"pending",value:void 0,then:function(u){i.push(u)}}}return $u++,a.then(gp,gp),a}function gp(){if(--$u===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 j5(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 bp=_.S;_.S=function(r,a){t0=vt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&v5(r,a),bp!==null&&bp(r,a)};var Ga=F(null);function Bu(){var r=Ga.current;return r!==null?r:gn.pooledCache}function cc(r,a){a===null?I(Ga,Ga.current):I(Ga,a.pool)}function yp(){var r=Bu();return r===null?null:{parent:Un._currentValue,pool:r}}var Tl=Error(l(460)),Hu=Error(l(474)),dc=Error(l(542)),uc={then:function(){}};function vp(r){return r=r.status,r==="fulfilled"||r==="rejected"}function jp(r,a,i){switch(i=r[i],i===void 0?r.push(a):i!==a&&(a.then(He,He),a=i),a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Np(r),r;default:if(typeof a.status=="string")a.then(He,He);else{if(r=gn,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,Np(r),r}throw Ka=a,Tl}}function Xa(r){try{var a=r._init;return a(r._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(Ka=i,Tl):i}}var Ka=null;function wp(){if(Ka===null)throw Error(l(459));var r=Ka;return Ka=null,r}function Np(r){if(r===Tl||r===dc)throw Error(l(483))}var _l=null,_i=0;function fc(r){var a=_i;return _i+=1,_l===null&&(_l=[]),jp(_l,r,a)}function Ai(r,a){a=a.props.ref,r.ref=a!==void 0?a:null}function hc(r,a){throw a.$$typeof===g?Error(l(525)):(r=Object.prototype.toString.call(a),Error(l(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r)))}function kp(r){function a(de,oe){if(r){var he=de.deletions;he===null?(de.deletions=[oe],de.flags|=16):he.push(oe)}}function i(de,oe){if(!r)return null;for(;oe!==null;)a(de,oe),oe=oe.sibling;return null}function u(de){for(var oe=new Map;de!==null;)de.key!==null?oe.set(de.key,de):oe.set(de.index,de),de=de.sibling;return oe}function b(de,oe){return de=Ds(de,oe),de.index=0,de.sibling=null,de}function j(de,oe,he){return de.index=he,r?(he=de.alternate,he!==null?(he=he.index,he<oe?(de.flags|=67108866,oe):he):(de.flags|=67108866,oe)):(de.flags|=1048576,oe)}function $(de){return r&&de.alternate===null&&(de.flags|=67108866),de}function Q(de,oe,he,Oe){return oe===null||oe.tag!==6?(oe=Tu(he,de.mode,Oe),oe.return=de,oe):(oe=b(oe,he),oe.return=de,oe)}function le(de,oe,he,Oe){var gt=he.type;return gt===N?Ae(de,oe,he.props.children,Oe,he.key):oe!==null&&(oe.elementType===gt||typeof gt=="object"&>!==null&>.$$typeof===z&&Xa(gt)===oe.type)?(oe=b(oe,he.props),Ai(oe,he),oe.return=de,oe):(oe=ac(he.type,he.key,he.props,null,de.mode,Oe),Ai(oe,he),oe.return=de,oe)}function me(de,oe,he,Oe){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==he.containerInfo||oe.stateNode.implementation!==he.implementation?(oe=_u(he,de.mode,Oe),oe.return=de,oe):(oe=b(oe,he.children||[]),oe.return=de,oe)}function Ae(de,oe,he,Oe,gt){return oe===null||oe.tag!==7?(oe=qa(he,de.mode,Oe,gt),oe.return=de,oe):(oe=b(oe,he),oe.return=de,oe)}function Re(de,oe,he){if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return oe=Tu(""+oe,de.mode,he),oe.return=de,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case y:return he=ac(oe.type,oe.key,oe.props,null,de.mode,he),Ai(he,oe),he.return=de,he;case w:return oe=_u(oe,de.mode,he),oe.return=de,oe;case z:return oe=Xa(oe),Re(de,oe,he)}if(L(oe)||q(oe))return oe=qa(oe,de.mode,he,null),oe.return=de,oe;if(typeof oe.then=="function")return Re(de,fc(oe),he);if(oe.$$typeof===k)return Re(de,oc(de,oe),he);hc(de,oe)}return null}function be(de,oe,he,Oe){var gt=oe!==null?oe.key:null;if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return gt!==null?null:Q(de,oe,""+he,Oe);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case y:return he.key===gt?le(de,oe,he,Oe):null;case w:return he.key===gt?me(de,oe,he,Oe):null;case z:return he=Xa(he),be(de,oe,he,Oe)}if(L(he)||q(he))return gt!==null?null:Ae(de,oe,he,Oe,null);if(typeof he.then=="function")return be(de,oe,fc(he),Oe);if(he.$$typeof===k)return be(de,oe,oc(de,he),Oe);hc(de,he)}return null}function ke(de,oe,he,Oe,gt){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number"||typeof Oe=="bigint")return de=de.get(he)||null,Q(oe,de,""+Oe,gt);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case y:return de=de.get(Oe.key===null?he:Oe.key)||null,le(oe,de,Oe,gt);case w:return de=de.get(Oe.key===null?he:Oe.key)||null,me(oe,de,Oe,gt);case z:return Oe=Xa(Oe),ke(de,oe,he,Oe,gt)}if(L(Oe)||q(Oe))return de=de.get(he)||null,Ae(oe,de,Oe,gt,null);if(typeof Oe.then=="function")return ke(de,oe,he,fc(Oe),gt);if(Oe.$$typeof===k)return ke(de,oe,he,oc(oe,Oe),gt);hc(oe,Oe)}return null}function et(de,oe,he,Oe){for(var gt=null,rn=null,it=oe,$t=oe=0,Xt=null;it!==null&&$t<he.length;$t++){it.index>$t?(Xt=it,it=null):Xt=it.sibling;var sn=be(de,it,he[$t],Oe);if(sn===null){it===null&&(it=Xt);break}r&&it&&sn.alternate===null&&a(de,it),oe=j(sn,oe,$t),rn===null?gt=sn:rn.sibling=sn,rn=sn,it=Xt}if($t===he.length)return i(de,it),Zt&&Ls(de,$t),gt;if(it===null){for(;$t<he.length;$t++)it=Re(de,he[$t],Oe),it!==null&&(oe=j(it,oe,$t),rn===null?gt=it:rn.sibling=it,rn=it);return Zt&&Ls(de,$t),gt}for(it=u(it);$t<he.length;$t++)Xt=ke(it,de,$t,he[$t],Oe),Xt!==null&&(r&&Xt.alternate!==null&&it.delete(Xt.key===null?$t:Xt.key),oe=j(Xt,oe,$t),rn===null?gt=Xt:rn.sibling=Xt,rn=Xt);return r&&it.forEach(function(Sa){return a(de,Sa)}),Zt&&Ls(de,$t),gt}function kt(de,oe,he,Oe){if(he==null)throw Error(l(151));for(var gt=null,rn=null,it=oe,$t=oe=0,Xt=null,sn=he.next();it!==null&&!sn.done;$t++,sn=he.next()){it.index>$t?(Xt=it,it=null):Xt=it.sibling;var Sa=be(de,it,sn.value,Oe);if(Sa===null){it===null&&(it=Xt);break}r&&it&&Sa.alternate===null&&a(de,it),oe=j(Sa,oe,$t),rn===null?gt=Sa:rn.sibling=Sa,rn=Sa,it=Xt}if(sn.done)return i(de,it),Zt&&Ls(de,$t),gt;if(it===null){for(;!sn.done;$t++,sn=he.next())sn=Re(de,sn.value,Oe),sn!==null&&(oe=j(sn,oe,$t),rn===null?gt=sn:rn.sibling=sn,rn=sn);return Zt&&Ls(de,$t),gt}for(it=u(it);!sn.done;$t++,sn=he.next())sn=ke(it,de,$t,sn.value,Oe),sn!==null&&(r&&sn.alternate!==null&&it.delete(sn.key===null?$t:sn.key),oe=j(sn,oe,$t),rn===null?gt=sn:rn.sibling=sn,rn=sn);return r&&it.forEach(function(O2){return a(de,O2)}),Zt&&Ls(de,$t),gt}function xn(de,oe,he,Oe){if(typeof he=="object"&&he!==null&&he.type===N&&he.key===null&&(he=he.props.children),typeof he=="object"&&he!==null){switch(he.$$typeof){case y:e:{for(var gt=he.key;oe!==null;){if(oe.key===gt){if(gt=he.type,gt===N){if(oe.tag===7){i(de,oe.sibling),Oe=b(oe,he.props.children),Oe.return=de,de=Oe;break e}}else if(oe.elementType===gt||typeof gt=="object"&>!==null&>.$$typeof===z&&Xa(gt)===oe.type){i(de,oe.sibling),Oe=b(oe,he.props),Ai(Oe,he),Oe.return=de,de=Oe;break e}i(de,oe);break}else a(de,oe);oe=oe.sibling}he.type===N?(Oe=qa(he.props.children,de.mode,Oe,he.key),Oe.return=de,de=Oe):(Oe=ac(he.type,he.key,he.props,null,de.mode,Oe),Ai(Oe,he),Oe.return=de,de=Oe)}return $(de);case w:e:{for(gt=he.key;oe!==null;){if(oe.key===gt)if(oe.tag===4&&oe.stateNode.containerInfo===he.containerInfo&&oe.stateNode.implementation===he.implementation){i(de,oe.sibling),Oe=b(oe,he.children||[]),Oe.return=de,de=Oe;break e}else{i(de,oe);break}else a(de,oe);oe=oe.sibling}Oe=_u(he,de.mode,Oe),Oe.return=de,de=Oe}return $(de);case z:return he=Xa(he),xn(de,oe,he,Oe)}if(L(he))return et(de,oe,he,Oe);if(q(he)){if(gt=q(he),typeof gt!="function")throw Error(l(150));return he=gt.call(he),kt(de,oe,he,Oe)}if(typeof he.then=="function")return xn(de,oe,fc(he),Oe);if(he.$$typeof===k)return xn(de,oe,oc(de,he),Oe);hc(de,he)}return typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint"?(he=""+he,oe!==null&&oe.tag===6?(i(de,oe.sibling),Oe=b(oe,he),Oe.return=de,de=Oe):(i(de,oe),Oe=Tu(he,de.mode,Oe),Oe.return=de,de=Oe),$(de)):i(de,oe)}return function(de,oe,he,Oe){try{_i=0;var gt=xn(de,oe,he,Oe);return _l=null,gt}catch(it){if(it===Tl||it===dc)throw it;var rn=Or(29,it,null,de.mode);return rn.lanes=Oe,rn.return=de,rn}}}var Za=kp(!0),Sp=kp(!1),oa=!1;function Pu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Uu(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 ca(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function da(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),op(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 qu(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 Vu=!1;function Oi(){if(Vu){var r=El;if(r!==null)throw r}}function Ri(r,a,i,u){Vu=!1;var b=r.updateQueue;oa=!1;var j=b.firstBaseUpdate,$=b.lastBaseUpdate,Q=b.shared.pending;if(Q!==null){b.shared.pending=null;var le=Q,me=le.next;le.next=null,$===null?j=me:$.next=me,$=le;var Ae=r.alternate;Ae!==null&&(Ae=Ae.updateQueue,Q=Ae.lastBaseUpdate,Q!==$&&(Q===null?Ae.firstBaseUpdate=me:Q.next=me,Ae.lastBaseUpdate=le))}if(j!==null){var Re=b.baseState;$=0,Ae=me=le=null,Q=j;do{var be=Q.lane&-536870913,ke=be!==Q.lane;if(ke?(Gt&be)===be:(u&be)===be){be!==0&&be===Cl&&(Vu=!0),Ae!==null&&(Ae=Ae.next={lane:0,tag:Q.tag,payload:Q.payload,callback:null,next:null});e:{var et=r,kt=Q;be=a;var xn=i;switch(kt.tag){case 1:if(et=kt.payload,typeof et=="function"){Re=et.call(xn,Re,be);break e}Re=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=kt.payload,be=typeof et=="function"?et.call(xn,Re,be):et,be==null)break e;Re=x({},Re,be);break e;case 2:oa=!0}}be=Q.callback,be!==null&&(r.flags|=64,ke&&(r.flags|=8192),ke=b.callbacks,ke===null?b.callbacks=[be]:ke.push(be))}else ke={lane:be,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},Ae===null?(me=Ae=ke,le=Re):Ae=Ae.next=ke,$|=be;if(Q=Q.next,Q===null){if(Q=b.shared.pending,Q===null)break;ke=Q,Q=ke.next,ke.next=null,b.lastBaseUpdate=ke,b.shared.pending=null}}while(!0);Ae===null&&(le=Re),b.baseState=le,b.firstBaseUpdate=me,b.lastBaseUpdate=Ae,j===null&&(b.shared.lanes=0),xa|=$,r.lanes=$,r.memoizedState=Re}}function Cp(r,a){if(typeof r!="function")throw Error(l(191,r));r.call(a)}function Ep(r,a){var i=r.callbacks;if(i!==null)for(r.callbacks=null,r=0;r<i.length;r++)Cp(i[r],a)}var Al=F(null),mc=F(0);function Tp(r,a){r=Ys,I(mc,r),I(Al,a),Ys=r|a.baseLanes}function Fu(){I(mc,Ys),I(Al,Al.current)}function Yu(){Ys=mc.current,X(Al),X(mc)}var Rr=F(null),Zr=null;function ua(r){var a=r.alternate;I($n,$n.current&1),I(Rr,r),Zr===null&&(a===null||Al.current!==null||a.memoizedState!==null)&&(Zr=r)}function Gu(r){I($n,$n.current),I(Rr,r),Zr===null&&(Zr=r)}function _p(r){r.tag===22?(I($n,$n.current),I(Rr,r),Zr===null&&(Zr=r)):fa()}function fa(){I($n,$n.current),I(Rr,Rr.current)}function Dr(r){X(Rr),Zr===r&&(Zr=null),X($n)}var $n=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||eh(i)||th(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,hn=null,qn=null,pc=!1,Ml=!1,Qa=!1,gc=0,Di=0,Ol=null,w5=0;function Ln(){throw Error(l(321))}function Xu(r,a){if(a===null)return!1;for(var i=0;i<a.length&&i<r.length;i++)if(!Mr(r[i],a[i]))return!1;return!0}function Ku(r,a,i,u,b,j){return $s=j,It=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,_.H=r===null||r.memoizedState===null?fg:uf,Qa=!1,j=i(u,b),Qa=!1,Ml&&(j=Mp(a,i,u,b)),Ap(r),j}function Ap(r){_.H=zi;var a=hn!==null&&hn.next!==null;if($s=0,qn=hn=It=null,pc=!1,Di=0,Ol=null,a)throw Error(l(300));r===null||Vn||(r=r.dependencies,r!==null&&ic(r)&&(Vn=!0))}function Mp(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,qn=hn=null,r.updateQueue!=null){var j=r.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}_.H=hg,j=a(i,u)}while(Ml);return j}function N5(){var r=_.H,a=r.useState()[0];return a=typeof a.then=="function"?Li(a):a,r=r.useState()[0],(hn!==null?hn.memoizedState:null)!==r&&(It.flags|=1024),a}function Zu(){var r=gc!==0;return gc=0,r}function Qu(r,a,i){a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~i}function Wu(r){if(pc){for(r=r.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}pc=!1}$s=0,qn=hn=It=null,Ml=!1,Di=gc=0,Ol=null}function pr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qn===null?It.memoizedState=qn=r:qn=qn.next=r,qn}function Bn(){if(hn===null){var r=It.alternate;r=r!==null?r.memoizedState:null}else r=hn.next;var a=qn===null?It.memoizedState:qn.next;if(a!==null)qn=a,hn=r;else{if(r===null)throw It.alternate===null?Error(l(467)):Error(l(310));hn=r,r={memoizedState:hn.memoizedState,baseState:hn.baseState,baseQueue:hn.baseQueue,queue:hn.queue,next:null},qn===null?It.memoizedState=qn=r:qn=qn.next=r}return qn}function bc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Li(r){var a=Di;return Di+=1,Ol===null&&(Ol=[]),r=jp(Ol,r,a),a=It,(qn===null?a.memoizedState:qn.next)===null&&(a=a.alternate,_.H=a===null||a.memoizedState===null?fg:uf),r}function yc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Li(r);if(r.$$typeof===k)return ar(r)}throw Error(l(438,String(r)))}function Ju(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=Bn();return ef(a,hn,r)}function ef(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,me=a,Ae=!1;do{var Re=me.lane&-536870913;if(Re!==me.lane?(Gt&Re)===Re:($s&Re)===Re){var be=me.revertLane;if(be===0)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),Re===Cl&&(Ae=!0);else if(($s&be)===be){me=me.next,be===Cl&&(Ae=!0);continue}else Re={lane:0,revertLane:me.revertLane,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},le===null?(Q=le=Re,$=j):le=le.next=Re,It.lanes|=be,xa|=be;Re=me.action,Qa&&i(j,Re),j=me.hasEagerState?me.eagerState:i(j,Re)}else be={lane:Re,revertLane:me.revertLane,gesture:me.gesture,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},le===null?(Q=le=be,$=j):le=le.next=be,It.lanes|=Re,xa|=Re;me=me.next}while(me!==null&&me!==a);if(le===null?$=j:le.next=Q,!Mr(j,r.memoizedState)&&(Vn=!0,Ae&&(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 tf(r){var a=Bn(),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);Mr(j,a.memoizedState)||(Vn=!0),a.memoizedState=j,a.baseQueue===null&&(a.baseState=j),i.lastRenderedState=j}return[j,u]}function Op(r,a,i){var u=It,b=Bn(),j=Zt;if(j){if(i===void 0)throw Error(l(407));i=i()}else i=a();var $=!Mr((hn||b).memoizedState,i);if($&&(b.memoizedState=i,Vn=!0),b=b.queue,sf(Lp.bind(null,u,b,r),[r]),b.getSnapshot!==a||$||qn!==null&&qn.memoizedState.tag&1){if(u.flags|=2048,Rl(9,{destroy:void 0},Dp.bind(null,u,b,i,a),null),gn===null)throw Error(l(349));j||($s&127)!==0||Rp(u,a,i)}return i}function Rp(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 Dp(r,a,i,u){a.value=i,a.getSnapshot=u,Ip(a)&&zp(r)}function Lp(r,a,i){return i(function(){Ip(a)&&zp(r)})}function Ip(r){var a=r.getSnapshot;r=r.value;try{var i=a();return!Mr(r,i)}catch{return!0}}function zp(r){var a=Ua(r,2);a!==null&&Sr(a,r,2)}function nf(r){var a=pr();if(typeof r=="function"){var i=r;if(r=i(),Qa){_t(!0);try{i()}finally{_t(!1)}}}return a.memoizedState=a.baseState=r,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:r},a}function $p(r,a,i,u){return r.baseState=i,ef(r,hn,typeof u=="function"?u:Bs)}function k5(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($)}};_.T!==null?i(!0):j.isTransition=!1,u(j),i=a.pending,i===null?(j.next=a.pending=j,Bp(a,j)):(j.next=i.next,a.pending=i.next=j)}}function Bp(r,a){var i=a.action,u=a.payload,b=r.state;if(a.isTransition){var j=_.T,$={};_.T=$;try{var Q=i(b,u),le=_.S;le!==null&&le($,Q),Hp(r,a,Q)}catch(me){rf(r,a,me)}finally{j!==null&&$.types!==null&&(j.types=$.types),_.T=j}}else try{j=i(b,u),Hp(r,a,j)}catch(me){rf(r,a,me)}}function Hp(r,a,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(u){Pp(r,a,u)},function(u){return rf(r,a,u)}):Pp(r,a,i)}function Pp(r,a,i){a.status="fulfilled",a.value=i,Up(a),r.state=i,a=r.pending,a!==null&&(i=a.next,i===a?r.pending=null:(i=i.next,a.next=i,Bp(r,i)))}function rf(r,a,i){var u=r.pending;if(r.pending=null,u!==null){u=u.next;do a.status="rejected",a.reason=i,Up(a),a=a.next;while(a!==u)}r.action=null}function Up(r){r=r.listeners;for(var a=0;a<r.length;a++)(0,r[a])()}function qp(r,a){return a}function Vp(r,a){if(Zt){var i=gn.formState;if(i!==null){e:{var u=It;if(Zt){if(Sn){t:{for(var b=Sn,j=Kr;b.nodeType!==8;){if(!j){b=null;break t}if(b=Qr(b.nextSibling),b===null){b=null;break t}}j=b.data,b=j==="F!"||j==="F"?b:null}if(b){Sn=Qr(b.nextSibling),u=b.data==="F!";break e}}la(u)}u=!1}u&&(a=i[0])}}return i=pr(),i.memoizedState=i.baseState=a,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:qp,lastRenderedState:a},i.queue=u,i=cg.bind(null,It,u),u.dispatch=i,u=nf(!1),j=df.bind(null,It,!1,u.queue),u=pr(),b={state:a,dispatch:null,action:r,pending:null},u.queue=b,i=k5.bind(null,It,b,j,i),b.dispatch=i,u.memoizedState=r,[a,i,!1]}function Fp(r){var a=Bn();return Yp(a,hn,r)}function Yp(r,a,i){if(a=ef(r,a,qp)[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=Bn();var b=a.queue,j=b.dispatch;return i!==a.memoizedState&&(It.flags|=2048,Rl(9,{destroy:void 0},S5.bind(null,b,i),null)),[u,j,r]}function S5(r,a){r.action=a}function Gp(r){var a=Bn(),i=hn;if(i!==null)return Yp(a,i,r);Bn(),a=a.memoizedState,i=Bn();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 Xp(){return Bn().memoizedState}function jc(r,a,i,u){var b=pr();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=Bn();u=u===void 0?null:u;var j=b.memoizedState.inst;hn!==null&&u!==null&&Xu(u,hn.memoizedState.deps)?b.memoizedState=Rl(a,j,i,u):(It.flags|=r,b.memoizedState=Rl(1|a,j,i,u))}function Kp(r,a){jc(8390656,8,r,a)}function sf(r,a){wc(2048,8,r,a)}function C5(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 Zp(r){var a=Bn().memoizedState;return C5({ref:a,nextImpl:r}),function(){if((an&2)!==0)throw Error(l(440));return a.impl.apply(void 0,arguments)}}function Qp(r,a){return wc(4,2,r,a)}function Wp(r,a){return wc(4,4,r,a)}function Jp(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 eg(r,a,i){i=i!=null?i.concat([r]):null,wc(4,4,Jp.bind(null,a,r),i)}function af(){}function tg(r,a){var i=Bn();a=a===void 0?null:a;var u=i.memoizedState;return a!==null&&Xu(a,u[1])?u[0]:(i.memoizedState=[r,a],r)}function ng(r,a){var i=Bn();a=a===void 0?null:a;var u=i.memoizedState;if(a!==null&&Xu(a,u[1]))return u[0];if(u=r(),Qa){_t(!0);try{r()}finally{_t(!1)}}return i.memoizedState=[u,a],u}function lf(r,a,i){return i===void 0||($s&1073741824)!==0&&(Gt&261930)===0?r.memoizedState=a:(r.memoizedState=i,r=r0(),It.lanes|=r,xa|=r,i)}function rg(r,a,i,u){return Mr(i,a)?i:Al.current!==null?(r=lf(r,i,u),Mr(r,a)||(Vn=!0),r):($s&42)===0||($s&1073741824)!==0&&(Gt&261930)===0?(Vn=!0,r.memoizedState=i):(r=r0(),It.lanes|=r,xa|=r,a)}function sg(r,a,i,u,b){var j=P.p;P.p=j!==0&&8>j?j:8;var $=_.T,Q={};_.T=Q,df(r,!1,a,i);try{var le=b(),me=_.S;if(me!==null&&me(Q,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var Ae=j5(le,u);Ii(r,a,Ae,zr(r))}else Ii(r,a,u,zr(r))}catch(Re){Ii(r,a,{then:function(){},status:"rejected",reason:Re},zr())}finally{P.p=j,$!==null&&Q.types!==null&&($.types=Q.types),_.T=$}}function E5(){}function of(r,a,i,u){if(r.tag!==5)throw Error(l(476));var b=ag(r).queue;sg(r,b,a,V,i===null?E5:function(){return lg(r),i(u)})}function ag(r){var a=r.memoizedState;if(a!==null)return a;a={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:V},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 lg(r){var a=ag(r);a.next===null&&(a=r.alternate.memoizedState),Ii(r,a.next.queue,{},zr())}function cf(){return ar(Ji)}function ig(){return Bn().memoizedState}function og(){return Bn().memoizedState}function T5(r){for(var a=r.return;a!==null;){switch(a.tag){case 24:case 3:var i=zr();r=ca(i);var u=da(a,r,i);u!==null&&(Sr(u,a,i),Mi(u,a,i)),a={cache:zu()},r.payload=a;return}a=a.return}}function _5(r,a,i){var u=zr();i={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Nc(r)?dg(a,i):(i=Cu(r,a,i,u),i!==null&&(Sr(i,r,u),ug(i,a,u)))}function cg(r,a,i){var u=zr();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))dg(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,Mr(Q,$))return rc(r,a,b,0),gn===null&&nc(),!1}catch{}if(i=Cu(r,a,b,u),i!==null)return Sr(i,r,u),ug(i,a,u),!0}return!1}function df(r,a,i,u){if(u={lane:2,revertLane:Uf(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Nc(r)){if(a)throw Error(l(479))}else a=Cu(r,i,u,2),a!==null&&Sr(a,r,2)}function Nc(r){var a=r.alternate;return r===It||a!==null&&a===It}function dg(r,a){Ml=pc=!0;var i=r.pending;i===null?a.next=a:(a.next=i.next,i.next=a),r.pending=a}function ug(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:ar,use:yc,useCallback:Ln,useContext:Ln,useEffect:Ln,useImperativeHandle:Ln,useLayoutEffect:Ln,useInsertionEffect:Ln,useMemo:Ln,useReducer:Ln,useRef:Ln,useState:Ln,useDebugValue:Ln,useDeferredValue:Ln,useTransition:Ln,useSyncExternalStore:Ln,useId:Ln,useHostTransitionStatus:Ln,useFormState:Ln,useActionState:Ln,useOptimistic:Ln,useMemoCache:Ln,useCacheRefresh:Ln};zi.useEffectEvent=Ln;var fg={readContext:ar,use:yc,useCallback:function(r,a){return pr().memoizedState=[r,a===void 0?null:a],r},useContext:ar,useEffect:Kp,useImperativeHandle:function(r,a,i){i=i!=null?i.concat([r]):null,jc(4194308,4,Jp.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=pr();a=a===void 0?null:a;var u=r();if(Qa){_t(!0);try{r()}finally{_t(!1)}}return i.memoizedState=[u,a],u},useReducer:function(r,a,i){var u=pr();if(i!==void 0){var b=i(a);if(Qa){_t(!0);try{i(a)}finally{_t(!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=_5.bind(null,It,r),[u.memoizedState,r]},useRef:function(r){var a=pr();return r={current:r},a.memoizedState=r},useState:function(r){r=nf(r);var a=r.queue,i=cg.bind(null,It,a);return a.dispatch=i,[r.memoizedState,i]},useDebugValue:af,useDeferredValue:function(r,a){var i=pr();return lf(i,r,a)},useTransition:function(){var r=nf(!1);return r=sg.bind(null,It,r.queue,!0,!1),pr().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,a,i){var u=It,b=pr();if(Zt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=a(),gn===null)throw Error(l(349));(Gt&127)!==0||Rp(u,a,i)}b.memoizedState=i;var j={value:i,getSnapshot:a};return b.queue=j,Kp(Lp.bind(null,u,j,r),[r]),u.flags|=2048,Rl(9,{destroy:void 0},Dp.bind(null,u,j,i,a),null),i},useId:function(){var r=pr(),a=gn.identifierPrefix;if(Zt){var i=ys,u=bs;i=(u&~(1<<32-St(u)-1)).toString(32)+i,a="_"+a+"R_"+i,i=gc++,0<i&&(a+="H"+i.toString(32)),a+="_"}else i=w5++,a="_"+a+"r_"+i.toString(32)+"_";return r.memoizedState=a},useHostTransitionStatus:cf,useFormState:Vp,useActionState:Vp,useOptimistic:function(r){var a=pr();a.memoizedState=a.baseState=r;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=i,a=df.bind(null,It,!0,i),i.dispatch=a,[r,a]},useMemoCache:Ju,useCacheRefresh:function(){return pr().memoizedState=T5.bind(null,It)},useEffectEvent:function(r){var a=pr(),i={impl:r};return a.memoizedState=i,function(){if((an&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},uf={readContext:ar,use:yc,useCallback:tg,useContext:ar,useEffect:sf,useImperativeHandle:eg,useInsertionEffect:Qp,useLayoutEffect:Wp,useMemo:ng,useReducer:vc,useRef:Xp,useState:function(){return vc(Bs)},useDebugValue:af,useDeferredValue:function(r,a){var i=Bn();return rg(i,hn.memoizedState,r,a)},useTransition:function(){var r=vc(Bs)[0],a=Bn().memoizedState;return[typeof r=="boolean"?r:Li(r),a]},useSyncExternalStore:Op,useId:ig,useHostTransitionStatus:cf,useFormState:Fp,useActionState:Fp,useOptimistic:function(r,a){var i=Bn();return $p(i,hn,r,a)},useMemoCache:Ju,useCacheRefresh:og};uf.useEffectEvent=Zp;var hg={readContext:ar,use:yc,useCallback:tg,useContext:ar,useEffect:sf,useImperativeHandle:eg,useInsertionEffect:Qp,useLayoutEffect:Wp,useMemo:ng,useReducer:tf,useRef:Xp,useState:function(){return tf(Bs)},useDebugValue:af,useDeferredValue:function(r,a){var i=Bn();return hn===null?lf(i,r,a):rg(i,hn.memoizedState,r,a)},useTransition:function(){var r=tf(Bs)[0],a=Bn().memoizedState;return[typeof r=="boolean"?r:Li(r),a]},useSyncExternalStore:Op,useId:ig,useHostTransitionStatus:cf,useFormState:Gp,useActionState:Gp,useOptimistic:function(r,a){var i=Bn();return hn!==null?$p(i,hn,r,a):(i.baseState=r,[r,i.queue.dispatch])},useMemoCache:Ju,useCacheRefresh:og};hg.useEffectEvent=Zp;function ff(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 hf={enqueueSetState:function(r,a,i){r=r._reactInternals;var u=zr(),b=ca(u);b.payload=a,i!=null&&(b.callback=i),a=da(r,b,u),a!==null&&(Sr(a,r,u),Mi(a,r,u))},enqueueReplaceState:function(r,a,i){r=r._reactInternals;var u=zr(),b=ca(u);b.tag=1,b.payload=a,i!=null&&(b.callback=i),a=da(r,b,u),a!==null&&(Sr(a,r,u),Mi(a,r,u))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var i=zr(),u=ca(i);u.tag=2,a!=null&&(u.callback=a),a=da(r,u,i),a!==null&&(Sr(a,r,i),Mi(a,r,i))}};function mg(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 xg(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&&hf.enqueueReplaceState(a,a.state,null)}function Wa(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 pg(r){tc(r)}function gg(r){console.error(r)}function bg(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 yg(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 mf(r,a,i){return i=ca(i),i.tag=3,i.payload={element:null},i.callback=function(){kc(r,a)},i}function vg(r){return r=ca(r),r.tag=3,r}function jg(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(){yg(a,i,u)}}var $=i.stateNode;$!==null&&typeof $.componentDidCatch=="function"&&(r.callback=function(){yg(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 A5(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=Rr.current,i!==null){switch(i.tag){case 31:case 13:return Zr===null?Ic():i.alternate===null&&In===0&&(In=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),Bf(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)),Bf(r,u,b)),!1}throw Error(l(435,i.tag))}return Bf(r,u,b),Ic(),!1}if(Zt)return a=Rr.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=b,u!==Ou&&(r=Error(l(422),{cause:u}),Ci(Yr(r,i)))):(u!==Ou&&(a=Error(l(423),{cause:u}),Ci(Yr(a,i))),r=r.current.alternate,r.flags|=65536,b&=-b,r.lanes|=b,u=Yr(u,i),b=mf(r.stateNode,u,b),qu(r,b),In!==4&&(In=2)),!1;var j=Error(l(520),{cause:u});if(j=Yr(j,i),Fi===null?Fi=[j]:Fi.push(j),In!==4&&(In=2),a===null)return!0;u=Yr(u,i),i=a;do{switch(i.tag){case 3:return i.flags|=65536,r=b&-b,i.lanes|=r,r=mf(i.stateNode,u,r),qu(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=vg(b),jg(b,r,i,u),qu(i,b),!1}i=i.return}while(i!==null);return!1}var xf=Error(l(461)),Vn=!1;function lr(r,a,i,u){a.child=r===null?Sp(a,null,i,u):Za(a,r.child,i,u)}function wg(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 Ya(a),u=Ku(r,a,i,$,j,b),Q=Zu(),r!==null&&!Vn?(Qu(r,a,b),Hs(r,a,b)):(Zt&&Q&&Au(a),a.flags|=1,lr(r,a,u,b),a.child)}function Ng(r,a,i,u,b){if(r===null){var j=i.type;return typeof j=="function"&&!Eu(j)&&j.defaultProps===void 0&&i.compare===null?(a.tag=15,a.type=j,kg(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,!Nf(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 kg(r,a,i,u,b){if(r!==null){var j=r.memoizedProps;if(Ni(j,u)&&r.ref===a.ref)if(Vn=!1,a.pendingProps=u=j,Nf(r,b))(r.flags&131072)!==0&&(Vn=!0);else return a.lanes=r.lanes,Hs(r,a,b)}return pf(r,a,i,u,b)}function Sg(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 Cg(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?Tp(a,j):Fu(),_p(a);else return u=a.lanes=536870912,Cg(r,a,j!==null?j.baseLanes|i:i,i,u)}else j!==null?(cc(a,j.cachePool),Tp(a,j),fa(),a.memoizedState=null):(r!==null&&cc(a,null),Fu(),fa());return lr(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 Cg(r,a,i,u,b){var j=Bu();return j=j===null?null:{parent:Un._currentValue,pool:j},a.memoizedState={baseLanes:i,cachePool:j},r!==null&&cc(a,null),Fu(),_p(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 Eg(r,a,i){return Za(a,r.child,null,i),r=Sc(a,a.pendingProps),r.flags|=2,Dr(a),a.memoizedState=null,r}function M5(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(Gu(a),(r=Sn)?(r=B0(r,Kr),r=r!==null&&r.data==="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:sa!==null?{id:bs,overflow:ys}:null,retryLane:536870912,hydrationErrors:null},i=dp(r),i.return=a,a.child=i,sr=a,Sn=null)):r=null,r===null)throw la(a);return a.lanes=536870912,null}return Sc(a,u)}var j=r.memoizedState;if(j!==null){var $=j.dehydrated;if(Gu(a),b)if(a.flags&256)a.flags&=-257,a=Eg(r,a,i);else if(a.memoizedState!==null)a.child=r.child,a.flags|=128,a=null;else throw Error(l(558));else if(Vn||Sl(r,a,i,!1),b=(i&r.childLanes)!==0,Vn||b){if(u=gn,u!==null&&($=Pe(u,i),$!==0&&$!==j.retryLane))throw j.retryLane=$,Ua(r,$),Sr(u,r,$),xf;Ic(),a=Eg(r,a,i)}else r=j.treeContext,Sn=Qr($.nextSibling),sr=a,Zt=!0,aa=null,Kr=!1,r!==null&&hp(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 Ya(a),i=Ku(r,a,i,u,void 0,b),u=Zu(),r!==null&&!Vn?(Qu(r,a,b),Hs(r,a,b)):(Zt&&u&&Au(a),a.flags|=1,lr(r,a,i,b),a.child)}function Tg(r,a,i,u,b,j){return Ya(a),a.updateQueue=null,i=Mp(a,u,i,b),Ap(r),u=Zu(),r!==null&&!Vn?(Qu(r,a,j),Hs(r,a,j)):(Zt&&u&&Au(a),a.flags|=1,lr(r,a,i,j),a.child)}function _g(r,a,i,u,b){if(Ya(a),a.stateNode===null){var j=jl,$=i.contextType;typeof $=="object"&&$!==null&&(j=ar($)),j=new i(u,j),a.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=hf,a.stateNode=j,j._reactInternals=a,j=a.stateNode,j.props=u,j.state=a.memoizedState,j.refs={},Pu(a),$=i.contextType,j.context=typeof $=="object"&&$!==null?ar($):jl,j.state=a.memoizedState,$=i.getDerivedStateFromProps,typeof $=="function"&&(ff(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&&hf.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=Wa(i,Q);j.props=le;var me=j.context,Ae=i.contextType;$=jl,typeof Ae=="object"&&Ae!==null&&($=ar(Ae));var Re=i.getDerivedStateFromProps;Ae=typeof Re=="function"||typeof j.getSnapshotBeforeUpdate=="function",Q=a.pendingProps!==Q,Ae||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(Q||me!==$)&&xg(a,j,u,$),oa=!1;var be=a.memoizedState;j.state=be,Ri(a,u,j,b),Oi(),me=a.memoizedState,Q||be!==me||oa?(typeof Re=="function"&&(ff(a,i,Re,u),me=a.memoizedState),(le=oa||mg(a,i,le,u,be,me,$))?(Ae||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=me),j.props=u,j.state=me,j.context=$,u=le):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!1)}else{j=a.stateNode,Uu(r,a),$=a.memoizedProps,Ae=Wa(i,$),j.props=Ae,Re=a.pendingProps,be=j.context,me=i.contextType,le=jl,typeof me=="object"&&me!==null&&(le=ar(me)),Q=i.getDerivedStateFromProps,(me=typeof Q=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||($!==Re||be!==le)&&xg(a,j,u,le),oa=!1,be=a.memoizedState,j.state=be,Ri(a,u,j,b),Oi();var ke=a.memoizedState;$!==Re||be!==ke||oa||r!==null&&r.dependencies!==null&&ic(r.dependencies)?(typeof Q=="function"&&(ff(a,i,Q,u),ke=a.memoizedState),(Ae=oa||mg(a,i,Ae,u,be,ke,le)||r!==null&&r.dependencies!==null&&ic(r.dependencies))?(me||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(u,ke,le),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(u,ke,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=ke),j.props=u,j.state=ke,j.context=le,u=Ae):(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=Za(a,r.child,null,b),a.child=Za(a,null,i,b)):lr(r,a,i,b),a.memoizedState=j.state,r=a.child):r=Hs(r,a,b),r}function Ag(r,a,i,u){return Va(),a.flags|=256,lr(r,a,i,u),a.child}var gf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bf(r){return{baseLanes:r,cachePool:yp()}}function yf(r,a,i){return r=r!==null?r.childLanes&~i:0,a&&(r|=Ir),r}function Mg(r,a,i){var u=a.pendingProps,b=!1,j=(a.flags&128)!==0,$;if(($=j)||($=r!==null&&r.memoizedState===null?!1:($n.current&2)!==0),$&&(b=!0,a.flags&=-129),$=(a.flags&32)!==0,a.flags&=-33,r===null){if(Zt){if(b?ua(a):fa(),(r=Sn)?(r=B0(r,Kr),r=r!==null&&r.data!=="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:sa!==null?{id:bs,overflow:ys}:null,retryLane:536870912,hydrationErrors:null},i=dp(r),i.return=a,a.child=i,sr=a,Sn=null)):r=null,r===null)throw la(a);return th(r)?a.lanes=32:a.lanes=536870912,null}var Q=u.children;return u=u.fallback,b?(fa(),b=a.mode,Q=Ec({mode:"hidden",children:Q},b),u=qa(u,b,i,null),Q.return=a,u.return=a,Q.sibling=u,a.child=Q,u=a.child,u.memoizedState=bf(i),u.childLanes=yf(r,$,i),a.memoizedState=gf,$i(null,u)):(ua(a),vf(a,Q))}var le=r.memoizedState;if(le!==null&&(Q=le.dehydrated,Q!==null)){if(j)a.flags&256?(ua(a),a.flags&=-257,a=jf(r,a,i)):a.memoizedState!==null?(fa(),a.child=r.child,a.flags|=128,a=null):(fa(),Q=u.fallback,b=a.mode,u=Ec({mode:"visible",children:u.children},b),Q=qa(Q,b,i,null),Q.flags|=2,u.return=a,Q.return=a,u.sibling=Q,a.child=u,Za(a,r.child,null,i),u=a.child,u.memoizedState=bf(i),u.childLanes=yf(r,$,i),a.memoizedState=gf,a=$i(null,u));else if(ua(a),th(Q)){if($=Q.nextSibling&&Q.nextSibling.dataset,$)var me=$.dgst;$=me,u=Error(l(419)),u.stack="",u.digest=$,Ci({value:u,source:null,stack:null}),a=jf(r,a,i)}else if(Vn||Sl(r,a,i,!1),$=(i&r.childLanes)!==0,Vn||$){if($=gn,$!==null&&(u=Pe($,i),u!==0&&u!==le.retryLane))throw le.retryLane=u,Ua(r,u),Sr($,r,u),xf;eh(Q)||Ic(),a=jf(r,a,i)}else eh(Q)?(a.flags|=192,a.child=r.child,a=null):(r=le.treeContext,Sn=Qr(Q.nextSibling),sr=a,Zt=!0,aa=null,Kr=!1,r!==null&&hp(a,r),a=vf(a,u.children),a.flags|=4096);return a}return b?(fa(),Q=u.fallback,b=a.mode,le=r.child,me=le.sibling,u=Ds(le,{mode:"hidden",children:u.children}),u.subtreeFlags=le.subtreeFlags&65011712,me!==null?Q=Ds(me,Q):(Q=qa(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=bf(i):(b=Q.cachePool,b!==null?(le=Un._currentValue,b=b.parent!==le?{parent:le,pool:le}:b):b=yp(),Q={baseLanes:Q.baseLanes|i,cachePool:b}),u.memoizedState=Q,u.childLanes=yf(r,$,i),a.memoizedState=gf,$i(r.child,u)):(ua(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 vf(r,a){return a=Ec({mode:"visible",children:a},r.mode),a.return=r,r.child=a}function Ec(r,a){return r=Or(22,r,null,a),r.lanes=0,r}function jf(r,a,i){return Za(a,r.child,null,i),r=vf(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function Og(r,a,i){r.lanes|=a;var u=r.alternate;u!==null&&(u.lanes|=a),Lu(r.return,a,i)}function wf(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 Rg(r,a,i){var u=a.pendingProps,b=u.revealOrder,j=u.tail;u=u.children;var $=$n.current,Q=($&2)!==0;if(Q?($=$&1|2,a.flags|=128):$&=1,I($n,$),lr(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&&Og(r,i,a);else if(r.tag===19)Og(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),wf(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}wf(a,!0,i,null,j,u);break;case"together":wf(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),xa|=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 Nf(r,a){return(r.lanes&a)!==0?!0:(r=r.dependencies,!!(r!==null&&ic(r)))}function O5(r,a,i){switch(a.tag){case 3:ne(a,a.stateNode.containerInfo),ia(a,Un,r.memoizedState.cache),Va();break;case 27:case 5:fe(a);break;case 4:ne(a,a.stateNode.containerInfo);break;case 10:ia(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Gu(a),null;break;case 13:var u=a.memoizedState;if(u!==null)return u.dehydrated!==null?(ua(a),a.flags|=128,null):(i&a.child.childLanes)!==0?Mg(r,a,i):(ua(a),r=Hs(r,a,i),r!==null?r.sibling:null);ua(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 Rg(r,a,i);a.flags|=128}if(b=a.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),I($n,$n.current),u)break;return null;case 22:return a.lanes=0,Sg(r,a,i,a.pendingProps);case 24:ia(a,Un,r.memoizedState.cache)}return Hs(r,a,i)}function Dg(r,a,i){if(r!==null)if(r.memoizedProps!==a.pendingProps)Vn=!0;else{if(!Nf(r,i)&&(a.flags&128)===0)return Vn=!1,O5(r,a,i);Vn=(r.flags&131072)!==0}else Vn=!1,Zt&&(a.flags&1048576)!==0&&fp(a,Si,a.index);switch(a.lanes=0,a.tag){case 16:e:{var u=a.pendingProps;if(r=Xa(a.elementType),a.type=r,typeof r=="function")Eu(r)?(u=Wa(r,u),a.tag=1,a=_g(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=wg(null,a,r,u,i);break e}else if(b===Y){a.tag=14,a=Ng(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=Wa(u,a.pendingProps),_g(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,Uu(r,a),Ri(a,u,null,i);var $=a.memoizedState;if(u=$.cache,ia(a,Un,u),u!==j.cache&&Iu(a,[Un],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=Ag(r,a,u,i);break e}else if(u!==b){b=Yr(Error(l(424)),a),Ci(b),a=Ag(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,Sn=Qr(r.firstChild),sr=a,Zt=!0,aa=null,Kr=!0,i=Sp(a,null,u,i),a.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Va(),u===b){a=Hs(r,a,i);break e}lr(r,a,u,i)}a=a.child}return a;case 26:return Cc(r,a),r===null?(i=F0(a.type,null,a.pendingProps,null))?a.memoizedState=i:Zt||(i=a.type,r=a.pendingProps,u=qc(Z.current).createElement(i),u[Qe]=a,u[at]=r,ir(u,i,r),wn(u),a.stateNode=u):a.memoizedState=F0(a.type,r.memoizedProps,a.pendingProps,r.memoizedState),null;case 27:return fe(a),r===null&&Zt&&(u=a.stateNode=U0(a.type,a.pendingProps,Z.current),sr=a,Kr=!0,b=Sn,va(a.type)?(nh=b,Sn=Qr(u.firstChild)):Sn=b),lr(r,a,a.pendingProps.children,i),Cc(r,a),r===null&&(a.flags|=4194304),a.child;case 5:return r===null&&Zt&&((b=u=Sn)&&(u=o2(u,a.type,a.pendingProps,Kr),u!==null?(a.stateNode=u,sr=a,Sn=Qr(u.firstChild),Kr=!1,b=!0):b=!1),b||la(a)),fe(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=Ku(r,a,N5,null,null,i),Ji._currentValue=b),Cc(r,a),lr(r,a,u,i),a.child;case 6:return r===null&&Zt&&((r=i=Sn)&&(i=c2(i,a.pendingProps,Kr),i!==null?(a.stateNode=i,sr=a,Sn=null,r=!0):r=!1),r||la(a)),null;case 13:return Mg(r,a,i);case 4:return ne(a,a.stateNode.containerInfo),u=a.pendingProps,r===null?a.child=Za(a,null,u,i):lr(r,a,u,i),a.child;case 11:return wg(r,a,a.type,a.pendingProps,i);case 7:return lr(r,a,a.pendingProps,i),a.child;case 8:return lr(r,a,a.pendingProps.children,i),a.child;case 12:return lr(r,a,a.pendingProps.children,i),a.child;case 10:return u=a.pendingProps,ia(a,a.type,u.value),lr(r,a,u.children,i),a.child;case 9:return b=a.type._context,u=a.pendingProps.children,Ya(a),b=ar(b),u=u(b),a.flags|=1,lr(r,a,u,i),a.child;case 14:return Ng(r,a,a.type,a.pendingProps,i);case 15:return kg(r,a,a.type,a.pendingProps,i);case 19:return Rg(r,a,i);case 31:return M5(r,a,i);case 22:return Sg(r,a,i,a.pendingProps);case 24:return Ya(a),u=ar(Un),r===null?(b=Bu(),b===null&&(b=gn,j=zu(),b.pooledCache=j,j.refCount++,j!==null&&(b.pooledCacheLanes|=i),b=j),a.memoizedState={parent:u,cache:b},Pu(a),ia(a,Un,b)):((r.lanes&i)!==0&&(Uu(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),ia(a,Un,u)):(u=j.cache,ia(a,Un,u),u!==b.cache&&Iu(a,[Un],i,!0))),lr(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 kf(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(i0())r.flags|=8192;else throw Ka=uc,Hu}else r.flags&=-16777217}function Lg(r,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!Z0(a))if(i0())r.flags|=8192;else throw Ka=uc,Hu}function Tc(r,a){a!==null&&(r.flags|=4),r.flags&16384&&(a=r.tag!==22?un():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 Cn(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 R5(r,a,i){var u=a.pendingProps;switch(Mu(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Cn(a),null;case 1:return Cn(a),null;case 3:return i=a.stateNode,u=null,r!==null&&(u=r.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),zs(Un),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,Ru())),Cn(a),null;case 26:var b=a.type,j=a.memoizedState;return r===null?(Ps(a),j!==null?(Cn(a),Lg(a,j)):(Cn(a),kf(a,b,null,u,i))):j?j!==r.memoizedState?(Ps(a),Cn(a),Lg(a,j)):(Cn(a),a.flags&=-16777217):(r=r.memoizedProps,r!==u&&Ps(a),Cn(a),kf(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 Cn(a),null}r=M.current,kl(a)?mp(a):(r=U0(b,u,i),a.stateNode=r,Ps(a))}return Cn(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 Cn(a),null}if(j=M.current,kl(a))mp(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[Qe]=a,j[at]=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(ir(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 Cn(a),kf(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=sr,b!==null)switch(b.tag){case 27:case 5:u=b.memoizedProps}r[Qe]=a,r=!!(r.nodeValue===i||u!==null&&u.suppressHydrationWarning===!0||M0(r.nodeValue,i)),r||la(a,!0)}else r=qc(r).createTextNode(u),r[Qe]=a,a.stateNode=r}return Cn(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[Qe]=a}else Va(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Cn(a),r=!1}else i=Ru(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=i),r=!0;if(!r)return a.flags&256?(Dr(a),a):(Dr(a),null);if((a.flags&128)!==0)throw Error(l(558))}return Cn(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[Qe]=a}else Va(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Cn(a),b=!1}else b=Ru(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=b),b=!0;if(!b)return a.flags&256?(Dr(a),a):(Dr(a),null)}return Dr(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),Cn(a),null);case 4:return ae(),r===null&&Yf(a.stateNode.containerInfo),Cn(a),null;case 10:return zs(a.type),Cn(a),null;case 19:if(X($n),u=a.memoizedState,u===null)return Cn(a),null;if(b=(a.flags&128)!==0,j=u.rendering,j===null)if(b)Bi(u,!1);else{if(In!==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;)cp(i,r),i=i.sibling;return I($n,$n.current&1|2),Zt&&Ls(a,u.treeForkCount),a.child}r=r.sibling}u.tail!==null&&vt()>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 Cn(a),null}else 2*vt()-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=vt(),r.sibling=null,i=$n.current,I($n,b?i&1|2:i&1),Zt&&Ls(a,u.treeForkCount),r):(Cn(a),null);case 22:case 23:return Dr(a),Yu(),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&&(Cn(a),a.subtreeFlags&6&&(a.flags|=8192)):Cn(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(Ga),null;case 24:return i=null,r!==null&&(i=r.memoizedState.cache),a.memoizedState.cache!==i&&(a.flags|=2048),zs(Un),Cn(a),null;case 25:return null;case 30:return null}throw Error(l(156,a.tag))}function D5(r,a){switch(Mu(a),a.tag){case 1:return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return zs(Un),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(Dr(a),a.alternate===null)throw Error(l(340));Va()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 13:if(Dr(a),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(l(340));Va()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return X($n),null;case 4:return ae(),null;case 10:return zs(a.type),null;case 22:case 23:return Dr(a),Yu(),r!==null&&X(Ga),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 24:return zs(Un),null;case 25:return null;default:return null}}function Ig(r,a){switch(Mu(a),a.tag){case 3:zs(Un),ae();break;case 26:case 27:case 5:Ne(a);break;case 4:ae();break;case 31:a.memoizedState!==null&&Dr(a);break;case 13:Dr(a);break;case 19:X($n);break;case 10:zs(a.type);break;case 22:case 23:Dr(a),Yu(),r!==null&&X(Ga);break;case 24:zs(Un)}}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){cn(a,a.return,Q)}}function ha(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,me=Q;try{me()}catch(Ae){cn(b,le,Ae)}}}u=u.next}while(u!==j)}}catch(Ae){cn(a,a.return,Ae)}}function zg(r){var a=r.updateQueue;if(a!==null){var i=r.stateNode;try{Ep(a,i)}catch(u){cn(r,r.return,u)}}}function $g(r,a,i){i.props=Wa(r.type,r.memoizedProps),i.state=r.memoizedState;try{i.componentWillUnmount()}catch(u){cn(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){cn(r,a,b)}}function vs(r,a){var i=r.ref,u=r.refCleanup;if(i!==null)if(typeof u=="function")try{u()}catch(b){cn(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){cn(r,a,b)}else i.current=null}function Bg(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){cn(r,r.return,b)}}function Sf(r,a,i){try{var u=r.stateNode;n2(u,r.type,i,a),u[at]=a}catch(b){cn(r,r.return,b)}}function Hg(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&va(r.type)||r.tag===4}function Cf(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Hg(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&&va(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 Ef(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=He));else if(u!==4&&(u===27&&va(r.type)&&(i=r.stateNode,a=null),r=r.child,r!==null))for(Ef(r,a,i),r=r.sibling;r!==null;)Ef(r,a,i),r=r.sibling}function _c(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&&va(r.type)&&(i=r.stateNode),r=r.child,r!==null))for(_c(r,a,i),r=r.sibling;r!==null;)_c(r,a,i),r=r.sibling}function Pg(r){var a=r.stateNode,i=r.memoizedProps;try{for(var u=r.type,b=a.attributes;b.length;)a.removeAttributeNode(b[0]);ir(a,u,i),a[Qe]=r,a[at]=i}catch(j){cn(r,r.return,j)}}var Us=!1,Fn=!1,Tf=!1,Ug=typeof WeakSet=="function"?WeakSet:Set,Wn=null;function L5(r,a){if(r=r.containerInfo,Kf=Zc,r=ep(r),vu(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,me=0,Ae=0,Re=r,be=null;t:for(;;){for(var ke;Re!==i||b!==0&&Re.nodeType!==3||(Q=$+b),Re!==j||u!==0&&Re.nodeType!==3||(le=$+u),Re.nodeType===3&&($+=Re.nodeValue.length),(ke=Re.firstChild)!==null;)be=Re,Re=ke;for(;;){if(Re===r)break t;if(be===i&&++me===b&&(Q=$),be===j&&++Ae===u&&(le=$),(ke=Re.nextSibling)!==null)break;Re=be,be=Re.parentNode}Re=ke}i=Q===-1||le===-1?null:{start:Q,end:le}}else i=null}i=i||{start:0,end:0}}else i=null;for(Zf={focusedElem:r,selectionRange:i},Zc=!1,Wn=a;Wn!==null;)if(a=Wn,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,Wn=r;else for(;Wn!==null;){switch(a=Wn,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 et=Wa(i.type,b);r=u.getSnapshotBeforeUpdate(et,j),u.__reactInternalSnapshotBeforeUpdate=r}catch(kt){cn(i,i.return,kt)}}break;case 3:if((r&1024)!==0){if(r=a.stateNode.containerInfo,i=r.nodeType,i===9)Jf(r);else if(i===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":Jf(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,Wn=r;break}Wn=a.return}}function qg(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($){cn(i,i.return,$)}else{var b=Wa(i.type,a.memoizedProps);a=a.memoizedState;try{r.componentDidUpdate(b,a,r.__reactInternalSnapshotBeforeUpdate)}catch($){cn(i,i.return,$)}}u&64&&zg(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{Ep(r,a)}catch($){cn(i,i.return,$)}}break;case 27:a===null&&u&4&&Pg(i);case 26:case 5:Vs(r,i),a===null&&u&4&&Bg(i),u&512&&Pi(i,i.return);break;case 12:Vs(r,i);break;case 31:Vs(r,i),u&4&&Yg(r,i);break;case 13:Vs(r,i),u&4&&Gg(r,i),u&64&&(r=i.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(i=V5.bind(null,i),d2(r,i))));break;case 22:if(u=i.memoizedState!==null||Us,!u){a=a!==null&&a.memoizedState!==null||Fn,b=Us;var j=Fn;Us=u,(Fn=a)&&!j?Fs(r,i,(i.subtreeFlags&8772)!==0):Vs(r,i),Us=b,Fn=j}break;case 30:break;default:Vs(r,i)}}function Vg(r){var a=r.alternate;a!==null&&(r.alternate=null,Vg(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&hr(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,jr=!1;function qs(r,a,i){for(i=i.child;i!==null;)Fg(r,a,i),i=i.sibling}function Fg(r,a,i){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(Ht,i)}catch{}switch(i.tag){case 26:Fn||vs(i,a),qs(r,a,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Fn||vs(i,a);var u=Tn,b=jr;va(i.type)&&(Tn=i.stateNode,jr=!1),qs(r,a,i),Zi(i.stateNode),Tn=u,jr=b;break;case 5:Fn||vs(i,a);case 6:if(u=Tn,b=jr,Tn=null,qs(r,a,i),Tn=u,jr=b,Tn!==null)if(jr)try{(Tn.nodeType===9?Tn.body:Tn.nodeName==="HTML"?Tn.ownerDocument.body:Tn).removeChild(i.stateNode)}catch(j){cn(i,a,j)}else try{Tn.removeChild(i.stateNode)}catch(j){cn(i,a,j)}break;case 18:Tn!==null&&(jr?(r=Tn,z0(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,i.stateNode),Fl(r)):z0(Tn,i.stateNode));break;case 4:u=Tn,b=jr,Tn=i.stateNode.containerInfo,jr=!0,qs(r,a,i),Tn=u,jr=b;break;case 0:case 11:case 14:case 15:ha(2,i,a),Fn||ha(4,i,a),qs(r,a,i);break;case 1:Fn||(vs(i,a),u=i.stateNode,typeof u.componentWillUnmount=="function"&&$g(i,a,u)),qs(r,a,i);break;case 21:qs(r,a,i);break;case 22:Fn=(u=Fn)||i.memoizedState!==null,qs(r,a,i),Fn=u;break;default:qs(r,a,i)}}function Yg(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{Fl(r)}catch(i){cn(a,a.return,i)}}}function Gg(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){cn(a,a.return,i)}}function I5(r){switch(r.tag){case 31:case 13:case 19:var a=r.stateNode;return a===null&&(a=r.stateNode=new Ug),a;case 22:return r=r.stateNode,a=r._retryCache,a===null&&(a=r._retryCache=new Ug),a;default:throw Error(l(435,r.tag))}}function Ac(r,a){var i=I5(r);a.forEach(function(u){if(!i.has(u)){i.add(u);var b=F5.bind(null,r,u);u.then(b,b)}})}function wr(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(va(Q.type)){Tn=Q.stateNode,jr=!1;break e}break;case 5:Tn=Q.stateNode,jr=!1;break e;case 3:case 4:Tn=Q.stateNode.containerInfo,jr=!0;break e}Q=Q.return}if(Tn===null)throw Error(l(160));Fg(j,$,b),Tn=null,jr=!1,j=b.alternate,j!==null&&(j.return=null),b.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)Xg(a,r),a=a.sibling}var is=null;function Xg(r,a){var i=r.alternate,u=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:wr(a,r),Nr(r),u&4&&(ha(3,r,r.return),Hi(3,r),ha(5,r,r.return));break;case 1:wr(a,r),Nr(r),u&512&&(Fn||i===null||vs(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(wr(a,r),Nr(r),u&512&&(Fn||i===null||vs(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[On]||j[Qe]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=b.createElement(u),b.head.insertBefore(j,b.querySelector("head > title"))),ir(j,u,i),j[Qe]=r,wn(j),u=j;break e;case"link":var $=X0("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),ir(j,u,i),b.head.appendChild(j);break;case"meta":if($=X0("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),ir(j,u,i),b.head.appendChild(j);break;default:throw Error(l(468,u))}j[Qe]=r,wn(j),u=j}r.stateNode=u}else K0(b,r.type,r.stateNode);else r.stateNode=G0(b,u,r.memoizedProps);else j!==u?(j===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):j.count--,u===null?K0(b,r.type,r.stateNode):G0(b,u,r.memoizedProps)):u===null&&r.stateNode!==null&&Sf(r,r.memoizedProps,i.memoizedProps)}break;case 27:wr(a,r),Nr(r),u&512&&(Fn||i===null||vs(i,i.return)),i!==null&&u&4&&Sf(r,r.memoizedProps,i.memoizedProps);break;case 5:if(wr(a,r),Nr(r),u&512&&(Fn||i===null||vs(i,i.return)),r.flags&32){b=r.stateNode;try{Ie(b,"")}catch(et){cn(r,r.return,et)}}u&4&&r.stateNode!=null&&(b=r.memoizedProps,Sf(r,b,i!==null?i.memoizedProps:b)),u&1024&&(Tf=!0);break;case 6:if(wr(a,r),Nr(r),u&4){if(r.stateNode===null)throw Error(l(162));u=r.memoizedProps,i=r.stateNode;try{i.nodeValue=u}catch(et){cn(r,r.return,et)}}break;case 3:if(Yc=null,b=is,is=Vc(a.containerInfo),wr(a,r),is=b,Nr(r),u&4&&i!==null&&i.memoizedState.isDehydrated)try{Fl(a.containerInfo)}catch(et){cn(r,r.return,et)}Tf&&(Tf=!1,Kg(r));break;case 4:u=is,is=Vc(r.stateNode.containerInfo),wr(a,r),Nr(r),is=u;break;case 12:wr(a,r),Nr(r);break;case 31:wr(a,r),Nr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Ac(r,u)));break;case 13:wr(a,r),Nr(r),r.child.flags&8192&&r.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(Oc=vt()),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Ac(r,u)));break;case 22:b=r.memoizedState!==null;var le=i!==null&&i.memoizedState!==null,me=Us,Ae=Fn;if(Us=me||b,Fn=Ae||le,wr(a,r),Fn=Ae,Us=me,Nr(r),u&8192)e:for(a=r.stateNode,a._visibility=b?a._visibility&-2:a._visibility|1,b&&(i===null||le||Us||Fn||Ja(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(et){cn(le,le.return,et)}}}else if(a.tag===6){if(i===null){le=a;try{le.stateNode.nodeValue=b?"":le.memoizedProps}catch(et){cn(le,le.return,et)}}}else if(a.tag===18){if(i===null){le=a;try{var ke=le.stateNode;b?$0(ke,!0):$0(le.stateNode,!1)}catch(et){cn(le,le.return,et)}}}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,Ac(r,i))));break;case 19:wr(a,r),Nr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Ac(r,u)));break;case 30:break;case 21:break;default:wr(a,r),Nr(r)}}function Nr(r){var a=r.flags;if(a&2){try{for(var i,u=r.return;u!==null;){if(Hg(u)){i=u;break}u=u.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var b=i.stateNode,j=Cf(r);_c(r,j,b);break;case 5:var $=i.stateNode;i.flags&32&&(Ie($,""),i.flags&=-33);var Q=Cf(r);_c(r,Q,$);break;case 3:case 4:var le=i.stateNode.containerInfo,me=Cf(r);Ef(r,me,le);break;default:throw Error(l(161))}}catch(Ae){cn(r,r.return,Ae)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function Kg(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var a=r;Kg(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;)qg(r,a.alternate,a),a=a.sibling}function Ja(r){for(r=r.child;r!==null;){var a=r;switch(a.tag){case 0:case 11:case 14:case 15:ha(4,a,a.return),Ja(a);break;case 1:vs(a,a.return);var i=a.stateNode;typeof i.componentWillUnmount=="function"&&$g(a,a.return,i),Ja(a);break;case 27:Zi(a.stateNode);case 26:case 5:vs(a,a.return),Ja(a);break;case 22:a.memoizedState===null&&Ja(a);break;case 30:Ja(a);break;default:Ja(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(me){cn(u,u.return,me)}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++)Cp(le[b],Q)}catch(me){cn(u,u.return,me)}}i&&$&64&&zg(j),Pi(j,j.return);break;case 27:Pg(j);case 26:case 5:Fs(b,j,i),i&&u===null&&$&4&&Bg(j),Pi(j,j.return);break;case 12:Fs(b,j,i);break;case 31:Fs(b,j,i),i&&$&4&&Yg(b,j);break;case 13:Fs(b,j,i),i&&$&4&&Gg(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 Af(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;)Zg(r,a,i,u),a=a.sibling}function Zg(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){cn(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&&Af(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,me=$.flags;switch($.tag){case 0:case 11:case 15:Dl(j,$,Q,le,b),Hi(8,$);break;case 23:break;case 22:var Ae=$.stateNode;$.memoizedState!==null?Ae._visibility&2?Dl(j,$,Q,le,b):Ui(j,$):(Ae._visibility|=2,Dl(j,$,Q,le,b)),b&&me&2048&&_f($.alternate,$);break;case 24:Dl(j,$,Q,le,b),b&&me&2048&&Af($.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&&Af(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;)Qg(r,a,i),r=r.sibling}function Qg(r,a,i){switch(r.tag){case 26:Ll(r,a,i),r.flags&qi&&r.memoizedState!==null&&w2(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 Wg(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];Wn=u,e0(u,r)}Wg(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Jg(r),r=r.sibling}function Jg(r){switch(r.tag){case 0:case 11:case 15:Vi(r),r.flags&2048&&ha(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];Wn=u,e0(u,r)}Wg(r)}for(r=r.child;r!==null;){switch(a=r,a.tag){case 0:case 11:case 15:ha(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 e0(r,a){for(;Wn!==null;){var i=Wn;switch(i.tag){case 0:case 11:case 15:ha(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,Wn=u;else e:for(i=r;Wn!==null;){u=Wn;var b=u.sibling,j=u.return;if(Vg(u),u===i){Wn=null;break e}if(b!==null){b.return=j,Wn=b;break e}Wn=j}}}var z5={getCacheForType:function(r){var a=ar(Un),i=a.data.get(r);return i===void 0&&(i=r(),a.data.set(r,i)),i},cacheSignal:function(){return ar(Un).controller.signal}},$5=typeof WeakMap=="function"?WeakMap:Map,an=0,gn=null,qt=null,Gt=0,on=0,Lr=null,ma=!1,Il=!1,Mf=!1,Ys=0,In=0,xa=0,el=0,Of=0,Ir=0,zl=0,Fi=null,kr=null,Rf=!1,Oc=0,t0=0,Rc=1/0,Dc=null,pa=null,Zn=0,ga=null,$l=null,Gs=0,Df=0,Lf=null,n0=null,Yi=0,If=null;function zr(){return(an&2)!==0&&Gt!==0?Gt&-Gt:_.T!==null?Uf():ot()}function r0(){if(Ir===0)if((Gt&536870912)===0||Zt){var r=Rt;Rt<<=1,(Rt&3932160)===0&&(Rt=262144),Ir=r}else Ir=536870912;return r=Rr.current,r!==null&&(r.flags|=32),Ir}function Sr(r,a,i){(r===gn&&(on===2||on===9)||r.cancelPendingCommit!==null)&&(Bl(r,0),ba(r,Gt,Ir,!1)),Dt(r,i),((an&2)===0||r!==gn)&&(r===gn&&((an&2)===0&&(el|=i),In===4&&ba(r,Gt,Ir,!1)),js(r))}function s0(r,a,i){if((an&6)!==0)throw Error(l(327));var u=!i&&(a&127)===0&&(a&r.expiredLanes)===0||yn(r,a),b=u?P5(r,a):$f(r,a,!0),j=u;do{if(b===0){Il&&!u&&ba(r,a,0,!1);break}else{if(i=r.current.alternate,j&&!B5(i)){b=$f(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),$=$f(Q,$,!1),$!==2){if(Mf&&!le){Q.errorRecoveryDisabledLanes|=j,el|=j,b=4;break e}j=kr,kr=b,j!==null&&(kr===null?kr=j:kr.push.apply(kr,j))}b=$}if(j=!1,b!==2)continue}}if(b===1){Bl(r,0),ba(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:ba(u,a,Ir,!ma);break e;case 2:kr=null;break;case 3:case 5:break;default:throw Error(l(329))}if((a&62914560)===a&&(b=Oc+300-vt(),10<b)){if(ba(u,a,Ir,!ma),Pt(u,0,!0)!==0)break e;Gs=a,u.timeoutHandle=L0(a0.bind(null,u,i,kr,Dc,Rf,a,Ir,el,zl,ma,j,"Throttled",-0,0),b);break e}a0(u,i,kr,Dc,Rf,a,Ir,el,zl,ma,j,null,-0,0)}}break}while(!0);js(r)}function a0(r,a,i,u,b,j,$,Q,le,me,Ae,Re,be,ke){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:He},Qg(a,j,Re);var et=(j&62914560)===j?Oc-vt():(j&4194048)===j?t0-vt():0;if(et=N2(Re,et),et!==null){Gs=j,r.cancelPendingCommit=et(h0.bind(null,r,a,j,i,u,b,$,Q,le,Ae,Re,null,be,ke)),ba(r,j,$,!me);return}}h0(r,a,j,i,u,b,$,Q,le)}function B5(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(!Mr(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 ba(r,a,i,u){a&=~Of,a&=~el,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&&Et(r,i,a)}function Lc(){return(an&6)===0?(Gi(0),!1):!0}function zf(){if(qt!==null){if(on===0)var r=qt.return;else r=qt,Is=Fa=null,Wu(r),_l=null,_i=0,r=qt;for(;r!==null;)Ig(r.alternate,r),r=r.return;qt=null}}function Bl(r,a){var i=r.timeoutHandle;i!==-1&&(r.timeoutHandle=-1,a2(i)),i=r.cancelPendingCommit,i!==null&&(r.cancelPendingCommit=null,i()),Gs=0,zf(),gn=r,qt=i=Ds(r.current,null),Gt=a,on=0,Lr=null,ma=!1,Il=yn(r,a),Mf=!1,zl=Ir=Of=el=xa=In=0,kr=Fi=null,Rf=!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 l0(r,a){It=null,_.H=zi,a===Tl||a===dc?(a=wp(),on=3):a===Hu?(a=wp(),on=4):on=a===xf?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Lr=a,qt===null&&(In=1,kc(r,Yr(a,r.current)))}function i0(){var r=Rr.current;return r===null?!0:(Gt&4194048)===Gt?Zr===null:(Gt&62914560)===Gt||(Gt&536870912)!==0?r===Zr:!1}function o0(){var r=_.H;return _.H=zi,r===null?zi:r}function c0(){var r=_.A;return _.A=z5,r}function Ic(){In=4,ma||(Gt&4194048)!==Gt&&Rr.current!==null||(Il=!0),(xa&134217727)===0&&(el&134217727)===0||gn===null||ba(gn,Gt,Ir,!1)}function $f(r,a,i){var u=an;an|=2;var b=o0(),j=c0();(gn!==r||Gt!==a)&&(Dc=null,Bl(r,a)),a=!1;var $=In;e:do try{if(on!==0&&qt!==null){var Q=qt,le=Lr;switch(on){case 8:zf(),$=6;break e;case 3:case 2:case 9:case 6:Rr.current===null&&(a=!0);var me=on;if(on=0,Lr=null,Hl(r,Q,le,me),i&&Il){$=0;break e}break;default:me=on,on=0,Lr=null,Hl(r,Q,le,me)}}H5(),$=In;break}catch(Ae){l0(r,Ae)}while(!0);return a&&r.shellSuspendCounter++,Is=Fa=null,an=u,_.H=b,_.A=j,qt===null&&(gn=null,Gt=0,nc()),$}function H5(){for(;qt!==null;)d0(qt)}function P5(r,a){var i=an;an|=2;var u=o0(),b=c0();gn!==r||Gt!==a?(Dc=null,Rc=vt()+500,Bl(r,a)):Il=yn(r,a);e:do try{if(on!==0&&qt!==null){a=qt;var j=Lr;t:switch(on){case 1:on=0,Lr=null,Hl(r,a,j,1);break;case 2:case 9:if(vp(j)){on=0,Lr=null,u0(a);break}a=function(){on!==2&&on!==9||gn!==r||(on=7),js(r)},j.then(a,a);break e;case 3:on=7;break e;case 4:on=5;break e;case 7:vp(j)?(on=0,Lr=null,u0(a)):(on=0,Lr=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($?Z0($):Q.stateNode.complete){on=0,Lr=null;var le=Q.sibling;if(le!==null)qt=le;else{var me=Q.return;me!==null?(qt=me,zc(me)):qt=null}break t}}on=0,Lr=null,Hl(r,a,j,5);break;case 6:on=0,Lr=null,Hl(r,a,j,6);break;case 8:zf(),In=6;break e;default:throw Error(l(462))}}U5();break}catch(Ae){l0(r,Ae)}while(!0);return Is=Fa=null,_.H=u,_.A=b,an=i,qt!==null?0:(gn=null,Gt=0,nc(),In)}function U5(){for(;qt!==null&&!Ee();)d0(qt)}function d0(r){var a=Dg(r.alternate,r,Ys);r.memoizedProps=r.pendingProps,a===null?zc(r):qt=a}function u0(r){var a=r,i=a.alternate;switch(a.tag){case 15:case 0:a=Tg(i,a,a.pendingProps,a.type,void 0,Gt);break;case 11:a=Tg(i,a,a.pendingProps,a.type.render,a.ref,Gt);break;case 5:Wu(a);default:Ig(i,a),a=qt=cp(a,Ys),a=Dg(i,a,Ys)}r.memoizedProps=r.pendingProps,a===null?zc(r):qt=a}function Hl(r,a,i,u){Is=Fa=null,Wu(a),_l=null,_i=0;var b=a.return;try{if(A5(r,b,a,i,Gt)){In=1,kc(r,Yr(i,r.current)),qt=null;return}}catch(j){if(b!==null)throw qt=b,j;In=1,kc(r,Yr(i,r.current)),qt=null;return}a.flags&32768?(Zt||u===1?r=!0:Il||(Gt&536870912)!==0?r=!1:(ma=r=!0,(u===2||u===9||u===3||u===6)&&(u=Rr.current,u!==null&&u.tag===13&&(u.flags|=16384))),f0(a,r)):zc(a)}function zc(r){var a=r;do{if((a.flags&32768)!==0){f0(a,ma);return}r=a.return;var i=R5(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);In===0&&(In=5)}function f0(r,a){do{var i=D5(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);In=6,qt=null}function h0(r,a,i,u,b,j,$,Q,le){r.cancelPendingCommit=null;do $c();while(Zn!==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|=Su,jn(r,i,j,$,Q,le),r===gn&&(qt=gn=null,Gt=0),$l=a,ga=r,Gs=i,Df=j,Lf=b,n0=u,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,Y5(Ue,function(){return b0(),null})):(r.callbackNode=null,r.callbackPriority=0),u=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||u){u=_.T,_.T=null,b=P.p,P.p=2,$=an,an|=4;try{L5(r,a,i)}finally{an=$,P.p=b,_.T=u}}Zn=1,m0(),x0(),p0()}}function m0(){if(Zn===1){Zn=0;var r=ga,a=$l,i=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||i){i=_.T,_.T=null;var u=P.p;P.p=2;var b=an;an|=4;try{Xg(a,r);var j=Zf,$=ep(r.containerInfo),Q=j.focusedElem,le=j.selectionRange;if($!==Q&&Q&&Q.ownerDocument&&Jx(Q.ownerDocument.documentElement,Q)){if(le!==null&&vu(Q)){var me=le.start,Ae=le.end;if(Ae===void 0&&(Ae=me),"selectionStart"in Q)Q.selectionStart=me,Q.selectionEnd=Math.min(Ae,Q.value.length);else{var Re=Q.ownerDocument||document,be=Re&&Re.defaultView||window;if(be.getSelection){var ke=be.getSelection(),et=Q.textContent.length,kt=Math.min(le.start,et),xn=le.end===void 0?kt:Math.min(le.end,et);!ke.extend&&kt>xn&&($=xn,xn=kt,kt=$);var de=Wx(Q,kt),oe=Wx(Q,xn);if(de&&oe&&(ke.rangeCount!==1||ke.anchorNode!==de.node||ke.anchorOffset!==de.offset||ke.focusNode!==oe.node||ke.focusOffset!==oe.offset)){var he=Re.createRange();he.setStart(de.node,de.offset),ke.removeAllRanges(),kt>xn?(ke.addRange(he),ke.extend(oe.node,oe.offset)):(he.setEnd(oe.node,oe.offset),ke.addRange(he))}}}}for(Re=[],ke=Q;ke=ke.parentNode;)ke.nodeType===1&&Re.push({element:ke,left:ke.scrollLeft,top:ke.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=!!Kf,Zf=Kf=null}finally{an=b,P.p=u,_.T=i}}r.current=a,Zn=2}}function x0(){if(Zn===2){Zn=0;var r=ga,a=$l,i=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||i){i=_.T,_.T=null;var u=P.p;P.p=2;var b=an;an|=4;try{qg(r,a.alternate,a)}finally{an=b,P.p=u,_.T=i}}Zn=3}}function p0(){if(Zn===4||Zn===3){Zn=0,rt();var r=ga,a=$l,i=Gs,u=n0;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Zn=5:(Zn=0,$l=ga=null,g0(r,r.pendingLanes));var b=r.pendingLanes;if(b===0&&(pa=null),st(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=_.T,b=P.p,P.p=2,_.T=null;try{for(var j=r.onRecoverableError,$=0;$<u.length;$++){var Q=u[$];j(Q.value,{componentStack:Q.stack})}}finally{_.T=a,P.p=b}}(Gs&3)!==0&&$c(),js(r),b=r.pendingLanes,(i&261930)!==0&&(b&42)!==0?r===If?Yi++:(Yi=0,If=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 m0(),x0(),p0(),b0()}function b0(){if(Zn!==5)return!1;var r=ga,a=Df;Df=0;var i=st(Gs),u=_.T,b=P.p;try{P.p=32>i?32:i,_.T=null,i=Lf,Lf=null;var j=ga,$=Gs;if(Zn=0,$l=ga=null,Gs=0,(an&6)!==0)throw Error(l(331));var Q=an;if(an|=4,Jg(j.current),Zg(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,_.T=u,g0(r,a)}}function y0(r,a,i){a=Yr(i,a),a=mf(r.stateNode,a,2),r=da(r,a,2),r!==null&&(Dt(r,2),js(r))}function cn(r,a,i){if(r.tag===3)y0(r,r,i);else for(;a!==null;){if(a.tag===3){y0(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=Yr(i,r),i=vg(2),u=da(a,i,2),u!==null&&(jg(i,u,a,r),Dt(u,2),js(u));break}}a=a.return}}function Bf(r,a,i){var u=r.pingCache;if(u===null){u=r.pingCache=new $5;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)||(Mf=!0,b.add(i),r=q5.bind(null,r,a,i),a.then(r,r))}function q5(r,a,i){var u=r.pingCache;u!==null&&u.delete(a),r.pingedLanes|=r.suspendedLanes&i,r.warmLanes&=~i,gn===r&&(Gt&i)===i&&(In===4||In===3&&(Gt&62914560)===Gt&&300>vt()-Oc?(an&2)===0&&Bl(r,0):Of|=i,zl===Gt&&(zl=0)),js(r)}function v0(r,a){a===0&&(a=un()),r=Ua(r,a),r!==null&&(Dt(r,a),js(r))}function V5(r){var a=r.memoizedState,i=0;a!==null&&(i=a.retryLane),v0(r,i)}function F5(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),v0(r,i)}function Y5(r,a){return Mt(r,a)}var Bc=null,Pl=null,Hf=!1,Hc=!1,Pf=!1,ya=0;function js(r){r!==Pl&&r.next===null&&(Pl===null?Bc=Pl=r:Pl=Pl.next=r),Hc=!0,Hf||(Hf=!0,X5())}function Gi(r,a){if(!Pf&&Hc){Pf=!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,k0(u,j))}else j=Gt,j=Pt(u,u===gn?j:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(j&3)===0||yn(u,j)||(i=!0,k0(u,j));u=u.next}while(i);Pf=!1}}function G5(){j0()}function j0(){Hc=Hf=!1;var r=0;ya!==0&&s2()&&(r=ya);for(var a=vt(),i=null,u=Bc;u!==null;){var b=u.next,j=w0(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}Zn!==0&&Zn!==5||Gi(r),ya!==0&&(ya=0)}function w0(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[$]=nn(Q,a)):le<=a&&(r.expiredLanes|=Q),j&=~Q}if(a=gn,i=Gt,i=Pt(r,r===a?i:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u=r.callbackNode,i===0||r===a&&(on===2||on===9)||r.cancelPendingCommit!==null)return u!==null&&u!==null&&se(u),r.callbackNode=null,r.callbackPriority=0;if((i&3)===0||yn(r,i)){if(a=i&-i,a===r.callbackPriority)return a;switch(u!==null&&se(u),st(i)){case 2:case 8:i=De;break;case 32:i=Ue;break;case 268435456:i=pt;break;default:i=Ue}return u=N0.bind(null,r),i=Mt(i,u),r.callbackPriority=a,r.callbackNode=i,a}return u!==null&&u!==null&&se(u),r.callbackPriority=2,r.callbackNode=null,2}function N0(r,a){if(Zn!==0&&Zn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var i=r.callbackNode;if($c()&&r.callbackNode!==i)return null;var u=Gt;return u=Pt(r,r===gn?u:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u===0?null:(s0(r,u,a),w0(r,vt()),r.callbackNode!=null&&r.callbackNode===i?N0.bind(null,r):null)}function k0(r,a){if($c())return null;s0(r,a,!0)}function X5(){l2(function(){(an&6)!==0?Mt(we,G5):j0()})}function Uf(){if(ya===0){var r=Cl;r===0&&(r=qe,qe<<=1,(qe&261888)===0&&(qe=256)),ya=r}return ya}function S0(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Ge(""+r)}function C0(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 K5(r,a,i,u,b){if(a==="submit"&&i&&i.stateNode===b){var j=S0((b[at]||null).action),$=u.submitter;$&&(a=(a=$[at]||null)?S0(a.formAction):$.getAttribute("formAction"),a!==null&&(j=a,$=null));var Q=new Wo("action","action",null,u,b);r.push({event:Q,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(ya!==0){var le=$?C0(b,$):new FormData(b);of(i,{pending:!0,data:le,method:b.method,action:j},null,le)}}else typeof j=="function"&&(Q.preventDefault(),le=$?C0(b,$):new FormData(b),of(i,{pending:!0,data:le,method:b.method,action:j},j,le))},currentTarget:b}]})}}for(var qf=0;qf<ku.length;qf++){var Vf=ku[qf],Z5=Vf.toLowerCase(),Q5=Vf[0].toUpperCase()+Vf.slice(1);ls(Z5,"on"+Q5)}ls(rp,"onAnimationEnd"),ls(sp,"onAnimationIteration"),ls(ap,"onAnimationStart"),ls("dblclick","onDoubleClick"),ls("focusin","onFocus"),ls("focusout","onBlur"),ls(h5,"onTransitionRun"),ls(m5,"onTransitionStart"),ls(x5,"onTransitionCancel"),ls(lp,"onTransitionEnd"),_e("onMouseEnter",["mouseout","mouseover"]),_e("onMouseLeave",["mouseout","mouseover"]),_e("onPointerEnter",["pointerout","pointerover"]),_e("onPointerLeave",["pointerout","pointerover"]),ce("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ce("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ce("onBeforeInput",["compositionend","keypress","textInput","paste"]),ce("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ce("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ce("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(" "),W5=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xi));function E0(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,me=Q.currentTarget;if(Q=Q.listener,le!==j&&b.isPropagationStopped())break e;j=Q,b.currentTarget=me;try{j(b)}catch(Ae){tc(Ae)}b.currentTarget=null,j=le}else for($=0;$<u.length;$++){if(Q=u[$],le=Q.instance,me=Q.currentTarget,Q=Q.listener,le!==j&&b.isPropagationStopped())break e;j=Q,b.currentTarget=me;try{j(b)}catch(Ae){tc(Ae)}b.currentTarget=null,j=le}}}}function Vt(r,a){var i=a[xe];i===void 0&&(i=a[xe]=new Set);var u=r+"__bubble";i.has(u)||(T0(a,r,2,!1),i.add(u))}function Ff(r,a,i){var u=0;a&&(u|=4),T0(i,r,u,a)}var Pc="_reactListening"+Math.random().toString(36).slice(2);function Yf(r){if(!r[Pc]){r[Pc]=!0,ts.forEach(function(i){i!=="selectionchange"&&(W5.has(i)||Ff(i,!1,r),Ff(i,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[Pc]||(a[Pc]=!0,Ff("selectionchange",!1,a))}}function T0(r,a,i,u){switch(rb(a)){case 2:var b=C2;break;case 8:b=E2;break;default:b=ih}i=b.bind(null,a,i,r),b=void 0,!yt||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 Gf(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($=mr(Q),$===null)return;if(le=$.tag,le===5||le===6||le===26||le===27){u=j=$;continue e}Q=Q.parentNode}}u=u.return}zn(function(){var me=j,Ae=ht(i),Re=[];e:{var be=ip.get(r);if(be!==void 0){var ke=Wo,et=r;switch(r){case"keypress":if(rr(i)===0)break e;case"keydown":case"keyup":ke=FN;break;case"focusin":et="focus",ke=xu;break;case"focusout":et="blur",ke=xu;break;case"beforeblur":case"afterblur":ke=xu;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":ke=Ix;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ke=RN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ke=XN;break;case rp:case sp:case ap:ke=IN;break;case lp:ke=ZN;break;case"scroll":case"scrollend":ke=MN;break;case"wheel":ke=WN;break;case"copy":case"cut":case"paste":ke=$N;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ke=$x;break;case"toggle":case"beforetoggle":ke=e5}var kt=(a&4)!==0,xn=!kt&&(r==="scroll"||r==="scrollend"),de=kt?be!==null?be+"Capture":null:be;kt=[];for(var oe=me,he;oe!==null;){var Oe=oe;if(he=Oe.stateNode,Oe=Oe.tag,Oe!==5&&Oe!==26&&Oe!==27||he===null||de===null||(Oe=jt(oe,de),Oe!=null&&kt.push(Ki(oe,Oe,he))),xn)break;oe=oe.return}0<kt.length&&(be=new ke(be,et,null,i,Ae),Re.push({event:be,listeners:kt}))}}if((a&7)===0){e:{if(be=r==="mouseover"||r==="pointerover",ke=r==="mouseout"||r==="pointerout",be&&i!==Nt&&(et=i.relatedTarget||i.fromElement)&&(mr(et)||et[fn]))break e;if((ke||be)&&(be=Ae.window===Ae?Ae:(be=Ae.ownerDocument)?be.defaultView||be.parentWindow:window,ke?(et=i.relatedTarget||i.toElement,ke=me,et=et?mr(et):null,et!==null&&(xn=d(et),kt=et.tag,et!==xn||kt!==5&&kt!==27&&kt!==6)&&(et=null)):(ke=null,et=me),ke!==et)){if(kt=Ix,Oe="onMouseLeave",de="onMouseEnter",oe="mouse",(r==="pointerout"||r==="pointerover")&&(kt=$x,Oe="onPointerLeave",de="onPointerEnter",oe="pointer"),xn=ke==null?be:or(ke),he=et==null?be:or(et),be=new kt(Oe,oe+"leave",ke,i,Ae),be.target=xn,be.relatedTarget=he,Oe=null,mr(Ae)===me&&(kt=new kt(de,oe+"enter",et,i,Ae),kt.target=he,kt.relatedTarget=xn,Oe=kt),xn=Oe,ke&&et)t:{for(kt=J5,de=ke,oe=et,he=0,Oe=de;Oe;Oe=kt(Oe))he++;Oe=0;for(var gt=oe;gt;gt=kt(gt))Oe++;for(;0<he-Oe;)de=kt(de),he--;for(;0<Oe-he;)oe=kt(oe),Oe--;for(;he--;){if(de===oe||oe!==null&&de===oe.alternate){kt=de;break t}de=kt(de),oe=kt(oe)}kt=null}else kt=null;ke!==null&&_0(Re,be,ke,kt,!1),et!==null&&xn!==null&&_0(Re,xn,et,kt,!0)}}e:{if(be=me?or(me):window,ke=be.nodeName&&be.nodeName.toLowerCase(),ke==="select"||ke==="input"&&be.type==="file")var rn=Yx;else if(Vx(be))if(Gx)rn=d5;else{rn=o5;var it=i5}else ke=be.nodeName,!ke||ke.toLowerCase()!=="input"||be.type!=="checkbox"&&be.type!=="radio"?me&&Ce(me.elementType)&&(rn=Yx):rn=c5;if(rn&&(rn=rn(r,me))){Fx(Re,rn,i,Ae);break e}it&&it(r,be,me),r==="focusout"&&me&&be.type==="number"&&me.memoizedProps.value!=null&&Ar(be,"number",be.value)}switch(it=me?or(me):window,r){case"focusin":(Vx(it)||it.contentEditable==="true")&&(bl=it,ju=me,ki=null);break;case"focusout":ki=ju=bl=null;break;case"mousedown":wu=!0;break;case"contextmenu":case"mouseup":case"dragend":wu=!1,tp(Re,i,Ae);break;case"selectionchange":if(f5)break;case"keydown":case"keyup":tp(Re,i,Ae)}var $t;if(gu)e:{switch(r){case"compositionstart":var Xt="onCompositionStart";break e;case"compositionend":Xt="onCompositionEnd";break e;case"compositionupdate":Xt="onCompositionUpdate";break e}Xt=void 0}else gl?Ux(r,i)&&(Xt="onCompositionEnd"):r==="keydown"&&i.keyCode===229&&(Xt="onCompositionStart");Xt&&(Bx&&i.locale!=="ko"&&(gl||Xt!=="onCompositionStart"?Xt==="onCompositionEnd"&&gl&&($t=Mn()):(Ze=Ae,ut="value"in Ze?Ze.value:Ze.textContent,gl=!0)),it=Uc(me,Xt),0<it.length&&(Xt=new zx(Xt,r,null,i,Ae),Re.push({event:Xt,listeners:it}),$t?Xt.data=$t:($t=qx(i),$t!==null&&(Xt.data=$t)))),($t=n5?r5(r,i):s5(r,i))&&(Xt=Uc(me,"onBeforeInput"),0<Xt.length&&(it=new zx("onBeforeInput","beforeinput",null,i,Ae),Re.push({event:it,listeners:Xt}),it.data=$t)),K5(Re,r,me,i,Ae)}E0(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 J5(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function _0(r,a,i,u,b){for(var j=a._reactName,$=[];i!==null&&i!==u;){var Q=i,le=Q.alternate,me=Q.stateNode;if(Q=Q.tag,le!==null&&le===u)break;Q!==5&&Q!==26&&Q!==27||me===null||(le=me,b?(me=jt(i,j),me!=null&&$.unshift(Ki(i,me,le))):b||(me=jt(i,j),me!=null&&$.push(Ki(i,me,le)))),i=i.return}$.length!==0&&r.push({event:a,listeners:$})}var e2=/\r\n?/g,t2=/\u0000|\uFFFD/g;function A0(r){return(typeof r=="string"?r:""+r).replace(e2,`
|
|
9
|
+
`).replace(t2,"")}function M0(r,a){return a=A0(a),A0(r)===a}function mn(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":gs(r,"class",u);break;case"tabIndex":gs(r,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":gs(r,i,u);break;case"style":ge(r,u,j);break;case"data":if(a!=="object"){gs(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"&&mn(r,a,"name",b.name,b,null),mn(r,a,"formEncType",b.formEncType,b,null),mn(r,a,"formMethod",b.formMethod,b,null),mn(r,a,"formTarget",b.formTarget,b,null)):(mn(r,a,"encType",b.encType,b,null),mn(r,a,"method",b.method,b,null),mn(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=He);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),yr(r,"popover",u);break;case"xlinkActuate":cr(r,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":cr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":cr(r,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":cr(r,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":cr(r,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":cr(r,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":cr(r,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":cr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":cr(r,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":yr(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,yr(r,i,u))}}function Xf(r,a,i,u,b,j){switch(i){case"style":ge(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=He);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ns.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[at]||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,""):yr(r,i,u)}}}function ir(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:mn(r,a,j,$,i,null)}}b&&mn(r,a,"srcSet",i.srcSet,i,null),u&&mn(r,a,"src",i.src,i,null);return;case"input":Vt("invalid",r);var Q=j=$=b=null,le=null,me=null;for(u in i)if(i.hasOwnProperty(u)){var Ae=i[u];if(Ae!=null)switch(u){case"name":b=Ae;break;case"type":$=Ae;break;case"checked":le=Ae;break;case"defaultChecked":me=Ae;break;case"value":j=Ae;break;case"defaultValue":Q=Ae;break;case"children":case"dangerouslySetInnerHTML":if(Ae!=null)throw Error(l(137,a));break;default:mn(r,a,u,Ae,i,null)}}xr(r,j,Q,le,me,$,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:mn(r,a,b,Q,i,null)}a=j,i=$,r.multiple=!!u,a!=null?nr(r,!!u,a,!1):i!=null&&nr(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:mn(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":mn(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(me in i)if(i.hasOwnProperty(me)&&(u=i[me],u!=null))switch(me){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,a));default:mn(r,a,me,u,i,null)}return;default:if(Ce(a)){for(Ae in i)i.hasOwnProperty(Ae)&&(u=i[Ae],u!==void 0&&Xf(r,a,Ae,u,i,void 0));return}}for(Q in i)i.hasOwnProperty(Q)&&(u=i[Q],u!=null&&mn(r,a,Q,u,i,null))}function n2(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,me=null,Ae=null;for(ke in i){var Re=i[ke];if(i.hasOwnProperty(ke)&&Re!=null)switch(ke){case"checked":break;case"value":break;case"defaultValue":le=Re;default:u.hasOwnProperty(ke)||mn(r,a,ke,null,u,Re)}}for(var be in u){var ke=u[be];if(Re=i[be],u.hasOwnProperty(be)&&(ke!=null||Re!=null))switch(be){case"type":j=ke;break;case"name":b=ke;break;case"checked":me=ke;break;case"defaultChecked":Ae=ke;break;case"value":$=ke;break;case"defaultValue":Q=ke;break;case"children":case"dangerouslySetInnerHTML":if(ke!=null)throw Error(l(137,a));break;default:ke!==Re&&mn(r,a,be,ke,u,Re)}}qr(r,$,Q,le,me,Ae,j,b);return;case"select":ke=$=Q=be=null;for(j in i)if(le=i[j],i.hasOwnProperty(j)&&le!=null)switch(j){case"value":break;case"multiple":ke=le;default:u.hasOwnProperty(j)||mn(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&&mn(r,a,b,j,u,le)}a=Q,i=$,u=ke,be!=null?nr(r,!!i,be,!1):!!u!=!!i&&(a!=null?nr(r,!!i,a,!0):nr(r,!!i,i?[]:"",!1));return;case"textarea":ke=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:mn(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":ke=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(l(91));break;default:b!==j&&mn(r,a,$,b,u,j)}Vr(r,be,ke);return;case"option":for(var et in i)be=i[et],i.hasOwnProperty(et)&&be!=null&&!u.hasOwnProperty(et)&&(et==="selected"?r.selected=!1:mn(r,a,et,null,u,be));for(le in u)be=u[le],ke=i[le],u.hasOwnProperty(le)&&be!==ke&&(be!=null||ke!=null)&&(le==="selected"?r.selected=be&&typeof be!="function"&&typeof be!="symbol":mn(r,a,le,be,u,ke));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)&&mn(r,a,kt,null,u,be);for(me in u)if(be=u[me],ke=i[me],u.hasOwnProperty(me)&&be!==ke&&(be!=null||ke!=null))switch(me){case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(l(137,a));break;default:mn(r,a,me,be,u,ke)}return;default:if(Ce(a)){for(var xn in i)be=i[xn],i.hasOwnProperty(xn)&&be!==void 0&&!u.hasOwnProperty(xn)&&Xf(r,a,xn,void 0,u,be);for(Ae in u)be=u[Ae],ke=i[Ae],!u.hasOwnProperty(Ae)||be===ke||be===void 0&&ke===void 0||Xf(r,a,Ae,be,u,ke);return}}for(var de in i)be=i[de],i.hasOwnProperty(de)&&be!=null&&!u.hasOwnProperty(de)&&mn(r,a,de,null,u,be);for(Re in u)be=u[Re],ke=i[Re],!u.hasOwnProperty(Re)||be===ke||be==null&&ke==null||mn(r,a,Re,be,u,ke)}function O0(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function r2(){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&&O0($)){for($=0,Q=b.responseEnd,u+=1;u<i.length;u++){var le=i[u],me=le.startTime;if(me>Q)break;var Ae=le.transferSize,Re=le.initiatorType;Ae&&O0(Re)&&(le=le.responseEnd,$+=Ae*(le<Q?1:(Q-me)/(le-me)))}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 Kf=null,Zf=null;function qc(r){return r.nodeType===9?r:r.ownerDocument}function R0(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 D0(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 Wf=null;function s2(){var r=window.event;return r&&r.type==="popstate"?r===Wf?!1:(Wf=r,!0):(Wf=null,!1)}var L0=typeof setTimeout=="function"?setTimeout:void 0,a2=typeof clearTimeout=="function"?clearTimeout:void 0,I0=typeof Promise=="function"?Promise:void 0,l2=typeof queueMicrotask=="function"?queueMicrotask:typeof I0<"u"?function(r){return I0.resolve(null).then(r).catch(i2)}:L0;function i2(r){setTimeout(function(){throw r})}function va(r){return r==="head"}function z0(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[On]||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 $0(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 Jf(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":Jf(i),hr(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}r.removeChild(i)}}function o2(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[On])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=Qr(r.nextSibling),r===null)break}return null}function c2(r,a,i){if(a==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!i||(r=Qr(r.nextSibling),r===null))return null;return r}function B0(r,a){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!a||(r=Qr(r.nextSibling),r===null))return null;return r}function eh(r){return r.data==="$?"||r.data==="$~"}function th(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function d2(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 Qr(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 nh=null;function H0(r){r=r.nextSibling;for(var a=0;r;){if(r.nodeType===8){var i=r.data;if(i==="/$"||i==="/&"){if(a===0)return Qr(r.nextSibling);a--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||a++}r=r.nextSibling}return null}function P0(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 U0(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]);hr(r)}var Wr=new Map,q0=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:u2,r:f2,D:h2,C:m2,L:x2,m:p2,X:b2,S:g2,M:y2};function u2(){var r=Xs.f(),a=Lc();return r||a}function f2(r){var a=er(r);a!==null&&a.tag===5&&a.type==="form"?lg(a):Xs.r(r)}var Ul=typeof document>"u"?null:document;function V0(r,a,i){var u=Ul;if(u&&typeof a=="string"&&a){var b=Dn(a);b='link[rel="'+r+'"][href="'+b+'"]',typeof i=="string"&&(b+='[crossorigin="'+i+'"]'),q0.has(b)||(q0.add(b),r={rel:r,crossOrigin:i,href:a},u.querySelector(b)===null&&(a=u.createElement("link"),ir(a,"link",r),wn(a),u.head.appendChild(a)))}}function h2(r){Xs.D(r),V0("dns-prefetch",r,null)}function m2(r,a){Xs.C(r,a),V0("preconnect",r,a)}function x2(r,a,i){Xs.L(r,a,i);var u=Ul;if(u&&r&&a){var b='link[rel="preload"][as="'+Dn(a)+'"]';a==="image"&&i&&i.imageSrcSet?(b+='[imagesrcset="'+Dn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(b+='[imagesizes="'+Dn(i.imageSizes)+'"]')):b+='[href="'+Dn(r)+'"]';var j=b;switch(a){case"style":j=ql(r);break;case"script":j=Vl(r)}Wr.has(j)||(r=x({rel:"preload",href:a==="image"&&i&&i.imageSrcSet?void 0:r,as:a},i),Wr.set(j,r),u.querySelector(b)!==null||a==="style"&&u.querySelector(Qi(j))||a==="script"&&u.querySelector(Wi(j))||(a=u.createElement("link"),ir(a,"link",r),wn(a),u.head.appendChild(a)))}}function p2(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="'+Dn(u)+'"][href="'+Dn(r)+'"]',j=b;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Vl(r)}if(!Wr.has(j)&&(r=x({rel:"modulepreload",href:r},a),Wr.set(j,r),i.querySelector(b)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(Wi(j)))return}u=i.createElement("link"),ir(u,"link",r),wn(u),i.head.appendChild(u)}}}function g2(r,a,i){Xs.S(r,a,i);var u=Ul;if(u&&r){var b=tr(u).hoistableStyles,j=ql(r);a=a||"default";var $=b.get(j);if(!$){var Q={loading:0,preload:null};if($=u.querySelector(Qi(j)))Q.loading=5;else{r=x({rel:"stylesheet",href:r,"data-precedence":a},i),(i=Wr.get(j))&&rh(r,i);var le=$=u.createElement("link");wn(le),ir(le,"link",r),le._p=new Promise(function(me,Ae){le.onload=me,le.onerror=Ae}),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 b2(r,a){Xs.X(r,a);var i=Ul;if(i&&r){var u=tr(i).hoistableScripts,b=Vl(r),j=u.get(b);j||(j=i.querySelector(Wi(b)),j||(r=x({src:r,async:!0},a),(a=Wr.get(b))&&sh(r,a),j=i.createElement("script"),wn(j),ir(j,"link",r),i.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function y2(r,a){Xs.M(r,a);var i=Ul;if(i&&r){var u=tr(i).hoistableScripts,b=Vl(r),j=u.get(b);j||(j=i.querySelector(Wi(b)),j||(r=x({src:r,async:!0,type:"module"},a),(a=Wr.get(b))&&sh(r,a),j=i.createElement("script"),wn(j),ir(j,"link",r),i.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function F0(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=tr(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=tr(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(Qi(r)))&&!j._p&&($.instance=j,$.state.loading=5),Wr.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},Wr.set(r,i),j||v2(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=tr(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="'+Dn(r)+'"'}function Qi(r){return'link[rel="stylesheet"]['+r+"]"}function Y0(r){return x({},r,{"data-precedence":r.precedence,precedence:null})}function v2(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}),ir(a,"link",i),wn(a),r.head.appendChild(a))}function Vl(r){return'[src="'+Dn(r)+'"]'}function Wi(r){return"script[async]"+r}function G0(r,a,i){if(a.count++,a.instance===null)switch(a.type){case"style":var u=r.querySelector('style[data-href~="'+Dn(i.href)+'"]');if(u)return a.instance=u,wn(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"),wn(u),ir(u,"style",b),Fc(u,i.precedence,r),a.instance=u;case"stylesheet":b=ql(i.href);var j=r.querySelector(Qi(b));if(j)return a.state.loading|=4,a.instance=j,wn(j),j;u=Y0(i),(b=Wr.get(b))&&rh(u,b),j=(r.ownerDocument||r).createElement("link"),wn(j);var $=j;return $._p=new Promise(function(Q,le){$.onload=Q,$.onerror=le}),ir(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(Wi(j)))?(a.instance=b,wn(b),b):(u=i,(b=Wr.get(j))&&(u=x({},i),sh(u,b)),r=r.ownerDocument||r,b=r.createElement("script"),wn(b),ir(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 rh(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.title==null&&(r.title=a.title)}function sh(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 X0(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[On]||j[Qe]||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 K0(r,a,i){r=r.ownerDocument||r,r.head.insertBefore(i,a==="title"?r.querySelector("head > title"):null)}function j2(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 Z0(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function w2(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(Qi(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,wn(j);return}j=a.ownerDocument||a,u=Y0(u),(b=Wr.get(b))&&rh(u,b),j=j.createElement("link"),wn(j);var $=j;$._p=new Promise(function(Q,le){$.onload=Q,$.onerror=le}),ir(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 ah=0;function N2(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&&ah===0&&(ah=62500*r2());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>ah?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(k2,r),Xc=null,Gc.call(r))}function k2(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:V,_currentValue2:V,_threadCount:0};function S2(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=vn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vn(0),this.hiddenUpdates=vn(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 Q0(r,a,i,u,b,j,$,Q,le,me,Ae,Re){return r=new S2(r,a,i,$,le,me,Ae,Re,Q),a=1,j===!0&&(a|=24),j=Or(3,null,null,a),r.current=j,j.stateNode=r,a=zu(),a.refCount++,r.pooledCache=a,a.refCount++,j.memoizedState={element:u,isDehydrated:i,cache:a},Pu(j),r}function W0(r){return r?(r=jl,r):jl}function J0(r,a,i,u,b,j){b=W0(b),u.context===null?u.context=b:u.pendingContext=b,u=ca(a),u.payload={element:i},j=j===void 0?null:j,j!==null&&(u.callback=j),i=da(r,u,a),i!==null&&(Sr(i,r,a),Mi(i,r,a))}function eb(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var i=r.retryLane;r.retryLane=i!==0&&i<a?i:a}}function lh(r,a){eb(r,a),(r=r.alternate)&&eb(r,a)}function tb(r){if(r.tag===13||r.tag===31){var a=Ua(r,67108864);a!==null&&Sr(a,r,67108864),lh(r,67108864)}}function nb(r){if(r.tag===13||r.tag===31){var a=zr();a=Fe(a);var i=Ua(r,a);i!==null&&Sr(i,r,a),lh(r,a)}}var Zc=!0;function C2(r,a,i,u){var b=_.T;_.T=null;var j=P.p;try{P.p=2,ih(r,a,i,u)}finally{P.p=j,_.T=b}}function E2(r,a,i,u){var b=_.T;_.T=null;var j=P.p;try{P.p=8,ih(r,a,i,u)}finally{P.p=j,_.T=b}}function ih(r,a,i,u){if(Zc){var b=oh(u);if(b===null)Gf(r,a,u,Qc,i),sb(r,u);else if(_2(b,r,a,i,u))u.stopPropagation();else if(sb(r,u),a&4&&-1<T2.indexOf(r)){for(;b!==null;){var j=er(b);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var $=Ve(j.pendingLanes);if($!==0){var Q=j;for(Q.pendingLanes|=2,Q.entangledLanes|=2;$;){var le=1<<31-St($);Q.entanglements[1]|=le,$&=~le}js(j),(an&6)===0&&(Rc=vt()+500,Gi(0))}}break;case 31:case 13:Q=Ua(j,2),Q!==null&&Sr(Q,j,2),Lc(),lh(j,2)}if(j=oh(u),j===null&&Gf(r,a,u,Qc,i),j===b)break;b=j}b!==null&&u.stopPropagation()}else Gf(r,a,u,null,i)}}function oh(r){return r=ht(r),ch(r)}var Qc=null;function ch(r){if(Qc=null,r=mr(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 Qc=r,null}function rb(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(Kt()){case we:return 2;case De:return 8;case Ue:case Je:return 32;case pt:return 268435456;default:return 32}default:return 32}}var dh=!1,ja=null,wa=null,Na=null,eo=new Map,to=new Map,ka=[],T2="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 sb(r,a){switch(r){case"focusin":case"focusout":ja=null;break;case"dragenter":case"dragleave":wa=null;break;case"mouseover":case"mouseout":Na=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=er(a),a!==null&&tb(a)),r):(r.eventSystemFlags|=u,a=r.targetContainers,b!==null&&a.indexOf(b)===-1&&a.push(b),r)}function _2(r,a,i,u,b){switch(a){case"focusin":return ja=no(ja,r,a,i,u,b),!0;case"dragenter":return wa=no(wa,r,a,i,u,b),!0;case"mouseover":return Na=no(Na,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 ab(r){var a=mr(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(){nb(i)});return}}else if(a===31){if(a=h(i),a!==null){r.blockedOn=a,Ct(r.priority,function(){nb(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 Wc(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var i=oh(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=er(i),a!==null&&tb(a),r.blockedOn=i,!1;a.shift()}return!0}function lb(r,a,i){Wc(r)&&i.delete(a)}function A2(){dh=!1,ja!==null&&Wc(ja)&&(ja=null),wa!==null&&Wc(wa)&&(wa=null),Na!==null&&Wc(Na)&&(Na=null),eo.forEach(lb),to.forEach(lb)}function Jc(r,a){r.blockedOn===a&&(r.blockedOn=null,dh||(dh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,A2)))}var ed=null;function ib(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(ch(u||i)===null)continue;break}var j=er(i);j!==null&&(r.splice(a,3),a-=3,of(j,{pending:!0,data:b,method:i.method,action:u},u,b))}}))}function Fl(r){function a(le){return Jc(le,r)}ja!==null&&Jc(ja,r),wa!==null&&Jc(wa,r),Na!==null&&Jc(Na,r),eo.forEach(a),to.forEach(a);for(var i=0;i<ka.length;i++){var u=ka[i];u.blockedOn===r&&(u.blockedOn=null)}for(;0<ka.length&&(i=ka[0],i.blockedOn===null);)ab(i),i.blockedOn===null&&ka.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[at]||null;if(typeof j=="function")$||ib(i);else if($){var Q=null;if(j&&j.hasAttribute("formAction")){if(b=j,$=j[at]||null)Q=$.formAction;else if(ch(b)!==null)continue}else Q=$.action;typeof Q=="function"?i[u+1]=Q:(i.splice(u,3),u-=3),ib(i)}}}function ob(){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 uh(r){this._internalRoot=r}td.prototype.render=uh.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(l(409));var i=a.current,u=zr();J0(i,u,r,a,null,null)},td.prototype.unmount=uh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;J0(r.current,2,null,r,null,null),Lc(),a[fn]=null}};function td(r){this._internalRoot=r}td.prototype.unstable_scheduleHydration=function(r){if(r){var a=ot();r={blockedOn:null,target:r,priority:a};for(var i=0;i<ka.length&&a!==0&&a<ka[i].priority;i++);ka.splice(i,0,r),i===0&&ab(r)}};var cb=n.version;if(cb!=="19.2.4")throw Error(l(527,cb,"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?p(r):null,r=r===null?null:r.stateNode,r};var M2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:_,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(M2),Lt=nd}catch{}}return so.createRoot=function(r,a){if(!o(r))throw Error(l(299));var i=!1,u="",b=pg,j=gg,$=bg;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=Q0(r,1,!1,null,null,i,u,null,b,j,$,ob),r[fn]=a.current,Yf(r),new uh(a)},so.hydrateRoot=function(r,a,i){if(!o(r))throw Error(l(299));var u=!1,b="",j=pg,$=gg,Q=bg,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=Q0(r,1,!0,a,i??null,u,b,le,j,$,Q,ob),a.context=W0(null),i=a.current,u=zr(),u=Fe(u),b=ca(u),b.callback=null,da(i,b,u),i=u,a.current.lanes=i,Dt(a,i),js(a),r[fn]=a.current,Yf(r),new td(a)},so.version="19.2.4",so}var yb;function P2(){if(yb)return mh.exports;yb=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(),mh.exports=H2(),mh.exports}var U2=P2();const pe={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",REPORTS:"reports",SETTINGS:"settings"},q2=new Set(Object.values(pe)),V2={dashboard:pe.HOME,overview:pe.HOME,chat:pe.TEAM,projects:pe.WORK,tasks:pe.WORK,usage:pe.REPORTS,prompts:pe.BUILDER,templates:pe.STORE,agents:pe.STORE,skills:pe.STORE,teams:pe.STORE,knowledge:pe.DELIVERABLES,governance:pe.SETTINGS};function La(e){return q2.has(e)?e:V2[e]??pe.HOME}function rd(){const e=window.location.hash.slice(1).split("/")[0];return La(e)}function im(e,n){return n?`#${e}/${n}`:`#${e}`}const F2={[pe.STORE]:pe.BUILDER,[pe.REPORTS]:pe.SETTINGS},Ql={[pe.HOME]:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",[pe.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",[pe.TEAM]:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",[pe.REPORTS]:"M18 20V10 M12 20V4 M6 20v-6",[pe.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",[pe.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",[pe.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",[pe.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"},Y2=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],G2=[{id:pe.HOME,label:"Home",section:"workspace"},{id:pe.TEAM,label:"Team",section:"workspace"},{id:pe.DELIVERABLES,label:"Deliverables",section:"workspace"},{id:pe.BUILDER,label:"Builder",section:"build"},{id:pe.STORE,label:"Store",section:"build"},{id:pe.REPORTS,label:"Reports",section:"system"},{id:pe.SETTINGS,label:"Settings",section:"system"}],X2=[{id:pe.HOME,label:"Home",group:[pe.HOME]},{id:pe.TEAM,label:"Team",group:[pe.TEAM]},{id:pe.WORK,label:"Work",group:[pe.WORK]},{id:pe.DELIVERABLES,label:"Deliverables",group:[pe.DELIVERABLES]},{id:pe.BUILDER,label:"Builder",group:[pe.BUILDER,pe.STORE]},{id:pe.SETTINGS,label:"Settings",group:[pe.SETTINGS,pe.REPORTS]}],u1="/api";async function ue(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:()=>ue("/agents"),get:e=>ue(`/agents/${e}`),create:(e,n,s,l)=>ue("/agents",{method:"POST",body:JSON.stringify({name:e,roleName:n,agentRole:s,teamId:l})}),start:e=>ue(`/agents/${e}/start`,{method:"POST"}),stop:e=>ue(`/agents/${e}/stop`,{method:"POST"}),remove:(e,n)=>ue(`/agents/${e}${n?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,n)=>ue(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(n)}),getMemory:e=>ue(`/agents/${e}/memory`),getMemorySession:(e,n)=>ue(`/agents/${e}/memory/sessions/${encodeURIComponent(n)}`),updateDailyMemory:(e,n)=>ue(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:n})}),updateLongTermMemory:(e,n,s)=>ue(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:n,content:s})}),getFiles:e=>ue(`/agents/${e}/files`),getFilesMap:e=>ue(`/agents/${e}/files`),updateFile:(e,n,s)=>ue(`/agents/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,n)=>ue(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:n})}),roleStatus:e=>ue(`/agents/${e}/role-status`),roleDiff:(e,n="ROLE.md")=>ue(`/agents/${e}/role-diff?file=${encodeURIComponent(n)}`),roleSync:(e,n)=>ue(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(n?{files:n}:{})}),roleUpdates:()=>ue("/agents/role-updates"),addSkill:(e,n)=>ue(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:n})}),removeSkill:(e,n)=>ue(`/agents/${e}/skills/${encodeURIComponent(n)}`,{method:"DELETE"}),getHeartbeat:e=>ue(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>ue(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),getRecentActivities:e=>ue(`/agents/${e}/recent-activities`),getActivityLogs:(e,n)=>ue(`/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 ue(`/agents/${e}/activities${l?"?"+l:""}`)},getMindState:e=>ue(`/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 ue(`/agents/${e}/mailbox${l?"?"+l:""}`)},getDecisions:(e,n=50)=>ue(`/agents/${e}/decisions?limit=${n}`),message:(e,n,s,l)=>ue(`/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="",p;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 g=x.body?.getReader();if(!g){m(new Error("No reader"));return}const y=new TextDecoder;let w="";for(;;){const{done:N,value:C}=await g.read();if(N)break;w+=y.decode(C,{stream:!0});const A=w.split(`
|
|
10
|
+
`);w=A.pop()??"";for(const O of A){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&&(p=S.sessionId);else if(S.type==="error"){const R=S;R.sessionId&&(p=R.sessionId);const D=new Error(R.message??R.error??"Unknown stream error");D.sessionId=R.sessionId,m(D),g.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:p})}catch(x){x instanceof Error&&x.name==="AbortError"?h({content:f,sessionId:p}):m(x)}})},roles:{list:()=>ue("/roles")},teams:{list:e=>ue(`/teams?orgId=${e??"default"}`),create:(e,n)=>ue("/teams",{method:"POST",body:JSON.stringify({name:e,description:n})}),update:(e,n)=>ue(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(n)}),delete:(e,n,s)=>ue(`/teams/${e}?deleteMembers=${n?"true":"false"}${s?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,n,s)=>ue(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:n,memberType:s})}),removeMember:(e,n)=>ue(`/teams/${e}/members/${n}`,{method:"DELETE"}),startAll:e=>ue(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>ue(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,n)=>ue(`/teams/${e}/pause`,{method:"POST",body:JSON.stringify({reason:n})}),resumeAll:e=>ue(`/teams/${e}/resume`,{method:"POST"}),status:e=>ue(`/teams/${e}/status`),getFiles:e=>ue(`/teams/${e}/files`),getFile:(e,n)=>ue(`/teams/${e}/files/${encodeURIComponent(n)}`),updateFile:(e,n,s)=>ue(`/teams/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),exportTeam:e=>ue(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>ue(`/teams/${e}/export`)},externalAgents:{list:e=>ue(`/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 ue(`/tasks${s?`?${s}`:""}`)},get:e=>ue(`/tasks/${e}`),create:(e,n,s,l,o,d,c,h,m,f)=>ue("/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)=>ue(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>ue(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:n})}),assign:(e,n)=>ue(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:n})}),approve:e=>ue(`/tasks/${e}/approve`,{method:"POST"}),reject:e=>ue(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,n=!1)=>ue(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:n})}),getDependentCount:e=>ue(`/tasks/${e}/dependents`),board:e=>{const n=new URLSearchParams;e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return ue(`/taskboard${s?`?${s}`:""}`)},listSubtasks:e=>ue(`/tasks/${e}/subtasks`),createSubtask:(e,n)=>ue(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:n})}),completeSubtask:(e,n)=>ue(`/tasks/${e}/subtasks/${n}/complete`,{method:"POST"}),cancelSubtask:(e,n)=>ue(`/tasks/${e}/subtasks/${n}/cancel`,{method:"POST"}),deleteSubtask:(e,n)=>ue(`/tasks/${e}/subtasks/${n}`,{method:"DELETE"}),run:e=>ue(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,n)=>ue(`/tasks/${e}/logs${n!=null?`?round=${n}`:""}`),getLogsSummary:e=>ue(`/tasks/${e}/logs/summary`),accept:(e,n)=>ue(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerAgentId:n??"human"})}),revision:(e,n,s)=>ue(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:n,reviewerAgentId:s??"human"})}),archive:e=>ue(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>ue(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>ue(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>ue(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>ue(`/tasks/${e}/comments`),addComment:(e,n,s,l,o,d,c)=>ue(`/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=>ue(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>ue(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>ue(`/tasks/${e}/schedule/run-now`,{method:"POST"}),deliverables:e=>{const n=e?`?projectId=${encodeURIComponent(e)}`:"";return ue(`/tasks/deliverables${n}`)}},files:{preview:e=>ue(`/files/preview?path=${encodeURIComponent(e)}`),reveal:e=>ue("/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 ue(`/requirements${s?`?${s}`:""}`)},get:e=>ue(`/requirements/${e}`),create:e=>ue("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>ue(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>ue(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:n})}),approve:e=>ue(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,n)=>ue(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:n})}),cancel:e=>ue(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>ue(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>ue(`/requirements/${e}/comments`),addComment:(e,n,s,l,o,d)=>ue(`/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=>ue(`/users?orgId=${e??"default"}`),create:(e,n,s,l,o,d)=>ue("/users",{method:"POST",body:JSON.stringify({name:e,role:n,orgId:s,email:l,password:o,teamId:d})}),remove:e=>ue(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const n=e?`?q=${encodeURIComponent(e)}`:"";return ue(`/team-templates${n}`)},get:e=>ue(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>ue(`/ops/dashboard?period=${e}`)},agentMetrics:(e,n="24h")=>ue(`/agents/${e}/metrics?period=${n}`),usage:{summary:(e="default",n)=>{const s=new URLSearchParams({orgId:e});return n&&s.set("period",n),ue(`/usage?${s}`)},agents:(e="default")=>ue(`/usage/agents?orgId=${e}`)},health:()=>ue("/health"),system:{openPath:e=>ue("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>ue("/system/storage"),orphans:()=>ue("/system/storage/orphans"),purgeOrphans:e=>ue("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},settings:{getLlm:()=>ue("/settings/llm"),getAgent:()=>ue("/settings/agent"),updateAgent:e=>ue("/settings/agent",{method:"POST",body:JSON.stringify(e)})},skills:{list:()=>ue("/skills"),builtin:()=>ue("/skills/builtin"),registry:e=>ue(`/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 ue(`/skills/registry/skillhub${s?`?${s}`:""}`)},registrySkillssh:e=>ue(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,n,s,l)=>ue("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:n,description:s,category:l})}),install:e=>ue("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>ue(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>ue(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>ue("/builder/artifacts"),get:(e,n)=>ue(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`),save:(e,n)=>ue("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:n})}),import:(e,n,s,l)=>ue("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:n,files:s,source:l})}),install:(e,n)=>ue(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/install`,{method:"POST"}),uninstall:(e,n)=>ue(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/uninstall`,{method:"POST"}),delete:(e,n)=>ue(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`,{method:"DELETE"}),installed:()=>ue("/builder/artifacts/installed")}},auth:{login:(e,n)=>ue("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})}),logout:()=>ue("/auth/logout",{method:"POST"}),me:()=>ue("/auth/me"),changePassword:(e,n)=>ue("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:n})})},sessions:{listByAgent:(e,n=20)=>ue(`/agents/${e}/sessions?limit=${n}`),getMessages:(e,n=50,s)=>ue(`/sessions/${e}/messages?limit=${n}${s?`&before=${s}`:""}`),delete:e=>ue(`/sessions/${e}`,{method:"DELETE"})},channels:{getMessages:(e,n=50,s)=>ue(`/channels/${encodeURIComponent(e)}/messages?limit=${n}${s?`&before=${s}`:""}`),sendMessage:(e,n)=>ue(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})},governance:{getSystemStatus:()=>ue("/system/status"),pauseAll:e=>ue("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>ue("/system/resume-all",{method:"POST"}),emergencyStop:e=>ue("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>ue("/system/announcements"),createAnnouncement:e=>ue("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>ue("/governance/policy"),setPolicy:e=>ue("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const n=e?`?status=${e}`:"";return ue(`/approvals${n}`)},respond:(e,n,s)=>ue(`/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)),ue(`/notifications?${l}`)},markRead:e=>ue(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>ue("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},projects:{list:e=>{const n=e?`?orgId=${e}`:"";return ue(`/projects${n}`)},get:e=>ue(`/projects/${e}`),create:e=>ue("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>ue(`/projects/${e}`,{method:"PUT",body:JSON.stringify(n)}),delete:e=>ue(`/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),ue(`/knowledge/search?${l}`)},contribute:e=>ue("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,n)=>ue(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:n})}),verify:e=>ue(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>ue(`/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)),ue(`/deliverables?${n}`)},create:e=>ue("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>ue(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(n)}),remove:e=>ue(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>ue(`/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)),ue(`/reviews?${s}`)},get:e=>ue(`/reviews/${e}`),run:e=>ue("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>ue("/reports"),get:e=>ue(`/reports/${e}`),generate:e=>ue("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,n)=>ue(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(n)}),rejectPlan:(e,n)=>ue(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(n)}),addFeedback:(e,n)=>ue(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(n)}),getFeedback:e=>ue(`/reports/${e}/feedback`)},executionLogs:{get:(e,n)=>ue(`/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 K2(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 Z2{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 pn=new Z2;let Eo=window.__MARKUS_HUB_URL__??"https://markus.global";ue("/settings/hub").then(e=>{e.hubUrl&&(Eo=e.hubUrl);const n=localStorage.getItem("markus_hub_token");n&&ue("/settings/hub-token",{method:"POST",body:JSON.stringify({token:n})}).catch(()=>{})}).catch(()=>{});const Gm="markus_hub_token",Xm="markus_hub_user";function Ra(){return localStorage.getItem(Gm)}function Q2(){try{const e=localStorage.getItem(Xm);return e?JSON.parse(e):null}catch{return null}}function f1(){localStorage.removeItem(Gm),localStorage.removeItem(Xm),h1(null)}function cm(e,n){localStorage.setItem(Gm,e),localStorage.setItem(Xm,JSON.stringify(n)),h1(e)}function h1(e){ue("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}let ao=null;function Ca(){if(Ra())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 p=()=>{clearInterval(x),clearInterval(g),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),p(),m?.close(),n())}catch{}},1500),g=setInterval(()=>{f||m?.closed&&(f=!0,p(),Ra()?n():s(new Error("Hub login cancelled")))},500)}),ao}async function Jr(e,n){const s=Ra(),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 Gn={getUrl:()=>Eo,isAuthenticated:()=>!!Ra(),getUser:Q2,logout:()=>{f1()},ensureAuth:Ca,login:async(e,n)=>{const s=await Jr("/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 Jr("/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 Jr(`/items${s?`?${s}`:""}`)},getItem:e=>Jr(`/items/${e}`),download:async e=>{await Ca();try{return await Jr(`/items/${e}/download`,{method:"POST"})}catch(n){if(!Ra())return await Ca(),Jr(`/items/${e}/download`,{method:"POST"});throw n}},publish:async e=>{await Ca();try{return await Jr("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!Ra())return await Ca(),Jr("/items",{method:"POST",body:JSON.stringify(e)});throw n}},publishViaProxy:async e=>{await Ca();try{return await Jr("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!Ra())return await Ca(),Jr("/items",{method:"POST",body:JSON.stringify(e)});throw n}},myItems:async()=>Ra()?Jr("/items/mine"):{items:[]},deleteItem:async e=>(await Ca(),Jr(`/items/${e}`,{method:"DELETE"}))};let vb=null;const bt={setHandler(e){vb=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}})),vb?.(e,n)}};function jb(){const[e,n]=v.useState([]),[s,l]=v.useState([]),[o,d]=v.useState({}),[c,h]=v.useState(null),m="7d",[f,p]=v.useState([]),[x,g]=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=>{p(z.requirements.filter(K=>K.status==="pending"))}).catch(()=>{}),re.system.storage().then(g).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,A=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,q=U.filter(E=>E.status==="idle"||E.status==="working").length;return{team:K,agents:U,working:G,active:q,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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.TEAM)}),t.jsx(sd,{label:"Tasks In Progress",value:A,color:"blue",onClick:()=>bt.navigate(pe.WORK)}),t.jsx(sd,{label:"Pending Queue",value:C,color:"amber",onClick:()=>bt.navigate(pe.WORK)}),t.jsx(sd,{label:"Completed",value:O,total:k>0?k:void 0,color:"green",onClick:()=>bt.navigate(pe.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:pe.TEAM},{label:"Hire Agents",desc:"Browse templates: developers, researchers, writers, analysts, and more",page:pe.STORE},{label:"Create a Project",desc:"Set up requirements and let agents plan, execute, and deliver",page:pe.WORK}].map(z=>t.jsxs("button",{onClick:()=>bt.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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.WORK),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"Task Distribution"}),t.jsx(J2,{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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.TEAM),children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",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 shrink-0",children:z.team.name.charAt(0)}),t.jsxs("div",{className:"min-w-0",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-[260px]",children:z.team.description})]}),t.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary ml-auto shrink-0",children:[t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-surface-overlay/50",children:[z.total," members"]}),z.working>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-500",children:[z.working," working"]}),t.jsxs("span",{className:`px-1.5 py-0.5 rounded ${z.active===z.total?"bg-green-500/15 text-green-600":"bg-surface-overlay/50"}`,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(),bt.navigate(pe.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-blue-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:()=>bt.navigate(pe.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-blue-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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.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:()=>bt.navigate(pe.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:wb(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: ",wb(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"},W2={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 J2({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 ${W2[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-400",border:"border-l-brand-500",glow:"hover:shadow-brand-500/10"},blue:{text:"text-blue-400",border:"border-l-blue-500",glow:"hover:shadow-blue-500/10"},amber:{text:"text-amber-400",border:"border-l-amber-500",glow:"hover:shadow-amber-500/10"},green:{text:"text-green-400",border:"border-l-green-500",glow:"hover:shadow-green-500/10"}},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/80 hover:shadow-lg ${c.glow} transition-all duration-200`,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",p=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 ${p}`,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 wb(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 ek(e,n){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const tk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rk={};function Nb(e,n){return(rk.jsx?nk:tk).test(e)}const sk=/[ \t\n\f\r]/g;function ak(e){return typeof e=="object"?e.type==="text"?kb(e.value):!1:kb(e)}function kb(e){return e.replace(sk,"")===""}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 lk=0;const Bt=pl(),Yn=pl(),fm=pl(),Be=pl(),kn=pl(),ri=pl(),$r=pl();function pl(){return 2**++lk}const hm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Bt,booleanish:Yn,commaOrSpaceSeparated:$r,commaSeparated:ri,number:Be,overloadedBoolean:fm,spaceSeparated:kn},Symbol.toStringTag,{value:"Module"})),bh=Object.keys(hm);class Km extends _r{constructor(n,s,l,o){let d=-1;if(super(n,s),Sb(this,"space",o),typeof l=="number")for(;++d<bh.length;){const c=bh[d];Sb(this,bh[d],(l&hm[c])===hm[c])}}}Km.prototype.defined=!0;function Sb(e,n,s){s&&(e[n]=s)}function pi(e){const n={},s={};for(const[l,o]of Object.entries(e.properties)){const d=new Km(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=pi({properties:{ariaActiveDescendant:null,ariaAtomic:Yn,ariaAutoComplete:null,ariaBusy:Yn,ariaChecked:Yn,ariaColCount:Be,ariaColIndex:Be,ariaColSpan:Be,ariaControls:kn,ariaCurrent:null,ariaDescribedBy:kn,ariaDetails:null,ariaDisabled:Yn,ariaDropEffect:kn,ariaErrorMessage:null,ariaExpanded:Yn,ariaFlowTo:kn,ariaGrabbed:Yn,ariaHasPopup:null,ariaHidden:Yn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kn,ariaLevel:Be,ariaLive:null,ariaModal:Yn,ariaMultiLine:Yn,ariaMultiSelectable:Yn,ariaOrientation:null,ariaOwns:kn,ariaPlaceholder:null,ariaPosInSet:Be,ariaPressed:Yn,ariaReadOnly:Yn,ariaRelevant:null,ariaRequired:Yn,ariaRoleDescription:kn,ariaRowCount:Be,ariaRowIndex:Be,ariaRowSpan:Be,ariaSelected:Yn,ariaSetSize:Be,ariaSort:null,ariaValueMax:Be,ariaValueMin:Be,ariaValueNow:Be,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function p1(e,n){return n in e?e[n]:n}function g1(e,n){return p1(e,n.toLowerCase())}const ik=pi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ri,acceptCharset:kn,accessKey:kn,action:null,allow:null,allowFullScreen:Bt,allowPaymentRequest:Bt,allowUserMedia:Bt,alt:null,as:null,async:Bt,autoCapitalize:null,autoComplete:kn,autoFocus:Bt,autoPlay:Bt,blocking:kn,capture:null,charSet:null,checked:Bt,cite:null,className:kn,cols:Be,colSpan:null,content:null,contentEditable:Yn,controls:Bt,controlsList:kn,coords:Be|ri,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Bt,defer:Bt,dir:null,dirName:null,disabled:Bt,download:fm,draggable:Yn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Bt,formTarget:null,headers:kn,height:Be,hidden:fm,high:Be,href:null,hrefLang:null,htmlFor:kn,httpEquiv:kn,id:null,imageSizes:null,imageSrcSet:null,inert:Bt,inputMode:null,integrity:null,is:null,isMap:Bt,itemId:null,itemProp:kn,itemRef:kn,itemScope:Bt,itemType:kn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Bt,low:Be,manifest:null,max:null,maxLength:Be,media:null,method:null,min:null,minLength:Be,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:Be,pattern:null,ping:kn,placeholder:null,playsInline:Bt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Bt,referrerPolicy:null,rel:kn,required:Bt,reversed:Bt,rows:Be,rowSpan:Be,sandbox:kn,scope:null,scoped:Bt,seamless:Bt,selected:Bt,shadowRootClonable:Bt,shadowRootDelegatesFocus:Bt,shadowRootMode:null,shape:null,size:Be,sizes:null,slot:null,span:Be,spellCheck:Yn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Be,step:null,style:null,tabIndex:Be,target:null,title:null,translate:null,type:null,typeMustMatch:Bt,useMap:null,value:Yn,width:Be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kn,axis:null,background:null,bgColor:null,border:Be,borderColor:null,bottomMargin:Be,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:Be,leftMargin:Be,link:null,longDesc:null,lowSrc:null,marginHeight:Be,marginWidth:Be,noResize:Bt,noHref:Bt,noShade:Bt,noWrap:Bt,object:null,profile:null,prompt:null,rev:null,rightMargin:Be,rules:null,scheme:null,scrolling:Yn,standby:null,summary:null,text:null,topMargin:Be,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Be,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Bt,disableRemotePlayback:Bt,prefix:null,property:null,results:Be,security:null,unselectable:null},space:"html",transform:g1}),ok=pi({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:$r,accentHeight:Be,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Be,amplitude:Be,arabicForm:null,ascent:Be,attributeName:null,attributeType:null,azimuth:Be,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Be,by:null,calcMode:null,capHeight:Be,className:kn,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:Be,diffuseConstant:Be,direction:null,display:null,dur:null,divisor:Be,dominantBaseline:null,download:Bt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Be,enableBackground:null,end:null,event:null,exponent:Be,externalResourcesRequired:null,fill:null,fillOpacity:Be,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:Be,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Be,horizOriginX:Be,horizOriginY:Be,id:null,ideographic:Be,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Be,k:Be,k1:Be,k2:Be,k3:Be,k4:Be,kernelMatrix:$r,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Be,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:Be,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:Be,overlineThickness:Be,paintOrder:null,panose1:null,path:null,pathLength:Be,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Be,pointsAtY:Be,pointsAtZ:Be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$r,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$r,rev:$r,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$r,requiredFeatures:$r,requiredFonts:$r,requiredFormats:$r,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:Be,specularExponent:Be,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Be,strikethroughThickness:Be,string:null,stroke:null,strokeDashArray:$r,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Be,strokeOpacity:Be,strokeWidth:null,style:null,surfaceScale:Be,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$r,tabIndex:Be,tableValues:null,target:null,targetX:Be,targetY:Be,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$r,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Be,underlineThickness:Be,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Be,values:null,vAlphabetic:Be,vMathematical:Be,vectorEffect:null,vHanging:Be,vIdeographic:Be,version:null,vertAdvY:Be,vertOriginX:Be,vertOriginY:Be,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Be,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:p1}),b1=pi({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=pi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:g1}),v1=pi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),ck={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"},dk=/[A-Z]/g,Cb=/-[a-z]/g,uk=/^data[-\w.:]+$/i;function fk(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"&&uk.test(n)){if(n.charAt(4)==="-"){const d=n.slice(5).replace(Cb,mk);l="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=n.slice(4);if(!Cb.test(d)){let c=d.replace(dk,hk);c.charAt(0)!=="-"&&(c="-"+c),n="data"+c}}o=Km}return new o(l,n)}function hk(e){return"-"+e.toLowerCase()}function mk(e){return e.charAt(1).toUpperCase()}const xk=m1([x1,ik,b1,y1,v1],"html"),Zm=m1([x1,ok,b1,y1,v1],"svg");function pk(e){return e.join(" ").trim()}var Yl={},yh,Eb;function gk(){if(Eb)return yh;Eb=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="/",p="*",x="",g="comment",y="declaration";function w(C,A){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];A=A||{};var O=1,k=1;function S(T){var L=T.match(n);L&&(O+=L.length);var _=T.lastIndexOf(m);k=~_?T.length-_: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=A.source}D.prototype.content=C;function Y(T){var L=new Error(A.source+":"+O+":"+k+": "+T);if(L.reason=T,L.filename=A.source,L.line=O,L.column=k,L.source=C,!A.silent)throw L}function z(T){var L=T.exec(C);if(L){var _=L[0];return S(_),C=C.slice(_.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)||p!=C.charAt(1))){for(var L=2;x!=C.charAt(L)&&(p!=C.charAt(L)||f!=C.charAt(L+1));)++L;if(L+=2,x===C.charAt(L-1))return Y("End of comment missing");var _=C.slice(2,L-2);return k+=2,S(_),C=C.slice(L),k+=2,T({type:g,comment:_})}}function q(){var T=R(),L=z(l);if(L){if(G(),!z(o))return Y("property missing ':'");var _=z(d),P=T({type:y,property:N(L[0].replace(e,x)),value:_?N(_[0].replace(e,x)):x});return z(c),P}}function E(){var T=[];U(T);for(var L;L=q();)L!==!1&&(T.push(L),U(T));return T}return K(),E()}function N(C){return C?C.replace(h,x):x}return yh=w,yh}var Tb;function bk(){if(Tb)return Yl;Tb=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(gk());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:p}=m;h?o(f,p,m):p&&(d=d||{},d[f]=p)}),d}return Yl}var io={},_b;function yk(){if(_b)return io;_b=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,p){return p.toUpperCase()},h=function(f,p){return"".concat(p,"-")},m=function(f,p){return p===void 0&&(p={}),d(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(o,h):f=f.replace(l,h),f.replace(n,c))};return io.camelCase=m,io}var oo,Ab;function vk(){if(Ab)return oo;Ab=1;var e=oo&&oo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(bk()),s=yk();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 jk=vk();const wk=Gd(jk),j1=w1("end"),Qm=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 Nk(e){const n=Qm(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?Mb(e.position):"start"in e||"end"in e?Mb(e):"line"in e||"column"in e?mm(e):""}function mm(e){return Ob(e&&e.line)+":"+Ob(e&&e.column)}function Mb(e){return mm(e&&e.start)+"-"+mm(e&&e.end)}function Ob(e){return e&&typeof e=="number"?e:1}class fr 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}}fr.prototype.file="";fr.prototype.name="";fr.prototype.reason="";fr.prototype.message="";fr.prototype.stack="";fr.prototype.column=void 0;fr.prototype.line=void 0;fr.prototype.ancestors=void 0;fr.prototype.cause=void 0;fr.prototype.fatal=void 0;fr.prototype.place=void 0;fr.prototype.ruleId=void 0;fr.prototype.source=void 0;const Wm={}.hasOwnProperty,kk=new Map,Sk=/[A-Z]/g,Ck=new Set(["table","tbody","thead","tfoot","tr"]),Ek=new Set(["td","th"]),N1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Tk(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=Ik(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=Lk(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"?Zm:xk,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 _k(e,n,s);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Ak(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return Ok(e,n,s);if(n.type==="mdxjsEsm")return Mk(e,n);if(n.type==="root")return Rk(e,n,s);if(n.type==="text")return Dk(e,n)}function _k(e,n,s){const l=e.schema;let o=l;n.tagName.toLowerCase()==="svg"&&l.space==="html"&&(o=Zm,e.schema=o),e.ancestors.push(n);const d=C1(e,n.tagName,!1),c=zk(e,n);let h=ex(e,n);return Ck.has(n.tagName)&&(h=h.filter(function(m){return typeof m=="string"?!ak(m):!0})),S1(e,c,d,n),Jm(c,h),e.ancestors.pop(),e.schema=l,e.create(n,d,c,s)}function Ak(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 Mk(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);To(e,n.position)}function Ok(e,n,s){const l=e.schema;let o=l;n.name==="svg"&&l.space==="html"&&(o=Zm,e.schema=o),e.ancestors.push(n);const d=n.name===null?e.Fragment:C1(e,n.name,!0),c=$k(e,n),h=ex(e,n);return S1(e,c,d,n),Jm(c,h),e.ancestors.pop(),e.schema=l,e.create(n,d,c,s)}function Rk(e,n,s){const l={};return Jm(l,ex(e,n)),e.create(n,e.Fragment,l,s)}function Dk(e,n){return n.value}function S1(e,n,s,l){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(n.node=l)}function Jm(e,n){if(n.length>0){const s=n.length>1?n:n[0];s&&(e.children=s)}}function Lk(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 Ik(e,n){return s;function s(l,o,d,c){const h=Array.isArray(d.children),m=Qm(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 zk(e,n){const s={};let l,o;for(o in n.properties)if(o!=="children"&&Wm.call(n.properties,o)){const d=Bk(e,o,n.properties[o]);if(d){const[c,h]=d;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&Ek.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 $k(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 ex(e,n){const s=[];let l=-1;const o=e.passKeys?new Map:kk;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 Bk(e,n,s){const l=fk(e.schema,n);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=l.commaSeparated?ek(s):pk(s)),l.property==="style"){let o=typeof s=="object"?s:Hk(e,String(s));return e.stylePropertyNameCase==="css"&&(o=Pk(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&l.space?ck[l.property]||l.property:l.attribute,s]}}function Hk(e,n){try{return wk(n,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const l=s,o=new fr("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=Nb(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=Nb(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(l.type==="Literal"){const o=l.value;return Wm.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 fr("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 Pk(e){const n={};let s;for(s in e)Wm.call(e,s)&&(n[Uk(s)]=e[s]);return n}function Uk(e){let n=e.replace(Sk,qk);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function qk(e){return"-"+e.toLowerCase()}const vh={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"]},Vk={};function tx(e,n){const s=Vk,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(Fk(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 Rb(e.children,n,s)}return Array.isArray(e)?Rb(e,n,s):""}function Rb(e,n,s){const l=[];let o=-1;for(;++o<e.length;)l[o]=E1(e[o],n,s);return l.join("")}function Fk(e){return!!(e&&typeof e=="object")}const Db=document.createElement("i");function nx(e){const n="&"+e+";";Db.innerHTML=n;const s=Db.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===n?!1:s}function Hr(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 es(e,n){return e.length>0?(Hr(e,e.length,0,n),e):n}const Lb={}.hasOwnProperty;function T1(e){const n={};let s=-1;for(;++s<e.length;)Yk(n,e[s]);return n}function Yk(e,n){let s;for(s in n){const o=(Lb.call(e,s)?e[s]:void 0)||(e[s]={}),d=n[s];let c;if(d)for(c in d){Lb.call(o,c)||(o[c]=[]);const h=d[c];Gk(o[c],Array.isArray(h)?h:h?[h]:[])}}}function Gk(e,n){let s=-1;const l=[];for(;++s<n.length;)(n[s].add==="after"?e:l).push(n[s]);Hr(e,0,0,l)}function _1(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 gr=$a(/[A-Za-z]/),ur=$a(/[\dA-Za-z]/),Xk=$a(/[#-'*+\--9=?A-Z^-~]/);function Cd(e){return e!==null&&(e<32||e===127)}const xm=$a(/\d/),Kk=$a(/[\dA-Fa-f]/),Zk=$a(/[!-/:-@[-`{-~]/);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 Xd=$a(new RegExp("\\p{P}|\\p{S}","u")),dl=$a(/\s/);function $a(e){return n;function n(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function gi(e){const n=[];let s=-1,l=0,o=0;for(;++s<e.length;){const d=e.charCodeAt(s);let c="";if(d===37&&ur(e.charCodeAt(s+1))&&ur(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 Qk={tokenize:Wk};function Wk(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 Jk={tokenize:eS},Ib={tokenize:tS};function eS(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}A(l);let Y=S;for(;Y<n.events.length;)n.events[Y][1].end={...D},Y++;return Hr(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 g(k);if(o.currentConstruct&&o.currentConstruct.concrete)return w(k);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Ib,p,x)(k)}function p(k){return o&&O(),A(l),g(k)}function x(k){return n.parser.lazy[n.now().line]=l!==s.length,c=n.now().offset,w(k)}function g(k){return n.containerState={},e.attempt(Ib,y,w)(k)}function y(k){return l++,s.push([n.currentConstruct,n.containerState]),g(k)}function w(k){if(k===null){o&&O(),A(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),A(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(A(l),D=Y;D<n.events.length;)n.events[D][1].end={...U},D++;Hr(n.events,z+1,0,n.events.slice(Y)),n.events.length=D}}function A(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 tS(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(Xd(e))return 2}function Kd(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 pm={name:"attention",resolveAll:nS,tokenize:rS};function nS(e,n){let s=-1,l,o,d,c,h,m,f,p;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},g={...e[s][1].start};zb(x,-m),zb(g,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:g},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=es(f,[["enter",e[l][1],n],["exit",e[l][1],n]])),f=es(f,[["enter",o,n],["enter",c,n],["exit",c,n],["enter",d,n]]),f=es(f,Kd(n.parser.constructs.insideSpan.null,e.slice(l+1,s),n)),f=es(f,[["exit",d,n],["enter",h,n],["exit",h,n],["exit",o,n]]),e[s][1].end.offset-e[s][1].start.offset?(p=2,f=es(f,[["enter",e[s][1],n],["exit",e[s][1],n]])):p=0,Hr(e,l-1,s-l+3,f),s=l+f.length-p-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function rS(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"),p=li(m),x=!p||p===2&&o||s.includes(m),g=!o||o===2&&p||s.includes(l);return f._open=!!(d===42?x:x&&(o||!g)),f._close=!!(d===42?g:g&&(p||!x)),n(m)}}function zb(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const sS={name:"autolink",tokenize:aS};function aS(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 gr(y)?(e.consume(y),c):y===64?s(y):f(y)}function c(y){return y===43||y===45||y===46||ur(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||ur(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),p):Xk(y)?(e.consume(y),f):s(y)}function p(y){return ur(y)?x(y):s(y)}function x(y){return y===46?(e.consume(y),l=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),n):g(y)}function g(y){if((y===45||ur(y))&&l++<63){const w=y===45?g:x;return e.consume(y),w}return s(y)}}const qo={partial:!0,tokenize:lS};function lS(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 A1={continuation:{tokenize:oS},exit:cS,name:"blockQuote",tokenize:iS};function iS(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 oS(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(A1,n,s)(c)}}function cS(e){e.exit("blockQuote")}const M1={name:"characterEscape",tokenize:dS};function dS(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 Zk(d)?(e.enter("characterEscapeValue"),e.consume(d),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):s(d)}}const O1={name:"characterReference",tokenize:uS};function uS(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=ur,p(x))}function f(x){return x===88||x===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(x),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),d=6,c=Kk,p):(e.enter("characterReferenceValue"),d=7,c=xm,p(x))}function p(x){if(x===59&&o){const g=e.exit("characterReferenceValue");return c===ur&&!nx(l.sliceSerialize(g))?s(x):(e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return c(x)&&o++<d?(e.consume(x),p):s(x)}}const $b={partial:!0,tokenize:hS},Bb={concrete:!0,name:"codeFenced",tokenize:fS};function fS(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"),p(D)}function p(D){return D===h?(c++,e.consume(D),p):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($b,N,S)(D)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(D))}function g(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),g)}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"),A}function A(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($b,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,q,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):q(L)}function q(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 hS(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 jh={name:"codeIndented",tokenize:xS},mS={partial:!0,tokenize:pS};function xS(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 p=l.events[l.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?c(f):s(f)}function c(f){return f===null?m(f):wt(f)?e.attempt(mS,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 pS(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 gS={name:"codeText",previous:yS,resolve:bS,tokenize:vS};function bS(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 yS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function vS(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,p(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 p(x){return x===96?(e.consume(x),o++,p):o===l?(e.exit("codeTextSequence"),e.exit("codeText"),n(x)):(d.type="codeTextData",f(x))}}class jS{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 p=new jS(e);for(;++s<p.length;){for(;s in n;)s=n[s];if(l=p.get(s),s&&l[1].type==="chunkFlow"&&p.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,wS(p,s)),s=n[s],f=!0);else if(l[1]._container){for(d=s,o=void 0;d--;)if(c=p.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(p.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={...p.get(o)[1].start},h=p.slice(o,s),h.unshift(l),p.splice(o,s-o+1,h))}}return Hr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function wS(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 p,x,g=-1,y=s,w=0,N=0;const C=[N];for(;y;){for(;e.get(++o)[1]!==y;);d.push(o),y._tokenizer||(p=l.sliceStream(y),y.next||p.push(null),x&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(p),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),x=y,y=y.next}for(y=s;++g<h.length;)h[g][0]==="exit"&&h[g-1][0]==="enter"&&h[g][1].type===h[g-1][1].type&&h[g][1].start.line!==h[g][1].end.line&&(N=g+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(),g=C.length;g--;){const A=h.slice(C[g],C[g+1]),O=d.pop();m.push([O,O+A.length-1]),e.splice(O,2,A)}for(m.reverse(),g=-1;++g<m.length;)f[w+m[g][0]]=w+m[g][1],w+=m[g][1]-m[g][0]-1;return f}const NS={resolve:SS,tokenize:CS},kS={partial:!0,tokenize:ES};function SS(e){return R1(e),e}function CS(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(kS,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 ES(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 p=0;return x;function x(A){return A===60?(e.enter(l),e.enter(o),e.enter(d),e.consume(A),e.exit(d),g):A===null||A===32||A===41||Cd(A)?s(A):(e.enter(l),e.enter(c),e.enter(h),e.enter("chunkString",{contentType:"string"}),N(A))}function g(A){return A===62?(e.enter(d),e.consume(A),e.exit(d),e.exit(o),e.exit(l),n):(e.enter(h),e.enter("chunkString",{contentType:"string"}),y(A))}function y(A){return A===62?(e.exit("chunkString"),e.exit(h),g(A)):A===null||A===60||wt(A)?s(A):(e.consume(A),A===92?w:y)}function w(A){return A===60||A===62||A===92?(e.consume(A),y):y(A)}function N(A){return!p&&(A===null||A===41||bn(A))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(l),n(A)):p<f&&A===40?(e.consume(A),p++,N):A===41?(e.consume(A),p--,N):A===null||A===32||A===40||Cd(A)?s(A):(e.consume(A),A===92?C:N)}function C(A){return A===40||A===41||A===92?(e.consume(A),N):N(A)}}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),p}function p(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"),p):(e.enter("chunkString",{contentType:"string"}),x(y))}function x(y){return y===null||y===91||y===93||wt(y)||h++>999?(e.exit("chunkString"),p(y)):(e.consume(y),m||(m=!Ft(y)),y===92?g:x)}function g(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(g){return g===34||g===39||g===40?(e.enter(l),e.enter(o),e.consume(g),e.exit(o),c=g===40?41:g,m):s(g)}function m(g){return g===c?(e.enter(o),e.consume(g),e.exit(o),e.exit(l),n):(e.enter(d),f(g))}function f(g){return g===c?(e.exit(d),m(c)):g===null?s(g):wt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Qt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===c||g===null||wt(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?x:p)}function x(g){return g===c||g===92?(e.consume(g),p):p(g)}}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 TS={name:"definition",tokenize:AS},_S={partial:!0,tokenize:MS};function AS(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,p,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(_S,x,x)(y)}function x(y){return Ft(y)?Qt(e,g,"whitespace")(y):g(y)}function g(y){return y===null||wt(y)?(e.exit("definition"),l.parser.defined.push(o),n(y)):s(y)}}function MS(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 OS={name:"hardBreakEscape",tokenize:RS};function RS(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 DS={name:"headingAtx",resolve:LS,tokenize:IS};function LS(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"},Hr(e,l,s-l+1,[["enter",o,n],["enter",d,n],["exit",d,n],["exit",o,n]])),e}function IS(e,n,s){let l=0;return o;function o(p){return e.enter("atxHeading"),d(p)}function d(p){return e.enter("atxHeadingSequence"),c(p)}function c(p){return p===35&&l++<6?(e.consume(p),c):p===null||bn(p)?(e.exit("atxHeadingSequence"),h(p)):s(p)}function h(p){return p===35?(e.enter("atxHeadingSequence"),m(p)):p===null||wt(p)?(e.exit("atxHeading"),n(p)):Ft(p)?Qt(e,h,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function m(p){return p===35?(e.consume(p),m):(e.exit("atxHeadingSequence"),h(p))}function f(p){return p===null||p===35||bn(p)?(e.exit("atxHeadingText"),h(p)):(e.consume(p),f)}}const zS=["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"],Hb=["pre","script","style","textarea"],$S={concrete:!0,name:"htmlFlow",resolveTo:PS,tokenize:US},BS={partial:!0,tokenize:VS},HS={partial:!0,tokenize:qS};function PS(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 US(e,n,s){const l=this;let o,d,c,h,m;return f;function f(I){return p(I)}function p(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),x}function x(I){return I===33?(e.consume(I),g):I===47?(e.consume(I),d=!0,N):I===63?(e.consume(I),o=3,l.interrupt?n:B):gr(I)?(e.consume(I),c=String.fromCharCode(I),C):s(I)}function g(I){return I===45?(e.consume(I),o=2,y):I===91?(e.consume(I),o=5,h=0,w):gr(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:q:w):s(I)}function N(I){return gr(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&&Hb.includes(H)?(o=1,l.interrupt?n(I):q(I)):zS.includes(c.toLowerCase())?(o=6,M?(e.consume(I),A):l.interrupt?n(I):q(I)):(o=7,l.interrupt&&!l.parser.lazy[l.now().line]?s(I):d?O(I):k(I))}return I===45||ur(I)?(e.consume(I),c+=String.fromCharCode(I),C):s(I)}function A(I){return I===62?(e.consume(I),l.interrupt?n:q):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||gr(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||ur(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)?q(I):Ft(I)?(e.consume(I),G):s(I)}function q(I){return I===45&&o===2?(e.consume(I),_):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(BS,X,E)(I)):I===null||wt(I)?(e.exit("htmlFlowData"),E(I)):(e.consume(I),q)}function E(I){return e.check(HS,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"),q(I))}function _(I){return I===45?(e.consume(I),B):q(I)}function P(I){return I===47?(e.consume(I),c="",V):q(I)}function V(I){if(I===62){const M=c.toLowerCase();return Hb.includes(M)?(e.consume(I),F):q(I)}return gr(I)&&c.length<8?(e.consume(I),c+=String.fromCharCode(I),V):q(I)}function W(I){return I===93?(e.consume(I),B):q(I)}function B(I){return I===62?(e.consume(I),F):I===45&&o===2?(e.consume(I),B):q(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 qS(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 VS(e,n,s){return l;function l(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(qo,n,s)}}const FS={name:"htmlText",tokenize:YS};function YS(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):gr(B)?(e.consume(B),z):s(B)}function f(B){return B===45?(e.consume(B),p):B===91?(e.consume(B),d=0,w):gr(B)?(e.consume(B),O):s(B)}function p(B){return B===45?(e.consume(B),y):s(B)}function x(B){return B===null?s(B):B===45?(e.consume(B),g):wt(B)?(c=x,P(B)):(e.consume(B),x)}function g(B){return B===45?(e.consume(B),y):x(B)}function y(B){return B===62?_(B):B===45?g(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),A):N(B)}function A(B){return B===62?_(B):B===93?(e.consume(B),A):N(B)}function O(B){return B===null||B===62?_(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?_(B):k(B)}function R(B){return gr(B)?(e.consume(B),D):s(B)}function D(B){return B===45||ur(B)?(e.consume(B),D):Y(B)}function Y(B){return wt(B)?(c=Y,P(B)):Ft(B)?(e.consume(B),Y):_(B)}function z(B){return B===45||ur(B)?(e.consume(B),z):B===47||B===62||bn(B)?K(B):s(B)}function K(B){return B===47?(e.consume(B),_):B===58||B===95||gr(B)?(e.consume(B),U):wt(B)?(c=K,P(B)):Ft(B)?(e.consume(B),K):_(B)}function U(B){return B===45||B===46||B===58||B===95||ur(B)?(e.consume(B),U):G(B)}function G(B){return B===61?(e.consume(B),q):wt(B)?(c=G,P(B)):Ft(B)?(e.consume(B),G):K(B)}function q(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=q,P(B)):Ft(B)?(e.consume(B),q):(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 _(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"),V}function V(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 rx={name:"labelEnd",resolveAll:ZS,resolveTo:QS,tokenize:WS},GS={tokenize:JS},XS={tokenize:eC},KS={tokenize:tC};function ZS(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&&Hr(e,0,e.length,s),e}function QS(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}},p={type:"labelText",start:{...e[d+l+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",m,n],["enter",f,n]],h=es(h,e.slice(d+1,d+l+3)),h=es(h,[["enter",p,n]]),h=es(h,Kd(n.parser.constructs.insideSpan.null,e.slice(d+l+4,c-3),n)),h=es(h,[["exit",p,n],e[c-2],e[c-1],["exit",f,n]]),h=es(h,e.slice(c+1)),h=es(h,[["exit",m,n]]),Hr(e,d,e.length,h),e}function WS(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(g){return d?d._inactive?x(g):(c=l.parser.defined.includes(hs(l.sliceSerialize({start:d.end,end:l.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),m):s(g)}function m(g){return g===40?e.attempt(GS,p,c?p:x)(g):g===91?e.attempt(XS,p,c?f:x)(g):c?p(g):x(g)}function f(g){return e.attempt(KS,p,x)(g)}function p(g){return n(g)}function x(g){return d._balanced=!0,s(g)}}function JS(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?p(x):D1(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(x)}function c(x){return bn(x)?wo(e,m)(x):p(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):p(x)}function f(x){return bn(x)?wo(e,p)(x):p(x)}function p(x){return x===41?(e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),e.exit("resource"),n):s(x)}}function eC(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 tC(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 nC={name:"labelStartImage",resolveAll:rx.resolveAll,tokenize:rC};function rC(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 sC={name:"labelStartLink",resolveAll:rx.resolveAll,tokenize:aC};function aC(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 wh={name:"lineEnding",tokenize:lC};function lC(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:iC};function iC(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 Cr={continuation:{tokenize:uC},exit:hC,name:"list",tokenize:dC},oC={partial:!0,tokenize:mC},cC={partial:!0,tokenize:fC};function dC(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:p,e.attempt(oC,g,x))}function p(y){return l.containerState.initialBlankLine=!0,d++,g(y)}function x(y){return Ft(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),g):s(y)}function g(y){return l.containerState.size=d+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(y)}}function uC(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(cC,n,c)(h))}function c(h){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qt(e,e.attempt(Cr,n,s),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function fC(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 hC(e){e.exit(this.containerState.type)}function mC(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 Pb={name:"setextUnderline",resolveTo:xC,tokenize:pC};function xC(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 pC(e,n,s){const l=this;let o;return d;function d(f){let p=l.events.length,x;for(;p--;)if(l.events[p][1].type!=="lineEnding"&&l.events[p][1].type!=="linePrefix"&&l.events[p][1].type!=="content"){x=l.events[p][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 gC={tokenize:bC};function bC(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(NS,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 yC={resolveAll:$1()},vC=z1("string"),jC=z1("text");function z1(e){return{resolveAll:$1(e==="text"?wC: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(p){return f(p)?d(p):h(p)}function h(p){if(p===null){s.consume(p);return}return s.enter("data"),s.consume(p),m}function m(p){return f(p)?(s.exit("data"),d(p)):(s.consume(p),m)}function f(p){if(p===null)return!0;const x=o[p];let g=-1;if(x)for(;++g<x.length;){const y=x[g];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 wC(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 NC={42:Cr,43:Cr,45:Cr,48:Cr,49:Cr,50:Cr,51:Cr,52:Cr,53:Cr,54:Cr,55:Cr,56:Cr,57:Cr,62:A1},kC={91:TS},SC={[-2]:jh,[-1]:jh,32:jh},CC={35:DS,42:yd,45:[Pb,yd],60:$S,61:Pb,95:yd,96:Bb,126:Bb},EC={38:O1,92:M1},TC={[-5]:wh,[-4]:wh,[-3]:wh,33:nC,38:O1,42:pm,60:[sS,FS],91:sC,92:[OS,M1],93:rx,95:pm,96:gS},_C={null:[pm,yC]},AC={null:[42,95]},MC={null:[]},OC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:AC,contentInitial:kC,disable:MC,document:NC,flow:CC,flowInitial:SC,insideSpan:_C,string:EC,text:TC},Symbol.toStringTag,{value:"Module"}));function RC(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:g,sliceStream:y,write:x};let p=n.tokenize.call(f,m);return n.resolveAll&&d.push(n),f;function x(G){return c=es(c,G),C(),c[c.length-1]!==null?[]:(z(n,0),f.events=Kd(d,f.events,f),f.events)}function g(G,q){return LC(y(G),q)}function y(G){return DC(c,G)}function w(){const{_bufferIndex:G,_index:q,line:E,column:T,offset:L}=l;return{_bufferIndex:G,_index:q,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 q=c[l._index];if(typeof q=="string")for(G=l._index,l._bufferIndex<0&&(l._bufferIndex=0);l._index===G&&l._bufferIndex<q.length;)A(q.charCodeAt(l._bufferIndex));else A(q)}}function A(G){p=p(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,q){const E=q||{};return E.type=G,E.start=w(),f.events.push(["enter",E,f]),h.push(E),E}function S(G){const q=h.pop();return q.end=w(),f.events.push(["exit",q,f]),q}function R(G,q){z(G,q.from)}function D(G,q){q.restore()}function Y(G,q){return E;function E(T,L,_){let P,V,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],fe=ne!==null&&Z.null,Ne=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(fe)?fe:fe?[fe]:[]];return X(Ne)(ne)}}function X(Z){return P=Z,V=0,Z.length===0?_:I(Z[V])}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(q?Object.assign(Object.create(f),q):f,m,M,H)(ne)}}function M(Z){return G(W,B),L}function H(Z){return B.restore(),++V<P.length?I(P[V]):_}}}function z(G,q){G.resolveAll&&!d.includes(G)&&d.push(G),G.resolve&&Hr(f.events,q,f.events.length-q,G.resolve(f.events.slice(q),f)),G.resolveTo&&(f.events=G.resolveTo(f.events,f))}function K(){const G=w(),q=f.previous,E=f.currentConstruct,T=f.events.length,L=Array.from(h);return{from:T,restore:_};function _(){l=G,f.previous=q,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 DC(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 LC(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 IC(e){const l={constructs:T1([OC,...(e||{}).extensions||[]]),content:o(Qk),defined:[],document:o(Jk),flow:o(gC),lazy:{},string:o(vC),text:o(jC)};return l;function o(d){return c;function c(h){return RC(l,d,h)}}}function zC(e){for(;!R1(e););return e}const Ub=/[\0\t\n\r]/g;function $C(){let e=1,n="",s=!0,l;return o;function o(d,c,h){const m=[];let f,p,x,g,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(Ub.lastIndex=x,f=Ub.exec(d),g=f&&f.index!==void 0?f.index:d.length,y=d.charCodeAt(g),!f){n=d.slice(x);break}if(y===10&&x===g&&l)m.push(-3),l=void 0;else switch(l&&(m.push(-5),l=void 0),x<g&&(m.push(d.slice(x,g)),e+=g-x),y){case 0:{m.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,m.push(-2);e++<p;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:l=!0,e=1}x=g+1}return h&&(l&&m.push(-5),n&&m.push(n),m.push(null)),m}}const BC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function HC(e){return e.replace(BC,PC)}function PC(e,n,s){if(n)return n;if(s.charCodeAt(0)===35){const o=s.charCodeAt(1),d=o===120||o===88;return _1(s.slice(d?2:1),d?16:10)}return nx(s)||e}const B1={}.hasOwnProperty;function UC(e,n,s){return n&&typeof n=="object"&&(s=n,n=void 0),qC(s)(zC(IC(s).document().write($C()(e,n,!0))))}function qC(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(tt),autolinkProtocol:K,autolinkEmail:K,atxHeading:d(Te),blockQuote:d(fe),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(ze),hardBreakTrailing:d(ze),htmlFlow:d(Xe,c),htmlFlowData:K,htmlText:d(Xe,c),htmlTextData:K,image:d(nt),label:c,link:d(tt),listItem:d(se),listItemValue:g,listOrdered:d(Mt,x),listUnordered:d(Mt),paragraph:d(Ee),reference:I,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(Te),strong:d(rt),thematicBreak:d(Kt)},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(A),codeText:m(L),codeTextData:U,data:U,definition:m(),definitionDestinationString:S,definitionLabelString:O,definitionTitleString:k,emphasis:m(),hardBreakEscape:m(q),hardBreakTrailing:m(q),htmlFlow:m(E),htmlFlowData:U,htmlText:m(T),htmlTextData:U,image:m(P),label:W,labelText:V,lineEnding:G,link:m(_),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 Ue={stack:[De],tokenStack:[],config:n,enter:h,exit:f,buffer:c,resume:p,data:s},Je=[];let pt=-1;for(;++pt<we.length;)if(we[pt][1].type==="listOrdered"||we[pt][1].type==="listUnordered")if(we[pt][0]==="enter")Je.push(pt);else{const Jt=Je.pop();pt=o(we,Jt,pt)}for(pt=-1;++pt<we.length;){const Jt=n[we[pt][0]];B1.call(Jt,we[pt][1].type)&&Jt[we[pt][1].type].call(Object.assign({sliceSerialize:we[pt][2].sliceSerialize},Ue),we[pt][1])}if(Ue.tokenStack.length>0){const Jt=Ue.tokenStack[Ue.tokenStack.length-1];(Jt[1]||qb).call(Ue,void 0,Jt[0])}for(De.position={start:Ea(we.length>0?we[0][1].start:{line:1,column:1,offset:0}),end:Ea(we.length>0?we[we.length-2][1].end:{line:1,column:1,offset:0})},pt=-1;++pt<n.transforms.length;)De=n.transforms[pt](De)||De;return De}function o(we,De,Ue){let Je=De-1,pt=-1,Jt=!1,ln,Ht,Lt,_t;for(;++Je<=Ue;){const St=we[Je];switch(St[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{St[0]==="enter"?pt++:pt--,_t=void 0;break}case"lineEndingBlank":{St[0]==="enter"&&(ln&&!_t&&!pt&&!Lt&&(Lt=Je),_t=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:_t=void 0}if(!pt&&St[0]==="enter"&&St[1].type==="listItemPrefix"||pt===-1&&St[0]==="exit"&&(St[1].type==="listUnordered"||St[1].type==="listOrdered")){if(ln){let en=Je;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",Jt=!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||Je,0,["exit",ln,St[2]]),Je++,Ue++}if(St[1].type==="listItemPrefix"){const en={type:"listItem",_spread:!1,start:Object.assign({},St[1].start),end:void 0};ln=en,we.splice(Je,0,["enter",en,St[2]]),Je++,Ue++,Lt=void 0,_t=!0}}}return we[De][1]._spread=Jt,Ue}function d(we,De){return Ue;function Ue(Je){h.call(this,we(Je),Je),De&&De.call(this,Je)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(we,De,Ue){this.stack[this.stack.length-1].children.push(we),this.stack.push(we),this.tokenStack.push([De,Ue||void 0]),we.position={start:Ea(De.start),end:void 0}}function m(we){return De;function De(Ue){we&&we.call(this,Ue),f.call(this,Ue)}}function f(we,De){const Ue=this.stack.pop(),Je=this.tokenStack.pop();if(Je)Je[0].type!==we.type&&(De?De.call(this,we,Je[0]):(Je[1]||qb).call(this,we,Je[0]));else throw new Error("Cannot close `"+we.type+"` ("+jo({start:we.start,end:we.end})+"): it’s not open");Ue.position.end=Ea(we.end)}function p(){return tx(this.stack.pop())}function x(){this.data.expectingFirstListItemValue=!0}function g(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 A(){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(),Ue=this.stack[this.stack.length-1];Ue.label=De,Ue.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 Ue=this.sliceSerialize(we).length;De.depth=Ue}}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 Ue=this.stack[this.stack.length-1].children;let Je=Ue[Ue.length-1];(!Je||Je.type!=="text")&&(Je=vt(),Je.position={start:Ea(we.start),end:void 0},Ue.push(Je)),this.stack.push(Je)}function U(we){const De=this.stack.pop();De.value+=this.sliceSerialize(we),De.position.end=Ea(we.end)}function G(we){const De=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ue=De.children[De.children.length-1];Ue.position.end=Ea(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 q(){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 _(){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 V(we){const De=this.sliceSerialize(we),Ue=this.stack[this.stack.length-2];Ue.label=HC(De),Ue.identifier=hs(De).toLowerCase()}function W(){const we=this.stack[this.stack.length-1],De=this.resume(),Ue=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ue.type==="link"){const Je=we.children;Ue.children=Je}else Ue.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(),Ue=this.stack[this.stack.length-1];Ue.label=De,Ue.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),Ue=this.data.characterReferenceType;let Je;Ue?(Je=_1(De,Ue==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Je=nx(De);const pt=this.stack[this.stack.length-1];pt.value+=Je}function ee(we){const De=this.stack.pop();De.position.end=Ea(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 fe(){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 Te(){return{type:"heading",depth:0,children:[]}}function ze(){return{type:"break"}}function Xe(){return{type:"html",value:""}}function nt(){return{type:"image",title:null,url:"",alt:null}}function tt(){return{type:"link",title:null,url:"",children:[]}}function Mt(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 Ee(){return{type:"paragraph",children:[]}}function rt(){return{type:"strong",children:[]}}function vt(){return{type:"text",value:""}}function Kt(){return{type:"thematicBreak"}}}function Ea(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):VC(e,l)}}function VC(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 qb(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 FC(e){const n=this;n.parser=s;function s(l){return UC(l,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function YC(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 GC(e,n){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,s),[e.applyData(n,s),{type:"text",value:`
|
|
14
|
+
`}]}function XC(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 KC(e,n){const s={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function ZC(e,n){const s={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function QC(e,n){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(n.identifier).toUpperCase(),o=gi(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 WC(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 JC(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 eE(e,n){const s=String(n.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return P1(e,n);const o={src:gi(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 tE(e,n){const s={src:gi(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 nE(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 rE(e,n){const s=String(n.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return P1(e,n);const o={href:gi(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 sE(e,n){const s={href:gi(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 aE(e,n,s){const l=e.all(n),o=s?lE(s):U1(n),d={},c=[];if(typeof n.checked=="boolean"){const p=l[0];let x;p&&p.type==="element"&&p.tagName==="p"?x=p:(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 p=l[h];(o||h!==0||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
|
|
16
|
+
`}),p.type==="element"&&p.tagName==="p"&&!o?c.push(...p.children):c.push(p)}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 lE(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 iE(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 oE(e,n){const s={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function cE(e,n){const s={type:"root",children:e.wrap(e.all(n))};return e.patch(n,s),e.applyData(n,s)}function dE(e,n){const s={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function uE(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=Qm(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 fE(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],g={},y=c?c[m]:void 0;y&&(g.align=y);let w={type:"element",tagName:d,properties:g,children:[]};x&&(w.children=e.all(x),e.patch(x,w),w=e.applyData(x,w)),f.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(n,p),e.applyData(n,p)}function hE(e,n){const s={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}const Vb=9,Fb=32;function mE(e){const n=String(e),s=/\r?\n|\r/g;let l=s.exec(n),o=0;const d=[];for(;l;)d.push(Yb(n.slice(o,l.index),o>0,!0),l[0]),o=l.index+l[0].length,l=s.exec(n);return d.push(Yb(n.slice(o),o>0,!1)),d.join("")}function Yb(e,n,s){let l=0,o=e.length;if(n){let d=e.codePointAt(l);for(;d===Vb||d===Fb;)l++,d=e.codePointAt(l)}if(s){let d=e.codePointAt(o-1);for(;d===Vb||d===Fb;)o--,d=e.codePointAt(o-1)}return o>l?e.slice(l,o):""}function xE(e,n){const s={type:"text",value:mE(String(n.value))};return e.patch(n,s),e.applyData(n,s)}function pE(e,n){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,s),e.applyData(n,s)}const gE={blockquote:YC,break:GC,code:XC,delete:KC,emphasis:ZC,footnoteReference:QC,heading:WC,html:JC,imageReference:eE,image:tE,inlineCode:nE,linkReference:rE,link:sE,listItem:aE,list:iE,paragraph:oE,root:cE,strong:dE,table:uE,tableCell:hE,tableRow:fE,text:xE,thematicBreak:pE,toml:ad,yaml:ad,definition:ad,footnoteDefinition:ad};function ad(){}const q1=-1,Zd=0,No=1,Ed=2,sx=3,ax=4,lx=5,ix=6,V1=7,F1=8,Gb=typeof self=="object"?self:globalThis,bE=(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 Zd: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 sx:return s(new Date(c),o);case ax:{const{source:h,flags:m}=c;return s(new RegExp(h,m),o)}case lx:{const h=s(new Map,o);for(const[m,f]of c)h.set(l(m),l(f));return h}case ix:{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 Gb[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 Gb[d](c),o)};return l},Xb=e=>bE(new Map,e)(0),Gl="",{toString:yE}={},{keys:vE}=Object,uo=e=>{const n=typeof e;if(n!=="object"||!e)return[Zd,n];const s=yE.call(e).slice(8,-1);switch(s){case"Array":return[No,Gl];case"Object":return[Ed,Gl];case"Date":return[sx,Gl];case"RegExp":return[ax,Gl];case"Map":return[lx,Gl];case"Set":return[ix,Gl];case"DataView":return[No,s]}return s.includes("Array")?[No,s]:s.includes("Error")?[V1,s]:[Ed,s]},ld=([e,n])=>e===Zd&&(n==="function"||n==="symbol"),jE=(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 Zd:{let p=c;switch(m){case"bigint":h=F1,p=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);p=null;break;case"undefined":return o([q1],c)}return o([h,p],c)}case No:{if(m){let g=c;return m==="DataView"?g=new Uint8Array(c.buffer):m==="ArrayBuffer"&&(g=new Uint8Array(c)),o([m,[...g]],c)}const p=[],x=o([h,p],c);for(const g of c)p.push(d(g));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 p=[],x=o([h,p],c);for(const g of vE(c))(e||!ld(uo(c[g])))&&p.push([d(g),d(c[g])]);return x}case sx:return o([h,c.toISOString()],c);case ax:{const{source:p,flags:x}=c;return o([h,{source:p,flags:x}],c)}case lx:{const p=[],x=o([h,p],c);for(const[g,y]of c)(e||!(ld(uo(g))||ld(uo(y))))&&p.push([d(g),d(y)]);return x}case ix:{const p=[],x=o([h,p],c);for(const g of c)(e||!ld(uo(g)))&&p.push(d(g));return x}}const{message:f}=c;return o([h,{name:m,message:f}],c)};return d},Kb=(e,{json:n,lossy:s}={})=>{const l=[];return jE(!(n||s),!!n,new Map,l)(e),l},Td=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?Xb(Kb(e,n)):structuredClone(e):(e,n)=>Xb(Kb(e,n));function wE(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 NE(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function kE(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||wE,l=e.options.footnoteBackLabel||NE,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 p=e.all(f),x=String(f.identifier).toUpperCase(),g=gi(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-"+g+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(m,y),className:["data-footnote-backref"]},children:Array.isArray(O)?O:[O]})}const C=p[p.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 p.push(...w);const A={type:"element",tagName:"li",properties:{id:n+"fn-"+g},children:e.wrap(p,!0)};e.patch(f,A),h.push(A)}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 TE;if(typeof e=="function")return Wd(e);if(typeof e=="object")return Array.isArray(e)?SE(e):CE(e);if(typeof e=="string")return EE(e);throw new Error("Expected function, string, or object as test")});function SE(e){const n=[];let s=-1;for(;++s<e.length;)n[s]=Qd(e[s]);return Wd(l);function l(...o){let d=-1;for(;++d<n.length;)if(n[d].apply(this,o))return!0;return!1}}function CE(e){const n=e;return Wd(s);function s(l){const o=l;let d;for(d in e)if(o[d]!==n[d])return!1;return!0}}function EE(e){return Wd(n);function n(s){return s&&s.type===e}}function Wd(e){return n;function n(s,l,o){return!!(_E(s)&&e.call(this,s,typeof l=="number"?l:void 0,o||void 0))}}function TE(){return!0}function _E(e){return e!==null&&typeof e=="object"&&"type"in e}const Y1=[],AE=!0,gm=!1,ME="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,p){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(g,"name",{value:"node ("+(m.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=Y1,w,N,C;if((!n||d(m,f,p[p.length-1]||void 0))&&(y=OE(s(m,p)),y[0]===gm))return y;if("children"in m&&m.children){const A=m;if(A.children&&y[0]!==ME)for(N=(l?A.children.length:-1)+c,C=p.concat(A);N>-1&&N<A.children.length;){const O=A.children[N];if(w=h(O,N,C)(),w[0]===gm)return w;N=typeof w[1]=="number"?w[1]:N+c}}return y}}}function OE(e){return Array.isArray(e)?e:typeof e=="number"?[AE,e]:e==null?Y1:[e]}function ox(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 p=f[f.length-1],x=p?p.children.indexOf(m):void 0;return c(m,x,p)}}const bm={}.hasOwnProperty,RE={};function DE(e,n){const s=n||RE,l=new Map,o=new Map,d=new Map,c={...gE,...s.handlers},h={all:f,applyData:IE,definitionById:l,footnoteById:o,footnoteCounts:d,footnoteOrder:[],handlers:c,one:m,options:s,patch:LE,wrap:$E};return ox(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const x=p.type==="definition"?l:o,g=String(p.identifier).toUpperCase();x.has(g)||x.set(g,p)}}),h;function m(p,x){const g=p.type,y=h.handlers[g];if(bm.call(h.handlers,g)&&y)return y(h,p,x);if(h.options.passThrough&&h.options.passThrough.includes(g)){if("children"in p){const{children:N,...C}=p,A=Td(C);return A.children=h.all(p),A}return Td(p)}return(h.options.unknownHandler||zE)(h,p,x)}function f(p){const x=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const w=h.one(g[y],p);if(w){if(y&&g[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Zb(w.value)),!Array.isArray(w)&&w.type==="element")){const N=w.children[0];N&&N.type==="text"&&(N.value=Zb(N.value))}Array.isArray(w)?x.push(...w):x.push(w)}}}return x}}function LE(e,n){e.position&&(n.position=Nk(e))}function IE(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 zE(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 $E(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 Zb(e){let n=0,s=e.charCodeAt(n);for(;s===9||s===32;)n++,s=e.charCodeAt(n);return e.slice(n)}function Qb(e,n){const s=DE(e,n),l=s.one(e,void 0),o=kE(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 BE(e,n){return e&&"run"in e?async function(s,l){const o=Qb(s,{file:l,...n});await e.run(o,l)}:function(s,l){return Qb(s,{file:l,...e||n})}}function Wb(e){if(e)throw e}var Nh,Jb;function HE(){if(Jb)return Nh;Jb=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 p=e.call(f,"constructor"),x=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!x)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},c=function(f,p){s&&p.name==="__proto__"?s(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},h=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(l)return l(f,p).value}else return;return f[p]};return Nh=function m(){var f,p,x,g,y,w,N=arguments[0],C=1,A=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<A;++C)if(f=arguments[C],f!=null)for(p in f)x=h(N,p),g=h(f,p),N!==g&&(O&&g&&(d(g)||(y=o(g)))?(y?(y=!1,w=x&&o(x)?x:[]):w=x&&d(x)?x:{},c(N,{name:p,newValue:m(O,w,g)})):typeof g<"u"&&c(N,{name:p,newValue:g}));return N},Nh}var PE=HE();const kh=Gd(PE);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 UE(){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 p=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,p?qE(p,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 qE(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 p=f;if(h&&s)throw p;return o(p)}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 Ss={basename:VE,dirname:FE,extname:YE,join:GE,sep:"/"};function VE(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 FE(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 YE(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 GE(...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?".":XE(s)}function XE(e){Vo(e);const n=e.codePointAt(0)===47;let s=KE(e,!n);return s.length===0&&!n&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),n?"/"+s:s}function KE(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 ZE={cwd:QE};function QE(){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 WE(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 JE(e)}function JE(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 Sh=["history","path","basename","stem","extname","dirname"];class X1{constructor(n){let s;n?vm(n)?s={path:n}:typeof n=="string"||e3(n)?s={value:n}:s=n:s={},this.cwd="cwd"in s?"":ZE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Sh.length;){const d=Sh[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)Sh.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?Ss.basename(this.path):void 0}set basename(n){Eh(n,"basename"),Ch(n,"basename"),this.path=Ss.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Ss.dirname(this.path):void 0}set dirname(n){ey(this.basename,"dirname"),this.path=Ss.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Ss.extname(this.path):void 0}set extname(n){if(Ch(n,"extname"),ey(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=Ss.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){vm(n)&&(n=WE(n)),Eh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Ss.basename(this.path,this.extname):void 0}set stem(n){Eh(n,"stem"),Ch(n,"stem"),this.path=Ss.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 fr(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 Ch(e,n){if(e&&e.includes(Ss.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Ss.sep+"`")}function Eh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function ey(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function e3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const t3=(function(e){const l=this.constructor.prototype,o=l[e],d=function(){return o.apply(d,arguments)};return Object.setPrototypeOf(d,l),d}),n3={}.hasOwnProperty;class cx extends t3{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=UE()}copy(){const n=new cx;let s=-1;for(;++s<this.attachers.length;){const l=this.attachers[s];n.use(...l)}return n.data(kh(!0,{},this.namespace)),n}data(n,s){return typeof n=="string"?arguments.length===2?(Ah("data",this.frozen),this.namespace[n]=s,this):n3.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Ah("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 Th("parse",l),l(String(s),s)}process(n,s){const l=this;return this.freeze(),Th("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(p,x,g){if(p||!x||!g)return f(p);const y=x,w=l.stringify(y,g);a3(w)?g.value=w:g.result=w,f(p,g)});function f(p,x){p||!x?c(p):d?d(x):s(void 0,x)}}}processSync(n){let s=!1,l;return this.freeze(),Th("processSync",this.parser||this.Parser),_h("processSync",this.compiler||this.Compiler),this.process(n,o),ny("processSync","process",s),l;function o(d,c){s=!0,Wb(d),l=c}}run(n,s,l){ty(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(p,x,g){const y=x||n;p?h(p):c?c(y):l(void 0,y,g)}}}runSync(n,s){let l=!1,o;return this.run(n,s,d),ny("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),ty(n),o(n,l)}use(n,...s){const l=this.attachers,o=this.namespace;if(Ah("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[p,...x]=f;m(p,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=kh(!0,o.settings,f.settings))}function h(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const x=f[p];d(x)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,p){let x=-1,g=-1;for(;++x<l.length;)if(l[x][0]===f){g=x;break}if(g===-1)l.push([f,...p]);else if(p.length>0){let[y,...w]=p;const N=l[g][1];ym(N)&&ym(y)&&(y=kh(!0,N,y)),l[g]=[f,y,...w]}}}}const r3=new cx().freeze();function Th(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 Ah(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 ty(e){if(!ym(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ny(e,n,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function id(e){return s3(e)?e:new X1(e)}function s3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function a3(e){return typeof e=="string"||l3(e)}function l3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const i3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",ry=[],sy={allowDangerousHtml:!0},o3=/^(https?|ircs?|mailto|xmpp)$/i,c3=[{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 ay(e){const n=d3(e),s=u3(e);return f3(n.runSync(n.parse(s),s),e)}function d3(e){const n=e.rehypePlugins||ry,s=e.remarkPlugins||ry,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sy}:sy;return r3().use(FC).use(s).use(BE,l).use(n)}function u3(e){const n=e.children||"",s=new X1;return typeof n=="string"&&(s.value=n),s}function f3(e,n){const s=n.allowedElements,l=n.allowElement,o=n.components,d=n.disallowedElements,c=n.skipHtml,h=n.unwrapDisallowed,m=n.urlTransform||h3;for(const p of c3)Object.hasOwn(n,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+i3+p.id,void 0);return ox(e,f),Tk(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(p,x,g){if(p.type==="raw"&&g&&typeof x=="number")return c?g.children.splice(x,1):g.children[x]={type:"text",value:p.value},x;if(p.type==="element"){let y;for(y in vh)if(Object.hasOwn(vh,y)&&Object.hasOwn(p.properties,y)){const w=p.properties[y],N=vh[y];(N===null||N.includes(p.tagName))&&(p.properties[y]=m(String(w||""),y,p))}}if(p.type==="element"){let y=s?!s.includes(p.tagName):d?d.includes(p.tagName):!1;if(!y&&l&&typeof x=="number"&&(y=!l(p,x,g)),y&&g&&typeof x=="number")return h&&p.children?g.children.splice(x,1,...p.children):g.children.splice(x,1),x}}}function h3(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||o3.test(e.slice(0,n))?e:""}function ly(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 m3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function x3(e,n,s){const o=Qd((s||{}).ignore||[]),d=p3(n);let c=-1;for(;++c<d.length;)G1(e,"text",h);function h(f,p){let x=-1,g;for(;++x<p.length;){const y=p[x],w=g?g.children:void 0;if(o(y,w?w.indexOf(y):void 0,g))return;g=y}if(g)return m(f,p)}function m(f,p){const x=p[p.length-1],g=d[c][0],y=d[c][1];let w=0;const C=x.children.indexOf(f);let A=!1,O=[];g.lastIndex=0;let k=g.exec(f.value);for(;k;){const S=k.index,R={index:k.index,input:k.input,stack:[...p,f]};let D=y(...k,R);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?g.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,A=!0),!g.global)break;k=g.exec(f.value)}return A?(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 p3(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([g3(o[0]),b3(o[1])])}return n}function g3(e){return typeof e=="string"?new RegExp(m3(e),"g"):e}function b3(e){return typeof e=="function"?e:function(){return e}}const Mh="phrasing",Oh=["autolink","link","image","label"];function y3(){return{transforms:[C3],enter:{literalAutolink:j3,literalAutolinkEmail:Rh,literalAutolinkHttp:Rh,literalAutolinkWww:Rh},exit:{literalAutolink:S3,literalAutolinkEmail:k3,literalAutolinkHttp:w3,literalAutolinkWww:N3}}}function v3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Mh,notInConstruct:Oh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Mh,notInConstruct:Oh},{character:":",before:"[ps]",after:"\\/",inConstruct:Mh,notInConstruct:Oh}]}}function j3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Rh(e){this.config.enter.autolinkProtocol.call(this,e)}function w3(e){this.config.exit.autolinkProtocol.call(this,e)}function N3(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 k3(e){this.config.exit.autolinkEmail.call(this,e)}function S3(e){this.exit(e)}function C3(e){x3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,E3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),T3]],{ignore:["link","linkReference"]})}function E3(e,n,s,l,o){let d="";if(!K1(o)||(/^w/i.test(n)&&(s=n+s,n="",d="http://"),!_3(s)))return!1;const c=A3(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 T3(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 _3(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 A3(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=ly(e,"(");let d=ly(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)||Xd(s))&&(!n||s!==47)}Z1.peek=B3;function M3(){this.buffer()}function O3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function R3(){this.buffer()}function D3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function L3(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 I3(e){this.exit(e)}function z3(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 $3(e){this.exit(e)}function B3(){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 H3(){return{enter:{gfmFootnoteCallString:M3,gfmFootnoteCall:O3,gfmFootnoteDefinitionLabelString:R3,gfmFootnoteDefinition:D3},exit:{gfmFootnoteCallString:L3,gfmFootnoteCall:I3,gfmFootnoteDefinitionLabelString:z3,gfmFootnoteDefinition:$3}}}function P3(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"),p=d.enter("label");return m+=h.move(d.safe(d.associationId(l),{before:m,after:"]"})),p(),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?Q1:U3))),f(),m}}function U3(e,n,s){return n===0?e:Q1(e,n,s)}function Q1(e,n,s){return(s?"":" ")+e}const q3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];W1.peek=X3;function V3(){return{canContainEols:["delete"],enter:{strikethrough:Y3},exit:{strikethrough:G3}}}function F3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:q3}],handlers:{delete:W1}}}function Y3(e){this.enter({type:"delete",children:[]},e)}function G3(e){this.exit(e)}function W1(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 X3(){return"~"}function K3(e){return e.length}function Z3(e,n){const s=n||{},l=(s.align||[]).concat(),o=s.stringLength||K3,d=[],c=[],h=[],m=[];let f=0,p=-1;for(;++p<e.length;){const N=[],C=[];let A=-1;for(e[p].length>f&&(f=e[p].length);++A<e[p].length;){const O=Q3(e[p][A]);if(s.alignDelimiters!==!1){const k=o(O);C[A]=k,(m[A]===void 0||k>m[A])&&(m[A]=k)}N.push(O)}c[p]=N,h[p]=C}let x=-1;if(typeof l=="object"&&"length"in l)for(;++x<f;)d[x]=iy(l[x]);else{const N=iy(l);for(;++x<f;)d[x]=N}x=-1;const g=[],y=[];for(;++x<f;){const N=d[x];let C="",A="";N===99?(C=":",A=":"):N===108?C=":":N===114&&(A=":");let O=s.alignDelimiters===!1?1:Math.max(1,m[x]-C.length-A.length);const k=C+"-".repeat(O)+A;s.alignDelimiters!==!1&&(O=C.length+O+A.length,O>m[x]&&(m[x]=O),y[x]=O),g[x]=k}c.splice(1,0,g),h.splice(1,0,y),p=-1;const w=[];for(;++p<c.length;){const N=c[p],C=h[p];x=-1;const A=[];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&&A.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&O==="")&&(s.delimiterStart!==!1||x)&&A.push(" "),s.alignDelimiters!==!1&&A.push(k),A.push(O),s.alignDelimiters!==!1&&A.push(S),s.padding!==!1&&A.push(" "),(s.delimiterEnd!==!1||x!==f-1)&&A.push("|")}w.push(s.delimiterEnd===!1?A.join("").replace(/ +$/,""):A.join(""))}return w.join(`
|
|
25
|
+
`)}function Q3(e){return e==null?"":String(e)}function iy(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 W3(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()),J3);return o(),c}function J3(e,n,s){return">"+(s?"":" ")+e}function e4(e,n){return oy(e,n.inConstruct,!0)&&!oy(e,n.notInConstruct,!1)}function oy(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 cy(e,n,s,l){let o=-1;for(;++o<s.unsafe.length;)if(s.unsafe[o].character===`
|
|
26
|
+
`&&e4(s.stack,s.unsafe[o]))return/[ \t]/.test(l.before)?"":" ";return`\\
|
|
27
|
+
`}function t4(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 n4(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 r4(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 s4(e,n,s,l){const o=r4(s),d=e.value||"",c=o==="`"?"GraveAccent":"Tilde";if(n4(e,s)){const x=s.enter("codeIndented"),g=s.indentLines(d,a4);return x(),g}const h=s.createTracker(l),m=o.repeat(Math.max(t4(d,o)+1,3)),f=s.enter("codeFenced");let p=h.move(m);if(e.lang){const x=s.enter(`codeFencedLang${c}`);p+=h.move(s.safe(e.lang,{before:p,after:" ",encode:["`"],...h.current()})),x()}if(e.lang&&e.meta){const x=s.enter(`codeFencedMeta${c}`);p+=h.move(" "),p+=h.move(s.safe(e.meta,{before:p,after:`
|
|
28
|
+
`,encode:["`"],...h.current()})),x()}return p+=h.move(`
|
|
29
|
+
`),d&&(p+=h.move(d+`
|
|
30
|
+
`)),p+=h.move(m),f(),p}function a4(e,n,s){return(s?"":" ")+e}function dx(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 l4(e,n,s,l){const o=dx(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 i4(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 _o(e){return"&#x"+e.toString(16).toUpperCase()+";"}function _d(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=o4;function J1(e,n,s,l){const o=i4(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),p=_d(l.before.charCodeAt(l.before.length-1),f,o);p.inside&&(m=_o(f)+m.slice(1));const x=m.charCodeAt(m.length-1),g=_d(l.after.charCodeAt(0),x,o);g.inside&&(m=m.slice(0,-1)+_o(x));const y=c.move(o);return d(),s.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},h+m+y}function o4(e,n,s){return s.options.emphasis||"*"}function c4(e,n){let s=!1;return ox(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return s=!0,gm}),!!((!e.depth||e.depth<3)&&tx(e)&&(n.options.setext||s))}function d4(e,n,s,l){const o=Math.max(Math.min(6,e.depth||1),1),d=s.createTracker(l);if(c4(e,s)){const p=s.enter("headingSetext"),x=s.enter("phrasing"),g=s.containerPhrasing(e,{...d.current(),before:`
|
|
32
|
+
`,after:`
|
|
33
|
+
`});return x(),p(),g+`
|
|
34
|
+
`+(o===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.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=_o(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,s.options.closeAtx&&(f+=" "+c),m(),h(),f}ej.peek=u4;function ej(e){return e.value||""}function u4(){return"<"}tj.peek=f4;function tj(e,n,s,l){const o=dx(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 f4(){return"!"}nj.peek=h4;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 p=s.stack;s.stack=[],c=s.enter("reference");const x=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=p,d(),o==="full"||!f||f!==x?m+=h.move(x+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function h4(){return"!"}rj.peek=m4;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 m4(){return"`"}function sj(e,n){const s=tx(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=x4;function aj(e,n,s,l){const o=dx(s),d=o==='"'?"Quote":"Apostrophe",c=s.createTracker(l);let h,m;if(sj(e,s)){const p=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=p,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 x4(e,n,s){return sj(e,s)?"<":"["}lj.peek=p4;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 p=s.stack;s.stack=[],c=s.enter("reference");const x=s.safe(s.associationId(e),{before:m,after:"]",...h.current()});return c(),s.stack=p,d(),o==="full"||!f||f!==x?m+=h.move(x+"]"):o==="shortcut"?m=m.slice(0,-1):m+=h.move("]"),m}function p4(){return"["}function ux(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 g4(e){const n=ux(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 b4(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 y4(e,n,s,l){const o=s.enter("list"),d=s.bulletCurrent;let c=e.ordered?b4(s):ux(s);const h=e.ordered?c==="."?")":".":g4(s);let m=n&&s.bulletLastUsed?c===s.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&p&&(!p.children||!p.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&&p){let x=-1;for(;++x<e.children.length;){const g=e.children[x];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.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 v4(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 j4(e,n,s,l){const o=v4(s);let d=s.bulletCurrent||ux(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()),p);return m(),f;function p(x,g,y){return g?(y?"":" ".repeat(c))+x:(y?d:d+" ".repeat(c-d.length))+x}}function w4(e,n,s,l){const o=s.enter("paragraph"),d=s.enter("phrasing"),c=s.containerPhrasing(e,l);return d(),o(),c}const N4=Qd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function k4(e,n,s,l){return(e.children.some(function(c){return N4(c)})?s.containerPhrasing:s.containerFlow).call(s,e,l)}function S4(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=C4;function oj(e,n,s,l){const o=S4(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),p=_d(l.before.charCodeAt(l.before.length-1),f,o);p.inside&&(m=_o(f)+m.slice(1));const x=m.charCodeAt(m.length-1),g=_d(l.after.charCodeAt(0),x,o);g.inside&&(m=m.slice(0,-1)+_o(x));const y=c.move(o+o);return d(),s.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},h+m+y}function C4(e,n,s){return s.options.strong||"*"}function E4(e,n,s,l){return s.safe(e.value,l)}function T4(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 _4(e,n,s){const l=(ij(s)+(s.options.ruleSpaces?" ":"")).repeat(T4(s));return s.options.ruleSpaces?l.slice(0,-1):l}const cj={blockquote:W3,break:cy,code:s4,definition:l4,emphasis:J1,hardBreak:cy,heading:d4,html:ej,image:tj,imageReference:nj,inlineCode:rj,link:aj,linkReference:lj,list:y4,listItem:j4,paragraph:w4,root:k4,strong:oj,text:E4,thematicBreak:_4};function A4(){return{enter:{table:M4,tableData:dy,tableHeader:dy,tableRow:R4},exit:{codeText:D4,table:O4,tableData:Dh,tableHeader:Dh,tableRow:Dh}}}function M4(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 O4(e){this.exit(e),this.data.inTable=void 0}function R4(e){this.enter({type:"tableRow",children:[]},e)}function Dh(e){this.exit(e)}function dy(e){this.enter({type:"tableCell",children:[]},e)}function D4(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,L4));const s=this.stack[this.stack.length-1];s.type,s.value=n,this.exit(e)}function L4(e,n){return n==="|"?n:e}function I4(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:g,table:c,tableCell:m,tableRow:h}};function c(y,w,N,C){return f(p(y,N,C),y.align)}function h(y,w,N,C){const A=x(y,N,C),O=f([A]);return O.slice(0,O.indexOf(`
|
|
38
|
+
`))}function m(y,w,N,C){const A=N.enter("tableCell"),O=N.enter("phrasing"),k=N.containerPhrasing(y,{...C,before:d,after:d});return O(),A(),k}function f(y,w){return Z3(y,{align:w,alignDelimiters:l,padding:s,stringLength:o})}function p(y,w,N){const C=y.children;let A=-1;const O=[],k=w.enter("table");for(;++A<C.length;)O[A]=x(C[A],w,N);return k(),O}function x(y,w,N){const C=y.children;let A=-1;const O=[],k=w.enter("tableRow");for(;++A<C.length;)O[A]=m(C[A],y,w,N);return k(),O}function g(y,w,N){let C=cj.inlineCode(y,w,N);return N.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function z4(){return{exit:{taskListCheckValueChecked:uy,taskListCheckValueUnchecked:uy,paragraph:B4}}}function $4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:H4}}}function uy(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function B4(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 H4(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(p){return p+c}}function P4(){return[y3(),H3(),V3(),A4(),z4()]}function U4(e){return{extensions:[v3(),P3(e),F3(),I4(e),$4()]}}const q4={tokenize:K4,partial:!0},dj={tokenize:Z4,partial:!0},uj={tokenize:Q4,partial:!0},fj={tokenize:W4,partial:!0},V4={tokenize:J4,partial:!0},hj={name:"wwwAutolink",tokenize:G4,previous:xj},mj={name:"protocolAutolink",tokenize:X4,previous:pj},ta={name:"emailAutolink",tokenize:Y4,previous:gj},As={};function F4(){return{text:As}}let tl=48;for(;tl<123;)As[tl]=ta,tl++,tl===58?tl=65:tl===91&&(tl=97);As[43]=ta;As[45]=ta;As[46]=ta;As[95]=ta;As[72]=[ta,mj];As[104]=[ta,mj];As[87]=[ta,hj];As[119]=[ta,hj];function Y4(e,n,s){const l=this;let o,d;return c;function c(x){return!jm(x)||!gj.call(l,l.previous)||fx(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(V4,p,f)(x):x===45||x===95||ur(x)?(d=!0,e.consume(x),m):p(x)}function f(x){return e.consume(x),o=!0,m}function p(x){return d&&o&&gr(l.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(x)):s(x)}}function G4(e,n,s){const l=this;return o;function o(c){return c!==87&&c!==119||!xj.call(l,l.previous)||fx(l.events)?s(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(q4,e.attempt(dj,e.attempt(uj,d),s),s)(c))}function d(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function X4(e,n,s){const l=this;let o="",d=!1;return c;function c(x){return(x===72||x===104)&&pj.call(l,l.previous)&&!fx(l.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(x),e.consume(x),h):s(x)}function h(x){if(gr(x)&&o.length<5)return o+=String.fromCodePoint(x),e.consume(x),h;if(x===58){const g=o.toLowerCase();if(g==="http"||g==="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)||Xd(x)?s(x):e.attempt(dj,e.attempt(uj,p),s)(x)}function p(x){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(x)}}function K4(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 Z4(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&&Xd(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 Q4(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 W4(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 gr(h)?c(h):s(h)}function c(h){return h===59?(e.consume(h),l):gr(h)?(e.consume(h),c):s(h)}}function J4(e,n,s){return l;function l(d){return e.consume(d),o}function o(d){return ur(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 pj(e){return!gr(e)}function gj(e){return!(e===47||jm(e))}function jm(e){return e===43||e===45||e===46||e===95||ur(e)}function fx(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 eT={tokenize:oT,partial:!0};function tT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:aT,continuation:{tokenize:lT},exit:iT}},text:{91:{name:"gfmFootnoteCall",tokenize:sT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:nT,resolveTo:rT}}}}function nT(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 rT(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 sT(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 g=e.exit("gfmFootnoteCallString");return o.includes(hs(l.sliceSerialize(g)))?(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?p:f}function p(x){return x===91||x===92||x===93?(e.consume(x),d++,f):f(x)}}function aT(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",p):s(w)}function p(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"),g}return bn(w)||(h=!0),c++,e.consume(w),w===92?x:p}function x(w){return w===91||w===92||w===93?(e.consume(w),c++,p):p(w)}function g(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 lT(e,n,s){return e.check(qo,n,e.attempt(eT,n,s))}function iT(e){e.exit("gfmFootnoteDefinition")}function oT(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 cT(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 p={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)},g=[["enter",p,h],["enter",c[f][1],h],["exit",c[f][1],h],["enter",x,h]],y=h.parser.constructs.insideSpan.null;y&&Hr(g,g.length,0,Kd(y,c.slice(f+1,m),h)),Hr(g,g.length,0,[["exit",x,h],["enter",c[m][1],h],["exit",c[m][1],h],["exit",p,h]]),Hr(c,f-1,m-f+3,g),m=f+g.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,p=this.events;let x=0;return g;function g(w){return f===126&&p[p.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"),A=li(w);return C._open=!A||A===2&&!!N,C._close=!N||N===2&&!!A,h(w)}}}class dT{constructor(){this.map=[]}add(n,s,l){uT(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 uT(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 fT(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 hT(){return{flow:{null:{name:"table",tokenize:mT,resolveAll:xT}}}}function mT(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 q=G>-1?l.events[G][1].type:null,E=q==="tableHead"||q==="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),p(U)}function p(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,p,"whitespace")(U):(d+=1,c&&(c=!1,o+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),c=!0,p):(e.enter("data"),x(U)))}function x(U){return U===null||U===124||bn(U)?(e.exit("data"),p(U)):(e.consume(U),U===92?g:x)}function g(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"),A):U===45?(d+=1,A(U)):U===null||wt(U)?S(U):R(U)}function A(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 xT(e,n){let s=-1,l=!0,o=0,d=[0,0,0,0],c=[0,0,0,0],h=!1,m=0,f,p,x;const g=new dT;for(;++s<e.length;){const y=e[s],w=y[1];y[0]==="enter"?w.type==="tableHead"?(h=!1,m!==0&&(fy(g,n,m,f,p),p=void 0,m=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.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,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(s,0,[["enter",p,n]])),o=w.type==="tableDelimiterRow"?2:p?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(g,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(g,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(g,n,d,o,s,x)):c[1]!==0&&(x=od(g,n,c,o,s,x)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=s)}for(m!==0&&fy(g,n,m,f,p),g.consume(n.events),s=-1;++s<n.events.length;){const y=n.events[s];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=fT(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({},Wl(n.events,s[0])),e.add(s[0],0,[["exit",d,n]]));const m=Wl(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=Wl(n.events,s[2]),p=Wl(n.events,s[3]),x={type:h,start:Object.assign({},f),end:Object.assign({},p)};if(e.add(s[2],0,[["enter",x,n]]),l!==2){const g=n.events[s[2]],y=n.events[s[3]];if(g[1].end=Object.assign({},y[1].end),g[1].type="chunkText",g[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({},Wl(n.events,o)),e.add(o,0,[["exit",d,n]]),d=void 0),d}function fy(e,n,s,l,o){const d=[],c=Wl(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 Wl(e,n){const s=e[n],l=s[0]==="enter"?"start":"end";return s[1][l]}const pT={name:"tasklistCheck",tokenize:bT};function gT(){return{text:{91:pT}}}function bT(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:yT},n,s)(m):s(m)}}function yT(e,n,s){return Qt(e,l,"whitespace");function l(o){return o===null?s(o):n(o)}}function vT(e){return T1([F4(),tT(),cT(e),hT(),gT()])}const jT={};function hy(e){const n=this,s=e||jT,l=n.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),d=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),c=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(vT(s)),d.push(P4()),c.push(U4(s))}const wT=/<think>([\s\S]*?)<\/think>/g;function NT(e){const n=[],s=e.replace(wT,(l,o)=>{const d=o.trim();return d&&n.push(d),""});return{thinking:n,rest:s.trim()}}const wm="#mention:";function kT(e){return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(n,s,l)=>{const o=s??l;return`[@${o}](${wm}${encodeURIComponent(o)})`})}const Lh={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 Jn({content:e,className:n="",onMentionClick:s}){const{thinking:l,rest:o}=NT(e),d=v.useMemo(()=>s?kT(o):o,[o,s]),c=v.useMemo(()=>s?{...Lh,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:p=>{p.preventDefault(),p.stopPropagation(),s(f,p)},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})}}:Lh,[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(ay,{remarkPlugins:[hy],components:Lh,children:h})})})]})})(),t.jsx(ay,{remarkPlugins:[hy],components:c,children:d})]})}const my={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 my[n]??my[e]??{label:n.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function hx(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function ST(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 xy(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function CT(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 ET(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 Ad(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=ST(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 TT(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 _T(){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 py({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 AT({activities:e,isActive:n,persistent:s}){const l=TT(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,p=f&&l.every(y=>y.status!=="running"),x=n&&!f,g=n&&f&&p;if(s&&p){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(py,{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(py,{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(_T,{})]}),g&&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(Jn,{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 MT({info:e,onClose:n}){const s=ul(e.tool),l=CT(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:hx(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:xy(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:xy(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"},by={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(()=>pn.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=by[n]??by.loading,h=()=>bt.navigate(pe.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 yy={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},vy={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:""}},OT=["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:g})=>{x||s(yy[g.status]??"pending")}).catch(()=>{x||s("pending")}),()=>{x=!0}},[e.requirementId]),v.useEffect(()=>{const x=OT.map(g=>pn.on(g,y=>{const w=y.payload;w.id===e.requirementId&&w.status&&s(yy[w.status]??"pending")}));return()=>x.forEach(g=>g())},[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",p=vy[n]??vy.loading;return t.jsxs("div",{className:`my-2 rounded-lg border ${p.borderClass} ${p.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:p.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 ${p.badgeClass}`,children:"REQ"}),!f&&n!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${p.textClass}`,children:p.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 RT({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",p=(e.tool==="spawn_subagent"||e.tool==="spawn_subagents")&&e.subagentLogs&&e.subagentLogs.length>0,x=h||p,g=ET(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:hx(e.durationMs)}),p&&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)"]})]}),g&&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:g,children:[t.jsx("span",{className:"text-fg-tertiary select-none",children:"$ "}),Nm(g,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(MT,{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 DT({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(Jn,{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(RT,{info:e.info,showTime:n,time:e.time,isLast:s},e.key);if(e.type==="thinking")return t.jsx(DT,{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(Jn,{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 mx({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(),p=c?new Date(c.createdAt).getTime():Date.now(),x=s?Date.now()-f:p-f,g=new Set(e.filter(k=>k.executionRound!=null).map(k=>k.executionRound)),y=g.size>0?Math.max(...g):void 0,w=o&&g.size>1;let N,C,A=null;if(s)if(n)N="✍",C="Writing response...",A=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&&(A=`$ ${Nm(S,80)}`)}else if(c?.type==="tool_end"){const k=ul(c.content);N=k.icon,C=k.label}else N="💭",C="Thinking...";else if(m>0&&c?.type==="error")N="❌",C="Failed";else{const S=[...e].reverse().find(R=>R.type==="status")?.content??"";S==="completed"||S==="execution_finished"?(N="✅",C="Completed"):(N="●",C=`${h} tool${h!==1?"s":""} executed`)}const O=hx(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(Jn,{content:n,className:"text-xs"})}):A?t.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:A}):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:[g.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 LT(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 xx({entries:e,streamingText:n,isActive:s,onCollapse:l,showRounds:o,embedded:d}){const c=v.useRef(null),[h,m]=v.useState(new Set),f=LT(e),p=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})},g=p?null:e.map(Md).filter(w=>w!==null),y=g?Ad(g):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:[p?f.map(w=>{const N=h.has(w.round),C=Ad(w.entries),A=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:[A," tool",A!==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 px=d1();function IT({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(p=>p.name.toLowerCase().includes(n));return v.useEffect(()=>{const p=s.current;if(!p)return;const x=p.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 g=x.getBoundingClientRect();h({top:g.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:px.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((p,x)=>t.jsxs("button",{"data-selected":x===o,onMouseDown:g=>{g.preventDefault(),l(p)},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:p.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:p.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:p.role})]}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${p.status==="idle"||p.status==="working"?"bg-green-400":"bg-gray-500"}`})]},p.id))]}),document.body)}function zT(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Rd=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function $T(e){const n=[];let s;for(Rd.lastIndex=0;(s=Rd.exec(e))!==null;)n.push(s[1]??s[2]);return n}function jy(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(p=>p.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,p]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(""),[N,C]=v.useState([]),[A,O]=v.useState(0),k=v.useRef(null),S=v.useRef(null),R=e.filter(q=>q.name.toLowerCase().includes(y)),D=async()=>{if(d.trim()){m(!0),p(null),S.current={content:d,mentions:[...N]};try{await n(d,N,l?.id),c(""),C([]),S.current=null,o?.()}catch(q){p(String(q instanceof Error?q.message:q)||"Failed to send comment")}m(!1)}},Y=async()=>{if(!S.current)return;const{content:q,mentions:E}=S.current;m(!0),p(null);try{await n(q,E),c(""),C([]),S.current=null}catch(T){p(String(T instanceof Error?T.message:T)||"Failed to send comment")}m(!1)},z=v.useCallback(q=>{c(E=>{const T=E.lastIndexOf("@"),L=zT(q.name);return T>=0?E.slice(0,T)+L+" ":E+L+" "}),N.includes(q.id)||C(E=>[...E,q.id]),g(!1),w(""),O(0),k.current?.focus()},[N]),K=q=>{c(q),p(null);const E=q.lastIndexOf("@");if(E>=0&&(E===0||q[E-1]===" ")){const L=q.slice(E+1).toLowerCase();if(e.some(P=>P.name.toLowerCase().includes(L))){w(L),g(!0),O(0);return}}g(!1)},U=q=>{if(x&&R.length>0){const E=q.key==="ArrowUp"||q.ctrlKey&&q.key==="p",T=q.key==="ArrowDown"||q.ctrlKey&&q.key==="n",L=q.key==="Enter"||q.key==="Tab",_=q.key==="Escape";if(E){q.preventDefault(),O(P=>(P-1+R.length)%R.length);return}if(T){q.preventDefault(),O(P=>(P+1)%R.length);return}if(L){q.preventDefault();const P=R[A];P&&z(P);return}if(_){q.preventDefault(),g(!1);return}}q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),D())},G=v.useCallback(()=>{setTimeout(()=>g(!1),200)},[]);return t.jsxs("div",{className:"relative",children:[x&&t.jsx(IT,{agents:e,filter:y,anchorRef:k,onSelect:z,selectedIndex:A,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(q=>{const E=e.find(T=>T.id===q);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??q,t.jsx("button",{onClick:()=>C(T=>T.filter(L=>L!==q)),className:"hover:text-red-400",children:"×"})]},q)})}),t.jsx("textarea",{ref:k,value:d,onChange:q=>K(q.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 BT="(max-width: 767px)";let Ih=null;function Cj(){return Ih||(Ih=window.matchMedia(BT)),Ih}function HT(e){const n=Cj();return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function PT(){return Cj().matches}function UT(){return!1}function xs(){return v.useSyncExternalStore(HT,PT,UT)}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(p=>({...p,[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 Jd({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 Ws({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 qT({onClose:e,onCreate:n}){const[s,l]=v.useState(""),[o,d]=v.useState("");return t.jsx(Jd,{onClose:e,title:"Create a New Team",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ws,{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(Ws,{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 VT({teamId:e,teams:n,onClose:s,onAdd:l}){const[o,d]=v.useState(""),[c,h]=v.useState("member"),[m,f]=v.useState(""),[p,x]=v.useState(""),[g,y]=v.useState(""),[w,N]=v.useState(e??""),[C,A]=v.useState(""),O=()=>{if(A(""),!o.trim()){A("Name is required");return}if(p&&p!==g){A("Passwords do not match");return}l(o.trim(),c,m||void 0,p||void 0,w||void 0)};return t.jsx(Jd,{onClose:s,title:"Add Human Team Member",width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ws,{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(Ws,{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(Ws,{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(Ws,{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(Ws,{label:"Password",children:t.jsx("input",{value:p,onChange:k=>x(k.target.value),type:"password",placeholder:"Leave blank for no login access",className:"input"})}),p&&t.jsx("div",{className:"mt-3",children:t.jsx(Ws,{label:"Confirm Password",children:t.jsx("input",{value:g,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 FT({teamId:e,ungrouped:n,onClose:s,onAdd:l}){return t.jsx(Jd,{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-blue-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 YT({onClose:e,onConnected:n}){const[s,l]=v.useState(""),[o,d]=v.useState(""),[c,h]=v.useState(!1),[m,f]=v.useState(null),[p,x]=v.useState(null),g=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 A=await N.json().catch(()=>({}));throw new Error(A.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(Jd,{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 ${p==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:p==="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(Ws,{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:g,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 wy=new Map;function GT(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function XT({authUser:e,agents:n,teams:s,humans:l,tasks:o,externalAgents:d,groupChats:c,chatMode:h,selectedAgent:m,activeChannel:f,activeDmUserId:p,onSelectAgent:x,onSelectChannel:g,onSelectDm:y,onRefreshTeams:w,onRefreshAgents:N,onViewProfile:C,width:A,onResizeStart:O,hidden:k}){const S=xs(),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,q]=v.useState(!1),[E,T]=v.useState(null),[L,_]=v.useState(null),[P,V]=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),fe=(ie,Pe="success")=>{ae({message:ie,type:Pe}),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 Te=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]),[ze,Xe]=v.useState(null),nt=(ie,Pe,Fe,st,ot)=>{Xe({title:ie,message:Pe,onConfirm:Fe,confirmLabel:st,checkboxes:ot})},[tt,Mt]=v.useState(null),[se,Ee]=v.useState(null),rt=v.useRef(null),vt=v.useRef(null),[Kt,we]=v.useState(!1),[De,Ue]=v.useState(null),[Je,pt]=v.useState(""),Jt=v.useCallback(ie=>{if(!ie)return;const Pe=ie.getBoundingClientRect(),Fe=8;Pe.bottom>window.innerHeight&&(ie.style.top=`${Math.max(Fe,window.innerHeight-Pe.height-Fe)}px`),Pe.right>window.innerWidth&&(ie.style.left=`${Math.max(Fe,window.innerWidth-Pe.width-Fe)}px`)},[]),[ln,Ht]=v.useState(wy),Lt=v.useMemo(()=>n.map(ie=>ie.id).sort().join(","),[n]);v.useEffect(()=>{if(!n.length)return;let ie=!1;const Pe=async()=>{const st=[];if(await Promise.allSettled(n.map(async ot=>{try{const{sessions:Ct}=await re.sessions.listByAgent(ot.id,1);if(!Ct.length)return;const{messages:dt}=await re.sessions.getMessages(Ct[0].id,1);if(dt.length){const Qe=dt[0],at=Qe.metadata?.segments;let fn=Qe.content;if(at&&at.length>0){const Ke=[...at].reverse().find(xt=>xt.type==="text");Ke&&Ke.type==="text"&&(fn=Ke.content)}const xe=fn.replace(/<think>[\s\S]*?<\/think>/g,"").replace(/\n+/g," ").trim().slice(0,80);xe&&st.push([ot.id,xe])}}catch{}})),!ie){const ot=new Map(st);wy=ot,Ht(ot)}};Pe();const Fe=setInterval(Pe,3e4);return()=>{ie=!0,clearInterval(Fe)}},[Lt]);const _t=v.useCallback(()=>{re.teams.list().then(ie=>z(ie.ungrouped)).catch(()=>{})},[]);v.useEffect(()=>{_t()},[_t]),v.useEffect(()=>pn.on("*",_t),[_t]),v.useEffect(()=>{if(!W&&!F&&!H)return;const ie=Pe=>{B(null),X(null),Z(!1)};return setTimeout(()=>document.addEventListener("click",ie),0),()=>document.removeEventListener("click",ie)},[W,F,H]);const St=(ie,Pe)=>{nt(`Delete "${Pe}"?`,"This team will be removed from the database. Check options below to also delete members and disk files.",async Fe=>{const st=Fe?.deleteMembers??!0,ot=Fe?.purgeFiles??!1;await re.teams.delete(ie,st,{purgeFiles:ot}),w(),_t(),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,Pe)=>{try{const st=await(Pe==="start"?re.teams.startAll:Pe==="stop"?re.teams.stopAll:Pe==="pause"?re.teams.pauseAll:re.teams.resumeAll)(ie),ot=st.success?.length??0,Ct=st.failed?.length??0,dt={start:"started",stop:"stopped",pause:"paused",resume:"resumed"};Ct>0?fe(`${Pe}: ${ot} succeeded, ${Ct} failed`,"error"):ot>0&&fe(`${ot} agent${ot>1?"s":""} ${dt[Pe]}`,"success"),N()}catch(Fe){fe(`Failed to ${Pe}: ${Fe instanceof Error?Fe.message:String(Fe)}`,"error")}},tn=async(ie,Pe,Fe)=>{await re.teams.update(ie,{managerId:Pe,managerType:Fe}),w()},ve=async ie=>{if(!Je.trim()){Ue(null);return}await re.teams.update(ie,{name:Je.trim()}),Ue(null),w()},qe=async(ie,Pe)=>{Pe==="offline"?await re.agents.start(ie):await re.agents.stop(ie),N()},Rt=(ie,Pe)=>{nt("Remove from team?","This member will be moved to Ungrouped.",async()=>{await re.teams.removeMember(ie,Pe),w(),_t()},"Remove")},zt=(ie,Pe,Fe)=>{nt(`Remove "${Pe}"?`,"This agent will be removed from the database. Check the option below to also delete its workspace, memory, and other files from disk.",async st=>{{const ot=st?.purgeFiles??!1;await re.agents.remove(ie,{purgeFiles:ot})}N(),w(),_t(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Remove",[{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},Ve=(ie,Pe,Fe)=>{vt.current={x:ie.clientX,y:ie.clientY},rt.current=setTimeout(()=>{Mt({agentId:Pe,fromTeamId:Fe}),we(!0)},200)},Pt=ie=>{if(!vt.current||!rt.current)return;const Pe=Math.abs(ie.clientX-vt.current.x),Fe=Math.abs(ie.clientY-vt.current.y);(Pe>5||Fe>5)&&(Kt||(clearTimeout(rt.current),rt.current=null))},yn=async()=>{if(rt.current&&(clearTimeout(rt.current),rt.current=null),vt.current=null,Kt&&tt&&se){const ie=se==="_ungrouped"?void 0:se;try{if(tt.fromTeamId&&tt.fromTeamId!==ie&&await re.teams.removeMember(tt.fromTeamId,tt.agentId),ie&&ie!==tt.fromTeamId){const Pe=n.find(Fe=>Fe.id===tt.agentId);await re.teams.addMember(ie,tt.agentId,"agent")}w(),N(),_t()}catch(Pe){fe(`Move failed: ${Pe instanceof Error?Pe.message:String(Pe)}`,"error")}}Mt(null),Ee(null),we(!1)},nn=v.useMemo(()=>new Map(s.map(ie=>[ie.id,ie])),[s]),un=v.useMemo(()=>{const ie=new Map,Pe=[];for(const Fe of n)if(Fe.teamId&&nn.has(Fe.teamId)){const st=ie.get(Fe.teamId)??[];st.push(Fe),ie.set(Fe.teamId,st)}else Pe.push(Fe);return{byTeam:ie,ungrouped:Pe}},[n,nn]);s.filter(ie=>un.byTeam.has(ie.id)||ie.members?.length>0).map(ie=>ie.id);const vn=ie=>U(Pe=>{const Fe=new Set(Pe);return Fe.has(ie)?Fe.delete(ie):Fe.add(ie),Fe}),Dt=(ie,Pe)=>{const Fe=h==="direct"&&m===ie.id,st=D.has(ie.id),ot=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=(Pe?nn.get(Pe):void 0)?.managerId===ie.id,Qe=ie.role?.toLowerCase().replace(/[-_]/g," ").trim(),at=ie.name.toLowerCase().trim(),fn=Qe&&Qe!==at,xe=ln.get(ie.id)||ie.currentActivity?.label?.slice(0,60)||"",Ke=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 ${Kt&&tt?.agentId===ie.id?"opacity-40":""}`,onPointerDown:xt=>Ve(xt,ie.id,Pe),onPointerMove:Pt,onPointerUp:yn,children:t.jsxs("button",{onClick:()=>{Kt||x(ie.id)},onContextMenu:xt=>{R&&(xt.preventDefault(),X({agentId:ie.id,teamId:Pe,x:xt.clientX,y:xt.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"} ${Fe?"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 ${Fe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:GT(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}),fn&&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"})}),st&&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:xe||" "})]}),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:Ke,onClick:xt=>{xt.stopPropagation(),C(ie.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${ot}`})]})]})},ie.id)},jn=(ie,Pe,Fe,st)=>{const ot=K.has(ie),Ct=Kt&&se===ie&&tt?.fromTeamId!==ie,dt=ie!=="_ungrouped"?(Et.byTeam.get(ie)??[])[0]:void 0,Qe=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:()=>{Kt&&Ee(ie)},onPointerLeave:()=>{Kt&&se===ie&&Ee(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{dt?g(dt.channelKey):vn(ie)},onContextMenu:at=>{!R||!Pe||(at.preventDefault(),B({teamId:ie,x:at.clientX,y:at.clientY}))},className:`flex-1 flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors min-w-0 ${Qe?"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 ${Qe?"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:Je,onChange:at=>pt(at.target.value),onBlur:()=>ve(ie),onKeyDown:at=>{at.key==="Enter"&&ve(ie),at.key==="Escape"&&Ue(null)},onClick:at=>at.stopPropagation(),autoFocus:!0}):t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:st}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:[Fe.length," members"]})]})]}),t.jsx("button",{onClick:()=>vn(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:ot?"Expand":"Collapse",children:t.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${ot?"":"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&&Pe&&t.jsx("button",{onClick:at=>{at.stopPropagation(),B({teamId:ie,x:at.clientX,y:at.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&&Kt&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:"Drop here"}),!ot&&t.jsx("div",{className:"ml-1",children:Fe.map(at=>Dt(at,ie==="_ungrouped"?void 0:ie))})]},ie)},Et=v.useMemo(()=>{const ie=new Map,Pe=[];for(const Fe of c)if(Fe.teamId){const st=ie.get(Fe.teamId)??[];st.push(Fe),ie.set(Fe.teamId,st)}else{const st=s.find(ot=>Fe.name.toLowerCase().includes(ot.name.toLowerCase())||ot.name.toLowerCase().includes(Fe.name.toLowerCase()));if(st){const ot=ie.get(st.id)??[];ot.push(Fe),ie.set(st.id,ot)}else Pe.push(Fe)}return{byTeam:ie,unmatched:Pe}},[c,s]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`bg-surface-secondary/60 border-r border-border-default flex flex-col ${A!=null?"shrink-0":"flex-1 min-w-0"}`,style:k?{display:"none"}:A!=null?{width:A}: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:Te,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),q(!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),bt.navigate(pe.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),V(!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"}),Et.unmatched.map(ie=>t.jsxs("button",{onClick:()=>g(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 Pe=un.byTeam.get(ie.id)??[];return Pe.length===0&&(!ie.members||ie.members.length===0)?null:jn(ie.id,ie,Pe,ie.name)}),s.filter(ie=>(un.byTeam.get(ie.id)??[]).length===0&&ie.members&&ie.members.length>0).map(ie=>jn(ie.id,ie,[],ie.name)),un.ungrouped.length>0&&jn("_ungrouped",null,un.ungrouped,"Other"),s.length===0&&n.length>0&&n.map(ie=>Dt(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"&&(p===e.id||!p)?"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"&&(p===e.id||!p)?"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"&&p===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"&&p===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=un.byTeam.get(W.teamId)??[],Pe=ie.some(Ct=>Ct.status==="offline"),Fe=ie.some(Ct=>Ct.status==="idle"||Ct.status==="working"),st=ie.some(Ct=>Ct.status==="paused"),ot=ie.some(Ct=>Ct.status!=="offline");return t.jsxs("div",{ref:Jt,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=nn.get(W.teamId);Ct&&(Ue(W.teamId),pt(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"]}),Pe&&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"]}),ot&&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"]}),Fe&&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"]}),st&&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),bt.navigate(pe.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),_(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=nn.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(ot=>ot.id===F.agentId);if(!ie)return null;const Fe=(F.teamId?nn.get(F.teamId):void 0)?.managerId===ie.id,st=ie.id===e?.id;return t.jsxs("div",{ref:Jt,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:ot=>ot.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:()=>{qe(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:()=>{qe(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&&!Fe&&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(ot=>ot.id!==F.teamId).map(ot=>t.jsx("button",{onClick:async()=>{F.teamId&&await re.teams.removeMember(F.teamId,ie.id),await re.teams.addMember(ot.id,ie.id,"agent"),w(),N(),_t(),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:ot.name},ot.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!st&&t.jsxs("button",{onClick:()=>{zt(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(qT,{onClose:()=>q(!1),onCreate:async(ie,Pe)=>{await re.teams.create(ie,Pe),q(!1),w()}}),E!==null&&t.jsx(VT,{teamId:E.teamId,teams:s,onClose:()=>T(null),onAdd:async(ie,Pe,Fe,st,ot)=>{await re.users.create(ie,Pe,void 0,Fe,st,ot),T(null),w()}}),L!==null&&t.jsx(FT,{teamId:L,ungrouped:Y,onClose:()=>_(null),onAdd:async(ie,Pe)=>{await re.teams.addMember(L,ie,Pe),_(null),w(),_t()}}),P&&t.jsx(YT,{onClose:()=>V(!1),onConnected:()=>{V(!1),N(),w()}}),ze&&t.jsx(Ej,{title:ze.title,message:ze.message,confirmLabel:ze.confirmLabel,checkboxes:ze.checkboxes,onConfirm:ie=>{ze.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 KT=[{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:"♡"}],ZT={idle:"bg-green-400",working:"bg-blue-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 QT({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),p=v.useCallback(()=>{re.agents.get(e).then(d).catch(()=>{})},[e]);if(v.useEffect(()=>(h(l??"overview"),f(null),p(),re.externalAgents.list().then(y=>{const w=y.agents.find(N=>N.markusAgentId===e);f(w??null)}).catch(()=>{}),pn.on("agent:update",y=>{y.payload.agentId===e&&p()})),[e,p]),!o)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading agent..."});const x=ZT[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:()=>bt.navigate(pe.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:g}=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 Gn.publishViaProxy({itemType:"agent",name:o.name,description:y.description,category:"general",config:y,files:g}),alert(`Published "${o.name}" to Markus Hub`)}catch(g){alert(`Failed to publish: ${g}`)}},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:KT.filter(g=>!m||["overview","mind"].includes(g.key)).map(g=>t.jsxs("button",{onClick:()=>h(g.key),className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${c===g.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:g.icon}),g.label]},g.key))})]}),t.jsxs("div",{className:"p-5",children:[c==="overview"&&t.jsx(WT,{agent:o,onUpdate:p,externalInfo:m}),c==="mind"&&t.jsx(d_,{agentId:e}),c==="files"&&t.jsx(JT,{agentId:e}),c==="tools"&&t.jsx(n_,{tools:o.tools??[]}),c==="skills"&&t.jsx(r_,{agent:o}),c==="memory"&&t.jsx(s_,{agentId:e}),c==="heartbeat"&&t.jsx(a_,{agentId:e,initialData:o.heartbeat})]})]})}function WT({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,p]=v.useState(e.config?.llmConfig?.modelMode??"default"),[x,g]=v.useState(e.config?.llmConfig.primary??""),[y,w]=v.useState(e.config?.llmConfig.fallback??""),[N,C]=v.useState(!1),[A,O]=v.useState({}),[k,S]=v.useState(""),[R,D]=v.useState([]),[Y,z]=v.useState(null),[K,U]=v.useState(null),[G,q]=v.useState([]),[E,T]=v.useState(null),[L,_]=v.useState(null),[P,V]=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=>q(M.activities)).catch(()=>{}),re.system.storage().then(M=>{V(M.dataDir+"/agents/"+e.id);const H=M.agents.find(Z=>Z.id===e.id);H&&_(H)}).catch(()=>{})},[e.id]);const W=Object.entries(A).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(En,{title:"Identity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Hn,{label:"Name",children:e.name}),t.jsx(Hn,{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(Hn,{label:"Role Template",children:e.role}),t.jsx(Hn,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx(Hn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Hn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsx(En,{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(En,{title:"External Agent Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Hn,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx(Hn,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx(Hn,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx(Hn,{label:"Last Heartbeat",children:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleString():"Never"})]})}),t.jsx(En,{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(En,{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(En,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>bt.navigate(pe.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(En,{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),p(e.config?.llmConfig?.modelMode??"default"),g(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(Hn,{label:"Name",children:l?t.jsx("input",{className:"input-sm",value:d,onChange:M=>c(M.target.value)}):e.name}),t.jsx(Hn,{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(Hn,{label:"Role Template",children:e.role}),t.jsx(Hn,{label:"Agent ID",mono:!0,children:e.id}),t.jsx(Hn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Hn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsxs(En,{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"?"blue":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(En,{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(En,{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:Ny(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:Ny(M.size)},M.name))})]}),t.jsx(En,{title:"LLM Configuration",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Hn,{label:"Model Mode",children:l?t.jsx("div",{className:"flex gap-1.5",children:["default","custom"].map(M=>t.jsx("button",{onClick:()=>p(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(Hn,{label:"Primary Model",children:l?f==="custom"?t.jsxs("select",{className:"input-sm",value:x,onChange:M=>g(M.target.value),children:[W.map(M=>t.jsxs("option",{value:M,children:[M," (",A[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(Hn,{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(Hn,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx(Hn,{label:"Max Tokens/Day",children:e.config?.llmConfig.maxTokensPerDay??"unlimited"})]})}),R.length>0&&t.jsx(En,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>bt.navigate(pe.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(En,{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(En,{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 JT({agentId:e}){const[n,s]=v.useState([]),[l,o]=v.useState(!0),[d,c]=v.useState(null),[h,m]=v.useState(""),[f,p]=v.useState(!1),[x,g]=v.useState(!1),[y,w]=v.useState(null),[N,C]=v.useState(!1),[A,O]=v.useState(null),k=v.useCallback(()=>{o(!0),Promise.all([re.agents.getFiles(e),re.agents.roleStatus(e).catch(()=>null)]).then(([q,E])=>{s(q.files),w(E),q.files.length>0&&!d&&(c(q.files[0].name),m(q.files[0].content))}).catch(()=>{}).finally(()=>o(!1))},[e]);v.useEffect(()=>{k()},[k]);const S=q=>{const E=n.find(T=>T.name===q);E&&(c(q),m(E.content),g(!1),O(null))},R=async()=>{if(d){p(!0);try{await re.agents.updateFile(e,d,h),s(q=>q.map(E=>E.name===d?{...E,content:h}:E)),g(!1),d==="ROLE.md"&&await re.agents.updateSystemPrompt(e,h)}catch{}p(!1)}},D=async q=>{C(!0);try{await re.agents.roleSync(e,q?[q]:void 0),O(null),g(!1),k()}catch{}C(!1)},Y=async q=>{if(A?.file===q){O(null);return}try{const E=await re.agents.roleDiff(e,q);E.agentContent!=null&&E.templateContent!=null&&O({file:q,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(q=>q.status==="modified"||q.status==="added_in_template")??[],U=y?.hasTemplate&&!y.isUpToDate,G=d?K.some(q=>q.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(q=>q.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(En,{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(q=>{const E=K.some(T=>T.file===q.name);return t.jsxs("button",{onClick:()=>S(q.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${d===q.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[q.name,E&&t.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},q.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:A?.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"})]})]}),A?.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:A.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:A.template})]})]}),t.jsx("textarea",{value:h,onChange:q=>{m(q.target.value),g(!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 e_={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 t_(e){const n=new Map,s=new Set;for(const[d,c]of Object.entries(e_)){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 n_({tools:e}){const n=t_(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(En,{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 r_({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 p=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 A=await C.json();d(A.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"},g=N=>{const C=n[N.name],A=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:()=>p(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()}`]})]}),A!==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 ${A>=80?"bg-green-400":A>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${A}%`}})}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[A,"%"]})]})]}),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 A=y.indexOf(N[0]),O=y.indexOf(C[0]);return(A===-1?999:A)-(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(En,{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(A=>g(A))})},N)),m.length===0&&t.jsx(ei,{text:"No skills installed"})]})}function s_({agentId:e}){const[n,s]=v.useState(null),[l,o]=v.useState(!0),[d,c]=v.useState("entries"),[h,m]=v.useState(!1),[f,p]=v.useState(""),[x,g]=v.useState(!1),[y,w]=v.useState(""),[N,C]=v.useState(!1),[A,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),p(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),g(!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 q=[{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:q.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(En,{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=A===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(En,{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 _=await re.agents.getMemorySession(e,E.id);D(_.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 _=new Map;for(const P of R)P.role==="tool"&&P.toolCallId&&_.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,V)=>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(Jn,{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(Jn,{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:_.get(W.id)};return t.jsx(kj,{entry:{type:"tool",info:F}},W.id)})})]})]},V))})})()})]},E.id)})})}),d==="daily"&&t.jsx(En,{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=>p(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(En,{title:"Long-term Memory",action:x?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>g(!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:()=>g(!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 a_({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),[p,x]=v.useState(!1),[g,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(()=>pn.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,A=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(En,{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:p||!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:p?"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?A(s.lastHeartbeat)??"—":"Never"}),t.jsx(Qn,{label:"Next Run",value:s.nextRunAt?A(s.nextRunAt)??"—":s.running?"Pending":"—"})]}),g&&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:g})]}),s.lastSummary&&t.jsx(En,{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(Jn,{content:s.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),c.length>0?t.jsx(En,{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(En,{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:p,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:p?"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(g=>{l(g.logs),h(!1)}).catch(()=>h(!1))},[e]),v.useEffect(()=>{if(!n)return;const g=pn.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(A=>C.id&&A.some(O=>O.id===C.id)?A:[...A,C]),C.type==="text"&&d("")}),y=pn.on("task:log:delta",w=>{const N=w.payload;N.taskId===e&&d(C=>C+N.text)});return()=>{g(),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 p=s.map(g=>om(g)),x=new Set(p.filter(g=>g.executionRound!=null).map(g=>g.executionRound)).size>1;return t.jsx("div",{className:"px-3 py-2",children:m==="compact"?t.jsx(mx,{entries:p,streamingText:o,isActive:n,onExpand:()=>f("full"),showRounds:x}):t.jsx(xx,{entries:p,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=>K2(f,n,e)).filter(f=>f!==null);return t.jsx("div",{className:"px-3 py-2",children:c==="compact"?t.jsx(mx,{entries:m,isActive:!1,onExpand:()=>h("full")}):t.jsx(xx,{entries:m,isActive:!1,onCollapse:()=>h("compact")})})}function En({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 Hn({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==="blue"?"text-blue-500":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 Ny(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 ky={0:"Critical",1:"High",2:"Normal",3:"Low",4:"Background"},Sy={0:"text-red-400",1:"text-amber-400",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},l_={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"},i_={idle:"bg-green-500/20 text-green-300",focused:"bg-brand-500/20 text-brand-300",deciding:"bg-amber-500/20 text-amber-300"},zh={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:"🧠"},o_=[{key:"all",label:"All"},{key:"interaction",label:"Interaction"},{key:"task",label:"Task"},{key:"notification",label:"Notification"},{key:"system",label:"System"}],c_={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 d_({agentId:e}){const[n,s]=v.useState(null),[l,o]=v.useState(null),[d,c]=v.useState(!0),[h,m]=v.useState("all"),[f,p]=v.useState(null),[x,g]=v.useState(!0),y=50,w=v.useCallback(async(C=!0)=>{C&&c(!0);try{const A=h==="all"?void 0:h,[O,k]=await Promise.all([re.agents.getMindState(e),re.agents.getMailbox(e,{limit:y,category:A})]);s(O),o(k),g((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 A=await re.agents.getMailbox(e,{limit:y,offset:l.history.length,category:C});o(O=>O?{...O,history:[...O.history,...A.history]}:A),g((A.history?.length??0)>=y)}catch{}},[e,l,h]);return v.useEffect(()=>{p(null),w()},[w]),v.useEffect(()=>{const C=pn.on("agent:mailbox",k=>{k.payload.agentId===e&&w(!1)}),A=pn.on("agent:decision",k=>{k.payload.agentId===e&&w(!1)}),O=pn.on("agent:attention",k=>{k.payload.agentId===e&&w(!1)});return()=>{C(),A(),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 ${i_[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:[zh[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,A)=>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:A+1}),t.jsx("span",{className:"text-sm",children:zh[C.sourceType]??"●"}),t.jsx("span",{className:`text-[10px] ${Sy[C.priority]??"text-fg-tertiary"}`,children:ky[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:o_.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 A=f===C.id,O=zh[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:()=>p(A?null:C.id),children:[t.jsx("span",{className:"text-xs mt-0.5 text-fg-tertiary",children:A?"▾":"▸"}),t.jsx("span",{className:`w-2 h-2 mt-1.5 rounded-full shrink-0 ${c_[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 ${A?"":"truncate"}`,children:k}),t.jsx("span",{className:`text-[10px] shrink-0 ${Sy[C.priority]??"text-fg-tertiary"}`,children:ky[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})]}),A&&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 ${l_[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 u_=[{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:"⚙"}],Cy={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function f_({teamId:e,onBack:n,inline:s}){const[l,o]=v.useState(null),[d,c]=v.useState("overview"),[h,m]=v.useState(""),[f,p]=v.useState(""),[x,g]=v.useState(!1),[y,w]=v.useState(!1),[N,C]=v.useState(""),[A,O]=v.useState(""),[k,S]=v.useState(!1),[R,D]=v.useState(!1),[Y,z]=v.useState(""),[K,U]=v.useState(""),[G,q]=v.useState(!1),[E,T]=v.useState([]),L=v.useRef(null),_=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");p(I.content)}catch{p("")}},[e]);v.useEffect(()=>{c("overview"),_(),P()},[e,_,P]);const V=async(I,M)=>{S(!0);try{await re.teams.updateFile(e,I,M),I==="ANNOUNCEMENT.md"?(m(M),g(!1)):(p(M),w(!1))}catch{}S(!1)},W=async()=>{Y.trim()&&(await re.teams.update(e,{name:Y.trim()}),D(!1),_())},B=async()=>{await re.teams.update(e,{description:K}),q(!1),_()};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 Gn.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:u_.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=Cy[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=Cy[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),g(!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:()=>V("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:()=>g(!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:A,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:()=>V("NORMS.md",A),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:()=>q(!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??""),q(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(h_,{teamId:e,teamName:l.name,onDeleted:n})]})]})]})}function h_({teamId:e,teamName:n,onDeleted:s}){const[l,o]=v.useState(!1),[d,c]=v.useState(!1),[h,m]=v.useState(!1),[f,p]=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()=>{p(!0);try{await re.teams.delete(e,h,{purgeFiles:d}),window.dispatchEvent(new CustomEvent("markus:data-changed")),s()}catch{p(!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 eu({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}}),p=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(),p.current=!0;const w=y.clientX,N=c,C=O=>{if(!p.current)return;const k=e==="left"?O.clientX-w:w-O.clientX;h(Math.max(s,Math.min(l,N+k)))},A=()=>{p.current=!1,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",A),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",C),document.addEventListener("mouseup",A),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e,s,l]),g=v.useCallback(()=>f(y=>!y),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:g,setCollapsed:f,onResizeStart:x}}function Ey(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 _j(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function m_({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:_j(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 x_({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:_j(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 Ty(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 _y({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 p_(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 g_({msg:e,isStreaming:n,liveActivities:s,onViewModeChange:l}){const o=e.segments,d=e.isStopped,[c,h]=v.useState("compact"),m=v.useCallback(p=>{h(p),l?.(p)},[l]);if(o!==void 0){const p=o.some(O=>O.type==="tool"),x=p_(o,e.agentId),g=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,A=[];if(c==="compact")for(const O of o){if(O.type!=="tool")continue;const k=bj(O.tool,O.result);if(k){A.push({key:`task-${k.taskId}`,kind:"task",info:k});continue}const S=yj(O.tool,O.result);S&&A.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:[(p||n)&&(c==="compact"?t.jsx(mx,{entries:x,streamingText:g,isActive:n,onExpand:()=>m("full"),embedded:!0}):t.jsx(xx,{entries:x,streamingText:g,isActive:n,onCollapse:()=>m("compact"),embedded:!0})),c==="compact"&&A.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(Jn,{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(AT,{activities:n?s:e.activities??[],isActive:n,persistent:!n&&f}),e.text?t.jsx(Jn,{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 b_(){return window.location.hash}function y_(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=xs(),h=v.useSyncExternalStore(y_,b_),m=c&&(h.startsWith(`#${pe.TEAM}/`)||h.startsWith("#chat/")),f=v.useCallback(()=>{window.location.hash=`${pe.TEAM}/d`},[]);v.useEffect(()=>{if(!c)return;const J=()=>{g.current==="profile"&&x("chat")};return window.addEventListener("popstate",J),()=>window.removeEventListener("popstate",J)},[c]);const[p,x]=v.useState("chat"),g=v.useRef("chat");g.current=p;const y=eu({side:"left",defaultWidth:224,minWidth:160,maxWidth:360,storageKey:"markus_chat_sidebar"}),[w,N]=v.useState(null),[C,A]=v.useState(),O=v.useCallback(J=>{A(J),x("profile"),c&&history.pushState({mobileProfile:!0},"",window.location.hash)},[c]),k=v.useCallback((J,ge)=>{R("direct"),Y(J),O(ge?.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(""),q=v.useRef(new Map),E=v.useRef(new Map),T=v.useRef(new Set),L=v.useRef(""),[_,P]=v.useState([]),[V,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),[fe,Ne]=v.useState([]),Le=v.useRef(null),ye=v.useRef(null),je="__new_chat__",[Te,ze]=v.useState([]),[Xe,nt]=v.useState(null),[tt,Mt]=v.useState(!1),[se,Ee]=v.useState([]),rt=v.useRef(new Map),vt=v.useRef(new Map),Kt=v.useRef(null),we=v.useRef(null),De=v.useRef(null),Ue=v.useRef(null),[Je,pt]=v.useState([]),[Jt,ln]=v.useState([]),[Ht,Lt]=v.useState([]),[_t,St]=v.useState([]),[en,tn]=v.useState(null),[ve,qe]=v.useState(!1),[Rt,zt]=v.useState(""),[Ve,Pt]=v.useState(!1),[yn,nn]=v.useState(""),[un,vn]=v.useState(0),Dt=S==="channel"?Je.find(J=>J.channelKey===z)?.teamId:void 0,jn=v.useRef(null),Et=v.useRef(null),ie=v.useRef(null),Pe=v.useRef(void 0),Fe=v.useRef(!1),st=v.useRef(!0);v.useEffect(()=>{if(!tt)return;const J=ge=>{we.current&&!we.current.contains(ge.target)&&Kt.current&&!Kt.current.contains(ge.target)&&Mt(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[tt]);const ot=(J,ge)=>{if(!ge||J===ge)return`notes:${J}`;const[Ce,Me]=[J,ge].sort();return`dm:${Ce}:${Me}`},Ct=(J,ge,Ce,Me)=>J==="channel"?`ch:${Ce}`:J==="dm"?`dm:${Me??""}`:ge||"_direct",dt=v.useCallback((J,ge)=>{const Ce=ge(q.current.get(J)??[]);q.current.set(J,Ce),L.current===J&&P(Ce)},[]),Qe=(J,ge)=>{const Ce=[...E.current.get(J)??[],ge];E.current.set(J,Ce),L.current===J&&H(Ce)};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 at=v.useCallback(()=>re.agents.list().then(J=>l(J.agents)).catch(()=>{}),[]),fn=v.useCallback(()=>re.teams.list().then(J=>ln(J.teams)).catch(()=>{}),[]);v.useEffect(()=>{at(),re.users.list().then(He=>d(He.users)).catch(()=>{}),re.tasks.list().then(He=>St(He.tasks)).catch(()=>{}),fn(),re.externalAgents.list().then(He=>Lt(He.agents)).catch(()=>{}),fetch("/api/group-chats").then(He=>He.json()).then(He=>pt(He.chats)).catch(()=>{});const J=setInterval(at,8e3),ge=setInterval(fn,15e3),Ce=pn.on("agent:update",at),Me=pn.on("*",fn),Se=pn.on("chat:group_created",()=>{fetch("/api/group-chats").then(He=>He.json()).then(He=>pt(He.chats)).catch(()=>{})}),Ge=()=>{at(),fn()};return window.addEventListener("markus:data-changed",Ge),()=>{clearInterval(J),clearInterval(ge),Ce(),Me(),Se(),window.removeEventListener("markus:data-changed",Ge)}},[]),v.useEffect(()=>{const J=Me=>{const Se=Me.detail;if(La(Se.page)===pe.TEAM){if(Se.params?.agentId){if(Se.params.profileTab)k(Se.params.agentId,{tab:Se.params.profileTab});else if(R("direct"),Y(Se.params.agentId),Se.params.sessionId){const Ge=Se.params.sessionId;setTimeout(async()=>{try{const{sessions:He}=await re.sessions.listByAgent(Se.params.agentId,20),Nt=He.find(ht=>ht.id===Ge);Nt&&$e(Nt)}catch{}},300)}}Se.params?.selectAgent&&k(Se.params.selectAgent),Se.params?.openHire}},ge=localStorage.getItem("markus_nav_agentId");if(ge){localStorage.removeItem("markus_nav_agentId");const Me=localStorage.getItem("markus_nav_profileTab");Me?(localStorage.removeItem("markus_nav_profileTab"),k(ge,{tab:Me})):(R("direct"),Y(ge))}const Ce=localStorage.getItem("markus_nav_selectAgent");return Ce&&(localStorage.removeItem("markus_nav_selectAgent"),k(Ce)),window.addEventListener("markus:navigate",J),()=>window.removeEventListener("markus:navigate",J)},[]);const xe=v.useRef(!1);v.useEffect(()=>{const J=Et.current;if(!J)return;const ge=()=>J.scrollHeight-J.scrollTop-J.clientHeight<80,Ce=()=>{xe.current=!0},Me=()=>{xe.current&&ge()?(xe.current=!1,st.current=!0):xe.current&&(st.current=!1)};return J.addEventListener("wheel",Ce,{passive:!0}),J.addEventListener("touchmove",Ce,{passive:!0}),J.addEventListener("scroll",Me,{passive:!0}),()=>{J.removeEventListener("wheel",Ce),J.removeEventListener("touchmove",Ce),J.removeEventListener("scroll",Me)}},[]),v.useLayoutEffect(()=>{if(Fe.current){Fe.current=!1;return}st.current&&jn.current?.scrollIntoView({behavior:"instant"})},[_,M]);const Ke=v.useCallback(async J=>{const ge=`ch:${J}`;try{const Ce=await re.channels.getMessages(J,50),Me=Ce.messages.map(fo);q.current.set(ge,Me),L.current===ge&&(P(Me),ee(Ce.hasMore),De.current=Ce.messages[0]?new Date(Ce.messages[0].createdAt).toISOString():null)}catch{L.current===ge&&(P([]),ee(!1))}},[]),xt=v.useCallback(async(J,ge)=>{Ue.current=J;try{const Ce=await re.sessions.getMessages(J,50),Me=Ce.messages.map(Ey);q.current.set(ge,Me),L.current===ge&&Ue.current===J&&(P(Me),ee(Ce.hasMore),De.current=Ce.messages[0]?new Date(Ce.messages[0].createdAt).toISOString():null)}catch{L.current===ge&&Ue.current===J&&(P([]),ee(!1),De.current=null)}},[]),At=v.useCallback(async J=>{if(!J)return ze([]),[];try{const{sessions:ge}=await re.sessions.listByAgent(J,10);return ze(ge),ge}catch{return ze([]),[]}},[]),On=v.useCallback(async()=>{if(!(ne||!Z||!De.current)){ae(!0);try{const J=L.current;if(S==="channel"||S==="dm"){const ge=S==="dm"?ot(n?.id??"",U):z,Ce=await re.channels.getMessages(ge,50,De.current),Me=Ce.messages.map(fo);Fe.current=!0,P(Se=>{const Ge=[...Me,...Se];return q.current.set(J,Ge),Ge}),ee(Ce.hasMore),Ce.messages[0]&&(De.current=new Date(Ce.messages[0].createdAt).toISOString())}else if(Xe){const ge=await re.sessions.getMessages(Xe,50,De.current),Ce=ge.messages.map(Ey);Fe.current=!0,P(Me=>{const Se=[...Ce,...Me];return q.current.set(J,Se),Se}),ee(ge.hasMore),ge.messages[0]&&(De.current=new Date(ge.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),ge=L.current;L.current=J,ge&&ge!==J&&(rt.current.set(ge,se),vt.current.set(ge,Xe));const Ce=q.current.get(J),Me=E.current.get(J)??[],Se=T.current.has(J);H(Me),I(Se),S==="direct"&&D&&At(D);const Ge=rt.current.get(J),He=vt.current.get(J);if(Ge&&Ge.length>0&&Ee(Ge),Mt(!1),Ce!==void 0)P(Ce),ee(!1),He!==void 0&&nt(He),(!Ge||Ge.length===0)&&Ee([]);else if(P([]),ee(!1),De.current=null,S==="channel"||S==="dm"){const Nt=S==="dm"?ot(n?.id??"",U):z;Ke(Nt),(!Ge||Ge.length===0)&&Ee([])}else S==="direct"&&D&&At(D).then(Nt=>{if(L.current===J)if(Nt.length>0){const ht=Ge&&Ge.length>0?Ge:Nt.slice(0,5),lt=He!==void 0?He:ht[0].id,Tt=lt&&ht.some(Ut=>Ut.id===lt)?lt:ht[0].id;nt(Tt),Ee(ht),xt(Tt,J)}else{nt(null),(!Ge||Ge.length===0)&&Ee([]);const ht=(()=>{const lt=(navigator.language||"").toLowerCase();return lt.startsWith("zh")?"介绍一下你自己":lt.startsWith("ja")?"自己紹介をしてください":lt.startsWith("ko")?"자기소개를 해주세요":lt.startsWith("fr")?"Présentez-vous":lt.startsWith("de")?"Stell dich vor":lt.startsWith("es")?"Preséntate":lt.startsWith("pt")?"Apresente-se":lt.startsWith("ru")?"Представьтесь":"Introduce yourself"})();setTimeout(()=>Pe.current?.(ht),150)}})},[S,D,z,U]),v.useEffect(()=>S!=="channel"?void 0:pn.on("chat:message",ge=>{const Ce=ge.payload,Me=Ce.channel??"";if(!Me||Me!==z)return;const Se=Ce.senderType??"agent",Ge=Ce.text??Ce.message??"",He=Ce.senderId??Ce.agentId??"",Nt=Ce.senderName??Ce.agentId??"Agent",ht=Ce.metadata,lt={id:`ws_${Date.now()}_${He}`,sender:Se==="human"?"user":"agent",text:Ge,time:new Date().toLocaleTimeString(),agentName:Se==="agent"?Nt:void 0,agentId:Se==="agent"?He:void 0};if(ht&&Se==="agent"){const Ut=[];if(ht.thinking?.length&&Ut.push({type:"text",content:"",thinking:ht.thinking.join(`
|
|
53
|
+
|
|
54
|
+
`)}),ht.toolCalls?.length)for(let Nn=0;Nn<ht.toolCalls.length;Nn++){const zn=ht.toolCalls[Nn];Ut.push({type:"tool",key:`${zn.tool}_${Nn}`,tool:zn.tool,status:zn.status==="error"?"error":"done",args:zn.arguments,result:zn.result,durationMs:zn.durationMs})}Ut.length>0&&(Ut.push({type:"text",content:Ge}),lt.segments=Ut)}const Tt=Ct("channel",D,z,U);dt(Tt,Ut=>[...Ut,lt])}),[S,z,D,U,dt]),v.useEffect(()=>pn.on("chat:proactive_message",ge=>{const Ce=ge.payload,Me=Ce.agentId??"",Se=Ce.agentName??"Agent",Ge=Ce.message??"",He=Ce.sessionId??"";if(!(!Me||!Ge)&&S==="direct"&&D===Me){const Nt={id:`proactive_${Date.now()}`,sender:"agent",text:Ge,time:new Date().toLocaleTimeString(),agentName:Se,agentId:Me},ht=Ct("direct",Me,z,U);dt(ht,lt=>[...lt,Nt]),He&&Xe!==He&&nt(He)}}),[S,D,z,U,Xe,dt]),_t.find(J=>J.id===en),v.useEffect(()=>{tn(null)},[D]);const hr=J=>$T(J),mr=()=>{ie.current?.abort(),ie.current=null;const J=L.current;T.current.delete(J),E.current.delete(J),I(!1),H([])},er=async J=>{const ge=(J??V).trim();if(!ge&&fe.length===0||S==="direct"&&!D)return;if(st.current=!0,xe.current=!1,X){ie.current?.abort(),ie.current=null;const He=L.current;T.current.delete(He),E.current.delete(He),dt(He,Nt=>{const ht=[...Nt];for(let lt=ht.length-1;lt>=0;lt--)if(ht[lt].sender==="agent"&&!ht[lt].isStopped&&!ht[lt].isError){const Tt=ht[lt],Ut=(Tt.segments??[]).map(Nn=>Nn.type==="tool"&&Nn.status==="running"?{...Nn,status:"stopped"}:Nn);ht[lt]={...Tt,isStopped:!0,segments:Ut};break}return ht}),I(!1),H([]),await new Promise(Nt=>setTimeout(Nt,50))}const Ce=fe.length>0?fe.map(He=>He.dataUrl):void 0,Me=Ct(S,D,z,U),Se=B;J||(W(""),ye.current&&(ye.current.style.height="auto")),Ne([]),Pt(!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 He=ot(n?.id??"",U),Nt=`opt_${Date.now()}`,ht={id:Nt,sender:"user",text:ge,time:new Date().toLocaleTimeString()};Se&&(ht.replyToId=Se.id,ht.replyToSender=Se.sender,ht.replyToText=Se.text),dt(Me,lt=>[...lt,ht]);try{const lt=await re.channels.sendMessage(He,{text:ge,senderName:n?.name??"You",senderId:n?.id,mentions:[],orgId:"default",humanOnly:!0});dt(Me,Tt=>{const Ut=Tt.filter(zn=>zn.id!==Nt),Nn=[];return lt.userMessage&&Nn.push(fo(lt.userMessage)),Nn.length>0?[...Ut,...Nn]:Tt})}catch(lt){dt(Me,Tt=>[...Tt,{id:`err_${Date.now()}`,sender:"agent",text:`Error: ${String(lt)}`,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}T.current.delete(Me),L.current===Me&&I(!1)}else if(S==="channel"){const He=`opt_${Date.now()}`,Nt={id:He,sender:"user",text:ge,time:new Date().toLocaleTimeString()};Se&&(Nt.replyToId=Se.id,Nt.replyToSender=Se.sender,Nt.replyToText=Se.text),dt(Me,ht=>[...ht,Nt]);try{const ht=hr(ge),lt=ht.length>0?s.find(Ut=>Ut.name.toLowerCase()===ht[0].toLowerCase()):null,Tt=await re.channels.sendMessage(z,{text:ge,senderName:n?.name??"You",mentions:ht,senderId:n?.id,targetAgentId:lt?.id,orgId:"default"});dt(Me,Ut=>{const Nn=Ut.filter(jt=>jt.id!==He),zn=[];return Tt.userMessage&&zn.push(fo(Tt.userMessage)),Tt.agentMessage&&zn.push(fo(Tt.agentMessage)),zn.length>0?[...Nn,...zn]:Ut})}catch(ht){const lt=Ty(ht)||`Error: ${String(ht)}`;dt(Me,Tt=>[...Tt,{id:`err_${Date.now()}`,sender:"agent",text:lt,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}T.current.delete(Me),L.current===Me&&I(!1)}else{const He=`a_${Date.now()}`,Nt={id:`u_${Date.now()}`,sender:"user",text:ge,time:new Date().toLocaleTimeString()};Ce?.length&&(Nt.images=Ce),Se&&(Nt.replyToId=Se.id,Nt.replyToSender=Se.sender,Nt.replyToText=Se.text),dt(Me,jt=>[...jt,Nt,{id:He,sender:"agent",text:"",time:new Date().toLocaleTimeString(),segments:[]}]);const ht=jt=>{dt(Me,ct=>{const yt=[...ct],We=yt.findIndex(Qo=>Qo.id===He);if(We<0)return ct;const Ze=yt[We].segments??[],ut=Ze[Ze.length-1];let ft,Mn=jt;const rr=jt.match(/<think>([\s\S]*?)<\/think>/);rr&&(ft=(ut?.type==="text"?ut.thinking??"":"")+rr[1],Mn=jt.replace(/<think>[\s\S]*?<\/think>/,""));const ra=ut?.type==="text"?[...Ze.slice(0,-1),{type:"text",content:ut.content+Mn,thinking:ft??ut.thinking}]:[...Ze,{type:"text",content:Mn,thinking:ft}];return yt[We]={...yt[We],text:yt[We].text+Mn,segments:ra},yt})},lt=jt=>{(jt.phase==="start"||jt.phase==="end")&&Qe(Me,{...jt,phase:jt.phase,ts:Date.now()}),jt.phase==="start"?dt(Me,ct=>{const yt=[...ct],We=yt.findIndex(ft=>ft.id===He);if(We<0)return ct;const Ze=[...yt[We].segments??[]];let ut=!1;if(jt.arguments)for(let ft=Ze.length-1;ft>=0;ft--){const Mn=Ze[ft];if(Mn.type==="tool"&&Mn.tool===jt.tool&&Mn.status==="running"){Ze[ft]={...Mn,args:jt.arguments},ut=!0;break}}if(!ut){const ft=`${jt.tool}_${Date.now()}`;Ze.push({type:"tool",key:ft,tool:jt.tool,status:"running",args:jt.arguments})}return yt[We]={...yt[We],segments:Ze},yt}):jt.phase==="output"?dt(Me,ct=>{const yt=[...ct],We=yt.findIndex(ut=>ut.id===He);if(We<0)return ct;const Ze=[...yt[We].segments??[]];for(let ut=Ze.length-1;ut>=0;ut--){const ft=Ze[ut];if(ft.type==="tool"&&ft.tool===jt.tool&&ft.status==="running"){Ze[ut]={...ft,liveOutput:(ft.liveOutput??"")+(jt.output??"")};break}}return yt[We]={...yt[We],segments:Ze},yt}):jt.phase==="subagent_progress"&&jt.subagentEvent?dt(Me,ct=>{const yt=[...ct],We=yt.findIndex(ut=>ut.id===He);if(We<0)return ct;const Ze=[...yt[We].segments??[]];for(let ut=Ze.length-1;ut>=0;ut--){const ft=Ze[ut];if(ft.type==="tool"&&(ft.tool==="spawn_subagent"||ft.tool==="spawn_subagents")&&ft.status==="running"){Ze[ut]={...ft,subagentLogs:[...ft.subagentLogs??[],jt.subagentEvent]};break}}return yt[We]={...yt[We],segments:Ze},yt}):dt(Me,ct=>{const yt=[...ct],We=yt.findIndex(ut=>ut.id===He);if(We<0)return ct;const Ze=[...yt[We].segments??[]];for(let ut=Ze.length-1;ut>=0;ut--){const ft=Ze[ut];if(ft.type==="tool"&&ft.tool===jt.tool&&ft.status==="running"){Ze[ut]={...ft,status:jt.success===!1?"error":"done",args:jt.arguments,result:jt.result,error:jt.error,durationMs:jt.durationMs,liveOutput:void 0};break}}return yt[We]={...yt[We],segments:Ze},yt})},Tt=new AbortController;ie.current=Tt;try{const jt=Xe===je?null:Xe,ct=await re.agents.messageStream(D,ge,ht,lt,Tt.signal,Ce,jt);L.current===Me&&(ct.sessionId&&(nt(ct.sessionId),Ee(yt=>yt.map(We=>We.id===je?{...We,id:ct.sessionId}:We))),At(D).then(yt=>{if(L.current===Me&&(ze(yt),ct.sessionId)){const We=yt.find(Ze=>Ze.id===ct.sessionId);We&&Ee(Ze=>Ze.some(ft=>ft.id===We.id)?Ze.map(ft=>ft.id===We.id?We:ft):[We,...Ze.filter(ft=>ft.id!==je)])}}))}catch(jt){const ct=jt?.sessionId;ct&&S==="direct"&&L.current===Me&&(nt(ct),Ee(We=>We.map(Ze=>Ze.id===je?{...Ze,id:ct}:Ze)),At(D).then(We=>{if(L.current!==Me)return;ze(We);const Ze=We.find(ut=>ut.id===ct);Ze&&Ee(ut=>ut.some(Mn=>Mn.id===Ze.id)?ut.map(Mn=>Mn.id===Ze.id?Ze:Mn):[Ze,...ut])}));const yt=Ty(jt);yt?dt(Me,We=>{const Ze=[...We],ut=Ze.findIndex(ft=>ft.id===He);if(ut>=0){const ft=Ze[ut].segments??[];Ze[ut]={...Ze[ut],text:yt,isError:!0,segments:[...ft,{type:"text",content:yt}]}}return Ze}):dt(Me,We=>{const Ze=[...We],ut=Ze.findIndex(ft=>ft.id===He);if(ut>=0){const ft=Ze[ut];if(!(ft.text||ft.segments&&ft.segments.length>0&&ft.segments.some(rr=>rr.type==="text"&&rr.content||rr.type==="tool")))return We.filter(rr=>rr.id!==He);Ze[ut]={...ft,isStopped:!0}}return Ze})}dt(Me,jt=>{const ct=[...jt],yt=ct.findIndex(We=>We.id===He);if(yt>=0){const We=(ct[yt].segments??[]).map(Ze=>Ze.type==="tool"&&Ze.status==="running"?{...Ze,status:"stopped"}:Ze);ct[yt]={...ct[yt],segments:We}}return ct}),Tt.signal.aborted&&dt(Me,jt=>{const ct=[...jt],yt=ct.findIndex(We=>We.id===He);if(yt>=0){const We=ct[yt];if(!(We.text||We.segments&&We.segments.length>0&&We.segments.some(ut=>ut.type==="text"&&ut.content||ut.type==="tool")))return jt.filter(ut=>ut.id!==He);ct[yt]={...We,isStopped:!0}}return ct});const Nn=(q.current.get(Me)??[]).find(jt=>jt.id===He),zn=Xe&&Xe!==je?Xe:null;Nn&&!Nn.text&&S==="direct"&&zn&&!Tt.signal.aborted&&(async(ct,yt)=>{for(let We=0;We<ct;We++){await new Promise(Ze=>setTimeout(Ze,yt));try{const ut=(await re.sessions.getMessages(zn,2)).messages.find(ft=>ft.role==="assistant");if(ut?.content){dt(Me,ft=>{const Mn=[...ft],rr=Mn.findIndex(ra=>ra.id===He);return rr>=0&&(Mn[rr]={...Mn[rr],text:ut.content,segments:[{type:"text",content:ut.content}]}),Mn});return}}catch{}}})(5,3e3)}ie.current=null,T.current.delete(Me),E.current.delete(Me),L.current===Me&&(I(!1),H([]))};Pe.current=er;const[or,tr]=v.useState(null),[wn,ts]=v.useState(new Set),ns=v.useCallback(J=>{const ge=J.segments?J.segments.filter(Ce=>Ce.type==="text").map(Ce=>Ce.content).join(`
|
|
55
|
+
`):J.text;navigator.clipboard.writeText(ge),tr(J.id),setTimeout(()=>tr(Ce=>Ce===J.id?null:Ce),2e3)},[]),ce=v.useCallback(J=>{const ge=L.current,Ce=q.current.get(ge)??_,Me=Ce.findIndex(He=>He.id===J.id);if(Me<0)return;const Se=Me>0&&Ce[Me-1]?.sender==="user"?Ce[Me-1]:null,Ge=Se?.text??"";Ge&&(dt(ge,He=>He.filter(Nt=>Nt.id!==J.id&&(Se?Nt.id!==Se.id:!0))),er(Ge))},[_,dt]),_e=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]),$e=async J=>{nt(J.id),Mt(!1),ee(!1),De.current=null;const ge=L.current;q.current.delete(ge),P([]),Ee(Ce=>Ce.some(Me=>Me.id===J.id)?Ce:[...Ce,J]),await xt(J.id,ge)},Yt=J=>{if(Ee(ge=>ge.filter(Ce=>Ce.id!==J)),Xe===J){const ge=se.filter(Ce=>Ce.id!==J);ge.length>0?$e(ge[ge.length-1]):br()}},br=()=>{nt(je);const J=L.current;q.current.delete(J),P([]),ee(!1),De.current=null,Mt(!1),Ee(ge=>{const Ce=ge.filter(Me=>Me.id!==je);return[{id:je,agentId:D??"",userId:null,title:"New Chat",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...Ce]})},rs=J=>{if(W(J),S!=="channel"){Pt(!1);return}const ge=J.lastIndexOf("@");if(ge>=0&&(ge===0||J[ge-1]===" ")){const Me=J.slice(ge+1).toLowerCase();if(s.some(Ge=>Ge.name.toLowerCase().includes(Me))){Pt(!0),nn(Me),vn(0);return}}Pt(!1)},yr=J=>{const ge=V.lastIndexOf("@"),Ce=J.includes(" ")?`@[${J}]`:`@${J}`;W(V.slice(0,ge)+Ce+" "),Pt(!1),vn(0)},gs=4*1024*1024,cr=5,Rn=v.useCallback(J=>{const ge=Array.from(J).filter(Ce=>Ce.type.startsWith("image/"));if(ge.length!==0)for(const Ce of ge){if(Ce.size>gs)continue;const Me=new FileReader;Me.onload=()=>{const Se=Me.result;Ne(Ge=>Ge.length>=cr||Ge.some(He=>He.dataUrl===Se)?Ge:[...Ge,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:Se,name:Ce.name}])},Me.readAsDataURL(Ce)}},[]),ss=v.useCallback(J=>{Ne(ge=>ge.filter(Ce=>Ce.id!==J))},[]),Os=v.useCallback(J=>{const ge=J.clipboardData?.files;if(ge&&ge.length>0){const Ce=Array.from(ge).filter(Me=>Me.type.startsWith("image/"));Ce.length>0&&(J.preventDefault(),Rn(Ce))}},[Rn]),as=v.useCallback(J=>{J.preventDefault();const ge=J.dataTransfer?.files;ge&&ge.length>0&&Rn(Array.from(ge).filter(Ce=>Ce.type.startsWith("image/")))},[Rn]),Ur=v.useCallback(J=>{J.preventDefault()},[]),Pn=s.find(J=>J.id===D),Rs=n?.name??"You",Dn=_[_.length-1],qr=X&&Dn?.sender==="agent",xr=s.filter(J=>J.name.toLowerCase().includes(yn)),Ar=o.find(J=>J.id===U),nr=U===n?.id||!U,Vr=Je.find(J=>J.channelKey===z),te=S==="channel"?Vr?.name??z:S==="direct"?Pn?.name??"Select Agent":S==="dm"?nr?"My Notes":Ar?.name??"Direct Message":"Chat",Ie=S==="channel"?Vr?`Message ${Vr.name}…`:`Message ${z}… (use @name to mention)`:S==="dm"?nr?"Write a note to yourself…":`Message ${Ar?.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(XT,{authUser:n,agents:s,teams:Jt,humans:o,tasks:_t,externalAgents:Ht,groupChats:Je,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:fn,onRefreshAgents:at,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=pe.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"&&Pn&&t.jsx(My,{agent:Pn,tasks:_t,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:()=>{p==="profile"?history.back():x("chat")},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${p==="chat"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>{p!=="profile"&&O()},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${p==="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:br,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:Kt,onClick:()=>Mt(!tt),className:`p-1 rounded-md transition-colors shrink-0 ${tt?"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"&&Pn&&t.jsx(My,{agent:Pn,tasks:_t,onViewProfile:k}),(S==="channel"||S==="dm")&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[_.length," messages"]}),S==="dm"&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-1",children:nr?"· Private notepad":`· Direct message with ${Ar?.name??""}`}),(S==="direct"&&D||S==="channel"&&Dt)&&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 ${p==="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 ${p==="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"&&Pn&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("button",{onClick:br,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:Kt,onClick:()=>Mt(!tt),className:`p-1.5 rounded-md transition-colors ${tt?"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&&p==="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){nt(je);const ge=L.current;q.current.delete(ge),P([])}else $e(J)},children:[t.jsx("span",{className:"truncate",children:J.id===je?"New Chat":J.title||"Conversation"}),t.jsx("button",{onClick:ge=>{ge.stopPropagation(),Yt(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&&tt&&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:()=>Mt(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[Te.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No conversations yet"}),(()=>{const J=new Date,ge=new Date(J.getFullYear(),J.getMonth(),J.getDate()).getTime(),Ce=ge-864e5,Me=ge-7*864e5,Se=[],Ge=[],He=[],Nt=[],ht=[];for(const lt of Te){const Tt=new Date(lt.lastMessageAt).getTime();Tt>=ge?Ge.push(lt):Tt>=Ce?He.push(lt):Tt>=Me?Nt.push(lt):ht.push(lt)}return Ge.length>0&&Se.push({label:"Today",items:Ge}),He.length>0&&Se.push({label:"Yesterday",items:He}),Nt.length>0&&Se.push({label:"Previous 7 days",items:Nt}),ht.length>0&&Se.push({label:"Older",items:ht}),Se.map(lt=>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:lt.label}),lt.items.map(Tt=>t.jsxs("button",{onClick:()=>{$e(Tt)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${Tt.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:Tt.title||"Conversation"}),t.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(Tt.lastMessageAt).toLocaleString()})]},Tt.id))]},lt.label))})()]})]})]}),p==="profile"&&S==="direct"&&D&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(QT,{agentId:D,onBack:()=>x("chat"),inline:!0,defaultTab:C})}),p==="profile"&&S==="channel"&&Dt&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(f_,{teamId:Dt,onBack:()=>x("chat"),inline:!0})}),t.jsxs("div",{ref:Et,className:`flex-1 overflow-y-auto space-y-3 ${c?"p-2.5":"p-5"} ${p!=="chat"?"hidden":""}`,children:[Z&&t.jsx("div",{className:"flex justify-center py-2",children:t.jsx("button",{onClick:()=>{On()},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"})}),_.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 ",Vr?.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 ",Pn?.name,"."]})]}),S==="channel"?_.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:ge=>{if(J.sender==="agent"&&J.agentId){const Ce=ge.currentTarget.getBoundingClientRect();N({agentId:J.agentId,top:Ce.top,left:Ce.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 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 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(Jn,{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((ge,Ce)=>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")},Ce))}),jy(J.text,s)]})}),t.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity",children:t.jsx(_y,{msg:J,onCopy:ns,onRetry:ce,onReply:_e,isCopied:or===J.id})})]})]},J.id)):_.map((J,ge)=>{const Me=qr&&ge===_.length-1&&X,Se=!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"&&wn.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(m_,{name:J.agentName??(S==="direct"?Pn?.name??"Agent":"Agent"),agentId:J.agentId??(S==="direct"?Pn?.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,He)=>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")},He))}),J.text&&t.jsx("span",{className:"whitespace-pre-wrap leading-relaxed",children:jy(J.text,s)})]}):t.jsx(g_,{msg:J,isStreaming:Me,liveActivities:Me?M:[],onViewModeChange:Ge=>ts(He=>{const Nt=new Set(He);return Ge==="full"?Nt.add(J.id):Nt.delete(J.id),Nt})})}),Se&&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(_y,{msg:J,onCopy:ns,onRetry:ce,onReply:_e,isCopied:or===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:jn})]}),w&&(()=>{const J=s.find(ge=>ge.id===w.agentId);return J?t.jsx(x_,{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 ${p!=="chat"?"hidden":""}`,onDrop:as,onDragOver:Ur,children:[Ve&&xr.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"}),xr.map((J,ge)=>t.jsxs("button",{onClick:()=>yr(J.name),onMouseEnter:()=>vn(ge),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${ge===un?"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))]}),fe.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[fe.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)),fe.length<cr&&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&&Rn(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:V,onChange:J=>{rs(J.target.value),J.target.style.height="auto";const ge=Math.min(J.target.scrollHeight,120);J.target.style.height=`${ge}px`,J.target.style.overflowY=ge>=120?"auto":"hidden"},onKeyDown:J=>{if(Ve&&xr.length>0){const ge=J.key==="ArrowUp"||J.ctrlKey&&J.key==="p",Ce=J.key==="ArrowDown"||J.ctrlKey&&J.key==="n",Me=J.key==="Enter"||J.key==="Tab",Se=J.key==="Escape";if(ge){J.preventDefault(),vn(Ge=>(Ge-1+xr.length)%xr.length);return}if(Ce){J.preventDefault(),vn(Ge=>(Ge+1)%xr.length);return}if(Me){J.preventDefault();const Ge=xr[un];Ge&&yr(Ge.name);return}if(Se){J.preventDefault(),Pt(!1);return}}J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),er())},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:mr,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:()=>{er()},disabled:S==="direct"&&!D||!V.trim()&&fe.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 My({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 p=h?"bg-red-400 animate-pulse":c?"bg-blue-400 animate-pulse":"bg-green-400",x=h?"error":c?"working":"idle",g=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-blue-500/10 border border-blue-500/20 hover:bg-blue-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 ${p}`}),t.jsx("span",{className:`text-xs ${h?"text-red-500":c?"text-blue-500":"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),bt.navigate(pe.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:g}),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 →"})]})]})}const v_=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"midnight",label:"Midnight"}],Aj="markus-theme";function Oy(e){const n=document.documentElement;n.classList.remove("light","dark","cyberpunk","midnight"),e==="light"?n.classList.add("light"):e==="dark"?n.classList.add("dark"):e==="cyberpunk"?n.classList.add("cyberpunk"):e==="midnight"&&n.classList.add("midnight")}function j_(){try{const e=localStorage.getItem(Aj);if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="midnight")return e}catch{}return"system"}function w_(){const[e,n]=v.useState(j_),s=v.useCallback(l=>{n(l);try{localStorage.setItem(Aj,l)}catch{}Oy(l)},[]);return v.useEffect(()=>{Oy(e)},[e]),{mode:e,setMode:s}}function Mj({theme:e,onThemeChange:n}={}){const[s,l]=v.useState(null),[o,d]=v.useState(null),[c,h]=v.useState(""),[m,f]=v.useState(!1),[p,x]=v.useState(null),[g,y]=v.useState(null),[w,N]=v.useState(null),[C,A]=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),[q,E]=v.useState({}),[T,L]=v.useState(!1),[_,P]=v.useState([]),[V,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),[fe,Ne]=v.useState(!1),[Le,ye]=v.useState(200),[je,Te]=v.useState(!1),[ze,Xe]=v.useState(null),[nt,tt]=v.useState(null),[Mt,se]=v.useState(!1),[Ee,rt]=v.useState(new Set),[vt,Kt]=v.useState(null),[we,De]=v.useState(!1),Ue=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`}),Je=v.useCallback(()=>{re.health().then(l).catch(()=>{}),fetch("/api/settings/llm").then(ce=>ce.ok?ce.json():Promise.reject(ce.status)).then(ce=>{ce&&typeof ce=="object"&&"providers"in ce&&(d(ce),h(ce.defaultProvider))}).catch(()=>{})},[]),pt=v.useCallback(()=>{fetch("/api/settings/oauth/providers").then(ce=>ce.ok?ce.json():Promise.reject(ce.status)).then(ce=>P(ce.providers??[])).catch(()=>{})},[]),Jt=v.useCallback(()=>{fetch("/api/settings/oauth/profiles",{headers:Ue()}).then(ce=>ce.ok?ce.json():Promise.reject(ce.status)).then(ce=>W(ce.profiles??[])).catch(()=>{})},[]),ln=v.useCallback(()=>{re.settings.getAgent().then(ce=>{ce&&typeof ce.maxToolIterations=="number"&&ye(ce.maxToolIterations)}).catch(()=>{})},[]),Ht=v.useCallback(()=>{se(!0),re.system.storage().then(tt).catch(()=>{}).finally(()=>se(!1)),re.system.orphans().then(Kt).catch(()=>{})},[]);v.useEffect(()=>{Je(),pt(),Jt(),ln(),Ht()},[Je,pt,Jt,ln,Ht]),v.useEffect(()=>{const ce=()=>Ht();return window.addEventListener("markus:data-changed",ce),()=>window.removeEventListener("markus:data-changed",ce)},[Ht]);const Lt=v.useCallback(async()=>{K(!0),G(null),Y(null),E({});try{const ce=await fetch("/api/settings/env-models",{headers:Ue()});if(!ce.ok){G({type:"err",text:`Detection failed (HTTP ${ce.status})`});return}const _e=await ce.json();if(Y(_e),_e.detected.length===0)G({type:"err",text:"No model API keys found in environment variables"});else{const $e={};for(const Yt of _e.detected)$e[Yt.provider]=!0;E($e)}}catch{G({type:"err",text:"Failed to detect environment variables"})}finally{K(!1)}},[]),_t=o?Object.values(o.providers).some(ce=>ce.configured):!1;v.useEffect(()=>{o&&!_t&&!ae.current&&(ae.current=!0,Lt())},[o,_t,Lt]);const St=async()=>{if(!(!c||c===o?.defaultProvider)){f(!0),x(null);try{const ce=await fetch("/api/settings/llm",{method:"POST",headers:Ue(),body:JSON.stringify({defaultProvider:c})}),_e=await ce.json();ce.ok?(d(_e),x({type:"ok",text:`Default provider updated to ${_e.defaultProvider}`})):x({type:"err",text:_e.error??"Save failed"})}catch{x({type:"err",text:"Network error"})}finally{f(!1)}}},en=async(ce,_e)=>{N(ce);try{const $e=await fetch(`/api/settings/llm/providers/${ce}/toggle`,{method:"POST",headers:Ue(),body:JSON.stringify({enabled:_e})});if($e.ok){const Yt=await $e.json();d(Yt)}}catch{}finally{N(null)}},tn=async()=>{k(!0),R(null);try{const _e=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Ue(),body:JSON.stringify({preview:!0})})).json();"error"in _e?R({type:"err",text:_e.error}):A(_e)}catch{R({type:"err",text:"Detection failed"})}finally{k(!1)}},ve=async()=>{k(!0),R(null);try{const _e=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Ue(),body:JSON.stringify({preview:!1})})).json();"error"in _e?R({type:"err",text:_e.error}):(R({type:"ok",text:`Imported ${_e.appliedModels} model configs from OpenClaw`}),Je())}catch{R({type:"err",text:"Import failed"})}finally{k(!1)}},qe=async()=>{if(!D)return;const ce=D.detected.filter(_e=>q[_e.provider]);if(ce.length===0){G({type:"err",text:"Select at least one provider to apply"});return}L(!0),G(null);try{const _e=await fetch("/api/settings/env-models",{method:"POST",headers:Ue(),body:JSON.stringify({providers:ce.map(Yt=>({provider:Yt.provider,model:Yt.model,baseUrl:Yt.baseUrl,enabled:!0}))})});if(!_e.ok){G({type:"err",text:`Apply failed (HTTP ${_e.status})`});return}const $e=await _e.json();G({type:"ok",text:$e.message}),Y(null),E({}),Je()}catch{G({type:"err",text:"Failed to apply environment configs"})}finally{L(!1)}};v.useEffect(()=>()=>{ne.current&&clearInterval(ne.current)},[]);const[Rt,zt]=v.useState(!1),[Ve,Pt]=v.useState({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),[yn,nn]=v.useState(!1),[un,vn]=v.useState(null),[Dt,jn]=v.useState(null),[Et,ie]=v.useState({apiKey:"",baseUrl:"",model:"",contextWindow:0,maxOutputTokens:0,costInput:0,costOutput:0}),[Pe,Fe]=v.useState(!1),[st,ot]=v.useState(null),[Ct,dt]=v.useState(null),[Qe,at]=v.useState({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1}),[fn,xe]=v.useState(!1),Ke=async()=>{if(!(!Ve.name||!Ve.model)){nn(!0),vn(null);try{const ce=await fetch("/api/settings/llm/providers",{method:"POST",headers:Ue(),body:JSON.stringify({name:Ve.name,apiKey:Ve.apiKey||void 0,baseUrl:Ve.baseUrl||void 0,model:Ve.model,contextWindow:Ve.contextWindow||void 0,maxOutputTokens:Ve.maxOutputTokens||void 0,cost:Ve.costInput||Ve.costOutput?{input:Ve.costInput,output:Ve.costOutput}:void 0})}),_e=await ce.json();ce.ok?(d(_e),zt(!1),Pt({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),vn({type:"ok",text:`Provider ${Ve.name} added`})):vn({type:"err",text:_e.error??"Failed to add"})}catch{vn({type:"err",text:"Network error"})}finally{nn(!1)}}},xt=(ce,_e)=>{jn(ce),ie({apiKey:"",baseUrl:_e.baseUrl??"",model:_e.model,contextWindow:_e.contextWindow??0,maxOutputTokens:_e.maxOutputTokens??0,costInput:_e.cost?.input??0,costOutput:_e.cost?.output??0})},At=async ce=>{Fe(!0);try{const _e={};Et.apiKey&&(_e.apiKey=Et.apiKey),Et.baseUrl!==void 0&&(_e.baseUrl=Et.baseUrl),Et.model&&(_e.model=Et.model),Et.contextWindow&&(_e.contextWindow=Et.contextWindow),Et.maxOutputTokens&&(_e.maxOutputTokens=Et.maxOutputTokens),(Et.costInput||Et.costOutput)&&(_e.cost={input:Et.costInput,output:Et.costOutput});const $e=await fetch(`/api/settings/llm/providers/${ce}`,{method:"PUT",headers:Ue(),body:JSON.stringify(_e)});if($e.ok){const Yt=await $e.json();d(Yt),jn(null)}}catch{}finally{Fe(!1)}},On=async ce=>{ot(ce);try{const _e=await fetch(`/api/settings/llm/providers/${ce}`,{method:"DELETE",headers:Ue()});if(_e.ok){const $e=await _e.json();d($e),h($e.defaultProvider)}}catch{}finally{ot(null)}},hr=async ce=>{if(!(!Qe.id||!Qe.name)){xe(!0);try{const _e=await fetch(`/api/settings/llm/providers/${ce}/models`,{method:"POST",headers:Ue(),body:JSON.stringify({id:Qe.id,name:Qe.name,contextWindow:Qe.contextWindow,maxOutputTokens:Qe.maxOutputTokens,cost:{input:Qe.costInput,output:Qe.costOutput},reasoning:Qe.reasoning||void 0,inputTypes:Qe.vision?["text","image"]:["text"]})});if(_e.ok){const $e=await _e.json();d($e),dt(null),at({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})}}catch{}finally{xe(!1)}}},mr=async(ce,_e)=>{try{const $e=await fetch(`/api/settings/llm/providers/${ce}/models/${encodeURIComponent(_e)}`,{method:"DELETE",headers:Ue()});if($e.ok){const Yt=await $e.json();d(Yt)}}catch{}},er=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"]),[or,tr]=v.useState(null),wn=async(ce,_e)=>{tr(`${ce}:${_e}`);try{const $e=await fetch(`/api/settings/llm/providers/${ce}/model`,{method:"POST",headers:Ue(),body:JSON.stringify({model:_e})});if($e.ok){const Yt=await $e.json();d(Yt)}}catch{}finally{tr(null)}},ts=o?.providers?Object.entries(o.providers).filter(([,ce])=>ce.configured&&ce.enabled).map(([ce])=>ce):[],ns=o&&!_t&&!fe;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(Ta,{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 a visual style for the interface"})]}),t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:v_.map(({value:ce,label:_e})=>t.jsx("button",{onClick:()=>n?.(ce),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${e===ce?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:_e},ce))})]})})}),ns&&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($h,{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(ce=>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:q[ce.provider]??!1,onChange:_e=>E({...q,[ce.provider]:_e.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:ce.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:ce.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:ce.apiKeyPreview})]},ce.provider)),t.jsx("button",{onClick:()=>{qe()},disabled:T||Object.values(q).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(q).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(nl,{type:U.type,text:U.text})]}),t.jsxs($h,{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((ce,_e)=>ce+_e.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(nl,{type:S.type,text:S.text})]}),t.jsx($h,{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(Ta,{title:"System Status",children:s?t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Bh,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx(Bh,{label:"Version",value:s.version,color:"indigo"}),t.jsx(Bh,{label:"Active Agents",value:String(s.agents),color:"purple"})]}):t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Loading..."})}),t.jsx(Ta,{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:ce=>{h(ce.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:ts.length>0?ts.map(ce=>t.jsx("option",{value:ce,children:o.providers[ce]?.displayName??ce},ce)):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"})]})]}),p&&t.jsx(nl,{type:p.type,text:p.text})]})}),t.jsxs(Ta,{title:"Model Providers & Pricing",children:[t.jsx("div",{className:"space-y-3",children:o&&Object.entries(o.providers).map(([ce,_e])=>t.jsxs("div",{className:`bg-surface-secondary border rounded-xl overflow-hidden transition-colors ${_e.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(g===ce?null:ce),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${_e.configured&&_e.enabled?"bg-green-400":_e.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:_e.displayName??ce}),ce===o.defaultProvider&&t.jsx("span",{className:"text-[10px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"default"}),_e.configured&&!_e.enabled&&t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded",children:"disabled"}),_e.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:_e.model||"Not configured"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[_e.configured&&t.jsx("button",{onClick:$e=>{$e.stopPropagation(),en(ce,!_e.enabled)},disabled:w===ce,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${_e.enabled?"bg-green-500":"bg-gray-600"} ${w===ce?"opacity-50":""}`,title:_e.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 ${_e.enabled?"translate-x-4":"translate-x-1"}`})}),_e.contextWindow&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[(_e.contextWindow/1e3).toFixed(0),"K ctx"]}),_e.cost&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["$",_e.cost.input,"/",_e.cost.output," per 1M"]}),t.jsx("span",{className:"text-fg-tertiary text-xs",children:g===ce?"▲":"▼"})]})]}),g===ce&&t.jsxs("div",{className:"px-5 pb-4 border-t border-border-default pt-4 space-y-4",children:[_e.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:_e.model}),t.jsx(_a,{label:"Context Window",value:_e.contextWindow?`${(_e.contextWindow/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(_a,{label:"Max Output",value:_e.maxOutputTokens?`${(_e.maxOutputTokens/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(_a,{label:"Base URL",value:_e.baseUrl??"Default"})]}),Dt===ce?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:Et.apiKey,onChange:$e=>ie({...Et,apiKey:$e.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:Et.baseUrl,onChange:$e=>ie({...Et,baseUrl:$e.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:Et.model,onChange:$e=>ie({...Et,model:$e.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:Et.contextWindow||"",onChange:$e=>ie({...Et,contextWindow:Number($e.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:Et.maxOutputTokens||"",onChange:$e=>ie({...Et,maxOutputTokens:Number($e.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:Et.costInput||"",onChange:$e=>ie({...Et,costInput:Number($e.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:Et.costOutput||"",onChange:$e=>ie({...Et,costOutput:Number($e.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:()=>{At(ce)},disabled:Pe,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:Pe?"Saving...":"Save"}),t.jsx("button",{onClick:()=>jn(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:$e=>{$e.stopPropagation(),xt(ce,_e)},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:$e=>{$e.stopPropagation(),confirm(`Delete provider "${_e.displayName??ce}"?`)&&On(ce)},disabled:st===ce,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:st===ce?"Deleting...":"Delete"})]})]}),_e.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:`$${_e.cost.input}`}),t.jsx(_a,{label:"Output",value:`$${_e.cost.output}`}),_e.cost.cacheRead!=null&&t.jsx(_a,{label:"Cache Read",value:`$${_e.cost.cacheRead}`}),_e.cost.cacheWrite!=null&&t.jsx(_a,{label:"Cache Write",value:`$${_e.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"}),_e.configured&&Ct!==ce&&t.jsx("button",{onClick:()=>{dt(ce),at({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"})]}),Ct===ce&&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:Qe.id,onChange:$e=>at({...Qe,id:$e.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:Qe.name,onChange:$e=>at({...Qe,name:$e.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:Qe.contextWindow,onChange:$e=>at({...Qe,contextWindow:Number($e.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:Qe.maxOutputTokens,onChange:$e=>at({...Qe,maxOutputTokens:Number($e.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:Qe.costInput,onChange:$e=>at({...Qe,costInput:Number($e.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:Qe.costOutput,onChange:$e=>at({...Qe,costOutput:Number($e.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:Qe.reasoning,onChange:$e=>at({...Qe,reasoning:$e.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:Qe.vision,onChange:$e=>at({...Qe,vision:$e.target.checked}),className:"rounded"}),"vision"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>{hr(ce)},disabled:fn||!Qe.id||!Qe.name,className:"px-2 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded transition-colors",children:fn?"Adding...":"Add"}),t.jsx("button",{onClick:()=>dt(null),className:"px-2 py-1 text-[10px] border border-border-default text-fg-secondary hover:bg-surface-elevated rounded transition-colors",children:"Cancel"})]})]}),_e.models&&_e.models.length>0&&t.jsx("div",{className:"space-y-1.5",children:_e.models.map($e=>{const Yt=$e.id===_e.model,br=or===`${ce}:${$e.id}`,rs=!er.has($e.id);return t.jsxs("div",{className:`flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-colors ${Yt?"bg-brand-500/15 border border-brand-500/30":_e.configured?"bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer":"bg-surface-elevated/30"}`,onClick:()=>{!Yt&&_e.configured&&!br&&wn(ce,$e.id)},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[Yt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0"}),t.jsx("span",{className:Yt?"text-brand-500 font-medium":"text-fg-secondary",children:$e.name}),$e.reasoning&&t.jsx("span",{className:"text-[9px] bg-amber-500/15 text-amber-600 px-1 py-0.5 rounded",children:"reasoning"}),$e.inputTypes?.includes("image")&&t.jsx("span",{className:"text-[9px] bg-blue-500/15 text-blue-600 px-1 py-0.5 rounded",children:"vision"}),rs&&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:[($e.contextWindow/1e3).toFixed(0),"K ctx"]}),t.jsxs("span",{children:["$",$e.cost.input,"/$",$e.cost.output]}),_e.configured&&!Yt&&t.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded transition-colors ${br?"bg-brand-500/30 text-brand-400":"bg-surface-overlay text-fg-tertiary hover:bg-brand-500/20 hover:text-brand-500"}`,children:br?"Switching...":"Use"}),Yt&&t.jsx("span",{className:"text-[9px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"active"}),rs&&!Yt&&t.jsx("button",{onClick:yr=>{yr.stopPropagation(),mr(ce,$e.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"})})})]})]},$e.id)})})]}),!_e.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.'})]})]},ce))}),Rt?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:Ve.name,onChange:ce=>Pt({...Ve,name:ce.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:Ve.apiKey,onChange:ce=>Pt({...Ve,apiKey:ce.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:Ve.baseUrl,onChange:ce=>Pt({...Ve,baseUrl:ce.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:Ve.model,onChange:ce=>Pt({...Ve,model:ce.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:Ve.contextWindow,onChange:ce=>Pt({...Ve,contextWindow:Number(ce.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:Ve.maxOutputTokens,onChange:ce=>Pt({...Ve,maxOutputTokens:Number(ce.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:Ve.costInput,onChange:ce=>Pt({...Ve,costInput:Number(ce.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:Ve.costOutput,onChange:ce=>Pt({...Ve,costOutput:Number(ce.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:()=>{Ke()},disabled:yn||!Ve.name||!Ve.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:yn?"Adding...":"Add Provider"}),t.jsx("button",{onClick:()=>{zt(!1),vn(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"})]}),un&&t.jsx(nl,{type:un.type,text:un.text})]}):t.jsx("button",{onClick:()=>zt(!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(Ta,{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(ce=>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:q[ce.provider]??!1,onChange:_e=>E({...q,[ce.provider]:_e.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:ce.displayName}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["Key: ",t.jsx("code",{className:"text-fg-secondary",children:ce.apiKeyPreview})," / ","Model: ",t.jsx("code",{className:"text-fg-secondary",children:ce.model}),ce.baseUrl&&t.jsxs(t.Fragment,{children:[" / ","URL: ",t.jsx("code",{className:"text-fg-secondary",children:ce.baseUrl})]})]})]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:Object.keys(ce.envVars).map(_e=>t.jsx("div",{children:t.jsx("code",{children:_e})},_e))})]},ce.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:()=>{qe()},disabled:T||Object.values(q).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(q).filter(Boolean).length} Provider(s) to Config`})]}),U&&t.jsx(nl,{type:U.type,text:U.text})]})}),t.jsx(Ta,{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(ce=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:ce.name}),t.jsxs("span",{className:"text-fg-tertiary",children:[ce.modelCount," models ",ce.baseUrl?`(${ce.baseUrl})`:""]})]},ce.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(nl,{type:S.type,text:S.text})]})}),t.jsx(Ta,{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:ce=>{ye(Number(ce.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()=>{Te(!0),Xe(null);try{const ce=await re.settings.updateAgent({maxToolIterations:Le});ye(ce.maxToolIterations),Xe({type:"ok",text:"Saved"})}catch{Xe({type:"err",text:"Failed to save"})}Te(!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"})]})]}),ze&&t.jsx(nl,{type:ze.type,text:ze.text})]})}),t.jsx(Ta,{title:"Data & Storage",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[Mt&&!nt&&t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Scanning storage..."}),nt&&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:Cs(nt.totalSize)}),t.jsx("div",{className:"text-xs text-fg-tertiary font-mono mt-0.5",children:nt.dataDir})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>Ht(),disabled:Mt,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:Mt?"Scanning...":"Refresh"}),t.jsx("button",{onClick:()=>{re.system.openPath(nt.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:nt.breakdown.filter(ce=>ce.size>0).map(ce=>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:ce.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:ce.description})]}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Cs(ce.size)})]},ce.name))})]}),nt.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 (",nt.agents.length,")"]}),t.jsx("div",{className:"space-y-1",children:nt.agents.map(ce=>{const _e=Ee.has(ce.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:()=>rt($e=>{const Yt=new Set($e);return Yt.has(ce.id)?Yt.delete(ce.id):Yt.add(ce.id),Yt}),children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:_e?"▼":"▶"}),t.jsx("button",{onClick:$e=>{$e.stopPropagation(),bt.navigate(pe.TEAM,{agentId:ce.id})},className:"text-sm text-brand-500 hover:text-brand-400 truncate",children:ce.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:ce.id})]}),t.jsx("span",{className:"text-xs font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Cs(ce.size)})]}),_e&&t.jsxs("div",{className:"px-3 pb-2 pt-0.5 space-y-0.5",children:[ce.subItems.filter($e=>$e.size>0).map($e=>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:$e.name}),t.jsx("span",{className:"text-fg-secondary tabular-nums",children:Cs($e.size)})]},$e.name)),t.jsx("div",{className:"pl-5 pt-1",children:t.jsx("button",{onClick:()=>{re.system.openPath(nt.dataDir+"/agents/"+ce.id)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary underline",children:"Open folder"})})]})]},ce.id)})})]}),vt&&(vt.orphanAgents.length>0||vt.orphanTeams.length>0)&&t.jsx(N_,{orphanInfo:vt,dataDir:nt.dataDir,onPurged:Ht})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function $h({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 nl({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 Ta({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 Bh({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 Cs(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 N_({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),p=N=>d(C=>{const A=new Set(C);return A.has(N)?A.delete(N):A.add(N),A}),x=o.size===l.length&&l.length>0,g=()=>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),A=C.purgedAgents.length+C.purgedTeams.length;f(`Cleaned ${A} dir${A!==1?"s":""}, freed ${Cs(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: ",Cs(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:g,className:"rounded"}),"Select all"]}),o.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[o.size," selected (",Cs(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:()=>p(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:Cs(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 (${Cs(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 (${Cs(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 Er={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function Oj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function k_(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 Rj={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function Em({authUser:e}={}){const[n,s]=v.useState("all"),[l,o]=v.useState(""),[d,c]=v.useState([]),[h,m]=v.useState([]),[f,p]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(!0),[N,C]=v.useState(new Map),A=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?Gn.search({type:"agent",q:l,limit:50}):ll(Er.hubAgents)??Gn.search({type:"agent",limit:50}),[R]=await Promise.all([S.catch(()=>({items:[],total:0})),A()]);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,A]);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}`);g(!1),p(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),p(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(S_,{item:S,localInfo:N.get(Oj(S.name)),onStatusChange:A},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(C_,{template:S,isSelected:f?.id===S.id,onSelect:()=>p(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.jsx("div",{className:"flex items-center gap-3",children: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:()=>g(!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:()=>p(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 ${Rj[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(E_,{template:f,onClose:()=>g(!1),onHire:k})]})}function S_({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&&k_(e.version,n.localVersion),f=async p=>{if(p.stopPropagation(),!l){o(!0),c("");try{const x=await Gn.download(e.id),g=x.name||e.name,y=Oj(g),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:g,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:"group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5",children:[t.jsx("div",{className:"absolute inset-0 rounded-xl border border-border-default group-hover:border-brand-500/30 transition-colors duration-300"}),t.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-green-500/40 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2.5 mb-2.5",children:[t.jsx("h3",{className:"text-sm font-semibold truncate flex-1 group-hover:text-brand-400 transition-colors",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-400 rounded-md border border-brand-500/10",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-500 rounded-md border border-green-500/10",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-500",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 pt-3 border-t border-border-default/50",children:[m?t.jsx("button",{onClick:p=>{f(p)},disabled:l,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:l?"Upgrading...":`Upgrade → v${e.version}`}):h?t.jsxs("span",{className:"px-3 py-1.5 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",n?.localVersion?` (v${n.localVersion})`:""]}):t.jsx("button",{onClick:p=>{f(p)},disabled:l,className:"px-3 py-1.5 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 C_({template:e,isSelected:n,onSelect:s}){return t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] 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-surface-elevated/80 text-fg-secondary rounded-md border border-border-default/50",children:l},l)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-muted",children:["+",e.skills.length-4]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-2 text-xs",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded-md text-[10px] font-medium capitalize ${Rj[e.agentRole]??"bg-surface-overlay text-fg-secondary"}`,children:e.agentRole}),e.tags.length>0&&t.jsx("span",{className:"text-fg-muted text-[10px]",children:e.tags.slice(0,2).join(" · ")})]})]})]})}function E_({template:e,onClose:n,onHire:s}){const[l,o]=v.useState(`${e.name} Agent`),[d,c]=v.useState(""),[h,m]=v.useState([]),[f,p]=v.useState(!1);v.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(g=>g.json()).then(g=>m(g.teams??[])).catch(()=>{})},[]);const x=async()=>{if(l.trim()){p(!0);try{await s(e.id,l.trim(),d||void 0)}finally{p(!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:g=>g.stopPropagation(),children:[t.jsx("div",{className:"flex items-center gap-3 mb-5",children: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:g=>o(g.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:g=>c(g.target.value),className:"input-field",children:[t.jsx("option",{value:"",children:"No team"}),h.map(g=>t.jsx("option",{value:g.id,children:g.name},g.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"})]})]})})}function Dj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function T_(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 Tm(){const[e,n]=v.useState("all"),[s,l]=v.useState(""),[o,d]=v.useState([]),[c,h]=v.useState([]),[m,f]=v.useState(null),[p,x]=v.useState(!0),[g,y]=v.useState(!1),[w,N]=v.useState(null),[C,A]=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})}A(Y)}catch{}},[]),k=v.useCallback(async()=>{x(!0);try{if(e==="hub"){const R=s?Gn.search({type:"team",q:s,limit:50}):ll(Er.hubTeams)??Gn.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 q of R.members){const E=q.count??1;for(let T=0;T<E;T++){const L=q.name??`${R.name} Agent ${T+1}`,_=E>1?`${L} ${T+1}`:L,P=q.roleName??q.templateId??"developer";try{const V=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:_,roleName:P,orgId:"default",teamId:Y,agentRole:q.role??"worker",skills:q.skills??[]})});if(V.ok){K++;const W=await V.json();q.role==="manager"&&!z&&(z=W.agent?.id)}else{const W=await V.json().catch(()=>({error:`HTTP ${V.status}`}));U.push(`${_}: ${W.error??V.statusText}`)}}catch(V){U.push(`${_}: ${String(V)}`)}}}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:p?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(__,{item:R,localInfo:C.get(Dj(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(A_,{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.jsx("div",{className:"flex items-center gap-3",children: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:g,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:g?"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 __({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&&T_(e.version,n.localVersion),f=async p=>{if(p.stopPropagation(),!l){o(!0),c("");try{const x=await Gn.download(e.id),g=x.name||e.name,y=Dj(g),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:g,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("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:p=>{f(p)},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:p=>{f(p)},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 A_({template:e,isSelected:n,onSelect:s}){const l=e.members.reduce((d,c)=>d+(c.count??1),0),o=e.members.some(d=>d.role==="manager");return e.category,t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] 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((d,c)=>t.jsxs("span",{className:`px-2 py-0.5 text-[10px] rounded-md border ${d.role==="manager"?"bg-brand-500/10 text-brand-400 border-brand-500/15":"bg-blue-500/10 text-blue-400 border-blue-500/15"}`,children:[d.name??d.roleName??d.templateId,(d.count??1)>1?` x${d.count}`:""]},c))}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-3 text-xs",children:[t.jsxs("span",{className:"text-fg-muted",children:[l," agent",l!==1?"s":""]}),o&&t.jsx("span",{className:"text-brand-400/60",children:"has manager"}),e.tags&&e.tags.length>0&&t.jsx("span",{className:"text-fg-muted text-[10px]",children:e.tags.slice(0,3).join(" · ")})]})]})]})}function Lj(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 Hh={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"},M_=[{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 O_({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&&Lj(e.version,h.version),p=async()=>{if(!o){d(!0);try{const x=await Gn.download(e.id),g=x.name||e.name,y=g.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:g,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:()=>{p()},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:()=>{p()},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 _m(){const e=xs(),[n,s]=v.useState("installed"),[l,o]=v.useState(null),[d,c]=v.useState(new Set),[h,m]=v.useState([]),[f,p]=v.useState(!0),[x,g]=v.useState(""),[y,w]=v.useState([]),[N,C]=v.useState(0),[A,O]=v.useState(1),[k,S]=v.useState([]),[R,D]=v.useState(""),[Y,z]=v.useState("score"),[K,U]=v.useState(""),[G,q]=v.useState(!1),[E,T]=v.useState([]),[L,_]=v.useState(!1),[P,V]=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,Ee="success")=>{o({text:se,type:Ee}),setTimeout(()=>o(null),Ee==="error"?1e4:4e3)},fe=v.useCallback(async()=>{p(!0);try{const se=await re.skills.list();m(se.skills)}catch{}p(!1)},[]),Ne=v.useCallback(async()=>{_(!0);try{const se=await re.skills.builtin();T(se.skills)}catch{}_(!1)},[]),Le=v.useCallback(async se=>{q(!0);try{const Ee=await re.skills.registrySkillhub({q:se?.q,category:se?.category,page:se?.page??1,limit:24,sort:se?.sort??Y});w(Ee.skills),C(Ee.total),Ee.categories?.length&&S(Ee.categories)}catch{}q(!1)},[Y]),ye=v.useCallback(async se=>{X(!0);try{const Ee=await re.skills.registrySkillssh(se);V(Ee.skills)}catch{}X(!1)},[]),je=v.useCallback(async se=>{Z(!0);try{const rt=await(se?Gn.search({type:"skill",q:se,limit:50}):ll(Er.hubSkills)??Gn.search({type:"skill",limit:50}));M(rt?.items??[])}catch{}Z(!1)},[]);v.useEffect(()=>{fe(),Ne(),Le(),ye()},[]),v.useEffect(()=>{n==="markus-hub"&&je(ee)},[n,ee,je]);const Te=async se=>{c(Ee=>new Set(Ee).add(se.name));try{const Ee=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 fe(),ae(`"${se.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${se.name}". You can try manually from: ${se.homepage}`,"error")}c(Ee=>{const rt=new Set(Ee);return rt.delete(se.name),rt})},ze=async se=>{c(Ee=>new Set(Ee).add(se.name));try{const Ee=await re.skills.install({name:se.name,source:"skillssh",sourceUrl:se.url,githubRepo:`${se.author}/${se.repo}`,githubSkillPath:se.name});await fe(),ae(`"${se.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${se.name}". You can try manually from: ${se.url}`,"error")}c(Ee=>{const rt=new Set(Ee);return rt.delete(se.name),rt})},Xe=async se=>{c(Ee=>new Set(Ee).add(se.name));try{const Ee=await re.skills.install({name:se.name,source:"builtin"});await fe(),await Ne(),ae(`"${se.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Ee){ae(`Install failed for "${se.name}": ${Ee}`,"error")}c(Ee=>{const rt=new Set(Ee);return rt.delete(se.name),rt})},nt=async se=>{if(confirm(`Uninstall "${se}"? This will delete the skill files from ~/.markus/skills/.`))try{await re.skills.uninstall(se),await fe(),ae(`"${se}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Ee){ae(`Uninstall failed: ${Ee}`,"error")}},tt=h.filter(se=>{if(!x)return!0;const Ee=x.toLowerCase();return se.name.toLowerCase().includes(Ee)||se.description?.toLowerCase().includes(Ee)}),Mt=P.filter(se=>{if(!W)return!0;const Ee=W.toLowerCase();return se.name.toLowerCase().includes(Ee)||se.repo.toLowerCase().includes(Ee)});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:M_.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=>g(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:[tt.length," skill",tt.length!==1?"s":""]})]}),f?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:"Loading..."}):tt.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:tt.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 ${Hh[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(Ee=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Ee},Ee))}),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:()=>{nt(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 ${Hh[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(Ee=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Ee},Ee))}),se.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:se.requiredPermissions.map(Ee=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:Ee},Ee))}),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&&Lj(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 Ee=h.some(rt=>rt.name===se.name||rt.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]?Hh[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 →"}),Ee?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:()=>{Te(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:A<=1,onClick:()=>{const se=A-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:["第 ",A," / ",Math.ceil(N/24)," 页"]}),t.jsx("button",{disabled:A>=Math.ceil(N/24),onClick:()=>{const se=A+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..."})}):Mt.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:Mt.map(se=>{const Ee=h.some(rt=>rt.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 →"}),Ee?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:()=>{ze(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(O_,{item:se,installedSkills:h,onMsg:ae,onRefresh:()=>{fe()}})})]},se.id))})]})]})}const R_=50,D_=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,p=Math.abs(m),x=Math.abs(f);if(p<R_||Math.atan2(x,p)*(180/Math.PI)>D_)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 Ph=[{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function L_(){const e=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_storeTab"),e==="agents"||e==="teams"||e==="skills"?e:"agents"}function I_({authUser:e}){const[n,s]=v.useState(L_),l=xs(),o=gx(Ph,n,s);return v.useEffect(()=>{const d=c=>{if(c.detail.page==="store"){const m=localStorage.getItem("markus_nav_storeTab");m&&(localStorage.removeItem("markus_nav_storeTab"),(m==="agents"||m==="teams"||m==="skills")&&s(m))}};return window.addEventListener("markus:navigate",d),()=>window.removeEventListener("markus:navigate",d)},[]),l?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",children:Ph.map(d=>t.jsx("button",{onClick:()=>s(d.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===d.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:d.label},d.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx(Em,{authUser:e}),n==="teams"&&t.jsx(Tm,{}),n==="skills"&&t.jsx(_m,{})]})]}):t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[t.jsxs("nav",{className:"w-48 shrink-0 border-r border-border-default bg-surface-secondary/50 flex flex-col py-4 px-2 gap-1",children:[t.jsx("div",{className:"px-3 pb-3 mb-1 border-b border-border-default/50",children:t.jsx("h2",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Store"})}),Ph.map(d=>t.jsx("button",{onClick:()=>s(d.id),className:`flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-sm font-medium transition-all ${n===d.id?"bg-brand-600/15 text-brand-400 shadow-sm shadow-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:d.label},d.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx(Em,{authUser:e}),n==="teams"&&t.jsx(Tm,{}),n==="skills"&&t.jsx(_m,{})]})]})}function z_(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"]}],Ry={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 Dy({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 Ij(){const e=xs(),[n,s]=v.useState([]),[l,o]=v.useState([]),[d,c]=v.useState(!1),[h,m]=v.useState("all"),[f,p]=v.useState(null),[x,g]=v.useState(new Map),[y,w]=v.useState(null),[N,C]=v.useState(new Map),[A,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(Er.builderArtifacts)??re.builder.artifacts.list()).then(E=>E?.artifacts??[]).catch(()=>[]),(ll(Er.builderAgents)??re.agents.list()).then(E=>E?.agents??[]).catch(()=>[]),(ll(Er.builderHubMyItems)??Gn.myItems()).then(E=>E?.items??[]).catch(()=>[]),(ll(Er.builderInstalled)??re.builder.artifacts.installed()).then(E=>E?.installed??{}).catch(()=>({}))]).then(([E,T,L,_])=>{if(o(E),s(T),L.length>0){const V=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))&&V.set(`${F.type}/${F.name}`,{id:W.id,name:W.name,slug:W.slug||F.name})}V.size>0&&C(W=>{const B=new Map(W);for(const[F,X]of V)B.set(F,X);return B})}const P=new Map;for(const V of E){const W=`${V.type}/${V.name}`,B=_[W];B&&P.set(W,{agentId:B.agentId,agentIds:B.agentIds,teamId:B.teamId})}g(P)}).finally(()=>c(!1))},[]);v.useEffect(()=>{R();const E=T=>{T.detail?.page===pe.BUILDER&&R()};return window.addEventListener("markus:navigate",E),()=>window.removeEventListener("markus:navigate",E)},[R]);const D=(E,T)=>{const L=n.find(_=>_.role===T||_.name===T);L?bt.navigate(pe.TEAM,{agentId:L.id}):bt.navigate(pe.TEAM)},Y=async E=>{const T=`${E.type}/${E.name}`;if(!x.has(T)){p(T);try{const L=await re.builder.artifacts.install(E.type,E.name),_={};L.agent&&typeof L.agent=="object"&&(_.agentId=L.agent.id),L.team&&typeof L.team=="object"&&(_.teamId=L.team.id),Array.isArray(L.agents)&&(_.agentIds=L.agents.map(P=>P.id)),g(P=>new Map(P).set(T,_)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Install failed:",L),alert(`Install failed: ${L}`)}finally{p(null)}}},z=async E=>{const T=`${E.type}/${E.name}`;if(x.has(T)){p(T);try{await re.builder.artifacts.uninstall(E.type,E.name),g(L=>{const _=new Map(L);return _.delete(T),_}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Uninstall failed:",L),alert(`Uninstall failed: ${L}`)}finally{p(null)}}},K=async E=>{const T=`${E.type}/${E.name}`;if(!N.has(T)){p(T);try{const L=await re.builder.artifacts.get(E.type,E.name),_=E.meta.displayName||E.meta.name||E.name,P=E.meta.description||"",V=E.meta.category||"general",W=Array.isArray(E.meta.tags)?E.meta.tags:[],B=E.name,F=await Gn.publishViaProxy({itemType:E.type==="team"?"team":E.type==="skill"?"skill":"agent",name:_,slug:B,description:P,category:V,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:_,slug:F.slug??B}),I})}catch(L){console.error("Share failed:",L),alert(`Share failed: ${L}`)}finally{p(null)}}},U=async()=>{if(!A)return;const{key:E}=A,T=N.get(E);if(O(null),!T)return;const L=T.id;p(E);try{await Gn.deleteItem(L),C(_=>{const P=new Map(_);return P.delete(E),P})}catch(_){console.error("Hub delete failed:",_),alert(`Failed to remove from Hub: ${_}`)}finally{p(null)}},G=async()=>{if(!y)return;const E=y,T=`${E.type}/${E.name}`;w(null),p(T);try{await re.builder.artifacts.delete(E.type,E.name),o(L=>L.filter(_=>!(_.type===E.type&&_.name===E.name))),g(L=>{const _=new Map(L);return _.delete(T),_}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Delete failed:",L)}finally{p(null)}},q=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..."}):q.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:q.map(E=>{const T=Ry[E.type]??Ry.agent,L=E.meta.displayName||E.meta.name||E.name,_=E.meta.description||"",P=`${E.type}/${E.name}`,V=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:V,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:V?"Uninstalling...":"Uninstall"}):t.jsx("button",{onClick:()=>Y(E),disabled:V,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:V?"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:V,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=Gn.getUser();if(!B||!F)return;const X=`${Gn.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:V,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:V?"Sharing...":"Share"}),t.jsx("button",{onClick:()=>w(E),disabled:V,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})]}),_&&t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2",children:_}),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:z_(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(Dy,{message:`Delete "${y.meta.displayName||y.meta.name||y.name}"? This cannot be undone.`,onConfirm:G,onCancel:()=>w(null)}),A&&t.jsx(Dy,{message:`Remove "${A.name}" from Markus Hub? It will no longer be available for others to download.`,onConfirm:()=>{U()},onCancel:()=>O(null)})]})})}function Kn(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=Kn(e[s]))!==""&&(n+=(n&&" ")+l);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}var $_={value:()=>{}};function tu(){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 B_(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=tu.prototype={constructor:jd,on:function(e,n){var s=this._,l=B_(e+"",s),o,d=-1,c=l.length;if(arguments.length<2){for(;++d<c;)if((o=(e=l[d]).type)&&(o=H_(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]=Ly(s[o],e.name,n);else if(n==null)for(o in s)s[o]=Ly(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 H_(e,n){for(var s=0,l=e.length,o;s<l;++s)if((o=e[s]).name===n)return o.value}function Ly(e,n,s){for(var l=0,o=e.length;l<o;++l)if(e[l].name===n){e[l]=$_,e=e.slice(0,l).concat(e.slice(l+1));break}return s!=null&&e.push({name:n,value:s}),e}var Am="http://www.w3.org/1999/xhtml";const Iy={svg:"http://www.w3.org/2000/svg",xhtml:Am,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function nu(e){var n=e+="",s=n.indexOf(":");return s>=0&&(n=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),Iy.hasOwnProperty(n)?{space:Iy[n],local:e}:e}function P_(e){return function(){var n=this.ownerDocument,s=this.namespaceURI;return s===Am&&n.documentElement.namespaceURI===Am?n.createElement(e):n.createElementNS(s,e)}}function U_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function zj(e){var n=nu(e);return(n.local?U_:P_)(n)}function q_(){}function bx(e){return e==null?q_:function(){return this.querySelector(e)}}function V_(e){typeof e!="function"&&(e=bx(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,p=0;p<c;++p)(m=d[p])&&(f=e.call(m,m.__data__,p,d))&&("__data__"in m&&(f.__data__=m.__data__),h[p]=f);return new Pr(l,this._parents)}function F_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Y_(){return[]}function $j(e){return e==null?Y_:function(){return this.querySelectorAll(e)}}function G_(e){return function(){return F_(e.apply(this,arguments))}}function X_(e){typeof e=="function"?e=G_(e):e=$j(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 Pr(l,o)}function Bj(e){return function(){return this.matches(e)}}function Hj(e){return function(n){return n.matches(e)}}var K_=Array.prototype.find;function Z_(e){return function(){return K_.call(this.children,e)}}function Q_(){return this.firstElementChild}function W_(e){return this.select(e==null?Q_:Z_(typeof e=="function"?e:Hj(e)))}var J_=Array.prototype.filter;function eA(){return Array.from(this.children)}function tA(e){return function(){return J_.call(this.children,e)}}function nA(e){return this.selectAll(e==null?eA:tA(typeof e=="function"?e:Hj(e)))}function rA(e){typeof e!="function"&&(e=Bj(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 Pr(l,this._parents)}function Pj(e){return new Array(e.length)}function sA(){return new Pr(this._enter||this._groups.map(Pj),this._parents)}function Id(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Id.prototype={constructor:Id,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 aA(e){return function(){return e}}function lA(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 Id(e,d[c]);for(;c<m;++c)(h=n[c])&&(o[c]=h)}function iA(e,n,s,l,o,d,c){var h,m,f=new Map,p=n.length,x=d.length,g=new Array(p),y;for(h=0;h<p;++h)(m=n[h])&&(g[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 Id(e,d[h]);for(h=0;h<p;++h)(m=n[h])&&f.get(g[h])===m&&(o[h]=m)}function oA(e){return e.__data__}function cA(e,n){if(!arguments.length)return Array.from(this,oA);var s=n?iA:lA,l=this._parents,o=this._groups;typeof e!="function"&&(e=aA(e));for(var d=o.length,c=new Array(d),h=new Array(d),m=new Array(d),f=0;f<d;++f){var p=l[f],x=o[f],g=x.length,y=dA(e.call(p,p&&p.__data__,f,l)),w=y.length,N=h[f]=new Array(w),C=c[f]=new Array(w),A=m[f]=new Array(g);s(p,x,N,C,A,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 Pr(c,l),c._enter=h,c._exit=m,c}function dA(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function uA(){return new Pr(this._exit||this._groups.map(Pj),this._parents)}function fA(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 hA(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],p=l[m],x=f.length,g=h[m]=new Array(x),y,w=0;w<x;++w)(y=f[w]||p[w])&&(g[w]=y);for(;m<o;++m)h[m]=s[m];return new Pr(h,this._parents)}function mA(){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 xA(e){e||(e=pA);function n(x,g){return x&&g?e(x.__data__,g.__data__):!x-!g}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,p=0;p<h;++p)(f=c[p])&&(m[p]=f);m.sort(n)}return new Pr(o,this._parents).order()}function pA(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function gA(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function bA(){return Array.from(this)}function yA(){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 vA(){let e=0;for(const n of this)++e;return e}function jA(){return!this.node()}function wA(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 NA(e){return function(){this.removeAttribute(e)}}function kA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function SA(e,n){return function(){this.setAttribute(e,n)}}function CA(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function EA(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function TA(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 _A(e,n){var s=nu(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?kA:NA:typeof n=="function"?s.local?TA:EA:s.local?CA:SA)(s,n))}function Uj(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function AA(e){return function(){this.style.removeProperty(e)}}function MA(e,n,s){return function(){this.style.setProperty(e,n,s)}}function OA(e,n,s){return function(){var l=n.apply(this,arguments);l==null?this.style.removeProperty(e):this.style.setProperty(e,l,s)}}function RA(e,n,s){return arguments.length>1?this.each((n==null?AA:typeof n=="function"?OA:MA)(e,n,s??"")):ii(this.node(),e)}function ii(e,n){return e.style.getPropertyValue(n)||Uj(e).getComputedStyle(e,null).getPropertyValue(n)}function DA(e){return function(){delete this[e]}}function LA(e,n){return function(){this[e]=n}}function IA(e,n){return function(){var s=n.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function zA(e,n){return arguments.length>1?this.each((n==null?DA:typeof n=="function"?IA:LA)(e,n)):this.node()[e]}function qj(e){return e.trim().split(/^|\s+/)}function yx(e){return e.classList||new Vj(e)}function Vj(e){this._node=e,this._names=qj(e.getAttribute("class")||"")}Vj.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 Fj(e,n){for(var s=yx(e),l=-1,o=n.length;++l<o;)s.add(n[l])}function Yj(e,n){for(var s=yx(e),l=-1,o=n.length;++l<o;)s.remove(n[l])}function $A(e){return function(){Fj(this,e)}}function BA(e){return function(){Yj(this,e)}}function HA(e,n){return function(){(n.apply(this,arguments)?Fj:Yj)(this,e)}}function PA(e,n){var s=qj(e+"");if(arguments.length<2){for(var l=yx(this.node()),o=-1,d=s.length;++o<d;)if(!l.contains(s[o]))return!1;return!0}return this.each((typeof n=="function"?HA:n?$A:BA)(s,n))}function UA(){this.textContent=""}function qA(e){return function(){this.textContent=e}}function VA(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function FA(e){return arguments.length?this.each(e==null?UA:(typeof e=="function"?VA:qA)(e)):this.node().textContent}function YA(){this.innerHTML=""}function GA(e){return function(){this.innerHTML=e}}function XA(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function KA(e){return arguments.length?this.each(e==null?YA:(typeof e=="function"?XA:GA)(e)):this.node().innerHTML}function ZA(){this.nextSibling&&this.parentNode.appendChild(this)}function QA(){return this.each(ZA)}function WA(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function JA(){return this.each(WA)}function eM(e){var n=typeof e=="function"?e:zj(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function tM(){return null}function nM(e,n){var s=typeof e=="function"?e:zj(e),l=n==null?tM:typeof n=="function"?n:bx(n);return this.select(function(){return this.insertBefore(s.apply(this,arguments),l.apply(this,arguments)||null)})}function rM(){var e=this.parentNode;e&&e.removeChild(this)}function sM(){return this.each(rM)}function aM(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function lM(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function iM(e){return this.select(e?lM:aM)}function oM(e){return arguments.length?this.property("__data__",e):this.node().__data__}function cM(e){return function(n){e.call(this,n,this.__data__)}}function dM(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 uM(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 fM(e,n,s){return function(){var l=this.__on,o,d=cM(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 hM(e,n,s){var l=dM(e+""),o,d=l.length,c;if(arguments.length<2){var h=this.node().__on;if(h){for(var m=0,f=h.length,p;m<f;++m)for(o=0,p=h[m];o<d;++o)if((c=l[o]).type===p.type&&c.name===p.name)return p.value}return}for(h=n?fM:uM,o=0;o<d;++o)this.each(h(l[o],n,s));return this}function Gj(e,n,s){var l=Uj(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 mM(e,n){return function(){return Gj(this,e,n)}}function xM(e,n){return function(){return Gj(this,e,n.apply(this,arguments))}}function pM(e,n){return this.each((typeof n=="function"?xM:mM)(e,n))}function*gM(){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 Xj=[null];function Pr(e,n){this._groups=e,this._parents=n}function Fo(){return new Pr([[document.documentElement]],Xj)}function bM(){return this}Pr.prototype=Fo.prototype={constructor:Pr,select:V_,selectAll:X_,selectChild:W_,selectChildren:nA,filter:rA,data:cA,enter:sA,exit:uA,join:fA,merge:hA,selection:bM,order:mA,sort:xA,call:gA,nodes:bA,node:yA,size:vA,empty:jA,each:wA,attr:_A,style:RA,property:zA,classed:PA,text:FA,html:KA,raise:QA,lower:JA,append:eM,insert:nM,remove:sM,clone:iM,datum:oM,on:hM,dispatch:pM,[Symbol.iterator]:gM};function Br(e){return typeof e=="string"?new Pr([[document.querySelector(e)]],[document.documentElement]):new Pr([[e]],Xj)}function yM(e){let n;for(;n=e.sourceEvent;)e=n;return e}function cs(e,n){if(e=yM(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 vM={passive:!1},Ao={capture:!0,passive:!1};function qh(e){e.stopImmediatePropagation()}function si(e){e.preventDefault(),e.stopImmediatePropagation()}function Kj(e){var n=e.document.documentElement,s=Br(e).on("dragstart.drag",si,Ao);"onselectstart"in n?s.on("selectstart.drag",si,Ao):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Zj(e,n){var s=e.document.documentElement,l=Br(e).on("dragstart.drag",null);n&&(l.on("click.drag",si,Ao),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 Mm(e,{sourceEvent:n,subject:s,target:l,identifier:o,active:d,x:c,y:h,dx:m,dy:f,dispatch:p}){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:p}})}Mm.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function jM(e){return!e.ctrlKey&&!e.button}function wM(){return this.parentNode}function NM(e,n){return n??{x:e.x,y:e.y}}function kM(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qj(){var e=jM,n=wM,s=NM,l=kM,o={},d=tu("start","drag","end"),c=0,h,m,f,p,x=0;function g(S){S.on("mousedown.drag",y).filter(l).on("touchstart.drag",C).on("touchmove.drag",A,vM).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(!(p||!e.call(this,S,R))){var D=k(this,n.call(this,S,R),S,R,"mouse");D&&(Br(S.view).on("mousemove.drag",w,Ao).on("mouseup.drag",N,Ao),Kj(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){Br(S.view).on("mousemove.drag mouseup.drag",null),Zj(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 A(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(p&&clearTimeout(p),p=setTimeout(function(){p=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),q,E,T;if((T=s.call(S,new Mm("beforestart",{sourceEvent:D,target:g,identifier:z,active:c,x:G[0],y:G[1],dx:0,dy:0,dispatch:U}),Y))!=null)return q=T.x-G[0]||0,E=T.y-G[1]||0,function L(_,P,V){var W=G,B;switch(_){case"start":o[z]=L,B=c++;break;case"end":delete o[z],--c;case"drag":G=cs(V||P,R),B=c;break}U.call(_,S,new Mm(_,{sourceEvent:P,subject:T,target:g,identifier:z,active:B,x:G[0]+q,y:G[1]+E,dx:G[0]-W[0],dy:G[1]-W[1],dispatch:U}),Y)}}return g.filter=function(S){return arguments.length?(e=typeof S=="function"?S:cd(!!S),g):e},g.container=function(S){return arguments.length?(n=typeof S=="function"?S:cd(S),g):n},g.subject=function(S){return arguments.length?(s=typeof S=="function"?S:cd(S),g):s},g.touchable=function(S){return arguments.length?(l=typeof S=="function"?S:cd(!!S),g):l},g.on=function(){var S=d.on.apply(d,arguments);return S===d?g:S},g.clickDistance=function(S){return arguments.length?(x=(S=+S)*S,g):Math.sqrt(x)},g}function vx(e,n,s){e.prototype=n.prototype=s,s.constructor=e}function Wj(e,n){var s=Object.create(e.prototype);for(var l in n)s[l]=n[l];return s}function Yo(){}var Mo=.7,zd=1/Mo,ai="\\s*([+-]?\\d+)\\s*",Oo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ts="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",SM=/^#([0-9a-f]{3,8})$/,CM=new RegExp(`^rgb\\(${ai},${ai},${ai}\\)$`),EM=new RegExp(`^rgb\\(${Ts},${Ts},${Ts}\\)$`),TM=new RegExp(`^rgba\\(${ai},${ai},${ai},${Oo}\\)$`),_M=new RegExp(`^rgba\\(${Ts},${Ts},${Ts},${Oo}\\)$`),AM=new RegExp(`^hsl\\(${Oo},${Ts},${Ts}\\)$`),MM=new RegExp(`^hsla\\(${Oo},${Ts},${Ts},${Oo}\\)$`),zy={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};vx(Yo,fl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$y,formatHex:$y,formatHex8:OM,formatHsl:RM,formatRgb:By,toString:By});function $y(){return this.rgb().formatHex()}function OM(){return this.rgb().formatHex8()}function RM(){return Jj(this).formatHsl()}function By(){return this.rgb().formatRgb()}function fl(e){var n,s;return e=(e+"").trim().toLowerCase(),(n=SM.exec(e))?(s=n[1].length,n=parseInt(n[1],16),s===6?Hy(n):s===3?new Tr(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=CM.exec(e))?new Tr(n[1],n[2],n[3],1):(n=EM.exec(e))?new Tr(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=TM.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=AM.exec(e))?qy(n[1],n[2]/100,n[3]/100,1):(n=MM.exec(e))?qy(n[1],n[2]/100,n[3]/100,n[4]):zy.hasOwnProperty(e)?Hy(zy[e]):e==="transparent"?new Tr(NaN,NaN,NaN,0):null}function Hy(e){return new Tr(e>>16&255,e>>8&255,e&255,1)}function dd(e,n,s,l){return l<=0&&(e=n=s=NaN),new Tr(e,n,s,l)}function DM(e){return e instanceof Yo||(e=fl(e)),e?(e=e.rgb(),new Tr(e.r,e.g,e.b,e.opacity)):new Tr}function Om(e,n,s,l){return arguments.length===1?DM(e):new Tr(e,n,s,l??1)}function Tr(e,n,s,l){this.r=+e,this.g=+n,this.b=+s,this.opacity=+l}vx(Tr,Om,Wj(Yo,{brighter(e){return e=e==null?zd:Math.pow(zd,e),new Tr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Mo:Math.pow(Mo,e),new Tr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Tr(ol(this.r),ol(this.g),ol(this.b),$d(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:Py,formatHex:Py,formatHex8:LM,formatRgb:Uy,toString:Uy}));function Py(){return`#${il(this.r)}${il(this.g)}${il(this.b)}`}function LM(){return`#${il(this.r)}${il(this.g)}${il(this.b)}${il((isNaN(this.opacity)?1:this.opacity)*255)}`}function Uy(){const e=$d(this.opacity);return`${e===1?"rgb(":"rgba("}${ol(this.r)}, ${ol(this.g)}, ${ol(this.b)}${e===1?")":`, ${e})`}`}function $d(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 qy(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 Jj(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 IM(e,n,s,l){return arguments.length===1?Jj(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}vx(ds,IM,Wj(Yo,{brighter(e){return e=e==null?zd:Math.pow(zd,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 Tr(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(Vy(this.h),ud(this.s),ud(this.l),$d(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=$d(this.opacity);return`${e===1?"hsl(":"hsla("}${Vy(this.h)}, ${ud(this.s)*100}%, ${ud(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Vy(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 jx=e=>()=>e;function zM(e,n){return function(s){return e+s*n}}function $M(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 BM(e){return(e=+e)==1?ew:function(n,s){return s-n?$M(n,s,e):jx(isNaN(n)?s:n)}}function ew(e,n){var s=n-e;return s?zM(e,s):jx(isNaN(e)?n:e)}const Bd=(function e(n){var s=BM(n);function l(o,d){var c=s((o=Om(o)).r,(d=Om(d)).r),h=s(o.g,d.g),m=s(o.b,d.b),f=ew(o.opacity,d.opacity);return function(p){return o.r=c(p),o.g=h(p),o.b=m(p),o.opacity=f(p),o+""}}return l.gamma=e,l})(1);function HM(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 PM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function UM(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 qM(e,n){var s=new Date;return e=+e,n=+n,function(l){return s.setTime(e*(1-l)+n*l),s}}function Es(e,n){return e=+e,n=+n,function(s){return e*(1-s)+n*s}}function VM(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 Rm=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fh=new RegExp(Rm.source,"g");function FM(e){return function(){return e}}function YM(e){return function(n){return e(n)+""}}function tw(e,n){var s=Rm.lastIndex=Fh.lastIndex=0,l,o,d,c=-1,h=[],m=[];for(e=e+"",n=n+"";(l=Rm.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:Es(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]?YM(m[0].x):FM(n):(n=m.length,function(f){for(var p=0,x;p<n;++p)h[(x=m[p]).i]=x.x(f);return h.join("")})}function ko(e,n){var s=typeof n,l;return n==null||s==="boolean"?jx(n):(s==="number"?Es:s==="string"?(l=fl(n))?(n=l,Bd):tw:n instanceof fl?Bd:n instanceof Date?qM:PM(n)?HM:Array.isArray(n)?UM:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?VM:Es)(e,n)}var Fy=180/Math.PI,Dm={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function nw(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)*Fy,skewX:Math.atan(m)*Fy,scaleX:c,scaleY:h}}var fd;function GM(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Dm:nw(n.a,n.b,n.c,n.d,n.e,n.f)}function XM(e){return e==null||(fd||(fd=document.createElementNS("http://www.w3.org/2000/svg","g")),fd.setAttribute("transform",e),!(e=fd.transform.baseVal.consolidate()))?Dm:(e=e.matrix,nw(e.a,e.b,e.c,e.d,e.e,e.f))}function rw(e,n,s,l){function o(f){return f.length?f.pop()+" ":""}function d(f,p,x,g,y,w){if(f!==x||p!==g){var N=y.push("translate(",null,n,null,s);w.push({i:N-4,x:Es(f,x)},{i:N-2,x:Es(p,g)})}else(x||g)&&y.push("translate("+x+n+g+s)}function c(f,p,x,g){f!==p?(f-p>180?p+=360:p-f>180&&(f+=360),g.push({i:x.push(o(x)+"rotate(",null,l)-2,x:Es(f,p)})):p&&x.push(o(x)+"rotate("+p+l)}function h(f,p,x,g){f!==p?g.push({i:x.push(o(x)+"skewX(",null,l)-2,x:Es(f,p)}):p&&x.push(o(x)+"skewX("+p+l)}function m(f,p,x,g,y,w){if(f!==x||p!==g){var N=y.push(o(y)+"scale(",null,",",null,")");w.push({i:N-4,x:Es(f,x)},{i:N-2,x:Es(p,g)})}else(x!==1||g!==1)&&y.push(o(y)+"scale("+x+","+g+")")}return function(f,p){var x=[],g=[];return f=e(f),p=e(p),d(f.translateX,f.translateY,p.translateX,p.translateY,x,g),c(f.rotate,p.rotate,x,g),h(f.skewX,p.skewX,x,g),m(f.scaleX,f.scaleY,p.scaleX,p.scaleY,x,g),f=p=null,function(y){for(var w=-1,N=g.length,C;++w<N;)x[(C=g[w]).i]=C.x(y);return x.join("")}}}var KM=rw(GM,"px, ","px)","deg)"),ZM=rw(XM,", ",")",")"),QM=1e-12;function Yy(e){return((e=Math.exp(e))+1/e)/2}function WM(e){return((e=Math.exp(e))-1/e)/2}function JM(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],p=c[0],x=c[1],g=c[2],y=p-h,w=x-m,N=y*y+w*w,C,A;if(N<QM)A=Math.log(g/f)/n,C=function(Y){return[h+Y*y,m+Y*w,f*Math.exp(n*Y*A)]};else{var O=Math.sqrt(N),k=(g*g-f*f+l*N)/(2*f*s*O),S=(g*g-f*f-l*N)/(2*g*s*O),R=Math.log(Math.sqrt(k*k+1)-k),D=Math.log(Math.sqrt(S*S+1)-S);A=(D-R)/n,C=function(Y){var z=Y*A,K=Yy(R),U=f/(s*O)*(K*JM(n*z+R)-WM(R));return[h+U*y,m+U*w,f*K/Yy(n*z+R)]}}return C.duration=A*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,sw=1e3,Hd,yo,Pd=0,hl=0,ru=0,Ro=typeof performance=="object"&&performance.now?performance:Date,aw=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function wx(){return hl||(aw(e6),hl=Ro.now()+ru)}function e6(){hl=0}function Ud(){this._call=this._time=this._next=null}Ud.prototype=lw.prototype={constructor:Ud,restart:function(e,n,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?wx():+s)+(n==null?0:+n),!this._next&&yo!==this&&(yo?yo._next=this:Hd=this,yo=this),this._call=e,this._time=s,Lm()},stop:function(){this._call&&(this._call=null,this._time=1/0,Lm())}};function lw(e,n,s){var l=new Ud;return l.restart(e,n,s),l}function t6(){wx(),++oi;for(var e=Hd,n;e;)(n=hl-e._time)>=0&&e._call.call(void 0,n),e=e._next;--oi}function Gy(){hl=(Pd=Ro.now())+ru,oi=bo=0;try{t6()}finally{oi=0,r6(),hl=0}}function n6(){var e=Ro.now(),n=e-Pd;n>sw&&(ru-=n,Pd=e)}function r6(){for(var e,n=Hd,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:Hd=s);yo=e,Lm(l)}function Lm(e){if(!oi){bo&&(bo=clearTimeout(bo));var n=e-hl;n>24?(e<1/0&&(bo=setTimeout(Gy,e-Ro.now()-ru)),ho&&(ho=clearInterval(ho))):(ho||(Pd=Ro.now(),ho=setInterval(n6,sw)),oi=1,aw(Gy))}}function Xy(e,n,s){var l=new Ud;return n=n==null?0:+n,l.restart(o=>{l.stop(),e(o+n)},n,s),l}var s6=tu("start","end","cancel","interrupt"),a6=[],iw=0,Ky=1,Im=2,Nd=3,Zy=4,zm=5,kd=6;function su(e,n,s,l,o,d){var c=e.__transition;if(!c)e.__transition={};else if(s in c)return;l6(e,s,{name:n,index:l,group:o,on:s6,tween:a6,time:d.time,delay:d.delay,duration:d.duration,ease:d.ease,timer:null,state:iw})}function Nx(e,n){var s=ps(e,n);if(s.state>iw)throw new Error("too late; already scheduled");return s}function Ms(e,n){var s=ps(e,n);if(s.state>Nd)throw new Error("too late; already running");return s}function ps(e,n){var s=e.__transition;if(!s||!(s=s[n]))throw new Error("transition not found");return s}function l6(e,n,s){var l=e.__transition,o;l[n]=s,s.timer=lw(d,0,s.time);function d(f){s.state=Ky,s.timer.restart(c,s.delay,s.time),s.delay<=f&&c(f-s.delay)}function c(f){var p,x,g,y;if(s.state!==Ky)return m();for(p in l)if(y=l[p],y.name===s.name){if(y.state===Nd)return Xy(c);y.state===Zy?(y.state=kd,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete l[p]):+p<n&&(y.state=kd,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete l[p])}if(Xy(function(){s.state===Nd&&(s.state=Zy,s.timer.restart(h,s.delay,s.time),h(f))}),s.state=Im,s.on.call("start",e,e.__data__,s.index,s.group),s.state===Im){for(s.state=Nd,o=new Array(g=s.tween.length),p=0,x=-1;p<g;++p)(y=s.tween[p].value.call(e,e.__data__,s.index,s.group))&&(o[++x]=y);o.length=x+1}}function h(f){for(var p=f<s.duration?s.ease.call(null,f/s.duration):(s.timer.restart(m),s.state=zm,1),x=-1,g=o.length;++x<g;)o[x].call(e,p);s.state===zm&&(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>Im&&l.state<zm,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 i6(e){return this.each(function(){Sd(this,e)})}function o6(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 c6(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 d6(e,n){var s=this._id;if(e+="",arguments.length<2){for(var l=ps(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?o6:c6)(s,e,n))}function kx(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 ps(o,l).value[n]}}function ow(e,n){var s;return(typeof n=="number"?Es:n instanceof fl?Bd:(s=fl(n))?(n=s,Bd):tw)(e,n)}function u6(e){return function(){this.removeAttribute(e)}}function f6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function h6(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 m6(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 x6(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 g6(e,n){var s=nu(e),l=s==="transform"?ZM:ow;return this.attrTween(e,typeof n=="function"?(s.local?p6:x6)(s,l,kx(this,"attr."+e,n)):n==null?(s.local?f6:u6)(s):(s.local?m6:h6)(s,l,n))}function b6(e,n){return function(s){this.setAttribute(e,n.call(this,s))}}function y6(e,n){return function(s){this.setAttributeNS(e.space,e.local,n.call(this,s))}}function v6(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 j6(e,n){var s,l;function o(){var d=n.apply(this,arguments);return d!==l&&(s=(l=d)&&b6(e,d)),s}return o._value=n,o}function w6(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=nu(e);return this.tween(s,(l.local?v6:j6)(l,n))}function N6(e,n){return function(){Nx(this,e).delay=+n.apply(this,arguments)}}function k6(e,n){return n=+n,function(){Nx(this,e).delay=n}}function S6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?N6:k6)(n,e)):ps(this.node(),n).delay}function C6(e,n){return function(){Ms(this,e).duration=+n.apply(this,arguments)}}function E6(e,n){return n=+n,function(){Ms(this,e).duration=n}}function T6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?C6:E6)(n,e)):ps(this.node(),n).duration}function _6(e,n){if(typeof n!="function")throw new Error;return function(){Ms(this,e).ease=n}}function A6(e){var n=this._id;return arguments.length?this.each(_6(n,e)):ps(this.node(),n).ease}function M6(e,n){return function(){var s=n.apply(this,arguments);if(typeof s!="function")throw new Error;Ms(this,e).ease=s}}function O6(e){if(typeof e!="function")throw new Error;return this.each(M6(this._id,e))}function R6(e){typeof e!="function"&&(e=Bj(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 ea(l,this._parents,this._name,this._id)}function D6(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],p=m.length,x=c[h]=new Array(p),g,y=0;y<p;++y)(g=m[y]||f[y])&&(x[y]=g);for(;h<l;++h)c[h]=n[h];return new ea(c,this._parents,this._name,this._id)}function L6(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 I6(e,n,s){var l,o,d=L6(n)?Nx:Ms;return function(){var c=d(this,e),h=c.on;h!==l&&(o=(l=h).copy()).on(n,s),c.on=o}}function z6(e,n){var s=this._id;return arguments.length<2?ps(this.node(),s).on.on(e):this.each(I6(s,e,n))}function $6(e){return function(){var n=this.parentNode;for(var s in this.__transition)if(+s!==e)return;n&&n.removeChild(this)}}function B6(){return this.on("end.remove",$6(this._id))}function H6(e){var n=this._name,s=this._id;typeof e!="function"&&(e=bx(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),p,x,g=0;g<m;++g)(p=h[g])&&(x=e.call(p,p.__data__,g,h))&&("__data__"in p&&(x.__data__=p.__data__),f[g]=x,su(f[g],n,s,g,f,ps(p,s)));return new ea(d,this._parents,n,s)}function P6(e){var n=this._name,s=this._id;typeof e!="function"&&(e=$j(e));for(var l=this._groups,o=l.length,d=[],c=[],h=0;h<o;++h)for(var m=l[h],f=m.length,p,x=0;x<f;++x)if(p=m[x]){for(var g=e.call(p,p.__data__,x,m),y,w=ps(p,s),N=0,C=g.length;N<C;++N)(y=g[N])&&su(y,n,s,N,g,w);d.push(g),c.push(p)}return new ea(d,c,n,s)}var U6=Fo.prototype.constructor;function q6(){return new U6(this._groups,this._parents)}function V6(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 cw(e){return function(){this.style.removeProperty(e)}}function F6(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 Y6(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 G6(e,n){var s,l,o,d="style."+n,c="end."+d,h;return function(){var m=Ms(this,e),f=m.on,p=m.value[d]==null?h||(h=cw(n)):void 0;(f!==s||o!==p)&&(l=(s=f).copy()).on(c,o=p),m.on=l}}function X6(e,n,s){var l=(e+="")=="transform"?KM:ow;return n==null?this.styleTween(e,V6(e,l)).on("end.style."+e,cw(e)):typeof n=="function"?this.styleTween(e,Y6(e,l,kx(this,"style."+e,n))).each(G6(this._id,e)):this.styleTween(e,F6(e,l,n),s).on("end.style."+e,null)}function K6(e,n,s){return function(l){this.style.setProperty(e,n.call(this,l),s)}}function Z6(e,n,s){var l,o;function d(){var c=n.apply(this,arguments);return c!==o&&(l=(o=c)&&K6(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,Z6(e,n,s??""))}function W6(e){return function(){this.textContent=e}}function J6(e){return function(){var n=e(this);this.textContent=n??""}}function eO(e){return this.tween("text",typeof e=="function"?J6(kx(this,"text",e)):W6(e==null?"":e+""))}function tO(e){return function(n){this.textContent=e.call(this,n)}}function nO(e){var n,s;function l(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&tO(o)),n}return l._value=e,l}function rO(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,nO(e))}function sO(){for(var e=this._name,n=this._id,s=dw(),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 p=ps(m,n);su(m,e,s,f,c,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new ea(l,this._parents,e,s)}function aO(){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),p=f.on;p!==e&&(n=(e=p).copy(),n._.cancel.push(h),n._.interrupt.push(h),n._.end.push(m)),f.on=n}),o===0&&d()})}var lO=0;function ea(e,n,s,l){this._groups=e,this._parents=n,this._name=s,this._id=l}function dw(){return++lO}var Ks=Fo.prototype;ea.prototype={constructor:ea,select:H6,selectAll:P6,selectChild:Ks.selectChild,selectChildren:Ks.selectChildren,filter:R6,merge:D6,selection:q6,transition:sO,call:Ks.call,nodes:Ks.nodes,node:Ks.node,size:Ks.size,empty:Ks.empty,each:Ks.each,on:z6,attr:g6,attrTween:w6,style:X6,styleTween:Q6,text:eO,textTween:rO,remove:B6,tween:d6,delay:S6,duration:T6,ease:A6,easeVarying:O6,end:aO,[Symbol.iterator]:Ks[Symbol.iterator]};function iO(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var oO={time:null,delay:0,duration:250,ease:iO};function cO(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 dO(e){var n,s;e instanceof ea?(n=e._id,e=e._name):(n=dw(),(s=oO).time=wx(),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])&&su(m,e,n,f,c,s||cO(m,n));return new ea(l,this._parents,e,n)}Fo.prototype.interrupt=i6;Fo.prototype.transition=dO;const hd=e=>()=>e;function uO(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 Js(e,n,s){this.k=e,this.x=n,this.y=s}Js.prototype={constructor:Js,scale:function(e){return e===1?this:new Js(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Js(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 au=new Js(1,0,0);uw.prototype=Js.prototype;function uw(e){for(;!e.__zoom;)if(!(e=e.parentNode))return au;return e.__zoom}function Yh(e){e.stopImmediatePropagation()}function mo(e){e.preventDefault(),e.stopImmediatePropagation()}function fO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hO(){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 Qy(){return this.__zoom||au}function mO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function xO(){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 fw(){var e=fO,n=hO,s=pO,l=mO,o=xO,d=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,m=wd,f=tu("start","zoom","end"),p,x,g,y=500,w=150,N=0,C=10;function A(T){T.property("__zoom",Qy).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",U).filter(o).on("touchstart.zoom",G).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}A.transform=function(T,L,_,P){var V=T.selection?T.selection():T;V.property("__zoom",Qy),T!==V?R(T,L,_,P):V.interrupt().each(function(){D(this,arguments).event(P).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},A.scaleBy=function(T,L,_,P){A.scaleTo(T,function(){var V=this.__zoom.k,W=typeof L=="function"?L.apply(this,arguments):L;return V*W},_,P)},A.scaleTo=function(T,L,_,P){A.transform(T,function(){var V=n.apply(this,arguments),W=this.__zoom,B=_==null?S(V):typeof _=="function"?_.apply(this,arguments):_,F=W.invert(B),X=typeof L=="function"?L.apply(this,arguments):L;return s(k(O(W,X),B,F),V,c)},_,P)},A.translateBy=function(T,L,_,P){A.transform(T,function(){return s(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof _=="function"?_.apply(this,arguments):_),n.apply(this,arguments),c)},null,P)},A.translateTo=function(T,L,_,P,V){A.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(au.translate(F[0],F[1]).scale(B.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof _=="function"?-_.apply(this,arguments):-_),W,c)},P,V)};function O(T,L){return L=Math.max(d[0],Math.min(d[1],L)),L===T.k?T:new Js(L,T.x,T.y)}function k(T,L,_){var P=L[0]-_[0]*T.k,V=L[1]-_[1]*T.k;return P===T.x&&V===T.y?T:new Js(T.k,P,V)}function S(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function R(T,L,_,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 V=this,W=arguments,B=D(V,W).event(P),F=n.apply(V,W),X=_==null?S(F):typeof _=="function"?_.apply(V,W):_,I=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),M=V.__zoom,H=typeof L=="function"?L.apply(V,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 Js(ae,X[0]-ne[0]*ae,X[1]-ne[1]*ae)}B.zoom(null,ee)}})}function D(T,L,_){return!_&&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=Br(this.that).datum();f.call(T,this.that,new uO(T,{sourceEvent:this.sourceEvent,target:A,transform:this.that.__zoom,dispatch:f}),L)}};function z(T,...L){if(!e.apply(this,arguments))return;var _=D(this,L).event(T),P=this.__zoom,V=Math.max(d[0],Math.min(d[1],P.k*Math.pow(2,l.apply(this,arguments)))),W=cs(T);if(_.wheel)(_.mouse[0][0]!==W[0]||_.mouse[0][1]!==W[1])&&(_.mouse[1]=P.invert(_.mouse[0]=W)),clearTimeout(_.wheel);else{if(P.k===V)return;_.mouse=[W,P.invert(W)],Sd(this),_.start()}mo(T),_.wheel=setTimeout(B,w),_.zoom("mouse",s(k(O(P,V),_.mouse[0],_.mouse[1]),_.extent,c));function B(){_.wheel=null,_.end()}}function K(T,...L){if(g||!e.apply(this,arguments))return;var _=T.currentTarget,P=D(this,L,!0).event(T),V=Br(T.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",I,!0),W=cs(T,_),B=T.clientX,F=T.clientY;Kj(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,_),P.mouse[1]),P.extent,c))}function I(M){V.on("mousemove.zoom mouseup.zoom",null),Zj(M.view,P.moved),mo(M),P.event(M).end()}}function U(T,...L){if(e.apply(this,arguments)){var _=this.__zoom,P=cs(T.changedTouches?T.changedTouches[0]:T,this),V=_.invert(P),W=_.k*(T.shiftKey?.5:2),B=s(k(O(_,W),P,V),n.apply(this,L),c);mo(T),h>0?Br(this).transition().duration(h).call(R,B,P,T):Br(this).call(A.transform,B,P,T)}}function G(T,...L){if(e.apply(this,arguments)){var _=T.touches,P=_.length,V=D(this,L,T.changedTouches.length===P).event(T),W,B,F,X;for(Yh(T),B=0;B<P;++B)F=_[B],X=cs(F,this),X=[X,this.__zoom.invert(X),F.identifier],V.touch0?!V.touch1&&V.touch0[2]!==X[2]&&(V.touch1=X,V.taps=0):(V.touch0=X,W=!0,V.taps=1+!!p);p&&(p=clearTimeout(p)),W&&(V.taps<2&&(x=X[0],p=setTimeout(function(){p=null},y)),Sd(this),V.start())}}function q(T,...L){if(this.__zooming){var _=D(this,L).event(T),P=T.changedTouches,V=P.length,W,B,F,X;for(mo(T),W=0;W<V;++W)B=P[W],F=cs(B,this),_.touch0&&_.touch0[2]===B.identifier?_.touch0[0]=F:_.touch1&&_.touch1[2]===B.identifier&&(_.touch1[0]=F);if(B=_.that.__zoom,_.touch1){var I=_.touch0[0],M=_.touch0[1],H=_.touch1[0],Z=_.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(_.touch0)F=_.touch0[0],X=_.touch0[1];else return;_.zoom("touch",s(k(B,F,X),_.extent,c))}}function E(T,...L){if(this.__zooming){var _=D(this,L).event(T),P=T.changedTouches,V=P.length,W,B;for(Yh(T),g&&clearTimeout(g),g=setTimeout(function(){g=null},y),W=0;W<V;++W)B=P[W],_.touch0&&_.touch0[2]===B.identifier?delete _.touch0:_.touch1&&_.touch1[2]===B.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(B=cs(B,this),Math.hypot(x[0]-B[0],x[1]-B[1])<C)){var F=Br(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return A.wheelDelta=function(T){return arguments.length?(l=typeof T=="function"?T:hd(+T),A):l},A.filter=function(T){return arguments.length?(e=typeof T=="function"?T:hd(!!T),A):e},A.touchable=function(T){return arguments.length?(o=typeof T=="function"?T:hd(!!T),A):o},A.extent=function(T){return arguments.length?(n=typeof T=="function"?T:hd([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),A):n},A.scaleExtent=function(T){return arguments.length?(d[0]=+T[0],d[1]=+T[1],A):[d[0],d[1]]},A.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],A):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},A.constrain=function(T){return arguments.length?(s=T,A):s},A.duration=function(T){return arguments.length?(h=+T,A):h},A.interpolate=function(T){return arguments.length?(m=T,A):m},A.on=function(){var T=f.on.apply(f,arguments);return T===f?A:T},A.clickDistance=function(T){return arguments.length?(N=(T=+T)*T,A):Math.sqrt(N)},A.tapDistance=function(T){return arguments.length?(C=+T,A):C},A}const _s={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]],hw=["Enter"," ","Escape"],mw={"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 xw={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Da;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Da||(Da={}));var di;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(di||(di={}));var mt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(mt||(mt={}));const Wy={[mt.Left]:mt.Right,[mt.Right]:mt.Left,[mt.Top]:mt.Bottom,[mt.Bottom]:mt.Top};function pw(e){return e===null?null:e?"valid":"invalid"}const gw=e=>"id"in e&&"source"in e&&"target"in e,gO=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Sx=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Go=(e,n=[0,0])=>{const{width:s,height:l}=na(e),o=e.origin??n,d=s*o[0],c=l*o[1];return{x:e.position.x-d,y:e.position.y-c}},bO=(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):Sx(o)?o:n.nodeLookup.get(o.id));const h=c?qd(c,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return lu(l,h)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return iu(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=lu(s,qd(o)),l=!0)}),l?iu(s):{x:0,y:0,width:0,height:0}},Cx=(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:p,selectable:x=!0,hidden:g=!1}=f;if(c&&!x||g)continue;const y=p.width??f.width??f.initialWidth??null,w=p.height??f.height??f.initialHeight??null,N=Io(h,fi(f)),C=(y??0)*(w??0),A=d&&N>0;(!f.internals.handleBounds||A||N>=C||f.dragging)&&m.push(f)}return m},yO=(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 vO(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 jO({nodes:e,width:n,height:s,panZoom:l,minZoom:o,maxZoom:d},c){if(e.size===0)return Promise.resolve(!0);const h=vO(e,c),m=Xo(h),f=Ex(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 bw({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},p=c.origin??l;let x=c.extent||o;if(c.extent==="parent"&&!c.expandParent)if(!h)d?.("005",_s.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 g=hi(x)?ml(n,x,c.measured):n;return(c.measured.width===void 0||c.measured.height===void 0)&&d?.("015",_s.error015()),{position:{x:g.x-m+(c.measured.width??0)*p[0],y:g.y-f+(c.measured.height??0)*p[1]},positionAbsolute:g}}async function wO({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:l,onBeforeDelete:o}){const d=new Set(e.map(g=>g.id)),c=[];for(const g of s){if(g.deletable===!1)continue;const y=d.has(g.id),w=!y&&g.parentId&&c.find(N=>N.id===g.parentId);(y||w)&&c.push(g)}const h=new Set(n.map(g=>g.id)),m=l.filter(g=>g.deletable!==!1),p=yO(c,m);for(const g of m)h.has(g.id)&&!p.find(w=>w.id===g.id)&&p.push(g);if(!o)return{edges:p,nodes:c};const x=await o({nodes:c,edges:p});return typeof x=="boolean"?x?{edges:p,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 yw(e,n,s){const{width:l,height:o}=na(s),{x:d,y:c}=s.internals.positionAbsolute;return ml(e,[[d,c],[d+l,c+o]],n)}const Jy=(e,n,s)=>e<n?ui(Math.abs(e-n),1,n)/n:e>s?-ui(Math.abs(e-s),1,n)/n:0,vw=(e,n,s=15,l=40)=>{const o=Jy(e.x,l,n.width-l)*s,d=Jy(e.y,l,n.height-l)*s;return[o,d]},lu=(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)}),$m=({x:e,y:n,width:s,height:l})=>({x:e,y:n,x2:e+s,y2:n+l}),iu=({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}=Sx(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}},qd=(e,n=[0,0])=>{const{x:s,y:l}=Sx(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)}},jw=(e,n)=>iu(lu($m(e),$m(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)},ev=e=>us(e.width)&&us(e.height)&&us(e.x)&&us(e.y),us=e=>!isNaN(e)&&isFinite(e),NO=(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},Vd=({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 kO(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 SO(e,n,s,l,o,d){const{x:c,y:h}=Vd(e,[n,s,l]),{x:m,y:f}=Vd({x:e.x+e.width,y:e.y+e.height},[n,s,l]),p=o-m,x=d-f;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(p),bottom:Math.floor(x)}}const Ex=(e,n,s,l,o,d)=>{const c=kO(d,n,s),h=(n-c.x)/e.width,m=(s-c.y)/e.height,f=Math.min(h,m),p=ui(f,l,o),x=e.x+e.width/2,g=e.y+e.height/2,y=n/2-x*p,w=s/2-g*p,N=SO(e,y,w,p,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:p}},zo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function hi(e){return e!=null&&e!=="parent"}function na(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ww(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Nw(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 tv(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function CO(){let e,n;return{promise:new Promise((l,o)=>{e=l,n=o}),resolve:e,reject:n}}function EO(e){return{...mw,...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 Tx=e=>({width:e.offsetWidth,height:e.offsetHeight}),kw=e=>e?.getRootNode?.()||window?.document,TO=["INPUT","SELECT","TEXTAREA"];function Sw(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:TO.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const Cw=e=>"clientX"in e,fs=(e,n)=>{const s=Cw(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)}},nv=(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,...Tx(c)}})};function Ew({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,p=Math.abs(m-e),x=Math.abs(f-n);return[m,f,p,x]}function md(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function rv({pos:e,x1:n,y1:s,x2:l,y2:o,c:d}){switch(e){case mt.Left:return[n-md(n-l,d),s];case mt.Right:return[n+md(l-n,d),s];case mt.Top:return[n,s-md(s-o,d)];case mt.Bottom:return[n,s+md(o-s,d)]}}function Tw({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:l,targetY:o,targetPosition:d=mt.Top,curvature:c=.25}){const[h,m]=rv({pos:s,x1:e,y1:n,x2:l,y2:o,c}),[f,p]=rv({pos:d,x1:l,y1:o,x2:e,y2:n,c}),[x,g,y,w]=Ew({sourceX:e,sourceY:n,targetX:l,targetY:o,sourceControlX:h,sourceControlY:m,targetControlX:f,targetControlY:p});return[`M${e},${n} C${h},${m} ${f},${p} ${l},${o}`,x,g,y,w]}function _w({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 AO({sourceNode:e,targetNode:n,width:s,height:l,transform:o}){const d=lu(qd(e),qd(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,iu(d))>0}const MO=({source:e,sourceHandle:n,target:s,targetHandle:l})=>`xy-edge__${e}${n||""}-${s}${l||""}`,OO=(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)),RO=(e,n,s={})=>{if(!e.source||!e.target)return n;const l=s.getEdgeId||MO;let o;return gw(e)?o={...e}:o={...e,id:l(e)},OO(o,n)?n:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,n.concat(o))};function Aw({sourceX:e,sourceY:n,targetX:s,targetY:l}){const[o,d,c,h]=_w({sourceX:e,sourceY:n,targetX:s,targetY:l});return[`M ${e},${n}L ${s},${l}`,o,d,c,h]}const sv={[mt.Left]:{x:-1,y:0},[mt.Right]:{x:1,y:0},[mt.Top]:{x:0,y:-1},[mt.Bottom]:{x:0,y:1}},DO=({source:e,sourcePosition:n=mt.Bottom,target:s})=>n===mt.Left||n===mt.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},av=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function LO({source:e,sourcePosition:n=mt.Bottom,target:s,targetPosition:l=mt.Top,center:o,offset:d,stepPosition:c}){const h=sv[n],m=sv[l],f={x:e.x+h.x*d,y:e.y+h.y*d},p={x:s.x+m.x*d,y:s.y+m.y*d},x=DO({source:f,sourcePosition:n,target:p}),g=x.x!==0?"x":"y",y=x[g];let w=[],N,C;const A={x:0,y:0},O={x:0,y:0},[,,k,S]=_w({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(h[g]*m[g]===-1){g==="x"?(N=o.x??f.x+(p.x-f.x)*c,C=o.y??(f.y+p.y)/2):(N=o.x??(f.x+p.x)/2,C=o.y??f.y+(p.y-f.y)*c);const D=[{x:N,y:f.y},{x:N,y:p.y}],Y=[{x:f.x,y:C},{x:p.x,y:C}];h[g]===y?w=g==="x"?D:Y:w=g==="x"?Y:D}else{const D=[{x:f.x,y:p.y}],Y=[{x:p.x,y:f.y}];if(g==="x"?w=h.x===y?Y:D:w=h.y===y?D:Y,n===l){const q=Math.abs(e[g]-s[g]);if(q<=d){const E=Math.min(d-1,d-q);h[g]===y?A[g]=(f[g]>e[g]?-1:1)*E:O[g]=(p[g]>s[g]?-1:1)*E}}if(n!==l){const q=g==="x"?"y":"x",E=h[g]===m[q],T=f[q]>p[q],L=f[q]<p[q];(h[g]===1&&(!E&&T||E&&L)||h[g]!==1&&(!E&&L||E&&T))&&(w=g==="x"?D:Y)}const z={x:f.x+A.x,y:f.y+A.y},K={x:p.x+O.x,y:p.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+A.x,y:f.y+A.y},...w,{x:p.x+O.x,y:p.y+O.y},s],N,C,k,S]}function IO(e,n,s,l){const o=Math.min(av(e,n)/2,av(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,p=e.y<s.y?1:-1;return`L ${d+o*f},${c}Q ${d},${c} ${d},${c+o*p}`}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 Bm({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:l,targetY:o,targetPosition:d=mt.Top,borderRadius:c=5,centerX:h,centerY:m,offset:f=20,stepPosition:p=.5}){const[x,g,y,w,N]=LO({source:{x:e,y:n},sourcePosition:s,target:{x:l,y:o},targetPosition:d,center:{x:h,y:m},offset:f,stepPosition:p});return[x.reduce((A,O,k)=>{let S="";return k>0&&k<x.length-1?S=IO(x[k-1],O,x[k+1],c):S=`${k===0?"M":"L"}${O.x} ${O.y}`,A+=S,A},""),g,y,w,N]}function lv(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zO(e){const{sourceNode:n,targetNode:s}=e;if(!lv(n)||!lv(s))return null;const l=n.internals.handleBounds||iv(n.handles),o=s.internals.handleBounds||iv(s.handles),d=ov(l?.source??[],e.sourceHandle),c=ov(e.connectionMode===ci.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!d||!c)return e.onError?.("008",_s.error008(d?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const h=d?.position||mt.Bottom,m=c?.position||mt.Top,f=xl(n,d,h),p=xl(s,c,m);return{sourceX:f.x,sourceY:f.y,targetX:p.x,targetY:p.y,sourcePosition:h,targetPosition:m}}function iv(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=mt.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??na(e);if(l)return{x:o+c/2,y:d+h/2};switch(n?.position??s){case mt.Top:return{x:o+c/2,y:d};case mt.Right:return{x:o+c,y:d+h/2};case mt.Bottom:return{x:o+c/2,y:d+h};case mt.Left:return{x:o,y:d+h/2}}}function ov(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function Hm(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function $O(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=Hm(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 Mw=1e3,BO=10,_x={nodeOrigin:[0,0],nodeExtent:Do,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},HO={..._x,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 PO(e,n,s){const l=Ax(_x,s);for(const o of e.values())if(o.parentId)Ox(o,e,n,l);else{const d=Go(o,l.nodeOrigin),c=hi(o.extent)?o.extent:l.nodeExtent,h=ml(d,c,na(o));o.internals.positionAbsolute=h}}function UO(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 Mx(e){return e==="manual"}function Pm(e,n,s,l={}){const o=Ax(HO,l),d={i:0},c=new Map(n),h=o?.elevateNodesOnSelect&&!Mx(o.zIndexMode)?Mw:0;let m=e.length>0;n.clear(),s.clear();for(const f of e){let p=c.get(f.id);if(o.checkEquality&&f===p?.internals.userNode)n.set(f.id,p);else{const x=Go(f,o.nodeOrigin),g=hi(f.extent)?f.extent:o.nodeExtent,y=ml(x,g,na(f));p={...o.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:y,handleBounds:UO(f,p),z:Ow(f,h,o.zIndexMode),userNode:f}},n.set(f.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(m=!1),f.parentId&&Ox(p,n,s,l,d)}return m}function qO(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 Ox(e,n,s,l,o){const{elevateNodesOnSelect:d,nodeOrigin:c,nodeExtent:h,zIndexMode:m}=Ax(_x,l),f=e.parentId,p=n.get(f);if(!p){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}qO(e,s),o&&!p.parentId&&p.internals.rootParentIndex===void 0&&m==="auto"&&(p.internals.rootParentIndex=++o.i,p.internals.z=p.internals.z+o.i*BO),o&&p.internals.rootParentIndex!==void 0&&(o.i=p.internals.rootParentIndex);const x=d&&!Mx(m)?Mw:0,{x:g,y,z:w}=VO(e,p,c,h,x,m),{positionAbsolute:N}=e.internals,C=g!==N.x||y!==N.y;(C||w!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:g,y}:N,z:w}})}function Ow(e,n,s){const l=us(e.zIndex)?e.zIndex:0;return Mx(s)?l:l+(e.selected?n:0)}function VO(e,n,s,l,o,d){const{x:c,y:h}=n.internals.positionAbsolute,m=na(e),f=Go(e,s),p=hi(e.extent)?ml(f,e.extent,m):f;let x=ml({x:c+p.x,y:h+p.y},l,m);e.extent==="parent"&&(x=yw(x,m,n));const g=Ow(e,o,d),y=n.internals.z??0;return{x:x.x,y:x.y,z:y>=g?y+1:g}}function Rx(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=jw(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,p=na(h),x=h.origin??l,g=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(p.width,Math.round(c.width)),N=Math.max(p.height,Math.round(c.height)),C=(w-p.width)*x[0],A=(N-p.height)*x[1];(g>0||y>0||C||A)&&(o.push({id:m,type:"position",position:{x:h.position.x-g+C,y:h.position.y-y+A}}),s.get(m)?.forEach(O=>{e.some(k=>k.id===O.id)||o.push({id:O.id,type:"position",position:{x:O.position.x+g,y:O.position.y+y}})})),(p.width<c.width||p.height<c.height||g||y)&&o.push({id:m,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?x[0]*g-C:0),height:N+(y?x[1]*y-A:0)}})}),o}function FO(e,n,s,l,o,d,c){const h=l?.querySelector(".xyflow__viewport");let m=!1;if(!h)return{changes:[],updatedInternals:m};const f=[],p=window.getComputedStyle(h),{m22:x}=new window.DOMMatrixReadOnly(p.transform),g=[];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=Tx(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=yw(S,N,n.get(w.parentId)):k&&(S=ml(S,k,N));const R={...w,measured:N,internals:{...w.internals,positionAbsolute:S,handleBounds:{source:nv("source",y.nodeElement,O,x,w.id),target:nv("target",y.nodeElement,O,x,w.id)}}};n.set(w.id,R),w.parentId&&Ox(R,n,s,{nodeOrigin:o,zIndexMode:c}),m=!0,C&&(f.push({id:w.id,type:"dimensions",dimensions:N}),w.expandParent&&w.parentId&&g.push({id:w.id,parentId:w.parentId,rect:fi(R,o)}))}}if(g.length>0){const y=Rx(g,n,s,o);f.push(...y)}return{changes:f,updatedInternals:m}}async function YO({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 cv(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 Rw(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}`,p=`${d}-${h}--${o}-${c}`;cv("source",m,p,e,o,c),cv("target",m,f,e,d,h),n.set(l.id,l)}}function Dw(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:Dw(s,n):!1}function dv(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 GO(e,n,s,l){const o=new Map;for(const[d,c]of e)if((c.selected||c.id===l)&&(!c.parentId||!Dw(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 XO({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 KO({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},p=null,x=!1,g=null,y=!1,w=!1,N=null;function C({noDragClassName:O,handleSelector:k,domNode:S,isSelectable:R,nodeId:D,nodeClickDistance:Y=0}){g=Br(S);function z({x:q,y:E}){const{nodeLookup:T,nodeExtent:L,snapGrid:_,snapToGrid:P,nodeOrigin:V,onNodeDrag:W,onSelectionDrag:B,onError:F,updateNodePositions:X}=n();d={x:q,y:E};let I=!1;const M=h.size>1,H=M&&L?$m(Xo(h)):null,Z=M&&P?XO({dragItems:h,snapGrid:_,x:q,y:E}):null;for(const[ee,ne]of h){if(!T.has(ee))continue;let ae={x:q-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,_));let fe=null;if(M&&L&&!ne.extent&&H){const{positionAbsolute:ye}=ne.internals,je=ye.x-H.x+L[0][0],Te=ye.x+ne.measured.width-H.x2+L[1][0],ze=ye.y-H.y+L[0][1],Xe=ye.y+ne.measured.height-H.y2+L[1][1];fe=[[je,ze],[Te,Xe]]}const{position:Ne,positionAbsolute:Le}=bw({nodeId:ee,nextPosition:ae,nodeLookup:T,nodeExtent:fe||L,nodeOrigin:V,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(!p)return;const{transform:q,panBy:E,autoPanSpeed:T,autoPanOnNodeDrag:L}=n();if(!L){m=!1,cancelAnimationFrame(c);return}const[_,P]=vw(f,p,T);(_!==0||P!==0)&&(d.x=(d.x??0)-_/q[2],d.y=(d.y??0)-P/q[2],await E({x:_,y:P})&&z(d)),c=requestAnimationFrame(K)}function U(q){const{nodeLookup:E,multiSelectionActive:T,nodesDraggable:L,transform:_,snapGrid:P,snapToGrid:V,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(q.sourceEvent,{transform:_,snapGrid:P,snapToGrid:V,containerBounds:p});if(d=I,h=GO(E,L,I,D),h.size>0&&(s||B||!D&&F)){const[M,H]=Gh({nodeId:D,dragItems:h,nodeLookup:E});s?.(q.sourceEvent,h,M,H),B?.(q.sourceEvent,M,H),D||F?.(q.sourceEvent,H)}}const G=Qj().clickDistance(Y).on("start",q=>{const{domNode:E,nodeDragThreshold:T,transform:L,snapGrid:_,snapToGrid:P}=n();p=E?.getBoundingClientRect()||null,y=!1,w=!1,N=q.sourceEvent,T===0&&U(q),d=So(q.sourceEvent,{transform:L,snapGrid:_,snapToGrid:P,containerBounds:p}),f=fs(q.sourceEvent,p)}).on("drag",q=>{const{autoPanOnNodeDrag:E,transform:T,snapGrid:L,snapToGrid:_,nodeDragThreshold:P,nodeLookup:V}=n(),W=So(q.sourceEvent,{transform:T,snapGrid:L,snapToGrid:_,containerBounds:p});if(N=q.sourceEvent,(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||D&&!V.has(D))&&(y=!0),!y){if(!m&&E&&x&&(m=!0,K()),!x){const B=fs(q.sourceEvent,p),F=B.x-f.x,X=B.y-f.y;Math.sqrt(F*F+X*X)>P&&U(q)}(d.x!==W.xSnapped||d.y!==W.ySnapped)&&h&&x&&(f=fs(q.sourceEvent,p),z(W))}}).on("end",q=>{if(!(!x||y)&&(m=!1,x=!1,cancelAnimationFrame(c),h.size>0)){const{nodeLookup:E,updateNodePositions:T,onNodeDragStop:L,onSelectionDragStop:_}=n();if(w&&(T(h,!1),w=!1),o||L||!D&&_){const[P,V]=Gh({nodeId:D,dragItems:h,nodeLookup:E,dragging:!1});o?.(q.sourceEvent,h,P,V),L?.(q.sourceEvent,P,V),D||_?.(q.sourceEvent,V)}}}).filter(q=>{const E=q.target;return!q.button&&(!O||!dv(E,`.${O}`,S))&&(!k||dv(E,k,S))});g.call(G)}function A(){g?.on(".drag",null)}return{update:C,destroy:A}}function ZO(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 WO(e,n,s,l){let o=[],d=1/0;const c=ZO(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:p,y:x}=xl(h,f,f.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(x-e.y,2));g>n||(g<d?(o=[{...f,x:p,y:x}],d=g):g===d&&o.push({...f,x:p,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 Lw(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 Iw(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function JO(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const zw=()=>!0;function eR(e,{connectionMode:n,connectionRadius:s,handleId:l,nodeId:o,edgeUpdaterType:d,isTarget:c,domNode:h,nodeLookup:m,lib:f,autoPanOnConnect:p,flowId:x,panBy:g,cancelConnection:y,onConnectStart:w,onConnect:N,onConnectEnd:C,isValidConnection:A=zw,onReconnectEnd:O,updateConnection:k,getTransform:S,getFromHandle:R,autoPanSpeed:D,dragThreshold:Y=1,handleDomNode:z}){const K=kw(e.target);let U=0,G;const{x:q,y:E}=fs(e),T=Iw(d,z),L=h?.getBoundingClientRect();let _=!1;if(!L||!T)return;const P=Lw(o,T,l,m,n);if(!P)return;let V=fs(e,L),W=!1,B=null,F=!1,X=null;function I(){if(!p||!L)return;const[Ne,Le]=vw(V,L,D);g({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,mt.Left,!0),fromHandle:M,fromPosition:M.position,fromNode:H,to:V,toHandle:null,toPosition:Wy[M.position],toNode:null,pointer:V};function ne(){_=!0,k(ee),w?.(e,{nodeId:o,handleId:l,handleType:T})}Y===0&&ne();function ae(Ne){if(!_){const{x:Xe,y:nt}=fs(Ne),tt=Xe-q,Mt=nt-E;if(!(tt*tt+Mt*Mt>Y*Y))return;ne()}if(!R()||!M){fe(Ne);return}const Le=S();V=fs(Ne,L),G=WO(Zo(V,Le,!1,[1,1]),s,m,M),W||(I(),W=!0);const ye=$w(Ne,{handle:G,connectionMode:n,fromNodeId:o,fromHandleId:l,fromType:c?"target":"source",isValidConnection:A,doc:K,lib:f,flowId:x,nodeLookup:m});X=ye.handleDomNode,B=ye.connection,F=JO(!!G,ye.isValid);const je=m.get(o),Te=je?xl(je,M,mt.Left,!0):ee.from,ze={...ee,from:Te,isValid:F,to:ye.toHandle&&F?Vd({x:ye.toHandle.x,y:ye.toHandle.y},Le):V,toHandle:ye.toHandle,toPosition:F&&ye.toHandle?ye.toHandle.position:Wy[M.position],toNode:ye.toHandle?m.get(ye.toHandle.nodeId):null,pointer:V};k(ze),ee=ze}function fe(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(_){(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",fe),K.removeEventListener("touchmove",ae),K.removeEventListener("touchend",fe)}}K.addEventListener("mousemove",ae),K.addEventListener("mouseup",fe),K.addEventListener("touchmove",ae),K.addEventListener("touchend",fe)}function $w(e,{handle:n,connectionMode:s,fromNodeId:l,fromHandleId:o,fromType:d,doc:c,lib:h,flowId:m,isValidConnection:f=zw,nodeLookup:p}){const x=d==="target",g=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:g,A={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const O=Iw(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 A;const Y={source:x?k:l,sourceHandle:x?S:o,target:x?l:k,targetHandle:x?o:S};A.connection=Y;const K=R&&D&&(s===ci.Strict?x&&O==="source"||!x&&O==="target":k!==l||S!==o);A.isValid=K&&f(Y),A.toHandle=Lw(k,O,S,p,s,!0)}return A}const Um={onPointerDown:eR,isValid:$w};function tR({domNode:e,panZoom:n,getTransform:s,getViewScale:l}){const o=Br(e);function d({translateExtent:h,width:m,height:f,zoomStep:p=1,pannable:x=!0,zoomable:g=!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)*p,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])},A=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=fw().on("start",C).on("zoom",x?A:null).on("zoom.wheel",g?w:null);o.call(O,{})}function c(){o.on("zoom",null)}return{update:d,destroy:c,pointer:cs}}const ou=e=>({x:e.x,y:e.y,zoom:e.k}),Xh=({x:e,y:n,zoom:s})=>au.translate(e,n).scale(s),ti=(e,n)=>e.target.closest(`.${n}`),Bw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),nR=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Kh=(e,n=0,s=nR,l=()=>{})=>{const o=typeof n=="number"&&n>0;return o||l(),o?e.transition().duration(n).ease(s).on("end",l):e},Hw=e=>{const n=e.ctrlKey&&zo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function rR({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:l,panOnScrollMode:o,panOnScrollSpeed:d,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:m,onPanZoomEnd:f}){return p=>{if(ti(p,n))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const x=s.property("__zoom").k||1;if(p.ctrlKey&&c){const C=cs(p),A=Hw(p),O=x*Math.pow(2,A);l.scaleTo(s,O,C,p);return}const g=p.deltaMode===1?20:1;let y=o===cl.Vertical?0:p.deltaX*g,w=o===cl.Horizontal?0:p.deltaY*g;!zo()&&p.shiftKey&&o!==cl.Vertical&&(y=p.deltaY*g,w=0),l.translateBy(s,-(y/x)*d,-(w/x)*d,{internal:!0});const N=ou(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(m?.(p,N),e.panScrollTimeout=setTimeout(()=>{f?.(p,N),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,h?.(p,N))}}function sR({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 aR({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return l=>{if(l.sourceEvent?.internal)return;const o=ou(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 lR({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:l,onPanZoom:o}){return d=>{e.usedRightMouseButton=!!(s&&Bw(n,e.mouseButton??0)),d.sourceEvent?.sync||l([d.transform.x,d.transform.y,d.transform.k]),o&&!d.sourceEvent?.internal&&o?.(d.sourceEvent,ou(d.transform))}}function iR({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:l,onPanZoomEnd:o,onPaneContextMenu:d}){return c=>{if(!c.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,d&&Bw(n,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&d(c.sourceEvent),e.usedRightMouseButton=!1,l(!1),o)){const h=ou(c.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(c.sourceEvent,h)},s?150:0)}}}function oR({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:l,panOnScroll:o,zoomOnDoubleClick:d,userSelectionActive:c,noWheelClassName:h,noPanClassName:m,lib:f,connectionInProgress:p}){return x=>{const g=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&&!g&&!o&&!d&&!s||c||p&&!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(!g&&!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 cR({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},p=e.getBoundingClientRect(),x=fw().scaleExtent([n,s]).translateExtent(l),g=Br(e).call(x);O({x:o.x,y:o.y,zoom:ui(o.zoom,n,s)},[[0,0],[p.width,p.height]],l);const y=g.on("wheel.zoom"),w=g.on("dblclick.zoom");x.wheelDelta(Hw);function N(G,q){return g?new Promise(E=>{x?.interpolate(q?.interpolate==="linear"?ko:wd).transform(Kh(g,q?.duration,q?.ease,()=>E(!0)),G)}):Promise.resolve(!1)}function C({noWheelClassName:G,noPanClassName:q,onPaneContextMenu:E,userSelectionActive:T,panOnScroll:L,panOnDrag:_,panOnScrollMode:P,panOnScrollSpeed:V,preventScrolling:W,zoomOnPinch:B,zoomOnScroll:F,zoomOnDoubleClick:X,zoomActivationKeyPressed:I,lib:M,onTransformChange:H,connectionInProgress:Z,paneClickDistance:ee,selectionOnDrag:ne}){T&&!f.isZoomingOrPanning&&A();const ae=L&&!I&&!T;x.clickDistance(ne?1/0:!us(ee)||ee<0?0:ee);const fe=ae?rR({zoomPanValues:f,noWheelClassName:G,d3Selection:g,d3Zoom:x,panOnScrollMode:P,panOnScrollSpeed:V,zoomOnPinch:B,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:h}):sR({noWheelClassName:G,preventScrolling:W,d3ZoomHandler:y});if(g.on("wheel.zoom",fe,{passive:!1}),!T){const Le=aR({zoomPanValues:f,onDraggingChange:m,onPanZoomStart:c});x.on("start",Le);const ye=lR({zoomPanValues:f,panOnDrag:_,onPaneContextMenu:!!E,onPanZoom:d,onTransformChange:H});x.on("zoom",ye);const je=iR({zoomPanValues:f,panOnDrag:_,panOnScroll:L,onPaneContextMenu:E,onPanZoomEnd:h,onDraggingChange:m});x.on("end",je)}const Ne=oR({zoomActivationKeyPressed:I,panOnDrag:_,zoomOnScroll:F,panOnScroll:L,zoomOnDoubleClick:X,zoomOnPinch:B,userSelectionActive:T,noPanClassName:q,noWheelClassName:G,lib:M,connectionInProgress:Z});x.filter(Ne),X?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function A(){x.on("zoom",null)}async function O(G,q,E){const T=Xh(G),L=x?.constrain()(T,q,E);return L&&await N(L),new Promise(_=>_(L))}async function k(G,q){const E=Xh(G);return await N(E,q),new Promise(T=>T(E))}function S(G){if(g){const q=Xh(G),E=g.property("__zoom");(E.k!==G.zoom||E.x!==G.x||E.y!==G.y)&&x?.transform(g,q,null,{sync:!0})}}function R(){const G=g?uw(g.node()):{x:0,y:0,k:1};return{x:G.x,y:G.y,zoom:G.k}}function D(G,q){return g?new Promise(E=>{x?.interpolate(q?.interpolate==="linear"?ko:wd).scaleTo(Kh(g,q?.duration,q?.ease,()=>E(!0)),G)}):Promise.resolve(!1)}function Y(G,q){return g?new Promise(E=>{x?.interpolate(q?.interpolate==="linear"?ko:wd).scaleBy(Kh(g,q?.duration,q?.ease,()=>E(!0)),G)}):Promise.resolve(!1)}function z(G){x?.scaleExtent(G)}function K(G){x?.translateExtent(G)}function U(G){const q=!us(G)||G<0?0:G;x?.clickDistance(q)}return{update:C,destroy:A,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 dR({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 uv(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 Aa(e,n){return Math.max(0,n-e)}function Ma(e,n){return Math.max(0,e-n)}function xd(e,n,s){return Math.max(0,n-e,e-s)}function fv(e,n){return e?!n:n}function uR(e,n,s,l,o,d,c,h){let{affectsX:m,affectsY:f}=n;const{isHorizontal:p,isVertical:x}=n,g=p&&x,{xSnapped:y,ySnapped:w}=s,{minWidth:N,maxWidth:C,minHeight:A,maxHeight:O}=l,{x:k,y:S,width:R,height:D,aspectRatio:Y}=e;let z=Math.floor(p?y-e.pointerX:0),K=Math.floor(x?w-e.pointerY:0);const U=R+(m?-z:z),G=D+(f?-K:K),q=-d[0]*R,E=-d[1]*D;let T=xd(U,N,C),L=xd(G,A,O);if(c){let V=0,W=0;m&&z<0?V=Aa(k+z+q,c[0][0]):!m&&z>0&&(V=Ma(k+U+q,c[1][0])),f&&K<0?W=Aa(S+K+E,c[0][1]):!f&&K>0&&(W=Ma(S+G+E,c[1][1])),T=Math.max(T,V),L=Math.max(L,W)}if(h){let V=0,W=0;m&&z>0?V=Ma(k+z,h[0][0]):!m&&z<0&&(V=Aa(k+U,h[1][0])),f&&K>0?W=Ma(S+K,h[0][1]):!f&&K<0&&(W=Aa(S+G,h[1][1])),T=Math.max(T,V),L=Math.max(L,W)}if(o){if(p){const V=xd(U/Y,A,O)*Y;if(T=Math.max(T,V),c){let W=0;!m&&!f||m&&!f&&g?W=Ma(S+E+U/Y,c[1][1])*Y:W=Aa(S+E+(m?z:-z)/Y,c[0][1])*Y,T=Math.max(T,W)}if(h){let W=0;!m&&!f||m&&!f&&g?W=Aa(S+U/Y,h[1][1])*Y:W=Ma(S+(m?z:-z)/Y,h[0][1])*Y,T=Math.max(T,W)}}if(x){const V=xd(G*Y,N,C)/Y;if(L=Math.max(L,V),c){let W=0;!m&&!f||f&&!m&&g?W=Ma(k+G*Y+q,c[1][0])/Y:W=Aa(k+(f?K:-K)*Y+q,c[0][0])/Y,L=Math.max(L,W)}if(h){let W=0;!m&&!f||f&&!m&&g?W=Aa(k+G*Y,h[1][0])/Y:W=Ma(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&&(g?U>G*Y?K=(fv(m,f)?-z:z)/Y:z=(fv(m,f)?-K:K)*Y:p?(K=z/Y,f=m):(z=K*Y,m=f));const _=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)+_,y:d[1]*K*(f?-1:1)+P}}const Pw={width:0,height:0,x:0,y:0},fR={...Pw,pointerX:0,pointerY:0,aspectRatio:1};function hR(e){return[[0,0],[e.measured.width,e.measured.height]]}function mR(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 xR({domNode:e,nodeId:n,getStoreItems:s,onChange:l,onEnd:o}){const d=Br(e);let c={controlDirection:uv("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:p,keepAspectRatio:x,resizeDirection:g,onResizeStart:y,onResize:w,onResizeEnd:N,shouldResize:C}){let A={...Pw},O={...fR};c={boundaries:p,resizeDirection:g,keepAspectRatio:x,controlDirection:uv(f)};let k,S=null,R=[],D,Y,z,K=!1;const U=Qj().on("start",G=>{const{nodeLookup:q,transform:E,snapGrid:T,snapToGrid:L,nodeOrigin:_,paneDomNode:P}=s();if(k=q.get(n),!k)return;S=P?.getBoundingClientRect()??null;const{xSnapped:V,ySnapped:W}=So(G.sourceEvent,{transform:E,snapGrid:T,snapToGrid:L,containerBounds:S});A={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},O={...A,pointerX:V,pointerY:W,aspectRatio:A.width/A.height},D=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(D=q.get(k.parentId),Y=D&&k.extent==="parent"?hR(D):void 0),R=[],z=void 0;for(const[B,F]of q)if(F.parentId===n&&(R.push({id:B,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const X=mR(F,k,F.origin??_);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,{...A})}).on("drag",G=>{const{transform:q,snapGrid:E,snapToGrid:T,nodeOrigin:L}=s(),_=So(G.sourceEvent,{transform:q,snapGrid:E,snapToGrid:T,containerBounds:S}),P=[];if(!k)return;const{x:V,y:W,width:B,height:F}=A,X={},I=k.origin??L,{width:M,height:H,x:Z,y:ee}=uR(O,c.controlDirection,_,c.boundaries,c.keepAspectRatio,I,Y,z),ne=M!==B,ae=H!==F,fe=Z!==V&&ne,Ne=ee!==W&&ae;if(!fe&&!Ne&&!ne&&!ae)return;if((fe||Ne||I[0]===1||I[1]===1)&&(X.x=fe?Z:A.x,X.y=Ne?ee:A.y,A.x=X.x,A.y=X.y,R.length>0)){const Te=Z-V,ze=ee-W;for(const Xe of R)Xe.position={x:Xe.position.x-Te+I[0]*(M-B),y:Xe.position.y-ze+I[1]*(H-F)},P.push(Xe)}if((ne||ae)&&(X.width=ne&&(!c.resizeDirection||c.resizeDirection==="horizontal")?M:A.width,X.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?H:A.height,A.width=X.width,A.height=X.height),D&&k.expandParent){const Te=I[0]*(X.width??0);X.x&&X.x<Te&&(A.x=Te,O.x=O.x-(X.x-Te));const ze=I[1]*(X.height??0);X.y&&X.y<ze&&(A.y=ze,O.y=O.y-(X.y-ze))}const Le=dR({width:A.width,prevWidth:B,height:A.height,prevHeight:F,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),ye={...A,direction:Le};C?.(G,ye)!==!1&&(K=!0,w?.(G,ye),l(X,P))}).on("end",G=>{K&&(N?.(G,{...A}),o?.({...A}),K=!1)});d.call(U)}function m(){d.on(".drag",null)}return{update:h,destroy:m}}var Zh={exports:{}},Qh={},Wh={exports:{}},Jh={};var hv;function pR(){if(hv)return Jh;hv=1;var e=Po();function n(x,g){return x===g&&(x!==0||1/x===1/g)||x!==x&&g!==g}var s=typeof Object.is=="function"?Object.is:n,l=e.useState,o=e.useEffect,d=e.useLayoutEffect,c=e.useDebugValue;function h(x,g){var y=g(),w=l({inst:{value:y,getSnapshot:g}}),N=w[0].inst,C=w[1];return d(function(){N.value=y,N.getSnapshot=g,m(N)&&C({inst:N})},[x,y,g]),o(function(){return m(N)&&C({inst:N}),x(function(){m(N)&&C({inst:N})})},[x]),c(y),y}function m(x){var g=x.getSnapshot;x=x.value;try{var y=g();return!s(x,y)}catch{return!0}}function f(x,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:h;return Jh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Jh}var mv;function gR(){return mv||(mv=1,Wh.exports=pR()),Wh.exports}var xv;function bR(){if(xv)return Qh;xv=1;var e=Po(),n=gR();function s(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}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 Qh.useSyncExternalStoreWithSelector=function(f,p,x,g,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 A(D){if(!O){if(O=!0,k=D,D=g(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=g(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 A(p())},R===null?void 0:function(){return A(R())}]},[p,x,g,y]);var C=o(f,w[0],w[1]);return c(function(){N.hasValue=!0,N.value=C},[C]),m(C),C},Qh}var pv;function yR(){return pv||(pv=1,Zh.exports=bR()),Zh.exports}var vR=yR();const jR=Gd(vR),wR={},gv=e=>{let n;const s=new Set,l=(p,x)=>{const g=typeof p=="function"?p(n):p;if(!Object.is(g,n)){const y=n;n=x??(typeof g!="object"||g===null)?g:Object.assign({},n,g),s.forEach(w=>w(n,y))}},o=()=>n,m={setState:l,getState:o,getInitialState:()=>f,subscribe:p=>(s.add(p),()=>s.delete(p)),destroy:()=>{(wR?"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},NR=e=>e?gv(e):gv,{useDebugValue:kR}=I2,{useSyncExternalStoreWithSelector:SR}=jR,CR=e=>e;function Uw(e,n=CR,s){const l=SR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return kR(l),l}const bv=(e,n)=>{const s=NR(e),l=(o,d=n)=>Uw(s,o,d);return Object.assign(l,s),l},ER=(e,n)=>e?bv(e,n):bv;function _n(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 cu=v.createContext(null),TR=cu.Provider,qw=_s.error001();function Wt(e,n){const s=v.useContext(cu);if(s===null)throw new Error(qw);return Uw(s,e,n)}function An(){const e=v.useContext(cu);if(e===null)throw new Error(qw);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const yv={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%)"},Vw="react-flow__node-desc",Fw="react-flow__edge-desc",AR="react-flow__aria-live",MR=e=>e.ariaLiveMessage,OR=e=>e.ariaLabelConfig;function RR({rfId:e}){const n=Wt(MR);return t.jsx("div",{id:`${AR}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:_R,children:n})}function DR({rfId:e,disableKeyboardA11y:n}){const s=Wt(OR);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${Vw}-${e}`,style:yv,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${Fw}-${e}`,style:yv,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(RR,{rfId:e})]})}const du=v.forwardRef(({position:e="top-left",children:n,className:s,style:l,...o},d)=>{const c=`${e}`.split("-");return t.jsx("div",{className:Kn(["react-flow__panel",s,...c]),style:l,ref:d,...o,children:n})});du.displayName="Panel";function LR({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(du,{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 IR=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}},pd=e=>e.id;function zR(e,n){return _n(e.selectedNodes.map(pd),n.selectedNodes.map(pd))&&_n(e.selectedEdges.map(pd),n.selectedEdges.map(pd))}function $R({onSelectionChange:e}){const n=An(),{selectedNodes:s,selectedEdges:l}=Wt(IR,zR);return v.useEffect(()=>{const o={nodes:s,edges:l};e?.(o),n.getState().onSelectionChangeHandlers.forEach(d=>d(o))},[s,l,e]),null}const BR=e=>!!e.onSelectionChangeHandlers;function HR({onSelectionChange:e}){const n=Wt(BR);return e||n?t.jsx($R,{onSelectionChange:e}):null}const Yw=[0,0],PR={x:0,y:0,zoom:1},UR=["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"],vv=[...UR,"rfId"],qR=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}),jv={translateExtent:Do,nodeOrigin:Yw,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function VR(e){const{setNodes:n,setEdges:s,setMinZoom:l,setMaxZoom:o,setTranslateExtent:d,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:m}=Wt(qR,_n),f=An();v.useEffect(()=>(m(e.defaultNodes,e.defaultEdges),()=>{p.current=jv,h()}),[]);const p=v.useRef(jv);return v.useEffect(()=>{for(const x of vv){const g=e[x],y=p.current[x];g!==y&&(typeof e[x]>"u"||(x==="nodes"?n(g):x==="edges"?s(g):x==="minZoom"?l(g):x==="maxZoom"?o(g):x==="translateExtent"?d(g):x==="nodeExtent"?c(g):x==="ariaLabelConfig"?f.setState({ariaLabelConfig:EO(g)}):x==="fitView"?f.setState({fitViewQueued:g}):x==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[x]:g})))}p.current=e},vv.map(x=>e[x])),null}function wv(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function FR(e){const[n,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const l=wv(),o=()=>s(l?.matches?"dark":"light");return o(),l?.addEventListener("change",o),()=>{l?.removeEventListener("change",o)}},[e]),n!==null?n:wv()?.matches?"dark":"light"}const Nv=typeof document<"u"?document:null;function $o(e=null,n={target:Nv,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
|
+
`)),p=f.reduce((x,g)=>x.concat(...g),[]);return[f,p]}return[[],[]]},[e]);return v.useEffect(()=>{const m=n?.target??Nv,f=n?.actInsideInputWithModifier??!0;if(e!==null){const p=y=>{if(o.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!o.current||o.current&&!f)&&Sw(y))return!1;const N=Sv(y.code,h);if(d.current.add(y[N]),kv(c,d.current,!1)){const C=y.composedPath?.()?.[0]||y.target,A=C?.nodeName==="BUTTON"||C?.nodeName==="A";n.preventDefault!==!1&&(o.current||!A)&&y.preventDefault(),l(!0)}},x=y=>{const w=Sv(y.code,h);kv(c,d.current,!0)?(l(!1),d.current.clear()):d.current.delete(y[w]),y.key==="Meta"&&d.current.clear(),o.current=!1},g=()=>{d.current.clear(),l(!1)};return m?.addEventListener("keydown",p),m?.addEventListener("keyup",x),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{m?.removeEventListener("keydown",p),m?.removeEventListener("keyup",x),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,l]),s}function kv(e,n,s){return e.filter(l=>s||l.length===n.size).some(l=>l.every(o=>n.has(o)))}function Sv(e,n){return n.includes(e)?"code":"key"}const YR=()=>{const e=An();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=Ex(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},p=s.snapGrid??o,x=s.snapToGrid??d;return Zo(f,l,x,p)},flowToScreenPosition:n=>{const{transform:s,domNode:l}=e.getState();if(!l)return n;const{x:o,y:d}=l.getBoundingClientRect(),c=Vd(n,s);return{x:c.x+o,y:c.y+d}}}),[])};function Gw(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)GR(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 GR(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 Xw(e,n){return Gw(e,n)}function Kw(e,n){return Gw(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 Cv({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 Ev(e){return{id:e.id,type:"remove"}}const Tv=e=>gO(e),XR=e=>gw(e);function Zw(e){return v.forwardRef(e)}const KR=typeof window<"u"?v.useLayoutEffect:v.useEffect;function _v(e){const[n,s]=v.useState(BigInt(0)),[l]=v.useState(()=>ZR(()=>s(o=>o+BigInt(1))));return KR(()=>{const o=l.get();o.length&&(e(o),l.reset())},[n]),l}function ZR(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:s=>{n.push(s),e()}}}const Qw=v.createContext(null);function QR({children:e}){const n=An(),s=v.useCallback(h=>{const{nodes:m=[],setNodes:f,hasDefaultNodes:p,onNodesChange:x,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:w}=n.getState();let N=m;for(const A of h)N=typeof A=="function"?A(N):A;let C=Cv({items:N,lookup:g});for(const A of w.values())C=A(C);p&&f(N),C.length>0?x?.(C):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:A,nodes:O,setNodes:k}=n.getState();A&&k(O)})},[]),l=_v(s),o=v.useCallback(h=>{const{edges:m=[],setEdges:f,hasDefaultEdges:p,onEdgesChange:x,edgeLookup:g}=n.getState();let y=m;for(const w of h)y=typeof w=="function"?w(y):w;p?f(y):x&&x(Cv({items:y,lookup:g}))},[]),d=_v(o),c=v.useMemo(()=>({nodeQueue:l,edgeQueue:d}),[]);return t.jsx(Qw.Provider,{value:c,children:e})}function WR(){const e=v.useContext(Qw);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const JR=e=>!!e.panZoom;function Dx(){const e=YR(),n=An(),s=WR(),l=Wt(JR),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:g,nodeOrigin:y}=n.getState(),w=Tv(x)?x:g.get(x.id),N=w.parentId?Nw(w.position,w.measured,w.parentId,g,y):w.position,C={...w,position:N,width:w.measured?.width??w.width,height:w.measured?.height??w.height};return fi(C)},f=(x,g,y={replace:!1})=>{c(w=>w.map(N=>{if(N.id===x){const C=typeof g=="function"?g(N):g;return y.replace&&Tv(C)?C:{...N,...C}}return N}))},p=(x,g,y={replace:!1})=>{h(w=>w.map(N=>{if(N.id===x){const C=typeof g=="function"?g(N):g;return y.replace&&XR(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(g=>({...g}))},getEdge:x=>n.getState().edgeLookup.get(x),setNodes:c,setEdges:h,addNodes:x=>{const g=Array.isArray(x)?x:[x];s.nodeQueue.push(y=>[...y,...g])},addEdges:x=>{const g=Array.isArray(x)?x:[x];s.edgeQueue.push(y=>[...y,...g])},toObject:()=>{const{nodes:x=[],edges:g=[],transform:y}=n.getState(),[w,N,C]=y;return{nodes:x.map(A=>({...A})),edges:g.map(A=>({...A})),viewport:{x:w,y:N,zoom:C}}},deleteElements:async({nodes:x=[],edges:g=[]})=>{const{nodes:y,edges:w,onNodesDelete:N,onEdgesDelete:C,triggerNodeChanges:A,triggerEdgeChanges:O,onDelete:k,onBeforeDelete:S}=n.getState(),{nodes:R,edges:D}=await wO({nodesToRemove:x,edgesToRemove:g,nodes:y,edges:w,onBeforeDelete:S}),Y=D.length>0,z=R.length>0;if(Y){const K=D.map(Ev);C?.(D),O(K)}if(z){const K=R.map(Ev);N?.(R),A(K)}return(z||Y)&&k?.({nodes:R,edges:D}),{deletedNodes:R,deletedEdges:D}},getIntersectingNodes:(x,g=!0,y)=>{const w=ev(x),N=w?x:m(x),C=y!==void 0;return N?(y||n.getState().nodes).filter(A=>{const O=n.getState().nodeLookup.get(A.id);if(O&&!w&&(A.id===x.id||!O.internals.positionAbsolute))return!1;const k=fi(C?A:O),S=Io(k,N);return g&&S>0||S>=k.width*k.height||S>=N.width*N.height}):[]},isNodeIntersecting:(x,g,y=!0)=>{const N=ev(x)?x:m(x);if(!N)return!1;const C=Io(N,g);return y&&C>0||C>=g.width*g.height||C>=N.width*N.height},updateNode:f,updateNodeData:(x,g,y={replace:!1})=>{f(x,w=>{const N=typeof g=="function"?g(w):g;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},updateEdge:p,updateEdgeData:(x,g,y={replace:!1})=>{p(x,w=>{const N=typeof g=="function"?g(w):g;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},getNodesBounds:x=>{const{nodeLookup:g,nodeOrigin:y}=n.getState();return bO(x,{nodeLookup:g,nodeOrigin:y})},getHandleConnections:({type:x,id:g,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}-${x}${g?`-${g}`:""}`)?.values()??[]),getNodeConnections:({type:x,handleId:g,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}${x?g?`-${x}-${g}`:`-${x}`:""}`)?.values()??[]),fitView:async x=>{const g=n.getState().fitViewResolver??CO();return n.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:g}),s.nodeQueue.push(y=>[...y]),g.promise}}},[]);return v.useMemo(()=>({...o,...e,viewportInitialized:l}),[l])}const Av=e=>e.selected,eD=typeof window<"u"?window:void 0;function tD({deleteKeyCode:e,multiSelectionKeyCode:n}){const s=An(),{deleteElements:l}=Dx(),o=$o(e,{actInsideInputWithModifier:!1}),d=$o(n,{target:eD});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 nD(e){const n=An();v.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const l=Tx(e.current);(l.height===0||l.width===0)&&n.getState().onError?.("004",_s.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 uu={position:"absolute",width:"100%",height:"100%",top:0,left:0},rD=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function sD({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:p,maxZoom:x,zoomActivationKeyCode:g,preventScrolling:y=!0,children:w,noWheelClassName:N,noPanClassName:C,onViewportChange:A,isControlledViewport:O,paneClickDistance:k,selectionOnDrag:S}){const R=An(),D=v.useRef(null),{userSelectionActive:Y,lib:z,connectionInProgress:K}=Wt(rD,_n),U=$o(g),G=v.useRef();nD(D);const q=v.useCallback(E=>{A?.({x:E[0],y:E[1],zoom:E[2]}),O||R.setState({transform:E})},[A,O]);return v.useEffect(()=>{if(D.current){G.current=cR({domNode:D.current,minZoom:p,maxZoom:x,translateExtent:f,viewport:m,onDraggingChange:_=>R.setState(P=>P.paneDragging===_?P:{paneDragging:_}),onPanZoomStart:(_,P)=>{const{onViewportChangeStart:V,onMoveStart:W}=R.getState();W?.(_,P),V?.(P)},onPanZoom:(_,P)=>{const{onViewportChange:V,onMove:W}=R.getState();W?.(_,P),V?.(P)},onPanZoomEnd:(_,P)=>{const{onViewportChangeEnd:V,onMoveEnd:W}=R.getState();W?.(_,P),V?.(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:q,connectionInProgress:K,selectionOnDrag:S,paneClickDistance:k})},[e,n,s,l,o,d,c,h,U,y,C,Y,N,z,q,K,S,k]),t.jsx("div",{className:"react-flow__renderer",ref:D,style:uu,children:w})}const aD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function lD(){const{userSelectionActive:e,userSelectionRect:n}=Wt(aD,_n);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)},iD=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function oD({isSelecting:e,selectionKeyPressed:n,selectionMode:s=Lo.Full,panOnDrag:l,paneClickDistance:o,selectionOnDrag:d,onSelectionStart:c,onSelectionEnd:h,onPaneClick:m,onPaneContextMenu:f,onPaneScroll:p,onPaneMouseEnter:x,onPaneMouseMove:g,onPaneMouseLeave:y,children:w}){const N=An(),{userSelectionActive:C,elementsSelectable:A,dragging:O,connectionInProgress:k}=Wt(iD,_n),S=A&&(e||C),R=v.useRef(null),D=v.useRef(),Y=v.useRef(new Set),z=v.useRef(new Set),K=v.useRef(!1),U=V=>{if(K.current||k){K.current=!1;return}m?.(V),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},G=V=>{if(Array.isArray(l)&&l?.includes(2)){V.preventDefault();return}f?.(V)},q=p?V=>p(V):void 0,E=V=>{K.current&&(V.stopPropagation(),K.current=!1)},T=V=>{const{domNode:W}=N.getState();if(D.current=W?.getBoundingClientRect(),!D.current)return;const B=V.target===R.current;if(!B&&!!V.target.closest(".nokey")||!e||!(d&&B||n)||V.button!==0||!V.isPrimary)return;V.target?.setPointerCapture?.(V.pointerId),K.current=!1;const{x:I,y:M}=fs(V.nativeEvent,D.current);N.setState({userSelectionRect:{width:0,height:0,startX:I,startY:M,x:I,y:M}}),B||(V.stopPropagation(),V.preventDefault())},L=V=>{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(V.nativeEvent,D.current),{startX:fe,startY:Ne}=W;if(!K.current){const ze=n?0:o;if(Math.hypot(ne-fe,ae-Ne)<=ze)return;ee(),c?.(V)}K.current=!0;const Le={startX:fe,startY:Ne,x:ne<fe?ne:fe,y:ae<Ne?ae:Ne,width:Math.abs(ne-fe),height:Math.abs(ae-Ne)},ye=Y.current,je=z.current;Y.current=new Set(Cx(F,Le,B,s===Lo.Partial,!0).map(ze=>ze.id)),z.current=new Set;const Te=Z?.selectable??!0;for(const ze of Y.current){const Xe=I.get(ze);if(Xe)for(const{edgeId:nt}of Xe.values()){const tt=X.get(nt);tt&&(tt.selectable??Te)&&z.current.add(nt)}}if(!tv(ye,Y.current)){const ze=ni(F,Y.current,!0);M(ze)}if(!tv(je,z.current)){const ze=ni(X,z.current);H(ze)}N.setState({userSelectionRect:Le,userSelectionActive:!0,nodesSelectionActive:!1})},_=V=>{V.button===0&&(V.target?.releasePointerCapture?.(V.pointerId),!C&&V.target===R.current&&N.getState().userSelectionRect&&U?.(V),N.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(h?.(V),N.setState({nodesSelectionActive:Y.current.size>0})))},P=l===!0||Array.isArray(l)&&l.includes(0);return t.jsxs("div",{className:Kn(["react-flow__pane",{draggable:P,dragging:O,selection:e}]),onClick:S?void 0:em(U,R),onContextMenu:em(G,R),onWheel:em(q,R),onPointerEnter:S?void 0:x,onPointerMove:S?L:g,onPointerUp:S?_:void 0,onPointerDownCapture:S?T:void 0,onClickCapture:S?E:void 0,onPointerLeave:y,ref:R,style:uu,children:[w,t.jsx(lD,{})]})}function qm({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",_s.error012(e));return}n.setState({nodesSelectionActive:!1}),f.selected?(s||f.selected&&c)&&(d({nodes:[f],edges:[]}),requestAnimationFrame(()=>l?.current?.blur())):o([e])}function Ww({nodeRef:e,disabled:n=!1,noDragClassName:s,handleSelector:l,nodeId:o,isSelectable:d,nodeClickDistance:c}){const h=An(),[m,f]=v.useState(!1),p=v.useRef();return v.useEffect(()=>{p.current=KO({getStoreItems:()=>h.getState(),onNodeMouseDown:x=>{qm({id:x,store:h,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),v.useEffect(()=>{if(!(n||!e.current||!p.current))return p.current.update({noDragClassName:s,handleSelector:l,domNode:e.current,isSelectable:d,nodeId:o,nodeClickDistance:c}),()=>{p.current?.destroy()}},[s,l,n,d,e,o,c]),m}const cD=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function Jw(){const e=An();return v.useCallback(s=>{const{nodeExtent:l,snapToGrid:o,snapGrid:d,nodesDraggable:c,onError:h,updateNodePositions:m,nodeLookup:f,nodeOrigin:p}=e.getState(),x=new Map,g=cD(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[,A]of f){if(!g(A))continue;let O={x:A.internals.positionAbsolute.x+N,y:A.internals.positionAbsolute.y+C};o&&(O=Ko(O,d));const{position:k,positionAbsolute:S}=bw({nodeId:A.id,nextPosition:O,nodeLookup:f,nodeExtent:l,nodeOrigin:p,onError:h});A.position=k,A.internals.positionAbsolute=S,x.set(A.id,A)}m(x)},[])}const Lx=v.createContext(null),dD=Lx.Provider;Lx.Consumer;const eN=()=>v.useContext(Lx),uD=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),fD=(e,n,s)=>l=>{const{connectionClickStartHandle:o,connectionMode:d,connection:c}=l,{fromHandle:h,toHandle:m,isValid:f}=c,p=m?.nodeId===e&&m?.id===n&&m?.type===s;return{connectingFrom:h?.nodeId===e&&h?.id===n&&h?.type===s,connectingTo:p,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:p&&f}};function hD({type:e="source",position:n=mt.Top,isValidConnection:s,isConnectable:l=!0,isConnectableStart:o=!0,isConnectableEnd:d=!0,id:c,onConnect:h,children:m,className:f,onMouseDown:p,onTouchStart:x,...g},y){const w=c||null,N=e==="target",C=An(),A=eN(),{connectOnClick:O,noPanClassName:k,rfId:S}=Wt(uD,_n),{connectingFrom:R,connectingTo:D,clickConnecting:Y,isPossibleEndHandle:z,connectionInProcess:K,clickConnectionInProcess:U,valid:G}=Wt(fD(A,w,e),_n);A||C.getState().onError?.("010",_s.error010());const q=L=>{const{defaultEdgeOptions:_,onConnect:P,hasDefaultEdges:V}=C.getState(),W={..._,...L};if(V){const{edges:B,setEdges:F}=C.getState();F(RO(W,B))}P?.(W),h?.(W)},E=L=>{if(!A)return;const _=Cw(L.nativeEvent);if(o&&(_&&L.button===0||!_)){const P=C.getState();Um.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:A,flowId:P.rfId,panBy:P.panBy,cancelConnection:P.cancelConnection,onConnectStart:P.onConnectStart,onConnectEnd:(...V)=>C.getState().onConnectEnd?.(...V),updateConnection:P.updateConnection,onConnect:q,isValidConnection:s||((...V)=>C.getState().isValidConnection?.(...V)??!0),getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:P.autoPanSpeed,dragThreshold:P.connectionDragThreshold})}_?p?.(L):x?.(L)},T=L=>{const{onClickConnectStart:_,onClickConnectEnd:P,connectionClickStartHandle:V,connectionMode:W,isValidConnection:B,lib:F,rfId:X,nodeLookup:I,connection:M}=C.getState();if(!A||!V&&!o)return;if(!V){_?.(L.nativeEvent,{nodeId:A,handleId:w,handleType:e}),C.setState({connectionClickStartHandle:{nodeId:A,type:e,id:w}});return}const H=kw(L.target),Z=s||B,{connection:ee,isValid:ne}=Um.isValid(L.nativeEvent,{handle:{nodeId:A,id:w,type:e},connectionMode:W,fromNodeId:V.nodeId,fromHandleId:V.id||null,fromType:V.type,isValidConnection:Z,flowId:X,doc:H,lib:F,nodeLookup:I});ne&&ee&&q(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":A,"data-handlepos":n,"data-id":`${S}-${A}-${w}-${e}`,className:Kn(["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,...g,children:m})}const za=v.memo(Zw(hD));function mD({data:e,isConnectable:n,sourcePosition:s=mt.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx(za,{type:"source",position:s,isConnectable:n})]})}function xD({data:e,isConnectable:n,targetPosition:s=mt.Top,sourcePosition:l=mt.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(za,{type:"target",position:s,isConnectable:n}),e?.label,t.jsx(za,{type:"source",position:l,isConnectable:n})]})}function pD(){return null}function gD({data:e,isConnectable:n,targetPosition:s=mt.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(za,{type:"target",position:s,isConnectable:n}),e?.label]})}const Fd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Mv={input:mD,default:xD,output:gD,group:pD};function bD(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 yD=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 vD({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:s}){const l=An(),{width:o,height:d,transformString:c,userSelectionActive:h}=Wt(yD,_n),m=Jw(),f=v.useRef(null);v.useEffect(()=>{s||f.current?.focus({preventScroll:!0})},[s]);const p=!h&&o!==null&&d!==null;if(Ww({nodeRef:f,disabled:!p}),!p)return null;const x=e?y=>{const w=l.getState().nodes.filter(N=>N.selected);e(y,w)}:void 0,g=y=>{Object.prototype.hasOwnProperty.call(Fd,y.key)&&(y.preventDefault(),m({direction:Fd[y.key],factor:y.shiftKey?4:1}))};return t.jsx("div",{className:Kn(["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:g,style:{width:o,height:d}})})}const Ov=typeof window<"u"?window:void 0,jD=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function tN({children:e,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:l,onPaneMouseLeave:o,onPaneContextMenu:d,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:m,selectionKeyCode:f,selectionOnDrag:p,selectionMode:x,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:w,panActivationKeyCode:N,zoomActivationKeyCode:C,elementsSelectable:A,zoomOnScroll:O,zoomOnPinch:k,panOnScroll:S,panOnScrollSpeed:R,panOnScrollMode:D,zoomOnDoubleClick:Y,panOnDrag:z,defaultViewport:K,translateExtent:U,minZoom:G,maxZoom:q,preventScrolling:E,onSelectionContextMenu:T,noWheelClassName:L,noPanClassName:_,disableKeyboardA11y:P,onViewportChange:V,isControlledViewport:W}){const{nodesSelectionActive:B,userSelectionActive:F}=Wt(jD,_n),X=$o(f,{target:Ov}),I=$o(N,{target:Ov}),M=I||z,H=I||S,Z=p&&M!==!0,ee=X||F||Z;return tD({deleteKeyCode:m,multiSelectionKeyCode:w}),t.jsx(sD,{onPaneContextMenu:d,elementsSelectable:A,zoomOnScroll:O,zoomOnPinch:k,panOnScroll:H,panOnScrollSpeed:R,panOnScrollMode:D,zoomOnDoubleClick:Y,panOnDrag:!X&&M,defaultViewport:K,translateExtent:U,minZoom:G,maxZoom:q,zoomActivationKeyCode:C,preventScrolling:E,noWheelClassName:L,noPanClassName:_,onViewportChange:V,isControlledViewport:W,paneClickDistance:h,selectionOnDrag:Z,children:t.jsxs(oD,{onSelectionStart:g,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(vD,{onSelectionContextMenu:T,noPanClassName:_,disableKeyboardA11y:P})]})})}tN.displayName="FlowRenderer";const wD=v.memo(tN),ND=e=>n=>e?Cx(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 kD(e){return Wt(v.useCallback(ND(e),[e]),_n)}const SD=e=>e.updateNodeInternals;function CD(){const e=Wt(SD),[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 ED({node:e,nodeType:n,hasDimensions:s,resizeObserver:l}){const o=An(),d=v.useRef(null),c=v.useRef(null),h=v.useRef(e.sourcePosition),m=v.useRef(e.targetPosition),f=v.useRef(n),p=s&&!!e.internals.handleBounds;return v.useEffect(()=>{d.current&&!e.hidden&&(!p||c.current!==d.current)&&(c.current&&l?.unobserve(c.current),l?.observe(d.current),c.current=d.current)},[p,e.hidden]),v.useEffect(()=>()=>{c.current&&(l?.unobserve(c.current),c.current=null)},[]),v.useEffect(()=>{if(d.current){const x=f.current!==n,g=h.current!==e.sourcePosition,y=m.current!==e.targetPosition;(x||g||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 TD({id:e,onClick:n,onMouseEnter:s,onMouseMove:l,onMouseLeave:o,onContextMenu:d,onDoubleClick:c,nodesDraggable:h,elementsSelectable:m,nodesConnectable:f,nodesFocusable:p,resizeObserver:x,noDragClassName:g,noPanClassName:y,disableKeyboardA11y:w,rfId:N,nodeTypes:C,nodeClickDistance:A,onError:O}){const{node:k,internals:S,isParent:R}=Wt(ne=>{const ae=ne.nodeLookup.get(e),fe=ne.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:fe}},_n);let D=k.type||"default",Y=C?.[D]||Mv[D];Y===void 0&&(O?.("003",_s.error003(D)),D="default",Y=C?.default||Mv.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||p&&typeof k.focusable>"u"),q=An(),E=ww(k),T=ED({node:k,nodeType:D,hasDimensions:E,resizeObserver:x}),L=Ww({nodeRef:T,disabled:k.hidden||!z,noDragClassName:g,handleSelector:k.dragHandle,nodeId:e,isSelectable:K,nodeClickDistance:A}),_=Jw();if(k.hidden)return null;const P=na(k),V=bD(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:fe}=q.getState();K&&(!ae||!z||fe>0)&&qm({id:e,store:q,nodeRef:T}),n&&n(ne,{...S.userNode})},Z=ne=>{if(!(Sw(ne.nativeEvent)||w)){if(hw.includes(ne.key)&&K){const ae=ne.key==="Escape";qm({id:e,store:q,unselect:ae,nodeRef:T})}else if(z&&k.selected&&Object.prototype.hasOwnProperty.call(Fd,ne.key)){ne.preventDefault();const{ariaLabelConfig:ae}=q.getState();q.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:ne.key.replace("Arrow","").toLowerCase(),x:~~S.positionAbsolute.x,y:~~S.positionAbsolute.y})}),_({direction:Fd[ne.key],factor:ne.shiftKey?4:1})}}},ee=()=>{if(w||!T.current?.matches(":focus-visible"))return;const{transform:ne,width:ae,height:fe,autoPanOnNodeFocus:Ne,setCenter:Le}=q.getState();if(!Ne)return;Cx(new Map([[e,k]]),{x:0,y:0,width:ae,height:fe},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:Kn(["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,...V},"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:`${Vw}-${N}`,"aria-label":k.ariaLabel,...k.domAttributes,children:t.jsx(dD,{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(TD);const AD=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function nN(e){const{nodesDraggable:n,nodesConnectable:s,nodesFocusable:l,elementsSelectable:o,onError:d}=Wt(AD,_n),c=kD(e.onlyRenderVisibleElements),h=CD();return t.jsx("div",{className:"react-flow__nodes",style:uu,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))})}nN.displayName="NodeRenderer";const MD=v.memo(nN);function OD(e){return Wt(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&&AO({sourceNode:d,targetNode:c,width:s.width,height:s.height,transform:s.transform})&&l.push(o.id)}return l},[e]),_n)}const RD=({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"})},DD=({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"})},Rv={[di.Arrow]:RD,[di.ArrowClosed]:DD};function LD(e){const n=An();return v.useMemo(()=>Object.prototype.hasOwnProperty.call(Rv,e)?Rv[e]:(n.getState().onError?.("009",_s.error009(e)),null),[e])}const ID=({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=LD(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},rN=({defaultColor:e,rfId:n})=>{const s=Wt(d=>d.edges),l=Wt(d=>d.defaultEdgeOptions),o=v.useMemo(()=>$O(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(ID,{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};rN.displayName="MarkerDefinitions";var zD=v.memo(rN);function sN({x:e,y:n,label:s,labelStyle:l,labelShowBg:o=!0,labelBgStyle:d,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:m,className:f,...p}){const[x,g]=v.useState({x:1,y:0,width:0,height:0}),y=Kn(["react-flow__edge-textwrapper",f]),w=v.useRef(null);return v.useEffect(()=>{if(w.current){const N=w.current.getBBox();g({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",...p,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}sN.displayName="EdgeText";const $D=v.memo(sN);function fu({path:e,labelX:n,labelY:s,label:l,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:m,interactionWidth:f=20,...p}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{...p,d:e,fill:"none",className:Kn(["react-flow__edge-path",p.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($D,{x:n,y:s,label:l,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:m}):null]})}function Dv({pos:e,x1:n,y1:s,x2:l,y2:o}){return e===mt.Left||e===mt.Right?[.5*(n+l),s]:[n,.5*(s+o)]}function aN({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:l,targetY:o,targetPosition:d=mt.Top}){const[c,h]=Dv({pos:s,x1:e,y1:n,x2:l,y2:o}),[m,f]=Dv({pos:d,x1:l,y1:o,x2:e,y2:n}),[p,x,g,y]=Ew({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}`,p,x,g,y]}function lN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,sourcePosition:c,targetPosition:h,label:m,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,interactionWidth:A})=>{const[O,k,S]=aN({sourceX:s,sourceY:l,sourcePosition:c,targetX:o,targetY:d,targetPosition:h}),R=e.isInternal?void 0:n;return t.jsx(fu,{id:R,path:O,labelX:k,labelY:S,label:m,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,interactionWidth:A})})}const BD=lN({isInternal:!1}),iN=lN({isInternal:!0});BD.displayName="SimpleBezierEdge";iN.displayName="SimpleBezierEdgeInternal";function oN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,sourcePosition:y=mt.Bottom,targetPosition:w=mt.Top,markerEnd:N,markerStart:C,pathOptions:A,interactionWidth:O})=>{const[k,S,R]=Bm({sourceX:s,sourceY:l,sourcePosition:y,targetX:o,targetY:d,targetPosition:w,borderRadius:A?.borderRadius,offset:A?.offset,stepPosition:A?.stepPosition}),D=e.isInternal?void 0:n;return t.jsx(fu,{id:D,path:k,labelX:S,labelY:R,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,markerEnd:N,markerStart:C,interactionWidth:O})})}const cN=oN({isInternal:!1}),dN=oN({isInternal:!0});cN.displayName="SmoothStepEdge";dN.displayName="SmoothStepEdgeInternal";function uN(e){return v.memo(({id:n,...s})=>{const l=e.isInternal?void 0:n;return t.jsx(cN,{...s,id:l,pathOptions:v.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const HD=uN({isInternal:!1}),fN=uN({isInternal:!0});HD.displayName="StepEdge";fN.displayName="StepEdgeInternal";function hN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,markerEnd:y,markerStart:w,interactionWidth:N})=>{const[C,A,O]=Aw({sourceX:s,sourceY:l,targetX:o,targetY:d}),k=e.isInternal?void 0:n;return t.jsx(fu,{id:k,path:C,labelX:A,labelY:O,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,markerEnd:y,markerStart:w,interactionWidth:N})})}const PD=hN({isInternal:!1}),mN=hN({isInternal:!0});PD.displayName="StraightEdge";mN.displayName="StraightEdgeInternal";function xN(e){return v.memo(({id:n,sourceX:s,sourceY:l,targetX:o,targetY:d,sourcePosition:c=mt.Bottom,targetPosition:h=mt.Top,label:m,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,pathOptions:A,interactionWidth:O})=>{const[k,S,R]=Tw({sourceX:s,sourceY:l,sourcePosition:c,targetX:o,targetY:d,targetPosition:h,curvature:A?.curvature}),D=e.isInternal?void 0:n;return t.jsx(fu,{id:D,path:k,labelX:S,labelY:R,label:m,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:C,interactionWidth:O})})}const UD=xN({isInternal:!1}),pN=xN({isInternal:!0});UD.displayName="BezierEdge";pN.displayName="BezierEdgeInternal";const Lv={default:pN,straight:mN,step:fN,smoothstep:dN,simplebezier:iN},Iv={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},qD=(e,n,s)=>s===mt.Left?e-n:s===mt.Right?e+n:e,VD=(e,n,s)=>s===mt.Top?e-n:s===mt.Bottom?e+n:e,zv="react-flow__edgeupdater";function $v({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:Kn([zv,`${zv}-${h}`]),cx:qD(n,l,e),cy:VD(s,l,e),r:l,stroke:"transparent",fill:"transparent"})}function FD({isReconnectable:e,reconnectRadius:n,edge:s,sourceX:l,sourceY:o,targetX:d,targetY:c,sourcePosition:h,targetPosition:m,onReconnect:f,onReconnectStart:p,onReconnectEnd:x,setReconnecting:g,setUpdateHover:y}){const w=An(),N=(S,R)=>{if(S.button!==0)return;const{autoPanOnConnect:D,domNode:Y,connectionMode:z,connectionRadius:K,lib:U,onConnectStart:G,cancelConnection:q,nodeLookup:E,rfId:T,panBy:L,updateConnection:_}=w.getState(),P=R.type==="target",V=(F,X)=>{g(!1),x?.(F,s,R.type,X)},W=F=>f?.(s,F),B=(F,X)=>{g(!0),p?.(S,s,R.type),G?.(F,X)};Um.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:q,panBy:L,isValidConnection:(...F)=>w.getState().isValidConnection?.(...F)??!0,onConnect:W,onConnectStart:B,onConnectEnd:(...F)=>w.getState().onConnectEnd?.(...F),onReconnectEnd:V,updateConnection:_,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"}),A=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($v,{position:h,centerX:l,centerY:o,radius:n,onMouseDown:C,onMouseEnter:O,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&t.jsx($v,{position:m,centerX:d,centerY:c,radius:n,onMouseDown:A,onMouseEnter:O,onMouseOut:k,type:"target"})]})}function YD({id:e,edgesFocusable:n,edgesReconnectable:s,elementsSelectable:l,onClick:o,onDoubleClick:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,reconnectRadius:p,onReconnect:x,onReconnectStart:g,onReconnectEnd:y,rfId:w,edgeTypes:N,noPanClassName:C,onError:A,disableKeyboardA11y:O}){let k=Wt(Le=>Le.edgeLookup.get(e));const S=Wt(Le=>Le.defaultEdgeOptions);k=S?{...S,...k}:k;let R=k.type||"default",D=N?.[R]||Lv[R];D===void 0&&(A?.("011",_s.error011(R)),R="default",D=N?.default||Lv.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,q]=v.useState(!1),[E,T]=v.useState(!1),L=An(),{zIndex:_,sourceX:P,sourceY:V,targetX:W,targetY:B,sourcePosition:F,targetPosition:X}=Wt(v.useCallback(Le=>{const ye=Le.nodeLookup.get(k.source),je=Le.nodeLookup.get(k.target);if(!ye||!je)return{zIndex:k.zIndex,...Iv};const Te=zO({id:e,sourceNode:ye,targetNode:je,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:Le.connectionMode,onError:A});return{zIndex:_O({selected:k.selected,zIndex:k.zIndex,sourceNode:ye,targetNode:je,elevateOnSelect:Le.elevateEdgesOnSelect,zIndexMode:Le.zIndexMode}),...Te||Iv}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),_n),I=v.useMemo(()=>k.markerStart?`url('#${Hm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),M=v.useMemo(()=>k.markerEnd?`url('#${Hm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||P===null||V===null||W===null||B===null)return null;const H=Le=>{const{addSelectedEdges:ye,unselectNodesAndEdges:je,multiSelectionActive:Te}=L.getState();K&&(L.setState({nodesSelectionActive:!1}),k.selected&&Te?(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,fe=f?Le=>{f(Le,{...k})}:void 0,Ne=Le=>{if(!O&&hw.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:_},children:t.jsxs("g",{className:Kn(["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:fe,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?`${Fw}-${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:V,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(FD,{edge:k,isReconnectable:z,reconnectRadius:p,onReconnect:x,onReconnectStart:g,onReconnectEnd:y,sourceX:P,sourceY:V,targetX:W,targetY:B,sourcePosition:F,targetPosition:X,setUpdateHover:q,setReconnecting:T})]})})}var GD=v.memo(YD);const XD=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function gN({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:s,edgeTypes:l,noPanClassName:o,onReconnect:d,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:m,onEdgeMouseLeave:f,onEdgeClick:p,reconnectRadius:x,onEdgeDoubleClick:g,onReconnectStart:y,onReconnectEnd:w,disableKeyboardA11y:N}){const{edgesFocusable:C,edgesReconnectable:A,elementsSelectable:O,onError:k}=Wt(XD,_n),S=OD(n);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(zD,{defaultColor:e,rfId:s}),S.map(R=>t.jsx(GD,{id:R,edgesFocusable:C,edgesReconnectable:A,elementsSelectable:O,noPanClassName:o,onReconnect:d,onContextMenu:c,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,onClick:p,reconnectRadius:x,onDoubleClick:g,onReconnectStart:y,onReconnectEnd:w,rfId:s,onError:k,edgeTypes:l,disableKeyboardA11y:N},R))]})}gN.displayName="EdgeRenderer";const KD=v.memo(gN),ZD=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function QD({children:e}){const n=Wt(ZD);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function WD(e){const n=Dx(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),s.current=!0)},[e,n.viewportInitialized])}const JD=e=>e.panZoom?.syncViewport;function eL(e){const n=Wt(JD),s=An();return v.useEffect(()=>{e&&(n?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function tL(e){return e.connection.inProgress?{...e.connection,to:Zo(e.connection.to,e.transform)}:{...e.connection}}function nL(e){return tL}function rL(e){const n=nL();return Wt(n,_n)}const sL=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function aL({containerStyle:e,style:n,type:s,component:l}){const{nodesConnectable:o,width:d,height:c,isValid:h,inProgress:m}=Wt(sL,_n);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:Kn(["react-flow__connection",pw(h)]),children:t.jsx(bN,{style:n,type:s,CustomComponent:l,isValid:h})})})}const bN=({style:e,type:n=Da.Bezier,CustomComponent:s,isValid:l})=>{const{inProgress:o,from:d,fromNode:c,fromHandle:h,fromPosition:m,to:f,toNode:p,toHandle:x,toPosition:g,pointer:y}=rL();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:g,connectionStatus:pw(l),toNode:p,toHandle:x,pointer:y});let w="";const N={sourceX:d.x,sourceY:d.y,sourcePosition:m,targetX:f.x,targetY:f.y,targetPosition:g};switch(n){case Da.Bezier:[w]=Tw(N);break;case Da.SimpleBezier:[w]=aN(N);break;case Da.Step:[w]=Bm({...N,borderRadius:0});break;case Da.SmoothStep:[w]=Bm(N);break;default:[w]=Aw(N)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};bN.displayName="ConnectionLine";const lL={};function Bv(e=lL){v.useRef(e),An(),v.useEffect(()=>{},[e])}function iL(){An(),v.useRef(!1),v.useEffect(()=>{},[])}function yN({nodeTypes:e,edgeTypes:n,onInit:s,onNodeClick:l,onEdgeClick:o,onNodeDoubleClick:d,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:x,onSelectionStart:g,onSelectionEnd:y,connectionLineType:w,connectionLineStyle:N,connectionLineComponent:C,connectionLineContainerStyle:A,selectionKeyCode:O,selectionOnDrag:k,selectionMode:S,multiSelectionKeyCode:R,panActivationKeyCode:D,zoomActivationKeyCode:Y,deleteKeyCode:z,onlyRenderVisibleElements:K,elementsSelectable:U,defaultViewport:G,translateExtent:q,minZoom:E,maxZoom:T,preventScrolling:L,defaultMarkerColor:_,zoomOnScroll:P,zoomOnPinch:V,panOnScroll:W,panOnScrollSpeed:B,panOnScrollMode:F,zoomOnDoubleClick:X,panOnDrag:I,onPaneClick:M,onPaneMouseEnter:H,onPaneMouseMove:Z,onPaneMouseLeave:ee,onPaneScroll:ne,onPaneContextMenu:ae,paneClickDistance:fe,nodeClickDistance:Ne,onEdgeContextMenu:Le,onEdgeMouseEnter:ye,onEdgeMouseMove:je,onEdgeMouseLeave:Te,reconnectRadius:ze,onReconnect:Xe,onReconnectStart:nt,onReconnectEnd:tt,noDragClassName:Mt,noWheelClassName:se,noPanClassName:Ee,disableKeyboardA11y:rt,nodeExtent:vt,rfId:Kt,viewport:we,onViewportChange:De}){return Bv(e),Bv(n),iL(),WD(s),eL(we),t.jsx(wD,{onPaneClick:M,onPaneMouseEnter:H,onPaneMouseMove:Z,onPaneMouseLeave:ee,onPaneContextMenu:ae,onPaneScroll:ne,paneClickDistance:fe,deleteKeyCode:z,selectionKeyCode:O,selectionOnDrag:k,selectionMode:S,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:R,panActivationKeyCode:D,zoomActivationKeyCode:Y,elementsSelectable:U,zoomOnScroll:P,zoomOnPinch:V,zoomOnDoubleClick:X,panOnScroll:W,panOnScrollSpeed:B,panOnScrollMode:F,panOnDrag:I,defaultViewport:G,translateExtent:q,minZoom:E,maxZoom:T,onSelectionContextMenu:x,preventScrolling:L,noDragClassName:Mt,noWheelClassName:se,noPanClassName:Ee,disableKeyboardA11y:rt,onViewportChange:De,isControlledViewport:!!we,children:t.jsxs(QD,{children:[t.jsx(KD,{edgeTypes:n,onEdgeClick:o,onEdgeDoubleClick:c,onReconnect:Xe,onReconnectStart:nt,onReconnectEnd:tt,onlyRenderVisibleElements:K,onEdgeContextMenu:Le,onEdgeMouseEnter:ye,onEdgeMouseMove:je,onEdgeMouseLeave:Te,reconnectRadius:ze,defaultMarkerColor:_,noPanClassName:Ee,disableKeyboardA11y:rt,rfId:Kt}),t.jsx(aL,{style:N,type:w,component:C,containerStyle:A}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(MD,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:p,nodeClickDistance:Ne,onlyRenderVisibleElements:K,noPanClassName:Ee,noDragClassName:Mt,disableKeyboardA11y:rt,nodeExtent:vt,rfId:Kt}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}yN.displayName="GraphView";const oL=v.memo(yN),Hv=({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m=.5,maxZoom:f=2,nodeOrigin:p,nodeExtent:x,zIndexMode:g="basic"}={})=>{const y=new Map,w=new Map,N=new Map,C=new Map,A=l??n??[],O=s??e??[],k=p??[0,0],S=x??Do;Rw(N,C,A);const R=Pm(O,y,w,{nodeOrigin:k,nodeExtent:S,zIndexMode:g});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}=Ex(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:A,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:{...xw},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:NO,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:mw,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},cL=({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:p,nodeExtent:x,zIndexMode:g})=>ER((y,w)=>{async function N(){const{nodeLookup:C,panZoom:A,fitViewOptions:O,fitViewResolver:k,width:S,height:R,minZoom:D,maxZoom:Y}=w();A&&(await jO({nodes:C,width:S,height:R,panZoom:A,minZoom:D,maxZoom:Y},O),k?.resolve(!0),y({fitViewResolver:null}))}return{...Hv({nodes:e,edges:n,width:o,height:d,fitView:c,fitViewOptions:h,minZoom:m,maxZoom:f,nodeOrigin:p,nodeExtent:x,defaultNodes:s,defaultEdges:l,zIndexMode:g}),setNodes:C=>{const{nodeLookup:A,parentLookup:O,nodeOrigin:k,elevateNodesOnSelect:S,fitViewQueued:R,zIndexMode:D}=w(),Y=Pm(C,A,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:A,edgeLookup:O}=w();Rw(A,O,C),y({edges:C})},setDefaultNodesAndEdges:(C,A)=>{if(C){const{setNodes:O}=w();O(C),y({hasDefaultNodes:!0})}if(A){const{setEdges:O}=w();O(A),y({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:A,nodeLookup:O,parentLookup:k,domNode:S,nodeOrigin:R,nodeExtent:D,debug:Y,fitViewQueued:z,zIndexMode:K}=w(),{changes:U,updatedInternals:G}=FO(C,O,k,S,R,D,K);G&&(PO(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),A?.(U)))},updateNodePositions:(C,A=!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),q=!!(G?.expandParent&&G?.parentId&&U?.position),E={id:K,type:"position",position:q?{x:Math.max(0,U.position.x),y:Math.max(0,U.position.y)}:U.position,dragging:A};if(G&&D.inProgress&&D.fromNode.id===G.id){const T=xl(G,D.fromHandle,mt.Left,!0);Y({...D,from:T})}q&&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=Rx(O,S,K,U);k.push(...G)}for(const K of z.values())k=K(k);R(k)},triggerNodeChanges:C=>{const{onNodesChange:A,setNodes:O,nodes:k,hasDefaultNodes:S,debug:R}=w();if(C?.length){if(S){const D=Xw(C,k);O(D)}R&&console.log("React Flow: trigger node changes",C),A?.(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:A,setEdges:O,edges:k,hasDefaultEdges:S,debug:R}=w();if(C?.length){if(S){const D=Kw(C,k);O(D)}R&&console.log("React Flow: trigger edge changes",C),A?.(C)}},addSelectedNodes:C=>{const{multiSelectionActive:A,edgeLookup:O,nodeLookup:k,triggerNodeChanges:S,triggerEdgeChanges:R}=w();if(A){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:A,edgeLookup:O,nodeLookup:k,triggerNodeChanges:S,triggerEdgeChanges:R}=w();if(A){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:A}={})=>{const{edges:O,nodes:k,nodeLookup:S,triggerNodeChanges:R,triggerEdgeChanges:D}=w(),Y=C||k,z=A||O,K=[];for(const G of Y){if(!G.selected)continue;const q=S.get(G.id);q&&(q.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:A,maxZoom:O}=w();A?.setScaleExtent([C,O]),y({minZoom:C})},setMaxZoom:C=>{const{panZoom:A,minZoom:O}=w();A?.setScaleExtent([O,C]),y({maxZoom:C})},setTranslateExtent:C=>{w().panZoom?.setTranslateExtent(C),y({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:A,triggerNodeChanges:O,triggerEdgeChanges:k,elementsSelectable:S}=w();if(!S)return;const R=A.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:A,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]||(Pm(A,O,k,{nodeOrigin:S,nodeExtent:C,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:Y}),y({nodeExtent:C}))},panBy:C=>{const{transform:A,width:O,height:k,panZoom:S,translateExtent:R}=w();return YO({delta:C,panZoom:S,transform:A,translateExtent:R,width:O,height:k})},setCenter:async(C,A,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-A*Y,zoom:Y},{duration:O?.duration,ease:O?.ease,interpolate:O?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...xw}})},updateConnection:C=>{y({connection:C})},reset:()=>y({...Hv()})}},Object.is);function dL({initialNodes:e,initialEdges:n,defaultNodes:s,defaultEdges:l,initialWidth:o,initialHeight:d,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:m,fitView:f,nodeOrigin:p,nodeExtent:x,zIndexMode:g,children:y}){const[w]=v.useState(()=>cL({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:o,height:d,fitView:f,minZoom:c,maxZoom:h,fitViewOptions:m,nodeOrigin:p,nodeExtent:x,zIndexMode:g}));return t.jsx(TR,{value:w,children:t.jsx(QR,{children:y})})}function uL({children:e,nodes:n,edges:s,defaultNodes:l,defaultEdges:o,width:d,height:c,fitView:h,fitViewOptions:m,minZoom:f,maxZoom:p,nodeOrigin:x,nodeExtent:g,zIndexMode:y}){return v.useContext(cu)?t.jsx(t.Fragment,{children:e}):t.jsx(dL,{initialNodes:n,initialEdges:s,defaultNodes:l,defaultEdges:o,initialWidth:d,initialHeight:c,fitView:h,initialFitViewOptions:m,initialMinZoom:f,initialMaxZoom:p,nodeOrigin:x,nodeExtent:g,zIndexMode:y,children:e})}const fL={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function hL({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,className:o,nodeTypes:d,edgeTypes:c,onNodeClick:h,onEdgeClick:m,onInit:f,onMove:p,onMoveStart:x,onMoveEnd:g,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:C,onClickConnectEnd:A,onNodeMouseEnter:O,onNodeMouseMove:k,onNodeMouseLeave:S,onNodeContextMenu:R,onNodeDoubleClick:D,onNodeDragStart:Y,onNodeDrag:z,onNodeDragStop:K,onNodesDelete:U,onEdgesDelete:G,onDelete:q,onSelectionChange:E,onSelectionDragStart:T,onSelectionDrag:L,onSelectionDragStop:_,onSelectionContextMenu:P,onSelectionStart:V,onSelectionEnd:W,onBeforeDelete:B,connectionMode:F,connectionLineType:X=Da.Bezier,connectionLineStyle:I,connectionLineComponent:M,connectionLineContainerStyle:H,deleteKeyCode:Z="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:ne=!1,selectionMode:ae=Lo.Full,panActivationKeyCode:fe="Space",multiSelectionKeyCode:Ne=zo()?"Meta":"Control",zoomActivationKeyCode:Le=zo()?"Meta":"Control",snapToGrid:ye,snapGrid:je,onlyRenderVisibleElements:Te=!1,selectNodesOnDrag:ze,nodesDraggable:Xe,autoPanOnNodeFocus:nt,nodesConnectable:tt,nodesFocusable:Mt,nodeOrigin:se=Yw,edgesFocusable:Ee,edgesReconnectable:rt,elementsSelectable:vt=!0,defaultViewport:Kt=PR,minZoom:we=.5,maxZoom:De=2,translateExtent:Ue=Do,preventScrolling:Je=!0,nodeExtent:pt,defaultMarkerColor:Jt="#b1b1b7",zoomOnScroll:ln=!0,zoomOnPinch:Ht=!0,panOnScroll:Lt=!1,panOnScrollSpeed:_t=.5,panOnScrollMode:St=cl.Free,zoomOnDoubleClick:en=!0,panOnDrag:tn=!0,onPaneClick:ve,onPaneMouseEnter:qe,onPaneMouseMove:Rt,onPaneMouseLeave:zt,onPaneScroll:Ve,onPaneContextMenu:Pt,paneClickDistance:yn=1,nodeClickDistance:nn=0,children:un,onReconnect:vn,onReconnectStart:Dt,onReconnectEnd:jn,onEdgeContextMenu:Et,onEdgeDoubleClick:ie,onEdgeMouseEnter:Pe,onEdgeMouseMove:Fe,onEdgeMouseLeave:st,reconnectRadius:ot=10,onNodesChange:Ct,onEdgesChange:dt,noDragClassName:Qe="nodrag",noWheelClassName:at="nowheel",noPanClassName:fn="nopan",fitView:xe,fitViewOptions:Ke,connectOnClick:xt,attributionPosition:At,proOptions:On,defaultEdgeOptions:hr,elevateNodesOnSelect:mr=!0,elevateEdgesOnSelect:er=!1,disableKeyboardA11y:or=!1,autoPanOnConnect:tr,autoPanOnNodeDrag:wn,autoPanSpeed:ts,connectionRadius:ns,isValidConnection:ce,onError:_e,style:$e,id:Yt,nodeDragThreshold:br,connectionDragThreshold:rs,viewport:yr,onViewportChange:gs,width:cr,height:Rn,colorMode:ss="light",debug:Os,onScroll:as,ariaLabelConfig:Ur,zIndexMode:Pn="basic",...Rs},Dn){const qr=Yt||"1",xr=FR(ss),Ar=v.useCallback(nr=>{nr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),as?.(nr)},[as]);return t.jsx("div",{"data-testid":"rf__wrapper",...Rs,onScroll:Ar,style:{...$e,...fL},ref:Dn,className:Kn(["react-flow",o,xr]),id:Yt,role:"application",children:t.jsxs(uL,{nodes:e,edges:n,width:cr,height:Rn,fitView:xe,fitViewOptions:Ke,minZoom:we,maxZoom:De,nodeOrigin:se,nodeExtent:pt,zIndexMode:Pn,children:[t.jsx(oL,{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:fe,zoomActivationKeyCode:Le,onlyRenderVisibleElements:Te,defaultViewport:Kt,translateExtent:Ue,minZoom:we,maxZoom:De,preventScrolling:Je,zoomOnScroll:ln,zoomOnPinch:Ht,zoomOnDoubleClick:en,panOnScroll:Lt,panOnScrollSpeed:_t,panOnScrollMode:St,panOnDrag:tn,onPaneClick:ve,onPaneMouseEnter:qe,onPaneMouseMove:Rt,onPaneMouseLeave:zt,onPaneScroll:Ve,onPaneContextMenu:Pt,paneClickDistance:yn,nodeClickDistance:nn,onSelectionContextMenu:P,onSelectionStart:V,onSelectionEnd:W,onReconnect:vn,onReconnectStart:Dt,onReconnectEnd:jn,onEdgeContextMenu:Et,onEdgeDoubleClick:ie,onEdgeMouseEnter:Pe,onEdgeMouseMove:Fe,onEdgeMouseLeave:st,reconnectRadius:ot,defaultMarkerColor:Jt,noDragClassName:Qe,noWheelClassName:at,noPanClassName:fn,rfId:qr,disableKeyboardA11y:or,nodeExtent:pt,viewport:yr,onViewportChange:gs}),t.jsx(VR,{nodes:e,edges:n,defaultNodes:s,defaultEdges:l,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:C,onClickConnectEnd:A,nodesDraggable:Xe,autoPanOnNodeFocus:nt,nodesConnectable:tt,nodesFocusable:Mt,edgesFocusable:Ee,edgesReconnectable:rt,elementsSelectable:vt,elevateNodesOnSelect:mr,elevateEdgesOnSelect:er,minZoom:we,maxZoom:De,nodeExtent:pt,onNodesChange:Ct,onEdgesChange:dt,snapToGrid:ye,snapGrid:je,connectionMode:F,translateExtent:Ue,connectOnClick:xt,defaultEdgeOptions:hr,fitView:xe,fitViewOptions:Ke,onNodesDelete:U,onEdgesDelete:G,onDelete:q,onNodeDragStart:Y,onNodeDrag:z,onNodeDragStop:K,onSelectionDrag:L,onSelectionDragStart:T,onSelectionDragStop:_,onMove:p,onMoveStart:x,onMoveEnd:g,noPanClassName:fn,nodeOrigin:se,rfId:qr,autoPanOnConnect:tr,autoPanOnNodeDrag:wn,autoPanSpeed:ts,onError:_e,connectionRadius:ns,isValidConnection:ce,selectNodesOnDrag:ze,nodeDragThreshold:br,connectionDragThreshold:rs,onBeforeDelete:B,debug:Os,ariaLabelConfig:Ur,zIndexMode:Pn}),t.jsx(HR,{onSelectionChange:E}),un,t.jsx(LR,{proOptions:On,position:At}),t.jsx(DR,{rfId:qr,disableKeyboardA11y:or})]})})}var mL=Zw(hL);function xL(e){const[n,s]=v.useState(e),l=v.useCallback(o=>s(d=>Xw(o,d)),[]);return[n,s,l]}function pL(e){const[n,s]=v.useState(e),l=v.useCallback(o=>s(d=>Kw(o,d)),[]);return[n,s,l]}function gL({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:Kn(["react-flow__background-pattern",s,l])})}function bL({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:Kn(["react-flow__background-pattern","dots",n])})}var Ia;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ia||(Ia={}));const yL={[Ia.Dots]:1,[Ia.Lines]:1,[Ia.Cross]:6},vL=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function vN({id:e,variant:n=Ia.Dots,gap:s=20,size:l,lineWidth:o=1,offset:d=0,color:c,bgColor:h,style:m,className:f,patternClassName:p}){const x=v.useRef(null),{transform:g,patternId:y}=Wt(vL,_n),w=l||yL[n],N=n===Ia.Dots,C=n===Ia.Cross,A=Array.isArray(s)?s:[s,s],O=[A[0]*g[2]||1,A[1]*g[2]||1],k=w*g[2],S=Array.isArray(d)?d:[d,d],R=C?[k,k]:O,D=[S[0]*g[2]||1+R[0]/2,S[1]*g[2]||1+R[1]/2],Y=`${y}${e||""}`;return t.jsxs("svg",{className:Kn(["react-flow__background",f]),style:{...m,...uu,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:x,"data-testid":"rf__background",children:[t.jsx("pattern",{id:Y,x:g[0]%O[0],y:g[1]%O[1],width:O[0],height:O[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:N?t.jsx(bL,{radius:k/2,className:p}):t.jsx(gL,{dimensions:R,lineWidth:o,variant:n,className:p})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${Y})`})]})}vN.displayName="Background";const jL=v.memo(vN);function wL(){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 NL(){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 kL(){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 SL(){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 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 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 gd({children:e,className:n,...s}){return t.jsx("button",{type:"button",className:Kn(["react-flow__controls-button",n]),...s,children:e})}const EL=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function jN({style:e,showZoom:n=!0,showFitView:s=!0,showInteractive:l=!0,fitViewOptions:o,onZoomIn:d,onZoomOut:c,onFitView:h,onInteractiveChange:m,className:f,children:p,position:x="bottom-left",orientation:g="vertical","aria-label":y}){const w=An(),{isInteractive:N,minZoomReached:C,maxZoomReached:A,ariaLabelConfig:O}=Wt(EL,_n),{zoomIn:k,zoomOut:S,fitView:R}=Dx(),D=()=>{k(),d?.()},Y=()=>{S(),c?.()},z=()=>{R(o),h?.()},K=()=>{w.setState({nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N}),m?.(!N)},U=g==="horizontal"?"horizontal":"vertical";return t.jsxs(du,{className:Kn(["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(gd,{onClick:D,className:"react-flow__controls-zoomin",title:O["controls.zoomIn.ariaLabel"],"aria-label":O["controls.zoomIn.ariaLabel"],disabled:A,children:t.jsx(wL,{})}),t.jsx(gd,{onClick:Y,className:"react-flow__controls-zoomout",title:O["controls.zoomOut.ariaLabel"],"aria-label":O["controls.zoomOut.ariaLabel"],disabled:C,children:t.jsx(NL,{})})]}),s&&t.jsx(gd,{className:"react-flow__controls-fitview",onClick:z,title:O["controls.fitView.ariaLabel"],"aria-label":O["controls.fitView.ariaLabel"],children:t.jsx(kL,{})}),l&&t.jsx(gd,{className:"react-flow__controls-interactive",onClick:K,title:O["controls.interactive.ariaLabel"],"aria-label":O["controls.interactive.ariaLabel"],children:N?t.jsx(CL,{}):t.jsx(SL,{})}),p]})}jN.displayName="Controls";const TL=v.memo(jN);function _L({id:e,x:n,y:s,width:l,height:o,style:d,color:c,strokeColor:h,strokeWidth:m,className:f,borderRadius:p,shapeRendering:x,selected:g,onClick:y}){const{background:w,backgroundColor:N}=d||{},C=c||w||N;return t.jsx("rect",{className:Kn(["react-flow__minimap-node",{selected:g},f]),x:n,y:s,rx:p,ry:p,width:l,height:o,style:{fill:C,stroke:h,strokeWidth:m},shapeRendering:x,onClick:y?A=>y(A,e):void 0})}const AL=v.memo(_L),ML=e=>e.nodes.map(n=>n.id),tm=e=>e instanceof Function?e:()=>e;function OL({nodeStrokeColor:e,nodeColor:n,nodeClassName:s="",nodeBorderRadius:l=5,nodeStrokeWidth:o,nodeComponent:d=AL,onClick:c}){const h=Wt(ML,_n),m=tm(n),f=tm(e),p=tm(s),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:h.map(g=>t.jsx(DL,{id:g,nodeColorFunc:m,nodeStrokeColorFunc:f,nodeClassNameFunc:p,nodeBorderRadius:l,nodeStrokeWidth:o,NodeComponent:d,onClick:c,shapeRendering:x},g))})}function RL({id:e,nodeColorFunc:n,nodeStrokeColorFunc:s,nodeClassNameFunc:l,nodeBorderRadius:o,nodeStrokeWidth:d,shapeRendering:c,NodeComponent:h,onClick:m}){const{node:f,x:p,y:x,width:g,height:y}=Wt(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:A,y:O}=N.internals.positionAbsolute,{width:k,height:S}=na(C);return{node:C,x:A,y:O,width:k,height:S}},_n);return!f||f.hidden||!ww(f)?null:t.jsx(h,{x:p,y:x,width:g,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 DL=v.memo(RL);var LL=v.memo(OL);const IL=200,zL=150,$L=e=>!e.hidden,BL=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?jw(Xo(e.nodeLookup,{filter:$L}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},HL="react-flow__minimap-desc";function wN({style:e,className:n,nodeStrokeColor:s,nodeColor:l,nodeClassName:o="",nodeBorderRadius:d=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:m,maskColor:f,maskStrokeColor:p,maskStrokeWidth:x,position:g="bottom-right",onClick:y,onNodeClick:w,pannable:N=!1,zoomable:C=!1,ariaLabel:A,inversePan:O,zoomStep:k=1,offsetScale:S=5}){const R=An(),D=v.useRef(null),{boundingRect:Y,viewBB:z,rfId:K,panZoom:U,translateExtent:G,flowWidth:q,flowHeight:E,ariaLabelConfig:T}=Wt(BL,_n),L=e?.width??IL,_=e?.height??zL,P=Y.width/L,V=Y.height/_,W=Math.max(P,V),B=W*L,F=W*_,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=`${HL}-${K}`,ne=v.useRef(0),ae=v.useRef();ne.current=W,v.useEffect(()=>{if(D.current&&U)return ae.current=tR({domNode:D.current,panZoom:U,getTransform:()=>R.getState().transform,getViewScale:()=>ne.current}),()=>{ae.current?.destroy()}},[U]),v.useEffect(()=>{ae.current?.update({translateExtent:G,width:q,height:E,inversePan:O,pannable:N,zoomStep:k,zoomable:C})},[N,C,O,k,G,q,E]);const fe=y?ye=>{const[je,Te]=ae.current?.pointer(ye)||[0,0];y(ye,{x:je,y:Te})}:void 0,Ne=w?v.useCallback((ye,je)=>{const Te=R.getState().nodeLookup.get(je).internals.userNode;w(ye,Te)},[]):void 0,Le=A??T["minimap.ariaLabel"];return t.jsx(du,{position:g,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 p=="string"?p: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:Kn(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:L,height:_,viewBox:`${I} ${M} ${H} ${Z}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:D,onClick:fe,children:[Le&&t.jsx("title",{id:ee,children:Le}),t.jsx(LL,{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"})]})})}wN.displayName="MiniMap";const PL=v.memo(wN),UL=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,qL={[mi.Line]:"right",[mi.Handle]:"bottom-right"};function VL({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:p=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:g,autoScale:y=!0,shouldResize:w,onResizeStart:N,onResize:C,onResizeEnd:A}){const O=eN(),k=typeof e=="string"?e:O,S=An(),R=v.useRef(null),D=s===mi.Handle,Y=Wt(v.useCallback(UL(D&&y),[D,y]),_n),z=v.useRef(null),K=n??qL[s];v.useEffect(()=>{if(!(!R.current||!k))return z.current||(z.current=xR({domNode:R.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:G,transform:q,snapGrid:E,snapToGrid:T,nodeOrigin:L,domNode:_}=S.getState();return{nodeLookup:G,transform:q,snapGrid:E,snapToGrid:T,nodeOrigin:L,paneDomNode:_}},onChange:(G,q)=>{const{triggerNodeChanges:E,nodeLookup:T,parentLookup:L,nodeOrigin:_}=S.getState(),P=[],V={x:G.x,y:G.y},W=T.get(k);if(W&&W.expandParent&&W.parentId){const B=W.origin??_,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,...Nw({x:G.x??W.position.x,y:G.y??W.position.y},{width:F,height:X},W.parentId,T,B)}},M=Rx([I],T,L,_);P.push(...M),V.x=G.x?Math.max(B[0]*F,G.x):void 0,V.y=G.y?Math.max(B[1]*X,G.y):void 0}if(V.x!==void 0&&V.y!==void 0){const B={id:k,type:"position",position:{...V}};P.push(B)}if(G.width!==void 0&&G.height!==void 0){const F={id:k,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:G.width,height:G.height}};P.push(F)}for(const B of q){const F={...B,type:"position"};P.push(F)}E(P)},onEnd:({width:G,height:q})=>{const E={id:k,type:"dimensions",resizing:!1,dimensions:{width:G,height:q}};S.getState().triggerNodeChanges([E])}})),z.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:m,maxWidth:f,maxHeight:p},keepAspectRatio:x,resizeDirection:g,onResizeStart:N,onResize:C,onResizeEnd:A,shouldResize:w}),()=>{z.current?.destroy()}},[K,h,m,f,p,x,N,C,A,w]);const U=K.split("-");return t.jsx("div",{className:Kn(["react-flow__resize-control","nodrag",...U,s,l]),ref:R,style:{...o,scale:Y,...c&&{[D?"backgroundColor":"borderColor"]:c}},children:d})}v.memo(VL);var dn=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ms=dn((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",_="\0",P="",V=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[_]={})}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]=_,this._children[M]={},this._children[_][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=_;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!==_)return H}}children(M=_){if(this._isCompound){var H=this._children[M];if(H)return Object.keys(H)}else{if(M===_)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,fe]){M(ae)&&H.setNode(ae,fe)}),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 fe=Z.parent(ae);return fe===void 0||H.hasNode(fe)?(ee[ae]=fe,fe):fe in ee?ee[fe]:ne(fe)}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 fe=F(this._isDirected,M,H,Z);if(Object.hasOwn(this._edgeLabels,fe))return ne&&(this._edgeLabels[fe]=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[fe]=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[fe]=Ne,W(this._preds[H],M),W(this._sucs[M],H),this._in[H][fe]=Ne,this._out[M][fe]=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 fe=ne;ne=ae,ae=fe}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 fe=ne;ne=ae,ae=fe}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=V}),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:_,read:W};function _(B){var F={options:{directed:B.isDirected(),multigraph:B.isMultigraph(),compound:B.isCompound()},nodes:P(B),edges:V(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 V(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}}),p=o((E,T)=>{T.exports=_;var L=()=>1;function _(V,W,B,F){return P(V,String(W),B||L,F||function(X){return V.outEdges(X)})}function P(V,W,B,F){var X={},I=!0,M=0,H=V.nodes(),Z=function(fe){var Ne=B(fe);X[fe.v].distance+Ne<X[fe.w].distance&&(X[fe.w]={distance:X[fe.v].distance+Ne,predecessor:fe.v},I=!0)},ee=function(){H.forEach(function(fe){F(fe).forEach(function(Ne){var Le=Ne.v===fe?Ne.v:Ne.w,ye=Le===Ne.v?Ne.w:Ne.v;Z({v:Le,w:ye})})})};H.forEach(function(fe){var Ne=fe===W?0:Number.POSITIVE_INFINITY;X[fe]={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(_){var P={},V=[],W;function B(F){Object.hasOwn(P,F)||(P[F]=!0,W.push(F),_.successors(F).forEach(B),_.predecessors(F).forEach(B))}return _.nodes().forEach(function(F){W=[],B(F),W.length&&V.push(W)}),V}}),g=o((E,T)=>{var L=class{constructor(){d(this,"_arr",[]),d(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(_){return _.key})}has(_){return Object.hasOwn(this._keyIndices,_)}priority(_){var P=this._keyIndices[_];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(_,P){var V=this._keyIndices;if(_=String(_),!Object.hasOwn(V,_)){var W=this._arr,B=W.length;return V[_]=B,W.push({key:_,priority:P}),this._decrease(B),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var _=this._arr.pop();return delete this._keyIndices[_.key],this._heapify(0),_.key}decrease(_,P){var V=this._keyIndices[_];if(P>this._arr[V].priority)throw new Error("New priority is greater than current priority. Key: "+_+" Old: "+this._arr[V].priority+" New: "+P);this._arr[V].priority=P,this._decrease(V)}_heapify(_){var P=this._arr,V=2*_,W=V+1,B=_;V<P.length&&(B=P[V].priority<P[B].priority?V:B,W<P.length&&(B=P[W].priority<P[B].priority?W:B),B!==_&&(this._swap(_,B),this._heapify(B)))}_decrease(_){for(var P=this._arr,V=P[_].priority,W;_!==0&&(W=_>>1,!(P[W].priority<V));)this._swap(_,W),_=W}_swap(_,P){var V=this._arr,W=this._keyIndices,B=V[_],F=V[P];V[_]=F,V[P]=B,W[F.key]=_,W[B.key]=P}};T.exports=L}),y=o((E,T)=>{var L=g();T.exports=P;var _=()=>1;function P(W,B,F,X){var I=function(M){return W.outEdges(M)};return V(W,String(B),F||_,X||I)}function V(W,B,F,X){var I={},M=new L,H,Z,ee=function(ne){var ae=ne.v!==H?ne.v:ne.w,fe=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<fe.distance&&(fe.distance=Le,fe.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=_;function _(P,V,W){return P.nodes().reduce(function(B,F){return B[F]=L(P,F,V,W),B},{})}}),N=o((E,T)=>{T.exports=L;function L(P,V,W){if(P[V].predecessor!==void 0)throw new Error("Invalid source vertex");if(P[W].predecessor===void 0&&W!==V)throw new Error("Invalid destination vertex");return{weight:P[W].distance,path:_(P,V,W)}}function _(P,V,W){for(var B=[],F=W;F!==V;)B.push(F),F=P[F].predecessor;return B.push(V),B.reverse()}}),C=o((E,T)=>{T.exports=L;function L(_){var P=0,V=[],W={},B=[];function F(X){var I=W[X]={onStack:!0,lowlink:P,index:P++};if(V.push(X),_.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=V.pop(),W[H].onStack=!1,M.push(H);while(X!==H);B.push(M)}}return _.nodes().forEach(function(X){Object.hasOwn(W,X)||F(X)}),B}}),A=o((E,T)=>{var L=C();T.exports=_;function _(P){return L(P).filter(function(V){return V.length>1||V.length===1&&P.hasEdge(V[0],V[0])})}}),O=o((E,T)=>{T.exports=_;var L=()=>1;function _(V,W,B){return P(V,W||L,B||function(F){return V.outEdges(F)})}function P(V,W,B){var F={},X=V.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],fe=Z[ee],Ne=ne.distance+ae.distance;Ne<fe.distance&&(fe.distance=Ne,fe.predecessor=ae.predecessor)})})}),F}}),k=o((E,T)=>{function L(P){var V={},W={},B=[];function F(X){if(Object.hasOwn(W,X))throw new _;Object.hasOwn(V,X)||(W[X]=!0,V[X]=!0,P.predecessors(X).forEach(F),delete W[X],B.push(X))}if(P.sinks().forEach(F),Object.keys(V).length!==P.nodeCount())throw new _;return B}var _=class extends Error{constructor(){super(...arguments)}};T.exports=L,L.CycleException=_}),S=o((E,T)=>{var L=k();T.exports=_;function _(P){try{L(P)}catch(V){if(V instanceof L.CycleException)return!1;throw V}return!0}}),R=o((E,T)=>{T.exports=L;function L(P,V,W,B,F){Array.isArray(V)||(V=[V]);var X=(P.isDirected()?P.successors:P.neighbors).bind(P),I={};return V.forEach(function(M){if(!P.hasNode(M))throw new Error("Graph does not have node: "+M);F=_(P,M,W==="post",I,X,B,F)}),F}function _(P,V,W,B,F,X,I){return Object.hasOwn(B,V)||(B[V]=!0,W||(I=X(I,V)),F(V).forEach(function(M){I=_(P,M,W,B,F,X,I)}),W&&(I=X(I,V))),I}}),D=o((E,T)=>{var L=R();T.exports=_;function _(P,V,W){return L(P,V,W,function(B,F){return B.push(F),B},[])}}),Y=o((E,T)=>{var L=D();T.exports=_;function _(P,V){return L(P,V,"post")}}),z=o((E,T)=>{var L=D();T.exports=_;function _(P,V){return L(P,V,"pre")}}),K=o((E,T)=>{var L=c(),_=g();T.exports=P;function P(V,W){var B=new L,F={},X=new _,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(V.nodeCount()===0)return B;V.nodes().forEach(function(Z){X.add(Z,Number.POSITIVE_INFINITY),B.setNode(Z)}),X.decrease(V.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: "+V);H=!0}V.nodeEdges(I).forEach(M)}return B}}),U=o((E,T)=>{var L=y(),_=p();T.exports=P;function P(W,B,F,X){return V(W,B,F,X||function(I){return W.outEdges(I)})}function V(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,fe=ae===ne.v?ne.w:ne.v;F({v:ae,w:fe})<0&&(I=!0)}if(I)return _(W,B,F,X)}return L(W,B,F,X)}}),G=o((E,T)=>{T.exports={bellmanFord:p(),components:x(),dijkstra:y(),dijkstraAll:w(),extractPath:N(),findCycles:A(),floydWarshall:O(),isAcyclic:S(),postorder:Y(),preorder:z(),prim:K(),shortestPaths:U(),reduce:R(),tarjan:C(),topsort:k()}}),q=m();n.exports={Graph:q.Graph,json:f(),alg:G(),version:q.version}}),FL=dn((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}),YL=dn((e,n)=>{var s=ms().Graph,l=FL();n.exports=d;var o=()=>1;function d(x,g){if(x.nodeCount()<=1)return[];let y=m(x,g||o);return c(y.graph,y.buckets,y.zeroIdx).flatMap(w=>x.outEdges(w.v,w.w))}function c(x,g,y){let w=[],N=g[g.length-1],C=g[0],A;for(;x.nodeCount();){for(;A=C.dequeue();)h(x,g,y,A);for(;A=N.dequeue();)h(x,g,y,A);if(x.nodeCount()){for(let O=g.length-2;O>0;--O)if(A=g[O].dequeue(),A){w=w.concat(h(x,g,y,A,!0));break}}}return w}function h(x,g,y,w,N){let C=N?[]:void 0;return x.inEdges(w.v).forEach(A=>{let O=x.edge(A),k=x.node(A.v);N&&C.push({v:A.v,w:A.w}),k.out-=O,f(g,y,k)}),x.outEdges(w.v).forEach(A=>{let O=x.edge(A),k=A.w,S=x.node(k);S.in-=O,f(g,y,S)}),x.removeNode(w.v),C}function m(x,g){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=g(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=p(N+w+3).map(()=>new l),A=w+1;return y.nodes().forEach(O=>{f(C,A,y.node(O))}),{graph:y,buckets:C,zeroIdx:A}}function f(x,g,y){y.out?y.in?x[y.out-y.in+g].enqueue(y):x[x.length-1].enqueue(y):x[0].enqueue(y)}function p(x){let g=[];for(let y=0;y<x;y++)g.push(y);return g}}),Xn=dn((e,n)=>{var s=ms().Graph;n.exports={addBorderNode:g,addDummyNode:l,applyWithChunking:N,asNonCompoundGraph:d,buildLayerMatrix:f,intersectRect:m,mapValues:z,maxRank:C,normalizeRanks:p,notime:k,partition:A,pick:Y,predecessorWeights:h,range:D,removeEmptyRanks:x,simplify:o,successorWeights:c,time:O,uniqueId:R,zipObject:K};function l(U,G,q,E){for(var T=E;U.hasNode(T);)T=R(E);return q.dummy=G,U.setNode(T,q),T}function o(U){let G=new s().setGraph(U.graph());return U.nodes().forEach(q=>G.setNode(q,U.node(q))),U.edges().forEach(q=>{let E=G.edge(q.v,q.w)||{weight:0,minlen:1},T=U.edge(q);G.setEdge(q.v,q.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(q=>{U.children(q).length||G.setNode(q,U.node(q))}),U.edges().forEach(q=>{G.setEdge(q,U.edge(q))}),G}function c(U){let G=U.nodes().map(q=>{let E={};return U.outEdges(q).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(q=>{let E={};return U.inEdges(q).forEach(T=>{E[T.v]=(E[T.v]||0)+U.edge(T).weight}),E});return K(U.nodes(),G)}function m(U,G){let q=U.x,E=U.y,T=G.x-q,L=G.y-E,_=U.width/2,P=U.height/2;if(!T&&!L)throw new Error("Not possible to find intersection inside of the rectangle");let V,W;return Math.abs(L)*_>Math.abs(T)*P?(L<0&&(P=-P),V=P*T/L,W=P):(T<0&&(_=-_),V=_,W=_*L/T),{x:q+V,y:E+W}}function f(U){let G=D(C(U)+1).map(()=>[]);return U.nodes().forEach(q=>{let E=U.node(q),T=E.rank;T!==void 0&&(G[T][E.order]=q)}),G}function p(U){let G=U.nodes().map(E=>{let T=U.node(E).rank;return T===void 0?Number.MAX_VALUE:T}),q=N(Math.min,G);U.nodes().forEach(E=>{let T=U.node(E);Object.hasOwn(T,"rank")&&(T.rank-=q)})}function x(U){let G=U.nodes().map(_=>U.node(_).rank).filter(_=>_!==void 0),q=N(Math.min,G),E=[];U.nodes().forEach(_=>{let P=U.node(_).rank-q;E[P]||(E[P]=[]),E[P].push(_)});let T=0,L=U.graph().nodeRankFactor;Array.from(E).forEach((_,P)=>{_===void 0&&P%L!==0?--T:_!==void 0&&T&&_.forEach(V=>U.node(V).rank+=T)})}function g(U,G,q,E){let T={width:0,height:0};return arguments.length>=4&&(T.rank=q,T.order=E),l(U,"border",T,G)}function y(U,G=w){let q=[];for(let E=0;E<U.length;E+=G){let T=U.slice(E,E+G);q.push(T)}return q}var w=65535;function N(U,G){if(G.length>w){let q=y(G);return U.apply(null,q.map(E=>U.apply(null,E)))}else return U.apply(null,G)}function C(U){let G=U.nodes().map(q=>{let E=U.node(q).rank;return E===void 0?Number.MIN_VALUE:E});return N(Math.max,G)}function A(U,G){let q={lhs:[],rhs:[]};return U.forEach(E=>{G(E)?q.lhs.push(E):q.rhs.push(E)}),q}function O(U,G){let q=Date.now();try{return G()}finally{console.log(U+" time: "+(Date.now()-q)+"ms")}}function k(U,G){return G()}var S=0;function R(U){var G=++S;return U+(""+G)}function D(U,G,q=1){G==null&&(G=U,U=0);let E=L=>L<G;q<0&&(E=L=>G<L);let T=[];for(let L=U;E(L);L+=q)T.push(L);return T}function Y(U,G){let q={};for(let E of G)U[E]!==void 0&&(q[E]=U[E]);return q}function z(U,G){let q=G;return typeof G=="string"&&(q=E=>E[G]),Object.entries(U).reduce((E,[T,L])=>(E[T]=q(L,T),E),{})}function K(U,G){return U.reduce((q,E,T)=>(q[E]=G[T],q),{})}}),GL=dn((e,n)=>{var s=YL(),l=Xn().uniqueId;n.exports={run:o,undo:c};function o(h){(h.graph().acyclicer==="greedy"?s(h,m(h)):d(h)).forEach(f=>{let p=h.edge(f);h.removeEdge(f),p.forwardName=f.name,p.reversed=!0,h.setEdge(f.w,f.v,p,l("rev"))});function m(f){return p=>f.edge(p).weight}}function d(h){let m=[],f={},p={};function x(g){Object.hasOwn(p,g)||(p[g]=!0,f[g]=!0,h.outEdges(g).forEach(y=>{Object.hasOwn(f,y.w)?m.push(y):x(y.w)}),delete f[g])}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 p=f.forwardName;delete f.reversed,delete f.forwardName,h.setEdge(m.w,m.v,f,p)}})}}),XL=dn((e,n)=>{var s=Xn();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,p=h.w,x=c.node(p).rank,g=h.name,y=c.edge(h),w=y.labelRank;if(x===f+1)return;c.removeEdge(h);let N,C,A;for(A=0,++f;f<x;++A,++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},g),A===0&&c.graph().dummyChains.push(N),m=N;c.setEdge(m,p,{weight:y.weight},g)}function d(c){c.graph().dummyChains.forEach(h=>{let m=c.node(h),f=m.edgeLabel,p;for(c.setEdge(m.edgeObj,f);m.dummy;)p=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=p,m=c.node(h)})}}),Yd=dn((e,n)=>{var{applyWithChunking:s}=Xn();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 p=d.outEdges(m).map(g=>g==null?Number.POSITIVE_INFINITY:h(g.w)-d.edge(g).minlen);var x=s(Math.min,p);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}}),NN=dn((e,n)=>{var s=ms().Graph,l=Yd().slack;n.exports=o;function o(m){var f=new s({directed:!1}),p=m.nodes()[0],x=m.nodeCount();f.setNode(p,{});for(var g,y;d(f,m)<x;)g=c(f,m),y=f.hasNode(g.v)?l(m,g):-l(m,g),h(f,m,y);return f}function d(m,f){function p(x){f.nodeEdges(x).forEach(g=>{var y=g.v,w=x===y?g.w:y;!m.hasNode(w)&&!l(f,g)&&(m.setNode(w,{}),m.setEdge(x,w,{}),p(w))})}return m.nodes().forEach(p),m.nodeCount()}function c(m,f){return f.edges().reduce((p,x)=>{let g=Number.POSITIVE_INFINITY;return m.hasNode(x.v)!==m.hasNode(x.w)&&(g=l(f,x)),g<p[0]?[g,x]:p},[Number.POSITIVE_INFINITY,null])[1]}function h(m,f,p){m.nodes().forEach(x=>f.node(x).rank+=p)}}),KL=dn((e,n)=>{var s=NN(),l=Yd().slack,o=Yd().longestPath,d=ms().alg.preorder,c=ms().alg.postorder,h=Xn().simplify;n.exports=m,m.initLowLimValues=g,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);g(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=>p(S,R,Y))}function p(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(q=>{var E=q.v===D,T=E?q.w:q.v;if(T!==z){var L=E===K,_=R.edge(q).weight;if(G+=L?_:-_,O(S,D,T)){var P=S.edge(D,T).cutvalue;G+=L?-P:P}}}),G}function g(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,q=!1;K.lim>U.lim&&(G=U,q=!0);var E=R.edges().filter(T=>q===k(S,S.node(T.v),G)&&q!==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,{}),g(S),f(S,R),A(S,R)}function A(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}}),ZL=dn((e,n)=>{var s=Yd(),l=s.longestPath,o=NN(),d=KL();n.exports=c;function c(p){var x=p.graph().ranker;if(x instanceof Function)return x(p);switch(p.graph().ranker){case"network-simplex":f(p);break;case"tight-tree":m(p);break;case"longest-path":h(p);break;case"none":break;default:f(p)}}var h=l;function m(p){l(p),o(p)}function f(p){d(p)}}),QL=dn((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,p=l(d,c,f.v,f.w),x=p.path,g=p.lca,y=0,w=x[y],N=!0;for(;h!==f.w;){if(m=d.node(h),N){for(;(w=x[y])!==g&&d.node(w).maxRank<m.rank;)y++;w===g&&(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=[],p=[],x=Math.min(c[h].low,c[m].low),g=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||g>c[y].lim));for(w=y,y=m;(y=d.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function o(d){let c={},h=0;function m(f){let p=h;d.children(f).forEach(m),c[f]={low:p,lim:h++}}return d.children().forEach(m),c}}),WL=dn((e,n)=>{var s=Xn();n.exports={run:l,cleanup:h};function l(m){let f=s.addDummyNode(m,"root",{},"_root"),p=d(m),x=Object.values(p),g=s.applyWithChunking(Math.max,x)-1,y=2*g+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,g,p,N)),m.graph().nodeRankFactor=y}function o(m,f,p,x,g,y,w){let N=m.children(w);if(!N.length){w!==f&&m.setEdge(f,w,{weight:0,minlen:p});return}let C=s.addBorderNode(m,"_bt"),A=s.addBorderNode(m,"_bb"),O=m.node(w);m.setParent(C,w),O.borderTop=C,m.setParent(A,w),O.borderBottom=A,N.forEach(k=>{o(m,f,p,x,g,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:g-y[w]+1;m.setEdge(C,R,{weight:Y,minlen:z,nestingEdge:!0}),m.setEdge(D,A,{weight:Y,minlen:z,nestingEdge:!0})}),m.parent(w)||m.setEdge(f,C,{weight:0,minlen:g+y[w]})}function d(m){var f={};function p(x,g){var y=m.children(x);y&&y.length&&y.forEach(w=>p(w,g+1)),f[x]=g}return m.children().forEach(x=>p(x,1)),f}function c(m){return m.edges().reduce((f,p)=>f+m.edge(p).weight,0)}function h(m){var f=m.graph();m.removeNode(f.nestingRoot),delete f.nestingRoot,m.edges().forEach(p=>{var x=m.edge(p);x.nestingEdge&&m.removeEdge(p)})}}),JL=dn((e,n)=>{var s=Xn();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 p=f.minRank,x=f.maxRank+1;p<x;++p)o(d,"borderLeft","_bl",h,f,p),o(d,"borderRight","_br",h,f,p)}}d.children().forEach(c)}function o(d,c,h,m,f,p){let x={width:0,height:0,rank:p,borderType:c},g=f[c][p-1],y=s.addDummyNode(d,"border",x,h);f[c][p]=y,d.setParent(y,m),g&&d.setEdge(g,y,{weight:1})}}),eI=dn((e,n)=>{n.exports={adjust:s,undo:l};function s(p){let x=p.graph().rankdir.toLowerCase();(x==="lr"||x==="rl")&&o(p)}function l(p){let x=p.graph().rankdir.toLowerCase();(x==="bt"||x==="rl")&&c(p),(x==="lr"||x==="rl")&&(m(p),o(p))}function o(p){p.nodes().forEach(x=>d(p.node(x))),p.edges().forEach(x=>d(p.edge(x)))}function d(p){let x=p.width;p.width=p.height,p.height=x}function c(p){p.nodes().forEach(x=>h(p.node(x))),p.edges().forEach(x=>{let g=p.edge(x);g.points.forEach(h),Object.hasOwn(g,"y")&&h(g)})}function h(p){p.y=-p.y}function m(p){p.nodes().forEach(x=>f(p.node(x))),p.edges().forEach(x=>{let g=p.edge(x);g.points.forEach(f),Object.hasOwn(g,"x")&&f(g)})}function f(p){let x=p.x;p.x=p.y,p.y=x}}),tI=dn((e,n)=>{var s=Xn();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 p(x){if(d[x])return;d[x]=!0;let g=o.node(x);f[g.rank].push(x),o.successors(x).forEach(p)}return c.sort((x,g)=>o.node(x).rank-o.node(g).rank).forEach(p),f}}),nI=dn((e,n)=>{var s=Xn().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)),p=1;for(;p<h.length;)p<<=1;let x=2*p-1;p-=1;let g=new Array(x).fill(0),y=0;return f.forEach(w=>{let N=w.pos+p;g[N]+=w.weight;let C=0;for(;N>0;)N%2&&(C+=g[N+1]),N=N-1>>1,g[N]+=w.weight;y+=w.weight*C}),y}}),rI=dn((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 p=l.edge(f),x=l.node(f.v);return{sum:m.sum+p.weight*x.order,weight:m.weight+p.weight}},{sum:0,weight:0});return{v:d,barycenter:h.sum/h.weight,weight:h.weight}}else return{v:d}})}}),sI=dn((e,n)=>{var s=Xn();n.exports=l;function l(c,h){let m={};c.forEach((p,x)=>{let g=m[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:x};p.barycenter!==void 0&&(g.barycenter=p.barycenter,g.weight=p.weight)}),h.edges().forEach(p=>{let x=m[p.v],g=m[p.w];x!==void 0&&g!==void 0&&(g.indegree++,x.out.push(m[p.w]))});let f=Object.values(m).filter(p=>!p.indegree);return o(f)}function o(c){let h=[];function m(p){return x=>{x.merged||(x.barycenter===void 0||p.barycenter===void 0||x.barycenter>=p.barycenter)&&d(p,x)}}function f(p){return x=>{x.in.push(p),--x.indegree===0&&c.push(x)}}for(;c.length;){let p=c.pop();h.push(p),p.in.reverse().forEach(m(p)),p.out.forEach(f(p))}return h.filter(p=>!p.merged).map(p=>s.pick(p,["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}}),aI=dn((e,n)=>{var s=Xn();n.exports=l;function l(c,h){let m=s.partition(c,C=>Object.hasOwn(C,"barycenter")),f=m.lhs,p=m.rhs.sort((C,A)=>A.i-C.i),x=[],g=0,y=0,w=0;f.sort(d(!!h)),w=o(x,p,w),f.forEach(C=>{w+=C.vs.length,x.push(C.vs),g+=C.barycenter*C.weight,y+=C.weight,w=o(x,p,w)});let N={vs:x.flat(!0)};return y&&(N.barycenter=g/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}}),lI=dn((e,n)=>{var s=rI(),l=sI(),o=aI();n.exports=d;function d(m,f,p,x){let g=m.children(f),y=m.node(f),w=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,C={};w&&(g=g.filter(S=>S!==w&&S!==N));let A=s(m,g);A.forEach(S=>{if(m.children(S.v).length){let R=d(m,S.v,p,x);C[S.v]=R,Object.hasOwn(R,"barycenter")&&h(S,R)}});let O=l(A,p);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(p=>{p.vs=p.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)}}),iI=dn((e,n)=>{var s=ms().Graph,l=Xn();n.exports=o;function o(c,h,m,f){f||(f=c.nodes());let p=d(c),x=new s({compound:!0}).setGraph({root:p}).setDefaultNodeLabel(g=>c.node(g));return f.forEach(g=>{let y=c.node(g),w=c.parent(g);(y.rank===h||y.minRank<=h&&h<=y.maxRank)&&(x.setNode(g),x.setParent(g,w||p),c[m](g).forEach(N=>{let C=N.v===g?N.w:N.v,A=x.edge(C,g),O=A!==void 0?A.weight:0;x.setEdge(C,g,{weight:c.edge(N).weight+O})}),Object.hasOwn(y,"minRank")&&x.setNode(g,{borderLeft:y.borderLeft[h],borderRight:y.borderRight[h]}))}),x}function d(c){for(var h;c.hasNode(h=l.uniqueId("_root")););return h}}),oI=dn((e,n)=>{n.exports=s;function s(l,o,d){let c={},h;d.forEach(m=>{let f=l.parent(m),p,x;for(;f;){if(p=l.parent(f),p?(x=c[p],c[p]=f):(x=h,h=f),x&&x!==f){o.setEdge(x,f);return}f=p}})}}),cI=dn((e,n)=>{var s=tI(),l=nI(),o=lI(),d=iI(),c=oI(),h=ms().Graph,m=Xn();n.exports=f;function f(y,w={}){if(typeof w.customOrder=="function"){w.customOrder(y,f);return}let N=m.maxRank(y),C=p(y,m.range(1,N+1),"inEdges"),A=p(y,m.range(N-1,-1,-1),"outEdges"),O=s(y);if(g(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:A,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))}g(y,S)}function p(y,w,N){let C=new Map,A=(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"&&A(k.rank,O),typeof k.minRank=="number"&&typeof k.maxRank=="number")for(let S=k.minRank;S<=k.maxRank;S++)S!==k.rank&&A(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(A){N.forEach(S=>C.setEdge(S.left,S.right));let O=A.graph().root,k=o(A,O,C,w);k.vs.forEach((S,R)=>A.node(S).order=R),c(A,C,k.vs)})}function g(y,w){Object.values(w).forEach(N=>N.forEach((C,A)=>y.node(C).order=A))}}),dI=dn((e,n)=>{var s=ms().Graph,l=Xn();n.exports={positionX:N,findType1Conflicts:o,findType2Conflicts:d,addConflict:h,hasConflict:m,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,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((q,E)=>{let T=c(O,q),L=T?O.node(T).order:U;(T||q===G)&&(Y.slice(K,E+1).forEach(_=>{O.predecessors(_).forEach(P=>{let V=O.node(P),W=V.order;(W<z||L<W)&&!(V.dummy&&O.node(_).dummy)&&h(S,P,_)})}),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 q;l.range(z,K).forEach(E=>{q=Y[E],O.node(q).dummy&&O.predecessors(q).forEach(T=>{let L=O.node(T);L.dummy&&(L.order<U||L.order>G)&&h(S,T,q)})})}function D(Y,z){let K=-1,U,G=0;return z.forEach((q,E)=>{if(O.node(q).dummy==="border"){let T=O.predecessors(q);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 q=R(G);if(q.length){q=q.sort((T,L)=>z[T]-z[L]);let E=(q.length-1)/2;for(let T=Math.floor(E),L=Math.ceil(E);T<=L;++T){let _=q[T];Y[G]===G&&U<z[_]&&!m(S,G,_)&&(Y[_]=G,Y[G]=D[G]=D[_],U=z[_])}}})}),{root:D,align:Y}}function p(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(),_={},P=L.pop();for(;P;){if(_[P])E(P);else{_[P]=!0,L.push(P);for(let V of T(P))L.push(V)}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 q(E){let T=z.outEdges(E).reduce((_,P)=>Math.min(_,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(q,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 q=S[G];if(D.setNode(q),U){var E=S[U],T=D.edge(E,q);D.setEdge(E,q,Math.max(z(O,G,U),T||0))}U=G})}),D}function g(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=A(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),q=R-l.applyWithChunking(Math.min,G);z!=="l"&&(q=D-l.applyWithChunking(Math.max,G)),q&&(O[K]=l.mapValues(U,E=>E+q))})})}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),q=p(O,D,G.root,G.align,K==="r");K==="r"&&(q=l.mapValues(q,E=>-E)),R[z+K]=q})});let Y=g(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 A(O,k){return O.node(k).width}}),uI=dn((e,n)=>{var s=Xn(),l=dI().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,p=0;h.forEach(x=>{let g=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=p+w.height/2:f==="bottom"?w.y=p+g-w.height/2:w.y=p+g/2}),p+=g+m})}}),fI=dn((e,n)=>{var s=GL(),l=XL(),o=ZL(),d=Xn().normalizeRanks,c=QL(),h=Xn().removeEmptyRanks,m=WL(),f=JL(),p=eI(),x=cI(),g=uI(),y=Xn(),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",()=>A(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",()=>q(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",()=>p.adjust(H)),Z(" position",()=>g(H)),Z(" positionSelfEdges",()=>X(H)),Z(" removeBorderNodes",()=>W(H)),Z(" normalize.undo",()=>l.undo(H)),Z(" fixupEdgeLabelCoords",()=>P(H)),Z(" undoCoordinateSystem",()=>p.undo(H)),Z(" translateGraph",()=>L(H)),Z(" assignNodeIntersects",()=>_(H)),Z(" reversePoints",()=>V(H)),Z(" acyclic.undo",()=>s.undo(H))}function A(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)),fe=I(ae,R);Object.keys(D).forEach(Ne=>{fe[Ne]===void 0&&(fe[Ne]=D[Ne])}),Z.setNode(ne,fe),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 q(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,fe=H.graph(),Ne=fe.marginx||0,Le=fe.marginy||0;function ye(je){let Te=je.x,ze=je.y,Xe=je.width,nt=je.height;Z=Math.min(Z,Te-Xe/2),ee=Math.max(ee,Te+Xe/2),ne=Math.min(ne,ze-nt/2),ae=Math.max(ae,ze+nt/2)}H.nodes().forEach(je=>ye(H.node(je))),H.edges().forEach(je=>{let Te=H.edge(je);Object.hasOwn(Te,"x")&&ye(Te)}),Z-=Ne,ne-=Le,H.nodes().forEach(je=>{let Te=H.node(je);Te.x-=Z,Te.y-=ne}),H.edges().forEach(je=>{let Te=H.edge(je);Te.points.forEach(ze=>{ze.x-=Z,ze.y-=ne}),Object.hasOwn(Te,"x")&&(Te.x-=Z),Object.hasOwn(Te,"y")&&(Te.y-=ne)}),fe.width=ee-Z+Ne,fe.height=ae-ne+Le}function _(H){H.edges().forEach(Z=>{let ee=H.edge(Z),ne=H.node(Z.v),ae=H.node(Z.w),fe,Ne;ee.points?(fe=ee.points[0],Ne=ee.points[ee.points.length-1]):(ee.points=[],fe=ae,Ne=ne),ee.points.unshift(y.intersectRect(ne,fe)),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 V(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),fe=H.node(ee.borderLeft[ee.borderLeft.length-1]),Ne=H.node(ee.borderRight[ee.borderRight.length-1]);ee.width=Math.abs(Ne.x-fe.x),ee.height=Math.abs(ae.y-ne.y),ee.x=fe.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,fe)=>{var Ne=H.node(ae);Ne.order=fe+ne,(Ne.selfEdges||[]).forEach(Le=>{y.addDummyNode(H,"selfedge",{width:Le.label.width,height:Le.label.height,rank:Ne.rank,order:fe+ ++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,fe=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:fe-Le},{x:ae+5*Ne/6,y:fe-Le},{x:ae+Ne,y:fe},{x:ae+5*Ne/6,y:fe+Le},{x:ae+2*Ne/3,y:fe+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}}),hI=dn((e,n)=>{var s=Xn(),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 p="layer"+f;h.setNode(p,{rank:"same"}),m.reduce((x,g)=>(h.setEdge(x,g,{style:"invis"}),g))}),h}}),mI=dn((e,n)=>{n.exports="2.0.4"}),xI=dn((e,n)=>{n.exports={graphlib:ms(),layout:fI(),debug:hI(),util:{time:Xn().time,notime:Xn().notime},version:mI()}});const Pv=xI();const Uv={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 gI({data:e}){const{task:n,agentName:s,selected:l}=e,o=Uv[n.status]??Uv.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(za,{type:"target",position:mt.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(za,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const qv={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"}},Vv={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done"};function bI({data:e}){const{req:n,selected:s}=e,l=qv[n.status]??qv.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(za,{type:"target",position:mt.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(za,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const yI={task:gI,requirement:bI},vI=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,jI=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 wI(){return v.useSyncExternalStore(jI,vI,()=>!1)}const Vm=200,Fm=80;function Fv(e,n,s="TB"){const l=new Pv.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const o of e)l.setNode(o.id,{width:Vm,height:Fm});for(const o of n)l.setEdge(o.source,o.target);return Pv.layout(l),e.map(o=>{const d=l.node(o.id);return{...o,position:{x:(d?.x??0)-Vm/2,y:(d?.y??0)-Fm/2}}})}function NI(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 p of s.get(f)??[])o.has(p)||m.push(p)}}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 kI(e,n){if(e.length===0)return[];const s=NI(e,n);if(s.length===1)return Fv(e,n);const l=s.map(x=>{const g=Fv(x.nodes,x.edges);let y=1/0,w=-1/0,N=1/0,C=-1/0;for(const A of g)y=Math.min(y,A.position.x),w=Math.max(w,A.position.x+Vm),N=Math.min(N,A.position.y),C=Math.max(C,A.position.y+Fm);for(const A of g)A.position.x-=y,A.position.y-=N;return{nodes:g,w:w-y,h:C-N}});l.sort((x,g)=>g.h-x.h);const o=60,d=l.reduce((x,g)=>x+(g.w+o)*(g.h+o),0),c=Math.sqrt(d)*1.1,h=[];let m=0,f=0,p=0;for(const x of l){m>0&&m+x.w>c&&(m=0,f+=p+o,p=0);for(const g of x.nodes)h.push({...g,position:{x:g.position.x+m,y:g.position.y+f}});m+=x.w+o,p=Math.max(p,x.h)}return h}function SI(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)),CI=1440*60*1e3,Yv=e=>e.status==="completed"&&e.updatedAt&&Date.now()-new Date(e.updatedAt).getTime()>CI;function EI({tasks:e,requirements:n=[],agents:s,showArchived:l,onShowArchivedChange:o,onTaskClick:d,onReqClick:c,onDependencyChange:h,selectedTaskId:m,selectedReqId:f}){const p=wI(),[x,g]=v.useState(null),[y,w]=v.useState(null),[N,C]=v.useState(new Set(nm)),[A,O]=v.useState(l??!1),k=l??A,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=>Yv(ye)).length,[e]),D=v.useMemo(()=>{const ye=new Set;for(const je of vo)if(N.has(je.id))for(const Te of je.statuses)ye.add(Te);return ye},[N]),Y=v.useMemo(()=>{const ye=new Set;for(const je of e)for(const Te of vo)if(Te.statuses.has(je.status)){ye.add(Te.id);break}for(const je of n){const Te=Vv[je.status];Te&&ye.add(Te)}return vo.filter(je=>ye.has(je.id))},[e,n]),z=v.useCallback(ye=>{C(je=>{const Te=new Set(je);return Te.has(ye)?Te.delete(ye):Te.add(ye),Te})},[]),K=v.useCallback((ye,je="success")=>{g({msg:ye,type:je}),setTimeout(()=>g(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]),q=v.useMemo(()=>{const ye=new Map;for(const je of n)ye.set(je.id,je);return ye},[n]),E=p?"#94a3b8":"#6b7280",T=v.useCallback((ye,je,Te)=>({id:`${ye}->${je}`,source:ye,target:je,animated:Te==="blocked",markerEnd:{type:di.ArrowClosed,width:14,height:14,color:Te==="blocked"?"#ef4444":E},style:{stroke:Te==="blocked"?"#ef4444":E,strokeWidth:1.5,cursor:"pointer"}}),[E]),{initialNodes:L,initialEdges:_}=v.useMemo(()=>{const ye=e.filter(Ee=>D.has(Ee.status)&&(k||!Yv(Ee))),je=ye.map(Ee=>({id:Ee.id,type:"task",data:{task:Ee,agentName:Ee.assignedAgentId?U.get(Ee.assignedAgentId):void 0,selected:Ee.id===m},position:{x:0,y:0}})),Te=new Set(je.map(Ee=>Ee.id)),ze=new Set;for(const Ee of vo)N.has(Ee.id)&&ze.add(Ee.id);const Xe=n.filter(Ee=>{const rt=Vv[Ee.status];return rt&&ze.has(rt)});for(const Ee of Xe){const rt=`req-${Ee.id}`;je.push({id:rt,type:"requirement",data:{req:Ee,selected:Ee.id===f},position:{x:0,y:0}}),Te.add(rt)}const nt=[];for(const Ee of ye)if(Ee.blockedBy)for(const rt of Ee.blockedBy)Te.has(rt)&&nt.push(T(rt,Ee.id,Ee.status));const tt=new Set,Mt=(Ee,rt)=>{const vt=`${Ee}->${rt}`;tt.has(vt)||(tt.add(vt),nt.push({id:vt,source:Ee,target:rt,markerEnd:{type:di.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const Ee of Xe){const rt=`req-${Ee.id}`;for(const vt of Ee.taskIds)Te.has(vt)&&Mt(rt,vt)}for(const Ee of ye)if(Ee.requirementId){const rt=`req-${Ee.requirementId}`;Te.has(rt)&&Mt(rt,Ee.id)}return{initialNodes:kI(je,nt),initialEdges:nt}},[e,n,U,G,T,D,N,k,m,f]),[P,V,W]=xL(L),[B,F,X]=pL(_),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(()=>{V(L),F(_),M.current||requestAnimationFrame(()=>{I.current?.fitView({padding:.2,duration:300})})},[L,_,V,F]);const Z=v.useCallback(ye=>{ye&&(M.current=!0)},[]),ee=v.useCallback((ye,je)=>{if(je.id.startsWith("req-")){const Te=q.get(je.id.slice(4));Te&&c&&c(Te)}else{const Te=G.get(je.id);Te&&d&&d(Te)}},[G,q,d,c]),ne=v.useCallback(async ye=>{const{source:je,target:Te}=ye;if(!je||!Te||je===Te)return;const ze=G.get(Te);if(!ze)return;if(ze.blockedBy?.includes(je)){K("Dependency already exists","error");return}if(SI(G,je,Te)){K("Cannot add: would create a cycle","error");return}const Xe=[...ze.blockedBy??[],je];try{await re.tasks.update(Te,{blockedBy:Xe}),K("Dependency added"),h?.()}catch(nt){K(`Failed: ${nt instanceof Error?nt.message:String(nt)}`,"error")}},[G,K,h]),ae=v.useCallback((ye,je)=>{w(je)},[]),fe=v.useCallback(async()=>{if(!y)return;const ye=G.get(y.target);if(!ye){w(null);return}const je=(ye.blockedBy??[]).filter(Te=>Te!==y.source);try{await re.tasks.update(y.target,{blockedBy:je}),K("Dependency removed"),h?.()}catch(Te){K(`Failed: ${Te instanceof Error?Te.message:String(Te)}`,"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(mL,{nodes:P,edges:B,onNodesChange:W,onEdgesChange:X,onNodeClick:ee,onConnect:ne,onEdgeClick:ae,onMoveEnd:Z,onInit:ye=>{I.current=ye},nodeTypes:yI,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(jL,{color:p?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(TL,{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(PL,{nodeColor:ye=>{const je=ye.data?.task,Te=je?.status;return je?.taskType==="scheduled"?"#06b6d4":Te==="completed"||Te==="accepted"?"#10b981":Te==="in_progress"?"#f59e0b":Te==="blocked"||Te==="failed"?"#ef4444":p?"#94a3b8":"#6b7280"},maskColor:p?"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:fe,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 kN({orgId:e,onCreated:n,onClose:s}){const[l,o]=v.useState(""),[d,c]=v.useState(""),[h,m]=v.useState(""),[f,p]=v.useState("main"),[x,g]=v.useState([]),[y,w]=v.useState([]),[N,C]=v.useState(!1),[A,O]=v.useState(""),[k,S]=v.useState(!1),R=xs();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 px.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:()=>g(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=>p(z.target.value),placeholder:"main",className:"input !w-24"})]})]}),A&&t.jsx("div",{className:"text-xs text-red-400 bg-red-500/10 rounded-lg px-3 py-2",children:A}),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 TI({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 p=c.trim();if(p&&p!==e)try{await n(p)}catch{h(e)}else h(e)};return o?t.jsx("input",{ref:m,value:c,onChange:p=>h(p.target.value),onBlur:()=>{f()},onKeyDown:p=>{p.key==="Enter"&&f(),p.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 p=c.trim();if(p!==e)try{await n(p)}catch{h(e)}else h(e)};return o?t.jsx("textarea",{ref:m,value:c,onChange:p=>{h(p.target.value),p.target.style.height="auto",p.target.style.height=p.target.scrollHeight+"px"},onBlur:()=>{f()},onKeyDown:p=>{p.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 AI=/^\[([^\]]+?)(?:\s+by\s+([^\]]+))?\]\s*([\s\S]*)$/;function SN(e){const n=e.match(AI);return n?{timestamp:n[1].trim(),author:n[2]?.trim()??"System",content:n[3].trim()}:{timestamp:"",author:"",content:e}}function MI(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 Gv=[{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 OI(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s)|0;return Gv[Math.abs(n)%Gv.length]}function RI({note:e,compact:n}){const s=SN(e),l=OI(s.author||"System"),o=s.author?s.author.split(/[\s_-]+/).map(h=>h[0]).join("").slice(0,2).toUpperCase():"SY",d=MI(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(Jn,{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(Jn,{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"}],CN={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"}},Ym={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"}},DI={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},Xv={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"}},LI=["low","medium","high","urgent"],II=["pending","in_progress","blocked","review","completed","failed","rejected","cancelled"],zI=["pending","in_progress","completed","rejected","cancelled"],EN={idle:"bg-green-400",working:"bg-blue-400",error:"bg-red-400",paused:"bg-amber-400",offline:"bg-gray-600",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"},$I={idle:"text-green-500",working:"text-blue-500",error:"text-red-500",paused:"text-amber-500",offline:"text-fg-muted"};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(),bt.navigate(pe.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,g)=>{const y=n.find(w=>w.name.toLowerCase()===x.toLowerCase());if(y){const w=g.target.getBoundingClientRect();m({agent:y,top:w.bottom,left:w.left})}},[n]),p=v.useCallback(x=>{const g=n.find(y=>y.name.toLowerCase()===e.authorName.toLowerCase());if(g){const y=x.currentTarget.getBoundingClientRect();m({agent:g,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:p,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:p,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(Jn,{content:e.content,className:"text-xs text-fg-primary",onMentionClick:f}),e.attachments?.map((x,g)=>x.type==="image"?t.jsx("img",{src:x.url,alt:x.name,className:"mt-1 max-w-[200px] rounded"},g):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(()=>pn.on("task:comment",g=>{g.payload?.taskId===e.id&&g.payload.comment&&d(y=>y.some(w=>w.id===g.payload.comment.id)?y:[...y,g.payload.comment])}),[e.id]);const c=v.useMemo(()=>{const x=[];for(const g of e.notes??[]){const y=SN(g);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:g,ts:w})}for(const g of o)x.push({type:"comment",comment:g,ts:new Date(g.createdAt)});return x.sort((g,y)=>g.ts.getTime()-y.ts.getTime()),x},[e.notes,o]),[h,m]=v.useState(null),f=async(x,g,y)=>{await re.tasks.addComment(e.id,x,l?.name,void 0,l?.id,g.length>0?g:void 0,y)},p=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,g)=>x.type==="note"?t.jsx(RI,{note:x.note,compact:!0},`n-${g}`):t.jsx(Co,{comment:x.comment,agents:n,onReply:p},`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),[p,x]=v.useState([]),[g,y]=v.useState(""),[w,N]=v.useState(n),[C,A]=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(()=>{A(!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){A(!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]])),A(!1)})})},[e]);const q=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)||q(X)),M})},[c,q]);v.useEffect(()=>{const X=pn.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 fe=ae.get(ne)??[];return ee.id&&fe.some(Ne=>Ne.id===ee.id)?ae:new Map(ae).set(ne,[...fe,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(fe=>fe.round===ne?{...fe,status:ee.content}:fe)))),ee.type==="error"&&N(!1)}),I=pn.on("task:log:delta",H=>{const Z=H.payload;Z.taskId===e&&y(ee=>ee+Z.text)}),M=pn.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]),_=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=""}},V=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(),V())},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:()=>{V()},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&&!g)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(!_){const X=L.map(H=>Md(H)).filter(H=>H!==null),I=Ad(X),M=[...I.map(H=>({kind:"entry",entry:H,ts:H.timestamp?new Date(H.timestamp).getTime():0})),...p.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&&g&&t.jsx(Sm,{content:g}),w&&!g&&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 p.filter(Z=>{const ee=new Date(Z.createdAt).getTime();return ee>=M&&ee<H})},F=o.length>0?p.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"?"⏹":"🔄",fe=X.lastAt&&X.firstAt?Math.max(0,new Date(X.lastAt).getTime()-new Date(X.firstAt).getTime()):0,Ne=fe>=6e4?`${Math.floor(fe/6e4)}m ${Math.floor(fe%6e4/1e3)}s`:fe>=1e3?`${Math.floor(fe/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(ze=>om(ze)).map(ze=>Md(ze)).filter(ze=>ze!==null),Te=[...Ad(ye).map(ze=>({kind:"entry",entry:ze,ts:ze.timestamp?new Date(ze.timestamp).getTime():0})),...ne.map(ze=>({kind:"comment",comment:ze,ts:new Date(ze.createdAt).getTime()}))];return Te.sort((ze,Xe)=>ze.ts-Xe.ts),Te.map((ze,Xe)=>ze.kind==="comment"?t.jsx(Co,{comment:ze.comment,agents:l},`c-${ze.comment.id}`):t.jsx(Od,{entry:ze.entry,showTime:!0,isLast:Xe===Te.length-1},`e-${Xe}`))})(),H&&w&&g&&t.jsx(Sm,{content:g}),H&&w&&!g&&!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(Jn,{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,p]=v.useState([]),[x,g]=v.useState(""),[y,w]=v.useState(!1),[N,C]=v.useState(!1),[A,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"),q=v.useCallback(ve=>{z(ve),requestAnimationFrame(()=>{K.current?.scrollTo({top:0,behavior:"instant"})})},[]);v.useEffect(()=>{const ve=K.current;if(!ve)return;const qe=()=>{const{scrollTop:zt,scrollHeight:Ve,clientHeight:Pt}=ve;if(!(Ve>Pt+50)){G("none");return}const nn=zt<30,un=zt+Pt>=Ve-30;G(nn?"top":un?"bottom":"middle")};qe(),ve.addEventListener("scroll",qe,{passive:!0});const Rt=new ResizeObserver(qe);return Rt.observe(ve),()=>{ve.removeEventListener("scroll",qe),Rt.disconnect()}},[Y]);const[E,T]=v.useState(!1),[L,_]=v.useState(null),[P,V]=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,fe]=v.useState(!1),Ne=xs(),Le=20,ye=v.useCallback(async()=>{try{const ve=await re.tasks.listSubtasks(e.id);p(ve.subtasks)}catch{}},[e.id]);v.useEffect(()=>{ye()},[ye]);const je=async ve=>{if(!R){D(!0);try{await ve(),h(),await ye()}catch(qe){_(String(qe).replace("Error: ",""))}finally{D(!1)}}},Te=ve=>je(()=>re.tasks.update(e.id,{priority:ve})),ze=ve=>je(()=>re.tasks.assign(e.id,ve||null)),Xe=ve=>je(()=>re.tasks.update(e.id,{projectId:ve||null})),nt=async()=>{if(!R){D(!0);try{await re.tasks.pause(e.id),h()}finally{D(!1)}}},tt=async()=>{if(!E){T(!0),_(null),q("logs");try{await re.tasks.resume(e.id),h()}catch(ve){_(String(ve).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{T(!1)}}},Mt=async()=>{x.trim()&&(await re.tasks.createSubtask(e.id,x.trim()),g(""),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()},Ee=async ve=>{await re.tasks.deleteSubtask(e.id,ve.id),O(null),ye(),h()},rt=async()=>{if(!R){D(!0);try{await re.tasks.updateStatus(e.id,"pending"),h()}finally{D(!1)}}},vt=async()=>{if(!R){D(!0),_(null),q("logs");try{await re.tasks.retry(e.id),h()}catch(ve){_(String(ve).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{D(!1)}}},Kt=async()=>{if(!E){T(!0),_(null),q("logs");try{await re.tasks.runNow(e.id),h()}catch(ve){_(String(ve).replace("Error: API error: 400","Server error").replace("Error: ","")),h()}finally{T(!1)}}},we=v.useRef(h);we.current=h,v.useEffect(()=>pn.on("task:update",qe=>{qe.payload.taskId===e.id&&(ye(),we.current())}),[e.id,ye]);const De=f.filter(ve=>ve.status==="completed").length,Ue=e.status==="in_progress",Je=e.status==="blocked",pt=e.status==="completed",Jt=e.status==="failed",ln=e.status==="cancelled",Ht=e.status==="archived",Lt=pt||Jt||ln||Ht,_t=e.taskType==="scheduled"&&!!e.scheduleConfig,St=_t&&!!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=Ym[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:()=>q("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:()=>q("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",Ue&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse"})]}),t.jsxs("button",{onClick:()=>q("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(qe=>qe.type!=="branch"&&typeof qe.reference=="string"&&qe.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(Jn,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})}),Ne&&e.description.length>150&&t.jsx("button",{onClick:()=>fe(!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 qe=o.find(zt=>zt.id===ve),Rt=qe&&(qe.status==="completed"||qe.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:qe?qe.title.slice(0,30):ve.slice(-8)}),!Lt&&t.jsx("button",{onClick:async()=>{const zt=(e.blockedBy??[]).filter(Ve=>Ve!==ve);await re.tasks.update(e.id,{blockedBy:zt}),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 qe=ve.target.value;if(!qe)return;const Rt=[...e.blockedBy??[],qe];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=>{ze(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=>{Te(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(qe=>qe.status!=="completed");return ve.length>0?t.jsx("div",{className:"space-y-1.5 mb-3",children:ve.map(qe=>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(qe)},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${qe.status==="completed"?"bg-green-600 border-green-600 text-white":"border-gray-600 hover:border-brand-500"}`,children:qe.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 ${qe.status==="completed"?"line-through text-fg-tertiary":"text-fg-secondary"}`,children:qe.title}),t.jsx("button",{onClick:()=>O(qe),className:"shrink-0 opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-red-500 transition-all text-xs",children:"✕"})]},qe.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=>g(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&Mt(),ve.key==="Escape"&&(w(!1),g(""))},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:()=>{Mt()},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),g("")},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(zt=>zt.type!=="branch"&&typeof zt.reference=="string"&&zt.reference.length>0);if(ve.length===0)return null;const qe={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:()=>q("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((zt,Ve)=>{const Pt=zt.reference.split("/").pop()??zt.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 ${qe[zt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:zt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>V(zt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:zt.reference,children:Pt}),zt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:zt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:zt.reference})]})]},Ve)})})]})})(),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(Ve=>Ve.type!=="branch"&&typeof Ve.reference=="string"&&Ve.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 qe={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),zt=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(Ve=>Ve-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(Ve=>Ve+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:zt.map((Ve,Pt)=>{const yn=Ve.reference.split("/").pop()??Ve.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 ${qe[Ve.type]??"bg-gray-500/15 text-fg-secondary"}`,children:Ve.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>V(Ve.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:Ve.reference,children:yn}),Ve.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:Ve.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:Ve.reference})]})]},Pt)})})]})})()})]}),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"})})})]})]}),_t&&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 qe=Math.floor(ve/6e4);if(qe<60)return`in ${qe}m`;const Rt=Math.floor(qe/60);return Rt<24?`in ${Rt}h ${qe%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(),qe=Math.floor(ve/6e4);if(qe<1)return"just now";if(qe<60)return`${qe}m ago`;const Rt=Math.floor(qe/60);return Rt<24?`${Rt}h ${qe%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"})]}),Ue&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>{nt()},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:()=>{vt()},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"]})]}),Je&&t.jsx("button",{onClick:()=>{tt()},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"]})}),Jt&&t.jsxs("button",{onClick:()=>{vt()},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"]}),_t&&(pt||Jt)&&t.jsx("button",{onClick:()=>{Kt()},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"]})}),_t&&!Ue&&(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"})),pt&&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:()=>{rt()},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"})]})}),A&&t.jsx(Ej,{title:`Delete subtask "${A.title}"?`,message:"This subtask will be permanently deleted.",confirmLabel:"Delete",onConfirm:()=>{Ee(A)},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:()=>V(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]),p=v.useMemo(()=>new Set(h.map(z=>z.assignedAgentId).filter(Boolean)),[h]),x=v.useMemo(()=>l.filter(z=>p.has(z.id)),[l,p]),[g,y]=v.useState(!1),[w,N]=v.useState(""),[C,A]=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(""),A("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(Zs,{label:"Total",value:f.total,color:"text-fg-primary"}),t.jsx(Zs,{label:"Completed",value:f.completed,color:"text-green-600"}),t.jsx(Zs,{label:"In Progress",value:f.inProgress,color:"text-brand-500"}),t.jsx(Zs,{label:"In Review",value:f.inReview,color:"text-brand-500"}),t.jsx(Zs,{label:"Blocked",value:f.blocked,color:"text-amber-600"}),t.jsx(Zs,{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(Zs,{label:"Total",value:f.reqs,color:"text-fg-primary"}),t.jsx(Zs,{label:"Completed",value:f.reqsDone,color:"text-green-600"}),t.jsx(Zs,{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(!g),className:"text-[10px] text-brand-500 hover:text-brand-500",children:g?"Cancel":"+ Add"})]}),(e.repositories??[]).length===0&&!g&&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)),g&&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=>A(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 Zs({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"}},TN={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed"},_N={failed:"rejected",todo:"pending",in_progress:"in_progress",review:"in_progress",done:"completed",closed:"cancelled"},FI={urgent:0,high:1,medium:2,low:3},Kv={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 Zv({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 Qv({row:e,idx:n,dragIdx:s,agentMap:l,projMap:o,onTaskClick:d,onReqClick:c,onRowDragStart:h,onRowDragEnd:m,handleStatusChange:f,handlePriorityChange:p,selected:x}){const g=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(Zv,{value:g,options:e.kind==="task"?II.map(C=>({value:C,label:Ym[C]?.label??C,cls:Ym[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})):zI.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(Zv,{value:y,options:LI.map(C=>({value:C,label:Xv[C]?.label??C,cls:Xv[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:C=>{p(e,C)}})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:w?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${EN[w.status]??"bg-gray-500"}`}),t.jsx("span",{className:`font-medium ${$I[w.status]??"text-fg-secondary"}`,children:w.name})]}):t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:N?.name?t.jsx("span",{className:"text-brand-400/70",children:N.name}):t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[90px] shrink-0 text-[10px] text-fg-muted text-right",children:ZI(e.data.updatedAt??"")})]})}function QI({tasks:e,requirements:n,agents:s,projects:l,onTaskClick:o,onReqClick:d,onRefresh:c,selectedTaskId:h,selectedReqId:m}){const[f,p]=v.useState("status"),[x,g]=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:Kv[L]??5})}for(const T of n){const L=TN[T.status]??"todo";E.push({kind:"req",data:T,group:L,groupOrder:Kv[L]??5})}if(f==="status")E.sort((T,L)=>{if(T.groupOrder!==L.groupOrder)return T.groupOrder-L.groupOrder;const _=new Date(T.data.updatedAt??0).getTime();return new Date(L.data.updatedAt??0).getTime()-_});else{const T=L=>FI[L.data.priority]??2;E.sort((L,_)=>{const P=T(L),V=T(_);return P!==V?P-V:new Date(_.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{}},A=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)=>{g(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",g(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 _=Bo.find(P=>P.id===T);if(_){try{if(L.kind==="task"){if(L.data.status==="pending")return;await re.tasks.updateStatus(L.data.id,_.dropStatus)}else{const P=_N[T];P&&await re.requirements.updateStatus(L.data.id,P)}c()}catch{}g(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 _=N[L];T.set(_,L);const P=E.get(_.group)??[];P.push(_),E.set(_.group,P)}return{rowsByGroup:E,rowIndexMap:T}},[N]),q=v.useMemo(()=>{if(f!=="status")return null;const E=new Set(N.map(_=>_.group)),T=[],L=new Set;E.has("failed")&&(T.push("failed"),L.add("failed"));for(const _ of z)T.push(_),L.add(_);for(const _ of N)L.has(_.group)||(T.push(_.group),L.add(_.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:()=>p("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:()=>p("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"&&q?q.map(E=>{const T=Bo.find(_=>_.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:_=>S(_,E),onDragLeave:()=>w(null),onDrop:_=>{R(_,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(_=>t.jsx(Qv,{row:_,idx:G.get(_)??0,dragIdx:x,agentMap:D,projMap:Y,onTaskClick:o,onReqClick:d,onRowDragStart:O,onRowDragEnd:k,handleStatusChange:C,handlePriorityChange:A,selected:_.kind==="task"?_.data.id===h:_.data.id===m},`${_.kind}-${_.data.id}`))]},E)}):N.map((E,T)=>t.jsx(Qv,{row:E,idx:T,dragIdx:x,agentMap:D,projMap:Y,onTaskClick:o,onReqClick:d,onRowDragStart:O,onRowDragEnd:k,handleStatusChange:C,handlePriorityChange:A,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=xs(),s=eu({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"),[p,x]=v.useState(null),[g,y]=v.useState({}),[w,N]=v.useState([]),[C,A]=v.useState([]),[O,k]=v.useState([]),[S,R]=v.useState(!0),[D,Y]=v.useState(""),[z,K]=v.useState(!1),U=v.useCallback(()=>{Pt(p??""),St(!0)},[p]),[G,q]=v.useState(!1),[E,T]=v.useState(!1),[L,_]=v.useState(""),[P,V]=v.useState(""),[W,B]=v.useState("medium"),[F,X]=v.useState(""),[I,M]=v.useState(""),[H,Z]=v.useState(""),[ee,ne]=v.useState(""),[ae,fe]=v.useState([]),[Ne,Le]=v.useState("standard"),[ye,je]=v.useState("4h"),[Te,ze]=v.useState(null),[Xe,nt]=v.useState(null),[tt,Mt]=v.useState(new Set),[se,Ee]=v.useState(new Set),rt=v.useRef(new Set),vt=v.useRef(new Set),[Kt,we]=v.useState(null),[De,Ue]=v.useState("backlog"),[Je,pt]=v.useState(!1),[Jt,ln]=v.useState(!1),Ht=v.useRef(null),Lt=v.useRef(null),[_t,St]=v.useState(!1),[en,tn]=v.useState(""),[ve,qe]=v.useState(""),[Rt,zt]=v.useState("medium"),[Ve,Pt]=v.useState(""),[yn,nn]=v.useState(null),[un,vn]=v.useState(""),Dt=te=>{Y(te),setTimeout(()=>Y(""),3e3)},jn=c.find(te=>te.id===p)??null;v.useEffect(()=>{vt.current=se},[se]);const Et=v.useCallback(async()=>{try{const{projects:te}=await re.projects.list();h(te)}catch{}},[]),ie=v.useCallback(async()=>{const te={};m==="project"&&p&&(te.projectId=p);try{const{board:Ie}=await re.tasks.board(te);y(Ie)}catch{}},[m,p]),Pe=v.useCallback(async()=>{try{const{agents:te}=await re.agents.list();N(te)}catch{}},[]),Fe=v.useCallback(async()=>{try{const{users:te}=await re.users.list(e?.orgId);A(te)}catch{}},[e?.orgId]),st=v.useCallback(async()=>{try{const{requirements:te}=await re.requirements.list({});k(te)}catch{}},[]),ot=v.useCallback(async()=>{await Promise.all([Et(),ie(),Pe(),Fe(),st()]),R(!1)},[Et,ie,Pe,Fe,st]);v.useEffect(()=>{ot()},[ot]);const Ct=v.useCallback(te=>{ze(Ie=>Ie?.id===te.id?(n&&d.current&&o(!1),null):(n&&(o(!0),history.pushState({mobileDetail:pe.WORK},"",window.location.hash)),te)),nt(null)},[n]),dt=v.useCallback(te=>{nt(Ie=>Ie?.id===te.id?(n&&d.current&&o(!1),null):(n&&(o(!0),history.pushState({mobileDetail:pe.WORK},"",window.location.hash)),te)),ze(null)},[n]),Qe=v.useCallback(()=>{ze(null),nt(null),n&&d.current&&o(!1)},[n]);v.useEffect(()=>{if(!n)return;const te=()=>{d.current&&(o(!1),ze(null),nt(null))};return window.addEventListener("popstate",te),()=>window.removeEventListener("popstate",te)},[n]);const at=v.useRef(Te);at.current=Te,v.useEffect(()=>{const Ie=setInterval(()=>{ie(),Pe(),st()},Te?6e4:15e3),Ye=pn.on("task:update",Me=>{at.current||(ie(),st());const Se=Me?.payload;Se?.taskId&&ze(Ge=>{if(!Ge||Ge.id!==Se.taskId)return Ge;const He={};return typeof Se.status=="string"&&(He.status=Se.status),Array.isArray(Se.deliverables)&&(He.deliverables=Se.deliverables),Array.isArray(Se.notes)&&(He.notes=Se.notes),Se.result!==void 0&&(He.result=Se.result),{...Ge,...He}})}),J=pn.on("task:create",()=>{ie()}),Ce=["requirement:created","requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"].map(Me=>pn.on(Me,()=>{st()}));return()=>{clearInterval(Ie),Ye(),J(),Ce.forEach(Me=>Me())}},[ie,Pe,st,Te]);const fn=v.useRef(g);fn.current=g;const xe=v.useRef(O);xe.current=O;const Ke=v.useCallback(te=>{if(!te)return;const Ie=vt.current;Ie.size>0&&!Ie.has(te)&&Ee(Ye=>new Set([...Ye,te]))},[]);v.useEffect(()=>{const te=localStorage.getItem("markus_nav_openTask");if(!te)return;const Ye=Object.values(g).flat().find(J=>J.id===te);Ye&&(Ke(Ye.projectId),Ct(Ye),localStorage.removeItem("markus_nav_openTask"))},[g,Ct,Ke]),v.useEffect(()=>{const te=window.location.hash.slice(1).split("/");if(La(te[0])===pe.WORK&&te[1])xt(te[1]);else{const Ie=localStorage.getItem("markus_nav_projectId");Ie&&(localStorage.removeItem("markus_nav_projectId"),xt(Ie))}},[]),v.useEffect(()=>{const te=()=>{const Ye=window.location.hash.slice(1).split("/");La(Ye[0])===pe.WORK&&Ye[1]?xt(Ye[1]):La(Ye[0])===pe.WORK&&At()},Ie=Ye=>{const J=Ye.detail;if(La(J.page)===pe.WORK){if(J.params?.openTask){const Ce=Object.values(fn.current).flat().find(Me=>Me.id===J.params.openTask);Ce&&(Ke(Ce.projectId),Ct(Ce),localStorage.removeItem("markus_nav_openTask"))}if(J.params?.openRequirement){const ge=xe.current.find(Ce=>Ce.id===J.params.openRequirement);ge&&(Ke(ge.projectId),dt(ge))}J.params?.projectId&&xt(J.params.projectId),!J.params?.projectId&&!J.params?.openTask&&!J.params?.openRequirement&&At()}};return window.addEventListener("markus:navigate",Ie),window.addEventListener("hashchange",te),()=>{window.removeEventListener("markus:navigate",Ie),window.removeEventListener("hashchange",te)}},[]);const xt=te=>{vt.current.size>0&&(rt.current=new Set(vt.current)),Ee(new Set),x(te),f("project"),K(!1),history.replaceState(null,"",im(pe.WORK,te))},At=()=>{Ee(rt.current),x(null),f("all"),K(!1),history.replaceState(null,"",im(pe.WORK))},On=()=>{q(!1),Dt("Project created"),Et()},hr=async te=>{if(confirm("Delete this project and unlink all its tasks?"))try{await re.projects.delete(te),p===te&&At(),Dt("Project deleted"),Et(),ie()}catch(Ie){Dt(`Error: ${Ie}`)}},mr=async()=>{if(!L||!F||!I)return;if(F===I){Dt("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),_(""),V(""),fe([]),ne(""),Le("standard"),je("4h"),T(!1),ie()}catch(Ye){Dt(`Error creating task: ${Ye}`)}},er=()=>{ie(),Te&&setTimeout(()=>{const te={};m==="project"&&p&&(te.projectId=p),re.tasks.board(te).then(Ie=>{const J=Object.values(Ie.board).flat().find(ge=>ge.id===Te.id);ze(J||null)}).catch(()=>{})},150)},or=async()=>{if(!en.trim()){Dt("Please enter a title for this requirement");return}if(!ve.trim()){Dt("Please enter a description for this requirement");return}if(!Ve){Dt("Please select a project for this requirement");return}try{await re.requirements.create({title:en.trim(),description:ve.trim(),priority:Rt,projectId:Ve}),Dt("Requirement created"),tn(""),qe(""),St(!1),st()}catch(te){Dt(`Error: ${te}`)}},tr=async te=>{try{await re.requirements.approve(te),Dt("Requirement approved"),st(),ie()}catch(Ie){Dt(`Error: ${Ie}`)}},wn=async()=>{if(yn)try{await re.requirements.reject(yn,un),Dt("Requirement rejected"),nn(null),vn(""),st()}catch(te){Dt(`Error: ${te}`)}},ts=async te=>{try{await re.requirements.cancel(te),Dt("Requirement cancelled"),st()}catch(Ie){Dt(`Error: ${Ie}`)}},ns=(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"},ce=(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"},_e=te=>{te.currentTarget.style.opacity="1",Ht.current=null,Lt.current=null,we(null)},$e=(te,Ie)=>{te.preventDefault(),te.dataTransfer.dropEffect="move",Kt!==Ie&&we(Ie)},Yt=(te,Ie)=>{const Ye=te.currentTarget.getBoundingClientRect(),{clientX:J,clientY:ge}=te;(J<Ye.left||J>Ye.right||ge<Ye.top||ge>Ye.bottom)&&Kt===Ie&&we(null)},br=async(te,Ie)=>{te.preventDefault(),we(null);const Ye=Ht.current,J=Lt.current;if(Ye){const ge=Bo.find(Me=>Me.id===Ie);if(!ge)return;const Ce=ge.dropStatus;if(Ye.status===Ce||Ye.status==="pending")return;try{await re.tasks.updateStatus(Ye.id,Ce),ie()}catch{}}else if(J){const ge=_N[Ie];if(!ge||J.status===ge)return;try{await re.requirements.updateStatus(J.id,ge),st()}catch{}}},rs=te=>{Mt(Ie=>{const Ye=new Set(Ie);return Ye.has(te)?Ye.delete(te):Ye.add(te),Ye})},yr=te=>{Ee(Ie=>{const Ye=new Set(Ie);return Ye.has(te)?Ye.delete(te):Ye.add(te),Ye})},gs=1440*60*1e3,cr=Date.now(),Rn=te=>te.updatedAt&&cr-new Date(te.updatedAt).getTime()>gs,ss=te=>(te.status==="completed"||te.status==="cancelled")&&Rn(te),Os=(te,Ie=!1)=>{let Ye=te.filter(J=>Je||Ie||!ss(J));return m==="project"&&p&&(Ye=Ye.filter(J=>J.projectId===p)),se.size>0&&(Ye=Ye.filter(J=>J.projectId&&se.has(J.projectId))),tt.size>0&&(Ye=Ye.filter(J=>J.assignedAgentId&&tt.has(J.assignedAgentId))),Ye},as=te=>te.statuses.flatMap(Ie=>Os(g[Ie]??[])),Ur=v.useMemo(()=>{let te=O;return Je||(te=te.filter(Ie=>!ss(Ie))),m==="project"&&p&&(te=te.filter(Ie=>Ie.projectId===p)),se.size>0&&(te=te.filter(Ie=>Ie.projectId&&se.has(Ie.projectId))),tt.size>0&&(te=te.filter(Ie=>tt.has(Ie.createdBy))),te},[O,Je,m,p,se,tt]),Pn=v.useCallback(te=>Ur.filter(Ie=>TN[Ie.status]===te.id),[Ur]),Rs=Bo.filter(te=>{if(te.id==="failed"||te.id==="closed"){const Ie=as(te),Ye=Pn(te);return Ie.length+Ye.length>0}return!0}),Dn=Object.values(g).flat().filter(te=>ss(te)).length+O.filter(te=>ss(te)).length,qr=v.useMemo(()=>{const te=new Set(["completed","failed","cancelled","archived"]),Ie=Object.values(g).flat(),Ye=new Set;for(const J of Ie)J.assignedAgentId&&!te.has(J.status)&&(!p||J.projectId===p)&&Ye.add(J.assignedAgentId);return[...w].sort((J,ge)=>{const Ce=Ye.has(J.id)?0:1,Me=Ye.has(ge.id)?0:1;return Ce-Me})},[w,g,p]),xr=v.useMemo(()=>{const te=new Set(["completed","failed","cancelled","archived"]),Ie=Object.values(g).flat(),Ye=new Set;for(const J of Ie)J.projectId&&!te.has(J.status)&&Ye.add(J.projectId);return[...c].sort((J,ge)=>{const Ce=Ye.has(J.id)?0:1,Me=Ye.has(ge.id)?0:1;return Ce-Me})},[c,g]),Ar=v.useMemo(()=>{const te={};for(const Ie of Object.values(g))for(const Ye of Ie){const J=Ye.projectId??"__none__";te[J]=(te[J]??0)+1}return te},[g]),nr=Object.values(Ar).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 Vr=!!(Te||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":Vr?"shrink-0":"flex-1"} overflow-hidden flex flex-col bg-surface-secondary`,style:n?l?{display:"none"}:void 0:Vr?{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:[jn?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:jn.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:()=>q(!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(p??""),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:()=>Ue(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))}),Dn>0&&t.jsx("button",{onClick:()=>pt(te=>!te),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Je?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary"}`,children:Je?"Hide archived":`${Dn} archived`}),t.jsx("div",{className:"flex-1"}),(se.size>0||tt.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||tt.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+tt.size>0?` (${se.size+tt.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:[jn?t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(TI,{value:jn.name,onSave:async te=>{await re.projects.update(jn.id,{name:te}),Et()},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`}),Dn>0&&t.jsx("button",{onClick:()=>pt(te=>!te),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Je?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary hover:text-fg-secondary"}`,children:Je?`Hide ${Dn} archived`:`${Dn} 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:()=>Ue(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(p??""),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&&!p&&!z&&(nr>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:()=>Ee(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"}),xr.map(te=>{const Ie=se.has(te.id),Ye=Ar[te.id]??0;return t.jsxs("button",{onClick:()=>yr(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&&(nr>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:()=>Mt(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 ${tt.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),qr.map(te=>{const Ie=tt.has(te.id);return t.jsxs("button",{onClick:()=>rs(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&&jn?t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(VI,{project:jn,tasks:Object.values(g).flat(),requirements:O,agents:w,onDeleteProject:()=>hr(jn.id),onUpdateProject:async te=>{await re.projects.update(jn.id,te)},onRefresh:()=>{Et()}})}):nr===0&&Ur.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(QI,{tasks:Os(Object.values(g).flat()),requirements:Ur,agents:w,projects:c,onTaskClick:te=>Ct(te),onReqClick:te=>dt(te),onRefresh:()=>{ie(),st()},selectedTaskId:Te?.id,selectedReqId:Xe?.id}):De==="dag"?t.jsx(EI,{tasks:Os(Object.values(g).flat(),!0),requirements:Ur,agents:w,showArchived:Je,onShowArchivedChange:pt,onTaskClick:te=>Ct(te),onReqClick:te=>dt(te),onDependencyChange:ie,selectedTaskId:Te?.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=Pn(te),J=Ie.length+Ye.length,ge=Kt===te.id;return t.jsxs("div",{className:`w-[280px] shrink-0 rounded-xl flex flex-col h-full transition-colors ${ge?"bg-surface-elevated/60 ring-1 ring-brand-500/30":"bg-surface-secondary/50"}`,onDragOver:Ce=>$e(Ce,te.id),onDragLeave:Ce=>Yt(Ce,te.id),onDrop:Ce=>{br(Ce,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 Ce=[...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 Ce.sort((Me,Se)=>Se.time-Me.time),Ce.map(Me=>{if(Me.kind==="req"){const Se=Me.data,Ge=Ho[Se.status]??{label:Se.status,cls:"bg-gray-500/15 text-fg-secondary"},Nt=Se.source==="agent"&&Se.status==="pending",ht=m==="all"&&Se.projectId?c.find(Ut=>Ut.id===Se.projectId):null,lt=xi(Se.createdBy,w,C)??Se.createdBy.slice(0,10),Tt=Xe?.id===Se.id;return t.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:Ut=>ce(Ut,Se),onDragEnd:_e,onClick:()=>dt(Se),onKeyDown:Ut=>Ut.key==="Enter"&&dt(Se),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
|
+
${Tt?"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:Se.title}),Se.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Se.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:[ht&&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:ht.name,children:ht.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Se.priority}),t.jsxs("span",{className:"text-[10px] text-fg-quaternary",children:["by ",lt]})]}),t.jsx("div",{className:"flex items-center gap-1",children:Se.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:["📋 ",Se.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(),tr(Se.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(),nn(Se.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-${Se.id}`)}else{const Se=Me.data,Ge=Se.subtasks?.length??0,He=CN[Se.status],Nt=Se.status==="pending",ht=Se.taskType==="scheduled"&&!!Se.scheduleConfig,lt=ht?Se.scheduleConfig.every?`Every ${Se.scheduleConfig.every}`:Se.scheduleConfig.cron?"Cron":"Scheduled":null,Tt=m==="all"&&Se.projectId?c.find(ct=>ct.id===Se.projectId)?.name:null,Ut=Se.requirementId?O.find(ct=>ct.id===Se.requirementId)?.title:null,Nn=Se.createdBy?xi(Se.createdBy,w,C)??Se.createdBy:null,zn=Te?.id===Se.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":Se.title,draggable:!Nt,onDragStart:ct=>!Nt&&ns(ct,Se),onDragEnd:_e,onClick:()=>Ct(Se),onKeyDown:ct=>ct.key==="Enter"&&Ct(Se),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":ht?"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"} ${zn?"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[Se.priority]??"bg-gray-400"}`,title:Se.priority}),ht&&t.jsx("span",{className:"text-blue-500 shrink-0",title:lt??"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"})})}),ht&<&&t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-blue-500/10 text-blue-500 whitespace-nowrap",children:lt}),He&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md ml-auto shrink-0 ${He.cls}`,children:He.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:Se.title}),Se.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Se.description}),(Tt||Ut||Se.blockedBy&&Se.blockedBy.length>0)&&t.jsxs("div",{className:"flex flex-wrap gap-1 mb-1.5",children:[Tt&&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:Tt,children:Tt}),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]}),Se.blockedBy&&Se.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:["⏳ ",Se.blockedBy.length," dep",Se.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:Nn&&t.jsxs("span",{className:"text-[10px] text-fg-quaternary",title:`by ${Nn}`,children:["by ",Nn]})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[Ge>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["⋮ ",Ge]}),Se.notes&&Se.notes.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["📝 ",Se.notes.length]}),Se.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 ${EN[w.find(ct=>ct.id===Se.assignedAgentId)?.status??""]??"bg-gray-500"}`}),w.find(ct=>ct.id===Se.assignedAgentId)?.name??Se.assignedAgentId.slice(0,8)]})]})]})]},Se.id)}})})()}),ge&&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&&Vr&&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)&&Vr&&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:Te?t.jsx(qI,{task:Te,agents:w,projects:c,requirements:O,allTasks:Object.values(g).flat(),users:C,onClose:Qe,onRefresh:er,authUser:e}):Xe?t.jsx(JI,{req:Xe,agents:w,projects:c,allTasks:Object.values(g).flat(),users:C,onClose:Qe,onApprove:te=>{tr(te),Qe()},onReject:te=>{nn(te),Qe()},onCancel:te=>{ts(te),Qe()},onStatusChange:async(te,Ie)=>{try{await re.requirements.updateStatus(te,Ie),Dt(`Requirement status → ${Ie}`),st(),ie()}catch(Ye){Dt(`Error: ${Ye}`)}},onRefresh:st,authUser:e}):null}),G&&t.jsx(kN,{orgId:e?.orgId,onCreated:On,onClose:()=>q(!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=>_(te.target.value),onKeyDown:te=>{te.key==="Enter"&&mr()},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=>V(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)&&fe([...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(g).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(g).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:()=>fe(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:()=>{mr()},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"})]})]})}),_t&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>{St(!1),tn(""),qe("")},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:Ve,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:"",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()&&or()}})]}),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=>qe(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=>zt(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(""),qe("")},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:()=>{or()},disabled:!en.trim()||!ve.trim()||!Ve,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"})]})]})}),yn&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>nn(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:un,onChange:te=>vn(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:()=>nn(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:()=>{wn()},className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 rounded-lg text-white",children:"Reject"})]})]})}),Jt&&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||tt.size>0)&&t.jsx("button",{onClick:()=>{Ee(new Set),Mt(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:xr.map(te=>{const Ie=se.has(te.id),Ye=Ar[te.id]??0;return t.jsxs("button",{onClick:()=>yr(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:qr.map(te=>{const Ie=tt.has(te.id);return t.jsxs("button",{onClick:()=>rs(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 WI({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(()=>pn.on("requirement:comment",p=>{p.payload?.requirementId===e&&p.payload.comment&&o(x=>x.some(g=>g.id===p.payload.comment.id)?x:[...x,p.payload.comment])}),[e]);const[d,c]=v.useState(null),h=async(f,p,x)=>{await re.requirements.addComment(e,f,s?.name,s?.id,p.length>0?p: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:p,authUser:x}){const g=xs(),[y,w]=v.useState(!1),[N,C]=v.useState(e.description),[A,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:[g&&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})]})]}),!g&&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),p?.()}catch{}finally{O(!1)}},disabled:A,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(Jn,{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 q=CN[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 ${DI[G.priority]?.replace("border-l-","bg-")??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:G.title}),q&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${q.cls}`,children:q.label})]},G.id)})})]}),t.jsx(WI,{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 q=Ho[G];return t.jsx("option",{value:G,children:q?.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 ws(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,p=l?.llmModel,x=ws(d?.env),g=ws(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"})]}),ws(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:ws(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||p)&&t.jsxs("div",{className:"flex gap-2",children:[f&&t.jsx(Kl,{label:"LLM Provider",value:f,color:"gray"}),p&&t.jsx(Kl,{label:"LLM Model",value:p,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))})]}),g.length>0&&t.jsx(sl,{label:"Skills",value:g.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"})}),ws(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:ws(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,p)=>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"?"★":p+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)]})]}),ws(f.skills).length>0&&t.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:ws(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))})]},p))})]})]})}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}),ws(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:ws(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"}},Jv={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"}},e1=["file","directory"],Ns={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 t1(){const e=xs(),n=eu({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 xe=()=>{o.current&&l(!1)};return window.addEventListener("popstate",xe),()=>window.removeEventListener("popstate",xe)},[e]);const d=100,[c,h]=v.useState([]),[m,f]=v.useState(0),[p,x]=v.useState(!1),[g,y]=v.useState([]),[w,N]=v.useState([]),[C,A]=v.useState(!0),[O,k]=v.useState(""),[S,R]=v.useState(""),[D,Y]=v.useState(""),[z,K]=v.useState(""),[U,G]=v.useState(""),[q,E]=v.useState(""),[T,L]=v.useState(""),[_,P]=v.useState("date"),[V,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),fe=v.useRef(null),[Ne,Le]=v.useState("file"),[ye,je]=v.useState(""),[Te,ze]=v.useState(""),[Xe,nt]=v.useState(""),[tt,Mt]=v.useState(""),[se,Ee]=v.useState(""),[rt,vt]=v.useState(null),[Kt,we]=v.useState(null),[De,Ue]=v.useState(!1),[Je,pt]=v.useState(!1),[Jt,ln]=v.useState(!1),[Ht,Lt]=v.useState(!1),_t=v.useRef(null),St=v.useRef(null),[en,tn]=v.useState(""),ve=v.useRef(void 0),qe=(xe,Ke)=>{F({type:xe,text:Ke}),setTimeout(()=>F(null),3e3)},Rt=async xe=>{try{return await navigator.clipboard.writeText(xe),!0}catch{try{const Ke=document.createElement("textarea");Ke.value=xe,Ke.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(Ke),Ke.select();const xt=document.execCommand("copy");return document.body.removeChild(Ke),xt}catch{return!1}}},zt=async xe=>{await Rt(xe)?(Lt(!0),setTimeout(()=>Lt(!1),1500)):qe("error","Copy failed — try long-pressing to copy manually")},Ve=v.useMemo(()=>new Map(w.map(xe=>[xe.id,xe])),[w]),Pt=v.useMemo(()=>new Map(g.map(xe=>[xe.id,xe])),[g]);v.useEffect(()=>{re.projects.list().then(xe=>y(xe.projects)).catch(()=>{}),re.agents.list().then(xe=>N(xe.agents??[])).catch(()=>{}),re.system.storage().then(xe=>tn(xe.dataDir+"/shared")).catch(()=>{})},[]),v.useEffect(()=>(ve.current=setTimeout(()=>R(O),300),()=>clearTimeout(ve.current)),[O]);const yn=v.useMemo(()=>({q:S||void 0,projectId:z||void 0,agentId:U||void 0,type:D||void 0,status:q||void 0,artifactType:T||void 0}),[S,z,U,D,q,T]),nn=v.useCallback(async()=>{A(!0);try{const{results:xe,total:Ke}=await re.deliverables.search({...yn,offset:0,limit:d});h(xe),f(Ke)}catch{h([]),f(0)}A(!1)},[yn]),un=v.useCallback(async()=>{if(!(p||c.length>=m)){x(!0);try{const{results:xe,total:Ke}=await re.deliverables.search({...yn,offset:c.length,limit:d});h(xt=>[...xt,...xe]),f(Ke)}catch{}x(!1)}},[yn,c.length,m,p]);v.useEffect(()=>{nn()},[nn]),v.useEffect(()=>pn.on("deliverable:created",()=>nn()),[nn]);const vn=v.useCallback(()=>{const xe=fe.current;!xe||C||p||c.length>=m||xe.scrollHeight<=xe.clientHeight+100&&un()},[C,p,c.length,m,un]);v.useEffect(()=>{const xe=fe.current;if(!xe)return;const Ke=()=>{xe.scrollTop+xe.clientHeight>=xe.scrollHeight-100&&un()};return xe.addEventListener("scroll",Ke,{passive:!0}),()=>xe.removeEventListener("scroll",Ke)},[un]),v.useEffect(()=>{vn()},[vn,ne]);const Dt=v.useMemo(()=>{const xe=new Map;for(const xt of c){let At,On;if(_==="project")At=xt.projectId??"_none",On=xt.projectId?Pt.get(xt.projectId)?.name??xt.projectId:"No Project";else if(_==="agent")At=xt.agentId??"_none",On=xt.agentId?Ve.get(xt.agentId)?.name??xt.agentId:"Unknown";else if(_==="type")At=xt.type,On=xt.type.charAt(0).toUpperCase()+xt.type.slice(1);else{const hr=new Date(xt.updatedAt);At=`${hr.getFullYear()}-${String(hr.getMonth()+1).padStart(2,"0")}-${String(hr.getDate()).padStart(2,"0")}`,On=At}xe.has(At)||xe.set(At,{label:On,items:[]}),xe.get(At).items.push(xt)}const Ke=[...xe.entries()];return _==="date"?Ke.sort((xt,At)=>At[0].localeCompare(xt[0])):Ke.sort((xt,At)=>xt[1].label.localeCompare(At[1].label)),Ke},[c,_,Pt,Ve]),jn=async()=>{if(!(!ye.trim()||!Te.trim())){ee(!0);try{await re.deliverables.create({type:Ne,title:ye,summary:Te,reference:Xe,projectId:tt||void 0,tags:se.split(",").map(xe=>xe.trim()).filter(Boolean)}),H(!1),qe("success","Deliverable created"),nn()}catch(xe){qe("error",`Error: ${xe}`)}ee(!1)}},Et=async xe=>{I("verify");try{await re.deliverables.verify(xe.id),qe("success","Verified"),W({...xe,status:"verified"}),nn()}catch(Ke){qe("error",`Error: ${Ke}`)}I("")},ie=async xe=>{I("flag");try{await re.deliverables.update(xe.id,{status:"outdated"}),qe("success","Flagged as outdated"),W({...xe,status:"outdated"}),nn()}catch(Ke){qe("error",`Error: ${Ke}`)}I("")},Pe=async xe=>{I("remove");try{await re.deliverables.remove(xe.id),qe("success","Removed"),W(null),nn()}catch(Ke){qe("error",`Error: ${Ke}`)}I("")},Fe=()=>{bt.navigate(pe.BUILDER)},st=async xe=>{if(xe.reference){if(xe.type==="directory"){pt(!0);return}Ue(!0);try{const Ke=await re.files.preview(xe.reference);Ke.type==="image"&&Ke.mimeType?we({src:`data:${Ke.mimeType};base64,${Ke.content}`,name:Ke.name}):vt(Ke.content)}catch{vt(null),xe.type==="file"&&pt(!0)}Ue(!1)}};v.useEffect(()=>{vt(null),we(null),pt(!1),ln(!1),V&&st(V)},[V?.id]),v.useEffect(()=>{if(!Jt)return;const xe=Ke=>{St.current&&!St.current.contains(Ke.target)&&ln(!1)};return document.addEventListener("mousedown",xe),()=>document.removeEventListener("mousedown",xe)},[Jt]);const ot=async(xe,Ke)=>{const xt=_t.current?.firstElementChild;if(!xt)return;const At=nz(xt,xe);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([At],{type:"text/html"}),"text/plain":new Blob([Ke],{type:"text/plain"})})]),qe("success",xe==="light"?"HTML (light) copied":"HTML (dark) copied")}catch{const On=await Rt(Ke);qe(On?"success":"error",On?"Text copied (HTML not supported)":"Copy failed")}ln(!1)},Ct=xe=>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(Ke=>!Ke),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"})})}),Jt&&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 Ke=await Rt(xe);qe(Ke?"success":"error",Ke?"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:()=>ot("light",xe),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:()=>ot("dark",xe),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:_t,children:t.jsx(Jn,{content:xe,className:"text-fg-secondary text-sm"})})]}),dt=v.useCallback(xe=>{ae(Ke=>{const xt=new Set(Ke);return xt.has(xe)?xt.delete(xe):xt.add(xe),xt})},[]),Qe=v.useCallback(()=>{ne.size===Dt.length?ae(new Set):ae(new Set(Dt.map(([xe])=>xe)))},[ne.size,Dt]),at=()=>{je(""),ze(""),nt(""),Ee(""),Le("file"),g.length>0&&Mt(g[0].id),H(!0)},fn=xe=>{W(xe),e&&(l(!0),history.pushState({mobileDetail:pe.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:at,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:xe=>k(xe.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(Oa,{label:"All types",value:"",current:D||T||"",onClick:()=>{Y(""),L("")}}),e1.map(xe=>t.jsx(Oa,{label:`${xo[xe]?.icon??""} ${xe}`,value:xe,current:D,onClick:Ke=>{Y(Ke),L("")}},xe)),["agent","team","skill"].map(xe=>t.jsx(Oa,{label:`${Ns[xe].icon} ${Ns[xe].label}`,value:xe,current:T,onClick:Ke=>{L(Ke),Y("")}},xe))]}),g.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Oa,{label:"All projects",value:"",current:z,onClick:K}),g.map(xe=>t.jsx(Oa,{label:xe.name,value:xe.id,current:z,onClick:K},xe.id))]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Oa,{label:"Active",value:"",current:q,onClick:E}),t.jsx(Oa,{label:"Verified",value:"verified",current:q,onClick:E}),t.jsx(Oa,{label:"Outdated",value:"outdated",current:q,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(xe=>t.jsx("button",{onClick:()=>{P(xe),ae(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${_===xe?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:xe.charAt(0).toUpperCase()+xe.slice(1)},xe)),Dt.length>1&&t.jsx("button",{onClick:Qe,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===Dt.length?"Expand all":"Collapse all",children:ne.size===Dt.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:fe,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(xe=>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"})]},xe))}):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:at,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create first"})]}):Dt.map(([xe,Ke])=>{const xt=ne.has(xe);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>dt(xe),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 ${xt?"":"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:Ke.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",Ke.items.length,")"]})]}),!xt&&Ke.items.map(At=>t.jsxs("button",{onClick:()=>fn(At),className:`w-full text-left p-3 rounded-lg transition-colors ${V?.id===At.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:At.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[At.artifactType&&Ns[At.artifactType]?t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Ns[At.artifactType].color}`,children:[Ns[At.artifactType].icon," ",Ns[At.artifactType].label]}):t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium uppercase ${xo[At.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:At.type}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Jv[At.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:At.status}),At.agentId&&t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:Ve.get(At.agentId)?.name??"Agent"})]})]},At.id))]},xe)}),p&&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:V?.title??"Details"})]}),V?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:V.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[V.status!=="verified"&&t.jsx("button",{onClick:()=>Et(V),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"}),V.status!=="outdated"&&t.jsx("button",{onClick:()=>ie(V),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:()=>Pe(V),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[V.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[xo[V.type]?.icon??""," ",V.type]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${Jv[V.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:V.status}),V.artifactType&&Ns[V.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Ns[V.artifactType].color}`,children:[Ns[V.artifactType].icon," Builder ",Ns[V.artifactType].label]})]}),V.reference&&(V.type==="file"||V.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(V.reference).catch(()=>qe("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:V.reference}),t.jsx("button",{onClick:()=>{re.files.reveal(V.reference).catch(()=>qe("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:()=>zt(V.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"})]}),V.reference&&V.type!=="file"&&V.type!=="directory"&&t.jsx("div",{className:"mt-2",children:t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:V.reference})})]}),V.artifactType&&V.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:V.artifactData,mode:V.artifactType})}),V.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:V.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:Fe,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"})}),V.summary&&t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(Jn,{content:V.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..."]}):Kt?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Kt.src,alt:Kt.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Kt.name})]}):rt?Ct(rt):Je?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-fg-secondary",children:["This ",V.type," cannot be previewed in the browser."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{re.files.reveal(V.reference).catch(()=>qe("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:V.reference}),t.jsx("button",{onClick:()=>{re.files.reveal(V.reference).catch(()=>qe("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:()=>zt(V.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"})]})]}):V.summary?Ct(V.summary):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No content"})}),(V.diffStats||V.testResults)&&t.jsxs("div",{className:"flex gap-4 flex-wrap",children:[V.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:[V.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-600",children:["+",V.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",V.diffStats.deletions]})]})]}),V.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:[V.testResults.passed," passed"]}),t.jsxs("span",{className:"text-red-500",children:[V.testResults.failed," failed"]}),t.jsxs("span",{className:"text-fg-secondary",children:[V.testResults.skipped," skipped"]})]})]})]}),V.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(xe=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:xe},xe))}),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:[V.taskId&&t.jsxs("button",{onClick:()=>bt.navigate(pe.WORK,{openTask:V.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2.5 py-1 rounded",children:["Task: ",V.taskId.slice(0,12),"..."]}),V.agentId&&t.jsxs("button",{onClick:()=>bt.navigate(pe.TEAM,{selectAgent:V.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Agent: ",Ve.get(V.agentId)?.name??V.agentId.slice(0,12)]}),V.projectId&&t.jsxs("button",{onClick:()=>bt.navigate(pe.WORK,{projectId:V.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Project: ",Pt.get(V.projectId)?.name??V.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(V.createdAt).toLocaleString()})]}),t.jsxs("span",{children:["Updated: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(V.updatedAt).toLocaleString()})]}),t.jsxs("span",{children:["Accessed: ",t.jsxs("span",{className:"text-fg-secondary",children:[V.accessCount,"x"]})]})]}),t.jsxs("div",{className:"text-fg-muted select-all",children:["ID: ",V.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:xe=>xe.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:xe=>Le(xe.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:e1.map(xe=>t.jsxs("option",{value:xe,children:[xo[xe]?.icon??""," ",xe]},xe))})]}),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:xe=>je(xe.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:xe=>nt(xe.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:Te,onChange:xe=>ze(xe.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:xe=>Ee(xe.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:tt,onChange:xe=>Mt(xe.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"}),g.map(xe=>t.jsx("option",{value:xe.id,children:xe.name},xe.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:jn,disabled:Z||!ye.trim()||!Te.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 Oa({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 AN({authUser:e}){const[n,s]=v.useState("weekly"),[l,o]=v.useState(null),[d,c]=v.useState(!0),[h,m]=v.useState(""),[f,p]=v.useState(null),[x,g]=v.useState([]),[y,w]=v.useState("totalTokens"),[N,C]=v.useState(!0),[A,O]=v.useState("generate"),[k,S]=v.useState([]),[R,D]=v.useState(null),[Y,z]=v.useState([]),[K,U]=v.useState(""),[G,q]=v.useState(""),E=M=>{q(M),setTimeout(()=>q(""),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=>p(M.usage)).catch(()=>{}),re.usage.agents().then(M=>g(M.agents)).catch(()=>{})},[]),_=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(()=>{A==="history"&&_()},[A,_]);const V=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 ${A==="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 ${A==="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}),A==="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))})]})]}),A==="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))})}),A==="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(ks,{label:"Completed",value:R.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(ks,{label:"In Progress",value:R.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(ks,{label:"Created",value:R.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(ks,{label:"Blocked",value:R.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(ks,{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"),_()}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"),_()}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"})]})]})]}),A==="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"})]}),A==="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(ks,{label:"Completed",value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(ks,{label:"In Progress",value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(ks,{label:"Created",value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(ks,{label:"Blocked",value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(ks,{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),A==="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(po,{label:"Total Tokens",col:"totalTokens",current:y,desc:N,onSort:X}),t.jsx(po,{label:"Today",col:"tokensUsedToday",current:y,desc:N,onSort:X}),t.jsx(po,{label:"Requests",col:"requestCount",current:y,desc:N,onSort:X}),t.jsx(po,{label:"Tool Calls",col:"toolCalls",current:y,desc:N,onSort:X}),t.jsx(po,{label:"Est. Cost",col:"estimatedCost",current:y,desc:N,onSort:X,align:"right"})]})}),t.jsx("tbody",{children:V.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 ks({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?()=>bt.navigate(pe.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 po({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:()=>bt.navigate(pe.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 n1={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"},az={task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",task_status_changed:"text-blue-400",requirement_created:"text-amber-500",requirement_decision:"text-green-500",approval_request:"text-amber-500",agent_alert:"text-red-500",agent_escalation:"text-red-400",agent_report:"text-blue-500",agent_chat_request:"text-brand-500",agent_notification:"text-blue-400",bounty_posted:"text-amber-500",mention:"text-brand-500",system:"text-fg-tertiary"};function r1(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 s1(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 a1({collapsed:e,userId:n}){const[s,l]=v.useState(!1),[o,d]=v.useState("approvals"),[c,h]=v.useState([]),[m,f]=v.useState([]),[p,x]=v.useState(null),[g,y]=v.useState(0),w=v.useRef(null),N=v.useRef(null),[C,A]=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();A({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=g+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,_=E.actionTarget;if(L==="open_chat"&&_)try{const P=typeof _=="string"?JSON.parse(_):_;if(P.agentId){const V={agentId:P.agentId};P.sessionId&&(V.sessionId=P.sessionId),bt.navigate(pe.TEAM,V);return}}catch{}if(L==="navigate"&&_)try{const P=typeof _=="string"?JSON.parse(_):_;if(P.path&&P.path.startsWith("/work")){const V={},W=new URLSearchParams(P.path.split("?")[1]||"");for(const[B,F]of W.entries())V[B]=F;bt.navigate(pe.WORK,V);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?bt.navigate(pe.WORK,{openTask:W}):bt.navigate(pe.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":case"task_status_changed":T.taskId?bt.navigate(pe.WORK,{openTask:T.taskId}):bt.navigate(pe.WORK);break;case"requirement_created":case"requirement_decision":T.requirementId?bt.navigate(pe.WORK,{openRequirement:T.requirementId}):bt.navigate(pe.WORK);break;case"agent_chat_request":{const P={};T.agentId&&(P.agentId=T.agentId),T.sessionId&&(P.sessionId=T.sessionId),bt.navigate(pe.TEAM,Object.keys(P).length>0?P:void 0);break}case"agent_notification":case"agent_alert":case"agent_escalation":T.agentId?bt.navigate(pe.TEAM,{selectAgent:T.agentId}):bt.navigate(pe.TEAM);break;case"bounty_posted":bt.navigate(pe.SETTINGS);break;default:T.taskId?bt.navigate(pe.WORK,{openTask:T.taskId}):T.requirementId?bt.navigate(pe.WORK,{openRequirement:T.requirementId}):T.projectId?bt.navigate(pe.WORK,{projectId:T.projectId}):T.agentId&&bt.navigate(pe.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(V=>V.id===E?L:V));const _=c.find(P=>P.type==="approval_request"&&P.metadata?.approvalId===E);_&&!_.read&&(re.notifications.markRead(_.id),h(P=>P.map(V=>V.id===_.id?{...V,read:!0}:V))),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)}},q=E=>{const T=E.details?.taskId;T?bt.navigate(pe.WORK,{openTask:T}):bt.navigate(pe.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&&px.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",g>0?` (${g})`:""]}),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"&&g>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:()=>q(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," · ",r1(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:p===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:p===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:()=>q(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=>{const T=az[E.type]??"text-fg-tertiary";return 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:T,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 ${n1[E.priority]??n1.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:r1(E.createdAt)}),s1(E)&&t.jsx("span",{className:`text-[10px] font-medium ${T}`,children:s1(E)})]})]})]},E.id)})}))]})]}),document.body)]})}function go({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 lz={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"},l1=5;function iz({currentPage:e,onNavigate:n,authUser:s,onLogout:l,collapsed:o,onToggleCollapse:d}){const[c,h]=v.useState([]),[m,f]=v.useState(!1),[p,x]=v.useState(null),[g,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!==pe.WORK){x(null);return}const k=window.location.hash.slice(1).split("/");La(k[0])===pe.WORK&&k[1]&&x(k[1])},[e]);const N=async()=>{try{await re.auth.logout()}catch{}l?.()},C=m?c:c.slice(0,l1),A=c.length>l1;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(a1,{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(a1,{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:Y2.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"}),G2.filter(S=>S.section===O.key&&!(O.key==="workspace"&&S.id===pe.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(go,{d:Ql[S.id]??""}),!o&&S.label]},S.id)}),O.key==="workspace"&&o&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{x(null),n(pe.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===pe.WORK&&!p?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":e===pe.WORK?"bg-brand-600/15 text-fg-primary":"text-fg-primary hover:bg-surface-overlay"}`,children:t.jsx(go,{d:Ql[pe.WORK]})}),t.jsx("button",{onClick:()=>n(pe.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===pe.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(go,{d:Ql[pe.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=pe.WORK,n(pe.WORK)},className:`flex-1 flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${e===pe.WORK&&!p?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(go,{d:Ql[pe.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===pe.WORK&&p===S.id;return t.jsxs("button",{onClick:()=>{x(S.id),e!==pe.WORK&&n(pe.WORK),window.location.hash=im(pe.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 ${lz[S.status]??"bg-gray-600"}`}),t.jsx("span",{className:"truncate text-xs",children:S.name})]},S.id)}),A&&!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(pe.DELIVERABLES),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===pe.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(go,{d:Ql[pe.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.14"]})]}),g&&t.jsx(kN,{orgId:s?.orgId,onCreated:()=>{y(!1),w()},onClose:()=>y(!1)})]})}function oz({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:X2.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:Ql[s.id]})}),t.jsx("span",{className:`text-[10px] leading-tight ${l?"font-semibold":""}`,children:s.label})]},s.id)})})}const i1=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function cz({authUser:e}){const[n,s]=v.useState("builder"),l=gx(i1,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:i1.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(Ij,{}),n==="agents"&&t.jsx(Em,{authUser:e}),n==="teams"&&t.jsx(Tm,{}),n==="skills"&&t.jsx(_m,{})]})]})}const o1=[{id:"settings",label:"Settings"},{id:"reports",label:"Reports"}];function dz({theme:e,onThemeChange:n}){const[s,l]=v.useState("settings"),o=gx(o1,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:o1.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(Mj,{theme:e,onThemeChange:n}),s==="reports"&&t.jsx(AN,{})]})]})}const c1=2;function uz({onComplete:e,theme:n,onThemeChange:s}){const[l,o]=v.useState(0),[d,c]=v.useState(null),[h,m]=v.useState(!1),[f,p]=v.useState({}),[x,g]=v.useState(!1),[y,w]=v.useState(null),[N,C]=v.useState(!1),[A,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(_=>_.configured)&&O(!0)}).catch(()=>{})},[]),v.useEffect(()=>{l===c1&&!R.current&&!A&&(R.current=!0,Y())},[l,A]);const Y=async()=>{m(!0);try{const L=await fetch("/api/settings/env-models",{headers:D()});if(L.ok){const _=await L.json();if(c(_),_.detected.length>0){const P={};for(const V of _.detected)P[V.provider]=!0;p(P)}}}catch{}finally{m(!1)}},z=async()=>{if(!d)return;const L=d.detected.filter(_=>f[_.provider]);if(L.length!==0){g(!0),S(null);try{const _=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(_.ok){const P=await _.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{g(!1)}}},K=async()=>{C(!0);try{const _=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:D(),body:JSON.stringify({preview:!0})})).json();"error"in _||w(_)}catch{}finally{C(!1)}},U=async()=>{C(!0),S(null);try{const _=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:D(),body:JSON.stringify({preview:!1})})).json();"error"in _?S({type:"err",text:_.error}):(S({type:"ok",text:`Imported ${_.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"},{value:"cyberpunk",label:"Cyberpunk",icon:"🔮",desc:"Neon pink, dark violet"},{value:"midnight",label:"Midnight",icon:"🌊",desc:"Deep ocean, teal accents"}],q=[{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,_])=>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:_})]},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:A?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:_=>p({...f,[L.provider]:_.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,_])=>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:_})]})]},L))})}],E=()=>{l<q.length-1?o(l+1):e()},T=q[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:q.map((L,_)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${_<=l?"bg-brand-500":"bg-surface-elevated"}`},_))}),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===c1&&!A&&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===q.length-1?"Get Started":"Next"})]})]})]})})})}const fz="markus123";function hz({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 p=>{if(p.preventDefault(),!(!n.trim()||!l)){c(""),m(!0);try{const{user:x}=await re.auth.login(n.trim(),l);e(x,l===fz)}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:p=>s(p.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:p=>o(p.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 mz({onComplete:e,isFirstTime:n}){const[s,l]=v.useState(""),[o,d]=v.useState(""),[c,h]=v.useState(""),[m,f]=v.useState(""),[p,x]=v.useState(!1),g=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:g,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:p||!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:p?"Saving…":n?"Set Password & Continue":"Change Password"})]})]})]})}const lm={};function xz(){const[e,n]=v.useState(rd),[s,l]=v.useState(()=>!localStorage.getItem("markus_onboarded")),[o,d]=v.useState(!0),c=xs(),h=w_(),m=eu({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[f,p]=v.useState(()=>new Set([rd()])),[x,g]=v.useState("loading"),[y,w]=v.useState(!1),[N,C]=v.useState(null),[A,O]=v.useState(!1),k=v.useCallback(Y=>{let z=La(Y);c&&(z=F2[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),p(q=>q.has(z)?q:new Set([...q,z]))},[c]);v.useEffect(()=>{bt.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})=>{g(K),S(),rl(Er.builderArtifacts,()=>re.builder.artifacts.list()),rl(Er.builderAgents,()=>re.agents.list()),rl(Er.builderHubMyItems,()=>Gn.myItems()),rl(Er.builderInstalled,()=>re.builder.artifacts.installed()),rl(Er.hubAgents,()=>Gn.search({type:"agent",limit:50})),rl(Er.hubTeams,()=>Gn.search({type:"team",limit:50})),rl(Er.hubSkills,()=>Gn.search({type:"skill",limit:50}))}).catch(()=>g(null)),pn.connect();const Y=pn.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),z=()=>{const K=rd();n(K),p(U=>U.has(K)?U:new Set([...U,K]))};return window.addEventListener("hashchange",z),()=>{Y(),pn.disconnect(),window.removeEventListener("hashchange",z)}},[]);const R=x!=="loading"&&x!==null?x:void 0,D=v.useMemo(()=>c?{[pe.HOME]:t.jsx(jb,{}),[pe.TEAM]:t.jsx(Ay,{authUser:R}),[pe.BUILDER]:t.jsx(cz,{authUser:R}),[pe.SETTINGS]:t.jsx(dz,{theme:h.mode,onThemeChange:h.setMode}),[pe.WORK]:t.jsx(Wv,{authUser:R}),[pe.DELIVERABLES]:t.jsx(t1,{})}:{[pe.HOME]:t.jsx(jb,{}),[pe.TEAM]:t.jsx(Ay,{authUser:R}),[pe.SETTINGS]:t.jsx(Mj,{theme:h.mode,onThemeChange:h.setMode}),[pe.STORE]:t.jsx(I_,{authUser:R}),[pe.BUILDER]:t.jsx(Ij,{}),[pe.WORK]:t.jsx(Wv,{authUser:R}),[pe.DELIVERABLES]:t.jsx(t1,{}),[pe.REPORTS]:t.jsx(AN,{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(hz,{onLogin:(Y,z)=>{g(Y),z&&w(!0)}}):y?t.jsx(mz,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(uz,{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(iz,{currentPage:e,onNavigate:Y=>{k(Y),d(!1)},authUser:x,onLogout:()=>g(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&&!A&&e!==pe.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(pe.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(oz,{currentPage:e,onNavigate:k})]})}U2.createRoot(document.getElementById("root")).render(t.jsx(v.StrictMode,{children:t.jsx(xz,{})}));
|