@markus-global/cli 0.2.4 → 0.3.0
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/commands/start.js +3 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +914 -814
- package/dist/web-ui/assets/index-CvTg0RPT.css +1 -0
- package/dist/web-ui/assets/index-DJ4hiBa1.js +61 -0
- package/dist/web-ui/index.html +2 -2
- package/package.json +1 -1
- package/templates/roles/agent-father/ROLE.md +15 -1
- package/templates/roles/developer/ROLE.md +61 -16
- package/templates/roles/devops/ROLE.md +26 -4
- package/templates/roles/project-manager/ROLE.md +59 -0
- package/templates/roles/qa-engineer/ROLE.md +36 -8
- package/templates/roles/research-assistant/ROLE.md +29 -2
- package/templates/roles/reviewer/ROLE.md +14 -7
- package/templates/roles/team-factory/ROLE.md +18 -1
- package/templates/skills/agent-building/SKILL.md +4 -2
- package/templates/skills/team-building/SKILL.md +25 -5
- package/templates/teams/content-team/ANNOUNCEMENT.md +20 -6
- package/templates/teams/content-team/NORMS.md +42 -14
- package/templates/teams/content-team/team.json +31 -6
- package/templates/teams/dev-squad/ANNOUNCEMENT.md +17 -6
- package/templates/teams/dev-squad/NORMS.md +60 -20
- package/templates/teams/dev-squad/team.json +38 -7
- package/templates/teams/engineering-pod/ANNOUNCEMENT.md +26 -0
- package/templates/teams/engineering-pod/NORMS.md +78 -0
- package/templates/teams/engineering-pod/team.json +50 -0
- package/templates/teams/research-lab/ANNOUNCEMENT.md +25 -0
- package/templates/teams/research-lab/NORMS.md +88 -0
- package/templates/teams/research-lab/team.json +43 -0
- package/templates/teams/startup-team/ANNOUNCEMENT.md +20 -7
- package/templates/teams/startup-team/NORMS.md +57 -19
- package/templates/teams/startup-team/team.json +24 -8
- package/dist/web-ui/assets/index-Bcc58A3R.css +0 -1
- package/dist/web-ui/assets/index-CM4C4YC8.js +0 -61
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();function Bu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ah={exports:{}},Vl={};var K0;function g2(){if(K0)return Vl;K0=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function s(i,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:i,key:u,ref:o!==void 0?o:null,props:c}}return Vl.Fragment=r,Vl.jsx=s,Vl.jsxs=s,Vl}var J0;function p2(){return J0||(J0=1,ah.exports=g2()),ah.exports}var t=p2(),ih={exports:{}},vt={};var W0;function b2(){if(W0)return vt;W0=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),b=Symbol.iterator;function p(L){return L===null||typeof L!="object"?null:(L=b&&L[b]||L["@@iterator"],typeof L=="function"?L:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,T={};function E(L,W,R){this.props=L,this.context=W,this.refs=T,this.updater=R||w}E.prototype.isReactComponent={},E.prototype.setState=function(L,W){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,W,"setState")},E.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function C(){}C.prototype=E.prototype;function N(L,W,R){this.props=L,this.context=W,this.refs=T,this.updater=R||w}var k=N.prototype=new C;k.constructor=N,S(k,E.prototype),k.isPureReactComponent=!0;var H=Array.isArray;function M(){}var Y={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function X(L,W,R){var z=R.ref;return{$$typeof:e,type:L,key:W,ref:z!==void 0?z:null,props:R}}function P(L,W){return X(L.type,W,L.props)}function q(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function F(L){var W={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(R){return W[R]})}var D=/\/+/g;function _(L,W){return typeof L=="object"&&L!==null&&L.key!=null?F(""+L.key):W.toString(36)}function I(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(M,M):(L.status="pending",L.then(function(W){L.status==="pending"&&(L.status="fulfilled",L.value=W)},function(W){L.status==="pending"&&(L.status="rejected",L.reason=W)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function A(L,W,R,z,V){var Q=typeof L;(Q==="undefined"||Q==="boolean")&&(L=null);var te=!1;if(L===null)te=!0;else switch(Q){case"bigint":case"string":case"number":te=!0;break;case"object":switch(L.$$typeof){case e:case r:te=!0;break;case x:return te=L._init,A(te(L._payload),W,R,z,V)}}if(te)return V=V(L),te=z===""?"."+_(L,0):z,H(V)?(R="",te!=null&&(R=te.replace(D,"$&/")+"/"),A(V,W,R,"",function(ie){return ie})):V!=null&&(q(V)&&(V=P(V,R+(V.key==null||L&&L.key===V.key?"":(""+V.key).replace(D,"$&/")+"/")+te)),W.push(V)),1;te=0;var Z=z===""?".":z+":";if(H(L))for(var ee=0;ee<L.length;ee++)z=L[ee],Q=Z+_(z,ee),te+=A(z,W,R,Q,V);else if(ee=p(L),typeof ee=="function")for(L=ee.call(L),ee=0;!(z=L.next()).done;)z=z.value,Q=Z+_(z,ee++),te+=A(z,W,R,Q,V);else if(Q==="object"){if(typeof L.then=="function")return A(I(L),W,R,z,V);throw W=String(L),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return te}function G(L,W,R){if(L==null)return L;var z=[],V=0;return A(L,z,"","",function(Q){return W.call(R,Q,V++)}),z}function U(L){if(L._status===-1){var W=L._result;W=W(),W.then(function(R){(L._status===0||L._status===-1)&&(L._status=1,L._result=R)},function(R){(L._status===0||L._status===-1)&&(L._status=2,L._result=R)}),L._status===-1&&(L._status=0,L._result=W)}if(L._status===1)return L._result.default;throw L._result}var K=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},B={map:G,forEach:function(L,W,R){G(L,function(){W.apply(this,arguments)},R)},count:function(L){var W=0;return G(L,function(){W++}),W},toArray:function(L){return G(L,function(W){return W})||[]},only:function(L){if(!q(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return vt.Activity=g,vt.Children=B,vt.Component=E,vt.Fragment=s,vt.Profiler=o,vt.PureComponent=N,vt.StrictMode=i,vt.Suspense=m,vt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Y,vt.__COMPILER_RUNTIME={__proto__:null,c:function(L){return Y.H.useMemoCache(L)}},vt.cache=function(L){return function(){return L.apply(null,arguments)}},vt.cacheSignal=function(){return null},vt.cloneElement=function(L,W,R){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var z=S({},L.props),V=L.key;if(W!=null)for(Q in W.key!==void 0&&(V=""+W.key),W)!$.call(W,Q)||Q==="key"||Q==="__self"||Q==="__source"||Q==="ref"&&W.ref===void 0||(z[Q]=W[Q]);var Q=arguments.length-2;if(Q===1)z.children=R;else if(1<Q){for(var te=Array(Q),Z=0;Z<Q;Z++)te[Z]=arguments[Z+2];z.children=te}return X(L.type,V,z)},vt.createContext=function(L){return L={$$typeof:u,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:c,_context:L},L},vt.createElement=function(L,W,R){var z,V={},Q=null;if(W!=null)for(z in W.key!==void 0&&(Q=""+W.key),W)$.call(W,z)&&z!=="key"&&z!=="__self"&&z!=="__source"&&(V[z]=W[z]);var te=arguments.length-2;if(te===1)V.children=R;else if(1<te){for(var Z=Array(te),ee=0;ee<te;ee++)Z[ee]=arguments[ee+2];V.children=Z}if(L&&L.defaultProps)for(z in te=L.defaultProps,te)V[z]===void 0&&(V[z]=te[z]);return X(L,Q,V)},vt.createRef=function(){return{current:null}},vt.forwardRef=function(L){return{$$typeof:f,render:L}},vt.isValidElement=q,vt.lazy=function(L){return{$$typeof:x,_payload:{_status:-1,_result:L},_init:U}},vt.memo=function(L,W){return{$$typeof:h,type:L,compare:W===void 0?null:W}},vt.startTransition=function(L){var W=Y.T,R={};Y.T=R;try{var z=L(),V=Y.S;V!==null&&V(R,z),typeof z=="object"&&z!==null&&typeof z.then=="function"&&z.then(M,K)}catch(Q){K(Q)}finally{W!==null&&R.types!==null&&(W.types=R.types),Y.T=W}},vt.unstable_useCacheRefresh=function(){return Y.H.useCacheRefresh()},vt.use=function(L){return Y.H.use(L)},vt.useActionState=function(L,W,R){return Y.H.useActionState(L,W,R)},vt.useCallback=function(L,W){return Y.H.useCallback(L,W)},vt.useContext=function(L){return Y.H.useContext(L)},vt.useDebugValue=function(){},vt.useDeferredValue=function(L,W){return Y.H.useDeferredValue(L,W)},vt.useEffect=function(L,W){return Y.H.useEffect(L,W)},vt.useEffectEvent=function(L){return Y.H.useEffectEvent(L)},vt.useId=function(){return Y.H.useId()},vt.useImperativeHandle=function(L,W,R){return Y.H.useImperativeHandle(L,W,R)},vt.useInsertionEffect=function(L,W){return Y.H.useInsertionEffect(L,W)},vt.useLayoutEffect=function(L,W){return Y.H.useLayoutEffect(L,W)},vt.useMemo=function(L,W){return Y.H.useMemo(L,W)},vt.useOptimistic=function(L,W){return Y.H.useOptimistic(L,W)},vt.useReducer=function(L,W,R){return Y.H.useReducer(L,W,R)},vt.useRef=function(L){return Y.H.useRef(L)},vt.useState=function(L){return Y.H.useState(L)},vt.useSyncExternalStore=function(L,W,R){return Y.H.useSyncExternalStore(L,W,R)},vt.useTransition=function(){return Y.H.useTransition()},vt.version="19.2.4",vt}var eb;function _o(){return eb||(eb=1,ih.exports=b2()),ih.exports}var j=_o();const y2=Bu(j);var lh={exports:{}},Fl={},oh={exports:{}},ch={};var tb;function v2(){return tb||(tb=1,(function(e){function r(A,G){var U=A.length;A.push(G);e:for(;0<U;){var K=U-1>>>1,B=A[K];if(0<o(B,G))A[K]=G,A[U]=B,U=K;else break e}}function s(A){return A.length===0?null:A[0]}function i(A){if(A.length===0)return null;var G=A[0],U=A.pop();if(U!==G){A[0]=U;e:for(var K=0,B=A.length,L=B>>>1;K<L;){var W=2*(K+1)-1,R=A[W],z=W+1,V=A[z];if(0>o(R,U))z<B&&0>o(V,R)?(A[K]=V,A[z]=U,K=z):(A[K]=R,A[W]=U,K=W);else if(z<B&&0>o(V,U))A[K]=V,A[z]=U,K=z;else break e}}return G}function o(A,G){var U=A.sortIndex-G.sortIndex;return U!==0?U:A.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var m=[],h=[],x=1,g=null,b=3,p=!1,w=!1,S=!1,T=!1,E=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function k(A){for(var G=s(h);G!==null;){if(G.callback===null)i(h);else if(G.startTime<=A)i(h),G.sortIndex=G.expirationTime,r(m,G);else break;G=s(h)}}function H(A){if(S=!1,k(A),!w)if(s(m)!==null)w=!0,M||(M=!0,F());else{var G=s(h);G!==null&&I(H,G.startTime-A)}}var M=!1,Y=-1,$=5,X=-1;function P(){return T?!0:!(e.unstable_now()-X<$)}function q(){if(T=!1,M){var A=e.unstable_now();X=A;var G=!0;try{e:{w=!1,S&&(S=!1,C(Y),Y=-1),p=!0;var U=b;try{t:{for(k(A),g=s(m);g!==null&&!(g.expirationTime>A&&P());){var K=g.callback;if(typeof K=="function"){g.callback=null,b=g.priorityLevel;var B=K(g.expirationTime<=A);if(A=e.unstable_now(),typeof B=="function"){g.callback=B,k(A),G=!0;break t}g===s(m)&&i(m),k(A)}else i(m);g=s(m)}if(g!==null)G=!0;else{var L=s(h);L!==null&&I(H,L.startTime-A),G=!1}}break e}finally{g=null,b=U,p=!1}G=void 0}}finally{G?F():M=!1}}}var F;if(typeof N=="function")F=function(){N(q)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,_=D.port2;D.port1.onmessage=q,F=function(){_.postMessage(null)}}else F=function(){E(q,0)};function I(A,G){Y=E(function(){A(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(A){switch(b){case 1:case 2:case 3:var G=3;break;default:G=b}var U=b;b=G;try{return A()}finally{b=U}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(A,G){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var U=b;b=A;try{return G()}finally{b=U}},e.unstable_scheduleCallback=function(A,G,U){var K=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?K+U:K):U=K,A){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=U+B,A={id:x++,callback:G,priorityLevel:A,startTime:U,expirationTime:B,sortIndex:-1},U>K?(A.sortIndex=U,r(h,A),s(m)===null&&A===s(h)&&(S?(C(Y),Y=-1):S=!0,I(H,U-K))):(A.sortIndex=B,r(m,A),w||p||(w=!0,M||(M=!0,F()))),A},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(A){var G=b;return function(){var U=b;b=G;try{return A.apply(this,arguments)}finally{b=U}}}})(ch)),ch}var nb;function j2(){return nb||(nb=1,oh.exports=v2()),oh.exports}var uh={exports:{}},Jn={};var rb;function w2(){if(rb)return Jn;rb=1;var e=_o();function r(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)h+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var i={d:{f:s,r:function(){throw Error(r(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 c(m,h,x){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:h,implementation:x}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Jn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Jn.createPortal=function(m,h){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(r(299));return c(m,h,null,x)},Jn.flushSync=function(m){var h=u.T,x=i.p;try{if(u.T=null,i.p=2,m)return m()}finally{u.T=h,i.p=x,i.d.f()}},Jn.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,i.d.C(m,h))},Jn.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},Jn.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,p=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;x==="style"?i.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:b,fetchPriority:p}):x==="script"&&i.d.X(m,{crossOrigin:g,integrity:b,fetchPriority:p,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Jn.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var x=f(h.as,h.crossOrigin);i.d.M(m,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&i.d.M(m)},Jn.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin);i.d.L(m,x,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Jn.preloadModule=function(m,h){if(typeof m=="string")if(h){var x=f(h.as,h.crossOrigin);i.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else i.d.m(m)},Jn.requestFormReset=function(m){i.d.r(m)},Jn.unstable_batchedUpdates=function(m,h){return m(h)},Jn.useFormState=function(m,h,x){return u.H.useFormState(m,h,x)},Jn.useFormStatus=function(){return u.H.useHostTransitionStatus()},Jn.version="19.2.4",Jn}var sb;function qv(){if(sb)return uh.exports;sb=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(r){console.error(r)}}return e(),uh.exports=w2(),uh.exports}var ab;function N2(){if(ab)return Fl;ab=1;var e=j2(),r=_o(),s=qv();function i(n){var a="https://react.dev/errors/"+n;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)a+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+n+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function c(n){var a=n,l=n;if(n.alternate)for(;a.return;)a=a.return;else{n=a;do a=n,(a.flags&4098)!==0&&(l=a.return),n=a.return;while(n)}return a.tag===3?l:null}function u(n){if(n.tag===13){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function f(n){if(n.tag===31){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function m(n){if(c(n)!==n)throw Error(i(188))}function h(n){var a=n.alternate;if(!a){if(a=c(n),a===null)throw Error(i(188));return a!==n?null:n}for(var l=n,d=a;;){var y=l.return;if(y===null)break;var v=y.alternate;if(v===null){if(d=y.return,d!==null){l=d;continue}break}if(y.child===v.child){for(v=y.child;v;){if(v===l)return m(y),n;if(v===d)return m(y),a;v=v.sibling}throw Error(i(188))}if(l.return!==d.return)l=y,d=v;else{for(var O=!1,J=y.child;J;){if(J===l){O=!0,l=y,d=v;break}if(J===d){O=!0,d=y,l=v;break}J=J.sibling}if(!O){for(J=v.child;J;){if(J===l){O=!0,l=v,d=y;break}if(J===d){O=!0,d=v,l=y;break}J=J.sibling}if(!O)throw Error(i(189))}}if(l.alternate!==d)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?n:a}function x(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n;for(n=n.child;n!==null;){if(a=x(n),a!==null)return a;n=n.sibling}return null}var g=Object.assign,b=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),N=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),q=Symbol.iterator;function F(n){return n===null||typeof n!="object"?null:(n=q&&n[q]||n["@@iterator"],typeof n=="function"?n:null)}var D=Symbol.for("react.client.reference");function _(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===D?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case S:return"Fragment";case E:return"Profiler";case T:return"StrictMode";case H:return"Suspense";case M:return"SuspenseList";case X:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case w:return"Portal";case N:return n.displayName||"Context";case C:return(n._context.displayName||"Context")+".Consumer";case k:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Y:return a=n.displayName||null,a!==null?a:_(n.type)||"Memo";case $:a=n._payload,n=n._init;try{return _(n(a))}catch{}}return null}var I=Array.isArray,A=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U={pending:!1,data:null,method:null,action:null},K=[],B=-1;function L(n){return{current:n}}function W(n){0>B||(n.current=K[B],K[B]=null,B--)}function R(n,a){B++,K[B]=n.current,n.current=a}var z=L(null),V=L(null),Q=L(null),te=L(null);function Z(n,a){switch(R(Q,a),R(V,n),R(z,null),a.nodeType){case 9:case 11:n=(n=a.documentElement)&&(n=n.namespaceURI)?v0(n):0;break;default:if(n=a.tagName,a=a.namespaceURI)a=v0(a),n=j0(a,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}W(z),R(z,n)}function ee(){W(z),W(V),W(Q)}function ie(n){n.memoizedState!==null&&R(te,n);var a=z.current,l=j0(a,n.type);a!==l&&(R(V,n),R(z,l))}function je(n){V.current===n&&(W(z),W(V)),te.current===n&&(W(te),Hl._currentValue=U)}var ke,De;function Ie(n){if(ke===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);ke=a&&a[1]||"",De=-1<l.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+ke+n+De}var ze=!1;function Ze(n,a){if(!n||ze)return"";ze=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var d={DetermineComponentFrameRoot:function(){try{if(a){var Te=function(){throw Error()};if(Object.defineProperty(Te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Te,[])}catch(we){var ge=we}Reflect.construct(n,[],Te)}else{try{Te.call()}catch(we){ge=we}n.call(Te.prototype)}}else{try{throw Error()}catch(we){ge=we}(Te=n())&&typeof Te.catch=="function"&&Te.catch(function(){})}}catch(we){if(we&&ge&&typeof we.stack=="string")return[we.stack,ge.stack]}return[null,null]}};d.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(d.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(d.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=d.DetermineComponentFrameRoot(),O=v[0],J=v[1];if(O&&J){var se=O.split(`
|
|
4
|
-
`),me=J.split(`
|
|
5
|
-
`);for(y=d=0;d<se.length&&!se[d].includes("DetermineComponentFrameRoot");)d++;for(;y<me.length&&!me[y].includes("DetermineComponentFrameRoot");)y++;if(d===se.length||y===me.length)for(d=se.length-1,y=me.length-1;1<=d&&0<=y&&se[d]!==me[y];)y--;for(;1<=d&&0<=y;d--,y--)if(se[d]!==me[y]){if(d!==1||y!==1)do if(d--,y--,0>y||se[d]!==me[y]){var Ce=`
|
|
6
|
-
`+se[d].replace(" at new "," at ");return n.displayName&&Ce.includes("<anonymous>")&&(Ce=Ce.replace("<anonymous>",n.displayName)),Ce}while(1<=d&&0<=y);break}}}finally{ze=!1,Error.prepareStackTrace=l}return(l=n?n.displayName||n.name:"")?Ie(l):""}function Ae(n,a){switch(n.tag){case 26:case 27:case 5:return Ie(n.type);case 16:return Ie("Lazy");case 13:return n.child!==a&&a!==null?Ie("Suspense Fallback"):Ie("Suspense");case 19:return Ie("SuspenseList");case 0:case 15:return Ze(n.type,!1);case 11:return Ze(n.type.render,!1);case 1:return Ze(n.type,!0);case 31:return Ie("Activity");default:return""}}function We(n){try{var a="",l=null;do a+=Ae(n,l),l=n,n=n.return;while(n);return a}catch(d){return`
|
|
7
|
-
Error generating stack: `+d.message+`
|
|
8
|
-
`+d.stack}}var xt=Object.prototype.hasOwnProperty,Lt=e.unstable_scheduleCallback,le=e.unstable_cancelCallback,_e=e.unstable_shouldYield,ht=e.unstable_requestPaint,Ct=e.unstable_now,Ft=e.unstable_getCurrentPriorityLevel,be=e.unstable_ImmediatePriority,Me=e.unstable_UserBlockingPriority,Ve=e.unstable_NormalPriority,Xe=e.unstable_LowPriority,rt=e.unstable_IdlePriority,It=e.log,Ht=e.unstable_setDisableYieldValue,_t=null,wt=null;function xe(n){if(typeof It=="function"&&Ht(n),wt&&typeof wt.setStrictMode=="function")try{wt.setStrictMode(_t,n)}catch{}}var Be=Math.clz32?Math.clz32:ue,gt=Math.log,pt=Math.LN2;function ue(n){return n>>>=0,n===0?32:31-(gt(n)/pt|0)|0}var Se=256,Ke=262144,At=4194304;function rn(n){var a=n&42;if(a!==0)return a;switch(n&-n){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 n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function vn(n,a,l){var d=n.pendingLanes;if(d===0)return 0;var y=0,v=n.suspendedLanes,O=n.pingedLanes;n=n.warmLanes;var J=d&134217727;return J!==0?(d=J&~v,d!==0?y=rn(d):(O&=J,O!==0?y=rn(O):l||(l=J&~n,l!==0&&(y=rn(l))))):(J=d&~v,J!==0?y=rn(J):O!==0?y=rn(O):l||(l=d&~n,l!==0&&(y=rn(l)))),y===0?0:a!==0&&a!==y&&(a&v)===0&&(v=y&-y,l=a&-a,v>=l||v===32&&(l&4194048)!==0)?a:y}function Mt(n,a){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&a)===0}function oe(n,a){switch(n){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 Le(){var n=At;return At<<=1,(At&62914560)===0&&(At=4194304),n}function $e(n){for(var a=[],l=0;31>l;l++)a.push(n);return a}function st(n,a){n.pendingLanes|=a,a!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function at(n,a,l,d,y,v){var O=n.pendingLanes;n.pendingLanes=l,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=l,n.entangledLanes&=l,n.errorRecoveryDisabledLanes&=l,n.shellSuspendCounter=0;var J=n.entanglements,se=n.expirationTimes,me=n.hiddenUpdates;for(l=O&~l;0<l;){var Ce=31-Be(l),Te=1<<Ce;J[Ce]=0,se[Ce]=-1;var ge=me[Ce];if(ge!==null)for(me[Ce]=null,Ce=0;Ce<ge.length;Ce++){var we=ge[Ce];we!==null&&(we.lane&=-536870913)}l&=~Te}d!==0&&Ue(n,d,0),v!==0&&y===0&&n.tag!==0&&(n.suspendedLanes|=v&~(O&~a))}function Ue(n,a,l){n.pendingLanes|=a,n.suspendedLanes&=~a;var d=31-Be(a);n.entangledLanes|=a,n.entanglements[d]=n.entanglements[d]|1073741824|l&261930}function jn(n,a){var l=n.entangledLanes|=a;for(n=n.entanglements;l;){var d=31-Be(l),y=1<<d;y&a|n[d]&a&&(n[d]|=a),l&=~y}}function gn(n,a){var l=a&-a;return l=(l&42)!==0?1:Dt(l),(l&(n.suspendedLanes|a))!==0?0:l}function Dt(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function Dn(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function Un(){var n=G.p;return n!==0?n:(n=window.event,n===void 0?32:V0(n.type))}function On(n,a){var l=G.p;try{return G.p=n,a()}finally{G.p=l}}var on=Math.random().toString(36).slice(2),cn="__reactFiber$"+on,wn="__reactProps$"+on,qn="__reactContainer$"+on,ve="__reactEvents$"+on,Qe="__reactListeners$"+on,Nt="__reactHandles$"+on,Et="__reactResources$"+on,Nn="__reactMarker$"+on;function ar(n){delete n[cn],delete n[wn],delete n[ve],delete n[Qe],delete n[Nt]}function ir(n){var a=n[cn];if(a)return a;for(var l=n.parentNode;l;){if(a=l[qn]||l[cn]){if(l=a.alternate,a.child!==null||l!==null&&l.child!==null)for(n=T0(n);n!==null;){if(l=n[cn])return l;n=T0(n)}return a}n=l,l=n.parentNode}return null}function Or(n){if(n=n[cn]||n[qn]){var a=n.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return n}return null}function Rr(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n.stateNode;throw Error(i(33))}function vr(n){var a=n[Et];return a||(a=n[Et]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function un(n){n[Nn]=!0}var zr=new Set,Ps={};function lr(n,a){or(n,a),or(n+"Capture",a)}function or(n,a){for(Ps[n]=a,n=0;n<a.length;n++)zr.add(a[n])}var Us=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]*$"),Tn={},Gr={};function Sa(n){return xt.call(Gr,n)?!0:xt.call(Tn,n)?!1:Us.test(n)?Gr[n]=!0:(Tn[n]=!0,!1)}function cr(n,a,l){if(Sa(a))if(l===null)n.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":n.removeAttribute(a);return;case"boolean":var d=a.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){n.removeAttribute(a);return}}n.setAttribute(a,""+l)}}function Lr(n,a,l){if(l===null)n.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(a);return}n.setAttribute(a,""+l)}}function Yn(n,a,l,d){if(d===null)n.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(l);return}n.setAttributeNS(a,l,""+d)}}function kn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function jr(n){var a=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function ne(n,a,l){var d=Object.getOwnPropertyDescriptor(n.constructor.prototype,a);if(!n.hasOwnProperty(a)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var y=d.get,v=d.set;return Object.defineProperty(n,a,{configurable:!0,get:function(){return y.call(this)},set:function(O){l=""+O,v.call(this,O)}}),Object.defineProperty(n,a,{enumerable:d.enumerable}),{getValue:function(){return l},setValue:function(O){l=""+O},stopTracking:function(){n._valueTracker=null,delete n[a]}}}}function Oe(n){if(!n._valueTracker){var a=jr(n)?"checked":"value";n._valueTracker=ne(n,a,""+n[a])}}function Pe(n){if(!n)return!1;var a=n._valueTracker;if(!a)return!0;var l=a.getValue(),d="";return n&&(d=jr(n)?n.checked?"true":"false":n.value),n=d,n!==l?(a.setValue(n),!0):!1}function et(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var re=/[\n"\\]/g;function pe(n){return n.replace(re,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Ne(n,a,l,d,y,v,O,J){n.name="",O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?n.type=O:n.removeAttribute("type"),a!=null?O==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+kn(a)):n.value!==""+kn(a)&&(n.value=""+kn(a)):O!=="submit"&&O!=="reset"||n.removeAttribute("value"),a!=null?dt(n,O,kn(a)):l!=null?dt(n,O,kn(l)):d!=null&&n.removeAttribute("value"),y==null&&v!=null&&(n.defaultChecked=!!v),y!=null&&(n.checked=y&&typeof y!="function"&&typeof y!="symbol"),J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?n.name=""+kn(J):n.removeAttribute("name")}function ye(n,a,l,d,y,v,O,J){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(n.type=v),a!=null||l!=null){if(!(v!=="submit"&&v!=="reset"||a!=null)){Oe(n);return}l=l!=null?""+kn(l):"",a=a!=null?""+kn(a):l,J||a===n.value||(n.value=a),n.defaultValue=a}d=d??y,d=typeof d!="function"&&typeof d!="symbol"&&!!d,n.checked=J?n.checked:!!d,n.defaultChecked=!!d,O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(n.name=O),Oe(n)}function dt(n,a,l){a==="number"&&et(n.ownerDocument)===n||n.defaultValue===""+l||(n.defaultValue=""+l)}function He(n,a,l,d){if(n=n.options,a){a={};for(var y=0;y<l.length;y++)a["$"+l[y]]=!0;for(l=0;l<n.length;l++)y=a.hasOwnProperty("$"+n[l].value),n[l].selected!==y&&(n[l].selected=y),y&&d&&(n[l].defaultSelected=!0)}else{for(l=""+kn(l),a=null,y=0;y<n.length;y++){if(n[y].value===l){n[y].selected=!0,d&&(n[y].defaultSelected=!0);return}a!==null||n[y].disabled||(a=n[y])}a!==null&&(a.selected=!0)}}function Fe(n,a,l){if(a!=null&&(a=""+kn(a),a!==n.value&&(n.value=a),l==null)){n.defaultValue!==a&&(n.defaultValue=a);return}n.defaultValue=l!=null?""+kn(l):""}function bt(n,a,l,d){if(a==null){if(d!=null){if(l!=null)throw Error(i(92));if(I(d)){if(1<d.length)throw Error(i(93));d=d[0]}l=d}l==null&&(l=""),a=l}l=kn(a),n.defaultValue=l,d=n.textContent,d===l&&d!==""&&d!==null&&(n.value=d),Oe(n)}function it(n,a){if(a){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=a;return}}n.textContent=a}var tt=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 Xt(n,a,l){var d=a.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?d?n.setProperty(a,""):a==="float"?n.cssFloat="":n[a]="":d?n.setProperty(a,l):typeof l!="number"||l===0||tt.has(a)?a==="float"?n.cssFloat=l:n[a]=(""+l).trim():n[a]=l+"px"}function Zt(n,a,l){if(a!=null&&typeof a!="object")throw Error(i(62));if(n=n.style,l!=null){for(var d in l)!l.hasOwnProperty(d)||a!=null&&a.hasOwnProperty(d)||(d.indexOf("--")===0?n.setProperty(d,""):d==="float"?n.cssFloat="":n[d]="");for(var y in a)d=a[y],a.hasOwnProperty(y)&&l[y]!==d&&Xt(n,y,d)}else for(var v in a)a.hasOwnProperty(v)&&Xt(n,v,a[v])}function hn(n){if(n.indexOf("-")===-1)return!1;switch(n){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 yt=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"]]),Tt=/^[\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 ut(n){return Tt.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function qe(){}var Ge=null;function ot(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ct=null,sn=null;function nr(n){var a=Or(n);if(a&&(n=a.stateNode)){var l=n[wn]||null;e:switch(n=a.stateNode,a.type){case"input":if(Ne(n,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),a=l.name,l.type==="radio"&&a!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+pe(""+a)+'"][type="radio"]'),a=0;a<l.length;a++){var d=l[a];if(d!==n&&d.form===n.form){var y=d[wn]||null;if(!y)throw Error(i(90));Ne(d,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name)}}for(a=0;a<l.length;a++)d=l[a],d.form===n.form&&Pe(d)}break e;case"textarea":Fe(n,l.value,l.defaultValue);break e;case"select":a=l.value,a!=null&&He(n,!!l.multiple,a,!1)}}}var Ca=!1;function Bo(n,a,l){if(Ca)return n(a,l);Ca=!0;try{var d=n(a);return d}finally{if(Ca=!1,(ct!==null||sn!==null)&&(Cc(),ct&&(a=ct,n=sn,sn=ct=null,nr(a),n)))for(a=0;a<n.length;a++)nr(n[a])}}function rl(n,a){var l=n.stateNode;if(l===null)return null;var d=l[wn]||null;if(d===null)return null;l=d[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":(d=!d.disabled)||(n=n.type,d=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!d;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(i(231,a,typeof l));return l}var bs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),sd=!1;if(bs)try{var sl={};Object.defineProperty(sl,"passive",{get:function(){sd=!0}}),window.addEventListener("test",sl,sl),window.removeEventListener("test",sl,sl)}catch{sd=!1}var qs=null,ad=null,Ho=null;function jx(){if(Ho)return Ho;var n,a=ad,l=a.length,d,y="value"in qs?qs.value:qs.textContent,v=y.length;for(n=0;n<l&&a[n]===y[n];n++);var O=l-n;for(d=1;d<=O&&a[l-d]===y[v-d];d++);return Ho=y.slice(n,1<d?1-d:void 0)}function Po(n){var a=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&a===13&&(n=13)):n=a,n===10&&(n=13),32<=n||n===13?n:0}function Uo(){return!0}function wx(){return!1}function ur(n){function a(l,d,y,v,O){this._reactName=l,this._targetInst=y,this.type=d,this.nativeEvent=v,this.target=O,this.currentTarget=null;for(var J in n)n.hasOwnProperty(J)&&(l=n[J],this[J]=l?l(v):v[J]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?Uo:wx,this.isPropagationStopped=wx,this}return g(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Uo)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Uo)},persist:function(){},isPersistent:Uo}),a}var Ea={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qo=ur(Ea),al=g({},Ea,{view:0,detail:0}),mN=ur(al),id,ld,il,Vo=g({},al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cd,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==il&&(il&&n.type==="mousemove"?(id=n.screenX-il.screenX,ld=n.screenY-il.screenY):ld=id=0,il=n),id)},movementY:function(n){return"movementY"in n?n.movementY:ld}}),Nx=ur(Vo),xN=g({},Vo,{dataTransfer:0}),gN=ur(xN),pN=g({},al,{relatedTarget:0}),od=ur(pN),bN=g({},Ea,{animationName:0,elapsedTime:0,pseudoElement:0}),yN=ur(bN),vN=g({},Ea,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),jN=ur(vN),wN=g({},Ea,{data:0}),kx=ur(wN),NN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},kN={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"},SN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function CN(n){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(n):(n=SN[n])?!!a[n]:!1}function cd(){return CN}var EN=g({},al,{key:function(n){if(n.key){var a=NN[n.key]||n.key;if(a!=="Unidentified")return a}return n.type==="keypress"?(n=Po(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?kN[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cd,charCode:function(n){return n.type==="keypress"?Po(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Po(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),TN=ur(EN),_N=g({},Vo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Sx=ur(_N),AN=g({},al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cd}),MN=ur(AN),DN=g({},Ea,{propertyName:0,elapsedTime:0,pseudoElement:0}),ON=ur(DN),RN=g({},Vo,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),zN=ur(RN),LN=g({},Ea,{newState:0,oldState:0}),IN=ur(LN),$N=[9,13,27,32],ud=bs&&"CompositionEvent"in window,ll=null;bs&&"documentMode"in document&&(ll=document.documentMode);var BN=bs&&"TextEvent"in window&&!ll,Cx=bs&&(!ud||ll&&8<ll&&11>=ll),Ex=" ",Tx=!1;function _x(n,a){switch(n){case"keyup":return $N.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ax(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ri=!1;function HN(n,a){switch(n){case"compositionend":return Ax(a);case"keypress":return a.which!==32?null:(Tx=!0,Ex);case"textInput":return n=a.data,n===Ex&&Tx?null:n;default:return null}}function PN(n,a){if(ri)return n==="compositionend"||!ud&&_x(n,a)?(n=jx(),Ho=ad=qs=null,ri=!1,n):null;switch(n){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 Cx&&a.locale!=="ko"?null:a.data;default:return null}}var UN={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 Mx(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a==="input"?!!UN[n.type]:a==="textarea"}function Dx(n,a,l,d){ct?sn?sn.push(d):sn=[d]:ct=d,a=Oc(a,"onChange"),0<a.length&&(l=new qo("onChange","change",null,l,d),n.push({event:l,listeners:a}))}var ol=null,cl=null;function qN(n){m0(n,0)}function Fo(n){var a=Rr(n);if(Pe(a))return n}function Ox(n,a){if(n==="change")return a}var Rx=!1;if(bs){var dd;if(bs){var fd="oninput"in document;if(!fd){var zx=document.createElement("div");zx.setAttribute("oninput","return;"),fd=typeof zx.oninput=="function"}dd=fd}else dd=!1;Rx=dd&&(!document.documentMode||9<document.documentMode)}function Lx(){ol&&(ol.detachEvent("onpropertychange",Ix),cl=ol=null)}function Ix(n){if(n.propertyName==="value"&&Fo(cl)){var a=[];Dx(a,cl,n,ot(n)),Bo(qN,a)}}function VN(n,a,l){n==="focusin"?(Lx(),ol=a,cl=l,ol.attachEvent("onpropertychange",Ix)):n==="focusout"&&Lx()}function FN(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Fo(cl)}function YN(n,a){if(n==="click")return Fo(a)}function GN(n,a){if(n==="input"||n==="change")return Fo(a)}function XN(n,a){return n===a&&(n!==0||1/n===1/a)||n!==n&&a!==a}var wr=typeof Object.is=="function"?Object.is:XN;function ul(n,a){if(wr(n,a))return!0;if(typeof n!="object"||n===null||typeof a!="object"||a===null)return!1;var l=Object.keys(n),d=Object.keys(a);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var y=l[d];if(!xt.call(a,y)||!wr(n[y],a[y]))return!1}return!0}function $x(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Bx(n,a){var l=$x(n);n=0;for(var d;l;){if(l.nodeType===3){if(d=n+l.textContent.length,n<=a&&d>=a)return{node:l,offset:a-n};n=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=$x(l)}}function Hx(n,a){return n&&a?n===a?!0:n&&n.nodeType===3?!1:a&&a.nodeType===3?Hx(n,a.parentNode):"contains"in n?n.contains(a):n.compareDocumentPosition?!!(n.compareDocumentPosition(a)&16):!1:!1}function Px(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var a=et(n.document);a instanceof n.HTMLIFrameElement;){try{var l=typeof a.contentWindow.location.href=="string"}catch{l=!1}if(l)n=a.contentWindow;else break;a=et(n.document)}return a}function hd(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a&&(a==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||a==="textarea"||n.contentEditable==="true")}var ZN=bs&&"documentMode"in document&&11>=document.documentMode,si=null,md=null,dl=null,xd=!1;function Ux(n,a,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;xd||si==null||si!==et(d)||(d=si,"selectionStart"in d&&hd(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),dl&&ul(dl,d)||(dl=d,d=Oc(md,"onSelect"),0<d.length&&(a=new qo("onSelect","select",null,a,l),n.push({event:a,listeners:d}),a.target=si)))}function Ta(n,a){var l={};return l[n.toLowerCase()]=a.toLowerCase(),l["Webkit"+n]="webkit"+a,l["Moz"+n]="moz"+a,l}var ai={animationend:Ta("Animation","AnimationEnd"),animationiteration:Ta("Animation","AnimationIteration"),animationstart:Ta("Animation","AnimationStart"),transitionrun:Ta("Transition","TransitionRun"),transitionstart:Ta("Transition","TransitionStart"),transitioncancel:Ta("Transition","TransitionCancel"),transitionend:Ta("Transition","TransitionEnd")},gd={},qx={};bs&&(qx=document.createElement("div").style,"AnimationEvent"in window||(delete ai.animationend.animation,delete ai.animationiteration.animation,delete ai.animationstart.animation),"TransitionEvent"in window||delete ai.transitionend.transition);function _a(n){if(gd[n])return gd[n];if(!ai[n])return n;var a=ai[n],l;for(l in a)if(a.hasOwnProperty(l)&&l in qx)return gd[n]=a[l];return n}var Vx=_a("animationend"),Fx=_a("animationiteration"),Yx=_a("animationstart"),QN=_a("transitionrun"),KN=_a("transitionstart"),JN=_a("transitioncancel"),Gx=_a("transitionend"),Xx=new Map,pd="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(" ");pd.push("scrollEnd");function Xr(n,a){Xx.set(n,a),lr(a,[n])}var Yo=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Ir=[],ii=0,bd=0;function Go(){for(var n=ii,a=bd=ii=0;a<n;){var l=Ir[a];Ir[a++]=null;var d=Ir[a];Ir[a++]=null;var y=Ir[a];Ir[a++]=null;var v=Ir[a];if(Ir[a++]=null,d!==null&&y!==null){var O=d.pending;O===null?y.next=y:(y.next=O.next,O.next=y),d.pending=y}v!==0&&Zx(l,y,v)}}function Xo(n,a,l,d){Ir[ii++]=n,Ir[ii++]=a,Ir[ii++]=l,Ir[ii++]=d,bd|=d,n.lanes|=d,n=n.alternate,n!==null&&(n.lanes|=d)}function yd(n,a,l,d){return Xo(n,a,l,d),Zo(n)}function Aa(n,a){return Xo(n,null,null,a),Zo(n)}function Zx(n,a,l){n.lanes|=l;var d=n.alternate;d!==null&&(d.lanes|=l);for(var y=!1,v=n.return;v!==null;)v.childLanes|=l,d=v.alternate,d!==null&&(d.childLanes|=l),v.tag===22&&(n=v.stateNode,n===null||n._visibility&1||(y=!0)),n=v,v=v.return;return n.tag===3?(v=n.stateNode,y&&a!==null&&(y=31-Be(l),n=v.hiddenUpdates,d=n[y],d===null?n[y]=[a]:d.push(a),a.lane=l|536870912),v):null}function Zo(n){if(50<Ol)throw Ol=0,_f=null,Error(i(185));for(var a=n.return;a!==null;)n=a,a=n.return;return n.tag===3?n.stateNode:null}var li={};function WN(n,a,l,d){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nr(n,a,l,d){return new WN(n,a,l,d)}function vd(n){return n=n.prototype,!(!n||!n.isReactComponent)}function ys(n,a){var l=n.alternate;return l===null?(l=Nr(n.tag,a,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=a,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&65011712,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,a=n.dependencies,l.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l.refCleanup=n.refCleanup,l}function Qx(n,a){n.flags&=65011714;var l=n.alternate;return l===null?(n.childLanes=0,n.lanes=a,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=l.childLanes,n.lanes=l.lanes,n.child=l.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=l.memoizedProps,n.memoizedState=l.memoizedState,n.updateQueue=l.updateQueue,n.type=l.type,a=l.dependencies,n.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),n}function Qo(n,a,l,d,y,v){var O=0;if(d=n,typeof n=="function")vd(n)&&(O=1);else if(typeof n=="string")O=s2(n,l,z.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case X:return n=Nr(31,l,a,y),n.elementType=X,n.lanes=v,n;case S:return Ma(l.children,y,v,a);case T:O=8,y|=24;break;case E:return n=Nr(12,l,a,y|2),n.elementType=E,n.lanes=v,n;case H:return n=Nr(13,l,a,y),n.elementType=H,n.lanes=v,n;case M:return n=Nr(19,l,a,y),n.elementType=M,n.lanes=v,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case N:O=10;break e;case C:O=9;break e;case k:O=11;break e;case Y:O=14;break e;case $:O=16,d=null;break e}O=29,l=Error(i(130,n===null?"null":typeof n,"")),d=null}return a=Nr(O,l,a,y),a.elementType=n,a.type=d,a.lanes=v,a}function Ma(n,a,l,d){return n=Nr(7,n,d,a),n.lanes=l,n}function jd(n,a,l){return n=Nr(6,n,null,a),n.lanes=l,n}function Kx(n){var a=Nr(18,null,null,0);return a.stateNode=n,a}function wd(n,a,l){return a=Nr(4,n.children!==null?n.children:[],n.key,a),a.lanes=l,a.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},a}var Jx=new WeakMap;function $r(n,a){if(typeof n=="object"&&n!==null){var l=Jx.get(n);return l!==void 0?l:(a={value:n,source:a,stack:We(a)},Jx.set(n,a),a)}return{value:n,source:a,stack:We(a)}}var oi=[],ci=0,Ko=null,fl=0,Br=[],Hr=0,Vs=null,ss=1,as="";function vs(n,a){oi[ci++]=fl,oi[ci++]=Ko,Ko=n,fl=a}function Wx(n,a,l){Br[Hr++]=ss,Br[Hr++]=as,Br[Hr++]=Vs,Vs=n;var d=ss;n=as;var y=32-Be(d)-1;d&=~(1<<y),l+=1;var v=32-Be(a)+y;if(30<v){var O=y-y%5;v=(d&(1<<O)-1).toString(32),d>>=O,y-=O,ss=1<<32-Be(a)+y|l<<y|d,as=v+n}else ss=1<<v|l<<y|d,as=n}function Nd(n){n.return!==null&&(vs(n,1),Wx(n,1,0))}function kd(n){for(;n===Ko;)Ko=oi[--ci],oi[ci]=null,fl=oi[--ci],oi[ci]=null;for(;n===Vs;)Vs=Br[--Hr],Br[Hr]=null,as=Br[--Hr],Br[Hr]=null,ss=Br[--Hr],Br[Hr]=null}function eg(n,a){Br[Hr++]=ss,Br[Hr++]=as,Br[Hr++]=Vs,ss=a.id,as=a.overflow,Vs=n}var Xn=null,mn=null,Pt=!1,Fs=null,Pr=!1,Sd=Error(i(519));function Ys(n){var a=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw hl($r(a,n)),Sd}function tg(n){var a=n.stateNode,l=n.type,d=n.memoizedProps;switch(a[cn]=n,a[wn]=d,l){case"dialog":Rt("cancel",a),Rt("close",a);break;case"iframe":case"object":case"embed":Rt("load",a);break;case"video":case"audio":for(l=0;l<zl.length;l++)Rt(zl[l],a);break;case"source":Rt("error",a);break;case"img":case"image":case"link":Rt("error",a),Rt("load",a);break;case"details":Rt("toggle",a);break;case"input":Rt("invalid",a),ye(a,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":Rt("invalid",a);break;case"textarea":Rt("invalid",a),bt(a,d.value,d.defaultValue,d.children)}l=d.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||a.textContent===""+l||d.suppressHydrationWarning===!0||b0(a.textContent,l)?(d.popover!=null&&(Rt("beforetoggle",a),Rt("toggle",a)),d.onScroll!=null&&Rt("scroll",a),d.onScrollEnd!=null&&Rt("scrollend",a),d.onClick!=null&&(a.onclick=qe),a=!0):a=!1,a||Ys(n,!0)}function ng(n){for(Xn=n.return;Xn;)switch(Xn.tag){case 5:case 31:case 13:Pr=!1;return;case 27:case 3:Pr=!0;return;default:Xn=Xn.return}}function ui(n){if(n!==Xn)return!1;if(!Pt)return ng(n),Pt=!0,!1;var a=n.tag,l;if((l=a!==3&&a!==27)&&((l=a===5)&&(l=n.type,l=!(l!=="form"&&l!=="button")||Vf(n.type,n.memoizedProps)),l=!l),l&&mn&&Ys(n),ng(n),a===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));mn=E0(n)}else if(a===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));mn=E0(n)}else a===27?(a=mn,ia(n.type)?(n=Zf,Zf=null,mn=n):mn=a):mn=Xn?qr(n.stateNode.nextSibling):null;return!0}function Da(){mn=Xn=null,Pt=!1}function Cd(){var n=Fs;return n!==null&&(mr===null?mr=n:mr.push.apply(mr,n),Fs=null),n}function hl(n){Fs===null?Fs=[n]:Fs.push(n)}var Ed=L(null),Oa=null,js=null;function Gs(n,a,l){R(Ed,a._currentValue),a._currentValue=l}function ws(n){n._currentValue=Ed.current,W(Ed)}function Td(n,a,l){for(;n!==null;){var d=n.alternate;if((n.childLanes&a)!==a?(n.childLanes|=a,d!==null&&(d.childLanes|=a)):d!==null&&(d.childLanes&a)!==a&&(d.childLanes|=a),n===l)break;n=n.return}}function _d(n,a,l,d){var y=n.child;for(y!==null&&(y.return=n);y!==null;){var v=y.dependencies;if(v!==null){var O=y.child;v=v.firstContext;e:for(;v!==null;){var J=v;v=y;for(var se=0;se<a.length;se++)if(J.context===a[se]){v.lanes|=l,J=v.alternate,J!==null&&(J.lanes|=l),Td(v.return,l,n),d||(O=null);break e}v=J.next}}else if(y.tag===18){if(O=y.return,O===null)throw Error(i(341));O.lanes|=l,v=O.alternate,v!==null&&(v.lanes|=l),Td(O,l,n),O=null}else O=y.child;if(O!==null)O.return=y;else for(O=y;O!==null;){if(O===n){O=null;break}if(y=O.sibling,y!==null){y.return=O.return,O=y;break}O=O.return}y=O}}function di(n,a,l,d){n=null;for(var y=a,v=!1;y!==null;){if(!v){if((y.flags&524288)!==0)v=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var O=y.alternate;if(O===null)throw Error(i(387));if(O=O.memoizedProps,O!==null){var J=y.type;wr(y.pendingProps.value,O.value)||(n!==null?n.push(J):n=[J])}}else if(y===te.current){if(O=y.alternate,O===null)throw Error(i(387));O.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(n!==null?n.push(Hl):n=[Hl])}y=y.return}n!==null&&_d(a,n,l,d),a.flags|=262144}function Jo(n){for(n=n.firstContext;n!==null;){if(!wr(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Ra(n){Oa=n,js=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function Zn(n){return rg(Oa,n)}function Wo(n,a){return Oa===null&&Ra(n),rg(n,a)}function rg(n,a){var l=a._currentValue;if(a={context:a,memoizedValue:l,next:null},js===null){if(n===null)throw Error(i(308));js=a,n.dependencies={lanes:0,firstContext:a},n.flags|=524288}else js=js.next=a;return l}var e5=typeof AbortController<"u"?AbortController:function(){var n=[],a=this.signal={aborted:!1,addEventListener:function(l,d){n.push(d)}};this.abort=function(){a.aborted=!0,n.forEach(function(l){return l()})}},t5=e.unstable_scheduleCallback,n5=e.unstable_NormalPriority,Rn={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ad(){return{controller:new e5,data:new Map,refCount:0}}function ml(n){n.refCount--,n.refCount===0&&t5(n5,function(){n.controller.abort()})}var xl=null,Md=0,fi=0,hi=null;function r5(n,a){if(xl===null){var l=xl=[];Md=0,fi=zf(),hi={status:"pending",value:void 0,then:function(d){l.push(d)}}}return Md++,a.then(sg,sg),a}function sg(){if(--Md===0&&xl!==null){hi!==null&&(hi.status="fulfilled");var n=xl;xl=null,fi=0,hi=null;for(var a=0;a<n.length;a++)(0,n[a])()}}function s5(n,a){var l=[],d={status:"pending",value:null,reason:null,then:function(y){l.push(y)}};return n.then(function(){d.status="fulfilled",d.value=a;for(var y=0;y<l.length;y++)(0,l[y])(a)},function(y){for(d.status="rejected",d.reason=y,y=0;y<l.length;y++)(0,l[y])(void 0)}),d}var ag=A.S;A.S=function(n,a){Up=Ct(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&r5(n,a),ag!==null&&ag(n,a)};var za=L(null);function Dd(){var n=za.current;return n!==null?n:an.pooledCache}function ec(n,a){a===null?R(za,za.current):R(za,a.pool)}function ig(){var n=Dd();return n===null?null:{parent:Rn._currentValue,pool:n}}var mi=Error(i(460)),Od=Error(i(474)),tc=Error(i(542)),nc={then:function(){}};function lg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function og(n,a,l){switch(l=n[l],l===void 0?n.push(a):l!==a&&(a.then(qe,qe),a=l),a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,ug(n),n;default:if(typeof a.status=="string")a.then(qe,qe);else{if(n=an,n!==null&&100<n.shellSuspendCounter)throw Error(i(482));n=a,n.status="pending",n.then(function(d){if(a.status==="pending"){var y=a;y.status="fulfilled",y.value=d}},function(d){if(a.status==="pending"){var y=a;y.status="rejected",y.reason=d}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,ug(n),n}throw Ia=a,mi}}function La(n){try{var a=n._init;return a(n._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Ia=l,mi):l}}var Ia=null;function cg(){if(Ia===null)throw Error(i(459));var n=Ia;return Ia=null,n}function ug(n){if(n===mi||n===tc)throw Error(i(483))}var xi=null,gl=0;function rc(n){var a=gl;return gl+=1,xi===null&&(xi=[]),og(xi,n,a)}function pl(n,a){a=a.props.ref,n.ref=a!==void 0?a:null}function sc(n,a){throw a.$$typeof===b?Error(i(525)):(n=Object.prototype.toString.call(a),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":n)))}function dg(n){function a(de,ce){if(n){var he=de.deletions;he===null?(de.deletions=[ce],de.flags|=16):he.push(ce)}}function l(de,ce){if(!n)return null;for(;ce!==null;)a(de,ce),ce=ce.sibling;return null}function d(de){for(var ce=new Map;de!==null;)de.key!==null?ce.set(de.key,de):ce.set(de.index,de),de=de.sibling;return ce}function y(de,ce){return de=ys(de,ce),de.index=0,de.sibling=null,de}function v(de,ce,he){return de.index=he,n?(he=de.alternate,he!==null?(he=he.index,he<ce?(de.flags|=67108866,ce):he):(de.flags|=67108866,ce)):(de.flags|=1048576,ce)}function O(de){return n&&de.alternate===null&&(de.flags|=67108866),de}function J(de,ce,he,Ee){return ce===null||ce.tag!==6?(ce=jd(he,de.mode,Ee),ce.return=de,ce):(ce=y(ce,he),ce.return=de,ce)}function se(de,ce,he,Ee){var lt=he.type;return lt===S?Ce(de,ce,he.props.children,Ee,he.key):ce!==null&&(ce.elementType===lt||typeof lt=="object"&<!==null&<.$$typeof===$&&La(lt)===ce.type)?(ce=y(ce,he.props),pl(ce,he),ce.return=de,ce):(ce=Qo(he.type,he.key,he.props,null,de.mode,Ee),pl(ce,he),ce.return=de,ce)}function me(de,ce,he,Ee){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==he.containerInfo||ce.stateNode.implementation!==he.implementation?(ce=wd(he,de.mode,Ee),ce.return=de,ce):(ce=y(ce,he.children||[]),ce.return=de,ce)}function Ce(de,ce,he,Ee,lt){return ce===null||ce.tag!==7?(ce=Ma(he,de.mode,Ee,lt),ce.return=de,ce):(ce=y(ce,he),ce.return=de,ce)}function Te(de,ce,he){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=jd(""+ce,de.mode,he),ce.return=de,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case p:return he=Qo(ce.type,ce.key,ce.props,null,de.mode,he),pl(he,ce),he.return=de,he;case w:return ce=wd(ce,de.mode,he),ce.return=de,ce;case $:return ce=La(ce),Te(de,ce,he)}if(I(ce)||F(ce))return ce=Ma(ce,de.mode,he,null),ce.return=de,ce;if(typeof ce.then=="function")return Te(de,rc(ce),he);if(ce.$$typeof===N)return Te(de,Wo(de,ce),he);sc(de,ce)}return null}function ge(de,ce,he,Ee){var lt=ce!==null?ce.key:null;if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return lt!==null?null:J(de,ce,""+he,Ee);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case p:return he.key===lt?se(de,ce,he,Ee):null;case w:return he.key===lt?me(de,ce,he,Ee):null;case $:return he=La(he),ge(de,ce,he,Ee)}if(I(he)||F(he))return lt!==null?null:Ce(de,ce,he,Ee,null);if(typeof he.then=="function")return ge(de,ce,rc(he),Ee);if(he.$$typeof===N)return ge(de,ce,Wo(de,he),Ee);sc(de,he)}return null}function we(de,ce,he,Ee,lt){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint")return de=de.get(he)||null,J(ce,de,""+Ee,lt);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case p:return de=de.get(Ee.key===null?he:Ee.key)||null,se(ce,de,Ee,lt);case w:return de=de.get(Ee.key===null?he:Ee.key)||null,me(ce,de,Ee,lt);case $:return Ee=La(Ee),we(de,ce,he,Ee,lt)}if(I(Ee)||F(Ee))return de=de.get(he)||null,Ce(ce,de,Ee,lt,null);if(typeof Ee.then=="function")return we(de,ce,he,rc(Ee),lt);if(Ee.$$typeof===N)return we(de,ce,he,Wo(ce,Ee),lt);sc(ce,Ee)}return null}function Ye(de,ce,he,Ee){for(var lt=null,Yt=null,Je=ce,kt=ce=0,Bt=null;Je!==null&&kt<he.length;kt++){Je.index>kt?(Bt=Je,Je=null):Bt=Je.sibling;var Gt=ge(de,Je,he[kt],Ee);if(Gt===null){Je===null&&(Je=Bt);break}n&&Je&&Gt.alternate===null&&a(de,Je),ce=v(Gt,ce,kt),Yt===null?lt=Gt:Yt.sibling=Gt,Yt=Gt,Je=Bt}if(kt===he.length)return l(de,Je),Pt&&vs(de,kt),lt;if(Je===null){for(;kt<he.length;kt++)Je=Te(de,he[kt],Ee),Je!==null&&(ce=v(Je,ce,kt),Yt===null?lt=Je:Yt.sibling=Je,Yt=Je);return Pt&&vs(de,kt),lt}for(Je=d(Je);kt<he.length;kt++)Bt=we(Je,de,kt,he[kt],Ee),Bt!==null&&(n&&Bt.alternate!==null&&Je.delete(Bt.key===null?kt:Bt.key),ce=v(Bt,ce,kt),Yt===null?lt=Bt:Yt.sibling=Bt,Yt=Bt);return n&&Je.forEach(function(da){return a(de,da)}),Pt&&vs(de,kt),lt}function mt(de,ce,he,Ee){if(he==null)throw Error(i(151));for(var lt=null,Yt=null,Je=ce,kt=ce=0,Bt=null,Gt=he.next();Je!==null&&!Gt.done;kt++,Gt=he.next()){Je.index>kt?(Bt=Je,Je=null):Bt=Je.sibling;var da=ge(de,Je,Gt.value,Ee);if(da===null){Je===null&&(Je=Bt);break}n&&Je&&da.alternate===null&&a(de,Je),ce=v(da,ce,kt),Yt===null?lt=da:Yt.sibling=da,Yt=da,Je=Bt}if(Gt.done)return l(de,Je),Pt&&vs(de,kt),lt;if(Je===null){for(;!Gt.done;kt++,Gt=he.next())Gt=Te(de,Gt.value,Ee),Gt!==null&&(ce=v(Gt,ce,kt),Yt===null?lt=Gt:Yt.sibling=Gt,Yt=Gt);return Pt&&vs(de,kt),lt}for(Je=d(Je);!Gt.done;kt++,Gt=he.next())Gt=we(Je,de,kt,Gt.value,Ee),Gt!==null&&(n&&Gt.alternate!==null&&Je.delete(Gt.key===null?kt:Gt.key),ce=v(Gt,ce,kt),Yt===null?lt=Gt:Yt.sibling=Gt,Yt=Gt);return n&&Je.forEach(function(x2){return a(de,x2)}),Pt&&vs(de,kt),lt}function nn(de,ce,he,Ee){if(typeof he=="object"&&he!==null&&he.type===S&&he.key===null&&(he=he.props.children),typeof he=="object"&&he!==null){switch(he.$$typeof){case p:e:{for(var lt=he.key;ce!==null;){if(ce.key===lt){if(lt=he.type,lt===S){if(ce.tag===7){l(de,ce.sibling),Ee=y(ce,he.props.children),Ee.return=de,de=Ee;break e}}else if(ce.elementType===lt||typeof lt=="object"&<!==null&<.$$typeof===$&&La(lt)===ce.type){l(de,ce.sibling),Ee=y(ce,he.props),pl(Ee,he),Ee.return=de,de=Ee;break e}l(de,ce);break}else a(de,ce);ce=ce.sibling}he.type===S?(Ee=Ma(he.props.children,de.mode,Ee,he.key),Ee.return=de,de=Ee):(Ee=Qo(he.type,he.key,he.props,null,de.mode,Ee),pl(Ee,he),Ee.return=de,de=Ee)}return O(de);case w:e:{for(lt=he.key;ce!==null;){if(ce.key===lt)if(ce.tag===4&&ce.stateNode.containerInfo===he.containerInfo&&ce.stateNode.implementation===he.implementation){l(de,ce.sibling),Ee=y(ce,he.children||[]),Ee.return=de,de=Ee;break e}else{l(de,ce);break}else a(de,ce);ce=ce.sibling}Ee=wd(he,de.mode,Ee),Ee.return=de,de=Ee}return O(de);case $:return he=La(he),nn(de,ce,he,Ee)}if(I(he))return Ye(de,ce,he,Ee);if(F(he)){if(lt=F(he),typeof lt!="function")throw Error(i(150));return he=lt.call(he),mt(de,ce,he,Ee)}if(typeof he.then=="function")return nn(de,ce,rc(he),Ee);if(he.$$typeof===N)return nn(de,ce,Wo(de,he),Ee);sc(de,he)}return typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint"?(he=""+he,ce!==null&&ce.tag===6?(l(de,ce.sibling),Ee=y(ce,he),Ee.return=de,de=Ee):(l(de,ce),Ee=jd(he,de.mode,Ee),Ee.return=de,de=Ee),O(de)):l(de,ce)}return function(de,ce,he,Ee){try{gl=0;var lt=nn(de,ce,he,Ee);return xi=null,lt}catch(Je){if(Je===mi||Je===tc)throw Je;var Yt=Nr(29,Je,null,de.mode);return Yt.lanes=Ee,Yt.return=de,Yt}}}var $a=dg(!0),fg=dg(!1),Xs=!1;function Rd(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function zd(n,a){n=n.updateQueue,a.updateQueue===n&&(a.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Zs(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Qs(n,a,l){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(Qt&2)!==0){var y=d.pending;return y===null?a.next=a:(a.next=y.next,y.next=a),d.pending=a,a=Zo(n),Zx(n,null,l),a}return Xo(n,d,a,l),Zo(n)}function bl(n,a,l){if(a=a.updateQueue,a!==null&&(a=a.shared,(l&4194048)!==0)){var d=a.lanes;d&=n.pendingLanes,l|=d,a.lanes=l,jn(n,l)}}function Ld(n,a){var l=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var y=null,v=null;if(l=l.firstBaseUpdate,l!==null){do{var O={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};v===null?y=v=O:v=v.next=O,l=l.next}while(l!==null);v===null?y=v=a:v=v.next=a}else y=v=a;l={baseState:d.baseState,firstBaseUpdate:y,lastBaseUpdate:v,shared:d.shared,callbacks:d.callbacks},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=a:n.next=a,l.lastBaseUpdate=a}var Id=!1;function yl(){if(Id){var n=hi;if(n!==null)throw n}}function vl(n,a,l,d){Id=!1;var y=n.updateQueue;Xs=!1;var v=y.firstBaseUpdate,O=y.lastBaseUpdate,J=y.shared.pending;if(J!==null){y.shared.pending=null;var se=J,me=se.next;se.next=null,O===null?v=me:O.next=me,O=se;var Ce=n.alternate;Ce!==null&&(Ce=Ce.updateQueue,J=Ce.lastBaseUpdate,J!==O&&(J===null?Ce.firstBaseUpdate=me:J.next=me,Ce.lastBaseUpdate=se))}if(v!==null){var Te=y.baseState;O=0,Ce=me=se=null,J=v;do{var ge=J.lane&-536870913,we=ge!==J.lane;if(we?($t&ge)===ge:(d&ge)===ge){ge!==0&&ge===fi&&(Id=!0),Ce!==null&&(Ce=Ce.next={lane:0,tag:J.tag,payload:J.payload,callback:null,next:null});e:{var Ye=n,mt=J;ge=a;var nn=l;switch(mt.tag){case 1:if(Ye=mt.payload,typeof Ye=="function"){Te=Ye.call(nn,Te,ge);break e}Te=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=mt.payload,ge=typeof Ye=="function"?Ye.call(nn,Te,ge):Ye,ge==null)break e;Te=g({},Te,ge);break e;case 2:Xs=!0}}ge=J.callback,ge!==null&&(n.flags|=64,we&&(n.flags|=8192),we=y.callbacks,we===null?y.callbacks=[ge]:we.push(ge))}else we={lane:ge,tag:J.tag,payload:J.payload,callback:J.callback,next:null},Ce===null?(me=Ce=we,se=Te):Ce=Ce.next=we,O|=ge;if(J=J.next,J===null){if(J=y.shared.pending,J===null)break;we=J,J=we.next,we.next=null,y.lastBaseUpdate=we,y.shared.pending=null}}while(!0);Ce===null&&(se=Te),y.baseState=se,y.firstBaseUpdate=me,y.lastBaseUpdate=Ce,v===null&&(y.shared.lanes=0),ta|=O,n.lanes=O,n.memoizedState=Te}}function hg(n,a){if(typeof n!="function")throw Error(i(191,n));n.call(a)}function mg(n,a){var l=n.callbacks;if(l!==null)for(n.callbacks=null,n=0;n<l.length;n++)hg(l[n],a)}var gi=L(null),ac=L(0);function xg(n,a){n=Ms,R(ac,n),R(gi,a),Ms=n|a.baseLanes}function $d(){R(ac,Ms),R(gi,gi.current)}function Bd(){Ms=ac.current,W(gi),W(ac)}var kr=L(null),Ur=null;function Ks(n){var a=n.alternate;R(_n,_n.current&1),R(kr,n),Ur===null&&(a===null||gi.current!==null||a.memoizedState!==null)&&(Ur=n)}function Hd(n){R(_n,_n.current),R(kr,n),Ur===null&&(Ur=n)}function gg(n){n.tag===22?(R(_n,_n.current),R(kr,n),Ur===null&&(Ur=n)):Js()}function Js(){R(_n,_n.current),R(kr,kr.current)}function Sr(n){W(kr),Ur===n&&(Ur=null),W(_n)}var _n=L(0);function ic(n){for(var a=n;a!==null;){if(a.tag===13){var l=a.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Gf(l)||Xf(l)))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===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Ns=0,jt=null,en=null,zn=null,lc=!1,pi=!1,Ba=!1,oc=0,jl=0,bi=null,a5=0;function Sn(){throw Error(i(321))}function Pd(n,a){if(a===null)return!1;for(var l=0;l<a.length&&l<n.length;l++)if(!wr(n[l],a[l]))return!1;return!0}function Ud(n,a,l,d,y,v){return Ns=v,jt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,A.H=n===null||n.memoizedState===null?Wg:rf,Ba=!1,v=l(d,y),Ba=!1,pi&&(v=bg(a,l,d,y)),pg(n),v}function pg(n){A.H=kl;var a=en!==null&&en.next!==null;if(Ns=0,zn=en=jt=null,lc=!1,jl=0,bi=null,a)throw Error(i(300));n===null||Ln||(n=n.dependencies,n!==null&&Jo(n)&&(Ln=!0))}function bg(n,a,l,d){jt=n;var y=0;do{if(pi&&(bi=null),jl=0,pi=!1,25<=y)throw Error(i(301));if(y+=1,zn=en=null,n.updateQueue!=null){var v=n.updateQueue;v.lastEffect=null,v.events=null,v.stores=null,v.memoCache!=null&&(v.memoCache.index=0)}A.H=ep,v=a(l,d)}while(pi);return v}function i5(){var n=A.H,a=n.useState()[0];return a=typeof a.then=="function"?wl(a):a,n=n.useState()[0],(en!==null?en.memoizedState:null)!==n&&(jt.flags|=1024),a}function qd(){var n=oc!==0;return oc=0,n}function Vd(n,a,l){a.updateQueue=n.updateQueue,a.flags&=-2053,n.lanes&=~l}function Fd(n){if(lc){for(n=n.memoizedState;n!==null;){var a=n.queue;a!==null&&(a.pending=null),n=n.next}lc=!1}Ns=0,zn=en=jt=null,pi=!1,jl=oc=0,bi=null}function rr(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zn===null?jt.memoizedState=zn=n:zn=zn.next=n,zn}function An(){if(en===null){var n=jt.alternate;n=n!==null?n.memoizedState:null}else n=en.next;var a=zn===null?jt.memoizedState:zn.next;if(a!==null)zn=a,en=n;else{if(n===null)throw jt.alternate===null?Error(i(467)):Error(i(310));en=n,n={memoizedState:en.memoizedState,baseState:en.baseState,baseQueue:en.baseQueue,queue:en.queue,next:null},zn===null?jt.memoizedState=zn=n:zn=zn.next=n}return zn}function cc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wl(n){var a=jl;return jl+=1,bi===null&&(bi=[]),n=og(bi,n,a),a=jt,(zn===null?a.memoizedState:zn.next)===null&&(a=a.alternate,A.H=a===null||a.memoizedState===null?Wg:rf),n}function uc(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return wl(n);if(n.$$typeof===N)return Zn(n)}throw Error(i(438,String(n)))}function Yd(n){var a=null,l=jt.updateQueue;if(l!==null&&(a=l.memoCache),a==null){var d=jt.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(a={data:d.data.map(function(y){return y.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),l===null&&(l=cc(),jt.updateQueue=l),l.memoCache=a,l=a.data[a.index],l===void 0)for(l=a.data[a.index]=Array(n),d=0;d<n;d++)l[d]=P;return a.index++,l}function ks(n,a){return typeof a=="function"?a(n):a}function dc(n){var a=An();return Gd(a,en,n)}function Gd(n,a,l){var d=n.queue;if(d===null)throw Error(i(311));d.lastRenderedReducer=l;var y=n.baseQueue,v=d.pending;if(v!==null){if(y!==null){var O=y.next;y.next=v.next,v.next=O}a.baseQueue=y=v,d.pending=null}if(v=n.baseState,y===null)n.memoizedState=v;else{a=y.next;var J=O=null,se=null,me=a,Ce=!1;do{var Te=me.lane&-536870913;if(Te!==me.lane?($t&Te)===Te:(Ns&Te)===Te){var ge=me.revertLane;if(ge===0)se!==null&&(se=se.next={lane:0,revertLane:0,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),Te===fi&&(Ce=!0);else if((Ns&ge)===ge){me=me.next,ge===fi&&(Ce=!0);continue}else Te={lane:0,revertLane:me.revertLane,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},se===null?(J=se=Te,O=v):se=se.next=Te,jt.lanes|=ge,ta|=ge;Te=me.action,Ba&&l(v,Te),v=me.hasEagerState?me.eagerState:l(v,Te)}else ge={lane:Te,revertLane:me.revertLane,gesture:me.gesture,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},se===null?(J=se=ge,O=v):se=se.next=ge,jt.lanes|=Te,ta|=Te;me=me.next}while(me!==null&&me!==a);if(se===null?O=v:se.next=J,!wr(v,n.memoizedState)&&(Ln=!0,Ce&&(l=hi,l!==null)))throw l;n.memoizedState=v,n.baseState=O,n.baseQueue=se,d.lastRenderedState=v}return y===null&&(d.lanes=0),[n.memoizedState,d.dispatch]}function Xd(n){var a=An(),l=a.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=l.dispatch,y=l.pending,v=a.memoizedState;if(y!==null){l.pending=null;var O=y=y.next;do v=n(v,O.action),O=O.next;while(O!==y);wr(v,a.memoizedState)||(Ln=!0),a.memoizedState=v,a.baseQueue===null&&(a.baseState=v),l.lastRenderedState=v}return[v,d]}function yg(n,a,l){var d=jt,y=An(),v=Pt;if(v){if(l===void 0)throw Error(i(407));l=l()}else l=a();var O=!wr((en||y).memoizedState,l);if(O&&(y.memoizedState=l,Ln=!0),y=y.queue,Kd(wg.bind(null,d,y,n),[n]),y.getSnapshot!==a||O||zn!==null&&zn.memoizedState.tag&1){if(d.flags|=2048,yi(9,{destroy:void 0},jg.bind(null,d,y,l,a),null),an===null)throw Error(i(349));v||(Ns&127)!==0||vg(d,a,l)}return l}function vg(n,a,l){n.flags|=16384,n={getSnapshot:a,value:l},a=jt.updateQueue,a===null?(a=cc(),jt.updateQueue=a,a.stores=[n]):(l=a.stores,l===null?a.stores=[n]:l.push(n))}function jg(n,a,l,d){a.value=l,a.getSnapshot=d,Ng(a)&&kg(n)}function wg(n,a,l){return l(function(){Ng(a)&&kg(n)})}function Ng(n){var a=n.getSnapshot;n=n.value;try{var l=a();return!wr(n,l)}catch{return!0}}function kg(n){var a=Aa(n,2);a!==null&&xr(a,n,2)}function Zd(n){var a=rr();if(typeof n=="function"){var l=n;if(n=l(),Ba){xe(!0);try{l()}finally{xe(!1)}}}return a.memoizedState=a.baseState=n,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ks,lastRenderedState:n},a}function Sg(n,a,l,d){return n.baseState=l,Gd(n,en,typeof d=="function"?d:ks)}function l5(n,a,l,d,y){if(mc(n))throw Error(i(485));if(n=a.action,n!==null){var v={payload:y,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(O){v.listeners.push(O)}};A.T!==null?l(!0):v.isTransition=!1,d(v),l=a.pending,l===null?(v.next=a.pending=v,Cg(a,v)):(v.next=l.next,a.pending=l.next=v)}}function Cg(n,a){var l=a.action,d=a.payload,y=n.state;if(a.isTransition){var v=A.T,O={};A.T=O;try{var J=l(y,d),se=A.S;se!==null&&se(O,J),Eg(n,a,J)}catch(me){Qd(n,a,me)}finally{v!==null&&O.types!==null&&(v.types=O.types),A.T=v}}else try{v=l(y,d),Eg(n,a,v)}catch(me){Qd(n,a,me)}}function Eg(n,a,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(d){Tg(n,a,d)},function(d){return Qd(n,a,d)}):Tg(n,a,l)}function Tg(n,a,l){a.status="fulfilled",a.value=l,_g(a),n.state=l,a=n.pending,a!==null&&(l=a.next,l===a?n.pending=null:(l=l.next,a.next=l,Cg(n,l)))}function Qd(n,a,l){var d=n.pending;if(n.pending=null,d!==null){d=d.next;do a.status="rejected",a.reason=l,_g(a),a=a.next;while(a!==d)}n.action=null}function _g(n){n=n.listeners;for(var a=0;a<n.length;a++)(0,n[a])()}function Ag(n,a){return a}function Mg(n,a){if(Pt){var l=an.formState;if(l!==null){e:{var d=jt;if(Pt){if(mn){t:{for(var y=mn,v=Pr;y.nodeType!==8;){if(!v){y=null;break t}if(y=qr(y.nextSibling),y===null){y=null;break t}}v=y.data,y=v==="F!"||v==="F"?y:null}if(y){mn=qr(y.nextSibling),d=y.data==="F!";break e}}Ys(d)}d=!1}d&&(a=l[0])}}return l=rr(),l.memoizedState=l.baseState=a,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ag,lastRenderedState:a},l.queue=d,l=Qg.bind(null,jt,d),d.dispatch=l,d=Zd(!1),v=nf.bind(null,jt,!1,d.queue),d=rr(),y={state:a,dispatch:null,action:n,pending:null},d.queue=y,l=l5.bind(null,jt,y,v,l),y.dispatch=l,d.memoizedState=n,[a,l,!1]}function Dg(n){var a=An();return Og(a,en,n)}function Og(n,a,l){if(a=Gd(n,a,Ag)[0],n=dc(ks)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var d=wl(a)}catch(O){throw O===mi?tc:O}else d=a;a=An();var y=a.queue,v=y.dispatch;return l!==a.memoizedState&&(jt.flags|=2048,yi(9,{destroy:void 0},o5.bind(null,y,l),null)),[d,v,n]}function o5(n,a){n.action=a}function Rg(n){var a=An(),l=en;if(l!==null)return Og(a,l,n);An(),a=a.memoizedState,l=An();var d=l.queue.dispatch;return l.memoizedState=n,[a,d,!1]}function yi(n,a,l,d){return n={tag:n,create:l,deps:d,inst:a,next:null},a=jt.updateQueue,a===null&&(a=cc(),jt.updateQueue=a),l=a.lastEffect,l===null?a.lastEffect=n.next=n:(d=l.next,l.next=n,n.next=d,a.lastEffect=n),n}function zg(){return An().memoizedState}function fc(n,a,l,d){var y=rr();jt.flags|=n,y.memoizedState=yi(1|a,{destroy:void 0},l,d===void 0?null:d)}function hc(n,a,l,d){var y=An();d=d===void 0?null:d;var v=y.memoizedState.inst;en!==null&&d!==null&&Pd(d,en.memoizedState.deps)?y.memoizedState=yi(a,v,l,d):(jt.flags|=n,y.memoizedState=yi(1|a,v,l,d))}function Lg(n,a){fc(8390656,8,n,a)}function Kd(n,a){hc(2048,8,n,a)}function c5(n){jt.flags|=4;var a=jt.updateQueue;if(a===null)a=cc(),jt.updateQueue=a,a.events=[n];else{var l=a.events;l===null?a.events=[n]:l.push(n)}}function Ig(n){var a=An().memoizedState;return c5({ref:a,nextImpl:n}),function(){if((Qt&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}function $g(n,a){return hc(4,2,n,a)}function Bg(n,a){return hc(4,4,n,a)}function Hg(n,a){if(typeof a=="function"){n=n();var l=a(n);return function(){typeof l=="function"?l():a(null)}}if(a!=null)return n=n(),a.current=n,function(){a.current=null}}function Pg(n,a,l){l=l!=null?l.concat([n]):null,hc(4,4,Hg.bind(null,a,n),l)}function Jd(){}function Ug(n,a){var l=An();a=a===void 0?null:a;var d=l.memoizedState;return a!==null&&Pd(a,d[1])?d[0]:(l.memoizedState=[n,a],n)}function qg(n,a){var l=An();a=a===void 0?null:a;var d=l.memoizedState;if(a!==null&&Pd(a,d[1]))return d[0];if(d=n(),Ba){xe(!0);try{n()}finally{xe(!1)}}return l.memoizedState=[d,a],d}function Wd(n,a,l){return l===void 0||(Ns&1073741824)!==0&&($t&261930)===0?n.memoizedState=a:(n.memoizedState=l,n=Vp(),jt.lanes|=n,ta|=n,l)}function Vg(n,a,l,d){return wr(l,a)?l:gi.current!==null?(n=Wd(n,l,d),wr(n,a)||(Ln=!0),n):(Ns&42)===0||(Ns&1073741824)!==0&&($t&261930)===0?(Ln=!0,n.memoizedState=l):(n=Vp(),jt.lanes|=n,ta|=n,a)}function Fg(n,a,l,d,y){var v=G.p;G.p=v!==0&&8>v?v:8;var O=A.T,J={};A.T=J,nf(n,!1,a,l);try{var se=y(),me=A.S;if(me!==null&&me(J,se),se!==null&&typeof se=="object"&&typeof se.then=="function"){var Ce=s5(se,d);Nl(n,a,Ce,Tr(n))}else Nl(n,a,d,Tr(n))}catch(Te){Nl(n,a,{then:function(){},status:"rejected",reason:Te},Tr())}finally{G.p=v,O!==null&&J.types!==null&&(O.types=J.types),A.T=O}}function u5(){}function ef(n,a,l,d){if(n.tag!==5)throw Error(i(476));var y=Yg(n).queue;Fg(n,y,a,U,l===null?u5:function(){return Gg(n),l(d)})}function Yg(n){var a=n.memoizedState;if(a!==null)return a;a={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ks,lastRenderedState:U},next:null};var l={};return a.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ks,lastRenderedState:l},next:null},n.memoizedState=a,n=n.alternate,n!==null&&(n.memoizedState=a),a}function Gg(n){var a=Yg(n);a.next===null&&(a=n.alternate.memoizedState),Nl(n,a.next.queue,{},Tr())}function tf(){return Zn(Hl)}function Xg(){return An().memoizedState}function Zg(){return An().memoizedState}function d5(n){for(var a=n.return;a!==null;){switch(a.tag){case 24:case 3:var l=Tr();n=Zs(l);var d=Qs(a,n,l);d!==null&&(xr(d,a,l),bl(d,a,l)),a={cache:Ad()},n.payload=a;return}a=a.return}}function f5(n,a,l){var d=Tr();l={lane:d,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},mc(n)?Kg(a,l):(l=yd(n,a,l,d),l!==null&&(xr(l,n,d),Jg(l,a,d)))}function Qg(n,a,l){var d=Tr();Nl(n,a,l,d)}function Nl(n,a,l,d){var y={lane:d,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(mc(n))Kg(a,y);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=a.lastRenderedReducer,v!==null))try{var O=a.lastRenderedState,J=v(O,l);if(y.hasEagerState=!0,y.eagerState=J,wr(J,O))return Xo(n,a,y,0),an===null&&Go(),!1}catch{}if(l=yd(n,a,y,d),l!==null)return xr(l,n,d),Jg(l,a,d),!0}return!1}function nf(n,a,l,d){if(d={lane:2,revertLane:zf(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},mc(n)){if(a)throw Error(i(479))}else a=yd(n,l,d,2),a!==null&&xr(a,n,2)}function mc(n){var a=n.alternate;return n===jt||a!==null&&a===jt}function Kg(n,a){pi=lc=!0;var l=n.pending;l===null?a.next=a:(a.next=l.next,l.next=a),n.pending=a}function Jg(n,a,l){if((l&4194048)!==0){var d=a.lanes;d&=n.pendingLanes,l|=d,a.lanes=l,jn(n,l)}}var kl={readContext:Zn,use:uc,useCallback:Sn,useContext:Sn,useEffect:Sn,useImperativeHandle:Sn,useLayoutEffect:Sn,useInsertionEffect:Sn,useMemo:Sn,useReducer:Sn,useRef:Sn,useState:Sn,useDebugValue:Sn,useDeferredValue:Sn,useTransition:Sn,useSyncExternalStore:Sn,useId:Sn,useHostTransitionStatus:Sn,useFormState:Sn,useActionState:Sn,useOptimistic:Sn,useMemoCache:Sn,useCacheRefresh:Sn};kl.useEffectEvent=Sn;var Wg={readContext:Zn,use:uc,useCallback:function(n,a){return rr().memoizedState=[n,a===void 0?null:a],n},useContext:Zn,useEffect:Lg,useImperativeHandle:function(n,a,l){l=l!=null?l.concat([n]):null,fc(4194308,4,Hg.bind(null,a,n),l)},useLayoutEffect:function(n,a){return fc(4194308,4,n,a)},useInsertionEffect:function(n,a){fc(4,2,n,a)},useMemo:function(n,a){var l=rr();a=a===void 0?null:a;var d=n();if(Ba){xe(!0);try{n()}finally{xe(!1)}}return l.memoizedState=[d,a],d},useReducer:function(n,a,l){var d=rr();if(l!==void 0){var y=l(a);if(Ba){xe(!0);try{l(a)}finally{xe(!1)}}}else y=a;return d.memoizedState=d.baseState=y,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:y},d.queue=n,n=n.dispatch=f5.bind(null,jt,n),[d.memoizedState,n]},useRef:function(n){var a=rr();return n={current:n},a.memoizedState=n},useState:function(n){n=Zd(n);var a=n.queue,l=Qg.bind(null,jt,a);return a.dispatch=l,[n.memoizedState,l]},useDebugValue:Jd,useDeferredValue:function(n,a){var l=rr();return Wd(l,n,a)},useTransition:function(){var n=Zd(!1);return n=Fg.bind(null,jt,n.queue,!0,!1),rr().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,a,l){var d=jt,y=rr();if(Pt){if(l===void 0)throw Error(i(407));l=l()}else{if(l=a(),an===null)throw Error(i(349));($t&127)!==0||vg(d,a,l)}y.memoizedState=l;var v={value:l,getSnapshot:a};return y.queue=v,Lg(wg.bind(null,d,v,n),[n]),d.flags|=2048,yi(9,{destroy:void 0},jg.bind(null,d,v,l,a),null),l},useId:function(){var n=rr(),a=an.identifierPrefix;if(Pt){var l=as,d=ss;l=(d&~(1<<32-Be(d)-1)).toString(32)+l,a="_"+a+"R_"+l,l=oc++,0<l&&(a+="H"+l.toString(32)),a+="_"}else l=a5++,a="_"+a+"r_"+l.toString(32)+"_";return n.memoizedState=a},useHostTransitionStatus:tf,useFormState:Mg,useActionState:Mg,useOptimistic:function(n){var a=rr();a.memoizedState=a.baseState=n;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=l,a=nf.bind(null,jt,!0,l),l.dispatch=a,[n,a]},useMemoCache:Yd,useCacheRefresh:function(){return rr().memoizedState=d5.bind(null,jt)},useEffectEvent:function(n){var a=rr(),l={impl:n};return a.memoizedState=l,function(){if((Qt&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},rf={readContext:Zn,use:uc,useCallback:Ug,useContext:Zn,useEffect:Kd,useImperativeHandle:Pg,useInsertionEffect:$g,useLayoutEffect:Bg,useMemo:qg,useReducer:dc,useRef:zg,useState:function(){return dc(ks)},useDebugValue:Jd,useDeferredValue:function(n,a){var l=An();return Vg(l,en.memoizedState,n,a)},useTransition:function(){var n=dc(ks)[0],a=An().memoizedState;return[typeof n=="boolean"?n:wl(n),a]},useSyncExternalStore:yg,useId:Xg,useHostTransitionStatus:tf,useFormState:Dg,useActionState:Dg,useOptimistic:function(n,a){var l=An();return Sg(l,en,n,a)},useMemoCache:Yd,useCacheRefresh:Zg};rf.useEffectEvent=Ig;var ep={readContext:Zn,use:uc,useCallback:Ug,useContext:Zn,useEffect:Kd,useImperativeHandle:Pg,useInsertionEffect:$g,useLayoutEffect:Bg,useMemo:qg,useReducer:Xd,useRef:zg,useState:function(){return Xd(ks)},useDebugValue:Jd,useDeferredValue:function(n,a){var l=An();return en===null?Wd(l,n,a):Vg(l,en.memoizedState,n,a)},useTransition:function(){var n=Xd(ks)[0],a=An().memoizedState;return[typeof n=="boolean"?n:wl(n),a]},useSyncExternalStore:yg,useId:Xg,useHostTransitionStatus:tf,useFormState:Rg,useActionState:Rg,useOptimistic:function(n,a){var l=An();return en!==null?Sg(l,en,n,a):(l.baseState=n,[n,l.queue.dispatch])},useMemoCache:Yd,useCacheRefresh:Zg};ep.useEffectEvent=Ig;function sf(n,a,l,d){a=n.memoizedState,l=l(d,a),l=l==null?a:g({},a,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var af={enqueueSetState:function(n,a,l){n=n._reactInternals;var d=Tr(),y=Zs(d);y.payload=a,l!=null&&(y.callback=l),a=Qs(n,y,d),a!==null&&(xr(a,n,d),bl(a,n,d))},enqueueReplaceState:function(n,a,l){n=n._reactInternals;var d=Tr(),y=Zs(d);y.tag=1,y.payload=a,l!=null&&(y.callback=l),a=Qs(n,y,d),a!==null&&(xr(a,n,d),bl(a,n,d))},enqueueForceUpdate:function(n,a){n=n._reactInternals;var l=Tr(),d=Zs(l);d.tag=2,a!=null&&(d.callback=a),a=Qs(n,d,l),a!==null&&(xr(a,n,l),bl(a,n,l))}};function tp(n,a,l,d,y,v,O){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(d,v,O):a.prototype&&a.prototype.isPureReactComponent?!ul(l,d)||!ul(y,v):!0}function np(n,a,l,d){n=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(l,d),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(l,d),a.state!==n&&af.enqueueReplaceState(a,a.state,null)}function Ha(n,a){var l=a;if("ref"in a){l={};for(var d in a)d!=="ref"&&(l[d]=a[d])}if(n=n.defaultProps){l===a&&(l=g({},l));for(var y in n)l[y]===void 0&&(l[y]=n[y])}return l}function rp(n){Yo(n)}function sp(n){console.error(n)}function ap(n){Yo(n)}function xc(n,a){try{var l=n.onUncaughtError;l(a.value,{componentStack:a.stack})}catch(d){setTimeout(function(){throw d})}}function ip(n,a,l){try{var d=n.onCaughtError;d(l.value,{componentStack:l.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function lf(n,a,l){return l=Zs(l),l.tag=3,l.payload={element:null},l.callback=function(){xc(n,a)},l}function lp(n){return n=Zs(n),n.tag=3,n}function op(n,a,l,d){var y=l.type.getDerivedStateFromError;if(typeof y=="function"){var v=d.value;n.payload=function(){return y(v)},n.callback=function(){ip(a,l,d)}}var O=l.stateNode;O!==null&&typeof O.componentDidCatch=="function"&&(n.callback=function(){ip(a,l,d),typeof y!="function"&&(na===null?na=new Set([this]):na.add(this));var J=d.stack;this.componentDidCatch(d.value,{componentStack:J!==null?J:""})})}function h5(n,a,l,d,y){if(l.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(a=l.alternate,a!==null&&di(a,l,y,!0),l=kr.current,l!==null){switch(l.tag){case 31:case 13:return Ur===null?Ec():l.alternate===null&&Cn===0&&(Cn=3),l.flags&=-257,l.flags|=65536,l.lanes=y,d===nc?l.flags|=16384:(a=l.updateQueue,a===null?l.updateQueue=new Set([d]):a.add(d),Df(n,d,y)),!1;case 22:return l.flags|=65536,d===nc?l.flags|=16384:(a=l.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([d])},l.updateQueue=a):(l=a.retryQueue,l===null?a.retryQueue=new Set([d]):l.add(d)),Df(n,d,y)),!1}throw Error(i(435,l.tag))}return Df(n,d,y),Ec(),!1}if(Pt)return a=kr.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=y,d!==Sd&&(n=Error(i(422),{cause:d}),hl($r(n,l)))):(d!==Sd&&(a=Error(i(423),{cause:d}),hl($r(a,l))),n=n.current.alternate,n.flags|=65536,y&=-y,n.lanes|=y,d=$r(d,l),y=lf(n.stateNode,d,y),Ld(n,y),Cn!==4&&(Cn=2)),!1;var v=Error(i(520),{cause:d});if(v=$r(v,l),Dl===null?Dl=[v]:Dl.push(v),Cn!==4&&(Cn=2),a===null)return!0;d=$r(d,l),l=a;do{switch(l.tag){case 3:return l.flags|=65536,n=y&-y,l.lanes|=n,n=lf(l.stateNode,d,n),Ld(l,n),!1;case 1:if(a=l.type,v=l.stateNode,(l.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(na===null||!na.has(v))))return l.flags|=65536,y&=-y,l.lanes|=y,y=lp(y),op(y,n,l,d),Ld(l,y),!1}l=l.return}while(l!==null);return!1}var of=Error(i(461)),Ln=!1;function Qn(n,a,l,d){a.child=n===null?fg(a,null,l,d):$a(a,n.child,l,d)}function cp(n,a,l,d,y){l=l.render;var v=a.ref;if("ref"in d){var O={};for(var J in d)J!=="ref"&&(O[J]=d[J])}else O=d;return Ra(a),d=Ud(n,a,l,O,v,y),J=qd(),n!==null&&!Ln?(Vd(n,a,y),Ss(n,a,y)):(Pt&&J&&Nd(a),a.flags|=1,Qn(n,a,d,y),a.child)}function up(n,a,l,d,y){if(n===null){var v=l.type;return typeof v=="function"&&!vd(v)&&v.defaultProps===void 0&&l.compare===null?(a.tag=15,a.type=v,dp(n,a,v,d,y)):(n=Qo(l.type,null,d,a,a.mode,y),n.ref=a.ref,n.return=a,a.child=n)}if(v=n.child,!gf(n,y)){var O=v.memoizedProps;if(l=l.compare,l=l!==null?l:ul,l(O,d)&&n.ref===a.ref)return Ss(n,a,y)}return a.flags|=1,n=ys(v,d),n.ref=a.ref,n.return=a,a.child=n}function dp(n,a,l,d,y){if(n!==null){var v=n.memoizedProps;if(ul(v,d)&&n.ref===a.ref)if(Ln=!1,a.pendingProps=d=v,gf(n,y))(n.flags&131072)!==0&&(Ln=!0);else return a.lanes=n.lanes,Ss(n,a,y)}return cf(n,a,l,d,y)}function fp(n,a,l,d){var y=d.children,v=n!==null?n.memoizedState:null;if(n===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((a.flags&128)!==0){if(v=v!==null?v.baseLanes|l:l,n!==null){for(d=a.child=n.child,y=0;d!==null;)y=y|d.lanes|d.childLanes,d=d.sibling;d=y&~v}else d=0,a.child=null;return hp(n,a,v,l,d)}if((l&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},n!==null&&ec(a,v!==null?v.cachePool:null),v!==null?xg(a,v):$d(),gg(a);else return d=a.lanes=536870912,hp(n,a,v!==null?v.baseLanes|l:l,l,d)}else v!==null?(ec(a,v.cachePool),xg(a,v),Js(),a.memoizedState=null):(n!==null&&ec(a,null),$d(),Js());return Qn(n,a,y,l),a.child}function Sl(n,a){return n!==null&&n.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function hp(n,a,l,d,y){var v=Dd();return v=v===null?null:{parent:Rn._currentValue,pool:v},a.memoizedState={baseLanes:l,cachePool:v},n!==null&&ec(a,null),$d(),gg(a),n!==null&&di(n,a,d,!0),a.childLanes=y,null}function gc(n,a){return a=bc({mode:a.mode,children:a.children},n.mode),a.ref=n.ref,n.child=a,a.return=n,a}function mp(n,a,l){return $a(a,n.child,null,l),n=gc(a,a.pendingProps),n.flags|=2,Sr(a),a.memoizedState=null,n}function m5(n,a,l){var d=a.pendingProps,y=(a.flags&128)!==0;if(a.flags&=-129,n===null){if(Pt){if(d.mode==="hidden")return n=gc(a,d),a.lanes=536870912,Sl(null,n);if(Hd(a),(n=mn)?(n=C0(n,Pr),n=n!==null&&n.data==="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:Vs!==null?{id:ss,overflow:as}:null,retryLane:536870912,hydrationErrors:null},l=Kx(n),l.return=a,a.child=l,Xn=a,mn=null)):n=null,n===null)throw Ys(a);return a.lanes=536870912,null}return gc(a,d)}var v=n.memoizedState;if(v!==null){var O=v.dehydrated;if(Hd(a),y)if(a.flags&256)a.flags&=-257,a=mp(n,a,l);else if(a.memoizedState!==null)a.child=n.child,a.flags|=128,a=null;else throw Error(i(558));else if(Ln||di(n,a,l,!1),y=(l&n.childLanes)!==0,Ln||y){if(d=an,d!==null&&(O=gn(d,l),O!==0&&O!==v.retryLane))throw v.retryLane=O,Aa(n,O),xr(d,n,O),of;Ec(),a=mp(n,a,l)}else n=v.treeContext,mn=qr(O.nextSibling),Xn=a,Pt=!0,Fs=null,Pr=!1,n!==null&&eg(a,n),a=gc(a,d),a.flags|=4096;return a}return n=ys(n.child,{mode:d.mode,children:d.children}),n.ref=a.ref,a.child=n,n.return=a,n}function pc(n,a){var l=a.ref;if(l===null)n!==null&&n.ref!==null&&(a.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(i(284));(n===null||n.ref!==l)&&(a.flags|=4194816)}}function cf(n,a,l,d,y){return Ra(a),l=Ud(n,a,l,d,void 0,y),d=qd(),n!==null&&!Ln?(Vd(n,a,y),Ss(n,a,y)):(Pt&&d&&Nd(a),a.flags|=1,Qn(n,a,l,y),a.child)}function xp(n,a,l,d,y,v){return Ra(a),a.updateQueue=null,l=bg(a,d,l,y),pg(n),d=qd(),n!==null&&!Ln?(Vd(n,a,v),Ss(n,a,v)):(Pt&&d&&Nd(a),a.flags|=1,Qn(n,a,l,v),a.child)}function gp(n,a,l,d,y){if(Ra(a),a.stateNode===null){var v=li,O=l.contextType;typeof O=="object"&&O!==null&&(v=Zn(O)),v=new l(d,v),a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=af,a.stateNode=v,v._reactInternals=a,v=a.stateNode,v.props=d,v.state=a.memoizedState,v.refs={},Rd(a),O=l.contextType,v.context=typeof O=="object"&&O!==null?Zn(O):li,v.state=a.memoizedState,O=l.getDerivedStateFromProps,typeof O=="function"&&(sf(a,l,O,d),v.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(O=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),O!==v.state&&af.enqueueReplaceState(v,v.state,null),vl(a,d,v,y),yl(),v.state=a.memoizedState),typeof v.componentDidMount=="function"&&(a.flags|=4194308),d=!0}else if(n===null){v=a.stateNode;var J=a.memoizedProps,se=Ha(l,J);v.props=se;var me=v.context,Ce=l.contextType;O=li,typeof Ce=="object"&&Ce!==null&&(O=Zn(Ce));var Te=l.getDerivedStateFromProps;Ce=typeof Te=="function"||typeof v.getSnapshotBeforeUpdate=="function",J=a.pendingProps!==J,Ce||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(J||me!==O)&&np(a,v,d,O),Xs=!1;var ge=a.memoizedState;v.state=ge,vl(a,d,v,y),yl(),me=a.memoizedState,J||ge!==me||Xs?(typeof Te=="function"&&(sf(a,l,Te,d),me=a.memoizedState),(se=Xs||tp(a,l,se,d,ge,me,O))?(Ce||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount()),typeof v.componentDidMount=="function"&&(a.flags|=4194308)):(typeof v.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=d,a.memoizedState=me),v.props=d,v.state=me,v.context=O,d=se):(typeof v.componentDidMount=="function"&&(a.flags|=4194308),d=!1)}else{v=a.stateNode,zd(n,a),O=a.memoizedProps,Ce=Ha(l,O),v.props=Ce,Te=a.pendingProps,ge=v.context,me=l.contextType,se=li,typeof me=="object"&&me!==null&&(se=Zn(me)),J=l.getDerivedStateFromProps,(me=typeof J=="function"||typeof v.getSnapshotBeforeUpdate=="function")||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(O!==Te||ge!==se)&&np(a,v,d,se),Xs=!1,ge=a.memoizedState,v.state=ge,vl(a,d,v,y),yl();var we=a.memoizedState;O!==Te||ge!==we||Xs||n!==null&&n.dependencies!==null&&Jo(n.dependencies)?(typeof J=="function"&&(sf(a,l,J,d),we=a.memoizedState),(Ce=Xs||tp(a,l,Ce,d,ge,we,se)||n!==null&&n.dependencies!==null&&Jo(n.dependencies))?(me||typeof v.UNSAFE_componentWillUpdate!="function"&&typeof v.componentWillUpdate!="function"||(typeof v.componentWillUpdate=="function"&&v.componentWillUpdate(d,we,se),typeof v.UNSAFE_componentWillUpdate=="function"&&v.UNSAFE_componentWillUpdate(d,we,se)),typeof v.componentDidUpdate=="function"&&(a.flags|=4),typeof v.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof v.componentDidUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(a.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(a.flags|=1024),a.memoizedProps=d,a.memoizedState=we),v.props=d,v.state=we,v.context=se,d=Ce):(typeof v.componentDidUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(a.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(a.flags|=1024),d=!1)}return v=d,pc(n,a),d=(a.flags&128)!==0,v||d?(v=a.stateNode,l=d&&typeof l.getDerivedStateFromError!="function"?null:v.render(),a.flags|=1,n!==null&&d?(a.child=$a(a,n.child,null,y),a.child=$a(a,null,l,y)):Qn(n,a,l,y),a.memoizedState=v.state,n=a.child):n=Ss(n,a,y),n}function pp(n,a,l,d){return Da(),a.flags|=256,Qn(n,a,l,d),a.child}var uf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function df(n){return{baseLanes:n,cachePool:ig()}}function ff(n,a,l){return n=n!==null?n.childLanes&~l:0,a&&(n|=Er),n}function bp(n,a,l){var d=a.pendingProps,y=!1,v=(a.flags&128)!==0,O;if((O=v)||(O=n!==null&&n.memoizedState===null?!1:(_n.current&2)!==0),O&&(y=!0,a.flags&=-129),O=(a.flags&32)!==0,a.flags&=-33,n===null){if(Pt){if(y?Ks(a):Js(),(n=mn)?(n=C0(n,Pr),n=n!==null&&n.data!=="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:Vs!==null?{id:ss,overflow:as}:null,retryLane:536870912,hydrationErrors:null},l=Kx(n),l.return=a,a.child=l,Xn=a,mn=null)):n=null,n===null)throw Ys(a);return Xf(n)?a.lanes=32:a.lanes=536870912,null}var J=d.children;return d=d.fallback,y?(Js(),y=a.mode,J=bc({mode:"hidden",children:J},y),d=Ma(d,y,l,null),J.return=a,d.return=a,J.sibling=d,a.child=J,d=a.child,d.memoizedState=df(l),d.childLanes=ff(n,O,l),a.memoizedState=uf,Sl(null,d)):(Ks(a),hf(a,J))}var se=n.memoizedState;if(se!==null&&(J=se.dehydrated,J!==null)){if(v)a.flags&256?(Ks(a),a.flags&=-257,a=mf(n,a,l)):a.memoizedState!==null?(Js(),a.child=n.child,a.flags|=128,a=null):(Js(),J=d.fallback,y=a.mode,d=bc({mode:"visible",children:d.children},y),J=Ma(J,y,l,null),J.flags|=2,d.return=a,J.return=a,d.sibling=J,a.child=d,$a(a,n.child,null,l),d=a.child,d.memoizedState=df(l),d.childLanes=ff(n,O,l),a.memoizedState=uf,a=Sl(null,d));else if(Ks(a),Xf(J)){if(O=J.nextSibling&&J.nextSibling.dataset,O)var me=O.dgst;O=me,d=Error(i(419)),d.stack="",d.digest=O,hl({value:d,source:null,stack:null}),a=mf(n,a,l)}else if(Ln||di(n,a,l,!1),O=(l&n.childLanes)!==0,Ln||O){if(O=an,O!==null&&(d=gn(O,l),d!==0&&d!==se.retryLane))throw se.retryLane=d,Aa(n,d),xr(O,n,d),of;Gf(J)||Ec(),a=mf(n,a,l)}else Gf(J)?(a.flags|=192,a.child=n.child,a=null):(n=se.treeContext,mn=qr(J.nextSibling),Xn=a,Pt=!0,Fs=null,Pr=!1,n!==null&&eg(a,n),a=hf(a,d.children),a.flags|=4096);return a}return y?(Js(),J=d.fallback,y=a.mode,se=n.child,me=se.sibling,d=ys(se,{mode:"hidden",children:d.children}),d.subtreeFlags=se.subtreeFlags&65011712,me!==null?J=ys(me,J):(J=Ma(J,y,l,null),J.flags|=2),J.return=a,d.return=a,d.sibling=J,a.child=d,Sl(null,d),d=a.child,J=n.child.memoizedState,J===null?J=df(l):(y=J.cachePool,y!==null?(se=Rn._currentValue,y=y.parent!==se?{parent:se,pool:se}:y):y=ig(),J={baseLanes:J.baseLanes|l,cachePool:y}),d.memoizedState=J,d.childLanes=ff(n,O,l),a.memoizedState=uf,Sl(n.child,d)):(Ks(a),l=n.child,n=l.sibling,l=ys(l,{mode:"visible",children:d.children}),l.return=a,l.sibling=null,n!==null&&(O=a.deletions,O===null?(a.deletions=[n],a.flags|=16):O.push(n)),a.child=l,a.memoizedState=null,l)}function hf(n,a){return a=bc({mode:"visible",children:a},n.mode),a.return=n,n.child=a}function bc(n,a){return n=Nr(22,n,null,a),n.lanes=0,n}function mf(n,a,l){return $a(a,n.child,null,l),n=hf(a,a.pendingProps.children),n.flags|=2,a.memoizedState=null,n}function yp(n,a,l){n.lanes|=a;var d=n.alternate;d!==null&&(d.lanes|=a),Td(n.return,a,l)}function xf(n,a,l,d,y,v){var O=n.memoizedState;O===null?n.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:y,treeForkCount:v}:(O.isBackwards=a,O.rendering=null,O.renderingStartTime=0,O.last=d,O.tail=l,O.tailMode=y,O.treeForkCount=v)}function vp(n,a,l){var d=a.pendingProps,y=d.revealOrder,v=d.tail;d=d.children;var O=_n.current,J=(O&2)!==0;if(J?(O=O&1|2,a.flags|=128):O&=1,R(_n,O),Qn(n,a,d,l),d=Pt?fl:0,!J&&n!==null&&(n.flags&128)!==0)e:for(n=a.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&yp(n,l,a);else if(n.tag===19)yp(n,l,a);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===a)break e;for(;n.sibling===null;){if(n.return===null||n.return===a)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(y){case"forwards":for(l=a.child,y=null;l!==null;)n=l.alternate,n!==null&&ic(n)===null&&(y=l),l=l.sibling;l=y,l===null?(y=a.child,a.child=null):(y=l.sibling,l.sibling=null),xf(a,!1,y,l,v,d);break;case"backwards":case"unstable_legacy-backwards":for(l=null,y=a.child,a.child=null;y!==null;){if(n=y.alternate,n!==null&&ic(n)===null){a.child=y;break}n=y.sibling,y.sibling=l,l=y,y=n}xf(a,!0,l,null,v,d);break;case"together":xf(a,!1,null,null,void 0,d);break;default:a.memoizedState=null}return a.child}function Ss(n,a,l){if(n!==null&&(a.dependencies=n.dependencies),ta|=a.lanes,(l&a.childLanes)===0)if(n!==null){if(di(n,a,l,!1),(l&a.childLanes)===0)return null}else return null;if(n!==null&&a.child!==n.child)throw Error(i(153));if(a.child!==null){for(n=a.child,l=ys(n,n.pendingProps),a.child=l,l.return=a;n.sibling!==null;)n=n.sibling,l=l.sibling=ys(n,n.pendingProps),l.return=a;l.sibling=null}return a.child}function gf(n,a){return(n.lanes&a)!==0?!0:(n=n.dependencies,!!(n!==null&&Jo(n)))}function x5(n,a,l){switch(a.tag){case 3:Z(a,a.stateNode.containerInfo),Gs(a,Rn,n.memoizedState.cache),Da();break;case 27:case 5:ie(a);break;case 4:Z(a,a.stateNode.containerInfo);break;case 10:Gs(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Hd(a),null;break;case 13:var d=a.memoizedState;if(d!==null)return d.dehydrated!==null?(Ks(a),a.flags|=128,null):(l&a.child.childLanes)!==0?bp(n,a,l):(Ks(a),n=Ss(n,a,l),n!==null?n.sibling:null);Ks(a);break;case 19:var y=(n.flags&128)!==0;if(d=(l&a.childLanes)!==0,d||(di(n,a,l,!1),d=(l&a.childLanes)!==0),y){if(d)return vp(n,a,l);a.flags|=128}if(y=a.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),R(_n,_n.current),d)break;return null;case 22:return a.lanes=0,fp(n,a,l,a.pendingProps);case 24:Gs(a,Rn,n.memoizedState.cache)}return Ss(n,a,l)}function jp(n,a,l){if(n!==null)if(n.memoizedProps!==a.pendingProps)Ln=!0;else{if(!gf(n,l)&&(a.flags&128)===0)return Ln=!1,x5(n,a,l);Ln=(n.flags&131072)!==0}else Ln=!1,Pt&&(a.flags&1048576)!==0&&Wx(a,fl,a.index);switch(a.lanes=0,a.tag){case 16:e:{var d=a.pendingProps;if(n=La(a.elementType),a.type=n,typeof n=="function")vd(n)?(d=Ha(n,d),a.tag=1,a=gp(null,a,n,d,l)):(a.tag=0,a=cf(null,a,n,d,l));else{if(n!=null){var y=n.$$typeof;if(y===k){a.tag=11,a=cp(null,a,n,d,l);break e}else if(y===Y){a.tag=14,a=up(null,a,n,d,l);break e}}throw a=_(n)||n,Error(i(306,a,""))}}return a;case 0:return cf(n,a,a.type,a.pendingProps,l);case 1:return d=a.type,y=Ha(d,a.pendingProps),gp(n,a,d,y,l);case 3:e:{if(Z(a,a.stateNode.containerInfo),n===null)throw Error(i(387));d=a.pendingProps;var v=a.memoizedState;y=v.element,zd(n,a),vl(a,d,null,l);var O=a.memoizedState;if(d=O.cache,Gs(a,Rn,d),d!==v.cache&&_d(a,[Rn],l,!0),yl(),d=O.element,v.isDehydrated)if(v={element:d,isDehydrated:!1,cache:O.cache},a.updateQueue.baseState=v,a.memoizedState=v,a.flags&256){a=pp(n,a,d,l);break e}else if(d!==y){y=$r(Error(i(424)),a),hl(y),a=pp(n,a,d,l);break e}else for(n=a.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,mn=qr(n.firstChild),Xn=a,Pt=!0,Fs=null,Pr=!0,l=fg(a,null,d,l),a.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Da(),d===y){a=Ss(n,a,l);break e}Qn(n,a,d,l)}a=a.child}return a;case 26:return pc(n,a),n===null?(l=D0(a.type,null,a.pendingProps,null))?a.memoizedState=l:Pt||(l=a.type,n=a.pendingProps,d=Rc(Q.current).createElement(l),d[cn]=a,d[wn]=n,Kn(d,l,n),un(d),a.stateNode=d):a.memoizedState=D0(a.type,n.memoizedProps,a.pendingProps,n.memoizedState),null;case 27:return ie(a),n===null&&Pt&&(d=a.stateNode=_0(a.type,a.pendingProps,Q.current),Xn=a,Pr=!0,y=mn,ia(a.type)?(Zf=y,mn=qr(d.firstChild)):mn=y),Qn(n,a,a.pendingProps.children,l),pc(n,a),n===null&&(a.flags|=4194304),a.child;case 5:return n===null&&Pt&&((y=d=mn)&&(d=F5(d,a.type,a.pendingProps,Pr),d!==null?(a.stateNode=d,Xn=a,mn=qr(d.firstChild),Pr=!1,y=!0):y=!1),y||Ys(a)),ie(a),y=a.type,v=a.pendingProps,O=n!==null?n.memoizedProps:null,d=v.children,Vf(y,v)?d=null:O!==null&&Vf(y,O)&&(a.flags|=32),a.memoizedState!==null&&(y=Ud(n,a,i5,null,null,l),Hl._currentValue=y),pc(n,a),Qn(n,a,d,l),a.child;case 6:return n===null&&Pt&&((n=l=mn)&&(l=Y5(l,a.pendingProps,Pr),l!==null?(a.stateNode=l,Xn=a,mn=null,n=!0):n=!1),n||Ys(a)),null;case 13:return bp(n,a,l);case 4:return Z(a,a.stateNode.containerInfo),d=a.pendingProps,n===null?a.child=$a(a,null,d,l):Qn(n,a,d,l),a.child;case 11:return cp(n,a,a.type,a.pendingProps,l);case 7:return Qn(n,a,a.pendingProps,l),a.child;case 8:return Qn(n,a,a.pendingProps.children,l),a.child;case 12:return Qn(n,a,a.pendingProps.children,l),a.child;case 10:return d=a.pendingProps,Gs(a,a.type,d.value),Qn(n,a,d.children,l),a.child;case 9:return y=a.type._context,d=a.pendingProps.children,Ra(a),y=Zn(y),d=d(y),a.flags|=1,Qn(n,a,d,l),a.child;case 14:return up(n,a,a.type,a.pendingProps,l);case 15:return dp(n,a,a.type,a.pendingProps,l);case 19:return vp(n,a,l);case 31:return m5(n,a,l);case 22:return fp(n,a,l,a.pendingProps);case 24:return Ra(a),d=Zn(Rn),n===null?(y=Dd(),y===null&&(y=an,v=Ad(),y.pooledCache=v,v.refCount++,v!==null&&(y.pooledCacheLanes|=l),y=v),a.memoizedState={parent:d,cache:y},Rd(a),Gs(a,Rn,y)):((n.lanes&l)!==0&&(zd(n,a),vl(a,null,null,l),yl()),y=n.memoizedState,v=a.memoizedState,y.parent!==d?(y={parent:d,cache:d},a.memoizedState=y,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=y),Gs(a,Rn,d)):(d=v.cache,Gs(a,Rn,d),d!==y.cache&&_d(a,[Rn],l,!0))),Qn(n,a,a.pendingProps.children,l),a.child;case 29:throw a.pendingProps}throw Error(i(156,a.tag))}function Cs(n){n.flags|=4}function pf(n,a,l,d,y){if((a=(n.mode&32)!==0)&&(a=!1),a){if(n.flags|=16777216,(y&335544128)===y)if(n.stateNode.complete)n.flags|=8192;else if(Xp())n.flags|=8192;else throw Ia=nc,Od}else n.flags&=-16777217}function wp(n,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!I0(a))if(Xp())n.flags|=8192;else throw Ia=nc,Od}function yc(n,a){a!==null&&(n.flags|=4),n.flags&16384&&(a=n.tag!==22?Le():536870912,n.lanes|=a,Ni|=a)}function Cl(n,a){if(!Pt)switch(n.tailMode){case"hidden":a=n.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?a||n.tail===null?n.tail=null:n.tail.sibling=null:d.sibling=null}}function xn(n){var a=n.alternate!==null&&n.alternate.child===n.child,l=0,d=0;if(a)for(var y=n.child;y!==null;)l|=y.lanes|y.childLanes,d|=y.subtreeFlags&65011712,d|=y.flags&65011712,y.return=n,y=y.sibling;else for(y=n.child;y!==null;)l|=y.lanes|y.childLanes,d|=y.subtreeFlags,d|=y.flags,y.return=n,y=y.sibling;return n.subtreeFlags|=d,n.childLanes=l,a}function g5(n,a,l){var d=a.pendingProps;switch(kd(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xn(a),null;case 1:return xn(a),null;case 3:return l=a.stateNode,d=null,n!==null&&(d=n.memoizedState.cache),a.memoizedState.cache!==d&&(a.flags|=2048),ws(Rn),ee(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(n===null||n.child===null)&&(ui(a)?Cs(a):n===null||n.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Cd())),xn(a),null;case 26:var y=a.type,v=a.memoizedState;return n===null?(Cs(a),v!==null?(xn(a),wp(a,v)):(xn(a),pf(a,y,null,d,l))):v?v!==n.memoizedState?(Cs(a),xn(a),wp(a,v)):(xn(a),a.flags&=-16777217):(n=n.memoizedProps,n!==d&&Cs(a),xn(a),pf(a,y,n,d,l)),null;case 27:if(je(a),l=Q.current,y=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==d&&Cs(a);else{if(!d){if(a.stateNode===null)throw Error(i(166));return xn(a),null}n=z.current,ui(a)?tg(a):(n=_0(y,d,l),a.stateNode=n,Cs(a))}return xn(a),null;case 5:if(je(a),y=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==d&&Cs(a);else{if(!d){if(a.stateNode===null)throw Error(i(166));return xn(a),null}if(v=z.current,ui(a))tg(a);else{var O=Rc(Q.current);switch(v){case 1:v=O.createElementNS("http://www.w3.org/2000/svg",y);break;case 2:v=O.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;default:switch(y){case"svg":v=O.createElementNS("http://www.w3.org/2000/svg",y);break;case"math":v=O.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;case"script":v=O.createElement("div"),v.innerHTML="<script><\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof d.is=="string"?O.createElement("select",{is:d.is}):O.createElement("select"),d.multiple?v.multiple=!0:d.size&&(v.size=d.size);break;default:v=typeof d.is=="string"?O.createElement(y,{is:d.is}):O.createElement(y)}}v[cn]=a,v[wn]=d;e:for(O=a.child;O!==null;){if(O.tag===5||O.tag===6)v.appendChild(O.stateNode);else if(O.tag!==4&&O.tag!==27&&O.child!==null){O.child.return=O,O=O.child;continue}if(O===a)break e;for(;O.sibling===null;){if(O.return===null||O.return===a)break e;O=O.return}O.sibling.return=O.return,O=O.sibling}a.stateNode=v;e:switch(Kn(v,y,d),y){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Cs(a)}}return xn(a),pf(a,a.type,n===null?null:n.memoizedProps,a.pendingProps,l),null;case 6:if(n&&a.stateNode!=null)n.memoizedProps!==d&&Cs(a);else{if(typeof d!="string"&&a.stateNode===null)throw Error(i(166));if(n=Q.current,ui(a)){if(n=a.stateNode,l=a.memoizedProps,d=null,y=Xn,y!==null)switch(y.tag){case 27:case 5:d=y.memoizedProps}n[cn]=a,n=!!(n.nodeValue===l||d!==null&&d.suppressHydrationWarning===!0||b0(n.nodeValue,l)),n||Ys(a,!0)}else n=Rc(n).createTextNode(d),n[cn]=a,a.stateNode=n}return xn(a),null;case 31:if(l=a.memoizedState,n===null||n.memoizedState!==null){if(d=ui(a),l!==null){if(n===null){if(!d)throw Error(i(318));if(n=a.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(557));n[cn]=a}else Da(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;xn(a),n=!1}else l=Cd(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=l),n=!0;if(!n)return a.flags&256?(Sr(a),a):(Sr(a),null);if((a.flags&128)!==0)throw Error(i(558))}return xn(a),null;case 13:if(d=a.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(y=ui(a),d!==null&&d.dehydrated!==null){if(n===null){if(!y)throw Error(i(318));if(y=a.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(i(317));y[cn]=a}else Da(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;xn(a),y=!1}else y=Cd(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=y),y=!0;if(!y)return a.flags&256?(Sr(a),a):(Sr(a),null)}return Sr(a),(a.flags&128)!==0?(a.lanes=l,a):(l=d!==null,n=n!==null&&n.memoizedState!==null,l&&(d=a.child,y=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(y=d.alternate.memoizedState.cachePool.pool),v=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(v=d.memoizedState.cachePool.pool),v!==y&&(d.flags|=2048)),l!==n&&l&&(a.child.flags|=8192),yc(a,a.updateQueue),xn(a),null);case 4:return ee(),n===null&&Bf(a.stateNode.containerInfo),xn(a),null;case 10:return ws(a.type),xn(a),null;case 19:if(W(_n),d=a.memoizedState,d===null)return xn(a),null;if(y=(a.flags&128)!==0,v=d.rendering,v===null)if(y)Cl(d,!1);else{if(Cn!==0||n!==null&&(n.flags&128)!==0)for(n=a.child;n!==null;){if(v=ic(n),v!==null){for(a.flags|=128,Cl(d,!1),n=v.updateQueue,a.updateQueue=n,yc(a,n),a.subtreeFlags=0,n=l,l=a.child;l!==null;)Qx(l,n),l=l.sibling;return R(_n,_n.current&1|2),Pt&&vs(a,d.treeForkCount),a.child}n=n.sibling}d.tail!==null&&Ct()>kc&&(a.flags|=128,y=!0,Cl(d,!1),a.lanes=4194304)}else{if(!y)if(n=ic(v),n!==null){if(a.flags|=128,y=!0,n=n.updateQueue,a.updateQueue=n,yc(a,n),Cl(d,!0),d.tail===null&&d.tailMode==="hidden"&&!v.alternate&&!Pt)return xn(a),null}else 2*Ct()-d.renderingStartTime>kc&&l!==536870912&&(a.flags|=128,y=!0,Cl(d,!1),a.lanes=4194304);d.isBackwards?(v.sibling=a.child,a.child=v):(n=d.last,n!==null?n.sibling=v:a.child=v,d.last=v)}return d.tail!==null?(n=d.tail,d.rendering=n,d.tail=n.sibling,d.renderingStartTime=Ct(),n.sibling=null,l=_n.current,R(_n,y?l&1|2:l&1),Pt&&vs(a,d.treeForkCount),n):(xn(a),null);case 22:case 23:return Sr(a),Bd(),d=a.memoizedState!==null,n!==null?n.memoizedState!==null!==d&&(a.flags|=8192):d&&(a.flags|=8192),d?(l&536870912)!==0&&(a.flags&128)===0&&(xn(a),a.subtreeFlags&6&&(a.flags|=8192)):xn(a),l=a.updateQueue,l!==null&&yc(a,l.retryQueue),l=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),d=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),d!==l&&(a.flags|=2048),n!==null&&W(za),null;case 24:return l=null,n!==null&&(l=n.memoizedState.cache),a.memoizedState.cache!==l&&(a.flags|=2048),ws(Rn),xn(a),null;case 25:return null;case 30:return null}throw Error(i(156,a.tag))}function p5(n,a){switch(kd(a),a.tag){case 1:return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 3:return ws(Rn),ee(),n=a.flags,(n&65536)!==0&&(n&128)===0?(a.flags=n&-65537|128,a):null;case 26:case 27:case 5:return je(a),null;case 31:if(a.memoizedState!==null){if(Sr(a),a.alternate===null)throw Error(i(340));Da()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 13:if(Sr(a),n=a.memoizedState,n!==null&&n.dehydrated!==null){if(a.alternate===null)throw Error(i(340));Da()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 19:return W(_n),null;case 4:return ee(),null;case 10:return ws(a.type),null;case 22:case 23:return Sr(a),Bd(),n!==null&&W(za),n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 24:return ws(Rn),null;case 25:return null;default:return null}}function Np(n,a){switch(kd(a),a.tag){case 3:ws(Rn),ee();break;case 26:case 27:case 5:je(a);break;case 4:ee();break;case 31:a.memoizedState!==null&&Sr(a);break;case 13:Sr(a);break;case 19:W(_n);break;case 10:ws(a.type);break;case 22:case 23:Sr(a),Bd(),n!==null&&W(za);break;case 24:ws(Rn)}}function El(n,a){try{var l=a.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var y=d.next;l=y;do{if((l.tag&n)===n){d=void 0;var v=l.create,O=l.inst;d=v(),O.destroy=d}l=l.next}while(l!==y)}}catch(J){Jt(a,a.return,J)}}function Ws(n,a,l){try{var d=a.updateQueue,y=d!==null?d.lastEffect:null;if(y!==null){var v=y.next;d=v;do{if((d.tag&n)===n){var O=d.inst,J=O.destroy;if(J!==void 0){O.destroy=void 0,y=a;var se=l,me=J;try{me()}catch(Ce){Jt(y,se,Ce)}}}d=d.next}while(d!==v)}}catch(Ce){Jt(a,a.return,Ce)}}function kp(n){var a=n.updateQueue;if(a!==null){var l=n.stateNode;try{mg(a,l)}catch(d){Jt(n,n.return,d)}}}function Sp(n,a,l){l.props=Ha(n.type,n.memoizedProps),l.state=n.memoizedState;try{l.componentWillUnmount()}catch(d){Jt(n,a,d)}}function Tl(n,a){try{var l=n.ref;if(l!==null){switch(n.tag){case 26:case 27:case 5:var d=n.stateNode;break;case 30:d=n.stateNode;break;default:d=n.stateNode}typeof l=="function"?n.refCleanup=l(d):l.current=d}}catch(y){Jt(n,a,y)}}function is(n,a){var l=n.ref,d=n.refCleanup;if(l!==null)if(typeof d=="function")try{d()}catch(y){Jt(n,a,y)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(y){Jt(n,a,y)}else l.current=null}function Cp(n){var a=n.type,l=n.memoizedProps,d=n.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":l.autoFocus&&d.focus();break e;case"img":l.src?d.src=l.src:l.srcSet&&(d.srcset=l.srcSet)}}catch(y){Jt(n,n.return,y)}}function bf(n,a,l){try{var d=n.stateNode;B5(d,n.type,l,a),d[wn]=a}catch(y){Jt(n,n.return,y)}}function Ep(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&ia(n.type)||n.tag===4}function yf(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Ep(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&ia(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function vf(n,a,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,a?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(n,a):(a=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,a.appendChild(n),l=l._reactRootContainer,l!=null||a.onclick!==null||(a.onclick=qe));else if(d!==4&&(d===27&&ia(n.type)&&(l=n.stateNode,a=null),n=n.child,n!==null))for(vf(n,a,l),n=n.sibling;n!==null;)vf(n,a,l),n=n.sibling}function vc(n,a,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,a?l.insertBefore(n,a):l.appendChild(n);else if(d!==4&&(d===27&&ia(n.type)&&(l=n.stateNode),n=n.child,n!==null))for(vc(n,a,l),n=n.sibling;n!==null;)vc(n,a,l),n=n.sibling}function Tp(n){var a=n.stateNode,l=n.memoizedProps;try{for(var d=n.type,y=a.attributes;y.length;)a.removeAttributeNode(y[0]);Kn(a,d,l),a[cn]=n,a[wn]=l}catch(v){Jt(n,n.return,v)}}var Es=!1,In=!1,jf=!1,_p=typeof WeakSet=="function"?WeakSet:Set,Gn=null;function b5(n,a){if(n=n.containerInfo,Uf=Pc,n=Px(n),hd(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var y=d.anchorOffset,v=d.focusNode;d=d.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break e}var O=0,J=-1,se=-1,me=0,Ce=0,Te=n,ge=null;t:for(;;){for(var we;Te!==l||y!==0&&Te.nodeType!==3||(J=O+y),Te!==v||d!==0&&Te.nodeType!==3||(se=O+d),Te.nodeType===3&&(O+=Te.nodeValue.length),(we=Te.firstChild)!==null;)ge=Te,Te=we;for(;;){if(Te===n)break t;if(ge===l&&++me===y&&(J=O),ge===v&&++Ce===d&&(se=O),(we=Te.nextSibling)!==null)break;Te=ge,ge=Te.parentNode}Te=we}l=J===-1||se===-1?null:{start:J,end:se}}else l=null}l=l||{start:0,end:0}}else l=null;for(qf={focusedElem:n,selectionRange:l},Pc=!1,Gn=a;Gn!==null;)if(a=Gn,n=a.child,(a.subtreeFlags&1028)!==0&&n!==null)n.return=a,Gn=n;else for(;Gn!==null;){switch(a=Gn,v=a.alternate,n=a.flags,a.tag){case 0:if((n&4)!==0&&(n=a.updateQueue,n=n!==null?n.events:null,n!==null))for(l=0;l<n.length;l++)y=n[l],y.ref.impl=y.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&v!==null){n=void 0,l=a,y=v.memoizedProps,v=v.memoizedState,d=l.stateNode;try{var Ye=Ha(l.type,y);n=d.getSnapshotBeforeUpdate(Ye,v),d.__reactInternalSnapshotBeforeUpdate=n}catch(mt){Jt(l,l.return,mt)}}break;case 3:if((n&1024)!==0){if(n=a.stateNode.containerInfo,l=n.nodeType,l===9)Yf(n);else if(l===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Yf(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(i(163))}if(n=a.sibling,n!==null){n.return=a.return,Gn=n;break}Gn=a.return}}function Ap(n,a,l){var d=l.flags;switch(l.tag){case 0:case 11:case 15:_s(n,l),d&4&&El(5,l);break;case 1:if(_s(n,l),d&4)if(n=l.stateNode,a===null)try{n.componentDidMount()}catch(O){Jt(l,l.return,O)}else{var y=Ha(l.type,a.memoizedProps);a=a.memoizedState;try{n.componentDidUpdate(y,a,n.__reactInternalSnapshotBeforeUpdate)}catch(O){Jt(l,l.return,O)}}d&64&&kp(l),d&512&&Tl(l,l.return);break;case 3:if(_s(n,l),d&64&&(n=l.updateQueue,n!==null)){if(a=null,l.child!==null)switch(l.child.tag){case 27:case 5:a=l.child.stateNode;break;case 1:a=l.child.stateNode}try{mg(n,a)}catch(O){Jt(l,l.return,O)}}break;case 27:a===null&&d&4&&Tp(l);case 26:case 5:_s(n,l),a===null&&d&4&&Cp(l),d&512&&Tl(l,l.return);break;case 12:_s(n,l);break;case 31:_s(n,l),d&4&&Op(n,l);break;case 13:_s(n,l),d&4&&Rp(n,l),d&64&&(n=l.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(l=E5.bind(null,l),G5(n,l))));break;case 22:if(d=l.memoizedState!==null||Es,!d){a=a!==null&&a.memoizedState!==null||In,y=Es;var v=In;Es=d,(In=a)&&!v?As(n,l,(l.subtreeFlags&8772)!==0):_s(n,l),Es=y,In=v}break;case 30:break;default:_s(n,l)}}function Mp(n){var a=n.alternate;a!==null&&(n.alternate=null,Mp(a)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(a=n.stateNode,a!==null&&ar(a)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var pn=null,dr=!1;function Ts(n,a,l){for(l=l.child;l!==null;)Dp(n,a,l),l=l.sibling}function Dp(n,a,l){if(wt&&typeof wt.onCommitFiberUnmount=="function")try{wt.onCommitFiberUnmount(_t,l)}catch{}switch(l.tag){case 26:In||is(l,a),Ts(n,a,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:In||is(l,a);var d=pn,y=dr;ia(l.type)&&(pn=l.stateNode,dr=!1),Ts(n,a,l),Il(l.stateNode),pn=d,dr=y;break;case 5:In||is(l,a);case 6:if(d=pn,y=dr,pn=null,Ts(n,a,l),pn=d,dr=y,pn!==null)if(dr)try{(pn.nodeType===9?pn.body:pn.nodeName==="HTML"?pn.ownerDocument.body:pn).removeChild(l.stateNode)}catch(v){Jt(l,a,v)}else try{pn.removeChild(l.stateNode)}catch(v){Jt(l,a,v)}break;case 18:pn!==null&&(dr?(n=pn,k0(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,l.stateNode),Mi(n)):k0(pn,l.stateNode));break;case 4:d=pn,y=dr,pn=l.stateNode.containerInfo,dr=!0,Ts(n,a,l),pn=d,dr=y;break;case 0:case 11:case 14:case 15:Ws(2,l,a),In||Ws(4,l,a),Ts(n,a,l);break;case 1:In||(is(l,a),d=l.stateNode,typeof d.componentWillUnmount=="function"&&Sp(l,a,d)),Ts(n,a,l);break;case 21:Ts(n,a,l);break;case 22:In=(d=In)||l.memoizedState!==null,Ts(n,a,l),In=d;break;default:Ts(n,a,l)}}function Op(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Mi(n)}catch(l){Jt(a,a.return,l)}}}function Rp(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Mi(n)}catch(l){Jt(a,a.return,l)}}function y5(n){switch(n.tag){case 31:case 13:case 19:var a=n.stateNode;return a===null&&(a=n.stateNode=new _p),a;case 22:return n=n.stateNode,a=n._retryCache,a===null&&(a=n._retryCache=new _p),a;default:throw Error(i(435,n.tag))}}function jc(n,a){var l=y5(n);a.forEach(function(d){if(!l.has(d)){l.add(d);var y=T5.bind(null,n,d);d.then(y,y)}})}function fr(n,a){var l=a.deletions;if(l!==null)for(var d=0;d<l.length;d++){var y=l[d],v=n,O=a,J=O;e:for(;J!==null;){switch(J.tag){case 27:if(ia(J.type)){pn=J.stateNode,dr=!1;break e}break;case 5:pn=J.stateNode,dr=!1;break e;case 3:case 4:pn=J.stateNode.containerInfo,dr=!0;break e}J=J.return}if(pn===null)throw Error(i(160));Dp(v,O,y),pn=null,dr=!1,v=y.alternate,v!==null&&(v.return=null),y.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)zp(a,n),a=a.sibling}var Zr=null;function zp(n,a){var l=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:fr(a,n),hr(n),d&4&&(Ws(3,n,n.return),El(3,n),Ws(5,n,n.return));break;case 1:fr(a,n),hr(n),d&512&&(In||l===null||is(l,l.return)),d&64&&Es&&(n=n.updateQueue,n!==null&&(d=n.callbacks,d!==null&&(l=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=l===null?d:l.concat(d))));break;case 26:var y=Zr;if(fr(a,n),hr(n),d&512&&(In||l===null||is(l,l.return)),d&4){var v=l!==null?l.memoizedState:null;if(d=n.memoizedState,l===null)if(d===null)if(n.stateNode===null){e:{d=n.type,l=n.memoizedProps,y=y.ownerDocument||y;t:switch(d){case"title":v=y.getElementsByTagName("title")[0],(!v||v[Nn]||v[cn]||v.namespaceURI==="http://www.w3.org/2000/svg"||v.hasAttribute("itemprop"))&&(v=y.createElement(d),y.head.insertBefore(v,y.querySelector("head > title"))),Kn(v,d,l),v[cn]=n,un(v),d=v;break e;case"link":var O=z0("link","href",y).get(d+(l.href||""));if(O){for(var J=0;J<O.length;J++)if(v=O[J],v.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&v.getAttribute("rel")===(l.rel==null?null:l.rel)&&v.getAttribute("title")===(l.title==null?null:l.title)&&v.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){O.splice(J,1);break t}}v=y.createElement(d),Kn(v,d,l),y.head.appendChild(v);break;case"meta":if(O=z0("meta","content",y).get(d+(l.content||""))){for(J=0;J<O.length;J++)if(v=O[J],v.getAttribute("content")===(l.content==null?null:""+l.content)&&v.getAttribute("name")===(l.name==null?null:l.name)&&v.getAttribute("property")===(l.property==null?null:l.property)&&v.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&v.getAttribute("charset")===(l.charSet==null?null:l.charSet)){O.splice(J,1);break t}}v=y.createElement(d),Kn(v,d,l),y.head.appendChild(v);break;default:throw Error(i(468,d))}v[cn]=n,un(v),d=v}n.stateNode=d}else L0(y,n.type,n.stateNode);else n.stateNode=R0(y,d,n.memoizedProps);else v!==d?(v===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):v.count--,d===null?L0(y,n.type,n.stateNode):R0(y,d,n.memoizedProps)):d===null&&n.stateNode!==null&&bf(n,n.memoizedProps,l.memoizedProps)}break;case 27:fr(a,n),hr(n),d&512&&(In||l===null||is(l,l.return)),l!==null&&d&4&&bf(n,n.memoizedProps,l.memoizedProps);break;case 5:if(fr(a,n),hr(n),d&512&&(In||l===null||is(l,l.return)),n.flags&32){y=n.stateNode;try{it(y,"")}catch(Ye){Jt(n,n.return,Ye)}}d&4&&n.stateNode!=null&&(y=n.memoizedProps,bf(n,y,l!==null?l.memoizedProps:y)),d&1024&&(jf=!0);break;case 6:if(fr(a,n),hr(n),d&4){if(n.stateNode===null)throw Error(i(162));d=n.memoizedProps,l=n.stateNode;try{l.nodeValue=d}catch(Ye){Jt(n,n.return,Ye)}}break;case 3:if(Ic=null,y=Zr,Zr=zc(a.containerInfo),fr(a,n),Zr=y,hr(n),d&4&&l!==null&&l.memoizedState.isDehydrated)try{Mi(a.containerInfo)}catch(Ye){Jt(n,n.return,Ye)}jf&&(jf=!1,Lp(n));break;case 4:d=Zr,Zr=zc(n.stateNode.containerInfo),fr(a,n),hr(n),Zr=d;break;case 12:fr(a,n),hr(n);break;case 31:fr(a,n),hr(n),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,jc(n,d)));break;case 13:fr(a,n),hr(n),n.child.flags&8192&&n.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Nc=Ct()),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,jc(n,d)));break;case 22:y=n.memoizedState!==null;var se=l!==null&&l.memoizedState!==null,me=Es,Ce=In;if(Es=me||y,In=Ce||se,fr(a,n),In=Ce,Es=me,hr(n),d&8192)e:for(a=n.stateNode,a._visibility=y?a._visibility&-2:a._visibility|1,y&&(l===null||se||Es||In||Pa(n)),l=null,a=n;;){if(a.tag===5||a.tag===26){if(l===null){se=l=a;try{if(v=se.stateNode,y)O=v.style,typeof O.setProperty=="function"?O.setProperty("display","none","important"):O.display="none";else{J=se.stateNode;var Te=se.memoizedProps.style,ge=Te!=null&&Te.hasOwnProperty("display")?Te.display:null;J.style.display=ge==null||typeof ge=="boolean"?"":(""+ge).trim()}}catch(Ye){Jt(se,se.return,Ye)}}}else if(a.tag===6){if(l===null){se=a;try{se.stateNode.nodeValue=y?"":se.memoizedProps}catch(Ye){Jt(se,se.return,Ye)}}}else if(a.tag===18){if(l===null){se=a;try{var we=se.stateNode;y?S0(we,!0):S0(se.stateNode,!1)}catch(Ye){Jt(se,se.return,Ye)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===n)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break e;for(;a.sibling===null;){if(a.return===null||a.return===n)break e;l===a&&(l=null),a=a.return}l===a&&(l=null),a.sibling.return=a.return,a=a.sibling}d&4&&(d=n.updateQueue,d!==null&&(l=d.retryQueue,l!==null&&(d.retryQueue=null,jc(n,l))));break;case 19:fr(a,n),hr(n),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,jc(n,d)));break;case 30:break;case 21:break;default:fr(a,n),hr(n)}}function hr(n){var a=n.flags;if(a&2){try{for(var l,d=n.return;d!==null;){if(Ep(d)){l=d;break}d=d.return}if(l==null)throw Error(i(160));switch(l.tag){case 27:var y=l.stateNode,v=yf(n);vc(n,v,y);break;case 5:var O=l.stateNode;l.flags&32&&(it(O,""),l.flags&=-33);var J=yf(n);vc(n,J,O);break;case 3:case 4:var se=l.stateNode.containerInfo,me=yf(n);vf(n,me,se);break;default:throw Error(i(161))}}catch(Ce){Jt(n,n.return,Ce)}n.flags&=-3}a&4096&&(n.flags&=-4097)}function Lp(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var a=n;Lp(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),n=n.sibling}}function _s(n,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)Ap(n,a.alternate,a),a=a.sibling}function Pa(n){for(n=n.child;n!==null;){var a=n;switch(a.tag){case 0:case 11:case 14:case 15:Ws(4,a,a.return),Pa(a);break;case 1:is(a,a.return);var l=a.stateNode;typeof l.componentWillUnmount=="function"&&Sp(a,a.return,l),Pa(a);break;case 27:Il(a.stateNode);case 26:case 5:is(a,a.return),Pa(a);break;case 22:a.memoizedState===null&&Pa(a);break;case 30:Pa(a);break;default:Pa(a)}n=n.sibling}}function As(n,a,l){for(l=l&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var d=a.alternate,y=n,v=a,O=v.flags;switch(v.tag){case 0:case 11:case 15:As(y,v,l),El(4,v);break;case 1:if(As(y,v,l),d=v,y=d.stateNode,typeof y.componentDidMount=="function")try{y.componentDidMount()}catch(me){Jt(d,d.return,me)}if(d=v,y=d.updateQueue,y!==null){var J=d.stateNode;try{var se=y.shared.hiddenCallbacks;if(se!==null)for(y.shared.hiddenCallbacks=null,y=0;y<se.length;y++)hg(se[y],J)}catch(me){Jt(d,d.return,me)}}l&&O&64&&kp(v),Tl(v,v.return);break;case 27:Tp(v);case 26:case 5:As(y,v,l),l&&d===null&&O&4&&Cp(v),Tl(v,v.return);break;case 12:As(y,v,l);break;case 31:As(y,v,l),l&&O&4&&Op(y,v);break;case 13:As(y,v,l),l&&O&4&&Rp(y,v);break;case 22:v.memoizedState===null&&As(y,v,l),Tl(v,v.return);break;case 30:break;default:As(y,v,l)}a=a.sibling}}function wf(n,a){var l=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),n=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(n=a.memoizedState.cachePool.pool),n!==l&&(n!=null&&n.refCount++,l!=null&&ml(l))}function Nf(n,a){n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&ml(n))}function Qr(n,a,l,d){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)Ip(n,a,l,d),a=a.sibling}function Ip(n,a,l,d){var y=a.flags;switch(a.tag){case 0:case 11:case 15:Qr(n,a,l,d),y&2048&&El(9,a);break;case 1:Qr(n,a,l,d);break;case 3:Qr(n,a,l,d),y&2048&&(n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&ml(n)));break;case 12:if(y&2048){Qr(n,a,l,d),n=a.stateNode;try{var v=a.memoizedProps,O=v.id,J=v.onPostCommit;typeof J=="function"&&J(O,a.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(se){Jt(a,a.return,se)}}else Qr(n,a,l,d);break;case 31:Qr(n,a,l,d);break;case 13:Qr(n,a,l,d);break;case 23:break;case 22:v=a.stateNode,O=a.alternate,a.memoizedState!==null?v._visibility&2?Qr(n,a,l,d):_l(n,a):v._visibility&2?Qr(n,a,l,d):(v._visibility|=2,vi(n,a,l,d,(a.subtreeFlags&10256)!==0||!1)),y&2048&&wf(O,a);break;case 24:Qr(n,a,l,d),y&2048&&Nf(a.alternate,a);break;default:Qr(n,a,l,d)}}function vi(n,a,l,d,y){for(y=y&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var v=n,O=a,J=l,se=d,me=O.flags;switch(O.tag){case 0:case 11:case 15:vi(v,O,J,se,y),El(8,O);break;case 23:break;case 22:var Ce=O.stateNode;O.memoizedState!==null?Ce._visibility&2?vi(v,O,J,se,y):_l(v,O):(Ce._visibility|=2,vi(v,O,J,se,y)),y&&me&2048&&wf(O.alternate,O);break;case 24:vi(v,O,J,se,y),y&&me&2048&&Nf(O.alternate,O);break;default:vi(v,O,J,se,y)}a=a.sibling}}function _l(n,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var l=n,d=a,y=d.flags;switch(d.tag){case 22:_l(l,d),y&2048&&wf(d.alternate,d);break;case 24:_l(l,d),y&2048&&Nf(d.alternate,d);break;default:_l(l,d)}a=a.sibling}}var Al=8192;function ji(n,a,l){if(n.subtreeFlags&Al)for(n=n.child;n!==null;)$p(n,a,l),n=n.sibling}function $p(n,a,l){switch(n.tag){case 26:ji(n,a,l),n.flags&Al&&n.memoizedState!==null&&a2(l,Zr,n.memoizedState,n.memoizedProps);break;case 5:ji(n,a,l);break;case 3:case 4:var d=Zr;Zr=zc(n.stateNode.containerInfo),ji(n,a,l),Zr=d;break;case 22:n.memoizedState===null&&(d=n.alternate,d!==null&&d.memoizedState!==null?(d=Al,Al=16777216,ji(n,a,l),Al=d):ji(n,a,l));break;default:ji(n,a,l)}}function Bp(n){var a=n.alternate;if(a!==null&&(n=a.child,n!==null)){a.child=null;do a=n.sibling,n.sibling=null,n=a;while(n!==null)}}function Ml(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var d=a[l];Gn=d,Pp(d,n)}Bp(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Hp(n),n=n.sibling}function Hp(n){switch(n.tag){case 0:case 11:case 15:Ml(n),n.flags&2048&&Ws(9,n,n.return);break;case 3:Ml(n);break;case 12:Ml(n);break;case 22:var a=n.stateNode;n.memoizedState!==null&&a._visibility&2&&(n.return===null||n.return.tag!==13)?(a._visibility&=-3,wc(n)):Ml(n);break;default:Ml(n)}}function wc(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var d=a[l];Gn=d,Pp(d,n)}Bp(n)}for(n=n.child;n!==null;){switch(a=n,a.tag){case 0:case 11:case 15:Ws(8,a,a.return),wc(a);break;case 22:l=a.stateNode,l._visibility&2&&(l._visibility&=-3,wc(a));break;default:wc(a)}n=n.sibling}}function Pp(n,a){for(;Gn!==null;){var l=Gn;switch(l.tag){case 0:case 11:case 15:Ws(8,l,a);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var d=l.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:ml(l.memoizedState.cache)}if(d=l.child,d!==null)d.return=l,Gn=d;else e:for(l=n;Gn!==null;){d=Gn;var y=d.sibling,v=d.return;if(Mp(d),d===l){Gn=null;break e}if(y!==null){y.return=v,Gn=y;break e}Gn=v}}}var v5={getCacheForType:function(n){var a=Zn(Rn),l=a.data.get(n);return l===void 0&&(l=n(),a.data.set(n,l)),l},cacheSignal:function(){return Zn(Rn).controller.signal}},j5=typeof WeakMap=="function"?WeakMap:Map,Qt=0,an=null,Ot=null,$t=0,Kt=0,Cr=null,ea=!1,wi=!1,kf=!1,Ms=0,Cn=0,ta=0,Ua=0,Sf=0,Er=0,Ni=0,Dl=null,mr=null,Cf=!1,Nc=0,Up=0,kc=1/0,Sc=null,na=null,Vn=0,ra=null,ki=null,Ds=0,Ef=0,Tf=null,qp=null,Ol=0,_f=null;function Tr(){return(Qt&2)!==0&&$t!==0?$t&-$t:A.T!==null?zf():Un()}function Vp(){if(Er===0)if(($t&536870912)===0||Pt){var n=Ke;Ke<<=1,(Ke&3932160)===0&&(Ke=262144),Er=n}else Er=536870912;return n=kr.current,n!==null&&(n.flags|=32),Er}function xr(n,a,l){(n===an&&(Kt===2||Kt===9)||n.cancelPendingCommit!==null)&&(Si(n,0),sa(n,$t,Er,!1)),st(n,l),((Qt&2)===0||n!==an)&&(n===an&&((Qt&2)===0&&(Ua|=l),Cn===4&&sa(n,$t,Er,!1)),ls(n))}function Fp(n,a,l){if((Qt&6)!==0)throw Error(i(327));var d=!l&&(a&127)===0&&(a&n.expiredLanes)===0||Mt(n,a),y=d?k5(n,a):Mf(n,a,!0),v=d;do{if(y===0){wi&&!d&&sa(n,a,0,!1);break}else{if(l=n.current.alternate,v&&!w5(l)){y=Mf(n,a,!1),v=!1;continue}if(y===2){if(v=a,n.errorRecoveryDisabledLanes&v)var O=0;else O=n.pendingLanes&-536870913,O=O!==0?O:O&536870912?536870912:0;if(O!==0){a=O;e:{var J=n;y=Dl;var se=J.current.memoizedState.isDehydrated;if(se&&(Si(J,O).flags|=256),O=Mf(J,O,!1),O!==2){if(kf&&!se){J.errorRecoveryDisabledLanes|=v,Ua|=v,y=4;break e}v=mr,mr=y,v!==null&&(mr===null?mr=v:mr.push.apply(mr,v))}y=O}if(v=!1,y!==2)continue}}if(y===1){Si(n,0),sa(n,a,0,!0);break}e:{switch(d=n,v=y,v){case 0:case 1:throw Error(i(345));case 4:if((a&4194048)!==a)break;case 6:sa(d,a,Er,!ea);break e;case 2:mr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((a&62914560)===a&&(y=Nc+300-Ct(),10<y)){if(sa(d,a,Er,!ea),vn(d,0,!0)!==0)break e;Ds=a,d.timeoutHandle=w0(Yp.bind(null,d,l,mr,Sc,Cf,a,Er,Ua,Ni,ea,v,"Throttled",-0,0),y);break e}Yp(d,l,mr,Sc,Cf,a,Er,Ua,Ni,ea,v,null,-0,0)}}break}while(!0);ls(n)}function Yp(n,a,l,d,y,v,O,J,se,me,Ce,Te,ge,we){if(n.timeoutHandle=-1,Te=a.subtreeFlags,Te&8192||(Te&16785408)===16785408){Te={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qe},$p(a,v,Te);var Ye=(v&62914560)===v?Nc-Ct():(v&4194048)===v?Up-Ct():0;if(Ye=i2(Te,Ye),Ye!==null){Ds=v,n.cancelPendingCommit=Ye(e0.bind(null,n,a,v,l,d,y,O,J,se,Ce,Te,null,ge,we)),sa(n,v,O,!me);return}}e0(n,a,v,l,d,y,O,J,se)}function w5(n){for(var a=n;;){var l=a.tag;if((l===0||l===11||l===15)&&a.flags&16384&&(l=a.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var d=0;d<l.length;d++){var y=l[d],v=y.getSnapshot;y=y.value;try{if(!wr(v(),y))return!1}catch{return!1}}if(l=a.child,a.subtreeFlags&16384&&l!==null)l.return=a,a=l;else{if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function sa(n,a,l,d){a&=~Sf,a&=~Ua,n.suspendedLanes|=a,n.pingedLanes&=~a,d&&(n.warmLanes|=a),d=n.expirationTimes;for(var y=a;0<y;){var v=31-Be(y),O=1<<v;d[v]=-1,y&=~O}l!==0&&Ue(n,l,a)}function Cc(){return(Qt&6)===0?(Rl(0),!1):!0}function Af(){if(Ot!==null){if(Kt===0)var n=Ot.return;else n=Ot,js=Oa=null,Fd(n),xi=null,gl=0,n=Ot;for(;n!==null;)Np(n.alternate,n),n=n.return;Ot=null}}function Si(n,a){var l=n.timeoutHandle;l!==-1&&(n.timeoutHandle=-1,U5(l)),l=n.cancelPendingCommit,l!==null&&(n.cancelPendingCommit=null,l()),Ds=0,Af(),an=n,Ot=l=ys(n.current,null),$t=a,Kt=0,Cr=null,ea=!1,wi=Mt(n,a),kf=!1,Ni=Er=Sf=Ua=ta=Cn=0,mr=Dl=null,Cf=!1,(a&8)!==0&&(a|=a&32);var d=n.entangledLanes;if(d!==0)for(n=n.entanglements,d&=a;0<d;){var y=31-Be(d),v=1<<y;a|=n[y],d&=~v}return Ms=a,Go(),l}function Gp(n,a){jt=null,A.H=kl,a===mi||a===tc?(a=cg(),Kt=3):a===Od?(a=cg(),Kt=4):Kt=a===of?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Cr=a,Ot===null&&(Cn=1,xc(n,$r(a,n.current)))}function Xp(){var n=kr.current;return n===null?!0:($t&4194048)===$t?Ur===null:($t&62914560)===$t||($t&536870912)!==0?n===Ur:!1}function Zp(){var n=A.H;return A.H=kl,n===null?kl:n}function Qp(){var n=A.A;return A.A=v5,n}function Ec(){Cn=4,ea||($t&4194048)!==$t&&kr.current!==null||(wi=!0),(ta&134217727)===0&&(Ua&134217727)===0||an===null||sa(an,$t,Er,!1)}function Mf(n,a,l){var d=Qt;Qt|=2;var y=Zp(),v=Qp();(an!==n||$t!==a)&&(Sc=null,Si(n,a)),a=!1;var O=Cn;e:do try{if(Kt!==0&&Ot!==null){var J=Ot,se=Cr;switch(Kt){case 8:Af(),O=6;break e;case 3:case 2:case 9:case 6:kr.current===null&&(a=!0);var me=Kt;if(Kt=0,Cr=null,Ci(n,J,se,me),l&&wi){O=0;break e}break;default:me=Kt,Kt=0,Cr=null,Ci(n,J,se,me)}}N5(),O=Cn;break}catch(Ce){Gp(n,Ce)}while(!0);return a&&n.shellSuspendCounter++,js=Oa=null,Qt=d,A.H=y,A.A=v,Ot===null&&(an=null,$t=0,Go()),O}function N5(){for(;Ot!==null;)Kp(Ot)}function k5(n,a){var l=Qt;Qt|=2;var d=Zp(),y=Qp();an!==n||$t!==a?(Sc=null,kc=Ct()+500,Si(n,a)):wi=Mt(n,a);e:do try{if(Kt!==0&&Ot!==null){a=Ot;var v=Cr;t:switch(Kt){case 1:Kt=0,Cr=null,Ci(n,a,v,1);break;case 2:case 9:if(lg(v)){Kt=0,Cr=null,Jp(a);break}a=function(){Kt!==2&&Kt!==9||an!==n||(Kt=7),ls(n)},v.then(a,a);break e;case 3:Kt=7;break e;case 4:Kt=5;break e;case 7:lg(v)?(Kt=0,Cr=null,Jp(a)):(Kt=0,Cr=null,Ci(n,a,v,7));break;case 5:var O=null;switch(Ot.tag){case 26:O=Ot.memoizedState;case 5:case 27:var J=Ot;if(O?I0(O):J.stateNode.complete){Kt=0,Cr=null;var se=J.sibling;if(se!==null)Ot=se;else{var me=J.return;me!==null?(Ot=me,Tc(me)):Ot=null}break t}}Kt=0,Cr=null,Ci(n,a,v,5);break;case 6:Kt=0,Cr=null,Ci(n,a,v,6);break;case 8:Af(),Cn=6;break e;default:throw Error(i(462))}}S5();break}catch(Ce){Gp(n,Ce)}while(!0);return js=Oa=null,A.H=d,A.A=y,Qt=l,Ot!==null?0:(an=null,$t=0,Go(),Cn)}function S5(){for(;Ot!==null&&!_e();)Kp(Ot)}function Kp(n){var a=jp(n.alternate,n,Ms);n.memoizedProps=n.pendingProps,a===null?Tc(n):Ot=a}function Jp(n){var a=n,l=a.alternate;switch(a.tag){case 15:case 0:a=xp(l,a,a.pendingProps,a.type,void 0,$t);break;case 11:a=xp(l,a,a.pendingProps,a.type.render,a.ref,$t);break;case 5:Fd(a);default:Np(l,a),a=Ot=Qx(a,Ms),a=jp(l,a,Ms)}n.memoizedProps=n.pendingProps,a===null?Tc(n):Ot=a}function Ci(n,a,l,d){js=Oa=null,Fd(a),xi=null,gl=0;var y=a.return;try{if(h5(n,y,a,l,$t)){Cn=1,xc(n,$r(l,n.current)),Ot=null;return}}catch(v){if(y!==null)throw Ot=y,v;Cn=1,xc(n,$r(l,n.current)),Ot=null;return}a.flags&32768?(Pt||d===1?n=!0:wi||($t&536870912)!==0?n=!1:(ea=n=!0,(d===2||d===9||d===3||d===6)&&(d=kr.current,d!==null&&d.tag===13&&(d.flags|=16384))),Wp(a,n)):Tc(a)}function Tc(n){var a=n;do{if((a.flags&32768)!==0){Wp(a,ea);return}n=a.return;var l=g5(a.alternate,a,Ms);if(l!==null){Ot=l;return}if(a=a.sibling,a!==null){Ot=a;return}Ot=a=n}while(a!==null);Cn===0&&(Cn=5)}function Wp(n,a){do{var l=p5(n.alternate,n);if(l!==null){l.flags&=32767,Ot=l;return}if(l=n.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!a&&(n=n.sibling,n!==null)){Ot=n;return}Ot=n=l}while(n!==null);Cn=6,Ot=null}function e0(n,a,l,d,y,v,O,J,se){n.cancelPendingCommit=null;do _c();while(Vn!==0);if((Qt&6)!==0)throw Error(i(327));if(a!==null){if(a===n.current)throw Error(i(177));if(v=a.lanes|a.childLanes,v|=bd,at(n,l,v,O,J,se),n===an&&(Ot=an=null,$t=0),ki=a,ra=n,Ds=l,Ef=v,Tf=y,qp=d,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,_5(Ve,function(){return a0(),null})):(n.callbackNode=null,n.callbackPriority=0),d=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||d){d=A.T,A.T=null,y=G.p,G.p=2,O=Qt,Qt|=4;try{b5(n,a,l)}finally{Qt=O,G.p=y,A.T=d}}Vn=1,t0(),n0(),r0()}}function t0(){if(Vn===1){Vn=0;var n=ra,a=ki,l=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||l){l=A.T,A.T=null;var d=G.p;G.p=2;var y=Qt;Qt|=4;try{zp(a,n);var v=qf,O=Px(n.containerInfo),J=v.focusedElem,se=v.selectionRange;if(O!==J&&J&&J.ownerDocument&&Hx(J.ownerDocument.documentElement,J)){if(se!==null&&hd(J)){var me=se.start,Ce=se.end;if(Ce===void 0&&(Ce=me),"selectionStart"in J)J.selectionStart=me,J.selectionEnd=Math.min(Ce,J.value.length);else{var Te=J.ownerDocument||document,ge=Te&&Te.defaultView||window;if(ge.getSelection){var we=ge.getSelection(),Ye=J.textContent.length,mt=Math.min(se.start,Ye),nn=se.end===void 0?mt:Math.min(se.end,Ye);!we.extend&&mt>nn&&(O=nn,nn=mt,mt=O);var de=Bx(J,mt),ce=Bx(J,nn);if(de&&ce&&(we.rangeCount!==1||we.anchorNode!==de.node||we.anchorOffset!==de.offset||we.focusNode!==ce.node||we.focusOffset!==ce.offset)){var he=Te.createRange();he.setStart(de.node,de.offset),we.removeAllRanges(),mt>nn?(we.addRange(he),we.extend(ce.node,ce.offset)):(he.setEnd(ce.node,ce.offset),we.addRange(he))}}}}for(Te=[],we=J;we=we.parentNode;)we.nodeType===1&&Te.push({element:we,left:we.scrollLeft,top:we.scrollTop});for(typeof J.focus=="function"&&J.focus(),J=0;J<Te.length;J++){var Ee=Te[J];Ee.element.scrollLeft=Ee.left,Ee.element.scrollTop=Ee.top}}Pc=!!Uf,qf=Uf=null}finally{Qt=y,G.p=d,A.T=l}}n.current=a,Vn=2}}function n0(){if(Vn===2){Vn=0;var n=ra,a=ki,l=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||l){l=A.T,A.T=null;var d=G.p;G.p=2;var y=Qt;Qt|=4;try{Ap(n,a.alternate,a)}finally{Qt=y,G.p=d,A.T=l}}Vn=3}}function r0(){if(Vn===4||Vn===3){Vn=0,ht();var n=ra,a=ki,l=Ds,d=qp;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Vn=5:(Vn=0,ki=ra=null,s0(n,n.pendingLanes));var y=n.pendingLanes;if(y===0&&(na=null),Dn(l),a=a.stateNode,wt&&typeof wt.onCommitFiberRoot=="function")try{wt.onCommitFiberRoot(_t,a,void 0,(a.current.flags&128)===128)}catch{}if(d!==null){a=A.T,y=G.p,G.p=2,A.T=null;try{for(var v=n.onRecoverableError,O=0;O<d.length;O++){var J=d[O];v(J.value,{componentStack:J.stack})}}finally{A.T=a,G.p=y}}(Ds&3)!==0&&_c(),ls(n),y=n.pendingLanes,(l&261930)!==0&&(y&42)!==0?n===_f?Ol++:(Ol=0,_f=n):Ol=0,Rl(0)}}function s0(n,a){(n.pooledCacheLanes&=a)===0&&(a=n.pooledCache,a!=null&&(n.pooledCache=null,ml(a)))}function _c(){return t0(),n0(),r0(),a0()}function a0(){if(Vn!==5)return!1;var n=ra,a=Ef;Ef=0;var l=Dn(Ds),d=A.T,y=G.p;try{G.p=32>l?32:l,A.T=null,l=Tf,Tf=null;var v=ra,O=Ds;if(Vn=0,ki=ra=null,Ds=0,(Qt&6)!==0)throw Error(i(331));var J=Qt;if(Qt|=4,Hp(v.current),Ip(v,v.current,O,l),Qt=J,Rl(0,!1),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(_t,v)}catch{}return!0}finally{G.p=y,A.T=d,s0(n,a)}}function i0(n,a,l){a=$r(l,a),a=lf(n.stateNode,a,2),n=Qs(n,a,2),n!==null&&(st(n,2),ls(n))}function Jt(n,a,l){if(n.tag===3)i0(n,n,l);else for(;a!==null;){if(a.tag===3){i0(a,n,l);break}else if(a.tag===1){var d=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(na===null||!na.has(d))){n=$r(l,n),l=lp(2),d=Qs(a,l,2),d!==null&&(op(l,d,a,n),st(d,2),ls(d));break}}a=a.return}}function Df(n,a,l){var d=n.pingCache;if(d===null){d=n.pingCache=new j5;var y=new Set;d.set(a,y)}else y=d.get(a),y===void 0&&(y=new Set,d.set(a,y));y.has(l)||(kf=!0,y.add(l),n=C5.bind(null,n,a,l),a.then(n,n))}function C5(n,a,l){var d=n.pingCache;d!==null&&d.delete(a),n.pingedLanes|=n.suspendedLanes&l,n.warmLanes&=~l,an===n&&($t&l)===l&&(Cn===4||Cn===3&&($t&62914560)===$t&&300>Ct()-Nc?(Qt&2)===0&&Si(n,0):Sf|=l,Ni===$t&&(Ni=0)),ls(n)}function l0(n,a){a===0&&(a=Le()),n=Aa(n,a),n!==null&&(st(n,a),ls(n))}function E5(n){var a=n.memoizedState,l=0;a!==null&&(l=a.retryLane),l0(n,l)}function T5(n,a){var l=0;switch(n.tag){case 31:case 13:var d=n.stateNode,y=n.memoizedState;y!==null&&(l=y.retryLane);break;case 19:d=n.stateNode;break;case 22:d=n.stateNode._retryCache;break;default:throw Error(i(314))}d!==null&&d.delete(a),l0(n,l)}function _5(n,a){return Lt(n,a)}var Ac=null,Ei=null,Of=!1,Mc=!1,Rf=!1,aa=0;function ls(n){n!==Ei&&n.next===null&&(Ei===null?Ac=Ei=n:Ei=Ei.next=n),Mc=!0,Of||(Of=!0,M5())}function Rl(n,a){if(!Rf&&Mc){Rf=!0;do for(var l=!1,d=Ac;d!==null;){if(n!==0){var y=d.pendingLanes;if(y===0)var v=0;else{var O=d.suspendedLanes,J=d.pingedLanes;v=(1<<31-Be(42|n)+1)-1,v&=y&~(O&~J),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(l=!0,d0(d,v))}else v=$t,v=vn(d,d===an?v:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(v&3)===0||Mt(d,v)||(l=!0,d0(d,v));d=d.next}while(l);Rf=!1}}function A5(){o0()}function o0(){Mc=Of=!1;var n=0;aa!==0&&P5()&&(n=aa);for(var a=Ct(),l=null,d=Ac;d!==null;){var y=d.next,v=c0(d,a);v===0?(d.next=null,l===null?Ac=y:l.next=y,y===null&&(Ei=l)):(l=d,(n!==0||(v&3)!==0)&&(Mc=!0)),d=y}Vn!==0&&Vn!==5||Rl(n),aa!==0&&(aa=0)}function c0(n,a){for(var l=n.suspendedLanes,d=n.pingedLanes,y=n.expirationTimes,v=n.pendingLanes&-62914561;0<v;){var O=31-Be(v),J=1<<O,se=y[O];se===-1?((J&l)===0||(J&d)!==0)&&(y[O]=oe(J,a)):se<=a&&(n.expiredLanes|=J),v&=~J}if(a=an,l=$t,l=vn(n,n===a?l:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),d=n.callbackNode,l===0||n===a&&(Kt===2||Kt===9)||n.cancelPendingCommit!==null)return d!==null&&d!==null&&le(d),n.callbackNode=null,n.callbackPriority=0;if((l&3)===0||Mt(n,l)){if(a=l&-l,a===n.callbackPriority)return a;switch(d!==null&&le(d),Dn(l)){case 2:case 8:l=Me;break;case 32:l=Ve;break;case 268435456:l=rt;break;default:l=Ve}return d=u0.bind(null,n),l=Lt(l,d),n.callbackPriority=a,n.callbackNode=l,a}return d!==null&&d!==null&&le(d),n.callbackPriority=2,n.callbackNode=null,2}function u0(n,a){if(Vn!==0&&Vn!==5)return n.callbackNode=null,n.callbackPriority=0,null;var l=n.callbackNode;if(_c()&&n.callbackNode!==l)return null;var d=$t;return d=vn(n,n===an?d:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),d===0?null:(Fp(n,d,a),c0(n,Ct()),n.callbackNode!=null&&n.callbackNode===l?u0.bind(null,n):null)}function d0(n,a){if(_c())return null;Fp(n,a,!0)}function M5(){q5(function(){(Qt&6)!==0?Lt(be,A5):o0()})}function zf(){if(aa===0){var n=fi;n===0&&(n=Se,Se<<=1,(Se&261888)===0&&(Se=256)),aa=n}return aa}function f0(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:ut(""+n)}function h0(n,a){var l=a.ownerDocument.createElement("input");return l.name=a.name,l.value=a.value,n.id&&l.setAttribute("form",n.id),a.parentNode.insertBefore(l,a),n=new FormData(n),l.parentNode.removeChild(l),n}function D5(n,a,l,d,y){if(a==="submit"&&l&&l.stateNode===y){var v=f0((y[wn]||null).action),O=d.submitter;O&&(a=(a=O[wn]||null)?f0(a.formAction):O.getAttribute("formAction"),a!==null&&(v=a,O=null));var J=new qo("action","action",null,d,y);n.push({event:J,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(aa!==0){var se=O?h0(y,O):new FormData(y);ef(l,{pending:!0,data:se,method:y.method,action:v},null,se)}}else typeof v=="function"&&(J.preventDefault(),se=O?h0(y,O):new FormData(y),ef(l,{pending:!0,data:se,method:y.method,action:v},v,se))},currentTarget:y}]})}}for(var Lf=0;Lf<pd.length;Lf++){var If=pd[Lf],O5=If.toLowerCase(),R5=If[0].toUpperCase()+If.slice(1);Xr(O5,"on"+R5)}Xr(Vx,"onAnimationEnd"),Xr(Fx,"onAnimationIteration"),Xr(Yx,"onAnimationStart"),Xr("dblclick","onDoubleClick"),Xr("focusin","onFocus"),Xr("focusout","onBlur"),Xr(QN,"onTransitionRun"),Xr(KN,"onTransitionStart"),Xr(JN,"onTransitionCancel"),Xr(Gx,"onTransitionEnd"),or("onMouseEnter",["mouseout","mouseover"]),or("onMouseLeave",["mouseout","mouseover"]),or("onPointerEnter",["pointerout","pointerover"]),or("onPointerLeave",["pointerout","pointerover"]),lr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),lr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),lr("onBeforeInput",["compositionend","keypress","textInput","paste"]),lr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),lr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),lr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zl="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(" "),z5=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(zl));function m0(n,a){a=(a&4)!==0;for(var l=0;l<n.length;l++){var d=n[l],y=d.event;d=d.listeners;e:{var v=void 0;if(a)for(var O=d.length-1;0<=O;O--){var J=d[O],se=J.instance,me=J.currentTarget;if(J=J.listener,se!==v&&y.isPropagationStopped())break e;v=J,y.currentTarget=me;try{v(y)}catch(Ce){Yo(Ce)}y.currentTarget=null,v=se}else for(O=0;O<d.length;O++){if(J=d[O],se=J.instance,me=J.currentTarget,J=J.listener,se!==v&&y.isPropagationStopped())break e;v=J,y.currentTarget=me;try{v(y)}catch(Ce){Yo(Ce)}y.currentTarget=null,v=se}}}}function Rt(n,a){var l=a[ve];l===void 0&&(l=a[ve]=new Set);var d=n+"__bubble";l.has(d)||(x0(a,n,2,!1),l.add(d))}function $f(n,a,l){var d=0;a&&(d|=4),x0(l,n,d,a)}var Dc="_reactListening"+Math.random().toString(36).slice(2);function Bf(n){if(!n[Dc]){n[Dc]=!0,zr.forEach(function(l){l!=="selectionchange"&&(z5.has(l)||$f(l,!1,n),$f(l,!0,n))});var a=n.nodeType===9?n:n.ownerDocument;a===null||a[Dc]||(a[Dc]=!0,$f("selectionchange",!1,a))}}function x0(n,a,l,d){switch(V0(a)){case 2:var y=c2;break;case 8:y=u2;break;default:y=eh}l=y.bind(null,a,l,n),y=void 0,!sd||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(y=!0),d?y!==void 0?n.addEventListener(a,l,{capture:!0,passive:y}):n.addEventListener(a,l,!0):y!==void 0?n.addEventListener(a,l,{passive:y}):n.addEventListener(a,l,!1)}function Hf(n,a,l,d,y){var v=d;if((a&1)===0&&(a&2)===0&&d!==null)e:for(;;){if(d===null)return;var O=d.tag;if(O===3||O===4){var J=d.stateNode.containerInfo;if(J===y)break;if(O===4)for(O=d.return;O!==null;){var se=O.tag;if((se===3||se===4)&&O.stateNode.containerInfo===y)return;O=O.return}for(;J!==null;){if(O=ir(J),O===null)return;if(se=O.tag,se===5||se===6||se===26||se===27){d=v=O;continue e}J=J.parentNode}}d=d.return}Bo(function(){var me=v,Ce=ot(l),Te=[];e:{var ge=Xx.get(n);if(ge!==void 0){var we=qo,Ye=n;switch(n){case"keypress":if(Po(l)===0)break e;case"keydown":case"keyup":we=TN;break;case"focusin":Ye="focus",we=od;break;case"focusout":Ye="blur",we=od;break;case"beforeblur":case"afterblur":we=od;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":we=Nx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":we=gN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":we=MN;break;case Vx:case Fx:case Yx:we=yN;break;case Gx:we=ON;break;case"scroll":case"scrollend":we=mN;break;case"wheel":we=zN;break;case"copy":case"cut":case"paste":we=jN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":we=Sx;break;case"toggle":case"beforetoggle":we=IN}var mt=(a&4)!==0,nn=!mt&&(n==="scroll"||n==="scrollend"),de=mt?ge!==null?ge+"Capture":null:ge;mt=[];for(var ce=me,he;ce!==null;){var Ee=ce;if(he=Ee.stateNode,Ee=Ee.tag,Ee!==5&&Ee!==26&&Ee!==27||he===null||de===null||(Ee=rl(ce,de),Ee!=null&&mt.push(Ll(ce,Ee,he))),nn)break;ce=ce.return}0<mt.length&&(ge=new we(ge,Ye,null,l,Ce),Te.push({event:ge,listeners:mt}))}}if((a&7)===0){e:{if(ge=n==="mouseover"||n==="pointerover",we=n==="mouseout"||n==="pointerout",ge&&l!==Ge&&(Ye=l.relatedTarget||l.fromElement)&&(ir(Ye)||Ye[qn]))break e;if((we||ge)&&(ge=Ce.window===Ce?Ce:(ge=Ce.ownerDocument)?ge.defaultView||ge.parentWindow:window,we?(Ye=l.relatedTarget||l.toElement,we=me,Ye=Ye?ir(Ye):null,Ye!==null&&(nn=c(Ye),mt=Ye.tag,Ye!==nn||mt!==5&&mt!==27&&mt!==6)&&(Ye=null)):(we=null,Ye=me),we!==Ye)){if(mt=Nx,Ee="onMouseLeave",de="onMouseEnter",ce="mouse",(n==="pointerout"||n==="pointerover")&&(mt=Sx,Ee="onPointerLeave",de="onPointerEnter",ce="pointer"),nn=we==null?ge:Rr(we),he=Ye==null?ge:Rr(Ye),ge=new mt(Ee,ce+"leave",we,l,Ce),ge.target=nn,ge.relatedTarget=he,Ee=null,ir(Ce)===me&&(mt=new mt(de,ce+"enter",Ye,l,Ce),mt.target=he,mt.relatedTarget=nn,Ee=mt),nn=Ee,we&&Ye)t:{for(mt=L5,de=we,ce=Ye,he=0,Ee=de;Ee;Ee=mt(Ee))he++;Ee=0;for(var lt=ce;lt;lt=mt(lt))Ee++;for(;0<he-Ee;)de=mt(de),he--;for(;0<Ee-he;)ce=mt(ce),Ee--;for(;he--;){if(de===ce||ce!==null&&de===ce.alternate){mt=de;break t}de=mt(de),ce=mt(ce)}mt=null}else mt=null;we!==null&&g0(Te,ge,we,mt,!1),Ye!==null&&nn!==null&&g0(Te,nn,Ye,mt,!0)}}e:{if(ge=me?Rr(me):window,we=ge.nodeName&&ge.nodeName.toLowerCase(),we==="select"||we==="input"&&ge.type==="file")var Yt=Ox;else if(Mx(ge))if(Rx)Yt=GN;else{Yt=FN;var Je=VN}else we=ge.nodeName,!we||we.toLowerCase()!=="input"||ge.type!=="checkbox"&&ge.type!=="radio"?me&&hn(me.elementType)&&(Yt=Ox):Yt=YN;if(Yt&&(Yt=Yt(n,me))){Dx(Te,Yt,l,Ce);break e}Je&&Je(n,ge,me),n==="focusout"&&me&&ge.type==="number"&&me.memoizedProps.value!=null&&dt(ge,"number",ge.value)}switch(Je=me?Rr(me):window,n){case"focusin":(Mx(Je)||Je.contentEditable==="true")&&(si=Je,md=me,dl=null);break;case"focusout":dl=md=si=null;break;case"mousedown":xd=!0;break;case"contextmenu":case"mouseup":case"dragend":xd=!1,Ux(Te,l,Ce);break;case"selectionchange":if(ZN)break;case"keydown":case"keyup":Ux(Te,l,Ce)}var kt;if(ud)e:{switch(n){case"compositionstart":var Bt="onCompositionStart";break e;case"compositionend":Bt="onCompositionEnd";break e;case"compositionupdate":Bt="onCompositionUpdate";break e}Bt=void 0}else ri?_x(n,l)&&(Bt="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(Bt="onCompositionStart");Bt&&(Cx&&l.locale!=="ko"&&(ri||Bt!=="onCompositionStart"?Bt==="onCompositionEnd"&&ri&&(kt=jx()):(qs=Ce,ad="value"in qs?qs.value:qs.textContent,ri=!0)),Je=Oc(me,Bt),0<Je.length&&(Bt=new kx(Bt,n,null,l,Ce),Te.push({event:Bt,listeners:Je}),kt?Bt.data=kt:(kt=Ax(l),kt!==null&&(Bt.data=kt)))),(kt=BN?HN(n,l):PN(n,l))&&(Bt=Oc(me,"onBeforeInput"),0<Bt.length&&(Je=new kx("onBeforeInput","beforeinput",null,l,Ce),Te.push({event:Je,listeners:Bt}),Je.data=kt)),D5(Te,n,me,l,Ce)}m0(Te,a)})}function Ll(n,a,l){return{instance:n,listener:a,currentTarget:l}}function Oc(n,a){for(var l=a+"Capture",d=[];n!==null;){var y=n,v=y.stateNode;if(y=y.tag,y!==5&&y!==26&&y!==27||v===null||(y=rl(n,l),y!=null&&d.unshift(Ll(n,y,v)),y=rl(n,a),y!=null&&d.push(Ll(n,y,v))),n.tag===3)return d;n=n.return}return[]}function L5(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function g0(n,a,l,d,y){for(var v=a._reactName,O=[];l!==null&&l!==d;){var J=l,se=J.alternate,me=J.stateNode;if(J=J.tag,se!==null&&se===d)break;J!==5&&J!==26&&J!==27||me===null||(se=me,y?(me=rl(l,v),me!=null&&O.unshift(Ll(l,me,se))):y||(me=rl(l,v),me!=null&&O.push(Ll(l,me,se)))),l=l.return}O.length!==0&&n.push({event:a,listeners:O})}var I5=/\r\n?/g,$5=/\u0000|\uFFFD/g;function p0(n){return(typeof n=="string"?n:""+n).replace(I5,`
|
|
9
|
-
`).replace($5,"")}function b0(n,a){return a=p0(a),p0(n)===a}function tn(n,a,l,d,y,v){switch(l){case"children":typeof d=="string"?a==="body"||a==="textarea"&&d===""||it(n,d):(typeof d=="number"||typeof d=="bigint")&&a!=="body"&&it(n,""+d);break;case"className":Lr(n,"class",d);break;case"tabIndex":Lr(n,"tabindex",d);break;case"dir":case"role":case"viewBox":case"width":case"height":Lr(n,l,d);break;case"style":Zt(n,d,v);break;case"data":if(a!=="object"){Lr(n,"data",d);break}case"src":case"href":if(d===""&&(a!=="a"||l!=="href")){n.removeAttribute(l);break}if(d==null||typeof d=="function"||typeof d=="symbol"||typeof d=="boolean"){n.removeAttribute(l);break}d=ut(""+d),n.setAttribute(l,d);break;case"action":case"formAction":if(typeof d=="function"){n.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof v=="function"&&(l==="formAction"?(a!=="input"&&tn(n,a,"name",y.name,y,null),tn(n,a,"formEncType",y.formEncType,y,null),tn(n,a,"formMethod",y.formMethod,y,null),tn(n,a,"formTarget",y.formTarget,y,null)):(tn(n,a,"encType",y.encType,y,null),tn(n,a,"method",y.method,y,null),tn(n,a,"target",y.target,y,null)));if(d==null||typeof d=="symbol"||typeof d=="boolean"){n.removeAttribute(l);break}d=ut(""+d),n.setAttribute(l,d);break;case"onClick":d!=null&&(n.onclick=qe);break;case"onScroll":d!=null&&Rt("scroll",n);break;case"onScrollEnd":d!=null&&Rt("scrollend",n);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(i(61));if(l=d.__html,l!=null){if(y.children!=null)throw Error(i(60));n.innerHTML=l}}break;case"multiple":n.multiple=d&&typeof d!="function"&&typeof d!="symbol";break;case"muted":n.muted=d&&typeof d!="function"&&typeof d!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(d==null||typeof d=="function"||typeof d=="boolean"||typeof d=="symbol"){n.removeAttribute("xlink:href");break}l=ut(""+d),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":d!=null&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(l,""+d):n.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":d&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(l,""):n.removeAttribute(l);break;case"capture":case"download":d===!0?n.setAttribute(l,""):d!==!1&&d!=null&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(l,d):n.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":d!=null&&typeof d!="function"&&typeof d!="symbol"&&!isNaN(d)&&1<=d?n.setAttribute(l,d):n.removeAttribute(l);break;case"rowSpan":case"start":d==null||typeof d=="function"||typeof d=="symbol"||isNaN(d)?n.removeAttribute(l):n.setAttribute(l,d);break;case"popover":Rt("beforetoggle",n),Rt("toggle",n),cr(n,"popover",d);break;case"xlinkActuate":Yn(n,"http://www.w3.org/1999/xlink","xlink:actuate",d);break;case"xlinkArcrole":Yn(n,"http://www.w3.org/1999/xlink","xlink:arcrole",d);break;case"xlinkRole":Yn(n,"http://www.w3.org/1999/xlink","xlink:role",d);break;case"xlinkShow":Yn(n,"http://www.w3.org/1999/xlink","xlink:show",d);break;case"xlinkTitle":Yn(n,"http://www.w3.org/1999/xlink","xlink:title",d);break;case"xlinkType":Yn(n,"http://www.w3.org/1999/xlink","xlink:type",d);break;case"xmlBase":Yn(n,"http://www.w3.org/XML/1998/namespace","xml:base",d);break;case"xmlLang":Yn(n,"http://www.w3.org/XML/1998/namespace","xml:lang",d);break;case"xmlSpace":Yn(n,"http://www.w3.org/XML/1998/namespace","xml:space",d);break;case"is":cr(n,"is",d);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=yt.get(l)||l,cr(n,l,d))}}function Pf(n,a,l,d,y,v){switch(l){case"style":Zt(n,d,v);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(i(61));if(l=d.__html,l!=null){if(y.children!=null)throw Error(i(60));n.innerHTML=l}}break;case"children":typeof d=="string"?it(n,d):(typeof d=="number"||typeof d=="bigint")&&it(n,""+d);break;case"onScroll":d!=null&&Rt("scroll",n);break;case"onScrollEnd":d!=null&&Rt("scrollend",n);break;case"onClick":d!=null&&(n.onclick=qe);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ps.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(y=l.endsWith("Capture"),a=l.slice(2,y?l.length-7:void 0),v=n[wn]||null,v=v!=null?v[l]:null,typeof v=="function"&&n.removeEventListener(a,v,y),typeof d=="function")){typeof v!="function"&&v!==null&&(l in n?n[l]=null:n.hasAttribute(l)&&n.removeAttribute(l)),n.addEventListener(a,d,y);break e}l in n?n[l]=d:d===!0?n.setAttribute(l,""):cr(n,l,d)}}}function Kn(n,a,l){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Rt("error",n),Rt("load",n);var d=!1,y=!1,v;for(v in l)if(l.hasOwnProperty(v)){var O=l[v];if(O!=null)switch(v){case"src":d=!0;break;case"srcSet":y=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:tn(n,a,v,O,l,null)}}y&&tn(n,a,"srcSet",l.srcSet,l,null),d&&tn(n,a,"src",l.src,l,null);return;case"input":Rt("invalid",n);var J=v=O=y=null,se=null,me=null;for(d in l)if(l.hasOwnProperty(d)){var Ce=l[d];if(Ce!=null)switch(d){case"name":y=Ce;break;case"type":O=Ce;break;case"checked":se=Ce;break;case"defaultChecked":me=Ce;break;case"value":v=Ce;break;case"defaultValue":J=Ce;break;case"children":case"dangerouslySetInnerHTML":if(Ce!=null)throw Error(i(137,a));break;default:tn(n,a,d,Ce,l,null)}}ye(n,v,J,se,me,O,y,!1);return;case"select":Rt("invalid",n),d=O=v=null;for(y in l)if(l.hasOwnProperty(y)&&(J=l[y],J!=null))switch(y){case"value":v=J;break;case"defaultValue":O=J;break;case"multiple":d=J;default:tn(n,a,y,J,l,null)}a=v,l=O,n.multiple=!!d,a!=null?He(n,!!d,a,!1):l!=null&&He(n,!!d,l,!0);return;case"textarea":Rt("invalid",n),v=y=d=null;for(O in l)if(l.hasOwnProperty(O)&&(J=l[O],J!=null))switch(O){case"value":d=J;break;case"defaultValue":y=J;break;case"children":v=J;break;case"dangerouslySetInnerHTML":if(J!=null)throw Error(i(91));break;default:tn(n,a,O,J,l,null)}bt(n,d,y,v);return;case"option":for(se in l)l.hasOwnProperty(se)&&(d=l[se],d!=null)&&(se==="selected"?n.selected=d&&typeof d!="function"&&typeof d!="symbol":tn(n,a,se,d,l,null));return;case"dialog":Rt("beforetoggle",n),Rt("toggle",n),Rt("cancel",n),Rt("close",n);break;case"iframe":case"object":Rt("load",n);break;case"video":case"audio":for(d=0;d<zl.length;d++)Rt(zl[d],n);break;case"image":Rt("error",n),Rt("load",n);break;case"details":Rt("toggle",n);break;case"embed":case"source":case"link":Rt("error",n),Rt("load",n);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 l)if(l.hasOwnProperty(me)&&(d=l[me],d!=null))switch(me){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:tn(n,a,me,d,l,null)}return;default:if(hn(a)){for(Ce in l)l.hasOwnProperty(Ce)&&(d=l[Ce],d!==void 0&&Pf(n,a,Ce,d,l,void 0));return}}for(J in l)l.hasOwnProperty(J)&&(d=l[J],d!=null&&tn(n,a,J,d,l,null))}function B5(n,a,l,d){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var y=null,v=null,O=null,J=null,se=null,me=null,Ce=null;for(we in l){var Te=l[we];if(l.hasOwnProperty(we)&&Te!=null)switch(we){case"checked":break;case"value":break;case"defaultValue":se=Te;default:d.hasOwnProperty(we)||tn(n,a,we,null,d,Te)}}for(var ge in d){var we=d[ge];if(Te=l[ge],d.hasOwnProperty(ge)&&(we!=null||Te!=null))switch(ge){case"type":v=we;break;case"name":y=we;break;case"checked":me=we;break;case"defaultChecked":Ce=we;break;case"value":O=we;break;case"defaultValue":J=we;break;case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(i(137,a));break;default:we!==Te&&tn(n,a,ge,we,d,Te)}}Ne(n,O,J,se,me,Ce,v,y);return;case"select":we=O=J=ge=null;for(v in l)if(se=l[v],l.hasOwnProperty(v)&&se!=null)switch(v){case"value":break;case"multiple":we=se;default:d.hasOwnProperty(v)||tn(n,a,v,null,d,se)}for(y in d)if(v=d[y],se=l[y],d.hasOwnProperty(y)&&(v!=null||se!=null))switch(y){case"value":ge=v;break;case"defaultValue":J=v;break;case"multiple":O=v;default:v!==se&&tn(n,a,y,v,d,se)}a=J,l=O,d=we,ge!=null?He(n,!!l,ge,!1):!!d!=!!l&&(a!=null?He(n,!!l,a,!0):He(n,!!l,l?[]:"",!1));return;case"textarea":we=ge=null;for(J in l)if(y=l[J],l.hasOwnProperty(J)&&y!=null&&!d.hasOwnProperty(J))switch(J){case"value":break;case"children":break;default:tn(n,a,J,null,d,y)}for(O in d)if(y=d[O],v=l[O],d.hasOwnProperty(O)&&(y!=null||v!=null))switch(O){case"value":ge=y;break;case"defaultValue":we=y;break;case"children":break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(i(91));break;default:y!==v&&tn(n,a,O,y,d,v)}Fe(n,ge,we);return;case"option":for(var Ye in l)ge=l[Ye],l.hasOwnProperty(Ye)&&ge!=null&&!d.hasOwnProperty(Ye)&&(Ye==="selected"?n.selected=!1:tn(n,a,Ye,null,d,ge));for(se in d)ge=d[se],we=l[se],d.hasOwnProperty(se)&&ge!==we&&(ge!=null||we!=null)&&(se==="selected"?n.selected=ge&&typeof ge!="function"&&typeof ge!="symbol":tn(n,a,se,ge,d,we));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 mt in l)ge=l[mt],l.hasOwnProperty(mt)&&ge!=null&&!d.hasOwnProperty(mt)&&tn(n,a,mt,null,d,ge);for(me in d)if(ge=d[me],we=l[me],d.hasOwnProperty(me)&&ge!==we&&(ge!=null||we!=null))switch(me){case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(i(137,a));break;default:tn(n,a,me,ge,d,we)}return;default:if(hn(a)){for(var nn in l)ge=l[nn],l.hasOwnProperty(nn)&&ge!==void 0&&!d.hasOwnProperty(nn)&&Pf(n,a,nn,void 0,d,ge);for(Ce in d)ge=d[Ce],we=l[Ce],!d.hasOwnProperty(Ce)||ge===we||ge===void 0&&we===void 0||Pf(n,a,Ce,ge,d,we);return}}for(var de in l)ge=l[de],l.hasOwnProperty(de)&&ge!=null&&!d.hasOwnProperty(de)&&tn(n,a,de,null,d,ge);for(Te in d)ge=d[Te],we=l[Te],!d.hasOwnProperty(Te)||ge===we||ge==null&&we==null||tn(n,a,Te,ge,d,we)}function y0(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function H5(){if(typeof performance.getEntriesByType=="function"){for(var n=0,a=0,l=performance.getEntriesByType("resource"),d=0;d<l.length;d++){var y=l[d],v=y.transferSize,O=y.initiatorType,J=y.duration;if(v&&J&&y0(O)){for(O=0,J=y.responseEnd,d+=1;d<l.length;d++){var se=l[d],me=se.startTime;if(me>J)break;var Ce=se.transferSize,Te=se.initiatorType;Ce&&y0(Te)&&(se=se.responseEnd,O+=Ce*(se<J?1:(J-me)/(se-me)))}if(--d,a+=8*(v+O)/(y.duration/1e3),n++,10<n)break}}if(0<n)return a/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Uf=null,qf=null;function Rc(n){return n.nodeType===9?n:n.ownerDocument}function v0(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function j0(n,a){if(n===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&a==="foreignObject"?0:n}function Vf(n,a){return n==="textarea"||n==="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 Ff=null;function P5(){var n=window.event;return n&&n.type==="popstate"?n===Ff?!1:(Ff=n,!0):(Ff=null,!1)}var w0=typeof setTimeout=="function"?setTimeout:void 0,U5=typeof clearTimeout=="function"?clearTimeout:void 0,N0=typeof Promise=="function"?Promise:void 0,q5=typeof queueMicrotask=="function"?queueMicrotask:typeof N0<"u"?function(n){return N0.resolve(null).then(n).catch(V5)}:w0;function V5(n){setTimeout(function(){throw n})}function ia(n){return n==="head"}function k0(n,a){var l=a,d=0;do{var y=l.nextSibling;if(n.removeChild(l),y&&y.nodeType===8)if(l=y.data,l==="/$"||l==="/&"){if(d===0){n.removeChild(y),Mi(a);return}d--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")d++;else if(l==="html")Il(n.ownerDocument.documentElement);else if(l==="head"){l=n.ownerDocument.head,Il(l);for(var v=l.firstChild;v;){var O=v.nextSibling,J=v.nodeName;v[Nn]||J==="SCRIPT"||J==="STYLE"||J==="LINK"&&v.rel.toLowerCase()==="stylesheet"||l.removeChild(v),v=O}}else l==="body"&&Il(n.ownerDocument.body);l=y}while(l);Mi(a)}function S0(n,a){var l=n;n=0;do{var d=l.nextSibling;if(l.nodeType===1?a?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(a?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),d&&d.nodeType===8)if(l=d.data,l==="/$"){if(n===0)break;n--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||n++;l=d}while(l)}function Yf(n){var a=n.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var l=a;switch(a=a.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Yf(l),ar(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}n.removeChild(l)}}function F5(n,a,l,d){for(;n.nodeType===1;){var y=l;if(n.nodeName.toLowerCase()!==a.toLowerCase()){if(!d&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(d){if(!n[Nn])switch(a){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(v=n.getAttribute("rel"),v==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(v!==y.rel||n.getAttribute("href")!==(y.href==null||y.href===""?null:y.href)||n.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin)||n.getAttribute("title")!==(y.title==null?null:y.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(v=n.getAttribute("src"),(v!==(y.src==null?null:y.src)||n.getAttribute("type")!==(y.type==null?null:y.type)||n.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin))&&v&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(a==="input"&&n.type==="hidden"){var v=y.name==null?null:""+y.name;if(y.type==="hidden"&&n.getAttribute("name")===v)return n}else return n;if(n=qr(n.nextSibling),n===null)break}return null}function Y5(n,a,l){if(a==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!l||(n=qr(n.nextSibling),n===null))return null;return n}function C0(n,a){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!a||(n=qr(n.nextSibling),n===null))return null;return n}function Gf(n){return n.data==="$?"||n.data==="$~"}function Xf(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function G5(n,a){var l=n.ownerDocument;if(n.data==="$~")n._reactRetry=a;else if(n.data!=="$?"||l.readyState!=="loading")a();else{var d=function(){a(),l.removeEventListener("DOMContentLoaded",d)};l.addEventListener("DOMContentLoaded",d),n._reactRetry=d}}function qr(n){for(;n!=null;n=n.nextSibling){var a=n.nodeType;if(a===1||a===3)break;if(a===8){if(a=n.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return n}var Zf=null;function E0(n){n=n.nextSibling;for(var a=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"||l==="/&"){if(a===0)return qr(n.nextSibling);a--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||a++}n=n.nextSibling}return null}function T0(n){n=n.previousSibling;for(var a=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(a===0)return n;a--}else l!=="/$"&&l!=="/&"||a++}n=n.previousSibling}return null}function _0(n,a,l){switch(a=Rc(l),n){case"html":if(n=a.documentElement,!n)throw Error(i(452));return n;case"head":if(n=a.head,!n)throw Error(i(453));return n;case"body":if(n=a.body,!n)throw Error(i(454));return n;default:throw Error(i(451))}}function Il(n){for(var a=n.attributes;a.length;)n.removeAttributeNode(a[0]);ar(n)}var Vr=new Map,A0=new Set;function zc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Os=G.d;G.d={f:X5,r:Z5,D:Q5,C:K5,L:J5,m:W5,X:t2,S:e2,M:n2};function X5(){var n=Os.f(),a=Cc();return n||a}function Z5(n){var a=Or(n);a!==null&&a.tag===5&&a.type==="form"?Gg(a):Os.r(n)}var Ti=typeof document>"u"?null:document;function M0(n,a,l){var d=Ti;if(d&&typeof a=="string"&&a){var y=pe(a);y='link[rel="'+n+'"][href="'+y+'"]',typeof l=="string"&&(y+='[crossorigin="'+l+'"]'),A0.has(y)||(A0.add(y),n={rel:n,crossOrigin:l,href:a},d.querySelector(y)===null&&(a=d.createElement("link"),Kn(a,"link",n),un(a),d.head.appendChild(a)))}}function Q5(n){Os.D(n),M0("dns-prefetch",n,null)}function K5(n,a){Os.C(n,a),M0("preconnect",n,a)}function J5(n,a,l){Os.L(n,a,l);var d=Ti;if(d&&n&&a){var y='link[rel="preload"][as="'+pe(a)+'"]';a==="image"&&l&&l.imageSrcSet?(y+='[imagesrcset="'+pe(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(y+='[imagesizes="'+pe(l.imageSizes)+'"]')):y+='[href="'+pe(n)+'"]';var v=y;switch(a){case"style":v=_i(n);break;case"script":v=Ai(n)}Vr.has(v)||(n=g({rel:"preload",href:a==="image"&&l&&l.imageSrcSet?void 0:n,as:a},l),Vr.set(v,n),d.querySelector(y)!==null||a==="style"&&d.querySelector($l(v))||a==="script"&&d.querySelector(Bl(v))||(a=d.createElement("link"),Kn(a,"link",n),un(a),d.head.appendChild(a)))}}function W5(n,a){Os.m(n,a);var l=Ti;if(l&&n){var d=a&&typeof a.as=="string"?a.as:"script",y='link[rel="modulepreload"][as="'+pe(d)+'"][href="'+pe(n)+'"]',v=y;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Ai(n)}if(!Vr.has(v)&&(n=g({rel:"modulepreload",href:n},a),Vr.set(v,n),l.querySelector(y)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Bl(v)))return}d=l.createElement("link"),Kn(d,"link",n),un(d),l.head.appendChild(d)}}}function e2(n,a,l){Os.S(n,a,l);var d=Ti;if(d&&n){var y=vr(d).hoistableStyles,v=_i(n);a=a||"default";var O=y.get(v);if(!O){var J={loading:0,preload:null};if(O=d.querySelector($l(v)))J.loading=5;else{n=g({rel:"stylesheet",href:n,"data-precedence":a},l),(l=Vr.get(v))&&Qf(n,l);var se=O=d.createElement("link");un(se),Kn(se,"link",n),se._p=new Promise(function(me,Ce){se.onload=me,se.onerror=Ce}),se.addEventListener("load",function(){J.loading|=1}),se.addEventListener("error",function(){J.loading|=2}),J.loading|=4,Lc(O,a,d)}O={type:"stylesheet",instance:O,count:1,state:J},y.set(v,O)}}}function t2(n,a){Os.X(n,a);var l=Ti;if(l&&n){var d=vr(l).hoistableScripts,y=Ai(n),v=d.get(y);v||(v=l.querySelector(Bl(y)),v||(n=g({src:n,async:!0},a),(a=Vr.get(y))&&Kf(n,a),v=l.createElement("script"),un(v),Kn(v,"link",n),l.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},d.set(y,v))}}function n2(n,a){Os.M(n,a);var l=Ti;if(l&&n){var d=vr(l).hoistableScripts,y=Ai(n),v=d.get(y);v||(v=l.querySelector(Bl(y)),v||(n=g({src:n,async:!0,type:"module"},a),(a=Vr.get(y))&&Kf(n,a),v=l.createElement("script"),un(v),Kn(v,"link",n),l.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},d.set(y,v))}}function D0(n,a,l,d){var y=(y=Q.current)?zc(y):null;if(!y)throw Error(i(446));switch(n){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(a=_i(l.href),l=vr(y).hoistableStyles,d=l.get(a),d||(d={type:"style",instance:null,count:0,state:null},l.set(a,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){n=_i(l.href);var v=vr(y).hoistableStyles,O=v.get(n);if(O||(y=y.ownerDocument||y,O={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(n,O),(v=y.querySelector($l(n)))&&!v._p&&(O.instance=v,O.state.loading=5),Vr.has(n)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Vr.set(n,l),v||r2(y,n,l,O.state))),a&&d===null)throw Error(i(528,""));return O}if(a&&d!==null)throw Error(i(529,""));return null;case"script":return a=l.async,l=l.src,typeof l=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Ai(l),l=vr(y).hoistableScripts,d=l.get(a),d||(d={type:"script",instance:null,count:0,state:null},l.set(a,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,n))}}function _i(n){return'href="'+pe(n)+'"'}function $l(n){return'link[rel="stylesheet"]['+n+"]"}function O0(n){return g({},n,{"data-precedence":n.precedence,precedence:null})}function r2(n,a,l,d){n.querySelector('link[rel="preload"][as="style"]['+a+"]")?d.loading=1:(a=n.createElement("link"),d.preload=a,a.addEventListener("load",function(){return d.loading|=1}),a.addEventListener("error",function(){return d.loading|=2}),Kn(a,"link",l),un(a),n.head.appendChild(a))}function Ai(n){return'[src="'+pe(n)+'"]'}function Bl(n){return"script[async]"+n}function R0(n,a,l){if(a.count++,a.instance===null)switch(a.type){case"style":var d=n.querySelector('style[data-href~="'+pe(l.href)+'"]');if(d)return a.instance=d,un(d),d;var y=g({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return d=(n.ownerDocument||n).createElement("style"),un(d),Kn(d,"style",y),Lc(d,l.precedence,n),a.instance=d;case"stylesheet":y=_i(l.href);var v=n.querySelector($l(y));if(v)return a.state.loading|=4,a.instance=v,un(v),v;d=O0(l),(y=Vr.get(y))&&Qf(d,y),v=(n.ownerDocument||n).createElement("link"),un(v);var O=v;return O._p=new Promise(function(J,se){O.onload=J,O.onerror=se}),Kn(v,"link",d),a.state.loading|=4,Lc(v,l.precedence,n),a.instance=v;case"script":return v=Ai(l.src),(y=n.querySelector(Bl(v)))?(a.instance=y,un(y),y):(d=l,(y=Vr.get(v))&&(d=g({},l),Kf(d,y)),n=n.ownerDocument||n,y=n.createElement("script"),un(y),Kn(y,"link",d),n.head.appendChild(y),a.instance=y);case"void":return null;default:throw Error(i(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(d=a.instance,a.state.loading|=4,Lc(d,l.precedence,n));return a.instance}function Lc(n,a,l){for(var d=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=d.length?d[d.length-1]:null,v=y,O=0;O<d.length;O++){var J=d[O];if(J.dataset.precedence===a)v=J;else if(v!==y)break}v?v.parentNode.insertBefore(n,v.nextSibling):(a=l.nodeType===9?l.head:l,a.insertBefore(n,a.firstChild))}function Qf(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.title==null&&(n.title=a.title)}function Kf(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.integrity==null&&(n.integrity=a.integrity)}var Ic=null;function z0(n,a,l){if(Ic===null){var d=new Map,y=Ic=new Map;y.set(l,d)}else y=Ic,d=y.get(l),d||(d=new Map,y.set(l,d));if(d.has(n))return d;for(d.set(n,null),l=l.getElementsByTagName(n),y=0;y<l.length;y++){var v=l[y];if(!(v[Nn]||v[cn]||n==="link"&&v.getAttribute("rel")==="stylesheet")&&v.namespaceURI!=="http://www.w3.org/2000/svg"){var O=v.getAttribute(a)||"";O=n+O;var J=d.get(O);J?J.push(v):d.set(O,[v])}}return d}function L0(n,a,l){n=n.ownerDocument||n,n.head.insertBefore(l,a==="title"?n.querySelector("head > title"):null)}function s2(n,a,l){if(l===1||a.itemProp!=null)return!1;switch(n){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"?(n=a.disabled,typeof a.precedence=="string"&&n==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 I0(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function a2(n,a,l,d){if(l.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var y=_i(d.href),v=a.querySelector($l(y));if(v){a=v._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(n.count++,n=$c.bind(n),a.then(n,n)),l.state.loading|=4,l.instance=v,un(v);return}v=a.ownerDocument||a,d=O0(d),(y=Vr.get(y))&&Qf(d,y),v=v.createElement("link"),un(v);var O=v;O._p=new Promise(function(J,se){O.onload=J,O.onerror=se}),Kn(v,"link",d),l.instance=v}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(l,a),(a=l.state.preload)&&(l.state.loading&3)===0&&(n.count++,l=$c.bind(n),a.addEventListener("load",l),a.addEventListener("error",l))}}var Jf=0;function i2(n,a){return n.stylesheets&&n.count===0&&Hc(n,n.stylesheets),0<n.count||0<n.imgCount?function(l){var d=setTimeout(function(){if(n.stylesheets&&Hc(n,n.stylesheets),n.unsuspend){var v=n.unsuspend;n.unsuspend=null,v()}},6e4+a);0<n.imgBytes&&Jf===0&&(Jf=62500*H5());var y=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&Hc(n,n.stylesheets),n.unsuspend)){var v=n.unsuspend;n.unsuspend=null,v()}},(n.imgBytes>Jf?50:800)+a);return n.unsuspend=l,function(){n.unsuspend=null,clearTimeout(d),clearTimeout(y)}}:null}function $c(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Hc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Bc=null;function Hc(n,a){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Bc=new Map,a.forEach(l2,n),Bc=null,$c.call(n))}function l2(n,a){if(!(a.state.loading&4)){var l=Bc.get(n);if(l)var d=l.get(null);else{l=new Map,Bc.set(n,l);for(var y=n.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v<y.length;v++){var O=y[v];(O.nodeName==="LINK"||O.getAttribute("media")!=="not all")&&(l.set(O.dataset.precedence,O),d=O)}d&&l.set(null,d)}y=a.instance,O=y.getAttribute("data-precedence"),v=l.get(O)||d,v===d&&l.set(null,y),l.set(O,y),this.count++,d=$c.bind(this),y.addEventListener("load",d),y.addEventListener("error",d),v?v.parentNode.insertBefore(y,v.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(y,n.firstChild)),a.state.loading|=4}}var Hl={$$typeof:N,Provider:null,Consumer:null,_currentValue:U,_currentValue2:U,_threadCount:0};function o2(n,a,l,d,y,v,O,J,se){this.tag=1,this.containerInfo=n,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=$e(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$e(0),this.hiddenUpdates=$e(null),this.identifierPrefix=d,this.onUncaughtError=y,this.onCaughtError=v,this.onRecoverableError=O,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=se,this.incompleteTransitions=new Map}function $0(n,a,l,d,y,v,O,J,se,me,Ce,Te){return n=new o2(n,a,l,O,se,me,Ce,Te,J),a=1,v===!0&&(a|=24),v=Nr(3,null,null,a),n.current=v,v.stateNode=n,a=Ad(),a.refCount++,n.pooledCache=a,a.refCount++,v.memoizedState={element:d,isDehydrated:l,cache:a},Rd(v),n}function B0(n){return n?(n=li,n):li}function H0(n,a,l,d,y,v){y=B0(y),d.context===null?d.context=y:d.pendingContext=y,d=Zs(a),d.payload={element:l},v=v===void 0?null:v,v!==null&&(d.callback=v),l=Qs(n,d,a),l!==null&&(xr(l,n,a),bl(l,n,a))}function P0(n,a){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<a?l:a}}function Wf(n,a){P0(n,a),(n=n.alternate)&&P0(n,a)}function U0(n){if(n.tag===13||n.tag===31){var a=Aa(n,67108864);a!==null&&xr(a,n,67108864),Wf(n,67108864)}}function q0(n){if(n.tag===13||n.tag===31){var a=Tr();a=Dt(a);var l=Aa(n,a);l!==null&&xr(l,n,a),Wf(n,a)}}var Pc=!0;function c2(n,a,l,d){var y=A.T;A.T=null;var v=G.p;try{G.p=2,eh(n,a,l,d)}finally{G.p=v,A.T=y}}function u2(n,a,l,d){var y=A.T;A.T=null;var v=G.p;try{G.p=8,eh(n,a,l,d)}finally{G.p=v,A.T=y}}function eh(n,a,l,d){if(Pc){var y=th(d);if(y===null)Hf(n,a,d,Uc,l),F0(n,d);else if(f2(y,n,a,l,d))d.stopPropagation();else if(F0(n,d),a&4&&-1<d2.indexOf(n)){for(;y!==null;){var v=Or(y);if(v!==null)switch(v.tag){case 3:if(v=v.stateNode,v.current.memoizedState.isDehydrated){var O=rn(v.pendingLanes);if(O!==0){var J=v;for(J.pendingLanes|=2,J.entangledLanes|=2;O;){var se=1<<31-Be(O);J.entanglements[1]|=se,O&=~se}ls(v),(Qt&6)===0&&(kc=Ct()+500,Rl(0))}}break;case 31:case 13:J=Aa(v,2),J!==null&&xr(J,v,2),Cc(),Wf(v,2)}if(v=th(d),v===null&&Hf(n,a,d,Uc,l),v===y)break;y=v}y!==null&&d.stopPropagation()}else Hf(n,a,d,null,l)}}function th(n){return n=ot(n),nh(n)}var Uc=null;function nh(n){if(Uc=null,n=ir(n),n!==null){var a=c(n);if(a===null)n=null;else{var l=a.tag;if(l===13){if(n=u(a),n!==null)return n;n=null}else if(l===31){if(n=f(a),n!==null)return n;n=null}else if(l===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;n=null}else a!==n&&(n=null)}}return Uc=n,null}function V0(n){switch(n){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(Ft()){case be:return 2;case Me:return 8;case Ve:case Xe:return 32;case rt:return 268435456;default:return 32}default:return 32}}var rh=!1,la=null,oa=null,ca=null,Pl=new Map,Ul=new Map,ua=[],d2="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 F0(n,a){switch(n){case"focusin":case"focusout":la=null;break;case"dragenter":case"dragleave":oa=null;break;case"mouseover":case"mouseout":ca=null;break;case"pointerover":case"pointerout":Pl.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ul.delete(a.pointerId)}}function ql(n,a,l,d,y,v){return n===null||n.nativeEvent!==v?(n={blockedOn:a,domEventName:l,eventSystemFlags:d,nativeEvent:v,targetContainers:[y]},a!==null&&(a=Or(a),a!==null&&U0(a)),n):(n.eventSystemFlags|=d,a=n.targetContainers,y!==null&&a.indexOf(y)===-1&&a.push(y),n)}function f2(n,a,l,d,y){switch(a){case"focusin":return la=ql(la,n,a,l,d,y),!0;case"dragenter":return oa=ql(oa,n,a,l,d,y),!0;case"mouseover":return ca=ql(ca,n,a,l,d,y),!0;case"pointerover":var v=y.pointerId;return Pl.set(v,ql(Pl.get(v)||null,n,a,l,d,y)),!0;case"gotpointercapture":return v=y.pointerId,Ul.set(v,ql(Ul.get(v)||null,n,a,l,d,y)),!0}return!1}function Y0(n){var a=ir(n.target);if(a!==null){var l=c(a);if(l!==null){if(a=l.tag,a===13){if(a=u(l),a!==null){n.blockedOn=a,On(n.priority,function(){q0(l)});return}}else if(a===31){if(a=f(l),a!==null){n.blockedOn=a,On(n.priority,function(){q0(l)});return}}else if(a===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function qc(n){if(n.blockedOn!==null)return!1;for(var a=n.targetContainers;0<a.length;){var l=th(n.nativeEvent);if(l===null){l=n.nativeEvent;var d=new l.constructor(l.type,l);Ge=d,l.target.dispatchEvent(d),Ge=null}else return a=Or(l),a!==null&&U0(a),n.blockedOn=l,!1;a.shift()}return!0}function G0(n,a,l){qc(n)&&l.delete(a)}function h2(){rh=!1,la!==null&&qc(la)&&(la=null),oa!==null&&qc(oa)&&(oa=null),ca!==null&&qc(ca)&&(ca=null),Pl.forEach(G0),Ul.forEach(G0)}function Vc(n,a){n.blockedOn===a&&(n.blockedOn=null,rh||(rh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,h2)))}var Fc=null;function X0(n){Fc!==n&&(Fc=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Fc===n&&(Fc=null);for(var a=0;a<n.length;a+=3){var l=n[a],d=n[a+1],y=n[a+2];if(typeof d!="function"){if(nh(d||l)===null)continue;break}var v=Or(l);v!==null&&(n.splice(a,3),a-=3,ef(v,{pending:!0,data:y,method:l.method,action:d},d,y))}}))}function Mi(n){function a(se){return Vc(se,n)}la!==null&&Vc(la,n),oa!==null&&Vc(oa,n),ca!==null&&Vc(ca,n),Pl.forEach(a),Ul.forEach(a);for(var l=0;l<ua.length;l++){var d=ua[l];d.blockedOn===n&&(d.blockedOn=null)}for(;0<ua.length&&(l=ua[0],l.blockedOn===null);)Y0(l),l.blockedOn===null&&ua.shift();if(l=(n.ownerDocument||n).$$reactFormReplay,l!=null)for(d=0;d<l.length;d+=3){var y=l[d],v=l[d+1],O=y[wn]||null;if(typeof v=="function")O||X0(l);else if(O){var J=null;if(v&&v.hasAttribute("formAction")){if(y=v,O=v[wn]||null)J=O.formAction;else if(nh(y)!==null)continue}else J=O.action;typeof J=="function"?l[d+1]=J:(l.splice(d,3),d-=3),X0(l)}}}function Z0(){function n(v){v.canIntercept&&v.info==="react-transition"&&v.intercept({handler:function(){return new Promise(function(O){return y=O})},focusReset:"manual",scroll:"manual"})}function a(){y!==null&&(y(),y=null),d||setTimeout(l,20)}function l(){if(!d&&!navigation.transition){var v=navigation.currentEntry;v&&v.url!=null&&navigation.navigate(v.url,{state:v.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var d=!1,y=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(l,100),function(){d=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),y!==null&&(y(),y=null)}}}function sh(n){this._internalRoot=n}Yc.prototype.render=sh.prototype.render=function(n){var a=this._internalRoot;if(a===null)throw Error(i(409));var l=a.current,d=Tr();H0(l,d,n,a,null,null)},Yc.prototype.unmount=sh.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var a=n.containerInfo;H0(n.current,2,null,n,null,null),Cc(),a[qn]=null}};function Yc(n){this._internalRoot=n}Yc.prototype.unstable_scheduleHydration=function(n){if(n){var a=Un();n={blockedOn:null,target:n,priority:a};for(var l=0;l<ua.length&&a!==0&&a<ua[l].priority;l++);ua.splice(l,0,n),l===0&&Y0(n)}};var Q0=r.version;if(Q0!=="19.2.4")throw Error(i(527,Q0,"19.2.4"));G.findDOMNode=function(n){var a=n._reactInternals;if(a===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=h(a),n=n!==null?x(n):null,n=n===null?null:n.stateNode,n};var m2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Gc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Gc.isDisabled&&Gc.supportsFiber)try{_t=Gc.inject(m2),wt=Gc}catch{}}return Fl.createRoot=function(n,a){if(!o(n))throw Error(i(299));var l=!1,d="",y=rp,v=sp,O=ap;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(d=a.identifierPrefix),a.onUncaughtError!==void 0&&(y=a.onUncaughtError),a.onCaughtError!==void 0&&(v=a.onCaughtError),a.onRecoverableError!==void 0&&(O=a.onRecoverableError)),a=$0(n,1,!1,null,null,l,d,null,y,v,O,Z0),n[qn]=a.current,Bf(n),new sh(a)},Fl.hydrateRoot=function(n,a,l){if(!o(n))throw Error(i(299));var d=!1,y="",v=rp,O=sp,J=ap,se=null;return l!=null&&(l.unstable_strictMode===!0&&(d=!0),l.identifierPrefix!==void 0&&(y=l.identifierPrefix),l.onUncaughtError!==void 0&&(v=l.onUncaughtError),l.onCaughtError!==void 0&&(O=l.onCaughtError),l.onRecoverableError!==void 0&&(J=l.onRecoverableError),l.formState!==void 0&&(se=l.formState)),a=$0(n,1,!0,a,l??null,d,y,se,v,O,J,Z0),a.context=B0(null),l=a.current,d=Tr(),d=Dt(d),y=Zs(d),y.callback=null,Qs(l,y,d),l=d,a.current.lanes=l,st(a,l),ls(a),n[qn]=a.current,Bf(n),new Yc(a)},Fl.version="19.2.4",Fl}var ib;function k2(){if(ib)return lh.exports;ib=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(r){console.error(r)}}return e(),lh.exports=N2(),lh.exports}var S2=k2();const Kh="/api";async function fe(e,r){const s=await fetch(`${Kh}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...r,body:r?.body?typeof r.body=="string"?r.body:JSON.stringify(r.body):void 0});if(!s.ok){let i="";try{const o=await s.json();i=o.error??o.message??""}catch{}throw new Error(i||`API error: ${s.status}`)}return s.json()}const ae={agents:{list:()=>fe("/agents"),get:e=>fe(`/agents/${e}`),create:(e,r,s,i)=>fe("/agents",{method:"POST",body:JSON.stringify({name:e,roleName:r,agentRole:s,teamId:i})}),start:e=>fe(`/agents/${e}/start`,{method:"POST"}),stop:e=>fe(`/agents/${e}/stop`,{method:"POST"}),remove:(e,r)=>fe(`/agents/${e}${r?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,r)=>fe(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(r)}),getMemory:e=>fe(`/agents/${e}/memory`),getMemorySession:(e,r)=>fe(`/agents/${e}/memory/sessions/${encodeURIComponent(r)}`),updateDailyMemory:(e,r)=>fe(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:r})}),updateLongTermMemory:(e,r,s)=>fe(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:r,content:s})}),getFiles:e=>fe(`/agents/${e}/files`),getFilesMap:e=>fe(`/agents/${e}/files`),updateFile:(e,r,s)=>fe(`/agents/${e}/files/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,r)=>fe(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:r})}),roleStatus:e=>fe(`/agents/${e}/role-status`),roleDiff:(e,r="ROLE.md")=>fe(`/agents/${e}/role-diff?file=${encodeURIComponent(r)}`),roleSync:(e,r)=>fe(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(r?{files:r}:{})}),roleUpdates:()=>fe("/agents/role-updates"),addSkill:(e,r)=>fe(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:r})}),removeSkill:(e,r)=>fe(`/agents/${e}/skills/${encodeURIComponent(r)}`,{method:"DELETE"}),getHeartbeat:e=>fe(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>fe(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),getRecentActivities:e=>fe(`/agents/${e}/recent-activities`),getActivityLogs:(e,r)=>fe(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(r)}`),getActivities:(e,r)=>{const s=new URLSearchParams;r?.type&&s.set("type",r.type),r?.limit&&s.set("limit",String(r.limit)),r?.before&&s.set("before",r.before);const i=s.toString();return fe(`/agents/${e}/activities${i?"?"+i:""}`)},message:(e,r,s,i)=>fe(`/agents/${e}/message`,{method:"POST",body:JSON.stringify({text:r,images:s,sessionId:i??void 0})}),messageStream:(e,r,s,i,o,c,u)=>new Promise(async(f,m)=>{let h="",x;try{const g=await fetch(`${Kh}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:r,stream:!0,images:c,sessionId:u??void 0}),signal:o});if(!g.ok){m(new Error(`API error: ${g.status}`));return}const b=g.body?.getReader();if(!b){m(new Error("No reader"));return}const p=new TextDecoder;let w="";for(;;){const{done:S,value:T}=await b.read();if(S)break;w+=p.decode(T,{stream:!0});const E=w.split(`
|
|
10
|
-
`);w=E.pop()??"";for(const C of E){const N=C.trim();if(N.startsWith("data: "))try{const k=JSON.parse(N.slice(6));if(k.type==="text_delta"&&k.text)h+=k.text,s(k.text);else if(k.type==="thinking_delta"&&k.thinking)s?.(`<think>${k.thinking}</think>`);else if(k.type==="done")h=k.content??h,k.sessionId&&(x=k.sessionId);else if(k.type==="error"){const H=k;H.sessionId&&(x=H.sessionId);const M=new Error(H.message??H.error??"Unknown stream error");M.sessionId=H.sessionId,m(M),b.cancel().catch(()=>{});return}else k.type==="tool_call_start"&&k.toolCall?.name?i?.({tool:k.toolCall.name,phase:"start"}):k.type==="agent_tool"&&k.tool&&k.phase?k.phase==="start"?i?.({tool:k.tool,phase:"start",arguments:k.arguments}):k.phase==="end"&&i?.({tool:k.tool,phase:"end",success:k.success,arguments:k.arguments,result:k.result,error:k.error,durationMs:k.durationMs}):k.type==="tool_output"&&k.tool&&i?.({tool:k.tool,phase:"output",output:k.text})}catch{}}}f({content:h,sessionId:x})}catch(g){g instanceof Error&&g.name==="AbortError"?f({content:h,sessionId:x}):m(g)}})},roles:{list:()=>fe("/roles")},teams:{list:e=>fe(`/teams?orgId=${e??"default"}`),create:(e,r)=>fe("/teams",{method:"POST",body:JSON.stringify({name:e,description:r})}),update:(e,r)=>fe(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(r)}),delete:(e,r,s)=>fe(`/teams/${e}?deleteMembers=${r?"true":"false"}${s?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,r,s)=>fe(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:r,memberType:s})}),removeMember:(e,r)=>fe(`/teams/${e}/members/${r}`,{method:"DELETE"}),startAll:e=>fe(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>fe(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,r)=>fe(`/teams/${e}/pause`,{method:"POST",body:JSON.stringify({reason:r})}),resumeAll:e=>fe(`/teams/${e}/resume`,{method:"POST"}),status:e=>fe(`/teams/${e}/status`),getFiles:e=>fe(`/teams/${e}/files`),getFile:(e,r)=>fe(`/teams/${e}/files/${encodeURIComponent(r)}`),updateFile:(e,r,s)=>fe(`/teams/${e}/files/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({content:s})}),exportTeam:e=>fe(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>fe(`/teams/${e}/export`)},externalAgents:{list:e=>fe(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const r=new URLSearchParams;e?.assignedAgentId&&r.set("assignedAgentId",e.assignedAgentId),e?.status&&r.set("status",e.status),e?.projectId&&r.set("projectId",e.projectId);const s=r.toString();return fe(`/tasks${s?`?${s}`:""}`)},get:e=>fe(`/tasks/${e}`),create:(e,r,s,i,o,c,u,f,m,h)=>fe("/tasks",{method:"POST",body:JSON.stringify({title:e,description:r,assignedAgentId:s,reviewerAgentId:i,priority:o,projectId:c,blockedBy:u,requirementId:f,taskType:m,scheduleConfig:h})}),update:(e,r)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(r)}),updateStatus:(e,r)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:r})}),assign:(e,r)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:r})}),approve:e=>fe(`/tasks/${e}/approve`,{method:"POST"}),reject:e=>fe(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,r=!1)=>fe(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:r})}),getDependentCount:e=>fe(`/tasks/${e}/dependents`),board:e=>{const r=new URLSearchParams;e?.projectId&&r.set("projectId",e.projectId);const s=r.toString();return fe(`/taskboard${s?`?${s}`:""}`)},listSubtasks:e=>fe(`/tasks/${e}/subtasks`),createSubtask:(e,r)=>fe(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:r})}),completeSubtask:(e,r)=>fe(`/tasks/${e}/subtasks/${r}/complete`,{method:"POST"}),cancelSubtask:(e,r)=>fe(`/tasks/${e}/subtasks/${r}/cancel`,{method:"POST"}),deleteSubtask:(e,r)=>fe(`/tasks/${e}/subtasks/${r}`,{method:"DELETE"}),run:e=>fe(`/tasks/${e}/run`,{method:"POST"}),getLogs:e=>fe(`/tasks/${e}/logs`),accept:(e,r)=>fe(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerAgentId:r??"human"})}),revision:(e,r,s)=>fe(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:r,reviewerAgentId:s??"human"})}),archive:e=>fe(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>fe(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>fe(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>fe(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>fe(`/tasks/${e}/comments`),addComment:(e,r,s,i,o)=>fe(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:r,authorId:o??"human",authorName:s??"User",authorType:"human",attachments:i})}),pauseSchedule:e=>fe(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>fe(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>fe(`/tasks/${e}/schedule/run-now`,{method:"POST"}),deliverables:e=>{const r=e?`?projectId=${encodeURIComponent(e)}`:"";return fe(`/tasks/deliverables${r}`)}},files:{preview:e=>fe(`/files/preview?path=${encodeURIComponent(e)}`),reveal:e=>fe("/files/reveal",{method:"POST",body:JSON.stringify({path:e})})},requirements:{list:e=>{const r=new URLSearchParams;e?.orgId&&r.set("orgId",e.orgId),e?.status&&r.set("status",e.status),e?.source&&r.set("source",e.source),e?.projectId&&r.set("projectId",e.projectId);const s=r.toString();return fe(`/requirements${s?`?${s}`:""}`)},get:e=>fe(`/requirements/${e}`),create:e=>fe("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,r)=>fe(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(r)}),updateStatus:(e,r)=>fe(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:r})}),approve:e=>fe(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,r)=>fe(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:r})}),delete:e=>fe(`/requirements/${e}`,{method:"DELETE"})},users:{list:e=>fe(`/users?orgId=${e??"default"}`),create:(e,r,s,i,o,c)=>fe("/users",{method:"POST",body:JSON.stringify({name:e,role:r,orgId:s,email:i,password:o,teamId:c})}),remove:e=>fe(`/users/${e}`,{method:"DELETE"})},message:{send:(e,r)=>fe("/message",{method:"POST",body:JSON.stringify({text:e,...r})}),sendStream:(e,r,s,i)=>new Promise(async(o,c)=>{let u="",f="";try{const{signal:m,...h}=s??{},x=await fetch(`${Kh}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:e,stream:!0,...h}),signal:m});if(!x.ok){c(new Error(`API error: ${x.status}`));return}const g=x.body?.getReader();if(!g){c(new Error("No reader"));return}const b=new TextDecoder;let p="";for(;;){const{done:w,value:S}=await g.read();if(w)break;p+=b.decode(S,{stream:!0});const T=p.split(`
|
|
11
|
-
`);p=T.pop()??"";for(const E of T){const C=E.trim();if(C.startsWith("data: "))try{const N=JSON.parse(C.slice(6));if(N.type==="text_delta"&&N.text)u+=N.text,r(N.text);else if(N.type==="thinking_delta"&&N.thinking)r(`<think>${N.thinking}</think>`);else if(N.type==="done")u=N.content??u,f=N.agentId??f;else if(N.type==="error"){const k=N,H=new Error(k.message??k.error??"Unknown stream error");H.sessionId=k.sessionId,c(H),g.cancel().catch(()=>{});return}else N.type==="tool_call_start"&&N.toolCall?.name?i?.({tool:N.toolCall.name,phase:"start"}):N.type==="agent_tool"&&N.tool&&N.phase?N.phase==="start"?i?.({tool:N.tool,phase:"start",arguments:N.arguments}):N.phase==="end"&&i?.({tool:N.tool,phase:"end",success:N.success,arguments:N.arguments,result:N.result,error:N.error,durationMs:N.durationMs}):N.type==="tool_output"&&N.tool&&i?.({tool:N.tool,phase:"output",output:N.text})}catch{}}}o({content:u,agentId:f})}catch(m){m instanceof Error&&m.name==="AbortError"?o({content:u,agentId:f}):c(m)}})},teamTemplates:{list:e=>{const r=e?`?q=${encodeURIComponent(e)}`:"";return fe(`/team-templates${r}`)},get:e=>fe(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>fe(`/ops/dashboard?period=${e}`)},agentMetrics:(e,r="24h")=>fe(`/agents/${e}/metrics?period=${r}`),usage:{summary:(e="default",r)=>{const s=new URLSearchParams({orgId:e});return r&&s.set("period",r),fe(`/usage?${s}`)},agents:(e="default")=>fe(`/usage/agents?orgId=${e}`)},health:()=>fe("/health"),system:{openPath:e=>fe("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>fe("/system/storage"),orphans:()=>fe("/system/storage/orphans"),purgeOrphans:e=>fe("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},settings:{getLlm:()=>fe("/settings/llm")},skills:{list:()=>fe("/skills"),builtin:()=>fe("/skills/builtin"),registry:e=>fe(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const r=new URLSearchParams;e?.q&&r.set("q",e.q),e?.category&&r.set("category",e.category),e?.page&&r.set("page",String(e.page)),e?.limit&&r.set("limit",String(e.limit)),e?.sort&&r.set("sort",e.sort);const s=r.toString();return fe(`/skills/registry/skillhub${s?`?${s}`:""}`)},registrySkillssh:e=>fe(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,r,s,i)=>fe("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:r,description:s,category:i})}),install:e=>fe("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>fe(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>fe(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>fe("/builder/artifacts"),get:(e,r)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(r)}`),save:(e,r)=>fe("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:r})}),import:(e,r,s,i)=>fe("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:r,files:s,source:i})}),install:(e,r)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(r)}/install`,{method:"POST"}),uninstall:(e,r)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(r)}/uninstall`,{method:"POST"}),delete:(e,r)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(r)}`,{method:"DELETE"}),installed:()=>fe("/builder/artifacts/installed")}},auth:{login:(e,r)=>fe("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:r})}),logout:()=>fe("/auth/logout",{method:"POST"}),me:()=>fe("/auth/me"),changePassword:(e,r)=>fe("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:r})})},sessions:{listByAgent:(e,r=20)=>fe(`/agents/${e}/sessions?limit=${r}`),getMessages:(e,r=50,s)=>fe(`/sessions/${e}/messages?limit=${r}${s?`&before=${s}`:""}`),delete:e=>fe(`/sessions/${e}`,{method:"DELETE"})},channels:{getMessages:(e,r=50,s)=>fe(`/channels/${encodeURIComponent(e)}/messages?limit=${r}${s?`&before=${s}`:""}`),sendMessage:(e,r)=>fe(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(r)})},promptStudio:{list:(e,r)=>{const s=new URLSearchParams;e&&s.set("category",e),r&&s.set("q",r);const i=s.toString();return fe(`/prompts${i?`?${i}`:""}`)},get:e=>fe(`/prompts/${e}`),create:e=>fe("/prompts",{method:"POST",body:JSON.stringify(e)}),delete:e=>fe(`/prompts/${e}`,{method:"DELETE"}),addVersion:(e,r,s)=>fe(`/prompts/${e}/versions`,{method:"POST",body:JSON.stringify({content:r,changelog:s})}),render:(e,r,s)=>fe(`/prompts/${e}/render`,{method:"POST",body:JSON.stringify({variables:r,version:s})}),evaluate:(e,r,s,i)=>fe(`/prompts/${e}/evaluate`,{method:"POST",body:JSON.stringify({version:r,testInput:s,variables:i})}),getEvaluations:(e,r)=>{const s=r!==void 0?`?version=${r}`:"";return fe(`/prompts/${e}/evaluations${s}`)},getEvaluationSummary:(e,r)=>fe(`/prompts/${e}/evaluation-summary?version=${r}`),scoreEvaluation:(e,r,s)=>fe(`/prompts/evaluations/${e}/score`,{method:"POST",body:JSON.stringify({score:r,notes:s})}),listABTests:e=>{const r=e?`?promptId=${e}`:"";return fe(`/prompts/ab-tests${r}`)},createABTest:e=>fe("/prompts/ab-tests",{method:"POST",body:JSON.stringify(e)}),startABTest:e=>fe(`/prompts/ab-tests/${e}/start`,{method:"POST"}),completeABTest:e=>fe(`/prompts/ab-tests/${e}/complete`,{method:"POST"}),recordABResult:(e,r,s)=>fe(`/prompts/ab-tests/${e}/record`,{method:"POST",body:JSON.stringify({variant:r,score:s})}),getABTestResults:e=>fe(`/prompts/ab-tests/${e}/results`)},governance:{getSystemStatus:()=>fe("/system/status"),pauseAll:e=>fe("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>fe("/system/resume-all",{method:"POST"}),emergencyStop:e=>fe("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>fe("/system/announcements"),createAnnouncement:e=>fe("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>fe("/governance/policy"),setPolicy:e=>fe("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},projects:{list:e=>{const r=e?`?orgId=${e}`:"";return fe(`/projects${r}`)},get:e=>fe(`/projects/${e}`),create:e=>fe("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,r)=>fe(`/projects/${e}`,{method:"PUT",body:JSON.stringify(r)}),delete:e=>fe(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,r,s)=>{const i=new URLSearchParams;return e&&i.set("query",e),r&&i.set("scope",r),s&&i.set("category",s),fe(`/knowledge/search?${i}`)},contribute:e=>fe("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,r)=>fe(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:r})}),verify:e=>fe(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>fe(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const r=new URLSearchParams;return e?.q&&r.set("q",e.q),e?.projectId&&r.set("projectId",e.projectId),e?.agentId&&r.set("agentId",e.agentId),e?.taskId&&r.set("taskId",e.taskId),e?.type&&r.set("type",e.type),e?.status&&r.set("status",e.status),e?.artifactType&&r.set("artifactType",e.artifactType),e?.offset&&r.set("offset",String(e.offset)),e?.limit&&r.set("limit",String(e.limit)),fe(`/deliverables?${r}`)},create:e=>fe("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,r)=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(r)}),remove:e=>fe(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})})},reports:{list:()=>fe("/reports"),get:e=>fe(`/reports/${e}`),generate:e=>fe("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,r)=>fe(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(r)}),rejectPlan:(e,r)=>fe(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(r)}),addFeedback:(e,r)=>fe(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(r)}),getFeedback:e=>fe(`/reports/${e}/feedback`)}};class C2{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`,i=new WebSocket(s);this.ws=i,i.onmessage=o=>{if(this.ws===i)try{const c=JSON.parse(o.data),u=this.handlers.get(c.type);if(u)for(const m of u)m(c);const f=this.handlers.get("*");if(f)for(const m of f)m(c)}catch{}},i.onclose=()=>{this.intentionalClose||(this.reconnectTimer=setTimeout(()=>this.connect(),3e3))},i.onerror=()=>{i.close()}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(r,s){return this.handlers.has(r)||this.handlers.set(r,new Set),this.handlers.get(r).add(s),()=>this.handlers.get(r)?.delete(s)}}const En=new C2;let xo=window.__MARKUS_HUB_URL__??"https://markus.global";fe("/settings/hub").then(e=>{e.hubUrl&&(xo=e.hubUrl);const r=localStorage.getItem("markus_hub_token");r&&fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:r})}).catch(()=>{})}).catch(()=>{});const Am="markus_hub_token",Mm="markus_hub_user";function va(){return localStorage.getItem(Am)}function E2(){try{const e=localStorage.getItem(Mm);return e?JSON.parse(e):null}catch{return null}}function Vv(){localStorage.removeItem(Am),localStorage.removeItem(Mm),Fv(null)}function Jh(e,r){localStorage.setItem(Am,e),localStorage.setItem(Mm,JSON.stringify(r)),Fv(e)}function Fv(e){fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}let Yl=null;function fa(){if(va())return Promise.resolve();if(Yl)return Yl;const e=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`;return Yl=new Promise((r,s)=>{const i=`${xo}/auth/connect?session=${encodeURIComponent(e)}`,o=460,c=580,u=Math.round(window.screenX+(window.outerWidth-o)/2),f=Math.round(window.screenY+(window.outerHeight-c)/2),m=window.open(i,"markus_hub_auth",`popup=yes,width=${o},height=${c},left=${u},top=${f}`);let h=!1;const x=()=>{clearInterval(g),clearInterval(b),Yl=null},g=setInterval(async()=>{if(!h)try{const w=await(await fetch(`${xo}/api/auth/connect-status?session=${encodeURIComponent(e)}`)).json();w.ready&&w.token&&w.user&&(h=!0,Jh(w.token,w.user),x(),m?.close(),r())}catch{}},1500),b=setInterval(()=>{h||m?.closed&&(h=!0,x(),va()?r():s(new Error("Hub login cancelled")))},500)}),Yl}async function Fr(e,r){const s=va(),i={"Content-Type":"application/json",...r?.headers};s&&(i.Authorization=`Bearer ${s}`);const o=await fetch(`${xo}/api${e}`,{...r,headers:i}),c=await o.json();if(o.status===401&&s&&Vv(),!o.ok)throw new Error(c.error??`Hub HTTP ${o.status}`);return c}const Bn={getUrl:()=>xo,isAuthenticated:()=>!!va(),getUser:E2,logout:()=>{Vv()},ensureAuth:fa,login:async(e,r)=>{const s=await Fr("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:r})});return Jh(s.token,s.user),s},register:async(e,r,s)=>{const i=await Fr("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:r,password:s})});return Jh(i.token,i.user),i},search:e=>{const r=new URLSearchParams;e?.type&&r.set("type",e.type),e?.q&&r.set("q",e.q),e?.category&&r.set("category",e.category),e?.sort&&r.set("sort",e.sort),e?.page&&r.set("page",String(e.page)),e?.limit&&r.set("limit",String(e.limit));const s=r.toString();return Fr(`/items${s?`?${s}`:""}`)},getItem:e=>Fr(`/items/${e}`),download:async e=>{await fa();try{return await Fr(`/items/${e}/download`,{method:"POST"})}catch(r){if(!va())return await fa(),Fr(`/items/${e}/download`,{method:"POST"});throw r}},publish:async e=>{await fa();try{return await Fr("/items",{method:"POST",body:JSON.stringify(e)})}catch(r){if(!va())return await fa(),Fr("/items",{method:"POST",body:JSON.stringify(e)});throw r}},publishViaProxy:async e=>{await fa();try{return await Fr("/items",{method:"POST",body:JSON.stringify(e)})}catch(r){if(!va())return await fa(),Fr("/items",{method:"POST",body:JSON.stringify(e)});throw r}},myItems:async()=>va()?Fr("/items/mine"):{items:[]},deleteItem:async e=>(await fa(),Fr(`/items/${e}`,{method:"DELETE"}))};let lb=null;const Ut={setHandler(e){lb=e},navigate(e,r){r&&Object.entries(r).forEach(([s,i])=>localStorage.setItem(`markus_nav_${s}`,i)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:r}})),lb?.(e,r)}};function ob(){const[e,r]=j.useState([]),[s,i]=j.useState([]),[o,c]=j.useState({}),[u,f]=j.useState(null),[m,h]=j.useState("24h"),[x,g]=j.useState([]),[b,p]=j.useState(null),w=()=>{ae.agents.list().then($=>r($.agents)).catch(()=>{}),ae.teams.list().then($=>i($.teams)).catch(()=>{}),ae.tasks.board().then($=>c($.board)).catch(()=>{}),ae.ops.dashboard(m).then(f).catch(()=>{}),ae.requirements.list({source:"agent"}).then($=>{g($.requirements.filter(X=>X.status==="draft"||X.status==="pending_review"))}).catch(()=>{}),ae.system.storage().then(p).catch(()=>{})};j.useEffect(()=>{w();const $=setInterval(w,3e4),X=()=>w();return window.addEventListener("markus:data-changed",X),()=>{clearInterval($),window.removeEventListener("markus:data-changed",X)}},[m]);const S=$=>$,T={};for(const[$,X]of Object.entries(o)){const P=S(X).length;P>0&&(T[$]=P)}const E=T.pending_approval??0,C=T.in_progress??0,N=T.completed??0;T.failed;const k=Object.values(T).reduce(($,X)=>$+X,0),H=e.filter($=>$.status==="idle"||$.status==="working").length,M=e.filter($=>$.status==="working").length,Y=j.useMemo(()=>{const $=new Map(e.map(X=>[X.id,X]));return s.map(X=>{const P=X.members.filter(D=>D.type==="agent").map(D=>$.get(D.id)).filter(D=>!!D),q=P.filter(D=>D.status==="working").length,F=P.filter(D=>D.status==="idle"||D.status==="working").length;return{team:X,agents:P,working:q,active:F,total:P.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.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Overview"}),t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["1h","24h","7d"].map($=>t.jsx("button",{onClick:()=>h($),className:`px-2.5 py-1 text-xs rounded-md transition-colors ${m===$?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:$},$))})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:()=>Ut.navigate("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(Xc,{label:"Active Agents",value:H,total:e.length,color:"indigo",onClick:()=>Ut.navigate("team")}),t.jsx(Xc,{label:"Tasks In Progress",value:C,color:"blue",onClick:()=>Ut.navigate("tasks")}),t.jsx(Xc,{label:"Pending Queue",value:E,color:"amber",onClick:()=>Ut.navigate("tasks")}),t.jsx(Xc,{label:"Completed",value:N,total:k>0?k:void 0,color:"green",onClick:()=>Ut.navigate("tasks")})]}),k===0&&(!u||u.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:"Getting Started"}),t.jsx("p",{className:"text-xs text-fg-secondary mb-4",children:"Your AI team is ready. Here are a few things to try first:"}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[{label:"Chat with Secretary",desc:"Your default team manager can help coordinate work",page:"team"},{label:"Browse Agent Templates",desc:"Hire specialized agents from the template library",page:"agents"},{label:"Create a Project",desc:"Set up a project with tasks and requirements",page:"projects"}].map($=>t.jsxs("button",{onClick:()=>Ut.navigate($.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:$.label}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1",children:$.desc})]},$.label))})]}),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:()=>Ut.navigate("tasks"),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"Task Distribution"}),t.jsx(_2,{statusCounts:T,total:k}),(T.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"}),T.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:()=>Ut.navigate("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:()=>Ut.navigate("team"),children:"No teams yet. Create a team or hire agents to get started."}):t.jsxs("div",{className:"space-y-4",children:[Y.map($=>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:()=>Ut.navigate("team"),children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-600/30 flex items-center justify-center text-xs font-bold text-brand-500",children:$.team.name.charAt(0)}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:$.team.name}),$.team.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate max-w-[200px]",children:$.team.description})]})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[t.jsxs("span",{children:[$.total," members"]}),$.working>0&&t.jsxs("span",{className:"text-brand-500",children:[$.working," working"]}),t.jsxs("span",{className:$.active===$.total?"text-green-600":"",children:[$.active," active"]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[$.agents.slice(0,6).map(X=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30",onClick:P=>{P.stopPropagation(),Ut.navigate("team",{selectAgent:X.id})},children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${X.status==="idle"?"bg-green-400":X.status==="working"?"bg-brand-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:X.name})]},X.id)),$.agents.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",$.agents.length-6," more"]})]})]},$.team.id)),(()=>{const $=new Set(s.flatMap(P=>P.members.filter(q=>q.type==="agent").map(q=>q.id))),X=e.filter(P=>!$.has(P.id));return X.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:[X.length," agents"]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[X.slice(0,6).map(P=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30 cursor-pointer",onClick:()=>Ut.navigate("team",{selectAgent:P.id}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${P.status==="idle"?"bg-green-400":P.status==="working"?"bg-brand-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:P.name})]},P.id)),X.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",X.length-6," more"]})]})]})})()]})]})]}),t.jsxs("div",{className:"space-y-6",children:[x.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:()=>Ut.navigate("projects"),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"Review →"})]}),t.jsxs("div",{className:"space-y-2",children:[x.slice(0,5).map($=>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:()=>Ut.navigate("projects"),children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:$.title}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:["proposed by ",$.createdBy," · ",$.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:$.source==="agent"?"Agent":"User"})]},$.id)),x.length>5&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary text-center pt-1",children:["+",x.length-5," more"]})]}),t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-3",children:["Agents proposed ",x.length," requirement",x.length>1?"s":""," — review to authorize work."]})]}),u&&u.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:()=>Ut.navigate("tasks"),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:u.taskKPI.recentActivity.slice(0,8).map($=>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:()=>Ut.navigate("tasks",{openTask:$.taskId}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Wh[$.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:$.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date($.updatedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},$.taskId))})]}),u&&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(Gl,{label:"Health Score",value:u.systemHealth.overallScore,max:100,unit:"%",color:u.systemHealth.overallScore>=80?"green":u.systemHealth.overallScore>=50?"amber":"red"}),t.jsx(Gl,{label:"Success Rate",value:u.taskKPI.successRate,max:100,unit:"%",color:u.taskKPI.successRate>=80?"green":"amber"}),t.jsx(Gl,{label:"Active / Total",value:H,max:e.length||1,unit:`/${e.length}`,color:"brand"}),t.jsx(Gl,{label:"Token Cost",value:parseFloat(u.systemHealth.totalTokenCost.toFixed(2)),max:Math.max(1,Math.ceil(u.systemHealth.totalTokenCost*2)),unit:"$",color:"brand",raw:!0}),t.jsx(Gl,{label:"Working Now",value:M,max:e.length||1,unit:`/${e.length}`,color:"blue"})]}),u.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:",u.systemHealth.criticalAgents.map($=>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:()=>Ut.navigate("team",{selectAgent:$.id}),children:[$.name," (",$.score,"%)"]},$.id))]})})]}),b&&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:()=>Ut.navigate("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:cb(b.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: ",cb(b.database.size)]}),t.jsxs("span",{children:["Agents: ",b.agents.length]})]}),t.jsx("div",{className:"mt-2 text-[10px] text-fg-tertiary",children:"Click to view details in Settings"})]})]})]})]})]})}const Wh={pending_approval:"bg-amber-500",in_progress:"bg-brand-500",blocked:"bg-red-500",review:"bg-blue-500",completed:"bg-green-500",failed:"bg-red-500",cancelled:"bg-gray-600"},T2={pending_approval:"text-amber-600",in_progress:"text-brand-500",blocked:"text-red-500",review:"text-blue-600",completed:"text-green-600",failed:"text-red-500",cancelled:"text-fg-tertiary"};function _2({statusCounts:e,total:r}){const s=Object.entries(e).filter(([,i])=>i>0).sort(([,i],[,o])=>o-i);return t.jsxs("div",{children:[t.jsx("div",{className:"flex h-4 rounded-full overflow-hidden gap-0.5 mb-4",children:s.map(([i,o])=>t.jsx("div",{className:`${Wh[i]??"bg-gray-600"} transition-all`,style:{width:`${o/r*100}%`},title:`${i}: ${o}`},i))}),t.jsx("div",{className:"flex gap-4 flex-wrap",children:s.map(([i,o])=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-sm ${Wh[i]??"bg-gray-600"}`}),t.jsx("span",{className:"text-xs text-fg-secondary capitalize",children:i.replace(/_/g," ")}),t.jsx("span",{className:`text-xs font-semibold ${T2[i]??"text-fg-secondary"}`,children:o})]},i))})]})}function Xc({label:e,value:r,total:s,color:i,onClick:o}){const c={indigo:{text:"text-brand-500",border:"border-l-brand-500"},blue:{text:"text-blue-600",border:"border-l-blue-500"},amber:{text:"text-amber-600",border:"border-l-amber-500"},green:{text:"text-green-600",border:"border-l-green-500"}},u=c[i]??c.indigo;return t.jsxs("div",{onClick:o,className:`bg-surface-secondary border border-border-default ${u.border} border-l-2 rounded-xl p-5 cursor-pointer hover:bg-surface-elevated transition-all`,children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2",children:e}),t.jsxs("div",{className:`text-3xl font-bold ${u.text}`,children:[r,s!==void 0&&t.jsxs("span",{className:"text-base font-normal text-fg-muted",children:["/",s]})]})]})}function Gl({label:e,value:r,max:s,unit:i,color:o,raw:c}){const u=s>0?Math.min(r/s*100,100):0,f={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"},h=f[o]??"bg-gray-400",x=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 ${x}`,children:c?`${i}${r}`:t.jsxs(t.Fragment,{children:[r,t.jsx("span",{className:"text-[10px] font-normal text-fg-tertiary",children:i})]})})]}),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 ${h} transition-all`,style:{width:`${u}%`}})})]})}function cb(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${r[s]}`}function A2(e,r){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const M2=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,D2=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,O2={};function ub(e,r){return(O2.jsx?D2:M2).test(e)}const R2=/[ \t\n\f\r]/g;function z2(e){return typeof e=="object"?e.type==="text"?db(e.value):!1:db(e)}function db(e){return e.replace(R2,"")===""}class Ao{constructor(r,s,i){this.normal=s,this.property=r,i&&(this.space=i)}}Ao.prototype.normal={};Ao.prototype.property={};Ao.prototype.space=void 0;function Yv(e,r){const s={},i={};for(const o of e)Object.assign(s,o.property),Object.assign(i,o.normal);return new Ao(s,i,r)}function em(e){return e.toLowerCase()}class yr{constructor(r,s){this.attribute=s,this.property=r}}yr.prototype.attribute="";yr.prototype.booleanish=!1;yr.prototype.boolean=!1;yr.prototype.commaOrSpaceSeparated=!1;yr.prototype.commaSeparated=!1;yr.prototype.defined=!1;yr.prototype.mustUseProperty=!1;yr.prototype.number=!1;yr.prototype.overloadedBoolean=!1;yr.prototype.property="";yr.prototype.spaceSeparated=!1;yr.prototype.space=void 0;let L2=0;const St=ni(),$n=ni(),tm=ni(),Re=ni(),dn=ni(),Pi=ni(),_r=ni();function ni(){return 2**++L2}const nm=Object.freeze(Object.defineProperty({__proto__:null,boolean:St,booleanish:$n,commaOrSpaceSeparated:_r,commaSeparated:Pi,number:Re,overloadedBoolean:tm,spaceSeparated:dn},Symbol.toStringTag,{value:"Module"})),dh=Object.keys(nm);class Dm extends yr{constructor(r,s,i,o){let c=-1;if(super(r,s),fb(this,"space",o),typeof i=="number")for(;++c<dh.length;){const u=dh[c];fb(this,dh[c],(i&nm[u])===nm[u])}}}Dm.prototype.defined=!0;function fb(e,r,s){s&&(e[r]=s)}function tl(e){const r={},s={};for(const[i,o]of Object.entries(e.properties)){const c=new Dm(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(c.mustUseProperty=!0),r[i]=c,s[em(i)]=i,s[em(c.attribute)]=i}return new Ao(r,s,e.space)}const Gv=tl({properties:{ariaActiveDescendant:null,ariaAtomic:$n,ariaAutoComplete:null,ariaBusy:$n,ariaChecked:$n,ariaColCount:Re,ariaColIndex:Re,ariaColSpan:Re,ariaControls:dn,ariaCurrent:null,ariaDescribedBy:dn,ariaDetails:null,ariaDisabled:$n,ariaDropEffect:dn,ariaErrorMessage:null,ariaExpanded:$n,ariaFlowTo:dn,ariaGrabbed:$n,ariaHasPopup:null,ariaHidden:$n,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:dn,ariaLevel:Re,ariaLive:null,ariaModal:$n,ariaMultiLine:$n,ariaMultiSelectable:$n,ariaOrientation:null,ariaOwns:dn,ariaPlaceholder:null,ariaPosInSet:Re,ariaPressed:$n,ariaReadOnly:$n,ariaRelevant:null,ariaRequired:$n,ariaRoleDescription:dn,ariaRowCount:Re,ariaRowIndex:Re,ariaRowSpan:Re,ariaSelected:$n,ariaSetSize:Re,ariaSort:null,ariaValueMax:Re,ariaValueMin:Re,ariaValueNow:Re,ariaValueText:null,role:null},transform(e,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function Xv(e,r){return r in e?e[r]:r}function Zv(e,r){return Xv(e,r.toLowerCase())}const I2=tl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Pi,acceptCharset:dn,accessKey:dn,action:null,allow:null,allowFullScreen:St,allowPaymentRequest:St,allowUserMedia:St,alt:null,as:null,async:St,autoCapitalize:null,autoComplete:dn,autoFocus:St,autoPlay:St,blocking:dn,capture:null,charSet:null,checked:St,cite:null,className:dn,cols:Re,colSpan:null,content:null,contentEditable:$n,controls:St,controlsList:dn,coords:Re|Pi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:St,defer:St,dir:null,dirName:null,disabled:St,download:tm,draggable:$n,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:St,formTarget:null,headers:dn,height:Re,hidden:tm,high:Re,href:null,hrefLang:null,htmlFor:dn,httpEquiv:dn,id:null,imageSizes:null,imageSrcSet:null,inert:St,inputMode:null,integrity:null,is:null,isMap:St,itemId:null,itemProp:dn,itemRef:dn,itemScope:St,itemType:dn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:St,low:Re,manifest:null,max:null,maxLength:Re,media:null,method:null,min:null,minLength:Re,multiple:St,muted:St,name:null,nonce:null,noModule:St,noValidate:St,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:St,optimum:Re,pattern:null,ping:dn,placeholder:null,playsInline:St,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:St,referrerPolicy:null,rel:dn,required:St,reversed:St,rows:Re,rowSpan:Re,sandbox:dn,scope:null,scoped:St,seamless:St,selected:St,shadowRootClonable:St,shadowRootDelegatesFocus:St,shadowRootMode:null,shape:null,size:Re,sizes:null,slot:null,span:Re,spellCheck:$n,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Re,step:null,style:null,tabIndex:Re,target:null,title:null,translate:null,type:null,typeMustMatch:St,useMap:null,value:$n,width:Re,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:dn,axis:null,background:null,bgColor:null,border:Re,borderColor:null,bottomMargin:Re,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:St,declare:St,event:null,face:null,frame:null,frameBorder:null,hSpace:Re,leftMargin:Re,link:null,longDesc:null,lowSrc:null,marginHeight:Re,marginWidth:Re,noResize:St,noHref:St,noShade:St,noWrap:St,object:null,profile:null,prompt:null,rev:null,rightMargin:Re,rules:null,scheme:null,scrolling:$n,standby:null,summary:null,text:null,topMargin:Re,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Re,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:St,disableRemotePlayback:St,prefix:null,property:null,results:Re,security:null,unselectable:null},space:"html",transform:Zv}),$2=tl({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:Re,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Re,amplitude:Re,arabicForm:null,ascent:Re,attributeName:null,attributeType:null,azimuth:Re,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Re,by:null,calcMode:null,capHeight:Re,className:dn,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:Re,diffuseConstant:Re,direction:null,display:null,dur:null,divisor:Re,dominantBaseline:null,download:St,dx:null,dy:null,edgeMode:null,editable:null,elevation:Re,enableBackground:null,end:null,event:null,exponent:Re,externalResourcesRequired:null,fill:null,fillOpacity:Re,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:Pi,g2:Pi,glyphName:Pi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Re,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Re,horizOriginX:Re,horizOriginY:Re,id:null,ideographic:Re,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Re,k:Re,k1:Re,k2:Re,k3:Re,k4:Re,kernelMatrix:_r,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Re,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:Re,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:Re,overlineThickness:Re,paintOrder:null,panose1:null,path:null,pathLength:Re,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:dn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Re,pointsAtY:Re,pointsAtZ:Re,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:Re,specularExponent:Re,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Re,strikethroughThickness:Re,string:null,stroke:null,strokeDashArray:_r,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Re,strokeOpacity:Re,strokeWidth:null,style:null,surfaceScale:Re,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_r,tabIndex:Re,tableValues:null,target:null,targetX:Re,targetY:Re,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:Re,underlineThickness:Re,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Re,values:null,vAlphabetic:Re,vMathematical:Re,vectorEffect:null,vHanging:Re,vIdeographic:Re,version:null,vertAdvY:Re,vertOriginX:Re,vertOriginY:Re,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Re,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Xv}),Qv=tl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,r){return"xlink:"+r.slice(5).toLowerCase()}}),Kv=tl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Zv}),Jv=tl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,r){return"xml:"+r.slice(3).toLowerCase()}}),B2={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"},H2=/[A-Z]/g,hb=/-[a-z]/g,P2=/^data[-\w.:]+$/i;function U2(e,r){const s=em(r);let i=r,o=yr;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&P2.test(r)){if(r.charAt(4)==="-"){const c=r.slice(5).replace(hb,V2);i="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=r.slice(4);if(!hb.test(c)){let u=c.replace(H2,q2);u.charAt(0)!=="-"&&(u="-"+u),r="data"+u}}o=Dm}return new o(i,r)}function q2(e){return"-"+e.toLowerCase()}function V2(e){return e.charAt(1).toUpperCase()}const F2=Yv([Gv,I2,Qv,Kv,Jv],"html"),Om=Yv([Gv,$2,Qv,Kv,Jv],"svg");function Y2(e){return e.join(" ").trim()}var Di={},fh,mb;function G2(){if(mb)return fh;mb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,s=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
|
|
12
|
-
`,h="/",x="*",g="",b="comment",p="declaration";function w(T,E){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];E=E||{};var C=1,N=1;function k(_){var I=_.match(r);I&&(C+=I.length);var A=_.lastIndexOf(m);N=~A?_.length-A:N+_.length}function H(){var _={line:C,column:N};return function(I){return I.position=new M(_),X(),I}}function M(_){this.start=_,this.end={line:C,column:N},this.source=E.source}M.prototype.content=T;function Y(_){var I=new Error(E.source+":"+C+":"+N+": "+_);if(I.reason=_,I.filename=E.source,I.line=C,I.column=N,I.source=T,!E.silent)throw I}function $(_){var I=_.exec(T);if(I){var A=I[0];return k(A),T=T.slice(A.length),I}}function X(){$(s)}function P(_){var I;for(_=_||[];I=q();)I!==!1&&_.push(I);return _}function q(){var _=H();if(!(h!=T.charAt(0)||x!=T.charAt(1))){for(var I=2;g!=T.charAt(I)&&(x!=T.charAt(I)||h!=T.charAt(I+1));)++I;if(I+=2,g===T.charAt(I-1))return Y("End of comment missing");var A=T.slice(2,I-2);return N+=2,k(A),T=T.slice(I),N+=2,_({type:b,comment:A})}}function F(){var _=H(),I=$(i);if(I){if(q(),!$(o))return Y("property missing ':'");var A=$(c),G=_({type:p,property:S(I[0].replace(e,g)),value:A?S(A[0].replace(e,g)):g});return $(u),G}}function D(){var _=[];P(_);for(var I;I=F();)I!==!1&&(_.push(I),P(_));return _}return X(),D()}function S(T){return T?T.replace(f,g):g}return fh=w,fh}var xb;function X2(){if(xb)return Di;xb=1;var e=Di&&Di.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Di,"__esModule",{value:!0}),Di.default=s;const r=e(G2());function s(i,o){let c=null;if(!i||typeof i!="string")return c;const u=(0,r.default)(i),f=typeof o=="function";return u.forEach(m=>{if(m.type!=="declaration")return;const{property:h,value:x}=m;f?o(h,x,m):x&&(c=c||{},c[h]=x)}),c}return Di}var Xl={},gb;function Z2(){if(gb)return Xl;gb=1,Object.defineProperty(Xl,"__esModule",{value:!0}),Xl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,s=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,c=function(h){return!h||s.test(h)||e.test(h)},u=function(h,x){return x.toUpperCase()},f=function(h,x){return"".concat(x,"-")},m=function(h,x){return x===void 0&&(x={}),c(h)?h:(h=h.toLowerCase(),x.reactCompat?h=h.replace(o,f):h=h.replace(i,f),h.replace(r,u))};return Xl.camelCase=m,Xl}var Zl,pb;function Q2(){if(pb)return Zl;pb=1;var e=Zl&&Zl.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},r=e(X2()),s=Z2();function i(o,c){var u={};return!o||typeof o!="string"||(0,r.default)(o,function(f,m){f&&m&&(u[(0,s.camelCase)(f,c)]=m)}),u}return i.default=i,Zl=i,Zl}var K2=Q2();const J2=Bu(K2),Wv=e1("end"),Rm=e1("start");function e1(e){return r;function r(s){const i=s&&s.position&&s.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function W2(e){const r=Rm(e),s=Wv(e);if(r&&s)return{start:r,end:s}}function co(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?bb(e.position):"start"in e||"end"in e?bb(e):"line"in e||"column"in e?rm(e):""}function rm(e){return yb(e&&e.line)+":"+yb(e&&e.column)}function bb(e){return rm(e&&e.start)+"-"+rm(e&&e.end)}function yb(e){return e&&typeof e=="number"?e:1}class tr extends Error{constructor(r,s,i){super(),typeof s=="string"&&(i=s,s=void 0);let o="",c={},u=!1;if(s&&("line"in s&&"column"in s?c={place:s}:"start"in s&&"end"in s?c={place:s}:"type"in s?c={ancestors:[s],place:s.position}:c={...s}),typeof r=="string"?o=r:!c.cause&&r&&(u=!0,o=r.message,c.cause=r),!c.ruleId&&!c.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?c.ruleId=i:(c.source=i.slice(0,m),c.ruleId=i.slice(m+1))}if(!c.place&&c.ancestors&&c.ancestors){const m=c.ancestors[c.ancestors.length-1];m&&(c.place=m.position)}const f=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=co(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=u&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}tr.prototype.file="";tr.prototype.name="";tr.prototype.reason="";tr.prototype.message="";tr.prototype.stack="";tr.prototype.column=void 0;tr.prototype.line=void 0;tr.prototype.ancestors=void 0;tr.prototype.cause=void 0;tr.prototype.fatal=void 0;tr.prototype.place=void 0;tr.prototype.ruleId=void 0;tr.prototype.source=void 0;const zm={}.hasOwnProperty,ek=new Map,tk=/[A-Z]/g,nk=new Set(["table","tbody","thead","tfoot","tr"]),rk=new Set(["td","th"]),t1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function sk(e,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=r.filePath||void 0;let i;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=fk(s,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=dk(s,r.jsx,r.jsxs)}const o={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:i,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?Om:F2,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},c=n1(o,e,void 0);return c&&typeof c!="string"?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}function n1(e,r,s){if(r.type==="element")return ak(e,r,s);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return ik(e,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return ok(e,r,s);if(r.type==="mdxjsEsm")return lk(e,r);if(r.type==="root")return ck(e,r,s);if(r.type==="text")return uk(e,r)}function ak(e,r,s){const i=e.schema;let o=i;r.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=Om,e.schema=o),e.ancestors.push(r);const c=s1(e,r.tagName,!1),u=hk(e,r);let f=Im(e,r);return nk.has(r.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!z2(m):!0})),r1(e,u,c,r),Lm(u,f),e.ancestors.pop(),e.schema=i,e.create(r,c,u,s)}function ik(e,r){if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}go(e,r.position)}function lk(e,r){if(r.data&&r.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(r.data.estree);go(e,r.position)}function ok(e,r,s){const i=e.schema;let o=i;r.name==="svg"&&i.space==="html"&&(o=Om,e.schema=o),e.ancestors.push(r);const c=r.name===null?e.Fragment:s1(e,r.name,!0),u=mk(e,r),f=Im(e,r);return r1(e,u,c,r),Lm(u,f),e.ancestors.pop(),e.schema=i,e.create(r,c,u,s)}function ck(e,r,s){const i={};return Lm(i,Im(e,r)),e.create(r,e.Fragment,i,s)}function uk(e,r){return r.value}function r1(e,r,s,i){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(r.node=i)}function Lm(e,r){if(r.length>0){const s=r.length>1?r:r[0];s&&(e.children=s)}}function dk(e,r,s){return i;function i(o,c,u,f){const h=Array.isArray(u.children)?s:r;return f?h(c,u,f):h(c,u)}}function fk(e,r){return s;function s(i,o,c,u){const f=Array.isArray(c.children),m=Rm(i);return r(o,c,u,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function hk(e,r){const s={};let i,o;for(o in r.properties)if(o!=="children"&&zm.call(r.properties,o)){const c=xk(e,o,r.properties[o]);if(c){const[u,f]=c;e.tableCellAlignToStyle&&u==="align"&&typeof f=="string"&&rk.has(r.tagName)?i=f:s[u]=f}}if(i){const c=s.style||(s.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return s}function mk(e,r){const s={};for(const i of r.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const c=i.data.estree.body[0];c.type;const u=c.expression;u.type;const f=u.properties[0];f.type,Object.assign(s,e.evaluater.evaluateExpression(f.argument))}else go(e,r.position);else{const o=i.name;let c;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const f=i.value.data.estree.body[0];f.type,c=e.evaluater.evaluateExpression(f.expression)}else go(e,r.position);else c=i.value===null?!0:i.value;s[o]=c}return s}function Im(e,r){const s=[];let i=-1;const o=e.passKeys?new Map:ek;for(;++i<r.children.length;){const c=r.children[i];let u;if(e.passKeys){const m=c.type==="element"?c.tagName:c.type==="mdxJsxFlowElement"||c.type==="mdxJsxTextElement"?c.name:void 0;if(m){const h=o.get(m)||0;u=m+"-"+h,o.set(m,h+1)}}const f=n1(e,c,u);f!==void 0&&s.push(f)}return s}function xk(e,r,s){const i=U2(e.schema,r);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=i.commaSeparated?A2(s):Y2(s)),i.property==="style"){let o=typeof s=="object"?s:gk(e,String(s));return e.stylePropertyNameCase==="css"&&(o=pk(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?B2[i.property]||i.property:i.attribute,s]}}function gk(e,r){try{return J2(r,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const i=s,o=new tr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=t1+"#cannot-parse-style-attribute",o}}function s1(e,r,s){let i;if(!s)i={type:"Literal",value:r};else if(r.includes(".")){const o=r.split(".");let c=-1,u;for(;++c<o.length;){const f=ub(o[c])?{type:"Identifier",name:o[c]}:{type:"Literal",value:o[c]};u=u?{type:"MemberExpression",object:u,property:f,computed:!!(c&&f.type==="Literal"),optional:!1}:f}i=u}else i=ub(r)&&!/^[a-z]/.test(r)?{type:"Identifier",name:r}:{type:"Literal",value:r};if(i.type==="Literal"){const o=i.value;return zm.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);go(e)}function go(e,r){const s=new tr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:r,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=t1+"#cannot-handle-mdx-estrees-without-createevaluater",s}function pk(e){const r={};let s;for(s in e)zm.call(e,s)&&(r[bk(s)]=e[s]);return r}function bk(e){let r=e.replace(tk,yk);return r.slice(0,3)==="ms-"&&(r="-"+r),r}function yk(e){return"-"+e.toLowerCase()}const hh={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 $m(e,r){const s=vk,i=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,o=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return a1(e,i,o)}function a1(e,r,s){if(jk(e)){if("value"in e)return e.type==="html"&&!s?"":e.value;if(r&&"alt"in e&&e.alt)return e.alt;if("children"in e)return vb(e.children,r,s)}return Array.isArray(e)?vb(e,r,s):""}function vb(e,r,s){const i=[];let o=-1;for(;++o<e.length;)i[o]=a1(e[o],r,s);return i.join("")}function jk(e){return!!(e&&typeof e=="object")}const jb=document.createElement("i");function Bm(e){const r="&"+e+";";jb.innerHTML=r;const s=jb.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===r?!1:s}function Mr(e,r,s,i){const o=e.length;let c=0,u;if(r<0?r=-r>o?0:o+r:r=r>o?o:r,s=s>0?s:0,i.length<1e4)u=Array.from(i),u.unshift(r,s),e.splice(...u);else for(s&&e.splice(r,s);c<i.length;)u=i.slice(c,c+1e4),u.unshift(r,0),e.splice(...u),c+=1e4,r+=1e4}function Yr(e,r){return e.length>0?(Mr(e,e.length,0,r),e):r}const wb={}.hasOwnProperty;function i1(e){const r={};let s=-1;for(;++s<e.length;)wk(r,e[s]);return r}function wk(e,r){let s;for(s in r){const o=(wb.call(e,s)?e[s]:void 0)||(e[s]={}),c=r[s];let u;if(c)for(u in c){wb.call(o,u)||(o[u]=[]);const f=c[u];Nk(o[u],Array.isArray(f)?f:f?[f]:[])}}}function Nk(e,r){let s=-1;const i=[];for(;++s<r.length;)(r[s].add==="after"?e:i).push(r[s]);Mr(e,0,0,i)}function l1(e,r){const s=Number.parseInt(e,r);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 ts(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const sr=ka(/[A-Za-z]/),Wn=ka(/[\dA-Za-z]/),kk=ka(/[#-'*+\--9=?A-Z^-~]/);function bu(e){return e!==null&&(e<32||e===127)}const sm=ka(/\d/),Sk=ka(/[\dA-Fa-f]/),Ck=ka(/[!-/:-@[-`{-~]/);function ft(e){return e!==null&&e<-2}function ln(e){return e!==null&&(e<0||e===32)}function zt(e){return e===-2||e===-1||e===32}const Hu=ka(new RegExp("\\p{P}|\\p{S}","u")),Ka=ka(/\s/);function ka(e){return r;function r(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function nl(e){const r=[];let s=-1,i=0,o=0;for(;++s<e.length;){const c=e.charCodeAt(s);let u="";if(c===37&&Wn(e.charCodeAt(s+1))&&Wn(e.charCodeAt(s+2)))o=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(u=String.fromCharCode(c));else if(c>55295&&c<57344){const f=e.charCodeAt(s+1);c<56320&&f>56319&&f<57344?(u=String.fromCharCode(c,f),o=1):u="�"}else u=String.fromCharCode(c);u&&(r.push(e.slice(i,s),encodeURIComponent(u)),i=s+o+1,u=""),o&&(s+=o,o=0)}return r.join("")+e.slice(i)}function qt(e,r,s,i){const o=i?i-1:Number.POSITIVE_INFINITY;let c=0;return u;function u(m){return zt(m)?(e.enter(s),f(m)):r(m)}function f(m){return zt(m)&&c++<o?(e.consume(m),f):(e.exit(s),r(m))}}const Ek={tokenize:Tk};function Tk(e){const r=e.attempt(this.parser.constructs.contentInitial,i,o);let s;return r;function i(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),qt(e,r,"linePrefix")}function o(f){return e.enter("paragraph"),c(f)}function c(f){const m=e.enter("chunkText",{contentType:"text",previous:s});return s&&(s.next=m),s=m,u(f)}function u(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return ft(f)?(e.consume(f),e.exit("chunkText"),c):(e.consume(f),u)}}const _k={tokenize:Ak},Nb={tokenize:Mk};function Ak(e){const r=this,s=[];let i=0,o,c,u;return f;function f(N){if(i<s.length){const k=s[i];return r.containerState=k[1],e.attempt(k[0].continuation,m,h)(N)}return h(N)}function m(N){if(i++,r.containerState._closeFlow){r.containerState._closeFlow=void 0,o&&C();const k=r.events.length;let H=k,M;for(;H--;)if(r.events[H][0]==="exit"&&r.events[H][1].type==="chunkFlow"){M=r.events[H][1].end;break}E(i);let Y=k;for(;Y<r.events.length;)r.events[Y][1].end={...M},Y++;return Mr(r.events,H+1,0,r.events.slice(k)),r.events.length=Y,h(N)}return f(N)}function h(N){if(i===s.length){if(!o)return b(N);if(o.currentConstruct&&o.currentConstruct.concrete)return w(N);r.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return r.containerState={},e.check(Nb,x,g)(N)}function x(N){return o&&C(),E(i),b(N)}function g(N){return r.parser.lazy[r.now().line]=i!==s.length,u=r.now().offset,w(N)}function b(N){return r.containerState={},e.attempt(Nb,p,w)(N)}function p(N){return i++,s.push([r.currentConstruct,r.containerState]),b(N)}function w(N){if(N===null){o&&C(),E(0),e.consume(N);return}return o=o||r.parser.flow(r.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:c}),S(N)}function S(N){if(N===null){T(e.exit("chunkFlow"),!0),E(0),e.consume(N);return}return ft(N)?(e.consume(N),T(e.exit("chunkFlow")),i=0,r.interrupt=void 0,f):(e.consume(N),S)}function T(N,k){const H=r.sliceStream(N);if(k&&H.push(null),N.previous=c,c&&(c.next=N),c=N,o.defineSkip(N.start),o.write(H),r.parser.lazy[N.start.line]){let M=o.events.length;for(;M--;)if(o.events[M][1].start.offset<u&&(!o.events[M][1].end||o.events[M][1].end.offset>u))return;const Y=r.events.length;let $=Y,X,P;for(;$--;)if(r.events[$][0]==="exit"&&r.events[$][1].type==="chunkFlow"){if(X){P=r.events[$][1].end;break}X=!0}for(E(i),M=Y;M<r.events.length;)r.events[M][1].end={...P},M++;Mr(r.events,$+1,0,r.events.slice(Y)),r.events.length=M}}function E(N){let k=s.length;for(;k-- >N;){const H=s[k];r.containerState=H[1],H[0].exit.call(r,e)}s.length=N}function C(){o.write([null]),c=void 0,o=void 0,r.containerState._closeFlow=void 0}}function Mk(e,r,s){return qt(e,e.attempt(this.parser.constructs.document,r,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vi(e){if(e===null||ln(e)||Ka(e))return 1;if(Hu(e))return 2}function Pu(e,r,s){const i=[];let o=-1;for(;++o<e.length;){const c=e[o].resolveAll;c&&!i.includes(c)&&(r=c(r,s),i.push(c))}return r}const am={name:"attention",resolveAll:Dk,tokenize:Ok};function Dk(e,r){let s=-1,i,o,c,u,f,m,h,x;for(;++s<e.length;)if(e[s][0]==="enter"&&e[s][1].type==="attentionSequence"&&e[s][1]._close){for(i=s;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&r.sliceSerialize(e[i][1]).charCodeAt(0)===r.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[i][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const g={...e[i][1].end},b={...e[s][1].start};kb(g,-m),kb(b,m),u={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[i][1].end}},f={type:m>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:b},c={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[s][1].start}},o={type:m>1?"strong":"emphasis",start:{...u.start},end:{...f.end}},e[i][1].end={...u.start},e[s][1].start={...f.end},h=[],e[i][1].end.offset-e[i][1].start.offset&&(h=Yr(h,[["enter",e[i][1],r],["exit",e[i][1],r]])),h=Yr(h,[["enter",o,r],["enter",u,r],["exit",u,r],["enter",c,r]]),h=Yr(h,Pu(r.parser.constructs.insideSpan.null,e.slice(i+1,s),r)),h=Yr(h,[["exit",c,r],["enter",f,r],["exit",f,r],["exit",o,r]]),e[s][1].end.offset-e[s][1].start.offset?(x=2,h=Yr(h,[["enter",e[s][1],r],["exit",e[s][1],r]])):x=0,Mr(e,i-1,s-i+3,h),s=i+h.length-x-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function Ok(e,r){const s=this.parser.constructs.attentionMarkers.null,i=this.previous,o=Vi(i);let c;return u;function u(m){return c=m,e.enter("attentionSequence"),f(m)}function f(m){if(m===c)return e.consume(m),f;const h=e.exit("attentionSequence"),x=Vi(m),g=!x||x===2&&o||s.includes(m),b=!o||o===2&&x||s.includes(i);return h._open=!!(c===42?g:g&&(o||!b)),h._close=!!(c===42?b:b&&(x||!g)),r(m)}}function kb(e,r){e.column+=r,e.offset+=r,e._bufferIndex+=r}const Rk={name:"autolink",tokenize:zk};function zk(e,r,s){let i=0;return o;function o(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),c}function c(p){return sr(p)?(e.consume(p),u):p===64?s(p):h(p)}function u(p){return p===43||p===45||p===46||Wn(p)?(i=1,f(p)):h(p)}function f(p){return p===58?(e.consume(p),i=0,m):(p===43||p===45||p===46||Wn(p))&&i++<32?(e.consume(p),f):(i=0,h(p))}function m(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),r):p===null||p===32||p===60||bu(p)?s(p):(e.consume(p),m)}function h(p){return p===64?(e.consume(p),x):kk(p)?(e.consume(p),h):s(p)}function x(p){return Wn(p)?g(p):s(p)}function g(p){return p===46?(e.consume(p),i=0,x):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),r):b(p)}function b(p){if((p===45||Wn(p))&&i++<63){const w=p===45?b:g;return e.consume(p),w}return s(p)}}const Mo={partial:!0,tokenize:Lk};function Lk(e,r,s){return i;function i(c){return zt(c)?qt(e,o,"linePrefix")(c):o(c)}function o(c){return c===null||ft(c)?r(c):s(c)}}const o1={continuation:{tokenize:$k},exit:Bk,name:"blockQuote",tokenize:Ik};function Ik(e,r,s){const i=this;return o;function o(u){if(u===62){const f=i.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),c}return s(u)}function c(u){return zt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),r):(e.exit("blockQuotePrefix"),r(u))}}function $k(e,r,s){const i=this;return o;function o(u){return zt(u)?qt(e,c,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):c(u)}function c(u){return e.attempt(o1,r,s)(u)}}function Bk(e){e.exit("blockQuote")}const c1={name:"characterEscape",tokenize:Hk};function Hk(e,r,s){return i;function i(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),o}function o(c){return Ck(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),r):s(c)}}const u1={name:"characterReference",tokenize:Pk};function Pk(e,r,s){const i=this;let o=0,c,u;return f;function f(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),c=31,u=Wn,x(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),c=6,u=Sk,x):(e.enter("characterReferenceValue"),c=7,u=sm,x(g))}function x(g){if(g===59&&o){const b=e.exit("characterReferenceValue");return u===Wn&&!Bm(i.sliceSerialize(b))?s(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),r)}return u(g)&&o++<c?(e.consume(g),x):s(g)}}const Sb={partial:!0,tokenize:qk},Cb={concrete:!0,name:"codeFenced",tokenize:Uk};function Uk(e,r,s){const i=this,o={partial:!0,tokenize:H};let c=0,u=0,f;return m;function m(M){return h(M)}function h(M){const Y=i.events[i.events.length-1];return c=Y&&Y[1].type==="linePrefix"?Y[2].sliceSerialize(Y[1],!0).length:0,f=M,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(M)}function x(M){return M===f?(u++,e.consume(M),x):u<3?s(M):(e.exit("codeFencedFenceSequence"),zt(M)?qt(e,g,"whitespace")(M):g(M))}function g(M){return M===null||ft(M)?(e.exit("codeFencedFence"),i.interrupt?r(M):e.check(Sb,S,k)(M)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(M))}function b(M){return M===null||ft(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(M)):zt(M)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qt(e,p,"whitespace")(M)):M===96&&M===f?s(M):(e.consume(M),b)}function p(M){return M===null||ft(M)?g(M):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(M))}function w(M){return M===null||ft(M)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(M)):M===96&&M===f?s(M):(e.consume(M),w)}function S(M){return e.attempt(o,k,T)(M)}function T(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),E}function E(M){return c>0&&zt(M)?qt(e,C,"linePrefix",c+1)(M):C(M)}function C(M){return M===null||ft(M)?e.check(Sb,S,k)(M):(e.enter("codeFlowValue"),N(M))}function N(M){return M===null||ft(M)?(e.exit("codeFlowValue"),C(M)):(e.consume(M),N)}function k(M){return e.exit("codeFenced"),r(M)}function H(M,Y,$){let X=0;return P;function P(I){return M.enter("lineEnding"),M.consume(I),M.exit("lineEnding"),q}function q(I){return M.enter("codeFencedFence"),zt(I)?qt(M,F,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):F(I)}function F(I){return I===f?(M.enter("codeFencedFenceSequence"),D(I)):$(I)}function D(I){return I===f?(X++,M.consume(I),D):X>=u?(M.exit("codeFencedFenceSequence"),zt(I)?qt(M,_,"whitespace")(I):_(I)):$(I)}function _(I){return I===null||ft(I)?(M.exit("codeFencedFence"),Y(I)):$(I)}}}function qk(e,r,s){const i=this;return o;function o(u){return u===null?s(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c)}function c(u){return i.parser.lazy[i.now().line]?s(u):r(u)}}const mh={name:"codeIndented",tokenize:Fk},Vk={partial:!0,tokenize:Yk};function Fk(e,r,s){const i=this;return o;function o(h){return e.enter("codeIndented"),qt(e,c,"linePrefix",5)(h)}function c(h){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?u(h):s(h)}function u(h){return h===null?m(h):ft(h)?e.attempt(Vk,u,m)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||ft(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),f)}function m(h){return e.exit("codeIndented"),r(h)}}function Yk(e,r,s){const i=this;return o;function o(u){return i.parser.lazy[i.now().line]?s(u):ft(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):qt(e,c,"linePrefix",5)(u)}function c(u){const f=i.events[i.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?r(u):ft(u)?o(u):s(u)}}const Gk={name:"codeText",previous:Zk,resolve:Xk,tokenize:Qk};function Xk(e){let r=e.length-4,s=3,i,o;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[r][1].type==="lineEnding"||e[r][1].type==="space")){for(i=s;++i<r;)if(e[i][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[r][1].type="codeTextPadding",s+=2,r-=2;break}}for(i=s-1,r++;++i<=r;)o===void 0?i!==r&&e[i][1].type!=="lineEnding"&&(o=i):(i===r||e[i][1].type==="lineEnding")&&(e[o][1].type="codeTextData",i!==o+2&&(e[o][1].end=e[i-1][1].end,e.splice(o+2,i-o-2),r-=i-o-2,i=o+2),o=void 0);return e}function Zk(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Qk(e,r,s){let i=0,o,c;return u;function u(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),i++,f):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?s(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(c=e.enter("codeTextSequence"),o=0,x(g)):ft(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||ft(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),h)}function x(g){return g===96?(e.consume(g),o++,x):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),r(g)):(c.type="codeTextData",h(g))}}class Kk{constructor(r){this.left=r?[...r]:[],this.right=[]}get(r){if(r<0||r>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return r<this.left.length?this.left[r]:this.right[this.right.length-r+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(r,s){const i=s??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(r,i):r>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(r,s,i){const o=s||0;this.setCursor(Math.trunc(r));const c=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return i&&Ql(this.left,i),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),Ql(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),Ql(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r<this.left.length){const s=this.left.splice(r,Number.POSITIVE_INFINITY);Ql(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-r,Number.POSITIVE_INFINITY);Ql(this.left,s.reverse())}}}function Ql(e,r){let s=0;if(r.length<1e4)e.push(...r);else for(;s<r.length;)e.push(...r.slice(s,s+1e4)),s+=1e4}function d1(e){const r={};let s=-1,i,o,c,u,f,m,h;const x=new Kk(e);for(;++s<x.length;){for(;s in r;)s=r[s];if(i=x.get(s),s&&i[1].type==="chunkFlow"&&x.get(s-1)[1].type==="listItemPrefix"&&(m=i[1]._tokenizer.events,c=0,c<m.length&&m[c][1].type==="lineEndingBlank"&&(c+=2),c<m.length&&m[c][1].type==="content"))for(;++c<m.length&&m[c][1].type!=="content";)m[c][1].type==="chunkText"&&(m[c][1]._isInFirstContentOfListItem=!0,c++);if(i[0]==="enter")i[1].contentType&&(Object.assign(r,Jk(x,s)),s=r[s],h=!0);else if(i[1]._container){for(c=s,o=void 0;c--;)if(u=x.get(c),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),u[1].type="lineEnding",o=c);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;o&&(i[1].end={...x.get(o)[1].start},f=x.slice(o,s),f.unshift(i),x.splice(o,s-o+1,f))}}return Mr(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!h}function Jk(e,r){const s=e.get(r)[1],i=e.get(r)[2];let o=r-1;const c=[];let u=s._tokenizer;u||(u=i.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const f=u.events,m=[],h={};let x,g,b=-1,p=s,w=0,S=0;const T=[S];for(;p;){for(;e.get(++o)[1]!==p;);c.push(o),p._tokenizer||(x=i.sliceStream(p),p.next||x.push(null),g&&u.defineSkip(p.start),p._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(x),p._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),g=p,p=p.next}for(p=s;++b<f.length;)f[b][0]==="exit"&&f[b-1][0]==="enter"&&f[b][1].type===f[b-1][1].type&&f[b][1].start.line!==f[b][1].end.line&&(S=b+1,T.push(S),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(u.events=[],p?(p._tokenizer=void 0,p.previous=void 0):T.pop(),b=T.length;b--;){const E=f.slice(T[b],T[b+1]),C=c.pop();m.push([C,C+E.length-1]),e.splice(C,2,E)}for(m.reverse(),b=-1;++b<m.length;)h[w+m[b][0]]=w+m[b][1],w+=m[b][1]-m[b][0]-1;return h}const Wk={resolve:tS,tokenize:nS},eS={partial:!0,tokenize:rS};function tS(e){return d1(e),e}function nS(e,r){let s;return i;function i(f){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?c(f):ft(f)?e.check(eS,u,c)(f):(e.consume(f),o)}function c(f){return e.exit("chunkContent"),e.exit("content"),r(f)}function u(f){return e.consume(f),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,o}}function rS(e,r,s){const i=this;return o;function o(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),qt(e,c,"linePrefix")}function c(u){if(u===null||ft(u))return s(u);const f=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?r(u):e.interrupt(i.parser.constructs.flow,s,r)(u)}}function f1(e,r,s,i,o,c,u,f,m){const h=m||Number.POSITIVE_INFINITY;let x=0;return g;function g(E){return E===60?(e.enter(i),e.enter(o),e.enter(c),e.consume(E),e.exit(c),b):E===null||E===32||E===41||bu(E)?s(E):(e.enter(i),e.enter(u),e.enter(f),e.enter("chunkString",{contentType:"string"}),S(E))}function b(E){return E===62?(e.enter(c),e.consume(E),e.exit(c),e.exit(o),e.exit(i),r):(e.enter(f),e.enter("chunkString",{contentType:"string"}),p(E))}function p(E){return E===62?(e.exit("chunkString"),e.exit(f),b(E)):E===null||E===60||ft(E)?s(E):(e.consume(E),E===92?w:p)}function w(E){return E===60||E===62||E===92?(e.consume(E),p):p(E)}function S(E){return!x&&(E===null||E===41||ln(E))?(e.exit("chunkString"),e.exit(f),e.exit(u),e.exit(i),r(E)):x<h&&E===40?(e.consume(E),x++,S):E===41?(e.consume(E),x--,S):E===null||E===32||E===40||bu(E)?s(E):(e.consume(E),E===92?T:S)}function T(E){return E===40||E===41||E===92?(e.consume(E),S):S(E)}}function h1(e,r,s,i,o,c){const u=this;let f=0,m;return h;function h(p){return e.enter(i),e.enter(o),e.consume(p),e.exit(o),e.enter(c),x}function x(p){return f>999||p===null||p===91||p===93&&!m||p===94&&!f&&"_hiddenFootnoteSupport"in u.parser.constructs?s(p):p===93?(e.exit(c),e.enter(o),e.consume(p),e.exit(o),e.exit(i),r):ft(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),g(p))}function g(p){return p===null||p===91||p===93||ft(p)||f++>999?(e.exit("chunkString"),x(p)):(e.consume(p),m||(m=!zt(p)),p===92?b:g)}function b(p){return p===91||p===92||p===93?(e.consume(p),f++,g):g(p)}}function m1(e,r,s,i,o,c){let u;return f;function f(b){return b===34||b===39||b===40?(e.enter(i),e.enter(o),e.consume(b),e.exit(o),u=b===40?41:b,m):s(b)}function m(b){return b===u?(e.enter(o),e.consume(b),e.exit(o),e.exit(i),r):(e.enter(c),h(b))}function h(b){return b===u?(e.exit(c),m(u)):b===null?s(b):ft(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),qt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(b))}function x(b){return b===u||b===null||ft(b)?(e.exit("chunkString"),h(b)):(e.consume(b),b===92?g:x)}function g(b){return b===u||b===92?(e.consume(b),x):x(b)}}function uo(e,r){let s;return i;function i(o){return ft(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s=!0,i):zt(o)?qt(e,i,s?"linePrefix":"lineSuffix")(o):r(o)}}const sS={name:"definition",tokenize:iS},aS={partial:!0,tokenize:lS};function iS(e,r,s){const i=this;let o;return c;function c(p){return e.enter("definition"),u(p)}function u(p){return h1.call(i,e,f,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function f(p){return o=ts(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),m):s(p)}function m(p){return ln(p)?uo(e,h)(p):h(p)}function h(p){return f1(e,x,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function x(p){return e.attempt(aS,g,g)(p)}function g(p){return zt(p)?qt(e,b,"whitespace")(p):b(p)}function b(p){return p===null||ft(p)?(e.exit("definition"),i.parser.defined.push(o),r(p)):s(p)}}function lS(e,r,s){return i;function i(f){return ln(f)?uo(e,o)(f):s(f)}function o(f){return m1(e,c,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function c(f){return zt(f)?qt(e,u,"whitespace")(f):u(f)}function u(f){return f===null||ft(f)?r(f):s(f)}}const oS={name:"hardBreakEscape",tokenize:cS};function cS(e,r,s){return i;function i(c){return e.enter("hardBreakEscape"),e.consume(c),o}function o(c){return ft(c)?(e.exit("hardBreakEscape"),r(c)):s(c)}}const uS={name:"headingAtx",resolve:dS,tokenize:fS};function dS(e,r){let s=e.length-2,i=3,o,c;return e[i][1].type==="whitespace"&&(i+=2),s-2>i&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(i===s-1||s-4>i&&e[s-2][1].type==="whitespace")&&(s-=i+1===s?2:4),s>i&&(o={type:"atxHeadingText",start:e[i][1].start,end:e[s][1].end},c={type:"chunkText",start:e[i][1].start,end:e[s][1].end,contentType:"text"},Mr(e,i,s-i+1,[["enter",o,r],["enter",c,r],["exit",c,r],["exit",o,r]])),e}function fS(e,r,s){let i=0;return o;function o(x){return e.enter("atxHeading"),c(x)}function c(x){return e.enter("atxHeadingSequence"),u(x)}function u(x){return x===35&&i++<6?(e.consume(x),u):x===null||ln(x)?(e.exit("atxHeadingSequence"),f(x)):s(x)}function f(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||ft(x)?(e.exit("atxHeading"),r(x)):zt(x)?qt(e,f,"whitespace")(x):(e.enter("atxHeadingText"),h(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),f(x))}function h(x){return x===null||x===35||ln(x)?(e.exit("atxHeadingText"),f(x)):(e.consume(x),h)}}const hS=["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"],Eb=["pre","script","style","textarea"],mS={concrete:!0,name:"htmlFlow",resolveTo:pS,tokenize:bS},xS={partial:!0,tokenize:vS},gS={partial:!0,tokenize:yS};function pS(e){let r=e.length;for(;r--&&!(e[r][0]==="enter"&&e[r][1].type==="htmlFlow"););return r>1&&e[r-2][1].type==="linePrefix"&&(e[r][1].start=e[r-2][1].start,e[r+1][1].start=e[r-2][1].start,e.splice(r-2,2)),e}function bS(e,r,s){const i=this;let o,c,u,f,m;return h;function h(R){return x(R)}function x(R){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(R),g}function g(R){return R===33?(e.consume(R),b):R===47?(e.consume(R),c=!0,S):R===63?(e.consume(R),o=3,i.interrupt?r:B):sr(R)?(e.consume(R),u=String.fromCharCode(R),T):s(R)}function b(R){return R===45?(e.consume(R),o=2,p):R===91?(e.consume(R),o=5,f=0,w):sr(R)?(e.consume(R),o=4,i.interrupt?r:B):s(R)}function p(R){return R===45?(e.consume(R),i.interrupt?r:B):s(R)}function w(R){const z="CDATA[";return R===z.charCodeAt(f++)?(e.consume(R),f===z.length?i.interrupt?r:F:w):s(R)}function S(R){return sr(R)?(e.consume(R),u=String.fromCharCode(R),T):s(R)}function T(R){if(R===null||R===47||R===62||ln(R)){const z=R===47,V=u.toLowerCase();return!z&&!c&&Eb.includes(V)?(o=1,i.interrupt?r(R):F(R)):hS.includes(u.toLowerCase())?(o=6,z?(e.consume(R),E):i.interrupt?r(R):F(R)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?s(R):c?C(R):N(R))}return R===45||Wn(R)?(e.consume(R),u+=String.fromCharCode(R),T):s(R)}function E(R){return R===62?(e.consume(R),i.interrupt?r:F):s(R)}function C(R){return zt(R)?(e.consume(R),C):P(R)}function N(R){return R===47?(e.consume(R),P):R===58||R===95||sr(R)?(e.consume(R),k):zt(R)?(e.consume(R),N):P(R)}function k(R){return R===45||R===46||R===58||R===95||Wn(R)?(e.consume(R),k):H(R)}function H(R){return R===61?(e.consume(R),M):zt(R)?(e.consume(R),H):N(R)}function M(R){return R===null||R===60||R===61||R===62||R===96?s(R):R===34||R===39?(e.consume(R),m=R,Y):zt(R)?(e.consume(R),M):$(R)}function Y(R){return R===m?(e.consume(R),m=null,X):R===null||ft(R)?s(R):(e.consume(R),Y)}function $(R){return R===null||R===34||R===39||R===47||R===60||R===61||R===62||R===96||ln(R)?H(R):(e.consume(R),$)}function X(R){return R===47||R===62||zt(R)?N(R):s(R)}function P(R){return R===62?(e.consume(R),q):s(R)}function q(R){return R===null||ft(R)?F(R):zt(R)?(e.consume(R),q):s(R)}function F(R){return R===45&&o===2?(e.consume(R),A):R===60&&o===1?(e.consume(R),G):R===62&&o===4?(e.consume(R),L):R===63&&o===3?(e.consume(R),B):R===93&&o===5?(e.consume(R),K):ft(R)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(xS,W,D)(R)):R===null||ft(R)?(e.exit("htmlFlowData"),D(R)):(e.consume(R),F)}function D(R){return e.check(gS,_,W)(R)}function _(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),I}function I(R){return R===null||ft(R)?D(R):(e.enter("htmlFlowData"),F(R))}function A(R){return R===45?(e.consume(R),B):F(R)}function G(R){return R===47?(e.consume(R),u="",U):F(R)}function U(R){if(R===62){const z=u.toLowerCase();return Eb.includes(z)?(e.consume(R),L):F(R)}return sr(R)&&u.length<8?(e.consume(R),u+=String.fromCharCode(R),U):F(R)}function K(R){return R===93?(e.consume(R),B):F(R)}function B(R){return R===62?(e.consume(R),L):R===45&&o===2?(e.consume(R),B):F(R)}function L(R){return R===null||ft(R)?(e.exit("htmlFlowData"),W(R)):(e.consume(R),L)}function W(R){return e.exit("htmlFlow"),r(R)}}function yS(e,r,s){const i=this;return o;function o(u){return ft(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):s(u)}function c(u){return i.parser.lazy[i.now().line]?s(u):r(u)}}function vS(e,r,s){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Mo,r,s)}}const jS={name:"htmlText",tokenize:wS};function wS(e,r,s){const i=this;let o,c,u;return f;function f(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),h):B===47?(e.consume(B),H):B===63?(e.consume(B),N):sr(B)?(e.consume(B),$):s(B)}function h(B){return B===45?(e.consume(B),x):B===91?(e.consume(B),c=0,w):sr(B)?(e.consume(B),C):s(B)}function x(B){return B===45?(e.consume(B),p):s(B)}function g(B){return B===null?s(B):B===45?(e.consume(B),b):ft(B)?(u=g,G(B)):(e.consume(B),g)}function b(B){return B===45?(e.consume(B),p):g(B)}function p(B){return B===62?A(B):B===45?b(B):g(B)}function w(B){const L="CDATA[";return B===L.charCodeAt(c++)?(e.consume(B),c===L.length?S:w):s(B)}function S(B){return B===null?s(B):B===93?(e.consume(B),T):ft(B)?(u=S,G(B)):(e.consume(B),S)}function T(B){return B===93?(e.consume(B),E):S(B)}function E(B){return B===62?A(B):B===93?(e.consume(B),E):S(B)}function C(B){return B===null||B===62?A(B):ft(B)?(u=C,G(B)):(e.consume(B),C)}function N(B){return B===null?s(B):B===63?(e.consume(B),k):ft(B)?(u=N,G(B)):(e.consume(B),N)}function k(B){return B===62?A(B):N(B)}function H(B){return sr(B)?(e.consume(B),M):s(B)}function M(B){return B===45||Wn(B)?(e.consume(B),M):Y(B)}function Y(B){return ft(B)?(u=Y,G(B)):zt(B)?(e.consume(B),Y):A(B)}function $(B){return B===45||Wn(B)?(e.consume(B),$):B===47||B===62||ln(B)?X(B):s(B)}function X(B){return B===47?(e.consume(B),A):B===58||B===95||sr(B)?(e.consume(B),P):ft(B)?(u=X,G(B)):zt(B)?(e.consume(B),X):A(B)}function P(B){return B===45||B===46||B===58||B===95||Wn(B)?(e.consume(B),P):q(B)}function q(B){return B===61?(e.consume(B),F):ft(B)?(u=q,G(B)):zt(B)?(e.consume(B),q):X(B)}function F(B){return B===null||B===60||B===61||B===62||B===96?s(B):B===34||B===39?(e.consume(B),o=B,D):ft(B)?(u=F,G(B)):zt(B)?(e.consume(B),F):(e.consume(B),_)}function D(B){return B===o?(e.consume(B),o=void 0,I):B===null?s(B):ft(B)?(u=D,G(B)):(e.consume(B),D)}function _(B){return B===null||B===34||B===39||B===60||B===61||B===96?s(B):B===47||B===62||ln(B)?X(B):(e.consume(B),_)}function I(B){return B===47||B===62||ln(B)?X(B):s(B)}function A(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),r):s(B)}function G(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),U}function U(B){return zt(B)?qt(e,K,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):K(B)}function K(B){return e.enter("htmlTextData"),u(B)}}const Hm={name:"labelEnd",resolveAll:CS,resolveTo:ES,tokenize:TS},NS={tokenize:_S},kS={tokenize:AS},SS={tokenize:MS};function CS(e){let r=-1;const s=[];for(;++r<e.length;){const i=e[r][1];if(s.push(e[r]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const o=i.type==="labelImage"?4:2;i.type="data",r+=o}}return e.length!==s.length&&Mr(e,0,e.length,s),e}function ES(e,r){let s=e.length,i=0,o,c,u,f;for(;s--;)if(o=e[s][1],c){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[s][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(u){if(e[s][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(c=s,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(u=s);const m={type:e[c][1].type==="labelLink"?"link":"image",start:{...e[c][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[c][1].start},end:{...e[u][1].end}},x={type:"labelText",start:{...e[c+i+2][1].end},end:{...e[u-2][1].start}};return f=[["enter",m,r],["enter",h,r]],f=Yr(f,e.slice(c+1,c+i+3)),f=Yr(f,[["enter",x,r]]),f=Yr(f,Pu(r.parser.constructs.insideSpan.null,e.slice(c+i+4,u-3),r)),f=Yr(f,[["exit",x,r],e[u-2],e[u-1],["exit",h,r]]),f=Yr(f,e.slice(u+1)),f=Yr(f,[["exit",m,r]]),Mr(e,c,e.length,f),e}function TS(e,r,s){const i=this;let o=i.events.length,c,u;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){c=i.events[o][1];break}return f;function f(b){return c?c._inactive?g(b):(u=i.parser.defined.includes(ts(i.sliceSerialize({start:c.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(b),e.exit("labelMarker"),e.exit("labelEnd"),m):s(b)}function m(b){return b===40?e.attempt(NS,x,u?x:g)(b):b===91?e.attempt(kS,x,u?h:g)(b):u?x(b):g(b)}function h(b){return e.attempt(SS,x,g)(b)}function x(b){return r(b)}function g(b){return c._balanced=!0,s(b)}}function _S(e,r,s){return i;function i(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return ln(g)?uo(e,c)(g):c(g)}function c(g){return g===41?x(g):f1(e,u,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function u(g){return ln(g)?uo(e,m)(g):x(g)}function f(g){return s(g)}function m(g){return g===34||g===39||g===40?m1(e,h,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function h(g){return ln(g)?uo(e,x)(g):x(g)}function x(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),r):s(g)}}function AS(e,r,s){const i=this;return o;function o(f){return h1.call(i,e,c,u,"reference","referenceMarker","referenceString")(f)}function c(f){return i.parser.defined.includes(ts(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?r(f):s(f)}function u(f){return s(f)}}function MS(e,r,s){return i;function i(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),o}function o(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),r):s(c)}}const DS={name:"labelStartImage",resolveAll:Hm.resolveAll,tokenize:OS};function OS(e,r,s){const i=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),c}function c(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),u):s(f)}function u(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?s(f):r(f)}}const RS={name:"labelStartLink",resolveAll:Hm.resolveAll,tokenize:zS};function zS(e,r,s){const i=this;return o;function o(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),c}function c(u){return u===94&&"_hiddenFootnoteSupport"in i.parser.constructs?s(u):r(u)}}const xh={name:"lineEnding",tokenize:LS};function LS(e,r){return s;function s(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),qt(e,r,"linePrefix")}}const uu={name:"thematicBreak",tokenize:IS};function IS(e,r,s){let i=0,o;return c;function c(h){return e.enter("thematicBreak"),u(h)}function u(h){return o=h,f(h)}function f(h){return h===o?(e.enter("thematicBreakSequence"),m(h)):i>=3&&(h===null||ft(h))?(e.exit("thematicBreak"),r(h)):s(h)}function m(h){return h===o?(e.consume(h),i++,m):(e.exit("thematicBreakSequence"),zt(h)?qt(e,f,"whitespace")(h):f(h))}}const gr={continuation:{tokenize:PS},exit:qS,name:"list",tokenize:HS},$S={partial:!0,tokenize:VS},BS={partial:!0,tokenize:US};function HS(e,r,s){const i=this,o=i.events[i.events.length-1];let c=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,u=0;return f;function f(p){const w=i.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||p===i.containerState.marker:sm(p)){if(i.containerState.type||(i.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(uu,s,h)(p):h(p);if(!i.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(p)}return s(p)}function m(p){return sm(p)&&++u<10?(e.consume(p),m):(!i.interrupt||u<2)&&(i.containerState.marker?p===i.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),h(p)):s(p)}function h(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||p,e.check(Mo,i.interrupt?s:x,e.attempt($S,b,g))}function x(p){return i.containerState.initialBlankLine=!0,c++,b(p)}function g(p){return zt(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),b):s(p)}function b(p){return i.containerState.size=c+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,r(p)}}function PS(e,r,s){const i=this;return i.containerState._closeFlow=void 0,e.check(Mo,o,c);function o(f){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,qt(e,r,"listItemIndent",i.containerState.size+1)(f)}function c(f){return i.containerState.furtherBlankLines||!zt(f)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,u(f)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(BS,r,u)(f))}function u(f){return i.containerState._closeFlow=!0,i.interrupt=void 0,qt(e,e.attempt(gr,r,s),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function US(e,r,s){const i=this;return qt(e,o,"listItemIndent",i.containerState.size+1);function o(c){const u=i.events[i.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===i.containerState.size?r(c):s(c)}}function qS(e){e.exit(this.containerState.type)}function VS(e,r,s){const i=this;return qt(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(c){const u=i.events[i.events.length-1];return!zt(c)&&u&&u[1].type==="listItemPrefixWhitespace"?r(c):s(c)}}const Tb={name:"setextUnderline",resolveTo:FS,tokenize:YS};function FS(e,r){let s=e.length,i,o,c;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){i=s;break}e[s][1].type==="paragraph"&&(o=s)}else e[s][1].type==="content"&&e.splice(s,1),!c&&e[s][1].type==="definition"&&(c=s);const u={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",c?(e.splice(o,0,["enter",u,r]),e.splice(c+1,0,["exit",e[i][1],r]),e[i][1].end={...e[c][1].end}):e[i][1]=u,e.push(["exit",u,r]),e}function YS(e,r,s){const i=this;let o;return c;function c(h){let x=i.events.length,g;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){g=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(e.enter("setextHeadingLine"),o=h,u(h)):s(h)}function u(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===o?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),zt(h)?qt(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||ft(h)?(e.exit("setextHeadingLine"),r(h)):s(h)}}const GS={tokenize:XS};function XS(e){const r=this,s=e.attempt(Mo,i,e.attempt(this.parser.constructs.flowInitial,o,qt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Wk,o)),"linePrefix")));return s;function i(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),r.currentConstruct=void 0,s}function o(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),r.currentConstruct=void 0,s}}const ZS={resolveAll:g1()},QS=x1("string"),KS=x1("text");function x1(e){return{resolveAll:g1(e==="text"?JS:void 0),tokenize:r};function r(s){const i=this,o=this.parser.constructs[e],c=s.attempt(o,u,f);return u;function u(x){return h(x)?c(x):f(x)}function f(x){if(x===null){s.consume(x);return}return s.enter("data"),s.consume(x),m}function m(x){return h(x)?(s.exit("data"),c(x)):(s.consume(x),m)}function h(x){if(x===null)return!0;const g=o[x];let b=-1;if(g)for(;++b<g.length;){const p=g[b];if(!p.previous||p.previous.call(i,i.previous))return!0}return!1}}}function g1(e){return r;function r(s,i){let o=-1,c;for(;++o<=s.length;)c===void 0?s[o]&&s[o][1].type==="data"&&(c=o,o++):(!s[o]||s[o][1].type!=="data")&&(o!==c+2&&(s[c][1].end=s[o-1][1].end,s.splice(c+2,o-c-2),o=c+2),c=void 0);return e?e(s,i):s}}function JS(e,r){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const i=e[s-1][1],o=r.sliceStream(i);let c=o.length,u=-1,f=0,m;for(;c--;){const h=o[c];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)f++,u--;if(u)break;u=-1}else if(h===-2)m=!0,f++;else if(h!==-1){c++;break}}if(r._contentTypeTextTrailing&&s===e.length&&(f=0),f){const h={type:s===e.length||m||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?u:i.start._bufferIndex+u,_index:i.start._index+c,line:i.end.line,column:i.end.column-f,offset:i.end.offset-f},end:{...i.end}};i.end={...h.start},i.start.offset===i.end.offset?Object.assign(i,h):(e.splice(s,0,["enter",h,r],["exit",h,r]),s+=2)}s++}return e}const WS={42:gr,43:gr,45:gr,48:gr,49:gr,50:gr,51:gr,52:gr,53:gr,54:gr,55:gr,56:gr,57:gr,62:o1},eC={91:sS},tC={[-2]:mh,[-1]:mh,32:mh},nC={35:uS,42:uu,45:[Tb,uu],60:mS,61:Tb,95:uu,96:Cb,126:Cb},rC={38:u1,92:c1},sC={[-5]:xh,[-4]:xh,[-3]:xh,33:DS,38:u1,42:am,60:[Rk,jS],91:RS,92:[oS,c1],93:Hm,95:am,96:Gk},aC={null:[am,ZS]},iC={null:[42,95]},lC={null:[]},oC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:iC,contentInitial:eC,disable:lC,document:WS,flow:nC,flowInitial:tC,insideSpan:aC,string:rC,text:sC},Symbol.toStringTag,{value:"Module"}));function cC(e,r,s){let i={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const o={},c=[];let u=[],f=[];const m={attempt:Y(H),check:Y(M),consume:C,enter:N,exit:k,interrupt:Y(M,{interrupt:!0})},h={code:null,containerState:{},defineSkip:S,events:[],now:w,parser:e,previous:null,sliceSerialize:b,sliceStream:p,write:g};let x=r.tokenize.call(h,m);return r.resolveAll&&c.push(r),h;function g(q){return u=Yr(u,q),T(),u[u.length-1]!==null?[]:($(r,0),h.events=Pu(c,h.events,h),h.events)}function b(q,F){return dC(p(q),F)}function p(q){return uC(u,q)}function w(){const{_bufferIndex:q,_index:F,line:D,column:_,offset:I}=i;return{_bufferIndex:q,_index:F,line:D,column:_,offset:I}}function S(q){o[q.line]=q.column,P()}function T(){let q;for(;i._index<u.length;){const F=u[i._index];if(typeof F=="string")for(q=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===q&&i._bufferIndex<F.length;)E(F.charCodeAt(i._bufferIndex));else E(F)}}function E(q){x=x(q)}function C(q){ft(q)?(i.line++,i.column=1,i.offset+=q===-3?2:1,P()):q!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===u[i._index].length&&(i._bufferIndex=-1,i._index++)),h.previous=q}function N(q,F){const D=F||{};return D.type=q,D.start=w(),h.events.push(["enter",D,h]),f.push(D),D}function k(q){const F=f.pop();return F.end=w(),h.events.push(["exit",F,h]),F}function H(q,F){$(q,F.from)}function M(q,F){F.restore()}function Y(q,F){return D;function D(_,I,A){let G,U,K,B;return Array.isArray(_)?W(_):"tokenize"in _?W([_]):L(_);function L(Q){return te;function te(Z){const ee=Z!==null&&Q[Z],ie=Z!==null&&Q.null,je=[...Array.isArray(ee)?ee:ee?[ee]:[],...Array.isArray(ie)?ie:ie?[ie]:[]];return W(je)(Z)}}function W(Q){return G=Q,U=0,Q.length===0?A:R(Q[U])}function R(Q){return te;function te(Z){return B=X(),K=Q,Q.partial||(h.currentConstruct=Q),Q.name&&h.parser.constructs.disable.null.includes(Q.name)?V():Q.tokenize.call(F?Object.assign(Object.create(h),F):h,m,z,V)(Z)}}function z(Q){return q(K,B),I}function V(Q){return B.restore(),++U<G.length?R(G[U]):A}}}function $(q,F){q.resolveAll&&!c.includes(q)&&c.push(q),q.resolve&&Mr(h.events,F,h.events.length-F,q.resolve(h.events.slice(F),h)),q.resolveTo&&(h.events=q.resolveTo(h.events,h))}function X(){const q=w(),F=h.previous,D=h.currentConstruct,_=h.events.length,I=Array.from(f);return{from:_,restore:A};function A(){i=q,h.previous=F,h.currentConstruct=D,h.events.length=_,f=I,P()}}function P(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function uC(e,r){const s=r.start._index,i=r.start._bufferIndex,o=r.end._index,c=r.end._bufferIndex;let u;if(s===o)u=[e[s].slice(i,c)];else{if(u=e.slice(s,o),i>-1){const f=u[0];typeof f=="string"?u[0]=f.slice(i):u.shift()}c>0&&u.push(e[o].slice(0,c))}return u}function dC(e,r){let s=-1;const i=[];let o;for(;++s<e.length;){const c=e[s];let u;if(typeof c=="string")u=c;else switch(c){case-5:{u="\r";break}case-4:{u=`
|
|
13
|
-
`;break}case-3:{u=`\r
|
|
14
|
-
`;break}case-2:{u=r?" ":" ";break}case-1:{if(!r&&o)continue;u=" ";break}default:u=String.fromCharCode(c)}o=c===-2,i.push(u)}return i.join("")}function fC(e){const i={constructs:i1([oC,...(e||{}).extensions||[]]),content:o(Ek),defined:[],document:o(_k),flow:o(GS),lazy:{},string:o(QS),text:o(KS)};return i;function o(c){return u;function u(f){return cC(i,c,f)}}}function hC(e){for(;!d1(e););return e}const _b=/[\0\t\n\r]/g;function mC(){let e=1,r="",s=!0,i;return o;function o(c,u,f){const m=[];let h,x,g,b,p;for(c=r+(typeof c=="string"?c.toString():new TextDecoder(u||void 0).decode(c)),g=0,r="",s&&(c.charCodeAt(0)===65279&&g++,s=void 0);g<c.length;){if(_b.lastIndex=g,h=_b.exec(c),b=h&&h.index!==void 0?h.index:c.length,p=c.charCodeAt(b),!h){r=c.slice(g);break}if(p===10&&g===b&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),g<b&&(m.push(c.slice(g,b)),e+=b-g),p){case 0:{m.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,m.push(-2);e++<x;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:i=!0,e=1}g=b+1}return f&&(i&&m.push(-5),r&&m.push(r),m.push(null)),m}}const xC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function gC(e){return e.replace(xC,pC)}function pC(e,r,s){if(r)return r;if(s.charCodeAt(0)===35){const o=s.charCodeAt(1),c=o===120||o===88;return l1(s.slice(c?2:1),c?16:10)}return Bm(s)||e}const p1={}.hasOwnProperty;function bC(e,r,s){return r&&typeof r=="object"&&(s=r,r=void 0),yC(s)(hC(fC(s).document().write(mC()(e,r,!0))))}function yC(e){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(xt),autolinkProtocol:X,autolinkEmail:X,atxHeading:c(ze),blockQuote:c(ie),characterEscape:X,characterReference:X,codeFenced:c(je),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:c(je,u),codeText:c(ke,u),codeTextData:X,data:X,codeFlowValue:X,definition:c(De),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:c(Ie),hardBreakEscape:c(Ze),hardBreakTrailing:c(Ze),htmlFlow:c(Ae,u),htmlFlowData:X,htmlText:c(Ae,u),htmlTextData:X,image:c(We),label:u,link:c(xt),listItem:c(le),listItemValue:b,listOrdered:c(Lt,g),listUnordered:c(Lt),paragraph:c(_e),reference:R,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:c(ze),strong:c(ht),thematicBreak:c(Ft)},exit:{atxHeading:m(),atxHeadingSequence:H,autolink:m(),autolinkEmail:ee,autolinkProtocol:Z,blockQuote:m(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:Q,characterReference:te,codeFenced:m(T),codeFencedFence:S,codeFencedFenceInfo:p,codeFencedFenceMeta:w,codeFlowValue:P,codeIndented:m(E),codeText:m(I),codeTextData:P,data:P,definition:m(),definitionDestinationString:k,definitionLabelString:C,definitionTitleString:N,emphasis:m(),hardBreakEscape:m(F),hardBreakTrailing:m(F),htmlFlow:m(D),htmlFlowData:P,htmlText:m(_),htmlTextData:P,image:m(G),label:K,labelText:U,lineEnding:q,link:m(A),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:z,resourceDestinationString:B,resourceTitleString:L,resource:W,setextHeading:m($),setextHeadingLineSequence:Y,setextHeadingText:M,strong:m(),thematicBreak:m()}};b1(r,(e||{}).mdastExtensions||[]);const s={};return i;function i(be){let Me={type:"root",children:[]};const Ve={stack:[Me],tokenStack:[],config:r,enter:f,exit:h,buffer:u,resume:x,data:s},Xe=[];let rt=-1;for(;++rt<be.length;)if(be[rt][1].type==="listOrdered"||be[rt][1].type==="listUnordered")if(be[rt][0]==="enter")Xe.push(rt);else{const It=Xe.pop();rt=o(be,It,rt)}for(rt=-1;++rt<be.length;){const It=r[be[rt][0]];p1.call(It,be[rt][1].type)&&It[be[rt][1].type].call(Object.assign({sliceSerialize:be[rt][2].sliceSerialize},Ve),be[rt][1])}if(Ve.tokenStack.length>0){const It=Ve.tokenStack[Ve.tokenStack.length-1];(It[1]||Ab).call(Ve,void 0,It[0])}for(Me.position={start:ha(be.length>0?be[0][1].start:{line:1,column:1,offset:0}),end:ha(be.length>0?be[be.length-2][1].end:{line:1,column:1,offset:0})},rt=-1;++rt<r.transforms.length;)Me=r.transforms[rt](Me)||Me;return Me}function o(be,Me,Ve){let Xe=Me-1,rt=-1,It=!1,Ht,_t,wt,xe;for(;++Xe<=Ve;){const Be=be[Xe];switch(Be[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Be[0]==="enter"?rt++:rt--,xe=void 0;break}case"lineEndingBlank":{Be[0]==="enter"&&(Ht&&!xe&&!rt&&!wt&&(wt=Xe),xe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:xe=void 0}if(!rt&&Be[0]==="enter"&&Be[1].type==="listItemPrefix"||rt===-1&&Be[0]==="exit"&&(Be[1].type==="listUnordered"||Be[1].type==="listOrdered")){if(Ht){let gt=Xe;for(_t=void 0;gt--;){const pt=be[gt];if(pt[1].type==="lineEnding"||pt[1].type==="lineEndingBlank"){if(pt[0]==="exit")continue;_t&&(be[_t][1].type="lineEndingBlank",It=!0),pt[1].type="lineEnding",_t=gt}else if(!(pt[1].type==="linePrefix"||pt[1].type==="blockQuotePrefix"||pt[1].type==="blockQuotePrefixWhitespace"||pt[1].type==="blockQuoteMarker"||pt[1].type==="listItemIndent"))break}wt&&(!_t||wt<_t)&&(Ht._spread=!0),Ht.end=Object.assign({},_t?be[_t][1].start:Be[1].end),be.splice(_t||Xe,0,["exit",Ht,Be[2]]),Xe++,Ve++}if(Be[1].type==="listItemPrefix"){const gt={type:"listItem",_spread:!1,start:Object.assign({},Be[1].start),end:void 0};Ht=gt,be.splice(Xe,0,["enter",gt,Be[2]]),Xe++,Ve++,wt=void 0,xe=!0}}}return be[Me][1]._spread=It,Ve}function c(be,Me){return Ve;function Ve(Xe){f.call(this,be(Xe),Xe),Me&&Me.call(this,Xe)}}function u(){this.stack.push({type:"fragment",children:[]})}function f(be,Me,Ve){this.stack[this.stack.length-1].children.push(be),this.stack.push(be),this.tokenStack.push([Me,Ve||void 0]),be.position={start:ha(Me.start),end:void 0}}function m(be){return Me;function Me(Ve){be&&be.call(this,Ve),h.call(this,Ve)}}function h(be,Me){const Ve=this.stack.pop(),Xe=this.tokenStack.pop();if(Xe)Xe[0].type!==be.type&&(Me?Me.call(this,be,Xe[0]):(Xe[1]||Ab).call(this,be,Xe[0]));else throw new Error("Cannot close `"+be.type+"` ("+co({start:be.start,end:be.end})+"): it’s not open");Ve.position.end=ha(be.end)}function x(){return $m(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function b(be){if(this.data.expectingFirstListItemValue){const Me=this.stack[this.stack.length-2];Me.start=Number.parseInt(this.sliceSerialize(be),10),this.data.expectingFirstListItemValue=void 0}}function p(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.lang=be}function w(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.meta=be}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function T(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.value=be.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.value=be.replace(/(\r?\n|\r)$/g,"")}function C(be){const Me=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=Me,Ve.identifier=ts(this.sliceSerialize(be)).toLowerCase()}function N(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.title=be}function k(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.url=be}function H(be){const Me=this.stack[this.stack.length-1];if(!Me.depth){const Ve=this.sliceSerialize(be).length;Me.depth=Ve}}function M(){this.data.setextHeadingSlurpLineEnding=!0}function Y(be){const Me=this.stack[this.stack.length-1];Me.depth=this.sliceSerialize(be).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function X(be){const Ve=this.stack[this.stack.length-1].children;let Xe=Ve[Ve.length-1];(!Xe||Xe.type!=="text")&&(Xe=Ct(),Xe.position={start:ha(be.start),end:void 0},Ve.push(Xe)),this.stack.push(Xe)}function P(be){const Me=this.stack.pop();Me.value+=this.sliceSerialize(be),Me.position.end=ha(be.end)}function q(be){const Me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ve=Me.children[Me.children.length-1];Ve.position.end=ha(be.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(Me.type)&&(X.call(this,be),P.call(this,be))}function F(){this.data.atHardBreak=!0}function D(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.value=be}function _(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.value=be}function I(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.value=be}function A(){const be=this.stack[this.stack.length-1];if(this.data.inReference){const Me=this.data.referenceType||"shortcut";be.type+="Reference",be.referenceType=Me,delete be.url,delete be.title}else delete be.identifier,delete be.label;this.data.referenceType=void 0}function G(){const be=this.stack[this.stack.length-1];if(this.data.inReference){const Me=this.data.referenceType||"shortcut";be.type+="Reference",be.referenceType=Me,delete be.url,delete be.title}else delete be.identifier,delete be.label;this.data.referenceType=void 0}function U(be){const Me=this.sliceSerialize(be),Ve=this.stack[this.stack.length-2];Ve.label=gC(Me),Ve.identifier=ts(Me).toLowerCase()}function K(){const be=this.stack[this.stack.length-1],Me=this.resume(),Ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ve.type==="link"){const Xe=be.children;Ve.children=Xe}else Ve.alt=Me}function B(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.url=be}function L(){const be=this.resume(),Me=this.stack[this.stack.length-1];Me.title=be}function W(){this.data.inReference=void 0}function R(){this.data.referenceType="collapsed"}function z(be){const Me=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=Me,Ve.identifier=ts(this.sliceSerialize(be)).toLowerCase(),this.data.referenceType="full"}function V(be){this.data.characterReferenceType=be.type}function Q(be){const Me=this.sliceSerialize(be),Ve=this.data.characterReferenceType;let Xe;Ve?(Xe=l1(Me,Ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Xe=Bm(Me);const rt=this.stack[this.stack.length-1];rt.value+=Xe}function te(be){const Me=this.stack.pop();Me.position.end=ha(be.end)}function Z(be){P.call(this,be);const Me=this.stack[this.stack.length-1];Me.url=this.sliceSerialize(be)}function ee(be){P.call(this,be);const Me=this.stack[this.stack.length-1];Me.url="mailto:"+this.sliceSerialize(be)}function ie(){return{type:"blockquote",children:[]}}function je(){return{type:"code",lang:null,meta:null,value:""}}function ke(){return{type:"inlineCode",value:""}}function De(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ie(){return{type:"emphasis",children:[]}}function ze(){return{type:"heading",depth:0,children:[]}}function Ze(){return{type:"break"}}function Ae(){return{type:"html",value:""}}function We(){return{type:"image",title:null,url:"",alt:null}}function xt(){return{type:"link",title:null,url:"",children:[]}}function Lt(be){return{type:"list",ordered:be.type==="listOrdered",start:null,spread:be._spread,children:[]}}function le(be){return{type:"listItem",spread:be._spread,checked:null,children:[]}}function _e(){return{type:"paragraph",children:[]}}function ht(){return{type:"strong",children:[]}}function Ct(){return{type:"text",value:""}}function Ft(){return{type:"thematicBreak"}}}function ha(e){return{line:e.line,column:e.column,offset:e.offset}}function b1(e,r){let s=-1;for(;++s<r.length;){const i=r[s];Array.isArray(i)?b1(e,i):vC(e,i)}}function vC(e,r){let s;for(s in r)if(p1.call(r,s))switch(s){case"canContainEols":{const i=r[s];i&&e[s].push(...i);break}case"transforms":{const i=r[s];i&&e[s].push(...i);break}case"enter":case"exit":{const i=r[s];i&&Object.assign(e[s],i);break}}}function Ab(e,r){throw e?new Error("Cannot close `"+e.type+"` ("+co({start:e.start,end:e.end})+"): a different token (`"+r.type+"`, "+co({start:r.start,end:r.end})+") is open"):new Error("Cannot close document, a token (`"+r.type+"`, "+co({start:r.start,end:r.end})+") is still open")}function jC(e){const r=this;r.parser=s;function s(i){return bC(i,{...r.data("settings"),...e,extensions:r.data("micromarkExtensions")||[],mdastExtensions:r.data("fromMarkdownExtensions")||[]})}}function wC(e,r){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(r),!0)};return e.patch(r,s),e.applyData(r,s)}function NC(e,r){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(r,s),[e.applyData(r,s),{type:"text",value:`
|
|
15
|
-
`}]}function kC(e,r){const s=r.value?r.value+`
|
|
16
|
-
`:"",i={},o=r.lang?r.lang.split(/\s+/):[];o.length>0&&(i.className=["language-"+o[0]]);let c={type:"element",tagName:"code",properties:i,children:[{type:"text",value:s}]};return r.meta&&(c.data={meta:r.meta}),e.patch(r,c),c=e.applyData(r,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(r,c),c}function SC(e,r){const s={type:"element",tagName:"del",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function CC(e,r){const s={type:"element",tagName:"em",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function EC(e,r){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(r.identifier).toUpperCase(),o=nl(i.toLowerCase()),c=e.footnoteOrder.indexOf(i);let u,f=e.footnoteCounts.get(i);f===void 0?(f=0,e.footnoteOrder.push(i),u=e.footnoteOrder.length):u=c+1,f+=1,e.footnoteCounts.set(i,f);const m={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(r,m);const h={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(r,h),e.applyData(r,h)}function TC(e,r){const s={type:"element",tagName:"h"+r.depth,properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function _C(e,r){if(e.options.allowDangerousHtml){const s={type:"raw",value:r.value};return e.patch(r,s),e.applyData(r,s)}}function y1(e,r){const s=r.referenceType;let i="]";if(s==="collapsed"?i+="[]":s==="full"&&(i+="["+(r.label||r.identifier)+"]"),r.type==="imageReference")return[{type:"text",value:"!["+r.alt+i}];const o=e.all(r),c=o[0];c&&c.type==="text"?c.value="["+c.value:o.unshift({type:"text",value:"["});const u=o[o.length-1];return u&&u.type==="text"?u.value+=i:o.push({type:"text",value:i}),o}function AC(e,r){const s=String(r.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return y1(e,r);const o={src:nl(i.url||""),alt:r.alt};i.title!==null&&i.title!==void 0&&(o.title=i.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(r,c),e.applyData(r,c)}function MC(e,r){const s={src:nl(r.url)};r.alt!==null&&r.alt!==void 0&&(s.alt=r.alt),r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(r,i),e.applyData(r,i)}function DC(e,r){const s={type:"text",value:r.value.replace(/\r?\n|\r/g," ")};e.patch(r,s);const i={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(r,i),e.applyData(r,i)}function OC(e,r){const s=String(r.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return y1(e,r);const o={href:nl(i.url||"")};i.title!==null&&i.title!==void 0&&(o.title=i.title);const c={type:"element",tagName:"a",properties:o,children:e.all(r)};return e.patch(r,c),e.applyData(r,c)}function RC(e,r){const s={href:nl(r.url)};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:e.all(r)};return e.patch(r,i),e.applyData(r,i)}function zC(e,r,s){const i=e.all(r),o=s?LC(s):v1(r),c={},u=[];if(typeof r.checked=="boolean"){const x=i[0];let g;x&&x.type==="element"&&x.tagName==="p"?g=x:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:r.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let f=-1;for(;++f<i.length;){const x=i[f];(o||f!==0||x.type!=="element"||x.tagName!=="p")&&u.push({type:"text",value:`
|
|
17
|
-
`}),x.type==="element"&&x.tagName==="p"&&!o?u.push(...x.children):u.push(x)}const m=i[i.length-1];m&&(o||m.type!=="element"||m.tagName!=="p")&&u.push({type:"text",value:`
|
|
18
|
-
`});const h={type:"element",tagName:"li",properties:c,children:u};return e.patch(r,h),e.applyData(r,h)}function LC(e){let r=!1;if(e.type==="list"){r=e.spread||!1;const s=e.children;let i=-1;for(;!r&&++i<s.length;)r=v1(s[i])}return r}function v1(e){const r=e.spread;return r??e.children.length>1}function IC(e,r){const s={},i=e.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(s.start=r.start);++o<i.length;){const u=i[o];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const c={type:"element",tagName:r.ordered?"ol":"ul",properties:s,children:e.wrap(i,!0)};return e.patch(r,c),e.applyData(r,c)}function $C(e,r){const s={type:"element",tagName:"p",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function BC(e,r){const s={type:"root",children:e.wrap(e.all(r))};return e.patch(r,s),e.applyData(r,s)}function HC(e,r){const s={type:"element",tagName:"strong",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function PC(e,r){const s=e.all(r),i=s.shift(),o=[];if(i){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(r.children[0],u),o.push(u)}if(s.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},f=Rm(r.children[1]),m=Wv(r.children[r.children.length-1]);f&&m&&(u.position={start:f,end:m}),o.push(u)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(r,c),e.applyData(r,c)}function UC(e,r,s){const i=s?s.children:void 0,c=(i?i.indexOf(r):1)===0?"th":"td",u=s&&s.type==="table"?s.align:void 0,f=u?u.length:r.children.length;let m=-1;const h=[];for(;++m<f;){const g=r.children[m],b={},p=u?u[m]:void 0;p&&(b.align=p);let w={type:"element",tagName:c,properties:b,children:[]};g&&(w.children=e.all(g),e.patch(g,w),w=e.applyData(g,w)),h.push(w)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(r,x),e.applyData(r,x)}function qC(e,r){const s={type:"element",tagName:"td",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}const Mb=9,Db=32;function VC(e){const r=String(e),s=/\r?\n|\r/g;let i=s.exec(r),o=0;const c=[];for(;i;)c.push(Ob(r.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=s.exec(r);return c.push(Ob(r.slice(o),o>0,!1)),c.join("")}function Ob(e,r,s){let i=0,o=e.length;if(r){let c=e.codePointAt(i);for(;c===Mb||c===Db;)i++,c=e.codePointAt(i)}if(s){let c=e.codePointAt(o-1);for(;c===Mb||c===Db;)o--,c=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function FC(e,r){const s={type:"text",value:VC(String(r.value))};return e.patch(r,s),e.applyData(r,s)}function YC(e,r){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(r,s),e.applyData(r,s)}const GC={blockquote:wC,break:NC,code:kC,delete:SC,emphasis:CC,footnoteReference:EC,heading:TC,html:_C,imageReference:AC,image:MC,inlineCode:DC,linkReference:OC,link:RC,listItem:zC,list:IC,paragraph:$C,root:BC,strong:HC,table:PC,tableCell:qC,tableRow:UC,text:FC,thematicBreak:YC,toml:Zc,yaml:Zc,definition:Zc,footnoteDefinition:Zc};function Zc(){}const j1=-1,Uu=0,fo=1,yu=2,Pm=3,Um=4,qm=5,Vm=6,w1=7,N1=8,Rb=typeof self=="object"?self:globalThis,XC=(e,r)=>{const s=(o,c)=>(e.set(c,o),o),i=o=>{if(e.has(o))return e.get(o);const[c,u]=r[o];switch(c){case Uu:case j1:return s(u,o);case fo:{const f=s([],o);for(const m of u)f.push(i(m));return f}case yu:{const f=s({},o);for(const[m,h]of u)f[i(m)]=i(h);return f}case Pm:return s(new Date(u),o);case Um:{const{source:f,flags:m}=u;return s(new RegExp(f,m),o)}case qm:{const f=s(new Map,o);for(const[m,h]of u)f.set(i(m),i(h));return f}case Vm:{const f=s(new Set,o);for(const m of u)f.add(i(m));return f}case w1:{const{name:f,message:m}=u;return s(new Rb[f](m),o)}case N1:return s(BigInt(u),o);case"BigInt":return s(Object(BigInt(u)),o);case"ArrayBuffer":return s(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:f}=new Uint8Array(u);return s(new DataView(f),u)}}return s(new Rb[c](u),o)};return i},zb=e=>XC(new Map,e)(0),Oi="",{toString:ZC}={},{keys:QC}=Object,Kl=e=>{const r=typeof e;if(r!=="object"||!e)return[Uu,r];const s=ZC.call(e).slice(8,-1);switch(s){case"Array":return[fo,Oi];case"Object":return[yu,Oi];case"Date":return[Pm,Oi];case"RegExp":return[Um,Oi];case"Map":return[qm,Oi];case"Set":return[Vm,Oi];case"DataView":return[fo,s]}return s.includes("Array")?[fo,s]:s.includes("Error")?[w1,s]:[yu,s]},Qc=([e,r])=>e===Uu&&(r==="function"||r==="symbol"),KC=(e,r,s,i)=>{const o=(u,f)=>{const m=i.push(u)-1;return s.set(f,m),m},c=u=>{if(s.has(u))return s.get(u);let[f,m]=Kl(u);switch(f){case Uu:{let x=u;switch(m){case"bigint":f=N1,x=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return o([j1],u)}return o([f,x],u)}case fo:{if(m){let b=u;return m==="DataView"?b=new Uint8Array(u.buffer):m==="ArrayBuffer"&&(b=new Uint8Array(u)),o([m,[...b]],u)}const x=[],g=o([f,x],u);for(const b of u)x.push(c(b));return g}case yu:{if(m)switch(m){case"BigInt":return o([m,u.toString()],u);case"Boolean":case"Number":case"String":return o([m,u.valueOf()],u)}if(r&&"toJSON"in u)return c(u.toJSON());const x=[],g=o([f,x],u);for(const b of QC(u))(e||!Qc(Kl(u[b])))&&x.push([c(b),c(u[b])]);return g}case Pm:return o([f,u.toISOString()],u);case Um:{const{source:x,flags:g}=u;return o([f,{source:x,flags:g}],u)}case qm:{const x=[],g=o([f,x],u);for(const[b,p]of u)(e||!(Qc(Kl(b))||Qc(Kl(p))))&&x.push([c(b),c(p)]);return g}case Vm:{const x=[],g=o([f,x],u);for(const b of u)(e||!Qc(Kl(b)))&&x.push(c(b));return g}}const{message:h}=u;return o([f,{name:m,message:h}],u)};return c},Lb=(e,{json:r,lossy:s}={})=>{const i=[];return KC(!(r||s),!!r,new Map,i)(e),i},vu=typeof structuredClone=="function"?(e,r)=>r&&("json"in r||"lossy"in r)?zb(Lb(e,r)):structuredClone(e):(e,r)=>zb(Lb(e,r));function JC(e,r){const s=[{type:"text",value:"↩"}];return r>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),s}function WC(e,r){return"Back to reference "+(e+1)+(r>1?"-"+r:"")}function eE(e){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||JC,i=e.options.footnoteBackLabel||WC,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let m=-1;for(;++m<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[m]);if(!h)continue;const x=e.all(h),g=String(h.identifier).toUpperCase(),b=nl(g.toLowerCase());let p=0;const w=[],S=e.footnoteCounts.get(g);for(;S!==void 0&&++p<=S;){w.length>0&&w.push({type:"text",value:" "});let C=typeof s=="string"?s:s(m,p);typeof C=="string"&&(C={type:"text",value:C}),w.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+b+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(m,p),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const T=x[x.length-1];if(T&&T.type==="element"&&T.tagName==="p"){const C=T.children[T.children.length-1];C&&C.type==="text"?C.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...w)}else x.push(...w);const E={type:"element",tagName:"li",properties:{id:r+"fn-"+b},children:e.wrap(x,!0)};e.patch(h,E),f.push(E)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...vu(u),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
|
|
19
|
-
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:`
|
|
20
|
-
`}]}}const qu=(function(e){if(e==null)return sE;if(typeof e=="function")return Vu(e);if(typeof e=="object")return Array.isArray(e)?tE(e):nE(e);if(typeof e=="string")return rE(e);throw new Error("Expected function, string, or object as test")});function tE(e){const r=[];let s=-1;for(;++s<e.length;)r[s]=qu(e[s]);return Vu(i);function i(...o){let c=-1;for(;++c<r.length;)if(r[c].apply(this,o))return!0;return!1}}function nE(e){const r=e;return Vu(s);function s(i){const o=i;let c;for(c in e)if(o[c]!==r[c])return!1;return!0}}function rE(e){return Vu(r);function r(s){return s&&s.type===e}}function Vu(e){return r;function r(s,i,o){return!!(aE(s)&&e.call(this,s,typeof i=="number"?i:void 0,o||void 0))}}function sE(){return!0}function aE(e){return e!==null&&typeof e=="object"&&"type"in e}const k1=[],iE=!0,im=!1,lE="skip";function S1(e,r,s,i){let o;typeof r=="function"&&typeof s!="function"?(i=s,s=r):o=r;const c=qu(o),u=i?-1:1;f(e,void 0,[])();function f(m,h,x){const g=m&&typeof m=="object"?m:{};if(typeof g.type=="string"){const p=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(m.type+(p?"<"+p+">":""))+")"})}return b;function b(){let p=k1,w,S,T;if((!r||c(m,h,x[x.length-1]||void 0))&&(p=oE(s(m,x)),p[0]===im))return p;if("children"in m&&m.children){const E=m;if(E.children&&p[0]!==lE)for(S=(i?E.children.length:-1)+u,T=x.concat(E);S>-1&&S<E.children.length;){const C=E.children[S];if(w=f(C,S,T)(),w[0]===im)return w;S=typeof w[1]=="number"?w[1]:S+u}}return p}}}function oE(e){return Array.isArray(e)?e:typeof e=="number"?[iE,e]:e==null?k1:[e]}function Fm(e,r,s,i){let o,c,u;typeof r=="function"&&typeof s!="function"?(c=void 0,u=r,o=s):(c=r,u=s,o=i),S1(e,c,f,o);function f(m,h){const x=h[h.length-1],g=x?x.children.indexOf(m):void 0;return u(m,g,x)}}const lm={}.hasOwnProperty,cE={};function uE(e,r){const s=r||cE,i=new Map,o=new Map,c=new Map,u={...GC,...s.handlers},f={all:h,applyData:fE,definitionById:i,footnoteById:o,footnoteCounts:c,footnoteOrder:[],handlers:u,one:m,options:s,patch:dE,wrap:mE};return Fm(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?i:o,b=String(x.identifier).toUpperCase();g.has(b)||g.set(b,x)}}),f;function m(x,g){const b=x.type,p=f.handlers[b];if(lm.call(f.handlers,b)&&p)return p(f,x,g);if(f.options.passThrough&&f.options.passThrough.includes(b)){if("children"in x){const{children:S,...T}=x,E=vu(T);return E.children=f.all(x),E}return vu(x)}return(f.options.unknownHandler||hE)(f,x,g)}function h(x){const g=[];if("children"in x){const b=x.children;let p=-1;for(;++p<b.length;){const w=f.one(b[p],x);if(w){if(p&&b[p-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Ib(w.value)),!Array.isArray(w)&&w.type==="element")){const S=w.children[0];S&&S.type==="text"&&(S.value=Ib(S.value))}Array.isArray(w)?g.push(...w):g.push(w)}}}return g}}function dE(e,r){e.position&&(r.position=W2(e))}function fE(e,r){let s=r;if(e&&e.data){const i=e.data.hName,o=e.data.hChildren,c=e.data.hProperties;if(typeof i=="string")if(s.type==="element")s.tagName=i;else{const u="children"in s?s.children:[s];s={type:"element",tagName:i,properties:{},children:u}}s.type==="element"&&c&&Object.assign(s.properties,vu(c)),"children"in s&&s.children&&o!==null&&o!==void 0&&(s.children=o)}return s}function hE(e,r){const s=r.data||{},i="value"in r&&!(lm.call(s,"hProperties")||lm.call(s,"hChildren"))?{type:"text",value:r.value}:{type:"element",tagName:"div",properties:{},children:e.all(r)};return e.patch(r,i),e.applyData(r,i)}function mE(e,r){const s=[];let i=-1;for(r&&s.push({type:"text",value:`
|
|
21
|
-
`});++i<e.length;)i&&s.push({type:"text",value:`
|
|
22
|
-
`}),s.push(e[i]);return r&&e.length>0&&s.push({type:"text",value:`
|
|
23
|
-
`}),s}function Ib(e){let r=0,s=e.charCodeAt(r);for(;s===9||s===32;)r++,s=e.charCodeAt(r);return e.slice(r)}function $b(e,r){const s=uE(e,r),i=s.one(e,void 0),o=eE(s),c=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return o&&c.children.push({type:"text",value:`
|
|
24
|
-
`},o),c}function xE(e,r){return e&&"run"in e?async function(s,i){const o=$b(s,{file:i,...r});await e.run(o,i)}:function(s,i){return $b(s,{file:i,...e||r})}}function Bb(e){if(e)throw e}var gh,Hb;function gE(){if(Hb)return gh;Hb=1;var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(h){return typeof Array.isArray=="function"?Array.isArray(h):r.call(h)==="[object Array]"},c=function(h){if(!h||r.call(h)!=="[object Object]")return!1;var x=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!x&&!g)return!1;var b;for(b in h);return typeof b>"u"||e.call(h,b)},u=function(h,x){s&&x.name==="__proto__"?s(h,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):h[x.name]=x.newValue},f=function(h,x){if(x==="__proto__")if(e.call(h,x)){if(i)return i(h,x).value}else return;return h[x]};return gh=function m(){var h,x,g,b,p,w,S=arguments[0],T=1,E=arguments.length,C=!1;for(typeof S=="boolean"&&(C=S,S=arguments[1]||{},T=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});T<E;++T)if(h=arguments[T],h!=null)for(x in h)g=f(S,x),b=f(h,x),S!==b&&(C&&b&&(c(b)||(p=o(b)))?(p?(p=!1,w=g&&o(g)?g:[]):w=g&&c(g)?g:{},u(S,{name:x,newValue:m(C,w,b)})):typeof b<"u"&&u(S,{name:x,newValue:b}));return S},gh}var pE=gE();const ph=Bu(pE);function om(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function bE(){const e=[],r={run:s,use:i};return r;function s(...o){let c=-1;const u=o.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);f(null,...o);function f(m,...h){const x=e[++c];let g=-1;if(m){u(m);return}for(;++g<o.length;)(h[g]===null||h[g]===void 0)&&(h[g]=o[g]);o=h,x?yE(x,f)(...h):u(null,...h)}}function i(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),r}}function yE(e,r){let s;return i;function i(...u){const f=e.length>u.length;let m;f&&u.push(o);try{m=e.apply(this,u)}catch(h){const x=h;if(f&&s)throw x;return o(x)}f||(m&&m.then&&typeof m.then=="function"?m.then(c,o):m instanceof Error?o(m):c(m))}function o(u,...f){s||(s=!0,r(u,...f))}function c(u){o(null,u)}}const us={basename:vE,dirname:jE,extname:wE,join:NE,sep:"/"};function vE(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');Do(e);let s=0,i=-1,o=e.length,c;if(r===void 0||r.length===0||r.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else i<0&&(c=!0,i=o+1);return i<0?"":e.slice(s,i)}if(r===e)return"";let u=-1,f=r.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else u<0&&(c=!0,u=o+1),f>-1&&(e.codePointAt(o)===r.codePointAt(f--)?f<0&&(i=o):(f=-1,i=u));return s===i?i=u:i<0&&(i=e.length),e.slice(s,i)}function jE(e){if(Do(e),e.length===0)return".";let r=-1,s=e.length,i;for(;--s;)if(e.codePointAt(s)===47){if(i){r=s;break}}else i||(i=!0);return r<0?e.codePointAt(0)===47?"/":".":r===1&&e.codePointAt(0)===47?"//":e.slice(0,r)}function wE(e){Do(e);let r=e.length,s=-1,i=0,o=-1,c=0,u;for(;r--;){const f=e.codePointAt(r);if(f===47){if(u){i=r+1;break}continue}s<0&&(u=!0,s=r+1),f===46?o<0?o=r:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||s<0||c===0||c===1&&o===s-1&&o===i+1?"":e.slice(o,s)}function NE(...e){let r=-1,s;for(;++r<e.length;)Do(e[r]),e[r]&&(s=s===void 0?e[r]:s+"/"+e[r]);return s===void 0?".":kE(s)}function kE(e){Do(e);const r=e.codePointAt(0)===47;let s=SE(e,!r);return s.length===0&&!r&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),r?"/"+s:s}function SE(e,r){let s="",i=0,o=-1,c=0,u=-1,f,m;for(;++u<=e.length;){if(u<e.length)f=e.codePointAt(u);else{if(f===47)break;f=47}if(f===47){if(!(o===u-1||c===1))if(o!==u-1&&c===2){if(s.length<2||i!==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="",i=0):(s=s.slice(0,m),i=s.length-1-s.lastIndexOf("/")),o=u,c=0;continue}}else if(s.length>0){s="",i=0,o=u,c=0;continue}}r&&(s=s.length>0?s+"/..":"..",i=2)}else s.length>0?s+="/"+e.slice(o+1,u):s=e.slice(o+1,u),i=u-o-1;o=u,c=0}else f===46&&c>-1?c++:c=-1}return s}function Do(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const CE={cwd:EE};function EE(){return"/"}function cm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function TE(e){if(typeof e=="string")e=new URL(e);else if(!cm(e)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(e.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return _E(e)}function _E(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const r=e.pathname;let s=-1;for(;++s<r.length;)if(r.codePointAt(s)===37&&r.codePointAt(s+1)===50){const i=r.codePointAt(s+2);if(i===70||i===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(r)}const bh=["history","path","basename","stem","extname","dirname"];class C1{constructor(r){let s;r?cm(r)?s={path:r}:typeof r=="string"||AE(r)?s={value:r}:s=r:s={},this.cwd="cwd"in s?"":CE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<bh.length;){const c=bh[i];c in s&&s[c]!==void 0&&s[c]!==null&&(this[c]=c==="history"?[...s[c]]:s[c])}let o;for(o in s)bh.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?us.basename(this.path):void 0}set basename(r){vh(r,"basename"),yh(r,"basename"),this.path=us.join(this.dirname||"",r)}get dirname(){return typeof this.path=="string"?us.dirname(this.path):void 0}set dirname(r){Pb(this.basename,"dirname"),this.path=us.join(r||"",this.basename)}get extname(){return typeof this.path=="string"?us.extname(this.path):void 0}set extname(r){if(yh(r,"extname"),Pb(this.dirname,"extname"),r){if(r.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(r.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=us.join(this.dirname,this.stem+(r||""))}get path(){return this.history[this.history.length-1]}set path(r){cm(r)&&(r=TE(r)),vh(r,"path"),this.path!==r&&this.history.push(r)}get stem(){return typeof this.path=="string"?us.basename(this.path,this.extname):void 0}set stem(r){vh(r,"stem"),yh(r,"stem"),this.path=us.join(this.dirname||"",r+(this.extname||""))}fail(r,s,i){const o=this.message(r,s,i);throw o.fatal=!0,o}info(r,s,i){const o=this.message(r,s,i);return o.fatal=void 0,o}message(r,s,i){const o=new tr(r,s,i);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(r){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(r||void 0).decode(this.value)}}function yh(e,r){if(e&&e.includes(us.sep))throw new Error("`"+r+"` cannot be a path: did not expect `"+us.sep+"`")}function vh(e,r){if(!e)throw new Error("`"+r+"` cannot be empty")}function Pb(e,r){if(!e)throw new Error("Setting `"+r+"` requires `path` to be set too")}function AE(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const ME=(function(e){const i=this.constructor.prototype,o=i[e],c=function(){return o.apply(c,arguments)};return Object.setPrototypeOf(c,i),c}),DE={}.hasOwnProperty;class Ym extends ME{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=bE()}copy(){const r=new Ym;let s=-1;for(;++s<this.attachers.length;){const i=this.attachers[s];r.use(...i)}return r.data(ph(!0,{},this.namespace)),r}data(r,s){return typeof r=="string"?arguments.length===2?(Nh("data",this.frozen),this.namespace[r]=s,this):DE.call(this.namespace,r)&&this.namespace[r]||void 0:r?(Nh("data",this.frozen),this.namespace=r,this):this.namespace}freeze(){if(this.frozen)return this;const r=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const o=s.call(r,...i);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(r){this.freeze();const s=Kc(r),i=this.parser||this.Parser;return jh("parse",i),i(String(s),s)}process(r,s){const i=this;return this.freeze(),jh("process",this.parser||this.Parser),wh("process",this.compiler||this.Compiler),s?o(void 0,s):new Promise(o);function o(c,u){const f=Kc(r),m=i.parse(f);i.run(m,f,function(x,g,b){if(x||!g||!b)return h(x);const p=g,w=i.stringify(p,b);zE(w)?b.value=w:b.result=w,h(x,b)});function h(x,g){x||!g?u(x):c?c(g):s(void 0,g)}}}processSync(r){let s=!1,i;return this.freeze(),jh("processSync",this.parser||this.Parser),wh("processSync",this.compiler||this.Compiler),this.process(r,o),qb("processSync","process",s),i;function o(c,u){s=!0,Bb(c),i=u}}run(r,s,i){Ub(r),this.freeze();const o=this.transformers;return!i&&typeof s=="function"&&(i=s,s=void 0),i?c(void 0,i):new Promise(c);function c(u,f){const m=Kc(s);o.run(r,m,h);function h(x,g,b){const p=g||r;x?f(x):u?u(p):i(void 0,p,b)}}}runSync(r,s){let i=!1,o;return this.run(r,s,c),qb("runSync","run",i),o;function c(u,f){Bb(u),o=f,i=!0}}stringify(r,s){this.freeze();const i=Kc(s),o=this.compiler||this.Compiler;return wh("stringify",o),Ub(r),o(r,i)}use(r,...s){const i=this.attachers,o=this.namespace;if(Nh("use",this.frozen),r!=null)if(typeof r=="function")m(r,s);else if(typeof r=="object")Array.isArray(r)?f(r):u(r);else throw new TypeError("Expected usable value, not `"+r+"`");return this;function c(h){if(typeof h=="function")m(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[x,...g]=h;m(x,g)}else u(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function u(h){if(!("plugins"in h)&&!("settings"in h))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");f(h.plugins),h.settings&&(o.settings=ph(!0,o.settings,h.settings))}function f(h){let x=-1;if(h!=null)if(Array.isArray(h))for(;++x<h.length;){const g=h[x];c(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function m(h,x){let g=-1,b=-1;for(;++g<i.length;)if(i[g][0]===h){b=g;break}if(b===-1)i.push([h,...x]);else if(x.length>0){let[p,...w]=x;const S=i[b][1];om(S)&&om(p)&&(p=ph(!0,S,p)),i[b]=[h,p,...w]}}}}const OE=new Ym().freeze();function jh(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function wh(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Nh(e,r){if(r)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ub(e){if(!om(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qb(e,r,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+r+"` instead")}function Kc(e){return RE(e)?e:new C1(e)}function RE(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function zE(e){return typeof e=="string"||LE(e)}function LE(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const IE="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Vb=[],Fb={allowDangerousHtml:!0},$E=/^(https?|ircs?|mailto|xmpp)$/i,BE=[{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 Yb(e){const r=HE(e),s=PE(e);return UE(r.runSync(r.parse(s),s),e)}function HE(e){const r=e.rehypePlugins||Vb,s=e.remarkPlugins||Vb,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Fb}:Fb;return OE().use(jC).use(s).use(xE,i).use(r)}function PE(e){const r=e.children||"",s=new C1;return typeof r=="string"&&(s.value=r),s}function UE(e,r){const s=r.allowedElements,i=r.allowElement,o=r.components,c=r.disallowedElements,u=r.skipHtml,f=r.unwrapDisallowed,m=r.urlTransform||qE;for(const x of BE)Object.hasOwn(r,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+IE+x.id,void 0);return Fm(e,h),sk(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function h(x,g,b){if(x.type==="raw"&&b&&typeof g=="number")return u?b.children.splice(g,1):b.children[g]={type:"text",value:x.value},g;if(x.type==="element"){let p;for(p in hh)if(Object.hasOwn(hh,p)&&Object.hasOwn(x.properties,p)){const w=x.properties[p],S=hh[p];(S===null||S.includes(x.tagName))&&(x.properties[p]=m(String(w||""),p,x))}}if(x.type==="element"){let p=s?!s.includes(x.tagName):c?c.includes(x.tagName):!1;if(!p&&i&&typeof g=="number"&&(p=!i(x,g,b)),p&&b&&typeof g=="number")return f&&x.children?b.children.splice(g,1,...x.children):b.children.splice(g,1),g}}}function qE(e){const r=e.indexOf(":"),s=e.indexOf("?"),i=e.indexOf("#"),o=e.indexOf("/");return r===-1||o!==-1&&r>o||s!==-1&&r>s||i!==-1&&r>i||$E.test(e.slice(0,r))?e:""}function Gb(e,r){const s=String(e);if(typeof r!="string")throw new TypeError("Expected character");let i=0,o=s.indexOf(r);for(;o!==-1;)i++,o=s.indexOf(r,o+r.length);return i}function VE(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function FE(e,r,s){const o=qu((s||{}).ignore||[]),c=YE(r);let u=-1;for(;++u<c.length;)S1(e,"text",f);function f(h,x){let g=-1,b;for(;++g<x.length;){const p=x[g],w=b?b.children:void 0;if(o(p,w?w.indexOf(p):void 0,b))return;b=p}if(b)return m(h,x)}function m(h,x){const g=x[x.length-1],b=c[u][0],p=c[u][1];let w=0;const T=g.children.indexOf(h);let E=!1,C=[];b.lastIndex=0;let N=b.exec(h.value);for(;N;){const k=N.index,H={index:N.index,input:N.input,stack:[...x,h]};let M=p(...N,H);if(typeof M=="string"&&(M=M.length>0?{type:"text",value:M}:void 0),M===!1?b.lastIndex=k+1:(w!==k&&C.push({type:"text",value:h.value.slice(w,k)}),Array.isArray(M)?C.push(...M):M&&C.push(M),w=k+N[0].length,E=!0),!b.global)break;N=b.exec(h.value)}return E?(w<h.value.length&&C.push({type:"text",value:h.value.slice(w)}),g.children.splice(T,1,...C)):C=[h],T+C.length}}function YE(e){const r=[];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 i=-1;for(;++i<s.length;){const o=s[i];r.push([GE(o[0]),XE(o[1])])}return r}function GE(e){return typeof e=="string"?new RegExp(VE(e),"g"):e}function XE(e){return typeof e=="function"?e:function(){return e}}const kh="phrasing",Sh=["autolink","link","image","label"];function ZE(){return{transforms:[n3],enter:{literalAutolink:KE,literalAutolinkEmail:Ch,literalAutolinkHttp:Ch,literalAutolinkWww:Ch},exit:{literalAutolink:t3,literalAutolinkEmail:e3,literalAutolinkHttp:JE,literalAutolinkWww:WE}}}function QE(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:kh,notInConstruct:Sh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:kh,notInConstruct:Sh},{character:":",before:"[ps]",after:"\\/",inConstruct:kh,notInConstruct:Sh}]}}function KE(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ch(e){this.config.enter.autolinkProtocol.call(this,e)}function JE(e){this.config.exit.autolinkProtocol.call(this,e)}function WE(e){this.config.exit.data.call(this,e);const r=this.stack[this.stack.length-1];r.type,r.url="http://"+this.sliceSerialize(e)}function e3(e){this.config.exit.autolinkEmail.call(this,e)}function t3(e){this.exit(e)}function n3(e){FE(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,r3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),s3]],{ignore:["link","linkReference"]})}function r3(e,r,s,i,o){let c="";if(!E1(o)||(/^w/i.test(r)&&(s=r+s,r="",c="http://"),!a3(s)))return!1;const u=i3(s+i);if(!u[0])return!1;const f={type:"link",title:null,url:c+r+u[0],children:[{type:"text",value:r+u[0]}]};return u[1]?[f,{type:"text",value:u[1]}]:f}function s3(e,r,s,i){return!E1(i,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+r+"@"+s,children:[{type:"text",value:r+"@"+s}]}}function a3(e){const r=e.split(".");return!(r.length<2||r[r.length-1]&&(/_/.test(r[r.length-1])||!/[a-zA-Z\d]/.test(r[r.length-1]))||r[r.length-2]&&(/_/.test(r[r.length-2])||!/[a-zA-Z\d]/.test(r[r.length-2])))}function i3(e){const r=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!r)return[e,void 0];e=e.slice(0,r.index);let s=r[0],i=s.indexOf(")");const o=Gb(e,"(");let c=Gb(e,")");for(;i!==-1&&o>c;)e+=s.slice(0,i+1),s=s.slice(i+1),i=s.indexOf(")"),c++;return[e,s]}function E1(e,r){const s=e.input.charCodeAt(e.index-1);return(e.index===0||Ka(s)||Hu(s))&&(!r||s!==47)}T1.peek=x3;function l3(){this.buffer()}function o3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function c3(){this.buffer()}function u3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function d3(e){const r=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=ts(this.sliceSerialize(e)).toLowerCase(),s.label=r}function f3(e){this.exit(e)}function h3(e){const r=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=ts(this.sliceSerialize(e)).toLowerCase(),s.label=r}function m3(e){this.exit(e)}function x3(){return"["}function T1(e,r,s,i){const o=s.createTracker(i);let c=o.move("[^");const u=s.enter("footnoteReference"),f=s.enter("reference");return c+=o.move(s.safe(s.associationId(e),{after:"]",before:c})),f(),u(),c+=o.move("]"),c}function g3(){return{enter:{gfmFootnoteCallString:l3,gfmFootnoteCall:o3,gfmFootnoteDefinitionLabelString:c3,gfmFootnoteDefinition:u3},exit:{gfmFootnoteCallString:d3,gfmFootnoteCall:f3,gfmFootnoteDefinitionLabelString:h3,gfmFootnoteDefinition:m3}}}function p3(e){let r=!1;return e&&e.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:s,footnoteReference:T1},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(i,o,c,u){const f=c.createTracker(u);let m=f.move("[^");const h=c.enter("footnoteDefinition"),x=c.enter("label");return m+=f.move(c.safe(c.associationId(i),{before:m,after:"]"})),x(),m+=f.move("]:"),i.children&&i.children.length>0&&(f.shift(4),m+=f.move((r?`
|
|
25
|
-
`:" ")+c.indentLines(c.containerFlow(i,f.current()),r?_1:b3))),h(),m}}function b3(e,r,s){return r===0?e:_1(e,r,s)}function _1(e,r,s){return(s?"":" ")+e}const y3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];A1.peek=k3;function v3(){return{canContainEols:["delete"],enter:{strikethrough:w3},exit:{strikethrough:N3}}}function j3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:y3}],handlers:{delete:A1}}}function w3(e){this.enter({type:"delete",children:[]},e)}function N3(e){this.exit(e)}function A1(e,r,s,i){const o=s.createTracker(i),c=s.enter("strikethrough");let u=o.move("~~");return u+=s.containerPhrasing(e,{...o.current(),before:u,after:"~"}),u+=o.move("~~"),c(),u}function k3(){return"~"}function S3(e){return e.length}function C3(e,r){const s=r||{},i=(s.align||[]).concat(),o=s.stringLength||S3,c=[],u=[],f=[],m=[];let h=0,x=-1;for(;++x<e.length;){const S=[],T=[];let E=-1;for(e[x].length>h&&(h=e[x].length);++E<e[x].length;){const C=E3(e[x][E]);if(s.alignDelimiters!==!1){const N=o(C);T[E]=N,(m[E]===void 0||N>m[E])&&(m[E]=N)}S.push(C)}u[x]=S,f[x]=T}let g=-1;if(typeof i=="object"&&"length"in i)for(;++g<h;)c[g]=Xb(i[g]);else{const S=Xb(i);for(;++g<h;)c[g]=S}g=-1;const b=[],p=[];for(;++g<h;){const S=c[g];let T="",E="";S===99?(T=":",E=":"):S===108?T=":":S===114&&(E=":");let C=s.alignDelimiters===!1?1:Math.max(1,m[g]-T.length-E.length);const N=T+"-".repeat(C)+E;s.alignDelimiters!==!1&&(C=T.length+C+E.length,C>m[g]&&(m[g]=C),p[g]=C),b[g]=N}u.splice(1,0,b),f.splice(1,0,p),x=-1;const w=[];for(;++x<u.length;){const S=u[x],T=f[x];g=-1;const E=[];for(;++g<h;){const C=S[g]||"";let N="",k="";if(s.alignDelimiters!==!1){const H=m[g]-(T[g]||0),M=c[g];M===114?N=" ".repeat(H):M===99?H%2?(N=" ".repeat(H/2+.5),k=" ".repeat(H/2-.5)):(N=" ".repeat(H/2),k=N):k=" ".repeat(H)}s.delimiterStart!==!1&&!g&&E.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&C==="")&&(s.delimiterStart!==!1||g)&&E.push(" "),s.alignDelimiters!==!1&&E.push(N),E.push(C),s.alignDelimiters!==!1&&E.push(k),s.padding!==!1&&E.push(" "),(s.delimiterEnd!==!1||g!==h-1)&&E.push("|")}w.push(s.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return w.join(`
|
|
26
|
-
`)}function E3(e){return e==null?"":String(e)}function Xb(e){const r=typeof e=="string"?e.codePointAt(0):0;return r===67||r===99?99:r===76||r===108?108:r===82||r===114?114:0}function T3(e,r,s,i){const o=s.enter("blockquote"),c=s.createTracker(i);c.move("> "),c.shift(2);const u=s.indentLines(s.containerFlow(e,c.current()),_3);return o(),u}function _3(e,r,s){return">"+(s?"":" ")+e}function A3(e,r){return Zb(e,r.inConstruct,!0)&&!Zb(e,r.notInConstruct,!1)}function Zb(e,r,s){if(typeof r=="string"&&(r=[r]),!r||r.length===0)return s;let i=-1;for(;++i<r.length;)if(e.includes(r[i]))return!0;return!1}function Qb(e,r,s,i){let o=-1;for(;++o<s.unsafe.length;)if(s.unsafe[o].character===`
|
|
27
|
-
`&&A3(s.stack,s.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
28
|
-
`}function M3(e,r){const s=String(e);let i=s.indexOf(r),o=i,c=0,u=0;if(typeof r!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===o?++c>u&&(u=c):c=1,o=i+r.length,i=s.indexOf(r,o);return u}function D3(e,r){return!!(r.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function O3(e){const r=e.options.fence||"`";if(r!=="`"&&r!=="~")throw new Error("Cannot serialize code with `"+r+"` for `options.fence`, expected `` ` `` or `~`");return r}function R3(e,r,s,i){const o=O3(s),c=e.value||"",u=o==="`"?"GraveAccent":"Tilde";if(D3(e,s)){const g=s.enter("codeIndented"),b=s.indentLines(c,z3);return g(),b}const f=s.createTracker(i),m=o.repeat(Math.max(M3(c,o)+1,3)),h=s.enter("codeFenced");let x=f.move(m);if(e.lang){const g=s.enter(`codeFencedLang${u}`);x+=f.move(s.safe(e.lang,{before:x,after:" ",encode:["`"],...f.current()})),g()}if(e.lang&&e.meta){const g=s.enter(`codeFencedMeta${u}`);x+=f.move(" "),x+=f.move(s.safe(e.meta,{before:x,after:`
|
|
29
|
-
`,encode:["`"],...f.current()})),g()}return x+=f.move(`
|
|
30
|
-
`),c&&(x+=f.move(c+`
|
|
31
|
-
`)),x+=f.move(m),h(),x}function z3(e,r,s){return(s?"":" ")+e}function Gm(e){const r=e.options.quote||'"';if(r!=='"'&&r!=="'")throw new Error("Cannot serialize title with `"+r+"` for `options.quote`, expected `\"`, or `'`");return r}function L3(e,r,s,i){const o=Gm(s),c=o==='"'?"Quote":"Apostrophe",u=s.enter("definition");let f=s.enter("label");const m=s.createTracker(i);let h=m.move("[");return h+=m.move(s.safe(s.associationId(e),{before:h,after:"]",...m.current()})),h+=m.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=s.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(s.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=s.enter("destinationRaw"),h+=m.move(s.safe(e.url,{before:h,after:e.title?" ":`
|
|
32
|
-
`,...m.current()}))),f(),e.title&&(f=s.enter(`title${c}`),h+=m.move(" "+o),h+=m.move(s.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),u(),h}function I3(e){const r=e.options.emphasis||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize emphasis with `"+r+"` for `options.emphasis`, expected `*`, or `_`");return r}function po(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ju(e,r,s){const i=Vi(e),o=Vi(r);return i===void 0?o===void 0?s==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===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}}M1.peek=$3;function M1(e,r,s,i){const o=I3(s),c=s.enter("emphasis"),u=s.createTracker(i),f=u.move(o);let m=u.move(s.containerPhrasing(e,{after:o,before:f,...u.current()}));const h=m.charCodeAt(0),x=ju(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=po(h)+m.slice(1));const g=m.charCodeAt(m.length-1),b=ju(i.after.charCodeAt(0),g,o);b.inside&&(m=m.slice(0,-1)+po(g));const p=u.move(o);return c(),s.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},f+m+p}function $3(e,r,s){return s.options.emphasis||"*"}function B3(e,r){let s=!1;return Fm(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return s=!0,im}),!!((!e.depth||e.depth<3)&&$m(e)&&(r.options.setext||s))}function H3(e,r,s,i){const o=Math.max(Math.min(6,e.depth||1),1),c=s.createTracker(i);if(B3(e,s)){const x=s.enter("headingSetext"),g=s.enter("phrasing"),b=s.containerPhrasing(e,{...c.current(),before:`
|
|
33
|
-
`,after:`
|
|
34
|
-
`});return g(),x(),b+`
|
|
35
|
-
`+(o===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(`
|
|
36
|
-
`))+1))}const u="#".repeat(o),f=s.enter("headingAtx"),m=s.enter("phrasing");c.move(u+" ");let h=s.containerPhrasing(e,{before:"# ",after:`
|
|
37
|
-
`,...c.current()});return/^[\t ]/.test(h)&&(h=po(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,s.options.closeAtx&&(h+=" "+u),m(),f(),h}D1.peek=P3;function D1(e){return e.value||""}function P3(){return"<"}O1.peek=U3;function O1(e,r,s,i){const o=Gm(s),c=o==='"'?"Quote":"Apostrophe",u=s.enter("image");let f=s.enter("label");const m=s.createTracker(i);let h=m.move("![");return h+=m.move(s.safe(e.alt,{before:h,after:"]",...m.current()})),h+=m.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=s.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(s.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=s.enter("destinationRaw"),h+=m.move(s.safe(e.url,{before:h,after:e.title?" ":")",...m.current()}))),f(),e.title&&(f=s.enter(`title${c}`),h+=m.move(" "+o),h+=m.move(s.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),h+=m.move(")"),u(),h}function U3(){return"!"}R1.peek=q3;function R1(e,r,s,i){const o=e.referenceType,c=s.enter("imageReference");let u=s.enter("label");const f=s.createTracker(i);let m=f.move("![");const h=s.safe(e.alt,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),u();const x=s.stack;s.stack=[],u=s.enter("reference");const g=s.safe(s.associationId(e),{before:m,after:"]",...f.current()});return u(),s.stack=x,c(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function q3(){return"!"}z1.peek=V3;function z1(e,r,s){let i=e.value||"",o="`",c=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(i);)o+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++c<s.unsafe.length;){const u=s.unsafe[c],f=s.compilePattern(u);let m;if(u.atBreak)for(;m=f.exec(i);){let h=m.index;i.charCodeAt(h)===10&&i.charCodeAt(h-1)===13&&h--,i=i.slice(0,h)+" "+i.slice(m.index+1)}}return o+i+o}function V3(){return"`"}function L1(e,r){const s=$m(e);return!!(!r.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))}I1.peek=F3;function I1(e,r,s,i){const o=Gm(s),c=o==='"'?"Quote":"Apostrophe",u=s.createTracker(i);let f,m;if(L1(e,s)){const x=s.stack;s.stack=[],f=s.enter("autolink");let g=u.move("<");return g+=u.move(s.containerPhrasing(e,{before:g,after:">",...u.current()})),g+=u.move(">"),f(),s.stack=x,g}f=s.enter("link"),m=s.enter("label");let h=u.move("[");return h+=u.move(s.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=s.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(s.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(m=s.enter("destinationRaw"),h+=u.move(s.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),m(),e.title&&(m=s.enter(`title${c}`),h+=u.move(" "+o),h+=u.move(s.safe(e.title,{before:h,after:o,...u.current()})),h+=u.move(o),m()),h+=u.move(")"),f(),h}function F3(e,r,s){return L1(e,s)?"<":"["}$1.peek=Y3;function $1(e,r,s,i){const o=e.referenceType,c=s.enter("linkReference");let u=s.enter("label");const f=s.createTracker(i);let m=f.move("[");const h=s.containerPhrasing(e,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),u();const x=s.stack;s.stack=[],u=s.enter("reference");const g=s.safe(s.associationId(e),{before:m,after:"]",...f.current()});return u(),s.stack=x,c(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function Y3(){return"["}function Xm(e){const r=e.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function G3(e){const r=Xm(e),s=e.options.bulletOther;if(!s)return r==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+s+"`) to be different");return s}function X3(e){const r=e.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function B1(e){const r=e.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function Z3(e,r,s,i){const o=s.enter("list"),c=s.bulletCurrent;let u=e.ordered?X3(s):Xm(s);const f=e.ordered?u==="."?")":".":G3(s);let m=r&&s.bulletLastUsed?u===s.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&x&&(!x.children||!x.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),B1(s)===u&&x){let g=-1;for(;++g<e.children.length;){const b=e.children[g];if(b&&b.type==="listItem"&&b.children&&b.children[0]&&b.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(u=f),s.bulletCurrent=u;const h=s.containerFlow(e,i);return s.bulletLastUsed=u,s.bulletCurrent=c,o(),h}function Q3(e){const r=e.options.listItemIndent||"one";if(r!=="tab"&&r!=="one"&&r!=="mixed")throw new Error("Cannot serialize items with `"+r+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return r}function K3(e,r,s,i){const o=Q3(s);let c=s.bulletCurrent||Xm(s);r&&r.type==="list"&&r.ordered&&(c=(typeof r.start=="number"&&r.start>-1?r.start:1)+(s.options.incrementListMarker===!1?0:r.children.indexOf(e))+c);let u=c.length+1;(o==="tab"||o==="mixed"&&(r&&r.type==="list"&&r.spread||e.spread))&&(u=Math.ceil(u/4)*4);const f=s.createTracker(i);f.move(c+" ".repeat(u-c.length)),f.shift(u);const m=s.enter("listItem"),h=s.indentLines(s.containerFlow(e,f.current()),x);return m(),h;function x(g,b,p){return b?(p?"":" ".repeat(u))+g:(p?c:c+" ".repeat(u-c.length))+g}}function J3(e,r,s,i){const o=s.enter("paragraph"),c=s.enter("phrasing"),u=s.containerPhrasing(e,i);return c(),o(),u}const W3=qu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function e4(e,r,s,i){return(e.children.some(function(u){return W3(u)})?s.containerPhrasing:s.containerFlow).call(s,e,i)}function t4(e){const r=e.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}H1.peek=n4;function H1(e,r,s,i){const o=t4(s),c=s.enter("strong"),u=s.createTracker(i),f=u.move(o+o);let m=u.move(s.containerPhrasing(e,{after:o,before:f,...u.current()}));const h=m.charCodeAt(0),x=ju(i.before.charCodeAt(i.before.length-1),h,o);x.inside&&(m=po(h)+m.slice(1));const g=m.charCodeAt(m.length-1),b=ju(i.after.charCodeAt(0),g,o);b.inside&&(m=m.slice(0,-1)+po(g));const p=u.move(o+o);return c(),s.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},f+m+p}function n4(e,r,s){return s.options.strong||"*"}function r4(e,r,s,i){return s.safe(e.value,i)}function s4(e){const r=e.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function a4(e,r,s){const i=(B1(s)+(s.options.ruleSpaces?" ":"")).repeat(s4(s));return s.options.ruleSpaces?i.slice(0,-1):i}const P1={blockquote:T3,break:Qb,code:R3,definition:L3,emphasis:M1,hardBreak:Qb,heading:H3,html:D1,image:O1,imageReference:R1,inlineCode:z1,link:I1,linkReference:$1,list:Z3,listItem:K3,paragraph:J3,root:e4,strong:H1,text:r4,thematicBreak:a4};function i4(){return{enter:{table:l4,tableData:Kb,tableHeader:Kb,tableRow:c4},exit:{codeText:u4,table:o4,tableData:Eh,tableHeader:Eh,tableRow:Eh}}}function l4(e){const r=e._align;this.enter({type:"table",align:r.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 c4(e){this.enter({type:"tableRow",children:[]},e)}function Eh(e){this.exit(e)}function Kb(e){this.enter({type:"tableCell",children:[]},e)}function u4(e){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,d4));const s=this.stack[this.stack.length-1];s.type,s.value=r,this.exit(e)}function d4(e,r){return r==="|"?r:e}function f4(e){const r=e||{},s=r.tableCellPadding,i=r.tablePipeAlign,o=r.stringLength,c=s?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
38
|
-
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:u,tableCell:m,tableRow:f}};function u(p,w,S,T){return h(x(p,S,T),p.align)}function f(p,w,S,T){const E=g(p,S,T),C=h([E]);return C.slice(0,C.indexOf(`
|
|
39
|
-
`))}function m(p,w,S,T){const E=S.enter("tableCell"),C=S.enter("phrasing"),N=S.containerPhrasing(p,{...T,before:c,after:c});return C(),E(),N}function h(p,w){return C3(p,{align:w,alignDelimiters:i,padding:s,stringLength:o})}function x(p,w,S){const T=p.children;let E=-1;const C=[],N=w.enter("table");for(;++E<T.length;)C[E]=g(T[E],w,S);return N(),C}function g(p,w,S){const T=p.children;let E=-1;const C=[],N=w.enter("tableRow");for(;++E<T.length;)C[E]=m(T[E],p,w,S);return N(),C}function b(p,w,S){let T=P1.inlineCode(p,w,S);return S.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function h4(){return{exit:{taskListCheckValueChecked:Jb,taskListCheckValueUnchecked:Jb,paragraph:x4}}}function m4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:g4}}}function Jb(e){const r=this.stack[this.stack.length-2];r.type,r.checked=e.type==="taskListCheckValueChecked"}function x4(e){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const i=s.children[0];if(i&&i.type==="text"){const o=r.children;let c=-1,u;for(;++c<o.length;){const f=o[c];if(f.type==="paragraph"){u=f;break}}u===s&&(i.value=i.value.slice(1),i.value.length===0?s.children.shift():s.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,s.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function g4(e,r,s,i){const o=e.children[0],c=typeof e.checked=="boolean"&&o&&o.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",f=s.createTracker(i);c&&f.move(u);let m=P1.listItem(e,r,s,{...i,...f.current()});return c&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),m;function h(x){return x+u}}function p4(){return[ZE(),g3(),v3(),i4(),h4()]}function b4(e){return{extensions:[QE(),p3(e),j3(),f4(e),m4()]}}const y4={tokenize:S4,partial:!0},U1={tokenize:C4,partial:!0},q1={tokenize:E4,partial:!0},V1={tokenize:T4,partial:!0},v4={tokenize:_4,partial:!0},F1={name:"wwwAutolink",tokenize:N4,previous:G1},Y1={name:"protocolAutolink",tokenize:k4,previous:X1},Bs={name:"emailAutolink",tokenize:w4,previous:Z1},xs={};function j4(){return{text:xs}}let qa=48;for(;qa<123;)xs[qa]=Bs,qa++,qa===58?qa=65:qa===91&&(qa=97);xs[43]=Bs;xs[45]=Bs;xs[46]=Bs;xs[95]=Bs;xs[72]=[Bs,Y1];xs[104]=[Bs,Y1];xs[87]=[Bs,F1];xs[119]=[Bs,F1];function w4(e,r,s){const i=this;let o,c;return u;function u(g){return!um(g)||!Z1.call(i,i.previous)||Zm(i.events)?s(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return um(g)?(e.consume(g),f):g===64?(e.consume(g),m):s(g)}function m(g){return g===46?e.check(v4,x,h)(g):g===45||g===95||Wn(g)?(c=!0,e.consume(g),m):x(g)}function h(g){return e.consume(g),o=!0,m}function x(g){return c&&o&&sr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),r(g)):s(g)}}function N4(e,r,s){const i=this;return o;function o(u){return u!==87&&u!==119||!G1.call(i,i.previous)||Zm(i.events)?s(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(y4,e.attempt(U1,e.attempt(q1,c),s),s)(u))}function c(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),r(u)}}function k4(e,r,s){const i=this;let o="",c=!1;return u;function u(g){return(g===72||g===104)&&X1.call(i,i.previous)&&!Zm(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):s(g)}function f(g){if(sr(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const b=o.toLowerCase();if(b==="http"||b==="https")return e.consume(g),m}return s(g)}function m(g){return g===47?(e.consume(g),c?h:(c=!0,m)):s(g)}function h(g){return g===null||bu(g)||ln(g)||Ka(g)||Hu(g)?s(g):e.attempt(U1,e.attempt(q1,x),s)(g)}function x(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),r(g)}}function S4(e,r,s){let i=0;return o;function o(u){return(u===87||u===119)&&i<3?(i++,e.consume(u),o):u===46&&i===3?(e.consume(u),c):s(u)}function c(u){return u===null?s(u):r(u)}}function C4(e,r,s){let i,o,c;return u;function u(h){return h===46||h===95?e.check(V1,m,f)(h):h===null||ln(h)||Ka(h)||h!==45&&Hu(h)?m(h):(c=!0,e.consume(h),u)}function f(h){return h===95?i=!0:(o=i,i=void 0),e.consume(h),u}function m(h){return o||i||!c?s(h):r(h)}}function E4(e,r){let s=0,i=0;return o;function o(u){return u===40?(s++,e.consume(u),o):u===41&&i<s?c(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(V1,r,c)(u):u===null||ln(u)||Ka(u)?r(u):(e.consume(u),o)}function c(u){return u===41&&i++,e.consume(u),o}}function T4(e,r,s){return i;function i(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),i):f===38?(e.consume(f),c):f===93?(e.consume(f),o):f===60||f===null||ln(f)||Ka(f)?r(f):s(f)}function o(f){return f===null||f===40||f===91||ln(f)||Ka(f)?r(f):i(f)}function c(f){return sr(f)?u(f):s(f)}function u(f){return f===59?(e.consume(f),i):sr(f)?(e.consume(f),u):s(f)}}function _4(e,r,s){return i;function i(c){return e.consume(c),o}function o(c){return Wn(c)?s(c):r(c)}}function G1(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ln(e)}function X1(e){return!sr(e)}function Z1(e){return!(e===47||um(e))}function um(e){return e===43||e===45||e===46||e===95||Wn(e)}function Zm(e){let r=e.length,s=!1;for(;r--;){const i=e[r][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){s=!0;break}if(i._gfmAutolinkLiteralWalkedInto){s=!1;break}}return e.length>0&&!s&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const A4={tokenize:$4,partial:!0};function M4(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:z4,continuation:{tokenize:L4},exit:I4}},text:{91:{name:"gfmFootnoteCall",tokenize:R4},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:D4,resolveTo:O4}}}}function D4(e,r,s){const i=this;let o=i.events.length;const c=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u;for(;o--;){const m=i.events[o][1];if(m.type==="labelImage"){u=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!u||!u._balanced)return s(m);const h=ts(i.sliceSerialize({start:u.end,end:i.now()}));return h.codePointAt(0)!==94||!c.includes(h.slice(1))?s(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),r(m))}}function O4(e,r){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 i={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 c={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},f=[e[s+1],e[s+2],["enter",i,r],e[s+3],e[s+4],["enter",o,r],["exit",o,r],["enter",c,r],["enter",u,r],["exit",u,r],["exit",c,r],e[e.length-2],e[e.length-1],["exit",i,r]];return e.splice(s,e.length-s+1,...f),e}function R4(e,r,s){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c=0,u;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?s(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(c>999||g===93&&!u||g===null||g===91||ln(g))return s(g);if(g===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return o.includes(ts(i.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):s(g)}return ln(g)||(u=!0),c++,e.consume(g),g===92?x:h}function x(g){return g===91||g===92||g===93?(e.consume(g),c++,h):h(g)}}function z4(e,r,s){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c,u=0,f;return m;function m(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):s(w)}function x(w){if(u>999||w===93&&!f||w===null||w===91||ln(w))return s(w);if(w===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return c=ts(i.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return ln(w)||(f=!0),u++,e.consume(w),w===92?g:x}function g(w){return w===91||w===92||w===93?(e.consume(w),u++,x):x(w)}function b(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),o.includes(c)||o.push(c),qt(e,p,"gfmFootnoteDefinitionWhitespace")):s(w)}function p(w){return r(w)}}function L4(e,r,s){return e.check(Mo,r,e.attempt(A4,r,s))}function I4(e){e.exit("gfmFootnoteDefinition")}function $4(e,r,s){const i=this;return qt(e,o,"gfmFootnoteDefinitionIndent",5);function o(c){const u=i.events[i.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?r(c):s(c)}}function B4(e){let s=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:c,resolveAll:o};return s==null&&(s=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(u,f){let m=-1;for(;++m<u.length;)if(u[m][0]==="enter"&&u[m][1].type==="strikethroughSequenceTemporary"&&u[m][1]._close){let h=m;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[m][1].end.offset-u[m][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[m][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[m][1].end)},g={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[m][1].start)},b=[["enter",x,f],["enter",u[h][1],f],["exit",u[h][1],f],["enter",g,f]],p=f.parser.constructs.insideSpan.null;p&&Mr(b,b.length,0,Pu(p,u.slice(h+1,m),f)),Mr(b,b.length,0,[["exit",g,f],["enter",u[m][1],f],["exit",u[m][1],f],["exit",x,f]]),Mr(u,h-1,m-h+3,b),m=h+b.length-2;break}}for(m=-1;++m<u.length;)u[m][1].type==="strikethroughSequenceTemporary"&&(u[m][1].type="data");return u}function c(u,f,m){const h=this.previous,x=this.events;let g=0;return b;function b(w){return h===126&&x[x.length-1][1].type!=="characterEscape"?m(w):(u.enter("strikethroughSequenceTemporary"),p(w))}function p(w){const S=Vi(h);if(w===126)return g>1?m(w):(u.consume(w),g++,p);if(g<2&&!s)return m(w);const T=u.exit("strikethroughSequenceTemporary"),E=Vi(w);return T._open=!E||E===2&&!!S,T._close=!S||S===2&&!!E,f(w)}}}class H4{constructor(){this.map=[]}add(r,s,i){P4(this,r,s,i)}consume(r){if(this.map.sort(function(c,u){return c[0]-u[0]}),this.map.length===0)return;let s=this.map.length;const i=[];for(;s>0;)s-=1,i.push(r.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),r.length=this.map[s][0];i.push(r.slice()),r.length=0;let o=i.pop();for(;o;){for(const c of o)r.push(c);o=i.pop()}this.map.length=0}}function P4(e,r,s,i){let o=0;if(!(s===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===r){e.map[o][1]+=s,e.map[o][2].push(...i);return}o+=1}e.map.push([r,s,i])}}function U4(e,r){let s=!1;const i=[];for(;r<e.length;){const o=e[r];if(s){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[r-1][1].type==="tableDelimiterMarker"){const c=i.length-1;i[c]=i[c]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(s=!0);r+=1}return i}function q4(){return{flow:{null:{name:"table",tokenize:V4,resolveAll:F4}}}}function V4(e,r,s){const i=this;let o=0,c=0,u;return f;function f(P){let q=i.events.length-1;for(;q>-1;){const _=i.events[q][1].type;if(_==="lineEnding"||_==="linePrefix")q--;else break}const F=q>-1?i.events[q][1].type:null,D=F==="tableHead"||F==="tableRow"?M:m;return D===M&&i.parser.lazy[i.now().line]?s(P):D(P)}function m(P){return e.enter("tableHead"),e.enter("tableRow"),h(P)}function h(P){return P===124||(u=!0,c+=1),x(P)}function x(P){return P===null?s(P):ft(P)?c>1?(c=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):s(P):zt(P)?qt(e,x,"whitespace")(P):(c+=1,u&&(u=!1,o+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),u=!0,x):(e.enter("data"),g(P)))}function g(P){return P===null||P===124||ln(P)?(e.exit("data"),x(P)):(e.consume(P),P===92?b:g)}function b(P){return P===92||P===124?(e.consume(P),g):g(P)}function p(P){return i.interrupt=!1,i.parser.lazy[i.now().line]?s(P):(e.enter("tableDelimiterRow"),u=!1,zt(P)?qt(e,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):w(P))}function w(P){return P===45||P===58?T(P):P===124?(u=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),S):H(P)}function S(P){return zt(P)?qt(e,T,"whitespace")(P):T(P)}function T(P){return P===58?(c+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),E):P===45?(c+=1,E(P)):P===null||ft(P)?k(P):H(P)}function E(P){return P===45?(e.enter("tableDelimiterFiller"),C(P)):H(P)}function C(P){return P===45?(e.consume(P),C):P===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),N):(e.exit("tableDelimiterFiller"),N(P))}function N(P){return zt(P)?qt(e,k,"whitespace")(P):k(P)}function k(P){return P===124?w(P):P===null||ft(P)?!u||o!==c?H(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r(P)):H(P)}function H(P){return s(P)}function M(P){return e.enter("tableRow"),Y(P)}function Y(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),Y):P===null||ft(P)?(e.exit("tableRow"),r(P)):zt(P)?qt(e,Y,"whitespace")(P):(e.enter("data"),$(P))}function $(P){return P===null||P===124||ln(P)?(e.exit("data"),Y(P)):(e.consume(P),P===92?X:$)}function X(P){return P===92||P===124?(e.consume(P),$):$(P)}}function F4(e,r){let s=-1,i=!0,o=0,c=[0,0,0,0],u=[0,0,0,0],f=!1,m=0,h,x,g;const b=new H4;for(;++s<e.length;){const p=e[s],w=p[1];p[0]==="enter"?w.type==="tableHead"?(f=!1,m!==0&&(Wb(b,r,m,h,x),x=void 0,m=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},b.add(s,0,[["enter",h,r]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(i=!0,g=void 0,c=[0,0,0,0],u=[0,s+1,0,0],f&&(f=!1,x={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},b.add(s,0,[["enter",x,r]])),o=w.type==="tableDelimiterRow"?2:x?3:1):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(i=!1,u[2]===0&&(c[1]!==0&&(u[0]=u[1],g=Jc(b,r,c,o,void 0,g),c=[0,0,0,0]),u[2]=s)):w.type==="tableCellDivider"&&(i?i=!1:(c[1]!==0&&(u[0]=u[1],g=Jc(b,r,c,o,void 0,g)),c=u,u=[c[1],s,0,0])):w.type==="tableHead"?(f=!0,m=s):w.type==="tableRow"||w.type==="tableDelimiterRow"?(m=s,c[1]!==0?(u[0]=u[1],g=Jc(b,r,c,o,s,g)):u[1]!==0&&(g=Jc(b,r,u,o,s,g)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=s)}for(m!==0&&Wb(b,r,m,h,x),b.consume(r.events),s=-1;++s<r.events.length;){const p=r.events[s];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=U4(r.events,s))}return e}function Jc(e,r,s,i,o,c){const u=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";s[0]!==0&&(c.end=Object.assign({},Ii(r.events,s[0])),e.add(s[0],0,[["exit",c,r]]));const m=Ii(r.events,s[1]);if(c={type:u,start:Object.assign({},m),end:Object.assign({},m)},e.add(s[1],0,[["enter",c,r]]),s[2]!==0){const h=Ii(r.events,s[2]),x=Ii(r.events,s[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},x)};if(e.add(s[2],0,[["enter",g,r]]),i!==2){const b=r.events[s[2]],p=r.events[s[3]];if(b[1].end=Object.assign({},p[1].end),b[1].type="chunkText",b[1].contentType="text",s[3]>s[2]+1){const w=s[2]+1,S=s[3]-s[2]-1;e.add(w,S,[])}}e.add(s[3]+1,0,[["exit",g,r]])}return o!==void 0&&(c.end=Object.assign({},Ii(r.events,o)),e.add(o,0,[["exit",c,r]]),c=void 0),c}function Wb(e,r,s,i,o){const c=[],u=Ii(r.events,s);o&&(o.end=Object.assign({},u),c.push(["exit",o,r])),i.end=Object.assign({},u),c.push(["exit",i,r]),e.add(s+1,0,c)}function Ii(e,r){const s=e[r],i=s[0]==="enter"?"start":"end";return s[1][i]}const Y4={name:"tasklistCheck",tokenize:X4};function G4(){return{text:{91:Y4}}}function X4(e,r,s){const i=this;return o;function o(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?s(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),c)}function c(m){return ln(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),u):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),u):s(m)}function u(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):s(m)}function f(m){return ft(m)?r(m):zt(m)?e.check({tokenize:Z4},r,s)(m):s(m)}}function Z4(e,r,s){return qt(e,i,"whitespace");function i(o){return o===null?s(o):r(o)}}function Q4(e){return i1([j4(),M4(),B4(e),q4(),G4()])}const K4={};function ey(e){const r=this,s=e||K4,i=r.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),c=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),u=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(Q4(s)),c.push(p4()),u.push(b4(s))}const J4=/<think>([\s\S]*?)<\/think>/g;function W4(e){const r=[],s=e.replace(J4,(i,o)=>{const c=o.trim();return c&&r.push(c),""});return{thinking:r,rest:s.trim()}}const ty={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:r})=>r?.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",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:r})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline",children:r}),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 er({content:e,className:r=""}){const{thinking:s,rest:i}=W4(e);return t.jsxs("div",{className:`prose prose-sm max-w-none ${r}`,children:[s.length>0&&(()=>{const o=s.join(`
|
|
40
|
-
|
|
41
|
-
`),c=o.split(`
|
|
42
|
-
`)[0]??"",u=c.length>80?c.slice(0,80)+"…":c;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:u})]}),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 max-h-60 overflow-y-auto leading-relaxed",children:t.jsx(Yb,{remarkPlugins:[ey],components:ty,children:o})})})]})})(),t.jsx(Yb,{remarkPlugins:[ey],components:ty,children:i})]})}const ny={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 webpage",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",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:"🔍"},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:"🌐"},click:{label:"Clicking element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list:{label:"Checking team",icon:"👥"},create_task:{label:"Creating task",icon:"📌"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"}};function dm(e){const r=e.includes("__")?e.split("__").pop():e;return ny[r]??ny[e]??{label:r.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function eT(e){const r=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const i=`${s.tool}_${s.ts}`;r.push({key:i,tool:s.tool,status:"running"})}else for(let i=r.length-1;i>=0;i--)if(r[i].tool===s.tool&&r[i].status==="running"){r[i]={...r[i],status:s.success===!1?"error":"done"};break}}return r}function Q1(){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 tT(){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 ry({item:e,idx:r,total:s}){const i=dm(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:[r>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"?"✗":""}),r<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:i.icon}),t.jsxs("span",{children:[i.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(Q1,{})]})]})}function nT({activities:e,isActive:r,persistent:s}){const i=eT(e),[o,c]=j.useState(!1),[u,f]=j.useState(!1),m=j.useRef(null);if(j.useEffect(()=>(s||r||e.length>0?(c(!0),m.current&&clearTimeout(m.current)):m.current=setTimeout(()=>c(!1),800),()=>{m.current&&clearTimeout(m.current)}),[s,r,e.length]),!o)return null;const h=i.length>0,x=h&&i.every(p=>p.status!=="running"),g=r&&!h,b=r&&h&&x;if(s&&x){const p=i.filter(S=>S.status==="error").length,w=i.filter(S=>S.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>f(S=>!S),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 ${u?"rotate-90":""}`,children:"▶"}),t.jsxs("span",{className:"font-medium",children:[w," step",w!==1?"s":""]}),p>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",p," failed"]}),!u&&t.jsxs("span",{className:"ml-1 flex gap-0.5",children:[i.slice(0,5).map(S=>t.jsx("span",{className:"text-[10px] opacity-60",title:dm(S.tool).label,children:dm(S.tool).icon},S.key)),i.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",i.length-5]})]})]}),u&&t.jsx("div",{className:"mt-2 space-y-0.5",children:i.map((S,T)=>t.jsx(ry,{item:S,idx:T,total:i.length},S.key))})]})}return t.jsxs("div",{className:"mb-2 space-y-0.5",children:[i.map((p,w)=>t.jsx(ry,{item:p,idx:w,total:i.length},p.key)),g&&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(tT,{})]}),b&&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(Q1,{}),t.jsx("span",{children:"Writing response…"})]})]})]})}var K1=qv();const sy={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:"🔍"}};function Qm(e){const r=e.includes("__")?e.split("__").pop():e;return sy[r]??sy[e]??{label:r.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function rT(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const r=e.args.command;return typeof r=="string"?r:null}function Km(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Jm(e){const r=new Date(e);if(isNaN(r.getTime()))return e;const s=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0"),o=String(r.getHours()).padStart(2,"0"),c=String(r.getMinutes()).padStart(2,"0"),u=String(r.getSeconds()).padStart(2,"0");return`${s}-${i} ${o}:${c}:${u}`}function J1(e,r){return e.length<=r?e:e.slice(0,r)+"…"}function wu(e){try{const r=JSON.parse(e);return JSON.stringify(r,null,2)}catch{return e}}function sT(e){if(!e||typeof e!="object")return"";const r=e,s=[];for(const[i,o]of Object.entries(r)){if(o==null)continue;const c=typeof o=="string"?o:JSON.stringify(o);s.push(`${i}: ${J1(c,120)}`)}return s.join(", ")}function aT(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,i])=>({key:s,value:typeof i=="string"?i:JSON.stringify(i,null,2)}))}function Wm(e){const r=Jm(e.createdAt),s=e.createdAt,i=e.metadata;switch(e.type){case"text":return{type:"text",content:e.content,time:r,timestamp:s};case"status":return{type:"status",content:e.content,time:r,timestamp:s};case"error":return{type:"error",content:e.content,time:r,timestamp:s};case"tool_start":return{type:"tool",time:r,timestamp:s,key:`ts_${e.seq}`,info:{tool:e.content,status:"running",args:i?.arguments}};case"tool_end":return{type:"tool",time:r,timestamp:s,key:`te_${e.seq}`,info:{tool:e.content,status:i?.success===!1?"error":"done",args:i?.arguments,result:i?.result,error:i?.error,durationMs:i?.durationMs}};default:return null}}function W1(e){const r=Jm(e.createdAt),s=e.metadata;switch(e.type){case"text":return{type:"text",content:e.content,time:r};case"status":return{type:"status",content:e.content,time:r};case"error":return{type:"error",content:e.content,time:r};case"tool_start":return{type:"tool",time:r,key:`as_${e.seq}`,info:{tool:e.content,status:"running",args:s?.arguments??s?.args}};case"tool_end":return{type:"tool",time:r,key:`ae_${e.seq}`,info:{tool:e.content,status:s?.success===!1?"error":"done",args:s?.arguments,result:s?.result??s?.preview,error:s?.error,durationMs:s?.durationMs}};default:return null}}function bo(e){const r=new Set;for(let s=0;s<e.length;s++){const i=e[s];if(i.type==="tool"&&(i.info.status==="done"||i.info.status==="error"))for(let o=s-1;o>=0;o--){const c=e[o];if(c.type==="tool"&&c.info.status==="running"&&c.info.tool===i.info.tool&&!r.has(o)){r.add(o);break}}}return e.filter((s,i)=>!r.has(i))}function Nu({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(r=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${r}ms`,animationDuration:"1s"}},r))})]})}function ej({content:e,className:r}){return t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1",children:[t.jsx(er,{content:e,className:r??"text-sm text-fg-secondary"}),t.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}function iT({info:e,anchorRef:r,onHover:s}){const[i,o]=j.useState(null);if(j.useEffect(()=>{if(r.current){const h=r.current.getBoundingClientRect(),x=h.top>240;o({left:Math.max(8,Math.min(h.left,window.innerWidth-340)),top:x?h.top-6:h.bottom+6,direction:x?"above":"below"})}},[r]),!i)return null;const c=sT(e.args),u=e.status!=="error",f=Qm(e.tool),m={position:"fixed",left:i.left,...i.direction==="above"?{bottom:window.innerHeight-i.top}:{top:i.top},zIndex:9999};return K1.createPortal(t.jsxs("div",{style:m,className:"w-96 max-w-[90vw] max-h-[60vh] bg-surface-secondary border border-border-default rounded-lg shadow-xl text-xs flex flex-col",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border-default flex items-center justify-between shrink-0",children:[t.jsx("span",{className:"font-medium text-fg-primary",children:f.label}),t.jsxs("div",{className:"flex items-center gap-2",children:[e.durationMs!=null&&t.jsx("span",{className:"text-fg-tertiary",children:Km(e.durationMs)}),t.jsx("span",{className:u?"text-green-600":"text-red-500",children:u?"✓ ok":"✗ failed"})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[c&&t.jsxs("div",{className:"px-3 py-1.5 border-b border-border-default",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider mb-0.5",children:"Arguments"}),t.jsx("div",{className:"text-fg-secondary font-mono text-[11px] break-all",children:c})]}),e.result&&t.jsxs("div",{className:"px-3 py-1.5",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider mb-0.5",children:"Result"}),t.jsx("div",{className:"text-fg-secondary font-mono text-[11px] break-all whitespace-pre-wrap",children:wu(e.result)})]}),e.error&&t.jsxs("div",{className:"px-3 py-1.5",children:[t.jsx("div",{className:"text-[10px] text-red-500 uppercase tracking-wider mb-0.5",children:"Error"}),t.jsx("div",{className:"text-red-500 font-mono text-[11px] break-all whitespace-pre-wrap",children:wu(String(e.error))})]}),!c&&!e.result&&!e.error&&t.jsx("div",{className:"px-3 py-1.5 text-fg-tertiary italic",children:"No details recorded"})]}),t.jsx("div",{className:"px-3 py-1 border-t border-border-default text-[10px] text-fg-tertiary shrink-0",children:"Click to expand full details"})]}),document.body)}function lT({info:e,onClose:r}){const s=Qm(e.tool),i=aT(e.args),o=e.status!=="error";return j.useEffect(()=>{const c=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[r]),t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:r,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:c=>c.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:Km(e.durationMs)}),t.jsx("button",{onClick:r,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:[i.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:i.map(({key:c,value:u})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:c}),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:u})]},c))})]}),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:wu(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:wu(String(e.error))})]}),!i.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."})]})]})]})}function oT(e,r){if(e!=="task_create"&&e!=="create_task"||!r)return null;try{const s=JSON.parse(r);if(!s.task)return null;const i=s.task;return{taskId:i.id,title:i.title,description:i.description,assignedAgentId:i.assignedAgentId,priority:i.priority}}catch{return null}}const tj={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},ay={pending_approval:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",cancelled:"cancelled",archived:"archived"},iy={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 cT({info:e}){const[r,s]=j.useState("loading");j.useEffect(()=>{let m=!1;return ae.tasks.get(e.taskId).then(({task:h})=>{m||s(ay[h.status]??"pending")}).catch(()=>{m||s("pending")}),()=>{m=!0}},[e.taskId]),j.useEffect(()=>En.on("task:update",m=>{const h=m.payload;h.taskId===e.taskId&&h.status&&s(ay[h.status]??"pending")}),[e.taskId]);const i=async()=>{s("approving");try{await ae.tasks.approve(e.taskId),s("in_progress")}catch{s("pending")}},o=async()=>{s("rejecting");try{await ae.tasks.reject(e.taskId),s("cancelled")}catch{s("pending")}},c=r==="pending"||r==="approving"||r==="rejecting",u=iy[r]??iy.loading,f=()=>Ut.navigate("tasks",{openTask:e.taskId});return t.jsxs("div",{className:`my-2 rounded-lg border ${u.borderClass} ${u.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:f,onKeyDown:m=>m.key==="Enter"&&f(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:u.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 ${u.badgeClass}`,children:"Task"}),!c&&r!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${u.textClass}`,children:u.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!c&&r!=="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:tj[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.taskId.slice(0,8),"..."]})]})]})]}),c&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:i,disabled:r!=="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:r==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:o,disabled:r!=="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:r==="rejecting"?"Rejecting…":"Reject"})]})]})}function uT(e,r){if(e!=="requirement_propose"||!r)return null;try{const s=JSON.parse(r);if(s.status!=="success"||!s.requirement)return null;const i=s.requirement;return i.status!=="draft"&&i.status!=="pending_review"?null:{requirementId:i.id,title:i.title,description:i.description,priority:i.priority}}catch{return null}}function dT({info:e}){const[r,s]=j.useState("idle"),[i,o]=j.useState(""),[c,u]=j.useState(!1),f=async()=>{s("approving");try{await ae.requirements.approve(e.requirementId),s("approved")}catch{s("idle")}},m=async()=>{if(!c){u(!0);return}if(i.trim()){s("rejecting");try{await ae.requirements.reject(e.requirementId,i.trim()),s("rejected")}catch{s("idle")}}},h=r==="approved"||r==="rejected";return t.jsxs("div",{className:`my-2 rounded-lg border ${h?"border-border-default/40 bg-surface-secondary/30":"border-amber-500/40 bg-amber-500/5"} p-3 max-w-md`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[t.jsx("span",{className:"text-amber-500 text-sm mt-0.5",children:h?r==="approved"?"✅":"❌":"📋"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 font-medium",children:"REQ"})}),t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate mt-1",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:tj[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.requirementId.slice(0,8),"..."]})]})]})]}),!h&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default/30 space-y-2",children:[c&&t.jsx("input",{type:"text",value:i,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:f,disabled:r!=="idle",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:r==="approving"?"Approving...":"Approve"}),t.jsx("button",{onClick:m,disabled:r!=="idle"||c&&!i.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:r==="rejecting"?"Rejecting...":"Reject"})]})]}),r==="approved"&&t.jsx("div",{className:"text-xs text-green-500 mt-1.5",children:"Requirement approved — agents can now create tasks for it"}),r==="rejected"&&t.jsxs("div",{className:"text-xs text-fg-tertiary mt-1.5",children:["Requirement rejected",i?`: ${i}`:""]})]})}function nj({info:e,showTime:r,time:s,isLast:i}){const o=Qm(e.tool),[c,u]=j.useState(!1),[f,m]=j.useState(!1),h=j.useRef(null),x=j.useRef(void 0),g=e.status!=="running",b=e.status==="stopped",p=j.useCallback(T=>{clearTimeout(x.current),T?x.current=setTimeout(()=>u(!0),200):x.current=setTimeout(()=>u(!1),150)},[]);j.useEffect(()=>()=>clearTimeout(x.current),[]);const w=rT(e),S=j.useRef(null);return j.useEffect(()=>{S.current&&(S.current.scrollTop=S.current.scrollHeight)},[e.liveOutput]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:h,className:`relative flex items-start gap-2 py-0.5 ${i?"":"border-b border-border-default/30 pb-1.5 mb-0.5"} ${g?"cursor-pointer rounded hover:bg-surface-elevated/30 transition-colors":""}`,onMouseEnter:()=>g&&p(!0),onMouseLeave:()=>p(!1),onClick:()=>g&&m(!0),children:[r&&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":b?"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"?"✗":b?"■":""})}),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":b?"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:Km(e.durationMs)})]}),w&&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:w,children:[t.jsx("span",{className:"text-fg-tertiary select-none",children:"$ "}),J1(w,120)]}),e.liveOutput&&e.status==="running"&&t.jsx("pre",{ref:S,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})]}),c&&t.jsx(iT,{info:e,anchorRef:h,onHover:p})]}),f&&t.jsx(lT,{info:e,onClose:()=>m(!1)}),g&&(()=>{const T=oT(e.tool,e.result);if(T)return t.jsx(cT,{info:T});const E=uT(e.tool,e.result);return E?t.jsx(dT,{info:E}):null})()]})}const fT=j.memo(Fi);function Fi({entry:e,showTime:r,isLast:s}){if(e.type==="tool")return t.jsx(nj,{info:e.info,showTime:r,time:e.time,isLast:s},e.key);if(e.type==="text")return t.jsxs("div",{className:"flex items-start gap-2 ",children:[r&&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 bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1",children:t.jsx(er,{content:e.content,className:"text-sm text-fg-secondary"})})]});if(e.type==="status"){const i=e.content==="completed"||e.content==="execution_finished",o=e.content==="started",c=e.content==="resumed",u=i?"text-green-600":o?"text-blue-600":c?"text-amber-600":"text-fg-tertiary",f=i?"bg-green-400":o?"bg-blue-400":c?"bg-amber-400":"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 py-0.5 px-1",children:[r&&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 ${f}`}),t.jsx("span",{className:`text-xs capitalize ${u}`,children:e.content})]})}return e.type==="error"?t.jsxs("div",{className:"flex items-start gap-2 ",children:[r&&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 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded px-2.5 py-2 my-1 leading-relaxed",children:[t.jsx("span",{className:"font-medium",children:"Error:"})," ",e.content]})]}):null}const hT="(max-width: 767px)";let Th=null;function rj(){return Th||(Th=window.matchMedia(hT)),Th}function mT(e){const r=rj();return r.addEventListener("change",e),()=>r.removeEventListener("change",e)}function xT(){return rj().matches}function gT(){return!1}function gs(){return j.useSyncExternalStore(mT,xT,gT)}function sj({title:e,message:r,confirmLabel:s="Confirm",checkboxes:i,onConfirm:o,onCancel:c}){const[u,f]=j.useState(()=>{const m={};for(const h of i??[])m[h.id]=h.defaultChecked??!1;return m});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:c,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:r}),i&&i.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:i.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:u[m.id]??!1,onChange:h=>f(x=>({...x,[m.id]:h.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:c,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(i?u: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 Fu({children:e,onClose:r,title:s,width:i="w-[440px]"}){return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:r,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${i} 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 Ls({label:e,children:r}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:e}),r]})}function pT({onClose:e,onCreate:r}){const[s,i]=j.useState(""),[o,c]=j.useState("");return t.jsx(Fu,{onClose:e,title:"Create a New Team",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ls,{label:"Team Name",children:t.jsx("input",{value:s,onChange:u=>i(u.target.value),placeholder:"e.g. Engineering, Marketing, Support",className:"input",autoFocus:!0,onKeyDown:u=>{u.key==="Enter"&&s.trim()&&r(s.trim(),o.trim()||void 0)}})}),t.jsx(Ls,{label:"Description (optional)",children:t.jsx("textarea",{value:o,onChange:u=>c(u.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()&&r(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 bT({teamId:e,teams:r,onClose:s,onAdd:i}){const[o,c]=j.useState(""),[u,f]=j.useState("member"),[m,h]=j.useState(""),[x,g]=j.useState(""),[b,p]=j.useState(""),[w,S]=j.useState(e??""),[T,E]=j.useState(""),C=()=>{if(E(""),!o.trim()){E("Name is required");return}if(x&&x!==b){E("Passwords do not match");return}i(o.trim(),u,m||void 0,x||void 0,w||void 0)};return t.jsx(Fu,{onClose:s,title:"Add Human Team Member",width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ls,{label:"Name *",children:t.jsx("input",{value:o,onChange:N=>c(N.target.value),placeholder:"Full name",className:"input",autoFocus:!0})}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Ls,{label:"Role",children:t.jsxs("select",{value:u,onChange:N=>f(N.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(Ls,{label:"Assign to Team",children:t.jsxs("select",{value:w,onChange:N=>S(N.target.value),className:"input",children:[t.jsx("option",{value:"",children:"No team"}),r.map(N=>t.jsx("option",{value:N.id,children:N.name},N.id))]})})]}),t.jsx(Ls,{label:"Email",children:t.jsx("input",{value:m,onChange:N=>h(N.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(Ls,{label:"Password",children:t.jsx("input",{value:x,onChange:N=>g(N.target.value),type:"password",placeholder:"Leave blank for no login access",className:"input"})}),x&&t.jsx("div",{className:"mt-3",children:t.jsx(Ls,{label:"Confirm Password",children:t.jsx("input",{value:b,onChange:N=>p(N.target.value),type:"password",placeholder:"Repeat password",className:"input"})})})]}),T&&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:T}),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:C,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 rounded-lg text-white",children:"Add Member"})]})]})})}function yT({teamId:e,ungrouped:r,onClose:s,onAdd:i}){return t.jsx(Fu,{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."}),r.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:r.map(o=>t.jsxs("button",{onClick:()=>i(o.id,o.type),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:border-brand-500 hover:bg-brand-500/10 text-left transition-all",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold text-white ${o.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:o.name.charAt(0)}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-sm",children:o.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[o.role," · ",o.type==="agent"?"AI":"Human"]})]}),o.status&&t.jsx("span",{className:`w-2 h-2 rounded-full ${o.status==="idle"?"bg-green-400":o.status==="working"?"bg-brand-400":"bg-gray-600"}`})]},o.id))}),t.jsx("div",{className:"flex justify-end pt-2",children:t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Close"})})]})})}function vT({onClose:e,onConnected:r}){const[s,i]=j.useState(""),[o,c]=j.useState(""),[u,f]=j.useState(!1),[m,h]=j.useState(null),[x,g]=j.useState(null),b=async()=>{if(!s.trim()){c("Agent name is required");return}const w=s.trim().toLowerCase().replace(/\s+/g,"-");f(!0),c("");try{const S=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(!S.ok){const E=await S.json().catch(()=>({}));throw new Error(E.error??`HTTP ${S.status}`)}const T=await S.json();h({externalAgentId:w,markusAgentId:T.registration?.markusAgentId,token:T.token,gatewayUrl:T.gatewayUrl})}catch(S){c(String(S))}f(!1)},p=(w,S)=>{navigator.clipboard.writeText(w),g(S),setTimeout(()=>g(null),2e3)};return t.jsx(Fu,{onClose:e,title:"Import OpenClaw Agent",width:"w-[560px]",children:m?(()=>{const w=m.gatewayUrl??`${window.location.origin}/api/gateway`,S=`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:()=>p(S,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${x==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:x==="prompt"?"Copied!":"Copy Connection Prompt"})]}),t.jsx("div",{className:"flex justify-end pt-5",children:t.jsx("button",{onClick:()=>{r()},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(Ls,{label:"Agent Name *",children:t.jsx("input",{className:"input",placeholder:"e.g. Alice",value:s,onChange:w=>i(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:b,disabled:u,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-white disabled:opacity-50",children:u?"Connecting...":"Import Agent"})]})]})]})})}let ly=new Map;function jT(e){return e.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2)}function wT({authUser:e,agents:r,teams:s,humans:i,tasks:o,externalAgents:c,groupChats:u,chatMode:f,selectedAgent:m,activeChannel:h,activeDmUserId:x,onSelectAgent:g,onSelectChannel:b,onSelectDm:p,onRefreshTeams:w,onRefreshAgents:S,onViewProfile:T,width:E,onResizeStart:C}){const N=gs(),k=e?.role==="owner"||e?.role==="admin",H=j.useMemo(()=>new Set(c.map(oe=>oe.markusAgentId).filter(Boolean)),[c]),[M,Y]=j.useState([]),[$,X]=j.useState(new Set),[P,q]=j.useState(!1),[F,D]=j.useState(null),[_,I]=j.useState(null),[A,G]=j.useState(!1),[U,K]=j.useState(null),[B,L]=j.useState(null),[W,R]=j.useState(null),[z,V]=j.useState(!1),Q=j.useRef(null),[te,Z]=j.useState(null),ee=(oe,Le="success")=>{Z({message:oe,type:Le}),setTimeout(()=>Z(null),3e3)},[ie,je]=j.useState(null),ke=(oe,Le,$e,st,at)=>{je({title:oe,message:Le,onConfirm:$e,confirmLabel:st,checkboxes:at})},[De,Ie]=j.useState(null),[ze,Ze]=j.useState(null),Ae=j.useRef(null),We=j.useRef(null),[xt,Lt]=j.useState(!1),[le,_e]=j.useState(null),[ht,Ct]=j.useState(""),Ft=j.useCallback(oe=>{if(!oe)return;const Le=oe.getBoundingClientRect(),$e=8;Le.bottom>window.innerHeight&&(oe.style.top=`${Math.max($e,window.innerHeight-Le.height-$e)}px`),Le.right>window.innerWidth&&(oe.style.left=`${Math.max($e,window.innerWidth-Le.width-$e)}px`)},[]),[be,Me]=j.useState(ly),Ve=j.useMemo(()=>r.map(oe=>oe.id).sort().join(","),[r]);j.useEffect(()=>{if(!r.length)return;let oe=!1;const Le=async()=>{const st=[];if(await Promise.allSettled(r.map(async at=>{try{const{sessions:Ue}=await ae.sessions.listByAgent(at.id,1);if(!Ue.length)return;const{messages:jn}=await ae.sessions.getMessages(Ue[0].id,1);if(jn.length){const gn=jn[0],Dt=gn.metadata?.segments;let Dn=gn.content;if(Dt&&Dt.length>0){const On=[...Dt].reverse().find(on=>on.type==="text");On&&On.type==="text"&&(Dn=On.content)}const Un=Dn.replace(/<think>[\s\S]*?<\/think>/g,"").replace(/\n+/g," ").trim().slice(0,80);Un&&st.push([at.id,Un])}}catch{}})),!oe){const at=new Map(st);ly=at,Me(at)}};Le();const $e=setInterval(Le,3e4);return()=>{oe=!0,clearInterval($e)}},[Ve]);const Xe=j.useCallback(()=>{ae.teams.list().then(oe=>Y(oe.ungrouped)).catch(()=>{})},[]);j.useEffect(()=>{Xe()},[Xe]),j.useEffect(()=>En.on("*",Xe),[Xe]),j.useEffect(()=>{if(!U&&!B&&!z)return;const oe=Le=>{K(null),L(null),V(!1)};return setTimeout(()=>document.addEventListener("click",oe),0),()=>document.removeEventListener("click",oe)},[U,B,z]);const rt=(oe,Le)=>{ke(`Delete "${Le}"?`,"This team will be removed from the database. Check options below to also delete members and disk files.",async $e=>{const st=$e?.deleteMembers??!0,at=$e?.purgeFiles??!1;await ae.teams.delete(oe,st,{purgeFiles:at}),w(),Xe(),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}])},It=async(oe,Le)=>{try{const st=await(Le==="start"?ae.teams.startAll:Le==="stop"?ae.teams.stopAll:Le==="pause"?ae.teams.pauseAll:ae.teams.resumeAll)(oe),at=st.success?.length??0,Ue=st.failed?.length??0,jn={start:"started",stop:"stopped",pause:"paused",resume:"resumed"};Ue>0?ee(`${Le}: ${at} succeeded, ${Ue} failed`,"error"):at>0&&ee(`${at} agent${at>1?"s":""} ${jn[Le]}`,"success"),S()}catch($e){ee(`Failed to ${Le}: ${$e instanceof Error?$e.message:String($e)}`,"error")}},Ht=async(oe,Le,$e)=>{await ae.teams.update(oe,{managerId:Le,managerType:$e}),w()},_t=async oe=>{if(!ht.trim()){_e(null);return}await ae.teams.update(oe,{name:ht.trim()}),_e(null),w()},wt=async(oe,Le)=>{Le==="offline"?await ae.agents.start(oe):await ae.agents.stop(oe),S()},xe=(oe,Le)=>{ke("Remove from team?","This member will be moved to Ungrouped.",async()=>{await ae.teams.removeMember(oe,Le),w(),Xe()},"Remove")},Be=(oe,Le,$e)=>{ke(`Remove "${Le}"?`,"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 at=st?.purgeFiles??!1;await ae.agents.remove(oe,{purgeFiles:at})}S(),w(),Xe(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Remove",[{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},gt=(oe,Le,$e)=>{We.current={x:oe.clientX,y:oe.clientY},Ae.current=setTimeout(()=>{Ie({agentId:Le,fromTeamId:$e}),Lt(!0)},200)},pt=oe=>{if(!We.current||!Ae.current)return;const Le=Math.abs(oe.clientX-We.current.x),$e=Math.abs(oe.clientY-We.current.y);(Le>5||$e>5)&&(xt||(clearTimeout(Ae.current),Ae.current=null))},ue=async()=>{if(Ae.current&&(clearTimeout(Ae.current),Ae.current=null),We.current=null,xt&&De&&ze){const oe=ze==="_ungrouped"?void 0:ze;try{if(De.fromTeamId&&De.fromTeamId!==oe&&await ae.teams.removeMember(De.fromTeamId,De.agentId),oe&&oe!==De.fromTeamId){const Le=r.find($e=>$e.id===De.agentId);await ae.teams.addMember(oe,De.agentId,"agent")}w(),S(),Xe()}catch(Le){ee(`Move failed: ${Le instanceof Error?Le.message:String(Le)}`,"error")}}Ie(null),Ze(null),Lt(!1)},Se=j.useMemo(()=>new Map(s.map(oe=>[oe.id,oe])),[s]),Ke=j.useMemo(()=>{const oe=new Map,Le=[];for(const $e of r)if($e.teamId&&Se.has($e.teamId)){const st=oe.get($e.teamId)??[];st.push($e),oe.set($e.teamId,st)}else Le.push($e);return{byTeam:oe,ungrouped:Le}},[r,Se]);s.filter(oe=>Ke.byTeam.has(oe.id)||oe.members?.length>0).map(oe=>oe.id);const At=oe=>X(Le=>{const $e=new Set(Le);return $e.has(oe)?$e.delete(oe):$e.add(oe),$e}),rn=(oe,Le)=>{const $e=f==="direct"&&m===oe.id,st=H.has(oe.id),at=oe.status==="idle"?"bg-green-500":oe.status==="working"?"bg-blue-500 animate-pulse":oe.status==="error"?"bg-red-500":oe.status==="paused"?"bg-amber-500":"bg-gray-600",jn=(Le?Se.get(Le):void 0)?.managerId===oe.id,gn=oe.role?.toLowerCase().replace(/[-_]/g," ").trim(),Dt=oe.name.toLowerCase().trim(),Dn=gn&&gn!==Dt,Un=be.get(oe.id)||oe.currentActivity?.label?.slice(0,60)||"",On=oe.status==="idle"?"Online":oe.status==="working"?"Working":oe.status==="error"?"Error":oe.status==="paused"?"Paused":"Offline";return t.jsx("div",{className:`relative mb-0.5 ${xt&&De?.agentId===oe.id?"opacity-40":""}`,onPointerDown:on=>gt(on,oe.id,Le),onPointerMove:pt,onPointerUp:ue,children:t.jsxs("button",{onClick:()=>{xt||g(oe.id)},onContextMenu:on=>{k&&(on.preventDefault(),L({agentId:oe.id,teamId:Le,x:on.clientX,y:on.clientY}))},className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs transition-colors select-none ${N?"":"touch-none"} ${$e?"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 ${$e?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:jT(oe.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:oe.name}),Dn&&t.jsxs("span",{className:"text-[9px] text-fg-tertiary shrink-0 truncate max-w-[60px]",children:["(",oe.role,")"]}),jn&&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:Un||" "})]}),t.jsx("span",{title:On,onClick:on=>{on.stopPropagation(),T(oe.id)},className:`w-2 h-2 rounded-full shrink-0 cursor-pointer transition-transform duration-150 hover:scale-[2] ${at}`})]})},oe.id)},vn=(oe,Le,$e,st)=>{const at=$.has(oe),Ue=xt&&ze===oe&&De?.fromTeamId!==oe,jn=oe!=="_ungrouped"?(Mt.byTeam.get(oe)??[])[0]:void 0,gn=jn&&f==="channel"&&h===jn.channelKey;return t.jsxs("div",{className:`mb-1 rounded-lg transition-colors ${Ue?"ring-1 ring-brand-500/50 bg-brand-500/5":""}`,onPointerEnter:()=>{xt&&Ze(oe)},onPointerLeave:()=>{xt&&ze===oe&&Ze(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{jn?b(jn.channelKey):At(oe)},onContextMenu:Dt=>{!k||!Le||(Dt.preventDefault(),K({teamId:oe,x:Dt.clientX,y:Dt.clientY}))},className:`flex-1 flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors min-w-0 ${gn?"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 ${gn?"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:[le===oe?t.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-secondary text-[11px] font-medium outline-none w-full",value:ht,onChange:Dt=>Ct(Dt.target.value),onBlur:()=>_t(oe),onKeyDown:Dt=>{Dt.key==="Enter"&&_t(oe),Dt.key==="Escape"&&_e(null)},onClick:Dt=>Dt.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:[$e.length," members"]})]})]}),t.jsx("button",{onClick:()=>At(oe),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:at?"Expand":"Collapse",children:t.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${at?"":"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"})})}),k&&Le&&t.jsx("button",{onClick:Dt=>{Dt.stopPropagation(),K({teamId:oe,x:Dt.clientX,y:Dt.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"})]})})]}),Ue&&xt&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:"Drop here"}),!at&&t.jsx("div",{className:"ml-1",children:$e.map(Dt=>rn(Dt,oe==="_ungrouped"?void 0:oe))})]},oe)},Mt=j.useMemo(()=>{const oe=new Map,Le=[];for(const $e of u)if($e.teamId){const st=oe.get($e.teamId)??[];st.push($e),oe.set($e.teamId,st)}else{const st=s.find(at=>$e.name.toLowerCase().includes(at.name.toLowerCase())||at.name.toLowerCase().includes($e.name.toLowerCase()));if(st){const at=oe.get(st.id)??[];at.push($e),oe.set(st.id,at)}else Le.push($e)}return{byTeam:oe,unmatched:Le}},[u,s]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`bg-surface-secondary/60 border-r border-border-default flex flex-col ${E!=null?"shrink-0":"flex-1 min-w-0"}`,style:E!=null?{width:E}:void 0,children:[t.jsx("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"})}),k&&t.jsx("div",{className:"px-3 pt-2 pb-1 flex items-center gap-1.5",ref:Q,children:t.jsxs("div",{className:"relative flex-1",children:[t.jsxs("button",{onClick:()=>V(!z),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 ${z?"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"})})]}),z&&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:()=>{V(!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:()=>{V(!1),Ut.navigate("agents")},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:()=>{V(!1),G(!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:()=>{V(!1),D({})},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:[r.length===0&&s.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:"No agents yet"}),Mt.unmatched.map(oe=>t.jsxs("button",{onClick:()=>b(oe.channelKey),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${f==="channel"&&h===oe.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 ${f==="channel"&&h===oe.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:oe.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:"Group Chat"})]}),oe.memberCount!==void 0&&oe.memberCount>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary shrink-0",children:oe.memberCount})]},oe.id)),s.map(oe=>{const Le=Ke.byTeam.get(oe.id)??[];return Le.length===0&&(!oe.members||oe.members.length===0)?null:vn(oe.id,oe,Le,oe.name)}),s.filter(oe=>(Ke.byTeam.get(oe.id)??[]).length===0&&oe.members&&oe.members.length>0).map(oe=>vn(oe.id,oe,[],oe.name)),Ke.ungrouped.length>0&&vn("_ungrouped",null,Ke.ungrouped,"Other"),s.length===0&&r.length>0&&r.map(oe=>rn(oe)),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:()=>p(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 ${f==="dm"&&(x===e.id||!x)?"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 ${f==="dm"&&(x===e.id||!x)?"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"})]})})]}),i.filter(oe=>oe.id!==e?.id).map(oe=>t.jsxs("button",{onClick:()=>p(oe.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${f==="dm"&&x===oe.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 ${f==="dm"&&x===oe.id?"bg-green-600 text-white":"bg-green-500/10 text-green-600"}`,children:oe.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:oe.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:oe.email||oe.role})]}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shrink-0"})]},oe.id))]})]})]}),C&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative",onMouseDown:C,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"})}),U&&(()=>{const oe=Ke.byTeam.get(U.teamId)??[],Le=oe.some(Ue=>Ue.status==="offline"),$e=oe.some(Ue=>Ue.status==="idle"||Ue.status==="working"),st=oe.some(Ue=>Ue.status==="paused"),at=oe.some(Ue=>Ue.status!=="offline");return t.jsxs("div",{ref:Ft,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:U.x,top:U.y},onClick:Ue=>Ue.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{const Ue=Se.get(U.teamId);Ue&&(_e(U.teamId),Ct(Ue.name)),K(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"]}),Le&&t.jsxs("button",{onClick:()=>{It(U.teamId,"start"),K(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"]}),at&&t.jsxs("button",{onClick:()=>{It(U.teamId,"stop"),K(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"]}),$e&&t.jsxs("button",{onClick:()=>{It(U.teamId,"pause"),K(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:()=>{It(U.teamId,"resume"),K(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:()=>{K(null),Ut.navigate("agents")},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:()=>{K(null),D({teamId:U.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"]}),M.length>0&&t.jsxs("button",{onClick:()=>{K(null),I(U.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 Ue=Se.get(U.teamId);Ue&&rt(U.teamId,Ue.name),K(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"]})]})})(),B&&(()=>{const oe=r.find(at=>at.id===B.agentId);if(!oe)return null;const $e=(B.teamId?Se.get(B.teamId):void 0)?.managerId===oe.id,st=oe.id===e?.id;return t.jsxs("div",{ref:Ft,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:B.x,top:B.y},onClick:at=>at.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{L(null),T(oe.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"]}),oe.status==="offline"?t.jsxs("button",{onClick:()=>{wt(oe.id,"offline"),L(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:()=>{wt(oe.id,oe.status??"idle"),L(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"]}),B.teamId&&!$e&&t.jsxs("button",{onClick:()=>{Ht(B.teamId,oe.id,"agent"),L(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"]}),B.teamId&&t.jsxs("button",{onClick:()=>{xe(B.teamId,oe.id),L(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(at=>at.id!==B.teamId).map(at=>t.jsx("button",{onClick:async()=>{B.teamId&&await ae.teams.removeMember(B.teamId,oe.id),await ae.teams.addMember(at.id,oe.id,"agent"),w(),S(),Xe(),L(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:at.name},at.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!st&&t.jsxs("button",{onClick:()=>{Be(oe.id,oe.name),L(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"]})]})})(),P&&t.jsx(pT,{onClose:()=>q(!1),onCreate:async(oe,Le)=>{await ae.teams.create(oe,Le),q(!1),w()}}),F!==null&&t.jsx(bT,{teamId:F.teamId,teams:s,onClose:()=>D(null),onAdd:async(oe,Le,$e,st,at)=>{await ae.users.create(oe,Le,void 0,$e,st,at),D(null),w()}}),_!==null&&t.jsx(yT,{teamId:_,ungrouped:M,onClose:()=>I(null),onAdd:async(oe,Le)=>{await ae.teams.addMember(_,oe,Le),I(null),w(),Xe()}}),A&&t.jsx(vT,{onClose:()=>G(!1),onConnected:()=>{G(!1),S(),w()}}),ie&&t.jsx(sj,{title:ie.title,message:ie.message,confirmLabel:ie.confirmLabel,checkboxes:ie.checkboxes,onConfirm:oe=>{ie.onConfirm(oe),je(null)},onCancel:()=>je(null)}),te&&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 ${te.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:te.message})]})}const NT=[{key:"overview",label:"Overview",icon:"▦"},{key:"activity",label:"Activity",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:"♡"}],kT={idle:"bg-green-400",working:"bg-brand-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function du(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function ST({agentId:e,onBack:r,inline:s}){const[i,o]=j.useState(null),[c,u]=j.useState("overview"),[f,m]=j.useState(null),h=j.useCallback(()=>{ae.agents.get(e).then(o).catch(()=>{})},[e]);if(j.useEffect(()=>(u("overview"),m(null),h(),ae.externalAgents.list().then(b=>{const p=b.agents.find(w=>w.markusAgentId===e);m(p??null)}).catch(()=>{}),En.on("agent:update",b=>{b.payload.agentId===e&&h()})),[e,h]),!i)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading agent..."});const x=kT[i.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:i.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:i.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${x}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:i.state.status}),f&&t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:"External"}),i.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:[i.role,i.roleDescription?` — ${i.roleDescription}`:""]})]}),t.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[t.jsxs("button",{onClick:()=>Ut.navigate("chat",{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(i)try{const{filesMap:g}=await ae.agents.getFilesMap(e),b={type:"agent",name:i.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||i.name,displayName:i.name,version:"1.0.0",description:i.roleDescription??i.role,author:"",category:"general",tags:[],agent:{roleName:i.role,agentRole:i.agentRole},dependencies:{skills:i.skills??[]}};await Bn.publishViaProxy({itemType:"agent",name:i.name,description:b.description,category:"general",config:b,files:g}),alert(`Published "${i.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:r,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:NT.filter(g=>!f||["overview","activity"].includes(g.key)).map(g=>t.jsxs("button",{onClick:()=>u(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(CT,{agent:i,onUpdate:h,externalInfo:f}),c==="activity"&&t.jsx(LT,{agentId:e}),c==="files"&&t.jsx(ET,{agentId:e}),c==="tools"&&t.jsx(AT,{tools:i.tools??[]}),c==="skills"&&t.jsx(MT,{agent:i,onUpdate:h}),c==="memory"&&t.jsx(DT,{agentId:e}),c==="heartbeat"&&t.jsx(OT,{agentId:e,initialData:i.heartbeat})]})]})}function CT({agent:e,onUpdate:r,externalInfo:s}){const[i,o]=j.useState(!1),[c,u]=j.useState(e.name),[f,m]=j.useState(e.agentRole),[h,x]=j.useState(e.config?.llmConfig?.modelMode??"default"),[g,b]=j.useState(e.config?.llmConfig.primary??""),[p,w]=j.useState(e.config?.llmConfig.fallback??""),[S,T]=j.useState(!1),[E,C]=j.useState({}),[N,k]=j.useState(""),[H,M]=j.useState([]),[Y,$]=j.useState(null),[X,P]=j.useState(null),[q,F]=j.useState([]),[D,_]=j.useState(null),[I,A]=j.useState(null),[G,U]=j.useState("");j.useEffect(()=>{ae.settings.getLlm().then(z=>{C(z.providers),k(z.defaultProvider)}).catch(()=>{}),ae.tasks.list({assignedAgentId:e.id}).then(z=>M(z.tasks.slice(0,5))).catch(()=>{}),ae.usage.agents().then(z=>{const V=z.agents.find(Q=>Q.agentId===e.id);V&&$(V)}).catch(()=>{}),ae.agents.getRecentActivities(e.id).then(z=>F(z.activities)).catch(()=>{}),ae.system.storage().then(z=>{U(z.dataDir+"/agents/"+e.id);const V=z.agents.find(Q=>Q.id===e.id);V&&A(V)}).catch(()=>{})},[e.id]);const K=Object.entries(E).filter(([,z])=>z.configured).map(([z])=>z),B=e.config?.llmConfig?.modelMode??"default",L=async()=>{T(!0);try{await ae.agents.updateConfig(e.id,{name:c,agentRole:f,llmConfig:{modelMode:h,primary:h==="custom"?g:N,fallback:p||void 0}}),r(),o(!1)}catch{}T(!1)},W=()=>{e.state.status==="offline"?ae.agents.start(e.id).then(r):ae.agents.stop(e.id).then(r)},R={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 z=[{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)"}],V=[{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(fn,{title:"Identity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Mn,{label:"Name",children:e.name}),t.jsx(Mn,{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(Mn,{label:"Role Template",children:e.role}),t.jsx(Mn,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx(Mn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Mn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsx(fn,{title:"Connection Status",children:t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Fn,{label:"Connection",value:s.connected?"Online":"Offline",color:s.connected?"green":"gray"}),t.jsx(Fn,{label:"Platform",value:"OpenClaw"}),t.jsx(Fn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Fn,{label:"Last Sync",value:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleTimeString():"Never"})]})}),t.jsx(fn,{title:"External Agent Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Mn,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx(Mn,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx(Mn,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx(Mn,{label:"Last Heartbeat",children:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleString():"Never"})]})}),t.jsx(fn,{title:"Sync Context (received every sync cycle)",children:t.jsx("div",{className:"space-y-1.5",children:V.map(Q=>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:Q.field}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Q.desc})]},Q.field))})}),t.jsx(fn,{title:"Gateway API Endpoints",children:t.jsx("div",{className:"space-y-1.5",children:z.map(Q=>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 ${Q.method==="POST"?"text-amber-600":"text-green-600"}`,children:Q.method}),t.jsx("span",{className:"font-mono text-[10px] text-fg-secondary shrink-0 pt-0.5",children:Q.path}),t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:Q.desc})]},Q.path))})}),H.length>0&&t.jsx(fn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>Ut.navigate("projects"),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:H.map(Q=>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 ${R[Q.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:Q.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:Q.status.replace(/_/g," ")})]},Q.id))})})]})}return t.jsxs("div",{className:"space-y-4",children:[t.jsx(fn,{title:"Identity",action:i?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:L,disabled:S,className:"text-xs text-brand-500 hover:text-brand-500",children:S?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>{o(!0),u(e.name),m(e.agentRole),x(e.config?.llmConfig?.modelMode??"default"),b(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(Mn,{label:"Name",children:i?t.jsx("input",{className:"input-sm",value:c,onChange:z=>u(z.target.value)}):e.name}),t.jsx(Mn,{label:"Agent Role",children:i?t.jsx("div",{className:"flex gap-1.5",children:["worker","manager"].map(z=>t.jsx("button",{onClick:()=>m(z),className:`px-2 py-1 text-[10px] rounded border transition-colors capitalize ${f===z?z==="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:z},z))}):t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx(Mn,{label:"Role Template",children:e.role}),t.jsx(Mn,{label:"Agent ID",mono:!0,children:e.id}),t.jsx(Mn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Mn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsxs(fn,{title:"Runtime Status",children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Fn,{label:"Status",value:e.state.status,color:e.state.status==="idle"?"green":e.state.status==="working"?"indigo":e.state.status==="error"?"red":"gray"}),t.jsx(Fn,{label:"Tokens Today",value:String(e.state.tokensUsedToday)}),t.jsx(Fn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Fn,{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:H.filter(z=>e.state.activeTaskIds?.includes(z.id)).map(z=>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:z.title}),t.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:z.status.replace(/_/g," ")})]},z.id))})]}),t.jsx("div",{className:"flex gap-2 mt-4 pt-3 border-t border-border-default/50",children:t.jsx("button",{onClick:W,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(fn,{title:"Usage",children:t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Fn,{label:"Total Tokens",value:du(Y.totalTokens)}),t.jsx(Fn,{label:"Requests",value:String(Y.requestCount)}),t.jsx(Fn,{label:"Tool Calls",value:String(Y.toolCalls)}),t.jsx(Fn,{label:"Prompt Tokens",value:du(Y.promptTokens)}),t.jsx(Fn,{label:"Completion Tokens",value:du(Y.completionTokens)}),t.jsx(Fn,{label:"Est. Cost",value:`$${Y.estimatedCost<.01?Y.estimatedCost.toFixed(4):Y.estimatedCost.toFixed(2)}`})]})}),I&&t.jsxs(fn,{title:"Storage",action:t.jsx("button",{onClick:()=>{ae.system.openPath(G)},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:oy(I.size)}),t.jsx("span",{className:"text-xs text-fg-tertiary font-mono truncate",children:G})]}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:I.subItems.filter(z=>z.size>0).map(z=>t.jsx(Fn,{label:z.name,value:oy(z.size)},z.name))})]}),t.jsx(fn,{title:"LLM Configuration",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Mn,{label:"Model Mode",children:i?t.jsx("div",{className:"flex gap-1.5",children:["default","custom"].map(z=>t.jsx("button",{onClick:()=>x(z),className:`px-2.5 py-1 text-[10px] rounded border transition-colors capitalize ${h===z?z==="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:z==="default"?"System Default":"Custom"},z))}):t.jsx("span",{className:`text-xs ${B==="custom"?"text-amber-600":"text-brand-500"}`,children:B==="custom"?"⚙ Custom":"◎ System Default"})}),t.jsx(Mn,{label:"Primary Model",children:i?h==="custom"?t.jsxs("select",{className:"input-sm",value:g,onChange:z=>b(z.target.value),children:[K.map(z=>t.jsxs("option",{value:z,children:[z," (",E[z]?.model,")"]},z)),!K.includes(g)&&g&&t.jsx("option",{value:g,children:g})]}):t.jsxs("span",{className:"text-xs text-fg-secondary italic",children:["follows system default (",N||"...",")"]}):t.jsx("span",{className:"font-mono text-xs",children:B==="custom"?e.config?.llmConfig.primary??"—":t.jsxs("span",{className:"text-fg-secondary",children:[N||e.config?.llmConfig.primary||"—"," ",t.jsx("span",{className:"text-fg-tertiary",children:"(system default)"})]})})}),t.jsx(Mn,{label:"Fallback",children:i?t.jsxs("select",{className:"input-sm",value:p,onChange:z=>w(z.target.value),children:[t.jsx("option",{value:"",children:"none"}),K.map(z=>t.jsx("option",{value:z,children:z},z))]}):t.jsx("span",{className:"font-mono text-xs",children:e.config?.llmConfig.fallback??"none"})}),t.jsx(Mn,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx(Mn,{label:"Max Tokens/Day",children:e.config?.llmConfig.maxTokensPerDay??"unlimited"})]})}),H.length>0&&t.jsx(fn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>Ut.navigate("projects"),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:H.map(z=>{const V=X===z.id,Q=["in_progress","failed","completed","review"].includes(z.status);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>Q?P(V?null:z.id):void 0,className:`w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors ${Q?"hover:bg-surface-elevated/40 cursor-pointer":"cursor-default"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${R[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," ")}),Q&&t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:V?"▲":"▼"})]}),V&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(aj,{taskId:z.id,isLive:z.status==="in_progress"})})]},z.id)})})}),q.filter(z=>z.type==="heartbeat").length>0&&t.jsx(fn,{title:"Recent Heartbeats",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[q.filter(z=>z.type==="heartbeat").length," runs"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:q.filter(z=>z.type==="heartbeat").map(z=>{const V=D===z.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>_(V?null:z.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:z.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(z.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:V?"▲":"▼"})]}),V&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(ku,{agentId:e.id,activityId:z.id})})]},z.id)})})}),q.filter(z=>z.type==="chat").length>0&&t.jsx(fn,{title:"Recent A2A Communications",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[q.filter(z=>z.type==="chat").length," conversations"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:q.filter(z=>z.type==="chat").map(z=>{const V=D===z.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>_(V?null:z.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:z.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(z.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:V?"▲":"▼"})]}),V&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(ku,{agentId:e.id,activityId:z.id})})]},z.id)})})})]})}function ET({agentId:e}){const[r,s]=j.useState([]),[i,o]=j.useState(!0),[c,u]=j.useState(null),[f,m]=j.useState(""),[h,x]=j.useState(!1),[g,b]=j.useState(!1),[p,w]=j.useState(null),[S,T]=j.useState(!1),[E,C]=j.useState(null),N=j.useCallback(()=>{o(!0),Promise.all([ae.agents.getFiles(e),ae.agents.roleStatus(e).catch(()=>null)]).then(([F,D])=>{s(F.files),w(D),F.files.length>0&&!c&&(u(F.files[0].name),m(F.files[0].content))}).catch(()=>{}).finally(()=>o(!1))},[e]);j.useEffect(()=>{N()},[N]);const k=F=>{const D=r.find(_=>_.name===F);D&&(u(F),m(D.content),b(!1),C(null))},H=async()=>{if(c){x(!0);try{await ae.agents.updateFile(e,c,f),s(F=>F.map(D=>D.name===c?{...D,content:f}:D)),b(!1),c==="ROLE.md"&&await ae.agents.updateSystemPrompt(e,f)}catch{}x(!1)}},M=async F=>{T(!0);try{await ae.agents.roleSync(e,F?[F]:void 0),C(null),b(!1),N()}catch{}T(!1)},Y=async F=>{if(E?.file===F){C(null);return}try{const D=await ae.agents.roleDiff(e,F);D.agentContent!=null&&D.templateContent!=null&&C({file:F,agent:D.agentContent,template:D.templateContent})}catch{}};if(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading files..."});const $={"ROLE.md":"System Prompt / Role Definition","HEARTBEAT.md":"Heartbeat Tasks","POLICIES.md":"Policies & Guardrails","CONTEXT.md":"Context & Instructions"},X=p?.files.filter(F=>F.status==="modified"||F.status==="added_in_template")??[],P=p?.hasTemplate&&!p.isUpToDate,q=c?X.some(F=>F.file===c):!1;return t.jsxs("div",{className:"space-y-4",children:[P&&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:[X.length," file",X.length>1?"s":""," differ from the ",t.jsx("code",{className:"px-1 py-0.5 bg-amber-500/10 rounded text-amber-600",children:p.templateId})," template:"," ",X.map(F=>F.file).join(", ")]})]}),t.jsx("button",{onClick:()=>M(),disabled:S,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:S?"Syncing...":"Sync All"})]}),t.jsxs(fn,{title:"Agent Configuration Files",action:p?.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 ${p.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:p.templateId}),p.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:r.map(F=>{const D=X.some(_=>_.file===F.name);return t.jsxs("button",{onClick:()=>k(F.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${c===F.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[F.name,D&&t.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},F.name)})}),c&&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:$[c]??c}),t.jsxs("div",{className:"flex gap-2 items-center",children:[q&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>Y(c),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:E?.file===c?"Hide Diff":"View Diff"}),t.jsx("button",{onClick:()=>M(c),disabled:S,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:S?"Syncing...":"Sync This File"})]}),g&&t.jsx("span",{className:"text-[10px] text-amber-600",children:"unsaved"}),t.jsx("button",{onClick:H,disabled:h||!g,className:`px-3 py-1 text-xs rounded-lg transition-colors ${g?"bg-brand-600 hover:bg-brand-500 text-white":"bg-surface-elevated text-fg-tertiary cursor-default"}`,children:h?"Saving...":"Save"})]})]}),E?.file===c&&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 (",p?.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:E.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:E.template})]})]}),t.jsx("textarea",{value:f,onChange:F=>{m(F.target.value),b(!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}),c==="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."})]}),r.length===0&&t.jsx($i,{text:"No configuration files found for this role"})]})]})}const TT={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_submit_review","subtask_create","subtask_complete","subtask_list"],Requirements:["requirement_propose","requirement_list","requirement_update_status"],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","task_check_duplicates","task_cleanup_duplicates","task_board_health"]};function _T(e){const r=new Map,s=new Set;for(const[c,u]of Object.entries(TT)){const f=e.filter(m=>u.some(h=>m.name.startsWith(h)));f.length>0&&(r.set(c,f),f.forEach(m=>s.add(m.name)))}const i=e.filter(c=>!s.has(c.name));for(const c of i){const u=c.name.indexOf("__");if(u>0){const m=`MCP: ${c.name.slice(0,u)}`;r.has(m)||r.set(m,[]),r.get(m).push(c),s.add(c.name)}}const o=e.filter(c=>!s.has(c.name));return o.length>0&&r.set("Other",o),[...r.entries()].map(([c,u])=>({category:c,tools:u}))}function AT({tools:e}){const r=_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"]}),r.map(s=>t.jsx(fn,{title:s.category,children:t.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.tools.map(i=>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:i.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:i.description})]})]},i.name))})},s.category)),e.length===0&&t.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:"No tools registered"})]})}function MT({agent:e,onUpdate:r}){const s=e.proficiency??{},[i,o]=j.useState(null),[c,u]=j.useState(null),[f,m]=j.useState(!1),[h,x]=j.useState(null),g=new Set(e.skills),b=e.availableSkills??[],p=b.filter(k=>g.has(k.name)),w=b.filter(k=>!g.has(k.name)),S=async k=>{if(i===k){o(null),u(null);return}o(k),m(!0);try{const H=await fetch(`/api/skills/${encodeURIComponent(k)}`);if(H.ok){const M=await H.json();u(M.skill)}else u(null)}catch{u(null)}m(!1)},T=async k=>{x(k);try{await fetch(`/api/agents/${e.id}/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skill:k})}),r()}catch{}x(null)},E=async k=>{x(k);try{await fetch(`/api/agents/${e.id}/skills/${encodeURIComponent(k)}`,{method:"DELETE"}),r()}catch{}x(null)},C={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"},N=(k,H)=>{const M=s[k.name],Y=M&&M.uses>0?Math.round(M.successes/M.uses*100):null,$=i===k.name,X=h===k.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 ${$?"bg-brand-500/10 border-brand-500/40":"bg-surface-elevated/30 border-border-default/30 hover:border-gray-600/50"}`,onClick:()=>S(k.name),children:[t.jsx("span",{className:`text-sm transition-transform ${$?"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:k.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-medium ${C[k.category]??C.custom}`,children:k.category}),k.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"}),k.builtIn&&!k.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"})]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 truncate",children:k.description}),M&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[M.uses," uses · ",M.successes," successes",M.lastUsed&&` · last ${new Date(M.lastUsed).toLocaleDateString()}`]})]}),Y!==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 ${Y>=80?"bg-green-400":Y>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${Y}%`}})}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[Y,"%"]})]}),!k.alwaysOn&&t.jsx("button",{className:`px-2.5 py-1 rounded text-[10px] font-medium transition-all shrink-0 ${H?"bg-red-500/10 text-red-400 hover:bg-red-500/20":"bg-brand-500/10 text-brand-400 hover:bg-brand-500/20"} ${X?"opacity-50 pointer-events-none":""}`,onClick:P=>{P.stopPropagation(),H?E(k.name):T(k.name)},children:X?"...":H?"Deactivate":"Activate"})]}),$&&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:f?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading skill details…"}):c?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 ${C[c.category]??C.custom}`,children:c.category}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",c.version]}),c.author&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",c.author]}),c.requiredPermissions?.map(P=>t.jsx("span",{className:"px-1.5 py-0.5 bg-amber-500/10 text-amber-600 text-[10px] rounded",children:P},P))]}),c.description&&t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:c.description}),c.tags&&c.tags.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:c.tags.map(P=>t.jsxs("span",{className:"px-1.5 py-0.5 bg-surface-overlay/40 text-fg-tertiary text-[10px] rounded",children:["#",P]},P))}),(c.toolDetails??c.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 (",(c.toolDetails??c.tools??[]).length,")"]}),t.jsx("div",{className:"space-y-1.5",children:(c.toolDetails??c.tools??[]).map(P=>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:P.name}),P.description&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:P.description})]},P.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)"})})]},k.name)};return t.jsxs("div",{className:"space-y-4",children:[t.jsx(fn,{title:`Active Skills (${p.length})`,action:t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Instructions injected into agent context"}),children:p.length===0?t.jsx($i,{text:"No active skills"}):t.jsx("div",{className:"space-y-2",children:p.map(k=>N(k,!0))})}),w.length>0&&t.jsx(fn,{title:`Available Skills (${w.length})`,action:t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Discoverable via discover_tools"}),children:t.jsx("div",{className:"space-y-2",children:w.map(k=>N(k,!1))})})]})}function DT({agentId:e}){const[r,s]=j.useState(null),[i,o]=j.useState(!0),[c,u]=j.useState("entries"),[f,m]=j.useState(!1),[h,x]=j.useState(""),[g,b]=j.useState(!1),[p,w]=j.useState(""),[S,T]=j.useState(!1),[E,C]=j.useState(null),[N,k]=j.useState(null),[H,M]=j.useState([]),[Y,$]=j.useState(!1),X=j.useCallback(()=>{o(!0),ae.agents.getMemory(e).then(D=>{s(D),x(D.recentDailyLogs??""),w(D.longTermMemory??"")}).catch(()=>{}).finally(()=>o(!1))},[e]);j.useEffect(()=>{X()},[X]);const P=async()=>{T(!0),await ae.agents.updateDailyMemory(e,h).catch(()=>{}),T(!1),m(!1),X()},q=async()=>{T(!0),await ae.agents.updateLongTermMemory(e,"User-edited",p).catch(()=>{}),T(!1),b(!1),X()};if(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading memory..."});if(!r)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Failed to load memory data"});const F=[{key:"entries",label:`Recent (${r.entries.length})`},{key:"sessions",label:`Sessions (${r.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:F.map(D=>t.jsx("button",{onClick:()=>u(D.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${c===D.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:D.label},D.key))}),c==="entries"&&t.jsx(fn,{title:"Recent Memory Entries",children:r.entries.length===0?t.jsx($i,{text:"No memory entries"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:r.entries.map((D,_)=>{const I=E===_;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>C(I?null:_),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 ${D.type==="fact"?"bg-blue-500/15 text-blue-600":D.type==="task"?"bg-green-500/15 text-green-600":D.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:D.type}),t.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${I?"":"line-clamp-2"}`,children:D.content}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[D.importance!=null&&t.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${D.importance>=7?"bg-red-500/15 text-red-500":D.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",D.importance]}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date(D.timestamp).toLocaleTimeString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:I?"▲":"▼"})]})]}),I&&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:D.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: ",D.type]}),D.importance!=null&&t.jsxs("span",{children:["Importance: ",D.importance]}),t.jsx("span",{children:new Date(D.timestamp).toLocaleString()})]})]})]},_)})})}),c==="sessions"&&t.jsx(fn,{title:"Chat Sessions",children:r.sessions.length===0?t.jsx($i,{text:"No sessions"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:r.sessions.map(D=>{const _=N===D.id,I=async()=>{if(_){k(null),M([]);return}k(D.id),$(!0);try{const A=await ae.agents.getMemorySession(e,D.id);M(A.messages)}catch{M([])}$(!1)};return t.jsxs("div",{children:[t.jsxs("button",{onClick:I,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:D.id}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[D.messageCount," msgs"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(D.updatedAt).toLocaleDateString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:_?"▲":"▼"})]}),_&&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..."}):H.length===0?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"No messages in this session"}):(()=>{const A=new Map;for(const G of H)G.role==="tool"&&G.toolCallId&&A.set(G.toolCallId,G.content);return t.jsx("div",{className:"divide-y divide-gray-700/30",children:H.filter(G=>G.role!=="tool").map((G,U)=>t.jsxs("div",{className:"px-3 py-2",children:[(G.role==="user"||G.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 ${G.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:G.role}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(er,{content:G.content,className:"text-xs text-fg-secondary"})})]}),G.role==="assistant"&&t.jsxs("div",{className:"space-y-1",children:[G.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(er,{content:G.content,className:"text-xs text-fg-secondary"})})]}),G.toolCalls&&G.toolCalls.length>0&&t.jsx("div",{className:"space-y-0.5",children:G.toolCalls.map(K=>{let B;try{B=JSON.parse(K.arguments)}catch{}const L={tool:K.name,status:"done",args:B,result:A.get(K.id)};return t.jsx(Fi,{entry:{type:"tool",info:L}},K.id)})})]})]},U))})})()})]},D.id)})})}),c==="daily"&&t.jsx(fn,{title:"Daily Logs",action:f?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:P,disabled:S,className:"text-xs text-brand-500",children:S?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>m(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:f?t.jsx("textarea",{value:h,onChange:D=>x(D.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"}):r.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:r.recentDailyLogs}):t.jsx($i,{text:"No daily logs"})}),c==="longterm"&&t.jsx(fn,{title:"Long-term Memory",action:g?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>b(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:q,disabled:S,className:"text-xs text-brand-500",children:S?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>b(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:g?t.jsx("textarea",{value:p,onChange:D=>w(D.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"}):r.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:r.longTermMemory}):t.jsx($i,{text:"No long-term memory stored"})})]})}function OT({agentId:e,initialData:r}){const[s,i]=j.useState(r??null),[o,c]=j.useState(!r),[u,f]=j.useState([]),[m,h]=j.useState(null),[x,g]=j.useState(!1),[b,p]=j.useState(null),w=j.useCallback(()=>{ae.agents.getHeartbeat(e).then(i).catch(()=>{}),ae.agents.getRecentActivities(e).then(C=>{f(C.activities.filter(N=>N.type==="heartbeat"))}).catch(()=>{})},[e]);j.useEffect(()=>{c(!0),w(),c(!1)},[w]),j.useEffect(()=>En.on("agent:update",N=>{N.payload?.agentId===e&&w()}),[e,w]);const S=async()=>{g(!0),p(null);try{const C=await ae.agents.triggerHeartbeat(e);p(C.message),setTimeout(()=>p(null),4e3),setTimeout(w,2e3)}catch(C){p(String(C).replace("Error: ",""))}g(!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 T=C=>C?C<1e3?`${C}ms`:C<6e4?`${(C/1e3).toFixed(1)}s`:`${(C/6e4).toFixed(1)}m`:null,E=C=>{if(!C)return null;const N=Date.now()-new Date(C).getTime();if(N<0){const k=Math.abs(N);return k<6e4?`in ${Math.ceil(k/1e3)}s`:k<36e5?`in ${Math.ceil(k/6e4)}m`:`in ${(k/36e5).toFixed(1)}h`}return N<6e4?`${Math.floor(N/1e3)}s ago`:N<36e5?`${Math.floor(N/6e4)}m ago`:`${(N/36e5).toFixed(1)}h ago`};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(fn,{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:S,disabled:x||!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:x?"Triggering...":"Trigger Now"})]}),children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Fn,{label:"Status",value:s.running?"Running":"Stopped",color:s.running?"green":"gray"}),t.jsx(Fn,{label:"Interval",value:T(s.intervalMs)??"—"}),t.jsx(Fn,{label:"Last Run",value:s.lastHeartbeat?E(s.lastHeartbeat)??"—":"Never"}),t.jsx(Fn,{label:"Next Run",value:s.nextRunAt?E(s.nextRunAt)??"—":s.running?"Pending":"—"})]}),b&&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:b})]}),s.lastSummary&&t.jsx(fn,{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(er,{content:s.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),u.length>0?t.jsx(fn,{title:"Recent Runs",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[u.length," runs this session"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:[...u].reverse().map(C=>{const N=m===C.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>h(N?null:C.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:C.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:[C.logCount," actions"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(C.startedAt).toLocaleString()}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary shrink-0 transition-transform ${N?"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"})})]}),N&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(ku,{agentId:e,activityId:C.id})})]},C.id)})})}):s.lastHeartbeat?null:t.jsx(fn,{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 ~${T(s.intervalMs-s.uptimeMs%s.intervalMs)??"soon"}.`:"Heartbeat scheduler is stopped."}),s.running&&t.jsx("button",{onClick:S,disabled:x,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:x?"Triggering...":"Run First Heartbeat Now"})]})})]})}function aj({taskId:e,isLive:r}){const[s,i]=j.useState([]),[o,c]=j.useState(""),[u,f]=j.useState(!0),m=j.useRef(null),h=j.useRef(null),x=j.useRef(!0);if(j.useEffect(()=>{const b=h.current;if(!b)return;const p=()=>{x.current=b.scrollHeight-b.scrollTop-b.clientHeight<60};return b.addEventListener("scroll",p,{passive:!0}),()=>b.removeEventListener("scroll",p)},[]),j.useEffect(()=>{f(!0),c(""),ae.tasks.getLogs(e).then(b=>{i(b.logs),f(!1)}).catch(()=>f(!1))},[e]),j.useEffect(()=>{if(!r)return;const b=En.on("task:log",w=>{const S=w.payload;if(S.taskId!==e)return;const T={id:S.id,taskId:S.taskId,agentId:S.agentId,seq:S.seq,type:S.logType,content:S.content,metadata:S.metadata,createdAt:S.createdAt};i(E=>T.id&&E.some(C=>C.id===T.id)?E:[...E,T]),T.type==="text"&&c("")}),p=En.on("task:log:delta",w=>{const S=w.payload;S.taskId===e&&c(T=>T+S.text)});return()=>{b(),p()}},[e,r]),j.useEffect(()=>{x.current&&m.current?.scrollIntoView({behavior:"smooth"})},[s,o]),u)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0&&!o)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No execution logs yet."});const g=bo(s.map(Wm).filter(b=>b!=null));return t.jsxs("div",{ref:h,className:"max-h-56 overflow-y-auto px-3 py-2 space-y-0.5",children:[g.map((b,p)=>t.jsx(Fi,{entry:b,showTime:!0},`e-${p}`)),o&&t.jsx(ej,{content:o}),t.jsx("div",{ref:m})]})}function ku({agentId:e,activityId:r}){const[s,i]=j.useState([]),[o,c]=j.useState(!0);if(j.useEffect(()=>{c(!0),ae.agents.getActivityLogs(e,r).then(f=>{i(f.logs),c(!1)}).catch(()=>c(!1))},[e,r]),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 u=bo(s.map(W1).filter(f=>f!=null));return t.jsx("div",{className:"max-h-56 overflow-y-auto px-3 py-2 space-y-0.5",children:u.map((f,m)=>t.jsx(Fi,{entry:f,showTime:!0},`a-${m}`))})}function fn({title:e,action:r,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}),r]}),s]})}function Mn({label:e,mono:r,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 ${r?"font-mono text-[10px]":""}`,children:s})]})}function Fn({label:e,value:r,color:s}){const i=s==="green"?"text-green-600":s==="indigo"?"text-brand-500":s==="red"?"text-red-500":"text-fg-secondary";return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-lg font-semibold ${i}`,children:r}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function $i({text:e}){return t.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:e})}function oy(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${r[s]}`}const RT=[{key:"all",label:"All"},{key:"task",label:"Task"},{key:"chat",label:"Chat"},{key:"heartbeat",label:"Heartbeat"},{key:"a2a",label:"A2A"},{key:"internal",label:"Internal"},{key:"respond_in_session",label:"Session"}],zT={task:"☑",chat:"💬",heartbeat:"♡",a2a:"🔗",internal:"⚙",respond_in_session:"↩"};function LT({agentId:e}){const[r,s]=j.useState([]),[i,o]=j.useState("all"),[c,u]=j.useState(!0),[f,m]=j.useState(null),[h,x]=j.useState(!0),g=j.useCallback(async p=>{u(!0);try{const w=i==="all"?void 0:i,S=await ae.agents.getActivities(e,{type:w,limit:30,before:p});s(p?T=>[...T,...S.activities]:S.activities),x(S.activities.length>=30)}catch{}u(!1)},[e,i]);j.useEffect(()=>{s([]),m(null),g()},[g]);const b=()=>{if(r.length>0){const p=r[r.length-1];g(p.startedAt)}};return t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:RT.map(p=>t.jsx("button",{onClick:()=>o(p.key),className:`px-2.5 py-1 text-xs rounded-md border transition-colors ${i===p.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:p.label},p.key))}),c&&r.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-8",children:"Loading activities..."}),!c&&r.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-8",children:"No activity history found."}),t.jsx("div",{className:"space-y-1.5",children:r.map(p=>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.5 text-left hover:bg-surface-3/50 transition-colors rounded-lg",onClick:()=>m(f===p.id?null:p.id),children:[t.jsx("span",{className:"text-sm mt-0.5",children:f===p.id?"▾":"▸"}),t.jsx("span",{className:"text-sm",children:zT[p.type]??"●"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:p.label}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${p.success?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:p.success?"✓":"✗"})]}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2",children:[t.jsx("span",{children:new Date(p.startedAt).toLocaleString()}),p.endedAt&&t.jsxs("span",{children:["→ ",new Date(p.endedAt).toLocaleTimeString()]}),p.totalTokens>0&&t.jsxs("span",{children:[du(p.totalTokens)," tokens"]}),p.totalTools>0&&t.jsxs("span",{children:[p.totalTools," tools"]})]})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-3 px-1.5 py-0.5 rounded",children:p.type})]}),f===p.id&&t.jsx("div",{className:"border-t border-border-subtle",children:p.type==="task"&&p.taskId?t.jsx(aj,{taskId:p.taskId,isLive:!p.endedAt}):t.jsx(ku,{agentId:e,activityId:p.id})})]},p.id))}),h&&r.length>0&&t.jsx("div",{className:"text-center",children:t.jsx("button",{onClick:b,disabled:c,className:"text-xs text-brand-400 hover:text-brand-300 transition-colors disabled:opacity-50",children:c?"Loading...":"Load Earlier..."})})]})}const IT=[{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-brand-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function $T({teamId:e,onBack:r,inline:s}){const[i,o]=j.useState(null),[c,u]=j.useState("overview"),[f,m]=j.useState(""),[h,x]=j.useState(""),[g,b]=j.useState(!1),[p,w]=j.useState(!1),[S,T]=j.useState(""),[E,C]=j.useState(""),[N,k]=j.useState(!1),[H,M]=j.useState(!1),[Y,$]=j.useState(""),[X,P]=j.useState(""),[q,F]=j.useState(!1),[D,_]=j.useState([]),I=j.useRef(null),A=j.useCallback(async()=>{try{const z=(await ae.teams.list()).teams.find(Q=>Q.id===e);z&&o(z);const V=await ae.teams.status(e);_(V.agents)}catch{}},[e]),G=j.useCallback(async()=>{try{const R=await ae.teams.getFile(e,"ANNOUNCEMENT.md");m(R.content)}catch{m("")}try{const R=await ae.teams.getFile(e,"NORMS.md");x(R.content)}catch{x("")}},[e]);j.useEffect(()=>{u("overview"),A(),G()},[e,A,G]);const U=async(R,z)=>{k(!0);try{await ae.teams.updateFile(e,R,z),R==="ANNOUNCEMENT.md"?(m(z),b(!1)):(x(z),w(!1))}catch{}k(!1)},K=async()=>{Y.trim()&&(await ae.teams.update(e,{name:Y.trim()}),M(!1),A())},B=async()=>{await ae.teams.update(e,{description:X}),F(!1),A()};if(!i)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading team..."});const L=i.members.find(R=>R.agentRole==="manager"),W=D.filter(R=>R.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:i.name}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:[i.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:[W," online"]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:i.description||"No description"})]}),t.jsxs("button",{onClick:async()=>{if(i)try{const{files:R}=await ae.teams.getFilesMap(i.id),z=i.members.filter(Q=>Q.type==="agent"),V={type:"team",name:i.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||i.name,displayName:i.name,version:"1.0.0",description:i.description??"",author:"",category:"general",tags:[],team:{members:z.map(Q=>({name:Q.name,roleName:Q.role,role:Q.agentRole??"worker",count:1,skills:[]}))}};await Bn.publishViaProxy({itemType:"team",name:i.name,description:i.description??"",category:"general",config:V,files:R}),alert(`Published "${i.name}" to Markus Hub`)}catch(R){alert(`Failed to publish: ${R}`)}},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:r,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:IT.map(R=>t.jsxs("button",{onClick:()=>u(R.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${c===R.key?"bg-surface-primary text-fg-primary border border-border-default border-b-gray-950":"text-fg-tertiary hover:text-fg-secondary"}`,children:[R.icon," ",R.label]},R.key))})]}),t.jsxs("div",{className:"p-5",children:[c==="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:L?.name??i.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:i.id})]})]}),f.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:[f.slice(0,500),f.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:i.members.map(R=>{const z=D.find(Q=>Q.id===R.id),V=cy[z?.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 ${V}`}),t.jsx("span",{className:"font-medium",children:R.name}),t.jsx("span",{className:"text-fg-tertiary",children:R.role}),R.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-amber-500/15 text-amber-600 rounded",children:"Manager"})]},R.id)})})]})]}),c==="members"&&t.jsxs("div",{className:"space-y-3",children:[i.members.map(R=>{const z=D.find(Q=>Q.id===R.id),V=cy[z?.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:R.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:R.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${V}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:z?.status??"offline"}),R.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:[R.role," · ",R.type]})]})]},R.id)}),i.members.length===0&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]}),c==="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"}),!g&&t.jsx("button",{onClick:()=>{T(f),b(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),g?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:S,onChange:R=>T(R.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:()=>U("ANNOUNCEMENT.md",S),disabled:N,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:N?"Saving...":"Save"}),t.jsx("button",{onClick:()=>b(!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 announcements yet. Click Edit to add."})})]}),c==="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"}),!p&&t.jsx("button",{onClick:()=>{C(h),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"})]}),p?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:E,onChange:R=>C(R.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:()=>U("NORMS.md",E),disabled:N,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:N?"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: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 norms defined yet. Click Edit to add."})})]}),c==="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"}),H?t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("input",{ref:I,value:Y,onChange:R=>$(R.target.value),onKeyDown:R=>R.key==="Enter"&&K(),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:K,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:()=>M(!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:i.name}),t.jsx("button",{onClick:()=>{$(i.name),M(!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"}),q?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:X,onChange:R=>P(R.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:()=>F(!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:i.description||"No description"}),t.jsx("button",{onClick:()=>{P(i.description??""),F(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(BT,{teamId:e,teamName:i.name,onDeleted:r})]})]})]})}function BT({teamId:e,teamName:r,onDeleted:s}){const[i,o]=j.useState(!1),[c,u]=j.useState(!1),[f,m]=j.useState(!1),[h,x]=j.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"}),i?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',r,'"? 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:f,onChange:g=>m(g.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:c,onChange:g=>u(g.target.checked),className:"rounded"}),"Also delete disk files (workspace, memory, logs)"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:h,onClick:async()=>{x(!0);try{await ae.teams.delete(e,f,{purgeFiles:c}),window.dispatchEvent(new CustomEvent("markus:data-changed")),s()}catch{x(!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:h?"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 ex({side:e,defaultWidth:r,minWidth:s,maxWidth:i,collapsedWidth:o=0,storageKey:c}){const[u,f]=j.useState(()=>{try{const p=localStorage.getItem(`${c}_w`);if(p)return Math.max(s,Math.min(i,parseInt(p,10)))}catch{}return r}),[m,h]=j.useState(()=>{try{return localStorage.getItem(`${c}_c`)==="1"}catch{return!1}}),x=j.useRef(!1);j.useEffect(()=>{try{localStorage.setItem(`${c}_w`,String(u))}catch{}},[u,c]),j.useEffect(()=>{try{localStorage.setItem(`${c}_c`,m?"1":"0")}catch{}},[m,c]);const g=j.useCallback(p=>{p.preventDefault(),x.current=!0;const w=p.clientX,S=u,T=C=>{if(!x.current)return;const N=C.clientX-w;f(Math.max(s,Math.min(i,S+N)))},E=()=>{x.current=!1,document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",E),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",T),document.addEventListener("mouseup",E),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[u,e,s,i]),b=j.useCallback(()=>h(p=>!p),[]);return{width:m?o:u,rawWidth:u,collapsed:m,toggle:b,setCollapsed:h,onResizeStart:g}}function uy(e){const r={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&&(r.segments=e.metadata.segments.map((s,i)=>s.type==="tool"?{type:"tool",key:`${s.tool}_${i}`,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("⚠"))&&(r.isError=!0),e.metadata?.isStopped&&(r.isStopped=!0),e.metadata?.images?.length&&(r.images=e.metadata.images),r}function Jl(e){const r=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:r};if(e.metadata&&e.senderType==="agent"){const i=[],o=e.metadata;if(o.thinking?.length&&i.push({type:"text",content:"",thinking:o.thinking.join(`
|
|
51
|
-
|
|
52
|
-
`)}),o.toolCalls?.length)for(let c=0;c<o.toolCalls.length;c++){const u=o.toolCalls[c];i.push({type:"tool",key:`${u.tool}_${c}`,tool:u.tool,status:u.status==="error"?"error":"done",args:u.arguments,result:u.result,durationMs:u.durationMs})}i.length>0&&(i.push({type:"text",content:e.text}),s.segments=i)}return s}function ij(e){return e.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2)}function HT({name:e,agentId:r,agents:s,onViewProfile:i}){const[o,c]=j.useState(!1),u=j.useRef(null),f=r?s.find(m=>m.id===r):s.find(m=>m.name===e);return j.useEffect(()=>{if(!o)return;const m=h=>{u.current&&!u.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),f?t.jsxs("span",{ref:u,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>c(!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:ij(f.name)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:f.name}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[f.role," · ",f.agentRole??"worker"]})]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${f.status==="working"?"bg-blue-400 animate-pulse":f.status==="error"?"bg-red-400":"bg-green-400"}`})]}),t.jsx("button",{onClick:()=>{c(!1),i?.(f.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 PT({agent:e,anchorRect:r,onClose:s,onViewProfile:i}){const o=j.useRef(null);j.useEffect(()=>{const f=m=>{o.current&&!o.current.contains(m.target)&&s()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[s]);const c=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",u=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:r.top+40,left:r.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:ij(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 ${c}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:u}),e.agentRole&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),t.jsx("button",{onClick:()=>{s(),i(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 dy(e){const r=String(e);if(r.includes("AbortError")||r.includes("abort"))return"";let s="";const i=r.match(/\{[\s\S]*\}/);if(i)try{const o=JSON.parse(i[0]);s=o.error?.message??o.message??""}catch{}if(!s){const o=r.lastIndexOf(": ");o>=0&&(s=r.slice(o+2).trim())}return r.includes("402")||/insufficient.?balance/i.test(r)?`⚠ AI service error: ${s||"Insufficient credits"}. Please top up the API balance or contact your administrator.`:r.includes("401")||/unauthorized|invalid.?api.?key/i.test(r)?`⚠ AI service authentication failed: ${s||"Invalid API key"}. Please check the configuration.`:r.includes("429")||/rate.?limit/i.test(r)?`⚠ Rate limit exceeded: ${s||"Too many requests"}. Please wait a moment and try again.`:r.includes("503")||/service.?unavailable/i.test(r)?`⚠ AI service unavailable: ${s||"Service temporarily down"}. Please try again later.`:`⚠ AI service error: ${s||r.slice(0,120)}`}function fy({msg:e,onCopy:r,onRetry:s,isCopied:i}){const o=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:()=>r(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:[i?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"})]}),i?"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"]}),o&&!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"]})]})}function UT({msg:e,isStreaming:r,liveActivities:s}){const i=e.segments,o=e.isStopped,[c,u]=j.useState(!1);if(i!==void 0){const m=i[i.length-1],h=r&&i.length>0&&m?.type==="tool"&&m.status!=="running",x=i.length===0,g=i.filter(p=>p.type==="text"&&!!p.thinking).map(p=>p.thinking).join(""),b=g.length>0;return t.jsxs("div",{className:"space-y-0.5 min-h-[1em]",children:[x&&r&&t.jsx(Nu,{}),b&&t.jsxs("div",{className:"mb-2",children:[t.jsxs("button",{onClick:()=>u(p=>!p),className:"flex items-center gap-1 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("span",{className:`transition-transform ${c?"rotate-90":""}▶`,style:{fontSize:8}}),t.jsxs("span",{children:["思考过程 (",g.length," 字符)"]})]}),c&&t.jsx("div",{className:"mt-1 pl-3 border-l-2 border-brand-500/50 text-xs text-fg-secondary whitespace-pre-wrap max-h-60 overflow-y-auto",children:g})]}),i.map((p,w)=>{const S=w===i.length-1;return p.type==="tool"?t.jsx(nj,{info:{tool:p.tool,status:p.status,args:p.args,result:p.result,error:p.error,durationMs:p.durationMs,liveOutput:p.liveOutput},isLast:S&&!h},p.key):t.jsxs("div",{className:p.content?"":"hidden",children:[t.jsx(er,{content:p.content}),r&&S&&t.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-text-bottom"})]},w)}),h&&t.jsxs("div",{className:"flex items-center gap-2 pl-0.5 pt-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center",style:{width:14},children:[t.jsx("div",{className:"w-px flex-1 bg-surface-overlay",style:{minHeight:6}}),t.jsx("div",{className:"w-2 h-2 rounded-full border border-gray-600 bg-surface-elevated shrink-0"})]}),t.jsx(Nu,{label:"Processing"})]}),o&&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:[(r||f)&&t.jsx(nT,{activities:r?s:e.activities??[],isActive:r,persistent:!r&&f}),e.text?t.jsx(er,{content:e.text}):null,o&&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 fm=new Set;function qT(){return window.location.hash}function VT(e){return fm.add(e),()=>{fm.delete(e)}}typeof window<"u"&&window.addEventListener("hashchange",()=>fm.forEach(e=>e()));function hy({initialAgentId:e,authUser:r}={}){const[s,i]=j.useState([]),[o,c]=j.useState([]),u=gs(),f=j.useSyncExternalStore(VT,qT),m=u&&f.startsWith("#chat/"),h=j.useCallback(()=>{window.location.hash="chat/d"},[]);j.useEffect(()=>{if(!u)return;const re=()=>{b.current==="profile"&&g("chat")};return window.addEventListener("popstate",re),()=>window.removeEventListener("popstate",re)},[u]);const[x,g]=j.useState("chat"),b=j.useRef("chat");b.current=x;const p=ex({side:"left",defaultWidth:224,minWidth:160,maxWidth:360,storageKey:"markus_chat_sidebar"}),[w,S]=j.useState(null),T=j.useCallback(()=>{g("profile"),u&&history.pushState({mobileProfile:!0},"",window.location.hash)},[u]),E=j.useCallback(re=>{N("direct"),H(re),T(),S(null)},[T]),[C,N]=j.useState(()=>e?"direct":localStorage.getItem("markus_chat_mode")??"direct"),[k,H]=j.useState(()=>e??localStorage.getItem("markus_chat_agent")??""),[M,Y]=j.useState(()=>localStorage.getItem("markus_chat_channel")??"#general"),[$,X]=j.useState(""),P=j.useRef(new Map),q=j.useRef(new Map),F=j.useRef(new Set),D=j.useRef(""),[_,I]=j.useState([]),[A,G]=j.useState(""),[U,K]=j.useState(!1),[B,L]=j.useState([]),[W,R]=j.useState(!1),[z,V]=j.useState(!1),[Q,te]=j.useState([]),Z=j.useRef(null),ee="__new_chat__",[ie,je]=j.useState([]),[ke,De]=j.useState(null),[Ie,ze]=j.useState(!1),[Ze,Ae]=j.useState([]),We=j.useRef(new Map),xt=j.useRef(new Map),Lt=j.useRef(null),le=j.useRef(null),_e=j.useRef(null),ht=j.useRef(null),[Ct,Ft]=j.useState([]),[be,Me]=j.useState([]),[Ve,Xe]=j.useState([]),[rt,It]=j.useState([]),[Ht,_t]=j.useState(null),[wt,xe]=j.useState(!1),[Be,gt]=j.useState(""),[pt,ue]=j.useState(!1),[Se,Ke]=j.useState(""),At=C==="channel"?Ct.find(re=>re.channelKey===M)?.teamId:void 0,rn=j.useRef(null),vn=j.useRef(null),Mt=j.useRef(null),oe=j.useRef(void 0),Le=j.useRef(!1),$e=j.useRef(!0);j.useEffect(()=>{if(!Ie)return;const re=pe=>{le.current&&!le.current.contains(pe.target)&&Lt.current&&!Lt.current.contains(pe.target)&&ze(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[Ie]);const st=(re,pe)=>{if(!pe||re===pe)return`notes:${re}`;const[Ne,ye]=[re,pe].sort();return`dm:${Ne}:${ye}`},at=(re,pe,Ne,ye)=>re==="channel"?`ch:${Ne}`:re==="direct"?pe||"_direct":re==="dm"?`dm:${ye??""}`:"_smart",Ue=j.useCallback((re,pe)=>{const Ne=pe(P.current.get(re)??[]);P.current.set(re,Ne),D.current===re&&I(Ne)},[]),jn=(re,pe)=>{const Ne=[...q.current.get(re)??[],pe];q.current.set(re,Ne),D.current===re&&L(Ne)};j.useEffect(()=>{localStorage.setItem("markus_chat_mode",C)},[C]),j.useEffect(()=>{localStorage.setItem("markus_chat_agent",k)},[k]),j.useEffect(()=>{localStorage.setItem("markus_chat_channel",M)},[M]);const gn=j.useCallback(()=>ae.agents.list().then(re=>i(re.agents)).catch(()=>{}),[]),Dt=j.useCallback(()=>ae.teams.list().then(re=>Me(re.teams)).catch(()=>{}),[]);j.useEffect(()=>{gn(),ae.users.list().then(Fe=>c(Fe.users)).catch(()=>{}),ae.tasks.list().then(Fe=>It(Fe.tasks)).catch(()=>{}),Dt(),ae.externalAgents.list().then(Fe=>Xe(Fe.agents)).catch(()=>{}),fetch("/api/group-chats").then(Fe=>Fe.json()).then(Fe=>Ft(Fe.chats)).catch(()=>{});const re=setInterval(gn,8e3),pe=setInterval(Dt,15e3),Ne=En.on("agent:update",gn),ye=En.on("*",Dt),dt=En.on("chat:group_created",()=>{fetch("/api/group-chats").then(Fe=>Fe.json()).then(Fe=>Ft(Fe.chats)).catch(()=>{})}),He=()=>{gn(),Dt()};return window.addEventListener("markus:data-changed",He),()=>{clearInterval(re),clearInterval(pe),Ne(),ye(),dt(),window.removeEventListener("markus:data-changed",He)}},[]),j.useEffect(()=>{const re=ye=>{const dt=ye.detail;(dt.page==="chat"||dt.page==="team")&&(dt.params?.agentId&&(N("direct"),H(dt.params.agentId)),dt.params?.selectAgent&&E(dt.params.selectAgent),dt.params?.openHire)},pe=localStorage.getItem("markus_nav_agentId");pe&&(localStorage.removeItem("markus_nav_agentId"),N("direct"),H(pe));const Ne=localStorage.getItem("markus_nav_selectAgent");return Ne&&(localStorage.removeItem("markus_nav_selectAgent"),E(Ne)),window.addEventListener("markus:navigate",re),()=>window.removeEventListener("markus:navigate",re)},[]),j.useEffect(()=>{const re=vn.current;if(!re)return;const pe=()=>{$e.current=re.scrollHeight-re.scrollTop-re.clientHeight<80};return re.addEventListener("scroll",pe,{passive:!0}),()=>re.removeEventListener("scroll",pe)},[]),j.useLayoutEffect(()=>{if(Le.current){Le.current=!1;return}$e.current&&rn.current?.scrollIntoView({behavior:"instant"})},[_,B]);const Dn=j.useCallback(async re=>{const pe=re==="smart:default"?"_smart":`ch:${re}`;try{const Ne=await ae.channels.getMessages(re,50),ye=Ne.messages.map(Jl);P.current.set(pe,ye),D.current===pe&&(I(ye),R(Ne.hasMore),_e.current=Ne.messages[0]?new Date(Ne.messages[0].createdAt).toISOString():null)}catch{D.current===pe&&(I([]),R(!1))}},[]),Un=j.useCallback(async(re,pe)=>{ht.current=re;try{const Ne=await ae.sessions.getMessages(re,50),ye=Ne.messages.map(uy);P.current.set(pe,ye),D.current===pe&&ht.current===re&&(I(ye),R(Ne.hasMore),_e.current=Ne.messages[0]?new Date(Ne.messages[0].createdAt).toISOString():null)}catch{D.current===pe&&ht.current===re&&(I([]),R(!1),_e.current=null)}},[]),On=j.useCallback(async re=>{if(!re)return je([]),[];try{const{sessions:pe}=await ae.sessions.listByAgent(re,10);return je(pe),pe}catch{return je([]),[]}},[]),on=j.useCallback(async()=>{if(!(z||!W||!_e.current)){V(!0);try{const re=D.current;if(C==="channel"||C==="smart"||C==="dm"){const pe=C==="smart"?"smart:default":C==="dm"?st(r?.id??"",$):M,Ne=await ae.channels.getMessages(pe,50,_e.current),ye=Ne.messages.map(Jl);Le.current=!0,I(dt=>{const He=[...ye,...dt];return P.current.set(re,He),He}),R(Ne.hasMore),Ne.messages[0]&&(_e.current=new Date(Ne.messages[0].createdAt).toISOString())}else if(ke){const pe=await ae.sessions.getMessages(ke,50,_e.current),Ne=pe.messages.map(uy);Le.current=!0,I(ye=>{const dt=[...Ne,...ye];return P.current.set(re,dt),dt}),R(pe.hasMore),pe.messages[0]&&(_e.current=new Date(pe.messages[0].createdAt).toISOString())}}catch{}finally{V(!1)}}},[z,W,C,M,ke,r?.id,$]);j.useEffect(()=>{const re=at(C,k,M,$),pe=D.current;D.current=re,pe&&pe!==re&&(We.current.set(pe,Ze),xt.current.set(pe,ke));const Ne=P.current.get(re),ye=q.current.get(re)??[],dt=F.current.has(re);L(ye),K(dt),C==="direct"&&k&&On(k);const He=We.current.get(re),Fe=xt.current.get(re);if(He&&He.length>0&&Ae(He),ze(!1),Ne!==void 0)I(Ne),R(!1),Fe!==void 0&&De(Fe),(!He||He.length===0)&&Ae([]);else if(I([]),R(!1),_e.current=null,C==="channel"||C==="dm"){const bt=C==="dm"?st(r?.id??"",$):M;Dn(bt),(!He||He.length===0)&&Ae([])}else C==="smart"?(Dn("smart:default"),(!He||He.length===0)&&Ae([])):C==="direct"&&k&&On(k).then(bt=>{if(D.current===re)if(bt.length>0){const it=He&&He.length>0?He:bt.slice(0,5),tt=Fe!==void 0?Fe:it[0].id,Xt=tt&&it.some(Zt=>Zt.id===tt)?tt:it[0].id;De(Xt),Ae(it),Un(Xt,re)}else{De(null),(!He||He.length===0)&&Ae([]);const it=(()=>{const tt=(navigator.language||"").toLowerCase();return tt.startsWith("zh")?"介绍一下你自己":tt.startsWith("ja")?"自己紹介をしてください":tt.startsWith("ko")?"자기소개를 해주세요":tt.startsWith("fr")?"Présentez-vous":tt.startsWith("de")?"Stell dich vor":tt.startsWith("es")?"Preséntate":tt.startsWith("pt")?"Apresente-se":tt.startsWith("ru")?"Представьтесь":"Introduce yourself"})();setTimeout(()=>oe.current?.(it),150)}})},[C,k,M,$]),j.useEffect(()=>C!=="channel"?void 0:En.on("chat:message",pe=>{const Ne=pe.payload,ye=Ne.channel??"";if(!ye||ye!==M)return;const dt=Ne.senderType??"agent",He=Ne.text??Ne.message??"",Fe=Ne.senderId??Ne.agentId??"",bt=Ne.senderName??Ne.agentId??"Agent",it=Ne.metadata,tt={id:`ws_${Date.now()}_${Fe}`,sender:dt==="human"?"user":"agent",text:He,time:new Date().toLocaleTimeString(),agentName:dt==="agent"?bt:void 0,agentId:dt==="agent"?Fe:void 0};if(it&&dt==="agent"){const Zt=[];if(it.thinking?.length&&Zt.push({type:"text",content:"",thinking:it.thinking.join(`
|
|
53
|
-
|
|
54
|
-
`)}),it.toolCalls?.length)for(let hn=0;hn<it.toolCalls.length;hn++){const yt=it.toolCalls[hn];Zt.push({type:"tool",key:`${yt.tool}_${hn}`,tool:yt.tool,status:yt.status==="error"?"error":"done",args:yt.arguments,result:yt.result,durationMs:yt.durationMs})}Zt.length>0&&(Zt.push({type:"text",content:He}),tt.segments=Zt)}const Xt=at("channel",k,M,$);Ue(Xt,Zt=>[...Zt,tt])}),[C,M,k,$,Ue]),j.useEffect(()=>En.on("chat:proactive_message",pe=>{const Ne=pe.payload,ye=Ne.agentId??"",dt=Ne.agentName??"Agent",He=Ne.message??"",Fe=Ne.sessionId??"";if(!(!ye||!He)&&C==="direct"&&k===ye){const bt={id:`proactive_${Date.now()}`,sender:"agent",text:He,time:new Date().toLocaleTimeString(),agentName:dt,agentId:ye},it=at("direct",ye,M,$);Ue(it,tt=>[...tt,bt]),Fe&&ke!==Fe&&De(Fe)}}),[C,k,M,$,ke,Ue]),rt.find(re=>re.id===Ht),j.useEffect(()=>{_t(null)},[k]);const cn=re=>(re.match(/@(\w+)/g)??[]).map(pe=>pe.slice(1)),wn=()=>{Mt.current?.abort(),Mt.current=null;const re=D.current;F.current.delete(re),q.current.delete(re),K(!1),L([])},qn=async re=>{const pe=(re??A).trim();if(!pe&&Q.length===0||C==="direct"&&!k)return;if($e.current=!0,U){Mt.current?.abort(),Mt.current=null;const He=D.current;F.current.delete(He),q.current.delete(He),Ue(He,Fe=>{const bt=[...Fe];for(let it=bt.length-1;it>=0;it--)if(bt[it].sender==="agent"&&!bt[it].isStopped&&!bt[it].isError){const tt=bt[it],Xt=(tt.segments??[]).map(Zt=>Zt.type==="tool"&&Zt.status==="running"?{...Zt,status:"stopped"}:Zt);bt[it]={...tt,isStopped:!0,segments:Xt};break}return bt}),K(!1),L([]),await new Promise(Fe=>setTimeout(Fe,50))}const Ne=Q.length>0?Q.map(He=>He.dataUrl):void 0,ye=at(C,k,M,$);re||G(""),te([]),ue(!1);const dt=C==="dm";if(F.current.add(ye),q.current.set(ye,[]),D.current===ye&&!dt&&(K(!0),L([])),C==="dm"){const He=st(r?.id??"",$),Fe=`opt_${Date.now()}`;Ue(ye,bt=>[...bt,{id:Fe,sender:"user",text:pe,time:new Date().toLocaleTimeString()}]);try{const bt=await ae.channels.sendMessage(He,{text:pe,senderName:r?.name??"You",senderId:r?.id,mentions:[],orgId:"default",humanOnly:!0});Ue(ye,it=>{const tt=it.filter(Zt=>Zt.id!==Fe),Xt=[];return bt.userMessage&&Xt.push(Jl(bt.userMessage)),Xt.length>0?[...tt,...Xt]:it})}catch(bt){Ue(ye,it=>[...it,{id:`err_${Date.now()}`,sender:"agent",text:`Error: ${String(bt)}`,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}F.current.delete(ye),D.current===ye&&K(!1)}else if(C==="channel"){const He=`opt_${Date.now()}`;Ue(ye,Fe=>[...Fe,{id:He,sender:"user",text:pe,time:new Date().toLocaleTimeString()}]);try{const Fe=cn(pe),bt=Fe.length>0?s.find(tt=>tt.name.toLowerCase()===Fe[0].toLowerCase()):null,it=await ae.channels.sendMessage(M,{text:pe,senderName:r?.name??"You",mentions:Fe,senderId:r?.id,targetAgentId:bt?.id,orgId:"default"});Ue(ye,tt=>{const Xt=tt.filter(hn=>hn.id!==He),Zt=[];return it.userMessage&&Zt.push(Jl(it.userMessage)),it.agentMessage&&Zt.push(Jl(it.agentMessage)),Zt.length>0?[...Xt,...Zt]:tt})}catch(Fe){const bt=dy(Fe)||`Error: ${String(Fe)}`;Ue(ye,it=>[...it,{id:`err_${Date.now()}`,sender:"agent",text:bt,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}F.current.delete(ye),D.current===ye&&K(!1)}else{const He=`a_${Date.now()}`,Fe={id:`u_${Date.now()}`,sender:"user",text:pe,time:new Date().toLocaleTimeString()};Ne?.length&&(Fe.images=Ne),Ue(ye,yt=>[...yt,Fe,{id:He,sender:"agent",text:"",time:new Date().toLocaleTimeString(),segments:[]}]);const bt=yt=>{Ue(ye,Tt=>{const ut=[...Tt],qe=ut.findIndex(Bo=>Bo.id===He);if(qe<0)return Tt;const Ge=ut[qe].segments??[],ot=Ge[Ge.length-1];let ct,sn=yt;const nr=yt.match(/<think>([\s\S]*?)<\/think>/);nr&&(ct=(ot?.type==="text"?ot.thinking??"":"")+nr[1],sn=yt.replace(/<think>[\s\S]*?<\/think>/,""));const Ca=ot?.type==="text"?[...Ge.slice(0,-1),{type:"text",content:ot.content+sn,thinking:ct??ot.thinking}]:[...Ge,{type:"text",content:sn,thinking:ct}];return ut[qe]={...ut[qe],text:ut[qe].text+sn,segments:Ca},ut})},it=yt=>{yt.phase!=="output"&&jn(ye,{...yt,ts:Date.now()}),yt.phase==="start"?Ue(ye,Tt=>{const ut=[...Tt],qe=ut.findIndex(ct=>ct.id===He);if(qe<0)return Tt;const Ge=[...ut[qe].segments??[]];let ot=!1;if(yt.arguments)for(let ct=Ge.length-1;ct>=0;ct--){const sn=Ge[ct];if(sn.type==="tool"&&sn.tool===yt.tool&&sn.status==="running"){Ge[ct]={...sn,args:yt.arguments},ot=!0;break}}if(!ot){const ct=`${yt.tool}_${Date.now()}`;Ge.push({type:"tool",key:ct,tool:yt.tool,status:"running",args:yt.arguments})}return ut[qe]={...ut[qe],segments:Ge},ut}):yt.phase==="output"?Ue(ye,Tt=>{const ut=[...Tt],qe=ut.findIndex(ot=>ot.id===He);if(qe<0)return Tt;const Ge=[...ut[qe].segments??[]];for(let ot=Ge.length-1;ot>=0;ot--){const ct=Ge[ot];if(ct.type==="tool"&&ct.tool===yt.tool&&ct.status==="running"){Ge[ot]={...ct,liveOutput:(ct.liveOutput??"")+(yt.output??"")};break}}return ut[qe]={...ut[qe],segments:Ge},ut}):Ue(ye,Tt=>{const ut=[...Tt],qe=ut.findIndex(ot=>ot.id===He);if(qe<0)return Tt;const Ge=[...ut[qe].segments??[]];for(let ot=Ge.length-1;ot>=0;ot--){const ct=Ge[ot];if(ct.type==="tool"&&ct.tool===yt.tool&&ct.status==="running"){Ge[ot]={...ct,status:yt.success===!1?"error":"done",args:yt.arguments,result:yt.result,error:yt.error,durationMs:yt.durationMs,liveOutput:void 0};break}}return ut[qe]={...ut[qe],segments:Ge},ut})},tt=new AbortController;Mt.current=tt;try{if(C==="smart"){const yt=await ae.message.sendStream(pe,bt,{senderId:r?.id||void 0,signal:tt.signal,images:Ne},it),Tt=s.find(ut=>ut.id===yt.agentId);Tt&&Ue(ye,ut=>{const qe=[...ut],Ge=qe.findIndex(ot=>ot.id===He);return Ge>=0&&(qe[Ge]={...qe[Ge],agentName:Tt.name}),qe})}else{const yt=ke===ee?null:ke,Tt=await ae.agents.messageStream(k,pe,bt,it,tt.signal,Ne,yt);D.current===ye&&(Tt.sessionId&&(De(Tt.sessionId),Ae(ut=>ut.map(qe=>qe.id===ee?{...qe,id:Tt.sessionId}:qe))),On(k).then(ut=>{if(D.current===ye&&(je(ut),Tt.sessionId)){const qe=ut.find(Ge=>Ge.id===Tt.sessionId);qe&&Ae(Ge=>Ge.some(ct=>ct.id===qe.id)?Ge.map(ct=>ct.id===qe.id?qe:ct):[qe,...Ge.filter(ct=>ct.id!==ee)])}}))}}catch(yt){const Tt=yt?.sessionId;Tt&&C==="direct"&&D.current===ye&&(De(Tt),Ae(qe=>qe.map(Ge=>Ge.id===ee?{...Ge,id:Tt}:Ge)),On(k).then(qe=>{if(D.current!==ye)return;je(qe);const Ge=qe.find(ot=>ot.id===Tt);Ge&&Ae(ot=>ot.some(sn=>sn.id===Ge.id)?ot.map(sn=>sn.id===Ge.id?Ge:sn):[Ge,...ot])}));const ut=dy(yt);ut?Ue(ye,qe=>{const Ge=[...qe],ot=Ge.findIndex(ct=>ct.id===He);if(ot>=0){const ct=Ge[ot].segments??[];Ge[ot]={...Ge[ot],text:ut,isError:!0,segments:[...ct,{type:"text",content:ut}]}}return Ge}):Ue(ye,qe=>{const Ge=[...qe],ot=Ge.findIndex(ct=>ct.id===He);if(ot>=0){const ct=Ge[ot];if(!(ct.text||ct.segments&&ct.segments.length>0&&ct.segments.some(nr=>nr.type==="text"&&nr.content||nr.type==="tool")))return qe.filter(nr=>nr.id!==He);Ge[ot]={...ct,isStopped:!0}}return Ge})}Ue(ye,yt=>{const Tt=[...yt],ut=Tt.findIndex(qe=>qe.id===He);if(ut>=0){const qe=(Tt[ut].segments??[]).map(Ge=>Ge.type==="tool"&&Ge.status==="running"?{...Ge,status:"stopped"}:Ge);Tt[ut]={...Tt[ut],segments:qe}}return Tt}),tt.signal.aborted&&Ue(ye,yt=>{const Tt=[...yt],ut=Tt.findIndex(qe=>qe.id===He);if(ut>=0){const qe=Tt[ut];if(!(qe.text||qe.segments&&qe.segments.length>0&&qe.segments.some(ot=>ot.type==="text"&&ot.content||ot.type==="tool")))return yt.filter(ot=>ot.id!==He);Tt[ut]={...qe,isStopped:!0}}return Tt});const Zt=(P.current.get(ye)??[]).find(yt=>yt.id===He),hn=ke&&ke!==ee?ke:null;Zt&&!Zt.text&&C==="direct"&&hn&&!tt.signal.aborted&&(async(Tt,ut)=>{for(let qe=0;qe<Tt;qe++){await new Promise(Ge=>setTimeout(Ge,ut));try{const ot=(await ae.sessions.getMessages(hn,2)).messages.find(ct=>ct.role==="assistant");if(ot?.content){Ue(ye,ct=>{const sn=[...ct],nr=sn.findIndex(Ca=>Ca.id===He);return nr>=0&&(sn[nr]={...sn[nr],text:ot.content,segments:[{type:"text",content:ot.content}]}),sn});return}}catch{}}})(5,3e3)}Mt.current=null,F.current.delete(ye),q.current.delete(ye),D.current===ye&&(K(!1),L([]))};oe.current=qn;const[ve,Qe]=j.useState(null),Nt=j.useCallback(re=>{const pe=re.segments?re.segments.filter(Ne=>Ne.type==="text").map(Ne=>Ne.content).join(`
|
|
55
|
-
`):re.text;navigator.clipboard.writeText(pe),Qe(re.id),setTimeout(()=>Qe(Ne=>Ne===re.id?null:Ne),2e3)},[]),Et=j.useCallback(re=>{const pe=D.current,Ne=P.current.get(pe)??_,ye=Ne.findIndex(Fe=>Fe.id===re.id);if(ye<0)return;const dt=ye>0&&Ne[ye-1]?.sender==="user"?Ne[ye-1]:null,He=dt?.text??"";He&&(Ue(pe,Fe=>Fe.filter(bt=>bt.id!==re.id&&(dt?bt.id!==dt.id:!0))),qn(He))},[_,Ue]),Nn=async re=>{De(re.id),ze(!1),R(!1),_e.current=null;const pe=D.current;P.current.delete(pe),I([]),Ae(Ne=>Ne.some(ye=>ye.id===re.id)?Ne:[...Ne,re]),await Un(re.id,pe)},ar=re=>{if(Ae(pe=>pe.filter(Ne=>Ne.id!==re)),ke===re){const pe=Ze.filter(Ne=>Ne.id!==re);pe.length>0?Nn(pe[pe.length-1]):ir()}},ir=()=>{De(ee);const re=D.current;P.current.delete(re),I([]),R(!1),_e.current=null,ze(!1),Ae(pe=>{const Ne=pe.filter(ye=>ye.id!==ee);return[{id:ee,agentId:k??"",userId:null,title:"New Chat",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...Ne]})},Or=re=>{if(G(re),C!=="channel"){ue(!1);return}const pe=re.lastIndexOf("@");if(pe>=0&&(pe===0||re[pe-1]===" ")){const Ne=re.slice(pe+1);if(!Ne.includes(" ")){ue(!0),Ke(Ne.toLowerCase());return}}ue(!1)},Rr=re=>{const pe=A.lastIndexOf("@");G(A.slice(0,pe)+"@"+re+" "),ue(!1)},vr=4*1024*1024,un=5,zr=j.useCallback(re=>{const pe=Array.from(re).filter(Ne=>Ne.type.startsWith("image/"));if(pe.length!==0)for(const Ne of pe){if(Ne.size>vr)continue;const ye=new FileReader;ye.onload=()=>{const dt=ye.result;te(He=>He.length>=un||He.some(Fe=>Fe.dataUrl===dt)?He:[...He,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:dt,name:Ne.name}])},ye.readAsDataURL(Ne)}},[]),Ps=j.useCallback(re=>{te(pe=>pe.filter(Ne=>Ne.id!==re))},[]),lr=j.useCallback(re=>{const pe=re.clipboardData?.files;if(pe&&pe.length>0){const Ne=Array.from(pe).filter(ye=>ye.type.startsWith("image/"));Ne.length>0&&(re.preventDefault(),zr(Ne))}},[zr]),or=j.useCallback(re=>{re.preventDefault();const pe=re.dataTransfer?.files;pe&&pe.length>0&&zr(Array.from(pe).filter(Ne=>Ne.type.startsWith("image/")))},[zr]),Us=j.useCallback(re=>{re.preventDefault()},[]),Tn=s.find(re=>re.id===k),Gr=r?.name??"You",Sa=_[_.length-1],cr=U&&Sa?.sender==="agent",Lr=s.filter(re=>re.name.toLowerCase().includes(Se)),Yn=o.find(re=>re.id===$),kn=$===r?.id||!$,jr=Ct.find(re=>re.channelKey===M),ne=C==="channel"?jr?.name??M:C==="direct"?Tn?.name??"Select Agent":C==="dm"?kn?"My Notes":Yn?.name??"Direct Message":"Chat",Oe=C==="channel"?jr?`Message ${jr.name}…`:`Message ${M}… (use @name to mention)`:C==="dm"?kn?"Write a note to yourself…":`Message ${Yn?.name??""}…`:k?"Type a message…":"Select an agent to start chatting",Pe=u&&!m,et=u&&m;return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[(!u||Pe)&&t.jsx(wT,{authUser:r,agents:s,teams:be,humans:o,tasks:rt,externalAgents:Ve,groupChats:Ct,chatMode:C,selectedAgent:k,activeChannel:M,activeDmUserId:$,onSelectAgent:re=>{N("direct"),H(re),g("chat"),u&&h()},onSelectChannel:re=>{N("channel"),Y(re),g("chat"),u&&h()},onSelectDm:re=>{N("dm"),X(re),g("chat"),u&&h()},onRefreshTeams:Dt,onRefreshAgents:gn,onViewProfile:E,width:u?void 0:p.width,onResizeStart:u?void 0:p.onResizeStart}),(!u||et)&&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:[u?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="chat"},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:ne}),C==="direct"&&Tn&&t.jsx(my,{agent:Tn,tasks:rt,onViewProfile:E})]}),t.jsxs("div",{className:"flex items-center px-3 h-9 gap-1 border-t border-border-default/40",children:[t.jsx("button",{onClick:()=>{x==="profile"?history.back():g("chat")},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${x==="chat"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>{x!=="profile"&&T()},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${x==="profile"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:C==="channel"?"Team":"Profile"}),t.jsx("div",{className:"flex-1"}),C==="direct"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:ir,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:Lt,onClick:()=>ze(!Ie),className:`p-1 rounded-md transition-colors shrink-0 ${Ie?"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:ne}),C==="direct"&&Tn&&t.jsx(my,{agent:Tn,tasks:rt,onViewProfile:E}),(C==="channel"||C==="dm")&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[_.length," messages"]}),C==="dm"&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-1",children:kn?"· Private notepad":`· Direct message with ${Yn?.name??""}`}),(C==="direct"&&k||C==="channel"&&At)&&t.jsxs("div",{className:"flex items-center gap-0.5 ml-4 -mb-px",children:[t.jsx("button",{onClick:()=>g("chat"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${x==="chat"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>g("profile"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${x==="profile"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:C==="channel"?"Team":"Profile"})]}),C==="direct"&&Tn&&t.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[t.jsx("button",{onClick:ir,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:Lt,onClick:()=>ze(!Ie),className:`p-1.5 rounded-md transition-colors ${Ie?"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"})})})]})]}),C==="direct"&&k&&x==="chat"&&Ze.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:Ze.map(re=>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] ${re.id===ke?"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(re.id===ee){De(ee);const pe=D.current;P.current.delete(pe),I([])}else Nn(re)},children:[t.jsx("span",{className:"truncate",children:re.id===ee?"New Chat":re.title||"Conversation"}),t.jsx("button",{onClick:pe=>{pe.stopPropagation(),ar(re.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},re.id))}),C==="direct"&&k&&Ie&&t.jsxs("div",{ref:le,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:()=>ze(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[ie.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No conversations yet"}),(()=>{const re=new Date,pe=new Date(re.getFullYear(),re.getMonth(),re.getDate()).getTime(),Ne=pe-864e5,ye=pe-7*864e5,dt=[],He=[],Fe=[],bt=[],it=[];for(const tt of ie){const Xt=new Date(tt.lastMessageAt).getTime();Xt>=pe?He.push(tt):Xt>=Ne?Fe.push(tt):Xt>=ye?bt.push(tt):it.push(tt)}return He.length>0&&dt.push({label:"Today",items:He}),Fe.length>0&&dt.push({label:"Yesterday",items:Fe}),bt.length>0&&dt.push({label:"Previous 7 days",items:bt}),it.length>0&&dt.push({label:"Older",items:it}),dt.map(tt=>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:tt.label}),tt.items.map(Xt=>t.jsxs("button",{onClick:()=>{Nn(Xt)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${Xt.id===ke?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:"truncate font-medium",children:Xt.title||"Conversation"}),t.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(Xt.lastMessageAt).toLocaleString()})]},Xt.id))]},tt.label))})()]})]})]}),x==="profile"&&C==="direct"&&k&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(ST,{agentId:k,onBack:()=>g("chat"),inline:!0})}),x==="profile"&&C==="channel"&&At&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx($T,{teamId:At,onBack:()=>g("chat"),inline:!0})}),t.jsxs("div",{ref:vn,className:`flex-1 overflow-y-auto p-5 space-y-3 ${x!=="chat"?"hidden":""}`,children:[W&&t.jsx("div",{className:"flex justify-center py-2",children:t.jsx("button",{onClick:()=>{on()},disabled:z,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:z?"Loading…":"↑ Load earlier messages"})}),_.length===0&&!U&&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:C==="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"})})}),C==="channel"&&t.jsxs("div",{children:["No messages in ",jr?.name??M," yet."]}),C==="direct"&&!k&&t.jsx("div",{children:"Select an agent from the sidebar to start."}),C==="direct"&&k&&t.jsxs("div",{children:["Start a new conversation with ",Tn?.name,"."]})]}),C==="channel"?_.map(re=>t.jsxs("div",{className:"group/msg flex gap-3",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 cursor-pointer ${re.sender==="user"?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-600 hover:ring-1 hover:ring-brand-500/40"}`,onClick:pe=>{if(re.sender==="agent"&&re.agentId){const Ne=pe.currentTarget.getBoundingClientRect();S({agentId:re.agentId,top:Ne.top,left:Ne.right+8})}},children:re.sender==="user"?Gr?.[0]??"Y":re.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:re.sender==="user"?Gr??"You":re.agentName??"Agent"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:re.time})]}),t.jsx("div",{className:re.isError||re.sender==="agent"&&re.text.startsWith("⚠")?"mt-0.5 px-3 py-2 rounded-lg border-b-2 border-red-500/60":"mt-0.5",children:re.sender==="agent"?t.jsx(er,{content:re.text,className:"text-sm text-fg-secondary"}):t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[re.images&&re.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:re.images.map((pe,Ne)=>t.jsx("img",{src:pe,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(pe,"_blank")},Ne))}),re.text]})}),t.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity",children:t.jsx(fy,{msg:re,onCopy:Nt,onRetry:Et,isCopied:ve===re.id})})]})]},re.id)):_.map((re,pe)=>{const ye=cr&&pe===_.length-1&&U,dt=!ye||re.isStopped;return t.jsx("div",{className:`group/msg flex ${re.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:"max-w-[75%]",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:[re.sender==="user"?Gr??"You":t.jsx(HT,{name:re.agentName??(C==="direct"?Tn?.name??"Agent":"Agent"),agentId:re.agentId??(C==="direct"?Tn?.id:void 0),agents:s,onViewProfile:E})," · ",re.time]}),t.jsx("div",{className:`px-4 py-3 rounded-2xl text-sm ${re.sender==="user"?"bg-brand-600 text-white rounded-br-sm":re.isError||re.sender==="agent"&&re.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:re.sender==="user"?t.jsxs(t.Fragment,{children:[re.images&&re.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:re.images.map((He,Fe)=>t.jsx("img",{src:He,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(He,"_blank")},Fe))}),re.text&&t.jsx("span",{className:"whitespace-pre-wrap leading-relaxed",children:re.text})]}):t.jsx(UT,{msg:re,isStreaming:ye,liveActivities:ye?B:[]})}),dt&&t.jsx("div",{className:`transition-opacity ${re.isStopped?"opacity-100":"opacity-0 group-hover/msg:opacity-100"} ${re.sender==="user"?"flex justify-end":""}`,children:t.jsx(fy,{msg:re,onCopy:Nt,onRetry:Et,isCopied:ve===re.id})})]})},re.id)}),C==="channel"&&U&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse ml-11",children:"Agent is thinking…"}),t.jsx("div",{ref:rn})]}),w&&(()=>{const re=s.find(pe=>pe.id===w.agentId);return re?t.jsx(PT,{agent:re,anchorRect:{top:w.top,left:w.left},onClose:()=>S(null),onViewProfile:E}):null})(),t.jsxs("div",{className:`p-4 border-t border-border-default bg-surface-secondary relative shrink-0 ${x!=="chat"?"hidden":""}`,onDrop:or,onDragOver:Us,children:[pt&&Lr.length>0&&t.jsx("div",{className:"absolute bottom-full left-4 mb-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden z-10",children:Lr.map(re=>t.jsxs("button",{onClick:()=>Rr(re.name),className:"w-full text-left px-4 py-2 text-sm text-fg-secondary hover:bg-surface-overlay flex items-center gap-2",children:[t.jsx("span",{className:"text-brand-500",children:"@"}),re.name,t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:re.role})]},re.id))}),Q.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[Q.map(re=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:re.dataUrl,alt:re.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>Ps(re.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:"×"})]},re.id)),Q.length<un&&t.jsx("button",{onClick:()=>Z.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:Z,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:re=>{re.target.files&&zr(re.target.files),re.target.value=""}}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("button",{onClick:()=>Z.current?.click(),disabled:C==="direct"&&!k,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",{value:A,onChange:re=>{Or(re.target.value),re.target.style.height="auto",re.target.style.height=`${Math.min(re.target.scrollHeight,120)}px`},onKeyDown:re=>{re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),qn())},onPaste:lr,placeholder:Oe,disabled:C==="direct"&&!k,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-y-auto leading-5",style:{maxHeight:"120px"}}),U&&C!=="dm"&&t.jsx("button",{onClick:wn,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:()=>{qn()},disabled:C==="direct"&&!k||!A.trim()&&Q.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:r,onViewProfile:s}){const[i,o]=j.useState(!1),[c,u]=j.useState(!1),f=j.useRef(null),m=e.status==="working",h=e.status==="error",x=m?r.find(S=>S.assignedAgentId===e.id&&S.status==="in_progress"):null,g=e.currentActivity;j.useEffect(()=>{if(!i)return;const S=T=>{f.current&&!f.current.contains(T.target)&&o(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[i]);const b=h?"bg-red-400 animate-pulse":m?"bg-blue-400 animate-pulse":"bg-green-400",p=h?"error":m?"working":"idle",w=g?g.type==="heartbeat"?`Heartbeat: ${g.heartbeatName??g.label}`:g.type==="chat"?g.label:g.type==="task"?`Task: ${g.label}`:g.label:"Processing...";return t.jsxs("div",{className:"relative",ref:f,children:[t.jsxs("button",{onClick:()=>o(S=>!S),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${m?"bg-amber-500/10 border border-amber-500/20 hover:bg-amber-500/20":h?"bg-red-500/10 border border-red-500/20 hover:bg-red-500/20":"bg-green-500/10 border border-green-500/20 hover:bg-green-500/20"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${b}`}),t.jsx("span",{className:`text-xs ${h?"text-red-500":m?"text-amber-600":"text-green-600"}`,children:p})]}),i&&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 →"})]}),i&&m&&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"}),x?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),Ut.navigate("tasks",{openTask:x.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:x.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 ${g?.type==="heartbeat"||g?.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:w}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:g?.type==="heartbeat"?"Periodic check-in task":g?.type==="chat"?"Responding to conversation":"Agent is thinking or communicating"})]})]}),t.jsx("button",{onClick:()=>{o(!1),u(!0)},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 Execution Log →"})]}),c&&t.jsx(FT,{agent:e,currentTask:x,onClose:()=>u(!1),onGoToTask:x?()=>{u(!1),Ut.navigate("tasks",{openTask:x.id})}:void 0})]})}function FT({agent:e,currentTask:r,onClose:s,onGoToTask:i}){const o=e.currentActivity,[c,u]=j.useState([]),[f,m]=j.useState([]),[h,x]=j.useState(!0),g=j.useRef(null),b=j.useRef(null),p=j.useRef(!0);j.useEffect(()=>{const T=b.current;if(!T)return;const E=()=>{p.current=T.scrollHeight-T.scrollTop-T.clientHeight<80};return T.addEventListener("scroll",E,{passive:!0}),()=>T.removeEventListener("scroll",E)},[]),j.useEffect(()=>{x(!0),r?ae.tasks.getLogs(r.id).then(T=>{u(T.logs),x(!1)}).catch(()=>x(!1)):o?ae.agents.getActivityLogs(e.id,o.id).then(T=>{m(T.logs),x(!1)}).catch(()=>x(!1)):x(!1)},[e.id,o,r]),j.useEffect(()=>r?En.on("task:log",E=>{const C=E.payload;if(C.taskId!==r.id)return;const N={id:C.id,taskId:C.taskId,agentId:C.agentId,seq:C.seq,type:C.logType,content:C.content,metadata:C.metadata,createdAt:C.createdAt};u(k=>N.id&&k.some(H=>H.id===N.id)?k:[...k,N])}):void 0,[r]),j.useEffect(()=>!o||r?void 0:En.on("agent:activity_log",E=>{const C=E.payload;if(C.agentId!==e.id||C.activityId!==o.id)return;const N={seq:C.seq,type:C.type,content:C.content,metadata:C.metadata,createdAt:C.createdAt};m(k=>k.some(H=>H.seq===N.seq)?k:[...k,N])}),[e.id,o,r]),j.useEffect(()=>{p.current&&g.current?.scrollIntoView({behavior:"smooth"})},[c,f]);const w=o?.type==="heartbeat"?"Heartbeat Task":o?.type==="chat"?"Chat Response":o?.type==="task"?"Task Execution":"Processing",S=o?.type==="heartbeat"||o?.type==="chat"?"text-blue-600":"text-brand-500";return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[780px] max-w-[95vw] max-h-[75vh] flex flex-col shadow-2xl",onClick:T=>T.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-border-default",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${o?.type==="heartbeat"||o?.type==="chat","bg-blue-400 animate-pulse"}`}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:e.name}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full border ${S} border-current/20 bg-current/5`,children:w})]}),t.jsx("div",{className:"text-xs text-fg-secondary truncate mt-0.5",children:o?.label??r?.title??"Processing..."}),o?.startedAt&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:["Started ",new Date(o.startedAt).toLocaleTimeString()]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i&&t.jsx("button",{onClick:i,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:"Go to Task →"}),t.jsx("button",{onClick:s,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none px-1",children:"×"})]})]}),t.jsxs("div",{ref:b,className:"flex-1 overflow-y-auto p-4 space-y-1.5",children:[h?t.jsx("div",{className:"text-center py-8 text-xs text-fg-tertiary",children:"Loading logs…"}):r&&c.length>0?t.jsx(t.Fragment,{children:bo(c.slice(-60).map(Wm).filter(T=>T!=null)).map((T,E)=>t.jsx(Fi,{entry:T,showTime:!0},`t-${E}`))}):f.length>0?t.jsx(t.Fragment,{children:bo(f.map(W1).filter(T=>T!=null)).map((T,E)=>t.jsx(Fi,{entry:T,showTime:!0},`a-${E}`))}):e.status==="working"?t.jsxs("div",{className:"text-center py-8 space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Agent just started processing..."}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Execution logs will appear here as the agent makes progress."})]}):t.jsx("div",{className:"text-center py-8 text-xs text-fg-tertiary",children:"No execution logs available."}),e.status==="working"&&t.jsx(Nu,{label:"Working"}),t.jsx("div",{ref:g})]})]})})}function lj({theme:e,onThemeChange:r}={}){const[s,i]=j.useState(null),[o,c]=j.useState(null),[u,f]=j.useState(""),[m,h]=j.useState(!1),[x,g]=j.useState(null),[b,p]=j.useState(null),[w,S]=j.useState(null),[T,E]=j.useState(null),[C,N]=j.useState(!1),[k,H]=j.useState(null),[M,Y]=j.useState(null),[$,X]=j.useState(!1),[P,q]=j.useState(null),[F,D]=j.useState({}),[_,I]=j.useState(!1),[A,G]=j.useState([]),[U,K]=j.useState([]),[B,L]=j.useState(null),[W,R]=j.useState(null),[z,V]=j.useState(""),[Q,te]=j.useState(null),Z=j.useRef(null),ee=j.useRef(!1),[ie,je]=j.useState(!1),[ke,De]=j.useState(null),[Ie,ze]=j.useState(!1),[Ze,Ae]=j.useState(new Set),[We,xt]=j.useState(null),[Lt,le]=j.useState(!1),_e=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`}),ht=j.useCallback(()=>{ae.health().then(i).catch(()=>{}),fetch("/api/settings/llm").then(ue=>ue.ok?ue.json():Promise.reject(ue.status)).then(ue=>{ue&&typeof ue=="object"&&"providers"in ue&&(c(ue),f(ue.defaultProvider))}).catch(()=>{})},[]),Ct=j.useCallback(()=>{fetch("/api/settings/oauth/providers").then(ue=>ue.ok?ue.json():Promise.reject(ue.status)).then(ue=>G(ue.providers??[])).catch(()=>{})},[]),Ft=j.useCallback(()=>{fetch("/api/settings/oauth/profiles",{headers:_e()}).then(ue=>ue.ok?ue.json():Promise.reject(ue.status)).then(ue=>K(ue.profiles??[])).catch(()=>{})},[]),be=j.useCallback(()=>{ze(!0),ae.system.storage().then(De).catch(()=>{}).finally(()=>ze(!1)),ae.system.orphans().then(xt).catch(()=>{})},[]);j.useEffect(()=>{ht(),Ct(),Ft(),be()},[ht,Ct,Ft,be]),j.useEffect(()=>{const ue=()=>be();return window.addEventListener("markus:data-changed",ue),()=>window.removeEventListener("markus:data-changed",ue)},[be]);const Me=j.useCallback(async()=>{X(!0),q(null),Y(null),D({});try{const ue=await fetch("/api/settings/env-models",{headers:_e()});if(!ue.ok){q({type:"err",text:`Detection failed (HTTP ${ue.status})`});return}const Se=await ue.json();if(Y(Se),Se.detected.length===0)q({type:"err",text:"No model API keys found in environment variables"});else{const Ke={};for(const At of Se.detected)Ke[At.provider]=!0;D(Ke)}}catch{q({type:"err",text:"Failed to detect environment variables"})}finally{X(!1)}},[]),Ve=o?Object.values(o.providers).some(ue=>ue.configured):!1;j.useEffect(()=>{o&&!Ve&&!ee.current&&(ee.current=!0,Me())},[o,Ve,Me]);const Xe=async()=>{if(!(!u||u===o?.defaultProvider)){h(!0),g(null);try{const ue=await fetch("/api/settings/llm",{method:"POST",headers:_e(),body:JSON.stringify({defaultProvider:u})}),Se=await ue.json();ue.ok?(c(Se),g({type:"ok",text:`Default provider updated to ${Se.defaultProvider}`})):g({type:"err",text:Se.error??"Save failed"})}catch{g({type:"err",text:"Network error"})}finally{h(!1)}}},rt=async(ue,Se)=>{S(ue);try{const Ke=await fetch(`/api/settings/llm/providers/${ue}/toggle`,{method:"POST",headers:_e(),body:JSON.stringify({enabled:Se})});if(Ke.ok){const At=await Ke.json();c(At)}}catch{}finally{S(null)}},It=async()=>{N(!0),H(null);try{const Se=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:_e(),body:JSON.stringify({preview:!0})})).json();"error"in Se?H({type:"err",text:Se.error}):E(Se)}catch{H({type:"err",text:"Detection failed"})}finally{N(!1)}},Ht=async()=>{N(!0),H(null);try{const Se=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:_e(),body:JSON.stringify({preview:!1})})).json();"error"in Se?H({type:"err",text:Se.error}):(H({type:"ok",text:`Imported ${Se.appliedModels} model configs from OpenClaw`}),ht())}catch{H({type:"err",text:"Import failed"})}finally{N(!1)}},_t=async()=>{if(!M)return;const ue=M.detected.filter(Se=>F[Se.provider]);if(ue.length===0){q({type:"err",text:"Select at least one provider to apply"});return}I(!0),q(null);try{const Se=await fetch("/api/settings/env-models",{method:"POST",headers:_e(),body:JSON.stringify({providers:ue.map(At=>({provider:At.provider,model:At.model,baseUrl:At.baseUrl,enabled:!0}))})});if(!Se.ok){q({type:"err",text:`Apply failed (HTTP ${Se.status})`});return}const Ke=await Se.json();q({type:"ok",text:Ke.message}),Y(null),D({}),ht()}catch{q({type:"err",text:"Failed to apply environment configs"})}finally{I(!1)}},wt=async ue=>{L(ue),R(null);try{const Se=await fetch("/api/settings/oauth/login",{method:"POST",headers:_e(),body:JSON.stringify({provider:ue})}),Ke=await Se.json();if(!Se.ok||Ke.error){R({type:"err",text:Ke.error??"Login failed"});return}Ke.authorizeUrl&&(window.open(Ke.authorizeUrl,"_blank","noopener"),te(ue),R({type:"ok",text:"Browser opened for authorization. Complete the login in the browser window..."}),Z.current&&clearInterval(Z.current),Z.current=setInterval(async()=>{try{const rn=await(await fetch(`/api/settings/oauth/status?provider=${ue}`,{headers:_e()})).json();!rn.pending&&rn.profiles.some(vn=>vn.provider===ue&&vn.hasOAuth)&&(Z.current&&clearInterval(Z.current),Z.current=null,te(null),K(rn.profiles),R({type:"ok",text:`Connected to ${ue} via OAuth`}),ht())}catch{}},2e3))}catch{R({type:"err",text:"Network error during OAuth login"})}finally{L(null)}},xe=async()=>{if(z.trim()){L("manual"),R(null);try{const ue=await fetch("/api/settings/oauth/callback",{method:"POST",headers:_e(),body:JSON.stringify({callbackUrl:z})}),Se=await ue.json();if(!ue.ok||Se.error){R({type:"err",text:Se.error??"Callback failed"});return}R({type:"ok",text:`Connected to ${Se.profile?.provider??"provider"} via OAuth`}),V(""),te(null),Z.current&&(clearInterval(Z.current),Z.current=null),Ft(),ht()}catch{R({type:"err",text:"Network error"})}finally{L(null)}}},Be=async ue=>{try{(await fetch(`/api/settings/oauth/profiles/${encodeURIComponent(ue)}`,{method:"DELETE",headers:_e()})).ok&&(Ft(),ht(),R({type:"ok",text:"Auth profile deleted"}))}catch{}};j.useEffect(()=>()=>{Z.current&&clearInterval(Z.current)},[]);const gt=o?.providers?Object.entries(o.providers).filter(([,ue])=>ue.configured&&ue.enabled).map(([ue])=>ue):[],pt=o&&!Ve&&!ie;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(ma,{title:"Appearance",children:t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Theme"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Choose light, dark, or follow your system preference"})]}),t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[["system","System"],["light","Light"],["dark","Dark"]].map(([ue,Se])=>t.jsx("button",{onClick:()=>r?.(ue),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${e===ue?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:Se},ue))})]})})}),pt&&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:()=>je(!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:!!(M&&M.detected.length>0),children:[$&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Detecting..."}),M&&M.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[M.detected.map(ue=>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:F[ue.provider]??!1,onChange:Se=>D({...F,[ue.provider]:Se.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:ue.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:ue.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:ue.apiKeyPreview})]},ue.provider)),t.jsx("button",{onClick:()=>{_t()},disabled:_||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:_?"Applying...":`Apply ${Object.values(F).filter(Boolean).length} Provider(s)`})]}),M&&M.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."]}),P&&t.jsx(Ri,{type:P.type,text:P.text})]}),t.jsxs(_h,{step:"2",title:"From OpenClaw Config",description:"Import model configs from an existing OpenClaw installation.",children:[T?T.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:T.summary.configPath})]}),T.summary.models&&t.jsxs("div",{className:"text-xs text-fg-secondary",children:[T.summary.models.providerCount," providers, ",T.summary.models.providers.reduce((ue,Se)=>ue+Se.modelCount,0)," models"]}),t.jsx("button",{onClick:()=>{Ht()},disabled:C,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:C?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{It()},disabled:C,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:C?"Detecting...":"Detect OpenClaw"}),k&&t.jsx(Ri,{type:k.type,text:k.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(ma,{title:"System Status",children:s?t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Ah,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx(Ah,{label:"Version",value:s.version,color:"indigo"}),t.jsx(Ah,{label:"Active Agents",value:String(s.agents),color:"purple"})]}):t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Loading..."})}),t.jsx(ma,{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:u,onChange:ue=>{f(ue.target.value),g(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:gt.length>0?gt.map(ue=>t.jsx("option",{value:ue,children:o.providers[ue]?.displayName??ue},ue)):t.jsx("option",{value:"",children:"No providers configured"})}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading..."}),u!==o?.defaultProvider&&t.jsx("button",{onClick:()=>{Xe()},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"})]})]}),x&&t.jsx(Ri,{type:x.type,text:x.text})]})}),A.length>0&&t.jsx(ma,{title:"OAuth Authentication",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Connect to LLM providers using your existing subscription via OAuth. No API key required."}),t.jsx("div",{className:"space-y-3",children:A.map(ue=>{const Se=U.find(At=>At.provider===ue.name&&At.hasOAuth),Ke=Q===ue.name;return t.jsxs("div",{className:"flex items-center justify-between bg-surface-elevated/30 rounded-lg px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${Se?"bg-green-400":"bg-gray-600"}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:ue.displayName}),Se&&t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[Se.accountId&&t.jsxs("span",{children:["Account: ",Se.accountId]}),Se.oauthExpired&&t.jsx("span",{className:"text-amber-500 ml-2",children:"Token expired"}),!Se.oauthExpired&&t.jsx("span",{className:"text-green-600 ml-2",children:"Connected"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Se&&t.jsx("button",{onClick:()=>{Be(Se.id)},className:"px-2 py-1 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded transition-colors",title:"Disconnect",children:"Disconnect"}),t.jsx("button",{onClick:()=>{wt(ue.name)},disabled:B===ue.name||Ke,className:`px-4 py-1.5 text-xs rounded-lg transition-colors ${Se?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-white"} disabled:opacity-40`,children:B===ue.name?"Starting...":Ke?"Waiting...":Se?"Reconnect":"Connect"})]})]},ue.name)})}),Q&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"If the browser didn't open or you're on a remote machine, paste the redirect URL here:"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:z,onChange:ue=>V(ue.target.value),placeholder:"http://localhost:1455/auth/callback?code=...&state=...",className:"flex-1 px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("button",{onClick:()=>{xe()},disabled:!z.trim()||B==="manual",className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-xs rounded-lg transition-colors",children:B==="manual"?"Processing...":"Submit"})]})]}),U.length>0&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-2",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Auth Profiles"}),U.map(ue=>t.jsxs("div",{className:"flex items-center justify-between text-xs px-3 py-2 bg-surface-elevated/20 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ue.hasOAuth&&!ue.oauthExpired?"bg-green-400":ue.oauthExpired?"bg-amber-400":"bg-gray-500"}`}),t.jsx("span",{className:"text-fg-secondary",children:ue.label??ue.id}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-overlay text-fg-tertiary",children:ue.authType})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[ue.accountId&&t.jsx("span",{className:"text-fg-tertiary",children:ue.accountId}),t.jsx("span",{className:"text-fg-tertiary",children:new Date(ue.updatedAt).toLocaleDateString()}),t.jsx("button",{onClick:()=>{Be(ue.id)},className:"text-red-400 hover:text-red-300 transition-colors",title:"Delete",children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},ue.id))]}),W&&t.jsx(Ri,{type:W.type,text:W.text})]})}),t.jsxs(ma,{title:"Model Providers & Pricing",children:[t.jsx("div",{className:"space-y-3",children:o&&Object.entries(o.providers).map(([ue,Se])=>t.jsxs("div",{className:`bg-surface-secondary border rounded-xl overflow-hidden transition-colors ${Se.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:()=>p(b===ue?null:ue),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${Se.configured&&Se.enabled?"bg-green-400":Se.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:Se.displayName??ue}),ue===o.defaultProvider&&t.jsx("span",{className:"text-[10px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"default"}),Se.configured&&!Se.enabled&&t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded",children:"disabled"}),Se.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:Se.model||"Not configured"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[Se.configured&&t.jsx("button",{onClick:Ke=>{Ke.stopPropagation(),rt(ue,!Se.enabled)},disabled:w===ue,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${Se.enabled?"bg-green-500":"bg-gray-600"} ${w===ue?"opacity-50":""}`,title:Se.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 ${Se.enabled?"translate-x-4":"translate-x-1"}`})}),Se.contextWindow&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[(Se.contextWindow/1e3).toFixed(0),"K ctx"]}),Se.cost&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["$",Se.cost.input,"/",Se.cost.output," per 1M"]}),t.jsx("span",{className:"text-fg-tertiary text-xs",children:b===ue?"▲":"▼"})]})]}),b===ue&&t.jsxs("div",{className:"px-5 pb-4 border-t border-border-default pt-4 space-y-4",children:[Se.configured&&t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(xa,{label:"Model",value:Se.model}),t.jsx(xa,{label:"Context Window",value:Se.contextWindow?`${(Se.contextWindow/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(xa,{label:"Max Output",value:Se.maxOutputTokens?`${(Se.maxOutputTokens/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(xa,{label:"Base URL",value:Se.baseUrl??"Default"})]}),Se.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(xa,{label:"Input",value:`$${Se.cost.input}`}),t.jsx(xa,{label:"Output",value:`$${Se.cost.output}`}),Se.cost.cacheRead!=null&&t.jsx(xa,{label:"Cache Read",value:`$${Se.cost.cacheRead}`}),Se.cost.cacheWrite!=null&&t.jsx(xa,{label:"Cache Write",value:`$${Se.cost.cacheWrite}`})]})]}),Se.models&&Se.models.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider mb-2",children:"Available Models"}),t.jsx("div",{className:"space-y-1.5",children:Se.models.map(Ke=>t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-surface-elevated/30 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-secondary",children:Ke.name}),Ke.reasoning&&t.jsx("span",{className:"text-[9px] bg-amber-500/15 text-amber-600 px-1 py-0.5 rounded",children:"reasoning"}),Ke.inputTypes?.includes("image")&&t.jsx("span",{className:"text-[9px] bg-blue-500/15 text-blue-600 px-1 py-0.5 rounded",children:"vision"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-fg-tertiary",children:[t.jsxs("span",{children:[(Ke.contextWindow/1e3).toFixed(0),"K ctx"]}),t.jsxs("span",{children:["$",Ke.cost.input,"/$",Ke.cost.output]})]})]},Ke.id))})]}),!Se.configured&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Configure the API key in ",t.jsx("code",{className:"text-fg-secondary",children:"~/.markus/markus.json"})," or environment variables to enable this provider."]})]})]},ue))}),t.jsxs("div",{className:"text-xs text-fg-tertiary px-1 mt-3",children:["Configure API keys in ",t.jsx("code",{className:"text-fg-tertiary",children:"~/.markus/markus.json"})," or environment variables"]})]}),t.jsx("div",{className:"border-t border-border-default"}),t.jsx(ma,{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:()=>{Me()},disabled:$,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 ${$?"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"})}),$?"Detecting...":"Refresh Environment Variables"]}),M&&M.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:"}),M.detected.map(ue=>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:F[ue.provider]??!1,onChange:Se=>D({...F,[ue.provider]:Se.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:ue.displayName}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["Key: ",t.jsx("code",{className:"text-fg-secondary",children:ue.apiKeyPreview})," / ","Model: ",t.jsx("code",{className:"text-fg-secondary",children:ue.model}),ue.baseUrl&&t.jsxs(t.Fragment,{children:[" / ","URL: ",t.jsx("code",{className:"text-fg-secondary",children:ue.baseUrl})]})]})]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:Object.keys(ue.envVars).map(Se=>t.jsx("div",{children:t.jsx("code",{children:Se})},Se))})]},ue.provider)),M.timeoutMs&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["LLM Timeout: ",t.jsxs("code",{className:"text-fg-secondary",children:[M.timeoutMs,"ms"]})," (from ",t.jsx("code",{children:"LLM_TIMEOUT_MS"}),")"]}),t.jsx("button",{onClick:()=>{_t()},disabled:_||Object.values(F).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:_?"Applying...":`Apply ${Object.values(F).filter(Boolean).length} Provider(s) to Config`})]}),P&&t.jsx(Ri,{type:P.type,text:P.text})]})}),t.jsx(ma,{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:()=>{It()},disabled:C,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:C?"Detecting...":"Detect OpenClaw Config"})}),T&&T.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:T.summary.configPath})]}),T.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:[T.summary.models.providerCount," model providers found:"]}),t.jsx("div",{className:"space-y-1",children:T.summary.models.providers.map(ue=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:ue.name}),t.jsxs("span",{className:"text-fg-tertiary",children:[ue.modelCount," models ",ue.baseUrl?`(${ue.baseUrl})`:""]})]},ue.name))})]}),T.summary.channels&&T.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: ",T.summary.channels.join(", ")]})}),t.jsx("button",{onClick:()=>{Ht()},disabled:C,className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:C?"Importing...":"Import Model Configs"})]}),k&&t.jsx(Ri,{type:k.type,text:k.text})]})}),t.jsx(ma,{title:"Data & Storage",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[Ie&&!ke&&t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Scanning storage..."}),ke&&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:ds(ke.totalSize)}),t.jsx("div",{className:"text-xs text-fg-tertiary font-mono mt-0.5",children:ke.dataDir})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>be(),disabled:Ie,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:Ie?"Scanning...":"Refresh"}),t.jsx("button",{onClick:()=>{ae.system.openPath(ke.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:ke.breakdown.filter(ue=>ue.size>0).map(ue=>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:ue.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:ue.description})]}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:ds(ue.size)})]},ue.name))})]}),ke.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 (",ke.agents.length,")"]}),t.jsx("div",{className:"space-y-1",children:ke.agents.map(ue=>{const Se=Ze.has(ue.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:()=>Ae(Ke=>{const At=new Set(Ke);return At.has(ue.id)?At.delete(ue.id):At.add(ue.id),At}),children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Se?"▼":"▶"}),t.jsx("button",{onClick:Ke=>{Ke.stopPropagation(),Ut.navigate("chat",{agentId:ue.id})},className:"text-sm text-brand-500 hover:text-brand-400 truncate",children:ue.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:ue.id})]}),t.jsx("span",{className:"text-xs font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:ds(ue.size)})]}),Se&&t.jsxs("div",{className:"px-3 pb-2 pt-0.5 space-y-0.5",children:[ue.subItems.filter(Ke=>Ke.size>0).map(Ke=>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:Ke.name}),t.jsx("span",{className:"text-fg-secondary tabular-nums",children:ds(Ke.size)})]},Ke.name)),t.jsx("div",{className:"pl-5 pt-1",children:t.jsx("button",{onClick:()=>{ae.system.openPath(ke.dataDir+"/agents/"+ue.id)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary underline",children:"Open folder"})})]})]},ue.id)})})]}),We&&(We.orphanAgents.length>0||We.orphanTeams.length>0)&&t.jsx(YT,{orphanInfo:We,dataDir:ke.dataDir,onPurged:be})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function _h({step:e,title:r,description:s,active:i,children:o}){return t.jsxs("div",{className:`rounded-xl border p-4 space-y-3 transition-colors ${i?"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:r}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s})]})]}),o&&t.jsx("div",{className:"pl-9",children:o})]})}function Ri({type:e,text:r}){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:r})}function ma({title:e,children:r}){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:r})]})}function Ah({label:e,value:r,color:s}){const i=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 ${i}`,children:[t.jsx("div",{className:"text-2xl font-bold",children:r}),t.jsx("div",{className:"text-xs mt-1 opacity-70",children:e})]})}function xa({label:e,value:r}){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:r})]})}function ds(e){if(e===0)return"0 B";const r=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${r[s]}`}function YT({orphanInfo:e,dataDir:r,onPurged:s}){const i=[...e.orphanAgents.map(S=>({...S,kind:"agent"})),...e.orphanTeams.map(S=>({...S,kind:"team"}))],[o,c]=j.useState(new Set),[u,f]=j.useState(!1),[m,h]=j.useState(null),x=S=>c(T=>{const E=new Set(T);return E.has(S)?E.delete(S):E.add(S),E}),g=o.size===i.length&&i.length>0,b=()=>c(g?new Set:new Set(i.map(S=>S.id))),p=i.filter(S=>o.has(S.id)).reduce((S,T)=>S+T.size,0),w=async S=>{f(!0),h(null);try{const T=await ae.system.purgeOrphans(S),E=T.purgedAgents.length+T.purgedTeams.length;h(`Cleaned ${E} dir${E!==1?"s":""}, freed ${ds(T.freedBytes)}${T.failures.length?` (${T.failures.length} failed)`:""}`),c(new Set),s()}catch{h("Cleanup failed")}finally{f(!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: ",ds(e.totalOrphanSize)," across ",i.length," director",i.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:g,onChange:b,className:"rounded"}),"Select all"]}),o.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[o.size," selected (",ds(p),")"]})]}),t.jsx("div",{className:"space-y-0.5 mb-3 max-h-52 overflow-y-auto",children:i.map(S=>t.jsxs("div",{className:`flex items-center gap-2 text-xs py-1.5 px-2 rounded transition-colors ${o.has(S.id)?"bg-amber-500/10":"bg-surface-elevated/30 hover:bg-surface-elevated/50"}`,children:[t.jsx("input",{type:"checkbox",checked:o.has(S.id),onChange:()=>x(S.id),className:"rounded shrink-0"}),S.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:S.id}),t.jsx("span",{className:"text-fg-secondary tabular-nums shrink-0",children:ds(S.size)}),t.jsx("button",{onClick:()=>{ae.system.openPath(S.path)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary shrink-0 underline",children:"Open"})]},S.id))}),t.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[o.size>0&&t.jsx("button",{disabled:u,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:u?"Cleaning...":`Clean Selected (${ds(p)})`}),t.jsx("button",{disabled:u,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:u?"Cleaning...":`Clean All (${ds(e.totalOrphanSize)})`})]}),m&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-2",children:m})]})}const Su=new Map;function Va(e,r){Su.has(e)||Su.set(e,r().catch(()=>{}))}function Ga(e){const r=Su.get(e);return Su.delete(e),r}const pr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function oj(e,r){const s=e.split(".").map(Number),i=r.split(".").map(Number);for(let o=0;o<Math.max(s.length,i.length);o++){const c=s[o]??0,u=i[o]??0;if(c>u)return!0;if(c<u)return!1}return!1}const Mh={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"},GT=[{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 XT({item:e,installedSkills:r,onMsg:s,onRefresh:i}){const[o,c]=j.useState(!1),u=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",f=r.find(g=>g.name===e.name||g.name===u),m=!!f,h=m&&e.version&&f?.version&&oj(e.version,f.version),x=async()=>{if(!o){c(!0);try{const g=await Bn.download(e.id),b=g.name||e.name,p=b.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",w={type:"hub",hubItemId:e.id};if(g.files&&Object.keys(g.files).length>0)await ae.builder.artifacts.import("skill",p,g.files,w);else{const S={...g.config,name:b,description:e.description,source:w};await ae.builder.artifacts.save("skill",S)}await ae.builder.artifacts.install("skill",p),s(h?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{s("Install failed","error")}finally{c(!1)}}};return h?t.jsx("button",{onClick:()=>{x()},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",f?.version?` (v${f.version})`:""]}):t.jsx("button",{onClick:()=>{x()},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 cj(){const e=gs(),[r,s]=j.useState("installed"),[i,o]=j.useState(null),[c,u]=j.useState(new Set),[f,m]=j.useState([]),[h,x]=j.useState(!0),[g,b]=j.useState(""),[p,w]=j.useState([]),[S,T]=j.useState(0),[E,C]=j.useState(1),[N,k]=j.useState([]),[H,M]=j.useState(""),[Y,$]=j.useState("score"),[X,P]=j.useState(""),[q,F]=j.useState(!1),[D,_]=j.useState([]),[I,A]=j.useState(!1),[G,U]=j.useState([]),[K,B]=j.useState(""),[L,W]=j.useState(!1),[R,z]=j.useState([]),[V,Q]=j.useState(!1),[te,Z]=j.useState(""),ee=(le,_e="success")=>{o({text:le,type:_e}),setTimeout(()=>o(null),_e==="error"?1e4:4e3)},ie=j.useCallback(async()=>{x(!0);try{const le=await ae.skills.list();m(le.skills)}catch{}x(!1)},[]),je=j.useCallback(async()=>{A(!0);try{const le=await ae.skills.builtin();_(le.skills)}catch{}A(!1)},[]),ke=j.useCallback(async le=>{F(!0);try{const _e=await ae.skills.registrySkillhub({q:le?.q,category:le?.category,page:le?.page??1,limit:24,sort:le?.sort??Y});w(_e.skills),T(_e.total),_e.categories?.length&&k(_e.categories)}catch{}F(!1)},[Y]),De=j.useCallback(async le=>{W(!0);try{const _e=await ae.skills.registrySkillssh(le);U(_e.skills)}catch{}W(!1)},[]),Ie=j.useCallback(async le=>{Q(!0);try{const ht=await(le?Bn.search({type:"skill",q:le,limit:50}):Ga(pr.hubSkills)??Bn.search({type:"skill",limit:50}));z(ht?.items??[])}catch{}Q(!1)},[]);j.useEffect(()=>{ie(),je(),ke(),De()},[]),j.useEffect(()=>{r==="markus-hub"&&Ie(te)},[r,te,Ie]);const ze=async le=>{u(_e=>new Set(_e).add(le.name));try{const _e=await ae.skills.install({name:le.name,source:"skillhub",slug:le.slug,sourceUrl:le.homepage,description:le.description_zh??le.description,category:"custom",version:le.version});await ie(),ee(`"${le.name}" installed (${_e.method}) → ${_e.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ee(`Download failed for "${le.name}". You can try manually from: ${le.homepage}`,"error")}u(_e=>{const ht=new Set(_e);return ht.delete(le.name),ht})},Ze=async le=>{u(_e=>new Set(_e).add(le.name));try{const _e=await ae.skills.install({name:le.name,source:"skillssh",sourceUrl:le.url,githubRepo:`${le.author}/${le.repo}`,githubSkillPath:le.name});await ie(),ee(`"${le.name}" installed (${_e.method}) → ${_e.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ee(`Download failed for "${le.name}". You can try manually from: ${le.url}`,"error")}u(_e=>{const ht=new Set(_e);return ht.delete(le.name),ht})},Ae=async le=>{u(_e=>new Set(_e).add(le.name));try{const _e=await ae.skills.install({name:le.name,source:"builtin"});await ie(),await je(),ee(`"${le.name}" installed (${_e.method}) → ${_e.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(_e){ee(`Install failed for "${le.name}": ${_e}`,"error")}u(_e=>{const ht=new Set(_e);return ht.delete(le.name),ht})},We=async le=>{if(confirm(`Uninstall "${le}"? This will delete the skill files from ~/.markus/skills/.`))try{await ae.skills.uninstall(le),await ie(),ee(`"${le}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(_e){ee(`Uninstall failed: ${_e}`,"error")}},xt=f.filter(le=>{if(!g)return!0;const _e=g.toLowerCase();return le.name.toLowerCase().includes(_e)||le.description?.toLowerCase().includes(_e)}),Lt=G.filter(le=>{if(!K)return!0;const _e=K.toLowerCase();return le.name.toLowerCase().includes(_e)||le.repo.toLowerCase().includes(_e)});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:GT.map(le=>t.jsx("button",{onClick:()=>s(le.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${r===le.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:le.label},le.id))})]}),i&&t.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${i.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:i.text}),r==="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:g,onChange:le=>b(le.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:[xt.length," skill",xt.length!==1?"s":""]})]}),h?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:"Loading..."}):xt.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:xt.map(le=>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:le.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] shrink-0 ${le.type==="builtin"?"bg-blue-500/15 text-blue-600":le.type==="filesystem"?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:le.type==="builtin"?"built-in":le.type==="filesystem"?"local":"imported"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[le.author?`by ${le.author} · `:"",le.version?`v${le.version}`:"",le.sourcePath&&t.jsxs("span",{className:"ml-1 text-fg-tertiary",title:le.sourcePath,children:["📁 ",le.sourcePath.replace(/^.*\/\.([^/]+)\/skills\//,"~/.$1/skills/")]})]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Mh[le.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:le.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:le.tags?.slice(0,3).map(_e=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:_e},_e))}),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:[le.tools&&le.tools.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[le.tools.length," tool",le.tools.length!==1?"s":""]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Auto-discovered by agents"})]}),le.type!=="builtin"&&t.jsx("button",{onClick:()=>{We(le.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"})]})]},le.name))})]}),r==="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:[D.length," built-in skill",D.length!==1?"s":""," available"]}),t.jsx("button",{onClick:()=>{je()},className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"Refresh"})]}),I?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading built-in skills..."})}):D.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:D.map(le=>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:le.name}),le.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:[le.author?`by ${le.author} · `:"","v",le.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Mh[le.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:le.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:le.tags.slice(0,4).map(_e=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:_e},_e))}),le.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:le.requiredPermissions.map(_e=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:_e},_e))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[le.installed&&le.installedVersion?t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",le.installedVersion]}):t.jsx("span",{}),le.installed&&le.installedVersion&&oj(le.version,le.installedVersion)?t.jsx("button",{onClick:()=>{Ae(le)},disabled:c.has(le.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:c.has(le.name)?"Upgrading...":`Upgrade → v${le.version}`}):le.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:()=>{Ae(le)},disabled:c.has(le.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:c.has(le.name)?"Installing...":"Install"})]})]},le.name))})]}),r==="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:H,onChange:le=>{M(le.target.value),C(1),ke({q:X||void 0,category:le.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:"全部分类"}),N.map(le=>t.jsx("option",{value:le,children:le},le))]}),t.jsxs("select",{value:Y,onChange:le=>{$(le.target.value),C(1),ke({q:X||void 0,category:H||void 0,page:1,sort:le.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:X,onChange:le=>P(le.target.value),onKeyDown:le=>{le.key==="Enter"&&(C(1),ke({q:X||void 0,category:H||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:()=>{C(1),ke({q:X||void 0,category:H||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"})]}),q?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"正在加载 SkillHub 技能..."})}):p.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:["共 ",S.toLocaleString()," 个技能"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:p.map(le=>{const _e=f.some(ht=>ht.name===le.name||ht.name===le.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:le.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["v",le.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ml-2 ${le.tags?.[0]?Mh[le.tags[0]]??"bg-brand-500/15 text-brand-500":"bg-brand-500/15 text-brand-500"}`,children:le.tags?.[0]??"SkillHub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description_zh??le.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:[le.stars>0&&t.jsxs("span",{className:"text-[10px] text-amber-600",children:["★ ",le.stars.toLocaleString()]}),le.downloads>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[le.downloads>=1e4?`${(le.downloads/1e4).toFixed(1)}万`:le.downloads.toLocaleString()," 下载"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:le.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),_e?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(le)},disabled:c.has(le.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:c.has(le.name)?"...":"Install"})]})]})]},le.slug)})}),S>24&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[t.jsx("button",{disabled:E<=1,onClick:()=>{const le=E-1;C(le),ke({q:X||void 0,category:H||void 0,page:le})},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:["第 ",E," / ",Math.ceil(S/24)," 页"]}),t.jsx("button",{disabled:E>=Math.ceil(S/24),onClick:()=>{const le=E+1;C(le),ke({q:X||void 0,category:H||void 0,page:le})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"下一页 →"})]})]})]}),r==="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:K,onChange:le=>B(le.target.value),onKeyDown:le=>{le.key==="Enter"&&K.trim()&&De(K)},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:()=>{K.trim()&&De(K)},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 →"})})]}),L?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Searching skills.sh..."})}):Lt.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:Lt.map(le=>{const _e=f.some(ht=>ht.name===le.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:le.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[le.author," / ",le.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:le.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:le.installs&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[le.installs," installs"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:le.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),_e?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(le)},disabled:c.has(le.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:c.has(le.name)?"...":"Install"})]})]})]},`${le.author}-${le.name}`)})})]}),r==="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:te,onChange:le=>Z(le.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"})]}),V?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading from Hub..."})}):R.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:R.map(le=>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:le.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",le.author?.displayName??le.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:le.description}),t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["★".repeat(Math.round(parseFloat(le.avgRating))),"☆".repeat(5-Math.round(parseFloat(le.avgRating))),t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",le.ratingCount,") · ↓ ",le.downloadCount]})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-end gap-2",children:t.jsx(XT,{item:le,installedSkills:f,onMsg:ee,onRefresh:()=>{ie()}})})]},le.id))})]})]})}function uj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function ZT(e,r){const s=e.split(".").map(Number),i=r.split(".").map(Number);for(let o=0;o<Math.max(s.length,i.length);o++){const c=s[o]??0,u=i[o]??0;if(c>u)return!0;if(c<u)return!1}return!1}const tx={development:"{ }",devops:"⚙",management:"◎",productivity:"⚡",general:"◆"},nx={development:"bg-blue-500/15 text-blue-600 border-blue-500/20",devops:"bg-amber-500/15 text-amber-600 border-amber-500/20",management:"bg-brand-500/15 text-brand-500 border-brand-500/20",productivity:"bg-green-500/15 text-green-600 border-green-500/20",general:"bg-gray-500/15 text-fg-secondary border-gray-500/20"},dj={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function fj({authUser:e}={}){const[r,s]=j.useState("all"),[i,o]=j.useState(""),[c,u]=j.useState([]),[f,m]=j.useState([]),[h,x]=j.useState(null),[g,b]=j.useState(!1),[p,w]=j.useState(!0),[S,T]=j.useState(new Map),E=j.useCallback(async()=>{try{const[k,H]=await Promise.all([ae.builder.artifacts.list().catch(()=>({artifacts:[]})),ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),M=new Map;for(const Y of k.artifacts){if(Y.type!=="agent")continue;const $=!!H.installed[`agent/${Y.name}`];M.set(Y.name,{installed:$,localVersion:Y.meta.version||void 0,localUpdatedAt:Y.updatedAt})}T(M)}catch{}},[]),C=j.useCallback(async()=>{w(!0);try{if(r==="hub"){const k=i?Bn.search({type:"agent",q:i,limit:50}):Ga(pr.hubAgents)??Bn.search({type:"agent",limit:50}),[H]=await Promise.all([k.catch(()=>({items:[],total:0})),E()]);m(H?.items??[]),u([])}else{m([]);const k=new URLSearchParams;i&&k.set("q",i);const H=await fetch("/api/templates?"+k.toString()).then(M=>M.json()).catch(()=>({templates:[]}));u(Array.isArray(H.templates)?H.templates:[])}}catch{u([]),m([])}finally{w(!1)}},[r,i,E]);j.useEffect(()=>{C()},[C]);const N=async(k,H,M)=>{try{const Y=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:k,name:H,orgId:"default",teamId:M})});if(!Y.ok)throw new Error(`Failed: ${Y.status}`);b(!1),x(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(k=>t.jsx("button",{onClick:()=>{s(k.id),x(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${r===k.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:k.label},k.id))}),r==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[c.length," agent",c.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search agents...",value:i,onChange:k=>o(k.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 agents..."}):r==="hub"?f.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:f.map(k=>t.jsx(QT,{item:k,localInfo:S.get(uj(k.name)),onStatusChange:E},k.id))}):c.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:i?`No agents match "${i}"`:"No agents found"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:i?"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:c.map(k=>t.jsx(KT,{template:k,isSelected:h?.id===k.id,onSelect:()=>x(h?.id===k.id?null:k)},k.id))})}),h&&r==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-72 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-lg ${nx[h.category]??"bg-surface-overlay text-fg-secondary"}`,children:tx[h.category]??"?"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children:h.name}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:h.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>b(!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:()=>x(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:[h.skills.map(k=>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:k},k)),h.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:h.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 ${dj[h.agentRole]??""}`,children:h.agentRole})]})]})]}),h.starterTasks&&h.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:h.starterTasks.map((k,H)=>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 ${k.priority==="high"?"bg-red-400":k.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),k.title]},H))})]})]})]})}),g&&h&&t.jsx(JT,{template:h,onClose:()=>b(!1),onHire:N})]})}function QT({item:e,localInfo:r,onStatusChange:s}){const[i,o]=j.useState(!1),[c,u]=j.useState(""),f=r?.installed??!1,m=f&&e.version&&r?.localVersion&&ZT(e.version,r.localVersion),h=async x=>{if(x.stopPropagation(),!i){o(!0),u("");try{const g=await Bn.download(e.id),b=g.name||e.name,p=uj(b),w=g.itemType==="team"?"team":g.itemType==="skill"?"skill":"agent",S={type:"hub",hubItemId:e.id};if(g.files&&Object.keys(g.files).length>0)await ae.builder.artifacts.import(w,p,g.files,S);else{const T={...g.config,name:b,description:e.description,source:S};await ae.builder.artifacts.save(w,T)}await ae.builder.artifacts.install(w,p),u(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{u("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-lg",children:"🤖"}),t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[m?t.jsx("button",{onClick:x=>{h(x)},disabled:i,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Upgrading...":`Upgrade → v${e.version}`}):f?t.jsxs("span",{className:"px-3 py-1 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",r?.localVersion?` (v${r.localVersion})`:""]}):t.jsx("button",{onClick:x=>{h(x)},disabled:i,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Installing...":"Install"}),c&&t.jsx("span",{className:`text-[10px] ${c==="Failed"?"text-red-500":"text-green-600"}`,children:c})]})]})}function KT({template:e,isSelected:r,onSelect:s}){return t.jsxs("div",{onClick:s,className:`bg-surface-secondary border rounded-xl p-5 cursor-pointer transition-all hover:shadow-lg hover:shadow-black/20 ${r?"border-brand-500 ring-1 ring-brand-500/30":"border-border-default hover:border-gray-600"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm shrink-0 border ${nx[e.category]??"bg-surface-overlay text-fg-secondary"}`,children:tx[e.category]??"?"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 bg-brand-500/20 text-brand-500",children:["v",e.version]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",e.author]})]})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-3",children:[e.skills.slice(0,4).map(i=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-brand-500/10 text-brand-500/80 rounded-full border border-brand-500/10",children:i},i)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-tertiary",children:["+",e.skills.length-4," more"]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default flex items-center gap-2 text-xs text-fg-tertiary",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-[10px] font-medium capitalize ${dj[e.agentRole]??"bg-surface-overlay text-fg-secondary"}`,children:e.agentRole}),e.tags.length>0&&t.jsx("span",{className:"text-fg-tertiary",children:e.tags.slice(0,2).join(", ")})]})]})}function JT({template:e,onClose:r,onHire:s}){const[i,o]=j.useState(`${e.name} Agent`),[c,u]=j.useState(""),[f,m]=j.useState([]),[h,x]=j.useState(!1);j.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(b=>b.json()).then(b=>m(b.teams??[])).catch(()=>{})},[]);const g=async()=>{if(i.trim()){x(!0);try{await s(e.id,i.trim(),c||void 0)}finally{x(!1)}}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:r,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm ${nx[e.category]??"bg-surface-overlay text-fg-secondary"}`,children:tx[e.category]??"?"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Hire Agent"}),t.jsxs("p",{className:"text-xs text-fg-tertiary",children:['Creating agent from "',e.name,'"']})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Agent Name"}),t.jsx("input",{type:"text",value:i,onChange:b=>o(b.target.value),className:"input-field",autoFocus:!0})]}),f.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:c,onChange:b=>u(b.target.value),className:"input-field",children:[t.jsx("option",{value:"",children:"No team"}),f.map(b=>t.jsx("option",{value:b.id,children:b.name},b.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:r,className:"btn-secondary",children:"Cancel"}),t.jsx("button",{onClick:g,disabled:!i.trim()||h,className:"btn-primary",children:h?"Creating...":"Create Agent"})]})]})})}const hj={development:"{ }",review:"⊘",operations:"⚙",general:"◎"},Cu={development:"bg-blue-500/15 text-blue-600 border-blue-500/20",review:"bg-brand-500/15 text-brand-500 border-brand-500/20",operations:"bg-amber-500/15 text-amber-600 border-amber-500/20",general:"bg-gray-500/15 text-fg-secondary border-gray-500/20"};function mj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function WT(e,r){const s=e.split(".").map(Number),i=r.split(".").map(Number);for(let o=0;o<Math.max(s.length,i.length);o++){const c=s[o]??0,u=i[o]??0;if(c>u)return!0;if(c<u)return!1}return!1}function xj(){const[e,r]=j.useState("all"),[s,i]=j.useState(""),[o,c]=j.useState([]),[u,f]=j.useState([]),[m,h]=j.useState(null),[x,g]=j.useState(!0),[b,p]=j.useState(!1),[w,S]=j.useState(null),[T,E]=j.useState(new Map),C=j.useCallback(async()=>{try{const[H,M]=await Promise.all([ae.builder.artifacts.list().catch(()=>({artifacts:[]})),ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),Y=new Map;for(const $ of H.artifacts){if($.type!=="team")continue;const X=!!M.installed[`team/${$.name}`];Y.set($.name,{installed:X,localVersion:$.meta.version||void 0,localUpdatedAt:$.updatedAt})}E(Y)}catch{}},[]),N=j.useCallback(async()=>{g(!0);try{if(e==="hub"){const H=s?Bn.search({type:"team",q:s,limit:50}):Ga(pr.hubTeams)??Bn.search({type:"team",limit:50}),[M]=await Promise.all([H.catch(()=>({items:[],total:0})),C()]);f(M?.items??[]),c([])}else{f([]);const H=await ae.teamTemplates.list(s||void 0);c(H?.templates??[])}}catch{c([]),f([])}finally{g(!1)}},[e,s,C]);j.useEffect(()=>{N()},[N]);const k=async H=>{p(!0),S(null);try{const Y=(await ae.teams.create(H.name,H.description)).team.id;let $,X=0;const P=[];for(const F of H.members){const D=F.count??1;for(let _=0;_<D;_++){const I=F.name??`${H.name} Agent ${_+1}`,A=D>1?`${I} ${_+1}`:I,G=F.roleName??F.templateId??"developer";try{const U=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:A,roleName:G,orgId:"default",teamId:Y,agentRole:F.role??"worker",skills:F.skills??[]})});if(U.ok){X++;const K=await U.json();F.role==="manager"&&!$&&($=K.agent?.id)}else{const K=await U.json().catch(()=>({error:`HTTP ${U.status}`}));P.push(`${A}: ${K.error??U.statusText}`)}}catch(U){P.push(`${A}: ${String(U)}`)}}}$&&await ae.teams.update(Y,{managerId:$,managerType:"agent"}).catch(()=>{});const q=P.length>0?` (${P.length} failed: ${P[0]})`:"";S({ok:X>0,message:`Team "${H.name}" deployed with ${X} agent(s)${q}`})}catch(M){S({ok:!1,message:`Failed: ${M}`})}finally{p(!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(H=>t.jsx("button",{onClick:()=>{r(H.id),h(null),S(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${e===H.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:H.label},H.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:H=>i(H.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:x?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading teams..."}):e==="hub"?u.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:u.map(H=>t.jsx(e_,{item:H,localInfo:T.get(mj(H.name)),onStatusChange:C},H.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(H=>t.jsx(t_,{template:H,isSelected:m?.id===H.id,onSelect:()=>h(m?.id===H.id?null:H)},H.id))})}),m&&e==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-80 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-lg border ${Cu[m.category??"general"]??Cu.general}`,children:hj[m.category??"general"]??"◎"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children:m.name}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:m.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>k(m),disabled:b,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:b?"Deploying...":"Deploy Team"}),t.jsx("button",{onClick:()=>{h(null),S(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((H,M)=>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 ${H.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:H.role==="manager"?"★":M+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-fg-primary",children:H.name??H.roleName??H.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:H.roleName??H.templateId}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize ${H.role==="manager"?"bg-brand-500/15 text-brand-500":"bg-blue-500/15 text-blue-600"}`,children:H.role??"worker"}),(H.count??1)>1&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",H.count]})]})]})]},M))})]}),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((H,M)=>H+(M.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(H=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-secondary rounded-full border border-border-default",children:H},H))})]})]})]})]})]})})]})}function e_({item:e,localInfo:r,onStatusChange:s}){const[i,o]=j.useState(!1),[c,u]=j.useState(""),f=r?.installed??!1,m=f&&e.version&&r?.localVersion&&WT(e.version,r.localVersion),h=async x=>{if(x.stopPropagation(),!i){o(!0),u("");try{const g=await Bn.download(e.id),b=g.name||e.name,p=mj(b),w={type:"hub",hubItemId:e.id};if(g.files&&Object.keys(g.files).length>0)await ae.builder.artifacts.import("team",p,g.files,w);else{const S={...g.config,name:b,description:e.description,source:w};await ae.builder.artifacts.save("team",S)}await ae.builder.artifacts.install("team",p),u(m?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{u("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-lg",children:"👥"}),t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[m?t.jsx("button",{onClick:x=>{h(x)},disabled:i,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Upgrading...":`Upgrade → v${e.version}`}):f?t.jsxs("span",{className:"px-3 py-1 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",r?.localVersion?` (v${r.localVersion})`:""]}):t.jsx("button",{onClick:x=>{h(x)},disabled:i,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Installing...":"Install"}),c&&t.jsx("span",{className:`text-[10px] ${c==="Failed"?"text-red-500":"text-green-600"}`,children:c})]})]})}function t_({template:e,isSelected:r,onSelect:s}){const i=e.members.reduce((u,f)=>u+(f.count??1),0),o=e.members.some(u=>u.role==="manager"),c=e.category??"general";return t.jsxs("div",{onClick:s,className:`bg-surface-secondary border rounded-xl p-5 cursor-pointer transition-all hover:shadow-lg hover:shadow-black/20 ${r?"border-brand-500 ring-1 ring-brand-500/30":"border-border-default hover:border-gray-600"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center text-sm shrink-0 border ${Cu[c]??Cu.general}`,children:hj[c]??"◎"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 bg-brand-500/20 text-brand-500",children:["v",e.version]})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",e.author]})]})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:e.members.map((u,f)=>t.jsxs("span",{className:`px-2 py-0.5 text-[10px] rounded-full border ${u.role==="manager"?"bg-brand-500/10 text-brand-500 border-brand-500/15":"bg-blue-500/10 text-blue-600 border-blue-500/15"}`,children:[u.name??u.roleName??u.templateId,(u.count??1)>1?` x${u.count}`:""]},f))}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{children:[i," agent",i!==1?"s":""]}),o&&t.jsx("span",{className:"text-brand-500/60",children:"has manager"}),e.tags&&e.tags.length>0&&t.jsx("span",{className:"text-fg-tertiary",children:e.tags.slice(0,3).join(", ")})]})]})}function n_(e){const r=e.indexOf(".markus/builder-artifacts/");return r>=0?"~/"+e.slice(r):e}const Dh=[{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"]}],xy={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 gy({message:e,onConfirm:r,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:i=>i.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:r,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:"Delete"})]})]})})}function gj(){const e=gs(),[r,s]=j.useState([]),[i,o]=j.useState([]),[c,u]=j.useState(!1),[f,m]=j.useState("all"),[h,x]=j.useState(null),[g,b]=j.useState(new Map),[p,w]=j.useState(null),[S,T]=j.useState(new Map),[E,C]=j.useState(null),[N,k]=j.useState(null);new Set(Dh.map(D=>D.roleName));const H=j.useCallback(()=>{u(!0),Promise.all([(Ga(pr.builderArtifacts)??ae.builder.artifacts.list()).then(D=>D?.artifacts??[]).catch(()=>[]),(Ga(pr.builderAgents)??ae.agents.list()).then(D=>D?.agents??[]).catch(()=>[]),(Ga(pr.builderHubMyItems)??Bn.myItems()).then(D=>D?.items??[]).catch(()=>[]),(Ga(pr.builderInstalled)??ae.builder.artifacts.installed()).then(D=>D?.installed??{}).catch(()=>({}))]).then(([D,_,I,A])=>{if(o(D),s(_),I.length>0){const U=new Map;for(const K of I){const B=K.itemType==="agent"?"agent":K.itemType==="team"?"team":"skill";for(const L of D)L.type===B&&(K.slug===L.name||K.name===(L.meta.displayName||L.meta.name||L.name))&&U.set(`${L.type}/${L.name}`,{id:K.id,name:K.name,slug:K.slug||L.name})}U.size>0&&T(K=>{const B=new Map(K);for(const[L,W]of U)B.set(L,W);return B})}const G=new Map;for(const U of D){const K=`${U.type}/${U.name}`,B=A[K];B&&G.set(K,{agentId:B.agentId,agentIds:B.agentIds,teamId:B.teamId})}b(G)}).finally(()=>u(!1))},[]);j.useEffect(()=>{H();const D=_=>{_.detail?.page==="builder"&&H()};return window.addEventListener("markus:navigate",D),()=>window.removeEventListener("markus:navigate",D)},[H]);const M=(D,_)=>{const I=r.find(A=>A.role===_||A.name===_);I?Ut.navigate("chat",{agentId:I.id}):Ut.navigate("chat")},Y=async D=>{const _=`${D.type}/${D.name}`;if(!g.has(_)){x(_);try{const I=await ae.builder.artifacts.install(D.type,D.name),A={};I.agent&&typeof I.agent=="object"&&(A.agentId=I.agent.id),I.team&&typeof I.team=="object"&&(A.teamId=I.team.id),Array.isArray(I.agents)&&(A.agentIds=I.agents.map(G=>G.id)),b(G=>new Map(G).set(_,A)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(I){console.error("Install failed:",I),alert(`Install failed: ${I}`)}finally{x(null)}}},$=async D=>{const _=`${D.type}/${D.name}`;if(g.has(_)){x(_);try{await ae.builder.artifacts.uninstall(D.type,D.name),b(I=>{const A=new Map(I);return A.delete(_),A}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(I){console.error("Uninstall failed:",I),alert(`Uninstall failed: ${I}`)}finally{x(null)}}},X=async D=>{const _=`${D.type}/${D.name}`;if(!S.has(_)){x(_);try{const I=await ae.builder.artifacts.get(D.type,D.name),A=D.meta.displayName||D.meta.name||D.name,G=D.meta.description||"",U=D.meta.category||"general",K=Array.isArray(D.meta.tags)?D.meta.tags:[],B=D.name,L=await Bn.publishViaProxy({itemType:D.type==="team"?"team":D.type==="skill"?"skill":"agent",name:A,slug:B,description:G,category:U,tags:K,config:D.meta,files:I.files&&Object.keys(I.files).length>0?I.files:void 0});L.id&&T(W=>{const R=new Map(W);return R.set(_,{id:L.id,name:A,slug:L.slug??B}),R})}catch(I){console.error("Share failed:",I),alert(`Share failed: ${I}`)}finally{x(null)}}},P=async()=>{if(!E)return;const{key:D}=E,_=S.get(D);if(C(null),!_)return;const I=_.id;x(D);try{await Bn.deleteItem(I),T(A=>{const G=new Map(A);return G.delete(D),G})}catch(A){console.error("Hub delete failed:",A),alert(`Failed to remove from Hub: ${A}`)}finally{x(null)}},q=async()=>{if(!p)return;const D=p,_=`${D.type}/${D.name}`;w(null),x(_);try{await ae.builder.artifacts.delete(D.type,D.name),o(I=>I.filter(A=>!(A.type===D.type&&A.name===D.name))),b(I=>{const A=new Map(I);return A.delete(_),A}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(I){console.error("Delete failed:",I)}finally{x(null)}},F=f==="all"?i:i.filter(D=>D.type===f);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:Dh.map(D=>t.jsx("button",{onClick:()=>M(D.roleId,D.roleName),className:`group text-left w-full rounded-xl border ${D.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 ${D.bgColor} flex items-center justify-center shrink-0`,children:D.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 ${D.color} bg-clip-text text-transparent`,children:D.roleName}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:D.desc}),r.find(_=>_.role===D.roleName||_.name===D.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:D.detail}),t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:D.examples.map((_,I)=>t.jsxs("span",{className:"text-[11px] text-fg-tertiary bg-surface-elevated/60 rounded-full px-3 py-1 border border-border-default",children:["“",_,"”"]},I))})]}),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"})})]})},D.roleId))}),r.length>0&&!r.some(D=>Dh.some(_=>D.role===_.roleName||D.name===_.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:H,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(D=>t.jsx("button",{onClick:()=>m(D),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${f===D?"border-gray-600 bg-surface-elevated text-fg-primary":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:D==="all"?"All":D.charAt(0).toUpperCase()+D.slice(1)+"s"},D))})]}),c&&i.length===0?t.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:"Loading artifacts..."}):F.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:F.map(D=>{const _=xy[D.type]??xy.agent,I=D.meta.displayName||D.meta.name||D.name,A=D.meta.description||"",G=`${D.type}/${D.name}`,U=h===G,K=t.jsxs("div",{className:`flex items-center gap-1.5 ${e?"flex-wrap":"shrink-0"}`,children:[g.has(G)?t.jsx("button",{onClick:()=>$(D),disabled:U,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:U?"Uninstalling...":"Uninstall"}):t.jsx("button",{onClick:()=>Y(D),disabled:U,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:U?"Installing...":"Install"}),S.has(G)?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>C({key:G,name:D.meta.displayName||D.meta.name||D.name}),disabled:U,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=S.get(G),L=Bn.getUser();if(!B||!L)return;const W=`${Bn.getUrl()}/${encodeURIComponent(L.username)}/${encodeURIComponent(B.slug)}`;navigator.clipboard.writeText(W).then(()=>{k(G),setTimeout(()=>k(R=>R===G?null:R),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:N===G?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:()=>X(D),disabled:U,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:U?"Sharing...":"Share"}),t.jsx("button",{onClick:()=>w(D),disabled:U,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 ${_.bg} flex items-center justify-center text-lg shrink-0`,children:_.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:I}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${_.color}`,children:D.type})]}),A&&t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2",children:A}),t.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-fg-tertiary min-w-0",children:[t.jsx("button",{onClick:B=>{B.stopPropagation(),ae.system.openPath(D.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:D.path,children:n_(D.path)}),t.jsx("span",{className:"shrink-0",children:new Date(D.updatedAt).toLocaleDateString()})]})]}),!e&&K]}),e&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-default/50",children:K})]},G)})}),p&&t.jsx(gy,{message:`Delete "${p.meta.displayName||p.meta.name||p.name}"? This cannot be undone.`,onConfirm:q,onCancel:()=>w(null)}),E&&t.jsx(gy,{message:`Remove "${E.name}" from Markus Hub? It will no longer be available for others to download.`,onConfirm:()=>{P()},onCancel:()=>C(null)})]})})}function pj(){const[e,r]=j.useState(null),[s,i]=j.useState([]),[o,c]=j.useState(null),[u,f]=j.useState(!0),[m,h]=j.useState(""),[x,g]=j.useState(!1),[b,p]=j.useState(""),[w,S]=j.useState(""),[T,E]=j.useState("normal"),[C,N]=j.useState(""),[k,H]=j.useState(!1),[M,Y]=j.useState(!1),[$,X]=j.useState("auto"),[P,q]=j.useState(10),[F,D]=j.useState(!0),_=j.useCallback(async()=>{try{const[L,W,R]=await Promise.all([ae.governance.getSystemStatus(),ae.governance.getAnnouncements(),ae.governance.getPolicy()]);r(L),i(W.announcements),c(R.policy)}catch{}f(!1)},[]);j.useEffect(()=>{_()},[_]);const I=L=>{h(L),setTimeout(()=>h(""),3e3)},A=async()=>{try{await ae.governance.pauseAll(C||void 0),I("All agents paused"),H(!1),N(""),_()}catch(L){I(`Error: ${L}`)}},G=async()=>{try{await ae.governance.resumeAll(),I("All agents resumed"),_()}catch(L){I(`Error: ${L}`)}},U=async()=>{if(confirm("EMERGENCY STOP will terminate all agents immediately. Continue?"))try{await ae.governance.emergencyStop("Manual emergency stop from UI"),I("EMERGENCY STOP executed"),_()}catch(L){I(`Error: ${L}`)}},K=async()=>{if(b.trim())try{await ae.governance.createAnnouncement({title:b,message:w,priority:T,scope:"all"}),g(!1),p(""),S(""),I("Announcement created"),_()}catch(L){I(`Error: ${L}`)}},B=async()=>{try{const L={defaultApprovalTier:$,maxTasksPerAgent:P,requireRequirement:F};await ae.governance.setPolicy(L),I("Policy updated"),Y(!1),_()}catch(L){I(`Error: ${L}`)}};return u?t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"}):t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary border-b border-border-default px-6 h-14 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary",children:"Governance"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:"System controls, announcements, and governance policy"})]}),m&&t.jsx("div",{className:"px-3 py-1.5 bg-green-500/10 text-green-600 text-xs rounded-lg",children:m})]}),t.jsxs("div",{className:"p-6 space-y-6 max-w-5xl",children:[t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary mb-4",children:"System Status"}),t.jsxs("div",{className:"flex items-center gap-4 mb-5",children:[t.jsx(py,{label:"Global",active:!e?.globalPaused,activeText:"Running",inactiveText:"Paused"}),t.jsx(py,{label:"Emergency",active:!e?.emergencyMode,activeText:"Normal",inactiveText:"ACTIVE",danger:!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[e?.globalPaused?t.jsx("button",{onClick:G,className:"btn-primary text-sm px-4 py-2 rounded-lg bg-green-600 hover:bg-green-500",children:"▶ Resume All Agents"}):t.jsx("button",{onClick:()=>H(!0),className:"text-sm px-4 py-2 rounded-lg bg-amber-600 hover:bg-amber-500 text-white",children:"⏸ Pause All Agents"}),t.jsx("button",{onClick:U,className:"text-sm px-4 py-2 rounded-lg bg-red-700 hover:bg-red-600 text-white",children:"⚠ Emergency Stop"})]})]}),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-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"Governance Policy"}),t.jsx("button",{onClick:()=>{Y(!M),o&&(X(o.defaultApprovalTier),q(o.maxTasksPerAgent??10),D(o.requireRequirement??!0))},className:"text-xs text-brand-500 hover:text-brand-500",children:M?"Cancel":"Edit"})]}),M?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Default Approval Tier"}),t.jsxs("select",{value:$,onChange:L=>X(L.target.value),className:"bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary w-48",children:[t.jsx("option",{value:"auto",children:"Auto (no approval)"}),t.jsx("option",{value:"manager",children:"Manager Approval"}),t.jsx("option",{value:"human",children:"Human Approval"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-fg-tertiary block mb-1",children:"Max Tasks per Agent"}),t.jsx("input",{type:"number",value:P,onChange:L=>q(Number(L.target.value)),className:"bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary w-32"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:F,onChange:L=>D(L.target.checked),className:"sr-only peer"}),t.jsx("div",{className:"w-9 h-5 bg-surface-overlay peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-brand-600"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-fg-secondary",children:"Require Requirement for Tasks"}),t.jsx("p",{className:"text-[10px] text-fg-tertiary",children:"Top-level tasks must link to an approved requirement"})]})]}),t.jsx("button",{onClick:B,className:"btn-primary text-sm px-4 py-2 rounded-lg",children:"Save Policy"})]}):o?t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-fg-tertiary",children:"Approval Tier:"}),t.jsx("span",{className:"ml-2 text-fg-primary",children:o.defaultApprovalTier})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-fg-tertiary",children:"Max Tasks/Agent:"}),t.jsx("span",{className:"ml-2 text-fg-primary",children:o.maxTasksPerAgent??"—"})]}),t.jsxs("div",{className:"col-span-2",children:[t.jsx("span",{className:"text-fg-tertiary",children:"Require Requirement:"}),t.jsx("span",{className:`ml-2 px-2 py-0.5 rounded-full text-xs font-medium ${o.requireRequirement!==!1?"bg-brand-500/10 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:o.requireRequirement!==!1?"Enabled":"Disabled"})]}),o.rules&&o.rules.length>0&&t.jsxs("div",{className:"col-span-2",children:[t.jsx("span",{className:"text-fg-tertiary",children:"Rules:"}),t.jsx("div",{className:"mt-1 space-y-1",children:o.rules.map((L,W)=>t.jsxs("div",{className:"text-xs bg-surface-elevated rounded px-2 py-1 text-fg-secondary",children:["When ",t.jsx("code",{className:"text-amber-600",children:L.condition})," → ",t.jsx("span",{className:"text-brand-500",children:L.approvalTier})]},W))})]})]}):t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No governance policy configured. Click Edit to set one."})]}),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-4",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"System Announcements"}),t.jsx("button",{onClick:()=>g(!x),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white",children:"+ New Announcement"})]}),x&&t.jsxs("div",{className:"mb-4 p-4 bg-surface-elevated rounded-lg space-y-3",children:[t.jsx("input",{value:b,onChange:L=>p(L.target.value),placeholder:"Title",className:"w-full bg-surface-overlay border border-gray-600 rounded-lg px-3 py-2 text-sm text-fg-primary"}),t.jsx("textarea",{value:w,onChange:L=>S(L.target.value),placeholder:"Message (optional)",className:"w-full bg-surface-overlay border border-gray-600 rounded-lg px-3 py-2 text-sm text-fg-primary h-20 resize-none"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("select",{value:T,onChange:L=>E(L.target.value),className:"bg-surface-overlay border border-gray-600 rounded-lg px-3 py-2 text-sm text-fg-primary",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"normal",children:"Normal"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"critical",children:"Critical"})]}),t.jsx("button",{onClick:K,className:"btn-primary text-sm px-4 py-2 rounded-lg",children:"Publish"}),t.jsx("button",{onClick:()=>g(!1),className:"text-sm text-fg-tertiary hover:text-fg-secondary",children:"Cancel"})]})]}),s.length===0?t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No announcements."}):t.jsx("div",{className:"space-y-2",children:s.map(L=>t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsx(r_,{priority:L.priority}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:L.title}),L.message&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:L.message}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-1",children:new Date(L.createdAt).toLocaleString()})]})]},L.id))})]})]}),k&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-96 space-y-4",children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Pause All Agents"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:"All agents will be paused. They will stop processing tasks until resumed."}),t.jsx("input",{value:C,onChange:L=>N(L.target.value),placeholder:"Reason (optional)",className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary"}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>H(!1),className:"text-sm text-fg-tertiary hover:text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:A,className:"text-sm px-4 py-2 rounded-lg bg-amber-600 hover:bg-amber-500 text-white",children:"Pause All"})]})]})})]})}function py({label:e,active:r,activeText:s,inactiveText:i,danger:o}){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[e,":"]}),t.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium ${r?"bg-green-500/10 text-green-600":o?"bg-red-500/10 text-red-500 animate-pulse":"bg-amber-500/10 text-amber-600"}`,children:r?s:i})]})}function r_({priority:e}){const r=e==="critical"?"bg-red-500":e==="high"?"bg-amber-500":e==="normal"?"bg-blue-500":"bg-gray-500";return t.jsx("div",{className:`w-2 h-2 rounded-full mt-1.5 shrink-0 ${r}`})}function Pn(e){if(typeof e=="string"||typeof e=="number")return""+e;let r="";if(Array.isArray(e))for(let s=0,i;s<e.length;s++)(i=Pn(e[s]))!==""&&(r+=(r&&" ")+i);else for(let s in e)e[s]&&(r+=(r&&" ")+s);return r}var s_={value:()=>{}};function Yu(){for(var e=0,r=arguments.length,s={},i;e<r;++e){if(!(i=arguments[e]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new fu(s)}function fu(e){this._=e}function a_(e,r){return e.trim().split(/^|\s+/).map(function(s){var i="",o=s.indexOf(".");if(o>=0&&(i=s.slice(o+1),s=s.slice(0,o)),s&&!r.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}fu.prototype=Yu.prototype={constructor:fu,on:function(e,r){var s=this._,i=a_(e+"",s),o,c=-1,u=i.length;if(arguments.length<2){for(;++c<u;)if((o=(e=i[c]).type)&&(o=i_(s[o],e.name)))return o;return}if(r!=null&&typeof r!="function")throw new Error("invalid callback: "+r);for(;++c<u;)if(o=(e=i[c]).type)s[o]=by(s[o],e.name,r);else if(r==null)for(o in s)s[o]=by(s[o],e.name,null);return this},copy:function(){var e={},r=this._;for(var s in r)e[s]=r[s].slice();return new fu(e)},call:function(e,r){if((o=arguments.length-2)>0)for(var s=new Array(o),i=0,o,c;i<o;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(c=this._[e],i=0,o=c.length;i<o;++i)c[i].value.apply(r,s)},apply:function(e,r,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],o=0,c=i.length;o<c;++o)i[o].value.apply(r,s)}};function i_(e,r){for(var s=0,i=e.length,o;s<i;++s)if((o=e[s]).name===r)return o.value}function by(e,r,s){for(var i=0,o=e.length;i<o;++i)if(e[i].name===r){e[i]=s_,e=e.slice(0,i).concat(e.slice(i+1));break}return s!=null&&e.push({name:r,value:s}),e}var hm="http://www.w3.org/1999/xhtml";const yy={svg:"http://www.w3.org/2000/svg",xhtml:hm,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Gu(e){var r=e+="",s=r.indexOf(":");return s>=0&&(r=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),yy.hasOwnProperty(r)?{space:yy[r],local:e}:e}function l_(e){return function(){var r=this.ownerDocument,s=this.namespaceURI;return s===hm&&r.documentElement.namespaceURI===hm?r.createElement(e):r.createElementNS(s,e)}}function o_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function bj(e){var r=Gu(e);return(r.local?o_:l_)(r)}function c_(){}function rx(e){return e==null?c_:function(){return this.querySelector(e)}}function u_(e){typeof e!="function"&&(e=rx(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o<s;++o)for(var c=r[o],u=c.length,f=i[o]=new Array(u),m,h,x=0;x<u;++x)(m=c[x])&&(h=e.call(m,m.__data__,x,c))&&("__data__"in m&&(h.__data__=m.__data__),f[x]=h);return new Dr(i,this._parents)}function d_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function f_(){return[]}function yj(e){return e==null?f_:function(){return this.querySelectorAll(e)}}function h_(e){return function(){return d_(e.apply(this,arguments))}}function m_(e){typeof e=="function"?e=h_(e):e=yj(e);for(var r=this._groups,s=r.length,i=[],o=[],c=0;c<s;++c)for(var u=r[c],f=u.length,m,h=0;h<f;++h)(m=u[h])&&(i.push(e.call(m,m.__data__,h,u)),o.push(m));return new Dr(i,o)}function vj(e){return function(){return this.matches(e)}}function jj(e){return function(r){return r.matches(e)}}var x_=Array.prototype.find;function g_(e){return function(){return x_.call(this.children,e)}}function p_(){return this.firstElementChild}function b_(e){return this.select(e==null?p_:g_(typeof e=="function"?e:jj(e)))}var y_=Array.prototype.filter;function v_(){return Array.from(this.children)}function j_(e){return function(){return y_.call(this.children,e)}}function w_(e){return this.selectAll(e==null?v_:j_(typeof e=="function"?e:jj(e)))}function N_(e){typeof e!="function"&&(e=vj(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o<s;++o)for(var c=r[o],u=c.length,f=i[o]=[],m,h=0;h<u;++h)(m=c[h])&&e.call(m,m.__data__,h,c)&&f.push(m);return new Dr(i,this._parents)}function wj(e){return new Array(e.length)}function k_(){return new Dr(this._enter||this._groups.map(wj),this._parents)}function Eu(e,r){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=r}Eu.prototype={constructor:Eu,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,r){return this._parent.insertBefore(e,r)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function S_(e){return function(){return e}}function C_(e,r,s,i,o,c){for(var u=0,f,m=r.length,h=c.length;u<h;++u)(f=r[u])?(f.__data__=c[u],i[u]=f):s[u]=new Eu(e,c[u]);for(;u<m;++u)(f=r[u])&&(o[u]=f)}function E_(e,r,s,i,o,c,u){var f,m,h=new Map,x=r.length,g=c.length,b=new Array(x),p;for(f=0;f<x;++f)(m=r[f])&&(b[f]=p=u.call(m,m.__data__,f,r)+"",h.has(p)?o[f]=m:h.set(p,m));for(f=0;f<g;++f)p=u.call(e,c[f],f,c)+"",(m=h.get(p))?(i[f]=m,m.__data__=c[f],h.delete(p)):s[f]=new Eu(e,c[f]);for(f=0;f<x;++f)(m=r[f])&&h.get(b[f])===m&&(o[f]=m)}function T_(e){return e.__data__}function __(e,r){if(!arguments.length)return Array.from(this,T_);var s=r?E_:C_,i=this._parents,o=this._groups;typeof e!="function"&&(e=S_(e));for(var c=o.length,u=new Array(c),f=new Array(c),m=new Array(c),h=0;h<c;++h){var x=i[h],g=o[h],b=g.length,p=A_(e.call(x,x&&x.__data__,h,i)),w=p.length,S=f[h]=new Array(w),T=u[h]=new Array(w),E=m[h]=new Array(b);s(x,g,S,T,E,p,r);for(var C=0,N=0,k,H;C<w;++C)if(k=S[C]){for(C>=N&&(N=C+1);!(H=T[N])&&++N<w;);k._next=H||null}}return u=new Dr(u,i),u._enter=f,u._exit=m,u}function A_(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function M_(){return new Dr(this._exit||this._groups.map(wj),this._parents)}function D_(e,r,s){var i=this.enter(),o=this,c=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),r!=null&&(o=r(o),o&&(o=o.selection())),s==null?c.remove():s(c),i&&o?i.merge(o).order():o}function O_(e){for(var r=e.selection?e.selection():e,s=this._groups,i=r._groups,o=s.length,c=i.length,u=Math.min(o,c),f=new Array(o),m=0;m<u;++m)for(var h=s[m],x=i[m],g=h.length,b=f[m]=new Array(g),p,w=0;w<g;++w)(p=h[w]||x[w])&&(b[w]=p);for(;m<o;++m)f[m]=s[m];return new Dr(f,this._parents)}function R_(){for(var e=this._groups,r=-1,s=e.length;++r<s;)for(var i=e[r],o=i.length-1,c=i[o],u;--o>=0;)(u=i[o])&&(c&&u.compareDocumentPosition(c)^4&&c.parentNode.insertBefore(u,c),c=u);return this}function z_(e){e||(e=L_);function r(g,b){return g&&b?e(g.__data__,b.__data__):!g-!b}for(var s=this._groups,i=s.length,o=new Array(i),c=0;c<i;++c){for(var u=s[c],f=u.length,m=o[c]=new Array(f),h,x=0;x<f;++x)(h=u[x])&&(m[x]=h);m.sort(r)}return new Dr(o,this._parents).order()}function L_(e,r){return e<r?-1:e>r?1:e>=r?0:NaN}function I_(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function $_(){return Array.from(this)}function B_(){for(var e=this._groups,r=0,s=e.length;r<s;++r)for(var i=e[r],o=0,c=i.length;o<c;++o){var u=i[o];if(u)return u}return null}function H_(){let e=0;for(const r of this)++e;return e}function P_(){return!this.node()}function U_(e){for(var r=this._groups,s=0,i=r.length;s<i;++s)for(var o=r[s],c=0,u=o.length,f;c<u;++c)(f=o[c])&&e.call(f,f.__data__,c,o);return this}function q_(e){return function(){this.removeAttribute(e)}}function V_(e){return function(){this.removeAttributeNS(e.space,e.local)}}function F_(e,r){return function(){this.setAttribute(e,r)}}function Y_(e,r){return function(){this.setAttributeNS(e.space,e.local,r)}}function G_(e,r){return function(){var s=r.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function X_(e,r){return function(){var s=r.apply(this,arguments);s==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,s)}}function Z_(e,r){var s=Gu(e);if(arguments.length<2){var i=this.node();return s.local?i.getAttributeNS(s.space,s.local):i.getAttribute(s)}return this.each((r==null?s.local?V_:q_:typeof r=="function"?s.local?X_:G_:s.local?Y_:F_)(s,r))}function Nj(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Q_(e){return function(){this.style.removeProperty(e)}}function K_(e,r,s){return function(){this.style.setProperty(e,r,s)}}function J_(e,r,s){return function(){var i=r.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,s)}}function W_(e,r,s){return arguments.length>1?this.each((r==null?Q_:typeof r=="function"?J_:K_)(e,r,s??"")):Yi(this.node(),e)}function Yi(e,r){return e.style.getPropertyValue(r)||Nj(e).getComputedStyle(e,null).getPropertyValue(r)}function eA(e){return function(){delete this[e]}}function tA(e,r){return function(){this[e]=r}}function nA(e,r){return function(){var s=r.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function rA(e,r){return arguments.length>1?this.each((r==null?eA:typeof r=="function"?nA:tA)(e,r)):this.node()[e]}function kj(e){return e.trim().split(/^|\s+/)}function sx(e){return e.classList||new Sj(e)}function Sj(e){this._node=e,this._names=kj(e.getAttribute("class")||"")}Sj.prototype={add:function(e){var r=this._names.indexOf(e);r<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var r=this._names.indexOf(e);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Cj(e,r){for(var s=sx(e),i=-1,o=r.length;++i<o;)s.add(r[i])}function Ej(e,r){for(var s=sx(e),i=-1,o=r.length;++i<o;)s.remove(r[i])}function sA(e){return function(){Cj(this,e)}}function aA(e){return function(){Ej(this,e)}}function iA(e,r){return function(){(r.apply(this,arguments)?Cj:Ej)(this,e)}}function lA(e,r){var s=kj(e+"");if(arguments.length<2){for(var i=sx(this.node()),o=-1,c=s.length;++o<c;)if(!i.contains(s[o]))return!1;return!0}return this.each((typeof r=="function"?iA:r?sA:aA)(s,r))}function oA(){this.textContent=""}function cA(e){return function(){this.textContent=e}}function uA(e){return function(){var r=e.apply(this,arguments);this.textContent=r??""}}function dA(e){return arguments.length?this.each(e==null?oA:(typeof e=="function"?uA:cA)(e)):this.node().textContent}function fA(){this.innerHTML=""}function hA(e){return function(){this.innerHTML=e}}function mA(e){return function(){var r=e.apply(this,arguments);this.innerHTML=r??""}}function xA(e){return arguments.length?this.each(e==null?fA:(typeof e=="function"?mA:hA)(e)):this.node().innerHTML}function gA(){this.nextSibling&&this.parentNode.appendChild(this)}function pA(){return this.each(gA)}function bA(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yA(){return this.each(bA)}function vA(e){var r=typeof e=="function"?e:bj(e);return this.select(function(){return this.appendChild(r.apply(this,arguments))})}function jA(){return null}function wA(e,r){var s=typeof e=="function"?e:bj(e),i=r==null?jA:typeof r=="function"?r:rx(r);return this.select(function(){return this.insertBefore(s.apply(this,arguments),i.apply(this,arguments)||null)})}function NA(){var e=this.parentNode;e&&e.removeChild(this)}function kA(){return this.each(NA)}function SA(){var e=this.cloneNode(!1),r=this.parentNode;return r?r.insertBefore(e,this.nextSibling):e}function CA(){var e=this.cloneNode(!0),r=this.parentNode;return r?r.insertBefore(e,this.nextSibling):e}function EA(e){return this.select(e?CA:SA)}function TA(e){return arguments.length?this.property("__data__",e):this.node().__data__}function _A(e){return function(r){e.call(this,r,this.__data__)}}function AA(e){return e.trim().split(/^|\s+/).map(function(r){var s="",i=r.indexOf(".");return i>=0&&(s=r.slice(i+1),r=r.slice(0,i)),{type:r,name:s}})}function MA(e){return function(){var r=this.__on;if(r){for(var s=0,i=-1,o=r.length,c;s<o;++s)c=r[s],(!e.type||c.type===e.type)&&c.name===e.name?this.removeEventListener(c.type,c.listener,c.options):r[++i]=c;++i?r.length=i:delete this.__on}}}function DA(e,r,s){return function(){var i=this.__on,o,c=_A(r);if(i){for(var u=0,f=i.length;u<f;++u)if((o=i[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=c,o.options=s),o.value=r;return}}this.addEventListener(e.type,c,s),o={type:e.type,name:e.name,value:r,listener:c,options:s},i?i.push(o):this.__on=[o]}}function OA(e,r,s){var i=AA(e+""),o,c=i.length,u;if(arguments.length<2){var f=this.node().__on;if(f){for(var m=0,h=f.length,x;m<h;++m)for(o=0,x=f[m];o<c;++o)if((u=i[o]).type===x.type&&u.name===x.name)return x.value}return}for(f=r?DA:MA,o=0;o<c;++o)this.each(f(i[o],r,s));return this}function Tj(e,r,s){var i=Nj(e),o=i.CustomEvent;typeof o=="function"?o=new o(r,s):(o=i.document.createEvent("Event"),s?(o.initEvent(r,s.bubbles,s.cancelable),o.detail=s.detail):o.initEvent(r,!1,!1)),e.dispatchEvent(o)}function RA(e,r){return function(){return Tj(this,e,r)}}function zA(e,r){return function(){return Tj(this,e,r.apply(this,arguments))}}function LA(e,r){return this.each((typeof r=="function"?zA:RA)(e,r))}function*IA(){for(var e=this._groups,r=0,s=e.length;r<s;++r)for(var i=e[r],o=0,c=i.length,u;o<c;++o)(u=i[o])&&(yield u)}var _j=[null];function Dr(e,r){this._groups=e,this._parents=r}function Oo(){return new Dr([[document.documentElement]],_j)}function $A(){return this}Dr.prototype=Oo.prototype={constructor:Dr,select:u_,selectAll:m_,selectChild:b_,selectChildren:w_,filter:N_,data:__,enter:k_,exit:M_,join:D_,merge:O_,selection:$A,order:R_,sort:z_,call:I_,nodes:$_,node:B_,size:H_,empty:P_,each:U_,attr:Z_,style:W_,property:rA,classed:lA,text:dA,html:xA,raise:pA,lower:yA,append:vA,insert:wA,remove:kA,clone:EA,datum:TA,on:OA,dispatch:LA,[Symbol.iterator]:IA};function Ar(e){return typeof e=="string"?new Dr([[document.querySelector(e)]],[document.documentElement]):new Dr([[e]],_j)}function BA(e){let r;for(;r=e.sourceEvent;)e=r;return e}function Kr(e,r){if(e=BA(e),r===void 0&&(r=e.currentTarget),r){var s=r.ownerSVGElement||r;if(s.createSVGPoint){var i=s.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(r.getScreenCTM().inverse()),[i.x,i.y]}if(r.getBoundingClientRect){var o=r.getBoundingClientRect();return[e.clientX-o.left-r.clientLeft,e.clientY-o.top-r.clientTop]}}return[e.pageX,e.pageY]}const HA={passive:!1},yo={capture:!0,passive:!1};function Oh(e){e.stopImmediatePropagation()}function Ui(e){e.preventDefault(),e.stopImmediatePropagation()}function Aj(e){var r=e.document.documentElement,s=Ar(e).on("dragstart.drag",Ui,yo);"onselectstart"in r?s.on("selectstart.drag",Ui,yo):(r.__noselect=r.style.MozUserSelect,r.style.MozUserSelect="none")}function Mj(e,r){var s=e.document.documentElement,i=Ar(e).on("dragstart.drag",null);r&&(i.on("click.drag",Ui,yo),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in s?i.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const Wc=e=>()=>e;function mm(e,{sourceEvent:r,subject:s,target:i,identifier:o,active:c,x:u,y:f,dx:m,dy:h,dispatch:x}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:c,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:f,enumerable:!0,configurable:!0},dx:{value:m,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:x}})}mm.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function PA(e){return!e.ctrlKey&&!e.button}function UA(){return this.parentNode}function qA(e,r){return r??{x:e.x,y:e.y}}function VA(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dj(){var e=PA,r=UA,s=qA,i=VA,o={},c=Yu("start","drag","end"),u=0,f,m,h,x,g=0;function b(k){k.on("mousedown.drag",p).filter(i).on("touchstart.drag",T).on("touchmove.drag",E,HA).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(k,H){if(!(x||!e.call(this,k,H))){var M=N(this,r.call(this,k,H),k,H,"mouse");M&&(Ar(k.view).on("mousemove.drag",w,yo).on("mouseup.drag",S,yo),Aj(k.view),Oh(k),h=!1,f=k.clientX,m=k.clientY,M("start",k))}}function w(k){if(Ui(k),!h){var H=k.clientX-f,M=k.clientY-m;h=H*H+M*M>g}o.mouse("drag",k)}function S(k){Ar(k.view).on("mousemove.drag mouseup.drag",null),Mj(k.view,h),Ui(k),o.mouse("end",k)}function T(k,H){if(e.call(this,k,H)){var M=k.changedTouches,Y=r.call(this,k,H),$=M.length,X,P;for(X=0;X<$;++X)(P=N(this,Y,k,H,M[X].identifier,M[X]))&&(Oh(k),P("start",k,M[X]))}}function E(k){var H=k.changedTouches,M=H.length,Y,$;for(Y=0;Y<M;++Y)($=o[H[Y].identifier])&&(Ui(k),$("drag",k,H[Y]))}function C(k){var H=k.changedTouches,M=H.length,Y,$;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),Y=0;Y<M;++Y)($=o[H[Y].identifier])&&(Oh(k),$("end",k,H[Y]))}function N(k,H,M,Y,$,X){var P=c.copy(),q=Kr(X||M,H),F,D,_;if((_=s.call(k,new mm("beforestart",{sourceEvent:M,target:b,identifier:$,active:u,x:q[0],y:q[1],dx:0,dy:0,dispatch:P}),Y))!=null)return F=_.x-q[0]||0,D=_.y-q[1]||0,function I(A,G,U){var K=q,B;switch(A){case"start":o[$]=I,B=u++;break;case"end":delete o[$],--u;case"drag":q=Kr(U||G,H),B=u;break}P.call(A,k,new mm(A,{sourceEvent:G,subject:_,target:b,identifier:$,active:B,x:q[0]+F,y:q[1]+D,dx:q[0]-K[0],dy:q[1]-K[1],dispatch:P}),Y)}}return b.filter=function(k){return arguments.length?(e=typeof k=="function"?k:Wc(!!k),b):e},b.container=function(k){return arguments.length?(r=typeof k=="function"?k:Wc(k),b):r},b.subject=function(k){return arguments.length?(s=typeof k=="function"?k:Wc(k),b):s},b.touchable=function(k){return arguments.length?(i=typeof k=="function"?k:Wc(!!k),b):i},b.on=function(){var k=c.on.apply(c,arguments);return k===c?b:k},b.clickDistance=function(k){return arguments.length?(g=(k=+k)*k,b):Math.sqrt(g)},b}function ax(e,r,s){e.prototype=r.prototype=s,s.constructor=e}function Oj(e,r){var s=Object.create(e.prototype);for(var i in r)s[i]=r[i];return s}function Ro(){}var vo=.7,Tu=1/vo,qi="\\s*([+-]?\\d+)\\s*",jo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",hs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",FA=/^#([0-9a-f]{3,8})$/,YA=new RegExp(`^rgb\\(${qi},${qi},${qi}\\)$`),GA=new RegExp(`^rgb\\(${hs},${hs},${hs}\\)$`),XA=new RegExp(`^rgba\\(${qi},${qi},${qi},${jo}\\)$`),ZA=new RegExp(`^rgba\\(${hs},${hs},${hs},${jo}\\)$`),QA=new RegExp(`^hsl\\(${jo},${hs},${hs}\\)$`),KA=new RegExp(`^hsla\\(${jo},${hs},${hs},${jo}\\)$`),vy={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};ax(Ro,Ja,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:jy,formatHex:jy,formatHex8:JA,formatHsl:WA,formatRgb:wy,toString:wy});function jy(){return this.rgb().formatHex()}function JA(){return this.rgb().formatHex8()}function WA(){return Rj(this).formatHsl()}function wy(){return this.rgb().formatRgb()}function Ja(e){var r,s;return e=(e+"").trim().toLowerCase(),(r=FA.exec(e))?(s=r[1].length,r=parseInt(r[1],16),s===6?Ny(r):s===3?new br(r>>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):s===8?eu(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):s===4?eu(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=YA.exec(e))?new br(r[1],r[2],r[3],1):(r=GA.exec(e))?new br(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=XA.exec(e))?eu(r[1],r[2],r[3],r[4]):(r=ZA.exec(e))?eu(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=QA.exec(e))?Cy(r[1],r[2]/100,r[3]/100,1):(r=KA.exec(e))?Cy(r[1],r[2]/100,r[3]/100,r[4]):vy.hasOwnProperty(e)?Ny(vy[e]):e==="transparent"?new br(NaN,NaN,NaN,0):null}function Ny(e){return new br(e>>16&255,e>>8&255,e&255,1)}function eu(e,r,s,i){return i<=0&&(e=r=s=NaN),new br(e,r,s,i)}function e6(e){return e instanceof Ro||(e=Ja(e)),e?(e=e.rgb(),new br(e.r,e.g,e.b,e.opacity)):new br}function xm(e,r,s,i){return arguments.length===1?e6(e):new br(e,r,s,i??1)}function br(e,r,s,i){this.r=+e,this.g=+r,this.b=+s,this.opacity=+i}ax(br,xm,Oj(Ro,{brighter(e){return e=e==null?Tu:Math.pow(Tu,e),new br(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vo:Math.pow(vo,e),new br(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new br(Za(this.r),Za(this.g),Za(this.b),_u(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:ky,formatHex:ky,formatHex8:t6,formatRgb:Sy,toString:Sy}));function ky(){return`#${Xa(this.r)}${Xa(this.g)}${Xa(this.b)}`}function t6(){return`#${Xa(this.r)}${Xa(this.g)}${Xa(this.b)}${Xa((isNaN(this.opacity)?1:this.opacity)*255)}`}function Sy(){const e=_u(this.opacity);return`${e===1?"rgb(":"rgba("}${Za(this.r)}, ${Za(this.g)}, ${Za(this.b)}${e===1?")":`, ${e})`}`}function _u(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Za(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Xa(e){return e=Za(e),(e<16?"0":"")+e.toString(16)}function Cy(e,r,s,i){return i<=0?e=r=s=NaN:s<=0||s>=1?e=r=NaN:r<=0&&(e=NaN),new Jr(e,r,s,i)}function Rj(e){if(e instanceof Jr)return new Jr(e.h,e.s,e.l,e.opacity);if(e instanceof Ro||(e=Ja(e)),!e)return new Jr;if(e instanceof Jr)return e;e=e.rgb();var r=e.r/255,s=e.g/255,i=e.b/255,o=Math.min(r,s,i),c=Math.max(r,s,i),u=NaN,f=c-o,m=(c+o)/2;return f?(r===c?u=(s-i)/f+(s<i)*6:s===c?u=(i-r)/f+2:u=(r-s)/f+4,f/=m<.5?c+o:2-c-o,u*=60):f=m>0&&m<1?0:u,new Jr(u,f,m,e.opacity)}function n6(e,r,s,i){return arguments.length===1?Rj(e):new Jr(e,r,s,i??1)}function Jr(e,r,s,i){this.h=+e,this.s=+r,this.l=+s,this.opacity=+i}ax(Jr,n6,Oj(Ro,{brighter(e){return e=e==null?Tu:Math.pow(Tu,e),new Jr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vo:Math.pow(vo,e),new Jr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,r=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,i=s+(s<.5?s:1-s)*r,o=2*s-i;return new br(Rh(e>=240?e-240:e+120,o,i),Rh(e,o,i),Rh(e<120?e+240:e-120,o,i),this.opacity)},clamp(){return new Jr(Ey(this.h),tu(this.s),tu(this.l),_u(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=_u(this.opacity);return`${e===1?"hsl(":"hsla("}${Ey(this.h)}, ${tu(this.s)*100}%, ${tu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ey(e){return e=(e||0)%360,e<0?e+360:e}function tu(e){return Math.max(0,Math.min(1,e||0))}function Rh(e,r,s){return(e<60?r+(s-r)*e/60:e<180?s:e<240?r+(s-r)*(240-e)/60:r)*255}const ix=e=>()=>e;function r6(e,r){return function(s){return e+s*r}}function s6(e,r,s){return e=Math.pow(e,s),r=Math.pow(r,s)-e,s=1/s,function(i){return Math.pow(e+i*r,s)}}function a6(e){return(e=+e)==1?zj:function(r,s){return s-r?s6(r,s,e):ix(isNaN(r)?s:r)}}function zj(e,r){var s=r-e;return s?r6(e,s):ix(isNaN(e)?r:e)}const Au=(function e(r){var s=a6(r);function i(o,c){var u=s((o=xm(o)).r,(c=xm(c)).r),f=s(o.g,c.g),m=s(o.b,c.b),h=zj(o.opacity,c.opacity);return function(x){return o.r=u(x),o.g=f(x),o.b=m(x),o.opacity=h(x),o+""}}return i.gamma=e,i})(1);function i6(e,r){r||(r=[]);var s=e?Math.min(r.length,e.length):0,i=r.slice(),o;return function(c){for(o=0;o<s;++o)i[o]=e[o]*(1-c)+r[o]*c;return i}}function l6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function o6(e,r){var s=r?r.length:0,i=e?Math.min(s,e.length):0,o=new Array(i),c=new Array(s),u;for(u=0;u<i;++u)o[u]=ho(e[u],r[u]);for(;u<s;++u)c[u]=r[u];return function(f){for(u=0;u<i;++u)c[u]=o[u](f);return c}}function c6(e,r){var s=new Date;return e=+e,r=+r,function(i){return s.setTime(e*(1-i)+r*i),s}}function fs(e,r){return e=+e,r=+r,function(s){return e*(1-s)+r*s}}function u6(e,r){var s={},i={},o;(e===null||typeof e!="object")&&(e={}),(r===null||typeof r!="object")&&(r={});for(o in r)o in e?s[o]=ho(e[o],r[o]):i[o]=r[o];return function(c){for(o in s)i[o]=s[o](c);return i}}var gm=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,zh=new RegExp(gm.source,"g");function d6(e){return function(){return e}}function f6(e){return function(r){return e(r)+""}}function Lj(e,r){var s=gm.lastIndex=zh.lastIndex=0,i,o,c,u=-1,f=[],m=[];for(e=e+"",r=r+"";(i=gm.exec(e))&&(o=zh.exec(r));)(c=o.index)>s&&(c=r.slice(s,c),f[u]?f[u]+=c:f[++u]=c),(i=i[0])===(o=o[0])?f[u]?f[u]+=o:f[++u]=o:(f[++u]=null,m.push({i:u,x:fs(i,o)})),s=zh.lastIndex;return s<r.length&&(c=r.slice(s),f[u]?f[u]+=c:f[++u]=c),f.length<2?m[0]?f6(m[0].x):d6(r):(r=m.length,function(h){for(var x=0,g;x<r;++x)f[(g=m[x]).i]=g.x(h);return f.join("")})}function ho(e,r){var s=typeof r,i;return r==null||s==="boolean"?ix(r):(s==="number"?fs:s==="string"?(i=Ja(r))?(r=i,Au):Lj:r instanceof Ja?Au:r instanceof Date?c6:l6(r)?i6:Array.isArray(r)?o6:typeof r.valueOf!="function"&&typeof r.toString!="function"||isNaN(r)?u6:fs)(e,r)}var Ty=180/Math.PI,pm={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ij(e,r,s,i,o,c){var u,f,m;return(u=Math.sqrt(e*e+r*r))&&(e/=u,r/=u),(m=e*s+r*i)&&(s-=e*m,i-=r*m),(f=Math.sqrt(s*s+i*i))&&(s/=f,i/=f,m/=f),e*i<r*s&&(e=-e,r=-r,m=-m,u=-u),{translateX:o,translateY:c,rotate:Math.atan2(r,e)*Ty,skewX:Math.atan(m)*Ty,scaleX:u,scaleY:f}}var nu;function h6(e){const r=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return r.isIdentity?pm:Ij(r.a,r.b,r.c,r.d,r.e,r.f)}function m6(e){return e==null||(nu||(nu=document.createElementNS("http://www.w3.org/2000/svg","g")),nu.setAttribute("transform",e),!(e=nu.transform.baseVal.consolidate()))?pm:(e=e.matrix,Ij(e.a,e.b,e.c,e.d,e.e,e.f))}function $j(e,r,s,i){function o(h){return h.length?h.pop()+" ":""}function c(h,x,g,b,p,w){if(h!==g||x!==b){var S=p.push("translate(",null,r,null,s);w.push({i:S-4,x:fs(h,g)},{i:S-2,x:fs(x,b)})}else(g||b)&&p.push("translate("+g+r+b+s)}function u(h,x,g,b){h!==x?(h-x>180?x+=360:x-h>180&&(h+=360),b.push({i:g.push(o(g)+"rotate(",null,i)-2,x:fs(h,x)})):x&&g.push(o(g)+"rotate("+x+i)}function f(h,x,g,b){h!==x?b.push({i:g.push(o(g)+"skewX(",null,i)-2,x:fs(h,x)}):x&&g.push(o(g)+"skewX("+x+i)}function m(h,x,g,b,p,w){if(h!==g||x!==b){var S=p.push(o(p)+"scale(",null,",",null,")");w.push({i:S-4,x:fs(h,g)},{i:S-2,x:fs(x,b)})}else(g!==1||b!==1)&&p.push(o(p)+"scale("+g+","+b+")")}return function(h,x){var g=[],b=[];return h=e(h),x=e(x),c(h.translateX,h.translateY,x.translateX,x.translateY,g,b),u(h.rotate,x.rotate,g,b),f(h.skewX,x.skewX,g,b),m(h.scaleX,h.scaleY,x.scaleX,x.scaleY,g,b),h=x=null,function(p){for(var w=-1,S=b.length,T;++w<S;)g[(T=b[w]).i]=T.x(p);return g.join("")}}}var x6=$j(h6,"px, ","px)","deg)"),g6=$j(m6,", ",")",")"),p6=1e-12;function _y(e){return((e=Math.exp(e))+1/e)/2}function b6(e){return((e=Math.exp(e))-1/e)/2}function y6(e){return((e=Math.exp(2*e))-1)/(e+1)}const hu=(function e(r,s,i){function o(c,u){var f=c[0],m=c[1],h=c[2],x=u[0],g=u[1],b=u[2],p=x-f,w=g-m,S=p*p+w*w,T,E;if(S<p6)E=Math.log(b/h)/r,T=function(Y){return[f+Y*p,m+Y*w,h*Math.exp(r*Y*E)]};else{var C=Math.sqrt(S),N=(b*b-h*h+i*S)/(2*h*s*C),k=(b*b-h*h-i*S)/(2*b*s*C),H=Math.log(Math.sqrt(N*N+1)-N),M=Math.log(Math.sqrt(k*k+1)-k);E=(M-H)/r,T=function(Y){var $=Y*E,X=_y(H),P=h/(s*C)*(X*y6(r*$+H)-b6(H));return[f+P*p,m+P*w,h*X/_y(r*$+H)]}}return T.duration=E*1e3*r/Math.SQRT2,T}return o.rho=function(c){var u=Math.max(.001,+c),f=u*u,m=f*f;return e(u,f,m)},o})(Math.SQRT2,2,4);var Gi=0,io=0,Wl=0,Bj=1e3,Mu,lo,Du=0,Wa=0,Xu=0,wo=typeof performance=="object"&&performance.now?performance:Date,Hj=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function lx(){return Wa||(Hj(v6),Wa=wo.now()+Xu)}function v6(){Wa=0}function Ou(){this._call=this._time=this._next=null}Ou.prototype=Pj.prototype={constructor:Ou,restart:function(e,r,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?lx():+s)+(r==null?0:+r),!this._next&&lo!==this&&(lo?lo._next=this:Mu=this,lo=this),this._call=e,this._time=s,bm()},stop:function(){this._call&&(this._call=null,this._time=1/0,bm())}};function Pj(e,r,s){var i=new Ou;return i.restart(e,r,s),i}function j6(){lx(),++Gi;for(var e=Mu,r;e;)(r=Wa-e._time)>=0&&e._call.call(void 0,r),e=e._next;--Gi}function Ay(){Wa=(Du=wo.now())+Xu,Gi=io=0;try{j6()}finally{Gi=0,N6(),Wa=0}}function w6(){var e=wo.now(),r=e-Du;r>Bj&&(Xu-=r,Du=e)}function N6(){for(var e,r=Mu,s,i=1/0;r;)r._call?(i>r._time&&(i=r._time),e=r,r=r._next):(s=r._next,r._next=null,r=e?e._next=s:Mu=s);lo=e,bm(i)}function bm(e){if(!Gi){io&&(io=clearTimeout(io));var r=e-Wa;r>24?(e<1/0&&(io=setTimeout(Ay,e-wo.now()-Xu)),Wl&&(Wl=clearInterval(Wl))):(Wl||(Du=wo.now(),Wl=setInterval(w6,Bj)),Gi=1,Hj(Ay))}}function My(e,r,s){var i=new Ou;return r=r==null?0:+r,i.restart(o=>{i.stop(),e(o+r)},r,s),i}var k6=Yu("start","end","cancel","interrupt"),S6=[],Uj=0,Dy=1,ym=2,mu=3,Oy=4,vm=5,xu=6;function Zu(e,r,s,i,o,c){var u=e.__transition;if(!u)e.__transition={};else if(s in u)return;C6(e,s,{name:r,index:i,group:o,on:k6,tween:S6,time:c.time,delay:c.delay,duration:c.duration,ease:c.ease,timer:null,state:Uj})}function ox(e,r){var s=rs(e,r);if(s.state>Uj)throw new Error("too late; already scheduled");return s}function ps(e,r){var s=rs(e,r);if(s.state>mu)throw new Error("too late; already running");return s}function rs(e,r){var s=e.__transition;if(!s||!(s=s[r]))throw new Error("transition not found");return s}function C6(e,r,s){var i=e.__transition,o;i[r]=s,s.timer=Pj(c,0,s.time);function c(h){s.state=Dy,s.timer.restart(u,s.delay,s.time),s.delay<=h&&u(h-s.delay)}function u(h){var x,g,b,p;if(s.state!==Dy)return m();for(x in i)if(p=i[x],p.name===s.name){if(p.state===mu)return My(u);p.state===Oy?(p.state=xu,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete i[x]):+x<r&&(p.state=xu,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete i[x])}if(My(function(){s.state===mu&&(s.state=Oy,s.timer.restart(f,s.delay,s.time),f(h))}),s.state=ym,s.on.call("start",e,e.__data__,s.index,s.group),s.state===ym){for(s.state=mu,o=new Array(b=s.tween.length),x=0,g=-1;x<b;++x)(p=s.tween[x].value.call(e,e.__data__,s.index,s.group))&&(o[++g]=p);o.length=g+1}}function f(h){for(var x=h<s.duration?s.ease.call(null,h/s.duration):(s.timer.restart(m),s.state=vm,1),g=-1,b=o.length;++g<b;)o[g].call(e,x);s.state===vm&&(s.on.call("end",e,e.__data__,s.index,s.group),m())}function m(){s.state=xu,s.timer.stop(),delete i[r];for(var h in i)return;delete e.__transition}}function gu(e,r){var s=e.__transition,i,o,c=!0,u;if(s){r=r==null?null:r+"";for(u in s){if((i=s[u]).name!==r){c=!1;continue}o=i.state>ym&&i.state<vm,i.state=xu,i.timer.stop(),i.on.call(o?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete s[u]}c&&delete e.__transition}}function E6(e){return this.each(function(){gu(this,e)})}function T6(e,r){var s,i;return function(){var o=ps(this,e),c=o.tween;if(c!==s){i=s=c;for(var u=0,f=i.length;u<f;++u)if(i[u].name===r){i=i.slice(),i.splice(u,1);break}}o.tween=i}}function _6(e,r,s){var i,o;if(typeof s!="function")throw new Error;return function(){var c=ps(this,e),u=c.tween;if(u!==i){o=(i=u).slice();for(var f={name:r,value:s},m=0,h=o.length;m<h;++m)if(o[m].name===r){o[m]=f;break}m===h&&o.push(f)}c.tween=o}}function A6(e,r){var s=this._id;if(e+="",arguments.length<2){for(var i=rs(this.node(),s).tween,o=0,c=i.length,u;o<c;++o)if((u=i[o]).name===e)return u.value;return null}return this.each((r==null?T6:_6)(s,e,r))}function cx(e,r,s){var i=e._id;return e.each(function(){var o=ps(this,i);(o.value||(o.value={}))[r]=s.apply(this,arguments)}),function(o){return rs(o,i).value[r]}}function qj(e,r){var s;return(typeof r=="number"?fs:r instanceof Ja?Au:(s=Ja(r))?(r=s,Au):Lj)(e,r)}function M6(e){return function(){this.removeAttribute(e)}}function D6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function O6(e,r,s){var i,o=s+"",c;return function(){var u=this.getAttribute(e);return u===o?null:u===i?c:c=r(i=u,s)}}function R6(e,r,s){var i,o=s+"",c;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===i?c:c=r(i=u,s)}}function z6(e,r,s){var i,o,c;return function(){var u,f=s(this),m;return f==null?void this.removeAttribute(e):(u=this.getAttribute(e),m=f+"",u===m?null:u===i&&m===o?c:(o=m,c=r(i=u,f)))}}function L6(e,r,s){var i,o,c;return function(){var u,f=s(this),m;return f==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),m=f+"",u===m?null:u===i&&m===o?c:(o=m,c=r(i=u,f)))}}function I6(e,r){var s=Gu(e),i=s==="transform"?g6:qj;return this.attrTween(e,typeof r=="function"?(s.local?L6:z6)(s,i,cx(this,"attr."+e,r)):r==null?(s.local?D6:M6)(s):(s.local?R6:O6)(s,i,r))}function $6(e,r){return function(s){this.setAttribute(e,r.call(this,s))}}function B6(e,r){return function(s){this.setAttributeNS(e.space,e.local,r.call(this,s))}}function H6(e,r){var s,i;function o(){var c=r.apply(this,arguments);return c!==i&&(s=(i=c)&&B6(e,c)),s}return o._value=r,o}function P6(e,r){var s,i;function o(){var c=r.apply(this,arguments);return c!==i&&(s=(i=c)&&$6(e,c)),s}return o._value=r,o}function U6(e,r){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(r==null)return this.tween(s,null);if(typeof r!="function")throw new Error;var i=Gu(e);return this.tween(s,(i.local?H6:P6)(i,r))}function q6(e,r){return function(){ox(this,e).delay=+r.apply(this,arguments)}}function V6(e,r){return r=+r,function(){ox(this,e).delay=r}}function F6(e){var r=this._id;return arguments.length?this.each((typeof e=="function"?q6:V6)(r,e)):rs(this.node(),r).delay}function Y6(e,r){return function(){ps(this,e).duration=+r.apply(this,arguments)}}function G6(e,r){return r=+r,function(){ps(this,e).duration=r}}function X6(e){var r=this._id;return arguments.length?this.each((typeof e=="function"?Y6:G6)(r,e)):rs(this.node(),r).duration}function Z6(e,r){if(typeof r!="function")throw new Error;return function(){ps(this,e).ease=r}}function Q6(e){var r=this._id;return arguments.length?this.each(Z6(r,e)):rs(this.node(),r).ease}function K6(e,r){return function(){var s=r.apply(this,arguments);if(typeof s!="function")throw new Error;ps(this,e).ease=s}}function J6(e){if(typeof e!="function")throw new Error;return this.each(K6(this._id,e))}function W6(e){typeof e!="function"&&(e=vj(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o<s;++o)for(var c=r[o],u=c.length,f=i[o]=[],m,h=0;h<u;++h)(m=c[h])&&e.call(m,m.__data__,h,c)&&f.push(m);return new $s(i,this._parents,this._name,this._id)}function eM(e){if(e._id!==this._id)throw new Error;for(var r=this._groups,s=e._groups,i=r.length,o=s.length,c=Math.min(i,o),u=new Array(i),f=0;f<c;++f)for(var m=r[f],h=s[f],x=m.length,g=u[f]=new Array(x),b,p=0;p<x;++p)(b=m[p]||h[p])&&(g[p]=b);for(;f<i;++f)u[f]=r[f];return new $s(u,this._parents,this._name,this._id)}function tM(e){return(e+"").trim().split(/^|\s+/).every(function(r){var s=r.indexOf(".");return s>=0&&(r=r.slice(0,s)),!r||r==="start"})}function nM(e,r,s){var i,o,c=tM(r)?ox:ps;return function(){var u=c(this,e),f=u.on;f!==i&&(o=(i=f).copy()).on(r,s),u.on=o}}function rM(e,r){var s=this._id;return arguments.length<2?rs(this.node(),s).on.on(e):this.each(nM(s,e,r))}function sM(e){return function(){var r=this.parentNode;for(var s in this.__transition)if(+s!==e)return;r&&r.removeChild(this)}}function aM(){return this.on("end.remove",sM(this._id))}function iM(e){var r=this._name,s=this._id;typeof e!="function"&&(e=rx(e));for(var i=this._groups,o=i.length,c=new Array(o),u=0;u<o;++u)for(var f=i[u],m=f.length,h=c[u]=new Array(m),x,g,b=0;b<m;++b)(x=f[b])&&(g=e.call(x,x.__data__,b,f))&&("__data__"in x&&(g.__data__=x.__data__),h[b]=g,Zu(h[b],r,s,b,h,rs(x,s)));return new $s(c,this._parents,r,s)}function lM(e){var r=this._name,s=this._id;typeof e!="function"&&(e=yj(e));for(var i=this._groups,o=i.length,c=[],u=[],f=0;f<o;++f)for(var m=i[f],h=m.length,x,g=0;g<h;++g)if(x=m[g]){for(var b=e.call(x,x.__data__,g,m),p,w=rs(x,s),S=0,T=b.length;S<T;++S)(p=b[S])&&Zu(p,r,s,S,b,w);c.push(b),u.push(x)}return new $s(c,u,r,s)}var oM=Oo.prototype.constructor;function cM(){return new oM(this._groups,this._parents)}function uM(e,r){var s,i,o;return function(){var c=Yi(this,e),u=(this.style.removeProperty(e),Yi(this,e));return c===u?null:c===s&&u===i?o:o=r(s=c,i=u)}}function Vj(e){return function(){this.style.removeProperty(e)}}function dM(e,r,s){var i,o=s+"",c;return function(){var u=Yi(this,e);return u===o?null:u===i?c:c=r(i=u,s)}}function fM(e,r,s){var i,o,c;return function(){var u=Yi(this,e),f=s(this),m=f+"";return f==null&&(m=f=(this.style.removeProperty(e),Yi(this,e))),u===m?null:u===i&&m===o?c:(o=m,c=r(i=u,f))}}function hM(e,r){var s,i,o,c="style."+r,u="end."+c,f;return function(){var m=ps(this,e),h=m.on,x=m.value[c]==null?f||(f=Vj(r)):void 0;(h!==s||o!==x)&&(i=(s=h).copy()).on(u,o=x),m.on=i}}function mM(e,r,s){var i=(e+="")=="transform"?x6:qj;return r==null?this.styleTween(e,uM(e,i)).on("end.style."+e,Vj(e)):typeof r=="function"?this.styleTween(e,fM(e,i,cx(this,"style."+e,r))).each(hM(this._id,e)):this.styleTween(e,dM(e,i,r),s).on("end.style."+e,null)}function xM(e,r,s){return function(i){this.style.setProperty(e,r.call(this,i),s)}}function gM(e,r,s){var i,o;function c(){var u=r.apply(this,arguments);return u!==o&&(i=(o=u)&&xM(e,u,s)),i}return c._value=r,c}function pM(e,r,s){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(r==null)return this.tween(i,null);if(typeof r!="function")throw new Error;return this.tween(i,gM(e,r,s??""))}function bM(e){return function(){this.textContent=e}}function yM(e){return function(){var r=e(this);this.textContent=r??""}}function vM(e){return this.tween("text",typeof e=="function"?yM(cx(this,"text",e)):bM(e==null?"":e+""))}function jM(e){return function(r){this.textContent=e.call(this,r)}}function wM(e){var r,s;function i(){var o=e.apply(this,arguments);return o!==s&&(r=(s=o)&&jM(o)),r}return i._value=e,i}function NM(e){var r="text";if(arguments.length<1)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,wM(e))}function kM(){for(var e=this._name,r=this._id,s=Fj(),i=this._groups,o=i.length,c=0;c<o;++c)for(var u=i[c],f=u.length,m,h=0;h<f;++h)if(m=u[h]){var x=rs(m,r);Zu(m,e,s,h,u,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new $s(i,this._parents,e,s)}function SM(){var e,r,s=this,i=s._id,o=s.size();return new Promise(function(c,u){var f={value:u},m={value:function(){--o===0&&c()}};s.each(function(){var h=ps(this,i),x=h.on;x!==e&&(r=(e=x).copy(),r._.cancel.push(f),r._.interrupt.push(f),r._.end.push(m)),h.on=r}),o===0&&c()})}var CM=0;function $s(e,r,s,i){this._groups=e,this._parents=r,this._name=s,this._id=i}function Fj(){return++CM}var Rs=Oo.prototype;$s.prototype={constructor:$s,select:iM,selectAll:lM,selectChild:Rs.selectChild,selectChildren:Rs.selectChildren,filter:W6,merge:eM,selection:cM,transition:kM,call:Rs.call,nodes:Rs.nodes,node:Rs.node,size:Rs.size,empty:Rs.empty,each:Rs.each,on:rM,attr:I6,attrTween:U6,style:mM,styleTween:pM,text:vM,textTween:NM,remove:aM,tween:A6,delay:F6,duration:X6,ease:Q6,easeVarying:J6,end:SM,[Symbol.iterator]:Rs[Symbol.iterator]};function EM(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var TM={time:null,delay:0,duration:250,ease:EM};function _M(e,r){for(var s;!(s=e.__transition)||!(s=s[r]);)if(!(e=e.parentNode))throw new Error(`transition ${r} not found`);return s}function AM(e){var r,s;e instanceof $s?(r=e._id,e=e._name):(r=Fj(),(s=TM).time=lx(),e=e==null?null:e+"");for(var i=this._groups,o=i.length,c=0;c<o;++c)for(var u=i[c],f=u.length,m,h=0;h<f;++h)(m=u[h])&&Zu(m,e,r,h,u,s||_M(m,r));return new $s(i,this._parents,e,r)}Oo.prototype.interrupt=E6;Oo.prototype.transition=AM;const ru=e=>()=>e;function MM(e,{sourceEvent:r,target:s,transform:i,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function Is(e,r,s){this.k=e,this.x=r,this.y=s}Is.prototype={constructor:Is,scale:function(e){return e===1?this:new Is(this.k*e,this.x,this.y)},translate:function(e,r){return e===0&r===0?this:new Is(this.k,this.x+this.k*e,this.y+this.k*r)},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 Qu=new Is(1,0,0);Yj.prototype=Is.prototype;function Yj(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Qu;return e.__zoom}function Lh(e){e.stopImmediatePropagation()}function eo(e){e.preventDefault(),e.stopImmediatePropagation()}function DM(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function OM(){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 Ry(){return this.__zoom||Qu}function RM(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function zM(){return navigator.maxTouchPoints||"ontouchstart"in this}function LM(e,r,s){var i=e.invertX(r[0][0])-s[0][0],o=e.invertX(r[1][0])-s[1][0],c=e.invertY(r[0][1])-s[0][1],u=e.invertY(r[1][1])-s[1][1];return e.translate(o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o),u>c?(c+u)/2:Math.min(0,c)||Math.max(0,u))}function Gj(){var e=DM,r=OM,s=LM,i=RM,o=zM,c=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],f=250,m=hu,h=Yu("start","zoom","end"),x,g,b,p=500,w=150,S=0,T=10;function E(_){_.property("__zoom",Ry).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",X).on("dblclick.zoom",P).filter(o).on("touchstart.zoom",q).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(_,I,A,G){var U=_.selection?_.selection():_;U.property("__zoom",Ry),_!==U?H(_,I,A,G):U.interrupt().each(function(){M(this,arguments).event(G).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},E.scaleBy=function(_,I,A,G){E.scaleTo(_,function(){var U=this.__zoom.k,K=typeof I=="function"?I.apply(this,arguments):I;return U*K},A,G)},E.scaleTo=function(_,I,A,G){E.transform(_,function(){var U=r.apply(this,arguments),K=this.__zoom,B=A==null?k(U):typeof A=="function"?A.apply(this,arguments):A,L=K.invert(B),W=typeof I=="function"?I.apply(this,arguments):I;return s(N(C(K,W),B,L),U,u)},A,G)},E.translateBy=function(_,I,A,G){E.transform(_,function(){return s(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof A=="function"?A.apply(this,arguments):A),r.apply(this,arguments),u)},null,G)},E.translateTo=function(_,I,A,G,U){E.transform(_,function(){var K=r.apply(this,arguments),B=this.__zoom,L=G==null?k(K):typeof G=="function"?G.apply(this,arguments):G;return s(Qu.translate(L[0],L[1]).scale(B.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof A=="function"?-A.apply(this,arguments):-A),K,u)},G,U)};function C(_,I){return I=Math.max(c[0],Math.min(c[1],I)),I===_.k?_:new Is(I,_.x,_.y)}function N(_,I,A){var G=I[0]-A[0]*_.k,U=I[1]-A[1]*_.k;return G===_.x&&U===_.y?_:new Is(_.k,G,U)}function k(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function H(_,I,A,G){_.on("start.zoom",function(){M(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(G).end()}).tween("zoom",function(){var U=this,K=arguments,B=M(U,K).event(G),L=r.apply(U,K),W=A==null?k(L):typeof A=="function"?A.apply(U,K):A,R=Math.max(L[1][0]-L[0][0],L[1][1]-L[0][1]),z=U.__zoom,V=typeof I=="function"?I.apply(U,K):I,Q=m(z.invert(W).concat(R/z.k),V.invert(W).concat(R/V.k));return function(te){if(te===1)te=V;else{var Z=Q(te),ee=R/Z[2];te=new Is(ee,W[0]-Z[0]*ee,W[1]-Z[1]*ee)}B.zoom(null,te)}})}function M(_,I,A){return!A&&_.__zooming||new Y(_,I)}function Y(_,I){this.that=_,this.args=I,this.active=0,this.sourceEvent=null,this.extent=r.apply(_,I),this.taps=0}Y.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,I){return this.mouse&&_!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var I=Ar(this.that).datum();h.call(_,this.that,new MM(_,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:h}),I)}};function $(_,...I){if(!e.apply(this,arguments))return;var A=M(this,I).event(_),G=this.__zoom,U=Math.max(c[0],Math.min(c[1],G.k*Math.pow(2,i.apply(this,arguments)))),K=Kr(_);if(A.wheel)(A.mouse[0][0]!==K[0]||A.mouse[0][1]!==K[1])&&(A.mouse[1]=G.invert(A.mouse[0]=K)),clearTimeout(A.wheel);else{if(G.k===U)return;A.mouse=[K,G.invert(K)],gu(this),A.start()}eo(_),A.wheel=setTimeout(B,w),A.zoom("mouse",s(N(C(G,U),A.mouse[0],A.mouse[1]),A.extent,u));function B(){A.wheel=null,A.end()}}function X(_,...I){if(b||!e.apply(this,arguments))return;var A=_.currentTarget,G=M(this,I,!0).event(_),U=Ar(_.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",R,!0),K=Kr(_,A),B=_.clientX,L=_.clientY;Aj(_.view),Lh(_),G.mouse=[K,this.__zoom.invert(K)],gu(this),G.start();function W(z){if(eo(z),!G.moved){var V=z.clientX-B,Q=z.clientY-L;G.moved=V*V+Q*Q>S}G.event(z).zoom("mouse",s(N(G.that.__zoom,G.mouse[0]=Kr(z,A),G.mouse[1]),G.extent,u))}function R(z){U.on("mousemove.zoom mouseup.zoom",null),Mj(z.view,G.moved),eo(z),G.event(z).end()}}function P(_,...I){if(e.apply(this,arguments)){var A=this.__zoom,G=Kr(_.changedTouches?_.changedTouches[0]:_,this),U=A.invert(G),K=A.k*(_.shiftKey?.5:2),B=s(N(C(A,K),G,U),r.apply(this,I),u);eo(_),f>0?Ar(this).transition().duration(f).call(H,B,G,_):Ar(this).call(E.transform,B,G,_)}}function q(_,...I){if(e.apply(this,arguments)){var A=_.touches,G=A.length,U=M(this,I,_.changedTouches.length===G).event(_),K,B,L,W;for(Lh(_),B=0;B<G;++B)L=A[B],W=Kr(L,this),W=[W,this.__zoom.invert(W),L.identifier],U.touch0?!U.touch1&&U.touch0[2]!==W[2]&&(U.touch1=W,U.taps=0):(U.touch0=W,K=!0,U.taps=1+!!x);x&&(x=clearTimeout(x)),K&&(U.taps<2&&(g=W[0],x=setTimeout(function(){x=null},p)),gu(this),U.start())}}function F(_,...I){if(this.__zooming){var A=M(this,I).event(_),G=_.changedTouches,U=G.length,K,B,L,W;for(eo(_),K=0;K<U;++K)B=G[K],L=Kr(B,this),A.touch0&&A.touch0[2]===B.identifier?A.touch0[0]=L:A.touch1&&A.touch1[2]===B.identifier&&(A.touch1[0]=L);if(B=A.that.__zoom,A.touch1){var R=A.touch0[0],z=A.touch0[1],V=A.touch1[0],Q=A.touch1[1],te=(te=V[0]-R[0])*te+(te=V[1]-R[1])*te,Z=(Z=Q[0]-z[0])*Z+(Z=Q[1]-z[1])*Z;B=C(B,Math.sqrt(te/Z)),L=[(R[0]+V[0])/2,(R[1]+V[1])/2],W=[(z[0]+Q[0])/2,(z[1]+Q[1])/2]}else if(A.touch0)L=A.touch0[0],W=A.touch0[1];else return;A.zoom("touch",s(N(B,L,W),A.extent,u))}}function D(_,...I){if(this.__zooming){var A=M(this,I).event(_),G=_.changedTouches,U=G.length,K,B;for(Lh(_),b&&clearTimeout(b),b=setTimeout(function(){b=null},p),K=0;K<U;++K)B=G[K],A.touch0&&A.touch0[2]===B.identifier?delete A.touch0:A.touch1&&A.touch1[2]===B.identifier&&delete A.touch1;if(A.touch1&&!A.touch0&&(A.touch0=A.touch1,delete A.touch1),A.touch0)A.touch0[1]=this.__zoom.invert(A.touch0[0]);else if(A.end(),A.taps===2&&(B=Kr(B,this),Math.hypot(g[0]-B[0],g[1]-B[1])<T)){var L=Ar(this).on("dblclick.zoom");L&&L.apply(this,arguments)}}}return E.wheelDelta=function(_){return arguments.length?(i=typeof _=="function"?_:ru(+_),E):i},E.filter=function(_){return arguments.length?(e=typeof _=="function"?_:ru(!!_),E):e},E.touchable=function(_){return arguments.length?(o=typeof _=="function"?_:ru(!!_),E):o},E.extent=function(_){return arguments.length?(r=typeof _=="function"?_:ru([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),E):r},E.scaleExtent=function(_){return arguments.length?(c[0]=+_[0],c[1]=+_[1],E):[c[0],c[1]]},E.translateExtent=function(_){return arguments.length?(u[0][0]=+_[0][0],u[1][0]=+_[1][0],u[0][1]=+_[0][1],u[1][1]=+_[1][1],E):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},E.constrain=function(_){return arguments.length?(s=_,E):s},E.duration=function(_){return arguments.length?(f=+_,E):f},E.interpolate=function(_){return arguments.length?(m=_,E):m},E.on=function(){var _=h.on.apply(h,arguments);return _===h?E:_},E.clickDistance=function(_){return arguments.length?(S=(_=+_)*_,E):Math.sqrt(S)},E.tapDistance=function(_){return arguments.length?(T=+_,E):T},E}const ms={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:r,sourceHandle:s,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:i}", edge id: ${r}.`,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."},No=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Xj=["Enter"," ","Escape"],Zj={"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:r,y:s})=>`Moved selected node ${e}. New position, x: ${r}, 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 Xi;(function(e){e.Strict="strict",e.Loose="loose"})(Xi||(Xi={}));var Qa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Qa||(Qa={}));var ko;(function(e){e.Partial="partial",e.Full="full"})(ko||(ko={}));const Qj={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ja;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ja||(ja={}));var Zi;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Zi||(Zi={}));var nt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(nt||(nt={}));const zy={[nt.Left]:nt.Right,[nt.Right]:nt.Left,[nt.Top]:nt.Bottom,[nt.Bottom]:nt.Top};function Kj(e){return e===null?null:e?"valid":"invalid"}const Jj=e=>"id"in e&&"source"in e&&"target"in e,IM=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ux=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),zo=(e,r=[0,0])=>{const{width:s,height:i}=Hs(e),o=e.origin??r,c=s*o[0],u=i*o[1];return{x:e.position.x-c,y:e.position.y-u}},$M=(e,r={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((i,o)=>{const c=typeof o=="string";let u=!r.nodeLookup&&!c?o:void 0;r.nodeLookup&&(u=c?r.nodeLookup.get(o):ux(o)?o:r.nodeLookup.get(o.id));const f=u?Ru(u,r.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ku(i,f)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ju(s)},Lo=(e,r={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(o=>{(r.filter===void 0||r.filter(o))&&(s=Ku(s,Ru(o)),i=!0)}),i?Ju(s):{x:0,y:0,width:0,height:0}},dx=(e,r,[s,i,o]=[0,0,1],c=!1,u=!1)=>{const f={...$o(r,[s,i,o]),width:r.width/o,height:r.height/o},m=[];for(const h of e.values()){const{measured:x,selectable:g=!0,hidden:b=!1}=h;if(u&&!g||b)continue;const p=x.width??h.width??h.initialWidth??null,w=x.height??h.height??h.initialHeight??null,S=So(f,Ki(h)),T=(p??0)*(w??0),E=c&&S>0;(!h.internals.handleBounds||E||S>=T||h.dragging)&&m.push(h)}return m},BM=(e,r)=>{const s=new Set;return e.forEach(i=>{s.add(i.id)}),r.filter(i=>s.has(i.source)||s.has(i.target))};function HM(e,r){const s=new Map,i=r?.nodes?new Set(r.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(r?.includeHiddenNodes||!o.hidden)&&(!i||i.has(o.id))&&s.set(o.id,o)}),s}async function PM({nodes:e,width:r,height:s,panZoom:i,minZoom:o,maxZoom:c},u){if(e.size===0)return Promise.resolve(!0);const f=HM(e,u),m=Lo(f),h=fx(m,r,s,u?.minZoom??o,u?.maxZoom??c,u?.padding??.1);return await i.setViewport(h,{duration:u?.duration,ease:u?.ease,interpolate:u?.interpolate}),Promise.resolve(!0)}function Wj({nodeId:e,nextPosition:r,nodeLookup:s,nodeOrigin:i=[0,0],nodeExtent:o,onError:c}){const u=s.get(e),f=u.parentId?s.get(u.parentId):void 0,{x:m,y:h}=f?f.internals.positionAbsolute:{x:0,y:0},x=u.origin??i;let g=u.extent||o;if(u.extent==="parent"&&!u.expandParent)if(!f)c?.("005",ms.error005());else{const p=f.measured.width,w=f.measured.height;p&&w&&(g=[[m,h],[m+p,h+w]])}else f&&Ji(u.extent)&&(g=[[u.extent[0][0]+m,u.extent[0][1]+h],[u.extent[1][0]+m,u.extent[1][1]+h]]);const b=Ji(g)?ei(r,g,u.measured):r;return(u.measured.width===void 0||u.measured.height===void 0)&&c?.("015",ms.error015()),{position:{x:b.x-m+(u.measured.width??0)*x[0],y:b.y-h+(u.measured.height??0)*x[1]},positionAbsolute:b}}async function UM({nodesToRemove:e=[],edgesToRemove:r=[],nodes:s,edges:i,onBeforeDelete:o}){const c=new Set(e.map(b=>b.id)),u=[];for(const b of s){if(b.deletable===!1)continue;const p=c.has(b.id),w=!p&&b.parentId&&u.find(S=>S.id===b.parentId);(p||w)&&u.push(b)}const f=new Set(r.map(b=>b.id)),m=i.filter(b=>b.deletable!==!1),x=BM(u,m);for(const b of m)f.has(b.id)&&!x.find(w=>w.id===b.id)&&x.push(b);if(!o)return{edges:x,nodes:u};const g=await o({nodes:u,edges:x});return typeof g=="boolean"?g?{edges:x,nodes:u}:{edges:[],nodes:[]}:g}const Qi=(e,r=0,s=1)=>Math.min(Math.max(e,r),s),ei=(e={x:0,y:0},r,s)=>({x:Qi(e.x,r[0][0],r[1][0]-(s?.width??0)),y:Qi(e.y,r[0][1],r[1][1]-(s?.height??0))});function ew(e,r,s){const{width:i,height:o}=Hs(s),{x:c,y:u}=s.internals.positionAbsolute;return ei(e,[[c,u],[c+i,u+o]],r)}const Ly=(e,r,s)=>e<r?Qi(Math.abs(e-r),1,r)/r:e>s?-Qi(Math.abs(e-s),1,r)/r:0,tw=(e,r,s=15,i=40)=>{const o=Ly(e.x,i,r.width-i)*s,c=Ly(e.y,i,r.height-i)*s;return[o,c]},Ku=(e,r)=>({x:Math.min(e.x,r.x),y:Math.min(e.y,r.y),x2:Math.max(e.x2,r.x2),y2:Math.max(e.y2,r.y2)}),jm=({x:e,y:r,width:s,height:i})=>({x:e,y:r,x2:e+s,y2:r+i}),Ju=({x:e,y:r,x2:s,y2:i})=>({x:e,y:r,width:s-e,height:i-r}),Ki=(e,r=[0,0])=>{const{x:s,y:i}=ux(e)?e.internals.positionAbsolute:zo(e,r);return{x:s,y:i,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Ru=(e,r=[0,0])=>{const{x:s,y:i}=ux(e)?e.internals.positionAbsolute:zo(e,r);return{x:s,y:i,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:i+(e.measured?.height??e.height??e.initialHeight??0)}},nw=(e,r)=>Ju(Ku(jm(e),jm(r))),So=(e,r)=>{const s=Math.max(0,Math.min(e.x+e.width,r.x+r.width)-Math.max(e.x,r.x)),i=Math.max(0,Math.min(e.y+e.height,r.y+r.height)-Math.max(e.y,r.y));return Math.ceil(s*i)},Iy=e=>Wr(e.width)&&Wr(e.height)&&Wr(e.x)&&Wr(e.y),Wr=e=>!isNaN(e)&&isFinite(e),qM=(e,r)=>{},Io=(e,r=[1,1])=>({x:r[0]*Math.round(e.x/r[0]),y:r[1]*Math.round(e.y/r[1])}),$o=({x:e,y:r},[s,i,o],c=!1,u=[1,1])=>{const f={x:(e-s)/o,y:(r-i)/o};return c?Io(f,u):f},zu=({x:e,y:r},[s,i,o])=>({x:e*o+s,y:r*o+i});function zi(e,r){if(typeof e=="number")return Math.floor((r-r/(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(r*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 VM(e,r,s){if(typeof e=="string"||typeof e=="number"){const i=zi(e,s),o=zi(e,r);return{top:i,right:o,bottom:i,left:o,x:o*2,y:i*2}}if(typeof e=="object"){const i=zi(e.top??e.y??0,s),o=zi(e.bottom??e.y??0,s),c=zi(e.left??e.x??0,r),u=zi(e.right??e.x??0,r);return{top:i,right:u,bottom:o,left:c,x:c+u,y:i+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function FM(e,r,s,i,o,c){const{x:u,y:f}=zu(e,[r,s,i]),{x:m,y:h}=zu({x:e.x+e.width,y:e.y+e.height},[r,s,i]),x=o-m,g=c-h;return{left:Math.floor(u),top:Math.floor(f),right:Math.floor(x),bottom:Math.floor(g)}}const fx=(e,r,s,i,o,c)=>{const u=VM(c,r,s),f=(r-u.x)/e.width,m=(s-u.y)/e.height,h=Math.min(f,m),x=Qi(h,i,o),g=e.x+e.width/2,b=e.y+e.height/2,p=r/2-g*x,w=s/2-b*x,S=FM(e,p,w,x,r,s),T={left:Math.min(S.left-u.left,0),top:Math.min(S.top-u.top,0),right:Math.min(S.right-u.right,0),bottom:Math.min(S.bottom-u.bottom,0)};return{x:p-T.left+T.right,y:w-T.top+T.bottom,zoom:x}},Co=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ji(e){return e!=null&&e!=="parent"}function Hs(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function rw(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function sw(e,r={width:0,height:0},s,i,o){const c={...e},u=i.get(s);if(u){const f=u.origin||o;c.x+=u.internals.positionAbsolute.x-(r.width??0)*f[0],c.y+=u.internals.positionAbsolute.y-(r.height??0)*f[1]}return c}function $y(e,r){if(e.size!==r.size)return!1;for(const s of e)if(!r.has(s))return!1;return!0}function YM(){let e,r;return{promise:new Promise((i,o)=>{e=i,r=o}),resolve:e,reject:r}}function GM(e){return{...Zj,...e||{}}}function mo(e,{snapGrid:r=[0,0],snapToGrid:s=!1,transform:i,containerBounds:o}){const{x:c,y:u}=es(e),f=$o({x:c-(o?.left??0),y:u-(o?.top??0)},i),{x:m,y:h}=s?Io(f,r):f;return{xSnapped:m,ySnapped:h,...f}}const hx=e=>({width:e.offsetWidth,height:e.offsetHeight}),aw=e=>e?.getRootNode?.()||window?.document,XM=["INPUT","SELECT","TEXTAREA"];function iw(e){const r=e.composedPath?.()?.[0]||e.target;return r?.nodeType!==1?!1:XM.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const lw=e=>"clientX"in e,es=(e,r)=>{const s=lw(e),i=s?e.clientX:e.touches?.[0].clientX,o=s?e.clientY:e.touches?.[0].clientY;return{x:i-(r?.left??0),y:o-(r?.top??0)}},By=(e,r,s,i,o)=>{const c=r.querySelectorAll(`.${e}`);return!c||!c.length?null:Array.from(c).map(u=>{const f=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),type:e,nodeId:o,position:u.getAttribute("data-handlepos"),x:(f.left-s.left)/i,y:(f.top-s.top)/i,...hx(u)}})};function ow({sourceX:e,sourceY:r,targetX:s,targetY:i,sourceControlX:o,sourceControlY:c,targetControlX:u,targetControlY:f}){const m=e*.125+o*.375+u*.375+s*.125,h=r*.125+c*.375+f*.375+i*.125,x=Math.abs(m-e),g=Math.abs(h-r);return[m,h,x,g]}function su(e,r){return e>=0?.5*e:r*25*Math.sqrt(-e)}function Hy({pos:e,x1:r,y1:s,x2:i,y2:o,c}){switch(e){case nt.Left:return[r-su(r-i,c),s];case nt.Right:return[r+su(i-r,c),s];case nt.Top:return[r,s-su(s-o,c)];case nt.Bottom:return[r,s+su(o-s,c)]}}function cw({sourceX:e,sourceY:r,sourcePosition:s=nt.Bottom,targetX:i,targetY:o,targetPosition:c=nt.Top,curvature:u=.25}){const[f,m]=Hy({pos:s,x1:e,y1:r,x2:i,y2:o,c:u}),[h,x]=Hy({pos:c,x1:i,y1:o,x2:e,y2:r,c:u}),[g,b,p,w]=ow({sourceX:e,sourceY:r,targetX:i,targetY:o,sourceControlX:f,sourceControlY:m,targetControlX:h,targetControlY:x});return[`M${e},${r} C${f},${m} ${h},${x} ${i},${o}`,g,b,p,w]}function uw({sourceX:e,sourceY:r,targetX:s,targetY:i}){const o=Math.abs(s-e)/2,c=s<e?s+o:s-o,u=Math.abs(i-r)/2,f=i<r?i+u:i-u;return[c,f,o,u]}function ZM({sourceNode:e,targetNode:r,selected:s=!1,zIndex:i=0,elevateOnSelect:o=!1,zIndexMode:c="basic"}){if(c==="manual")return i;const u=o&&s?i+1e3:i,f=Math.max(e.parentId||o&&e.selected?e.internals.z:0,r.parentId||o&&r.selected?r.internals.z:0);return u+f}function QM({sourceNode:e,targetNode:r,width:s,height:i,transform:o}){const c=Ku(Ru(e),Ru(r));c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u={x:-o[0]/o[2],y:-o[1]/o[2],width:s/o[2],height:i/o[2]};return So(u,Ju(c))>0}const KM=({source:e,sourceHandle:r,target:s,targetHandle:i})=>`xy-edge__${e}${r||""}-${s}${i||""}`,JM=(e,r)=>r.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)),WM=(e,r,s={})=>{if(!e.source||!e.target)return r;const i=s.getEdgeId||KM;let o;return Jj(e)?o={...e}:o={...e,id:i(e)},JM(o,r)?r:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,r.concat(o))};function dw({sourceX:e,sourceY:r,targetX:s,targetY:i}){const[o,c,u,f]=uw({sourceX:e,sourceY:r,targetX:s,targetY:i});return[`M ${e},${r}L ${s},${i}`,o,c,u,f]}const Py={[nt.Left]:{x:-1,y:0},[nt.Right]:{x:1,y:0},[nt.Top]:{x:0,y:-1},[nt.Bottom]:{x:0,y:1}},eD=({source:e,sourcePosition:r=nt.Bottom,target:s})=>r===nt.Left||r===nt.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},Uy=(e,r)=>Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2));function tD({source:e,sourcePosition:r=nt.Bottom,target:s,targetPosition:i=nt.Top,center:o,offset:c,stepPosition:u}){const f=Py[r],m=Py[i],h={x:e.x+f.x*c,y:e.y+f.y*c},x={x:s.x+m.x*c,y:s.y+m.y*c},g=eD({source:h,sourcePosition:r,target:x}),b=g.x!==0?"x":"y",p=g[b];let w=[],S,T;const E={x:0,y:0},C={x:0,y:0},[,,N,k]=uw({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(f[b]*m[b]===-1){b==="x"?(S=o.x??h.x+(x.x-h.x)*u,T=o.y??(h.y+x.y)/2):(S=o.x??(h.x+x.x)/2,T=o.y??h.y+(x.y-h.y)*u);const M=[{x:S,y:h.y},{x:S,y:x.y}],Y=[{x:h.x,y:T},{x:x.x,y:T}];f[b]===p?w=b==="x"?M:Y:w=b==="x"?Y:M}else{const M=[{x:h.x,y:x.y}],Y=[{x:x.x,y:h.y}];if(b==="x"?w=f.x===p?Y:M:w=f.y===p?M:Y,r===i){const F=Math.abs(e[b]-s[b]);if(F<=c){const D=Math.min(c-1,c-F);f[b]===p?E[b]=(h[b]>e[b]?-1:1)*D:C[b]=(x[b]>s[b]?-1:1)*D}}if(r!==i){const F=b==="x"?"y":"x",D=f[b]===m[F],_=h[F]>x[F],I=h[F]<x[F];(f[b]===1&&(!D&&_||D&&I)||f[b]!==1&&(!D&&I||D&&_))&&(w=b==="x"?M:Y)}const $={x:h.x+E.x,y:h.y+E.y},X={x:x.x+C.x,y:x.y+C.y},P=Math.max(Math.abs($.x-w[0].x),Math.abs(X.x-w[0].x)),q=Math.max(Math.abs($.y-w[0].y),Math.abs(X.y-w[0].y));P>=q?(S=($.x+X.x)/2,T=w[0].y):(S=w[0].x,T=($.y+X.y)/2)}return[[e,{x:h.x+E.x,y:h.y+E.y},...w,{x:x.x+C.x,y:x.y+C.y},s],S,T,N,k]}function nD(e,r,s,i){const o=Math.min(Uy(e,r)/2,Uy(r,s)/2,i),{x:c,y:u}=r;if(e.x===c&&c===s.x||e.y===u&&u===s.y)return`L${c} ${u}`;if(e.y===u){const h=e.x<s.x?-1:1,x=e.y<s.y?1:-1;return`L ${c+o*h},${u}Q ${c},${u} ${c},${u+o*x}`}const f=e.x<s.x?1:-1,m=e.y<s.y?-1:1;return`L ${c},${u+o*m}Q ${c},${u} ${c+o*f},${u}`}function wm({sourceX:e,sourceY:r,sourcePosition:s=nt.Bottom,targetX:i,targetY:o,targetPosition:c=nt.Top,borderRadius:u=5,centerX:f,centerY:m,offset:h=20,stepPosition:x=.5}){const[g,b,p,w,S]=tD({source:{x:e,y:r},sourcePosition:s,target:{x:i,y:o},targetPosition:c,center:{x:f,y:m},offset:h,stepPosition:x});return[g.reduce((E,C,N)=>{let k="";return N>0&&N<g.length-1?k=nD(g[N-1],C,g[N+1],u):k=`${N===0?"M":"L"}${C.x} ${C.y}`,E+=k,E},""),b,p,w,S]}function qy(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function rD(e){const{sourceNode:r,targetNode:s}=e;if(!qy(r)||!qy(s))return null;const i=r.internals.handleBounds||Vy(r.handles),o=s.internals.handleBounds||Vy(s.handles),c=Fy(i?.source??[],e.sourceHandle),u=Fy(e.connectionMode===Xi.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!c||!u)return e.onError?.("008",ms.error008(c?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const f=c?.position||nt.Bottom,m=u?.position||nt.Top,h=ti(r,c,f),x=ti(s,u,m);return{sourceX:h.x,sourceY:h.y,targetX:x.x,targetY:x.y,sourcePosition:f,targetPosition:m}}function Vy(e){if(!e)return null;const r=[],s=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?r.push(i):i.type==="target"&&s.push(i);return{source:r,target:s}}function ti(e,r,s=nt.Left,i=!1){const o=(r?.x??0)+e.internals.positionAbsolute.x,c=(r?.y??0)+e.internals.positionAbsolute.y,{width:u,height:f}=r??Hs(e);if(i)return{x:o+u/2,y:c+f/2};switch(r?.position??s){case nt.Top:return{x:o+u/2,y:c};case nt.Right:return{x:o+u,y:c+f/2};case nt.Bottom:return{x:o+u/2,y:c+f};case nt.Left:return{x:o,y:c+f/2}}}function Fy(e,r){return e&&(r?e.find(s=>s.id===r):e[0])||null}function Nm(e,r){return e?typeof e=="string"?e:`${r?`${r}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function sD(e,{id:r,defaultColor:s,defaultMarkerStart:i,defaultMarkerEnd:o}){const c=new Set;return e.reduce((u,f)=>([f.markerStart||i,f.markerEnd||o].forEach(m=>{if(m&&typeof m=="object"){const h=Nm(m,r);c.has(h)||(u.push({id:h,color:m.color||s,...m}),c.add(h))}}),u),[]).sort((u,f)=>u.id.localeCompare(f.id))}const fw=1e3,aD=10,mx={nodeOrigin:[0,0],nodeExtent:No,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},iD={...mx,checkEquality:!0};function xx(e,r){const s={...e};for(const i in r)r[i]!==void 0&&(s[i]=r[i]);return s}function lD(e,r,s){const i=xx(mx,s);for(const o of e.values())if(o.parentId)px(o,e,r,i);else{const c=zo(o,i.nodeOrigin),u=Ji(o.extent)?o.extent:i.nodeExtent,f=ei(c,u,Hs(o));o.internals.positionAbsolute=f}}function oD(e,r){if(!e.handles)return e.measured?r?.internals.handleBounds:void 0;const s=[],i=[];for(const o of e.handles){const c={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(c):o.type==="target"&&i.push(c)}return{source:s,target:i}}function gx(e){return e==="manual"}function km(e,r,s,i={}){const o=xx(iD,i),c={i:0},u=new Map(r),f=o?.elevateNodesOnSelect&&!gx(o.zIndexMode)?fw:0;let m=e.length>0;r.clear(),s.clear();for(const h of e){let x=u.get(h.id);if(o.checkEquality&&h===x?.internals.userNode)r.set(h.id,x);else{const g=zo(h,o.nodeOrigin),b=Ji(h.extent)?h.extent:o.nodeExtent,p=ei(g,b,Hs(h));x={...o.defaults,...h,measured:{width:h.measured?.width,height:h.measured?.height},internals:{positionAbsolute:p,handleBounds:oD(h,x),z:hw(h,f,o.zIndexMode),userNode:h}},r.set(h.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(m=!1),h.parentId&&px(x,r,s,i,c)}return m}function cD(e,r){if(!e.parentId)return;const s=r.get(e.parentId);s?s.set(e.id,e):r.set(e.parentId,new Map([[e.id,e]]))}function px(e,r,s,i,o){const{elevateNodesOnSelect:c,nodeOrigin:u,nodeExtent:f,zIndexMode:m}=xx(mx,i),h=e.parentId,x=r.get(h);if(!x){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}cD(e,s),o&&!x.parentId&&x.internals.rootParentIndex===void 0&&m==="auto"&&(x.internals.rootParentIndex=++o.i,x.internals.z=x.internals.z+o.i*aD),o&&x.internals.rootParentIndex!==void 0&&(o.i=x.internals.rootParentIndex);const g=c&&!gx(m)?fw:0,{x:b,y:p,z:w}=uD(e,x,u,f,g,m),{positionAbsolute:S}=e.internals,T=b!==S.x||p!==S.y;(T||w!==e.internals.z)&&r.set(e.id,{...e,internals:{...e.internals,positionAbsolute:T?{x:b,y:p}:S,z:w}})}function hw(e,r,s){const i=Wr(e.zIndex)?e.zIndex:0;return gx(s)?i:i+(e.selected?r:0)}function uD(e,r,s,i,o,c){const{x:u,y:f}=r.internals.positionAbsolute,m=Hs(e),h=zo(e,s),x=Ji(e.extent)?ei(h,e.extent,m):h;let g=ei({x:u+x.x,y:f+x.y},i,m);e.extent==="parent"&&(g=ew(g,m,r));const b=hw(e,o,c),p=r.internals.z??0;return{x:g.x,y:g.y,z:p>=b?p+1:b}}function bx(e,r,s,i=[0,0]){const o=[],c=new Map;for(const u of e){const f=r.get(u.parentId);if(!f)continue;const m=c.get(u.parentId)?.expandedRect??Ki(f),h=nw(m,u.rect);c.set(u.parentId,{expandedRect:h,parent:f})}return c.size>0&&c.forEach(({expandedRect:u,parent:f},m)=>{const h=f.internals.positionAbsolute,x=Hs(f),g=f.origin??i,b=u.x<h.x?Math.round(Math.abs(h.x-u.x)):0,p=u.y<h.y?Math.round(Math.abs(h.y-u.y)):0,w=Math.max(x.width,Math.round(u.width)),S=Math.max(x.height,Math.round(u.height)),T=(w-x.width)*g[0],E=(S-x.height)*g[1];(b>0||p>0||T||E)&&(o.push({id:m,type:"position",position:{x:f.position.x-b+T,y:f.position.y-p+E}}),s.get(m)?.forEach(C=>{e.some(N=>N.id===C.id)||o.push({id:C.id,type:"position",position:{x:C.position.x+b,y:C.position.y+p}})})),(x.width<u.width||x.height<u.height||b||p)&&o.push({id:m,type:"dimensions",setAttributes:!0,dimensions:{width:w+(b?g[0]*b-T:0),height:S+(p?g[1]*p-E:0)}})}),o}function dD(e,r,s,i,o,c,u){const f=i?.querySelector(".xyflow__viewport");let m=!1;if(!f)return{changes:[],updatedInternals:m};const h=[],x=window.getComputedStyle(f),{m22:g}=new window.DOMMatrixReadOnly(x.transform),b=[];for(const p of e.values()){const w=r.get(p.id);if(!w)continue;if(w.hidden){r.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),m=!0;continue}const S=hx(p.nodeElement),T=w.measured.width!==S.width||w.measured.height!==S.height;if(!!(S.width&&S.height&&(T||!w.internals.handleBounds||p.force))){const C=p.nodeElement.getBoundingClientRect(),N=Ji(w.extent)?w.extent:c;let{positionAbsolute:k}=w.internals;w.parentId&&w.extent==="parent"?k=ew(k,S,r.get(w.parentId)):N&&(k=ei(k,N,S));const H={...w,measured:S,internals:{...w.internals,positionAbsolute:k,handleBounds:{source:By("source",p.nodeElement,C,g,w.id),target:By("target",p.nodeElement,C,g,w.id)}}};r.set(w.id,H),w.parentId&&px(H,r,s,{nodeOrigin:o,zIndexMode:u}),m=!0,T&&(h.push({id:w.id,type:"dimensions",dimensions:S}),w.expandParent&&w.parentId&&b.push({id:w.id,parentId:w.parentId,rect:Ki(H,o)}))}}if(b.length>0){const p=bx(b,r,s,o);h.push(...p)}return{changes:h,updatedInternals:m}}async function fD({delta:e,panZoom:r,transform:s,translateExtent:i,width:o,height:c}){if(!r||!e.x&&!e.y)return Promise.resolve(!1);const u=await r.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[o,c]],i),f=!!u&&(u.x!==s[0]||u.y!==s[1]||u.k!==s[2]);return Promise.resolve(f)}function Yy(e,r,s,i,o,c){let u=o;const f=i.get(u)||new Map;i.set(u,f.set(s,r)),u=`${o}-${e}`;const m=i.get(u)||new Map;if(i.set(u,m.set(s,r)),c){u=`${o}-${e}-${c}`;const h=i.get(u)||new Map;i.set(u,h.set(s,r))}}function mw(e,r,s){e.clear(),r.clear();for(const i of s){const{source:o,target:c,sourceHandle:u=null,targetHandle:f=null}=i,m={edgeId:i.id,source:o,target:c,sourceHandle:u,targetHandle:f},h=`${o}-${u}--${c}-${f}`,x=`${c}-${f}--${o}-${u}`;Yy("source",m,x,e,o,u),Yy("target",m,h,e,c,f),r.set(i.id,i)}}function xw(e,r){if(!e.parentId)return!1;const s=r.get(e.parentId);return s?s.selected?!0:xw(s,r):!1}function Gy(e,r,s){let i=e;do{if(i?.matches?.(r))return!0;if(i===s)return!1;i=i?.parentElement}while(i);return!1}function hD(e,r,s,i){const o=new Map;for(const[c,u]of e)if((u.selected||u.id===i)&&(!u.parentId||!xw(u,e))&&(u.draggable||r&&typeof u.draggable>"u")){const f=e.get(c);f&&o.set(c,{id:c,position:f.position||{x:0,y:0},distance:{x:s.x-f.internals.positionAbsolute.x,y:s.y-f.internals.positionAbsolute.y},extent:f.extent,parentId:f.parentId,origin:f.origin,expandParent:f.expandParent,internals:{positionAbsolute:f.internals.positionAbsolute||{x:0,y:0}},measured:{width:f.measured.width??0,height:f.measured.height??0}})}return o}function Ih({nodeId:e,dragItems:r,nodeLookup:s,dragging:i=!0}){const o=[];for(const[u,f]of r){const m=s.get(u)?.internals.userNode;m&&o.push({...m,position:f.position,dragging:i})}if(!e)return[o[0],o];const c=s.get(e)?.internals.userNode;return[c?{...c,position:r.get(e)?.position||c.position,dragging:i}:o[0],o]}function mD({dragItems:e,snapGrid:r,x:s,y:i}){const o=e.values().next().value;if(!o)return null;const c={x:s-o.distance.x,y:i-o.distance.y},u=Io(c,r);return{x:u.x-c.x,y:u.y-c.y}}function xD({onNodeMouseDown:e,getStoreItems:r,onDragStart:s,onDrag:i,onDragStop:o}){let c={x:null,y:null},u=0,f=new Map,m=!1,h={x:0,y:0},x=null,g=!1,b=null,p=!1,w=!1,S=null;function T({noDragClassName:C,handleSelector:N,domNode:k,isSelectable:H,nodeId:M,nodeClickDistance:Y=0}){b=Ar(k);function $({x:F,y:D}){const{nodeLookup:_,nodeExtent:I,snapGrid:A,snapToGrid:G,nodeOrigin:U,onNodeDrag:K,onSelectionDrag:B,onError:L,updateNodePositions:W}=r();c={x:F,y:D};let R=!1;const z=f.size>1,V=z&&I?jm(Lo(f)):null,Q=z&&G?mD({dragItems:f,snapGrid:A,x:F,y:D}):null;for(const[te,Z]of f){if(!_.has(te))continue;let ee={x:F-Z.distance.x,y:D-Z.distance.y};G&&(ee=Q?{x:Math.round(ee.x+Q.x),y:Math.round(ee.y+Q.y)}:Io(ee,A));let ie=null;if(z&&I&&!Z.extent&&V){const{positionAbsolute:De}=Z.internals,Ie=De.x-V.x+I[0][0],ze=De.x+Z.measured.width-V.x2+I[1][0],Ze=De.y-V.y+I[0][1],Ae=De.y+Z.measured.height-V.y2+I[1][1];ie=[[Ie,Ze],[ze,Ae]]}const{position:je,positionAbsolute:ke}=Wj({nodeId:te,nextPosition:ee,nodeLookup:_,nodeExtent:ie||I,nodeOrigin:U,onError:L});R=R||Z.position.x!==je.x||Z.position.y!==je.y,Z.position=je,Z.internals.positionAbsolute=ke}if(w=w||R,!!R&&(W(f,!0),S&&(i||K||!M&&B))){const[te,Z]=Ih({nodeId:M,dragItems:f,nodeLookup:_});i?.(S,f,te,Z),K?.(S,te,Z),M||B?.(S,Z)}}async function X(){if(!x)return;const{transform:F,panBy:D,autoPanSpeed:_,autoPanOnNodeDrag:I}=r();if(!I){m=!1,cancelAnimationFrame(u);return}const[A,G]=tw(h,x,_);(A!==0||G!==0)&&(c.x=(c.x??0)-A/F[2],c.y=(c.y??0)-G/F[2],await D({x:A,y:G})&&$(c)),u=requestAnimationFrame(X)}function P(F){const{nodeLookup:D,multiSelectionActive:_,nodesDraggable:I,transform:A,snapGrid:G,snapToGrid:U,selectNodesOnDrag:K,onNodeDragStart:B,onSelectionDragStart:L,unselectNodesAndEdges:W}=r();g=!0,(!K||!H)&&!_&&M&&(D.get(M)?.selected||W()),H&&K&&M&&e?.(M);const R=mo(F.sourceEvent,{transform:A,snapGrid:G,snapToGrid:U,containerBounds:x});if(c=R,f=hD(D,I,R,M),f.size>0&&(s||B||!M&&L)){const[z,V]=Ih({nodeId:M,dragItems:f,nodeLookup:D});s?.(F.sourceEvent,f,z,V),B?.(F.sourceEvent,z,V),M||L?.(F.sourceEvent,V)}}const q=Dj().clickDistance(Y).on("start",F=>{const{domNode:D,nodeDragThreshold:_,transform:I,snapGrid:A,snapToGrid:G}=r();x=D?.getBoundingClientRect()||null,p=!1,w=!1,S=F.sourceEvent,_===0&&P(F),c=mo(F.sourceEvent,{transform:I,snapGrid:A,snapToGrid:G,containerBounds:x}),h=es(F.sourceEvent,x)}).on("drag",F=>{const{autoPanOnNodeDrag:D,transform:_,snapGrid:I,snapToGrid:A,nodeDragThreshold:G,nodeLookup:U}=r(),K=mo(F.sourceEvent,{transform:_,snapGrid:I,snapToGrid:A,containerBounds:x});if(S=F.sourceEvent,(F.sourceEvent.type==="touchmove"&&F.sourceEvent.touches.length>1||M&&!U.has(M))&&(p=!0),!p){if(!m&&D&&g&&(m=!0,X()),!g){const B=es(F.sourceEvent,x),L=B.x-h.x,W=B.y-h.y;Math.sqrt(L*L+W*W)>G&&P(F)}(c.x!==K.xSnapped||c.y!==K.ySnapped)&&f&&g&&(h=es(F.sourceEvent,x),$(K))}}).on("end",F=>{if(!(!g||p)&&(m=!1,g=!1,cancelAnimationFrame(u),f.size>0)){const{nodeLookup:D,updateNodePositions:_,onNodeDragStop:I,onSelectionDragStop:A}=r();if(w&&(_(f,!1),w=!1),o||I||!M&&A){const[G,U]=Ih({nodeId:M,dragItems:f,nodeLookup:D,dragging:!1});o?.(F.sourceEvent,f,G,U),I?.(F.sourceEvent,G,U),M||A?.(F.sourceEvent,U)}}}).filter(F=>{const D=F.target;return!F.button&&(!C||!Gy(D,`.${C}`,k))&&(!N||Gy(D,N,k))});b.call(q)}function E(){b?.on(".drag",null)}return{update:T,destroy:E}}function gD(e,r,s){const i=[],o={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const c of r.values())So(o,Ki(c))>0&&i.push(c);return i}const pD=250;function bD(e,r,s,i){let o=[],c=1/0;const u=gD(e,s,r+pD);for(const f of u){const m=[...f.internals.handleBounds?.source??[],...f.internals.handleBounds?.target??[]];for(const h of m){if(i.nodeId===h.nodeId&&i.type===h.type&&i.id===h.id)continue;const{x,y:g}=ti(f,h,h.position,!0),b=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(g-e.y,2));b>r||(b<c?(o=[{...h,x,y:g}],c=b):b===c&&o.push({...h,x,y:g}))}}if(!o.length)return null;if(o.length>1){const f=i.type==="source"?"target":"source";return o.find(m=>m.type===f)??o[0]}return o[0]}function gw(e,r,s,i,o,c=!1){const u=i.get(e);if(!u)return null;const f=o==="strict"?u.internals.handleBounds?.[r]:[...u.internals.handleBounds?.source??[],...u.internals.handleBounds?.target??[]],m=(s?f?.find(h=>h.id===s):f?.[0])??null;return m&&c?{...m,...ti(u,m,m.position,!0)}:m}function pw(e,r){return e||(r?.classList.contains("target")?"target":r?.classList.contains("source")?"source":null)}function yD(e,r){let s=null;return r?s=!0:e&&!r&&(s=!1),s}const bw=()=>!0;function vD(e,{connectionMode:r,connectionRadius:s,handleId:i,nodeId:o,edgeUpdaterType:c,isTarget:u,domNode:f,nodeLookup:m,lib:h,autoPanOnConnect:x,flowId:g,panBy:b,cancelConnection:p,onConnectStart:w,onConnect:S,onConnectEnd:T,isValidConnection:E=bw,onReconnectEnd:C,updateConnection:N,getTransform:k,getFromHandle:H,autoPanSpeed:M,dragThreshold:Y=1,handleDomNode:$}){const X=aw(e.target);let P=0,q;const{x:F,y:D}=es(e),_=pw(c,$),I=f?.getBoundingClientRect();let A=!1;if(!I||!_)return;const G=gw(o,_,i,m,r);if(!G)return;let U=es(e,I),K=!1,B=null,L=!1,W=null;function R(){if(!x||!I)return;const[je,ke]=tw(U,I,M);b({x:je,y:ke}),P=requestAnimationFrame(R)}const z={...G,nodeId:o,type:_,position:G.position},V=m.get(o);let te={inProgress:!0,isValid:null,from:ti(V,z,nt.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:V,to:U,toHandle:null,toPosition:zy[z.position],toNode:null,pointer:U};function Z(){A=!0,N(te),w?.(e,{nodeId:o,handleId:i,handleType:_})}Y===0&&Z();function ee(je){if(!A){const{x:Ae,y:We}=es(je),xt=Ae-F,Lt=We-D;if(!(xt*xt+Lt*Lt>Y*Y))return;Z()}if(!H()||!z){ie(je);return}const ke=k();U=es(je,I),q=bD($o(U,ke,!1,[1,1]),s,m,z),K||(R(),K=!0);const De=yw(je,{handle:q,connectionMode:r,fromNodeId:o,fromHandleId:i,fromType:u?"target":"source",isValidConnection:E,doc:X,lib:h,flowId:g,nodeLookup:m});W=De.handleDomNode,B=De.connection,L=yD(!!q,De.isValid);const Ie=m.get(o),ze=Ie?ti(Ie,z,nt.Left,!0):te.from,Ze={...te,from:ze,isValid:L,to:De.toHandle&&L?zu({x:De.toHandle.x,y:De.toHandle.y},ke):U,toHandle:De.toHandle,toPosition:L&&De.toHandle?De.toHandle.position:zy[z.position],toNode:De.toHandle?m.get(De.toHandle.nodeId):null,pointer:U};N(Ze),te=Ze}function ie(je){if(!("touches"in je&&je.touches.length>0)){if(A){(q||W)&&B&&L&&S?.(B);const{inProgress:ke,...De}=te,Ie={...De,toPosition:te.toHandle?te.toPosition:null};T?.(je,Ie),c&&C?.(je,Ie)}p(),cancelAnimationFrame(P),K=!1,L=!1,B=null,W=null,X.removeEventListener("mousemove",ee),X.removeEventListener("mouseup",ie),X.removeEventListener("touchmove",ee),X.removeEventListener("touchend",ie)}}X.addEventListener("mousemove",ee),X.addEventListener("mouseup",ie),X.addEventListener("touchmove",ee),X.addEventListener("touchend",ie)}function yw(e,{handle:r,connectionMode:s,fromNodeId:i,fromHandleId:o,fromType:c,doc:u,lib:f,flowId:m,isValidConnection:h=bw,nodeLookup:x}){const g=c==="target",b=r?u.querySelector(`.${f}-flow__handle[data-id="${m}-${r?.nodeId}-${r?.id}-${r?.type}"]`):null,{x:p,y:w}=es(e),S=u.elementFromPoint(p,w),T=S?.classList.contains(`${f}-flow__handle`)?S:b,E={handleDomNode:T,isValid:!1,connection:null,toHandle:null};if(T){const C=pw(void 0,T),N=T.getAttribute("data-nodeid"),k=T.getAttribute("data-handleid"),H=T.classList.contains("connectable"),M=T.classList.contains("connectableend");if(!N||!C)return E;const Y={source:g?N:i,sourceHandle:g?k:o,target:g?i:N,targetHandle:g?o:k};E.connection=Y;const X=H&&M&&(s===Xi.Strict?g&&C==="source"||!g&&C==="target":N!==i||k!==o);E.isValid=X&&h(Y),E.toHandle=gw(N,C,k,x,s,!0)}return E}const Sm={onPointerDown:vD,isValid:yw};function jD({domNode:e,panZoom:r,getTransform:s,getViewScale:i}){const o=Ar(e);function c({translateExtent:f,width:m,height:h,zoomStep:x=1,pannable:g=!0,zoomable:b=!0,inversePan:p=!1}){const w=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const k=s(),H=N.sourceEvent.ctrlKey&&Co()?10:1,M=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*x,Y=k[2]*Math.pow(2,M*H);r.scaleTo(Y)};let S=[0,0];const T=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(S=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},E=N=>{const k=s();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const H=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],M=[H[0]-S[0],H[1]-S[1]];S=H;const Y=i()*Math.max(k[2],Math.log(k[2]))*(p?-1:1),$={x:k[0]-M[0]*Y,y:k[1]-M[1]*Y},X=[[0,0],[m,h]];r.setViewportConstrained({x:$.x,y:$.y,zoom:k[2]},X,f)},C=Gj().on("start",T).on("zoom",g?E:null).on("zoom.wheel",b?w:null);o.call(C,{})}function u(){o.on("zoom",null)}return{update:c,destroy:u,pointer:Kr}}const Wu=e=>({x:e.x,y:e.y,zoom:e.k}),$h=({x:e,y:r,zoom:s})=>Qu.translate(e,r).scale(s),Bi=(e,r)=>e.target.closest(`.${r}`),vw=(e,r)=>r===2&&Array.isArray(e)&&e.includes(2),wD=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Bh=(e,r=0,s=wD,i=()=>{})=>{const o=typeof r=="number"&&r>0;return o||i(),o?e.transition().duration(r).ease(s).on("end",i):e},jw=e=>{const r=e.ctrlKey&&Co()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*r};function ND({zoomPanValues:e,noWheelClassName:r,d3Selection:s,d3Zoom:i,panOnScrollMode:o,panOnScrollSpeed:c,zoomOnPinch:u,onPanZoomStart:f,onPanZoom:m,onPanZoomEnd:h}){return x=>{if(Bi(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const g=s.property("__zoom").k||1;if(x.ctrlKey&&u){const T=Kr(x),E=jw(x),C=g*Math.pow(2,E);i.scaleTo(s,C,T,x);return}const b=x.deltaMode===1?20:1;let p=o===Qa.Vertical?0:x.deltaX*b,w=o===Qa.Horizontal?0:x.deltaY*b;!Co()&&x.shiftKey&&o!==Qa.Vertical&&(p=x.deltaY*b,w=0),i.translateBy(s,-(p/g)*c,-(w/g)*c,{internal:!0});const S=Wu(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(m?.(x,S),e.panScrollTimeout=setTimeout(()=>{h?.(x,S),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,f?.(x,S))}}function kD({noWheelClassName:e,preventScrolling:r,d3ZoomHandler:s}){return function(i,o){const c=i.type==="wheel",u=!r&&c&&!i.ctrlKey,f=Bi(i,e);if(i.ctrlKey&&c&&f&&i.preventDefault(),u||f)return null;i.preventDefault(),s.call(this,i,o)}}function SD({zoomPanValues:e,onDraggingChange:r,onPanZoomStart:s}){return i=>{if(i.sourceEvent?.internal)return;const o=Wu(i.transform);e.mouseButton=i.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,i.sourceEvent?.type==="mousedown"&&r(!0),s&&s?.(i.sourceEvent,o)}}function CD({zoomPanValues:e,panOnDrag:r,onPaneContextMenu:s,onTransformChange:i,onPanZoom:o}){return c=>{e.usedRightMouseButton=!!(s&&vw(r,e.mouseButton??0)),c.sourceEvent?.sync||i([c.transform.x,c.transform.y,c.transform.k]),o&&!c.sourceEvent?.internal&&o?.(c.sourceEvent,Wu(c.transform))}}function ED({zoomPanValues:e,panOnDrag:r,panOnScroll:s,onDraggingChange:i,onPanZoomEnd:o,onPaneContextMenu:c}){return u=>{if(!u.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,c&&vw(r,e.mouseButton??0)&&!e.usedRightMouseButton&&u.sourceEvent&&c(u.sourceEvent),e.usedRightMouseButton=!1,i(!1),o)){const f=Wu(u.transform);e.prevViewport=f,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(u.sourceEvent,f)},s?150:0)}}}function TD({zoomActivationKeyPressed:e,zoomOnScroll:r,zoomOnPinch:s,panOnDrag:i,panOnScroll:o,zoomOnDoubleClick:c,userSelectionActive:u,noWheelClassName:f,noPanClassName:m,lib:h,connectionInProgress:x}){return g=>{const b=e||r,p=s&&g.ctrlKey,w=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Bi(g,`${h}-flow__node`)||Bi(g,`${h}-flow__edge`)))return!0;if(!i&&!b&&!o&&!c&&!s||u||x&&!w||Bi(g,f)&&w||Bi(g,m)&&(!w||o&&w&&!e)||!s&&g.ctrlKey&&w)return!1;if(!s&&g.type==="touchstart"&&g.touches?.length>1)return g.preventDefault(),!1;if(!b&&!o&&!p&&w||!i&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(i)&&!i.includes(g.button)&&g.type==="mousedown")return!1;const S=Array.isArray(i)&&i.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||w)&&S}}function _D({domNode:e,minZoom:r,maxZoom:s,translateExtent:i,viewport:o,onPanZoom:c,onPanZoomStart:u,onPanZoomEnd:f,onDraggingChange:m}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=e.getBoundingClientRect(),g=Gj().scaleExtent([r,s]).translateExtent(i),b=Ar(e).call(g);C({x:o.x,y:o.y,zoom:Qi(o.zoom,r,s)},[[0,0],[x.width,x.height]],i);const p=b.on("wheel.zoom"),w=b.on("dblclick.zoom");g.wheelDelta(jw);function S(q,F){return b?new Promise(D=>{g?.interpolate(F?.interpolate==="linear"?ho:hu).transform(Bh(b,F?.duration,F?.ease,()=>D(!0)),q)}):Promise.resolve(!1)}function T({noWheelClassName:q,noPanClassName:F,onPaneContextMenu:D,userSelectionActive:_,panOnScroll:I,panOnDrag:A,panOnScrollMode:G,panOnScrollSpeed:U,preventScrolling:K,zoomOnPinch:B,zoomOnScroll:L,zoomOnDoubleClick:W,zoomActivationKeyPressed:R,lib:z,onTransformChange:V,connectionInProgress:Q,paneClickDistance:te,selectionOnDrag:Z}){_&&!h.isZoomingOrPanning&&E();const ee=I&&!R&&!_;g.clickDistance(Z?1/0:!Wr(te)||te<0?0:te);const ie=ee?ND({zoomPanValues:h,noWheelClassName:q,d3Selection:b,d3Zoom:g,panOnScrollMode:G,panOnScrollSpeed:U,zoomOnPinch:B,onPanZoomStart:u,onPanZoom:c,onPanZoomEnd:f}):kD({noWheelClassName:q,preventScrolling:K,d3ZoomHandler:p});if(b.on("wheel.zoom",ie,{passive:!1}),!_){const ke=SD({zoomPanValues:h,onDraggingChange:m,onPanZoomStart:u});g.on("start",ke);const De=CD({zoomPanValues:h,panOnDrag:A,onPaneContextMenu:!!D,onPanZoom:c,onTransformChange:V});g.on("zoom",De);const Ie=ED({zoomPanValues:h,panOnDrag:A,panOnScroll:I,onPaneContextMenu:D,onPanZoomEnd:f,onDraggingChange:m});g.on("end",Ie)}const je=TD({zoomActivationKeyPressed:R,panOnDrag:A,zoomOnScroll:L,panOnScroll:I,zoomOnDoubleClick:W,zoomOnPinch:B,userSelectionActive:_,noPanClassName:F,noWheelClassName:q,lib:z,connectionInProgress:Q});g.filter(je),W?b.on("dblclick.zoom",w):b.on("dblclick.zoom",null)}function E(){g.on("zoom",null)}async function C(q,F,D){const _=$h(q),I=g?.constrain()(_,F,D);return I&&await S(I),new Promise(A=>A(I))}async function N(q,F){const D=$h(q);return await S(D,F),new Promise(_=>_(D))}function k(q){if(b){const F=$h(q),D=b.property("__zoom");(D.k!==q.zoom||D.x!==q.x||D.y!==q.y)&&g?.transform(b,F,null,{sync:!0})}}function H(){const q=b?Yj(b.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}function M(q,F){return b?new Promise(D=>{g?.interpolate(F?.interpolate==="linear"?ho:hu).scaleTo(Bh(b,F?.duration,F?.ease,()=>D(!0)),q)}):Promise.resolve(!1)}function Y(q,F){return b?new Promise(D=>{g?.interpolate(F?.interpolate==="linear"?ho:hu).scaleBy(Bh(b,F?.duration,F?.ease,()=>D(!0)),q)}):Promise.resolve(!1)}function $(q){g?.scaleExtent(q)}function X(q){g?.translateExtent(q)}function P(q){const F=!Wr(q)||q<0?0:q;g?.clickDistance(F)}return{update:T,destroy:E,setViewport:N,setViewportConstrained:C,getViewport:H,scaleTo:M,scaleBy:Y,setScaleExtent:$,setTranslateExtent:X,syncViewport:k,setClickDistance:P}}var Wi;(function(e){e.Line="line",e.Handle="handle"})(Wi||(Wi={}));function AD({width:e,prevWidth:r,height:s,prevHeight:i,affectsX:o,affectsY:c}){const u=e-r,f=s-i,m=[u>0?1:u<0?-1:0,f>0?1:f<0?-1:0];return u&&o&&(m[0]=m[0]*-1),f&&c&&(m[1]=m[1]*-1),m}function Xy(e){const r=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),i=e.includes("left"),o=e.includes("top");return{isHorizontal:r,isVertical:s,affectsX:i,affectsY:o}}function ga(e,r){return Math.max(0,r-e)}function pa(e,r){return Math.max(0,e-r)}function au(e,r,s){return Math.max(0,r-e,e-s)}function Zy(e,r){return e?!r:r}function MD(e,r,s,i,o,c,u,f){let{affectsX:m,affectsY:h}=r;const{isHorizontal:x,isVertical:g}=r,b=x&&g,{xSnapped:p,ySnapped:w}=s,{minWidth:S,maxWidth:T,minHeight:E,maxHeight:C}=i,{x:N,y:k,width:H,height:M,aspectRatio:Y}=e;let $=Math.floor(x?p-e.pointerX:0),X=Math.floor(g?w-e.pointerY:0);const P=H+(m?-$:$),q=M+(h?-X:X),F=-c[0]*H,D=-c[1]*M;let _=au(P,S,T),I=au(q,E,C);if(u){let U=0,K=0;m&&$<0?U=ga(N+$+F,u[0][0]):!m&&$>0&&(U=pa(N+P+F,u[1][0])),h&&X<0?K=ga(k+X+D,u[0][1]):!h&&X>0&&(K=pa(k+q+D,u[1][1])),_=Math.max(_,U),I=Math.max(I,K)}if(f){let U=0,K=0;m&&$>0?U=pa(N+$,f[0][0]):!m&&$<0&&(U=ga(N+P,f[1][0])),h&&X>0?K=pa(k+X,f[0][1]):!h&&X<0&&(K=ga(k+q,f[1][1])),_=Math.max(_,U),I=Math.max(I,K)}if(o){if(x){const U=au(P/Y,E,C)*Y;if(_=Math.max(_,U),u){let K=0;!m&&!h||m&&!h&&b?K=pa(k+D+P/Y,u[1][1])*Y:K=ga(k+D+(m?$:-$)/Y,u[0][1])*Y,_=Math.max(_,K)}if(f){let K=0;!m&&!h||m&&!h&&b?K=ga(k+P/Y,f[1][1])*Y:K=pa(k+(m?$:-$)/Y,f[0][1])*Y,_=Math.max(_,K)}}if(g){const U=au(q*Y,S,T)/Y;if(I=Math.max(I,U),u){let K=0;!m&&!h||h&&!m&&b?K=pa(N+q*Y+F,u[1][0])/Y:K=ga(N+(h?X:-X)*Y+F,u[0][0])/Y,I=Math.max(I,K)}if(f){let K=0;!m&&!h||h&&!m&&b?K=ga(N+q*Y,f[1][0])/Y:K=pa(N+(h?X:-X)*Y,f[0][0])/Y,I=Math.max(I,K)}}}X=X+(X<0?I:-I),$=$+($<0?_:-_),o&&(b?P>q*Y?X=(Zy(m,h)?-$:$)/Y:$=(Zy(m,h)?-X:X)*Y:x?(X=$/Y,h=m):($=X*Y,m=h));const A=m?N+$:N,G=h?k+X:k;return{width:H+(m?-$:$),height:M+(h?-X:X),x:c[0]*$*(m?-1:1)+A,y:c[1]*X*(h?-1:1)+G}}const ww={width:0,height:0,x:0,y:0},DD={...ww,pointerX:0,pointerY:0,aspectRatio:1};function OD(e){return[[0,0],[e.measured.width,e.measured.height]]}function RD(e,r,s){const i=r.position.x+e.position.x,o=r.position.y+e.position.y,c=e.measured.width??0,u=e.measured.height??0,f=s[0]*c,m=s[1]*u;return[[i-f,o-m],[i+c-f,o+u-m]]}function zD({domNode:e,nodeId:r,getStoreItems:s,onChange:i,onEnd:o}){const c=Ar(e);let u={controlDirection:Xy("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:h,boundaries:x,keepAspectRatio:g,resizeDirection:b,onResizeStart:p,onResize:w,onResizeEnd:S,shouldResize:T}){let E={...ww},C={...DD};u={boundaries:x,resizeDirection:b,keepAspectRatio:g,controlDirection:Xy(h)};let N,k=null,H=[],M,Y,$,X=!1;const P=Dj().on("start",q=>{const{nodeLookup:F,transform:D,snapGrid:_,snapToGrid:I,nodeOrigin:A,paneDomNode:G}=s();if(N=F.get(r),!N)return;k=G?.getBoundingClientRect()??null;const{xSnapped:U,ySnapped:K}=mo(q.sourceEvent,{transform:D,snapGrid:_,snapToGrid:I,containerBounds:k});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},C={...E,pointerX:U,pointerY:K,aspectRatio:E.width/E.height},M=void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(M=F.get(N.parentId),Y=M&&N.extent==="parent"?OD(M):void 0),H=[],$=void 0;for(const[B,L]of F)if(L.parentId===r&&(H.push({id:B,position:{...L.position},extent:L.extent}),L.extent==="parent"||L.expandParent)){const W=RD(L,N,L.origin??A);$?$=[[Math.min(W[0][0],$[0][0]),Math.min(W[0][1],$[0][1])],[Math.max(W[1][0],$[1][0]),Math.max(W[1][1],$[1][1])]]:$=W}p?.(q,{...E})}).on("drag",q=>{const{transform:F,snapGrid:D,snapToGrid:_,nodeOrigin:I}=s(),A=mo(q.sourceEvent,{transform:F,snapGrid:D,snapToGrid:_,containerBounds:k}),G=[];if(!N)return;const{x:U,y:K,width:B,height:L}=E,W={},R=N.origin??I,{width:z,height:V,x:Q,y:te}=MD(C,u.controlDirection,A,u.boundaries,u.keepAspectRatio,R,Y,$),Z=z!==B,ee=V!==L,ie=Q!==U&&Z,je=te!==K&ⅇif(!ie&&!je&&!Z&&!ee)return;if((ie||je||R[0]===1||R[1]===1)&&(W.x=ie?Q:E.x,W.y=je?te:E.y,E.x=W.x,E.y=W.y,H.length>0)){const ze=Q-U,Ze=te-K;for(const Ae of H)Ae.position={x:Ae.position.x-ze+R[0]*(z-B),y:Ae.position.y-Ze+R[1]*(V-L)},G.push(Ae)}if((Z||ee)&&(W.width=Z&&(!u.resizeDirection||u.resizeDirection==="horizontal")?z:E.width,W.height=ee&&(!u.resizeDirection||u.resizeDirection==="vertical")?V:E.height,E.width=W.width,E.height=W.height),M&&N.expandParent){const ze=R[0]*(W.width??0);W.x&&W.x<ze&&(E.x=ze,C.x=C.x-(W.x-ze));const Ze=R[1]*(W.height??0);W.y&&W.y<Ze&&(E.y=Ze,C.y=C.y-(W.y-Ze))}const ke=AD({width:E.width,prevWidth:B,height:E.height,prevHeight:L,affectsX:u.controlDirection.affectsX,affectsY:u.controlDirection.affectsY}),De={...E,direction:ke};T?.(q,De)!==!1&&(X=!0,w?.(q,De),i(W,G))}).on("end",q=>{X&&(S?.(q,{...E}),o?.({...E}),X=!1)});c.call(P)}function m(){c.on(".drag",null)}return{update:f,destroy:m}}var Hh={exports:{}},Ph={},Uh={exports:{}},qh={};var Qy;function LD(){if(Qy)return qh;Qy=1;var e=_o();function r(g,b){return g===b&&(g!==0||1/g===1/b)||g!==g&&b!==b}var s=typeof Object.is=="function"?Object.is:r,i=e.useState,o=e.useEffect,c=e.useLayoutEffect,u=e.useDebugValue;function f(g,b){var p=b(),w=i({inst:{value:p,getSnapshot:b}}),S=w[0].inst,T=w[1];return c(function(){S.value=p,S.getSnapshot=b,m(S)&&T({inst:S})},[g,p,b]),o(function(){return m(S)&&T({inst:S}),g(function(){m(S)&&T({inst:S})})},[g]),u(p),p}function m(g){var b=g.getSnapshot;g=g.value;try{var p=b();return!s(g,p)}catch{return!0}}function h(g,b){return b()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return qh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,qh}var Ky;function ID(){return Ky||(Ky=1,Uh.exports=LD()),Uh.exports}var Jy;function $D(){if(Jy)return Ph;Jy=1;var e=_o(),r=ID();function s(h,x){return h===x&&(h!==0||1/h===1/x)||h!==h&&x!==x}var i=typeof Object.is=="function"?Object.is:s,o=r.useSyncExternalStore,c=e.useRef,u=e.useEffect,f=e.useMemo,m=e.useDebugValue;return Ph.useSyncExternalStoreWithSelector=function(h,x,g,b,p){var w=c(null);if(w.current===null){var S={hasValue:!1,value:null};w.current=S}else S=w.current;w=f(function(){function E(M){if(!C){if(C=!0,N=M,M=b(M),p!==void 0&&S.hasValue){var Y=S.value;if(p(Y,M))return k=Y}return k=M}if(Y=k,i(N,M))return Y;var $=b(M);return p!==void 0&&p(Y,$)?(N=M,Y):(N=M,k=$)}var C=!1,N,k,H=g===void 0?null:g;return[function(){return E(x())},H===null?void 0:function(){return E(H())}]},[x,g,b,p]);var T=o(h,w[0],w[1]);return u(function(){S.hasValue=!0,S.value=T},[T]),m(T),T},Ph}var Wy;function BD(){return Wy||(Wy=1,Hh.exports=$D()),Hh.exports}var HD=BD();const PD=Bu(HD),UD={},ev=e=>{let r;const s=new Set,i=(x,g)=>{const b=typeof x=="function"?x(r):x;if(!Object.is(b,r)){const p=r;r=g??(typeof b!="object"||b===null)?b:Object.assign({},r,b),s.forEach(w=>w(r,p))}},o=()=>r,m={setState:i,getState:o,getInitialState:()=>h,subscribe:x=>(s.add(x),()=>s.delete(x)),destroy:()=>{(UD?"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()}},h=r=e(i,o,m);return m},qD=e=>e?ev(e):ev,{useDebugValue:VD}=y2,{useSyncExternalStoreWithSelector:FD}=PD,YD=e=>e;function Nw(e,r=YD,s){const i=FD(e.subscribe,e.getState,e.getServerState||e.getInitialState,r,s);return VD(i),i}const tv=(e,r)=>{const s=qD(e),i=(o,c=r)=>Nw(s,o,c);return Object.assign(i,s),i},GD=(e,r)=>e?tv(e,r):tv;function bn(e,r){if(Object.is(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(const[i,o]of e)if(!Object.is(o,r.get(i)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(const i of e)if(!r.has(i))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(r).length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(r,i)||!Object.is(e[i],r[i]))return!1;return!0}const ed=j.createContext(null),XD=ed.Provider,kw=ms.error001();function Vt(e,r){const s=j.useContext(ed);if(s===null)throw new Error(kw);return Nw(s,e,r)}function yn(){const e=j.useContext(ed);if(e===null)throw new Error(kw);return j.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nv={display:"none"},ZD={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Sw="react-flow__node-desc",Cw="react-flow__edge-desc",QD="react-flow__aria-live",KD=e=>e.ariaLiveMessage,JD=e=>e.ariaLabelConfig;function WD({rfId:e}){const r=Vt(KD);return t.jsx("div",{id:`${QD}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ZD,children:r})}function eO({rfId:e,disableKeyboardA11y:r}){const s=Vt(JD);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${Sw}-${e}`,style:nv,children:r?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${Cw}-${e}`,style:nv,children:s["edge.a11yDescription.default"]}),!r&&t.jsx(WD,{rfId:e})]})}const td=j.forwardRef(({position:e="top-left",children:r,className:s,style:i,...o},c)=>{const u=`${e}`.split("-");return t.jsx("div",{className:Pn(["react-flow__panel",s,...u]),style:i,ref:c,...o,children:r})});td.displayName="Panel";function tO({proOptions:e,position:r="bottom-right"}){return e?.hideAttribution?null:t.jsx(td,{position:r,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 nO=e=>{const r=[],s=[];for(const[,i]of e.nodeLookup)i.selected&&r.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&s.push(i);return{selectedNodes:r,selectedEdges:s}},iu=e=>e.id;function rO(e,r){return bn(e.selectedNodes.map(iu),r.selectedNodes.map(iu))&&bn(e.selectedEdges.map(iu),r.selectedEdges.map(iu))}function sO({onSelectionChange:e}){const r=yn(),{selectedNodes:s,selectedEdges:i}=Vt(nO,rO);return j.useEffect(()=>{const o={nodes:s,edges:i};e?.(o),r.getState().onSelectionChangeHandlers.forEach(c=>c(o))},[s,i,e]),null}const aO=e=>!!e.onSelectionChangeHandlers;function iO({onSelectionChange:e}){const r=Vt(aO);return e||r?t.jsx(sO,{onSelectionChange:e}):null}const Ew=[0,0],lO={x:0,y:0,zoom:1},oO=["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"],rv=[...oO,"rfId"],cO=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}),sv={translateExtent:No,nodeOrigin:Ew,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function uO(e){const{setNodes:r,setEdges:s,setMinZoom:i,setMaxZoom:o,setTranslateExtent:c,setNodeExtent:u,reset:f,setDefaultNodesAndEdges:m}=Vt(cO,bn),h=yn();j.useEffect(()=>(m(e.defaultNodes,e.defaultEdges),()=>{x.current=sv,f()}),[]);const x=j.useRef(sv);return j.useEffect(()=>{for(const g of rv){const b=e[g],p=x.current[g];b!==p&&(typeof e[g]>"u"||(g==="nodes"?r(b):g==="edges"?s(b):g==="minZoom"?i(b):g==="maxZoom"?o(b):g==="translateExtent"?c(b):g==="nodeExtent"?u(b):g==="ariaLabelConfig"?h.setState({ariaLabelConfig:GM(b)}):g==="fitView"?h.setState({fitViewQueued:b}):g==="fitViewOptions"?h.setState({fitViewOptions:b}):h.setState({[g]:b})))}x.current=e},rv.map(g=>e[g])),null}function av(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function dO(e){const[r,s]=j.useState(e==="system"?null:e);return j.useEffect(()=>{if(e!=="system"){s(e);return}const i=av(),o=()=>s(i?.matches?"dark":"light");return o(),i?.addEventListener("change",o),()=>{i?.removeEventListener("change",o)}},[e]),r!==null?r:av()?.matches?"dark":"light"}const iv=typeof document<"u"?document:null;function Eo(e=null,r={target:iv,actInsideInputWithModifier:!0}){const[s,i]=j.useState(!1),o=j.useRef(!1),c=j.useRef(new Set([])),[u,f]=j.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(g=>typeof g=="string").map(g=>g.replace("+",`
|
|
56
|
-
`).replace(`
|
|
57
|
-
|
|
58
|
-
`,`
|
|
59
|
-
+`).split(`
|
|
60
|
-
`)),x=h.reduce((g,b)=>g.concat(...b),[]);return[h,x]}return[[],[]]},[e]);return j.useEffect(()=>{const m=r?.target??iv,h=r?.actInsideInputWithModifier??!0;if(e!==null){const x=p=>{if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!h)&&iw(p))return!1;const S=ov(p.code,f);if(c.current.add(p[S]),lv(u,c.current,!1)){const T=p.composedPath?.()?.[0]||p.target,E=T?.nodeName==="BUTTON"||T?.nodeName==="A";r.preventDefault!==!1&&(o.current||!E)&&p.preventDefault(),i(!0)}},g=p=>{const w=ov(p.code,f);lv(u,c.current,!0)?(i(!1),c.current.clear()):c.current.delete(p[w]),p.key==="Meta"&&c.current.clear(),o.current=!1},b=()=>{c.current.clear(),i(!1)};return m?.addEventListener("keydown",x),m?.addEventListener("keyup",g),window.addEventListener("blur",b),window.addEventListener("contextmenu",b),()=>{m?.removeEventListener("keydown",x),m?.removeEventListener("keyup",g),window.removeEventListener("blur",b),window.removeEventListener("contextmenu",b)}}},[e,i]),s}function lv(e,r,s){return e.filter(i=>s||i.length===r.size).some(i=>i.every(o=>r.has(o)))}function ov(e,r){return r.includes(e)?"code":"key"}const fO=()=>{const e=yn();return j.useMemo(()=>({zoomIn:r=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1.2,{duration:r?.duration}):Promise.resolve(!1)},zoomOut:r=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1/1.2,{duration:r?.duration}):Promise.resolve(!1)},zoomTo:(r,s)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(r,{duration:s?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(r,s)=>{const{transform:[i,o,c],panZoom:u}=e.getState();return u?(await u.setViewport({x:r.x??i,y:r.y??o,zoom:r.zoom??c},s),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[r,s,i]=e.getState().transform;return{x:r,y:s,zoom:i}},setCenter:async(r,s,i)=>e.getState().setCenter(r,s,i),fitBounds:async(r,s)=>{const{width:i,height:o,minZoom:c,maxZoom:u,panZoom:f}=e.getState(),m=fx(r,i,o,c,u,s?.padding??.1);return f?(await f.setViewport(m,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(r,s={})=>{const{transform:i,snapGrid:o,snapToGrid:c,domNode:u}=e.getState();if(!u)return r;const{x:f,y:m}=u.getBoundingClientRect(),h={x:r.x-f,y:r.y-m},x=s.snapGrid??o,g=s.snapToGrid??c;return $o(h,i,g,x)},flowToScreenPosition:r=>{const{transform:s,domNode:i}=e.getState();if(!i)return r;const{x:o,y:c}=i.getBoundingClientRect(),u=zu(r,s);return{x:u.x+o,y:u.y+c}}}),[])};function Tw(e,r){const s=[],i=new Map,o=[];for(const c of e)if(c.type==="add"){o.push(c);continue}else if(c.type==="remove"||c.type==="replace")i.set(c.id,[c]);else{const u=i.get(c.id);u?u.push(c):i.set(c.id,[c])}for(const c of r){const u=i.get(c.id);if(!u){s.push(c);continue}if(u[0].type==="remove")continue;if(u[0].type==="replace"){s.push({...u[0].item});continue}const f={...c};for(const m of u)hO(m,f);s.push(f)}return o.length&&o.forEach(c=>{c.index!==void 0?s.splice(c.index,0,{...c.item}):s.push({...c.item})}),s}function hO(e,r){switch(e.type){case"select":{r.selected=e.selected;break}case"position":{typeof e.position<"u"&&(r.position=e.position),typeof e.dragging<"u"&&(r.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(r.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(r.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(r.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(r.resizing=e.resizing);break}}}function _w(e,r){return Tw(e,r)}function Aw(e,r){return Tw(e,r)}function Ya(e,r){return{id:e,type:"select",selected:r}}function Hi(e,r=new Set,s=!1){const i=[];for(const[o,c]of e){const u=r.has(o);!(c.selected===void 0&&!u)&&c.selected!==u&&(s&&(c.selected=u),i.push(Ya(c.id,u)))}return i}function cv({items:e=[],lookup:r}){const s=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,c]of e.entries()){const u=r.get(c.id),f=u?.internals?.userNode??u;f!==void 0&&f!==c&&s.push({id:c.id,item:c,type:"replace"}),f===void 0&&s.push({item:c,type:"add",index:o})}for(const[o]of r)i.get(o)===void 0&&s.push({id:o,type:"remove"});return s}function uv(e){return{id:e.id,type:"remove"}}const dv=e=>IM(e),mO=e=>Jj(e);function Mw(e){return j.forwardRef(e)}const xO=typeof window<"u"?j.useLayoutEffect:j.useEffect;function fv(e){const[r,s]=j.useState(BigInt(0)),[i]=j.useState(()=>gO(()=>s(o=>o+BigInt(1))));return xO(()=>{const o=i.get();o.length&&(e(o),i.reset())},[r]),i}function gO(e){let r=[];return{get:()=>r,reset:()=>{r=[]},push:s=>{r.push(s),e()}}}const Dw=j.createContext(null);function pO({children:e}){const r=yn(),s=j.useCallback(f=>{const{nodes:m=[],setNodes:h,hasDefaultNodes:x,onNodesChange:g,nodeLookup:b,fitViewQueued:p,onNodesChangeMiddlewareMap:w}=r.getState();let S=m;for(const E of f)S=typeof E=="function"?E(S):E;let T=cv({items:S,lookup:b});for(const E of w.values())T=E(T);x&&h(S),T.length>0?g?.(T):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:C,setNodes:N}=r.getState();E&&N(C)})},[]),i=fv(s),o=j.useCallback(f=>{const{edges:m=[],setEdges:h,hasDefaultEdges:x,onEdgesChange:g,edgeLookup:b}=r.getState();let p=m;for(const w of f)p=typeof w=="function"?w(p):w;x?h(p):g&&g(cv({items:p,lookup:b}))},[]),c=fv(o),u=j.useMemo(()=>({nodeQueue:i,edgeQueue:c}),[]);return t.jsx(Dw.Provider,{value:u,children:e})}function bO(){const e=j.useContext(Dw);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const yO=e=>!!e.panZoom;function yx(){const e=fO(),r=yn(),s=bO(),i=Vt(yO),o=j.useMemo(()=>{const c=g=>r.getState().nodeLookup.get(g),u=g=>{s.nodeQueue.push(g)},f=g=>{s.edgeQueue.push(g)},m=g=>{const{nodeLookup:b,nodeOrigin:p}=r.getState(),w=dv(g)?g:b.get(g.id),S=w.parentId?sw(w.position,w.measured,w.parentId,b,p):w.position,T={...w,position:S,width:w.measured?.width??w.width,height:w.measured?.height??w.height};return Ki(T)},h=(g,b,p={replace:!1})=>{u(w=>w.map(S=>{if(S.id===g){const T=typeof b=="function"?b(S):b;return p.replace&&dv(T)?T:{...S,...T}}return S}))},x=(g,b,p={replace:!1})=>{f(w=>w.map(S=>{if(S.id===g){const T=typeof b=="function"?b(S):b;return p.replace&&mO(T)?T:{...S,...T}}return S}))};return{getNodes:()=>r.getState().nodes.map(g=>({...g})),getNode:g=>c(g)?.internals.userNode,getInternalNode:c,getEdges:()=>{const{edges:g=[]}=r.getState();return g.map(b=>({...b}))},getEdge:g=>r.getState().edgeLookup.get(g),setNodes:u,setEdges:f,addNodes:g=>{const b=Array.isArray(g)?g:[g];s.nodeQueue.push(p=>[...p,...b])},addEdges:g=>{const b=Array.isArray(g)?g:[g];s.edgeQueue.push(p=>[...p,...b])},toObject:()=>{const{nodes:g=[],edges:b=[],transform:p}=r.getState(),[w,S,T]=p;return{nodes:g.map(E=>({...E})),edges:b.map(E=>({...E})),viewport:{x:w,y:S,zoom:T}}},deleteElements:async({nodes:g=[],edges:b=[]})=>{const{nodes:p,edges:w,onNodesDelete:S,onEdgesDelete:T,triggerNodeChanges:E,triggerEdgeChanges:C,onDelete:N,onBeforeDelete:k}=r.getState(),{nodes:H,edges:M}=await UM({nodesToRemove:g,edgesToRemove:b,nodes:p,edges:w,onBeforeDelete:k}),Y=M.length>0,$=H.length>0;if(Y){const X=M.map(uv);T?.(M),C(X)}if($){const X=H.map(uv);S?.(H),E(X)}return($||Y)&&N?.({nodes:H,edges:M}),{deletedNodes:H,deletedEdges:M}},getIntersectingNodes:(g,b=!0,p)=>{const w=Iy(g),S=w?g:m(g),T=p!==void 0;return S?(p||r.getState().nodes).filter(E=>{const C=r.getState().nodeLookup.get(E.id);if(C&&!w&&(E.id===g.id||!C.internals.positionAbsolute))return!1;const N=Ki(T?E:C),k=So(N,S);return b&&k>0||k>=N.width*N.height||k>=S.width*S.height}):[]},isNodeIntersecting:(g,b,p=!0)=>{const S=Iy(g)?g:m(g);if(!S)return!1;const T=So(S,b);return p&&T>0||T>=b.width*b.height||T>=S.width*S.height},updateNode:h,updateNodeData:(g,b,p={replace:!1})=>{h(g,w=>{const S=typeof b=="function"?b(w):b;return p.replace?{...w,data:S}:{...w,data:{...w.data,...S}}},p)},updateEdge:x,updateEdgeData:(g,b,p={replace:!1})=>{x(g,w=>{const S=typeof b=="function"?b(w):b;return p.replace?{...w,data:S}:{...w,data:{...w.data,...S}}},p)},getNodesBounds:g=>{const{nodeLookup:b,nodeOrigin:p}=r.getState();return $M(g,{nodeLookup:b,nodeOrigin:p})},getHandleConnections:({type:g,id:b,nodeId:p})=>Array.from(r.getState().connectionLookup.get(`${p}-${g}${b?`-${b}`:""}`)?.values()??[]),getNodeConnections:({type:g,handleId:b,nodeId:p})=>Array.from(r.getState().connectionLookup.get(`${p}${g?b?`-${g}-${b}`:`-${g}`:""}`)?.values()??[]),fitView:async g=>{const b=r.getState().fitViewResolver??YM();return r.setState({fitViewQueued:!0,fitViewOptions:g,fitViewResolver:b}),s.nodeQueue.push(p=>[...p]),b.promise}}},[]);return j.useMemo(()=>({...o,...e,viewportInitialized:i}),[i])}const hv=e=>e.selected,vO=typeof window<"u"?window:void 0;function jO({deleteKeyCode:e,multiSelectionKeyCode:r}){const s=yn(),{deleteElements:i}=yx(),o=Eo(e,{actInsideInputWithModifier:!1}),c=Eo(r,{target:vO});j.useEffect(()=>{if(o){const{edges:u,nodes:f}=s.getState();i({nodes:f.filter(hv),edges:u.filter(hv)}),s.setState({nodesSelectionActive:!1})}},[o]),j.useEffect(()=>{s.setState({multiSelectionActive:c})},[c])}function wO(e){const r=yn();j.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const i=hx(e.current);(i.height===0||i.width===0)&&r.getState().onError?.("004",ms.error004()),r.setState({width:i.width||500,height:i.height||500})};if(e.current){s(),window.addEventListener("resize",s);const i=new ResizeObserver(()=>s());return i.observe(e.current),()=>{window.removeEventListener("resize",s),i&&e.current&&i.unobserve(e.current)}}},[])}const nd={position:"absolute",width:"100%",height:"100%",top:0,left:0},NO=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function kO({onPaneContextMenu:e,zoomOnScroll:r=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:o=.5,panOnScrollMode:c=Qa.Free,zoomOnDoubleClick:u=!0,panOnDrag:f=!0,defaultViewport:m,translateExtent:h,minZoom:x,maxZoom:g,zoomActivationKeyCode:b,preventScrolling:p=!0,children:w,noWheelClassName:S,noPanClassName:T,onViewportChange:E,isControlledViewport:C,paneClickDistance:N,selectionOnDrag:k}){const H=yn(),M=j.useRef(null),{userSelectionActive:Y,lib:$,connectionInProgress:X}=Vt(NO,bn),P=Eo(b),q=j.useRef();wO(M);const F=j.useCallback(D=>{E?.({x:D[0],y:D[1],zoom:D[2]}),C||H.setState({transform:D})},[E,C]);return j.useEffect(()=>{if(M.current){q.current=_D({domNode:M.current,minZoom:x,maxZoom:g,translateExtent:h,viewport:m,onDraggingChange:A=>H.setState(G=>G.paneDragging===A?G:{paneDragging:A}),onPanZoomStart:(A,G)=>{const{onViewportChangeStart:U,onMoveStart:K}=H.getState();K?.(A,G),U?.(G)},onPanZoom:(A,G)=>{const{onViewportChange:U,onMove:K}=H.getState();K?.(A,G),U?.(G)},onPanZoomEnd:(A,G)=>{const{onViewportChangeEnd:U,onMoveEnd:K}=H.getState();K?.(A,G),U?.(G)}});const{x:D,y:_,zoom:I}=q.current.getViewport();return H.setState({panZoom:q.current,transform:[D,_,I],domNode:M.current.closest(".react-flow")}),()=>{q.current?.destroy()}}},[]),j.useEffect(()=>{q.current?.update({onPaneContextMenu:e,zoomOnScroll:r,zoomOnPinch:s,panOnScroll:i,panOnScrollSpeed:o,panOnScrollMode:c,zoomOnDoubleClick:u,panOnDrag:f,zoomActivationKeyPressed:P,preventScrolling:p,noPanClassName:T,userSelectionActive:Y,noWheelClassName:S,lib:$,onTransformChange:F,connectionInProgress:X,selectionOnDrag:k,paneClickDistance:N})},[e,r,s,i,o,c,u,f,P,p,T,Y,S,$,F,X,k,N]),t.jsx("div",{className:"react-flow__renderer",ref:M,style:nd,children:w})}const SO=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function CO(){const{userSelectionActive:e,userSelectionRect:r}=Vt(SO,bn);return e&&r?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Vh=(e,r)=>s=>{s.target===r.current&&e?.(s)},EO=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function TO({isSelecting:e,selectionKeyPressed:r,selectionMode:s=ko.Full,panOnDrag:i,paneClickDistance:o,selectionOnDrag:c,onSelectionStart:u,onSelectionEnd:f,onPaneClick:m,onPaneContextMenu:h,onPaneScroll:x,onPaneMouseEnter:g,onPaneMouseMove:b,onPaneMouseLeave:p,children:w}){const S=yn(),{userSelectionActive:T,elementsSelectable:E,dragging:C,connectionInProgress:N}=Vt(EO,bn),k=E&&(e||T),H=j.useRef(null),M=j.useRef(),Y=j.useRef(new Set),$=j.useRef(new Set),X=j.useRef(!1),P=U=>{if(X.current||N){X.current=!1;return}m?.(U),S.getState().resetSelectedElements(),S.setState({nodesSelectionActive:!1})},q=U=>{if(Array.isArray(i)&&i?.includes(2)){U.preventDefault();return}h?.(U)},F=x?U=>x(U):void 0,D=U=>{X.current&&(U.stopPropagation(),X.current=!1)},_=U=>{const{domNode:K}=S.getState();if(M.current=K?.getBoundingClientRect(),!M.current)return;const B=U.target===H.current;if(!B&&!!U.target.closest(".nokey")||!e||!(c&&B||r)||U.button!==0||!U.isPrimary)return;U.target?.setPointerCapture?.(U.pointerId),X.current=!1;const{x:R,y:z}=es(U.nativeEvent,M.current);S.setState({userSelectionRect:{width:0,height:0,startX:R,startY:z,x:R,y:z}}),B||(U.stopPropagation(),U.preventDefault())},I=U=>{const{userSelectionRect:K,transform:B,nodeLookup:L,edgeLookup:W,connectionLookup:R,triggerNodeChanges:z,triggerEdgeChanges:V,defaultEdgeOptions:Q,resetSelectedElements:te}=S.getState();if(!M.current||!K)return;const{x:Z,y:ee}=es(U.nativeEvent,M.current),{startX:ie,startY:je}=K;if(!X.current){const Ze=r?0:o;if(Math.hypot(Z-ie,ee-je)<=Ze)return;te(),u?.(U)}X.current=!0;const ke={startX:ie,startY:je,x:Z<ie?Z:ie,y:ee<je?ee:je,width:Math.abs(Z-ie),height:Math.abs(ee-je)},De=Y.current,Ie=$.current;Y.current=new Set(dx(L,ke,B,s===ko.Partial,!0).map(Ze=>Ze.id)),$.current=new Set;const ze=Q?.selectable??!0;for(const Ze of Y.current){const Ae=R.get(Ze);if(Ae)for(const{edgeId:We}of Ae.values()){const xt=W.get(We);xt&&(xt.selectable??ze)&&$.current.add(We)}}if(!$y(De,Y.current)){const Ze=Hi(L,Y.current,!0);z(Ze)}if(!$y(Ie,$.current)){const Ze=Hi(W,$.current);V(Ze)}S.setState({userSelectionRect:ke,userSelectionActive:!0,nodesSelectionActive:!1})},A=U=>{U.button===0&&(U.target?.releasePointerCapture?.(U.pointerId),!T&&U.target===H.current&&S.getState().userSelectionRect&&P?.(U),S.setState({userSelectionActive:!1,userSelectionRect:null}),X.current&&(f?.(U),S.setState({nodesSelectionActive:Y.current.size>0})))},G=i===!0||Array.isArray(i)&&i.includes(0);return t.jsxs("div",{className:Pn(["react-flow__pane",{draggable:G,dragging:C,selection:e}]),onClick:k?void 0:Vh(P,H),onContextMenu:Vh(q,H),onWheel:Vh(F,H),onPointerEnter:k?void 0:g,onPointerMove:k?I:b,onPointerUp:k?A:void 0,onPointerDownCapture:k?_:void 0,onClickCapture:k?D:void 0,onPointerLeave:p,ref:H,style:nd,children:[w,t.jsx(CO,{})]})}function Cm({id:e,store:r,unselect:s=!1,nodeRef:i}){const{addSelectedNodes:o,unselectNodesAndEdges:c,multiSelectionActive:u,nodeLookup:f,onError:m}=r.getState(),h=f.get(e);if(!h){m?.("012",ms.error012(e));return}r.setState({nodesSelectionActive:!1}),h.selected?(s||h.selected&&u)&&(c({nodes:[h],edges:[]}),requestAnimationFrame(()=>i?.current?.blur())):o([e])}function Ow({nodeRef:e,disabled:r=!1,noDragClassName:s,handleSelector:i,nodeId:o,isSelectable:c,nodeClickDistance:u}){const f=yn(),[m,h]=j.useState(!1),x=j.useRef();return j.useEffect(()=>{x.current=xD({getStoreItems:()=>f.getState(),onNodeMouseDown:g=>{Cm({id:g,store:f,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}})},[]),j.useEffect(()=>{if(!(r||!e.current||!x.current))return x.current.update({noDragClassName:s,handleSelector:i,domNode:e.current,isSelectable:c,nodeId:o,nodeClickDistance:u}),()=>{x.current?.destroy()}},[s,i,r,c,e,o,u]),m}const _O=e=>r=>r.selected&&(r.draggable||e&&typeof r.draggable>"u");function Rw(){const e=yn();return j.useCallback(s=>{const{nodeExtent:i,snapToGrid:o,snapGrid:c,nodesDraggable:u,onError:f,updateNodePositions:m,nodeLookup:h,nodeOrigin:x}=e.getState(),g=new Map,b=_O(u),p=o?c[0]:5,w=o?c[1]:5,S=s.direction.x*p*s.factor,T=s.direction.y*w*s.factor;for(const[,E]of h){if(!b(E))continue;let C={x:E.internals.positionAbsolute.x+S,y:E.internals.positionAbsolute.y+T};o&&(C=Io(C,c));const{position:N,positionAbsolute:k}=Wj({nodeId:E.id,nextPosition:C,nodeLookup:h,nodeExtent:i,nodeOrigin:x,onError:f});E.position=N,E.internals.positionAbsolute=k,g.set(E.id,E)}m(g)},[])}const vx=j.createContext(null),AO=vx.Provider;vx.Consumer;const zw=()=>j.useContext(vx),MO=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),DO=(e,r,s)=>i=>{const{connectionClickStartHandle:o,connectionMode:c,connection:u}=i,{fromHandle:f,toHandle:m,isValid:h}=u,x=m?.nodeId===e&&m?.id===r&&m?.type===s;return{connectingFrom:f?.nodeId===e&&f?.id===r&&f?.type===s,connectingTo:x,clickConnecting:o?.nodeId===e&&o?.id===r&&o?.type===s,isPossibleEndHandle:c===Xi.Strict?f?.type!==s:e!==f?.nodeId||r!==f?.id,connectionInProcess:!!f,clickConnectionInProcess:!!o,valid:x&&h}};function OO({type:e="source",position:r=nt.Top,isValidConnection:s,isConnectable:i=!0,isConnectableStart:o=!0,isConnectableEnd:c=!0,id:u,onConnect:f,children:m,className:h,onMouseDown:x,onTouchStart:g,...b},p){const w=u||null,S=e==="target",T=yn(),E=zw(),{connectOnClick:C,noPanClassName:N,rfId:k}=Vt(MO,bn),{connectingFrom:H,connectingTo:M,clickConnecting:Y,isPossibleEndHandle:$,connectionInProcess:X,clickConnectionInProcess:P,valid:q}=Vt(DO(E,w,e),bn);E||T.getState().onError?.("010",ms.error010());const F=I=>{const{defaultEdgeOptions:A,onConnect:G,hasDefaultEdges:U}=T.getState(),K={...A,...I};if(U){const{edges:B,setEdges:L}=T.getState();L(WM(K,B))}G?.(K),f?.(K)},D=I=>{if(!E)return;const A=lw(I.nativeEvent);if(o&&(A&&I.button===0||!A)){const G=T.getState();Sm.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:G.autoPanOnConnect,connectionMode:G.connectionMode,connectionRadius:G.connectionRadius,domNode:G.domNode,nodeLookup:G.nodeLookup,lib:G.lib,isTarget:S,handleId:w,nodeId:E,flowId:G.rfId,panBy:G.panBy,cancelConnection:G.cancelConnection,onConnectStart:G.onConnectStart,onConnectEnd:(...U)=>T.getState().onConnectEnd?.(...U),updateConnection:G.updateConnection,onConnect:F,isValidConnection:s||((...U)=>T.getState().isValidConnection?.(...U)??!0),getTransform:()=>T.getState().transform,getFromHandle:()=>T.getState().connection.fromHandle,autoPanSpeed:G.autoPanSpeed,dragThreshold:G.connectionDragThreshold})}A?x?.(I):g?.(I)},_=I=>{const{onClickConnectStart:A,onClickConnectEnd:G,connectionClickStartHandle:U,connectionMode:K,isValidConnection:B,lib:L,rfId:W,nodeLookup:R,connection:z}=T.getState();if(!E||!U&&!o)return;if(!U){A?.(I.nativeEvent,{nodeId:E,handleId:w,handleType:e}),T.setState({connectionClickStartHandle:{nodeId:E,type:e,id:w}});return}const V=aw(I.target),Q=s||B,{connection:te,isValid:Z}=Sm.isValid(I.nativeEvent,{handle:{nodeId:E,id:w,type:e},connectionMode:K,fromNodeId:U.nodeId,fromHandleId:U.id||null,fromType:U.type,isValidConnection:Q,flowId:W,doc:V,lib:L,nodeLookup:R});Z&&te&&F(te);const ee=structuredClone(z);delete ee.inProgress,ee.toPosition=ee.toHandle?ee.toHandle.position:null,G?.(I,ee),T.setState({connectionClickStartHandle:null})};return t.jsx("div",{"data-handleid":w,"data-nodeid":E,"data-handlepos":r,"data-id":`${k}-${E}-${w}-${e}`,className:Pn(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,h,{source:!S,target:S,connectable:i,connectablestart:o,connectableend:c,clickconnecting:Y,connectingfrom:H,connectingto:M,valid:q,connectionindicator:i&&(!X||$)&&(X||P?c:o)}]),onMouseDown:D,onTouchStart:D,onClick:C?_:void 0,ref:p,...b,children:m})}const Na=j.memo(Mw(OO));function RO({data:e,isConnectable:r,sourcePosition:s=nt.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx(Na,{type:"source",position:s,isConnectable:r})]})}function zO({data:e,isConnectable:r,targetPosition:s=nt.Top,sourcePosition:i=nt.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(Na,{type:"target",position:s,isConnectable:r}),e?.label,t.jsx(Na,{type:"source",position:i,isConnectable:r})]})}function LO(){return null}function IO({data:e,isConnectable:r,targetPosition:s=nt.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(Na,{type:"target",position:s,isConnectable:r}),e?.label]})}const Lu={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},mv={input:RO,default:zO,output:IO,group:LO};function $O(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 BO=e=>{const{width:r,height:s,x:i,y:o}=Lo(e.nodeLookup,{filter:c=>!!c.selected});return{width:Wr(r)?r:null,height:Wr(s)?s:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${o}px)`}};function HO({onSelectionContextMenu:e,noPanClassName:r,disableKeyboardA11y:s}){const i=yn(),{width:o,height:c,transformString:u,userSelectionActive:f}=Vt(BO,bn),m=Rw(),h=j.useRef(null);j.useEffect(()=>{s||h.current?.focus({preventScroll:!0})},[s]);const x=!f&&o!==null&&c!==null;if(Ow({nodeRef:h,disabled:!x}),!x)return null;const g=e?p=>{const w=i.getState().nodes.filter(S=>S.selected);e(p,w)}:void 0,b=p=>{Object.prototype.hasOwnProperty.call(Lu,p.key)&&(p.preventDefault(),m({direction:Lu[p.key],factor:p.shiftKey?4:1}))};return t.jsx("div",{className:Pn(["react-flow__nodesselection","react-flow__container",r]),style:{transform:u},children:t.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:s?void 0:-1,onKeyDown:s?void 0:b,style:{width:o,height:c}})})}const xv=typeof window<"u"?window:void 0,PO=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Lw({children:e,onPaneClick:r,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:c,onPaneScroll:u,paneClickDistance:f,deleteKeyCode:m,selectionKeyCode:h,selectionOnDrag:x,selectionMode:g,onSelectionStart:b,onSelectionEnd:p,multiSelectionKeyCode:w,panActivationKeyCode:S,zoomActivationKeyCode:T,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:N,panOnScroll:k,panOnScrollSpeed:H,panOnScrollMode:M,zoomOnDoubleClick:Y,panOnDrag:$,defaultViewport:X,translateExtent:P,minZoom:q,maxZoom:F,preventScrolling:D,onSelectionContextMenu:_,noWheelClassName:I,noPanClassName:A,disableKeyboardA11y:G,onViewportChange:U,isControlledViewport:K}){const{nodesSelectionActive:B,userSelectionActive:L}=Vt(PO,bn),W=Eo(h,{target:xv}),R=Eo(S,{target:xv}),z=R||$,V=R||k,Q=x&&z!==!0,te=W||L||Q;return jO({deleteKeyCode:m,multiSelectionKeyCode:w}),t.jsx(kO,{onPaneContextMenu:c,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:N,panOnScroll:V,panOnScrollSpeed:H,panOnScrollMode:M,zoomOnDoubleClick:Y,panOnDrag:!W&&z,defaultViewport:X,translateExtent:P,minZoom:q,maxZoom:F,zoomActivationKeyCode:T,preventScrolling:D,noWheelClassName:I,noPanClassName:A,onViewportChange:U,isControlledViewport:K,paneClickDistance:f,selectionOnDrag:Q,children:t.jsxs(TO,{onSelectionStart:b,onSelectionEnd:p,onPaneClick:r,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:c,onPaneScroll:u,panOnDrag:z,isSelecting:!!te,selectionMode:g,selectionKeyPressed:W,paneClickDistance:f,selectionOnDrag:Q,children:[e,B&&t.jsx(HO,{onSelectionContextMenu:_,noPanClassName:A,disableKeyboardA11y:G})]})})}Lw.displayName="FlowRenderer";const UO=j.memo(Lw),qO=e=>r=>e?dx(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(s=>s.id):Array.from(r.nodeLookup.keys());function VO(e){return Vt(j.useCallback(qO(e),[e]),bn)}const FO=e=>e.updateNodeInternals;function YO(){const e=Vt(FO),[r]=j.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const i=new Map;s.forEach(o=>{const c=o.target.getAttribute("data-id");i.set(c,{id:c,nodeElement:o.target,force:!0})}),e(i)}));return j.useEffect(()=>()=>{r?.disconnect()},[r]),r}function GO({node:e,nodeType:r,hasDimensions:s,resizeObserver:i}){const o=yn(),c=j.useRef(null),u=j.useRef(null),f=j.useRef(e.sourcePosition),m=j.useRef(e.targetPosition),h=j.useRef(r),x=s&&!!e.internals.handleBounds;return j.useEffect(()=>{c.current&&!e.hidden&&(!x||u.current!==c.current)&&(u.current&&i?.unobserve(u.current),i?.observe(c.current),u.current=c.current)},[x,e.hidden]),j.useEffect(()=>()=>{u.current&&(i?.unobserve(u.current),u.current=null)},[]),j.useEffect(()=>{if(c.current){const g=h.current!==r,b=f.current!==e.sourcePosition,p=m.current!==e.targetPosition;(g||b||p)&&(h.current=r,f.current=e.sourcePosition,m.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:c.current,force:!0}]])))}},[e.id,r,e.sourcePosition,e.targetPosition]),c}function XO({id:e,onClick:r,onMouseEnter:s,onMouseMove:i,onMouseLeave:o,onContextMenu:c,onDoubleClick:u,nodesDraggable:f,elementsSelectable:m,nodesConnectable:h,nodesFocusable:x,resizeObserver:g,noDragClassName:b,noPanClassName:p,disableKeyboardA11y:w,rfId:S,nodeTypes:T,nodeClickDistance:E,onError:C}){const{node:N,internals:k,isParent:H}=Vt(Z=>{const ee=Z.nodeLookup.get(e),ie=Z.parentLookup.has(e);return{node:ee,internals:ee.internals,isParent:ie}},bn);let M=N.type||"default",Y=T?.[M]||mv[M];Y===void 0&&(C?.("003",ms.error003(M)),M="default",Y=T?.default||mv.default);const $=!!(N.draggable||f&&typeof N.draggable>"u"),X=!!(N.selectable||m&&typeof N.selectable>"u"),P=!!(N.connectable||h&&typeof N.connectable>"u"),q=!!(N.focusable||x&&typeof N.focusable>"u"),F=yn(),D=rw(N),_=GO({node:N,nodeType:M,hasDimensions:D,resizeObserver:g}),I=Ow({nodeRef:_,disabled:N.hidden||!$,noDragClassName:b,handleSelector:N.dragHandle,nodeId:e,isSelectable:X,nodeClickDistance:E}),A=Rw();if(N.hidden)return null;const G=Hs(N),U=$O(N),K=X||$||r||s||i||o,B=s?Z=>s(Z,{...k.userNode}):void 0,L=i?Z=>i(Z,{...k.userNode}):void 0,W=o?Z=>o(Z,{...k.userNode}):void 0,R=c?Z=>c(Z,{...k.userNode}):void 0,z=u?Z=>u(Z,{...k.userNode}):void 0,V=Z=>{const{selectNodesOnDrag:ee,nodeDragThreshold:ie}=F.getState();X&&(!ee||!$||ie>0)&&Cm({id:e,store:F,nodeRef:_}),r&&r(Z,{...k.userNode})},Q=Z=>{if(!(iw(Z.nativeEvent)||w)){if(Xj.includes(Z.key)&&X){const ee=Z.key==="Escape";Cm({id:e,store:F,unselect:ee,nodeRef:_})}else if($&&N.selected&&Object.prototype.hasOwnProperty.call(Lu,Z.key)){Z.preventDefault();const{ariaLabelConfig:ee}=F.getState();F.setState({ariaLiveMessage:ee["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~k.positionAbsolute.x,y:~~k.positionAbsolute.y})}),A({direction:Lu[Z.key],factor:Z.shiftKey?4:1})}}},te=()=>{if(w||!_.current?.matches(":focus-visible"))return;const{transform:Z,width:ee,height:ie,autoPanOnNodeFocus:je,setCenter:ke}=F.getState();if(!je)return;dx(new Map([[e,N]]),{x:0,y:0,width:ee,height:ie},Z,!0).length>0||ke(N.position.x+G.width/2,N.position.y+G.height/2,{zoom:Z[2]})};return t.jsx("div",{className:Pn(["react-flow__node",`react-flow__node-${M}`,{[p]:$},N.className,{selected:N.selected,selectable:X,parent:H,draggable:$,dragging:I}]),ref:_,style:{zIndex:k.z,transform:`translate(${k.positionAbsolute.x}px,${k.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:D?"visible":"hidden",...N.style,...U},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:L,onMouseLeave:W,onContextMenu:R,onClick:V,onDoubleClick:z,onKeyDown:q?Q:void 0,tabIndex:q?0:void 0,onFocus:q?te:void 0,role:N.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Sw}-${S}`,"aria-label":N.ariaLabel,...N.domAttributes,children:t.jsx(AO,{value:e,children:t.jsx(Y,{id:e,data:N.data,type:M,positionAbsoluteX:k.positionAbsolute.x,positionAbsoluteY:k.positionAbsolute.y,selected:N.selected??!1,selectable:X,draggable:$,deletable:N.deletable??!0,isConnectable:P,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:I,dragHandle:N.dragHandle,zIndex:k.z,parentId:N.parentId,...G})})})}var ZO=j.memo(XO);const QO=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Iw(e){const{nodesDraggable:r,nodesConnectable:s,nodesFocusable:i,elementsSelectable:o,onError:c}=Vt(QO,bn),u=VO(e.onlyRenderVisibleElements),f=YO();return t.jsx("div",{className:"react-flow__nodes",style:nd,children:u.map(m=>t.jsx(ZO,{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:f,nodesDraggable:r,nodesConnectable:s,nodesFocusable:i,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:c},m))})}Iw.displayName="NodeRenderer";const KO=j.memo(Iw);function JO(e){return Vt(j.useCallback(s=>{if(!e)return s.edges.map(o=>o.id);const i=[];if(s.width&&s.height)for(const o of s.edges){const c=s.nodeLookup.get(o.source),u=s.nodeLookup.get(o.target);c&&u&&QM({sourceNode:c,targetNode:u,width:s.width,height:s.height,transform:s.transform})&&i.push(o.id)}return i},[e]),bn)}const WO=({color:e="none",strokeWidth:r=1})=>{const s={strokeWidth:r,...e&&{stroke:e}};return t.jsx("polyline",{className:"arrow",style:s,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},eR=({color:e="none",strokeWidth:r=1})=>{const s={strokeWidth:r,...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"})},gv={[Zi.Arrow]:WO,[Zi.ArrowClosed]:eR};function tR(e){const r=yn();return j.useMemo(()=>Object.prototype.hasOwnProperty.call(gv,e)?gv[e]:(r.getState().onError?.("009",ms.error009(e)),null),[e])}const nR=({id:e,type:r,color:s,width:i=12.5,height:o=12.5,markerUnits:c="strokeWidth",strokeWidth:u,orient:f="auto-start-reverse"})=>{const m=tR(r);return m?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:f,refX:"0",refY:"0",children:t.jsx(m,{color:s,strokeWidth:u})}):null},$w=({defaultColor:e,rfId:r})=>{const s=Vt(c=>c.edges),i=Vt(c=>c.defaultEdgeOptions),o=j.useMemo(()=>sD(s,{id:r,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd}),[s,i,r,e]);return o.length?t.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:t.jsx("defs",{children:o.map(c=>t.jsx(nR,{id:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,strokeWidth:c.strokeWidth,orient:c.orient},c.id))})}):null};$w.displayName="MarkerDefinitions";var rR=j.memo($w);function Bw({x:e,y:r,label:s,labelStyle:i,labelShowBg:o=!0,labelBgStyle:c,labelBgPadding:u=[2,4],labelBgBorderRadius:f=2,children:m,className:h,...x}){const[g,b]=j.useState({x:1,y:0,width:0,height:0}),p=Pn(["react-flow__edge-textwrapper",h]),w=j.useRef(null);return j.useEffect(()=>{if(w.current){const S=w.current.getBBox();b({x:S.x,y:S.y,width:S.width,height:S.height})}},[s]),s?t.jsxs("g",{transform:`translate(${e-g.width/2} ${r-g.height/2})`,className:p,visibility:g.width?"visible":"hidden",...x,children:[o&&t.jsx("rect",{width:g.width+2*u[0],x:-u[0],y:-u[1],height:g.height+2*u[1],className:"react-flow__edge-textbg",style:c,rx:f,ry:f}),t.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:w,style:i,children:s}),m]}):null}Bw.displayName="EdgeText";const sR=j.memo(Bw);function rd({path:e,labelX:r,labelY:s,label:i,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:m,interactionWidth:h=20,...x}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{...x,d:e,fill:"none",className:Pn(["react-flow__edge-path",x.className])}),h?t.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,i&&Wr(r)&&Wr(s)?t.jsx(sR,{x:r,y:s,label:i,labelStyle:o,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:m}):null]})}function pv({pos:e,x1:r,y1:s,x2:i,y2:o}){return e===nt.Left||e===nt.Right?[.5*(r+i),s]:[r,.5*(s+o)]}function Hw({sourceX:e,sourceY:r,sourcePosition:s=nt.Bottom,targetX:i,targetY:o,targetPosition:c=nt.Top}){const[u,f]=pv({pos:s,x1:e,y1:r,x2:i,y2:o}),[m,h]=pv({pos:c,x1:i,y1:o,x2:e,y2:r}),[x,g,b,p]=ow({sourceX:e,sourceY:r,targetX:i,targetY:o,sourceControlX:u,sourceControlY:f,targetControlX:m,targetControlY:h});return[`M${e},${r} C${u},${f} ${m},${h} ${i},${o}`,x,g,b,p]}function Pw(e){return j.memo(({id:r,sourceX:s,sourceY:i,targetX:o,targetY:c,sourcePosition:u,targetPosition:f,label:m,labelStyle:h,labelShowBg:x,labelBgStyle:g,labelBgPadding:b,labelBgBorderRadius:p,style:w,markerEnd:S,markerStart:T,interactionWidth:E})=>{const[C,N,k]=Hw({sourceX:s,sourceY:i,sourcePosition:u,targetX:o,targetY:c,targetPosition:f}),H=e.isInternal?void 0:r;return t.jsx(rd,{id:H,path:C,labelX:N,labelY:k,label:m,labelStyle:h,labelShowBg:x,labelBgStyle:g,labelBgPadding:b,labelBgBorderRadius:p,style:w,markerEnd:S,markerStart:T,interactionWidth:E})})}const aR=Pw({isInternal:!1}),Uw=Pw({isInternal:!0});aR.displayName="SimpleBezierEdge";Uw.displayName="SimpleBezierEdgeInternal";function qw(e){return j.memo(({id:r,sourceX:s,sourceY:i,targetX:o,targetY:c,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:h,labelBgPadding:x,labelBgBorderRadius:g,style:b,sourcePosition:p=nt.Bottom,targetPosition:w=nt.Top,markerEnd:S,markerStart:T,pathOptions:E,interactionWidth:C})=>{const[N,k,H]=wm({sourceX:s,sourceY:i,sourcePosition:p,targetX:o,targetY:c,targetPosition:w,borderRadius:E?.borderRadius,offset:E?.offset,stepPosition:E?.stepPosition}),M=e.isInternal?void 0:r;return t.jsx(rd,{id:M,path:N,labelX:k,labelY:H,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:h,labelBgPadding:x,labelBgBorderRadius:g,style:b,markerEnd:S,markerStart:T,interactionWidth:C})})}const Vw=qw({isInternal:!1}),Fw=qw({isInternal:!0});Vw.displayName="SmoothStepEdge";Fw.displayName="SmoothStepEdgeInternal";function Yw(e){return j.memo(({id:r,...s})=>{const i=e.isInternal?void 0:r;return t.jsx(Vw,{...s,id:i,pathOptions:j.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const iR=Yw({isInternal:!1}),Gw=Yw({isInternal:!0});iR.displayName="StepEdge";Gw.displayName="StepEdgeInternal";function Xw(e){return j.memo(({id:r,sourceX:s,sourceY:i,targetX:o,targetY:c,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:h,labelBgPadding:x,labelBgBorderRadius:g,style:b,markerEnd:p,markerStart:w,interactionWidth:S})=>{const[T,E,C]=dw({sourceX:s,sourceY:i,targetX:o,targetY:c}),N=e.isInternal?void 0:r;return t.jsx(rd,{id:N,path:T,labelX:E,labelY:C,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:h,labelBgPadding:x,labelBgBorderRadius:g,style:b,markerEnd:p,markerStart:w,interactionWidth:S})})}const lR=Xw({isInternal:!1}),Zw=Xw({isInternal:!0});lR.displayName="StraightEdge";Zw.displayName="StraightEdgeInternal";function Qw(e){return j.memo(({id:r,sourceX:s,sourceY:i,targetX:o,targetY:c,sourcePosition:u=nt.Bottom,targetPosition:f=nt.Top,label:m,labelStyle:h,labelShowBg:x,labelBgStyle:g,labelBgPadding:b,labelBgBorderRadius:p,style:w,markerEnd:S,markerStart:T,pathOptions:E,interactionWidth:C})=>{const[N,k,H]=cw({sourceX:s,sourceY:i,sourcePosition:u,targetX:o,targetY:c,targetPosition:f,curvature:E?.curvature}),M=e.isInternal?void 0:r;return t.jsx(rd,{id:M,path:N,labelX:k,labelY:H,label:m,labelStyle:h,labelShowBg:x,labelBgStyle:g,labelBgPadding:b,labelBgBorderRadius:p,style:w,markerEnd:S,markerStart:T,interactionWidth:C})})}const oR=Qw({isInternal:!1}),Kw=Qw({isInternal:!0});oR.displayName="BezierEdge";Kw.displayName="BezierEdgeInternal";const bv={default:Kw,straight:Zw,step:Gw,smoothstep:Fw,simplebezier:Uw},yv={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},cR=(e,r,s)=>s===nt.Left?e-r:s===nt.Right?e+r:e,uR=(e,r,s)=>s===nt.Top?e-r:s===nt.Bottom?e+r:e,vv="react-flow__edgeupdater";function jv({position:e,centerX:r,centerY:s,radius:i=10,onMouseDown:o,onMouseEnter:c,onMouseOut:u,type:f}){return t.jsx("circle",{onMouseDown:o,onMouseEnter:c,onMouseOut:u,className:Pn([vv,`${vv}-${f}`]),cx:cR(r,i,e),cy:uR(s,i,e),r:i,stroke:"transparent",fill:"transparent"})}function dR({isReconnectable:e,reconnectRadius:r,edge:s,sourceX:i,sourceY:o,targetX:c,targetY:u,sourcePosition:f,targetPosition:m,onReconnect:h,onReconnectStart:x,onReconnectEnd:g,setReconnecting:b,setUpdateHover:p}){const w=yn(),S=(k,H)=>{if(k.button!==0)return;const{autoPanOnConnect:M,domNode:Y,connectionMode:$,connectionRadius:X,lib:P,onConnectStart:q,cancelConnection:F,nodeLookup:D,rfId:_,panBy:I,updateConnection:A}=w.getState(),G=H.type==="target",U=(L,W)=>{b(!1),g?.(L,s,H.type,W)},K=L=>h?.(s,L),B=(L,W)=>{b(!0),x?.(k,s,H.type),q?.(L,W)};Sm.onPointerDown(k.nativeEvent,{autoPanOnConnect:M,connectionMode:$,connectionRadius:X,domNode:Y,handleId:H.id,nodeId:H.nodeId,nodeLookup:D,isTarget:G,edgeUpdaterType:H.type,lib:P,flowId:_,cancelConnection:F,panBy:I,isValidConnection:(...L)=>w.getState().isValidConnection?.(...L)??!0,onConnect:K,onConnectStart:B,onConnectEnd:(...L)=>w.getState().onConnectEnd?.(...L),onReconnectEnd:U,updateConnection:A,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:k.currentTarget})},T=k=>S(k,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),E=k=>S(k,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),C=()=>p(!0),N=()=>p(!1);return t.jsxs(t.Fragment,{children:[(e===!0||e==="source")&&t.jsx(jv,{position:f,centerX:i,centerY:o,radius:r,onMouseDown:T,onMouseEnter:C,onMouseOut:N,type:"source"}),(e===!0||e==="target")&&t.jsx(jv,{position:m,centerX:c,centerY:u,radius:r,onMouseDown:E,onMouseEnter:C,onMouseOut:N,type:"target"})]})}function fR({id:e,edgesFocusable:r,edgesReconnectable:s,elementsSelectable:i,onClick:o,onDoubleClick:c,onContextMenu:u,onMouseEnter:f,onMouseMove:m,onMouseLeave:h,reconnectRadius:x,onReconnect:g,onReconnectStart:b,onReconnectEnd:p,rfId:w,edgeTypes:S,noPanClassName:T,onError:E,disableKeyboardA11y:C}){let N=Vt(ke=>ke.edgeLookup.get(e));const k=Vt(ke=>ke.defaultEdgeOptions);N=k?{...k,...N}:N;let H=N.type||"default",M=S?.[H]||bv[H];M===void 0&&(E?.("011",ms.error011(H)),H="default",M=S?.default||bv.default);const Y=!!(N.focusable||r&&typeof N.focusable>"u"),$=typeof g<"u"&&(N.reconnectable||s&&typeof N.reconnectable>"u"),X=!!(N.selectable||i&&typeof N.selectable>"u"),P=j.useRef(null),[q,F]=j.useState(!1),[D,_]=j.useState(!1),I=yn(),{zIndex:A,sourceX:G,sourceY:U,targetX:K,targetY:B,sourcePosition:L,targetPosition:W}=Vt(j.useCallback(ke=>{const De=ke.nodeLookup.get(N.source),Ie=ke.nodeLookup.get(N.target);if(!De||!Ie)return{zIndex:N.zIndex,...yv};const ze=rD({id:e,sourceNode:De,targetNode:Ie,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:ke.connectionMode,onError:E});return{zIndex:ZM({selected:N.selected,zIndex:N.zIndex,sourceNode:De,targetNode:Ie,elevateOnSelect:ke.elevateEdgesOnSelect,zIndexMode:ke.zIndexMode}),...ze||yv}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex]),bn),R=j.useMemo(()=>N.markerStart?`url('#${Nm(N.markerStart,w)}')`:void 0,[N.markerStart,w]),z=j.useMemo(()=>N.markerEnd?`url('#${Nm(N.markerEnd,w)}')`:void 0,[N.markerEnd,w]);if(N.hidden||G===null||U===null||K===null||B===null)return null;const V=ke=>{const{addSelectedEdges:De,unselectNodesAndEdges:Ie,multiSelectionActive:ze}=I.getState();X&&(I.setState({nodesSelectionActive:!1}),N.selected&&ze?(Ie({nodes:[],edges:[N]}),P.current?.blur()):De([e])),o&&o(ke,N)},Q=c?ke=>{c(ke,{...N})}:void 0,te=u?ke=>{u(ke,{...N})}:void 0,Z=f?ke=>{f(ke,{...N})}:void 0,ee=m?ke=>{m(ke,{...N})}:void 0,ie=h?ke=>{h(ke,{...N})}:void 0,je=ke=>{if(!C&&Xj.includes(ke.key)&&X){const{unselectNodesAndEdges:De,addSelectedEdges:Ie}=I.getState();ke.key==="Escape"?(P.current?.blur(),De({edges:[N]})):Ie([e])}};return t.jsx("svg",{style:{zIndex:A},children:t.jsxs("g",{className:Pn(["react-flow__edge",`react-flow__edge-${H}`,N.className,T,{selected:N.selected,animated:N.animated,inactive:!X&&!o,updating:q,selectable:X}]),onClick:V,onDoubleClick:Q,onContextMenu:te,onMouseEnter:Z,onMouseMove:ee,onMouseLeave:ie,onKeyDown:Y?je:void 0,tabIndex:Y?0:void 0,role:N.ariaRole??(Y?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":Y?`${Cw}-${w}`:void 0,ref:P,...N.domAttributes,children:[!D&&t.jsx(M,{id:e,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:X,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:G,sourceY:U,targetX:K,targetY:B,sourcePosition:L,targetPosition:W,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:R,markerEnd:z,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),$&&t.jsx(dR,{edge:N,isReconnectable:$,reconnectRadius:x,onReconnect:g,onReconnectStart:b,onReconnectEnd:p,sourceX:G,sourceY:U,targetX:K,targetY:B,sourcePosition:L,targetPosition:W,setUpdateHover:F,setReconnecting:_})]})})}var hR=j.memo(fR);const mR=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Jw({defaultMarkerColor:e,onlyRenderVisibleElements:r,rfId:s,edgeTypes:i,noPanClassName:o,onReconnect:c,onEdgeContextMenu:u,onEdgeMouseEnter:f,onEdgeMouseMove:m,onEdgeMouseLeave:h,onEdgeClick:x,reconnectRadius:g,onEdgeDoubleClick:b,onReconnectStart:p,onReconnectEnd:w,disableKeyboardA11y:S}){const{edgesFocusable:T,edgesReconnectable:E,elementsSelectable:C,onError:N}=Vt(mR,bn),k=JO(r);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(rR,{defaultColor:e,rfId:s}),k.map(H=>t.jsx(hR,{id:H,edgesFocusable:T,edgesReconnectable:E,elementsSelectable:C,noPanClassName:o,onReconnect:c,onContextMenu:u,onMouseEnter:f,onMouseMove:m,onMouseLeave:h,onClick:x,reconnectRadius:g,onDoubleClick:b,onReconnectStart:p,onReconnectEnd:w,rfId:s,onError:N,edgeTypes:i,disableKeyboardA11y:S},H))]})}Jw.displayName="EdgeRenderer";const xR=j.memo(Jw),gR=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function pR({children:e}){const r=Vt(gR);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:r},children:e})}function bR(e){const r=yx(),s=j.useRef(!1);j.useEffect(()=>{!s.current&&r.viewportInitialized&&e&&(setTimeout(()=>e(r),1),s.current=!0)},[e,r.viewportInitialized])}const yR=e=>e.panZoom?.syncViewport;function vR(e){const r=Vt(yR),s=yn();return j.useEffect(()=>{e&&(r?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,r]),null}function jR(e){return e.connection.inProgress?{...e.connection,to:$o(e.connection.to,e.transform)}:{...e.connection}}function wR(e){return jR}function NR(e){const r=wR();return Vt(r,bn)}const kR=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function SR({containerStyle:e,style:r,type:s,component:i}){const{nodesConnectable:o,width:c,height:u,isValid:f,inProgress:m}=Vt(kR,bn);return!(c&&o&&m)?null:t.jsx("svg",{style:e,width:c,height:u,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:Pn(["react-flow__connection",Kj(f)]),children:t.jsx(Ww,{style:r,type:s,CustomComponent:i,isValid:f})})})}const Ww=({style:e,type:r=ja.Bezier,CustomComponent:s,isValid:i})=>{const{inProgress:o,from:c,fromNode:u,fromHandle:f,fromPosition:m,to:h,toNode:x,toHandle:g,toPosition:b,pointer:p}=NR();if(!o)return;if(s)return t.jsx(s,{connectionLineType:r,connectionLineStyle:e,fromNode:u,fromHandle:f,fromX:c.x,fromY:c.y,toX:h.x,toY:h.y,fromPosition:m,toPosition:b,connectionStatus:Kj(i),toNode:x,toHandle:g,pointer:p});let w="";const S={sourceX:c.x,sourceY:c.y,sourcePosition:m,targetX:h.x,targetY:h.y,targetPosition:b};switch(r){case ja.Bezier:[w]=cw(S);break;case ja.SimpleBezier:[w]=Hw(S);break;case ja.Step:[w]=wm({...S,borderRadius:0});break;case ja.SmoothStep:[w]=wm(S);break;default:[w]=dw(S)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};Ww.displayName="ConnectionLine";const CR={};function wv(e=CR){j.useRef(e),yn(),j.useEffect(()=>{},[e])}function ER(){yn(),j.useRef(!1),j.useEffect(()=>{},[])}function eN({nodeTypes:e,edgeTypes:r,onInit:s,onNodeClick:i,onEdgeClick:o,onNodeDoubleClick:c,onEdgeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:h,onNodeContextMenu:x,onSelectionContextMenu:g,onSelectionStart:b,onSelectionEnd:p,connectionLineType:w,connectionLineStyle:S,connectionLineComponent:T,connectionLineContainerStyle:E,selectionKeyCode:C,selectionOnDrag:N,selectionMode:k,multiSelectionKeyCode:H,panActivationKeyCode:M,zoomActivationKeyCode:Y,deleteKeyCode:$,onlyRenderVisibleElements:X,elementsSelectable:P,defaultViewport:q,translateExtent:F,minZoom:D,maxZoom:_,preventScrolling:I,defaultMarkerColor:A,zoomOnScroll:G,zoomOnPinch:U,panOnScroll:K,panOnScrollSpeed:B,panOnScrollMode:L,zoomOnDoubleClick:W,panOnDrag:R,onPaneClick:z,onPaneMouseEnter:V,onPaneMouseMove:Q,onPaneMouseLeave:te,onPaneScroll:Z,onPaneContextMenu:ee,paneClickDistance:ie,nodeClickDistance:je,onEdgeContextMenu:ke,onEdgeMouseEnter:De,onEdgeMouseMove:Ie,onEdgeMouseLeave:ze,reconnectRadius:Ze,onReconnect:Ae,onReconnectStart:We,onReconnectEnd:xt,noDragClassName:Lt,noWheelClassName:le,noPanClassName:_e,disableKeyboardA11y:ht,nodeExtent:Ct,rfId:Ft,viewport:be,onViewportChange:Me}){return wv(e),wv(r),ER(),bR(s),vR(be),t.jsx(UO,{onPaneClick:z,onPaneMouseEnter:V,onPaneMouseMove:Q,onPaneMouseLeave:te,onPaneContextMenu:ee,onPaneScroll:Z,paneClickDistance:ie,deleteKeyCode:$,selectionKeyCode:C,selectionOnDrag:N,selectionMode:k,onSelectionStart:b,onSelectionEnd:p,multiSelectionKeyCode:H,panActivationKeyCode:M,zoomActivationKeyCode:Y,elementsSelectable:P,zoomOnScroll:G,zoomOnPinch:U,zoomOnDoubleClick:W,panOnScroll:K,panOnScrollSpeed:B,panOnScrollMode:L,panOnDrag:R,defaultViewport:q,translateExtent:F,minZoom:D,maxZoom:_,onSelectionContextMenu:g,preventScrolling:I,noDragClassName:Lt,noWheelClassName:le,noPanClassName:_e,disableKeyboardA11y:ht,onViewportChange:Me,isControlledViewport:!!be,children:t.jsxs(pR,{children:[t.jsx(xR,{edgeTypes:r,onEdgeClick:o,onEdgeDoubleClick:u,onReconnect:Ae,onReconnectStart:We,onReconnectEnd:xt,onlyRenderVisibleElements:X,onEdgeContextMenu:ke,onEdgeMouseEnter:De,onEdgeMouseMove:Ie,onEdgeMouseLeave:ze,reconnectRadius:Ze,defaultMarkerColor:A,noPanClassName:_e,disableKeyboardA11y:ht,rfId:Ft}),t.jsx(SR,{style:S,type:w,component:T,containerStyle:E}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(KO,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:h,onNodeContextMenu:x,nodeClickDistance:je,onlyRenderVisibleElements:X,noPanClassName:_e,noDragClassName:Lt,disableKeyboardA11y:ht,nodeExtent:Ct,rfId:Ft}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}eN.displayName="GraphView";const TR=j.memo(eN),Nv=({nodes:e,edges:r,defaultNodes:s,defaultEdges:i,width:o,height:c,fitView:u,fitViewOptions:f,minZoom:m=.5,maxZoom:h=2,nodeOrigin:x,nodeExtent:g,zIndexMode:b="basic"}={})=>{const p=new Map,w=new Map,S=new Map,T=new Map,E=i??r??[],C=s??e??[],N=x??[0,0],k=g??No;mw(S,T,E);const H=km(C,p,w,{nodeOrigin:N,nodeExtent:k,zIndexMode:b});let M=[0,0,1];if(u&&o&&c){const Y=Lo(p,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:$,y:X,zoom:P}=fx(Y,o,c,m,h,f?.padding??.1);M=[$,X,P]}return{rfId:"1",width:o??0,height:c??0,transform:M,nodes:C,nodesInitialized:H,nodeLookup:p,parentLookup:w,edges:E,edgeLookup:T,connectionLookup:S,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:m,maxZoom:h,translateExtent:No,nodeExtent:k,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Xi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,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:u??!1,fitViewOptions:f,fitViewResolver:null,connection:{...Qj},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:qM,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Zj,zIndexMode:b,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},_R=({nodes:e,edges:r,defaultNodes:s,defaultEdges:i,width:o,height:c,fitView:u,fitViewOptions:f,minZoom:m,maxZoom:h,nodeOrigin:x,nodeExtent:g,zIndexMode:b})=>GD((p,w)=>{async function S(){const{nodeLookup:T,panZoom:E,fitViewOptions:C,fitViewResolver:N,width:k,height:H,minZoom:M,maxZoom:Y}=w();E&&(await PM({nodes:T,width:k,height:H,panZoom:E,minZoom:M,maxZoom:Y},C),N?.resolve(!0),p({fitViewResolver:null}))}return{...Nv({nodes:e,edges:r,width:o,height:c,fitView:u,fitViewOptions:f,minZoom:m,maxZoom:h,nodeOrigin:x,nodeExtent:g,defaultNodes:s,defaultEdges:i,zIndexMode:b}),setNodes:T=>{const{nodeLookup:E,parentLookup:C,nodeOrigin:N,elevateNodesOnSelect:k,fitViewQueued:H,zIndexMode:M}=w(),Y=km(T,E,C,{nodeOrigin:N,nodeExtent:g,elevateNodesOnSelect:k,checkEquality:!0,zIndexMode:M});H&&Y?(S(),p({nodes:T,nodesInitialized:Y,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:T,nodesInitialized:Y})},setEdges:T=>{const{connectionLookup:E,edgeLookup:C}=w();mw(E,C,T),p({edges:T})},setDefaultNodesAndEdges:(T,E)=>{if(T){const{setNodes:C}=w();C(T),p({hasDefaultNodes:!0})}if(E){const{setEdges:C}=w();C(E),p({hasDefaultEdges:!0})}},updateNodeInternals:T=>{const{triggerNodeChanges:E,nodeLookup:C,parentLookup:N,domNode:k,nodeOrigin:H,nodeExtent:M,debug:Y,fitViewQueued:$,zIndexMode:X}=w(),{changes:P,updatedInternals:q}=dD(T,C,N,k,H,M,X);q&&(lD(C,N,{nodeOrigin:H,nodeExtent:M,zIndexMode:X}),$?(S(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),P?.length>0&&(Y&&console.log("React Flow: trigger node changes",P),E?.(P)))},updateNodePositions:(T,E=!1)=>{const C=[];let N=[];const{nodeLookup:k,triggerNodeChanges:H,connection:M,updateConnection:Y,onNodesChangeMiddlewareMap:$}=w();for(const[X,P]of T){const q=k.get(X),F=!!(q?.expandParent&&q?.parentId&&P?.position),D={id:X,type:"position",position:F?{x:Math.max(0,P.position.x),y:Math.max(0,P.position.y)}:P.position,dragging:E};if(q&&M.inProgress&&M.fromNode.id===q.id){const _=ti(q,M.fromHandle,nt.Left,!0);Y({...M,from:_})}F&&q.parentId&&C.push({id:X,parentId:q.parentId,rect:{...P.internals.positionAbsolute,width:P.measured.width??0,height:P.measured.height??0}}),N.push(D)}if(C.length>0){const{parentLookup:X,nodeOrigin:P}=w(),q=bx(C,k,X,P);N.push(...q)}for(const X of $.values())N=X(N);H(N)},triggerNodeChanges:T=>{const{onNodesChange:E,setNodes:C,nodes:N,hasDefaultNodes:k,debug:H}=w();if(T?.length){if(k){const M=_w(T,N);C(M)}H&&console.log("React Flow: trigger node changes",T),E?.(T)}},triggerEdgeChanges:T=>{const{onEdgesChange:E,setEdges:C,edges:N,hasDefaultEdges:k,debug:H}=w();if(T?.length){if(k){const M=Aw(T,N);C(M)}H&&console.log("React Flow: trigger edge changes",T),E?.(T)}},addSelectedNodes:T=>{const{multiSelectionActive:E,edgeLookup:C,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:H}=w();if(E){const M=T.map(Y=>Ya(Y,!0));k(M);return}k(Hi(N,new Set([...T]),!0)),H(Hi(C))},addSelectedEdges:T=>{const{multiSelectionActive:E,edgeLookup:C,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:H}=w();if(E){const M=T.map(Y=>Ya(Y,!0));H(M);return}H(Hi(C,new Set([...T]))),k(Hi(N,new Set,!0))},unselectNodesAndEdges:({nodes:T,edges:E}={})=>{const{edges:C,nodes:N,nodeLookup:k,triggerNodeChanges:H,triggerEdgeChanges:M}=w(),Y=T||N,$=E||C,X=[];for(const q of Y){if(!q.selected)continue;const F=k.get(q.id);F&&(F.selected=!1),X.push(Ya(q.id,!1))}const P=[];for(const q of $)q.selected&&P.push(Ya(q.id,!1));H(X),M(P)},setMinZoom:T=>{const{panZoom:E,maxZoom:C}=w();E?.setScaleExtent([T,C]),p({minZoom:T})},setMaxZoom:T=>{const{panZoom:E,minZoom:C}=w();E?.setScaleExtent([C,T]),p({maxZoom:T})},setTranslateExtent:T=>{w().panZoom?.setTranslateExtent(T),p({translateExtent:T})},resetSelectedElements:()=>{const{edges:T,nodes:E,triggerNodeChanges:C,triggerEdgeChanges:N,elementsSelectable:k}=w();if(!k)return;const H=E.reduce((Y,$)=>$.selected?[...Y,Ya($.id,!1)]:Y,[]),M=T.reduce((Y,$)=>$.selected?[...Y,Ya($.id,!1)]:Y,[]);C(H),N(M)},setNodeExtent:T=>{const{nodes:E,nodeLookup:C,parentLookup:N,nodeOrigin:k,elevateNodesOnSelect:H,nodeExtent:M,zIndexMode:Y}=w();T[0][0]===M[0][0]&&T[0][1]===M[0][1]&&T[1][0]===M[1][0]&&T[1][1]===M[1][1]||(km(E,C,N,{nodeOrigin:k,nodeExtent:T,elevateNodesOnSelect:H,checkEquality:!1,zIndexMode:Y}),p({nodeExtent:T}))},panBy:T=>{const{transform:E,width:C,height:N,panZoom:k,translateExtent:H}=w();return fD({delta:T,panZoom:k,transform:E,translateExtent:H,width:C,height:N})},setCenter:async(T,E,C)=>{const{width:N,height:k,maxZoom:H,panZoom:M}=w();if(!M)return Promise.resolve(!1);const Y=typeof C?.zoom<"u"?C.zoom:H;return await M.setViewport({x:N/2-T*Y,y:k/2-E*Y,zoom:Y},{duration:C?.duration,ease:C?.ease,interpolate:C?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...Qj}})},updateConnection:T=>{p({connection:T})},reset:()=>p({...Nv()})}},Object.is);function AR({initialNodes:e,initialEdges:r,defaultNodes:s,defaultEdges:i,initialWidth:o,initialHeight:c,initialMinZoom:u,initialMaxZoom:f,initialFitViewOptions:m,fitView:h,nodeOrigin:x,nodeExtent:g,zIndexMode:b,children:p}){const[w]=j.useState(()=>_R({nodes:e,edges:r,defaultNodes:s,defaultEdges:i,width:o,height:c,fitView:h,minZoom:u,maxZoom:f,fitViewOptions:m,nodeOrigin:x,nodeExtent:g,zIndexMode:b}));return t.jsx(XD,{value:w,children:t.jsx(pO,{children:p})})}function MR({children:e,nodes:r,edges:s,defaultNodes:i,defaultEdges:o,width:c,height:u,fitView:f,fitViewOptions:m,minZoom:h,maxZoom:x,nodeOrigin:g,nodeExtent:b,zIndexMode:p}){return j.useContext(ed)?t.jsx(t.Fragment,{children:e}):t.jsx(AR,{initialNodes:r,initialEdges:s,defaultNodes:i,defaultEdges:o,initialWidth:c,initialHeight:u,fitView:f,initialFitViewOptions:m,initialMinZoom:h,initialMaxZoom:x,nodeOrigin:g,nodeExtent:b,zIndexMode:p,children:e})}const DR={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function OR({nodes:e,edges:r,defaultNodes:s,defaultEdges:i,className:o,nodeTypes:c,edgeTypes:u,onNodeClick:f,onEdgeClick:m,onInit:h,onMove:x,onMoveStart:g,onMoveEnd:b,onConnect:p,onConnectStart:w,onConnectEnd:S,onClickConnectStart:T,onClickConnectEnd:E,onNodeMouseEnter:C,onNodeMouseMove:N,onNodeMouseLeave:k,onNodeContextMenu:H,onNodeDoubleClick:M,onNodeDragStart:Y,onNodeDrag:$,onNodeDragStop:X,onNodesDelete:P,onEdgesDelete:q,onDelete:F,onSelectionChange:D,onSelectionDragStart:_,onSelectionDrag:I,onSelectionDragStop:A,onSelectionContextMenu:G,onSelectionStart:U,onSelectionEnd:K,onBeforeDelete:B,connectionMode:L,connectionLineType:W=ja.Bezier,connectionLineStyle:R,connectionLineComponent:z,connectionLineContainerStyle:V,deleteKeyCode:Q="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:Z=!1,selectionMode:ee=ko.Full,panActivationKeyCode:ie="Space",multiSelectionKeyCode:je=Co()?"Meta":"Control",zoomActivationKeyCode:ke=Co()?"Meta":"Control",snapToGrid:De,snapGrid:Ie,onlyRenderVisibleElements:ze=!1,selectNodesOnDrag:Ze,nodesDraggable:Ae,autoPanOnNodeFocus:We,nodesConnectable:xt,nodesFocusable:Lt,nodeOrigin:le=Ew,edgesFocusable:_e,edgesReconnectable:ht,elementsSelectable:Ct=!0,defaultViewport:Ft=lO,minZoom:be=.5,maxZoom:Me=2,translateExtent:Ve=No,preventScrolling:Xe=!0,nodeExtent:rt,defaultMarkerColor:It="#b1b1b7",zoomOnScroll:Ht=!0,zoomOnPinch:_t=!0,panOnScroll:wt=!1,panOnScrollSpeed:xe=.5,panOnScrollMode:Be=Qa.Free,zoomOnDoubleClick:gt=!0,panOnDrag:pt=!0,onPaneClick:ue,onPaneMouseEnter:Se,onPaneMouseMove:Ke,onPaneMouseLeave:At,onPaneScroll:rn,onPaneContextMenu:vn,paneClickDistance:Mt=1,nodeClickDistance:oe=0,children:Le,onReconnect:$e,onReconnectStart:st,onReconnectEnd:at,onEdgeContextMenu:Ue,onEdgeDoubleClick:jn,onEdgeMouseEnter:gn,onEdgeMouseMove:Dt,onEdgeMouseLeave:Dn,reconnectRadius:Un=10,onNodesChange:On,onEdgesChange:on,noDragClassName:cn="nodrag",noWheelClassName:wn="nowheel",noPanClassName:qn="nopan",fitView:ve,fitViewOptions:Qe,connectOnClick:Nt,attributionPosition:Et,proOptions:Nn,defaultEdgeOptions:ar,elevateNodesOnSelect:ir=!0,elevateEdgesOnSelect:Or=!1,disableKeyboardA11y:Rr=!1,autoPanOnConnect:vr,autoPanOnNodeDrag:un,autoPanSpeed:zr,connectionRadius:Ps,isValidConnection:lr,onError:or,style:Us,id:Tn,nodeDragThreshold:Gr,connectionDragThreshold:Sa,viewport:cr,onViewportChange:Lr,width:Yn,height:kn,colorMode:jr="light",debug:ne,onScroll:Oe,ariaLabelConfig:Pe,zIndexMode:et="basic",...re},pe){const Ne=Tn||"1",ye=dO(jr),dt=j.useCallback(He=>{He.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Oe?.(He)},[Oe]);return t.jsx("div",{"data-testid":"rf__wrapper",...re,onScroll:dt,style:{...Us,...DR},ref:pe,className:Pn(["react-flow",o,ye]),id:Tn,role:"application",children:t.jsxs(MR,{nodes:e,edges:r,width:Yn,height:kn,fitView:ve,fitViewOptions:Qe,minZoom:be,maxZoom:Me,nodeOrigin:le,nodeExtent:rt,zIndexMode:et,children:[t.jsx(TR,{onInit:h,onNodeClick:f,onEdgeClick:m,onNodeMouseEnter:C,onNodeMouseMove:N,onNodeMouseLeave:k,onNodeContextMenu:H,onNodeDoubleClick:M,nodeTypes:c,edgeTypes:u,connectionLineType:W,connectionLineStyle:R,connectionLineComponent:z,connectionLineContainerStyle:V,selectionKeyCode:te,selectionOnDrag:Z,selectionMode:ee,deleteKeyCode:Q,multiSelectionKeyCode:je,panActivationKeyCode:ie,zoomActivationKeyCode:ke,onlyRenderVisibleElements:ze,defaultViewport:Ft,translateExtent:Ve,minZoom:be,maxZoom:Me,preventScrolling:Xe,zoomOnScroll:Ht,zoomOnPinch:_t,zoomOnDoubleClick:gt,panOnScroll:wt,panOnScrollSpeed:xe,panOnScrollMode:Be,panOnDrag:pt,onPaneClick:ue,onPaneMouseEnter:Se,onPaneMouseMove:Ke,onPaneMouseLeave:At,onPaneScroll:rn,onPaneContextMenu:vn,paneClickDistance:Mt,nodeClickDistance:oe,onSelectionContextMenu:G,onSelectionStart:U,onSelectionEnd:K,onReconnect:$e,onReconnectStart:st,onReconnectEnd:at,onEdgeContextMenu:Ue,onEdgeDoubleClick:jn,onEdgeMouseEnter:gn,onEdgeMouseMove:Dt,onEdgeMouseLeave:Dn,reconnectRadius:Un,defaultMarkerColor:It,noDragClassName:cn,noWheelClassName:wn,noPanClassName:qn,rfId:Ne,disableKeyboardA11y:Rr,nodeExtent:rt,viewport:cr,onViewportChange:Lr}),t.jsx(uO,{nodes:e,edges:r,defaultNodes:s,defaultEdges:i,onConnect:p,onConnectStart:w,onConnectEnd:S,onClickConnectStart:T,onClickConnectEnd:E,nodesDraggable:Ae,autoPanOnNodeFocus:We,nodesConnectable:xt,nodesFocusable:Lt,edgesFocusable:_e,edgesReconnectable:ht,elementsSelectable:Ct,elevateNodesOnSelect:ir,elevateEdgesOnSelect:Or,minZoom:be,maxZoom:Me,nodeExtent:rt,onNodesChange:On,onEdgesChange:on,snapToGrid:De,snapGrid:Ie,connectionMode:L,translateExtent:Ve,connectOnClick:Nt,defaultEdgeOptions:ar,fitView:ve,fitViewOptions:Qe,onNodesDelete:P,onEdgesDelete:q,onDelete:F,onNodeDragStart:Y,onNodeDrag:$,onNodeDragStop:X,onSelectionDrag:I,onSelectionDragStart:_,onSelectionDragStop:A,onMove:x,onMoveStart:g,onMoveEnd:b,noPanClassName:qn,nodeOrigin:le,rfId:Ne,autoPanOnConnect:vr,autoPanOnNodeDrag:un,autoPanSpeed:zr,onError:or,connectionRadius:Ps,isValidConnection:lr,selectNodesOnDrag:Ze,nodeDragThreshold:Gr,connectionDragThreshold:Sa,onBeforeDelete:B,debug:ne,ariaLabelConfig:Pe,zIndexMode:et}),t.jsx(iO,{onSelectionChange:D}),Le,t.jsx(tO,{proOptions:Nn,position:Et}),t.jsx(eO,{rfId:Ne,disableKeyboardA11y:Rr})]})})}var RR=Mw(OR);function zR(e){const[r,s]=j.useState(e),i=j.useCallback(o=>s(c=>_w(o,c)),[]);return[r,s,i]}function LR(e){const[r,s]=j.useState(e),i=j.useCallback(o=>s(c=>Aw(o,c)),[]);return[r,s,i]}function IR({dimensions:e,lineWidth:r,variant:s,className:i}){return t.jsx("path",{strokeWidth:r,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Pn(["react-flow__background-pattern",s,i])})}function $R({radius:e,className:r}){return t.jsx("circle",{cx:e,cy:e,r:e,className:Pn(["react-flow__background-pattern","dots",r])})}var wa;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(wa||(wa={}));const BR={[wa.Dots]:1,[wa.Lines]:1,[wa.Cross]:6},HR=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function tN({id:e,variant:r=wa.Dots,gap:s=20,size:i,lineWidth:o=1,offset:c=0,color:u,bgColor:f,style:m,className:h,patternClassName:x}){const g=j.useRef(null),{transform:b,patternId:p}=Vt(HR,bn),w=i||BR[r],S=r===wa.Dots,T=r===wa.Cross,E=Array.isArray(s)?s:[s,s],C=[E[0]*b[2]||1,E[1]*b[2]||1],N=w*b[2],k=Array.isArray(c)?c:[c,c],H=T?[N,N]:C,M=[k[0]*b[2]||1+H[0]/2,k[1]*b[2]||1+H[1]/2],Y=`${p}${e||""}`;return t.jsxs("svg",{className:Pn(["react-flow__background",h]),style:{...m,...nd,"--xy-background-color-props":f,"--xy-background-pattern-color-props":u},ref:g,"data-testid":"rf__background",children:[t.jsx("pattern",{id:Y,x:b[0]%C[0],y:b[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${M[0]},-${M[1]})`,children:S?t.jsx($R,{radius:N/2,className:x}):t.jsx(IR,{dimensions:H,lineWidth:o,variant:r,className:x})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${Y})`})]})}tN.displayName="Background";const PR=j.memo(tN);function UR(){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 qR(){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 VR(){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 FR(){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 YR(){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 lu({children:e,className:r,...s}){return t.jsx("button",{type:"button",className:Pn(["react-flow__controls-button",r]),...s,children:e})}const GR=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function nN({style:e,showZoom:r=!0,showFitView:s=!0,showInteractive:i=!0,fitViewOptions:o,onZoomIn:c,onZoomOut:u,onFitView:f,onInteractiveChange:m,className:h,children:x,position:g="bottom-left",orientation:b="vertical","aria-label":p}){const w=yn(),{isInteractive:S,minZoomReached:T,maxZoomReached:E,ariaLabelConfig:C}=Vt(GR,bn),{zoomIn:N,zoomOut:k,fitView:H}=yx(),M=()=>{N(),c?.()},Y=()=>{k(),u?.()},$=()=>{H(o),f?.()},X=()=>{w.setState({nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S}),m?.(!S)},P=b==="horizontal"?"horizontal":"vertical";return t.jsxs(td,{className:Pn(["react-flow__controls",P,h]),position:g,style:e,"data-testid":"rf__controls","aria-label":p??C["controls.ariaLabel"],children:[r&&t.jsxs(t.Fragment,{children:[t.jsx(lu,{onClick:M,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:E,children:t.jsx(UR,{})}),t.jsx(lu,{onClick:Y,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:T,children:t.jsx(qR,{})})]}),s&&t.jsx(lu,{className:"react-flow__controls-fitview",onClick:$,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:t.jsx(VR,{})}),i&&t.jsx(lu,{className:"react-flow__controls-interactive",onClick:X,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:S?t.jsx(YR,{}):t.jsx(FR,{})}),x]})}nN.displayName="Controls";const XR=j.memo(nN);function ZR({id:e,x:r,y:s,width:i,height:o,style:c,color:u,strokeColor:f,strokeWidth:m,className:h,borderRadius:x,shapeRendering:g,selected:b,onClick:p}){const{background:w,backgroundColor:S}=c||{},T=u||w||S;return t.jsx("rect",{className:Pn(["react-flow__minimap-node",{selected:b},h]),x:r,y:s,rx:x,ry:x,width:i,height:o,style:{fill:T,stroke:f,strokeWidth:m},shapeRendering:g,onClick:p?E=>p(E,e):void 0})}const QR=j.memo(ZR),KR=e=>e.nodes.map(r=>r.id),Fh=e=>e instanceof Function?e:()=>e;function JR({nodeStrokeColor:e,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:c=QR,onClick:u}){const f=Vt(KR,bn),m=Fh(r),h=Fh(e),x=Fh(s),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:f.map(b=>t.jsx(ez,{id:b,nodeColorFunc:m,nodeStrokeColorFunc:h,nodeClassNameFunc:x,nodeBorderRadius:i,nodeStrokeWidth:o,NodeComponent:c,onClick:u,shapeRendering:g},b))})}function WR({id:e,nodeColorFunc:r,nodeStrokeColorFunc:s,nodeClassNameFunc:i,nodeBorderRadius:o,nodeStrokeWidth:c,shapeRendering:u,NodeComponent:f,onClick:m}){const{node:h,x,y:g,width:b,height:p}=Vt(w=>{const S=w.nodeLookup.get(e);if(!S)return{node:void 0,x:0,y:0,width:0,height:0};const T=S.internals.userNode,{x:E,y:C}=S.internals.positionAbsolute,{width:N,height:k}=Hs(T);return{node:T,x:E,y:C,width:N,height:k}},bn);return!h||h.hidden||!rw(h)?null:t.jsx(f,{x,y:g,width:b,height:p,style:h.style,selected:!!h.selected,className:i(h),color:r(h),borderRadius:o,strokeColor:s(h),strokeWidth:c,shapeRendering:u,onClick:m,id:h.id})}const ez=j.memo(WR);var tz=j.memo(JR);const nz=200,rz=150,sz=e=>!e.hidden,az=e=>{const r={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:r,boundingRect:e.nodeLookup.size>0?nw(Lo(e.nodeLookup,{filter:sz}),r):r,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},iz="react-flow__minimap-desc";function rN({style:e,className:r,nodeStrokeColor:s,nodeColor:i,nodeClassName:o="",nodeBorderRadius:c=5,nodeStrokeWidth:u,nodeComponent:f,bgColor:m,maskColor:h,maskStrokeColor:x,maskStrokeWidth:g,position:b="bottom-right",onClick:p,onNodeClick:w,pannable:S=!1,zoomable:T=!1,ariaLabel:E,inversePan:C,zoomStep:N=1,offsetScale:k=5}){const H=yn(),M=j.useRef(null),{boundingRect:Y,viewBB:$,rfId:X,panZoom:P,translateExtent:q,flowWidth:F,flowHeight:D,ariaLabelConfig:_}=Vt(az,bn),I=e?.width??nz,A=e?.height??rz,G=Y.width/I,U=Y.height/A,K=Math.max(G,U),B=K*I,L=K*A,W=k*K,R=Y.x-(B-Y.width)/2-W,z=Y.y-(L-Y.height)/2-W,V=B+W*2,Q=L+W*2,te=`${iz}-${X}`,Z=j.useRef(0),ee=j.useRef();Z.current=K,j.useEffect(()=>{if(M.current&&P)return ee.current=jD({domNode:M.current,panZoom:P,getTransform:()=>H.getState().transform,getViewScale:()=>Z.current}),()=>{ee.current?.destroy()}},[P]),j.useEffect(()=>{ee.current?.update({translateExtent:q,width:F,height:D,inversePan:C,pannable:S,zoomStep:N,zoomable:T})},[S,T,C,N,q,F,D]);const ie=p?De=>{const[Ie,ze]=ee.current?.pointer(De)||[0,0];p(De,{x:Ie,y:ze})}:void 0,je=w?j.useCallback((De,Ie)=>{const ze=H.getState().nodeLookup.get(Ie).internals.userNode;w(De,ze)},[]):void 0,ke=E??_["minimap.ariaLabel"];return t.jsx(td,{position:b,style:{...e,"--xy-minimap-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof g=="number"?g*K:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-width-props":typeof u=="number"?u:void 0},className:Pn(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:I,height:A,viewBox:`${R} ${z} ${V} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:M,onClick:ie,children:[ke&&t.jsx("title",{id:te,children:ke}),t.jsx(tz,{onClick:je,nodeColor:i,nodeStrokeColor:s,nodeBorderRadius:c,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:f}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${R-W},${z-W}h${V+W*2}v${Q+W*2}h${-V-W*2}z
|
|
61
|
-
M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}rN.displayName="MiniMap";const lz=j.memo(rN),oz=e=>r=>e?`${Math.max(1/r.transform[2],1)}`:void 0,cz={[Wi.Line]:"right",[Wi.Handle]:"bottom-right"};function uz({nodeId:e,position:r,variant:s=Wi.Handle,className:i,style:o=void 0,children:c,color:u,minWidth:f=10,minHeight:m=10,maxWidth:h=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:b,autoScale:p=!0,shouldResize:w,onResizeStart:S,onResize:T,onResizeEnd:E}){const C=zw(),N=typeof e=="string"?e:C,k=yn(),H=j.useRef(null),M=s===Wi.Handle,Y=Vt(j.useCallback(oz(M&&p),[M,p]),bn),$=j.useRef(null),X=r??cz[s];j.useEffect(()=>{if(!(!H.current||!N))return $.current||($.current=zD({domNode:H.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:q,transform:F,snapGrid:D,snapToGrid:_,nodeOrigin:I,domNode:A}=k.getState();return{nodeLookup:q,transform:F,snapGrid:D,snapToGrid:_,nodeOrigin:I,paneDomNode:A}},onChange:(q,F)=>{const{triggerNodeChanges:D,nodeLookup:_,parentLookup:I,nodeOrigin:A}=k.getState(),G=[],U={x:q.x,y:q.y},K=_.get(N);if(K&&K.expandParent&&K.parentId){const B=K.origin??A,L=q.width??K.measured.width??0,W=q.height??K.measured.height??0,R={id:K.id,parentId:K.parentId,rect:{width:L,height:W,...sw({x:q.x??K.position.x,y:q.y??K.position.y},{width:L,height:W},K.parentId,_,B)}},z=bx([R],_,I,A);G.push(...z),U.x=q.x?Math.max(B[0]*L,q.x):void 0,U.y=q.y?Math.max(B[1]*W,q.y):void 0}if(U.x!==void 0&&U.y!==void 0){const B={id:N,type:"position",position:{...U}};G.push(B)}if(q.width!==void 0&&q.height!==void 0){const L={id:N,type:"dimensions",resizing:!0,setAttributes:b?b==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};G.push(L)}for(const B of F){const L={...B,type:"position"};G.push(L)}D(G)},onEnd:({width:q,height:F})=>{const D={id:N,type:"dimensions",resizing:!1,dimensions:{width:q,height:F}};k.getState().triggerNodeChanges([D])}})),$.current.update({controlPosition:X,boundaries:{minWidth:f,minHeight:m,maxWidth:h,maxHeight:x},keepAspectRatio:g,resizeDirection:b,onResizeStart:S,onResize:T,onResizeEnd:E,shouldResize:w}),()=>{$.current?.destroy()}},[X,f,m,h,x,g,S,T,E,w]);const P=X.split("-");return t.jsx("div",{className:Pn(["react-flow__resize-control","nodrag",...P,s,i]),ref:H,style:{...o,scale:Y,...u&&{[M?"backgroundColor":"borderColor"]:u}},children:c})}j.memo(uz);var Wt=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),ns=Wt((e,r)=>{var s=Object.defineProperty,i=(D,_,I)=>_ in D?s(D,_,{enumerable:!0,configurable:!0,writable:!0,value:I}):D[_]=I,o=(D,_)=>()=>(_||D((_={exports:{}}).exports,_),_.exports),c=(D,_,I)=>i(D,typeof _!="symbol"?_+"":_,I),u=o((D,_)=>{var I="\0",A="\0",G="",U=class{constructor(z){c(this,"_isDirected",!0),c(this,"_isMultigraph",!1),c(this,"_isCompound",!1),c(this,"_label"),c(this,"_defaultNodeLabelFn",()=>{}),c(this,"_defaultEdgeLabelFn",()=>{}),c(this,"_nodes",{}),c(this,"_in",{}),c(this,"_preds",{}),c(this,"_out",{}),c(this,"_sucs",{}),c(this,"_edgeObjs",{}),c(this,"_edgeLabels",{}),c(this,"_nodeCount",0),c(this,"_edgeCount",0),c(this,"_parent"),c(this,"_children"),z&&(this._isDirected=Object.hasOwn(z,"directed")?z.directed:!0,this._isMultigraph=Object.hasOwn(z,"multigraph")?z.multigraph:!1,this._isCompound=Object.hasOwn(z,"compound")?z.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[A]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(z){return this._label=z,this}graph(){return this._label}setDefaultNodeLabel(z){return this._defaultNodeLabelFn=z,typeof z!="function"&&(this._defaultNodeLabelFn=()=>z),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var z=this;return this.nodes().filter(V=>Object.keys(z._in[V]).length===0)}sinks(){var z=this;return this.nodes().filter(V=>Object.keys(z._out[V]).length===0)}setNodes(z,V){var Q=arguments,te=this;return z.forEach(function(Z){Q.length>1?te.setNode(Z,V):te.setNode(Z)}),this}setNode(z,V){return Object.hasOwn(this._nodes,z)?(arguments.length>1&&(this._nodes[z]=V),this):(this._nodes[z]=arguments.length>1?V:this._defaultNodeLabelFn(z),this._isCompound&&(this._parent[z]=A,this._children[z]={},this._children[A][z]=!0),this._in[z]={},this._preds[z]={},this._out[z]={},this._sucs[z]={},++this._nodeCount,this)}node(z){return this._nodes[z]}hasNode(z){return Object.hasOwn(this._nodes,z)}removeNode(z){var V=this;if(Object.hasOwn(this._nodes,z)){var Q=te=>V.removeEdge(V._edgeObjs[te]);delete this._nodes[z],this._isCompound&&(this._removeFromParentsChildList(z),delete this._parent[z],this.children(z).forEach(function(te){V.setParent(te)}),delete this._children[z]),Object.keys(this._in[z]).forEach(Q),delete this._in[z],delete this._preds[z],Object.keys(this._out[z]).forEach(Q),delete this._out[z],delete this._sucs[z],--this._nodeCount}return this}setParent(z,V){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(V===void 0)V=A;else{V+="";for(var Q=V;Q!==void 0;Q=this.parent(Q))if(Q===z)throw new Error("Setting "+V+" as parent of "+z+" would create a cycle");this.setNode(V)}return this.setNode(z),this._removeFromParentsChildList(z),this._parent[z]=V,this._children[V][z]=!0,this}_removeFromParentsChildList(z){delete this._children[this._parent[z]][z]}parent(z){if(this._isCompound){var V=this._parent[z];if(V!==A)return V}}children(z=A){if(this._isCompound){var V=this._children[z];if(V)return Object.keys(V)}else{if(z===A)return this.nodes();if(this.hasNode(z))return[]}}predecessors(z){var V=this._preds[z];if(V)return Object.keys(V)}successors(z){var V=this._sucs[z];if(V)return Object.keys(V)}neighbors(z){var V=this.predecessors(z);if(V){let te=new Set(V);for(var Q of this.successors(z))te.add(Q);return Array.from(te.values())}}isLeaf(z){var V;return this.isDirected()?V=this.successors(z):V=this.neighbors(z),V.length===0}filterNodes(z){var V=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});V.setGraph(this.graph());var Q=this;Object.entries(this._nodes).forEach(function([ee,ie]){z(ee)&&V.setNode(ee,ie)}),Object.values(this._edgeObjs).forEach(function(ee){V.hasNode(ee.v)&&V.hasNode(ee.w)&&V.setEdge(ee,Q.edge(ee))});var te={};function Z(ee){var ie=Q.parent(ee);return ie===void 0||V.hasNode(ie)?(te[ee]=ie,ie):ie in te?te[ie]:Z(ie)}return this._isCompound&&V.nodes().forEach(ee=>V.setParent(ee,Z(ee))),V}setDefaultEdgeLabel(z){return this._defaultEdgeLabelFn=z,typeof z!="function"&&(this._defaultEdgeLabelFn=()=>z),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(z,V){var Q=this,te=arguments;return z.reduce(function(Z,ee){return te.length>1?Q.setEdge(Z,ee,V):Q.setEdge(Z,ee),ee}),this}setEdge(){var z,V,Q,te,Z=!1,ee=arguments[0];typeof ee=="object"&&ee!==null&&"v"in ee?(z=ee.v,V=ee.w,Q=ee.name,arguments.length===2&&(te=arguments[1],Z=!0)):(z=ee,V=arguments[1],Q=arguments[3],arguments.length>2&&(te=arguments[2],Z=!0)),z=""+z,V=""+V,Q!==void 0&&(Q=""+Q);var ie=L(this._isDirected,z,V,Q);if(Object.hasOwn(this._edgeLabels,ie))return Z&&(this._edgeLabels[ie]=te),this;if(Q!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(z),this.setNode(V),this._edgeLabels[ie]=Z?te:this._defaultEdgeLabelFn(z,V,Q);var je=W(this._isDirected,z,V,Q);return z=je.v,V=je.w,Object.freeze(je),this._edgeObjs[ie]=je,K(this._preds[V],z),K(this._sucs[z],V),this._in[V][ie]=je,this._out[z][ie]=je,this._edgeCount++,this}edge(z,V,Q){var te=arguments.length===1?R(this._isDirected,arguments[0]):L(this._isDirected,z,V,Q);return this._edgeLabels[te]}edgeAsObj(){let z=this.edge(...arguments);return typeof z!="object"?{label:z}:z}hasEdge(z,V,Q){var te=arguments.length===1?R(this._isDirected,arguments[0]):L(this._isDirected,z,V,Q);return Object.hasOwn(this._edgeLabels,te)}removeEdge(z,V,Q){var te=arguments.length===1?R(this._isDirected,arguments[0]):L(this._isDirected,z,V,Q),Z=this._edgeObjs[te];return Z&&(z=Z.v,V=Z.w,delete this._edgeLabels[te],delete this._edgeObjs[te],B(this._preds[V],z),B(this._sucs[z],V),delete this._in[V][te],delete this._out[z][te],this._edgeCount--),this}inEdges(z,V){return this.isDirected()?this.filterEdges(this._in[z],z,V):this.nodeEdges(z,V)}outEdges(z,V){return this.isDirected()?this.filterEdges(this._out[z],z,V):this.nodeEdges(z,V)}nodeEdges(z,V){if(z in this._nodes)return this.filterEdges({...this._in[z],...this._out[z]},z,V)}filterEdges(z,V,Q){if(z){var te=Object.values(z);return Q?te.filter(function(Z){return Z.v===V&&Z.w===Q||Z.v===Q&&Z.w===V}):te}}};function K(z,V){z[V]?z[V]++:z[V]=1}function B(z,V){--z[V]||delete z[V]}function L(z,V,Q,te){var Z=""+V,ee=""+Q;if(!z&&Z>ee){var ie=Z;Z=ee,ee=ie}return Z+G+ee+G+(te===void 0?I:te)}function W(z,V,Q,te){var Z=""+V,ee=""+Q;if(!z&&Z>ee){var ie=Z;Z=ee,ee=ie}var je={v:Z,w:ee};return te&&(je.name=te),je}function R(z,V){return L(z,V.v,V.w,V.name)}_.exports=U}),f=o((D,_)=>{_.exports="3.0.2"}),m=o((D,_)=>{_.exports={Graph:u(),version:f()}}),h=o((D,_)=>{var I=u();_.exports={write:A,read:K};function A(B){var L={options:{directed:B.isDirected(),multigraph:B.isMultigraph(),compound:B.isCompound()},nodes:G(B),edges:U(B)};return B.graph()!==void 0&&(L.value=structuredClone(B.graph())),L}function G(B){return B.nodes().map(function(L){var W=B.node(L),R=B.parent(L),z={v:L};return W!==void 0&&(z.value=W),R!==void 0&&(z.parent=R),z})}function U(B){return B.edges().map(function(L){var W=B.edge(L),R={v:L.v,w:L.w};return L.name!==void 0&&(R.name=L.name),W!==void 0&&(R.value=W),R})}function K(B){var L=new I(B.options).setGraph(B.value);return B.nodes.forEach(function(W){L.setNode(W.v,W.value),W.parent&&L.setParent(W.v,W.parent)}),B.edges.forEach(function(W){L.setEdge({v:W.v,w:W.w,name:W.name},W.value)}),L}}),x=o((D,_)=>{_.exports=A;var I=()=>1;function A(U,K,B,L){return G(U,String(K),B||I,L||function(W){return U.outEdges(W)})}function G(U,K,B,L){var W={},R=!0,z=0,V=U.nodes(),Q=function(ie){var je=B(ie);W[ie.v].distance+je<W[ie.w].distance&&(W[ie.w]={distance:W[ie.v].distance+je,predecessor:ie.v},R=!0)},te=function(){V.forEach(function(ie){L(ie).forEach(function(je){var ke=je.v===ie?je.v:je.w,De=ke===je.v?je.w:je.v;Q({v:ke,w:De})})})};V.forEach(function(ie){var je=ie===K?0:Number.POSITIVE_INFINITY;W[ie]={distance:je}});for(var Z=V.length,ee=1;ee<Z&&(R=!1,z++,te(),!!R);ee++);if(z===Z-1&&(R=!1,te(),R))throw new Error("The graph contains a negative weight cycle");return W}}),g=o((D,_)=>{_.exports=I;function I(A){var G={},U=[],K;function B(L){Object.hasOwn(G,L)||(G[L]=!0,K.push(L),A.successors(L).forEach(B),A.predecessors(L).forEach(B))}return A.nodes().forEach(function(L){K=[],B(L),K.length&&U.push(K)}),U}}),b=o((D,_)=>{var I=class{constructor(){c(this,"_arr",[]),c(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(A){return A.key})}has(A){return Object.hasOwn(this._keyIndices,A)}priority(A){var G=this._keyIndices[A];if(G!==void 0)return this._arr[G].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(A,G){var U=this._keyIndices;if(A=String(A),!Object.hasOwn(U,A)){var K=this._arr,B=K.length;return U[A]=B,K.push({key:A,priority:G}),this._decrease(B),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var A=this._arr.pop();return delete this._keyIndices[A.key],this._heapify(0),A.key}decrease(A,G){var U=this._keyIndices[A];if(G>this._arr[U].priority)throw new Error("New priority is greater than current priority. Key: "+A+" Old: "+this._arr[U].priority+" New: "+G);this._arr[U].priority=G,this._decrease(U)}_heapify(A){var G=this._arr,U=2*A,K=U+1,B=A;U<G.length&&(B=G[U].priority<G[B].priority?U:B,K<G.length&&(B=G[K].priority<G[B].priority?K:B),B!==A&&(this._swap(A,B),this._heapify(B)))}_decrease(A){for(var G=this._arr,U=G[A].priority,K;A!==0&&(K=A>>1,!(G[K].priority<U));)this._swap(A,K),A=K}_swap(A,G){var U=this._arr,K=this._keyIndices,B=U[A],L=U[G];U[A]=L,U[G]=B,K[L.key]=A,K[B.key]=G}};_.exports=I}),p=o((D,_)=>{var I=b();_.exports=G;var A=()=>1;function G(K,B,L,W){var R=function(z){return K.outEdges(z)};return U(K,String(B),L||A,W||R)}function U(K,B,L,W){var R={},z=new I,V,Q,te=function(Z){var ee=Z.v!==V?Z.v:Z.w,ie=R[ee],je=L(Z),ke=Q.distance+je;if(je<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+Z+" Weight: "+je);ke<ie.distance&&(ie.distance=ke,ie.predecessor=V,z.decrease(ee,ke))};for(K.nodes().forEach(function(Z){var ee=Z===B?0:Number.POSITIVE_INFINITY;R[Z]={distance:ee},z.add(Z,ee)});z.size()>0&&(V=z.removeMin(),Q=R[V],Q.distance!==Number.POSITIVE_INFINITY);)W(V).forEach(te);return R}}),w=o((D,_)=>{var I=p();_.exports=A;function A(G,U,K){return G.nodes().reduce(function(B,L){return B[L]=I(G,L,U,K),B},{})}}),S=o((D,_)=>{_.exports=I;function I(G,U,K){if(G[U].predecessor!==void 0)throw new Error("Invalid source vertex");if(G[K].predecessor===void 0&&K!==U)throw new Error("Invalid destination vertex");return{weight:G[K].distance,path:A(G,U,K)}}function A(G,U,K){for(var B=[],L=K;L!==U;)B.push(L),L=G[L].predecessor;return B.push(U),B.reverse()}}),T=o((D,_)=>{_.exports=I;function I(A){var G=0,U=[],K={},B=[];function L(W){var R=K[W]={onStack:!0,lowlink:G,index:G++};if(U.push(W),A.successors(W).forEach(function(Q){Object.hasOwn(K,Q)?K[Q].onStack&&(R.lowlink=Math.min(R.lowlink,K[Q].index)):(L(Q),R.lowlink=Math.min(R.lowlink,K[Q].lowlink))}),R.lowlink===R.index){var z=[],V;do V=U.pop(),K[V].onStack=!1,z.push(V);while(W!==V);B.push(z)}}return A.nodes().forEach(function(W){Object.hasOwn(K,W)||L(W)}),B}}),E=o((D,_)=>{var I=T();_.exports=A;function A(G){return I(G).filter(function(U){return U.length>1||U.length===1&&G.hasEdge(U[0],U[0])})}}),C=o((D,_)=>{_.exports=A;var I=()=>1;function A(U,K,B){return G(U,K||I,B||function(L){return U.outEdges(L)})}function G(U,K,B){var L={},W=U.nodes();return W.forEach(function(R){L[R]={},L[R][R]={distance:0},W.forEach(function(z){R!==z&&(L[R][z]={distance:Number.POSITIVE_INFINITY})}),B(R).forEach(function(z){var V=z.v===R?z.w:z.v,Q=K(z);L[R][V]={distance:Q,predecessor:R}})}),W.forEach(function(R){var z=L[R];W.forEach(function(V){var Q=L[V];W.forEach(function(te){var Z=Q[R],ee=z[te],ie=Q[te],je=Z.distance+ee.distance;je<ie.distance&&(ie.distance=je,ie.predecessor=ee.predecessor)})})}),L}}),N=o((D,_)=>{function I(G){var U={},K={},B=[];function L(W){if(Object.hasOwn(K,W))throw new A;Object.hasOwn(U,W)||(K[W]=!0,U[W]=!0,G.predecessors(W).forEach(L),delete K[W],B.push(W))}if(G.sinks().forEach(L),Object.keys(U).length!==G.nodeCount())throw new A;return B}var A=class extends Error{constructor(){super(...arguments)}};_.exports=I,I.CycleException=A}),k=o((D,_)=>{var I=N();_.exports=A;function A(G){try{I(G)}catch(U){if(U instanceof I.CycleException)return!1;throw U}return!0}}),H=o((D,_)=>{_.exports=I;function I(G,U,K,B,L){Array.isArray(U)||(U=[U]);var W=(G.isDirected()?G.successors:G.neighbors).bind(G),R={};return U.forEach(function(z){if(!G.hasNode(z))throw new Error("Graph does not have node: "+z);L=A(G,z,K==="post",R,W,B,L)}),L}function A(G,U,K,B,L,W,R){return Object.hasOwn(B,U)||(B[U]=!0,K||(R=W(R,U)),L(U).forEach(function(z){R=A(G,z,K,B,L,W,R)}),K&&(R=W(R,U))),R}}),M=o((D,_)=>{var I=H();_.exports=A;function A(G,U,K){return I(G,U,K,function(B,L){return B.push(L),B},[])}}),Y=o((D,_)=>{var I=M();_.exports=A;function A(G,U){return I(G,U,"post")}}),$=o((D,_)=>{var I=M();_.exports=A;function A(G,U){return I(G,U,"pre")}}),X=o((D,_)=>{var I=u(),A=b();_.exports=G;function G(U,K){var B=new I,L={},W=new A,R;function z(Q){var te=Q.v===R?Q.w:Q.v,Z=W.priority(te);if(Z!==void 0){var ee=K(Q);ee<Z&&(L[te]=R,W.decrease(te,ee))}}if(U.nodeCount()===0)return B;U.nodes().forEach(function(Q){W.add(Q,Number.POSITIVE_INFINITY),B.setNode(Q)}),W.decrease(U.nodes()[0],0);for(var V=!1;W.size()>0;){if(R=W.removeMin(),Object.hasOwn(L,R))B.setEdge(R,L[R]);else{if(V)throw new Error("Input graph is not connected: "+U);V=!0}U.nodeEdges(R).forEach(z)}return B}}),P=o((D,_)=>{var I=p(),A=x();_.exports=G;function G(K,B,L,W){return U(K,B,L,W||function(R){return K.outEdges(R)})}function U(K,B,L,W){if(L===void 0)return I(K,B,L,W);for(var R=!1,z=K.nodes(),V=0;V<z.length;V++){for(var Q=W(z[V]),te=0;te<Q.length;te++){var Z=Q[te],ee=Z.v===z[V]?Z.v:Z.w,ie=ee===Z.v?Z.w:Z.v;L({v:ee,w:ie})<0&&(R=!0)}if(R)return A(K,B,L,W)}return I(K,B,L,W)}}),q=o((D,_)=>{_.exports={bellmanFord:x(),components:g(),dijkstra:p(),dijkstraAll:w(),extractPath:S(),findCycles:E(),floydWarshall:C(),isAcyclic:k(),postorder:Y(),preorder:$(),prim:X(),shortestPaths:P(),reduce:H(),tarjan:T(),topsort:N()}}),F=m();r.exports={Graph:F.Graph,json:h(),alg:q(),version:F.version}}),dz=Wt((e,r)=>{var s=class{constructor(){let c={};c._next=c._prev=c,this._sentinel=c}dequeue(){let c=this._sentinel,u=c._prev;if(u!==c)return i(u),u}enqueue(c){let u=this._sentinel;c._prev&&c._next&&i(c),c._next=u._next,u._next._prev=c,u._next=c,c._prev=u}toString(){let c=[],u=this._sentinel,f=u._prev;for(;f!==u;)c.push(JSON.stringify(f,o)),f=f._prev;return"["+c.join(", ")+"]"}};function i(c){c._prev._next=c._next,c._next._prev=c._prev,delete c._next,delete c._prev}function o(c,u){if(c!=="_next"&&c!=="_prev")return u}r.exports=s}),fz=Wt((e,r)=>{var s=ns().Graph,i=dz();r.exports=c;var o=()=>1;function c(g,b){if(g.nodeCount()<=1)return[];let p=m(g,b||o);return u(p.graph,p.buckets,p.zeroIdx).flatMap(w=>g.outEdges(w.v,w.w))}function u(g,b,p){let w=[],S=b[b.length-1],T=b[0],E;for(;g.nodeCount();){for(;E=T.dequeue();)f(g,b,p,E);for(;E=S.dequeue();)f(g,b,p,E);if(g.nodeCount()){for(let C=b.length-2;C>0;--C)if(E=b[C].dequeue(),E){w=w.concat(f(g,b,p,E,!0));break}}}return w}function f(g,b,p,w,S){let T=S?[]:void 0;return g.inEdges(w.v).forEach(E=>{let C=g.edge(E),N=g.node(E.v);S&&T.push({v:E.v,w:E.w}),N.out-=C,h(b,p,N)}),g.outEdges(w.v).forEach(E=>{let C=g.edge(E),N=E.w,k=g.node(N);k.in-=C,h(b,p,k)}),g.removeNode(w.v),T}function m(g,b){let p=new s,w=0,S=0;g.nodes().forEach(C=>{p.setNode(C,{v:C,in:0,out:0})}),g.edges().forEach(C=>{let N=p.edge(C.v,C.w)||0,k=b(C),H=N+k;p.setEdge(C.v,C.w,H),S=Math.max(S,p.node(C.v).out+=k),w=Math.max(w,p.node(C.w).in+=k)});let T=x(S+w+3).map(()=>new i),E=w+1;return p.nodes().forEach(C=>{h(T,E,p.node(C))}),{graph:p,buckets:T,zeroIdx:E}}function h(g,b,p){p.out?p.in?g[p.out-p.in+b].enqueue(p):g[g.length-1].enqueue(p):g[0].enqueue(p)}function x(g){let b=[];for(let p=0;p<g;p++)b.push(p);return b}}),Hn=Wt((e,r)=>{var s=ns().Graph;r.exports={addBorderNode:b,addDummyNode:i,applyWithChunking:S,asNonCompoundGraph:c,buildLayerMatrix:h,intersectRect:m,mapValues:$,maxRank:T,normalizeRanks:x,notime:N,partition:E,pick:Y,predecessorWeights:f,range:M,removeEmptyRanks:g,simplify:o,successorWeights:u,time:C,uniqueId:H,zipObject:X};function i(P,q,F,D){for(var _=D;P.hasNode(_);)_=H(D);return F.dummy=q,P.setNode(_,F),_}function o(P){let q=new s().setGraph(P.graph());return P.nodes().forEach(F=>q.setNode(F,P.node(F))),P.edges().forEach(F=>{let D=q.edge(F.v,F.w)||{weight:0,minlen:1},_=P.edge(F);q.setEdge(F.v,F.w,{weight:D.weight+_.weight,minlen:Math.max(D.minlen,_.minlen)})}),q}function c(P){let q=new s({multigraph:P.isMultigraph()}).setGraph(P.graph());return P.nodes().forEach(F=>{P.children(F).length||q.setNode(F,P.node(F))}),P.edges().forEach(F=>{q.setEdge(F,P.edge(F))}),q}function u(P){let q=P.nodes().map(F=>{let D={};return P.outEdges(F).forEach(_=>{D[_.w]=(D[_.w]||0)+P.edge(_).weight}),D});return X(P.nodes(),q)}function f(P){let q=P.nodes().map(F=>{let D={};return P.inEdges(F).forEach(_=>{D[_.v]=(D[_.v]||0)+P.edge(_).weight}),D});return X(P.nodes(),q)}function m(P,q){let F=P.x,D=P.y,_=q.x-F,I=q.y-D,A=P.width/2,G=P.height/2;if(!_&&!I)throw new Error("Not possible to find intersection inside of the rectangle");let U,K;return Math.abs(I)*A>Math.abs(_)*G?(I<0&&(G=-G),U=G*_/I,K=G):(_<0&&(A=-A),U=A,K=A*I/_),{x:F+U,y:D+K}}function h(P){let q=M(T(P)+1).map(()=>[]);return P.nodes().forEach(F=>{let D=P.node(F),_=D.rank;_!==void 0&&(q[_][D.order]=F)}),q}function x(P){let q=P.nodes().map(D=>{let _=P.node(D).rank;return _===void 0?Number.MAX_VALUE:_}),F=S(Math.min,q);P.nodes().forEach(D=>{let _=P.node(D);Object.hasOwn(_,"rank")&&(_.rank-=F)})}function g(P){let q=P.nodes().map(A=>P.node(A).rank).filter(A=>A!==void 0),F=S(Math.min,q),D=[];P.nodes().forEach(A=>{let G=P.node(A).rank-F;D[G]||(D[G]=[]),D[G].push(A)});let _=0,I=P.graph().nodeRankFactor;Array.from(D).forEach((A,G)=>{A===void 0&&G%I!==0?--_:A!==void 0&&_&&A.forEach(U=>P.node(U).rank+=_)})}function b(P,q,F,D){let _={width:0,height:0};return arguments.length>=4&&(_.rank=F,_.order=D),i(P,"border",_,q)}function p(P,q=w){let F=[];for(let D=0;D<P.length;D+=q){let _=P.slice(D,D+q);F.push(_)}return F}var w=65535;function S(P,q){if(q.length>w){let F=p(q);return P.apply(null,F.map(D=>P.apply(null,D)))}else return P.apply(null,q)}function T(P){let q=P.nodes().map(F=>{let D=P.node(F).rank;return D===void 0?Number.MIN_VALUE:D});return S(Math.max,q)}function E(P,q){let F={lhs:[],rhs:[]};return P.forEach(D=>{q(D)?F.lhs.push(D):F.rhs.push(D)}),F}function C(P,q){let F=Date.now();try{return q()}finally{console.log(P+" time: "+(Date.now()-F)+"ms")}}function N(P,q){return q()}var k=0;function H(P){var q=++k;return P+(""+q)}function M(P,q,F=1){q==null&&(q=P,P=0);let D=I=>I<q;F<0&&(D=I=>q<I);let _=[];for(let I=P;D(I);I+=F)_.push(I);return _}function Y(P,q){let F={};for(let D of q)P[D]!==void 0&&(F[D]=P[D]);return F}function $(P,q){let F=q;return typeof q=="string"&&(F=D=>D[q]),Object.entries(P).reduce((D,[_,I])=>(D[_]=F(I,_),D),{})}function X(P,q){return P.reduce((F,D,_)=>(F[D]=q[_],F),{})}}),hz=Wt((e,r)=>{var s=fz(),i=Hn().uniqueId;r.exports={run:o,undo:u};function o(f){(f.graph().acyclicer==="greedy"?s(f,m(f)):c(f)).forEach(h=>{let x=f.edge(h);f.removeEdge(h),x.forwardName=h.name,x.reversed=!0,f.setEdge(h.w,h.v,x,i("rev"))});function m(h){return x=>h.edge(x).weight}}function c(f){let m=[],h={},x={};function g(b){Object.hasOwn(x,b)||(x[b]=!0,h[b]=!0,f.outEdges(b).forEach(p=>{Object.hasOwn(h,p.w)?m.push(p):g(p.w)}),delete h[b])}return f.nodes().forEach(g),m}function u(f){f.edges().forEach(m=>{let h=f.edge(m);if(h.reversed){f.removeEdge(m);let x=h.forwardName;delete h.reversed,delete h.forwardName,f.setEdge(m.w,m.v,h,x)}})}}),mz=Wt((e,r)=>{var s=Hn();r.exports={run:i,undo:c};function i(u){u.graph().dummyChains=[],u.edges().forEach(f=>o(u,f))}function o(u,f){let m=f.v,h=u.node(m).rank,x=f.w,g=u.node(x).rank,b=f.name,p=u.edge(f),w=p.labelRank;if(g===h+1)return;u.removeEdge(f);let S,T,E;for(E=0,++h;h<g;++E,++h)p.points=[],T={width:0,height:0,edgeLabel:p,edgeObj:f,rank:h},S=s.addDummyNode(u,"edge",T,"_d"),h===w&&(T.width=p.width,T.height=p.height,T.dummy="edge-label",T.labelpos=p.labelpos),u.setEdge(m,S,{weight:p.weight},b),E===0&&u.graph().dummyChains.push(S),m=S;u.setEdge(m,x,{weight:p.weight},b)}function c(u){u.graph().dummyChains.forEach(f=>{let m=u.node(f),h=m.edgeLabel,x;for(u.setEdge(m.edgeObj,h);m.dummy;)x=u.successors(f)[0],u.removeNode(f),h.points.push({x:m.x,y:m.y}),m.dummy==="edge-label"&&(h.x=m.x,h.y=m.y,h.width=m.width,h.height=m.height),f=x,m=u.node(f)})}}),Iu=Wt((e,r)=>{var{applyWithChunking:s}=Hn();r.exports={longestPath:i,slack:o};function i(c){var u={};function f(m){var h=c.node(m);if(Object.hasOwn(u,m))return h.rank;u[m]=!0;let x=c.outEdges(m).map(b=>b==null?Number.POSITIVE_INFINITY:f(b.w)-c.edge(b).minlen);var g=s(Math.min,x);return g===Number.POSITIVE_INFINITY&&(g=0),h.rank=g}c.sources().forEach(f)}function o(c,u){return c.node(u.w).rank-c.node(u.v).rank-c.edge(u).minlen}}),sN=Wt((e,r)=>{var s=ns().Graph,i=Iu().slack;r.exports=o;function o(m){var h=new s({directed:!1}),x=m.nodes()[0],g=m.nodeCount();h.setNode(x,{});for(var b,p;c(h,m)<g;)b=u(h,m),p=h.hasNode(b.v)?i(m,b):-i(m,b),f(h,m,p);return h}function c(m,h){function x(g){h.nodeEdges(g).forEach(b=>{var p=b.v,w=g===p?b.w:p;!m.hasNode(w)&&!i(h,b)&&(m.setNode(w,{}),m.setEdge(g,w,{}),x(w))})}return m.nodes().forEach(x),m.nodeCount()}function u(m,h){return h.edges().reduce((x,g)=>{let b=Number.POSITIVE_INFINITY;return m.hasNode(g.v)!==m.hasNode(g.w)&&(b=i(h,g)),b<x[0]?[b,g]:x},[Number.POSITIVE_INFINITY,null])[1]}function f(m,h,x){m.nodes().forEach(g=>h.node(g).rank+=x)}}),xz=Wt((e,r)=>{var s=sN(),i=Iu().slack,o=Iu().longestPath,c=ns().alg.preorder,u=ns().alg.postorder,f=Hn().simplify;r.exports=m,m.initLowLimValues=b,m.initCutValues=h,m.calcCutValue=g,m.leaveEdge=w,m.enterEdge=S,m.exchangeEdges=T;function m(k){k=f(k),o(k);var H=s(k);b(H),h(H,k);for(var M,Y;M=w(H);)Y=S(H,k,M),T(H,k,M,Y)}function h(k,H){var M=u(k,k.nodes());M=M.slice(0,M.length-1),M.forEach(Y=>x(k,H,Y))}function x(k,H,M){var Y=k.node(M),$=Y.parent;k.edge(M,$).cutvalue=g(k,H,M)}function g(k,H,M){var Y=k.node(M),$=Y.parent,X=!0,P=H.edge(M,$),q=0;return P||(X=!1,P=H.edge($,M)),q=P.weight,H.nodeEdges(M).forEach(F=>{var D=F.v===M,_=D?F.w:F.v;if(_!==$){var I=D===X,A=H.edge(F).weight;if(q+=I?A:-A,C(k,M,_)){var G=k.edge(M,_).cutvalue;q+=I?-G:G}}}),q}function b(k,H){arguments.length<2&&(H=k.nodes()[0]),p(k,{},1,H)}function p(k,H,M,Y,$){var X=M,P=k.node(Y);return H[Y]=!0,k.neighbors(Y).forEach(q=>{Object.hasOwn(H,q)||(M=p(k,H,M,q,Y))}),P.low=X,P.lim=M++,$?P.parent=$:delete P.parent,M}function w(k){return k.edges().find(H=>k.edge(H).cutvalue<0)}function S(k,H,M){var Y=M.v,$=M.w;H.hasEdge(Y,$)||(Y=M.w,$=M.v);var X=k.node(Y),P=k.node($),q=X,F=!1;X.lim>P.lim&&(q=P,F=!0);var D=H.edges().filter(_=>F===N(k,k.node(_.v),q)&&F!==N(k,k.node(_.w),q));return D.reduce((_,I)=>i(H,I)<i(H,_)?I:_)}function T(k,H,M,Y){var $=M.v,X=M.w;k.removeEdge($,X),k.setEdge(Y.v,Y.w,{}),b(k),h(k,H),E(k,H)}function E(k,H){var M=k.nodes().find($=>!H.node($).parent),Y=c(k,M);Y=Y.slice(1),Y.forEach($=>{var X=k.node($).parent,P=H.edge($,X),q=!1;P||(P=H.edge(X,$),q=!0),H.node($).rank=H.node(X).rank+(q?P.minlen:-P.minlen)})}function C(k,H,M){return k.hasEdge(H,M)}function N(k,H,M){return M.low<=H.lim&&H.lim<=M.lim}}),gz=Wt((e,r)=>{var s=Iu(),i=s.longestPath,o=sN(),c=xz();r.exports=u;function u(x){var g=x.graph().ranker;if(g instanceof Function)return g(x);switch(x.graph().ranker){case"network-simplex":h(x);break;case"tight-tree":m(x);break;case"longest-path":f(x);break;case"none":break;default:h(x)}}var f=i;function m(x){i(x),o(x)}function h(x){c(x)}}),pz=Wt((e,r)=>{r.exports=s;function s(c){let u=o(c);c.graph().dummyChains.forEach(f=>{let m=c.node(f),h=m.edgeObj,x=i(c,u,h.v,h.w),g=x.path,b=x.lca,p=0,w=g[p],S=!0;for(;f!==h.w;){if(m=c.node(f),S){for(;(w=g[p])!==b&&c.node(w).maxRank<m.rank;)p++;w===b&&(S=!1)}if(!S){for(;p<g.length-1&&c.node(w=g[p+1]).minRank<=m.rank;)p++;w=g[p]}c.setParent(f,w),f=c.successors(f)[0]}})}function i(c,u,f,m){let h=[],x=[],g=Math.min(u[f].low,u[m].low),b=Math.max(u[f].lim,u[m].lim),p,w;p=f;do p=c.parent(p),h.push(p);while(p&&(u[p].low>g||b>u[p].lim));for(w=p,p=m;(p=c.parent(p))!==w;)x.push(p);return{path:h.concat(x.reverse()),lca:w}}function o(c){let u={},f=0;function m(h){let x=f;c.children(h).forEach(m),u[h]={low:x,lim:f++}}return c.children().forEach(m),u}}),bz=Wt((e,r)=>{var s=Hn();r.exports={run:i,cleanup:f};function i(m){let h=s.addDummyNode(m,"root",{},"_root"),x=c(m),g=Object.values(x),b=s.applyWithChunking(Math.max,g)-1,p=2*b+1;m.graph().nestingRoot=h,m.edges().forEach(S=>m.edge(S).minlen*=p);let w=u(m)+1;m.children().forEach(S=>o(m,h,p,w,b,x,S)),m.graph().nodeRankFactor=p}function o(m,h,x,g,b,p,w){let S=m.children(w);if(!S.length){w!==h&&m.setEdge(h,w,{weight:0,minlen:x});return}let T=s.addBorderNode(m,"_bt"),E=s.addBorderNode(m,"_bb"),C=m.node(w);m.setParent(T,w),C.borderTop=T,m.setParent(E,w),C.borderBottom=E,S.forEach(N=>{o(m,h,x,g,b,p,N);let k=m.node(N),H=k.borderTop?k.borderTop:N,M=k.borderBottom?k.borderBottom:N,Y=k.borderTop?g:2*g,$=H!==M?1:b-p[w]+1;m.setEdge(T,H,{weight:Y,minlen:$,nestingEdge:!0}),m.setEdge(M,E,{weight:Y,minlen:$,nestingEdge:!0})}),m.parent(w)||m.setEdge(h,T,{weight:0,minlen:b+p[w]})}function c(m){var h={};function x(g,b){var p=m.children(g);p&&p.length&&p.forEach(w=>x(w,b+1)),h[g]=b}return m.children().forEach(g=>x(g,1)),h}function u(m){return m.edges().reduce((h,x)=>h+m.edge(x).weight,0)}function f(m){var h=m.graph();m.removeNode(h.nestingRoot),delete h.nestingRoot,m.edges().forEach(x=>{var g=m.edge(x);g.nestingEdge&&m.removeEdge(x)})}}),yz=Wt((e,r)=>{var s=Hn();r.exports=i;function i(c){function u(f){let m=c.children(f),h=c.node(f);if(m.length&&m.forEach(u),Object.hasOwn(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(let x=h.minRank,g=h.maxRank+1;x<g;++x)o(c,"borderLeft","_bl",f,h,x),o(c,"borderRight","_br",f,h,x)}}c.children().forEach(u)}function o(c,u,f,m,h,x){let g={width:0,height:0,rank:x,borderType:u},b=h[u][x-1],p=s.addDummyNode(c,"border",g,f);h[u][x]=p,c.setParent(p,m),b&&c.setEdge(b,p,{weight:1})}}),vz=Wt((e,r)=>{r.exports={adjust:s,undo:i};function s(x){let g=x.graph().rankdir.toLowerCase();(g==="lr"||g==="rl")&&o(x)}function i(x){let g=x.graph().rankdir.toLowerCase();(g==="bt"||g==="rl")&&u(x),(g==="lr"||g==="rl")&&(m(x),o(x))}function o(x){x.nodes().forEach(g=>c(x.node(g))),x.edges().forEach(g=>c(x.edge(g)))}function c(x){let g=x.width;x.width=x.height,x.height=g}function u(x){x.nodes().forEach(g=>f(x.node(g))),x.edges().forEach(g=>{let b=x.edge(g);b.points.forEach(f),Object.hasOwn(b,"y")&&f(b)})}function f(x){x.y=-x.y}function m(x){x.nodes().forEach(g=>h(x.node(g))),x.edges().forEach(g=>{let b=x.edge(g);b.points.forEach(h),Object.hasOwn(b,"x")&&h(b)})}function h(x){let g=x.x;x.x=x.y,x.y=g}}),jz=Wt((e,r)=>{var s=Hn();r.exports=i;function i(o){let c={},u=o.nodes().filter(g=>!o.children(g).length),f=u.map(g=>o.node(g).rank),m=s.applyWithChunking(Math.max,f),h=s.range(m+1).map(()=>[]);function x(g){if(c[g])return;c[g]=!0;let b=o.node(g);h[b.rank].push(g),o.successors(g).forEach(x)}return u.sort((g,b)=>o.node(g).rank-o.node(b).rank).forEach(x),h}}),wz=Wt((e,r)=>{var s=Hn().zipObject;r.exports=i;function i(c,u){let f=0;for(let m=1;m<u.length;++m)f+=o(c,u[m-1],u[m]);return f}function o(c,u,f){let m=s(f,f.map((w,S)=>S)),h=u.flatMap(w=>c.outEdges(w).map(S=>({pos:m[S.w],weight:c.edge(S).weight})).sort((S,T)=>S.pos-T.pos)),x=1;for(;x<f.length;)x<<=1;let g=2*x-1;x-=1;let b=new Array(g).fill(0),p=0;return h.forEach(w=>{let S=w.pos+x;b[S]+=w.weight;let T=0;for(;S>0;)S%2&&(T+=b[S+1]),S=S-1>>1,b[S]+=w.weight;p+=w.weight*T}),p}}),Nz=Wt((e,r)=>{r.exports=s;function s(i,o=[]){return o.map(c=>{let u=i.inEdges(c);if(u.length){let f=u.reduce((m,h)=>{let x=i.edge(h),g=i.node(h.v);return{sum:m.sum+x.weight*g.order,weight:m.weight+x.weight}},{sum:0,weight:0});return{v:c,barycenter:f.sum/f.weight,weight:f.weight}}else return{v:c}})}}),kz=Wt((e,r)=>{var s=Hn();r.exports=i;function i(u,f){let m={};u.forEach((x,g)=>{let b=m[x.v]={indegree:0,in:[],out:[],vs:[x.v],i:g};x.barycenter!==void 0&&(b.barycenter=x.barycenter,b.weight=x.weight)}),f.edges().forEach(x=>{let g=m[x.v],b=m[x.w];g!==void 0&&b!==void 0&&(b.indegree++,g.out.push(m[x.w]))});let h=Object.values(m).filter(x=>!x.indegree);return o(h)}function o(u){let f=[];function m(x){return g=>{g.merged||(g.barycenter===void 0||x.barycenter===void 0||g.barycenter>=x.barycenter)&&c(x,g)}}function h(x){return g=>{g.in.push(x),--g.indegree===0&&u.push(g)}}for(;u.length;){let x=u.pop();f.push(x),x.in.reverse().forEach(m(x)),x.out.forEach(h(x))}return f.filter(x=>!x.merged).map(x=>s.pick(x,["vs","i","barycenter","weight"]))}function c(u,f){let m=0,h=0;u.weight&&(m+=u.barycenter*u.weight,h+=u.weight),f.weight&&(m+=f.barycenter*f.weight,h+=f.weight),u.vs=f.vs.concat(u.vs),u.barycenter=m/h,u.weight=h,u.i=Math.min(f.i,u.i),f.merged=!0}}),Sz=Wt((e,r)=>{var s=Hn();r.exports=i;function i(u,f){let m=s.partition(u,T=>Object.hasOwn(T,"barycenter")),h=m.lhs,x=m.rhs.sort((T,E)=>E.i-T.i),g=[],b=0,p=0,w=0;h.sort(c(!!f)),w=o(g,x,w),h.forEach(T=>{w+=T.vs.length,g.push(T.vs),b+=T.barycenter*T.weight,p+=T.weight,w=o(g,x,w)});let S={vs:g.flat(!0)};return p&&(S.barycenter=b/p,S.weight=p),S}function o(u,f,m){let h;for(;f.length&&(h=f[f.length-1]).i<=m;)f.pop(),u.push(h.vs),m++;return m}function c(u){return(f,m)=>f.barycenter<m.barycenter?-1:f.barycenter>m.barycenter?1:u?m.i-f.i:f.i-m.i}}),Cz=Wt((e,r)=>{var s=Nz(),i=kz(),o=Sz();r.exports=c;function c(m,h,x,g){let b=m.children(h),p=m.node(h),w=p?p.borderLeft:void 0,S=p?p.borderRight:void 0,T={};w&&(b=b.filter(k=>k!==w&&k!==S));let E=s(m,b);E.forEach(k=>{if(m.children(k.v).length){let H=c(m,k.v,x,g);T[k.v]=H,Object.hasOwn(H,"barycenter")&&f(k,H)}});let C=i(E,x);u(C,T);let N=o(C,g);if(w&&(N.vs=[w,N.vs,S].flat(!0),m.predecessors(w).length)){let k=m.node(m.predecessors(w)[0]),H=m.node(m.predecessors(S)[0]);Object.hasOwn(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+k.order+H.order)/(N.weight+2),N.weight+=2}return N}function u(m,h){m.forEach(x=>{x.vs=x.vs.flatMap(g=>h[g]?h[g].vs:g)})}function f(m,h){m.barycenter!==void 0?(m.barycenter=(m.barycenter*m.weight+h.barycenter*h.weight)/(m.weight+h.weight),m.weight+=h.weight):(m.barycenter=h.barycenter,m.weight=h.weight)}}),Ez=Wt((e,r)=>{var s=ns().Graph,i=Hn();r.exports=o;function o(u,f,m,h){h||(h=u.nodes());let x=c(u),g=new s({compound:!0}).setGraph({root:x}).setDefaultNodeLabel(b=>u.node(b));return h.forEach(b=>{let p=u.node(b),w=u.parent(b);(p.rank===f||p.minRank<=f&&f<=p.maxRank)&&(g.setNode(b),g.setParent(b,w||x),u[m](b).forEach(S=>{let T=S.v===b?S.w:S.v,E=g.edge(T,b),C=E!==void 0?E.weight:0;g.setEdge(T,b,{weight:u.edge(S).weight+C})}),Object.hasOwn(p,"minRank")&&g.setNode(b,{borderLeft:p.borderLeft[f],borderRight:p.borderRight[f]}))}),g}function c(u){for(var f;u.hasNode(f=i.uniqueId("_root")););return f}}),Tz=Wt((e,r)=>{r.exports=s;function s(i,o,c){let u={},f;c.forEach(m=>{let h=i.parent(m),x,g;for(;h;){if(x=i.parent(h),x?(g=u[x],u[x]=h):(g=f,f=h),g&&g!==h){o.setEdge(g,h);return}h=x}})}}),_z=Wt((e,r)=>{var s=jz(),i=wz(),o=Cz(),c=Ez(),u=Tz(),f=ns().Graph,m=Hn();r.exports=h;function h(p,w={}){if(typeof w.customOrder=="function"){w.customOrder(p,h);return}let S=m.maxRank(p),T=x(p,m.range(1,S+1),"inEdges"),E=x(p,m.range(S-1,-1,-1),"outEdges"),C=s(p);if(b(p,C),w.disableOptimalOrderHeuristic)return;let N=Number.POSITIVE_INFINITY,k,H=w.constraints||[];for(let M=0,Y=0;Y<4;++M,++Y){g(M%2?T:E,M%4>=2,H),C=m.buildLayerMatrix(p);let $=i(p,C);$<N?(Y=0,k=Object.assign({},C),N=$):$===N&&(k=structuredClone(C))}b(p,k)}function x(p,w,S){let T=new Map,E=(C,N)=>{T.has(C)||T.set(C,[]),T.get(C).push(N)};for(let C of p.nodes()){let N=p.node(C);if(typeof N.rank=="number"&&E(N.rank,C),typeof N.minRank=="number"&&typeof N.maxRank=="number")for(let k=N.minRank;k<=N.maxRank;k++)k!==N.rank&&E(k,C)}return w.map(function(C){return c(p,C,S,T.get(C)||[])})}function g(p,w,S){let T=new f;p.forEach(function(E){S.forEach(k=>T.setEdge(k.left,k.right));let C=E.graph().root,N=o(E,C,T,w);N.vs.forEach((k,H)=>E.node(k).order=H),u(E,T,N.vs)})}function b(p,w){Object.values(w).forEach(S=>S.forEach((T,E)=>p.node(T).order=E))}}),Az=Wt((e,r)=>{var s=ns().Graph,i=Hn();r.exports={positionX:S,findType1Conflicts:o,findType2Conflicts:c,addConflict:f,hasConflict:m,verticalAlignment:h,horizontalCompaction:x,alignCoordinates:p,findSmallestWidthAlignment:b,balance:w};function o(C,N){let k={};function H(M,Y){let $=0,X=0,P=M.length,q=Y[Y.length-1];return Y.forEach((F,D)=>{let _=u(C,F),I=_?C.node(_).order:P;(_||F===q)&&(Y.slice(X,D+1).forEach(A=>{C.predecessors(A).forEach(G=>{let U=C.node(G),K=U.order;(K<$||I<K)&&!(U.dummy&&C.node(A).dummy)&&f(k,G,A)})}),X=D+1,$=I)}),Y}return N.length&&N.reduce(H),k}function c(C,N){let k={};function H(Y,$,X,P,q){let F;i.range($,X).forEach(D=>{F=Y[D],C.node(F).dummy&&C.predecessors(F).forEach(_=>{let I=C.node(_);I.dummy&&(I.order<P||I.order>q)&&f(k,_,F)})})}function M(Y,$){let X=-1,P,q=0;return $.forEach((F,D)=>{if(C.node(F).dummy==="border"){let _=C.predecessors(F);_.length&&(P=C.node(_[0]).order,H($,q,D,X,P),q=D,X=P)}H($,q,$.length,P,Y.length)}),$}return N.length&&N.reduce(M),k}function u(C,N){if(C.node(N).dummy)return C.predecessors(N).find(k=>C.node(k).dummy)}function f(C,N,k){if(N>k){let M=N;N=k,k=M}let H=C[N];H||(C[N]=H={}),H[k]=!0}function m(C,N,k){if(N>k){let H=N;N=k,k=H}return!!C[N]&&Object.hasOwn(C[N],k)}function h(C,N,k,H){let M={},Y={},$={};return N.forEach(X=>{X.forEach((P,q)=>{M[P]=P,Y[P]=P,$[P]=q})}),N.forEach(X=>{let P=-1;X.forEach(q=>{let F=H(q);if(F.length){F=F.sort((_,I)=>$[_]-$[I]);let D=(F.length-1)/2;for(let _=Math.floor(D),I=Math.ceil(D);_<=I;++_){let A=F[_];Y[q]===q&&P<$[A]&&!m(k,q,A)&&(Y[A]=q,Y[q]=M[q]=M[A],P=$[A])}}})}),{root:M,align:Y}}function x(C,N,k,H,M){let Y={},$=g(C,N,k,M),X=M?"borderLeft":"borderRight";function P(D,_){let I=$.nodes().slice(),A={},G=I.pop();for(;G;){if(A[G])D(G);else{A[G]=!0,I.push(G);for(let U of _(G))I.push(U)}G=I.pop()}}function q(D){Y[D]=$.inEdges(D).reduce((_,I)=>Math.max(_,Y[I.v]+$.edge(I)),0)}function F(D){let _=$.outEdges(D).reduce((A,G)=>Math.min(A,Y[G.w]-$.edge(G)),Number.POSITIVE_INFINITY),I=C.node(D);_!==Number.POSITIVE_INFINITY&&I.borderType!==X&&(Y[D]=Math.max(Y[D],_))}return P(q,$.predecessors.bind($)),P(F,$.successors.bind($)),Object.keys(H).forEach(D=>Y[D]=Y[k[D]]),Y}function g(C,N,k,H){let M=new s,Y=C.graph(),$=T(Y.nodesep,Y.edgesep,H);return N.forEach(X=>{let P;X.forEach(q=>{let F=k[q];if(M.setNode(F),P){var D=k[P],_=M.edge(D,F);M.setEdge(D,F,Math.max($(C,q,P),_||0))}P=q})}),M}function b(C,N){return Object.values(N).reduce((k,H)=>{let M=Number.NEGATIVE_INFINITY,Y=Number.POSITIVE_INFINITY;Object.entries(H).forEach(([X,P])=>{let q=E(C,X)/2;M=Math.max(P+q,M),Y=Math.min(P-q,Y)});let $=M-Y;return $<k[0]&&(k=[$,H]),k},[Number.POSITIVE_INFINITY,null])[1]}function p(C,N){let k=Object.values(N),H=i.applyWithChunking(Math.min,k),M=i.applyWithChunking(Math.max,k);["u","d"].forEach(Y=>{["l","r"].forEach($=>{let X=Y+$,P=C[X];if(P===N)return;let q=Object.values(P),F=H-i.applyWithChunking(Math.min,q);$!=="l"&&(F=M-i.applyWithChunking(Math.max,q)),F&&(C[X]=i.mapValues(P,D=>D+F))})})}function w(C,N){return i.mapValues(C.ul,(k,H)=>{if(N)return C[N.toLowerCase()][H];{let M=Object.values(C).map(Y=>Y[H]).sort((Y,$)=>Y-$);return(M[1]+M[2])/2}})}function S(C){let N=i.buildLayerMatrix(C),k=Object.assign(o(C,N),c(C,N)),H={},M;["u","d"].forEach($=>{M=$==="u"?N:Object.values(N).reverse(),["l","r"].forEach(X=>{X==="r"&&(M=M.map(D=>Object.values(D).reverse()));let P=($==="u"?C.predecessors:C.successors).bind(C),q=h(C,M,k,P),F=x(C,M,q.root,q.align,X==="r");X==="r"&&(F=i.mapValues(F,D=>-D)),H[$+X]=F})});let Y=b(C,H);return p(H,Y),w(H,C.graph().align)}function T(C,N,k){return(H,M,Y)=>{let $=H.node(M),X=H.node(Y),P=0,q;if(P+=$.width/2,Object.hasOwn($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":q=-$.width/2;break;case"r":q=$.width/2;break}if(q&&(P+=k?q:-q),q=0,P+=($.dummy?N:C)/2,P+=(X.dummy?N:C)/2,P+=X.width/2,Object.hasOwn(X,"labelpos"))switch(X.labelpos.toLowerCase()){case"l":q=X.width/2;break;case"r":q=-X.width/2;break}return q&&(P+=k?q:-q),q=0,P}}function E(C,N){return C.node(N).width}}),Mz=Wt((e,r)=>{var s=Hn(),i=Az().positionX;r.exports=o;function o(u){u=s.asNonCompoundGraph(u),c(u),Object.entries(i(u)).forEach(([f,m])=>u.node(f).x=m)}function c(u){let f=s.buildLayerMatrix(u),m=u.graph().ranksep,h=u.graph().rankalign,x=0;f.forEach(g=>{let b=g.reduce((p,w)=>{let S=u.node(w).height;return p>S?p:S},0);g.forEach(p=>{let w=u.node(p);h==="top"?w.y=x+w.height/2:h==="bottom"?w.y=x+b-w.height/2:w.y=x+b/2}),x+=b+m})}}),Dz=Wt((e,r)=>{var s=hz(),i=mz(),o=gz(),c=Hn().normalizeRanks,u=pz(),f=Hn().removeEmptyRanks,m=bz(),h=yz(),x=vz(),g=_z(),b=Mz(),p=Hn(),w=ns().Graph;r.exports=S;function S(V,Q={}){let te=Q.debugTiming?p.time:p.notime;return te("layout",()=>{let Z=te(" buildLayoutGraph",()=>P(V));return te(" runLayout",()=>T(Z,te,Q)),te(" updateInputGraph",()=>E(V,Z)),Z})}function T(V,Q,te){Q(" makeSpaceForEdgeLabels",()=>q(V)),Q(" removeSelfEdges",()=>B(V)),Q(" acyclic",()=>s.run(V)),Q(" nestingGraph.run",()=>m.run(V)),Q(" rank",()=>o(p.asNonCompoundGraph(V))),Q(" injectEdgeLabelProxies",()=>F(V)),Q(" removeEmptyRanks",()=>f(V)),Q(" nestingGraph.cleanup",()=>m.cleanup(V)),Q(" normalizeRanks",()=>c(V)),Q(" assignRankMinMax",()=>D(V)),Q(" removeEdgeLabelProxies",()=>_(V)),Q(" normalize.run",()=>i.run(V)),Q(" parentDummyChains",()=>u(V)),Q(" addBorderSegments",()=>h(V)),Q(" order",()=>g(V,te)),Q(" insertSelfEdges",()=>L(V)),Q(" adjustCoordinateSystem",()=>x.adjust(V)),Q(" position",()=>b(V)),Q(" positionSelfEdges",()=>W(V)),Q(" removeBorderNodes",()=>K(V)),Q(" normalize.undo",()=>i.undo(V)),Q(" fixupEdgeLabelCoords",()=>G(V)),Q(" undoCoordinateSystem",()=>x.undo(V)),Q(" translateGraph",()=>I(V)),Q(" assignNodeIntersects",()=>A(V)),Q(" reversePoints",()=>U(V)),Q(" acyclic.undo",()=>s.undo(V))}function E(V,Q){V.nodes().forEach(te=>{let Z=V.node(te),ee=Q.node(te);Z&&(Z.x=ee.x,Z.y=ee.y,Z.order=ee.order,Z.rank=ee.rank,Q.children(te).length&&(Z.width=ee.width,Z.height=ee.height))}),V.edges().forEach(te=>{let Z=V.edge(te),ee=Q.edge(te);Z.points=ee.points,Object.hasOwn(ee,"x")&&(Z.x=ee.x,Z.y=ee.y)}),V.graph().width=Q.graph().width,V.graph().height=Q.graph().height}var C=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},k=["acyclicer","ranker","rankdir","align","rankalign"],H=["width","height","rank"],M={width:0,height:0},Y=["minlen","weight","width","height","labeloffset"],$={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},X=["labelpos"];function P(V){let Q=new w({multigraph:!0,compound:!0}),te=z(V.graph());return Q.setGraph(Object.assign({},N,R(te,C),p.pick(te,k))),V.nodes().forEach(Z=>{let ee=z(V.node(Z)),ie=R(ee,H);Object.keys(M).forEach(je=>{ie[je]===void 0&&(ie[je]=M[je])}),Q.setNode(Z,ie),Q.setParent(Z,V.parent(Z))}),V.edges().forEach(Z=>{let ee=z(V.edge(Z));Q.setEdge(Z,Object.assign({},$,R(ee,Y),p.pick(ee,X)))}),Q}function q(V){let Q=V.graph();Q.ranksep/=2,V.edges().forEach(te=>{let Z=V.edge(te);Z.minlen*=2,Z.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?Z.width+=Z.labeloffset:Z.height+=Z.labeloffset)})}function F(V){V.edges().forEach(Q=>{let te=V.edge(Q);if(te.width&&te.height){let Z=V.node(Q.v),ee={rank:(V.node(Q.w).rank-Z.rank)/2+Z.rank,e:Q};p.addDummyNode(V,"edge-proxy",ee,"_ep")}})}function D(V){let Q=0;V.nodes().forEach(te=>{let Z=V.node(te);Z.borderTop&&(Z.minRank=V.node(Z.borderTop).rank,Z.maxRank=V.node(Z.borderBottom).rank,Q=Math.max(Q,Z.maxRank))}),V.graph().maxRank=Q}function _(V){V.nodes().forEach(Q=>{let te=V.node(Q);te.dummy==="edge-proxy"&&(V.edge(te.e).labelRank=te.rank,V.removeNode(Q))})}function I(V){let Q=Number.POSITIVE_INFINITY,te=0,Z=Number.POSITIVE_INFINITY,ee=0,ie=V.graph(),je=ie.marginx||0,ke=ie.marginy||0;function De(Ie){let ze=Ie.x,Ze=Ie.y,Ae=Ie.width,We=Ie.height;Q=Math.min(Q,ze-Ae/2),te=Math.max(te,ze+Ae/2),Z=Math.min(Z,Ze-We/2),ee=Math.max(ee,Ze+We/2)}V.nodes().forEach(Ie=>De(V.node(Ie))),V.edges().forEach(Ie=>{let ze=V.edge(Ie);Object.hasOwn(ze,"x")&&De(ze)}),Q-=je,Z-=ke,V.nodes().forEach(Ie=>{let ze=V.node(Ie);ze.x-=Q,ze.y-=Z}),V.edges().forEach(Ie=>{let ze=V.edge(Ie);ze.points.forEach(Ze=>{Ze.x-=Q,Ze.y-=Z}),Object.hasOwn(ze,"x")&&(ze.x-=Q),Object.hasOwn(ze,"y")&&(ze.y-=Z)}),ie.width=te-Q+je,ie.height=ee-Z+ke}function A(V){V.edges().forEach(Q=>{let te=V.edge(Q),Z=V.node(Q.v),ee=V.node(Q.w),ie,je;te.points?(ie=te.points[0],je=te.points[te.points.length-1]):(te.points=[],ie=ee,je=Z),te.points.unshift(p.intersectRect(Z,ie)),te.points.push(p.intersectRect(ee,je))})}function G(V){V.edges().forEach(Q=>{let te=V.edge(Q);if(Object.hasOwn(te,"x"))switch((te.labelpos==="l"||te.labelpos==="r")&&(te.width-=te.labeloffset),te.labelpos){case"l":te.x-=te.width/2+te.labeloffset;break;case"r":te.x+=te.width/2+te.labeloffset;break}})}function U(V){V.edges().forEach(Q=>{let te=V.edge(Q);te.reversed&&te.points.reverse()})}function K(V){V.nodes().forEach(Q=>{if(V.children(Q).length){let te=V.node(Q),Z=V.node(te.borderTop),ee=V.node(te.borderBottom),ie=V.node(te.borderLeft[te.borderLeft.length-1]),je=V.node(te.borderRight[te.borderRight.length-1]);te.width=Math.abs(je.x-ie.x),te.height=Math.abs(ee.y-Z.y),te.x=ie.x+te.width/2,te.y=Z.y+te.height/2}}),V.nodes().forEach(Q=>{V.node(Q).dummy==="border"&&V.removeNode(Q)})}function B(V){V.edges().forEach(Q=>{if(Q.v===Q.w){var te=V.node(Q.v);te.selfEdges||(te.selfEdges=[]),te.selfEdges.push({e:Q,label:V.edge(Q)}),V.removeEdge(Q)}})}function L(V){var Q=p.buildLayerMatrix(V);Q.forEach(te=>{var Z=0;te.forEach((ee,ie)=>{var je=V.node(ee);je.order=ie+Z,(je.selfEdges||[]).forEach(ke=>{p.addDummyNode(V,"selfedge",{width:ke.label.width,height:ke.label.height,rank:je.rank,order:ie+ ++Z,e:ke.e,label:ke.label},"_se")}),delete je.selfEdges})})}function W(V){V.nodes().forEach(Q=>{var te=V.node(Q);if(te.dummy==="selfedge"){var Z=V.node(te.e.v),ee=Z.x+Z.width/2,ie=Z.y,je=te.x-ee,ke=Z.height/2;V.setEdge(te.e,te.label),V.removeNode(Q),te.label.points=[{x:ee+2*je/3,y:ie-ke},{x:ee+5*je/6,y:ie-ke},{x:ee+je,y:ie},{x:ee+5*je/6,y:ie+ke},{x:ee+2*je/3,y:ie+ke}],te.label.x=te.x,te.label.y=te.y}})}function R(V,Q){return p.mapValues(p.pick(V,Q),Number)}function z(V){var Q={};return V&&Object.entries(V).forEach(([te,Z])=>{typeof te=="string"&&(te=te.toLowerCase()),Q[te]=Z}),Q}}),Oz=Wt((e,r)=>{var s=Hn(),i=ns().Graph;r.exports={debugOrdering:o};function o(c){let u=s.buildLayerMatrix(c),f=new i({compound:!0,multigraph:!0}).setGraph({});return c.nodes().forEach(m=>{f.setNode(m,{label:m}),f.setParent(m,"layer"+c.node(m).rank)}),c.edges().forEach(m=>f.setEdge(m.v,m.w,{},m.name)),u.forEach((m,h)=>{let x="layer"+h;f.setNode(x,{rank:"same"}),m.reduce((g,b)=>(f.setEdge(g,b,{style:"invis"}),b))}),f}}),Rz=Wt((e,r)=>{r.exports="2.0.4"}),zz=Wt((e,r)=>{r.exports={graphlib:ns(),layout:Dz(),debug:Oz(),util:{time:Hn().time,notime:Hn().notime},version:Rz()}});const kv=zz();const Sv={pending:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"},pending_approval:{bg:"bg-blue-500/8",border:"border-blue-400/25",text:"text-blue-500"},assigned:{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"},revision:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},accepted:{bg:"bg-green-500/8",border:"border-green-500/25",text:"text-green-600"},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"},cancelled:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-tertiary"}},Lz={critical:"bg-red-500",high:"bg-amber-500",medium:"bg-amber-500",low:"bg-blue-500"};function Iz({data:e}){const{task:r,agentName:s}=e,i=Sv[r.status]??Sv.pending,o=r.taskType==="scheduled"&&!!r.scheduleConfig,c=o?r.scheduleConfig.every?`Every ${r.scheduleConfig.every}`:r.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 ${o?`${i.bg} border-blue-500/40 ring-1 ring-blue-500/20`:`${i.bg} ${i.border}`}`,children:[t.jsx(Na,{type:"target",position:nt.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 ${Lz[r.priority]??"bg-gray-500"}`}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${i.text}`,children:r.status.replace("_"," ")}),o&&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:r.title}),s&&t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:s}),r.blockedBy&&r.blockedBy.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[r.blockedBy.length," dep",r.blockedBy.length>1?"s":""]}),t.jsx(Na,{type:"source",position:nt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const Cv={draft:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-secondary"},pending_review:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},approved:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"},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"}},Ev={draft:"todo",pending_review:"todo",approved:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done"};function $z({data:e}){const{req:r}=e,s=Cv[r.status]??Cv.draft;return t.jsxs("div",{className:`rounded-lg border-2 border-dashed px-3 py-2 min-w-[180px] max-w-[220px] shadow-lg ${s.bg} ${s.border}`,children:[t.jsx(Na,{type:"target",position:nt.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 ${s.text}`,children:r.status.replace("_"," ")})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:r.title}),r.taskIds.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[r.taskIds.length," task",r.taskIds.length>1?"s":""]}),t.jsx(Na,{type:"source",position:nt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const Bz={task:Iz,requirement:$z},Hz=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,Pz=e=>{const r=new MutationObserver(e);r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const s=window.matchMedia("(prefers-color-scheme: light)");return s.addEventListener("change",e),()=>{r.disconnect(),s.removeEventListener("change",e)}};function Uz(){return j.useSyncExternalStore(Pz,Hz,()=>!1)}const Em=200,Tm=80;function Tv(e,r,s="TB"){const i=new kv.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const o of e)i.setNode(o.id,{width:Em,height:Tm});for(const o of r)i.setEdge(o.source,o.target);return kv.layout(i),e.map(o=>{const c=i.node(o.id);return{...o,position:{x:(c?.x??0)-Em/2,y:(c?.y??0)-Tm/2}}})}function qz(e,r){const s=new Map,i=new Map;for(const u of e)i.set(u.id,u),s.set(u.id,new Set);for(const u of r)s.get(u.source)?.add(u.target),s.get(u.target)?.add(u.source);const o=new Set,c=[];for(const u of e){if(o.has(u.id))continue;const f=new Set,m=[u.id];for(;m.length>0;){const h=m.pop();if(!o.has(h)){o.add(h),f.add(h);for(const x of s.get(h)??[])o.has(x)||m.push(x)}}c.push({nodes:e.filter(h=>f.has(h.id)),edges:r.filter(h=>f.has(h.source)&&f.has(h.target))})}return c}function Vz(e,r){if(e.length===0)return[];const s=qz(e,r);if(s.length===1)return Tv(e,r);const i=s.map(g=>{const b=Tv(g.nodes,g.edges);let p=1/0,w=-1/0,S=1/0,T=-1/0;for(const E of b)p=Math.min(p,E.position.x),w=Math.max(w,E.position.x+Em),S=Math.min(S,E.position.y),T=Math.max(T,E.position.y+Tm);for(const E of b)E.position.x-=p,E.position.y-=S;return{nodes:b,w:w-p,h:T-S}});i.sort((g,b)=>b.h-g.h);const o=60,c=i.reduce((g,b)=>g+(b.w+o)*(b.h+o),0),u=Math.sqrt(c)*1.1,f=[];let m=0,h=0,x=0;for(const g of i){m>0&&m+g.w>u&&(m=0,h+=x+o,x=0);for(const b of g.nodes)f.push({...b,position:{x:b.position.x+m,y:b.position.y+h}});m+=g.w+o,x=Math.max(x,g.h)}return f}function Fz(e,r,s){const i=new Set,o=[r];for(;o.length>0;){const c=o.pop();if(c===s)return!0;if(i.has(c))continue;i.add(c);const u=e.get(c);if(u?.blockedBy)for(const f of u.blockedBy)o.push(f)}return!1}const oo=[{id:"todo",label:"To Do",statuses:new Set(["pending_approval","pending","assigned"]),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","revision","accepted"]),color:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"}},{id:"done",label:"Done",statuses:new Set(["completed","failed","cancelled"]),color:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"}}],Yh=new Set(oo.map(e=>e.id)),Yz=1440*60*1e3,_v=e=>e.status==="completed"&&e.updatedAt&&Date.now()-new Date(e.updatedAt).getTime()>Yz;function Gz({tasks:e,requirements:r=[],agents:s,showArchived:i,onShowArchivedChange:o,onTaskClick:c,onReqClick:u,onDependencyChange:f}){const m=Uz(),[h,x]=j.useState(null),[g,b]=j.useState(null),[p,w]=j.useState(new Set(Yh)),[S,T]=j.useState(i??!1),E=i??S,C=j.useCallback(Z=>{const ee=typeof Z=="function"?Z(E):Z;T(ee),o?.(ee)},[E,o]);j.useEffect(()=>{i!==void 0&&T(i)},[i]);const N=j.useMemo(()=>e.filter(Z=>_v(Z)).length,[e]),k=j.useMemo(()=>{const Z=new Set;for(const ee of oo)if(p.has(ee.id))for(const ie of ee.statuses)Z.add(ie);return Z},[p]),H=j.useMemo(()=>{const Z=new Set;for(const ee of e)for(const ie of oo)if(ie.statuses.has(ee.status)){Z.add(ie.id);break}for(const ee of r){const ie=Ev[ee.status];ie&&Z.add(ie)}return oo.filter(ee=>Z.has(ee.id))},[e,r]),M=j.useCallback(Z=>{w(ee=>{const ie=new Set(ee);return ie.has(Z)?ie.delete(Z):ie.add(Z),ie})},[]),Y=j.useCallback((Z,ee="success")=>{x({msg:Z,type:ee}),setTimeout(()=>x(null),2500)},[]),$=j.useMemo(()=>{const Z=new Map;for(const ee of s)Z.set(ee.id,ee.name);return Z},[s]),X=j.useMemo(()=>{const Z=new Map;for(const ee of e)Z.set(ee.id,ee);return Z},[e]),P=j.useMemo(()=>{const Z=new Map;for(const ee of r)Z.set(ee.id,ee);return Z},[r]),q=m?"#94a3b8":"#6b7280",F=j.useCallback((Z,ee,ie)=>({id:`${Z}->${ee}`,source:Z,target:ee,animated:ie==="blocked",markerEnd:{type:Zi.ArrowClosed,width:14,height:14,color:ie==="blocked"?"#ef4444":q},style:{stroke:ie==="blocked"?"#ef4444":q,strokeWidth:1.5,cursor:"pointer"}}),[q]),{initialNodes:D,initialEdges:_}=j.useMemo(()=>{const Z=e.filter(Ae=>k.has(Ae.status)&&(E||!_v(Ae))),ee=Z.map(Ae=>({id:Ae.id,type:"task",data:{task:Ae,agentName:Ae.assignedAgentId?$.get(Ae.assignedAgentId):void 0},position:{x:0,y:0}})),ie=new Set(ee.map(Ae=>Ae.id)),je=new Set;for(const Ae of oo)p.has(Ae.id)&&je.add(Ae.id);const ke=r.filter(Ae=>{const We=Ev[Ae.status];return We&&je.has(We)});for(const Ae of ke){const We=`req-${Ae.id}`;ee.push({id:We,type:"requirement",data:{req:Ae},position:{x:0,y:0}}),ie.add(We)}const De=[];for(const Ae of Z)if(Ae.blockedBy)for(const We of Ae.blockedBy)ie.has(We)&&De.push(F(We,Ae.id,Ae.status));const Ie=new Set,ze=(Ae,We)=>{const xt=`${Ae}->${We}`;Ie.has(xt)||(Ie.add(xt),De.push({id:xt,source:Ae,target:We,markerEnd:{type:Zi.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const Ae of ke){const We=`req-${Ae.id}`;for(const xt of Ae.taskIds)ie.has(xt)&&ze(We,xt)}for(const Ae of Z)if(Ae.requirementId){const We=`req-${Ae.requirementId}`;ie.has(We)&&ze(We,Ae.id)}return{initialNodes:Vz(ee,De),initialEdges:De}},[e,r,$,X,F,k,p,E]),[I,A,G]=zR(D),[U,K,B]=LR(_),L=j.useRef(null);j.useEffect(()=>{A(D),K(_),requestAnimationFrame(()=>{L.current?.fitView({padding:.2,duration:300})})},[D,_,A,K]);const W=j.useCallback((Z,ee)=>{if(ee.id.startsWith("req-")){const ie=P.get(ee.id.slice(4));ie&&u&&u(ie)}else{const ie=X.get(ee.id);ie&&c&&c(ie)}},[X,P,c,u]),R=j.useCallback(async Z=>{const{source:ee,target:ie}=Z;if(!ee||!ie||ee===ie)return;const je=X.get(ie);if(!je)return;if(je.blockedBy?.includes(ee)){Y("Dependency already exists","error");return}if(Fz(X,ee,ie)){Y("Cannot add: would create a cycle","error");return}const ke=[...je.blockedBy??[],ee];try{await ae.tasks.update(ie,{blockedBy:ke}),Y("Dependency added"),f?.()}catch(De){Y(`Failed: ${De instanceof Error?De.message:String(De)}`,"error")}},[X,Y,f]),z=j.useCallback((Z,ee)=>{b(ee)},[]),V=j.useCallback(async()=>{if(!g)return;const Z=X.get(g.target);if(!Z){b(null);return}const ee=(Z.blockedBy??[]).filter(ie=>ie!==g.source);try{await ae.tasks.update(g.target,{blockedBy:ee}),Y("Dependency removed"),f?.()}catch(ie){Y(`Failed: ${ie instanceof Error?ie.message:String(ie)}`,"error")}b(null)},[g,X,Y,f]);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 Q=g?X.get(g.source):null,te=g?X.get(g.target):null;return t.jsxs("div",{className:"flex-1 min-h-0 relative",style:{height:"100%"},children:[t.jsxs(RR,{nodes:I,edges:U,onNodesChange:G,onEdgesChange:B,onNodeClick:W,onConnect:R,onEdgeClick:z,onInit:Z=>{L.current=Z},nodeTypes:Bz,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(PR,{color:m?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(XR,{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(lz,{nodeColor:Z=>{const ee=Z.data?.task,ie=ee?.status;return ee?.taskType==="scheduled"?"#06b6d4":ie==="completed"||ie==="accepted"?"#10b981":ie==="in_progress"?"#f59e0b":ie==="blocked"||ie==="failed"?"#ef4444":m?"#94a3b8":"#6b7280"},maskColor:m?"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:[H.map(Z=>{const ee=p.has(Z.id);return t.jsx("button",{onClick:()=>M(Z.id),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${ee?`${Z.color.bg} ${Z.color.border} ${Z.color.text}`:"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:Z.label},Z.id)}),N>0&&t.jsxs("button",{onClick:()=>C(Z=>!Z),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${E?"bg-surface-overlay/60 border-gray-500/50 text-fg-secondary":"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:["Archived ",N]}),p.size<Yh.size&&t.jsx("button",{onClick:()=>{w(new Set(Yh)),C(!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"})]}),h&&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 ${h.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:h.msg}),g&&t.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center z-50 backdrop-blur-[2px]",onClick:()=>b(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 shadow-2xl max-w-sm",onClick:Z=>Z.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:te?.title??g.target.slice(-8)})," ","will no longer be blocked by"," ",t.jsx("span",{className:"text-fg-secondary font-medium",children:Q?.title??g.source.slice(-8)}),"."]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>b(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:V,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 aN({orgId:e,onCreated:r,onClose:s}){const[i,o]=j.useState(""),[c,u]=j.useState(""),[f,m]=j.useState(""),[h,x]=j.useState("main"),[g,b]=j.useState([]),[p,w]=j.useState([]),[S,T]=j.useState(!1),[E,C]=j.useState(""),[N,k]=j.useState(!1),H=gs();j.useEffect(()=>{ae.teams.list().then($=>w($.teams)).catch(()=>{})},[]);const M=j.useCallback(async $=>{if($?.preventDefault(),k(!0),!(!i.trim()||S)){T(!0),C("");try{const X=f.trim()?[{url:f.trim(),defaultBranch:h.trim()||"main"}]:[],P=await ae.projects.create({name:i.trim(),description:c.trim()||void 0,repositories:X.length>0?X:void 0,teamIds:g.length>0?g:void 0,orgId:e??"default"});r(P.project)}catch(X){C(X instanceof Error?X.message:"Failed to create project")}T(!1)}},[i,c,f,h,g,e,S,r]),Y=N&&!i.trim();return K1.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 ${H?"w-full":"w-[520px]"}`,onClick:$=>$.stopPropagation(),onSubmit:M,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:i,onChange:$=>{o($.target.value),C("")},onBlur:()=>k(!0),placeholder:"e.g. Mobile App, Website Redesign",className:`input ${Y?"!border-red-500 focus:!ring-red-500/25":""}`,autoFocus:!H}),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:c,onChange:$=>u($.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"}),p.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:p.map($=>{const X=g.includes($.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:X,onChange:()=>b(P=>X?P.filter(q=>q!==$.id):[...P,$.id]),className:"accent-brand-500"}),t.jsx("span",{className:"truncate",children:$.name})]},$.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:f,onChange:$=>m($.target.value),placeholder:"https://github.com/org/repo (optional)",className:"input"})]}),f.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:h,onChange:$=>x($.target.value),placeholder:"main",className:"input !w-24"})]})]}),E&&t.jsx("div",{className:"text-xs text-red-400 bg-red-500/10 rounded-lg px-3 py-2",children:E}),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:!i.trim()||S,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:S?"Creating...":"Create Project"})]})]})]})}),document.body)}function el(e,r,s){if(!e)return null;const i=r.find(c=>c.id===e);if(i)return i.name;const o=s.find(c=>c.id===e);return o?o.name:e==="anonymous"?"Admin":null}function Xz({value:e,onSave:r,className:s,placeholder:i}){const[o,c]=j.useState(!1),[u,f]=j.useState(e),m=j.useRef(null);j.useEffect(()=>{f(e)},[e]),j.useEffect(()=>{o&&m.current?.focus()},[o]);const h=async()=>{c(!1);const x=u.trim();if(x&&x!==e)try{await r(x)}catch{f(e)}else f(e)};return o?t.jsx("input",{ref:m,value:u,onChange:x=>f(x.target.value),onBlur:()=>{h()},onKeyDown:x=>{x.key==="Enter"&&h(),x.key==="Escape"&&(f(e),c(!1))},className:`bg-transparent border-b border-brand-500/50 outline-none ${s??""}`,placeholder:i}):t.jsx("span",{onClick:()=>c(!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:i??"Click to edit"})})}function Zz({value:e,onSave:r,className:s,placeholder:i}){const[o,c]=j.useState(!1),[u,f]=j.useState(e),m=j.useRef(null);j.useEffect(()=>{f(e)},[e]),j.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.style.height="auto",m.current.style.height=m.current.scrollHeight+"px")},[o]);const h=async()=>{c(!1);const x=u.trim();if(x!==e)try{await r(x)}catch{f(e)}else f(e)};return o?t.jsx("textarea",{ref:m,value:u,onChange:x=>{f(x.target.value),x.target.style.height="auto",x.target.style.height=x.target.scrollHeight+"px"},onBlur:()=>{h()},onKeyDown:x=>{x.key==="Escape"&&(f(e),c(!1))},className:`bg-transparent border border-brand-500/30 rounded-lg p-2 outline-none resize-none w-full ${s??""}`,placeholder:i,rows:2}):t.jsx("p",{onClick:()=>c(!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:i??"Add a description…"})})}const Qz=["pending_approval","in_progress","blocked","review","completed","failed","cancelled","archived"],To=[{id:"failed",label:"Failed",statuses:["failed"],accent:"border-t-red-500",dropStatus:"failed"},{id:"todo",label:"To Do",statuses:["pending_approval"],accent:"border-t-amber-500",dropStatus:"pending_approval"},{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:["cancelled"],accent:"border-t-gray-500",dropStatus:"cancelled"}],Kz={pending_approval:"Awaiting Approval",in_progress:"In Progress",blocked:"Blocked",review:"In Review",completed:"Completed",failed:"Failed",cancelled:"Cancelled",archived:"Archived"},iN={pending_approval:{label:"Awaiting",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"}},Jz={pending_approval:{label:"Pending Approval",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"},cancelled:{label:"Cancelled",cls:"bg-gray-500/15 text-fg-tertiary"},archived:{label:"Archived",cls:"bg-gray-500/15 text-fg-tertiary"}},_m={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},lN={pending_approval:"bg-amber-400",in_progress:"bg-brand-400",blocked:"bg-amber-400",review:"bg-brand-400",completed:"bg-green-400",failed:"bg-red-400",cancelled:"bg-gray-600",archived:"bg-surface-overlay"},Av=j.memo(function({comment:r}){return t.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/30 rounded-lg px-3 py-2.5 my-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-blue-600/30 flex items-center justify-center text-[10px] text-blue-600 font-bold shrink-0",children:r.authorType==="human"?"👤":"🤖"}),t.jsx("span",{className:"text-[11px] font-medium text-blue-600",children:r.authorName}),t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:new Date(r.createdAt).toLocaleString()})]}),t.jsx(er,{content:r.content,className:"text-sm text-fg-secondary"}),r.attachments?.map((s,i)=>s.type==="image"?t.jsx("img",{src:s.url,alt:s.name,className:"mt-2 max-w-full max-h-48 rounded-lg border border-border-default"},i):null)]})});function Wz(e){return e.kind==="log"?e.executionRound??1:0}function eL(e){const r=[];let s=null,i=[],o=1;for(const c of e){if(c.kind==="comment"){s?s.items.push(c):i.push(c);continue}const u=Wz(c);if(c.entry.type==="status"&&(c.entry.content==="started"||c.entry.content==="resumed")){(!s||u!==s.roundNumber)&&(s={id:o++,roundNumber:u,startTime:c.entry.timestamp??c.entry.time??"",status:"running",items:[],preComments:[...i]},i=[],r.push(s)),c.entry.content==="resumed"&&s.items.push(c);continue}if(c.entry.type==="status"&&["completed","failed","cancelled","execution_finished"].includes(c.entry.content)){if(s){const f=c.entry.content==="execution_finished"?"completed":c.entry.content;s.status=f,s.endTime=c.entry.timestamp??c.entry.time}continue}s&&s.items.push(c)}return s&&s.status==="running"&&(s.items.length>0||(s.status="interrupted")),i.length>0&&r.length>0&&r[r.length-1].items.push(...i),r.length===0&&e.length>0&&r.push({id:o++,roundNumber:1,startTime:e[0].kind==="log"?e[0].entry.timestamp??"":new Date(e[0].time).toISOString(),status:"running",items:[...i,...e],preComments:[]}),r}function tL(e,r){if(!r)return"";const s=new Date(r).getTime()-new Date(e).getTime();if(s<1e3)return"<1s";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const o=Math.floor(i/60);return o<60?`${o}m ${i%60}s`:`${Math.floor(o/60)}h ${o%60}m`}const Mv={running:{label:"Running",color:"text-blue-600",bg:"bg-blue-500/15"},completed:{label:"Completed",color:"text-green-600",bg:"bg-green-500/15"},failed:{label:"Failed",color:"text-red-500",bg:"bg-red-500/15"},cancelled:{label:"Cancelled",color:"text-fg-secondary",bg:"bg-gray-500/15"},interrupted:{label:"Interrupted",color:"text-amber-600",bg:"bg-amber-500/15"}},nL=j.memo(function({round:r,expanded:s,onToggle:i,isLive:o,streamingText:c,isExecuting:u,totalRounds:f}){const m=Mv[r.status]??Mv.running,h=tL(r.startTime,r.endTime),x=Jm(r.startTime),g=r.items.filter(p=>p.kind==="log"&&p.entry.type==="tool").length,b=r.items.filter(p=>p.kind==="log"&&p.entry.type==="error").length;return t.jsxs("div",{className:"border-b border-border-default/60 last:border-b-0",children:[r.preComments.length>0&&t.jsx("div",{className:"px-4 py-2",children:r.preComments.map((p,w)=>p.kind==="comment"?t.jsx(Av,{comment:p.entry},`pc-${p.entry.id}`):null)}),t.jsxs("button",{onClick:i,className:"w-full flex items-center gap-2 px-4 py-2.5 hover:bg-surface-elevated/40 transition-colors text-left min-w-0 overflow-hidden",children:[t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary shrink-0 transition-transform ${s?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M4 2l5 4-5 4V2z"})}),t.jsx("span",{className:"text-xs font-medium text-fg-secondary shrink-0",children:f>1?`Round #${r.id}`:"Execution"}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${m.bg} ${m.color}`,children:m.label}),r.status==="running"&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-blue-400 animate-pulse shrink-0"}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary ml-auto flex items-center gap-2 shrink-0 truncate",children:[g>0&&t.jsxs("span",{children:[g," tools"]}),b>0&&t.jsxs("span",{className:"text-red-500",children:[b," err"]}),h&&t.jsx("span",{children:h}),t.jsx("span",{children:x})]})]}),s&&t.jsxs("div",{className:"px-4 pb-3 space-y-0.5 overflow-x-hidden min-w-0",children:[r.items.map((p,w)=>p.kind==="comment"?t.jsx(Av,{comment:p.entry},`c-${p.entry.id}`):t.jsx(fT,{entry:p.entry,showTime:!0},`l-${(p.entry.type==="tool"?p.entry.key:void 0)??`${p.entry.timestamp}-${w}`}`)),o&&c&&t.jsx(ej,{content:c}),o&&u&&!c&&t.jsx(Nu,{label:"Thinking"})]})]})});function rL({taskId:e,isVisible:r,isRunning:s,authUser:i}){const[o,c]=j.useState([]),[u,f]=j.useState([]),[m,h]=j.useState(""),[x,g]=j.useState(s),[b,p]=j.useState(!0),[w,S]=j.useState(""),[T,E]=j.useState(!1),[C,N]=j.useState([]),[k,H]=j.useState(new Set),[M,Y]=j.useState(1),$=20,X=j.useRef(null),P=j.useRef(null),q=j.useRef(null),F=j.useRef(!0);j.useEffect(()=>{const z=q.current;if(!z)return;let V=z.parentElement;for(;V&&V.scrollHeight<=V.clientHeight;)V=V.parentElement;if(!V)return;const Q=V,te=()=>{F.current=Q.scrollHeight-Q.scrollTop-Q.clientHeight<80};return Q.addEventListener("scroll",te,{passive:!0}),()=>Q.removeEventListener("scroll",te)},[]),j.useEffect(()=>{g(s)},[s]),j.useEffect(()=>{p(!0),Promise.all([ae.tasks.getLogs(e).catch(()=>({logs:[]})),ae.tasks.getComments(e).catch(()=>({comments:[]}))]).then(([z,V])=>{c(z.logs),f(V.comments),p(!1)})},[e]),j.useEffect(()=>{const z=En.on("task:log",te=>{const Z=te.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};c(ie=>ee.id&&ie.some(je=>je.id===ee.id)||!ee.id&&ie.some(je=>je.seq===ee.seq&&je.type===ee.type)?ie:[...ie,ee]),ee.type==="text"&&h(""),ee.type==="status"&&(ee.content==="started"||ee.content==="resumed"?g(!0):["completed","failed","cancelled","execution_finished"].includes(ee.content)&&g(!1)),ee.type==="error"&&g(!1)}),V=En.on("task:log:delta",te=>{const Z=te.payload;Z.taskId===e&&h(ee=>ee+Z.text)}),Q=En.on("task:comment",te=>{const Z=te.payload;if(Z.taskId!==e)return;const ee=Z.comment;f(ie=>ie.some(je=>je.id===ee.id)?ie:[...ie,ee])});return()=>{z(),V(),Q()}},[e]);const D=j.useMemo(()=>{const z=new Map;for(const V of o)V.executionRound&&z.set(V.seq,V.executionRound);return z},[o]),_=j.useMemo(()=>{const z=o.map(Z=>({log:Z,entry:Wm(Z)})).filter(Z=>Z.entry!=null),V=bo(z.map(Z=>Z.entry)),Q=new Set(V),te=[...z.filter(Z=>Q.has(Z.entry)).map(({log:Z,entry:ee})=>({kind:"log",entry:ee,time:new Date(ee.timestamp??ee.time??0).getTime(),executionRound:Z.executionRound??D.get(Z.seq)??1})),...u.map(Z=>({kind:"comment",entry:Z,time:new Date(Z.createdAt).getTime()}))];return te.sort((Z,ee)=>Z.time-ee.time),te},[o,u,D]),I=j.useMemo(()=>eL(_),[_]);j.useEffect(()=>{I.length>0&&H(z=>{const V=I[I.length-1].id;return z.has(V)?z:new Set([V])})},[I.length]),j.useEffect(()=>{r&&x&&P.current?.scrollIntoView({behavior:"smooth",block:"start"})},[I.length,r,x]);const A=j.useCallback(z=>{H(V=>{const Q=new Set(V);return Q.has(z)?Q.delete(z):Q.add(z),Q})},[]),G=z=>{const V=z.target.files;if(V){for(const Q of Array.from(V)){if(!Q.type.startsWith("image/"))continue;const te=new FileReader;te.onload=()=>{N(Z=>[...Z,{type:"image",url:te.result,name:Q.name}])},te.readAsDataURL(Q)}z.target.value=""}},U=async()=>{if(!(!w.trim()&&C.length===0)){E(!0);try{const z=await ae.tasks.addComment(e,w,i?.name,C.length>0?C:void 0,i?.id);z.comment&&f(V=>V.some(Q=>Q.id===z.comment.id)?V:[...V,z.comment]),S(""),N([])}catch{}E(!1)}},K=t.jsxs("div",{className:"border-t border-border-default px-4 py-3 sticky bottom-0 bg-surface-secondary z-10",children:[C.length>0&&t.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:C.map((z,V)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:z.url,alt:z.name,className:"w-16 h-16 object-cover rounded-lg border border-border-default"}),t.jsx("button",{onClick:()=>N(Q=>Q.filter((te,Z)=>Z!==V)),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:"×"})]},V))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:w,onChange:z=>S(z.target.value),onKeyDown:z=>{z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),U())},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:X,accept:"image/*",multiple:!0,onChange:G,className:"hidden"}),t.jsx("button",{onClick:()=>X.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:()=>{U()},disabled:T||!w.trim()&&C.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(b)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-fg-tertiary",children:"Loading logs…"});if(I.length===0&&!m)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.']})]})}),K]});const B=Math.ceil(I.length/$),L=M*$,W=(M-1)*$,R=I.slice(Math.max(0,I.length-L),I.length-W).slice().reverse();return t.jsxs("div",{children:[B>1&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-default",children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[I.length," rounds total"]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:M<=1,onClick:()=>Y(z=>z-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"← Newer"}),t.jsxs("span",{children:[M,"/",B]}),t.jsx("button",{disabled:M>=B,onClick:()=>Y(z=>z+1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"Older →"})]})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("div",{ref:P}),R.map(z=>{const V=z.id===I[I.length-1]?.id;return t.jsx(nL,{round:z,expanded:k.has(z.id),onToggle:()=>A(z.id),isLive:V&&x,streamingText:V?m:void 0,isExecuting:V?x:!1,totalRounds:I.length},z.id)}),t.jsx("div",{ref:q})]}),K]})}function sL({filePath:e,onClose:r}){const[s,i]=j.useState(null),[o,c]=j.useState(null),[u,f]=j.useState(!0);j.useEffect(()=>{f(!0),c(null),ae.files.preview(e).then(h=>i(h)).catch(h=>c(String(h))).finally(()=>f(!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:r,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:h=>h.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:r,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:[u&&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(er,{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 aL({task:e,agents:r,projects:s,requirements:i,allTasks:o,users:c,onClose:u,onRefresh:f,authUser:m}){const[h,x]=j.useState([]),[g,b]=j.useState(""),[p,w]=j.useState(!1),[S,T]=j.useState(null),[E,C]=j.useState(null),[N,k]=j.useState(!1),[H,M]=j.useState("details"),[Y,$]=j.useState(!1),[X,P]=j.useState(null),[q,F]=j.useState(null),[D,_]=j.useState(!1),[I,A]=j.useState(e.description),[G,U]=j.useState(!1),[K,B]=j.useState(""),[L,W]=j.useState(1),[R,z]=j.useState(1),[V,Q]=j.useState(!1),te=gs(),Z=20,ee=j.useCallback(async()=>{try{const xe=await ae.tasks.listSubtasks(e.id);x(xe.subtasks)}catch{}},[e.id]);j.useEffect(()=>{ee()},[ee]);const ie=async xe=>{if(!N){k(!0);try{await xe(),f(),await ee()}catch(Be){P(String(Be).replace("Error: ",""))}finally{k(!1)}}},je=xe=>ie(()=>ae.tasks.update(e.id,{priority:xe})),ke=xe=>ie(()=>ae.tasks.assign(e.id,xe||null)),De=xe=>ie(()=>ae.tasks.update(e.id,{projectId:xe||null})),Ie=async()=>{if(!N){k(!0);try{await ae.tasks.pause(e.id),f()}finally{k(!1)}}},ze=async()=>{if(!Y){$(!0),P(null),M("logs");try{await ae.tasks.resume(e.id),f()}catch(xe){P(String(xe).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{$(!1)}}},Ze=async()=>{g.trim()&&(await ae.tasks.createSubtask(e.id,g.trim()),b(""),w(!1),ee(),f())},Ae=async xe=>{xe.status==="completed"?await ae.tasks.cancelSubtask(e.id,xe.id):await ae.tasks.completeSubtask(e.id,xe.id),ee(),f()},We=async xe=>{await ae.tasks.deleteSubtask(e.id,xe.id),T(null),ee(),f()},xt=async()=>{if(!N){k(!0);try{await ae.tasks.updateStatus(e.id,"pending_approval"),f()}finally{k(!1)}}},Lt=async()=>{if(!N){k(!0),P(null),M("logs");try{await ae.tasks.retry(e.id),f()}catch(xe){P(String(xe).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{k(!1)}}},le=async()=>{if(!Y){$(!0),P(null),M("logs");try{await ae.tasks.runNow(e.id),f()}catch(xe){P(String(xe).replace("Error: API error: 400","Server error").replace("Error: ","")),f()}finally{$(!1)}}};j.useEffect(()=>En.on("task:log:delta",Be=>{Be.payload.taskId===e.id&&M("logs")}),[e.id]);const _e=j.useRef(f);_e.current=f,j.useEffect(()=>En.on("task:update",Be=>{Be.payload.taskId===e.id&&(ee(),_e.current())}),[e.id,ee]);const ht=h.filter(xe=>xe.status==="completed").length,Ct=e.status==="in_progress",Ft=e.status==="blocked",be=e.status==="completed",Me=e.status==="failed",Ve=e.status==="cancelled",Xe=e.status==="archived",rt=be||Me||Ve||Xe,It=e.taskType==="scheduled"&&!!e.scheduleConfig,Ht=It&&!!e.scheduleConfig?.paused,_t=s.find(xe=>xe.id===e.projectId),wt=i.find(xe=>xe.id===e.requirementId);return r.find(xe=>xe.id===e.assignedAgentId),t.jsxs("div",{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-3 ${te?"pb-[4.5rem]":""}`,onClick:u,children:[t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl flex flex-col shadow-2xl ${te?"w-full max-h-full":"w-[780px] max-w-[95vw] max-h-[88vh]"}`,onClick:xe=>xe.stopPropagation(),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.jsx("div",{className:"flex-1 min-w-0 pr-4",children:t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h3",{className:"text-base font-semibold leading-snug",children:e.title}),(()=>{const xe=Jz[e.status];return xe?t.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium whitespace-nowrap ${xe.cls}`,children:xe.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," ")})})()]})}),t.jsx("button",{onClick:u,className:"text-fg-tertiary hover:text-fg-secondary text-lg shrink-0",children:"×"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[t.jsx("div",{className:"px-6 pt-4 pb-3 border-b border-border-default",children:D?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:I,onChange:xe=>A(xe.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:()=>{_(!1),A(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:()=>{ie(()=>ae.tasks.update(e.id,{description:I})),_(!1)},disabled:N,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:te&&!V?"line-clamp-3":"",children:t.jsx(er,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})}),te&&e.description.length>150&&t.jsx("button",{onClick:()=>Q(!V),className:"text-[11px] text-brand-500 mt-1 font-medium",children:V?"Collapse":"Show more"})]}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),t.jsx("button",{onClick:()=>{A(e.description),_(!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||wt)&&t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default flex flex-wrap items-center gap-2",children:[_t&&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"}),_t.name]}),wt&&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"}),wt.title.length>40?wt.title.slice(0,40)+"…":wt.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(xe=>{const Be=o.find(pt=>pt.id===xe),gt=Be&&(Be.status==="completed"||Be.status==="cancelled");return t.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-full ${gt?"bg-green-500/10 text-green-600":"bg-amber-500/10 text-amber-600"}`,children:[t.jsx("span",{className:"text-[9px]",children:gt?"✓":"⏳"}),t.jsx("span",{className:`font-mono ${gt?"line-through opacity-60":""}`,children:Be?Be.title.slice(0,30):xe.slice(-8)}),!rt&&t.jsx("button",{onClick:async()=>{const pt=(e.blockedBy??[]).filter(ue=>ue!==xe);await ae.tasks.update(e.id,{blockedBy:pt}),f()},className:"ml-0.5 text-current opacity-40 hover:opacity-100 transition-opacity",title:"Remove dependency",children:"×"})]},xe)})}):t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-2",children:"No dependencies"}),!rt&&t.jsxs("select",{value:"",onChange:async xe=>{const Be=xe.target.value;if(!Be)return;const gt=[...e.blockedBy??[],Be];await ae.tasks.update(e.id,{blockedBy:gt}),f()},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(xe=>xe.id!==e.id&&!(e.blockedBy??[]).includes(xe.id)).map(xe=>t.jsx("option",{value:xe.id,children:xe.title},xe.id))]})]}),t.jsxs("div",{className:"flex gap-1 px-6 pt-3 border-b border-border-default sticky top-0 z-10 bg-surface-secondary",children:[t.jsx("button",{onClick:()=>M("details"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors ${H==="details"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Details"}),t.jsxs("button",{onClick:()=>M("logs"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${H==="logs"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Execution Log",Ct&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse"})]}),t.jsxs("button",{onClick:()=>M("notes"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${H==="notes"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Notes",e.notes&&e.notes.length>0&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-normal",children:e.notes.length})]}),t.jsxs("button",{onClick:()=>M("deliverables"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${H==="deliverables"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Deliverables",(()=>{const xe=(e.deliverables??[]).filter(Be=>Be.type!=="branch"&&typeof Be.reference=="string"&&Be.reference.length>0).length;return xe>0?t.jsx("span",{className:"text-[10px] text-fg-tertiary font-normal",children:xe}):null})()]})]}),H==="logs"&&t.jsxs("div",{className:"overflow-x-hidden min-w-0",children:[X&&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:"})," ",X]}),t.jsx(rL,{taskId:e.id,isVisible:!0,isRunning:e.status==="in_progress",authUser:m})]}),H==="details"&&t.jsxs(t.Fragment,{children:[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:xe=>{De(xe.target.value)},disabled:N,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(xe=>t.jsx("option",{value:xe.id,children:xe.name},xe.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:xe=>ie(()=>ae.tasks.update(e.id,{requirementId:xe.target.value||null})),disabled:N,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"}),i.filter(xe=>!e.projectId||xe.projectId===e.projectId).map(xe=>t.jsx("option",{value:xe.id,children:xe.title},xe.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:xe=>{ke(xe.target.value)},disabled:N,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"}),r.map(xe=>t.jsxs("option",{value:xe.id,children:[xe.name," (",xe.status,")"]},xe.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:xe=>{xe.target.value&&xe.target.value!==e.reviewerAgentId&&ie(()=>ae.tasks.update(e.id,{reviewerAgentId:xe.target.value}))},disabled:N,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:r.map(xe=>t.jsx("option",{value:xe.id,children:xe.name},xe.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:xe=>{je(xe.target.value)},disabled:N,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:el(e.createdBy,r,c)??e.createdBy})]}),e.updatedBy&&t.jsxs("span",{children:["Updated by ",t.jsx("span",{className:"text-fg-secondary",children:el(e.updatedBy,r,c)??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 ",h.length>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal normal-case",children:[ht,"/",h.length," done"]})]}),t.jsx("button",{onClick:()=>w(!0),className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"+ Add subtask"})]}),h.length>0&&t.jsx("div",{className:"space-y-1.5 mb-3",children:h.map(xe=>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:()=>{Ae(xe)},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${xe.status==="completed"?"bg-green-600 border-green-600 text-white":"border-gray-600 hover:border-brand-500"}`,children:xe.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 ${xe.status==="completed"?"line-through text-fg-tertiary":"text-fg-secondary"}`,children:xe.title}),t.jsx("button",{onClick:()=>T(xe),className:"shrink-0 opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-red-500 transition-all text-xs",children:"✕"})]},xe.id))}),h.length===0&&!p&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:"No subtasks yet."}),p&&t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("input",{autoFocus:!0,value:g,onChange:xe=>b(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&Ze(),xe.key==="Escape"&&(w(!1),b(""))},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:()=>{Ze()},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),b("")},className:"px-3 py-1.5 border border-border-default text-xs rounded-lg hover:bg-surface-elevated",children:"Cancel"})]}),(()=>{const xe=(e.deliverables??[]).filter(pt=>pt.type!=="branch"&&typeof pt.reference=="string"&&pt.reference.length>0);if(xe.length===0)return null;const Be={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"},gt=xe.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:["(",xe.length,")"]})]}),xe.length>3&&t.jsx("button",{onClick:()=>M("deliverables"),className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:gt.map((pt,ue)=>{const Se=pt.reference.split("/").pop()??pt.reference;return t.jsxs("div",{className:"flex items-start gap-2.5 bg-surface-elevated/60 rounded-lg px-3 py-2 group hover:bg-surface-elevated/80 transition-colors",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium shrink-0 mt-0.5 ${Be[pt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:pt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>F(pt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:pt.reference,children:Se}),pt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:pt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:pt.reference})]})]},ue)})})]})})(),e.notes&&e.notes.length>0&&(()=>{const xe=[...e.notes].reverse().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:["Progress Notes ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",e.notes.length,")"]})]}),e.notes.length>3&&t.jsx("button",{onClick:()=>M("notes"),className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:xe.map((Be,gt)=>t.jsx("div",{className:"text-xs text-fg-secondary bg-surface-elevated/60 rounded px-2.5 py-1.5 leading-relaxed",children:t.jsx(er,{content:Be,className:"text-xs text-fg-secondary"})},gt))})]})})()]})]}),H==="notes"&&t.jsx("div",{className:"px-6 py-4",children:e.notes&&e.notes.length>0?(()=>{const xe=[...e.notes].reverse(),Be=Math.ceil(xe.length/Z),gt=xe.slice((R-1)*Z,R*Z);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:["Progress Notes ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",e.notes.length,")"]})]}),Be>1&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:R<=1,onClick:()=>z(pt=>pt-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"‹"}),t.jsxs("span",{children:[R,"/",Be]}),t.jsx("button",{disabled:R>=Be,onClick:()=>z(pt=>pt+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:gt.map((pt,ue)=>t.jsx("div",{className:"text-xs text-fg-secondary bg-surface-elevated/60 rounded px-2.5 py-1.5 leading-relaxed",children:t.jsx(er,{content:pt,className:"text-xs text-fg-secondary"})},ue))})]})})():t.jsx("div",{className:"flex items-center justify-center py-12 text-xs text-fg-tertiary",children:"No progress notes yet."})}),H==="deliverables"&&t.jsx("div",{className:"px-6 py-4",children:(()=>{const xe=(e.deliverables??[]).filter(ue=>ue.type!=="branch"&&typeof ue.reference=="string"&&ue.reference.length>0);if(xe.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12 text-xs text-fg-tertiary",children:"No deliverables yet."});const Be={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"},gt=Math.ceil(xe.length/Z),pt=xe.slice((L-1)*Z,L*Z);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:["(",xe.length,")"]})]}),gt>1&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:L<=1,onClick:()=>W(ue=>ue-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"‹"}),t.jsxs("span",{children:[L,"/",gt]}),t.jsx("button",{disabled:L>=gt,onClick:()=>W(ue=>ue+1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"›"})]})]}),t.jsx("div",{className:"space-y-1.5",children:pt.map((ue,Se)=>{const Ke=ue.reference.split("/").pop()??ue.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 ${Be[ue.type]??"bg-gray-500/15 text-fg-secondary"}`,children:ue.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>F(ue.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:ue.reference,children:Ke}),ue.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:ue.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:ue.reference})]})]},Se)})})]})})()})]}),It&&e.scheduleConfig&&t.jsxs("div",{className:`mx-6 mt-3 mb-0 px-4 py-2.5 rounded-lg border text-xs ${Ht?"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:Ht?"text-amber-600":"text-brand-500",children:Ht?"⏸ 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"}),!Ht&&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 xe=new Date(e.scheduleConfig.nextRunAt).getTime()-Date.now();if(xe<=0)return"due now";const Be=Math.floor(xe/6e4);if(Be<60)return`in ${Be}m`;const gt=Math.floor(Be/60);return gt<24?`in ${gt}h ${Be%60}m`:`in ${Math.floor(gt/24)}d ${gt%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 xe=Date.now()-new Date(e.scheduleConfig.lastRunAt).getTime(),Be=Math.floor(xe/6e4);if(Be<1)return"just now";if(Be<60)return`${Be}m ago`;const gt=Math.floor(Be/60);return gt<24?`${gt}h ${Be%60}m ago`:`${Math.floor(gt/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_approval"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>ie(()=>ae.tasks.approve(e.id)),disabled:N,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:()=>ie(()=>ae.tasks.reject(e.id)),disabled:N,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:()=>{ie(()=>ae.tasks.accept(e.id,m?.id))},disabled:N,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"✓ Approve"}),G?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"text",value:K,onChange:xe=>B(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&K.trim()&&(ie(()=>ae.tasks.revision(e.id,K.trim(),m?.id)),U(!1),B(""))},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:()=>{ie(()=>ae.tasks.revision(e.id,K.trim()||"Revisions needed",m?.id)),U(!1),B("")},disabled:N,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:()=>{U(!1),B("")},className:"px-1.5 py-1 text-xs text-fg-secondary hover:text-fg-primary",children:"✕"})]}):t.jsx("button",{onClick:()=>U(!0),disabled:N,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"})]}),Ct&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>{Ie()},disabled:N,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:()=>{Lt()},disabled:N,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"]})]}),Ft&&t.jsx("button",{onClick:()=>{ze()},disabled:Y,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:Y?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"]})}),Me&&t.jsxs("button",{onClick:()=>{Lt()},disabled:N,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"]}),It&&(be||Me)&&t.jsx("button",{onClick:()=>{le()},disabled:Y,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:Y?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"]})}),It&&!Ct&&(Ht?t.jsx("button",{onClick:()=>{ie(()=>ae.tasks.resumeSchedule(e.id))},disabled:N,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:()=>{ie(()=>ae.tasks.pauseSchedule(e.id))},disabled:N,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"})),be&&t.jsx("button",{onClick:()=>ie(()=>ae.tasks.archive(e.id)),disabled:N,className:"px-3 py-1.5 text-xs bg-gray-600 hover:bg-gray-500 rounded-lg text-white disabled:opacity-50",children:"Archive"}),rt&&t.jsx("button",{onClick:()=>{xt()},disabled:N,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"}),!rt&&e.status!=="pending_approval"&&t.jsx("button",{onClick:async()=>{const{count:xe}=await ae.tasks.getDependentCount(e.id);xe>0?C({dependentCount:xe}):ie(()=>ae.tasks.cancel(e.id))},disabled:N,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"})]})})]}),S&&t.jsx(sj,{title:`Delete subtask "${S.title}"?`,message:"This subtask will be permanently deleted.",confirmLabel:"Delete",onConfirm:()=>{We(S)},onCancel:()=>T(null)}),E&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>C(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:xe=>xe.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:E.dependentCount})," dependent task",E.dependentCount>1?"s":""," that ",E.dependentCount>1?"are":"is"," currently blocked by it."]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{onClick:()=>{C(null),ie(()=>ae.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:()=>{C(null),ie(()=>ae.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 ",E.dependentCount," blocked task",E.dependentCount>1?"s":""]})]}),t.jsx("button",{onClick:()=>C(null),className:"w-full px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary",children:"Keep task running"})]})]})}),q&&t.jsx(sL,{filePath:q,onClose:()=>F(null)})]})}function iL({project:e,tasks:r,requirements:s,agents:i,onDeleteProject:o,onUpdateProject:c,onRefresh:u}){const f=j.useMemo(()=>r.filter(b=>b.projectId===e.id),[r,e.id]),m=j.useMemo(()=>s.filter(b=>b.projectId===e.id),[s,e.id]),h=j.useMemo(()=>{const b={total:f.length,completed:0,inProgress:0,inReview:0,blocked:0,pending:0,failed:0,reqs:m.length,reqsDone:0};for(const p of f)p.status==="completed"||p.status==="accepted"?b.completed++:p.status==="in_progress"?b.inProgress++:p.status==="review"||p.status==="revision"?b.inReview++:p.status==="blocked"?b.blocked++:p.status==="failed"?b.failed++:b.pending++;for(const p of m)p.status==="completed"&&b.reqsDone++;return b},[f,m]),x=j.useMemo(()=>new Set(f.map(b=>b.assignedAgentId).filter(Boolean)),[f]),g=j.useMemo(()=>i.filter(b=>x.has(b.id)),[i,x]);return t.jsxs("div",{className:"p-5 space-y-5 max-w-3xl",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[t.jsx(Zz,{value:e.description??"",onSave:async b=>{await c({description:b}),u()},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:[t.jsx(mL,{status:e.status}),e.createdAt&&t.jsxs("span",{className:"text-fg-tertiary",children:["Created ",new Date(e.createdAt).toLocaleDateString()]})]})]}),t.jsx("button",{onClick:o,className:"text-xs text-red-500 hover:text-red-500 shrink-0 ml-4",children:"Delete Project"})]}),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:h.total,color:"text-fg-primary"}),t.jsx(zs,{label:"Completed",value:h.completed,color:"text-green-600"}),t.jsx(zs,{label:"In Progress",value:h.inProgress,color:"text-brand-500"}),t.jsx(zs,{label:"In Review",value:h.inReview,color:"text-brand-500"}),t.jsx(zs,{label:"Blocked",value:h.blocked,color:"text-amber-600"}),t.jsx(zs,{label:"Failed",value:h.failed,color:"text-red-500"})]}),h.total>0&&t.jsxs("div",{className:"mt-3 flex h-2 rounded-full overflow-hidden bg-surface-elevated",children:[h.completed>0&&t.jsx("div",{className:"bg-green-500",style:{width:`${h.completed/h.total*100}%`}}),h.inProgress>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${h.inProgress/h.total*100}%`}}),h.inReview>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${h.inReview/h.total*100}%`}}),h.blocked>0&&t.jsx("div",{className:"bg-amber-500",style:{width:`${h.blocked/h.total*100}%`}}),h.pending>0&&t.jsx("div",{className:"bg-blue-500/40",style:{width:`${h.pending/h.total*100}%`}}),h.failed>0&&t.jsx("div",{className:"bg-red-500",style:{width:`${h.failed/h.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:h.reqs,color:"text-fg-primary"}),t.jsx(zs,{label:"Completed",value:h.reqsDone,color:"text-green-600"}),t.jsx(zs,{label:"Active",value:h.reqs-h.reqsDone,color:"text-brand-500"})]})]}),g.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 (",g.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(b=>{const p=f.filter(S=>S.assignedAgentId===b.id),w=p.filter(S=>!["completed","failed","cancelled","archived"].includes(S.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 ${b.status==="working"?"bg-blue-500":b.status==="idle"?"bg-green-500":"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary",children:b.name}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[w.length," active / ",p.length," total"]})]},b.id)})})]}),e.repositories&&e.repositories.length>0&&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-2",children:"Repositories"}),e.repositories.map((b,p)=>t.jsxs("div",{className:"text-sm text-fg-secondary flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary",children:"⎇"}),t.jsx("span",{children:b.url||b.localPath}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:["(",b.defaultBranch,")"]})]},p))]})]})}function zs({label:e,value:r,color:s}){return t.jsxs("div",{className:"text-center py-2",children:[t.jsx("div",{className:`text-xl font-bold ${s}`,children:r}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}const $u={draft:{label:"Draft",cls:"bg-gray-500/15 text-fg-secondary"},pending_review:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},approved:{label:"Approved",cls:"bg-green-500/15 text-green-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"}},oN={draft:"todo",pending_review:"todo",approved:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed"},cN={failed:"rejected",todo:"approved",in_progress:"in_progress",review:"approved",done:"completed",closed:"cancelled"},lL={urgent:0,high:1,medium:2,low:3},Dv={failed:0,todo:1,in_progress:2,review:3,done:4,closed:5},oL={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"},cL={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"},uN=["draft","pending_review","approved","in_progress","completed","rejected","cancelled"];function uL(e){for(const r of To)if(r.statuses.includes(e))return r.id;return"closed"}function dL(e){const r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Ov({row:e,idx:r,dragIdx:s,agentMap:i,projMap:o,onTaskClick:c,onReqClick:u,onRowDragStart:f,onRowDragEnd:m,handleStatusChange:h,handlePriorityChange:x}){const g=e.data.status,b=e.data.priority,p=e.kind==="task"?i.get(e.data.assignedAgentId??""):void 0,w=o.get((e.kind==="task",e.data.projectId??""));return t.jsxs("div",{draggable:!0,onDragStart:S=>f(S,r),onDragEnd:m,onClick:()=>e.kind==="task"?c(e.data):u(e.data),className:`flex items-center gap-2 px-6 py-2 border-b border-border-default/40 cursor-pointer hover:bg-surface-elevated/50 transition-colors border-l-2 ${oL[e.group]??"border-l-gray-700"} ${s===r?"opacity-40":""}`,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:S=>S.stopPropagation(),children:t.jsx("select",{value:g,onChange:S=>{h(e,S.target.value)},className:"w-full px-1.5 py-1 bg-surface-elevated/80 border border-border-default/50 rounded text-[11px] text-fg-secondary outline-none focus:border-brand-500 cursor-pointer",children:e.kind==="task"?Qz.map(S=>t.jsx("option",{value:S,children:Kz[S]??S},S)):uN.map(S=>t.jsx("option",{value:S,children:$u[S]?.label??S},S))})}),t.jsx("div",{className:"w-[100px] shrink-0",onClick:S=>S.stopPropagation(),children:t.jsxs("select",{value:b,onChange:S=>{x(e,S.target.value)},className:"w-full px-1.5 py-1 bg-surface-elevated/80 border border-border-default/50 rounded text-[11px] text-fg-secondary outline-none focus:border-brand-500 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.jsx("div",{className:"w-[120px] shrink-0 text-[11px] text-fg-secondary truncate",children:p?t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${lN[p.status]??"bg-gray-500"}`}),p.name]}):t.jsx("span",{className:"text-fg-tertiary",children:"—"})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] text-fg-tertiary truncate",children:w?.name??t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[90px] shrink-0 text-[10px] text-fg-tertiary text-right",children:dL(e.data.updatedAt??"")})]})}function fL({tasks:e,requirements:r,agents:s,projects:i,onTaskClick:o,onReqClick:c,onRefresh:u}){const[f,m]=j.useState("status"),[h,x]=j.useState(null),[g,b]=j.useState(null),p=j.useMemo(()=>{const q=[];for(const F of e){const D=uL(F.status);q.push({kind:"task",data:F,group:D,groupOrder:Dv[D]??5})}for(const F of r){const D=oN[F.status]??"todo";q.push({kind:"req",data:F,group:D,groupOrder:Dv[D]??5})}if(f==="status")q.sort((F,D)=>{if(F.groupOrder!==D.groupOrder)return F.groupOrder-D.groupOrder;const _=new Date(F.data.updatedAt??0).getTime();return new Date(D.data.updatedAt??0).getTime()-_});else{const F=D=>lL[D.data.priority]??2;q.sort((D,_)=>{const I=F(D),A=F(_);return I!==A?I-A:new Date(_.data.updatedAt??0).getTime()-new Date(D.data.updatedAt??0).getTime()})}return q},[e,r,f]),w=async(q,F)=>{try{q.kind==="task"?await ae.tasks.updateStatus(q.data.id,F):await ae.requirements.updateStatus(q.data.id,F),u()}catch{}},S=async(q,F)=>{try{q.kind==="task"?await ae.tasks.update(q.data.id,{priority:F}):await ae.requirements.update(q.data.id,{priority:F}),u()}catch{}},T=(q,F)=>{x(F),q.dataTransfer.effectAllowed="move",q.dataTransfer.setData("text/plain",String(F)),q.currentTarget.style.opacity="0.4"},E=q=>{q.currentTarget.style.opacity="1",x(null),b(null)},C=(q,F)=>{q.preventDefault(),q.dataTransfer.dropEffect="move",g!==F&&b(F)},N=async(q,F)=>{if(q.preventDefault(),b(null),h==null)return;const D=p[h];if(!D||D.group===F)return;const _=To.find(I=>I.id===F);if(_){try{if(D.kind==="task"){if(D.data.status==="pending_approval")return;await ae.tasks.updateStatus(D.data.id,_.dropStatus)}else{const I=cN[F];I&&await ae.requirements.updateStatus(D.data.id,I)}u()}catch{}x(null)}},k=j.useMemo(()=>new Map(s.map(q=>[q.id,q])),[s]),H=j.useMemo(()=>new Map(i.map(q=>[q.id,q])),[i]),M=["todo","in_progress","review","done"],Y=j.useMemo(()=>{const q={};for(const F of p)q[F.group]=(q[F.group]??0)+1;return q},[p]),{rowsByGroup:$,rowIndexMap:X}=j.useMemo(()=>{const q=new Map,F=new Map;for(let D=0;D<p.length;D++){const _=p[D];F.set(_,D);const I=q.get(_.group)??[];I.push(_),q.set(_.group,I)}return{rowsByGroup:q,rowIndexMap:F}},[p]),P=j.useMemo(()=>{if(f!=="status")return null;const q=new Set(p.map(_=>_.group)),F=[],D=new Set;q.has("failed")&&(F.push("failed"),D.add("failed"));for(const _ of M)F.push(_),D.add(_);for(const _ of p)D.has(_.group)||(F.push(_.group),D.add(_.group));return F},[p,f]);return t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsxs("div",{className:"min-w-[850px] h-full flex flex-col",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 shrink-0 bg-surface-secondary/80",children:[t.jsx("div",{className:"w-12 shrink-0 text-fg-muted normal-case font-normal",children:p.length}),t.jsx("div",{className:"flex-1 min-w-[200px]",children:"Title"}),t.jsxs("button",{onClick:()=>m("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:()=>m("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",{className:"flex-1 min-h-0 overflow-y-auto",children:[f==="status"&&P?P.map(q=>{const F=To.find(_=>_.id===q),D=$.get(q)??[];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 ${cL[q]??""} ${g===q?"ring-1 ring-brand-500/40":""}`,onDragOver:_=>C(_,q),onDragLeave:()=>b(null),onDrop:_=>{N(_,q)},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",children:F?.label??q}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Y[q]??0})]}),D.map(_=>t.jsx(Ov,{row:_,idx:X.get(_)??0,dragIdx:h,agentMap:k,projMap:H,onTaskClick:o,onReqClick:c,onRowDragStart:T,onRowDragEnd:E,handleStatusChange:w,handlePriorityChange:S},`${_.kind}-${_.data.id}`))]},q)}):p.map((q,F)=>t.jsx(Ov,{row:q,idx:F,dragIdx:h,agentMap:k,projMap:H,onTaskClick:o,onReqClick:c,onRowDragStart:T,onRowDragEnd:E,handleStatusChange:w,handlePriorityChange:S},`${q.kind}-${q.data.id}`)),p.length===0&&t.jsx("div",{className:"flex items-center justify-center py-16 text-sm text-fg-tertiary",children:"No items"})]})]})})}function Rv({authUser:e}){const r=gs(),[s,i]=j.useState([]),[o,c]=j.useState("all"),[u,f]=j.useState(null),[m,h]=j.useState({}),[x,g]=j.useState([]),[b,p]=j.useState([]),[w,S]=j.useState([]),[T,E]=j.useState(!0),[C,N]=j.useState(""),[k,H]=j.useState(!1),M=j.useCallback(()=>{Se(u??""),Ht(!0)},[u]),[Y,$]=j.useState(!1),[X,P]=j.useState(!1),[q,F]=j.useState(""),[D,_]=j.useState(""),[I,A]=j.useState("medium"),[G,U]=j.useState(""),[K,B]=j.useState(""),[L,W]=j.useState(""),[R,z]=j.useState(""),[V,Q]=j.useState([]),[te,Z]=j.useState("standard"),[ee,ie]=j.useState("4h"),[je,ke]=j.useState(null),[De,Ie]=j.useState(null),[ze,Ze]=j.useState(new Set),[Ae,We]=j.useState(new Set),xt=j.useRef(new Set),Lt=j.useRef(new Set),[le,_e]=j.useState(null),[ht,Ct]=j.useState("backlog"),[Ft,be]=j.useState(!1),[Me,Ve]=j.useState(!1),Xe=j.useRef(null),rt=j.useRef(null),[It,Ht]=j.useState(!1),[_t,wt]=j.useState(""),[xe,Be]=j.useState(""),[gt,pt]=j.useState("medium"),[ue,Se]=j.useState(""),[Ke,At]=j.useState(null),[rn,vn]=j.useState(""),Mt=ne=>{N(ne),setTimeout(()=>N(""),3e3)},oe=s.find(ne=>ne.id===u)??null;j.useEffect(()=>{Lt.current=Ae},[Ae]);const Le=j.useCallback(async()=>{try{const{projects:ne}=await ae.projects.list();i(ne)}catch{}},[]),$e=j.useCallback(async()=>{const ne={};o==="project"&&u&&(ne.projectId=u);try{const{board:Oe}=await ae.tasks.board(ne);h(Oe)}catch{}},[o,u]),st=j.useCallback(async()=>{try{const{agents:ne}=await ae.agents.list();g(ne)}catch{}},[]),at=j.useCallback(async()=>{try{const{users:ne}=await ae.users.list(e?.orgId);p(ne)}catch{}},[e?.orgId]),Ue=j.useCallback(async()=>{try{const{requirements:ne}=await ae.requirements.list({});S(ne)}catch{}},[]),jn=j.useCallback(async()=>{await Promise.all([Le(),$e(),st(),at(),Ue()]),E(!1)},[Le,$e,st,at,Ue]);j.useEffect(()=>{jn()},[jn]);const gn=j.useRef(je);gn.current=je,j.useEffect(()=>{const Oe=setInterval(()=>{$e(),st(),Ue()},je?6e4:15e3),Pe=En.on("task:update",et=>{gn.current||($e(),Ue());const re=et?.payload;re?.taskId&&ke(pe=>{if(!pe||pe.id!==re.taskId)return pe;const Ne={};return typeof re.status=="string"&&(Ne.status=re.status),Array.isArray(re.deliverables)&&(Ne.deliverables=re.deliverables),Array.isArray(re.notes)&&(Ne.notes=re.notes),re.result!==void 0&&(Ne.result=re.result),{...pe,...Ne}})});return()=>{clearInterval(Oe),Pe()}},[$e,st,Ue,je]);const Dt=j.useRef(m);Dt.current=m,j.useEffect(()=>{const ne=localStorage.getItem("markus_nav_openTask");if(!ne)return;const Pe=Object.values(m).flat().find(et=>et.id===ne);Pe&&(ke(Pe),localStorage.removeItem("markus_nav_openTask"))},[m]),j.useEffect(()=>{const ne=window.location.hash.slice(1).split("/");if(ne[0]==="projects"&&ne[1])Dn(ne[1]);else{const Oe=localStorage.getItem("markus_nav_projectId");Oe&&(localStorage.removeItem("markus_nav_projectId"),Dn(Oe))}},[]),j.useEffect(()=>{const ne=()=>{const Pe=window.location.hash.slice(1).split("/");Pe[0]==="projects"&&Pe[1]?Dn(Pe[1]):Pe[0]==="projects"&&Un()},Oe=Pe=>{const et=Pe.detail;if(et.page==="tasks"||et.page==="projects"){if(et.params?.openTask){const pe=Object.values(Dt.current).flat().find(Ne=>Ne.id===et.params.openTask);pe&&ke(pe)}et.params?.projectId&&Dn(et.params.projectId),!et.params?.projectId&&!et.params?.openTask&&Un()}};return window.addEventListener("markus:navigate",Oe),window.addEventListener("hashchange",ne),()=>{window.removeEventListener("markus:navigate",Oe),window.removeEventListener("hashchange",ne)}},[]);const Dn=ne=>{Lt.current.size>0&&(xt.current=new Set(Lt.current)),We(new Set),f(ne),c("project"),H(!1),history.replaceState(null,"","#projects/"+ne)},Un=()=>{We(xt.current),f(null),c("all"),H(!1),history.replaceState(null,"","#projects")},On=()=>{$(!1),Mt("Project created"),Le()},on=async ne=>{if(confirm("Delete this project and unlink all its tasks?"))try{await ae.projects.delete(ne),u===ne&&Un(),Mt("Project deleted"),Le(),$e()}catch(Oe){Mt(`Error: ${Oe}`)}},cn=async()=>{if(!q||!G||!K)return;if(G===K){Mt("Assigned agent and reviewer must be different");return}const ne=L||void 0,Oe=R||void 0;try{await ae.tasks.create(q,D,G,K,I,ne,V.length>0?V:void 0,Oe,te!=="standard"?te:void 0,te==="scheduled"?{every:ee}:void 0),F(""),_(""),Q([]),z(""),Z("standard"),ie("4h"),P(!1),$e()}catch(Pe){Mt(`Error creating task: ${Pe}`)}},wn=()=>{$e(),je&&setTimeout(()=>{const ne={};o==="project"&&u&&(ne.projectId=u),ae.tasks.board(ne).then(Oe=>{const et=Object.values(Oe.board).flat().find(re=>re.id===je.id);ke(et||null)}).catch(()=>{})},150)},qn=async()=>{if(_t.trim()){if(!ue){Mt("Please select a project for this requirement");return}try{await ae.requirements.create({title:_t,description:xe,priority:gt,projectId:ue}),Mt("Requirement created"),wt(""),Be(""),Ht(!1),Ue()}catch(ne){Mt(`Error: ${ne}`)}}},ve=async ne=>{try{await ae.requirements.approve(ne),Mt("Requirement approved"),Ue(),$e()}catch(Oe){Mt(`Error: ${Oe}`)}},Qe=async()=>{if(Ke)try{await ae.requirements.reject(Ke,rn),Mt("Requirement rejected"),At(null),vn(""),Ue()}catch(ne){Mt(`Error: ${ne}`)}},Nt=async ne=>{try{await ae.requirements.delete(ne),Mt("Requirement cancelled"),Ue()}catch(Oe){Mt(`Error: ${Oe}`)}},Et=(ne,Oe)=>{Xe.current=Oe,rt.current=null,ne.dataTransfer.effectAllowed="move",ne.dataTransfer.setData("text/plain",`task:${Oe.id}`),ne.currentTarget.style.opacity="0.4"},Nn=(ne,Oe)=>{rt.current=Oe,Xe.current=null,ne.dataTransfer.effectAllowed="move",ne.dataTransfer.setData("text/plain",`req:${Oe.id}`),ne.currentTarget.style.opacity="0.4"},ar=ne=>{ne.currentTarget.style.opacity="1",Xe.current=null,rt.current=null,_e(null)},ir=(ne,Oe)=>{ne.preventDefault(),ne.dataTransfer.dropEffect="move",le!==Oe&&_e(Oe)},Or=(ne,Oe)=>{const Pe=ne.currentTarget.getBoundingClientRect(),{clientX:et,clientY:re}=ne;(et<Pe.left||et>Pe.right||re<Pe.top||re>Pe.bottom)&&le===Oe&&_e(null)},Rr=async(ne,Oe)=>{ne.preventDefault(),_e(null);const Pe=Xe.current,et=rt.current;if(Pe){const re=To.find(Ne=>Ne.id===Oe);if(!re)return;const pe=re.dropStatus;if(Pe.status===pe||Pe.status==="pending_approval")return;try{await ae.tasks.updateStatus(Pe.id,pe),$e()}catch{}}else if(et){const re=cN[Oe];if(!re||et.status===re)return;try{await ae.requirements.updateStatus(et.id,re),Ue()}catch{}}},vr=ne=>{Ze(Oe=>{const Pe=new Set(Oe);return Pe.has(ne)?Pe.delete(ne):Pe.add(ne),Pe})},un=ne=>{We(Oe=>{const Pe=new Set(Oe);return Pe.has(ne)?Pe.delete(ne):Pe.add(ne),Pe})},zr=1440*60*1e3,Ps=Date.now(),lr=ne=>ne.status==="completed"&&ne.updatedAt&&Ps-new Date(ne.updatedAt).getTime()>zr,or=(ne,Oe=!1)=>{let Pe=ne.filter(et=>Ft||Oe||!lr(et));return o==="project"&&u&&(Pe=Pe.filter(et=>et.projectId===u)),Ae.size>0&&(Pe=Pe.filter(et=>et.projectId&&Ae.has(et.projectId))),ze.size>0&&(Pe=Pe.filter(et=>et.assignedAgentId&&ze.has(et.assignedAgentId))),Pe},Us=ne=>ne.statuses.flatMap(Oe=>or(m[Oe]??[])),Tn=j.useMemo(()=>{let ne=w;return o==="project"&&u&&(ne=ne.filter(Oe=>Oe.projectId===u)),Ae.size>0&&(ne=ne.filter(Oe=>Oe.projectId&&Ae.has(Oe.projectId))),ze.size>0&&(ne=ne.filter(Oe=>ze.has(Oe.createdBy))),ne},[w,o,u,Ae,ze]),Gr=j.useCallback(ne=>Tn.filter(Oe=>oN[Oe.status]===ne.id),[Tn]),Sa=To.filter(ne=>{if(ne.id==="failed"||ne.id==="closed"){const Oe=Us(ne),Pe=Gr(ne);return Oe.length+Pe.length>0}return!0}),cr=Object.values(m).flat().filter(ne=>lr(ne)).length,Lr=j.useMemo(()=>{const ne=new Set(["completed","failed","cancelled","archived"]),Oe=Object.values(m).flat(),Pe=new Set;for(const et of Oe)et.assignedAgentId&&!ne.has(et.status)&&(!u||et.projectId===u)&&Pe.add(et.assignedAgentId);return[...x].sort((et,re)=>{const pe=Pe.has(et.id)?0:1,Ne=Pe.has(re.id)?0:1;return pe-Ne})},[x,m,u]),Yn=j.useMemo(()=>{const ne=new Set(["completed","failed","cancelled","archived"]),Oe=Object.values(m).flat(),Pe=new Set;for(const et of Oe)et.projectId&&!ne.has(et.status)&&Pe.add(et.projectId);return[...s].sort((et,re)=>{const pe=Pe.has(et.id)?0:1,Ne=Pe.has(re.id)?0:1;return pe-Ne})},[s,m]),kn=j.useMemo(()=>{const ne={};for(const Oe of Object.values(m))for(const Pe of Oe){const et=Pe.projectId??"__none__";ne[et]=(ne[et]??0)+1}return ne},[m]),jr=Object.values(kn).reduce((ne,Oe)=>ne+Oe,0);return T?t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"}):t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[C&&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:C}),r?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:[oe?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:oe.name}),t.jsx("button",{onClick:()=>H(!k),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors shrink-0 ${k?"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:s.length===1?s[0].name:`${s.length} Projects`}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx("button",{onClick:()=>$(!0),className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Project"}),t.jsx("button",{onClick:M,className:"px-2 py-1 text-[11px] bg-brand-600 text-white rounded-md",children:"+ Req"}),t.jsx("button",{onClick:()=>{W(u??""),P(!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(ne=>t.jsx("button",{onClick:()=>Ct(ne),className:`px-2 py-0.5 text-[10px] font-medium transition-colors ${ht===ne?"bg-brand-600/25 text-brand-500":"text-fg-tertiary"}`,children:ne==="backlog"?"Backlog":ne==="kanban"?"Kanban":"DAG"},ne))}),cr>0&&t.jsx("button",{onClick:()=>be(ne=>!ne),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Ft?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary"}`,children:Ft?"Hide archived":`${cr} archived`}),t.jsx("div",{className:"flex-1"}),(Ae.size>0||ze.size>0||s.length>1||x.length>0)&&t.jsxs("button",{onClick:()=>Ve(!0),className:`px-2 py-1 text-[11px] rounded-md font-medium transition-colors flex items-center gap-1 ${Ae.size>0||ze.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",Ae.size+ze.size>0?` (${Ae.size+ze.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:[oe?t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Xz,{value:oe.name,onSave:async ne=>{await ae.projects.update(oe.id,{name:ne}),Le()},className:"text-sm font-semibold text-fg-primary"}),t.jsx("button",{onClick:()=>H(!k),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors ${k?"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:s.length===1?s[0].name:`${s.length} Projects`}),cr>0&&t.jsx("button",{onClick:()=>be(ne=>!ne),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Ft?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary hover:text-fg-secondary"}`,children:Ft?`Hide ${cr} archived`:`${cr} archived`}),t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(ne=>t.jsx("button",{onClick:()=>Ct(ne),className:`px-2.5 py-1 text-[10px] font-medium transition-colors ${ht===ne?"bg-brand-600/25 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:ne==="backlog"?"Backlog":ne==="kanban"?"Kanban":"DAG"},ne))}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("button",{onClick:M,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:()=>{W(u??""),P(!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"})]}),!r&&s.length>1&&!u&&!k&&(jr>0||w.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:()=>We(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 ${Ae.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),Yn.map(ne=>{const Oe=Ae.has(ne.id),Pe=kn[ne.id]??0;return t.jsxs("button",{onClick:()=>un(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${Oe?"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 ${Oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:ne.name[0]?.toUpperCase()}),ne.name,Pe>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary ml-0.5",children:Pe})]},ne.id)})]}),!r&&x.length>0&&!k&&(jr>0||w.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:()=>Ze(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 ${ze.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),Lr.map(ne=>{const Oe=ze.has(ne.id);return t.jsxs("button",{onClick:()=>vr(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${Oe?"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 ${Oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:ne.name[0]?.toUpperCase()}),ne.name]},ne.id)})]}),k&&oe?t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(iL,{project:oe,tasks:Object.values(m).flat(),requirements:w,agents:x,onDeleteProject:()=>on(oe.id),onUpdateProject:async ne=>{await ae.projects.update(oe.id,ne)},onRefresh:()=>{Le()}})}):jr===0&&Tn.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:M,className:"text-xs text-brand-500 hover:text-brand-500 font-medium",children:"+ Create a requirement"})]})}):ht==="backlog"?t.jsx(fL,{tasks:or(Object.values(m).flat()),requirements:Tn,agents:x,projects:s,onTaskClick:ne=>ke(ne),onReqClick:ne=>Ie(ne),onRefresh:()=>{$e(),Ue()}}):ht==="dag"?t.jsx(Gz,{tasks:or(Object.values(m).flat(),!0),requirements:Tn,agents:x,showArchived:Ft,onShowArchivedChange:be,onTaskClick:ne=>ke(ne),onReqClick:ne=>Ie(ne),onDependencyChange:$e}):t.jsx("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden p-6",children:t.jsx("div",{className:"flex gap-4 h-full",children:Sa.map(ne=>{const Oe=Us(ne),Pe=Gr(ne),et=Oe.length+Pe.length,re=le===ne.id;return t.jsxs("div",{className:`w-72 shrink-0 rounded-xl p-3.5 border-t-2 transition-colors flex flex-col h-full ${ne.accent} ${re?"bg-surface-elevated/80 ring-1 ring-brand-500/40":"bg-surface-secondary"}`,onDragOver:pe=>ir(pe,ne.id),onDragLeave:pe=>Or(pe,ne.id),onDrop:pe=>{Rr(pe,ne.id)},children:[t.jsxs("div",{className:"flex justify-between items-center mb-3 shrink-0",children:[t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:ne.label}),t.jsx("span",{className:"text-xs bg-surface-elevated px-2 py-0.5 rounded-full",children:et})]}),t.jsx("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto scrollbar-thin",children:(()=>{const pe=[...Pe.map(Ne=>({kind:"req",data:Ne,time:new Date(Ne.updatedAt??Ne.createdAt).getTime()})),...Oe.map(Ne=>({kind:"task",data:Ne,time:new Date(Ne.updatedAt??Ne.createdAt??0).getTime()}))];return pe.sort((Ne,ye)=>ye.time-Ne.time),pe.map(Ne=>{if(Ne.kind==="req"){const ye=Ne.data,dt=$u[ye.status]??{label:ye.status,cls:"bg-gray-500/15 text-fg-secondary"},Fe=ye.source==="agent"&&(ye.status==="draft"||ye.status==="pending_review"),bt=o==="all"&&ye.projectId?s.find(tt=>tt.id===ye.projectId):null,it=el(ye.createdBy,x,b)??ye.createdBy.slice(0,10);return t.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:tt=>Nn(tt,ye),onDragEnd:ar,onClick:()=>Ie(ye),onKeyDown:tt=>tt.key==="Enter"&&Ie(ye),className:`bg-brand-500/[0.06] border rounded-lg p-3 border-l-[3px] border-l-purple-500 transition-colors cursor-grab active:cursor-grabbing ${Fe?"border-amber-500/40 ring-1 ring-amber-500/20":"border-brand-500/20"} hover:border-brand-400/50`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx("span",{className:"text-[9px] font-bold text-brand-500 bg-brand-500/15 px-1.5 py-0.5 rounded shrink-0",children:"REQ"}),t.jsx("span",{className:"text-sm font-medium leading-snug truncate",children:ye.title})]}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${dt.cls}`,children:dt.label})]}),ye.description&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-1 line-clamp-2",children:ye.description}),bt&&t.jsx("div",{className:"mt-1.5",children:t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded truncate max-w-[120px]",title:bt.name,children:bt.name})}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-xs text-fg-tertiary",children:ye.priority}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",it]})]}),t.jsx("div",{className:"flex items-center gap-1.5",children:ye.taskIds.length>0&&t.jsxs("span",{className:"text-[10px] text-brand-500/60 bg-brand-500/10 px-1.5 py-0.5 rounded",children:[ye.taskIds.length," tasks"]})})]}),Fe&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-brand-500/10",children:[t.jsx("button",{onClick:tt=>{tt.stopPropagation(),ve(ye.id)},className:"px-2.5 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:tt=>{tt.stopPropagation(),At(ye.id)},className:"px-2.5 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-${ye.id}`)}else{const ye=Ne.data,dt=ye.subtasks?.length??0,He=iN[ye.status],Fe=ye.status==="pending_approval",bt=ye.taskType==="scheduled"&&!!ye.scheduleConfig,it=bt?ye.scheduleConfig.every?`Every ${ye.scheduleConfig.every}`:ye.scheduleConfig.cron?"Cron":"Scheduled":null,tt=o==="all"&&ye.projectId?s.find(hn=>hn.id===ye.projectId)?.name:null,Xt=ye.requirementId?w.find(hn=>hn.id===ye.requirementId)?.title:null,Zt=ye.createdBy?el(ye.createdBy,x,b)??ye.createdBy:null;return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":ye.title,draggable:!Fe,onDragStart:hn=>!Fe&&Et(hn,ye),onDragEnd:ar,onClick:()=>ke(ye),onKeyDown:hn=>hn.key==="Enter"&&ke(ye),className:`border rounded-lg p-3 border-l-[3px] transition-colors ${Fe?"bg-amber-500/[0.04] border-amber-500/30 border-l-amber-500 cursor-pointer":bt?`bg-blue-500/[0.03] border-blue-500/20 ${_m[ye.priority]??""} hover:border-blue-500/40 cursor-pointer`:`bg-surface-elevated border-border-default ${_m[ye.priority]??""} hover:border-brand-500/50 cursor-grab active:cursor-grabbing`}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[bt&&t.jsx("span",{className:"text-blue-600 shrink-0",title:it??"Scheduled",children: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("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"})})}),t.jsx("div",{className:"text-sm font-medium leading-snug truncate",children:ye.title})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[bt&&it&&t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-600 whitespace-nowrap",children:it}),He&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${He.cls}`,children:He.label})]})]}),ye.description&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-1 line-clamp-2",children:ye.description}),(tt||Xt)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[tt&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded truncate max-w-[100px]",title:tt,children:tt}),Xt&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/10 text-brand-500 rounded truncate max-w-[120px]",title:Xt,children:["# ",Xt]})]}),ye.blockedBy&&ye.blockedBy.length>0&&t.jsx("div",{className:"mt-1.5 flex items-center gap-1",children:t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/10 text-amber-600 rounded",children:["⏳ ",ye.blockedBy.length," dep",ye.blockedBy.length>1?"s":""]})}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-xs text-fg-tertiary",children:ye.priority}),Zt&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",title:`Created by ${Zt}`,children:["by ",Zt]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[dt>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary bg-surface-overlay/50 px-1.5 py-0.5 rounded",children:["⋮ ",dt]}),ye.notes&&ye.notes.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["📝 ",ye.notes.length]}),ye.assignedAgentId&&t.jsxs("span",{className:"text-[10px] text-brand-500 bg-brand-500/10 px-1.5 py-0.5 rounded flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${lN[x.find(hn=>hn.id===ye.assignedAgentId)?.status??""]??"bg-gray-500"}`}),x.find(hn=>hn.id===ye.assignedAgentId)?.name??ye.assignedAgentId.slice(0,8)]})]})]})]},ye.id)}})})()}),re&&t.jsx("div",{className:"mt-2 border-2 border-dashed border-brand-500/30 rounded-lg h-12 flex items-center justify-center shrink-0",children:t.jsx("span",{className:"text-xs text-brand-500/60",children:"Drop here"})})]},ne.id)})})})]}),Y&&t.jsx(aN,{orgId:e?.orgId,onCreated:On,onClose:()=>$(!1)}),X&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>P(!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 ${r?"w-full":"w-[28rem]"}`,onClick:ne=>ne.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:L,onChange:ne=>W(ne.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"}),s.map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Requirement"}),t.jsxs("select",{value:R,onChange:ne=>z(ne.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…"}),w.filter(ne=>ne.status==="approved"&&(!L||ne.projectId===L)).map(ne=>t.jsx("option",{value:ne.id,children:ne.title},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{autoFocus:!r,value:q,onChange:ne=>F(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&cn()},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:D,onChange:ne=>_(ne.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:I,onChange:ne=>A(ne.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:G,onChange:ne=>U(ne.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…"}),x.map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.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:K,onChange:ne=>B(ne.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…"}),x.filter(ne=>ne.id!==G).map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.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:te,onChange:ne=>Z(ne.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)"})]})]}),te==="scheduled"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Frequency"}),t.jsxs("select",{value:ee,onChange:ne=>ie(ne.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:ne=>{const Oe=ne.target.value;Oe&&!V.includes(Oe)&&Q([...V,Oe])},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(m).flat().filter(ne=>ne.status!=="completed"&&ne.status!=="cancelled"&&!V.includes(ne.id)).map(ne=>t.jsx("option",{value:ne.id,children:ne.title},ne.id))]}),V.length>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:V.map(ne=>{const Oe=Object.values(m).flat().find(Pe=>Pe.id===ne);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:["⏳ ",Oe?Oe.title.slice(0,30):ne.slice(-8),t.jsx("button",{onClick:()=>Q(V.filter(Pe=>Pe!==ne)),className:"ml-0.5 text-amber-600/60 hover:text-amber-600",children:"×"})]},ne)})})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>P(!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:()=>{cn()},disabled:!G||!K,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Create"})]})]})}),je&&t.jsx(aL,{task:je,agents:x,projects:s,requirements:w,allTasks:Object.values(m).flat(),users:b,onClose:()=>ke(null),onRefresh:wn,authUser:e}),It&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>{Ht(!1),wt(""),Be("")},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 ${r?"w-full":"w-[28rem]"}`,onClick:ne=>ne.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:ue,onChange:ne=>Se(ne.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…"}),s.map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{value:_t,onChange:ne=>wt(ne.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:!r,onKeyDown:ne=>{ne.key==="Enter"&&_t.trim()&&qn()}})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:xe,onChange:ne=>Be(ne.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:gt,onChange:ne=>pt(ne.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:()=>{Ht(!1),wt(""),Be("")},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:()=>{qn()},className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Create"})]})]})}),Ke&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>At(null),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 ${r?"w-full":"w-96"}`,onClick:ne=>ne.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:rn,onChange:ne=>vn(ne.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:!r})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>At(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:()=>{Qe()},className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 rounded-lg text-white",children:"Reject"})]})]})}),De&&t.jsx(hL,{req:De,agents:x,projects:s,allTasks:Object.values(m).flat(),users:b,onClose:()=>Ie(null),onApprove:ne=>{ve(ne),Ie(null)},onReject:ne=>{At(ne),Ie(null)},onCancel:ne=>{Nt(ne),Ie(null)},onStatusChange:async(ne,Oe)=>{try{await ae.requirements.updateStatus(ne,Oe),Mt(`Requirement status → ${Oe}`),Ue(),$e()}catch(Pe){Mt(`Error: ${Pe}`)}}}),Me&&t.jsxs("div",{className:"fixed inset-0 z-[60] flex flex-col justify-end",onClick:()=>Ve(!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:ne=>ne.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:[(Ae.size>0||ze.size>0)&&t.jsx("button",{onClick:()=>{We(new Set),Ze(new Set)},className:"text-[11px] text-brand-500 font-medium",children:"Clear all"}),t.jsx("button",{onClick:()=>Ve(!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"})]})})]})]}),s.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:Yn.map(ne=>{const Oe=Ae.has(ne.id),Pe=kn[ne.id]??0;return t.jsxs("button",{onClick:()=>un(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${Oe?"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 ${Oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:ne.name[0]?.toUpperCase()}),ne.name,Pe>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary",children:Pe})]},ne.id)})})]}),x.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:Lr.map(ne=>{const Oe=ze.has(ne.id);return t.jsxs("button",{onClick:()=>vr(ne.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${Oe?"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 ${Oe?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:ne.name[0]?.toUpperCase()}),ne.name]},ne.id)})})]}),t.jsx("div",{className:"h-[env(safe-area-inset-bottom,0px)]"})]})]})]})}function hL({req:e,agents:r,projects:s,allTasks:i,users:o,onClose:c,onApprove:u,onReject:f,onCancel:m,onStatusChange:h}){const x=gs(),g=$u[e.status]??{label:e.status,cls:"bg-gray-500/15 text-fg-secondary"},b=e.source==="agent",p=b&&(e.status==="draft"||e.status==="pending_review"),w=e.status==="draft"||e.status==="approved",S=e.status==="completed"||e.status==="rejected"||e.status==="cancelled",T=e.projectId?s.find(N=>N.id===e.projectId):null,E=el(e.createdBy,r,o)??e.createdBy.slice(0,12),C=i.filter(N=>e.taskIds.includes(N.id));return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:c,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl max-h-[85dvh] flex flex-col ${x?"w-full":"w-[36rem]"}`,onClick:N=>N.stopPropagation(),children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 p-5 pb-0",children:[t.jsxs("div",{className:"flex-1 min-w-0",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 ${g.cls}`,children:g.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})]}),t.jsx("button",{onClick:c,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:[e.description&&t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1 block",children:"Description"}),t.jsx(er,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})]}),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:E}),b&&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()})]}),T&&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:T.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:el(e.approvedBy,r,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})]}),e.tags&&e.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(N=>t.jsxs("span",{className:"text-[10px] bg-surface-elevated text-fg-secondary px-2 py-0.5 rounded-full",children:["#",N]},N))}),C.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 (",C.length,")"]}),t.jsx("div",{className:"space-y-1.5",children:C.map(N=>{const k=iN[N.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 ${_m[N.priority]?.replace("border-l-","bg-")??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:N.title}),k&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${k.cls}`,children:k.label})]},N.id)})})]})]}),t.jsxs("div",{className:"flex items-center gap-2 p-5 pt-3 border-t border-border-default",children:[p&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>u(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:()=>f(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"})]}),!p&&h&&!S&&t.jsx("select",{value:e.status,onChange:N=>{N.target.value!==e.status&&h(e.id,N.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:uN.map(N=>{const k=$u[N];return t.jsx("option",{value:N,children:k?.label??N},N)})}),S&&h&&t.jsx("button",{onClick:()=>h(e.id,"approved"),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"}),w&&!p&&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 mL({status:e}){const r={active:"bg-green-500/10 text-green-600",planning:"bg-blue-500/10 text-blue-600",review:"bg-amber-500/10 text-amber-600",completed:"bg-surface-overlay text-fg-secondary",archived:"bg-surface-elevated text-fg-tertiary",paused:"bg-amber-500/10 text-amber-600"};return t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${r[e]??"bg-surface-overlay text-fg-secondary"}`,children:e})}function os(e){return Array.isArray(e)?e.map(r=>String(r).trim()).filter(Boolean):typeof e=="string"&&e?e.split(",").map(r=>r.trim()).filter(Boolean):[]}function xL(e){return e.files&&typeof e.files=="object"&&!Array.isArray(e.files)?e.files:null}function Fa({label:e,value:r}){return r?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:r})]}):null}function Li({label:e,value:r,color:s}){if(!r)return null;const i={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 ${i[s]??i.gray} capitalize inline-block`,children:r})]})}function Gh({files:e}){const[r,s]=j.useState(Object.keys(e)[0]??""),i=Object.keys(e);return i.length===0?null:t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Files (",i.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:i.map(o=>t.jsx("button",{onClick:()=>s(o),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${r===o?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o},o))}),r&&e[r]!=null&&t.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:e[r]})]})]})}function gL({artifact:e,mode:r}){const s=xL(e),i=e.agent,o=e.team,c=e.dependencies,u=e.displayName??e.name;if(r==="agent"){const f=i?.roleName,m=i?.agentRole,h=i?.llmProvider,x=i?.llmModel,g=os(c?.env),b=os(c?.skills);return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Fa,{label:"Name",value:u}),t.jsx(Fa,{label:"Description",value:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Li,{label:"Role Template",value:f,color:"indigo"}),t.jsx(Li,{label:"Agent Role",value:m,color:m==="manager"?"purple":"cyan"})]}),os(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:os(e.tags).map(p=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:p},p))}),(h||x)&&t.jsxs("div",{className:"flex gap-2",children:[h&&t.jsx(Li,{label:"LLM Provider",value:h,color:"gray"}),x&&t.jsx(Li,{label:"LLM Model",value:x,color:"gray"})]}),g.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:g.map(p=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:p},p))})]}),b.length>0&&t.jsx(Fa,{label:"Skills",value:b.join(", ")}),s&&t.jsx(Gh,{files:s})]})}if(r==="team"){const m=o?.members??[];return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Fa,{label:"Name",value:u}),t.jsx(Fa,{label:"Description",value:e.description}),t.jsx("div",{className:"flex flex-wrap gap-2",children:t.jsx(Li,{label:"Category",value:e.category,color:"indigo"})}),os(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:os(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))}),s&&t.jsx(Gh,{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((h,x)=>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 ${h.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:h.role==="manager"?"★":x+1}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:h.name}),typeof h.roleName=="string"&&h.roleName&&t.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:h.roleName}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(h.count??1)]})]}),os(h.skills).length>0&&t.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:os(h.skills).map(g=>t.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:g},g))})]},x))})]})]})}return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Fa,{label:"Name",value:u}),t.jsx(Fa,{label:"Description",value:e.description}),t.jsx("div",{className:"flex gap-2",children:t.jsx(Li,{label:"Category",value:e.category,color:"indigo"})}),s&&t.jsx(Gh,{files:s}),os(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:os(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))})]})}const to={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},zv={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"}},Lv=["file","directory"],cs={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 Iv(){const e=gs(),r=ex({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[s,i]=j.useState(!1),o=j.useRef(s);o.current=s,j.useEffect(()=>{if(!e)return;const ve=()=>{o.current&&i(!1)};return window.addEventListener("popstate",ve),()=>window.removeEventListener("popstate",ve)},[e]);const c=100,[u,f]=j.useState([]),[m,h]=j.useState(0),[x,g]=j.useState(!1),[b,p]=j.useState([]),[w,S]=j.useState([]),[T,E]=j.useState(!0),[C,N]=j.useState(""),[k,H]=j.useState(""),[M,Y]=j.useState(""),[$,X]=j.useState(""),[P,q]=j.useState(""),[F,D]=j.useState(""),[_,I]=j.useState(""),[A,G]=j.useState("date"),[U,K]=j.useState(null),[B,L]=j.useState(null),[W,R]=j.useState(""),[z,V]=j.useState(!1),[Q,te]=j.useState(!1),[Z,ee]=j.useState(new Set),ie=j.useRef(null),[je,ke]=j.useState("file"),[De,Ie]=j.useState(""),[ze,Ze]=j.useState(""),[Ae,We]=j.useState(""),[xt,Lt]=j.useState(""),[le,_e]=j.useState(""),[ht,Ct]=j.useState(null),[Ft,be]=j.useState(null),[Me,Ve]=j.useState(!1),[Xe,rt]=j.useState(!1),[It,Ht]=j.useState(!1),[_t,wt]=j.useState(!1),xe=j.useRef(null),Be=j.useRef(null),[gt,pt]=j.useState(""),ue=j.useRef(void 0),Se=(ve,Qe)=>{L({type:ve,text:Qe}),setTimeout(()=>L(null),3e3)},Ke=async ve=>{try{return await navigator.clipboard.writeText(ve),!0}catch{try{const Qe=document.createElement("textarea");Qe.value=ve,Qe.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(Qe),Qe.select();const Nt=document.execCommand("copy");return document.body.removeChild(Qe),Nt}catch{return!1}}},At=async ve=>{await Ke(ve)?(wt(!0),setTimeout(()=>wt(!1),1500)):Se("error","Copy failed — try long-pressing to copy manually")},rn=j.useMemo(()=>new Map(w.map(ve=>[ve.id,ve])),[w]),vn=j.useMemo(()=>new Map(b.map(ve=>[ve.id,ve])),[b]);j.useEffect(()=>{ae.projects.list().then(ve=>p(ve.projects)).catch(()=>{}),ae.agents.list().then(ve=>S(ve.agents??[])).catch(()=>{}),ae.system.storage().then(ve=>pt(ve.dataDir+"/shared")).catch(()=>{})},[]),j.useEffect(()=>(ue.current=setTimeout(()=>H(C),300),()=>clearTimeout(ue.current)),[C]);const Mt=j.useMemo(()=>({q:k||void 0,projectId:$||void 0,agentId:P||void 0,type:M||void 0,status:F||void 0,artifactType:_||void 0}),[k,$,P,M,F,_]),oe=j.useCallback(async()=>{E(!0);try{const{results:ve,total:Qe}=await ae.deliverables.search({...Mt,offset:0,limit:c});f(ve),h(Qe)}catch{f([]),h(0)}E(!1)},[Mt]),Le=j.useCallback(async()=>{if(!(x||u.length>=m)){g(!0);try{const{results:ve,total:Qe}=await ae.deliverables.search({...Mt,offset:u.length,limit:c});f(Nt=>[...Nt,...ve]),h(Qe)}catch{}g(!1)}},[Mt,u.length,m,x]);j.useEffect(()=>{oe()},[oe]),j.useEffect(()=>En.on("deliverable:created",()=>oe()),[oe]);const $e=j.useCallback(()=>{const ve=ie.current;!ve||T||x||u.length>=m||ve.scrollHeight<=ve.clientHeight+100&&Le()},[T,x,u.length,m,Le]);j.useEffect(()=>{const ve=ie.current;if(!ve)return;const Qe=()=>{ve.scrollTop+ve.clientHeight>=ve.scrollHeight-100&&Le()};return ve.addEventListener("scroll",Qe,{passive:!0}),()=>ve.removeEventListener("scroll",Qe)},[Le]),j.useEffect(()=>{$e()},[$e,Z]);const st=j.useMemo(()=>{const ve=new Map;for(const Nt of u){let Et,Nn;if(A==="project")Et=Nt.projectId??"_none",Nn=Nt.projectId?vn.get(Nt.projectId)?.name??Nt.projectId:"No Project";else if(A==="agent")Et=Nt.agentId??"_none",Nn=Nt.agentId?rn.get(Nt.agentId)?.name??Nt.agentId:"Unknown";else if(A==="type")Et=Nt.type,Nn=Nt.type.charAt(0).toUpperCase()+Nt.type.slice(1);else{const ar=new Date(Nt.updatedAt);Et=`${ar.getFullYear()}-${String(ar.getMonth()+1).padStart(2,"0")}-${String(ar.getDate()).padStart(2,"0")}`,Nn=Et}ve.has(Et)||ve.set(Et,{label:Nn,items:[]}),ve.get(Et).items.push(Nt)}const Qe=[...ve.entries()];return A==="date"?Qe.sort((Nt,Et)=>Et[0].localeCompare(Nt[0])):Qe.sort((Nt,Et)=>Nt[1].label.localeCompare(Et[1].label)),Qe},[u,A,vn,rn]),at=async()=>{if(!(!De.trim()||!ze.trim())){te(!0);try{await ae.deliverables.create({type:je,title:De,summary:ze,reference:Ae,projectId:xt||void 0,tags:le.split(",").map(ve=>ve.trim()).filter(Boolean)}),V(!1),Se("success","Deliverable created"),oe()}catch(ve){Se("error",`Error: ${ve}`)}te(!1)}},Ue=async ve=>{R("verify");try{await ae.deliverables.verify(ve.id),Se("success","Verified"),K({...ve,status:"verified"}),oe()}catch(Qe){Se("error",`Error: ${Qe}`)}R("")},jn=async ve=>{R("flag");try{await ae.deliverables.update(ve.id,{status:"outdated"}),Se("success","Flagged as outdated"),K({...ve,status:"outdated"}),oe()}catch(Qe){Se("error",`Error: ${Qe}`)}R("")},gn=async ve=>{R("remove");try{await ae.deliverables.remove(ve.id),Se("success","Removed"),K(null),oe()}catch(Qe){Se("error",`Error: ${Qe}`)}R("")},Dt=()=>{Ut.navigate("builder")},Dn=async ve=>{if(ve.reference){if(ve.type==="directory"){rt(!0);return}Ve(!0);try{const Qe=await ae.files.preview(ve.reference);Qe.type==="image"&&Qe.mimeType?be({src:`data:${Qe.mimeType};base64,${Qe.content}`,name:Qe.name}):Ct(Qe.content)}catch{Ct(null),ve.type==="file"&&rt(!0)}Ve(!1)}};j.useEffect(()=>{Ct(null),be(null),rt(!1),Ht(!1),U&&Dn(U)},[U?.id]),j.useEffect(()=>{if(!It)return;const ve=Qe=>{Be.current&&!Be.current.contains(Qe.target)&&Ht(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[It]);const Un=async(ve,Qe)=>{const Nt=xe.current?.firstElementChild;if(!Nt)return;const Et=pL(Nt,ve);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([Et],{type:"text/html"}),"text/plain":new Blob([Qe],{type:"text/plain"})})]),Se("success",ve==="light"?"HTML (light) copied":"HTML (dark) copied")}catch{const Nn=await Ke(Qe);Se(Nn?"success":"error",Nn?"Text copied (HTML not supported)":"Copy failed")}Ht(!1)},On=ve=>t.jsxs("div",{className:"relative group/preview",children:[t.jsxs("div",{className:"absolute -top-1 -right-1 z-10",ref:Be,children:[t.jsx("button",{onClick:()=>Ht(Qe=>!Qe),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"})})}),It&&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 Qe=await Ke(ve);Se(Qe?"success":"error",Qe?"Markdown source copied":"Copy failed"),Ht(!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:()=>Un("light",ve),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:()=>Un("dark",ve),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:xe,children:t.jsx(er,{content:ve,className:"text-fg-secondary text-sm"})})]}),on=j.useCallback(ve=>{ee(Qe=>{const Nt=new Set(Qe);return Nt.has(ve)?Nt.delete(ve):Nt.add(ve),Nt})},[]),cn=j.useCallback(()=>{Z.size===st.length?ee(new Set):ee(new Set(st.map(([ve])=>ve)))},[Z.size,st]),wn=()=>{Ie(""),Ze(""),We(""),_e(""),ke("file"),b.length>0&&Lt(b[0].id),V(!0)},qn=ve=>{K(ve),e&&(i(!0),history.pushState({mobileDetail:"deliverables"},"",window.location.hash))};return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[(!e||!s)&&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?void 0:{width:r.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:wn,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:C,onChange:ve=>N(ve.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"}),gt&&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:gt}),t.jsx("button",{onClick:()=>{ae.system.openPath(gt)},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(ba,{label:"All types",value:"",current:M||_||"",onClick:()=>{Y(""),I("")}}),Lv.map(ve=>t.jsx(ba,{label:`${to[ve]?.icon??""} ${ve}`,value:ve,current:M,onClick:Qe=>{Y(Qe),I("")}},ve)),["agent","team","skill"].map(ve=>t.jsx(ba,{label:`${cs[ve].icon} ${cs[ve].label}`,value:ve,current:_,onClick:Qe=>{I(Qe),Y("")}},ve))]}),b.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(ba,{label:"All projects",value:"",current:$,onClick:X}),b.map(ve=>t.jsx(ba,{label:ve.name,value:ve.id,current:$,onClick:X},ve.id))]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(ba,{label:"Active",value:"",current:F,onClick:D}),t.jsx(ba,{label:"Verified",value:"verified",current:F,onClick:D}),t.jsx(ba,{label:"Outdated",value:"outdated",current:F,onClick:D})]}),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(ve=>t.jsx("button",{onClick:()=>{G(ve),ee(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${A===ve?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:ve.charAt(0).toUpperCase()+ve.slice(1)},ve)),st.length>1&&t.jsx("button",{onClick:cn,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:Z.size===st.length?"Expand all":"Collapse all",children:Z.size===st.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:ie,className:"flex-1 overflow-y-auto p-2 space-y-1",children:[T?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(ve=>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"})]},ve))}):u.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:wn,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create first"})]}):st.map(([ve,Qe])=>{const Nt=Z.has(ve);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>on(ve),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 ${Nt?"":"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:Qe.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",Qe.items.length,")"]})]}),!Nt&&Qe.items.map(Et=>t.jsxs("button",{onClick:()=>qn(Et),className:`w-full text-left p-3 rounded-lg transition-colors ${U?.id===Et.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:Et.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[Et.artifactType&&cs[Et.artifactType]?t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${cs[Et.artifactType].color}`,children:[cs[Et.artifactType].icon," ",cs[Et.artifactType].label]}):t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium uppercase ${to[Et.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:Et.type}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${zv[Et.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:Et.status}),Et.agentId&&t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:rn.get(Et.agentId)?.name??"Agent"})]})]},Et.id))]},ve)}),x&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(Xh,{})," ",t.jsx("span",{className:"text-[10px]",children:"Loading more..."})]}),!T&&u.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:u.length<m?`${u.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:r.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:U?.title??"Details"})]}),U?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:U.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[U.status!=="verified"&&t.jsx("button",{onClick:()=>Ue(U),disabled:!!W,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:W==="verify"?"Verifying...":"Verify"}),U.status!=="outdated"&&t.jsx("button",{onClick:()=>jn(U),disabled:!!W,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:W==="flag"?"Flagging...":"Flag Outdated"}),t.jsx("button",{onClick:()=>gn(U),disabled:!!W,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:W==="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 ${to[U.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[to[U.type]?.icon??""," ",U.type]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${zv[U.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:U.status}),U.artifactType&&cs[U.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${cs[U.artifactType].color}`,children:[cs[U.artifactType].icon," Builder ",cs[U.artifactType].label]})]}),U.reference&&(U.type==="file"||U.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:()=>{ae.files.reveal(U.reference).catch(()=>Se("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:U.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(U.reference).catch(()=>Se("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:()=>At(U.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${_t?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:"Copy path to clipboard",children:_t?"Copied!":"Copy"})]}),U.reference&&U.type!=="file"&&U.type!=="directory"&&t.jsx("div",{className:"mt-2",children:t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:U.reference})})]}),U.artifactType&&U.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(gL,{artifact:U.artifactData,mode:U.artifactType})}),U.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:U.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:Dt,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"})}),U.summary&&t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(er,{content:U.summary,className:"text-fg-secondary text-sm"})})]}):t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:Me?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(Xh,{})," Loading preview..."]}):Ft?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Ft.src,alt:Ft.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Ft.name})]}):ht?On(ht):Xe?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-fg-secondary",children:["This ",U.type," cannot be previewed in the browser."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(U.reference).catch(()=>Se("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:U.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(U.reference).catch(()=>Se("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:()=>At(U.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${_t?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:_t?"Copied!":"Copy"})]})]}):U.summary?On(U.summary):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No content"})}),(U.diffStats||U.testResults)&&t.jsxs("div",{className:"flex gap-4 flex-wrap",children:[U.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:[U.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-600",children:["+",U.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",U.diffStats.deletions]})]})]}),U.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:[U.testResults.passed," passed"]}),t.jsxs("span",{className:"text-red-500",children:[U.testResults.failed," failed"]}),t.jsxs("span",{className:"text-fg-secondary",children:[U.testResults.skipped," skipped"]})]})]})]}),U.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.tags.map(ve=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:ve},ve))}),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:[U.taskId&&t.jsxs("button",{onClick:()=>Ut.navigate("projects",{openTask:U.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2.5 py-1 rounded",children:["Task: ",U.taskId.slice(0,12),"..."]}),U.agentId&&t.jsxs("button",{onClick:()=>Ut.navigate("team",{selectAgent:U.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Agent: ",rn.get(U.agentId)?.name??U.agentId.slice(0,12)]}),U.projectId&&t.jsxs("button",{onClick:()=>Ut.navigate("projects",{projectId:U.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Project: ",vn.get(U.projectId)?.name??U.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(U.createdAt).toLocaleString()})]}),t.jsxs("span",{children:["Updated: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(U.updatedAt).toLocaleString()})]}),t.jsxs("span",{children:["Accessed: ",t.jsxs("span",{className:"text-fg-secondary",children:[U.accessCount,"x"]})]})]}),t.jsxs("div",{className:"text-fg-muted select-all",children:["ID: ",U.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"})]})})]}),z&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!Q&&V(!1),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[36rem] space-y-4",onClick:ve=>ve.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:je,onChange:ve=>ke(ve.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:Lv.map(ve=>t.jsxs("option",{value:ve,children:[to[ve]?.icon??""," ",ve]},ve))})]}),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:De,onChange:ve=>Ie(ve.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:Ae,onChange:ve=>We(ve.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:ze,onChange:ve=>Ze(ve.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:le,onChange:ve=>_e(ve.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:xt,onChange:ve=>Lt(ve.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"}),b.map(ve=>t.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1 border-t border-border-default",children:[t.jsx("button",{onClick:()=>V(!1),disabled:Q,className:"text-sm text-fg-tertiary hover:text-fg-secondary disabled:opacity-50 transition-colors py-2",children:"Cancel"}),t.jsxs("button",{onClick:at,disabled:Q||!De.trim()||!ze.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:[Q&&t.jsx(Xh,{}),Q?"Creating...":"Create"]})]})]})})]})}function pL(e,r){const s=e.cloneNode(!0),i=r==="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:${i.text};line-height:1.7;`,h1:`font-size:1.6em;font-weight:700;color:${i.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${i.border};padding-bottom:6px;`,h2:`font-size:1.35em;font-weight:700;color:${i.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:1.15em;font-weight:600;color:${i.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:1em;font-weight:600;color:${i.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${i.strong};`,em:"font-style:italic;",a:`color:${i.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:${i.text};`,blockquote:`border-left:3px solid ${i.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${i.blockquoteText};`,hr:`border:none;border-top:1px solid ${i.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${i.tableHeaderBg};`,th:`border:1px solid ${i.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${i.tableHeaderText};`,td:`border:1px solid ${i.tableBorder};padding:8px 12px;color:${i.text};`,img:"max-width:100%;height:auto;"};function c(u){u.removeAttribute("class");const f=u.tagName.toLowerCase();if(f==="pre"){u.setAttribute("style",`background:${i.preBg};color:${i.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${i.preBorder};`);const m=u.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}f==="code"?u.setAttribute("style",`background:${i.codeBg};color:${i.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):o[f]&&u.setAttribute("style",o[f]),Array.from(u.children).forEach(c)}return s.removeAttribute("class"),Array.from(s.children).forEach(u=>c(u)),`<div style="background:${i.bg};color:${i.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 ba({label:e,value:r,current:s,onClick:i}){return t.jsx("button",{onClick:()=>i(s===r?"":r),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${s===r?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function Xh(){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 ya(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function pu(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function bL(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 dN(){const[e,r]=j.useState("weekly"),[s,i]=j.useState(null),[o,c]=j.useState(!0),[u,f]=j.useState(""),[m,h]=j.useState(null),[x,g]=j.useState([]),[b,p]=j.useState("totalTokens"),[w,S]=j.useState(!0),T=j.useCallback(async $=>{c(!0),f("");try{const{report:X}=await ae.reports.generate({period:$,scope:"org",orgId:"default"});i(X)}catch(X){f(String(X)),i(null)}c(!1)},[]),E=j.useCallback(()=>{ae.usage.summary().then($=>h($.usage)).catch(()=>{}),ae.usage.agents().then($=>g($.agents)).catch(()=>{})},[]);j.useEffect(()=>{T(e)},[e,T]),j.useEffect(()=>{E();const $=setInterval(E,3e4);return()=>clearInterval($)},[E]);const C=j.useMemo(()=>[...x].sort(($,X)=>{const P=$[b],q=X[b];return w?q-P:P-q}),[x,b,w]),N=x.reduce(($,X)=>$+X.estimatedCost,0),k=x.reduce(($,X)=>$+X.tokensUsedToday,0),H=Math.max(1,...x.map($=>$.totalTokens)),M=$=>{b===$?S(!w):(p($),S(!0))},Y={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.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:"Reports"}),t.jsxs("select",{value:e,onChange:$=>r($.target.value),className:"bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary",children:[t.jsx("option",{value:"daily",children:"Daily"}),t.jsx("option",{value:"weekly",children:"Weekly"}),t.jsx("option",{value:"monthly",children:"Monthly"})]})]}),m&&t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(ou,{label:"LLM Tokens (this month)",value:ya(m.llmTokens),color:"text-brand-500"}),t.jsx(ou,{label:"Tool Calls (today)",value:ya(m.toolCalls),color:"text-blue-600"}),t.jsx(ou,{label:"Messages (today)",value:ya(m.messages),color:"text-green-600"}),t.jsx(ou,{label:"Storage",value:bL(m.storageBytes),color:"text-amber-600"})]}),o?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:"Loading…"}):u?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:u}):s?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[Y[e]," · ",new Date(s.periodStart).toLocaleDateString()," — ",new Date(s.periodEnd).toLocaleDateString()]}),s.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(no,{label:"Completed",value:s.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(no,{label:"In Progress",value:s.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(no,{label:"Created",value:s.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(no,{label:"Blocked",value:s.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(no,{label:"Failed",value:s.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:pu(N)}),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:ya(k)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Tokens Today"})]}),s.costSummary&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:s.costSummary.totalTokens.toLocaleString()}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Tokens (",Y[e],")"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:pu(s.costSummary.totalEstimatedCost)}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Cost (",Y[e],")"]})]})]})]})]}),s.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:[s.taskSummary.completed.length>0&&t.jsx(Zh,{title:`Completed (${s.taskSummary.completed.length})`,color:"emerald",items:s.taskSummary.completed.map($=>({label:$.title,sub:$.agent}))}),s.taskSummary.inProgress.length>0&&t.jsx(Zh,{title:`In Progress (${s.taskSummary.inProgress.length})`,color:"indigo",items:s.taskSummary.inProgress.map($=>({label:$.title,sub:$.agent}))}),s.taskSummary.blocked.length>0&&t.jsx(Zh,{title:`Blocked (${s.taskSummary.blocked.length})`,color:"amber",items:s.taskSummary.blocked.map($=>({label:$.title,sub:$.reason||$.agent}))}),s.taskSummary.completed.length===0&&s.taskSummary.inProgress.length===0&&s.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]})]}):null,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(ro,{label:"Total Tokens",col:"totalTokens",current:b,desc:w,onSort:M}),t.jsx(ro,{label:"Today",col:"tokensUsedToday",current:b,desc:w,onSort:M}),t.jsx(ro,{label:"Requests",col:"requestCount",current:b,desc:w,onSort:M}),t.jsx(ro,{label:"Tool Calls",col:"toolCalls",current:b,desc:w,onSort:M}),t.jsx(ro,{label:"Est. Cost",col:"estimatedCost",current:b,desc:w,onSort:M,align:"right"})]})}),t.jsx("tbody",{children:C.map($=>t.jsx(yL,{agent:$,maxTokens:H},$.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:ya(x.reduce(($,X)=>$+X.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:ya(k)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:x.reduce(($,X)=>$+X.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:x.reduce(($,X)=>$+X.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:pu(N)})]})})]})})]})]})})}function no({label:e,value:r,color:s}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${s}`,children:r}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function Zh({title:e,color:r,items:s}){return t.jsxs("div",{children:[t.jsx("div",{className:`text-xs font-medium text-${r}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1",children:s.map((i,o)=>t.jsxs("div",{className:"text-sm text-fg-secondary flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${r}-500 shrink-0`}),t.jsx("span",{className:"truncate",children:i.label}),i.sub&&i.sub!=="unassigned"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:i.sub})]},o))})]})}function ou({label:e,value:r,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:r})]})}function ro({label:e,col:r,current:s,desc:i,onSort:o,align:c}){const u=s===r?i?"↓":"↑":"↕",f=s===r?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${c==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>o(r),children:[e,t.jsx("span",{className:`ml-1 ${f}`,children:u})]})}function yL({agent:e,maxTokens:r}){const s=r>0?Math.min(100,e.totalTokens/r*100):0,i=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:()=>Ut.navigate("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 ${i}`}),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:ya(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:ya(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:pu(e.estimatedCost)})]})}function so({d:e,size:r=18}){return t.jsx("svg",{width:r,height:r,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 ao={dashboard:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",projects:"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",chat:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",reports:"M18 20V10 M12 20V4 M6 20v-6",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",usage:"M21.21 15.89A10 10 0 1 1 8 2.83 M22 12A10 10 0 0 0 12 2v10z",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",agents:"M8 3H5a2 2 0 0 0-2 2v3 M21 8V5a2 2 0 0 0-2-2h-3 M3 16v3a2 2 0 0 0 2 2h3 M16 21h3a2 2 0 0 0 2-2v-3 M9 9h6v6H9z",teams:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",skills:"M12 2L2 7l10 5 10-5-10-5z M2 17l10 5 10-5 M2 12l10 5 10-5",governance:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",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"},vL={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"},jL=[{id:"dashboard",label:"Overview",section:"workspace"},{id:"chat",label:"Chat",section:"workspace"},{id:"deliverables",label:"Deliverables",section:"workspace"},{id:"builder",label:"Builder",section:"build"},{id:"agents",label:"Agents",section:"build"},{id:"teams",label:"Teams",section:"build"},{id:"skills",label:"Skills",section:"build"},{id:"governance",label:"Governance",section:"system"},{id:"reports",label:"Reports",section:"system"},{id:"settings",label:"Settings",section:"system"}],wL=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],$v=5;function NL({currentPage:e,onNavigate:r,authUser:s,onLogout:i,collapsed:o,onToggleCollapse:c}){const[u,f]=j.useState([]),[m,h]=j.useState(!1),[x,g]=j.useState(null),[b,p]=j.useState(!1),w=j.useCallback(()=>{ae.projects.list().then(C=>f(C.projects)).catch(()=>{})},[]);j.useEffect(()=>{w();const C=setInterval(w,3e4);return()=>clearInterval(C)},[w]),j.useEffect(()=>{if(e!=="projects"){g(null);return}const N=window.location.hash.slice(1).split("/");N[0]==="projects"&&N[1]&&g(N[1])},[e]);const S=async()=>{try{await ae.auth.logout()}catch{}i?.()},T=m?u:u.slice(0,$v),E=u.length>$v;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.jsx("button",{onClick:c,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.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shadow-md shadow-black/30 shrink-0"}),t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]}),t.jsx("button",{onClick:c,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1 rounded-md hover:bg-surface-overlay shrink-0",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:wL.map((C,N)=>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:C.label}),o&&N>0&&t.jsx("div",{className:"my-2 mx-1"}),jL.filter(k=>k.section===C.key&&!(C.key==="workspace"&&k.id==="deliverables")).map(k=>{const H=e===k.id;return t.jsxs("button",{onClick:()=>r(k.id),title:o?k.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 ${H?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":"text-fg-primary hover:bg-surface-overlay"}`,children:[t.jsx(so,{d:ao[k.id]??""}),!o&&k.label]},k.id)}),C.key==="workspace"&&o&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{g(null),r("projects")},title:"Projects",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-all ${e==="projects"&&!x?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":e==="projects"?"bg-brand-600/15 text-fg-primary":"text-fg-primary hover:bg-surface-overlay"}`,children:t.jsx(so,{d:ao.projects})}),t.jsx("button",{onClick:()=>r("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==="deliverables"?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(so,{d:ao.deliverables})})]}),C.key==="workspace"&&!o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center mb-0.5",children:[t.jsxs("button",{onClick:()=>{g(null),window.location.hash="projects",r("projects")},className:`flex-1 flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${e==="projects"&&!x?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(so,{d:ao.projects}),"Projects"]}),t.jsx("button",{onClick:()=>p(!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"})]})})]}),u.length===0&&t.jsxs("button",{onClick:()=>p(!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"]}),T.map(k=>{const H=e==="projects"&&x===k.id;return t.jsxs("button",{onClick:()=>{g(k.id),e!=="projects"&&r("projects"),window.location.hash="projects/"+k.id},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 ${H?"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 ${vL[k.status]??"bg-gray-600"}`}),t.jsx("span",{className:"truncate text-xs",children:k.name})]},k.id)}),E&&!m&&t.jsxs("button",{onClick:()=>h(!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 ",u.length," projects..."]}),t.jsxs("button",{onClick:()=>r("deliverables"),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e==="deliverables"?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(so,{d:ao.deliverables}),"Deliverables"]})]})]})},C.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:S,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:S,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.2.4"]})]}),b&&t.jsx(aN,{orgId:s?.orgId,onCreated:()=>{p(!1),w()},onClose:()=>p(!1)})]})}const kL={dashboard:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",chat:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",projects:"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",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",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",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"},SL=[{id:"dashboard",label:"Home",iconKey:"dashboard",group:["dashboard"]},{id:"chat",label:"Chat",iconKey:"chat",group:["chat"]},{id:"projects",label:"Projects",iconKey:"projects",group:["projects"]},{id:"deliverables",label:"Deliverables",iconKey:"deliverables",group:["deliverables"]},{id:"builder",label:"Builder",iconKey:"builder",group:["builder","agents","teams","skills"]},{id:"settings",label:"Settings",iconKey:"settings",group:["settings","governance","reports"]}];function CL({currentPage:e,onNavigate:r}){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:SL.map(s=>{const i=s.group.includes(e);return t.jsxs("button",{onClick:()=>r(s.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${i?"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:i?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:kL[s.iconKey]})}),t.jsx("span",{className:`text-[10px] leading-tight ${i?"font-semibold":""}`,children:s.label})]},s.id)})})}const EL=50,TL=30;function fN(e,r,s){const i=j.useRef(0),o=j.useRef(0),c=j.useCallback(f=>{i.current=f.touches[0].clientX,o.current=f.touches[0].clientY},[]),u=j.useCallback(f=>{const m=f.changedTouches[0].clientX-i.current,h=f.changedTouches[0].clientY-o.current,x=Math.abs(m),g=Math.abs(h);if(x<EL||Math.atan2(g,x)*(180/Math.PI)>TL)return;const p=e.findIndex(w=>w.id===r);m<0&&p<e.length-1?s(e[p+1].id):m>0&&p>0&&s(e[p-1].id)},[e,r,s]);return{onTouchStart:c,onTouchEnd:u}}const Bv=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function _L({authUser:e}){const[r,s]=j.useState("builder"),i=fN(Bv,r,s);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:i.onTouchStart,onTouchEnd:i.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:Bv.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 ${r===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:[r==="builder"&&t.jsx(gj,{}),r==="agents"&&t.jsx(fj,{authUser:e}),r==="teams"&&t.jsx(xj,{}),r==="skills"&&t.jsx(cj,{})]})]})}const Hv=[{id:"settings",label:"Settings"},{id:"governance",label:"Governance"},{id:"reports",label:"Reports"}];function AL({theme:e,onThemeChange:r}){const[s,i]=j.useState("settings"),o=fN(Hv,s,i);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:Hv.map(c=>t.jsx("button",{onClick:()=>i(c.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===c.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:c.label},c.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="settings"&&t.jsx(lj,{theme:e,onThemeChange:r}),s==="governance"&&t.jsx(pj,{}),s==="reports"&&t.jsx(dN,{})]})]})}const Pv=2;function ML({onComplete:e,theme:r,onThemeChange:s}){const[i,o]=j.useState(0),[c,u]=j.useState(null),[f,m]=j.useState(!1),[h,x]=j.useState({}),[g,b]=j.useState(!1),[p,w]=j.useState(null),[S,T]=j.useState(!1),[E,C]=j.useState(!1),[N,k]=j.useState(null),H=j.useRef(!1),M=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`});j.useEffect(()=>{fetch("/api/settings/llm").then(I=>I.ok?I.json():null).then(I=>{I?.providers&&Object.values(I.providers).some(A=>A.configured)&&C(!0)}).catch(()=>{})},[]),j.useEffect(()=>{i===Pv&&!H.current&&!E&&(H.current=!0,Y())},[i,E]);const Y=async()=>{m(!0);try{const I=await fetch("/api/settings/env-models",{headers:M()});if(I.ok){const A=await I.json();if(u(A),A.detected.length>0){const G={};for(const U of A.detected)G[U.provider]=!0;x(G)}}}catch{}finally{m(!1)}},$=async()=>{if(!c)return;const I=c.detected.filter(A=>h[A.provider]);if(I.length!==0){b(!0),k(null);try{const A=await fetch("/api/settings/env-models",{method:"POST",headers:M(),body:JSON.stringify({providers:I.map(G=>({provider:G.provider,model:G.model,baseUrl:G.baseUrl,enabled:!0}))})});if(A.ok){const G=await A.json();k({type:"ok",text:G.message}),C(!0)}else k({type:"err",text:"Failed to apply"})}catch{k({type:"err",text:"Network error"})}finally{b(!1)}}},X=async()=>{T(!0);try{const A=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:M(),body:JSON.stringify({preview:!0})})).json();"error"in A||w(A)}catch{}finally{T(!1)}},P=async()=>{T(!0),k(null);try{const A=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:M(),body:JSON.stringify({preview:!1})})).json();"error"in A?k({type:"err",text:A.error}):(k({type:"ok",text:`Imported ${A.appliedModels} model configs`}),C(!0))}catch{k({type:"err",text:"Import failed"})}finally{T(!1)}},q=[{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"}],F=[{title:"Welcome to Markus",subtitle:"Your AI Digital Employee Platform",content:t.jsxs("div",{className:"space-y-4 text-fg-secondary text-sm leading-relaxed",children:[t.jsxs("p",{children:["Markus helps you build ",t.jsx("strong",{className:"text-fg-primary",children:"AI teams"})," — digital employees that work autonomously, collaborate with each other, and communicate with you naturally."]}),t.jsx("div",{className:"grid grid-cols-2 gap-3 mt-6",children:[["Always Online","Agents work 24/7 autonomously"],["Team Collaboration","Agents communicate via A2A messaging"],["Smart Routing","Messages auto-route to the right agent"],["Tool Capable","Shell, files, web, git, browser tools"]].map(([I,A])=>t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:I}),t.jsx("div",{className:"text-fg-secondary text-xs mt-1",children:A})]},I))})]})},{title:"Choose Your Theme",subtitle:"You can change this anytime in Settings",content:t.jsx("div",{className:"grid grid-cols-3 gap-3",children:q.map(I=>t.jsxs("button",{onClick:()=>s(I.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${r===I.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:I.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:I.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:I.desc})]},I.value))})},{title:"Configure LLM",subtitle:"Agents need an LLM to think and act",content:E?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"}),f&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse",children:"Detecting API keys..."}),c&&c.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[c.detected.map(I=>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:h[I.provider]??!1,onChange:A=>x({...h,[I.provider]:A.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:I.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:I.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:I.apiKeyPreview})]},I.provider)),t.jsx("button",{onClick:()=>{$()},disabled:g||Object.values(h).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:g?"Applying...":`Apply ${Object.values(h).filter(Boolean).length} Provider(s)`})]}),c&&c.detected.length===0&&!f&&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"}),p?p.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:p.summary.configPath}),p.summary.models&&t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",p.summary.models.providerCount," providers)"]})]}),t.jsx("button",{onClick:()=>{P()},disabled:S,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:S?"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:()=>{X()},disabled:S,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:S?"Detecting...":"Detect OpenClaw Config"})]}),N&&t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${N.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:N.text})]})},{title:"You're All Set",subtitle:"Here's what you can do",content:t.jsx("div",{className:"space-y-2 text-fg-secondary text-sm",children:[["Chat","Talk to agents or use Smart Route to auto-pick the best one"],["Projects","Create tasks and track progress on kanban boards"],["Builder","Create and customize agents, teams, and prompts"],["Settings","Manage LLM providers, themes, and import configs"]].map(([I,A])=>t.jsxs("div",{className:"flex gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"text-brand-500 mt-0.5 shrink-0",children:"→"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:I}),t.jsx("div",{className:"text-fg-secondary text-xs",children:A})]})]},I))})}],D=()=>{i<F.length-1?o(i+1):e()},_=F[i];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:F.map((I,A)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${A<=i?"bg-brand-500":"bg-surface-elevated"}`},A))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:_.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:_.subtitle}),_.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[i>0?t.jsx("button",{onClick:()=>o(i-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:[i===Pv&&!E&&t.jsx("button",{onClick:D,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),t.jsx("button",{onClick:D,className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-xl transition-colors",children:i===F.length-1?"Get Started":"Next"})]})]})]})})})}const DL="markus123";function OL({onLogin:e}){const[r,s]=j.useState("admin@markus.local"),[i,o]=j.useState(""),[c,u]=j.useState(""),[f,m]=j.useState(!1),h=async x=>{if(x.preventDefault(),!(!r.trim()||!i)){u(""),m(!0);try{const{user:g}=await ae.auth.login(r.trim(),i);e(g,i===DL)}catch{u("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:h,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:r,onChange:x=>s(x.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:i,onChange:x=>o(x.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})]}),c&&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:c}),t.jsx("button",{type:"submit",disabled:f||!r||!i,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:f?"Signing in…":"Sign in"}),t.jsx("p",{className:"text-center text-xs text-fg-tertiary",children:"Default: admin@markus.local / markus123"})]})]})]})}function RL({onComplete:e,isFirstTime:r}){const[s,i]=j.useState(""),[o,c]=j.useState(""),[u,f]=j.useState(""),[m,h]=j.useState(""),[x,g]=j.useState(!1),b=async p=>{if(p.preventDefault(),h(""),o.length<6){h("Password must be at least 6 characters");return}if(o!==u){h("Passwords do not match");return}g(!0);try{await ae.auth.changePassword(s,o),e()}catch{h("Failed to change password. Check your current password.")}finally{g(!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:b,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:r?"Set Your Password":"Change Password"}),r&&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."})]}),!r&&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:p=>i(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"})]}),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:p=>c(p.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:u,onChange:p=>f(p.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:x||!o||!u,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:x?"Saving…":r?"Set Password & Continue":"Change Password"})]})]})]})}const hN="markus-theme";function Uv(e){const r=document.documentElement;r.classList.remove("light","dark"),e==="light"?r.classList.add("light"):e==="dark"&&r.classList.add("dark")}function zL(){try{const e=localStorage.getItem(hN);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"system"}function LL(){const[e,r]=j.useState(zL),s=j.useCallback(i=>{r(i);try{localStorage.setItem(hN,i)}catch{}Uv(i)},[]);return j.useEffect(()=>{Uv(e)},[e]),{mode:e,setMode:s}}const IL=["dashboard","tasks","chat","team","usage","skills","agents","teams","builder","prompts","settings","governance","projects","deliverables","reports"];function cu(){const e=window.location.hash.slice(1).split("/")[0];return e==="team"?"chat":e==="tasks"?"projects":e==="usage"?"reports":e==="prompts"?"builder":e==="templates"?"agents":e==="knowledge"?"deliverables":IL.includes(e)?e:"dashboard"}const Qh={};function $L(){const[e,r]=j.useState(cu),[s,i]=j.useState(()=>!localStorage.getItem("markus_onboarded")),[o,c]=j.useState(!0),u=gs(),f=LL(),m=ex({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[h,x]=j.useState(()=>new Set([cu()])),[g,b]=j.useState("loading"),[p,w]=j.useState(!1),[S,T]=j.useState(null),[E,C]=j.useState(!1),N=j.useCallback(Y=>{let $=Y==="tasks"?"projects":Y==="team"?"chat":Y==="usage"?"reports":Y==="prompts"?"builder":Y==="templates"?"agents":Y;u&&(($==="agents"||$==="teams"||$==="skills")&&($="builder"),($==="governance"||$==="reports")&&($="settings"));const X=cu(),P=window.location.hash.slice(1);P!==X?Qh[X]=P:delete Qh[X],r($),x(q=>q.has($)?q:new Set([...q,$])),window.location.hash=Qh[$]||$},[u]);j.useEffect(()=>{Ut.setHandler(Y=>N(Y))},[N]);const k=j.useCallback(()=>{fetch("/api/settings/llm").then(Y=>Y.ok?Y.json():null).then(Y=>{if(Y?.providers){const $=Object.values(Y.providers).some(X=>X.configured);T($)}}).catch(()=>{})},[]);j.useEffect(()=>{ae.auth.me().then(({user:$})=>{b($),k(),Va(pr.builderArtifacts,()=>ae.builder.artifacts.list()),Va(pr.builderAgents,()=>ae.agents.list()),Va(pr.builderHubMyItems,()=>Bn.myItems()),Va(pr.builderInstalled,()=>ae.builder.artifacts.installed()),Va(pr.hubAgents,()=>Bn.search({type:"agent",limit:50})),Va(pr.hubTeams,()=>Bn.search({type:"team",limit:50})),Va(pr.hubSkills,()=>Bn.search({type:"skill",limit:50}))}).catch(()=>b(null)),En.connect();const Y=()=>{const $=cu();r($),x(X=>X.has($)?X:new Set([...X,$]))};return window.addEventListener("hashchange",Y),()=>{En.disconnect(),window.removeEventListener("hashchange",Y)}},[]);const H=g!=="loading"&&g!==null?g:void 0,M=j.useMemo(()=>u?{dashboard:t.jsx(ob,{}),chat:t.jsx(hy,{authUser:H}),builder:t.jsx(_L,{authUser:H}),settings:t.jsx(AL,{theme:f.mode,onThemeChange:f.setMode}),projects:t.jsx(Rv,{authUser:H}),deliverables:t.jsx(Iv,{})}:{dashboard:t.jsx(ob,{}),chat:t.jsx(hy,{authUser:H}),settings:t.jsx(lj,{theme:f.mode,onThemeChange:f.setMode}),skills:t.jsx(cj,{}),agents:t.jsx(fj,{authUser:H}),teams:t.jsx(xj,{}),builder:t.jsx(gj,{}),governance:t.jsx(pj,{}),projects:t.jsx(Rv,{authUser:H}),deliverables:t.jsx(Iv,{}),reports:t.jsx(dN,{})},[H?.id,f.mode,u]);return g==="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…"})}):g===null?t.jsx(OL,{onLogin:(Y,$)=>{b(Y),$&&w(!0)}}):p?t.jsx(RL,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(ML,{theme:f.mode,onThemeChange:f.setMode,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),i(!1),k()}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary ${u?"flex-col":""}`,children:[!u&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:m.width},children:t.jsx(NL,{currentPage:e,onNavigate:Y=>{N(Y),c(!1)},authUser:g,onLogout:()=>b(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 ${u?"pb-14":""}`,children:[S===!1&&!E&&e!=="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:u?"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:()=>{N("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:()=>C(!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(M).map(Y=>h.has(Y)?t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:{display:Y===e?"flex":"none"},children:M[Y]},Y):null)})]}),u&&t.jsx(CL,{currentPage:e,onNavigate:N})]})}S2.createRoot(document.getElementById("root")).render(t.jsx(j.StrictMode,{children:t.jsx($L,{})}));
|