@markus-global/cli 0.4.16 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,63 +0,0 @@
1
- (function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const d of o)if(d.type==="childList")for(const c of d.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).observe(document,{childList:!0,subtree:!0});function s(o){const d={};return o.integrity&&(d.integrity=o.integrity),o.referrerPolicy&&(d.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?d.credentials="include":o.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function i(o){if(o.ep)return;o.ep=!0;const d=s(o);fetch(o.href,d)}})();function Zd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ph={exports:{}},lo={};var hb;function B2(){if(hb)return lo;hb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(i,o,d){var c=null;if(d!==void 0&&(c=""+d),o.key!==void 0&&(c=""+o.key),"key"in o){d={};for(var m in o)m!=="key"&&(d[m]=o[m])}else d=o;return o=d.ref,{$$typeof:e,type:i,key:c,ref:o!==void 0?o:null,props:d}}return lo.Fragment=n,lo.jsx=s,lo.jsxs=s,lo}var mb;function H2(){return mb||(mb=1,ph.exports=B2()),ph.exports}var t=H2(),gh={exports:{}},Ot={};var xb;function P2(){if(xb)return Ot;xb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),g=Symbol.iterator;function y(q){return q===null||typeof q!="object"?null:(q=g&&q[g]||q["@@iterator"],typeof q=="function"?q:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,S={};function E(q,X,I){this.props=q,this.context=X,this.refs=S,this.updater=I||w}E.prototype.isReactComponent={},E.prototype.setState=function(q,X){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,X,"setState")},E.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function C(){}C.prototype=E.prototype;function k(q,X,I){this.props=q,this.context=X,this.refs=S,this.updater=I||w}var T=k.prototype=new C;T.constructor=k,N(T,E.prototype),T.isPureReactComponent=!0;var R=Array.isArray;function z(){}var U={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function W(q,X,I){var _=I.ref;return{$$typeof:e,type:q,key:X,ref:_!==void 0?_:null,props:I}}function $(q,X){return W(q.type,X,q.props)}function F(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function Y(q){var X={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(I){return X[I]})}var P=/\/+/g;function M(q,X){return typeof q=="object"&&q!==null&&q.key!=null?Y(""+q.key):X.toString(36)}function L(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(z,z):(q.status="pending",q.then(function(X){q.status==="pending"&&(q.status="fulfilled",q.value=X)},function(X){q.status==="pending"&&(q.status="rejected",q.reason=X)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function A(q,X,I,_,V){var Q=typeof q;(Q==="undefined"||Q==="boolean")&&(q=null);var ee=!1;if(q===null)ee=!0;else switch(Q){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(q.$$typeof){case e:case n:ee=!0;break;case p:return ee=q._init,A(ee(q._payload),X,I,_,V)}}if(ee)return V=V(q),ee=_===""?"."+M(q,0):_,R(V)?(I="",ee!=null&&(I=ee.replace(P,"$&/")+"/"),A(V,X,I,"",function(me){return me})):V!=null&&(F(V)&&(V=$(V,I+(V.key==null||q&&q.key===V.key?"":(""+V.key).replace(P,"$&/")+"/")+ee)),X.push(V)),1;ee=0;var te=_===""?".":_+":";if(R(q))for(var ae=0;ae<q.length;ae++)_=q[ae],Q=te+M(_,ae),ee+=A(_,X,I,Q,V);else if(ae=y(q),typeof ae=="function")for(q=ae.call(q),ae=0;!(_=q.next()).done;)_=_.value,Q=te+M(_,ae++),ee+=A(_,X,I,Q,V);else if(Q==="object"){if(typeof q.then=="function")return A(L(q),X,I,_,V);throw X=String(q),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.")}return ee}function O(q,X,I){if(q==null)return q;var _=[],V=0;return A(q,_,"","",function(Q){return X.call(I,Q,V++)}),_}function D(q){if(q._status===-1){var X=q._result;X=X(),X.then(function(I){(q._status===0||q._status===-1)&&(q._status=1,q._result=I)},function(I){(q._status===0||q._status===-1)&&(q._status=2,q._result=I)}),q._status===-1&&(q._status=0,q._result=X)}if(q._status===1)return q._result.default;throw q._result}var Z=typeof reportError=="function"?reportError:function(q){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var X=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof q=="object"&&q!==null&&typeof q.message=="string"?String(q.message):String(q),error:q});if(!window.dispatchEvent(X))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",q);return}console.error(q)},B={map:O,forEach:function(q,X,I){O(q,function(){X.apply(this,arguments)},I)},count:function(q){var X=0;return O(q,function(){X++}),X},toArray:function(q){return O(q,function(X){return X})||[]},only:function(q){if(!F(q))throw Error("React.Children.only expected to receive a single React element child.");return q}};return Ot.Activity=x,Ot.Children=B,Ot.Component=E,Ot.Fragment=s,Ot.Profiler=o,Ot.PureComponent=k,Ot.StrictMode=i,Ot.Suspense=h,Ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=U,Ot.__COMPILER_RUNTIME={__proto__:null,c:function(q){return U.H.useMemoCache(q)}},Ot.cache=function(q){return function(){return q.apply(null,arguments)}},Ot.cacheSignal=function(){return null},Ot.cloneElement=function(q,X,I){if(q==null)throw Error("The argument must be a React element, but you passed "+q+".");var _=N({},q.props),V=q.key;if(X!=null)for(Q in X.key!==void 0&&(V=""+X.key),X)!G.call(X,Q)||Q==="key"||Q==="__self"||Q==="__source"||Q==="ref"&&X.ref===void 0||(_[Q]=X[Q]);var Q=arguments.length-2;if(Q===1)_.children=I;else if(1<Q){for(var ee=Array(Q),te=0;te<Q;te++)ee[te]=arguments[te+2];_.children=ee}return W(q.type,V,_)},Ot.createContext=function(q){return q={$$typeof:c,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null},q.Provider=q,q.Consumer={$$typeof:d,_context:q},q},Ot.createElement=function(q,X,I){var _,V={},Q=null;if(X!=null)for(_ in X.key!==void 0&&(Q=""+X.key),X)G.call(X,_)&&_!=="key"&&_!=="__self"&&_!=="__source"&&(V[_]=X[_]);var ee=arguments.length-2;if(ee===1)V.children=I;else if(1<ee){for(var te=Array(ee),ae=0;ae<ee;ae++)te[ae]=arguments[ae+2];V.children=te}if(q&&q.defaultProps)for(_ in ee=q.defaultProps,ee)V[_]===void 0&&(V[_]=ee[_]);return W(q,Q,V)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(q){return{$$typeof:m,render:q}},Ot.isValidElement=F,Ot.lazy=function(q){return{$$typeof:p,_payload:{_status:-1,_result:q},_init:D}},Ot.memo=function(q,X){return{$$typeof:f,type:q,compare:X===void 0?null:X}},Ot.startTransition=function(q){var X=U.T,I={};U.T=I;try{var _=q(),V=U.S;V!==null&&V(I,_),typeof _=="object"&&_!==null&&typeof _.then=="function"&&_.then(z,Z)}catch(Q){Z(Q)}finally{X!==null&&I.types!==null&&(X.types=I.types),U.T=X}},Ot.unstable_useCacheRefresh=function(){return U.H.useCacheRefresh()},Ot.use=function(q){return U.H.use(q)},Ot.useActionState=function(q,X,I){return U.H.useActionState(q,X,I)},Ot.useCallback=function(q,X){return U.H.useCallback(q,X)},Ot.useContext=function(q){return U.H.useContext(q)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(q,X){return U.H.useDeferredValue(q,X)},Ot.useEffect=function(q,X){return U.H.useEffect(q,X)},Ot.useEffectEvent=function(q){return U.H.useEffectEvent(q)},Ot.useId=function(){return U.H.useId()},Ot.useImperativeHandle=function(q,X,I){return U.H.useImperativeHandle(q,X,I)},Ot.useInsertionEffect=function(q,X){return U.H.useInsertionEffect(q,X)},Ot.useLayoutEffect=function(q,X){return U.H.useLayoutEffect(q,X)},Ot.useMemo=function(q,X){return U.H.useMemo(q,X)},Ot.useOptimistic=function(q,X){return U.H.useOptimistic(q,X)},Ot.useReducer=function(q,X,I){return U.H.useReducer(q,X,I)},Ot.useRef=function(q){return U.H.useRef(q)},Ot.useState=function(q){return U.H.useState(q)},Ot.useSyncExternalStore=function(q,X,I){return U.H.useSyncExternalStore(q,X,I)},Ot.useTransition=function(){return U.H.useTransition()},Ot.version="19.2.4",Ot}var pb;function Fo(){return pb||(pb=1,gh.exports=P2()),gh.exports}var v=Fo();const U2=Zd(v);var bh={exports:{}},oo={},yh={exports:{}},vh={};var gb;function q2(){return gb||(gb=1,(function(e){function n(A,O){var D=A.length;A.push(O);e:for(;0<D;){var Z=D-1>>>1,B=A[Z];if(0<o(B,O))A[Z]=O,A[D]=B,D=Z;else break e}}function s(A){return A.length===0?null:A[0]}function i(A){if(A.length===0)return null;var O=A[0],D=A.pop();if(D!==O){A[0]=D;e:for(var Z=0,B=A.length,q=B>>>1;Z<q;){var X=2*(Z+1)-1,I=A[X],_=X+1,V=A[_];if(0>o(I,D))_<B&&0>o(V,I)?(A[Z]=V,A[_]=D,Z=_):(A[Z]=I,A[X]=D,Z=X);else if(_<B&&0>o(V,D))A[Z]=V,A[_]=D,Z=_;else break e}}return O}function o(A,O){var D=A.sortIndex-O.sortIndex;return D!==0?D:A.id-O.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;e.unstable_now=function(){return d.now()}}else{var c=Date,m=c.now();e.unstable_now=function(){return c.now()-m}}var h=[],f=[],p=1,x=null,g=3,y=!1,w=!1,N=!1,S=!1,E=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function T(A){for(var O=s(f);O!==null;){if(O.callback===null)i(f);else if(O.startTime<=A)i(f),O.sortIndex=O.expirationTime,n(h,O);else break;O=s(f)}}function R(A){if(N=!1,T(A),!w)if(s(h)!==null)w=!0,z||(z=!0,Y());else{var O=s(f);O!==null&&L(R,O.startTime-A)}}var z=!1,U=-1,G=5,W=-1;function $(){return S?!0:!(e.unstable_now()-W<G)}function F(){if(S=!1,z){var A=e.unstable_now();W=A;var O=!0;try{e:{w=!1,N&&(N=!1,C(U),U=-1),y=!0;var D=g;try{t:{for(T(A),x=s(h);x!==null&&!(x.expirationTime>A&&$());){var Z=x.callback;if(typeof Z=="function"){x.callback=null,g=x.priorityLevel;var B=Z(x.expirationTime<=A);if(A=e.unstable_now(),typeof B=="function"){x.callback=B,T(A),O=!0;break t}x===s(h)&&i(h),T(A)}else i(h);x=s(h)}if(x!==null)O=!0;else{var q=s(f);q!==null&&L(R,q.startTime-A),O=!1}}break e}finally{x=null,g=D,y=!1}O=void 0}}finally{O?Y():z=!1}}}var Y;if(typeof k=="function")Y=function(){k(F)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,M=P.port2;P.port1.onmessage=F,Y=function(){M.postMessage(null)}}else Y=function(){E(F,0)};function L(A,O){U=E(function(){A(e.unstable_now())},O)}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"):G=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(A){switch(g){case 1:case 2:case 3:var O=3;break;default:O=g}var D=g;g=O;try{return A()}finally{g=D}},e.unstable_requestPaint=function(){S=!0},e.unstable_runWithPriority=function(A,O){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var D=g;g=A;try{return O()}finally{g=D}},e.unstable_scheduleCallback=function(A,O,D){var Z=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?Z+D:Z):D=Z,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=D+B,A={id:p++,callback:O,priorityLevel:A,startTime:D,expirationTime:B,sortIndex:-1},D>Z?(A.sortIndex=D,n(f,A),s(h)===null&&A===s(f)&&(N?(C(U),U=-1):N=!0,L(R,D-Z))):(A.sortIndex=B,n(h,A),w||y||(w=!0,z||(z=!0,Y()))),A},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(A){var O=g;return function(){var D=g;g=O;try{return A.apply(this,arguments)}finally{g=D}}}})(vh)),vh}var bb;function V2(){return bb||(bb=1,yh.exports=q2()),yh.exports}var jh={exports:{}},or={};var yb;function F2(){if(yb)return or;yb=1;var e=Fo();function n(h){var f="https://react.dev/errors/"+h;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+h+"; visit "+f+" 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(n(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");function d(h,f,p){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:x==null?null:""+x,children:h,containerInfo:f,implementation:p}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(h,f){if(h==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return or.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,or.createPortal=function(h,f){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(n(299));return d(h,f,null,p)},or.flushSync=function(h){var f=c.T,p=i.p;try{if(c.T=null,i.p=2,h)return h()}finally{c.T=f,i.p=p,i.d.f()}},or.preconnect=function(h,f){typeof h=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,i.d.C(h,f))},or.prefetchDNS=function(h){typeof h=="string"&&i.d.D(h)},or.preinit=function(h,f){if(typeof h=="string"&&f&&typeof f.as=="string"){var p=f.as,x=m(p,f.crossOrigin),g=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?i.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:x,integrity:g,fetchPriority:y}):p==="script"&&i.d.X(h,{crossOrigin:x,integrity:g,fetchPriority:y,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},or.preinitModule=function(h,f){if(typeof h=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var p=m(f.as,f.crossOrigin);i.d.M(h,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&i.d.M(h)},or.preload=function(h,f){if(typeof h=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,x=m(p,f.crossOrigin);i.d.L(h,p,{crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},or.preloadModule=function(h,f){if(typeof h=="string")if(f){var p=m(f.as,f.crossOrigin);i.d.m(h,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else i.d.m(h)},or.requestFormReset=function(h){i.d.r(h)},or.unstable_batchedUpdates=function(h,f){return h(f)},or.useFormState=function(h,f,p){return c.H.useFormState(h,f,p)},or.useFormStatus=function(){return c.H.useHostTransitionStatus()},or.version="19.2.4",or}var vb;function g1(){if(vb)return jh.exports;vb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),jh.exports=F2(),jh.exports}var jb;function Y2(){if(jb)return oo;jb=1;var e=V2(),n=Fo(),s=g1();function i(r){var a="https://react.dev/errors/"+r;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 #"+r+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function d(r){var a=r,l=r;if(r.alternate)for(;a.return;)a=a.return;else{r=a;do a=r,(a.flags&4098)!==0&&(l=a.return),r=a.return;while(r)}return a.tag===3?l:null}function c(r){if(r.tag===13){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function m(r){if(r.tag===31){var a=r.memoizedState;if(a===null&&(r=r.alternate,r!==null&&(a=r.memoizedState)),a!==null)return a.dehydrated}return null}function h(r){if(d(r)!==r)throw Error(i(188))}function f(r){var a=r.alternate;if(!a){if(a=d(r),a===null)throw Error(i(188));return a!==r?null:r}for(var l=r,u=a;;){var b=l.return;if(b===null)break;var j=b.alternate;if(j===null){if(u=b.return,u!==null){l=u;continue}break}if(b.child===j.child){for(j=b.child;j;){if(j===l)return h(b),r;if(j===u)return h(b),a;j=j.sibling}throw Error(i(188))}if(l.return!==u.return)l=b,u=j;else{for(var H=!1,J=b.child;J;){if(J===l){H=!0,l=b,u=j;break}if(J===u){H=!0,u=b,l=j;break}J=J.sibling}if(!H){for(J=j.child;J;){if(J===l){H=!0,l=j,u=b;break}if(J===u){H=!0,u=j,l=b;break}J=J.sibling}if(!H)throw Error(i(189))}}if(l.alternate!==u)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?r:a}function p(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r;for(r=r.child;r!==null;){if(a=p(r),a!==null)return a;r=r.sibling}return null}var x=Object.assign,g=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),k=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function Y(r){return r===null||typeof r!="object"?null:(r=F&&r[F]||r["@@iterator"],typeof r=="function"?r:null)}var P=Symbol.for("react.client.reference");function M(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===P?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case N:return"Fragment";case E:return"Profiler";case S:return"StrictMode";case R:return"Suspense";case z:return"SuspenseList";case W:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case k:return r.displayName||"Context";case C:return(r._context.displayName||"Context")+".Consumer";case T:var a=r.render;return r=r.displayName,r||(r=a.displayName||a.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case U:return a=r.displayName||null,a!==null?a:M(r.type)||"Memo";case G:a=r._payload,r=r._init;try{return M(r(a))}catch{}}return null}var L=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D={pending:!1,data:null,method:null,action:null},Z=[],B=-1;function q(r){return{current:r}}function X(r){0>B||(r.current=Z[B],Z[B]=null,B--)}function I(r,a){B++,Z[B]=r.current,r.current=a}var _=q(null),V=q(null),Q=q(null),ee=q(null);function te(r,a){switch(I(Q,a),I(V,r),I(_,null),a.nodeType){case 9:case 11:r=(r=a.documentElement)&&(r=r.namespaceURI)?I0(r):0;break;default:if(r=a.tagName,a=a.namespaceURI)a=I0(a),r=z0(a,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}X(_),I(_,r)}function ae(){X(_),X(V),X(Q)}function me(r){r.memoizedState!==null&&I(ee,r);var a=_.current,l=z0(a,r.type);a!==l&&(I(V,r),I(_,l))}function Ne(r){V.current===r&&(X(_),X(V)),ee.current===r&&(X(ee),ro._currentValue=D)}var Ie,je;function Te(r){if(Ie===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);Ie=a&&a[1]||"",je=-1<l.stack.indexOf(`
2
- at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+Ie+r+je}var Ce=!1;function Re(r,a){if(!r||Ce)return"";Ce=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(a){var De=function(){throw Error()};if(Object.defineProperty(De.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(De,[])}catch(ke){var be=ke}Reflect.construct(r,[],De)}else{try{De.call()}catch(ke){be=ke}r.call(De.prototype)}}else{try{throw Error()}catch(ke){be=ke}(De=r())&&typeof De.catch=="function"&&De.catch(function(){})}}catch(ke){if(ke&&be&&typeof ke.stack=="string")return[ke.stack,be.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=u.DetermineComponentFrameRoot(),H=j[0],J=j[1];if(H&&J){var ie=H.split(`
4
- `),ge=J.split(`
5
- `);for(b=u=0;u<ie.length&&!ie[u].includes("DetermineComponentFrameRoot");)u++;for(;b<ge.length&&!ge[b].includes("DetermineComponentFrameRoot");)b++;if(u===ie.length||b===ge.length)for(u=ie.length-1,b=ge.length-1;1<=u&&0<=b&&ie[u]!==ge[b];)b--;for(;1<=u&&0<=b;u--,b--)if(ie[u]!==ge[b]){if(u!==1||b!==1)do if(u--,b--,0>b||ie[u]!==ge[b]){var _e=`
6
- `+ie[u].replace(" at new "," at ");return r.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",r.displayName)),_e}while(1<=u&&0<=b);break}}}finally{Ce=!1,Error.prepareStackTrace=l}return(l=r?r.displayName||r.name:"")?Te(l):""}function Ge(r,a){switch(r.tag){case 26:case 27:case 5:return Te(r.type);case 16:return Te("Lazy");case 13:return r.child!==a&&a!==null?Te("Suspense Fallback"):Te("Suspense");case 19:return Te("SuspenseList");case 0:case 15:return Re(r.type,!1);case 11:return Re(r.type.render,!1);case 1:return Re(r.type,!0);case 31:return Te("Activity");default:return""}}function ot(r){try{var a="",l=null;do a+=Ge(r,l),l=r,r=r.return;while(r);return a}catch(u){return`
7
- Error generating stack: `+u.message+`
8
- `+u.stack}}var st=Object.prototype.hasOwnProperty,jt=e.unstable_scheduleCallback,re=e.unstable_cancelCallback,Ee=e.unstable_shouldYield,Ze=e.unstable_requestPaint,yt=e.unstable_now,Dt=e.unstable_getCurrentPriorityLevel,we=e.unstable_ImmediatePriority,Le=e.unstable_UserBlockingPriority,Ue=e.unstable_NormalPriority,at=e.unstable_LowPriority,rt=e.unstable_IdlePriority,Zt=e.log,fn=e.unstable_setDisableYieldValue,zt=null,Mt=null;function _t(r){if(typeof Zt=="function"&&fn(r),Mt&&typeof Mt.setStrictMode=="function")try{Mt.setStrictMode(zt,r)}catch{}}var Ct=Math.clz32?Math.clz32:Tn,en=Math.log,Ht=Math.LN2;function Tn(r){return r>>>=0,r===0?32:31-(en(r)/Ht|0)|0}var wn=256,ye=262144,We=4194304;function He(r){var a=r&42;if(a!==0)return a;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function wt(r,a,l){var u=r.pendingLanes;if(u===0)return 0;var b=0,j=r.suspendedLanes,H=r.pingedLanes;r=r.warmLanes;var J=u&134217727;return J!==0?(u=J&~j,u!==0?b=He(u):(H&=J,H!==0?b=He(H):l||(l=J&~r,l!==0&&(b=He(l))))):(J=u&~j,J!==0?b=He(J):H!==0?b=He(H):l||(l=u&~r,l!==0&&(b=He(l)))),b===0?0:a!==0&&a!==b&&(a&j)===0&&(j=b&-b,l=a&-a,j>=l||j===32&&(l&4194048)!==0)?a:b}function Tt(r,a){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&a)===0}function tn(r,a){switch(r){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function nn(){var r=We;return We<<=1,(We&62914560)===0&&(We=4194304),r}function hn(r){for(var a=[],l=0;31>l;l++)a.push(r);return a}function mn(r,a){r.pendingLanes|=a,a!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function On(r,a,l,u,b,j){var H=r.pendingLanes;r.pendingLanes=l,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=l,r.entangledLanes&=l,r.errorRecoveryDisabledLanes&=l,r.shellSuspendCounter=0;var J=r.entanglements,ie=r.expirationTimes,ge=r.hiddenUpdates;for(l=H&~l;0<l;){var _e=31-Ct(l),De=1<<_e;J[_e]=0,ie[_e]=-1;var be=ge[_e];if(be!==null)for(ge[_e]=null,_e=0;_e<be.length;_e++){var ke=be[_e];ke!==null&&(ke.lane&=-536870913)}l&=~De}u!==0&&Nt(r,u,0),j!==0&&b===0&&r.tag!==0&&(r.suspendedLanes|=j&~(H&~a))}function Nt(r,a,l){r.pendingLanes|=a,r.suspendedLanes&=~a;var u=31-Ct(a);r.entangledLanes|=a,r.entanglements[u]=r.entanglements[u]|1073741824|l&261930}function oe(r,a){var l=r.entangledLanes|=a;for(r=r.entanglements;l;){var u=31-Ct(l),b=1<<u;b&a|r[u]&a&&(r[u]|=a),l&=~b}}function Ve(r,a){var l=a&-a;return l=(l&42)!==0?1:ze(l),(l&(r.suspendedLanes|a))!==0?0:l}function ze(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function dt(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function it(){var r=O.p;return r!==0?r:(r=window.event,r===void 0?32:ib(r.type))}function xt(r,a){var l=O.p;try{return O.p=r,a()}finally{O.p=l}}var $t=Math.random().toString(36).slice(2),Je="__reactFiber$"+$t,Fe="__reactProps$"+$t,Et="__reactContainer$"+$t,Rn="__reactEvents$"+$t,Nn="__reactListeners$"+$t,ln="__reactHandles$"+$t,ve="__reactResources$"+$t,Xe="__reactMarker$"+$t;function At(r){delete r[Je],delete r[Fe],delete r[Rn],delete r[Nn],delete r[ln]}function St(r){var a=r[Je];if(a)return a;for(var l=r.parentNode;l;){if(a=l[Et]||l[Je]){if(l=a.alternate,a.child!==null||l!==null&&l.child!==null)for(r=V0(r);r!==null;){if(l=r[Je])return l;r=V0(r)}return a}r=l,l=r.parentNode}return null}function xn(r){if(r=r[Je]||r[Et]){var a=r.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return r}return null}function Qn(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r.stateNode;throw Error(i(33))}function lr(r){var a=r[ve];return a||(a=r[ve]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function on(r){r[Xe]=!0}var ur=new Set,Jr={};function de(r,a){Ae(r,a),Ae(r+"Capture",a)}function Ae(r,a){for(Jr[r]=a,r=0;r<a.length;r++)ur.add(a[r])}var qe=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]*$"),Bt={},xr={};function es(r){return st.call(xr,r)?!0:st.call(Bt,r)?!1:qe.test(r)?xr[r]=!0:(Bt[r]=!0,!1)}function fr(r,a,l){if(es(a))if(l===null)r.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":r.removeAttribute(a);return;case"boolean":var u=a.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){r.removeAttribute(a);return}}r.setAttribute(a,""+l)}}function ms(r,a,l){if(l===null)r.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(a);return}r.setAttribute(a,""+l)}}function nr(r,a,l,u){if(u===null)r.removeAttribute(l);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(l);return}r.setAttributeNS(a,l,""+u)}}function Xn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ms(r){var a=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Ha(r,a,l){var u=Object.getOwnPropertyDescriptor(r.constructor.prototype,a);if(!r.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var b=u.get,j=u.set;return Object.defineProperty(r,a,{configurable:!0,get:function(){return b.call(this)},set:function(H){l=""+H,j.call(this,H)}}),Object.defineProperty(r,a,{enumerable:u.enumerable}),{getValue:function(){return l},setValue:function(H){l=""+H},stopTracking:function(){r._valueTracker=null,delete r[a]}}}}function ts(r){if(!r._valueTracker){var a=Ms(r)?"checked":"value";r._valueTracker=Ha(r,a,""+r[a])}}function Er(r){if(!r)return!1;var a=r._valueTracker;if(!a)return!0;var l=a.getValue(),u="";return r&&(u=Ms(r)?r.checked?"true":"false":r.value),r=u,r!==l?(a.setValue(r),!0):!1}function Pr(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var Pa=/[\n"\\]/g;function Jn(r){return r.replace(Pa,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function ns(r,a,l,u,b,j,H,J){r.name="",H!=null&&typeof H!="function"&&typeof H!="symbol"&&typeof H!="boolean"?r.type=H:r.removeAttribute("type"),a!=null?H==="number"?(a===0&&r.value===""||r.value!=a)&&(r.value=""+Xn(a)):r.value!==""+Xn(a)&&(r.value=""+Xn(a)):H!=="submit"&&H!=="reset"||r.removeAttribute("value"),a!=null?Tr(r,H,Xn(a)):l!=null?Tr(r,H,Xn(l)):u!=null&&r.removeAttribute("value"),b==null&&j!=null&&(r.defaultChecked=!!j),b!=null&&(r.checked=b&&typeof b!="function"&&typeof b!="symbol"),J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?r.name=""+Xn(J):r.removeAttribute("name")}function Kn(r,a,l,u,b,j,H,J){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.type=j),a!=null||l!=null){if(!(j!=="submit"&&j!=="reset"||a!=null)){ts(r);return}l=l!=null?""+Xn(l):"",a=a!=null?""+Xn(a):l,J||a===r.value||(r.value=a),r.defaultValue=a}u=u??b,u=typeof u!="function"&&typeof u!="symbol"&&!!u,r.checked=J?r.checked:!!u,r.defaultChecked=!!u,H!=null&&typeof H!="function"&&typeof H!="symbol"&&typeof H!="boolean"&&(r.name=H),ts(r)}function Tr(r,a,l){a==="number"&&Pr(r.ownerDocument)===r||r.defaultValue===""+l||(r.defaultValue=""+l)}function pr(r,a,l,u){if(r=r.options,a){a={};for(var b=0;b<l.length;b++)a["$"+l[b]]=!0;for(l=0;l<r.length;l++)b=a.hasOwnProperty("$"+r[l].value),r[l].selected!==b&&(r[l].selected=b),b&&u&&(r[l].defaultSelected=!0)}else{for(l=""+Xn(l),a=null,b=0;b<r.length;b++){if(r[b].value===l){r[b].selected=!0,u&&(r[b].defaultSelected=!0);return}a!==null||r[b].disabled||(a=r[b])}a!==null&&(a.selected=!0)}}function xs(r,a,l){if(a!=null&&(a=""+Xn(a),a!==r.value&&(r.value=a),l==null)){r.defaultValue!==a&&(r.defaultValue=a);return}r.defaultValue=l!=null?""+Xn(l):""}function _r(r,a,l,u){if(a==null){if(u!=null){if(l!=null)throw Error(i(92));if(L(u)){if(1<u.length)throw Error(i(93));u=u[0]}l=u}l==null&&(l=""),a=l}l=Xn(a),r.defaultValue=l,u=r.textContent,u===l&&u!==""&&u!==null&&(r.value=u),ts(r)}function Ur(r,a){if(a){var l=r.firstChild;if(l&&l===r.lastChild&&l.nodeType===3){l.nodeValue=a;return}}r.textContent=a}var rs=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 ps(r,a,l){var u=a.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?u?r.setProperty(a,""):a==="float"?r.cssFloat="":r[a]="":u?r.setProperty(a,l):typeof l!="number"||l===0||rs.has(a)?a==="float"?r.cssFloat=l:r[a]=(""+l).trim():r[a]=l+"px"}function sa(r,a,l){if(a!=null&&typeof a!="object")throw Error(i(62));if(r=r.style,l!=null){for(var u in l)!l.hasOwnProperty(u)||a!=null&&a.hasOwnProperty(u)||(u.indexOf("--")===0?r.setProperty(u,""):u==="float"?r.cssFloat="":r[u]="");for(var b in a)u=a[b],a.hasOwnProperty(b)&&l[b]!==u&&ps(r,b,u)}else for(var j in a)a.hasOwnProperty(j)&&ps(r,j,a[j])}function Os(r){if(r.indexOf("-")===-1)return!1;switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ua=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"]]),ne=/^[\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 K(r){return ne.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function le(){}var he=null;function Me(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Be=null,$e=null;function Ke(r){var a=xn(r);if(a&&(r=a.stateNode)){var l=r[Fe]||null;e:switch(r=a.stateNode,a.type){case"input":if(ns(r,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),a=l.name,l.type==="radio"&&a!=null){for(l=r;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Jn(""+a)+'"][type="radio"]'),a=0;a<l.length;a++){var u=l[a];if(u!==r&&u.form===r.form){var b=u[Fe]||null;if(!b)throw Error(i(90));ns(u,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name)}}for(a=0;a<l.length;a++)u=l[a],u.form===r.form&&Er(u)}break e;case"textarea":xs(r,l.value,l.defaultValue);break e;case"select":a=l.value,a!=null&&pr(r,!!l.multiple,a,!1)}}}var Se=!1;function et(r,a,l){if(Se)return r(a,l);Se=!0;try{var u=r(a);return u}finally{if(Se=!1,(Be!==null||$e!==null)&&(zc(),Be&&(a=Be,r=$e,$e=Be=null,Ke(a),r)))for(a=0;a<r.length;a++)Ke(r[a])}}function bt(r,a){var l=r.stateNode;if(l===null)return null;var u=l[Fe]||null;if(u===null)return null;l=u[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(r=r.type,u=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!u;break e;default:r=!1}if(r)return null;if(l&&typeof l!="function")throw Error(i(231,a,typeof l));return l}var Vt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rn=!1;if(Vt)try{var pn={};Object.defineProperty(pn,"passive",{get:function(){rn=!0}}),window.addEventListener("test",pn,pn),window.removeEventListener("test",pn,pn)}catch{rn=!1}var ct=null,ht=null,ut=null;function tt(){if(ut)return ut;var r,a=ht,l=a.length,u,b="value"in ct?ct.value:ct.textContent,j=b.length;for(r=0;r<l&&a[r]===b[r];r++);var H=l-r;for(u=1;u<=H&&a[l-u]===b[j-u];u++);return ut=b.slice(r,1<u?1-u:void 0)}function Qe(r){var a=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&a===13&&(r=13)):r=a,r===10&&(r=13),32<=r||r===13?r:0}function Ye(){return!0}function mt(){return!1}function Gt(r){function a(l,u,b,j,H){this._reactName=l,this._targetInst=b,this.type=u,this.nativeEvent=j,this.target=H,this.currentTarget=null;for(var J in r)r.hasOwnProperty(J)&&(l=r[J],this[J]=l?l(j):j[J]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?Ye:mt,this.isPropagationStopped=mt,this}return x(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=Ye)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Ye)},persist:function(){},isPersistent:Ye}),a}var Bn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},aa=Gt(Bn),qa=x({},Bn,{view:0,detail:0}),zN=Gt(qa),gu,bu,Nl,tc=x({},qa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vu,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Nl&&(Nl&&r.type==="mousemove"?(gu=r.screenX-Nl.screenX,bu=r.screenY-Nl.screenY):bu=gu=0,Nl=r),gu)},movementY:function(r){return"movementY"in r?r.movementY:bu}}),Bx=Gt(tc),$N=x({},tc,{dataTransfer:0}),BN=Gt($N),HN=x({},qa,{relatedTarget:0}),yu=Gt(HN),PN=x({},Bn,{animationName:0,elapsedTime:0,pseudoElement:0}),UN=Gt(PN),qN=x({},Bn,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),VN=Gt(qN),FN=x({},Bn,{data:0}),Hx=Gt(FN),YN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},GN={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"},XN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function KN(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=XN[r])?!!a[r]:!1}function vu(){return KN}var WN=x({},qa,{key:function(r){if(r.key){var a=YN[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=Qe(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?GN[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vu,charCode:function(r){return r.type==="keypress"?Qe(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Qe(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),ZN=Gt(WN),QN=x({},tc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Px=Gt(QN),JN=x({},qa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vu}),e5=Gt(JN),t5=x({},Bn,{propertyName:0,elapsedTime:0,pseudoElement:0}),n5=Gt(t5),r5=x({},tc,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),s5=Gt(r5),a5=x({},Bn,{newState:0,oldState:0}),i5=Gt(a5),l5=[9,13,27,32],ju=Vt&&"CompositionEvent"in window,kl=null;Vt&&"documentMode"in document&&(kl=document.documentMode);var o5=Vt&&"TextEvent"in window&&!kl,Ux=Vt&&(!ju||kl&&8<kl&&11>=kl),qx=" ",Vx=!1;function Fx(r,a){switch(r){case"keyup":return l5.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yx(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var wi=!1;function c5(r,a){switch(r){case"compositionend":return Yx(a);case"keypress":return a.which!==32?null:(Vx=!0,qx);case"textInput":return r=a.data,r===qx&&Vx?null:r;default:return null}}function d5(r,a){if(wi)return r==="compositionend"||!ju&&Fx(r,a)?(r=tt(),ut=ht=ct=null,wi=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Ux&&a.locale!=="ko"?null:a.data;default:return null}}var u5={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 Gx(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!u5[r.type]:a==="textarea"}function Xx(r,a,l,u){Be?$e?$e.push(u):$e=[u]:Be=u,a=Vc(a,"onChange"),0<a.length&&(l=new aa("onChange","change",null,l,u),r.push({event:l,listeners:a}))}var Sl=null,Cl=null;function f5(r){A0(r,0)}function nc(r){var a=Qn(r);if(Er(a))return r}function Kx(r,a){if(r==="change")return a}var Wx=!1;if(Vt){var wu;if(Vt){var Nu="oninput"in document;if(!Nu){var Zx=document.createElement("div");Zx.setAttribute("oninput","return;"),Nu=typeof Zx.oninput=="function"}wu=Nu}else wu=!1;Wx=wu&&(!document.documentMode||9<document.documentMode)}function Qx(){Sl&&(Sl.detachEvent("onpropertychange",Jx),Cl=Sl=null)}function Jx(r){if(r.propertyName==="value"&&nc(Cl)){var a=[];Xx(a,Cl,r,Me(r)),et(f5,a)}}function h5(r,a,l){r==="focusin"?(Qx(),Sl=a,Cl=l,Sl.attachEvent("onpropertychange",Jx)):r==="focusout"&&Qx()}function m5(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return nc(Cl)}function x5(r,a){if(r==="click")return nc(a)}function p5(r,a){if(r==="input"||r==="change")return nc(a)}function g5(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Ar=typeof Object.is=="function"?Object.is:g5;function El(r,a){if(Ar(r,a))return!0;if(typeof r!="object"||r===null||typeof a!="object"||a===null)return!1;var l=Object.keys(r),u=Object.keys(a);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var b=l[u];if(!st.call(a,b)||!Ar(r[b],a[b]))return!1}return!0}function ep(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function tp(r,a){var l=ep(r);r=0;for(var u;l;){if(l.nodeType===3){if(u=r+l.textContent.length,r<=a&&u>=a)return{node:l,offset:a-r};r=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=ep(l)}}function np(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?np(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function rp(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var a=Pr(r.document);a instanceof r.HTMLIFrameElement;){try{var l=typeof a.contentWindow.location.href=="string"}catch{l=!1}if(l)r=a.contentWindow;else break;a=Pr(r.document)}return a}function ku(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a&&(a==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||a==="textarea"||r.contentEditable==="true")}var b5=Vt&&"documentMode"in document&&11>=document.documentMode,Ni=null,Su=null,Tl=null,Cu=!1;function sp(r,a,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Cu||Ni==null||Ni!==Pr(u)||(u=Ni,"selectionStart"in u&&ku(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Tl&&El(Tl,u)||(Tl=u,u=Vc(Su,"onSelect"),0<u.length&&(a=new aa("onSelect","select",null,a,l),r.push({event:a,listeners:u}),a.target=Ni)))}function Va(r,a){var l={};return l[r.toLowerCase()]=a.toLowerCase(),l["Webkit"+r]="webkit"+a,l["Moz"+r]="moz"+a,l}var ki={animationend:Va("Animation","AnimationEnd"),animationiteration:Va("Animation","AnimationIteration"),animationstart:Va("Animation","AnimationStart"),transitionrun:Va("Transition","TransitionRun"),transitionstart:Va("Transition","TransitionStart"),transitioncancel:Va("Transition","TransitionCancel"),transitionend:Va("Transition","TransitionEnd")},Eu={},ap={};Vt&&(ap=document.createElement("div").style,"AnimationEvent"in window||(delete ki.animationend.animation,delete ki.animationiteration.animation,delete ki.animationstart.animation),"TransitionEvent"in window||delete ki.transitionend.transition);function Fa(r){if(Eu[r])return Eu[r];if(!ki[r])return r;var a=ki[r],l;for(l in a)if(a.hasOwnProperty(l)&&l in ap)return Eu[r]=a[l];return r}var ip=Fa("animationend"),lp=Fa("animationiteration"),op=Fa("animationstart"),y5=Fa("transitionrun"),v5=Fa("transitionstart"),j5=Fa("transitioncancel"),cp=Fa("transitionend"),dp=new Map,Tu="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(" ");Tu.push("scrollEnd");function ss(r,a){dp.set(r,a),de(a,[r])}var rc=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},qr=[],Si=0,_u=0;function sc(){for(var r=Si,a=_u=Si=0;a<r;){var l=qr[a];qr[a++]=null;var u=qr[a];qr[a++]=null;var b=qr[a];qr[a++]=null;var j=qr[a];if(qr[a++]=null,u!==null&&b!==null){var H=u.pending;H===null?b.next=b:(b.next=H.next,H.next=b),u.pending=b}j!==0&&up(l,b,j)}}function ac(r,a,l,u){qr[Si++]=r,qr[Si++]=a,qr[Si++]=l,qr[Si++]=u,_u|=u,r.lanes|=u,r=r.alternate,r!==null&&(r.lanes|=u)}function Au(r,a,l,u){return ac(r,a,l,u),ic(r)}function Ya(r,a){return ac(r,null,null,a),ic(r)}function up(r,a,l){r.lanes|=l;var u=r.alternate;u!==null&&(u.lanes|=l);for(var b=!1,j=r.return;j!==null;)j.childLanes|=l,u=j.alternate,u!==null&&(u.childLanes|=l),j.tag===22&&(r=j.stateNode,r===null||r._visibility&1||(b=!0)),r=j,j=j.return;return r.tag===3?(j=r.stateNode,b&&a!==null&&(b=31-Ct(l),r=j.hiddenUpdates,u=r[b],u===null?r[b]=[a]:u.push(a),a.lane=l|536870912),j):null}function ic(r){if(50<Wl)throw Wl=0,Hf=null,Error(i(185));for(var a=r.return;a!==null;)r=a,a=r.return;return r.tag===3?r.stateNode:null}var Ci={};function w5(r,a,l,u){this.tag=r,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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mr(r,a,l,u){return new w5(r,a,l,u)}function Mu(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Rs(r,a){var l=r.alternate;return l===null?(l=Mr(r.tag,a,r.key,r.mode),l.elementType=r.elementType,l.type=r.type,l.stateNode=r.stateNode,l.alternate=r,r.alternate=l):(l.pendingProps=a,l.type=r.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=r.flags&65011712,l.childLanes=r.childLanes,l.lanes=r.lanes,l.child=r.child,l.memoizedProps=r.memoizedProps,l.memoizedState=r.memoizedState,l.updateQueue=r.updateQueue,a=r.dependencies,l.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},l.sibling=r.sibling,l.index=r.index,l.ref=r.ref,l.refCleanup=r.refCleanup,l}function fp(r,a){r.flags&=65011714;var l=r.alternate;return l===null?(r.childLanes=0,r.lanes=a,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=l.childLanes,r.lanes=l.lanes,r.child=l.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=l.memoizedProps,r.memoizedState=l.memoizedState,r.updateQueue=l.updateQueue,r.type=l.type,a=l.dependencies,r.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),r}function lc(r,a,l,u,b,j){var H=0;if(u=r,typeof r=="function")Mu(r)&&(H=1);else if(typeof r=="string")H=E2(r,l,_.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case W:return r=Mr(31,l,a,b),r.elementType=W,r.lanes=j,r;case N:return Ga(l.children,b,j,a);case S:H=8,b|=24;break;case E:return r=Mr(12,l,a,b|2),r.elementType=E,r.lanes=j,r;case R:return r=Mr(13,l,a,b),r.elementType=R,r.lanes=j,r;case z:return r=Mr(19,l,a,b),r.elementType=z,r.lanes=j,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case k:H=10;break e;case C:H=9;break e;case T:H=11;break e;case U:H=14;break e;case G:H=16,u=null;break e}H=29,l=Error(i(130,r===null?"null":typeof r,"")),u=null}return a=Mr(H,l,a,b),a.elementType=r,a.type=u,a.lanes=j,a}function Ga(r,a,l,u){return r=Mr(7,r,u,a),r.lanes=l,r}function Ou(r,a,l){return r=Mr(6,r,null,a),r.lanes=l,r}function hp(r){var a=Mr(18,null,null,0);return a.stateNode=r,a}function Ru(r,a,l){return a=Mr(4,r.children!==null?r.children:[],r.key,a),a.lanes=l,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}var mp=new WeakMap;function Vr(r,a){if(typeof r=="object"&&r!==null){var l=mp.get(r);return l!==void 0?l:(a={value:r,source:a,stack:ot(a)},mp.set(r,a),a)}return{value:r,source:a,stack:ot(a)}}var Ei=[],Ti=0,oc=null,_l=0,Fr=[],Yr=0,ia=null,gs=1,bs="";function Ds(r,a){Ei[Ti++]=_l,Ei[Ti++]=oc,oc=r,_l=a}function xp(r,a,l){Fr[Yr++]=gs,Fr[Yr++]=bs,Fr[Yr++]=ia,ia=r;var u=gs;r=bs;var b=32-Ct(u)-1;u&=~(1<<b),l+=1;var j=32-Ct(a)+b;if(30<j){var H=b-b%5;j=(u&(1<<H)-1).toString(32),u>>=H,b-=H,gs=1<<32-Ct(a)+b|l<<b|u,bs=j+r}else gs=1<<j|l<<b|u,bs=r}function Du(r){r.return!==null&&(Ds(r,1),xp(r,1,0))}function Lu(r){for(;r===oc;)oc=Ei[--Ti],Ei[Ti]=null,_l=Ei[--Ti],Ei[Ti]=null;for(;r===ia;)ia=Fr[--Yr],Fr[Yr]=null,bs=Fr[--Yr],Fr[Yr]=null,gs=Fr[--Yr],Fr[Yr]=null}function pp(r,a){Fr[Yr++]=gs,Fr[Yr++]=bs,Fr[Yr++]=ia,gs=a.id,bs=a.overflow,ia=r}var rr=null,Sn=null,Xt=!1,la=null,Gr=!1,Iu=Error(i(519));function oa(r){var a=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Al(Vr(a,r)),Iu}function gp(r){var a=r.stateNode,l=r.type,u=r.memoizedProps;switch(a[Je]=r,a[Fe]=u,l){case"dialog":Ut("cancel",a),Ut("close",a);break;case"iframe":case"object":case"embed":Ut("load",a);break;case"video":case"audio":for(l=0;l<Ql.length;l++)Ut(Ql[l],a);break;case"source":Ut("error",a);break;case"img":case"image":case"link":Ut("error",a),Ut("load",a);break;case"details":Ut("toggle",a);break;case"input":Ut("invalid",a),Kn(a,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":Ut("invalid",a);break;case"textarea":Ut("invalid",a),_r(a,u.value,u.defaultValue,u.children)}l=u.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||a.textContent===""+l||u.suppressHydrationWarning===!0||D0(a.textContent,l)?(u.popover!=null&&(Ut("beforetoggle",a),Ut("toggle",a)),u.onScroll!=null&&Ut("scroll",a),u.onScrollEnd!=null&&Ut("scrollend",a),u.onClick!=null&&(a.onclick=le),a=!0):a=!1,a||oa(r,!0)}function bp(r){for(rr=r.return;rr;)switch(rr.tag){case 5:case 31:case 13:Gr=!1;return;case 27:case 3:Gr=!0;return;default:rr=rr.return}}function _i(r){if(r!==rr)return!1;if(!Xt)return bp(r),Xt=!0,!1;var a=r.tag,l;if((l=a!==3&&a!==27)&&((l=a===5)&&(l=r.type,l=!(l!=="form"&&l!=="button")||th(r.type,r.memoizedProps)),l=!l),l&&Sn&&oa(r),bp(r),a===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));Sn=q0(r)}else if(a===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));Sn=q0(r)}else a===27?(a=Sn,wa(r.type)?(r=ih,ih=null,Sn=r):Sn=a):Sn=rr?Kr(r.stateNode.nextSibling):null;return!0}function Xa(){Sn=rr=null,Xt=!1}function zu(){var r=la;return r!==null&&(vr===null?vr=r:vr.push.apply(vr,r),la=null),r}function Al(r){la===null?la=[r]:la.push(r)}var $u=q(null),Ka=null,Ls=null;function ca(r,a,l){I($u,a._currentValue),a._currentValue=l}function Is(r){r._currentValue=$u.current,X($u)}function Bu(r,a,l){for(;r!==null;){var u=r.alternate;if((r.childLanes&a)!==a?(r.childLanes|=a,u!==null&&(u.childLanes|=a)):u!==null&&(u.childLanes&a)!==a&&(u.childLanes|=a),r===l)break;r=r.return}}function Hu(r,a,l,u){var b=r.child;for(b!==null&&(b.return=r);b!==null;){var j=b.dependencies;if(j!==null){var H=b.child;j=j.firstContext;e:for(;j!==null;){var J=j;j=b;for(var ie=0;ie<a.length;ie++)if(J.context===a[ie]){j.lanes|=l,J=j.alternate,J!==null&&(J.lanes|=l),Bu(j.return,l,r),u||(H=null);break e}j=J.next}}else if(b.tag===18){if(H=b.return,H===null)throw Error(i(341));H.lanes|=l,j=H.alternate,j!==null&&(j.lanes|=l),Bu(H,l,r),H=null}else H=b.child;if(H!==null)H.return=b;else for(H=b;H!==null;){if(H===r){H=null;break}if(b=H.sibling,b!==null){b.return=H.return,H=b;break}H=H.return}b=H}}function Ai(r,a,l,u){r=null;for(var b=a,j=!1;b!==null;){if(!j){if((b.flags&524288)!==0)j=!0;else if((b.flags&262144)!==0)break}if(b.tag===10){var H=b.alternate;if(H===null)throw Error(i(387));if(H=H.memoizedProps,H!==null){var J=b.type;Ar(b.pendingProps.value,H.value)||(r!==null?r.push(J):r=[J])}}else if(b===ee.current){if(H=b.alternate,H===null)throw Error(i(387));H.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(r!==null?r.push(ro):r=[ro])}b=b.return}r!==null&&Hu(a,r,l,u),a.flags|=262144}function cc(r){for(r=r.firstContext;r!==null;){if(!Ar(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Wa(r){Ka=r,Ls=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function sr(r){return yp(Ka,r)}function dc(r,a){return Ka===null&&Wa(r),yp(r,a)}function yp(r,a){var l=a._currentValue;if(a={context:a,memoizedValue:l,next:null},Ls===null){if(r===null)throw Error(i(308));Ls=a,r.dependencies={lanes:0,firstContext:a},r.flags|=524288}else Ls=Ls.next=a;return l}var N5=typeof AbortController<"u"?AbortController:function(){var r=[],a=this.signal={aborted:!1,addEventListener:function(l,u){r.push(u)}};this.abort=function(){a.aborted=!0,r.forEach(function(l){return l()})}},k5=e.unstable_scheduleCallback,S5=e.unstable_NormalPriority,Hn={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Pu(){return{controller:new N5,data:new Map,refCount:0}}function Ml(r){r.refCount--,r.refCount===0&&k5(S5,function(){r.controller.abort()})}var Ol=null,Uu=0,Mi=0,Oi=null;function C5(r,a){if(Ol===null){var l=Ol=[];Uu=0,Mi=Yf(),Oi={status:"pending",value:void 0,then:function(u){l.push(u)}}}return Uu++,a.then(vp,vp),a}function vp(){if(--Uu===0&&Ol!==null){Oi!==null&&(Oi.status="fulfilled");var r=Ol;Ol=null,Mi=0,Oi=null;for(var a=0;a<r.length;a++)(0,r[a])()}}function E5(r,a){var l=[],u={status:"pending",value:null,reason:null,then:function(b){l.push(b)}};return r.then(function(){u.status="fulfilled",u.value=a;for(var b=0;b<l.length;b++)(0,l[b])(a)},function(b){for(u.status="rejected",u.reason=b,b=0;b<l.length;b++)(0,l[b])(void 0)}),u}var jp=A.S;A.S=function(r,a){s0=yt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&C5(r,a),jp!==null&&jp(r,a)};var Za=q(null);function qu(){var r=Za.current;return r!==null?r:vn.pooledCache}function uc(r,a){a===null?I(Za,Za.current):I(Za,a.pool)}function wp(){var r=qu();return r===null?null:{parent:Hn._currentValue,pool:r}}var Ri=Error(i(460)),Vu=Error(i(474)),fc=Error(i(542)),hc={then:function(){}};function Np(r){return r=r.status,r==="fulfilled"||r==="rejected"}function kp(r,a,l){switch(l=r[l],l===void 0?r.push(a):l!==a&&(a.then(le,le),a=l),a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Cp(r),r;default:if(typeof a.status=="string")a.then(le,le);else{if(r=vn,r!==null&&100<r.shellSuspendCounter)throw Error(i(482));r=a,r.status="pending",r.then(function(u){if(a.status==="pending"){var b=a;b.status="fulfilled",b.value=u}},function(u){if(a.status==="pending"){var b=a;b.status="rejected",b.reason=u}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Cp(r),r}throw Ja=a,Ri}}function Qa(r){try{var a=r._init;return a(r._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Ja=l,Ri):l}}var Ja=null;function Sp(){if(Ja===null)throw Error(i(459));var r=Ja;return Ja=null,r}function Cp(r){if(r===Ri||r===fc)throw Error(i(483))}var Di=null,Rl=0;function mc(r){var a=Rl;return Rl+=1,Di===null&&(Di=[]),kp(Di,r,a)}function Dl(r,a){a=a.props.ref,r.ref=a!==void 0?a:null}function xc(r,a){throw a.$$typeof===g?Error(i(525)):(r=Object.prototype.toString.call(a),Error(i(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r)))}function Ep(r){function a(ue,ce){if(r){var pe=ue.deletions;pe===null?(ue.deletions=[ce],ue.flags|=16):pe.push(ce)}}function l(ue,ce){if(!r)return null;for(;ce!==null;)a(ue,ce),ce=ce.sibling;return null}function u(ue){for(var ce=new Map;ue!==null;)ue.key!==null?ce.set(ue.key,ue):ce.set(ue.index,ue),ue=ue.sibling;return ce}function b(ue,ce){return ue=Rs(ue,ce),ue.index=0,ue.sibling=null,ue}function j(ue,ce,pe){return ue.index=pe,r?(pe=ue.alternate,pe!==null?(pe=pe.index,pe<ce?(ue.flags|=67108866,ce):pe):(ue.flags|=67108866,ce)):(ue.flags|=1048576,ce)}function H(ue){return r&&ue.alternate===null&&(ue.flags|=67108866),ue}function J(ue,ce,pe,Oe){return ce===null||ce.tag!==6?(ce=Ou(pe,ue.mode,Oe),ce.return=ue,ce):(ce=b(ce,pe),ce.return=ue,ce)}function ie(ue,ce,pe,Oe){var gt=pe.type;return gt===N?_e(ue,ce,pe.props.children,Oe,pe.key):ce!==null&&(ce.elementType===gt||typeof gt=="object"&&gt!==null&&gt.$$typeof===G&&Qa(gt)===ce.type)?(ce=b(ce,pe.props),Dl(ce,pe),ce.return=ue,ce):(ce=lc(pe.type,pe.key,pe.props,null,ue.mode,Oe),Dl(ce,pe),ce.return=ue,ce)}function ge(ue,ce,pe,Oe){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==pe.containerInfo||ce.stateNode.implementation!==pe.implementation?(ce=Ru(pe,ue.mode,Oe),ce.return=ue,ce):(ce=b(ce,pe.children||[]),ce.return=ue,ce)}function _e(ue,ce,pe,Oe,gt){return ce===null||ce.tag!==7?(ce=Ga(pe,ue.mode,Oe,gt),ce.return=ue,ce):(ce=b(ce,pe),ce.return=ue,ce)}function De(ue,ce,pe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=Ou(""+ce,ue.mode,pe),ce.return=ue,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case y:return pe=lc(ce.type,ce.key,ce.props,null,ue.mode,pe),Dl(pe,ce),pe.return=ue,pe;case w:return ce=Ru(ce,ue.mode,pe),ce.return=ue,ce;case G:return ce=Qa(ce),De(ue,ce,pe)}if(L(ce)||Y(ce))return ce=Ga(ce,ue.mode,pe,null),ce.return=ue,ce;if(typeof ce.then=="function")return De(ue,mc(ce),pe);if(ce.$$typeof===k)return De(ue,dc(ue,ce),pe);xc(ue,ce)}return null}function be(ue,ce,pe,Oe){var gt=ce!==null?ce.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return gt!==null?null:J(ue,ce,""+pe,Oe);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case y:return pe.key===gt?ie(ue,ce,pe,Oe):null;case w:return pe.key===gt?ge(ue,ce,pe,Oe):null;case G:return pe=Qa(pe),be(ue,ce,pe,Oe)}if(L(pe)||Y(pe))return gt!==null?null:_e(ue,ce,pe,Oe,null);if(typeof pe.then=="function")return be(ue,ce,mc(pe),Oe);if(pe.$$typeof===k)return be(ue,ce,dc(ue,pe),Oe);xc(ue,pe)}return null}function ke(ue,ce,pe,Oe,gt){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number"||typeof Oe=="bigint")return ue=ue.get(pe)||null,J(ce,ue,""+Oe,gt);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case y:return ue=ue.get(Oe.key===null?pe:Oe.key)||null,ie(ce,ue,Oe,gt);case w:return ue=ue.get(Oe.key===null?pe:Oe.key)||null,ge(ce,ue,Oe,gt);case G:return Oe=Qa(Oe),ke(ue,ce,pe,Oe,gt)}if(L(Oe)||Y(Oe))return ue=ue.get(pe)||null,_e(ce,ue,Oe,gt,null);if(typeof Oe.then=="function")return ke(ue,ce,pe,mc(Oe),gt);if(Oe.$$typeof===k)return ke(ue,ce,pe,dc(ce,Oe),gt);xc(ce,Oe)}return null}function nt(ue,ce,pe,Oe){for(var gt=null,Qt=null,lt=ce,Lt=ce=0,Yt=null;lt!==null&&Lt<pe.length;Lt++){lt.index>Lt?(Yt=lt,lt=null):Yt=lt.sibling;var Jt=be(ue,lt,pe[Lt],Oe);if(Jt===null){lt===null&&(lt=Yt);break}r&&lt&&Jt.alternate===null&&a(ue,lt),ce=j(Jt,ce,Lt),Qt===null?gt=Jt:Qt.sibling=Jt,Qt=Jt,lt=Yt}if(Lt===pe.length)return l(ue,lt),Xt&&Ds(ue,Lt),gt;if(lt===null){for(;Lt<pe.length;Lt++)lt=De(ue,pe[Lt],Oe),lt!==null&&(ce=j(lt,ce,Lt),Qt===null?gt=lt:Qt.sibling=lt,Qt=lt);return Xt&&Ds(ue,Lt),gt}for(lt=u(lt);Lt<pe.length;Lt++)Yt=ke(lt,ue,Lt,pe[Lt],Oe),Yt!==null&&(r&&Yt.alternate!==null&&lt.delete(Yt.key===null?Lt:Yt.key),ce=j(Yt,ce,Lt),Qt===null?gt=Yt:Qt.sibling=Yt,Qt=Yt);return r&&lt.forEach(function(Ea){return a(ue,Ea)}),Xt&&Ds(ue,Lt),gt}function kt(ue,ce,pe,Oe){if(pe==null)throw Error(i(151));for(var gt=null,Qt=null,lt=ce,Lt=ce=0,Yt=null,Jt=pe.next();lt!==null&&!Jt.done;Lt++,Jt=pe.next()){lt.index>Lt?(Yt=lt,lt=null):Yt=lt.sibling;var Ea=be(ue,lt,Jt.value,Oe);if(Ea===null){lt===null&&(lt=Yt);break}r&&lt&&Ea.alternate===null&&a(ue,lt),ce=j(Ea,ce,Lt),Qt===null?gt=Ea:Qt.sibling=Ea,Qt=Ea,lt=Yt}if(Jt.done)return l(ue,lt),Xt&&Ds(ue,Lt),gt;if(lt===null){for(;!Jt.done;Lt++,Jt=pe.next())Jt=De(ue,Jt.value,Oe),Jt!==null&&(ce=j(Jt,ce,Lt),Qt===null?gt=Jt:Qt.sibling=Jt,Qt=Jt);return Xt&&Ds(ue,Lt),gt}for(lt=u(lt);!Jt.done;Lt++,Jt=pe.next())Jt=ke(lt,ue,Lt,Jt.value,Oe),Jt!==null&&(r&&Jt.alternate!==null&&lt.delete(Jt.key===null?Lt:Jt.key),ce=j(Jt,ce,Lt),Qt===null?gt=Jt:Qt.sibling=Jt,Qt=Jt);return r&&lt.forEach(function($2){return a(ue,$2)}),Xt&&Ds(ue,Lt),gt}function yn(ue,ce,pe,Oe){if(typeof pe=="object"&&pe!==null&&pe.type===N&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case y:e:{for(var gt=pe.key;ce!==null;){if(ce.key===gt){if(gt=pe.type,gt===N){if(ce.tag===7){l(ue,ce.sibling),Oe=b(ce,pe.props.children),Oe.return=ue,ue=Oe;break e}}else if(ce.elementType===gt||typeof gt=="object"&&gt!==null&&gt.$$typeof===G&&Qa(gt)===ce.type){l(ue,ce.sibling),Oe=b(ce,pe.props),Dl(Oe,pe),Oe.return=ue,ue=Oe;break e}l(ue,ce);break}else a(ue,ce);ce=ce.sibling}pe.type===N?(Oe=Ga(pe.props.children,ue.mode,Oe,pe.key),Oe.return=ue,ue=Oe):(Oe=lc(pe.type,pe.key,pe.props,null,ue.mode,Oe),Dl(Oe,pe),Oe.return=ue,ue=Oe)}return H(ue);case w:e:{for(gt=pe.key;ce!==null;){if(ce.key===gt)if(ce.tag===4&&ce.stateNode.containerInfo===pe.containerInfo&&ce.stateNode.implementation===pe.implementation){l(ue,ce.sibling),Oe=b(ce,pe.children||[]),Oe.return=ue,ue=Oe;break e}else{l(ue,ce);break}else a(ue,ce);ce=ce.sibling}Oe=Ru(pe,ue.mode,Oe),Oe.return=ue,ue=Oe}return H(ue);case G:return pe=Qa(pe),yn(ue,ce,pe,Oe)}if(L(pe))return nt(ue,ce,pe,Oe);if(Y(pe)){if(gt=Y(pe),typeof gt!="function")throw Error(i(150));return pe=gt.call(pe),kt(ue,ce,pe,Oe)}if(typeof pe.then=="function")return yn(ue,ce,mc(pe),Oe);if(pe.$$typeof===k)return yn(ue,ce,dc(ue,pe),Oe);xc(ue,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint"?(pe=""+pe,ce!==null&&ce.tag===6?(l(ue,ce.sibling),Oe=b(ce,pe),Oe.return=ue,ue=Oe):(l(ue,ce),Oe=Ou(pe,ue.mode,Oe),Oe.return=ue,ue=Oe),H(ue)):l(ue,ce)}return function(ue,ce,pe,Oe){try{Rl=0;var gt=yn(ue,ce,pe,Oe);return Di=null,gt}catch(lt){if(lt===Ri||lt===fc)throw lt;var Qt=Mr(29,lt,null,ue.mode);return Qt.lanes=Oe,Qt.return=ue,Qt}}}var ei=Ep(!0),Tp=Ep(!1),da=!1;function Fu(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Yu(r,a){r=r.updateQueue,a.updateQueue===r&&(a.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function ua(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function fa(r,a,l){var u=r.updateQueue;if(u===null)return null;if(u=u.shared,(sn&2)!==0){var b=u.pending;return b===null?a.next=a:(a.next=b.next,b.next=a),u.pending=a,a=ic(r),up(r,null,l),a}return ac(r,u,a,l),ic(r)}function Ll(r,a,l){if(a=a.updateQueue,a!==null&&(a=a.shared,(l&4194048)!==0)){var u=a.lanes;u&=r.pendingLanes,l|=u,a.lanes=l,oe(r,l)}}function Gu(r,a){var l=r.updateQueue,u=r.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var b=null,j=null;if(l=l.firstBaseUpdate,l!==null){do{var H={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};j===null?b=j=H:j=j.next=H,l=l.next}while(l!==null);j===null?b=j=a:j=j.next=a}else b=j=a;l={baseState:u.baseState,firstBaseUpdate:b,lastBaseUpdate:j,shared:u.shared,callbacks:u.callbacks},r.updateQueue=l;return}r=l.lastBaseUpdate,r===null?l.firstBaseUpdate=a:r.next=a,l.lastBaseUpdate=a}var Xu=!1;function Il(){if(Xu){var r=Oi;if(r!==null)throw r}}function zl(r,a,l,u){Xu=!1;var b=r.updateQueue;da=!1;var j=b.firstBaseUpdate,H=b.lastBaseUpdate,J=b.shared.pending;if(J!==null){b.shared.pending=null;var ie=J,ge=ie.next;ie.next=null,H===null?j=ge:H.next=ge,H=ie;var _e=r.alternate;_e!==null&&(_e=_e.updateQueue,J=_e.lastBaseUpdate,J!==H&&(J===null?_e.firstBaseUpdate=ge:J.next=ge,_e.lastBaseUpdate=ie))}if(j!==null){var De=b.baseState;H=0,_e=ge=ie=null,J=j;do{var be=J.lane&-536870913,ke=be!==J.lane;if(ke?(Ft&be)===be:(u&be)===be){be!==0&&be===Mi&&(Xu=!0),_e!==null&&(_e=_e.next={lane:0,tag:J.tag,payload:J.payload,callback:null,next:null});e:{var nt=r,kt=J;be=a;var yn=l;switch(kt.tag){case 1:if(nt=kt.payload,typeof nt=="function"){De=nt.call(yn,De,be);break e}De=nt;break e;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=kt.payload,be=typeof nt=="function"?nt.call(yn,De,be):nt,be==null)break e;De=x({},De,be);break e;case 2:da=!0}}be=J.callback,be!==null&&(r.flags|=64,ke&&(r.flags|=8192),ke=b.callbacks,ke===null?b.callbacks=[be]:ke.push(be))}else ke={lane:be,tag:J.tag,payload:J.payload,callback:J.callback,next:null},_e===null?(ge=_e=ke,ie=De):_e=_e.next=ke,H|=be;if(J=J.next,J===null){if(J=b.shared.pending,J===null)break;ke=J,J=ke.next,ke.next=null,b.lastBaseUpdate=ke,b.shared.pending=null}}while(!0);_e===null&&(ie=De),b.baseState=ie,b.firstBaseUpdate=ge,b.lastBaseUpdate=_e,j===null&&(b.shared.lanes=0),ga|=H,r.lanes=H,r.memoizedState=De}}function _p(r,a){if(typeof r!="function")throw Error(i(191,r));r.call(a)}function Ap(r,a){var l=r.callbacks;if(l!==null)for(r.callbacks=null,r=0;r<l.length;r++)_p(l[r],a)}var Li=q(null),pc=q(0);function Mp(r,a){r=Fs,I(pc,r),I(Li,a),Fs=r|a.baseLanes}function Ku(){I(pc,Fs),I(Li,Li.current)}function Wu(){Fs=pc.current,X(Li),X(pc)}var Or=q(null),Xr=null;function ha(r){var a=r.alternate;I(In,In.current&1),I(Or,r),Xr===null&&(a===null||Li.current!==null||a.memoizedState!==null)&&(Xr=r)}function Zu(r){I(In,In.current),I(Or,r),Xr===null&&(Xr=r)}function Op(r){r.tag===22?(I(In,In.current),I(Or,r),Xr===null&&(Xr=r)):ma()}function ma(){I(In,In.current),I(Or,Or.current)}function Rr(r){X(Or),Xr===r&&(Xr=null),X(In)}var In=q(0);function gc(r){for(var a=r;a!==null;){if(a.tag===13){var l=a.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||sh(l)||ah(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===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var zs=0,Rt=null,gn=null,Pn=null,bc=!1,Ii=!1,ti=!1,yc=0,$l=0,zi=null,T5=0;function Dn(){throw Error(i(321))}function Qu(r,a){if(a===null)return!1;for(var l=0;l<a.length&&l<r.length;l++)if(!Ar(r[l],a[l]))return!1;return!0}function Ju(r,a,l,u,b,j){return zs=j,Rt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,A.H=r===null||r.memoizedState===null?xg:xf,ti=!1,j=l(u,b),ti=!1,Ii&&(j=Dp(a,l,u,b)),Rp(r),j}function Rp(r){A.H=Pl;var a=gn!==null&&gn.next!==null;if(zs=0,Pn=gn=Rt=null,bc=!1,$l=0,zi=null,a)throw Error(i(300));r===null||Un||(r=r.dependencies,r!==null&&cc(r)&&(Un=!0))}function Dp(r,a,l,u){Rt=r;var b=0;do{if(Ii&&(zi=null),$l=0,Ii=!1,25<=b)throw Error(i(301));if(b+=1,Pn=gn=null,r.updateQueue!=null){var j=r.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}A.H=pg,j=a(l,u)}while(Ii);return j}function _5(){var r=A.H,a=r.useState()[0];return a=typeof a.then=="function"?Bl(a):a,r=r.useState()[0],(gn!==null?gn.memoizedState:null)!==r&&(Rt.flags|=1024),a}function ef(){var r=yc!==0;return yc=0,r}function tf(r,a,l){a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~l}function nf(r){if(bc){for(r=r.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}bc=!1}zs=0,Pn=gn=Rt=null,Ii=!1,$l=yc=0,zi=null}function hr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pn===null?Rt.memoizedState=Pn=r:Pn=Pn.next=r,Pn}function zn(){if(gn===null){var r=Rt.alternate;r=r!==null?r.memoizedState:null}else r=gn.next;var a=Pn===null?Rt.memoizedState:Pn.next;if(a!==null)Pn=a,gn=r;else{if(r===null)throw Rt.alternate===null?Error(i(467)):Error(i(310));gn=r,r={memoizedState:gn.memoizedState,baseState:gn.baseState,baseQueue:gn.baseQueue,queue:gn.queue,next:null},Pn===null?Rt.memoizedState=Pn=r:Pn=Pn.next=r}return Pn}function vc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bl(r){var a=$l;return $l+=1,zi===null&&(zi=[]),r=kp(zi,r,a),a=Rt,(Pn===null?a.memoizedState:Pn.next)===null&&(a=a.alternate,A.H=a===null||a.memoizedState===null?xg:xf),r}function jc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Bl(r);if(r.$$typeof===k)return sr(r)}throw Error(i(438,String(r)))}function rf(r){var a=null,l=Rt.updateQueue;if(l!==null&&(a=l.memoCache),a==null){var u=Rt.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(a={data:u.data.map(function(b){return b.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),l===null&&(l=vc(),Rt.updateQueue=l),l.memoCache=a,l=a.data[a.index],l===void 0)for(l=a.data[a.index]=Array(r),u=0;u<r;u++)l[u]=$;return a.index++,l}function $s(r,a){return typeof a=="function"?a(r):a}function wc(r){var a=zn();return sf(a,gn,r)}function sf(r,a,l){var u=r.queue;if(u===null)throw Error(i(311));u.lastRenderedReducer=l;var b=r.baseQueue,j=u.pending;if(j!==null){if(b!==null){var H=b.next;b.next=j.next,j.next=H}a.baseQueue=b=j,u.pending=null}if(j=r.baseState,b===null)r.memoizedState=j;else{a=b.next;var J=H=null,ie=null,ge=a,_e=!1;do{var De=ge.lane&-536870913;if(De!==ge.lane?(Ft&De)===De:(zs&De)===De){var be=ge.revertLane;if(be===0)ie!==null&&(ie=ie.next={lane:0,revertLane:0,gesture:null,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null}),De===Mi&&(_e=!0);else if((zs&be)===be){ge=ge.next,be===Mi&&(_e=!0);continue}else De={lane:0,revertLane:ge.revertLane,gesture:null,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null},ie===null?(J=ie=De,H=j):ie=ie.next=De,Rt.lanes|=be,ga|=be;De=ge.action,ti&&l(j,De),j=ge.hasEagerState?ge.eagerState:l(j,De)}else be={lane:De,revertLane:ge.revertLane,gesture:ge.gesture,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null},ie===null?(J=ie=be,H=j):ie=ie.next=be,Rt.lanes|=De,ga|=De;ge=ge.next}while(ge!==null&&ge!==a);if(ie===null?H=j:ie.next=J,!Ar(j,r.memoizedState)&&(Un=!0,_e&&(l=Oi,l!==null)))throw l;r.memoizedState=j,r.baseState=H,r.baseQueue=ie,u.lastRenderedState=j}return b===null&&(u.lanes=0),[r.memoizedState,u.dispatch]}function af(r){var a=zn(),l=a.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=r;var u=l.dispatch,b=l.pending,j=a.memoizedState;if(b!==null){l.pending=null;var H=b=b.next;do j=r(j,H.action),H=H.next;while(H!==b);Ar(j,a.memoizedState)||(Un=!0),a.memoizedState=j,a.baseQueue===null&&(a.baseState=j),l.lastRenderedState=j}return[j,u]}function Lp(r,a,l){var u=Rt,b=zn(),j=Xt;if(j){if(l===void 0)throw Error(i(407));l=l()}else l=a();var H=!Ar((gn||b).memoizedState,l);if(H&&(b.memoizedState=l,Un=!0),b=b.queue,cf($p.bind(null,u,b,r),[r]),b.getSnapshot!==a||H||Pn!==null&&Pn.memoizedState.tag&1){if(u.flags|=2048,$i(9,{destroy:void 0},zp.bind(null,u,b,l,a),null),vn===null)throw Error(i(349));j||(zs&127)!==0||Ip(u,a,l)}return l}function Ip(r,a,l){r.flags|=16384,r={getSnapshot:a,value:l},a=Rt.updateQueue,a===null?(a=vc(),Rt.updateQueue=a,a.stores=[r]):(l=a.stores,l===null?a.stores=[r]:l.push(r))}function zp(r,a,l,u){a.value=l,a.getSnapshot=u,Bp(a)&&Hp(r)}function $p(r,a,l){return l(function(){Bp(a)&&Hp(r)})}function Bp(r){var a=r.getSnapshot;r=r.value;try{var l=a();return!Ar(r,l)}catch{return!0}}function Hp(r){var a=Ya(r,2);a!==null&&jr(a,r,2)}function lf(r){var a=hr();if(typeof r=="function"){var l=r;if(r=l(),ti){_t(!0);try{l()}finally{_t(!1)}}}return a.memoizedState=a.baseState=r,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:$s,lastRenderedState:r},a}function Pp(r,a,l,u){return r.baseState=l,sf(r,gn,typeof u=="function"?u:$s)}function A5(r,a,l,u,b){if(Sc(r))throw Error(i(485));if(r=a.action,r!==null){var j={payload:b,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(H){j.listeners.push(H)}};A.T!==null?l(!0):j.isTransition=!1,u(j),l=a.pending,l===null?(j.next=a.pending=j,Up(a,j)):(j.next=l.next,a.pending=l.next=j)}}function Up(r,a){var l=a.action,u=a.payload,b=r.state;if(a.isTransition){var j=A.T,H={};A.T=H;try{var J=l(b,u),ie=A.S;ie!==null&&ie(H,J),qp(r,a,J)}catch(ge){of(r,a,ge)}finally{j!==null&&H.types!==null&&(j.types=H.types),A.T=j}}else try{j=l(b,u),qp(r,a,j)}catch(ge){of(r,a,ge)}}function qp(r,a,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(u){Vp(r,a,u)},function(u){return of(r,a,u)}):Vp(r,a,l)}function Vp(r,a,l){a.status="fulfilled",a.value=l,Fp(a),r.state=l,a=r.pending,a!==null&&(l=a.next,l===a?r.pending=null:(l=l.next,a.next=l,Up(r,l)))}function of(r,a,l){var u=r.pending;if(r.pending=null,u!==null){u=u.next;do a.status="rejected",a.reason=l,Fp(a),a=a.next;while(a!==u)}r.action=null}function Fp(r){r=r.listeners;for(var a=0;a<r.length;a++)(0,r[a])()}function Yp(r,a){return a}function Gp(r,a){if(Xt){var l=vn.formState;if(l!==null){e:{var u=Rt;if(Xt){if(Sn){t:{for(var b=Sn,j=Gr;b.nodeType!==8;){if(!j){b=null;break t}if(b=Kr(b.nextSibling),b===null){b=null;break t}}j=b.data,b=j==="F!"||j==="F"?b:null}if(b){Sn=Kr(b.nextSibling),u=b.data==="F!";break e}}oa(u)}u=!1}u&&(a=l[0])}}return l=hr(),l.memoizedState=l.baseState=a,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yp,lastRenderedState:a},l.queue=u,l=fg.bind(null,Rt,u),u.dispatch=l,u=lf(!1),j=mf.bind(null,Rt,!1,u.queue),u=hr(),b={state:a,dispatch:null,action:r,pending:null},u.queue=b,l=A5.bind(null,Rt,b,j,l),b.dispatch=l,u.memoizedState=r,[a,l,!1]}function Xp(r){var a=zn();return Kp(a,gn,r)}function Kp(r,a,l){if(a=sf(r,a,Yp)[0],r=wc($s)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var u=Bl(a)}catch(H){throw H===Ri?fc:H}else u=a;a=zn();var b=a.queue,j=b.dispatch;return l!==a.memoizedState&&(Rt.flags|=2048,$i(9,{destroy:void 0},M5.bind(null,b,l),null)),[u,j,r]}function M5(r,a){r.action=a}function Wp(r){var a=zn(),l=gn;if(l!==null)return Kp(a,l,r);zn(),a=a.memoizedState,l=zn();var u=l.queue.dispatch;return l.memoizedState=r,[a,u,!1]}function $i(r,a,l,u){return r={tag:r,create:l,deps:u,inst:a,next:null},a=Rt.updateQueue,a===null&&(a=vc(),Rt.updateQueue=a),l=a.lastEffect,l===null?a.lastEffect=r.next=r:(u=l.next,l.next=r,r.next=u,a.lastEffect=r),r}function Zp(){return zn().memoizedState}function Nc(r,a,l,u){var b=hr();Rt.flags|=r,b.memoizedState=$i(1|a,{destroy:void 0},l,u===void 0?null:u)}function kc(r,a,l,u){var b=zn();u=u===void 0?null:u;var j=b.memoizedState.inst;gn!==null&&u!==null&&Qu(u,gn.memoizedState.deps)?b.memoizedState=$i(a,j,l,u):(Rt.flags|=r,b.memoizedState=$i(1|a,j,l,u))}function Qp(r,a){Nc(8390656,8,r,a)}function cf(r,a){kc(2048,8,r,a)}function O5(r){Rt.flags|=4;var a=Rt.updateQueue;if(a===null)a=vc(),Rt.updateQueue=a,a.events=[r];else{var l=a.events;l===null?a.events=[r]:l.push(r)}}function Jp(r){var a=zn().memoizedState;return O5({ref:a,nextImpl:r}),function(){if((sn&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}function eg(r,a){return kc(4,2,r,a)}function tg(r,a){return kc(4,4,r,a)}function ng(r,a){if(typeof a=="function"){r=r();var l=a(r);return function(){typeof l=="function"?l():a(null)}}if(a!=null)return r=r(),a.current=r,function(){a.current=null}}function rg(r,a,l){l=l!=null?l.concat([r]):null,kc(4,4,ng.bind(null,a,r),l)}function df(){}function sg(r,a){var l=zn();a=a===void 0?null:a;var u=l.memoizedState;return a!==null&&Qu(a,u[1])?u[0]:(l.memoizedState=[r,a],r)}function ag(r,a){var l=zn();a=a===void 0?null:a;var u=l.memoizedState;if(a!==null&&Qu(a,u[1]))return u[0];if(u=r(),ti){_t(!0);try{r()}finally{_t(!1)}}return l.memoizedState=[u,a],u}function uf(r,a,l){return l===void 0||(zs&1073741824)!==0&&(Ft&261930)===0?r.memoizedState=a:(r.memoizedState=l,r=i0(),Rt.lanes|=r,ga|=r,l)}function ig(r,a,l,u){return Ar(l,a)?l:Li.current!==null?(r=uf(r,l,u),Ar(r,a)||(Un=!0),r):(zs&42)===0||(zs&1073741824)!==0&&(Ft&261930)===0?(Un=!0,r.memoizedState=l):(r=i0(),Rt.lanes|=r,ga|=r,a)}function lg(r,a,l,u,b){var j=O.p;O.p=j!==0&&8>j?j:8;var H=A.T,J={};A.T=J,mf(r,!1,a,l);try{var ie=b(),ge=A.S;if(ge!==null&&ge(J,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var _e=E5(ie,u);Hl(r,a,_e,Ir(r))}else Hl(r,a,u,Ir(r))}catch(De){Hl(r,a,{then:function(){},status:"rejected",reason:De},Ir())}finally{O.p=j,H!==null&&J.types!==null&&(H.types=J.types),A.T=H}}function R5(){}function ff(r,a,l,u){if(r.tag!==5)throw Error(i(476));var b=og(r).queue;lg(r,b,a,D,l===null?R5:function(){return cg(r),l(u)})}function og(r){var a=r.memoizedState;if(a!==null)return a;a={memoizedState:D,baseState:D,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$s,lastRenderedState:D},next:null};var l={};return a.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$s,lastRenderedState:l},next:null},r.memoizedState=a,r=r.alternate,r!==null&&(r.memoizedState=a),a}function cg(r){var a=og(r);a.next===null&&(a=r.alternate.memoizedState),Hl(r,a.next.queue,{},Ir())}function hf(){return sr(ro)}function dg(){return zn().memoizedState}function ug(){return zn().memoizedState}function D5(r){for(var a=r.return;a!==null;){switch(a.tag){case 24:case 3:var l=Ir();r=ua(l);var u=fa(a,r,l);u!==null&&(jr(u,a,l),Ll(u,a,l)),a={cache:Pu()},r.payload=a;return}a=a.return}}function L5(r,a,l){var u=Ir();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Sc(r)?hg(a,l):(l=Au(r,a,l,u),l!==null&&(jr(l,r,u),mg(l,a,u)))}function fg(r,a,l){var u=Ir();Hl(r,a,l,u)}function Hl(r,a,l,u){var b={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Sc(r))hg(a,b);else{var j=r.alternate;if(r.lanes===0&&(j===null||j.lanes===0)&&(j=a.lastRenderedReducer,j!==null))try{var H=a.lastRenderedState,J=j(H,l);if(b.hasEagerState=!0,b.eagerState=J,Ar(J,H))return ac(r,a,b,0),vn===null&&sc(),!1}catch{}if(l=Au(r,a,b,u),l!==null)return jr(l,r,u),mg(l,a,u),!0}return!1}function mf(r,a,l,u){if(u={lane:2,revertLane:Yf(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Sc(r)){if(a)throw Error(i(479))}else a=Au(r,l,u,2),a!==null&&jr(a,r,2)}function Sc(r){var a=r.alternate;return r===Rt||a!==null&&a===Rt}function hg(r,a){Ii=bc=!0;var l=r.pending;l===null?a.next=a:(a.next=l.next,l.next=a),r.pending=a}function mg(r,a,l){if((l&4194048)!==0){var u=a.lanes;u&=r.pendingLanes,l|=u,a.lanes=l,oe(r,l)}}var Pl={readContext:sr,use:jc,useCallback:Dn,useContext:Dn,useEffect:Dn,useImperativeHandle:Dn,useLayoutEffect:Dn,useInsertionEffect:Dn,useMemo:Dn,useReducer:Dn,useRef:Dn,useState:Dn,useDebugValue:Dn,useDeferredValue:Dn,useTransition:Dn,useSyncExternalStore:Dn,useId:Dn,useHostTransitionStatus:Dn,useFormState:Dn,useActionState:Dn,useOptimistic:Dn,useMemoCache:Dn,useCacheRefresh:Dn};Pl.useEffectEvent=Dn;var xg={readContext:sr,use:jc,useCallback:function(r,a){return hr().memoizedState=[r,a===void 0?null:a],r},useContext:sr,useEffect:Qp,useImperativeHandle:function(r,a,l){l=l!=null?l.concat([r]):null,Nc(4194308,4,ng.bind(null,a,r),l)},useLayoutEffect:function(r,a){return Nc(4194308,4,r,a)},useInsertionEffect:function(r,a){Nc(4,2,r,a)},useMemo:function(r,a){var l=hr();a=a===void 0?null:a;var u=r();if(ti){_t(!0);try{r()}finally{_t(!1)}}return l.memoizedState=[u,a],u},useReducer:function(r,a,l){var u=hr();if(l!==void 0){var b=l(a);if(ti){_t(!0);try{l(a)}finally{_t(!1)}}}else b=a;return u.memoizedState=u.baseState=b,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:b},u.queue=r,r=r.dispatch=L5.bind(null,Rt,r),[u.memoizedState,r]},useRef:function(r){var a=hr();return r={current:r},a.memoizedState=r},useState:function(r){r=lf(r);var a=r.queue,l=fg.bind(null,Rt,a);return a.dispatch=l,[r.memoizedState,l]},useDebugValue:df,useDeferredValue:function(r,a){var l=hr();return uf(l,r,a)},useTransition:function(){var r=lf(!1);return r=lg.bind(null,Rt,r.queue,!0,!1),hr().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,a,l){var u=Rt,b=hr();if(Xt){if(l===void 0)throw Error(i(407));l=l()}else{if(l=a(),vn===null)throw Error(i(349));(Ft&127)!==0||Ip(u,a,l)}b.memoizedState=l;var j={value:l,getSnapshot:a};return b.queue=j,Qp($p.bind(null,u,j,r),[r]),u.flags|=2048,$i(9,{destroy:void 0},zp.bind(null,u,j,l,a),null),l},useId:function(){var r=hr(),a=vn.identifierPrefix;if(Xt){var l=bs,u=gs;l=(u&~(1<<32-Ct(u)-1)).toString(32)+l,a="_"+a+"R_"+l,l=yc++,0<l&&(a+="H"+l.toString(32)),a+="_"}else l=T5++,a="_"+a+"r_"+l.toString(32)+"_";return r.memoizedState=a},useHostTransitionStatus:hf,useFormState:Gp,useActionState:Gp,useOptimistic:function(r){var a=hr();a.memoizedState=a.baseState=r;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=l,a=mf.bind(null,Rt,!0,l),l.dispatch=a,[r,a]},useMemoCache:rf,useCacheRefresh:function(){return hr().memoizedState=D5.bind(null,Rt)},useEffectEvent:function(r){var a=hr(),l={impl:r};return a.memoizedState=l,function(){if((sn&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},xf={readContext:sr,use:jc,useCallback:sg,useContext:sr,useEffect:cf,useImperativeHandle:rg,useInsertionEffect:eg,useLayoutEffect:tg,useMemo:ag,useReducer:wc,useRef:Zp,useState:function(){return wc($s)},useDebugValue:df,useDeferredValue:function(r,a){var l=zn();return ig(l,gn.memoizedState,r,a)},useTransition:function(){var r=wc($s)[0],a=zn().memoizedState;return[typeof r=="boolean"?r:Bl(r),a]},useSyncExternalStore:Lp,useId:dg,useHostTransitionStatus:hf,useFormState:Xp,useActionState:Xp,useOptimistic:function(r,a){var l=zn();return Pp(l,gn,r,a)},useMemoCache:rf,useCacheRefresh:ug};xf.useEffectEvent=Jp;var pg={readContext:sr,use:jc,useCallback:sg,useContext:sr,useEffect:cf,useImperativeHandle:rg,useInsertionEffect:eg,useLayoutEffect:tg,useMemo:ag,useReducer:af,useRef:Zp,useState:function(){return af($s)},useDebugValue:df,useDeferredValue:function(r,a){var l=zn();return gn===null?uf(l,r,a):ig(l,gn.memoizedState,r,a)},useTransition:function(){var r=af($s)[0],a=zn().memoizedState;return[typeof r=="boolean"?r:Bl(r),a]},useSyncExternalStore:Lp,useId:dg,useHostTransitionStatus:hf,useFormState:Wp,useActionState:Wp,useOptimistic:function(r,a){var l=zn();return gn!==null?Pp(l,gn,r,a):(l.baseState=r,[r,l.queue.dispatch])},useMemoCache:rf,useCacheRefresh:ug};pg.useEffectEvent=Jp;function pf(r,a,l,u){a=r.memoizedState,l=l(u,a),l=l==null?a:x({},a,l),r.memoizedState=l,r.lanes===0&&(r.updateQueue.baseState=l)}var gf={enqueueSetState:function(r,a,l){r=r._reactInternals;var u=Ir(),b=ua(u);b.payload=a,l!=null&&(b.callback=l),a=fa(r,b,u),a!==null&&(jr(a,r,u),Ll(a,r,u))},enqueueReplaceState:function(r,a,l){r=r._reactInternals;var u=Ir(),b=ua(u);b.tag=1,b.payload=a,l!=null&&(b.callback=l),a=fa(r,b,u),a!==null&&(jr(a,r,u),Ll(a,r,u))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var l=Ir(),u=ua(l);u.tag=2,a!=null&&(u.callback=a),a=fa(r,u,l),a!==null&&(jr(a,r,l),Ll(a,r,l))}};function gg(r,a,l,u,b,j,H){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(u,j,H):a.prototype&&a.prototype.isPureReactComponent?!El(l,u)||!El(b,j):!0}function bg(r,a,l,u){r=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(l,u),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(l,u),a.state!==r&&gf.enqueueReplaceState(a,a.state,null)}function ni(r,a){var l=a;if("ref"in a){l={};for(var u in a)u!=="ref"&&(l[u]=a[u])}if(r=r.defaultProps){l===a&&(l=x({},l));for(var b in r)l[b]===void 0&&(l[b]=r[b])}return l}function yg(r){rc(r)}function vg(r){console.error(r)}function jg(r){rc(r)}function Cc(r,a){try{var l=r.onUncaughtError;l(a.value,{componentStack:a.stack})}catch(u){setTimeout(function(){throw u})}}function wg(r,a,l){try{var u=r.onCaughtError;u(l.value,{componentStack:l.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function bf(r,a,l){return l=ua(l),l.tag=3,l.payload={element:null},l.callback=function(){Cc(r,a)},l}function Ng(r){return r=ua(r),r.tag=3,r}function kg(r,a,l,u){var b=l.type.getDerivedStateFromError;if(typeof b=="function"){var j=u.value;r.payload=function(){return b(j)},r.callback=function(){wg(a,l,u)}}var H=l.stateNode;H!==null&&typeof H.componentDidCatch=="function"&&(r.callback=function(){wg(a,l,u),typeof b!="function"&&(ba===null?ba=new Set([this]):ba.add(this));var J=u.stack;this.componentDidCatch(u.value,{componentStack:J!==null?J:""})})}function I5(r,a,l,u,b){if(l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(a=l.alternate,a!==null&&Ai(a,l,b,!0),l=Or.current,l!==null){switch(l.tag){case 31:case 13:return Xr===null?$c():l.alternate===null&&Ln===0&&(Ln=3),l.flags&=-257,l.flags|=65536,l.lanes=b,u===hc?l.flags|=16384:(a=l.updateQueue,a===null?l.updateQueue=new Set([u]):a.add(u),qf(r,u,b)),!1;case 22:return l.flags|=65536,u===hc?l.flags|=16384:(a=l.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([u])},l.updateQueue=a):(l=a.retryQueue,l===null?a.retryQueue=new Set([u]):l.add(u)),qf(r,u,b)),!1}throw Error(i(435,l.tag))}return qf(r,u,b),$c(),!1}if(Xt)return a=Or.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=b,u!==Iu&&(r=Error(i(422),{cause:u}),Al(Vr(r,l)))):(u!==Iu&&(a=Error(i(423),{cause:u}),Al(Vr(a,l))),r=r.current.alternate,r.flags|=65536,b&=-b,r.lanes|=b,u=Vr(u,l),b=bf(r.stateNode,u,b),Gu(r,b),Ln!==4&&(Ln=2)),!1;var j=Error(i(520),{cause:u});if(j=Vr(j,l),Kl===null?Kl=[j]:Kl.push(j),Ln!==4&&(Ln=2),a===null)return!0;u=Vr(u,l),l=a;do{switch(l.tag){case 3:return l.flags|=65536,r=b&-b,l.lanes|=r,r=bf(l.stateNode,u,r),Gu(l,r),!1;case 1:if(a=l.type,j=l.stateNode,(l.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(ba===null||!ba.has(j))))return l.flags|=65536,b&=-b,l.lanes|=b,b=Ng(b),kg(b,r,l,u),Gu(l,b),!1}l=l.return}while(l!==null);return!1}var yf=Error(i(461)),Un=!1;function ar(r,a,l,u){a.child=r===null?Tp(a,null,l,u):ei(a,r.child,l,u)}function Sg(r,a,l,u,b){l=l.render;var j=a.ref;if("ref"in u){var H={};for(var J in u)J!=="ref"&&(H[J]=u[J])}else H=u;return Wa(a),u=Ju(r,a,l,H,j,b),J=ef(),r!==null&&!Un?(tf(r,a,b),Bs(r,a,b)):(Xt&&J&&Du(a),a.flags|=1,ar(r,a,u,b),a.child)}function Cg(r,a,l,u,b){if(r===null){var j=l.type;return typeof j=="function"&&!Mu(j)&&j.defaultProps===void 0&&l.compare===null?(a.tag=15,a.type=j,Eg(r,a,j,u,b)):(r=lc(l.type,null,u,a,a.mode,b),r.ref=a.ref,r.return=a,a.child=r)}if(j=r.child,!Ef(r,b)){var H=j.memoizedProps;if(l=l.compare,l=l!==null?l:El,l(H,u)&&r.ref===a.ref)return Bs(r,a,b)}return a.flags|=1,r=Rs(j,u),r.ref=a.ref,r.return=a,a.child=r}function Eg(r,a,l,u,b){if(r!==null){var j=r.memoizedProps;if(El(j,u)&&r.ref===a.ref)if(Un=!1,a.pendingProps=u=j,Ef(r,b))(r.flags&131072)!==0&&(Un=!0);else return a.lanes=r.lanes,Bs(r,a,b)}return vf(r,a,l,u,b)}function Tg(r,a,l,u){var b=u.children,j=r!==null?r.memoizedState:null;if(r===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((a.flags&128)!==0){if(j=j!==null?j.baseLanes|l:l,r!==null){for(u=a.child=r.child,b=0;u!==null;)b=b|u.lanes|u.childLanes,u=u.sibling;u=b&~j}else u=0,a.child=null;return _g(r,a,j,l,u)}if((l&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},r!==null&&uc(a,j!==null?j.cachePool:null),j!==null?Mp(a,j):Ku(),Op(a);else return u=a.lanes=536870912,_g(r,a,j!==null?j.baseLanes|l:l,l,u)}else j!==null?(uc(a,j.cachePool),Mp(a,j),ma(),a.memoizedState=null):(r!==null&&uc(a,null),Ku(),ma());return ar(r,a,b,l),a.child}function Ul(r,a){return r!==null&&r.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function _g(r,a,l,u,b){var j=qu();return j=j===null?null:{parent:Hn._currentValue,pool:j},a.memoizedState={baseLanes:l,cachePool:j},r!==null&&uc(a,null),Ku(),Op(a),r!==null&&Ai(r,a,u,!0),a.childLanes=b,null}function Ec(r,a){return a=_c({mode:a.mode,children:a.children},r.mode),a.ref=r.ref,r.child=a,a.return=r,a}function Ag(r,a,l){return ei(a,r.child,null,l),r=Ec(a,a.pendingProps),r.flags|=2,Rr(a),a.memoizedState=null,r}function z5(r,a,l){var u=a.pendingProps,b=(a.flags&128)!==0;if(a.flags&=-129,r===null){if(Xt){if(u.mode==="hidden")return r=Ec(a,u),a.lanes=536870912,Ul(null,r);if(Zu(a),(r=Sn)?(r=U0(r,Gr),r=r!==null&&r.data==="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:ia!==null?{id:gs,overflow:bs}:null,retryLane:536870912,hydrationErrors:null},l=hp(r),l.return=a,a.child=l,rr=a,Sn=null)):r=null,r===null)throw oa(a);return a.lanes=536870912,null}return Ec(a,u)}var j=r.memoizedState;if(j!==null){var H=j.dehydrated;if(Zu(a),b)if(a.flags&256)a.flags&=-257,a=Ag(r,a,l);else if(a.memoizedState!==null)a.child=r.child,a.flags|=128,a=null;else throw Error(i(558));else if(Un||Ai(r,a,l,!1),b=(l&r.childLanes)!==0,Un||b){if(u=vn,u!==null&&(H=Ve(u,l),H!==0&&H!==j.retryLane))throw j.retryLane=H,Ya(r,H),jr(u,r,H),yf;$c(),a=Ag(r,a,l)}else r=j.treeContext,Sn=Kr(H.nextSibling),rr=a,Xt=!0,la=null,Gr=!1,r!==null&&pp(a,r),a=Ec(a,u),a.flags|=4096;return a}return r=Rs(r.child,{mode:u.mode,children:u.children}),r.ref=a.ref,a.child=r,r.return=a,r}function Tc(r,a){var l=a.ref;if(l===null)r!==null&&r.ref!==null&&(a.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(i(284));(r===null||r.ref!==l)&&(a.flags|=4194816)}}function vf(r,a,l,u,b){return Wa(a),l=Ju(r,a,l,u,void 0,b),u=ef(),r!==null&&!Un?(tf(r,a,b),Bs(r,a,b)):(Xt&&u&&Du(a),a.flags|=1,ar(r,a,l,b),a.child)}function Mg(r,a,l,u,b,j){return Wa(a),a.updateQueue=null,l=Dp(a,u,l,b),Rp(r),u=ef(),r!==null&&!Un?(tf(r,a,j),Bs(r,a,j)):(Xt&&u&&Du(a),a.flags|=1,ar(r,a,l,j),a.child)}function Og(r,a,l,u,b){if(Wa(a),a.stateNode===null){var j=Ci,H=l.contextType;typeof H=="object"&&H!==null&&(j=sr(H)),j=new l(u,j),a.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=gf,a.stateNode=j,j._reactInternals=a,j=a.stateNode,j.props=u,j.state=a.memoizedState,j.refs={},Fu(a),H=l.contextType,j.context=typeof H=="object"&&H!==null?sr(H):Ci,j.state=a.memoizedState,H=l.getDerivedStateFromProps,typeof H=="function"&&(pf(a,l,H,u),j.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(H=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),H!==j.state&&gf.enqueueReplaceState(j,j.state,null),zl(a,u,j,b),Il(),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!0}else if(r===null){j=a.stateNode;var J=a.memoizedProps,ie=ni(l,J);j.props=ie;var ge=j.context,_e=l.contextType;H=Ci,typeof _e=="object"&&_e!==null&&(H=sr(_e));var De=l.getDerivedStateFromProps;_e=typeof De=="function"||typeof j.getSnapshotBeforeUpdate=="function",J=a.pendingProps!==J,_e||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(J||ge!==H)&&bg(a,j,u,H),da=!1;var be=a.memoizedState;j.state=be,zl(a,u,j,b),Il(),ge=a.memoizedState,J||be!==ge||da?(typeof De=="function"&&(pf(a,l,De,u),ge=a.memoizedState),(ie=da||gg(a,l,ie,u,be,ge,H))?(_e||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(a.flags|=4194308)):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=u,a.memoizedState=ge),j.props=u,j.state=ge,j.context=H,u=ie):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),u=!1)}else{j=a.stateNode,Yu(r,a),H=a.memoizedProps,_e=ni(l,H),j.props=_e,De=a.pendingProps,be=j.context,ge=l.contextType,ie=Ci,typeof ge=="object"&&ge!==null&&(ie=sr(ge)),J=l.getDerivedStateFromProps,(ge=typeof J=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(H!==De||be!==ie)&&bg(a,j,u,ie),da=!1,be=a.memoizedState,j.state=be,zl(a,u,j,b),Il();var ke=a.memoizedState;H!==De||be!==ke||da||r!==null&&r.dependencies!==null&&cc(r.dependencies)?(typeof J=="function"&&(pf(a,l,J,u),ke=a.memoizedState),(_e=da||gg(a,l,_e,u,be,ke,ie)||r!==null&&r.dependencies!==null&&cc(r.dependencies))?(ge||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(u,ke,ie),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(u,ke,ie)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||H===r.memoizedProps&&be===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||H===r.memoizedProps&&be===r.memoizedState||(a.flags|=1024),a.memoizedProps=u,a.memoizedState=ke),j.props=u,j.state=ke,j.context=ie,u=_e):(typeof j.componentDidUpdate!="function"||H===r.memoizedProps&&be===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||H===r.memoizedProps&&be===r.memoizedState||(a.flags|=1024),u=!1)}return j=u,Tc(r,a),u=(a.flags&128)!==0,j||u?(j=a.stateNode,l=u&&typeof l.getDerivedStateFromError!="function"?null:j.render(),a.flags|=1,r!==null&&u?(a.child=ei(a,r.child,null,b),a.child=ei(a,null,l,b)):ar(r,a,l,b),a.memoizedState=j.state,r=a.child):r=Bs(r,a,b),r}function Rg(r,a,l,u){return Xa(),a.flags|=256,ar(r,a,l,u),a.child}var jf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function wf(r){return{baseLanes:r,cachePool:wp()}}function Nf(r,a,l){return r=r!==null?r.childLanes&~l:0,a&&(r|=Lr),r}function Dg(r,a,l){var u=a.pendingProps,b=!1,j=(a.flags&128)!==0,H;if((H=j)||(H=r!==null&&r.memoizedState===null?!1:(In.current&2)!==0),H&&(b=!0,a.flags&=-129),H=(a.flags&32)!==0,a.flags&=-33,r===null){if(Xt){if(b?ha(a):ma(),(r=Sn)?(r=U0(r,Gr),r=r!==null&&r.data!=="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:ia!==null?{id:gs,overflow:bs}:null,retryLane:536870912,hydrationErrors:null},l=hp(r),l.return=a,a.child=l,rr=a,Sn=null)):r=null,r===null)throw oa(a);return ah(r)?a.lanes=32:a.lanes=536870912,null}var J=u.children;return u=u.fallback,b?(ma(),b=a.mode,J=_c({mode:"hidden",children:J},b),u=Ga(u,b,l,null),J.return=a,u.return=a,J.sibling=u,a.child=J,u=a.child,u.memoizedState=wf(l),u.childLanes=Nf(r,H,l),a.memoizedState=jf,Ul(null,u)):(ha(a),kf(a,J))}var ie=r.memoizedState;if(ie!==null&&(J=ie.dehydrated,J!==null)){if(j)a.flags&256?(ha(a),a.flags&=-257,a=Sf(r,a,l)):a.memoizedState!==null?(ma(),a.child=r.child,a.flags|=128,a=null):(ma(),J=u.fallback,b=a.mode,u=_c({mode:"visible",children:u.children},b),J=Ga(J,b,l,null),J.flags|=2,u.return=a,J.return=a,u.sibling=J,a.child=u,ei(a,r.child,null,l),u=a.child,u.memoizedState=wf(l),u.childLanes=Nf(r,H,l),a.memoizedState=jf,a=Ul(null,u));else if(ha(a),ah(J)){if(H=J.nextSibling&&J.nextSibling.dataset,H)var ge=H.dgst;H=ge,u=Error(i(419)),u.stack="",u.digest=H,Al({value:u,source:null,stack:null}),a=Sf(r,a,l)}else if(Un||Ai(r,a,l,!1),H=(l&r.childLanes)!==0,Un||H){if(H=vn,H!==null&&(u=Ve(H,l),u!==0&&u!==ie.retryLane))throw ie.retryLane=u,Ya(r,u),jr(H,r,u),yf;sh(J)||$c(),a=Sf(r,a,l)}else sh(J)?(a.flags|=192,a.child=r.child,a=null):(r=ie.treeContext,Sn=Kr(J.nextSibling),rr=a,Xt=!0,la=null,Gr=!1,r!==null&&pp(a,r),a=kf(a,u.children),a.flags|=4096);return a}return b?(ma(),J=u.fallback,b=a.mode,ie=r.child,ge=ie.sibling,u=Rs(ie,{mode:"hidden",children:u.children}),u.subtreeFlags=ie.subtreeFlags&65011712,ge!==null?J=Rs(ge,J):(J=Ga(J,b,l,null),J.flags|=2),J.return=a,u.return=a,u.sibling=J,a.child=u,Ul(null,u),u=a.child,J=r.child.memoizedState,J===null?J=wf(l):(b=J.cachePool,b!==null?(ie=Hn._currentValue,b=b.parent!==ie?{parent:ie,pool:ie}:b):b=wp(),J={baseLanes:J.baseLanes|l,cachePool:b}),u.memoizedState=J,u.childLanes=Nf(r,H,l),a.memoizedState=jf,Ul(r.child,u)):(ha(a),l=r.child,r=l.sibling,l=Rs(l,{mode:"visible",children:u.children}),l.return=a,l.sibling=null,r!==null&&(H=a.deletions,H===null?(a.deletions=[r],a.flags|=16):H.push(r)),a.child=l,a.memoizedState=null,l)}function kf(r,a){return a=_c({mode:"visible",children:a},r.mode),a.return=r,r.child=a}function _c(r,a){return r=Mr(22,r,null,a),r.lanes=0,r}function Sf(r,a,l){return ei(a,r.child,null,l),r=kf(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function Lg(r,a,l){r.lanes|=a;var u=r.alternate;u!==null&&(u.lanes|=a),Bu(r.return,a,l)}function Cf(r,a,l,u,b,j){var H=r.memoizedState;H===null?r.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:b,treeForkCount:j}:(H.isBackwards=a,H.rendering=null,H.renderingStartTime=0,H.last=u,H.tail=l,H.tailMode=b,H.treeForkCount=j)}function Ig(r,a,l){var u=a.pendingProps,b=u.revealOrder,j=u.tail;u=u.children;var H=In.current,J=(H&2)!==0;if(J?(H=H&1|2,a.flags|=128):H&=1,I(In,H),ar(r,a,u,l),u=Xt?_l:0,!J&&r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Lg(r,l,a);else if(r.tag===19)Lg(r,l,a);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===a)break e;for(;r.sibling===null;){if(r.return===null||r.return===a)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(b){case"forwards":for(l=a.child,b=null;l!==null;)r=l.alternate,r!==null&&gc(r)===null&&(b=l),l=l.sibling;l=b,l===null?(b=a.child,a.child=null):(b=l.sibling,l.sibling=null),Cf(a,!1,b,l,j,u);break;case"backwards":case"unstable_legacy-backwards":for(l=null,b=a.child,a.child=null;b!==null;){if(r=b.alternate,r!==null&&gc(r)===null){a.child=b;break}r=b.sibling,b.sibling=l,l=b,b=r}Cf(a,!0,l,null,j,u);break;case"together":Cf(a,!1,null,null,void 0,u);break;default:a.memoizedState=null}return a.child}function Bs(r,a,l){if(r!==null&&(a.dependencies=r.dependencies),ga|=a.lanes,(l&a.childLanes)===0)if(r!==null){if(Ai(r,a,l,!1),(l&a.childLanes)===0)return null}else return null;if(r!==null&&a.child!==r.child)throw Error(i(153));if(a.child!==null){for(r=a.child,l=Rs(r,r.pendingProps),a.child=l,l.return=a;r.sibling!==null;)r=r.sibling,l=l.sibling=Rs(r,r.pendingProps),l.return=a;l.sibling=null}return a.child}function Ef(r,a){return(r.lanes&a)!==0?!0:(r=r.dependencies,!!(r!==null&&cc(r)))}function $5(r,a,l){switch(a.tag){case 3:te(a,a.stateNode.containerInfo),ca(a,Hn,r.memoizedState.cache),Xa();break;case 27:case 5:me(a);break;case 4:te(a,a.stateNode.containerInfo);break;case 10:ca(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Zu(a),null;break;case 13:var u=a.memoizedState;if(u!==null)return u.dehydrated!==null?(ha(a),a.flags|=128,null):(l&a.child.childLanes)!==0?Dg(r,a,l):(ha(a),r=Bs(r,a,l),r!==null?r.sibling:null);ha(a);break;case 19:var b=(r.flags&128)!==0;if(u=(l&a.childLanes)!==0,u||(Ai(r,a,l,!1),u=(l&a.childLanes)!==0),b){if(u)return Ig(r,a,l);a.flags|=128}if(b=a.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),I(In,In.current),u)break;return null;case 22:return a.lanes=0,Tg(r,a,l,a.pendingProps);case 24:ca(a,Hn,r.memoizedState.cache)}return Bs(r,a,l)}function zg(r,a,l){if(r!==null)if(r.memoizedProps!==a.pendingProps)Un=!0;else{if(!Ef(r,l)&&(a.flags&128)===0)return Un=!1,$5(r,a,l);Un=(r.flags&131072)!==0}else Un=!1,Xt&&(a.flags&1048576)!==0&&xp(a,_l,a.index);switch(a.lanes=0,a.tag){case 16:e:{var u=a.pendingProps;if(r=Qa(a.elementType),a.type=r,typeof r=="function")Mu(r)?(u=ni(r,u),a.tag=1,a=Og(null,a,r,u,l)):(a.tag=0,a=vf(null,a,r,u,l));else{if(r!=null){var b=r.$$typeof;if(b===T){a.tag=11,a=Sg(null,a,r,u,l);break e}else if(b===U){a.tag=14,a=Cg(null,a,r,u,l);break e}}throw a=M(r)||r,Error(i(306,a,""))}}return a;case 0:return vf(r,a,a.type,a.pendingProps,l);case 1:return u=a.type,b=ni(u,a.pendingProps),Og(r,a,u,b,l);case 3:e:{if(te(a,a.stateNode.containerInfo),r===null)throw Error(i(387));u=a.pendingProps;var j=a.memoizedState;b=j.element,Yu(r,a),zl(a,u,null,l);var H=a.memoizedState;if(u=H.cache,ca(a,Hn,u),u!==j.cache&&Hu(a,[Hn],l,!0),Il(),u=H.element,j.isDehydrated)if(j={element:u,isDehydrated:!1,cache:H.cache},a.updateQueue.baseState=j,a.memoizedState=j,a.flags&256){a=Rg(r,a,u,l);break e}else if(u!==b){b=Vr(Error(i(424)),a),Al(b),a=Rg(r,a,u,l);break e}else for(r=a.stateNode.containerInfo,r.nodeType===9?r=r.body:r=r.nodeName==="HTML"?r.ownerDocument.body:r,Sn=Kr(r.firstChild),rr=a,Xt=!0,la=null,Gr=!0,l=Tp(a,null,u,l),a.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Xa(),u===b){a=Bs(r,a,l);break e}ar(r,a,u,l)}a=a.child}return a;case 26:return Tc(r,a),r===null?(l=X0(a.type,null,a.pendingProps,null))?a.memoizedState=l:Xt||(l=a.type,r=a.pendingProps,u=Fc(Q.current).createElement(l),u[Je]=a,u[Fe]=r,ir(u,l,r),on(u),a.stateNode=u):a.memoizedState=X0(a.type,r.memoizedProps,a.pendingProps,r.memoizedState),null;case 27:return me(a),r===null&&Xt&&(u=a.stateNode=F0(a.type,a.pendingProps,Q.current),rr=a,Gr=!0,b=Sn,wa(a.type)?(ih=b,Sn=Kr(u.firstChild)):Sn=b),ar(r,a,a.pendingProps.children,l),Tc(r,a),r===null&&(a.flags|=4194304),a.child;case 5:return r===null&&Xt&&((b=u=Sn)&&(u=m2(u,a.type,a.pendingProps,Gr),u!==null?(a.stateNode=u,rr=a,Sn=Kr(u.firstChild),Gr=!1,b=!0):b=!1),b||oa(a)),me(a),b=a.type,j=a.pendingProps,H=r!==null?r.memoizedProps:null,u=j.children,th(b,j)?u=null:H!==null&&th(b,H)&&(a.flags|=32),a.memoizedState!==null&&(b=Ju(r,a,_5,null,null,l),ro._currentValue=b),Tc(r,a),ar(r,a,u,l),a.child;case 6:return r===null&&Xt&&((r=l=Sn)&&(l=x2(l,a.pendingProps,Gr),l!==null?(a.stateNode=l,rr=a,Sn=null,r=!0):r=!1),r||oa(a)),null;case 13:return Dg(r,a,l);case 4:return te(a,a.stateNode.containerInfo),u=a.pendingProps,r===null?a.child=ei(a,null,u,l):ar(r,a,u,l),a.child;case 11:return Sg(r,a,a.type,a.pendingProps,l);case 7:return ar(r,a,a.pendingProps,l),a.child;case 8:return ar(r,a,a.pendingProps.children,l),a.child;case 12:return ar(r,a,a.pendingProps.children,l),a.child;case 10:return u=a.pendingProps,ca(a,a.type,u.value),ar(r,a,u.children,l),a.child;case 9:return b=a.type._context,u=a.pendingProps.children,Wa(a),b=sr(b),u=u(b),a.flags|=1,ar(r,a,u,l),a.child;case 14:return Cg(r,a,a.type,a.pendingProps,l);case 15:return Eg(r,a,a.type,a.pendingProps,l);case 19:return Ig(r,a,l);case 31:return z5(r,a,l);case 22:return Tg(r,a,l,a.pendingProps);case 24:return Wa(a),u=sr(Hn),r===null?(b=qu(),b===null&&(b=vn,j=Pu(),b.pooledCache=j,j.refCount++,j!==null&&(b.pooledCacheLanes|=l),b=j),a.memoizedState={parent:u,cache:b},Fu(a),ca(a,Hn,b)):((r.lanes&l)!==0&&(Yu(r,a),zl(a,null,null,l),Il()),b=r.memoizedState,j=a.memoizedState,b.parent!==u?(b={parent:u,cache:u},a.memoizedState=b,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=b),ca(a,Hn,u)):(u=j.cache,ca(a,Hn,u),u!==b.cache&&Hu(a,[Hn],l,!0))),ar(r,a,a.pendingProps.children,l),a.child;case 29:throw a.pendingProps}throw Error(i(156,a.tag))}function Hs(r){r.flags|=4}function Tf(r,a,l,u,b){if((a=(r.mode&32)!==0)&&(a=!1),a){if(r.flags|=16777216,(b&335544128)===b)if(r.stateNode.complete)r.flags|=8192;else if(d0())r.flags|=8192;else throw Ja=hc,Vu}else r.flags&=-16777217}function $g(r,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!J0(a))if(d0())r.flags|=8192;else throw Ja=hc,Vu}function Ac(r,a){a!==null&&(r.flags|=4),r.flags&16384&&(a=r.tag!==22?nn():536870912,r.lanes|=a,Ui|=a)}function ql(r,a){if(!Xt)switch(r.tailMode){case"hidden":a=r.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r.tail=null:l.sibling=null;break;case"collapsed":l=r.tail;for(var u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?a||r.tail===null?r.tail=null:r.tail.sibling=null:u.sibling=null}}function Cn(r){var a=r.alternate!==null&&r.alternate.child===r.child,l=0,u=0;if(a)for(var b=r.child;b!==null;)l|=b.lanes|b.childLanes,u|=b.subtreeFlags&65011712,u|=b.flags&65011712,b.return=r,b=b.sibling;else for(b=r.child;b!==null;)l|=b.lanes|b.childLanes,u|=b.subtreeFlags,u|=b.flags,b.return=r,b=b.sibling;return r.subtreeFlags|=u,r.childLanes=l,a}function B5(r,a,l){var u=a.pendingProps;switch(Lu(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Cn(a),null;case 1:return Cn(a),null;case 3:return l=a.stateNode,u=null,r!==null&&(u=r.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),Is(Hn),ae(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(_i(a)?Hs(a):r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,zu())),Cn(a),null;case 26:var b=a.type,j=a.memoizedState;return r===null?(Hs(a),j!==null?(Cn(a),$g(a,j)):(Cn(a),Tf(a,b,null,u,l))):j?j!==r.memoizedState?(Hs(a),Cn(a),$g(a,j)):(Cn(a),a.flags&=-16777217):(r=r.memoizedProps,r!==u&&Hs(a),Cn(a),Tf(a,b,r,u,l)),null;case 27:if(Ne(a),l=Q.current,b=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Hs(a);else{if(!u){if(a.stateNode===null)throw Error(i(166));return Cn(a),null}r=_.current,_i(a)?gp(a):(r=F0(b,u,l),a.stateNode=r,Hs(a))}return Cn(a),null;case 5:if(Ne(a),b=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==u&&Hs(a);else{if(!u){if(a.stateNode===null)throw Error(i(166));return Cn(a),null}if(j=_.current,_i(a))gp(a);else{var H=Fc(Q.current);switch(j){case 1:j=H.createElementNS("http://www.w3.org/2000/svg",b);break;case 2:j=H.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;default:switch(b){case"svg":j=H.createElementNS("http://www.w3.org/2000/svg",b);break;case"math":j=H.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;case"script":j=H.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof u.is=="string"?H.createElement("select",{is:u.is}):H.createElement("select"),u.multiple?j.multiple=!0:u.size&&(j.size=u.size);break;default:j=typeof u.is=="string"?H.createElement(b,{is:u.is}):H.createElement(b)}}j[Je]=a,j[Fe]=u;e:for(H=a.child;H!==null;){if(H.tag===5||H.tag===6)j.appendChild(H.stateNode);else if(H.tag!==4&&H.tag!==27&&H.child!==null){H.child.return=H,H=H.child;continue}if(H===a)break e;for(;H.sibling===null;){if(H.return===null||H.return===a)break e;H=H.return}H.sibling.return=H.return,H=H.sibling}a.stateNode=j;e:switch(ir(j,b,u),b){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Hs(a)}}return Cn(a),Tf(a,a.type,r===null?null:r.memoizedProps,a.pendingProps,l),null;case 6:if(r&&a.stateNode!=null)r.memoizedProps!==u&&Hs(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(i(166));if(r=Q.current,_i(a)){if(r=a.stateNode,l=a.memoizedProps,u=null,b=rr,b!==null)switch(b.tag){case 27:case 5:u=b.memoizedProps}r[Je]=a,r=!!(r.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||D0(r.nodeValue,l)),r||oa(a,!0)}else r=Fc(r).createTextNode(u),r[Je]=a,a.stateNode=r}return Cn(a),null;case 31:if(l=a.memoizedState,r===null||r.memoizedState!==null){if(u=_i(a),l!==null){if(r===null){if(!u)throw Error(i(318));if(r=a.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[Je]=a}else Xa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Cn(a),r=!1}else l=zu(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=l),r=!0;if(!r)return a.flags&256?(Rr(a),a):(Rr(a),null);if((a.flags&128)!==0)throw Error(i(558))}return Cn(a),null;case 13:if(u=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(b=_i(a),u!==null&&u.dehydrated!==null){if(r===null){if(!b)throw Error(i(318));if(b=a.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(i(317));b[Je]=a}else Xa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Cn(a),b=!1}else b=zu(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=b),b=!0;if(!b)return a.flags&256?(Rr(a),a):(Rr(a),null)}return Rr(a),(a.flags&128)!==0?(a.lanes=l,a):(l=u!==null,r=r!==null&&r.memoizedState!==null,l&&(u=a.child,b=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(b=u.alternate.memoizedState.cachePool.pool),j=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(j=u.memoizedState.cachePool.pool),j!==b&&(u.flags|=2048)),l!==r&&l&&(a.child.flags|=8192),Ac(a,a.updateQueue),Cn(a),null);case 4:return ae(),r===null&&Wf(a.stateNode.containerInfo),Cn(a),null;case 10:return Is(a.type),Cn(a),null;case 19:if(X(In),u=a.memoizedState,u===null)return Cn(a),null;if(b=(a.flags&128)!==0,j=u.rendering,j===null)if(b)ql(u,!1);else{if(Ln!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(j=gc(r),j!==null){for(a.flags|=128,ql(u,!1),r=j.updateQueue,a.updateQueue=r,Ac(a,r),a.subtreeFlags=0,r=l,l=a.child;l!==null;)fp(l,r),l=l.sibling;return I(In,In.current&1|2),Xt&&Ds(a,u.treeForkCount),a.child}r=r.sibling}u.tail!==null&&yt()>Lc&&(a.flags|=128,b=!0,ql(u,!1),a.lanes=4194304)}else{if(!b)if(r=gc(j),r!==null){if(a.flags|=128,b=!0,r=r.updateQueue,a.updateQueue=r,Ac(a,r),ql(u,!0),u.tail===null&&u.tailMode==="hidden"&&!j.alternate&&!Xt)return Cn(a),null}else 2*yt()-u.renderingStartTime>Lc&&l!==536870912&&(a.flags|=128,b=!0,ql(u,!1),a.lanes=4194304);u.isBackwards?(j.sibling=a.child,a.child=j):(r=u.last,r!==null?r.sibling=j:a.child=j,u.last=j)}return u.tail!==null?(r=u.tail,u.rendering=r,u.tail=r.sibling,u.renderingStartTime=yt(),r.sibling=null,l=In.current,I(In,b?l&1|2:l&1),Xt&&Ds(a,u.treeForkCount),r):(Cn(a),null);case 22:case 23:return Rr(a),Wu(),u=a.memoizedState!==null,r!==null?r.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(l&536870912)!==0&&(a.flags&128)===0&&(Cn(a),a.subtreeFlags&6&&(a.flags|=8192)):Cn(a),l=a.updateQueue,l!==null&&Ac(a,l.retryQueue),l=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==l&&(a.flags|=2048),r!==null&&X(Za),null;case 24:return l=null,r!==null&&(l=r.memoizedState.cache),a.memoizedState.cache!==l&&(a.flags|=2048),Is(Hn),Cn(a),null;case 25:return null;case 30:return null}throw Error(i(156,a.tag))}function H5(r,a){switch(Lu(a),a.tag){case 1:return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return Is(Hn),ae(),r=a.flags,(r&65536)!==0&&(r&128)===0?(a.flags=r&-65537|128,a):null;case 26:case 27:case 5:return Ne(a),null;case 31:if(a.memoizedState!==null){if(Rr(a),a.alternate===null)throw Error(i(340));Xa()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 13:if(Rr(a),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(i(340));Xa()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return X(In),null;case 4:return ae(),null;case 10:return Is(a.type),null;case 22:case 23:return Rr(a),Wu(),r!==null&&X(Za),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 24:return Is(Hn),null;case 25:return null;default:return null}}function Bg(r,a){switch(Lu(a),a.tag){case 3:Is(Hn),ae();break;case 26:case 27:case 5:Ne(a);break;case 4:ae();break;case 31:a.memoizedState!==null&&Rr(a);break;case 13:Rr(a);break;case 19:X(In);break;case 10:Is(a.type);break;case 22:case 23:Rr(a),Wu(),r!==null&&X(Za);break;case 24:Is(Hn)}}function Vl(r,a){try{var l=a.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var b=u.next;l=b;do{if((l.tag&r)===r){u=void 0;var j=l.create,H=l.inst;u=j(),H.destroy=u}l=l.next}while(l!==b)}}catch(J){dn(a,a.return,J)}}function xa(r,a,l){try{var u=a.updateQueue,b=u!==null?u.lastEffect:null;if(b!==null){var j=b.next;u=j;do{if((u.tag&r)===r){var H=u.inst,J=H.destroy;if(J!==void 0){H.destroy=void 0,b=a;var ie=l,ge=J;try{ge()}catch(_e){dn(b,ie,_e)}}}u=u.next}while(u!==j)}}catch(_e){dn(a,a.return,_e)}}function Hg(r){var a=r.updateQueue;if(a!==null){var l=r.stateNode;try{Ap(a,l)}catch(u){dn(r,r.return,u)}}}function Pg(r,a,l){l.props=ni(r.type,r.memoizedProps),l.state=r.memoizedState;try{l.componentWillUnmount()}catch(u){dn(r,a,u)}}function Fl(r,a){try{var l=r.ref;if(l!==null){switch(r.tag){case 26:case 27:case 5:var u=r.stateNode;break;case 30:u=r.stateNode;break;default:u=r.stateNode}typeof l=="function"?r.refCleanup=l(u):l.current=u}}catch(b){dn(r,a,b)}}function ys(r,a){var l=r.ref,u=r.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(b){dn(r,a,b)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(b){dn(r,a,b)}else l.current=null}function Ug(r){var a=r.type,l=r.memoizedProps,u=r.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(b){dn(r,r.return,b)}}function _f(r,a,l){try{var u=r.stateNode;o2(u,r.type,l,a),u[Fe]=a}catch(b){dn(r,r.return,b)}}function qg(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&wa(r.type)||r.tag===4}function Af(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||qg(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&wa(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Mf(r,a,l){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(r,a):(a=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,a.appendChild(r),l=l._reactRootContainer,l!=null||a.onclick!==null||(a.onclick=le));else if(u!==4&&(u===27&&wa(r.type)&&(l=r.stateNode,a=null),r=r.child,r!==null))for(Mf(r,a,l),r=r.sibling;r!==null;)Mf(r,a,l),r=r.sibling}function Mc(r,a,l){var u=r.tag;if(u===5||u===6)r=r.stateNode,a?l.insertBefore(r,a):l.appendChild(r);else if(u!==4&&(u===27&&wa(r.type)&&(l=r.stateNode),r=r.child,r!==null))for(Mc(r,a,l),r=r.sibling;r!==null;)Mc(r,a,l),r=r.sibling}function Vg(r){var a=r.stateNode,l=r.memoizedProps;try{for(var u=r.type,b=a.attributes;b.length;)a.removeAttributeNode(b[0]);ir(a,u,l),a[Je]=r,a[Fe]=l}catch(j){dn(r,r.return,j)}}var Ps=!1,qn=!1,Of=!1,Fg=typeof WeakSet=="function"?WeakSet:Set,er=null;function P5(r,a){if(r=r.containerInfo,Jf=Qc,r=rp(r),ku(r)){if("selectionStart"in r)var l={start:r.selectionStart,end:r.selectionEnd};else e:{l=(l=r.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var b=u.anchorOffset,j=u.focusNode;u=u.focusOffset;try{l.nodeType,j.nodeType}catch{l=null;break e}var H=0,J=-1,ie=-1,ge=0,_e=0,De=r,be=null;t:for(;;){for(var ke;De!==l||b!==0&&De.nodeType!==3||(J=H+b),De!==j||u!==0&&De.nodeType!==3||(ie=H+u),De.nodeType===3&&(H+=De.nodeValue.length),(ke=De.firstChild)!==null;)be=De,De=ke;for(;;){if(De===r)break t;if(be===l&&++ge===b&&(J=H),be===j&&++_e===u&&(ie=H),(ke=De.nextSibling)!==null)break;De=be,be=De.parentNode}De=ke}l=J===-1||ie===-1?null:{start:J,end:ie}}else l=null}l=l||{start:0,end:0}}else l=null;for(eh={focusedElem:r,selectionRange:l},Qc=!1,er=a;er!==null;)if(a=er,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,er=r;else for(;er!==null;){switch(a=er,j=a.alternate,r=a.flags,a.tag){case 0:if((r&4)!==0&&(r=a.updateQueue,r=r!==null?r.events:null,r!==null))for(l=0;l<r.length;l++)b=r[l],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&j!==null){r=void 0,l=a,b=j.memoizedProps,j=j.memoizedState,u=l.stateNode;try{var nt=ni(l.type,b);r=u.getSnapshotBeforeUpdate(nt,j),u.__reactInternalSnapshotBeforeUpdate=r}catch(kt){dn(l,l.return,kt)}}break;case 3:if((r&1024)!==0){if(r=a.stateNode.containerInfo,l=r.nodeType,l===9)rh(r);else if(l===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":rh(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(i(163))}if(r=a.sibling,r!==null){r.return=a.return,er=r;break}er=a.return}}function Yg(r,a,l){var u=l.flags;switch(l.tag){case 0:case 11:case 15:qs(r,l),u&4&&Vl(5,l);break;case 1:if(qs(r,l),u&4)if(r=l.stateNode,a===null)try{r.componentDidMount()}catch(H){dn(l,l.return,H)}else{var b=ni(l.type,a.memoizedProps);a=a.memoizedState;try{r.componentDidUpdate(b,a,r.__reactInternalSnapshotBeforeUpdate)}catch(H){dn(l,l.return,H)}}u&64&&Hg(l),u&512&&Fl(l,l.return);break;case 3:if(qs(r,l),u&64&&(r=l.updateQueue,r!==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{Ap(r,a)}catch(H){dn(l,l.return,H)}}break;case 27:a===null&&u&4&&Vg(l);case 26:case 5:qs(r,l),a===null&&u&4&&Ug(l),u&512&&Fl(l,l.return);break;case 12:qs(r,l);break;case 31:qs(r,l),u&4&&Kg(r,l);break;case 13:qs(r,l),u&4&&Wg(r,l),u&64&&(r=l.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(l=W5.bind(null,l),p2(r,l))));break;case 22:if(u=l.memoizedState!==null||Ps,!u){a=a!==null&&a.memoizedState!==null||qn,b=Ps;var j=qn;Ps=u,(qn=a)&&!j?Vs(r,l,(l.subtreeFlags&8772)!==0):qs(r,l),Ps=b,qn=j}break;case 30:break;default:qs(r,l)}}function Gg(r){var a=r.alternate;a!==null&&(r.alternate=null,Gg(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&At(a)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var _n=null,gr=!1;function Us(r,a,l){for(l=l.child;l!==null;)Xg(r,a,l),l=l.sibling}function Xg(r,a,l){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(zt,l)}catch{}switch(l.tag){case 26:qn||ys(l,a),Us(r,a,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:qn||ys(l,a);var u=_n,b=gr;wa(l.type)&&(_n=l.stateNode,gr=!1),Us(r,a,l),eo(l.stateNode),_n=u,gr=b;break;case 5:qn||ys(l,a);case 6:if(u=_n,b=gr,_n=null,Us(r,a,l),_n=u,gr=b,_n!==null)if(gr)try{(_n.nodeType===9?_n.body:_n.nodeName==="HTML"?_n.ownerDocument.body:_n).removeChild(l.stateNode)}catch(j){dn(l,a,j)}else try{_n.removeChild(l.stateNode)}catch(j){dn(l,a,j)}break;case 18:_n!==null&&(gr?(r=_n,H0(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,l.stateNode),Wi(r)):H0(_n,l.stateNode));break;case 4:u=_n,b=gr,_n=l.stateNode.containerInfo,gr=!0,Us(r,a,l),_n=u,gr=b;break;case 0:case 11:case 14:case 15:xa(2,l,a),qn||xa(4,l,a),Us(r,a,l);break;case 1:qn||(ys(l,a),u=l.stateNode,typeof u.componentWillUnmount=="function"&&Pg(l,a,u)),Us(r,a,l);break;case 21:Us(r,a,l);break;case 22:qn=(u=qn)||l.memoizedState!==null,Us(r,a,l),qn=u;break;default:Us(r,a,l)}}function Kg(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{Wi(r)}catch(l){dn(a,a.return,l)}}}function Wg(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{Wi(r)}catch(l){dn(a,a.return,l)}}function U5(r){switch(r.tag){case 31:case 13:case 19:var a=r.stateNode;return a===null&&(a=r.stateNode=new Fg),a;case 22:return r=r.stateNode,a=r._retryCache,a===null&&(a=r._retryCache=new Fg),a;default:throw Error(i(435,r.tag))}}function Oc(r,a){var l=U5(r);a.forEach(function(u){if(!l.has(u)){l.add(u);var b=Z5.bind(null,r,u);u.then(b,b)}})}function br(r,a){var l=a.deletions;if(l!==null)for(var u=0;u<l.length;u++){var b=l[u],j=r,H=a,J=H;e:for(;J!==null;){switch(J.tag){case 27:if(wa(J.type)){_n=J.stateNode,gr=!1;break e}break;case 5:_n=J.stateNode,gr=!1;break e;case 3:case 4:_n=J.stateNode.containerInfo,gr=!0;break e}J=J.return}if(_n===null)throw Error(i(160));Xg(j,H,b),_n=null,gr=!1,j=b.alternate,j!==null&&(j.return=null),b.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)Zg(a,r),a=a.sibling}var as=null;function Zg(r,a){var l=r.alternate,u=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:br(a,r),yr(r),u&4&&(xa(3,r,r.return),Vl(3,r),xa(5,r,r.return));break;case 1:br(a,r),yr(r),u&512&&(qn||l===null||ys(l,l.return)),u&64&&Ps&&(r=r.updateQueue,r!==null&&(u=r.callbacks,u!==null&&(l=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=l===null?u:l.concat(u))));break;case 26:var b=as;if(br(a,r),yr(r),u&512&&(qn||l===null||ys(l,l.return)),u&4){var j=l!==null?l.memoizedState:null;if(u=r.memoizedState,l===null)if(u===null)if(r.stateNode===null){e:{u=r.type,l=r.memoizedProps,b=b.ownerDocument||b;t:switch(u){case"title":j=b.getElementsByTagName("title")[0],(!j||j[Xe]||j[Je]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=b.createElement(u),b.head.insertBefore(j,b.querySelector("head > title"))),ir(j,u,l),j[Je]=r,on(j),u=j;break e;case"link":var H=Z0("link","href",b).get(u+(l.href||""));if(H){for(var J=0;J<H.length;J++)if(j=H[J],j.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&j.getAttribute("rel")===(l.rel==null?null:l.rel)&&j.getAttribute("title")===(l.title==null?null:l.title)&&j.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){H.splice(J,1);break t}}j=b.createElement(u),ir(j,u,l),b.head.appendChild(j);break;case"meta":if(H=Z0("meta","content",b).get(u+(l.content||""))){for(J=0;J<H.length;J++)if(j=H[J],j.getAttribute("content")===(l.content==null?null:""+l.content)&&j.getAttribute("name")===(l.name==null?null:l.name)&&j.getAttribute("property")===(l.property==null?null:l.property)&&j.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&j.getAttribute("charset")===(l.charSet==null?null:l.charSet)){H.splice(J,1);break t}}j=b.createElement(u),ir(j,u,l),b.head.appendChild(j);break;default:throw Error(i(468,u))}j[Je]=r,on(j),u=j}r.stateNode=u}else Q0(b,r.type,r.stateNode);else r.stateNode=W0(b,u,r.memoizedProps);else j!==u?(j===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):j.count--,u===null?Q0(b,r.type,r.stateNode):W0(b,u,r.memoizedProps)):u===null&&r.stateNode!==null&&_f(r,r.memoizedProps,l.memoizedProps)}break;case 27:br(a,r),yr(r),u&512&&(qn||l===null||ys(l,l.return)),l!==null&&u&4&&_f(r,r.memoizedProps,l.memoizedProps);break;case 5:if(br(a,r),yr(r),u&512&&(qn||l===null||ys(l,l.return)),r.flags&32){b=r.stateNode;try{Ur(b,"")}catch(nt){dn(r,r.return,nt)}}u&4&&r.stateNode!=null&&(b=r.memoizedProps,_f(r,b,l!==null?l.memoizedProps:b)),u&1024&&(Of=!0);break;case 6:if(br(a,r),yr(r),u&4){if(r.stateNode===null)throw Error(i(162));u=r.memoizedProps,l=r.stateNode;try{l.nodeValue=u}catch(nt){dn(r,r.return,nt)}}break;case 3:if(Xc=null,b=as,as=Yc(a.containerInfo),br(a,r),as=b,yr(r),u&4&&l!==null&&l.memoizedState.isDehydrated)try{Wi(a.containerInfo)}catch(nt){dn(r,r.return,nt)}Of&&(Of=!1,Qg(r));break;case 4:u=as,as=Yc(r.stateNode.containerInfo),br(a,r),yr(r),as=u;break;case 12:br(a,r),yr(r);break;case 31:br(a,r),yr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Oc(r,u)));break;case 13:br(a,r),yr(r),r.child.flags&8192&&r.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Dc=yt()),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Oc(r,u)));break;case 22:b=r.memoizedState!==null;var ie=l!==null&&l.memoizedState!==null,ge=Ps,_e=qn;if(Ps=ge||b,qn=_e||ie,br(a,r),qn=_e,Ps=ge,yr(r),u&8192)e:for(a=r.stateNode,a._visibility=b?a._visibility&-2:a._visibility|1,b&&(l===null||ie||Ps||qn||ri(r)),l=null,a=r;;){if(a.tag===5||a.tag===26){if(l===null){ie=l=a;try{if(j=ie.stateNode,b)H=j.style,typeof H.setProperty=="function"?H.setProperty("display","none","important"):H.display="none";else{J=ie.stateNode;var De=ie.memoizedProps.style,be=De!=null&&De.hasOwnProperty("display")?De.display:null;J.style.display=be==null||typeof be=="boolean"?"":(""+be).trim()}}catch(nt){dn(ie,ie.return,nt)}}}else if(a.tag===6){if(l===null){ie=a;try{ie.stateNode.nodeValue=b?"":ie.memoizedProps}catch(nt){dn(ie,ie.return,nt)}}}else if(a.tag===18){if(l===null){ie=a;try{var ke=ie.stateNode;b?P0(ke,!0):P0(ie.stateNode,!1)}catch(nt){dn(ie,ie.return,nt)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===r)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break e;for(;a.sibling===null;){if(a.return===null||a.return===r)break e;l===a&&(l=null),a=a.return}l===a&&(l=null),a.sibling.return=a.return,a=a.sibling}u&4&&(u=r.updateQueue,u!==null&&(l=u.retryQueue,l!==null&&(u.retryQueue=null,Oc(r,l))));break;case 19:br(a,r),yr(r),u&4&&(u=r.updateQueue,u!==null&&(r.updateQueue=null,Oc(r,u)));break;case 30:break;case 21:break;default:br(a,r),yr(r)}}function yr(r){var a=r.flags;if(a&2){try{for(var l,u=r.return;u!==null;){if(qg(u)){l=u;break}u=u.return}if(l==null)throw Error(i(160));switch(l.tag){case 27:var b=l.stateNode,j=Af(r);Mc(r,j,b);break;case 5:var H=l.stateNode;l.flags&32&&(Ur(H,""),l.flags&=-33);var J=Af(r);Mc(r,J,H);break;case 3:case 4:var ie=l.stateNode.containerInfo,ge=Af(r);Mf(r,ge,ie);break;default:throw Error(i(161))}}catch(_e){dn(r,r.return,_e)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function Qg(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var a=r;Qg(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),r=r.sibling}}function qs(r,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)Yg(r,a.alternate,a),a=a.sibling}function ri(r){for(r=r.child;r!==null;){var a=r;switch(a.tag){case 0:case 11:case 14:case 15:xa(4,a,a.return),ri(a);break;case 1:ys(a,a.return);var l=a.stateNode;typeof l.componentWillUnmount=="function"&&Pg(a,a.return,l),ri(a);break;case 27:eo(a.stateNode);case 26:case 5:ys(a,a.return),ri(a);break;case 22:a.memoizedState===null&&ri(a);break;case 30:ri(a);break;default:ri(a)}r=r.sibling}}function Vs(r,a,l){for(l=l&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var u=a.alternate,b=r,j=a,H=j.flags;switch(j.tag){case 0:case 11:case 15:Vs(b,j,l),Vl(4,j);break;case 1:if(Vs(b,j,l),u=j,b=u.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(ge){dn(u,u.return,ge)}if(u=j,b=u.updateQueue,b!==null){var J=u.stateNode;try{var ie=b.shared.hiddenCallbacks;if(ie!==null)for(b.shared.hiddenCallbacks=null,b=0;b<ie.length;b++)_p(ie[b],J)}catch(ge){dn(u,u.return,ge)}}l&&H&64&&Hg(j),Fl(j,j.return);break;case 27:Vg(j);case 26:case 5:Vs(b,j,l),l&&u===null&&H&4&&Ug(j),Fl(j,j.return);break;case 12:Vs(b,j,l);break;case 31:Vs(b,j,l),l&&H&4&&Kg(b,j);break;case 13:Vs(b,j,l),l&&H&4&&Wg(b,j);break;case 22:j.memoizedState===null&&Vs(b,j,l),Fl(j,j.return);break;case 30:break;default:Vs(b,j,l)}a=a.sibling}}function Rf(r,a){var l=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),r=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(r=a.memoizedState.cachePool.pool),r!==l&&(r!=null&&r.refCount++,l!=null&&Ml(l))}function Df(r,a){r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Ml(r))}function is(r,a,l,u){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)Jg(r,a,l,u),a=a.sibling}function Jg(r,a,l,u){var b=a.flags;switch(a.tag){case 0:case 11:case 15:is(r,a,l,u),b&2048&&Vl(9,a);break;case 1:is(r,a,l,u);break;case 3:is(r,a,l,u),b&2048&&(r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Ml(r)));break;case 12:if(b&2048){is(r,a,l,u),r=a.stateNode;try{var j=a.memoizedProps,H=j.id,J=j.onPostCommit;typeof J=="function"&&J(H,a.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(ie){dn(a,a.return,ie)}}else is(r,a,l,u);break;case 31:is(r,a,l,u);break;case 13:is(r,a,l,u);break;case 23:break;case 22:j=a.stateNode,H=a.alternate,a.memoizedState!==null?j._visibility&2?is(r,a,l,u):Yl(r,a):j._visibility&2?is(r,a,l,u):(j._visibility|=2,Bi(r,a,l,u,(a.subtreeFlags&10256)!==0||!1)),b&2048&&Rf(H,a);break;case 24:is(r,a,l,u),b&2048&&Df(a.alternate,a);break;default:is(r,a,l,u)}}function Bi(r,a,l,u,b){for(b=b&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var j=r,H=a,J=l,ie=u,ge=H.flags;switch(H.tag){case 0:case 11:case 15:Bi(j,H,J,ie,b),Vl(8,H);break;case 23:break;case 22:var _e=H.stateNode;H.memoizedState!==null?_e._visibility&2?Bi(j,H,J,ie,b):Yl(j,H):(_e._visibility|=2,Bi(j,H,J,ie,b)),b&&ge&2048&&Rf(H.alternate,H);break;case 24:Bi(j,H,J,ie,b),b&&ge&2048&&Df(H.alternate,H);break;default:Bi(j,H,J,ie,b)}a=a.sibling}}function Yl(r,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var l=r,u=a,b=u.flags;switch(u.tag){case 22:Yl(l,u),b&2048&&Rf(u.alternate,u);break;case 24:Yl(l,u),b&2048&&Df(u.alternate,u);break;default:Yl(l,u)}a=a.sibling}}var Gl=8192;function Hi(r,a,l){if(r.subtreeFlags&Gl)for(r=r.child;r!==null;)e0(r,a,l),r=r.sibling}function e0(r,a,l){switch(r.tag){case 26:Hi(r,a,l),r.flags&Gl&&r.memoizedState!==null&&T2(l,as,r.memoizedState,r.memoizedProps);break;case 5:Hi(r,a,l);break;case 3:case 4:var u=as;as=Yc(r.stateNode.containerInfo),Hi(r,a,l),as=u;break;case 22:r.memoizedState===null&&(u=r.alternate,u!==null&&u.memoizedState!==null?(u=Gl,Gl=16777216,Hi(r,a,l),Gl=u):Hi(r,a,l));break;default:Hi(r,a,l)}}function t0(r){var a=r.alternate;if(a!==null&&(r=a.child,r!==null)){a.child=null;do a=r.sibling,r.sibling=null,r=a;while(r!==null)}}function Xl(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var u=a[l];er=u,r0(u,r)}t0(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)n0(r),r=r.sibling}function n0(r){switch(r.tag){case 0:case 11:case 15:Xl(r),r.flags&2048&&xa(9,r,r.return);break;case 3:Xl(r);break;case 12:Xl(r);break;case 22:var a=r.stateNode;r.memoizedState!==null&&a._visibility&2&&(r.return===null||r.return.tag!==13)?(a._visibility&=-3,Rc(r)):Xl(r);break;default:Xl(r)}}function Rc(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var u=a[l];er=u,r0(u,r)}t0(r)}for(r=r.child;r!==null;){switch(a=r,a.tag){case 0:case 11:case 15:xa(8,a,a.return),Rc(a);break;case 22:l=a.stateNode,l._visibility&2&&(l._visibility&=-3,Rc(a));break;default:Rc(a)}r=r.sibling}}function r0(r,a){for(;er!==null;){var l=er;switch(l.tag){case 0:case 11:case 15:xa(8,l,a);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var u=l.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Ml(l.memoizedState.cache)}if(u=l.child,u!==null)u.return=l,er=u;else e:for(l=r;er!==null;){u=er;var b=u.sibling,j=u.return;if(Gg(u),u===l){er=null;break e}if(b!==null){b.return=j,er=b;break e}er=j}}}var q5={getCacheForType:function(r){var a=sr(Hn),l=a.data.get(r);return l===void 0&&(l=r(),a.data.set(r,l)),l},cacheSignal:function(){return sr(Hn).controller.signal}},V5=typeof WeakMap=="function"?WeakMap:Map,sn=0,vn=null,Pt=null,Ft=0,cn=0,Dr=null,pa=!1,Pi=!1,Lf=!1,Fs=0,Ln=0,ga=0,si=0,If=0,Lr=0,Ui=0,Kl=null,vr=null,zf=!1,Dc=0,s0=0,Lc=1/0,Ic=null,ba=null,Wn=0,ya=null,qi=null,Ys=0,$f=0,Bf=null,a0=null,Wl=0,Hf=null;function Ir(){return(sn&2)!==0&&Ft!==0?Ft&-Ft:A.T!==null?Yf():it()}function i0(){if(Lr===0)if((Ft&536870912)===0||Xt){var r=ye;ye<<=1,(ye&3932160)===0&&(ye=262144),Lr=r}else Lr=536870912;return r=Or.current,r!==null&&(r.flags|=32),Lr}function jr(r,a,l){(r===vn&&(cn===2||cn===9)||r.cancelPendingCommit!==null)&&(Vi(r,0),va(r,Ft,Lr,!1)),mn(r,l),((sn&2)===0||r!==vn)&&(r===vn&&((sn&2)===0&&(si|=l),Ln===4&&va(r,Ft,Lr,!1)),vs(r))}function l0(r,a,l){if((sn&6)!==0)throw Error(i(327));var u=!l&&(a&127)===0&&(a&r.expiredLanes)===0||Tt(r,a),b=u?G5(r,a):Uf(r,a,!0),j=u;do{if(b===0){Pi&&!u&&va(r,a,0,!1);break}else{if(l=r.current.alternate,j&&!F5(l)){b=Uf(r,a,!1),j=!1;continue}if(b===2){if(j=a,r.errorRecoveryDisabledLanes&j)var H=0;else H=r.pendingLanes&-536870913,H=H!==0?H:H&536870912?536870912:0;if(H!==0){a=H;e:{var J=r;b=Kl;var ie=J.current.memoizedState.isDehydrated;if(ie&&(Vi(J,H).flags|=256),H=Uf(J,H,!1),H!==2){if(Lf&&!ie){J.errorRecoveryDisabledLanes|=j,si|=j,b=4;break e}j=vr,vr=b,j!==null&&(vr===null?vr=j:vr.push.apply(vr,j))}b=H}if(j=!1,b!==2)continue}}if(b===1){Vi(r,0),va(r,a,0,!0);break}e:{switch(u=r,j=b,j){case 0:case 1:throw Error(i(345));case 4:if((a&4194048)!==a)break;case 6:va(u,a,Lr,!pa);break e;case 2:vr=null;break;case 3:case 5:break;default:throw Error(i(329))}if((a&62914560)===a&&(b=Dc+300-yt(),10<b)){if(va(u,a,Lr,!pa),wt(u,0,!0)!==0)break e;Ys=a,u.timeoutHandle=$0(o0.bind(null,u,l,vr,Ic,zf,a,Lr,si,Ui,pa,j,"Throttled",-0,0),b);break e}o0(u,l,vr,Ic,zf,a,Lr,si,Ui,pa,j,null,-0,0)}}break}while(!0);vs(r)}function o0(r,a,l,u,b,j,H,J,ie,ge,_e,De,be,ke){if(r.timeoutHandle=-1,De=a.subtreeFlags,De&8192||(De&16785408)===16785408){De={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:le},e0(a,j,De);var nt=(j&62914560)===j?Dc-yt():(j&4194048)===j?s0-yt():0;if(nt=_2(De,nt),nt!==null){Ys=j,r.cancelPendingCommit=nt(p0.bind(null,r,a,j,l,u,b,H,J,ie,_e,De,null,be,ke)),va(r,j,H,!ge);return}}p0(r,a,j,l,u,b,H,J,ie)}function F5(r){for(var a=r;;){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 u=0;u<l.length;u++){var b=l[u],j=b.getSnapshot;b=b.value;try{if(!Ar(j(),b))return!1}catch{return!1}}if(l=a.child,a.subtreeFlags&16384&&l!==null)l.return=a,a=l;else{if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function va(r,a,l,u){a&=~If,a&=~si,r.suspendedLanes|=a,r.pingedLanes&=~a,u&&(r.warmLanes|=a),u=r.expirationTimes;for(var b=a;0<b;){var j=31-Ct(b),H=1<<j;u[j]=-1,b&=~H}l!==0&&Nt(r,l,a)}function zc(){return(sn&6)===0?(Zl(0),!1):!0}function Pf(){if(Pt!==null){if(cn===0)var r=Pt.return;else r=Pt,Ls=Ka=null,nf(r),Di=null,Rl=0,r=Pt;for(;r!==null;)Bg(r.alternate,r),r=r.return;Pt=null}}function Vi(r,a){var l=r.timeoutHandle;l!==-1&&(r.timeoutHandle=-1,u2(l)),l=r.cancelPendingCommit,l!==null&&(r.cancelPendingCommit=null,l()),Ys=0,Pf(),vn=r,Pt=l=Rs(r.current,null),Ft=a,cn=0,Dr=null,pa=!1,Pi=Tt(r,a),Lf=!1,Ui=Lr=If=si=ga=Ln=0,vr=Kl=null,zf=!1,(a&8)!==0&&(a|=a&32);var u=r.entangledLanes;if(u!==0)for(r=r.entanglements,u&=a;0<u;){var b=31-Ct(u),j=1<<b;a|=r[b],u&=~j}return Fs=a,sc(),l}function c0(r,a){Rt=null,A.H=Pl,a===Ri||a===fc?(a=Sp(),cn=3):a===Vu?(a=Sp(),cn=4):cn=a===yf?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Dr=a,Pt===null&&(Ln=1,Cc(r,Vr(a,r.current)))}function d0(){var r=Or.current;return r===null?!0:(Ft&4194048)===Ft?Xr===null:(Ft&62914560)===Ft||(Ft&536870912)!==0?r===Xr:!1}function u0(){var r=A.H;return A.H=Pl,r===null?Pl:r}function f0(){var r=A.A;return A.A=q5,r}function $c(){Ln=4,pa||(Ft&4194048)!==Ft&&Or.current!==null||(Pi=!0),(ga&134217727)===0&&(si&134217727)===0||vn===null||va(vn,Ft,Lr,!1)}function Uf(r,a,l){var u=sn;sn|=2;var b=u0(),j=f0();(vn!==r||Ft!==a)&&(Ic=null,Vi(r,a)),a=!1;var H=Ln;e:do try{if(cn!==0&&Pt!==null){var J=Pt,ie=Dr;switch(cn){case 8:Pf(),H=6;break e;case 3:case 2:case 9:case 6:Or.current===null&&(a=!0);var ge=cn;if(cn=0,Dr=null,Fi(r,J,ie,ge),l&&Pi){H=0;break e}break;default:ge=cn,cn=0,Dr=null,Fi(r,J,ie,ge)}}Y5(),H=Ln;break}catch(_e){c0(r,_e)}while(!0);return a&&r.shellSuspendCounter++,Ls=Ka=null,sn=u,A.H=b,A.A=j,Pt===null&&(vn=null,Ft=0,sc()),H}function Y5(){for(;Pt!==null;)h0(Pt)}function G5(r,a){var l=sn;sn|=2;var u=u0(),b=f0();vn!==r||Ft!==a?(Ic=null,Lc=yt()+500,Vi(r,a)):Pi=Tt(r,a);e:do try{if(cn!==0&&Pt!==null){a=Pt;var j=Dr;t:switch(cn){case 1:cn=0,Dr=null,Fi(r,a,j,1);break;case 2:case 9:if(Np(j)){cn=0,Dr=null,m0(a);break}a=function(){cn!==2&&cn!==9||vn!==r||(cn=7),vs(r)},j.then(a,a);break e;case 3:cn=7;break e;case 4:cn=5;break e;case 7:Np(j)?(cn=0,Dr=null,m0(a)):(cn=0,Dr=null,Fi(r,a,j,7));break;case 5:var H=null;switch(Pt.tag){case 26:H=Pt.memoizedState;case 5:case 27:var J=Pt;if(H?J0(H):J.stateNode.complete){cn=0,Dr=null;var ie=J.sibling;if(ie!==null)Pt=ie;else{var ge=J.return;ge!==null?(Pt=ge,Bc(ge)):Pt=null}break t}}cn=0,Dr=null,Fi(r,a,j,5);break;case 6:cn=0,Dr=null,Fi(r,a,j,6);break;case 8:Pf(),Ln=6;break e;default:throw Error(i(462))}}X5();break}catch(_e){c0(r,_e)}while(!0);return Ls=Ka=null,A.H=u,A.A=b,sn=l,Pt!==null?0:(vn=null,Ft=0,sc(),Ln)}function X5(){for(;Pt!==null&&!Ee();)h0(Pt)}function h0(r){var a=zg(r.alternate,r,Fs);r.memoizedProps=r.pendingProps,a===null?Bc(r):Pt=a}function m0(r){var a=r,l=a.alternate;switch(a.tag){case 15:case 0:a=Mg(l,a,a.pendingProps,a.type,void 0,Ft);break;case 11:a=Mg(l,a,a.pendingProps,a.type.render,a.ref,Ft);break;case 5:nf(a);default:Bg(l,a),a=Pt=fp(a,Fs),a=zg(l,a,Fs)}r.memoizedProps=r.pendingProps,a===null?Bc(r):Pt=a}function Fi(r,a,l,u){Ls=Ka=null,nf(a),Di=null,Rl=0;var b=a.return;try{if(I5(r,b,a,l,Ft)){Ln=1,Cc(r,Vr(l,r.current)),Pt=null;return}}catch(j){if(b!==null)throw Pt=b,j;Ln=1,Cc(r,Vr(l,r.current)),Pt=null;return}a.flags&32768?(Xt||u===1?r=!0:Pi||(Ft&536870912)!==0?r=!1:(pa=r=!0,(u===2||u===9||u===3||u===6)&&(u=Or.current,u!==null&&u.tag===13&&(u.flags|=16384))),x0(a,r)):Bc(a)}function Bc(r){var a=r;do{if((a.flags&32768)!==0){x0(a,pa);return}r=a.return;var l=B5(a.alternate,a,Fs);if(l!==null){Pt=l;return}if(a=a.sibling,a!==null){Pt=a;return}Pt=a=r}while(a!==null);Ln===0&&(Ln=5)}function x0(r,a){do{var l=H5(r.alternate,r);if(l!==null){l.flags&=32767,Pt=l;return}if(l=r.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!a&&(r=r.sibling,r!==null)){Pt=r;return}Pt=r=l}while(r!==null);Ln=6,Pt=null}function p0(r,a,l,u,b,j,H,J,ie){r.cancelPendingCommit=null;do Hc();while(Wn!==0);if((sn&6)!==0)throw Error(i(327));if(a!==null){if(a===r.current)throw Error(i(177));if(j=a.lanes|a.childLanes,j|=_u,On(r,l,j,H,J,ie),r===vn&&(Pt=vn=null,Ft=0),qi=a,ya=r,Ys=l,$f=j,Bf=b,a0=u,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,Q5(Ue,function(){return j0(),null})):(r.callbackNode=null,r.callbackPriority=0),u=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||u){u=A.T,A.T=null,b=O.p,O.p=2,H=sn,sn|=4;try{P5(r,a,l)}finally{sn=H,O.p=b,A.T=u}}Wn=1,g0(),b0(),y0()}}function g0(){if(Wn===1){Wn=0;var r=ya,a=qi,l=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||l){l=A.T,A.T=null;var u=O.p;O.p=2;var b=sn;sn|=4;try{Zg(a,r);var j=eh,H=rp(r.containerInfo),J=j.focusedElem,ie=j.selectionRange;if(H!==J&&J&&J.ownerDocument&&np(J.ownerDocument.documentElement,J)){if(ie!==null&&ku(J)){var ge=ie.start,_e=ie.end;if(_e===void 0&&(_e=ge),"selectionStart"in J)J.selectionStart=ge,J.selectionEnd=Math.min(_e,J.value.length);else{var De=J.ownerDocument||document,be=De&&De.defaultView||window;if(be.getSelection){var ke=be.getSelection(),nt=J.textContent.length,kt=Math.min(ie.start,nt),yn=ie.end===void 0?kt:Math.min(ie.end,nt);!ke.extend&&kt>yn&&(H=yn,yn=kt,kt=H);var ue=tp(J,kt),ce=tp(J,yn);if(ue&&ce&&(ke.rangeCount!==1||ke.anchorNode!==ue.node||ke.anchorOffset!==ue.offset||ke.focusNode!==ce.node||ke.focusOffset!==ce.offset)){var pe=De.createRange();pe.setStart(ue.node,ue.offset),ke.removeAllRanges(),kt>yn?(ke.addRange(pe),ke.extend(ce.node,ce.offset)):(pe.setEnd(ce.node,ce.offset),ke.addRange(pe))}}}}for(De=[],ke=J;ke=ke.parentNode;)ke.nodeType===1&&De.push({element:ke,left:ke.scrollLeft,top:ke.scrollTop});for(typeof J.focus=="function"&&J.focus(),J=0;J<De.length;J++){var Oe=De[J];Oe.element.scrollLeft=Oe.left,Oe.element.scrollTop=Oe.top}}Qc=!!Jf,eh=Jf=null}finally{sn=b,O.p=u,A.T=l}}r.current=a,Wn=2}}function b0(){if(Wn===2){Wn=0;var r=ya,a=qi,l=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||l){l=A.T,A.T=null;var u=O.p;O.p=2;var b=sn;sn|=4;try{Yg(r,a.alternate,a)}finally{sn=b,O.p=u,A.T=l}}Wn=3}}function y0(){if(Wn===4||Wn===3){Wn=0,Ze();var r=ya,a=qi,l=Ys,u=a0;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?Wn=5:(Wn=0,qi=ya=null,v0(r,r.pendingLanes));var b=r.pendingLanes;if(b===0&&(ba=null),dt(l),a=a.stateNode,Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(zt,a,void 0,(a.current.flags&128)===128)}catch{}if(u!==null){a=A.T,b=O.p,O.p=2,A.T=null;try{for(var j=r.onRecoverableError,H=0;H<u.length;H++){var J=u[H];j(J.value,{componentStack:J.stack})}}finally{A.T=a,O.p=b}}(Ys&3)!==0&&Hc(),vs(r),b=r.pendingLanes,(l&261930)!==0&&(b&42)!==0?r===Hf?Wl++:(Wl=0,Hf=r):Wl=0,Zl(0)}}function v0(r,a){(r.pooledCacheLanes&=a)===0&&(a=r.pooledCache,a!=null&&(r.pooledCache=null,Ml(a)))}function Hc(){return g0(),b0(),y0(),j0()}function j0(){if(Wn!==5)return!1;var r=ya,a=$f;$f=0;var l=dt(Ys),u=A.T,b=O.p;try{O.p=32>l?32:l,A.T=null,l=Bf,Bf=null;var j=ya,H=Ys;if(Wn=0,qi=ya=null,Ys=0,(sn&6)!==0)throw Error(i(331));var J=sn;if(sn|=4,n0(j.current),Jg(j,j.current,H,l),sn=J,Zl(0,!1),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(zt,j)}catch{}return!0}finally{O.p=b,A.T=u,v0(r,a)}}function w0(r,a,l){a=Vr(l,a),a=bf(r.stateNode,a,2),r=fa(r,a,2),r!==null&&(mn(r,2),vs(r))}function dn(r,a,l){if(r.tag===3)w0(r,r,l);else for(;a!==null;){if(a.tag===3){w0(a,r,l);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(ba===null||!ba.has(u))){r=Vr(l,r),l=Ng(2),u=fa(a,l,2),u!==null&&(kg(l,u,a,r),mn(u,2),vs(u));break}}a=a.return}}function qf(r,a,l){var u=r.pingCache;if(u===null){u=r.pingCache=new V5;var b=new Set;u.set(a,b)}else b=u.get(a),b===void 0&&(b=new Set,u.set(a,b));b.has(l)||(Lf=!0,b.add(l),r=K5.bind(null,r,a,l),a.then(r,r))}function K5(r,a,l){var u=r.pingCache;u!==null&&u.delete(a),r.pingedLanes|=r.suspendedLanes&l,r.warmLanes&=~l,vn===r&&(Ft&l)===l&&(Ln===4||Ln===3&&(Ft&62914560)===Ft&&300>yt()-Dc?(sn&2)===0&&Vi(r,0):If|=l,Ui===Ft&&(Ui=0)),vs(r)}function N0(r,a){a===0&&(a=nn()),r=Ya(r,a),r!==null&&(mn(r,a),vs(r))}function W5(r){var a=r.memoizedState,l=0;a!==null&&(l=a.retryLane),N0(r,l)}function Z5(r,a){var l=0;switch(r.tag){case 31:case 13:var u=r.stateNode,b=r.memoizedState;b!==null&&(l=b.retryLane);break;case 19:u=r.stateNode;break;case 22:u=r.stateNode._retryCache;break;default:throw Error(i(314))}u!==null&&u.delete(a),N0(r,l)}function Q5(r,a){return jt(r,a)}var Pc=null,Yi=null,Vf=!1,Uc=!1,Ff=!1,ja=0;function vs(r){r!==Yi&&r.next===null&&(Yi===null?Pc=Yi=r:Yi=Yi.next=r),Uc=!0,Vf||(Vf=!0,e2())}function Zl(r,a){if(!Ff&&Uc){Ff=!0;do for(var l=!1,u=Pc;u!==null;){if(r!==0){var b=u.pendingLanes;if(b===0)var j=0;else{var H=u.suspendedLanes,J=u.pingedLanes;j=(1<<31-Ct(42|r)+1)-1,j&=b&~(H&~J),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(l=!0,E0(u,j))}else j=Ft,j=wt(u,u===vn?j:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(j&3)===0||Tt(u,j)||(l=!0,E0(u,j));u=u.next}while(l);Ff=!1}}function J5(){k0()}function k0(){Uc=Vf=!1;var r=0;ja!==0&&d2()&&(r=ja);for(var a=yt(),l=null,u=Pc;u!==null;){var b=u.next,j=S0(u,a);j===0?(u.next=null,l===null?Pc=b:l.next=b,b===null&&(Yi=l)):(l=u,(r!==0||(j&3)!==0)&&(Uc=!0)),u=b}Wn!==0&&Wn!==5||Zl(r),ja!==0&&(ja=0)}function S0(r,a){for(var l=r.suspendedLanes,u=r.pingedLanes,b=r.expirationTimes,j=r.pendingLanes&-62914561;0<j;){var H=31-Ct(j),J=1<<H,ie=b[H];ie===-1?((J&l)===0||(J&u)!==0)&&(b[H]=tn(J,a)):ie<=a&&(r.expiredLanes|=J),j&=~J}if(a=vn,l=Ft,l=wt(r,r===a?l:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u=r.callbackNode,l===0||r===a&&(cn===2||cn===9)||r.cancelPendingCommit!==null)return u!==null&&u!==null&&re(u),r.callbackNode=null,r.callbackPriority=0;if((l&3)===0||Tt(r,l)){if(a=l&-l,a===r.callbackPriority)return a;switch(u!==null&&re(u),dt(l)){case 2:case 8:l=Le;break;case 32:l=Ue;break;case 268435456:l=rt;break;default:l=Ue}return u=C0.bind(null,r),l=jt(l,u),r.callbackPriority=a,r.callbackNode=l,a}return u!==null&&u!==null&&re(u),r.callbackPriority=2,r.callbackNode=null,2}function C0(r,a){if(Wn!==0&&Wn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var l=r.callbackNode;if(Hc()&&r.callbackNode!==l)return null;var u=Ft;return u=wt(r,r===vn?u:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),u===0?null:(l0(r,u,a),S0(r,yt()),r.callbackNode!=null&&r.callbackNode===l?C0.bind(null,r):null)}function E0(r,a){if(Hc())return null;l0(r,a,!0)}function e2(){f2(function(){(sn&6)!==0?jt(we,J5):k0()})}function Yf(){if(ja===0){var r=Mi;r===0&&(r=wn,wn<<=1,(wn&261888)===0&&(wn=256)),ja=r}return ja}function T0(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:K(""+r)}function _0(r,a){var l=a.ownerDocument.createElement("input");return l.name=a.name,l.value=a.value,r.id&&l.setAttribute("form",r.id),a.parentNode.insertBefore(l,a),r=new FormData(r),l.parentNode.removeChild(l),r}function t2(r,a,l,u,b){if(a==="submit"&&l&&l.stateNode===b){var j=T0((b[Fe]||null).action),H=u.submitter;H&&(a=(a=H[Fe]||null)?T0(a.formAction):H.getAttribute("formAction"),a!==null&&(j=a,H=null));var J=new aa("action","action",null,u,b);r.push({event:J,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(ja!==0){var ie=H?_0(b,H):new FormData(b);ff(l,{pending:!0,data:ie,method:b.method,action:j},null,ie)}}else typeof j=="function"&&(J.preventDefault(),ie=H?_0(b,H):new FormData(b),ff(l,{pending:!0,data:ie,method:b.method,action:j},j,ie))},currentTarget:b}]})}}for(var Gf=0;Gf<Tu.length;Gf++){var Xf=Tu[Gf],n2=Xf.toLowerCase(),r2=Xf[0].toUpperCase()+Xf.slice(1);ss(n2,"on"+r2)}ss(ip,"onAnimationEnd"),ss(lp,"onAnimationIteration"),ss(op,"onAnimationStart"),ss("dblclick","onDoubleClick"),ss("focusin","onFocus"),ss("focusout","onBlur"),ss(y5,"onTransitionRun"),ss(v5,"onTransitionStart"),ss(j5,"onTransitionCancel"),ss(cp,"onTransitionEnd"),Ae("onMouseEnter",["mouseout","mouseover"]),Ae("onMouseLeave",["mouseout","mouseover"]),Ae("onPointerEnter",["pointerout","pointerover"]),Ae("onPointerLeave",["pointerout","pointerover"]),de("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),de("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),de("onBeforeInput",["compositionend","keypress","textInput","paste"]),de("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),de("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),de("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ql="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(" "),s2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ql));function A0(r,a){a=(a&4)!==0;for(var l=0;l<r.length;l++){var u=r[l],b=u.event;u=u.listeners;e:{var j=void 0;if(a)for(var H=u.length-1;0<=H;H--){var J=u[H],ie=J.instance,ge=J.currentTarget;if(J=J.listener,ie!==j&&b.isPropagationStopped())break e;j=J,b.currentTarget=ge;try{j(b)}catch(_e){rc(_e)}b.currentTarget=null,j=ie}else for(H=0;H<u.length;H++){if(J=u[H],ie=J.instance,ge=J.currentTarget,J=J.listener,ie!==j&&b.isPropagationStopped())break e;j=J,b.currentTarget=ge;try{j(b)}catch(_e){rc(_e)}b.currentTarget=null,j=ie}}}}function Ut(r,a){var l=a[Rn];l===void 0&&(l=a[Rn]=new Set);var u=r+"__bubble";l.has(u)||(M0(a,r,2,!1),l.add(u))}function Kf(r,a,l){var u=0;a&&(u|=4),M0(l,r,u,a)}var qc="_reactListening"+Math.random().toString(36).slice(2);function Wf(r){if(!r[qc]){r[qc]=!0,ur.forEach(function(l){l!=="selectionchange"&&(s2.has(l)||Kf(l,!1,r),Kf(l,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[qc]||(a[qc]=!0,Kf("selectionchange",!1,a))}}function M0(r,a,l,u){switch(ib(a)){case 2:var b=O2;break;case 8:b=R2;break;default:b=uh}l=b.bind(null,a,l,r),b=void 0,!rn||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(b=!0),u?b!==void 0?r.addEventListener(a,l,{capture:!0,passive:b}):r.addEventListener(a,l,!0):b!==void 0?r.addEventListener(a,l,{passive:b}):r.addEventListener(a,l,!1)}function Zf(r,a,l,u,b){var j=u;if((a&1)===0&&(a&2)===0&&u!==null)e:for(;;){if(u===null)return;var H=u.tag;if(H===3||H===4){var J=u.stateNode.containerInfo;if(J===b)break;if(H===4)for(H=u.return;H!==null;){var ie=H.tag;if((ie===3||ie===4)&&H.stateNode.containerInfo===b)return;H=H.return}for(;J!==null;){if(H=St(J),H===null)return;if(ie=H.tag,ie===5||ie===6||ie===26||ie===27){u=j=H;continue e}J=J.parentNode}}u=u.return}et(function(){var ge=j,_e=Me(l),De=[];e:{var be=dp.get(r);if(be!==void 0){var ke=aa,nt=r;switch(r){case"keypress":if(Qe(l)===0)break e;case"keydown":case"keyup":ke=ZN;break;case"focusin":nt="focus",ke=yu;break;case"focusout":nt="blur",ke=yu;break;case"beforeblur":case"afterblur":ke=yu;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":ke=Bx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ke=BN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ke=e5;break;case ip:case lp:case op:ke=UN;break;case cp:ke=n5;break;case"scroll":case"scrollend":ke=zN;break;case"wheel":ke=s5;break;case"copy":case"cut":case"paste":ke=VN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ke=Px;break;case"toggle":case"beforetoggle":ke=i5}var kt=(a&4)!==0,yn=!kt&&(r==="scroll"||r==="scrollend"),ue=kt?be!==null?be+"Capture":null:be;kt=[];for(var ce=ge,pe;ce!==null;){var Oe=ce;if(pe=Oe.stateNode,Oe=Oe.tag,Oe!==5&&Oe!==26&&Oe!==27||pe===null||ue===null||(Oe=bt(ce,ue),Oe!=null&&kt.push(Jl(ce,Oe,pe))),yn)break;ce=ce.return}0<kt.length&&(be=new ke(be,nt,null,l,_e),De.push({event:be,listeners:kt}))}}if((a&7)===0){e:{if(be=r==="mouseover"||r==="pointerover",ke=r==="mouseout"||r==="pointerout",be&&l!==he&&(nt=l.relatedTarget||l.fromElement)&&(St(nt)||nt[Et]))break e;if((ke||be)&&(be=_e.window===_e?_e:(be=_e.ownerDocument)?be.defaultView||be.parentWindow:window,ke?(nt=l.relatedTarget||l.toElement,ke=ge,nt=nt?St(nt):null,nt!==null&&(yn=d(nt),kt=nt.tag,nt!==yn||kt!==5&&kt!==27&&kt!==6)&&(nt=null)):(ke=null,nt=ge),ke!==nt)){if(kt=Bx,Oe="onMouseLeave",ue="onMouseEnter",ce="mouse",(r==="pointerout"||r==="pointerover")&&(kt=Px,Oe="onPointerLeave",ue="onPointerEnter",ce="pointer"),yn=ke==null?be:Qn(ke),pe=nt==null?be:Qn(nt),be=new kt(Oe,ce+"leave",ke,l,_e),be.target=yn,be.relatedTarget=pe,Oe=null,St(_e)===ge&&(kt=new kt(ue,ce+"enter",nt,l,_e),kt.target=pe,kt.relatedTarget=yn,Oe=kt),yn=Oe,ke&&nt)t:{for(kt=a2,ue=ke,ce=nt,pe=0,Oe=ue;Oe;Oe=kt(Oe))pe++;Oe=0;for(var gt=ce;gt;gt=kt(gt))Oe++;for(;0<pe-Oe;)ue=kt(ue),pe--;for(;0<Oe-pe;)ce=kt(ce),Oe--;for(;pe--;){if(ue===ce||ce!==null&&ue===ce.alternate){kt=ue;break t}ue=kt(ue),ce=kt(ce)}kt=null}else kt=null;ke!==null&&O0(De,be,ke,kt,!1),nt!==null&&yn!==null&&O0(De,yn,nt,kt,!0)}}e:{if(be=ge?Qn(ge):window,ke=be.nodeName&&be.nodeName.toLowerCase(),ke==="select"||ke==="input"&&be.type==="file")var Qt=Kx;else if(Gx(be))if(Wx)Qt=p5;else{Qt=m5;var lt=h5}else ke=be.nodeName,!ke||ke.toLowerCase()!=="input"||be.type!=="checkbox"&&be.type!=="radio"?ge&&Os(ge.elementType)&&(Qt=Kx):Qt=x5;if(Qt&&(Qt=Qt(r,ge))){Xx(De,Qt,l,_e);break e}lt&&lt(r,be,ge),r==="focusout"&&ge&&be.type==="number"&&ge.memoizedProps.value!=null&&Tr(be,"number",be.value)}switch(lt=ge?Qn(ge):window,r){case"focusin":(Gx(lt)||lt.contentEditable==="true")&&(Ni=lt,Su=ge,Tl=null);break;case"focusout":Tl=Su=Ni=null;break;case"mousedown":Cu=!0;break;case"contextmenu":case"mouseup":case"dragend":Cu=!1,sp(De,l,_e);break;case"selectionchange":if(b5)break;case"keydown":case"keyup":sp(De,l,_e)}var Lt;if(ju)e:{switch(r){case"compositionstart":var Yt="onCompositionStart";break e;case"compositionend":Yt="onCompositionEnd";break e;case"compositionupdate":Yt="onCompositionUpdate";break e}Yt=void 0}else wi?Fx(r,l)&&(Yt="onCompositionEnd"):r==="keydown"&&l.keyCode===229&&(Yt="onCompositionStart");Yt&&(Ux&&l.locale!=="ko"&&(wi||Yt!=="onCompositionStart"?Yt==="onCompositionEnd"&&wi&&(Lt=tt()):(ct=_e,ht="value"in ct?ct.value:ct.textContent,wi=!0)),lt=Vc(ge,Yt),0<lt.length&&(Yt=new Hx(Yt,r,null,l,_e),De.push({event:Yt,listeners:lt}),Lt?Yt.data=Lt:(Lt=Yx(l),Lt!==null&&(Yt.data=Lt)))),(Lt=o5?c5(r,l):d5(r,l))&&(Yt=Vc(ge,"onBeforeInput"),0<Yt.length&&(lt=new Hx("onBeforeInput","beforeinput",null,l,_e),De.push({event:lt,listeners:Yt}),lt.data=Lt)),t2(De,r,ge,l,_e)}A0(De,a)})}function Jl(r,a,l){return{instance:r,listener:a,currentTarget:l}}function Vc(r,a){for(var l=a+"Capture",u=[];r!==null;){var b=r,j=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||j===null||(b=bt(r,l),b!=null&&u.unshift(Jl(r,b,j)),b=bt(r,a),b!=null&&u.push(Jl(r,b,j))),r.tag===3)return u;r=r.return}return[]}function a2(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function O0(r,a,l,u,b){for(var j=a._reactName,H=[];l!==null&&l!==u;){var J=l,ie=J.alternate,ge=J.stateNode;if(J=J.tag,ie!==null&&ie===u)break;J!==5&&J!==26&&J!==27||ge===null||(ie=ge,b?(ge=bt(l,j),ge!=null&&H.unshift(Jl(l,ge,ie))):b||(ge=bt(l,j),ge!=null&&H.push(Jl(l,ge,ie)))),l=l.return}H.length!==0&&r.push({event:a,listeners:H})}var i2=/\r\n?/g,l2=/\u0000|\uFFFD/g;function R0(r){return(typeof r=="string"?r:""+r).replace(i2,`
9
- `).replace(l2,"")}function D0(r,a){return a=R0(a),R0(r)===a}function bn(r,a,l,u,b,j){switch(l){case"children":typeof u=="string"?a==="body"||a==="textarea"&&u===""||Ur(r,u):(typeof u=="number"||typeof u=="bigint")&&a!=="body"&&Ur(r,""+u);break;case"className":ms(r,"class",u);break;case"tabIndex":ms(r,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":ms(r,l,u);break;case"style":sa(r,u,j);break;case"data":if(a!=="object"){ms(r,"data",u);break}case"src":case"href":if(u===""&&(a!=="a"||l!=="href")){r.removeAttribute(l);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(l);break}u=K(""+u),r.setAttribute(l,u);break;case"action":case"formAction":if(typeof u=="function"){r.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 j=="function"&&(l==="formAction"?(a!=="input"&&bn(r,a,"name",b.name,b,null),bn(r,a,"formEncType",b.formEncType,b,null),bn(r,a,"formMethod",b.formMethod,b,null),bn(r,a,"formTarget",b.formTarget,b,null)):(bn(r,a,"encType",b.encType,b,null),bn(r,a,"method",b.method,b,null),bn(r,a,"target",b.target,b,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){r.removeAttribute(l);break}u=K(""+u),r.setAttribute(l,u);break;case"onClick":u!=null&&(r.onclick=le);break;case"onScroll":u!=null&&Ut("scroll",r);break;case"onScrollEnd":u!=null&&Ut("scrollend",r);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(l=u.__html,l!=null){if(b.children!=null)throw Error(i(60));r.innerHTML=l}}break;case"multiple":r.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":r.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){r.removeAttribute("xlink:href");break}l=K(""+u),r.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":u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(l,""+u):r.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":u&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(l,""):r.removeAttribute(l);break;case"capture":case"download":u===!0?r.setAttribute(l,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?r.setAttribute(l,u):r.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?r.setAttribute(l,u):r.removeAttribute(l);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?r.removeAttribute(l):r.setAttribute(l,u);break;case"popover":Ut("beforetoggle",r),Ut("toggle",r),fr(r,"popover",u);break;case"xlinkActuate":nr(r,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":nr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":nr(r,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":nr(r,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":nr(r,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":nr(r,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":nr(r,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":nr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":nr(r,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":fr(r,"is",u);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Ua.get(l)||l,fr(r,l,u))}}function Qf(r,a,l,u,b,j){switch(l){case"style":sa(r,u,j);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(l=u.__html,l!=null){if(b.children!=null)throw Error(i(60));r.innerHTML=l}}break;case"children":typeof u=="string"?Ur(r,u):(typeof u=="number"||typeof u=="bigint")&&Ur(r,""+u);break;case"onScroll":u!=null&&Ut("scroll",r);break;case"onScrollEnd":u!=null&&Ut("scrollend",r);break;case"onClick":u!=null&&(r.onclick=le);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Jr.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(b=l.endsWith("Capture"),a=l.slice(2,b?l.length-7:void 0),j=r[Fe]||null,j=j!=null?j[l]:null,typeof j=="function"&&r.removeEventListener(a,j,b),typeof u=="function")){typeof j!="function"&&j!==null&&(l in r?r[l]=null:r.hasAttribute(l)&&r.removeAttribute(l)),r.addEventListener(a,u,b);break e}l in r?r[l]=u:u===!0?r.setAttribute(l,""):fr(r,l,u)}}}function ir(r,a,l){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ut("error",r),Ut("load",r);var u=!1,b=!1,j;for(j in l)if(l.hasOwnProperty(j)){var H=l[j];if(H!=null)switch(j){case"src":u=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:bn(r,a,j,H,l,null)}}b&&bn(r,a,"srcSet",l.srcSet,l,null),u&&bn(r,a,"src",l.src,l,null);return;case"input":Ut("invalid",r);var J=j=H=b=null,ie=null,ge=null;for(u in l)if(l.hasOwnProperty(u)){var _e=l[u];if(_e!=null)switch(u){case"name":b=_e;break;case"type":H=_e;break;case"checked":ie=_e;break;case"defaultChecked":ge=_e;break;case"value":j=_e;break;case"defaultValue":J=_e;break;case"children":case"dangerouslySetInnerHTML":if(_e!=null)throw Error(i(137,a));break;default:bn(r,a,u,_e,l,null)}}Kn(r,j,J,ie,ge,H,b,!1);return;case"select":Ut("invalid",r),u=H=j=null;for(b in l)if(l.hasOwnProperty(b)&&(J=l[b],J!=null))switch(b){case"value":j=J;break;case"defaultValue":H=J;break;case"multiple":u=J;default:bn(r,a,b,J,l,null)}a=j,l=H,r.multiple=!!u,a!=null?pr(r,!!u,a,!1):l!=null&&pr(r,!!u,l,!0);return;case"textarea":Ut("invalid",r),j=b=u=null;for(H in l)if(l.hasOwnProperty(H)&&(J=l[H],J!=null))switch(H){case"value":u=J;break;case"defaultValue":b=J;break;case"children":j=J;break;case"dangerouslySetInnerHTML":if(J!=null)throw Error(i(91));break;default:bn(r,a,H,J,l,null)}_r(r,u,b,j);return;case"option":for(ie in l)l.hasOwnProperty(ie)&&(u=l[ie],u!=null)&&(ie==="selected"?r.selected=u&&typeof u!="function"&&typeof u!="symbol":bn(r,a,ie,u,l,null));return;case"dialog":Ut("beforetoggle",r),Ut("toggle",r),Ut("cancel",r),Ut("close",r);break;case"iframe":case"object":Ut("load",r);break;case"video":case"audio":for(u=0;u<Ql.length;u++)Ut(Ql[u],r);break;case"image":Ut("error",r),Ut("load",r);break;case"details":Ut("toggle",r);break;case"embed":case"source":case"link":Ut("error",r),Ut("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ge in l)if(l.hasOwnProperty(ge)&&(u=l[ge],u!=null))switch(ge){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,a));default:bn(r,a,ge,u,l,null)}return;default:if(Os(a)){for(_e in l)l.hasOwnProperty(_e)&&(u=l[_e],u!==void 0&&Qf(r,a,_e,u,l,void 0));return}}for(J in l)l.hasOwnProperty(J)&&(u=l[J],u!=null&&bn(r,a,J,u,l,null))}function o2(r,a,l,u){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var b=null,j=null,H=null,J=null,ie=null,ge=null,_e=null;for(ke in l){var De=l[ke];if(l.hasOwnProperty(ke)&&De!=null)switch(ke){case"checked":break;case"value":break;case"defaultValue":ie=De;default:u.hasOwnProperty(ke)||bn(r,a,ke,null,u,De)}}for(var be in u){var ke=u[be];if(De=l[be],u.hasOwnProperty(be)&&(ke!=null||De!=null))switch(be){case"type":j=ke;break;case"name":b=ke;break;case"checked":ge=ke;break;case"defaultChecked":_e=ke;break;case"value":H=ke;break;case"defaultValue":J=ke;break;case"children":case"dangerouslySetInnerHTML":if(ke!=null)throw Error(i(137,a));break;default:ke!==De&&bn(r,a,be,ke,u,De)}}ns(r,H,J,ie,ge,_e,j,b);return;case"select":ke=H=J=be=null;for(j in l)if(ie=l[j],l.hasOwnProperty(j)&&ie!=null)switch(j){case"value":break;case"multiple":ke=ie;default:u.hasOwnProperty(j)||bn(r,a,j,null,u,ie)}for(b in u)if(j=u[b],ie=l[b],u.hasOwnProperty(b)&&(j!=null||ie!=null))switch(b){case"value":be=j;break;case"defaultValue":J=j;break;case"multiple":H=j;default:j!==ie&&bn(r,a,b,j,u,ie)}a=J,l=H,u=ke,be!=null?pr(r,!!l,be,!1):!!u!=!!l&&(a!=null?pr(r,!!l,a,!0):pr(r,!!l,l?[]:"",!1));return;case"textarea":ke=be=null;for(J in l)if(b=l[J],l.hasOwnProperty(J)&&b!=null&&!u.hasOwnProperty(J))switch(J){case"value":break;case"children":break;default:bn(r,a,J,null,u,b)}for(H in u)if(b=u[H],j=l[H],u.hasOwnProperty(H)&&(b!=null||j!=null))switch(H){case"value":be=b;break;case"defaultValue":ke=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(i(91));break;default:b!==j&&bn(r,a,H,b,u,j)}xs(r,be,ke);return;case"option":for(var nt in l)be=l[nt],l.hasOwnProperty(nt)&&be!=null&&!u.hasOwnProperty(nt)&&(nt==="selected"?r.selected=!1:bn(r,a,nt,null,u,be));for(ie in u)be=u[ie],ke=l[ie],u.hasOwnProperty(ie)&&be!==ke&&(be!=null||ke!=null)&&(ie==="selected"?r.selected=be&&typeof be!="function"&&typeof be!="symbol":bn(r,a,ie,be,u,ke));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var kt in l)be=l[kt],l.hasOwnProperty(kt)&&be!=null&&!u.hasOwnProperty(kt)&&bn(r,a,kt,null,u,be);for(ge in u)if(be=u[ge],ke=l[ge],u.hasOwnProperty(ge)&&be!==ke&&(be!=null||ke!=null))switch(ge){case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(i(137,a));break;default:bn(r,a,ge,be,u,ke)}return;default:if(Os(a)){for(var yn in l)be=l[yn],l.hasOwnProperty(yn)&&be!==void 0&&!u.hasOwnProperty(yn)&&Qf(r,a,yn,void 0,u,be);for(_e in u)be=u[_e],ke=l[_e],!u.hasOwnProperty(_e)||be===ke||be===void 0&&ke===void 0||Qf(r,a,_e,be,u,ke);return}}for(var ue in l)be=l[ue],l.hasOwnProperty(ue)&&be!=null&&!u.hasOwnProperty(ue)&&bn(r,a,ue,null,u,be);for(De in u)be=u[De],ke=l[De],!u.hasOwnProperty(De)||be===ke||be==null&&ke==null||bn(r,a,De,be,u,ke)}function L0(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function c2(){if(typeof performance.getEntriesByType=="function"){for(var r=0,a=0,l=performance.getEntriesByType("resource"),u=0;u<l.length;u++){var b=l[u],j=b.transferSize,H=b.initiatorType,J=b.duration;if(j&&J&&L0(H)){for(H=0,J=b.responseEnd,u+=1;u<l.length;u++){var ie=l[u],ge=ie.startTime;if(ge>J)break;var _e=ie.transferSize,De=ie.initiatorType;_e&&L0(De)&&(ie=ie.responseEnd,H+=_e*(ie<J?1:(J-ge)/(ie-ge)))}if(--u,a+=8*(j+H)/(b.duration/1e3),r++,10<r)break}}if(0<r)return a/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var Jf=null,eh=null;function Fc(r){return r.nodeType===9?r:r.ownerDocument}function I0(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function z0(r,a){if(r===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&a==="foreignObject"?0:r}function th(r,a){return r==="textarea"||r==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var nh=null;function d2(){var r=window.event;return r&&r.type==="popstate"?r===nh?!1:(nh=r,!0):(nh=null,!1)}var $0=typeof setTimeout=="function"?setTimeout:void 0,u2=typeof clearTimeout=="function"?clearTimeout:void 0,B0=typeof Promise=="function"?Promise:void 0,f2=typeof queueMicrotask=="function"?queueMicrotask:typeof B0<"u"?function(r){return B0.resolve(null).then(r).catch(h2)}:$0;function h2(r){setTimeout(function(){throw r})}function wa(r){return r==="head"}function H0(r,a){var l=a,u=0;do{var b=l.nextSibling;if(r.removeChild(l),b&&b.nodeType===8)if(l=b.data,l==="/$"||l==="/&"){if(u===0){r.removeChild(b),Wi(a);return}u--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")u++;else if(l==="html")eo(r.ownerDocument.documentElement);else if(l==="head"){l=r.ownerDocument.head,eo(l);for(var j=l.firstChild;j;){var H=j.nextSibling,J=j.nodeName;j[Xe]||J==="SCRIPT"||J==="STYLE"||J==="LINK"&&j.rel.toLowerCase()==="stylesheet"||l.removeChild(j),j=H}}else l==="body"&&eo(r.ownerDocument.body);l=b}while(l);Wi(a)}function P0(r,a){var l=r;r=0;do{var u=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||""),u&&u.nodeType===8)if(l=u.data,l==="/$"){if(r===0)break;r--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||r++;l=u}while(l)}function rh(r){var a=r.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":rh(l),At(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}r.removeChild(l)}}function m2(r,a,l,u){for(;r.nodeType===1;){var b=l;if(r.nodeName.toLowerCase()!==a.toLowerCase()){if(!u&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(u){if(!r[Xe])switch(a){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(j=r.getAttribute("rel"),j==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(j!==b.rel||r.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||r.getAttribute("title")!==(b.title==null?null:b.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(j=r.getAttribute("src"),(j!==(b.src==null?null:b.src)||r.getAttribute("type")!==(b.type==null?null:b.type)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&j&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(a==="input"&&r.type==="hidden"){var j=b.name==null?null:""+b.name;if(b.type==="hidden"&&r.getAttribute("name")===j)return r}else return r;if(r=Kr(r.nextSibling),r===null)break}return null}function x2(r,a,l){if(a==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!l||(r=Kr(r.nextSibling),r===null))return null;return r}function U0(r,a){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!a||(r=Kr(r.nextSibling),r===null))return null;return r}function sh(r){return r.data==="$?"||r.data==="$~"}function ah(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function p2(r,a){var l=r.ownerDocument;if(r.data==="$~")r._reactRetry=a;else if(r.data!=="$?"||l.readyState!=="loading")a();else{var u=function(){a(),l.removeEventListener("DOMContentLoaded",u)};l.addEventListener("DOMContentLoaded",u),r._reactRetry=u}}function Kr(r){for(;r!=null;r=r.nextSibling){var a=r.nodeType;if(a===1||a===3)break;if(a===8){if(a=r.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return r}var ih=null;function q0(r){r=r.nextSibling;for(var a=0;r;){if(r.nodeType===8){var l=r.data;if(l==="/$"||l==="/&"){if(a===0)return Kr(r.nextSibling);a--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||a++}r=r.nextSibling}return null}function V0(r){r=r.previousSibling;for(var a=0;r;){if(r.nodeType===8){var l=r.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(a===0)return r;a--}else l!=="/$"&&l!=="/&"||a++}r=r.previousSibling}return null}function F0(r,a,l){switch(a=Fc(l),r){case"html":if(r=a.documentElement,!r)throw Error(i(452));return r;case"head":if(r=a.head,!r)throw Error(i(453));return r;case"body":if(r=a.body,!r)throw Error(i(454));return r;default:throw Error(i(451))}}function eo(r){for(var a=r.attributes;a.length;)r.removeAttributeNode(a[0]);At(r)}var Wr=new Map,Y0=new Set;function Yc(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var Gs=O.d;O.d={f:g2,r:b2,D:y2,C:v2,L:j2,m:w2,X:k2,S:N2,M:S2};function g2(){var r=Gs.f(),a=zc();return r||a}function b2(r){var a=xn(r);a!==null&&a.tag===5&&a.type==="form"?cg(a):Gs.r(r)}var Gi=typeof document>"u"?null:document;function G0(r,a,l){var u=Gi;if(u&&typeof a=="string"&&a){var b=Jn(a);b='link[rel="'+r+'"][href="'+b+'"]',typeof l=="string"&&(b+='[crossorigin="'+l+'"]'),Y0.has(b)||(Y0.add(b),r={rel:r,crossOrigin:l,href:a},u.querySelector(b)===null&&(a=u.createElement("link"),ir(a,"link",r),on(a),u.head.appendChild(a)))}}function y2(r){Gs.D(r),G0("dns-prefetch",r,null)}function v2(r,a){Gs.C(r,a),G0("preconnect",r,a)}function j2(r,a,l){Gs.L(r,a,l);var u=Gi;if(u&&r&&a){var b='link[rel="preload"][as="'+Jn(a)+'"]';a==="image"&&l&&l.imageSrcSet?(b+='[imagesrcset="'+Jn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(b+='[imagesizes="'+Jn(l.imageSizes)+'"]')):b+='[href="'+Jn(r)+'"]';var j=b;switch(a){case"style":j=Xi(r);break;case"script":j=Ki(r)}Wr.has(j)||(r=x({rel:"preload",href:a==="image"&&l&&l.imageSrcSet?void 0:r,as:a},l),Wr.set(j,r),u.querySelector(b)!==null||a==="style"&&u.querySelector(to(j))||a==="script"&&u.querySelector(no(j))||(a=u.createElement("link"),ir(a,"link",r),on(a),u.head.appendChild(a)))}}function w2(r,a){Gs.m(r,a);var l=Gi;if(l&&r){var u=a&&typeof a.as=="string"?a.as:"script",b='link[rel="modulepreload"][as="'+Jn(u)+'"][href="'+Jn(r)+'"]',j=b;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Ki(r)}if(!Wr.has(j)&&(r=x({rel:"modulepreload",href:r},a),Wr.set(j,r),l.querySelector(b)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(no(j)))return}u=l.createElement("link"),ir(u,"link",r),on(u),l.head.appendChild(u)}}}function N2(r,a,l){Gs.S(r,a,l);var u=Gi;if(u&&r){var b=lr(u).hoistableStyles,j=Xi(r);a=a||"default";var H=b.get(j);if(!H){var J={loading:0,preload:null};if(H=u.querySelector(to(j)))J.loading=5;else{r=x({rel:"stylesheet",href:r,"data-precedence":a},l),(l=Wr.get(j))&&lh(r,l);var ie=H=u.createElement("link");on(ie),ir(ie,"link",r),ie._p=new Promise(function(ge,_e){ie.onload=ge,ie.onerror=_e}),ie.addEventListener("load",function(){J.loading|=1}),ie.addEventListener("error",function(){J.loading|=2}),J.loading|=4,Gc(H,a,u)}H={type:"stylesheet",instance:H,count:1,state:J},b.set(j,H)}}}function k2(r,a){Gs.X(r,a);var l=Gi;if(l&&r){var u=lr(l).hoistableScripts,b=Ki(r),j=u.get(b);j||(j=l.querySelector(no(b)),j||(r=x({src:r,async:!0},a),(a=Wr.get(b))&&oh(r,a),j=l.createElement("script"),on(j),ir(j,"link",r),l.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function S2(r,a){Gs.M(r,a);var l=Gi;if(l&&r){var u=lr(l).hoistableScripts,b=Ki(r),j=u.get(b);j||(j=l.querySelector(no(b)),j||(r=x({src:r,async:!0,type:"module"},a),(a=Wr.get(b))&&oh(r,a),j=l.createElement("script"),on(j),ir(j,"link",r),l.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},u.set(b,j))}}function X0(r,a,l,u){var b=(b=Q.current)?Yc(b):null;if(!b)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(a=Xi(l.href),l=lr(b).hoistableStyles,u=l.get(a),u||(u={type:"style",instance:null,count:0,state:null},l.set(a,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){r=Xi(l.href);var j=lr(b).hoistableStyles,H=j.get(r);if(H||(b=b.ownerDocument||b,H={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(r,H),(j=b.querySelector(to(r)))&&!j._p&&(H.instance=j,H.state.loading=5),Wr.has(r)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Wr.set(r,l),j||C2(b,r,l,H.state))),a&&u===null)throw Error(i(528,""));return H}if(a&&u!==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=Ki(l),l=lr(b).hoistableScripts,u=l.get(a),u||(u={type:"script",instance:null,count:0,state:null},l.set(a,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function Xi(r){return'href="'+Jn(r)+'"'}function to(r){return'link[rel="stylesheet"]['+r+"]"}function K0(r){return x({},r,{"data-precedence":r.precedence,precedence:null})}function C2(r,a,l,u){r.querySelector('link[rel="preload"][as="style"]['+a+"]")?u.loading=1:(a=r.createElement("link"),u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2}),ir(a,"link",l),on(a),r.head.appendChild(a))}function Ki(r){return'[src="'+Jn(r)+'"]'}function no(r){return"script[async]"+r}function W0(r,a,l){if(a.count++,a.instance===null)switch(a.type){case"style":var u=r.querySelector('style[data-href~="'+Jn(l.href)+'"]');if(u)return a.instance=u,on(u),u;var b=x({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(r.ownerDocument||r).createElement("style"),on(u),ir(u,"style",b),Gc(u,l.precedence,r),a.instance=u;case"stylesheet":b=Xi(l.href);var j=r.querySelector(to(b));if(j)return a.state.loading|=4,a.instance=j,on(j),j;u=K0(l),(b=Wr.get(b))&&lh(u,b),j=(r.ownerDocument||r).createElement("link"),on(j);var H=j;return H._p=new Promise(function(J,ie){H.onload=J,H.onerror=ie}),ir(j,"link",u),a.state.loading|=4,Gc(j,l.precedence,r),a.instance=j;case"script":return j=Ki(l.src),(b=r.querySelector(no(j)))?(a.instance=b,on(b),b):(u=l,(b=Wr.get(j))&&(u=x({},l),oh(u,b)),r=r.ownerDocument||r,b=r.createElement("script"),on(b),ir(b,"link",u),r.head.appendChild(b),a.instance=b);case"void":return null;default:throw Error(i(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,Gc(u,l.precedence,r));return a.instance}function Gc(r,a,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=u.length?u[u.length-1]:null,j=b,H=0;H<u.length;H++){var J=u[H];if(J.dataset.precedence===a)j=J;else if(j!==b)break}j?j.parentNode.insertBefore(r,j.nextSibling):(a=l.nodeType===9?l.head:l,a.insertBefore(r,a.firstChild))}function lh(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.title==null&&(r.title=a.title)}function oh(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.integrity==null&&(r.integrity=a.integrity)}var Xc=null;function Z0(r,a,l){if(Xc===null){var u=new Map,b=Xc=new Map;b.set(l,u)}else b=Xc,u=b.get(l),u||(u=new Map,b.set(l,u));if(u.has(r))return u;for(u.set(r,null),l=l.getElementsByTagName(r),b=0;b<l.length;b++){var j=l[b];if(!(j[Xe]||j[Je]||r==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var H=j.getAttribute(a)||"";H=r+H;var J=u.get(H);J?J.push(j):u.set(H,[j])}}return u}function Q0(r,a,l){r=r.ownerDocument||r,r.head.insertBefore(l,a==="title"?r.querySelector("head > title"):null)}function E2(r,a,l){if(l===1||a.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(r=a.disabled,typeof a.precedence=="string"&&r==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function J0(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function T2(r,a,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var b=Xi(u.href),j=a.querySelector(to(b));if(j){a=j._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(r.count++,r=Kc.bind(r),a.then(r,r)),l.state.loading|=4,l.instance=j,on(j);return}j=a.ownerDocument||a,u=K0(u),(b=Wr.get(b))&&lh(u,b),j=j.createElement("link"),on(j);var H=j;H._p=new Promise(function(J,ie){H.onload=J,H.onerror=ie}),ir(j,"link",u),l.instance=j}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(l,a),(a=l.state.preload)&&(l.state.loading&3)===0&&(r.count++,l=Kc.bind(r),a.addEventListener("load",l),a.addEventListener("error",l))}}var ch=0;function _2(r,a){return r.stylesheets&&r.count===0&&Zc(r,r.stylesheets),0<r.count||0<r.imgCount?function(l){var u=setTimeout(function(){if(r.stylesheets&&Zc(r,r.stylesheets),r.unsuspend){var j=r.unsuspend;r.unsuspend=null,j()}},6e4+a);0<r.imgBytes&&ch===0&&(ch=62500*c2());var b=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&Zc(r,r.stylesheets),r.unsuspend)){var j=r.unsuspend;r.unsuspend=null,j()}},(r.imgBytes>ch?50:800)+a);return r.unsuspend=l,function(){r.unsuspend=null,clearTimeout(u),clearTimeout(b)}}:null}function Kc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zc(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var Wc=null;function Zc(r,a){r.stylesheets=null,r.unsuspend!==null&&(r.count++,Wc=new Map,a.forEach(A2,r),Wc=null,Kc.call(r))}function A2(r,a){if(!(a.state.loading&4)){var l=Wc.get(r);if(l)var u=l.get(null);else{l=new Map,Wc.set(r,l);for(var b=r.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<b.length;j++){var H=b[j];(H.nodeName==="LINK"||H.getAttribute("media")!=="not all")&&(l.set(H.dataset.precedence,H),u=H)}u&&l.set(null,u)}b=a.instance,H=b.getAttribute("data-precedence"),j=l.get(H)||u,j===u&&l.set(null,b),l.set(H,b),this.count++,u=Kc.bind(this),b.addEventListener("load",u),b.addEventListener("error",u),j?j.parentNode.insertBefore(b,j.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(b,r.firstChild)),a.state.loading|=4}}var ro={$$typeof:k,Provider:null,Consumer:null,_currentValue:D,_currentValue2:D,_threadCount:0};function M2(r,a,l,u,b,j,H,J,ie){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=hn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hn(0),this.hiddenUpdates=hn(null),this.identifierPrefix=u,this.onUncaughtError=b,this.onCaughtError=j,this.onRecoverableError=H,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function eb(r,a,l,u,b,j,H,J,ie,ge,_e,De){return r=new M2(r,a,l,H,ie,ge,_e,De,J),a=1,j===!0&&(a|=24),j=Mr(3,null,null,a),r.current=j,j.stateNode=r,a=Pu(),a.refCount++,r.pooledCache=a,a.refCount++,j.memoizedState={element:u,isDehydrated:l,cache:a},Fu(j),r}function tb(r){return r?(r=Ci,r):Ci}function nb(r,a,l,u,b,j){b=tb(b),u.context===null?u.context=b:u.pendingContext=b,u=ua(a),u.payload={element:l},j=j===void 0?null:j,j!==null&&(u.callback=j),l=fa(r,u,a),l!==null&&(jr(l,r,a),Ll(l,r,a))}function rb(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var l=r.retryLane;r.retryLane=l!==0&&l<a?l:a}}function dh(r,a){rb(r,a),(r=r.alternate)&&rb(r,a)}function sb(r){if(r.tag===13||r.tag===31){var a=Ya(r,67108864);a!==null&&jr(a,r,67108864),dh(r,67108864)}}function ab(r){if(r.tag===13||r.tag===31){var a=Ir();a=ze(a);var l=Ya(r,a);l!==null&&jr(l,r,a),dh(r,a)}}var Qc=!0;function O2(r,a,l,u){var b=A.T;A.T=null;var j=O.p;try{O.p=2,uh(r,a,l,u)}finally{O.p=j,A.T=b}}function R2(r,a,l,u){var b=A.T;A.T=null;var j=O.p;try{O.p=8,uh(r,a,l,u)}finally{O.p=j,A.T=b}}function uh(r,a,l,u){if(Qc){var b=fh(u);if(b===null)Zf(r,a,u,Jc,l),lb(r,u);else if(L2(b,r,a,l,u))u.stopPropagation();else if(lb(r,u),a&4&&-1<D2.indexOf(r)){for(;b!==null;){var j=xn(b);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var H=He(j.pendingLanes);if(H!==0){var J=j;for(J.pendingLanes|=2,J.entangledLanes|=2;H;){var ie=1<<31-Ct(H);J.entanglements[1]|=ie,H&=~ie}vs(j),(sn&6)===0&&(Lc=yt()+500,Zl(0))}}break;case 31:case 13:J=Ya(j,2),J!==null&&jr(J,j,2),zc(),dh(j,2)}if(j=fh(u),j===null&&Zf(r,a,u,Jc,l),j===b)break;b=j}b!==null&&u.stopPropagation()}else Zf(r,a,u,null,l)}}function fh(r){return r=Me(r),hh(r)}var Jc=null;function hh(r){if(Jc=null,r=St(r),r!==null){var a=d(r);if(a===null)r=null;else{var l=a.tag;if(l===13){if(r=c(a),r!==null)return r;r=null}else if(l===31){if(r=m(a),r!==null)return r;r=null}else if(l===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;r=null}else a!==r&&(r=null)}}return Jc=r,null}function ib(r){switch(r){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Dt()){case we:return 2;case Le:return 8;case Ue:case at:return 32;case rt:return 268435456;default:return 32}default:return 32}}var mh=!1,Na=null,ka=null,Sa=null,so=new Map,ao=new Map,Ca=[],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 lb(r,a){switch(r){case"focusin":case"focusout":Na=null;break;case"dragenter":case"dragleave":ka=null;break;case"mouseover":case"mouseout":Sa=null;break;case"pointerover":case"pointerout":so.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":ao.delete(a.pointerId)}}function io(r,a,l,u,b,j){return r===null||r.nativeEvent!==j?(r={blockedOn:a,domEventName:l,eventSystemFlags:u,nativeEvent:j,targetContainers:[b]},a!==null&&(a=xn(a),a!==null&&sb(a)),r):(r.eventSystemFlags|=u,a=r.targetContainers,b!==null&&a.indexOf(b)===-1&&a.push(b),r)}function L2(r,a,l,u,b){switch(a){case"focusin":return Na=io(Na,r,a,l,u,b),!0;case"dragenter":return ka=io(ka,r,a,l,u,b),!0;case"mouseover":return Sa=io(Sa,r,a,l,u,b),!0;case"pointerover":var j=b.pointerId;return so.set(j,io(so.get(j)||null,r,a,l,u,b)),!0;case"gotpointercapture":return j=b.pointerId,ao.set(j,io(ao.get(j)||null,r,a,l,u,b)),!0}return!1}function ob(r){var a=St(r.target);if(a!==null){var l=d(a);if(l!==null){if(a=l.tag,a===13){if(a=c(l),a!==null){r.blockedOn=a,xt(r.priority,function(){ab(l)});return}}else if(a===31){if(a=m(l),a!==null){r.blockedOn=a,xt(r.priority,function(){ab(l)});return}}else if(a===3&&l.stateNode.current.memoizedState.isDehydrated){r.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}r.blockedOn=null}function ed(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var l=fh(r.nativeEvent);if(l===null){l=r.nativeEvent;var u=new l.constructor(l.type,l);he=u,l.target.dispatchEvent(u),he=null}else return a=xn(l),a!==null&&sb(a),r.blockedOn=l,!1;a.shift()}return!0}function cb(r,a,l){ed(r)&&l.delete(a)}function I2(){mh=!1,Na!==null&&ed(Na)&&(Na=null),ka!==null&&ed(ka)&&(ka=null),Sa!==null&&ed(Sa)&&(Sa=null),so.forEach(cb),ao.forEach(cb)}function td(r,a){r.blockedOn===a&&(r.blockedOn=null,mh||(mh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,I2)))}var nd=null;function db(r){nd!==r&&(nd=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){nd===r&&(nd=null);for(var a=0;a<r.length;a+=3){var l=r[a],u=r[a+1],b=r[a+2];if(typeof u!="function"){if(hh(u||l)===null)continue;break}var j=xn(l);j!==null&&(r.splice(a,3),a-=3,ff(j,{pending:!0,data:b,method:l.method,action:u},u,b))}}))}function Wi(r){function a(ie){return td(ie,r)}Na!==null&&td(Na,r),ka!==null&&td(ka,r),Sa!==null&&td(Sa,r),so.forEach(a),ao.forEach(a);for(var l=0;l<Ca.length;l++){var u=Ca[l];u.blockedOn===r&&(u.blockedOn=null)}for(;0<Ca.length&&(l=Ca[0],l.blockedOn===null);)ob(l),l.blockedOn===null&&Ca.shift();if(l=(r.ownerDocument||r).$$reactFormReplay,l!=null)for(u=0;u<l.length;u+=3){var b=l[u],j=l[u+1],H=b[Fe]||null;if(typeof j=="function")H||db(l);else if(H){var J=null;if(j&&j.hasAttribute("formAction")){if(b=j,H=j[Fe]||null)J=H.formAction;else if(hh(b)!==null)continue}else J=H.action;typeof J=="function"?l[u+1]=J:(l.splice(u,3),u-=3),db(l)}}}function ub(){function r(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(H){return b=H})},focusReset:"manual",scroll:"manual"})}function a(){b!==null&&(b(),b=null),u||setTimeout(l,20)}function l(){if(!u&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,b=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(l,100),function(){u=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),b!==null&&(b(),b=null)}}}function xh(r){this._internalRoot=r}rd.prototype.render=xh.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(i(409));var l=a.current,u=Ir();nb(l,u,r,a,null,null)},rd.prototype.unmount=xh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;nb(r.current,2,null,r,null,null),zc(),a[Et]=null}};function rd(r){this._internalRoot=r}rd.prototype.unstable_scheduleHydration=function(r){if(r){var a=it();r={blockedOn:null,target:r,priority:a};for(var l=0;l<Ca.length&&a!==0&&a<Ca[l].priority;l++);Ca.splice(l,0,r),l===0&&ob(r)}};var fb=n.version;if(fb!=="19.2.4")throw Error(i(527,fb,"19.2.4"));O.findDOMNode=function(r){var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(i(188)):(r=Object.keys(r).join(","),Error(i(268,r)));return r=f(a),r=r!==null?p(r):null,r=r===null?null:r.stateNode,r};var z2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var sd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sd.isDisabled&&sd.supportsFiber)try{zt=sd.inject(z2),Mt=sd}catch{}}return oo.createRoot=function(r,a){if(!o(r))throw Error(i(299));var l=!1,u="",b=yg,j=vg,H=jg;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(b=a.onUncaughtError),a.onCaughtError!==void 0&&(j=a.onCaughtError),a.onRecoverableError!==void 0&&(H=a.onRecoverableError)),a=eb(r,1,!1,null,null,l,u,null,b,j,H,ub),r[Et]=a.current,Wf(r),new xh(a)},oo.hydrateRoot=function(r,a,l){if(!o(r))throw Error(i(299));var u=!1,b="",j=yg,H=vg,J=jg,ie=null;return l!=null&&(l.unstable_strictMode===!0&&(u=!0),l.identifierPrefix!==void 0&&(b=l.identifierPrefix),l.onUncaughtError!==void 0&&(j=l.onUncaughtError),l.onCaughtError!==void 0&&(H=l.onCaughtError),l.onRecoverableError!==void 0&&(J=l.onRecoverableError),l.formState!==void 0&&(ie=l.formState)),a=eb(r,1,!0,a,l??null,u,b,ie,j,H,J,ub),a.context=tb(null),l=a.current,u=Ir(),u=ze(u),b=ua(u),b.callback=null,fa(l,b,u),l=u,a.current.lanes=l,mn(a,l),vs(a),r[Et]=a.current,Wf(r),new rd(a)},oo.version="19.2.4",oo}var wb;function G2(){if(wb)return bh.exports;wb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),bh.exports=Y2(),bh.exports}var X2=G2();const xe={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",REPORTS:"reports",SETTINGS:"settings"},K2=new Set(Object.values(xe)),W2={dashboard:xe.HOME,overview:xe.HOME,chat:xe.TEAM,projects:xe.WORK,tasks:xe.WORK,usage:xe.REPORTS,prompts:xe.BUILDER,templates:xe.STORE,agents:xe.STORE,skills:xe.STORE,teams:xe.STORE,knowledge:xe.DELIVERABLES,governance:xe.SETTINGS};function Qs(e){return K2.has(e)?e:W2[e]??xe.HOME}function ad(){const e=window.location.hash.slice(1).split("/")[0];return Qs(e)}function dm(e,n){return n?`#${e}/${n}`:`#${e}`}const Z2={[xe.STORE]:xe.BUILDER,[xe.REPORTS]:xe.SETTINGS},nl={[xe.HOME]:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",[xe.WORK]:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",[xe.TEAM]:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",[xe.REPORTS]:"M18 20V10 M12 20V4 M6 20v-6",[xe.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",[xe.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",[xe.STORE]:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",[xe.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"},Q2=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],J2=[{id:xe.HOME,label:"Home",section:"workspace"},{id:xe.TEAM,label:"Team",section:"workspace"},{id:xe.DELIVERABLES,label:"Deliverables",section:"workspace"},{id:xe.BUILDER,label:"Builder",section:"build"},{id:xe.STORE,label:"Store",section:"build"},{id:xe.REPORTS,label:"Reports",section:"system"},{id:xe.SETTINGS,label:"Settings",section:"system"}],ek=[{id:xe.HOME,label:"Home",group:[xe.HOME]},{id:xe.TEAM,label:"Team",group:[xe.TEAM]},{id:xe.WORK,label:"Work",group:[xe.WORK]},{id:xe.DELIVERABLES,label:"Deliverables",group:[xe.DELIVERABLES]},{id:xe.BUILDER,label:"Builder",group:[xe.BUILDER,xe.STORE]},{id:xe.SETTINGS,label:"Settings",group:[xe.SETTINGS,xe.REPORTS]}],b1="/api";async function fe(e,n){const s=await fetch(`${b1}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...n,body:n?.body?typeof n.body=="string"?n.body:JSON.stringify(n.body):void 0});if(!s.ok){let 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 se={agents:{list:()=>fe("/agents").then(e=>({...e,agents:e.agents.filter(n=>n.name)})),get:e=>fe(`/agents/${e}`),create:(e,n,s,i)=>fe("/agents",{method:"POST",body:JSON.stringify({name:e,roleName:n,agentRole:s,teamId:i})}),start:e=>fe(`/agents/${e}/start`,{method:"POST"}),stop:e=>fe(`/agents/${e}/stop`,{method:"POST"}),remove:(e,n)=>fe(`/agents/${e}${n?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,n)=>fe(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(n)}),getMemory:e=>fe(`/agents/${e}/memory`),getMemorySession:(e,n)=>fe(`/agents/${e}/memory/sessions/${encodeURIComponent(n)}`),updateDailyMemory:(e,n)=>fe(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:n})}),updateLongTermMemory:(e,n,s)=>fe(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:n,content:s})}),getFiles:e=>fe(`/agents/${e}/files`),getFilesMap:e=>fe(`/agents/${e}/files`),updateFile:(e,n,s)=>fe(`/agents/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,n)=>fe(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:n})}),roleStatus:e=>fe(`/agents/${e}/role-status`),roleDiff:(e,n="ROLE.md")=>fe(`/agents/${e}/role-diff?file=${encodeURIComponent(n)}`),roleSync:(e,n)=>fe(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(n?{files:n}:{})}),roleUpdates:()=>fe("/agents/role-updates"),addSkill:(e,n)=>fe(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:n})}),removeSkill:(e,n)=>fe(`/agents/${e}/skills/${encodeURIComponent(n)}`,{method:"DELETE"}),getHeartbeat:e=>fe(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>fe(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),getRecentActivities:e=>fe(`/agents/${e}/recent-activities`),getActivityLogs:(e,n)=>fe(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(n)}`),getActivities:(e,n)=>{const s=new URLSearchParams;n?.type&&s.set("type",n.type),n?.limit&&s.set("limit",String(n.limit)),n?.before&&s.set("before",n.before);const i=s.toString();return fe(`/agents/${e}/activities${i?"?"+i:""}`)},getMindState:e=>fe(`/agents/${e}/mind`),getMailbox:(e,n)=>{const s=new URLSearchParams;n?.limit&&s.set("limit",String(n.limit)),n?.offset&&s.set("offset",String(n.offset)),n?.category&&s.set("category",n.category),n?.sourceType&&s.set("sourceType",n.sourceType);const i=s.toString();return fe(`/agents/${e}/mailbox${i?"?"+i:""}`)},getDecisions:(e,n=50)=>fe(`/agents/${e}/decisions?limit=${n}`),message:(e,n,s,i)=>fe(`/agents/${e}/message`,{method:"POST",body:JSON.stringify({text:n,images:s,sessionId:i??void 0})}),messageStream:(e,n,s,i,o,d,c)=>new Promise(async(m,h)=>{let f="",p;try{const x=await fetch(`${b1}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:n,stream:!0,images:d,sessionId:c??void 0}),signal:o});if(!x.ok){h(new Error(`API error: ${x.status}`));return}const g=x.body?.getReader();if(!g){h(new Error("No reader"));return}const y=new TextDecoder;let w="";for(;;){const{done:N,value:S}=await g.read();if(N)break;w+=y.decode(S,{stream:!0});const E=w.split(`
10
- `);w=E.pop()??"";for(const C of E){const k=C.trim();if(k.startsWith("data: "))try{const T=JSON.parse(k.slice(6));if(T.type==="text_delta"&&T.text)f+=T.text,s(T.text);else if(T.type==="thinking_delta"&&T.thinking)s?.(`<think>${T.thinking}</think>`);else if(T.type==="done")f=T.content??f,T.sessionId&&(p=T.sessionId);else if(T.type==="error"){const R=T;R.sessionId&&(p=R.sessionId);const z=new Error(R.message??R.error??"Unknown stream error");z.sessionId=R.sessionId,h(z),g.cancel().catch(()=>{});return}else T.type==="tool_call_start"&&T.toolCall?.name?i?.({tool:T.toolCall.name,phase:"start"}):T.type==="agent_tool"&&T.tool&&T.phase?T.phase==="start"?i?.({tool:T.tool,phase:"start",arguments:T.arguments}):T.phase==="end"&&i?.({tool:T.tool,phase:"end",success:T.success,arguments:T.arguments,result:T.result,error:T.error,durationMs:T.durationMs}):T.type==="tool_output"&&T.tool?i?.({tool:T.tool,phase:"output",output:T.text}):T.type==="subagent_progress"&&T.tool&&i?.({tool:T.tool,phase:"subagent_progress",subagentEvent:T.subagentEvent})}catch{}}}m({content:f,sessionId:p})}catch(x){x instanceof Error&&x.name==="AbortError"?m({content:f,sessionId:p}):h(x)}})},roles:{list:()=>fe("/roles")},teams:{list:e=>fe(`/teams?orgId=${e??"default"}`),create:(e,n)=>fe("/teams",{method:"POST",body:JSON.stringify({name:e,description:n})}),update:(e,n)=>fe(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(n)}),delete:(e,n,s)=>fe(`/teams/${e}?deleteMembers=${n?"true":"false"}${s?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,n,s)=>fe(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:n,memberType:s})}),removeMember:(e,n)=>fe(`/teams/${e}/members/${n}`,{method:"DELETE"}),startAll:e=>fe(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>fe(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,n)=>fe(`/teams/${e}/pause`,{method:"POST",body:JSON.stringify({reason:n})}),resumeAll:e=>fe(`/teams/${e}/resume`,{method:"POST"}),status:e=>fe(`/teams/${e}/status`),getFiles:e=>fe(`/teams/${e}/files`),getFile:(e,n)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`),updateFile:(e,n,s)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),exportTeam:e=>fe(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>fe(`/teams/${e}/export`)},externalAgents:{list:e=>fe(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const n=new URLSearchParams;e?.assignedAgentId&&n.set("assignedAgentId",e.assignedAgentId),e?.status&&n.set("status",e.status),e?.projectId&&n.set("projectId",e.projectId),e?.requirementId&&n.set("requirementId",e.requirementId),e?.priority&&n.set("priority",e.priority),e?.search&&n.set("search",e.search),e?.sortBy&&n.set("sortBy",e.sortBy),e?.sortOrder&&n.set("sortOrder",e.sortOrder),e?.page!==null&&e?.page!==void 0&&n.set("page",String(e.page)),e?.pageSize!==null&&e?.pageSize!==void 0&&n.set("pageSize",String(e.pageSize));const s=n.toString();return fe(`/tasks${s?`?${s}`:""}`)},get:e=>fe(`/tasks/${e}`),create:(e,n,s,i,o,d,c,m,h,f)=>fe("/tasks",{method:"POST",body:JSON.stringify({title:e,description:n,assignedAgentId:s,reviewerAgentId:i,priority:o,projectId:d,blockedBy:c,requirementId:m,taskType:h,scheduleConfig:f})}),update:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({status:n})}),assign:(e,n)=>fe(`/tasks/${e}`,{method:"PUT",body:JSON.stringify({assignedAgentId:n})}),approve:e=>fe(`/tasks/${e}/approve`,{method:"POST"}),reject:e=>fe(`/tasks/${e}/reject`,{method:"POST"}),cancel:(e,n=!1)=>fe(`/tasks/${e}/cancel`,{method:"POST",body:JSON.stringify({cascade:n})}),getDependentCount:e=>fe(`/tasks/${e}/dependents`),board:e=>{const n=new URLSearchParams;e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return fe(`/taskboard${s?`?${s}`:""}`)},listSubtasks:e=>fe(`/tasks/${e}/subtasks`),createSubtask:(e,n)=>fe(`/tasks/${e}/subtasks`,{method:"POST",body:JSON.stringify({title:n})}),completeSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}/complete`,{method:"POST"}),cancelSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}/cancel`,{method:"POST"}),deleteSubtask:(e,n)=>fe(`/tasks/${e}/subtasks/${n}`,{method:"DELETE"}),run:e=>fe(`/tasks/${e}/run`,{method:"POST"}),getLogs:(e,n)=>fe(`/tasks/${e}/logs${n!=null?`?round=${n}`:""}`),getLogsSummary:e=>fe(`/tasks/${e}/logs/summary`),accept:(e,n)=>fe(`/tasks/${e}/accept`,{method:"POST",body:JSON.stringify({reviewerAgentId:n??"human"})}),revision:(e,n,s)=>fe(`/tasks/${e}/revision`,{method:"POST",body:JSON.stringify({reason:n,reviewerAgentId:s??"human"})}),archive:e=>fe(`/tasks/${e}/archive`,{method:"POST"}),pause:e=>fe(`/tasks/${e}/pause`,{method:"POST"}),resume:e=>fe(`/tasks/${e}/resume`,{method:"POST"}),retry:e=>fe(`/tasks/${e}/retry`,{method:"POST"}),getComments:e=>fe(`/tasks/${e}/comments`),addComment:(e,n,s,i,o,d,c)=>fe(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:o??"human",authorName:s??"User",authorType:"human",attachments:i,mentions:d,replyTo:c})}),pauseSchedule:e=>fe(`/tasks/${e}/schedule/pause`,{method:"POST"}),resumeSchedule:e=>fe(`/tasks/${e}/schedule/resume`,{method:"POST"}),runNow:e=>fe(`/tasks/${e}/schedule/run-now`,{method:"POST"}),deliverables:e=>{const n=e?`?projectId=${encodeURIComponent(e)}`:"";return fe(`/tasks/deliverables${n}`)}},files:{preview:e=>fe(`/files/preview?path=${encodeURIComponent(e)}`),reveal:e=>fe("/files/reveal",{method:"POST",body:JSON.stringify({path:e})})},requirements:{list:e=>{const n=new URLSearchParams;e?.orgId&&n.set("orgId",e.orgId),e?.status&&n.set("status",e.status),e?.source&&n.set("source",e.source),e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return fe(`/requirements${s?`?${s}`:""}`)},get:e=>fe(`/requirements/${e}`),create:e=>fe("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>fe(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:n})}),approve:e=>fe(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,n)=>fe(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:n})}),cancel:e=>fe(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>fe(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>fe(`/requirements/${e}/comments`),addComment:(e,n,s,i,o,d)=>fe(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:i??"human",authorName:s??"User",authorType:"human",mentions:o,replyTo:d})})},users:{list:e=>fe(`/users?orgId=${e??"default"}`),create:(e,n,s,i,o,d)=>fe("/users",{method:"POST",body:JSON.stringify({name:e,role:n,orgId:s,email:i,password:o,teamId:d})}),remove:e=>fe(`/users/${e}`,{method:"DELETE"})},teamTemplates:{list:e=>{const n=e?`?q=${encodeURIComponent(e)}`:"";return fe(`/team-templates${n}`)},get:e=>fe(`/team-templates/${e}`)},ops:{dashboard:(e="24h")=>fe(`/ops/dashboard?period=${e}`)},agentMetrics:(e,n="24h")=>fe(`/agents/${e}/metrics?period=${n}`),usage:{summary:(e="default",n)=>{const s=new URLSearchParams({orgId:e});return n&&s.set("period",n),fe(`/usage?${s}`)},agents:(e="default")=>fe(`/usage/agents?orgId=${e}`)},health:()=>fe("/health"),system:{openPath:e=>fe("/system/open-path",{method:"POST",body:JSON.stringify({path:e})}),storage:()=>fe("/system/storage"),orphans:()=>fe("/system/storage/orphans"),purgeOrphans:e=>fe("/system/storage/orphans",{method:"DELETE",body:e?JSON.stringify({ids:e}):void 0})},settings:{getLlm:()=>fe("/settings/llm"),getAgent:()=>fe("/settings/agent"),updateAgent:e=>fe("/settings/agent",{method:"POST",body:JSON.stringify(e)})},skills:{list:()=>fe("/skills"),builtin:()=>fe("/skills/builtin"),registry:e=>fe(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const n=new URLSearchParams;e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit)),e?.sort&&n.set("sort",e.sort);const s=n.toString();return fe(`/skills/registry/skillhub${s?`?${s}`:""}`)},registrySkillssh:e=>fe(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,n,s,i)=>fe("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:n,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,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`),save:(e,n)=>fe("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:n})}),import:(e,n,s,i)=>fe("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:n,files:s,source:i})}),install:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/install`,{method:"POST"}),uninstall:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/uninstall`,{method:"POST"}),delete:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`,{method:"DELETE"}),installed:()=>fe("/builder/artifacts/installed")}},auth:{login:(e,n)=>fe("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})}),logout:()=>fe("/auth/logout",{method:"POST"}),me:()=>fe("/auth/me"),changePassword:(e,n)=>fe("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:n})})},sessions:{listByAgent:(e,n=20)=>fe(`/agents/${e}/sessions?limit=${n}`),getMessages:(e,n=50,s)=>fe(`/sessions/${e}/messages?limit=${n}${s?`&before=${s}`:""}`),delete:e=>fe(`/sessions/${e}`,{method:"DELETE"})},channels:{getMessages:(e,n=50,s)=>fe(`/channels/${encodeURIComponent(e)}/messages?limit=${n}${s?`&before=${s}`:""}`),sendMessage:(e,n)=>fe(`/channels/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})},governance:{getSystemStatus:()=>fe("/system/status"),pauseAll:e=>fe("/system/pause-all",{method:"POST",body:JSON.stringify({reason:e})}),resumeAll:()=>fe("/system/resume-all",{method:"POST"}),emergencyStop:e=>fe("/system/emergency-stop",{method:"POST",body:JSON.stringify({reason:e})}),getAnnouncements:()=>fe("/system/announcements"),createAnnouncement:e=>fe("/system/announcements",{method:"POST",body:JSON.stringify(e)}),getPolicy:()=>fe("/governance/policy"),setPolicy:e=>fe("/governance/policy",{method:"PUT",body:JSON.stringify(e)})},approvals:{list:e=>{const n=e?`?status=${e}`:"";return fe(`/approvals${n}`)},respond:(e,n,s,i)=>fe(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:n,respondedBy:s,comment:i})})},notifications:{list:(e,n,s)=>{const i=new URLSearchParams;return e&&i.set("userId",e),n&&i.set("unread","true"),s?.type&&i.set("type",s.type),s?.limit&&i.set("limit",String(s.limit)),s?.offset&&i.set("offset",String(s.offset)),fe(`/notifications?${i}`)},markRead:e=>fe(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>fe("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},projects:{list:e=>{const n=e?`?orgId=${e}`:"";return fe(`/projects${n}`)},get:e=>fe(`/projects/${e}`),create:e=>fe("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/projects/${e}`,{method:"PUT",body:JSON.stringify(n)}),delete:e=>fe(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,n,s)=>{const i=new URLSearchParams;return e&&i.set("query",e),n&&i.set("scope",n),s&&i.set("category",s),fe(`/knowledge/search?${i}`)},contribute:e=>fe("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,n)=>fe(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:n})}),verify:e=>fe(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>fe(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const n=new URLSearchParams;return e?.q&&n.set("q",e.q),e?.projectId&&n.set("projectId",e.projectId),e?.agentId&&n.set("agentId",e.agentId),e?.taskId&&n.set("taskId",e.taskId),e?.type&&n.set("type",e.type),e?.status&&n.set("status",e.status),e?.artifactType&&n.set("artifactType",e.artifactType),e?.offset&&n.set("offset",String(e.offset)),e?.limit&&n.set("limit",String(e.limit)),fe(`/deliverables?${n}`)},create:e=>fe("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(n)}),remove:e=>fe(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})})},codeReviews:{list:(e,n=20)=>{const s=new URLSearchParams;return e&&s.set("taskId",e),s.set("limit",String(n)),fe(`/reviews?${s}`)},get:e=>fe(`/reviews/${e}`),run:e=>fe("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>fe("/reports"),get:e=>fe(`/reports/${e}`),generate:e=>fe("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,n)=>fe(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(n)}),rejectPlan:(e,n)=>fe(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(n)}),addFeedback:(e,n)=>fe(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(n)}),getFeedback:e=>fe(`/reports/${e}/feedback`)},executionLogs:{get:(e,n)=>fe(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(n)}`)}};function um(e){return{id:e.id,sourceType:"task",sourceId:e.taskId,agentId:e.agentId,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,executionRound:e.executionRound,createdAt:e.createdAt}}function tk(e,n,s){return e.type==="llm_request"?null:{id:`alog_${n}_${e.seq}`,sourceType:"activity",sourceId:n,agentId:s,seq:e.seq,type:e.type,content:e.content,metadata:e.metadata,createdAt:e.createdAt}}class nk{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 d=JSON.parse(o.data),c=this.handlers.get(d.type);if(c)for(const h of c)h(d);const m=this.handlers.get("*");if(m)for(const h of m)h(d)}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(n,s){return this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n).add(s),()=>this.handlers.get(n)?.delete(s)}}const an=new nk;let Oo=window.__MARKUS_HUB_URL__??"https://markus.global";fe("/settings/hub").then(e=>{e.hubUrl&&(Oo=e.hubUrl);const n=localStorage.getItem("markus_hub_token");n&&fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:n})}).catch(()=>{})}).catch(()=>{});const Zm="markus_hub_token",Qm="markus_hub_user";function La(){return localStorage.getItem(Zm)}function rk(){try{const e=localStorage.getItem(Qm);return e?JSON.parse(e):null}catch{return null}}function y1(){localStorage.removeItem(Zm),localStorage.removeItem(Qm),v1(null)}function fm(e,n){localStorage.setItem(Zm,e),localStorage.setItem(Qm,JSON.stringify(n)),v1(e)}function v1(e){fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}let co=null;function Ta(){if(La())return Promise.resolve();if(co)return co;const e=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`;return co=new Promise((n,s)=>{const i=`${Oo}/auth/connect?session=${encodeURIComponent(e)}`,o=460,d=580,c=Math.round(window.screenX+(window.outerWidth-o)/2),m=Math.round(window.screenY+(window.outerHeight-d)/2),h=window.open(i,"markus_hub_auth",`popup=yes,width=${o},height=${d},left=${c},top=${m}`);let f=!1;const p=()=>{clearInterval(x),clearInterval(g),co=null},x=setInterval(async()=>{if(!f)try{const w=await(await fetch(`${Oo}/api/auth/connect-status?session=${encodeURIComponent(e)}`)).json();w.ready&&w.token&&w.user&&(f=!0,fm(w.token,w.user),p(),h?.close(),n())}catch{}},1500),g=setInterval(()=>{f||h?.closed&&(f=!0,p(),La()?n():s(new Error("Hub login cancelled")))},500)}),co}async function Zr(e,n){const s=La(),i={"Content-Type":"application/json",...n?.headers};s&&(i.Authorization=`Bearer ${s}`);const o=await fetch(`${Oo}/api${e}`,{...n,headers:i}),d=await o.json();if(o.status===401&&s&&y1(),!o.ok)throw new Error(d.error??`Hub HTTP ${o.status}`);return d}const Fn={getUrl:()=>Oo,isAuthenticated:()=>!!La(),getUser:rk,logout:()=>{y1()},ensureAuth:Ta,login:async(e,n)=>{const s=await Zr("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})});return fm(s.token,s.user),s},register:async(e,n,s)=>{const i=await Zr("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:n,password:s})});return fm(i.token,i.user),i},search:e=>{const n=new URLSearchParams;e?.type&&n.set("type",e.type),e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.sort&&n.set("sort",e.sort),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit));const s=n.toString();return Zr(`/items${s?`?${s}`:""}`)},getItem:e=>Zr(`/items/${e}`),download:async e=>{await Ta();try{return await Zr(`/items/${e}/download`,{method:"POST"})}catch(n){if(!La())return await Ta(),Zr(`/items/${e}/download`,{method:"POST"});throw n}},publish:async e=>{await Ta();try{return await Zr("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!La())return await Ta(),Zr("/items",{method:"POST",body:JSON.stringify(e)});throw n}},publishViaProxy:async e=>{await Ta();try{return await Zr("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!La())return await Ta(),Zr("/items",{method:"POST",body:JSON.stringify(e)});throw n}},myItems:async()=>La()?Zr("/items/mine"):{items:[]},deleteItem:async e=>(await Ta(),Zr(`/items/${e}`,{method:"DELETE"}))};let Nb=null;const pt={setHandler(e){Nb=e},navigate(e,n){n&&Object.entries(n).forEach(([s,i])=>localStorage.setItem(`markus_nav_${s}`,i)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:n}})),Nb?.(e,n)}};var Jm=g1();const kb={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},wh={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_status_changed:"M23 4v6h-6 M1 20v-6h6 M3.51 9a9 9 0 0 1 14.85-3.36L23 10 M1 14l4.64 4.36A9 9 0 0 0 20.49 15",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z M12 9v4 M12 17h.01",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",agent_chat_request:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",agent_escalation:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z M12 9v4 M12 17h.01",bounty_posted:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z M19 10v2a7 7 0 0 1-14 0v-2",mention:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M12.5 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0z M20 8v6 M23 11h-6",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},sk={task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",task_status_changed:"text-blue-400",requirement_created:"text-amber-500",requirement_decision:"text-green-500",approval_request:"text-amber-500",agent_alert:"text-red-500",agent_escalation:"text-red-400",agent_report:"text-blue-500",agent_chat_request:"text-brand-500",agent_notification:"text-blue-400",bounty_posted:"text-amber-500",mention:"text-brand-500",system:"text-fg-tertiary"};function Sb(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Cb(e){const n=e.actionType;if(n==="open_chat")return"Open chat →";if(n==="navigate")return"View details →";const s=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":case"task_status_changed":return s.taskId?"View task →":null;case"requirement_created":case"requirement_decision":return s.requirementId?"View requirement →":null;case"agent_chat_request":return"Open chat →";case"agent_alert":case"agent_escalation":case"agent_notification":return s.agentId?"View agent →":null;case"approval_request":return"View approval →";default:return s.taskId?"View task →":s.requirementId?"View requirement →":s.agentId?"View agent →":null}}function hm({collapsed:e,userId:n}){const[s,i]=v.useState(!1),[o,d]=v.useState("approvals"),[c,m]=v.useState([]),[h,f]=v.useState([]),[p,x]=v.useState(null),[g,y]=v.useState(null),[w,N]=v.useState(""),[S,E]=v.useState(0),C=v.useRef(null),k=v.useRef(null),[T,R]=v.useState({top:0,left:0}),z=v.useCallback(async()=>{try{const[O,D]=await Promise.all([se.notifications.list(n,!1),se.approvals.list()]);m(O.notifications),E(O.unreadCount??O.notifications.filter(Z=>!Z.read).length),f(D.approvals)}catch{}},[n]);v.useEffect(()=>{z();const O=setInterval(z,15e3),D=()=>z();return window.addEventListener("markus:notifications-changed",D),()=>{clearInterval(O),window.removeEventListener("markus:notifications-changed",D)}},[z]),v.useLayoutEffect(()=>{if(!s||!C.current)return;const O=C.current.getBoundingClientRect();R({top:O.top,left:O.right+8})},[s]),v.useEffect(()=>{if(!s)return;const O=D=>{C.current?.contains(D.target)||k.current?.contains(D.target)||i(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[s]);const U=new Set(h.map(O=>O.id)),G=c.filter(O=>!(O.type==="approval_request"&&O.metadata?.approvalId&&U.has(O.metadata.approvalId))),W=h.filter(O=>O.status==="pending").length,$=S+W,F=async O=>{await se.notifications.markRead(O),m(D=>D.map(Z=>Z.id===O?{...Z,read:!0}:Z)),E(D=>Math.max(0,D-1))},Y=O=>{const D=O.metadata??{},Z=O.actionType,B=O.actionTarget;if(Z==="open_chat"&&B)try{const q=typeof B=="string"?JSON.parse(B):B;if(q.agentId){const X={agentId:q.agentId};q.sessionId&&(X.sessionId=q.sessionId),pt.navigate(xe.TEAM,X);return}}catch{}if(Z==="navigate"&&B)try{const q=typeof B=="string"?JSON.parse(B):B;if(q.path&&q.path.startsWith("/work")){const X={},I=new URLSearchParams(q.path.split("?")[1]||"");for(const[_,V]of I.entries())X[_]=V;pt.navigate(xe.WORK,X);return}}catch{}switch(O.type){case"approval_request":{const q=D.approvalId,I=(q?h.find(_=>_.id===q):void 0)?.details?.taskId??D.taskId;I?pt.navigate(xe.WORK,{openTask:I}):pt.navigate(xe.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":case"task_status_changed":D.taskId?pt.navigate(xe.WORK,{openTask:D.taskId}):pt.navigate(xe.WORK);break;case"requirement_created":case"requirement_decision":D.requirementId?pt.navigate(xe.WORK,{openRequirement:D.requirementId}):pt.navigate(xe.WORK);break;case"agent_chat_request":{const q={};D.agentId&&(q.agentId=D.agentId),D.sessionId&&(q.sessionId=D.sessionId),pt.navigate(xe.TEAM,Object.keys(q).length>0?q:void 0);break}case"agent_notification":case"agent_alert":case"agent_escalation":D.agentId?pt.navigate(xe.TEAM,{selectAgent:D.agentId}):pt.navigate(xe.TEAM);break;case"bounty_posted":pt.navigate(xe.SETTINGS);break;default:D.taskId?pt.navigate(xe.WORK,{openTask:D.taskId}):D.requirementId?pt.navigate(xe.WORK,{openRequirement:D.requirementId}):D.projectId?pt.navigate(xe.WORK,{projectId:D.projectId}):D.agentId&&pt.navigate(xe.TEAM,{selectAgent:D.agentId});break}},P=async O=>{O.read||F(O.id);const D=O.metadata??{},Z=D.taskId,B=D.requirementId;if(Z||B){const q=c.filter(X=>X.id!==O.id&&!X.read&&(Z&&X.metadata?.taskId===Z||B&&X.metadata?.requirementId===B));for(const X of q)F(X.id)}Y(O)},M=async(O,D,Z)=>{x(O);try{const{approval:B}=await se.approvals.respond(O,D,n,Z);f(X=>X.map(I=>I.id===O?B:I)),y(null),N("");const q=c.find(X=>X.type==="approval_request"&&X.metadata?.approvalId===O);q&&!q.read&&(se.notifications.markRead(q.id),m(X=>X.map(I=>I.id===q.id?{...I,read:!0}:I))),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}x(null)},L=async()=>{try{await se.notifications.markAllRead(n??"default"),m(O=>O.map(D=>({...D,read:!0}))),E(0)}catch{const O=G.filter(D=>!D.read);await Promise.all(O.map(D=>se.notifications.markRead(D.id))),m(D=>D.map(Z=>({...Z,read:!0}))),E(0)}},A=O=>{const D=O.details?.taskId,Z=O.details?.agentId;D?pt.navigate(xe.WORK,{openTask:D}):Z?pt.navigate(xe.TEAM,{selectAgent:Z}):pt.navigate(xe.WORK)};return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:C,onClick:()=>{i(!s),s||z()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${s?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:"Notifications",children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),$>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:$>99?"99+":$})]}),s&&Jm.createPortal(t.jsxs("div",{ref:k,className:"fixed w-[28rem] max-h-[36rem] bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:T.top,left:T.left},children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>d("approvals"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${o==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Approvals",W>0?` (${W})`:""]}),t.jsxs("button",{onClick:()=>d("notifications"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${o==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Notifications",S>0?` (${S})`:""]}),t.jsx("button",{onClick:()=>i(!1),className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:"Close",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),o==="notifications"&&S>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:L,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:"Mark all read"})}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o==="approvals"&&(h.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:"No approval requests"}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[h.filter(O=>O.status==="pending").map(O=>{const D=O.details?.command,Z=D?O.description.replace(/\s*Command:.*$/,""):O.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:wh.approval_request})}),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 text-fg-primary font-medium",children:O.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Sb(O.requestedAt)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:O.agentName})]})]}),t.jsx("p",{className:"text-[11px] text-fg-secondary leading-relaxed",children:Z}),D&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed",children:D}),t.jsx("button",{onClick:()=>A(O),className:"text-[11px] text-brand-500 hover:text-brand-400 transition-colors",children:"View execution context →"}),g===O.id?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:"Reason for rejection (optional, Enter to submit)",value:w,onChange:B=>N(B.target.value),onKeyDown:B=>{B.key==="Enter"&&M(O.id,!1,w||void 0),B.key==="Escape"&&(y(null),N(""))},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:p===O.id,onClick:()=>M(O.id,!1,w||void 0),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-red-600 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors",children:"Confirm Reject"}),t.jsx("button",{onClick:()=>{y(null),N("")},className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:p===O.id,onClick:()=>M(O.id,!0),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:"Approve"}),t.jsx("button",{disabled:p===O.id,onClick:()=>{y(O.id),N("")},className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:"Reject"})]})]},O.id)}),h.filter(O=>O.status!=="pending").slice(0,20).map(O=>t.jsxs("button",{onClick:()=>A(O),className:"w-full text-left px-3 py-2.5 opacity-50 hover:opacity-70 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${O.status==="approved"?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:O.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:O.status})]}),O.responseComment&&t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-3.5 truncate",children:["“",O.responseComment,"”"]})]},O.id))]})),o==="notifications"&&(G.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:"No notifications"}):t.jsx("div",{className:"divide-y divide-border-default/50",children:G.slice(0,50).map(O=>{const D=sk[O.type]??"text-fg-tertiary";return t.jsxs("button",{onClick:()=>P(O),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${O.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:D,children:t.jsx("path",{d:wh[O.type]??wh.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!O.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${kb[O.priority]??kb.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:O.title})]}),t.jsx("p",{className:"text-[11px] text-fg-tertiary line-clamp-2 mt-0.5",children:O.body}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Sb(O.createdAt)}),Cb(O)&&t.jsx("span",{className:`text-[10px] font-medium ${D}`,children:Cb(O)})]})]})]},O.id)})}))]})]}),document.body)]})}const ak="(max-width: 767px)";let Nh=null;function j1(){return Nh||(Nh=window.matchMedia(ak)),Nh}function ik(e){const n=j1();return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function lk(){return j1().matches}function ok(){return!1}function Sr(){return v.useSyncExternalStore(ik,lk,ok)}function Eb({authUser:e}={}){const n=Sr(),[s,i]=v.useState([]),[o,d]=v.useState([]),[c,m]=v.useState({}),[h,f]=v.useState(null),p="7d",[x,g]=v.useState([]),[y,w]=v.useState(null),N=()=>{se.agents.list().then($=>i($.agents)).catch(()=>{}),se.teams.list().then($=>d($.teams)).catch(()=>{}),se.tasks.board().then($=>m($.board)).catch(()=>{}),se.ops.dashboard(p).then(f).catch(()=>{}),se.requirements.list({source:"agent"}).then($=>{g($.requirements.filter(F=>F.status==="pending"))}).catch(()=>{}),se.system.storage().then(w).catch(()=>{})};v.useEffect(()=>{N();const $=setInterval(N,3e4),F=()=>N();return window.addEventListener("markus:data-changed",F),()=>{clearInterval($),window.removeEventListener("markus:data-changed",F)}},[p]);const S=$=>$,E={};for(const[$,F]of Object.entries(c)){const Y=S(F).length;Y>0&&(E[$]=Y)}const C=E.pending??0,k=E.in_progress??0,T=E.completed??0;E.failed;const R=Object.values(E).reduce(($,F)=>$+F,0),z=s.filter($=>$.status==="idle"||$.status==="working").length,U=s.filter($=>$.status==="working").length,G=s.reduce(($,F)=>$+(F.mailboxDepth??0),0),W=v.useMemo(()=>{const $=new Map(s.map(F=>[F.id,F]));return o.map(F=>{const Y=F.members.filter(L=>L.type==="agent").map(L=>$.get(L.id)).filter(L=>!!L),P=Y.filter(L=>L.status==="working").length,M=Y.filter(L=>L.status==="idle"||L.status==="working").length;return{team:F,agents:Y,working:P,active:M,total:Y.length}})},[o,s]);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:[n&&t.jsx(hm,{collapsed:!0,userId:e?.id}),t.jsx("h2",{className:"text-lg font-semibold",children:"Overview"})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:()=>pt.navigate(xe.STORE,{storeTab:"agents"}),className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-lg transition-colors",children:"+ Hire Agent"})})]}),t.jsxs("div",{className:"p-7 space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(id,{label:"Active Agents",value:z,total:s.length,color:"indigo",onClick:()=>pt.navigate(xe.TEAM)}),t.jsx(id,{label:"Tasks In Progress",value:k,color:"blue",onClick:()=>pt.navigate(xe.WORK)}),t.jsx(id,{label:"Pending Queue",value:C,color:"amber",onClick:()=>pt.navigate(xe.WORK)}),t.jsx(id,{label:"Completed",value:T,total:R>0?R:void 0,color:"green",onClick:()=>pt.navigate(xe.WORK)})]}),R===0&&(!h||h.taskKPI.recentActivity.length===0)&&t.jsxs("div",{className:"bg-surface-secondary border border-brand-500/20 rounded-xl p-6",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-primary mb-1",children:"Your AI workforce is ready"}),t.jsx("p",{className:"text-xs text-fg-secondary mb-4",children:"Get started in under a minute — describe what you need and let your team take it from here."}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[{label:"Describe Your Goal",desc:"Chat with the Secretary — it will assemble a team and break down tasks",page:xe.TEAM},{label:"Hire Agents",desc:"Browse templates: developers, researchers, writers, analysts, and more",page:xe.STORE},{label:"Create a Project",desc:"Set up requirements and let agents plan, execute, and deliver",page:xe.WORK}].map($=>t.jsxs("button",{onClick:()=>pt.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))})]}),U>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Agent Focus"}),G>0&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[G," total queued"]})]}),t.jsx("div",{className:"space-y-1.5",children:s.filter($=>$.status==="working").map($=>t.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer transition-colors",onClick:()=>pt.navigate(xe.TEAM,{agentId:$.id,profileTab:"mind"}),children:[t.jsx("div",{className:"w-5 h-5 rounded-full bg-brand-600/30 flex items-center justify-center text-[9px] font-bold text-brand-400 shrink-0",children:$.name.charAt(0)}),t.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:$.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate flex-1",children:$.currentActivity?.label??"Working..."}),($.mailboxDepth??0)>0&&t.jsxs("span",{className:"text-[9px] bg-amber-500/20 text-amber-400 rounded-full px-1.5 shrink-0",children:[$.mailboxDepth," queued"]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${$.attentionState==="focused"?"bg-brand-400 animate-pulse":$.attentionState==="deciding"?"bg-amber-400 animate-pulse":"bg-green-400"}`})]},$.id))})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[R>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:()=>pt.navigate(xe.WORK),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"Task Distribution"}),t.jsx(dk,{statusCounts:E,total:R}),(E.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"}),E.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:()=>pt.navigate(xe.TEAM),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),W.length===0&&s.length===0?t.jsx("div",{className:"text-sm text-fg-tertiary py-4 text-center cursor-pointer",onClick:()=>pt.navigate(xe.TEAM),children:"No teams yet. Create a team or hire agents to get started."}):t.jsxs("div",{className:"space-y-4",children:[W.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:()=>pt.navigate(xe.TEAM),children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-600/30 flex items-center justify-center text-xs font-bold text-brand-500 shrink-0",children:$.team.name.charAt(0)}),t.jsxs("div",{className:"min-w-0",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-[260px]",children:$.team.description})]}),t.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary ml-auto shrink-0",children:[t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-surface-overlay/50",children:[$.total," members"]}),$.working>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-500",children:[$.working," working"]}),t.jsxs("span",{className:`px-1.5 py-0.5 rounded ${$.active===$.total?"bg-green-500/15 text-green-600":"bg-surface-overlay/50"}`,children:[$.active," active"]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[$.agents.slice(0,6).map(F=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30",onClick:Y=>{Y.stopPropagation(),pt.navigate(xe.TEAM,{selectAgent:F.id})},children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${F.status==="idle"?"bg-green-400":F.status==="working"?"bg-blue-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:F.name})]},F.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(o.flatMap(Y=>Y.members.filter(P=>P.type==="agent").map(P=>P.id))),F=s.filter(Y=>!$.has(Y.id));return F.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:[F.length," agents"]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[F.slice(0,6).map(Y=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30 cursor-pointer",onClick:()=>pt.navigate(xe.TEAM,{selectAgent:Y.id}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Y.status==="idle"?"bg-green-400":Y.status==="working"?"bg-blue-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:Y.name})]},Y.id)),F.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",F.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:()=>pt.navigate(xe.WORK),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:()=>pt.navigate(xe.WORK),children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:$.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."]})]}),h&&h.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:()=>pt.navigate(xe.WORK),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:h.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:()=>pt.navigate(xe.WORK,{openTask:$.taskId}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${mm[$.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))})]}),h&&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(uo,{label:"Health Score",value:h.systemHealth.overallScore,max:100,unit:"%",color:h.systemHealth.overallScore>=80?"green":h.systemHealth.overallScore>=50?"amber":"red"}),t.jsx(uo,{label:"Success Rate",value:h.taskKPI.successRate,max:100,unit:"%",color:h.taskKPI.successRate>=80?"green":"amber"}),t.jsx(uo,{label:"Active / Total",value:z,max:s.length||1,unit:`/${s.length}`,color:"brand"}),t.jsx(uo,{label:"Token Cost",value:parseFloat(h.systemHealth.totalTokenCost.toFixed(2)),max:Math.max(1,Math.ceil(h.systemHealth.totalTokenCost*2)),unit:"$",color:"brand",raw:!0}),t.jsx(uo,{label:"Working Now",value:U,max:s.length||1,unit:`/${s.length}`,color:"blue"})]}),h.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:",h.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:()=>pt.navigate(xe.TEAM,{selectAgent:$.id}),children:[$.name," (",$.score,"%)"]},$.id))]})})]}),y&&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:()=>pt.navigate(xe.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:Tb(y.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: ",Tb(y.database.size)]}),t.jsxs("span",{children:["Agents: ",y.agents.length]})]}),t.jsx("div",{className:"mt-2 text-[10px] text-fg-tertiary",children:"Click to view details in Settings"})]})]})]})]})]})}const mm={pending:"bg-amber-500",in_progress:"bg-brand-500",blocked:"bg-red-500",review:"bg-blue-500",completed:"bg-green-500",failed:"bg-red-500",rejected:"bg-red-500",cancelled:"bg-gray-600"},ck={pending:"text-amber-600",in_progress:"text-brand-500",blocked:"text-red-500",review:"text-blue-600",completed:"text-green-600",failed:"text-red-500",rejected:"text-red-500",cancelled:"text-fg-tertiary"};function dk({statusCounts:e,total:n}){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:`${mm[i]??"bg-gray-600"} transition-all`,style:{width:`${o/n*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 ${mm[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 ${ck[i]??"text-fg-secondary"}`,children:o})]},i))})]})}function id({label:e,value:n,total:s,color:i,onClick:o}){const d={indigo:{text:"text-brand-400",border:"border-l-brand-500",glow:"hover:shadow-brand-500/10"},blue:{text:"text-blue-400",border:"border-l-blue-500",glow:"hover:shadow-blue-500/10"},amber:{text:"text-amber-400",border:"border-l-amber-500",glow:"hover:shadow-amber-500/10"},green:{text:"text-green-400",border:"border-l-green-500",glow:"hover:shadow-green-500/10"}},c=d[i]??d.indigo;return t.jsxs("div",{onClick:o,className:`bg-surface-secondary border border-border-default ${c.border} border-l-2 rounded-xl p-5 cursor-pointer hover:bg-surface-elevated/80 hover:shadow-lg ${c.glow} transition-all duration-200`,children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2",children:e}),t.jsxs("div",{className:`text-3xl font-bold ${c.text}`,children:[n,s!==void 0&&t.jsxs("span",{className:"text-base font-normal text-fg-muted",children:["/",s]})]})]})}function uo({label:e,value:n,max:s,unit:i,color:o,raw:d}){const c=s>0?Math.min(n/s*100,100):0,m={green:"bg-green-400",amber:"bg-amber-400",red:"bg-red-400",brand:"bg-brand-400",blue:"bg-blue-400"},h={green:"text-green-600",amber:"text-amber-600",red:"text-red-500",brand:"text-brand-500",blue:"text-blue-600"},f=m[o]??"bg-gray-400",p=h[o]??"text-fg-secondary";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-sm font-semibold ${p}`,children:d?`${i}${n}`:t.jsxs(t.Fragment,{children:[n,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 ${f} transition-all`,style:{width:`${c}%`}})})]})}function Tb(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}function uk(e,n){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const fk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mk={};function _b(e,n){return(mk.jsx?hk:fk).test(e)}const xk=/[ \t\n\f\r]/g;function pk(e){return typeof e=="object"?e.type==="text"?Ab(e.value):!1:Ab(e)}function Ab(e){return e.replace(xk,"")===""}class Yo{constructor(n,s,i){this.normal=s,this.property=n,i&&(this.space=i)}}Yo.prototype.normal={};Yo.prototype.property={};Yo.prototype.space=void 0;function w1(e,n){const s={},i={};for(const o of e)Object.assign(s,o.property),Object.assign(i,o.normal);return new Yo(s,i,n)}function xm(e){return e.toLowerCase()}class Cr{constructor(n,s){this.attribute=s,this.property=n}}Cr.prototype.attribute="";Cr.prototype.booleanish=!1;Cr.prototype.boolean=!1;Cr.prototype.commaOrSpaceSeparated=!1;Cr.prototype.commaSeparated=!1;Cr.prototype.defined=!1;Cr.prototype.mustUseProperty=!1;Cr.prototype.number=!1;Cr.prototype.overloadedBoolean=!1;Cr.prototype.property="";Cr.prototype.spaceSeparated=!1;Cr.prototype.space=void 0;let gk=0;const It=ji(),Vn=ji(),pm=ji(),Pe=ji(),kn=ji(),ol=ji(),zr=ji();function ji(){return 2**++gk}const gm=Object.freeze(Object.defineProperty({__proto__:null,boolean:It,booleanish:Vn,commaOrSpaceSeparated:zr,commaSeparated:ol,number:Pe,overloadedBoolean:pm,spaceSeparated:kn},Symbol.toStringTag,{value:"Module"})),kh=Object.keys(gm);class ex extends Cr{constructor(n,s,i,o){let d=-1;if(super(n,s),Mb(this,"space",o),typeof i=="number")for(;++d<kh.length;){const c=kh[d];Mb(this,kh[d],(i&gm[c])===gm[c])}}}ex.prototype.defined=!0;function Mb(e,n,s){s&&(e[n]=s)}function jl(e){const n={},s={};for(const[i,o]of Object.entries(e.properties)){const d=new ex(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(d.mustUseProperty=!0),n[i]=d,s[xm(i)]=i,s[xm(d.attribute)]=i}return new Yo(n,s,e.space)}const N1=jl({properties:{ariaActiveDescendant:null,ariaAtomic:Vn,ariaAutoComplete:null,ariaBusy:Vn,ariaChecked:Vn,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:kn,ariaCurrent:null,ariaDescribedBy:kn,ariaDetails:null,ariaDisabled:Vn,ariaDropEffect:kn,ariaErrorMessage:null,ariaExpanded:Vn,ariaFlowTo:kn,ariaGrabbed:Vn,ariaHasPopup:null,ariaHidden:Vn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kn,ariaLevel:Pe,ariaLive:null,ariaModal:Vn,ariaMultiLine:Vn,ariaMultiSelectable:Vn,ariaOrientation:null,ariaOwns:kn,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:Vn,ariaReadOnly:Vn,ariaRelevant:null,ariaRequired:Vn,ariaRoleDescription:kn,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:Vn,ariaSetSize:Pe,ariaSort:null,ariaValueMax:Pe,ariaValueMin:Pe,ariaValueNow:Pe,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function k1(e,n){return n in e?e[n]:n}function S1(e,n){return k1(e,n.toLowerCase())}const bk=jl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ol,acceptCharset:kn,accessKey:kn,action:null,allow:null,allowFullScreen:It,allowPaymentRequest:It,allowUserMedia:It,alt:null,as:null,async:It,autoCapitalize:null,autoComplete:kn,autoFocus:It,autoPlay:It,blocking:kn,capture:null,charSet:null,checked:It,cite:null,className:kn,cols:Pe,colSpan:null,content:null,contentEditable:Vn,controls:It,controlsList:kn,coords:Pe|ol,crossOrigin:null,data:null,dateTime:null,decoding:null,default:It,defer:It,dir:null,dirName:null,disabled:It,download:pm,draggable:Vn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:It,formTarget:null,headers:kn,height:Pe,hidden:pm,high:Pe,href:null,hrefLang:null,htmlFor:kn,httpEquiv:kn,id:null,imageSizes:null,imageSrcSet:null,inert:It,inputMode:null,integrity:null,is:null,isMap:It,itemId:null,itemProp:kn,itemRef:kn,itemScope:It,itemType:kn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:It,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:It,muted:It,name:null,nonce:null,noModule:It,noValidate:It,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:It,optimum:Pe,pattern:null,ping:kn,placeholder:null,playsInline:It,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:It,referrerPolicy:null,rel:kn,required:It,reversed:It,rows:Pe,rowSpan:Pe,sandbox:kn,scope:null,scoped:It,seamless:It,selected:It,shadowRootClonable:It,shadowRootDelegatesFocus:It,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:Vn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Pe,step:null,style:null,tabIndex:Pe,target:null,title:null,translate:null,type:null,typeMustMatch:It,useMap:null,value:Vn,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kn,axis:null,background:null,bgColor:null,border:Pe,borderColor:null,bottomMargin:Pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:It,declare:It,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:It,noHref:It,noShade:It,noWrap:It,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:Vn,standby:null,summary:null,text:null,topMargin:Pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:It,disableRemotePlayback:It,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:S1}),yk=jl({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:zr,accentHeight:Pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Pe,amplitude:Pe,arabicForm:null,ascent:Pe,attributeName:null,attributeType:null,azimuth:Pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Pe,by:null,calcMode:null,capHeight:Pe,className:kn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Pe,diffuseConstant:Pe,direction:null,display:null,dur:null,divisor:Pe,dominantBaseline:null,download:It,dx:null,dy:null,edgeMode:null,editable:null,elevation:Pe,enableBackground:null,end:null,event:null,exponent:Pe,externalResourcesRequired:null,fill:null,fillOpacity:Pe,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:ol,g2:ol,glyphName:ol,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Pe,horizOriginX:Pe,horizOriginY:Pe,id:null,ideographic:Pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Pe,k:Pe,k1:Pe,k2:Pe,k3:Pe,k4:Pe,kernelMatrix:zr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Pe,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:Pe,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:Pe,overlineThickness:Pe,paintOrder:null,panose1:null,path:null,pathLength:Pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:zr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:zr,rev:zr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:zr,requiredFeatures:zr,requiredFonts:zr,requiredFormats:zr,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:Pe,specularExponent:Pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Pe,strikethroughThickness:Pe,string:null,stroke:null,strokeDashArray:zr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Pe,strokeOpacity:Pe,strokeWidth:null,style:null,surfaceScale:Pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:zr,tabIndex:Pe,tableValues:null,target:null,targetX:Pe,targetY:Pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:zr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Pe,underlineThickness:Pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Pe,values:null,vAlphabetic:Pe,vMathematical:Pe,vectorEffect:null,vHanging:Pe,vIdeographic:Pe,version:null,vertAdvY:Pe,vertOriginX:Pe,vertOriginY:Pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:k1}),C1=jl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),E1=jl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:S1}),T1=jl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),vk={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"},jk=/[A-Z]/g,Ob=/-[a-z]/g,wk=/^data[-\w.:]+$/i;function Nk(e,n){const s=xm(n);let i=n,o=Cr;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&wk.test(n)){if(n.charAt(4)==="-"){const d=n.slice(5).replace(Ob,Sk);i="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=n.slice(4);if(!Ob.test(d)){let c=d.replace(jk,kk);c.charAt(0)!=="-"&&(c="-"+c),n="data"+c}}o=ex}return new o(i,n)}function kk(e){return"-"+e.toLowerCase()}function Sk(e){return e.charAt(1).toUpperCase()}const Ck=w1([N1,bk,C1,E1,T1],"html"),tx=w1([N1,yk,C1,E1,T1],"svg");function Ek(e){return e.join(" ").trim()}var Zi={},Sh,Rb;function Tk(){if(Rb)return Sh;Rb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,s=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,d=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,m=/^\s+|\s+$/g,h=`
11
- `,f="/",p="*",x="",g="comment",y="declaration";function w(S,E){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];E=E||{};var C=1,k=1;function T(M){var L=M.match(n);L&&(C+=L.length);var A=M.lastIndexOf(h);k=~A?M.length-A:k+M.length}function R(){var M={line:C,column:k};return function(L){return L.position=new z(M),W(),L}}function z(M){this.start=M,this.end={line:C,column:k},this.source=E.source}z.prototype.content=S;function U(M){var L=new Error(E.source+":"+C+":"+k+": "+M);if(L.reason=M,L.filename=E.source,L.line=C,L.column=k,L.source=S,!E.silent)throw L}function G(M){var L=M.exec(S);if(L){var A=L[0];return T(A),S=S.slice(A.length),L}}function W(){G(s)}function $(M){var L;for(M=M||[];L=F();)L!==!1&&M.push(L);return M}function F(){var M=R();if(!(f!=S.charAt(0)||p!=S.charAt(1))){for(var L=2;x!=S.charAt(L)&&(p!=S.charAt(L)||f!=S.charAt(L+1));)++L;if(L+=2,x===S.charAt(L-1))return U("End of comment missing");var A=S.slice(2,L-2);return k+=2,T(A),S=S.slice(L),k+=2,M({type:g,comment:A})}}function Y(){var M=R(),L=G(i);if(L){if(F(),!G(o))return U("property missing ':'");var A=G(d),O=M({type:y,property:N(L[0].replace(e,x)),value:A?N(A[0].replace(e,x)):x});return G(c),O}}function P(){var M=[];$(M);for(var L;L=Y();)L!==!1&&(M.push(L),$(M));return M}return W(),P()}function N(S){return S?S.replace(m,x):x}return Sh=w,Sh}var Db;function _k(){if(Db)return Zi;Db=1;var e=Zi&&Zi.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.default=s;const n=e(Tk());function s(i,o){let d=null;if(!i||typeof i!="string")return d;const c=(0,n.default)(i),m=typeof o=="function";return c.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:p}=h;m?o(f,p,h):p&&(d=d||{},d[f]=p)}),d}return Zi}var fo={},Lb;function Ak(){if(Lb)return fo;Lb=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,s=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,d=function(f){return!f||s.test(f)||e.test(f)},c=function(f,p){return p.toUpperCase()},m=function(f,p){return"".concat(p,"-")},h=function(f,p){return p===void 0&&(p={}),d(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(o,m):f=f.replace(i,m),f.replace(n,c))};return fo.camelCase=h,fo}var ho,Ib;function Mk(){if(Ib)return ho;Ib=1;var e=ho&&ho.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},n=e(_k()),s=Ak();function i(o,d){var c={};return!o||typeof o!="string"||(0,n.default)(o,function(m,h){m&&h&&(c[(0,s.camelCase)(m,d)]=h)}),c}return i.default=i,ho=i,ho}var Ok=Mk();const Rk=Zd(Ok),_1=A1("end"),nx=A1("start");function A1(e){return n;function n(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 Dk(e){const n=nx(e),s=_1(e);if(n&&s)return{start:n,end:s}}function Co(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?zb(e.position):"start"in e||"end"in e?zb(e):"line"in e||"column"in e?bm(e):""}function bm(e){return $b(e&&e.line)+":"+$b(e&&e.column)}function zb(e){return bm(e&&e.start)+"-"+bm(e&&e.end)}function $b(e){return e&&typeof e=="number"?e:1}class dr extends Error{constructor(n,s,i){super(),typeof s=="string"&&(i=s,s=void 0);let o="",d={},c=!1;if(s&&("line"in s&&"column"in s?d={place:s}:"start"in s&&"end"in s?d={place:s}:"type"in s?d={ancestors:[s],place:s.position}:d={...s}),typeof n=="string"?o=n:!d.cause&&n&&(c=!0,o=n.message,d.cause=n),!d.ruleId&&!d.source&&typeof i=="string"){const h=i.indexOf(":");h===-1?d.ruleId=i:(d.source=i.slice(0,h),d.ruleId=i.slice(h+1))}if(!d.place&&d.ancestors&&d.ancestors){const h=d.ancestors[d.ancestors.length-1];h&&(d.place=h.position)}const m=d.place&&"start"in d.place?d.place.start:d.place;this.ancestors=d.ancestors||void 0,this.cause=d.cause||void 0,this.column=m?m.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=m?m.line:void 0,this.name=Co(d.place)||"1:1",this.place=d.place||void 0,this.reason=this.message,this.ruleId=d.ruleId||void 0,this.source=d.source||void 0,this.stack=c&&d.cause&&typeof d.cause.stack=="string"?d.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}dr.prototype.file="";dr.prototype.name="";dr.prototype.reason="";dr.prototype.message="";dr.prototype.stack="";dr.prototype.column=void 0;dr.prototype.line=void 0;dr.prototype.ancestors=void 0;dr.prototype.cause=void 0;dr.prototype.fatal=void 0;dr.prototype.place=void 0;dr.prototype.ruleId=void 0;dr.prototype.source=void 0;const rx={}.hasOwnProperty,Lk=new Map,Ik=/[A-Z]/g,zk=new Set(["table","tbody","thead","tfoot","tr"]),$k=new Set(["td","th"]),M1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Bk(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=Gk(s,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=Yk(s,n.jsx,n.jsxs)}const o={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?tx:Ck,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},d=O1(o,e,void 0);return d&&typeof d!="string"?d:o.create(e,o.Fragment,{children:d||void 0},void 0)}function O1(e,n,s){if(n.type==="element")return Hk(e,n,s);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return Pk(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return qk(e,n,s);if(n.type==="mdxjsEsm")return Uk(e,n);if(n.type==="root")return Vk(e,n,s);if(n.type==="text")return Fk(e,n)}function Hk(e,n,s){const i=e.schema;let o=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=tx,e.schema=o),e.ancestors.push(n);const d=D1(e,n.tagName,!1),c=Xk(e,n);let m=ax(e,n);return zk.has(n.tagName)&&(m=m.filter(function(h){return typeof h=="string"?!pk(h):!0})),R1(e,c,d,n),sx(c,m),e.ancestors.pop(),e.schema=i,e.create(n,d,c,s)}function Pk(e,n){if(n.data&&n.data.estree&&e.evaluater){const i=n.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Ro(e,n.position)}function Uk(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Ro(e,n.position)}function qk(e,n,s){const i=e.schema;let o=i;n.name==="svg"&&i.space==="html"&&(o=tx,e.schema=o),e.ancestors.push(n);const d=n.name===null?e.Fragment:D1(e,n.name,!0),c=Kk(e,n),m=ax(e,n);return R1(e,c,d,n),sx(c,m),e.ancestors.pop(),e.schema=i,e.create(n,d,c,s)}function Vk(e,n,s){const i={};return sx(i,ax(e,n)),e.create(n,e.Fragment,i,s)}function Fk(e,n){return n.value}function R1(e,n,s,i){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(n.node=i)}function sx(e,n){if(n.length>0){const s=n.length>1?n:n[0];s&&(e.children=s)}}function Yk(e,n,s){return i;function i(o,d,c,m){const f=Array.isArray(c.children)?s:n;return m?f(d,c,m):f(d,c)}}function Gk(e,n){return s;function s(i,o,d,c){const m=Array.isArray(d.children),h=nx(i);return n(o,d,c,m,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function Xk(e,n){const s={};let i,o;for(o in n.properties)if(o!=="children"&&rx.call(n.properties,o)){const d=Wk(e,o,n.properties[o]);if(d){const[c,m]=d;e.tableCellAlignToStyle&&c==="align"&&typeof m=="string"&&$k.has(n.tagName)?i=m:s[c]=m}}if(i){const d=s.style||(s.style={});d[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return s}function Kk(e,n){const s={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const d=i.data.estree.body[0];d.type;const c=d.expression;c.type;const m=c.properties[0];m.type,Object.assign(s,e.evaluater.evaluateExpression(m.argument))}else Ro(e,n.position);else{const o=i.name;let d;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const m=i.value.data.estree.body[0];m.type,d=e.evaluater.evaluateExpression(m.expression)}else Ro(e,n.position);else d=i.value===null?!0:i.value;s[o]=d}return s}function ax(e,n){const s=[];let i=-1;const o=e.passKeys?new Map:Lk;for(;++i<n.children.length;){const d=n.children[i];let c;if(e.passKeys){const h=d.type==="element"?d.tagName:d.type==="mdxJsxFlowElement"||d.type==="mdxJsxTextElement"?d.name:void 0;if(h){const f=o.get(h)||0;c=h+"-"+f,o.set(h,f+1)}}const m=O1(e,d,c);m!==void 0&&s.push(m)}return s}function Wk(e,n,s){const i=Nk(e.schema,n);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=i.commaSeparated?uk(s):Ek(s)),i.property==="style"){let o=typeof s=="object"?s:Zk(e,String(s));return e.stylePropertyNameCase==="css"&&(o=Qk(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?vk[i.property]||i.property:i.attribute,s]}}function Zk(e,n){try{return Rk(n,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const i=s,o=new dr("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=M1+"#cannot-parse-style-attribute",o}}function D1(e,n,s){let i;if(!s)i={type:"Literal",value:n};else if(n.includes(".")){const o=n.split(".");let d=-1,c;for(;++d<o.length;){const m=_b(o[d])?{type:"Identifier",name:o[d]}:{type:"Literal",value:o[d]};c=c?{type:"MemberExpression",object:c,property:m,computed:!!(d&&m.type==="Literal"),optional:!1}:m}i=c}else i=_b(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const o=i.value;return rx.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);Ro(e)}function Ro(e,n){const s=new dr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=M1+"#cannot-handle-mdx-estrees-without-createevaluater",s}function Qk(e){const n={};let s;for(s in e)rx.call(e,s)&&(n[Jk(s)]=e[s]);return n}function Jk(e){let n=e.replace(Ik,eS);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function eS(e){return"-"+e.toLowerCase()}const Ch={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"]},tS={};function ix(e,n){const s=tS,i=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,o=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return L1(e,i,o)}function L1(e,n,s){if(nS(e)){if("value"in e)return e.type==="html"&&!s?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Bb(e.children,n,s)}return Array.isArray(e)?Bb(e,n,s):""}function Bb(e,n,s){const i=[];let o=-1;for(;++o<e.length;)i[o]=L1(e[o],n,s);return i.join("")}function nS(e){return!!(e&&typeof e=="object")}const Hb=document.createElement("i");function lx(e){const n="&"+e+";";Hb.innerHTML=n;const s=Hb.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===n?!1:s}function Br(e,n,s,i){const o=e.length;let d=0,c;if(n<0?n=-n>o?0:o+n:n=n>o?o:n,s=s>0?s:0,i.length<1e4)c=Array.from(i),c.unshift(n,s),e.splice(...c);else for(s&&e.splice(n,s);d<i.length;)c=i.slice(d,d+1e4),c.unshift(n,0),e.splice(...c),d+=1e4,n+=1e4}function Qr(e,n){return e.length>0?(Br(e,e.length,0,n),e):n}const Pb={}.hasOwnProperty;function I1(e){const n={};let s=-1;for(;++s<e.length;)rS(n,e[s]);return n}function rS(e,n){let s;for(s in n){const o=(Pb.call(e,s)?e[s]:void 0)||(e[s]={}),d=n[s];let c;if(d)for(c in d){Pb.call(o,c)||(o[c]=[]);const m=d[c];sS(o[c],Array.isArray(m)?m:m?[m]:[])}}}function sS(e,n){let s=-1;const i=[];for(;++s<n.length;)(n[s].add==="after"?e:i).push(n[s]);Br(e,0,0,i)}function z1(e,n){const s=Number.parseInt(e,n);return s<9||s===11||s>13&&s<32||s>126&&s<160||s>55295&&s<57344||s>64975&&s<65008||(s&65535)===65535||(s&65535)===65534||s>1114111?"�":String.fromCodePoint(s)}function us(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const mr=Ba(/[A-Za-z]/),cr=Ba(/[\dA-Za-z]/),aS=Ba(/[#-'*+\--9=?A-Z^-~]/);function Ad(e){return e!==null&&(e<32||e===127)}const ym=Ba(/\d/),iS=Ba(/[\dA-Fa-f]/),lS=Ba(/[!-/:-@[-`{-~]/);function vt(e){return e!==null&&e<-2}function jn(e){return e!==null&&(e<0||e===32)}function qt(e){return e===-2||e===-1||e===32}const Qd=Ba(new RegExp("\\p{P}|\\p{S}","u")),xi=Ba(/\s/);function Ba(e){return n;function n(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function wl(e){const n=[];let s=-1,i=0,o=0;for(;++s<e.length;){const d=e.charCodeAt(s);let c="";if(d===37&&cr(e.charCodeAt(s+1))&&cr(e.charCodeAt(s+2)))o=2;else if(d<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(d))||(c=String.fromCharCode(d));else if(d>55295&&d<57344){const m=e.charCodeAt(s+1);d<56320&&m>56319&&m<57344?(c=String.fromCharCode(d,m),o=1):c="�"}else c=String.fromCharCode(d);c&&(n.push(e.slice(i,s),encodeURIComponent(c)),i=s+o+1,c=""),o&&(s+=o,o=0)}return n.join("")+e.slice(i)}function Kt(e,n,s,i){const o=i?i-1:Number.POSITIVE_INFINITY;let d=0;return c;function c(h){return qt(h)?(e.enter(s),m(h)):n(h)}function m(h){return qt(h)&&d++<o?(e.consume(h),m):(e.exit(s),n(h))}}const oS={tokenize:cS};function cS(e){const n=e.attempt(this.parser.constructs.contentInitial,i,o);let s;return n;function i(m){if(m===null){e.consume(m);return}return e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Kt(e,n,"linePrefix")}function o(m){return e.enter("paragraph"),d(m)}function d(m){const h=e.enter("chunkText",{contentType:"text",previous:s});return s&&(s.next=h),s=h,c(m)}function c(m){if(m===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(m);return}return vt(m)?(e.consume(m),e.exit("chunkText"),d):(e.consume(m),c)}}const dS={tokenize:uS},Ub={tokenize:fS};function uS(e){const n=this,s=[];let i=0,o,d,c;return m;function m(k){if(i<s.length){const T=s[i];return n.containerState=T[1],e.attempt(T[0].continuation,h,f)(k)}return f(k)}function h(k){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,o&&C();const T=n.events.length;let R=T,z;for(;R--;)if(n.events[R][0]==="exit"&&n.events[R][1].type==="chunkFlow"){z=n.events[R][1].end;break}E(i);let U=T;for(;U<n.events.length;)n.events[U][1].end={...z},U++;return Br(n.events,R+1,0,n.events.slice(T)),n.events.length=U,f(k)}return m(k)}function f(k){if(i===s.length){if(!o)return g(k);if(o.currentConstruct&&o.currentConstruct.concrete)return w(k);n.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(Ub,p,x)(k)}function p(k){return o&&C(),E(i),g(k)}function x(k){return n.parser.lazy[n.now().line]=i!==s.length,c=n.now().offset,w(k)}function g(k){return n.containerState={},e.attempt(Ub,y,w)(k)}function y(k){return i++,s.push([n.currentConstruct,n.containerState]),g(k)}function w(k){if(k===null){o&&C(),E(0),e.consume(k);return}return o=o||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:d}),N(k)}function N(k){if(k===null){S(e.exit("chunkFlow"),!0),E(0),e.consume(k);return}return vt(k)?(e.consume(k),S(e.exit("chunkFlow")),i=0,n.interrupt=void 0,m):(e.consume(k),N)}function S(k,T){const R=n.sliceStream(k);if(T&&R.push(null),k.previous=d,d&&(d.next=k),d=k,o.defineSkip(k.start),o.write(R),n.parser.lazy[k.start.line]){let z=o.events.length;for(;z--;)if(o.events[z][1].start.offset<c&&(!o.events[z][1].end||o.events[z][1].end.offset>c))return;const U=n.events.length;let G=U,W,$;for(;G--;)if(n.events[G][0]==="exit"&&n.events[G][1].type==="chunkFlow"){if(W){$=n.events[G][1].end;break}W=!0}for(E(i),z=U;z<n.events.length;)n.events[z][1].end={...$},z++;Br(n.events,G+1,0,n.events.slice(U)),n.events.length=z}}function E(k){let T=s.length;for(;T-- >k;){const R=s[T];n.containerState=R[1],R[0].exit.call(n,e)}s.length=k}function C(){o.write([null]),d=void 0,o=void 0,n.containerState._closeFlow=void 0}}function fS(e,n,s){return Kt(e,e.attempt(this.parser.constructs.document,n,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ul(e){if(e===null||jn(e)||xi(e))return 1;if(Qd(e))return 2}function Jd(e,n,s){const i=[];let o=-1;for(;++o<e.length;){const d=e[o].resolveAll;d&&!i.includes(d)&&(n=d(n,s),i.push(d))}return n}const vm={name:"attention",resolveAll:hS,tokenize:mS};function hS(e,n){let s=-1,i,o,d,c,m,h,f,p;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&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.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;h=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 x={...e[i][1].end},g={...e[s][1].start};qb(x,-h),qb(g,h),c={type:h>1?"strongSequence":"emphasisSequence",start:x,end:{...e[i][1].end}},m={type:h>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:g},d={type:h>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[s][1].start}},o={type:h>1?"strong":"emphasis",start:{...c.start},end:{...m.end}},e[i][1].end={...c.start},e[s][1].start={...m.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=Qr(f,[["enter",e[i][1],n],["exit",e[i][1],n]])),f=Qr(f,[["enter",o,n],["enter",c,n],["exit",c,n],["enter",d,n]]),f=Qr(f,Jd(n.parser.constructs.insideSpan.null,e.slice(i+1,s),n)),f=Qr(f,[["exit",d,n],["enter",m,n],["exit",m,n],["exit",o,n]]),e[s][1].end.offset-e[s][1].start.offset?(p=2,f=Qr(f,[["enter",e[s][1],n],["exit",e[s][1],n]])):p=0,Br(e,i-1,s-i+3,f),s=i+f.length-p-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function mS(e,n){const s=this.parser.constructs.attentionMarkers.null,i=this.previous,o=ul(i);let d;return c;function c(h){return d=h,e.enter("attentionSequence"),m(h)}function m(h){if(h===d)return e.consume(h),m;const f=e.exit("attentionSequence"),p=ul(h),x=!p||p===2&&o||s.includes(h),g=!o||o===2&&p||s.includes(i);return f._open=!!(d===42?x:x&&(o||!g)),f._close=!!(d===42?g:g&&(p||!x)),n(h)}}function qb(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const xS={name:"autolink",tokenize:pS};function pS(e,n,s){let i=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),d}function d(y){return mr(y)?(e.consume(y),c):y===64?s(y):f(y)}function c(y){return y===43||y===45||y===46||cr(y)?(i=1,m(y)):f(y)}function m(y){return y===58?(e.consume(y),i=0,h):(y===43||y===45||y===46||cr(y))&&i++<32?(e.consume(y),m):(i=0,f(y))}function h(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),n):y===null||y===32||y===60||Ad(y)?s(y):(e.consume(y),h)}function f(y){return y===64?(e.consume(y),p):aS(y)?(e.consume(y),f):s(y)}function p(y){return cr(y)?x(y):s(y)}function x(y){return y===46?(e.consume(y),i=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),n):g(y)}function g(y){if((y===45||cr(y))&&i++<63){const w=y===45?g:x;return e.consume(y),w}return s(y)}}const Go={partial:!0,tokenize:gS};function gS(e,n,s){return i;function i(d){return qt(d)?Kt(e,o,"linePrefix")(d):o(d)}function o(d){return d===null||vt(d)?n(d):s(d)}}const $1={continuation:{tokenize:yS},exit:vS,name:"blockQuote",tokenize:bS};function bS(e,n,s){const i=this;return o;function o(c){if(c===62){const m=i.containerState;return m.open||(e.enter("blockQuote",{_container:!0}),m.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),d}return s(c)}function d(c){return qt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(c))}}function yS(e,n,s){const i=this;return o;function o(c){return qt(c)?Kt(e,d,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):d(c)}function d(c){return e.attempt($1,n,s)(c)}}function vS(e){e.exit("blockQuote")}const B1={name:"characterEscape",tokenize:jS};function jS(e,n,s){return i;function i(d){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(d),e.exit("escapeMarker"),o}function o(d){return lS(d)?(e.enter("characterEscapeValue"),e.consume(d),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):s(d)}}const H1={name:"characterReference",tokenize:wS};function wS(e,n,s){const i=this;let o=0,d,c;return m;function m(x){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),h}function h(x){return x===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(x),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),d=31,c=cr,p(x))}function f(x){return x===88||x===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(x),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),d=6,c=iS,p):(e.enter("characterReferenceValue"),d=7,c=ym,p(x))}function p(x){if(x===59&&o){const g=e.exit("characterReferenceValue");return c===cr&&!lx(i.sliceSerialize(g))?s(x):(e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return c(x)&&o++<d?(e.consume(x),p):s(x)}}const Vb={partial:!0,tokenize:kS},Fb={concrete:!0,name:"codeFenced",tokenize:NS};function NS(e,n,s){const i=this,o={partial:!0,tokenize:R};let d=0,c=0,m;return h;function h(z){return f(z)}function f(z){const U=i.events[i.events.length-1];return d=U&&U[1].type==="linePrefix"?U[2].sliceSerialize(U[1],!0).length:0,m=z,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(z)}function p(z){return z===m?(c++,e.consume(z),p):c<3?s(z):(e.exit("codeFencedFenceSequence"),qt(z)?Kt(e,x,"whitespace")(z):x(z))}function x(z){return z===null||vt(z)?(e.exit("codeFencedFence"),i.interrupt?n(z):e.check(Vb,N,T)(z)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(z))}function g(z){return z===null||vt(z)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),x(z)):qt(z)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Kt(e,y,"whitespace")(z)):z===96&&z===m?s(z):(e.consume(z),g)}function y(z){return z===null||vt(z)?x(z):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(z))}function w(z){return z===null||vt(z)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),x(z)):z===96&&z===m?s(z):(e.consume(z),w)}function N(z){return e.attempt(o,T,S)(z)}function S(z){return e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),E}function E(z){return d>0&&qt(z)?Kt(e,C,"linePrefix",d+1)(z):C(z)}function C(z){return z===null||vt(z)?e.check(Vb,N,T)(z):(e.enter("codeFlowValue"),k(z))}function k(z){return z===null||vt(z)?(e.exit("codeFlowValue"),C(z)):(e.consume(z),k)}function T(z){return e.exit("codeFenced"),n(z)}function R(z,U,G){let W=0;return $;function $(L){return z.enter("lineEnding"),z.consume(L),z.exit("lineEnding"),F}function F(L){return z.enter("codeFencedFence"),qt(L)?Kt(z,Y,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):Y(L)}function Y(L){return L===m?(z.enter("codeFencedFenceSequence"),P(L)):G(L)}function P(L){return L===m?(W++,z.consume(L),P):W>=c?(z.exit("codeFencedFenceSequence"),qt(L)?Kt(z,M,"whitespace")(L):M(L)):G(L)}function M(L){return L===null||vt(L)?(z.exit("codeFencedFence"),U(L)):G(L)}}}function kS(e,n,s){const i=this;return o;function o(c){return c===null?s(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d)}function d(c){return i.parser.lazy[i.now().line]?s(c):n(c)}}const Eh={name:"codeIndented",tokenize:CS},SS={partial:!0,tokenize:ES};function CS(e,n,s){const i=this;return o;function o(f){return e.enter("codeIndented"),Kt(e,d,"linePrefix",5)(f)}function d(f){const p=i.events[i.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?c(f):s(f)}function c(f){return f===null?h(f):vt(f)?e.attempt(SS,c,h)(f):(e.enter("codeFlowValue"),m(f))}function m(f){return f===null||vt(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),m)}function h(f){return e.exit("codeIndented"),n(f)}}function ES(e,n,s){const i=this;return o;function o(c){return i.parser.lazy[i.now().line]?s(c):vt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):Kt(e,d,"linePrefix",5)(c)}function d(c){const m=i.events[i.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?n(c):vt(c)?o(c):s(c)}}const TS={name:"codeText",previous:AS,resolve:_S,tokenize:MS};function _S(e){let n=e.length-4,s=3,i,o;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=s;++i<n;)if(e[i][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[n][1].type="codeTextPadding",s+=2,n-=2;break}}for(i=s-1,n++;++i<=n;)o===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(o=i):(i===n||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),n-=i-o-2,i=o+2),o=void 0);return e}function AS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function MS(e,n,s){let i=0,o,d;return c;function c(x){return e.enter("codeText"),e.enter("codeTextSequence"),m(x)}function m(x){return x===96?(e.consume(x),i++,m):(e.exit("codeTextSequence"),h(x))}function h(x){return x===null?s(x):x===32?(e.enter("space"),e.consume(x),e.exit("space"),h):x===96?(d=e.enter("codeTextSequence"),o=0,p(x)):vt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),h):(e.enter("codeTextData"),f(x))}function f(x){return x===null||x===32||x===96||vt(x)?(e.exit("codeTextData"),h(x)):(e.consume(x),f)}function p(x){return x===96?(e.consume(x),o++,p):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(x)):(d.type="codeTextData",f(x))}}class OS{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,s){const i=s??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(n,i):n>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(n,s,i){const o=s||0;this.setCursor(Math.trunc(n));const d=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return i&&mo(this.left,i),d.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),mo(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),mo(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const s=this.left.splice(n,Number.POSITIVE_INFINITY);mo(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);mo(this.left,s.reverse())}}}function mo(e,n){let s=0;if(n.length<1e4)e.push(...n);else for(;s<n.length;)e.push(...n.slice(s,s+1e4)),s+=1e4}function P1(e){const n={};let s=-1,i,o,d,c,m,h,f;const p=new OS(e);for(;++s<p.length;){for(;s in n;)s=n[s];if(i=p.get(s),s&&i[1].type==="chunkFlow"&&p.get(s-1)[1].type==="listItemPrefix"&&(h=i[1]._tokenizer.events,d=0,d<h.length&&h[d][1].type==="lineEndingBlank"&&(d+=2),d<h.length&&h[d][1].type==="content"))for(;++d<h.length&&h[d][1].type!=="content";)h[d][1].type==="chunkText"&&(h[d][1]._isInFirstContentOfListItem=!0,d++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,RS(p,s)),s=n[s],f=!0);else if(i[1]._container){for(d=s,o=void 0;d--;)if(c=p.get(d),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(p.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=d);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(i[1].end={...p.get(o)[1].start},m=p.slice(o,s),m.unshift(i),p.splice(o,s-o+1,m))}}return Br(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function RS(e,n){const s=e.get(n)[1],i=e.get(n)[2];let o=n-1;const d=[];let c=s._tokenizer;c||(c=i.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const m=c.events,h=[],f={};let p,x,g=-1,y=s,w=0,N=0;const S=[N];for(;y;){for(;e.get(++o)[1]!==y;);d.push(o),y._tokenizer||(p=i.sliceStream(y),y.next||p.push(null),x&&c.defineSkip(y.start),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(p),y._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),x=y,y=y.next}for(y=s;++g<m.length;)m[g][0]==="exit"&&m[g-1][0]==="enter"&&m[g][1].type===m[g-1][1].type&&m[g][1].start.line!==m[g][1].end.line&&(N=g+1,S.push(N),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(c.events=[],y?(y._tokenizer=void 0,y.previous=void 0):S.pop(),g=S.length;g--;){const E=m.slice(S[g],S[g+1]),C=d.pop();h.push([C,C+E.length-1]),e.splice(C,2,E)}for(h.reverse(),g=-1;++g<h.length;)f[w+h[g][0]]=w+h[g][1],w+=h[g][1]-h[g][0]-1;return f}const DS={resolve:IS,tokenize:zS},LS={partial:!0,tokenize:$S};function IS(e){return P1(e),e}function zS(e,n){let s;return i;function i(m){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),o(m)}function o(m){return m===null?d(m):vt(m)?e.check(LS,c,d)(m):(e.consume(m),o)}function d(m){return e.exit("chunkContent"),e.exit("content"),n(m)}function c(m){return e.consume(m),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,o}}function $S(e,n,s){const i=this;return o;function o(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Kt(e,d,"linePrefix")}function d(c){if(c===null||vt(c))return s(c);const m=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?n(c):e.interrupt(i.parser.constructs.flow,s,n)(c)}}function U1(e,n,s,i,o,d,c,m,h){const f=h||Number.POSITIVE_INFINITY;let p=0;return x;function x(E){return E===60?(e.enter(i),e.enter(o),e.enter(d),e.consume(E),e.exit(d),g):E===null||E===32||E===41||Ad(E)?s(E):(e.enter(i),e.enter(c),e.enter(m),e.enter("chunkString",{contentType:"string"}),N(E))}function g(E){return E===62?(e.enter(d),e.consume(E),e.exit(d),e.exit(o),e.exit(i),n):(e.enter(m),e.enter("chunkString",{contentType:"string"}),y(E))}function y(E){return E===62?(e.exit("chunkString"),e.exit(m),g(E)):E===null||E===60||vt(E)?s(E):(e.consume(E),E===92?w:y)}function w(E){return E===60||E===62||E===92?(e.consume(E),y):y(E)}function N(E){return!p&&(E===null||E===41||jn(E))?(e.exit("chunkString"),e.exit(m),e.exit(c),e.exit(i),n(E)):p<f&&E===40?(e.consume(E),p++,N):E===41?(e.consume(E),p--,N):E===null||E===32||E===40||Ad(E)?s(E):(e.consume(E),E===92?S:N)}function S(E){return E===40||E===41||E===92?(e.consume(E),N):N(E)}}function q1(e,n,s,i,o,d){const c=this;let m=0,h;return f;function f(y){return e.enter(i),e.enter(o),e.consume(y),e.exit(o),e.enter(d),p}function p(y){return m>999||y===null||y===91||y===93&&!h||y===94&&!m&&"_hiddenFootnoteSupport"in c.parser.constructs?s(y):y===93?(e.exit(d),e.enter(o),e.consume(y),e.exit(o),e.exit(i),n):vt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),x(y))}function x(y){return y===null||y===91||y===93||vt(y)||m++>999?(e.exit("chunkString"),p(y)):(e.consume(y),h||(h=!qt(y)),y===92?g:x)}function g(y){return y===91||y===92||y===93?(e.consume(y),m++,x):x(y)}}function V1(e,n,s,i,o,d){let c;return m;function m(g){return g===34||g===39||g===40?(e.enter(i),e.enter(o),e.consume(g),e.exit(o),c=g===40?41:g,h):s(g)}function h(g){return g===c?(e.enter(o),e.consume(g),e.exit(o),e.exit(i),n):(e.enter(d),f(g))}function f(g){return g===c?(e.exit(d),h(c)):g===null?s(g):vt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Kt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===c||g===null||vt(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?x:p)}function x(g){return g===c||g===92?(e.consume(g),p):p(g)}}function Eo(e,n){let s;return i;function i(o){return vt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s=!0,i):qt(o)?Kt(e,i,s?"linePrefix":"lineSuffix")(o):n(o)}}const BS={name:"definition",tokenize:PS},HS={partial:!0,tokenize:US};function PS(e,n,s){const i=this;let o;return d;function d(y){return e.enter("definition"),c(y)}function c(y){return q1.call(i,e,m,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function m(y){return o=us(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),h):s(y)}function h(y){return jn(y)?Eo(e,f)(y):f(y)}function f(y){return U1(e,p,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(HS,x,x)(y)}function x(y){return qt(y)?Kt(e,g,"whitespace")(y):g(y)}function g(y){return y===null||vt(y)?(e.exit("definition"),i.parser.defined.push(o),n(y)):s(y)}}function US(e,n,s){return i;function i(m){return jn(m)?Eo(e,o)(m):s(m)}function o(m){return V1(e,d,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(m)}function d(m){return qt(m)?Kt(e,c,"whitespace")(m):c(m)}function c(m){return m===null||vt(m)?n(m):s(m)}}const qS={name:"hardBreakEscape",tokenize:VS};function VS(e,n,s){return i;function i(d){return e.enter("hardBreakEscape"),e.consume(d),o}function o(d){return vt(d)?(e.exit("hardBreakEscape"),n(d)):s(d)}}const FS={name:"headingAtx",resolve:YS,tokenize:GS};function YS(e,n){let s=e.length-2,i=3,o,d;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},d={type:"chunkText",start:e[i][1].start,end:e[s][1].end,contentType:"text"},Br(e,i,s-i+1,[["enter",o,n],["enter",d,n],["exit",d,n],["exit",o,n]])),e}function GS(e,n,s){let i=0;return o;function o(p){return e.enter("atxHeading"),d(p)}function d(p){return e.enter("atxHeadingSequence"),c(p)}function c(p){return p===35&&i++<6?(e.consume(p),c):p===null||jn(p)?(e.exit("atxHeadingSequence"),m(p)):s(p)}function m(p){return p===35?(e.enter("atxHeadingSequence"),h(p)):p===null||vt(p)?(e.exit("atxHeading"),n(p)):qt(p)?Kt(e,m,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function h(p){return p===35?(e.consume(p),h):(e.exit("atxHeadingSequence"),m(p))}function f(p){return p===null||p===35||jn(p)?(e.exit("atxHeadingText"),m(p)):(e.consume(p),f)}}const XS=["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"],Yb=["pre","script","style","textarea"],KS={concrete:!0,name:"htmlFlow",resolveTo:QS,tokenize:JS},WS={partial:!0,tokenize:tC},ZS={partial:!0,tokenize:eC};function QS(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function JS(e,n,s){const i=this;let o,d,c,m,h;return f;function f(I){return p(I)}function p(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),x}function x(I){return I===33?(e.consume(I),g):I===47?(e.consume(I),d=!0,N):I===63?(e.consume(I),o=3,i.interrupt?n:B):mr(I)?(e.consume(I),c=String.fromCharCode(I),S):s(I)}function g(I){return I===45?(e.consume(I),o=2,y):I===91?(e.consume(I),o=5,m=0,w):mr(I)?(e.consume(I),o=4,i.interrupt?n:B):s(I)}function y(I){return I===45?(e.consume(I),i.interrupt?n:B):s(I)}function w(I){const _="CDATA[";return I===_.charCodeAt(m++)?(e.consume(I),m===_.length?i.interrupt?n:Y:w):s(I)}function N(I){return mr(I)?(e.consume(I),c=String.fromCharCode(I),S):s(I)}function S(I){if(I===null||I===47||I===62||jn(I)){const _=I===47,V=c.toLowerCase();return!_&&!d&&Yb.includes(V)?(o=1,i.interrupt?n(I):Y(I)):XS.includes(c.toLowerCase())?(o=6,_?(e.consume(I),E):i.interrupt?n(I):Y(I)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?s(I):d?C(I):k(I))}return I===45||cr(I)?(e.consume(I),c+=String.fromCharCode(I),S):s(I)}function E(I){return I===62?(e.consume(I),i.interrupt?n:Y):s(I)}function C(I){return qt(I)?(e.consume(I),C):$(I)}function k(I){return I===47?(e.consume(I),$):I===58||I===95||mr(I)?(e.consume(I),T):qt(I)?(e.consume(I),k):$(I)}function T(I){return I===45||I===46||I===58||I===95||cr(I)?(e.consume(I),T):R(I)}function R(I){return I===61?(e.consume(I),z):qt(I)?(e.consume(I),R):k(I)}function z(I){return I===null||I===60||I===61||I===62||I===96?s(I):I===34||I===39?(e.consume(I),h=I,U):qt(I)?(e.consume(I),z):G(I)}function U(I){return I===h?(e.consume(I),h=null,W):I===null||vt(I)?s(I):(e.consume(I),U)}function G(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||jn(I)?R(I):(e.consume(I),G)}function W(I){return I===47||I===62||qt(I)?k(I):s(I)}function $(I){return I===62?(e.consume(I),F):s(I)}function F(I){return I===null||vt(I)?Y(I):qt(I)?(e.consume(I),F):s(I)}function Y(I){return I===45&&o===2?(e.consume(I),A):I===60&&o===1?(e.consume(I),O):I===62&&o===4?(e.consume(I),q):I===63&&o===3?(e.consume(I),B):I===93&&o===5?(e.consume(I),Z):vt(I)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(WS,X,P)(I)):I===null||vt(I)?(e.exit("htmlFlowData"),P(I)):(e.consume(I),Y)}function P(I){return e.check(ZS,M,X)(I)}function M(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),L}function L(I){return I===null||vt(I)?P(I):(e.enter("htmlFlowData"),Y(I))}function A(I){return I===45?(e.consume(I),B):Y(I)}function O(I){return I===47?(e.consume(I),c="",D):Y(I)}function D(I){if(I===62){const _=c.toLowerCase();return Yb.includes(_)?(e.consume(I),q):Y(I)}return mr(I)&&c.length<8?(e.consume(I),c+=String.fromCharCode(I),D):Y(I)}function Z(I){return I===93?(e.consume(I),B):Y(I)}function B(I){return I===62?(e.consume(I),q):I===45&&o===2?(e.consume(I),B):Y(I)}function q(I){return I===null||vt(I)?(e.exit("htmlFlowData"),X(I)):(e.consume(I),q)}function X(I){return e.exit("htmlFlow"),n(I)}}function eC(e,n,s){const i=this;return o;function o(c){return vt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),d):s(c)}function d(c){return i.parser.lazy[i.now().line]?s(c):n(c)}}function tC(e,n,s){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Go,n,s)}}const nC={name:"htmlText",tokenize:rC};function rC(e,n,s){const i=this;let o,d,c;return m;function m(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),h}function h(B){return B===33?(e.consume(B),f):B===47?(e.consume(B),R):B===63?(e.consume(B),k):mr(B)?(e.consume(B),G):s(B)}function f(B){return B===45?(e.consume(B),p):B===91?(e.consume(B),d=0,w):mr(B)?(e.consume(B),C):s(B)}function p(B){return B===45?(e.consume(B),y):s(B)}function x(B){return B===null?s(B):B===45?(e.consume(B),g):vt(B)?(c=x,O(B)):(e.consume(B),x)}function g(B){return B===45?(e.consume(B),y):x(B)}function y(B){return B===62?A(B):B===45?g(B):x(B)}function w(B){const q="CDATA[";return B===q.charCodeAt(d++)?(e.consume(B),d===q.length?N:w):s(B)}function N(B){return B===null?s(B):B===93?(e.consume(B),S):vt(B)?(c=N,O(B)):(e.consume(B),N)}function S(B){return B===93?(e.consume(B),E):N(B)}function E(B){return B===62?A(B):B===93?(e.consume(B),E):N(B)}function C(B){return B===null||B===62?A(B):vt(B)?(c=C,O(B)):(e.consume(B),C)}function k(B){return B===null?s(B):B===63?(e.consume(B),T):vt(B)?(c=k,O(B)):(e.consume(B),k)}function T(B){return B===62?A(B):k(B)}function R(B){return mr(B)?(e.consume(B),z):s(B)}function z(B){return B===45||cr(B)?(e.consume(B),z):U(B)}function U(B){return vt(B)?(c=U,O(B)):qt(B)?(e.consume(B),U):A(B)}function G(B){return B===45||cr(B)?(e.consume(B),G):B===47||B===62||jn(B)?W(B):s(B)}function W(B){return B===47?(e.consume(B),A):B===58||B===95||mr(B)?(e.consume(B),$):vt(B)?(c=W,O(B)):qt(B)?(e.consume(B),W):A(B)}function $(B){return B===45||B===46||B===58||B===95||cr(B)?(e.consume(B),$):F(B)}function F(B){return B===61?(e.consume(B),Y):vt(B)?(c=F,O(B)):qt(B)?(e.consume(B),F):W(B)}function Y(B){return B===null||B===60||B===61||B===62||B===96?s(B):B===34||B===39?(e.consume(B),o=B,P):vt(B)?(c=Y,O(B)):qt(B)?(e.consume(B),Y):(e.consume(B),M)}function P(B){return B===o?(e.consume(B),o=void 0,L):B===null?s(B):vt(B)?(c=P,O(B)):(e.consume(B),P)}function M(B){return B===null||B===34||B===39||B===60||B===61||B===96?s(B):B===47||B===62||jn(B)?W(B):(e.consume(B),M)}function L(B){return B===47||B===62||jn(B)?W(B):s(B)}function A(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),n):s(B)}function O(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),D}function D(B){return qt(B)?Kt(e,Z,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):Z(B)}function Z(B){return e.enter("htmlTextData"),c(B)}}const ox={name:"labelEnd",resolveAll:lC,resolveTo:oC,tokenize:cC},sC={tokenize:dC},aC={tokenize:uC},iC={tokenize:fC};function lC(e){let n=-1;const s=[];for(;++n<e.length;){const i=e[n][1];if(s.push(e[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const o=i.type==="labelImage"?4:2;i.type="data",n+=o}}return e.length!==s.length&&Br(e,0,e.length,s),e}function oC(e,n){let s=e.length,i=0,o,d,c,m;for(;s--;)if(o=e[s][1],d){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[s][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(e[s][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(d=s,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(c=s);const h={type:e[d][1].type==="labelLink"?"link":"image",start:{...e[d][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[d][1].start},end:{...e[c][1].end}},p={type:"labelText",start:{...e[d+i+2][1].end},end:{...e[c-2][1].start}};return m=[["enter",h,n],["enter",f,n]],m=Qr(m,e.slice(d+1,d+i+3)),m=Qr(m,[["enter",p,n]]),m=Qr(m,Jd(n.parser.constructs.insideSpan.null,e.slice(d+i+4,c-3),n)),m=Qr(m,[["exit",p,n],e[c-2],e[c-1],["exit",f,n]]),m=Qr(m,e.slice(c+1)),m=Qr(m,[["exit",h,n]]),Br(e,d,e.length,m),e}function cC(e,n,s){const i=this;let o=i.events.length,d,c;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){d=i.events[o][1];break}return m;function m(g){return d?d._inactive?x(g):(c=i.parser.defined.includes(us(i.sliceSerialize({start:d.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),h):s(g)}function h(g){return g===40?e.attempt(sC,p,c?p:x)(g):g===91?e.attempt(aC,p,c?f:x)(g):c?p(g):x(g)}function f(g){return e.attempt(iC,p,x)(g)}function p(g){return n(g)}function x(g){return d._balanced=!0,s(g)}}function dC(e,n,s){return i;function i(x){return e.enter("resource"),e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),o}function o(x){return jn(x)?Eo(e,d)(x):d(x)}function d(x){return x===41?p(x):U1(e,c,m,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(x)}function c(x){return jn(x)?Eo(e,h)(x):p(x)}function m(x){return s(x)}function h(x){return x===34||x===39||x===40?V1(e,f,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(x):p(x)}function f(x){return jn(x)?Eo(e,p)(x):p(x)}function p(x){return x===41?(e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),e.exit("resource"),n):s(x)}}function uC(e,n,s){const i=this;return o;function o(m){return q1.call(i,e,d,c,"reference","referenceMarker","referenceString")(m)}function d(m){return i.parser.defined.includes(us(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(m):s(m)}function c(m){return s(m)}}function fC(e,n,s){return i;function i(d){return e.enter("reference"),e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),o}function o(d){return d===93?(e.enter("referenceMarker"),e.consume(d),e.exit("referenceMarker"),e.exit("reference"),n):s(d)}}const hC={name:"labelStartImage",resolveAll:ox.resolveAll,tokenize:mC};function mC(e,n,s){const i=this;return o;function o(m){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(m),e.exit("labelImageMarker"),d}function d(m){return m===91?(e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelImage"),c):s(m)}function c(m){return m===94&&"_hiddenFootnoteSupport"in i.parser.constructs?s(m):n(m)}}const xC={name:"labelStartLink",resolveAll:ox.resolveAll,tokenize:pC};function pC(e,n,s){const i=this;return o;function o(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),d}function d(c){return c===94&&"_hiddenFootnoteSupport"in i.parser.constructs?s(c):n(c)}}const Th={name:"lineEnding",tokenize:gC};function gC(e,n){return s;function s(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Kt(e,n,"linePrefix")}}const Nd={name:"thematicBreak",tokenize:bC};function bC(e,n,s){let i=0,o;return d;function d(f){return e.enter("thematicBreak"),c(f)}function c(f){return o=f,m(f)}function m(f){return f===o?(e.enter("thematicBreakSequence"),h(f)):i>=3&&(f===null||vt(f))?(e.exit("thematicBreak"),n(f)):s(f)}function h(f){return f===o?(e.consume(f),i++,h):(e.exit("thematicBreakSequence"),qt(f)?Kt(e,m,"whitespace")(f):m(f))}}const wr={continuation:{tokenize:wC},exit:kC,name:"list",tokenize:jC},yC={partial:!0,tokenize:SC},vC={partial:!0,tokenize:NC};function jC(e,n,s){const i=this,o=i.events[i.events.length-1];let d=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return m;function m(y){const w=i.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||y===i.containerState.marker:ym(y)){if(i.containerState.type||(i.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Nd,s,f)(y):f(y);if(!i.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(y)}return s(y)}function h(y){return ym(y)&&++c<10?(e.consume(y),h):(!i.interrupt||c<2)&&(i.containerState.marker?y===i.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):s(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||y,e.check(Go,i.interrupt?s:p,e.attempt(yC,g,x))}function p(y){return i.containerState.initialBlankLine=!0,d++,g(y)}function x(y){return qt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),g):s(y)}function g(y){return i.containerState.size=d+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(y)}}function wC(e,n,s){const i=this;return i.containerState._closeFlow=void 0,e.check(Go,o,d);function o(m){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Kt(e,n,"listItemIndent",i.containerState.size+1)(m)}function d(m){return i.containerState.furtherBlankLines||!qt(m)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,c(m)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(vC,n,c)(m))}function c(m){return i.containerState._closeFlow=!0,i.interrupt=void 0,Kt(e,e.attempt(wr,n,s),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m)}}function NC(e,n,s){const i=this;return Kt(e,o,"listItemIndent",i.containerState.size+1);function o(d){const c=i.events[i.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===i.containerState.size?n(d):s(d)}}function kC(e){e.exit(this.containerState.type)}function SC(e,n,s){const i=this;return Kt(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(d){const c=i.events[i.events.length-1];return!qt(d)&&c&&c[1].type==="listItemPrefixWhitespace"?n(d):s(d)}}const Gb={name:"setextUnderline",resolveTo:CC,tokenize:EC};function CC(e,n){let s=e.length,i,o,d;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),!d&&e[s][1].type==="definition"&&(d=s);const c={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",d?(e.splice(o,0,["enter",c,n]),e.splice(d+1,0,["exit",e[i][1],n]),e[i][1].end={...e[d][1].end}):e[i][1]=c,e.push(["exit",c,n]),e}function EC(e,n,s){const i=this;let o;return d;function d(f){let p=i.events.length,x;for(;p--;)if(i.events[p][1].type!=="lineEnding"&&i.events[p][1].type!=="linePrefix"&&i.events[p][1].type!=="content"){x=i.events[p][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||x)?(e.enter("setextHeadingLine"),o=f,c(f)):s(f)}function c(f){return e.enter("setextHeadingLineSequence"),m(f)}function m(f){return f===o?(e.consume(f),m):(e.exit("setextHeadingLineSequence"),qt(f)?Kt(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||vt(f)?(e.exit("setextHeadingLine"),n(f)):s(f)}}const TC={tokenize:_C};function _C(e){const n=this,s=e.attempt(Go,i,e.attempt(this.parser.constructs.flowInitial,o,Kt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(DS,o)),"linePrefix")));return s;function i(d){if(d===null){e.consume(d);return}return e.enter("lineEndingBlank"),e.consume(d),e.exit("lineEndingBlank"),n.currentConstruct=void 0,s}function o(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),n.currentConstruct=void 0,s}}const AC={resolveAll:Y1()},MC=F1("string"),OC=F1("text");function F1(e){return{resolveAll:Y1(e==="text"?RC:void 0),tokenize:n};function n(s){const i=this,o=this.parser.constructs[e],d=s.attempt(o,c,m);return c;function c(p){return f(p)?d(p):m(p)}function m(p){if(p===null){s.consume(p);return}return s.enter("data"),s.consume(p),h}function h(p){return f(p)?(s.exit("data"),d(p)):(s.consume(p),h)}function f(p){if(p===null)return!0;const x=o[p];let g=-1;if(x)for(;++g<x.length;){const y=x[g];if(!y.previous||y.previous.call(i,i.previous))return!0}return!1}}}function Y1(e){return n;function n(s,i){let o=-1,d;for(;++o<=s.length;)d===void 0?s[o]&&s[o][1].type==="data"&&(d=o,o++):(!s[o]||s[o][1].type!=="data")&&(o!==d+2&&(s[d][1].end=s[o-1][1].end,s.splice(d+2,o-d-2),o=d+2),d=void 0);return e?e(s,i):s}}function RC(e,n){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const i=e[s-1][1],o=n.sliceStream(i);let d=o.length,c=-1,m=0,h;for(;d--;){const f=o[d];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)m++,c--;if(c)break;c=-1}else if(f===-2)h=!0,m++;else if(f!==-1){d++;break}}if(n._contentTypeTextTrailing&&s===e.length&&(m=0),m){const f={type:s===e.length||h||m<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:d?c:i.start._bufferIndex+c,_index:i.start._index+d,line:i.end.line,column:i.end.column-m,offset:i.end.offset-m},end:{...i.end}};i.end={...f.start},i.start.offset===i.end.offset?Object.assign(i,f):(e.splice(s,0,["enter",f,n],["exit",f,n]),s+=2)}s++}return e}const DC={42:wr,43:wr,45:wr,48:wr,49:wr,50:wr,51:wr,52:wr,53:wr,54:wr,55:wr,56:wr,57:wr,62:$1},LC={91:BS},IC={[-2]:Eh,[-1]:Eh,32:Eh},zC={35:FS,42:Nd,45:[Gb,Nd],60:KS,61:Gb,95:Nd,96:Fb,126:Fb},$C={38:H1,92:B1},BC={[-5]:Th,[-4]:Th,[-3]:Th,33:hC,38:H1,42:vm,60:[xS,nC],91:xC,92:[qS,B1],93:ox,95:vm,96:TS},HC={null:[vm,AC]},PC={null:[42,95]},UC={null:[]},qC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:PC,contentInitial:LC,disable:UC,document:DC,flow:zC,flowInitial:IC,insideSpan:HC,string:$C,text:BC},Symbol.toStringTag,{value:"Module"}));function VC(e,n,s){let i={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const o={},d=[];let c=[],m=[];const h={attempt:U(R),check:U(z),consume:C,enter:k,exit:T,interrupt:U(z,{interrupt:!0})},f={code:null,containerState:{},defineSkip:N,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:y,write:x};let p=n.tokenize.call(f,h);return n.resolveAll&&d.push(n),f;function x(F){return c=Qr(c,F),S(),c[c.length-1]!==null?[]:(G(n,0),f.events=Jd(d,f.events,f),f.events)}function g(F,Y){return YC(y(F),Y)}function y(F){return FC(c,F)}function w(){const{_bufferIndex:F,_index:Y,line:P,column:M,offset:L}=i;return{_bufferIndex:F,_index:Y,line:P,column:M,offset:L}}function N(F){o[F.line]=F.column,$()}function S(){let F;for(;i._index<c.length;){const Y=c[i._index];if(typeof Y=="string")for(F=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===F&&i._bufferIndex<Y.length;)E(Y.charCodeAt(i._bufferIndex));else E(Y)}}function E(F){p=p(F)}function C(F){vt(F)?(i.line++,i.column=1,i.offset+=F===-3?2:1,$()):F!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===c[i._index].length&&(i._bufferIndex=-1,i._index++)),f.previous=F}function k(F,Y){const P=Y||{};return P.type=F,P.start=w(),f.events.push(["enter",P,f]),m.push(P),P}function T(F){const Y=m.pop();return Y.end=w(),f.events.push(["exit",Y,f]),Y}function R(F,Y){G(F,Y.from)}function z(F,Y){Y.restore()}function U(F,Y){return P;function P(M,L,A){let O,D,Z,B;return Array.isArray(M)?X(M):"tokenize"in M?X([M]):q(M);function q(Q){return ee;function ee(te){const ae=te!==null&&Q[te],me=te!==null&&Q.null,Ne=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(me)?me:me?[me]:[]];return X(Ne)(te)}}function X(Q){return O=Q,D=0,Q.length===0?A:I(Q[D])}function I(Q){return ee;function ee(te){return B=W(),Z=Q,Q.partial||(f.currentConstruct=Q),Q.name&&f.parser.constructs.disable.null.includes(Q.name)?V():Q.tokenize.call(Y?Object.assign(Object.create(f),Y):f,h,_,V)(te)}}function _(Q){return F(Z,B),L}function V(Q){return B.restore(),++D<O.length?I(O[D]):A}}}function G(F,Y){F.resolveAll&&!d.includes(F)&&d.push(F),F.resolve&&Br(f.events,Y,f.events.length-Y,F.resolve(f.events.slice(Y),f)),F.resolveTo&&(f.events=F.resolveTo(f.events,f))}function W(){const F=w(),Y=f.previous,P=f.currentConstruct,M=f.events.length,L=Array.from(m);return{from:M,restore:A};function A(){i=F,f.previous=Y,f.currentConstruct=P,f.events.length=M,m=L,$()}}function $(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function FC(e,n){const s=n.start._index,i=n.start._bufferIndex,o=n.end._index,d=n.end._bufferIndex;let c;if(s===o)c=[e[s].slice(i,d)];else{if(c=e.slice(s,o),i>-1){const m=c[0];typeof m=="string"?c[0]=m.slice(i):c.shift()}d>0&&c.push(e[o].slice(0,d))}return c}function YC(e,n){let s=-1;const i=[];let o;for(;++s<e.length;){const d=e[s];let c;if(typeof d=="string")c=d;else switch(d){case-5:{c="\r";break}case-4:{c=`
12
- `;break}case-3:{c=`\r
13
- `;break}case-2:{c=n?" ":" ";break}case-1:{if(!n&&o)continue;c=" ";break}default:c=String.fromCharCode(d)}o=d===-2,i.push(c)}return i.join("")}function GC(e){const i={constructs:I1([qC,...(e||{}).extensions||[]]),content:o(oS),defined:[],document:o(dS),flow:o(TC),lazy:{},string:o(MC),text:o(OC)};return i;function o(d){return c;function c(m){return VC(i,d,m)}}}function XC(e){for(;!P1(e););return e}const Xb=/[\0\t\n\r]/g;function KC(){let e=1,n="",s=!0,i;return o;function o(d,c,m){const h=[];let f,p,x,g,y;for(d=n+(typeof d=="string"?d.toString():new TextDecoder(c||void 0).decode(d)),x=0,n="",s&&(d.charCodeAt(0)===65279&&x++,s=void 0);x<d.length;){if(Xb.lastIndex=x,f=Xb.exec(d),g=f&&f.index!==void 0?f.index:d.length,y=d.charCodeAt(g),!f){n=d.slice(x);break}if(y===10&&x===g&&i)h.push(-3),i=void 0;else switch(i&&(h.push(-5),i=void 0),x<g&&(h.push(d.slice(x,g)),e+=g-x),y){case 0:{h.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,h.push(-2);e++<p;)h.push(-1);break}case 10:{h.push(-4),e=1;break}default:i=!0,e=1}x=g+1}return m&&(i&&h.push(-5),n&&h.push(n),h.push(null)),h}}const WC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ZC(e){return e.replace(WC,QC)}function QC(e,n,s){if(n)return n;if(s.charCodeAt(0)===35){const o=s.charCodeAt(1),d=o===120||o===88;return z1(s.slice(d?2:1),d?16:10)}return lx(s)||e}const G1={}.hasOwnProperty;function JC(e,n,s){return n&&typeof n=="object"&&(s=n,n=void 0),eE(s)(XC(GC(s).document().write(KC()(e,n,!0))))}function eE(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:d(st),autolinkProtocol:W,autolinkEmail:W,atxHeading:d(Ce),blockQuote:d(me),characterEscape:W,characterReference:W,codeFenced:d(Ne),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:d(Ne,c),codeText:d(Ie,c),codeTextData:W,data:W,codeFlowValue:W,definition:d(je),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:d(Te),hardBreakEscape:d(Re),hardBreakTrailing:d(Re),htmlFlow:d(Ge,c),htmlFlowData:W,htmlText:d(Ge,c),htmlTextData:W,image:d(ot),label:c,link:d(st),listItem:d(re),listItemValue:g,listOrdered:d(jt,x),listUnordered:d(jt),paragraph:d(Ee),reference:I,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:d(Ce),strong:d(Ze),thematicBreak:d(Dt)},exit:{atxHeading:h(),atxHeadingSequence:R,autolink:h(),autolinkEmail:ae,autolinkProtocol:te,blockQuote:h(),characterEscapeValue:$,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:Q,characterReference:ee,codeFenced:h(S),codeFencedFence:N,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:$,codeIndented:h(E),codeText:h(L),codeTextData:$,data:$,definition:h(),definitionDestinationString:T,definitionLabelString:C,definitionTitleString:k,emphasis:h(),hardBreakEscape:h(Y),hardBreakTrailing:h(Y),htmlFlow:h(P),htmlFlowData:$,htmlText:h(M),htmlTextData:$,image:h(O),label:Z,labelText:D,lineEnding:F,link:h(A),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:_,resourceDestinationString:B,resourceTitleString:q,resource:X,setextHeading:h(G),setextHeadingLineSequence:U,setextHeadingText:z,strong:h(),thematicBreak:h()}};X1(n,(e||{}).mdastExtensions||[]);const s={};return i;function i(we){let Le={type:"root",children:[]};const Ue={stack:[Le],tokenStack:[],config:n,enter:m,exit:f,buffer:c,resume:p,data:s},at=[];let rt=-1;for(;++rt<we.length;)if(we[rt][1].type==="listOrdered"||we[rt][1].type==="listUnordered")if(we[rt][0]==="enter")at.push(rt);else{const Zt=at.pop();rt=o(we,Zt,rt)}for(rt=-1;++rt<we.length;){const Zt=n[we[rt][0]];G1.call(Zt,we[rt][1].type)&&Zt[we[rt][1].type].call(Object.assign({sliceSerialize:we[rt][2].sliceSerialize},Ue),we[rt][1])}if(Ue.tokenStack.length>0){const Zt=Ue.tokenStack[Ue.tokenStack.length-1];(Zt[1]||Kb).call(Ue,void 0,Zt[0])}for(Le.position={start:_a(we.length>0?we[0][1].start:{line:1,column:1,offset:0}),end:_a(we.length>0?we[we.length-2][1].end:{line:1,column:1,offset:0})},rt=-1;++rt<n.transforms.length;)Le=n.transforms[rt](Le)||Le;return Le}function o(we,Le,Ue){let at=Le-1,rt=-1,Zt=!1,fn,zt,Mt,_t;for(;++at<=Ue;){const Ct=we[at];switch(Ct[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ct[0]==="enter"?rt++:rt--,_t=void 0;break}case"lineEndingBlank":{Ct[0]==="enter"&&(fn&&!_t&&!rt&&!Mt&&(Mt=at),_t=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:_t=void 0}if(!rt&&Ct[0]==="enter"&&Ct[1].type==="listItemPrefix"||rt===-1&&Ct[0]==="exit"&&(Ct[1].type==="listUnordered"||Ct[1].type==="listOrdered")){if(fn){let en=at;for(zt=void 0;en--;){const Ht=we[en];if(Ht[1].type==="lineEnding"||Ht[1].type==="lineEndingBlank"){if(Ht[0]==="exit")continue;zt&&(we[zt][1].type="lineEndingBlank",Zt=!0),Ht[1].type="lineEnding",zt=en}else if(!(Ht[1].type==="linePrefix"||Ht[1].type==="blockQuotePrefix"||Ht[1].type==="blockQuotePrefixWhitespace"||Ht[1].type==="blockQuoteMarker"||Ht[1].type==="listItemIndent"))break}Mt&&(!zt||Mt<zt)&&(fn._spread=!0),fn.end=Object.assign({},zt?we[zt][1].start:Ct[1].end),we.splice(zt||at,0,["exit",fn,Ct[2]]),at++,Ue++}if(Ct[1].type==="listItemPrefix"){const en={type:"listItem",_spread:!1,start:Object.assign({},Ct[1].start),end:void 0};fn=en,we.splice(at,0,["enter",en,Ct[2]]),at++,Ue++,Mt=void 0,_t=!0}}}return we[Le][1]._spread=Zt,Ue}function d(we,Le){return Ue;function Ue(at){m.call(this,we(at),at),Le&&Le.call(this,at)}}function c(){this.stack.push({type:"fragment",children:[]})}function m(we,Le,Ue){this.stack[this.stack.length-1].children.push(we),this.stack.push(we),this.tokenStack.push([Le,Ue||void 0]),we.position={start:_a(Le.start),end:void 0}}function h(we){return Le;function Le(Ue){we&&we.call(this,Ue),f.call(this,Ue)}}function f(we,Le){const Ue=this.stack.pop(),at=this.tokenStack.pop();if(at)at[0].type!==we.type&&(Le?Le.call(this,we,at[0]):(at[1]||Kb).call(this,we,at[0]));else throw new Error("Cannot close `"+we.type+"` ("+Co({start:we.start,end:we.end})+"): it’s not open");Ue.position.end=_a(we.end)}function p(){return ix(this.stack.pop())}function x(){this.data.expectingFirstListItemValue=!0}function g(we){if(this.data.expectingFirstListItemValue){const Le=this.stack[this.stack.length-2];Le.start=Number.parseInt(this.sliceSerialize(we),10),this.data.expectingFirstListItemValue=void 0}}function y(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.lang=we}function w(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.meta=we}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.value=we.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.value=we.replace(/(\r?\n|\r)$/g,"")}function C(we){const Le=this.resume(),Ue=this.stack[this.stack.length-1];Ue.label=Le,Ue.identifier=us(this.sliceSerialize(we)).toLowerCase()}function k(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.title=we}function T(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.url=we}function R(we){const Le=this.stack[this.stack.length-1];if(!Le.depth){const Ue=this.sliceSerialize(we).length;Le.depth=Ue}}function z(){this.data.setextHeadingSlurpLineEnding=!0}function U(we){const Le=this.stack[this.stack.length-1];Le.depth=this.sliceSerialize(we).codePointAt(0)===61?1:2}function G(){this.data.setextHeadingSlurpLineEnding=void 0}function W(we){const Ue=this.stack[this.stack.length-1].children;let at=Ue[Ue.length-1];(!at||at.type!=="text")&&(at=yt(),at.position={start:_a(we.start),end:void 0},Ue.push(at)),this.stack.push(at)}function $(we){const Le=this.stack.pop();Le.value+=this.sliceSerialize(we),Le.position.end=_a(we.end)}function F(we){const Le=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ue=Le.children[Le.children.length-1];Ue.position.end=_a(we.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(Le.type)&&(W.call(this,we),$.call(this,we))}function Y(){this.data.atHardBreak=!0}function P(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.value=we}function M(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.value=we}function L(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.value=we}function A(){const we=this.stack[this.stack.length-1];if(this.data.inReference){const Le=this.data.referenceType||"shortcut";we.type+="Reference",we.referenceType=Le,delete we.url,delete we.title}else delete we.identifier,delete we.label;this.data.referenceType=void 0}function O(){const we=this.stack[this.stack.length-1];if(this.data.inReference){const Le=this.data.referenceType||"shortcut";we.type+="Reference",we.referenceType=Le,delete we.url,delete we.title}else delete we.identifier,delete we.label;this.data.referenceType=void 0}function D(we){const Le=this.sliceSerialize(we),Ue=this.stack[this.stack.length-2];Ue.label=ZC(Le),Ue.identifier=us(Le).toLowerCase()}function Z(){const we=this.stack[this.stack.length-1],Le=this.resume(),Ue=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ue.type==="link"){const at=we.children;Ue.children=at}else Ue.alt=Le}function B(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.url=we}function q(){const we=this.resume(),Le=this.stack[this.stack.length-1];Le.title=we}function X(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function _(we){const Le=this.resume(),Ue=this.stack[this.stack.length-1];Ue.label=Le,Ue.identifier=us(this.sliceSerialize(we)).toLowerCase(),this.data.referenceType="full"}function V(we){this.data.characterReferenceType=we.type}function Q(we){const Le=this.sliceSerialize(we),Ue=this.data.characterReferenceType;let at;Ue?(at=z1(Le,Ue==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):at=lx(Le);const rt=this.stack[this.stack.length-1];rt.value+=at}function ee(we){const Le=this.stack.pop();Le.position.end=_a(we.end)}function te(we){$.call(this,we);const Le=this.stack[this.stack.length-1];Le.url=this.sliceSerialize(we)}function ae(we){$.call(this,we);const Le=this.stack[this.stack.length-1];Le.url="mailto:"+this.sliceSerialize(we)}function me(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function Ie(){return{type:"inlineCode",value:""}}function je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Te(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function Re(){return{type:"break"}}function Ge(){return{type:"html",value:""}}function ot(){return{type:"image",title:null,url:"",alt:null}}function st(){return{type:"link",title:null,url:"",children:[]}}function jt(we){return{type:"list",ordered:we.type==="listOrdered",start:null,spread:we._spread,children:[]}}function re(we){return{type:"listItem",spread:we._spread,checked:null,children:[]}}function Ee(){return{type:"paragraph",children:[]}}function Ze(){return{type:"strong",children:[]}}function yt(){return{type:"text",value:""}}function Dt(){return{type:"thematicBreak"}}}function _a(e){return{line:e.line,column:e.column,offset:e.offset}}function X1(e,n){let s=-1;for(;++s<n.length;){const i=n[s];Array.isArray(i)?X1(e,i):tE(e,i)}}function tE(e,n){let s;for(s in n)if(G1.call(n,s))switch(s){case"canContainEols":{const i=n[s];i&&e[s].push(...i);break}case"transforms":{const i=n[s];i&&e[s].push(...i);break}case"enter":case"exit":{const i=n[s];i&&Object.assign(e[s],i);break}}}function Kb(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Co({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Co({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Co({start:n.start,end:n.end})+") is still open")}function nE(e){const n=this;n.parser=s;function s(i){return JC(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function rE(e,n){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,s),e.applyData(n,s)}function sE(e,n){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,s),[e.applyData(n,s),{type:"text",value:`
14
- `}]}function aE(e,n){const s=n.value?n.value+`
15
- `:"",i={},o=n.lang?n.lang.split(/\s+/):[];o.length>0&&(i.className=["language-"+o[0]]);let d={type:"element",tagName:"code",properties:i,children:[{type:"text",value:s}]};return n.meta&&(d.data={meta:n.meta}),e.patch(n,d),d=e.applyData(n,d),d={type:"element",tagName:"pre",properties:{},children:[d]},e.patch(n,d),d}function iE(e,n){const s={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function lE(e,n){const s={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function oE(e,n){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),o=wl(i.toLowerCase()),d=e.footnoteOrder.indexOf(i);let c,m=e.footnoteCounts.get(i);m===void 0?(m=0,e.footnoteOrder.push(i),c=e.footnoteOrder.length):c=d+1,m+=1,e.footnoteCounts.set(i,m);const h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(m>1?"-"+m:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(n,h);const f={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(n,f),e.applyData(n,f)}function cE(e,n){const s={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function dE(e,n){if(e.options.allowDangerousHtml){const s={type:"raw",value:n.value};return e.patch(n,s),e.applyData(n,s)}}function K1(e,n){const s=n.referenceType;let i="]";if(s==="collapsed"?i+="[]":s==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const o=e.all(n),d=o[0];d&&d.type==="text"?d.value="["+d.value:o.unshift({type:"text",value:"["});const c=o[o.length-1];return c&&c.type==="text"?c.value+=i:o.push({type:"text",value:i}),o}function uE(e,n){const s=String(n.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return K1(e,n);const o={src:wl(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(o.title=i.title);const d={type:"element",tagName:"img",properties:o,children:[]};return e.patch(n,d),e.applyData(n,d)}function fE(e,n){const s={src:wl(n.url)};n.alt!==null&&n.alt!==void 0&&(s.alt=n.alt),n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(n,i),e.applyData(n,i)}function hE(e,n){const s={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,s);const i={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(n,i),e.applyData(n,i)}function mE(e,n){const s=String(n.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return K1(e,n);const o={href:wl(i.url||"")};i.title!==null&&i.title!==void 0&&(o.title=i.title);const d={type:"element",tagName:"a",properties:o,children:e.all(n)};return e.patch(n,d),e.applyData(n,d)}function xE(e,n){const s={href:wl(n.url)};n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"a",properties:s,children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function pE(e,n,s){const i=e.all(n),o=s?gE(s):W1(n),d={},c=[];if(typeof n.checked=="boolean"){const p=i[0];let x;p&&p.type==="element"&&p.tagName==="p"?x=p:(x={type:"element",tagName:"p",properties:{},children:[]},i.unshift(x)),x.children.length>0&&x.children.unshift({type:"text",value:" "}),x.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),d.className=["task-list-item"]}let m=-1;for(;++m<i.length;){const p=i[m];(o||m!==0||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
16
- `}),p.type==="element"&&p.tagName==="p"&&!o?c.push(...p.children):c.push(p)}const h=i[i.length-1];h&&(o||h.type!=="element"||h.tagName!=="p")&&c.push({type:"text",value:`
17
- `});const f={type:"element",tagName:"li",properties:d,children:c};return e.patch(n,f),e.applyData(n,f)}function gE(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const s=e.children;let i=-1;for(;!n&&++i<s.length;)n=W1(s[i])}return n}function W1(e){const n=e.spread;return n??e.children.length>1}function bE(e,n){const s={},i=e.all(n);let o=-1;for(typeof n.start=="number"&&n.start!==1&&(s.start=n.start);++o<i.length;){const c=i[o];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const d={type:"element",tagName:n.ordered?"ol":"ul",properties:s,children:e.wrap(i,!0)};return e.patch(n,d),e.applyData(n,d)}function yE(e,n){const s={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function vE(e,n){const s={type:"root",children:e.wrap(e.all(n))};return e.patch(n,s),e.applyData(n,s)}function jE(e,n){const s={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function wE(e,n){const s=e.all(n),i=s.shift(),o=[];if(i){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(n.children[0],c),o.push(c)}if(s.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},m=nx(n.children[1]),h=_1(n.children[n.children.length-1]);m&&h&&(c.position={start:m,end:h}),o.push(c)}const d={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(n,d),e.applyData(n,d)}function NE(e,n,s){const i=s?s.children:void 0,d=(i?i.indexOf(n):1)===0?"th":"td",c=s&&s.type==="table"?s.align:void 0,m=c?c.length:n.children.length;let h=-1;const f=[];for(;++h<m;){const x=n.children[h],g={},y=c?c[h]:void 0;y&&(g.align=y);let w={type:"element",tagName:d,properties:g,children:[]};x&&(w.children=e.all(x),e.patch(x,w),w=e.applyData(x,w)),f.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(n,p),e.applyData(n,p)}function kE(e,n){const s={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}const Wb=9,Zb=32;function SE(e){const n=String(e),s=/\r?\n|\r/g;let i=s.exec(n),o=0;const d=[];for(;i;)d.push(Qb(n.slice(o,i.index),o>0,!0),i[0]),o=i.index+i[0].length,i=s.exec(n);return d.push(Qb(n.slice(o),o>0,!1)),d.join("")}function Qb(e,n,s){let i=0,o=e.length;if(n){let d=e.codePointAt(i);for(;d===Wb||d===Zb;)i++,d=e.codePointAt(i)}if(s){let d=e.codePointAt(o-1);for(;d===Wb||d===Zb;)o--,d=e.codePointAt(o-1)}return o>i?e.slice(i,o):""}function CE(e,n){const s={type:"text",value:SE(String(n.value))};return e.patch(n,s),e.applyData(n,s)}function EE(e,n){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,s),e.applyData(n,s)}const TE={blockquote:rE,break:sE,code:aE,delete:iE,emphasis:lE,footnoteReference:oE,heading:cE,html:dE,imageReference:uE,image:fE,inlineCode:hE,linkReference:mE,link:xE,listItem:pE,list:bE,paragraph:yE,root:vE,strong:jE,table:wE,tableCell:kE,tableRow:NE,text:CE,thematicBreak:EE,toml:ld,yaml:ld,definition:ld,footnoteDefinition:ld};function ld(){}const Z1=-1,eu=0,To=1,Md=2,cx=3,dx=4,ux=5,fx=6,Q1=7,J1=8,Jb=typeof self=="object"?self:globalThis,_E=(e,n)=>{const s=(o,d)=>(e.set(d,o),o),i=o=>{if(e.has(o))return e.get(o);const[d,c]=n[o];switch(d){case eu:case Z1:return s(c,o);case To:{const m=s([],o);for(const h of c)m.push(i(h));return m}case Md:{const m=s({},o);for(const[h,f]of c)m[i(h)]=i(f);return m}case cx:return s(new Date(c),o);case dx:{const{source:m,flags:h}=c;return s(new RegExp(m,h),o)}case ux:{const m=s(new Map,o);for(const[h,f]of c)m.set(i(h),i(f));return m}case fx:{const m=s(new Set,o);for(const h of c)m.add(i(h));return m}case Q1:{const{name:m,message:h}=c;return s(new Jb[m](h),o)}case J1:return s(BigInt(c),o);case"BigInt":return s(Object(BigInt(c)),o);case"ArrayBuffer":return s(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:m}=new Uint8Array(c);return s(new DataView(m),c)}}return s(new Jb[d](c),o)};return i},ey=e=>_E(new Map,e)(0),Qi="",{toString:AE}={},{keys:ME}=Object,xo=e=>{const n=typeof e;if(n!=="object"||!e)return[eu,n];const s=AE.call(e).slice(8,-1);switch(s){case"Array":return[To,Qi];case"Object":return[Md,Qi];case"Date":return[cx,Qi];case"RegExp":return[dx,Qi];case"Map":return[ux,Qi];case"Set":return[fx,Qi];case"DataView":return[To,s]}return s.includes("Array")?[To,s]:s.includes("Error")?[Q1,s]:[Md,s]},od=([e,n])=>e===eu&&(n==="function"||n==="symbol"),OE=(e,n,s,i)=>{const o=(c,m)=>{const h=i.push(c)-1;return s.set(m,h),h},d=c=>{if(s.has(c))return s.get(c);let[m,h]=xo(c);switch(m){case eu:{let p=c;switch(h){case"bigint":m=J1,p=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);p=null;break;case"undefined":return o([Z1],c)}return o([m,p],c)}case To:{if(h){let g=c;return h==="DataView"?g=new Uint8Array(c.buffer):h==="ArrayBuffer"&&(g=new Uint8Array(c)),o([h,[...g]],c)}const p=[],x=o([m,p],c);for(const g of c)p.push(d(g));return x}case Md:{if(h)switch(h){case"BigInt":return o([h,c.toString()],c);case"Boolean":case"Number":case"String":return o([h,c.valueOf()],c)}if(n&&"toJSON"in c)return d(c.toJSON());const p=[],x=o([m,p],c);for(const g of ME(c))(e||!od(xo(c[g])))&&p.push([d(g),d(c[g])]);return x}case cx:return o([m,c.toISOString()],c);case dx:{const{source:p,flags:x}=c;return o([m,{source:p,flags:x}],c)}case ux:{const p=[],x=o([m,p],c);for(const[g,y]of c)(e||!(od(xo(g))||od(xo(y))))&&p.push([d(g),d(y)]);return x}case fx:{const p=[],x=o([m,p],c);for(const g of c)(e||!od(xo(g)))&&p.push(d(g));return x}}const{message:f}=c;return o([m,{name:h,message:f}],c)};return d},ty=(e,{json:n,lossy:s}={})=>{const i=[];return OE(!(n||s),!!n,new Map,i)(e),i},Od=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?ey(ty(e,n)):structuredClone(e):(e,n)=>ey(ty(e,n));function RE(e,n){const s=[{type:"text",value:"↩"}];return n>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),s}function DE(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function LE(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||RE,i=e.options.footnoteBackLabel||DE,o=e.options.footnoteLabel||"Footnotes",d=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},m=[];let h=-1;for(;++h<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[h]);if(!f)continue;const p=e.all(f),x=String(f.identifier).toUpperCase(),g=wl(x.toLowerCase());let y=0;const w=[],N=e.footnoteCounts.get(x);for(;N!==void 0&&++y<=N;){w.length>0&&w.push({type:"text",value:" "});let C=typeof s=="string"?s:s(h,y);typeof C=="string"&&(C={type:"text",value:C}),w.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+g+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(h,y),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const S=p[p.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const C=S.children[S.children.length-1];C&&C.type==="text"?C.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...w)}else p.push(...w);const E={type:"element",tagName:"li",properties:{id:n+"fn-"+g},children:e.wrap(p,!0)};e.patch(f,E),m.push(E)}if(m.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:d,properties:{...Od(c),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
18
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(m,!0)},{type:"text",value:`
19
- `}]}}const tu=(function(e){if(e==null)return BE;if(typeof e=="function")return nu(e);if(typeof e=="object")return Array.isArray(e)?IE(e):zE(e);if(typeof e=="string")return $E(e);throw new Error("Expected function, string, or object as test")});function IE(e){const n=[];let s=-1;for(;++s<e.length;)n[s]=tu(e[s]);return nu(i);function i(...o){let d=-1;for(;++d<n.length;)if(n[d].apply(this,o))return!0;return!1}}function zE(e){const n=e;return nu(s);function s(i){const o=i;let d;for(d in e)if(o[d]!==n[d])return!1;return!0}}function $E(e){return nu(n);function n(s){return s&&s.type===e}}function nu(e){return n;function n(s,i,o){return!!(HE(s)&&e.call(this,s,typeof i=="number"?i:void 0,o||void 0))}}function BE(){return!0}function HE(e){return e!==null&&typeof e=="object"&&"type"in e}const ej=[],PE=!0,jm=!1,UE="skip";function tj(e,n,s,i){let o;typeof n=="function"&&typeof s!="function"?(i=s,s=n):o=n;const d=tu(o),c=i?-1:1;m(e,void 0,[])();function m(h,f,p){const x=h&&typeof h=="object"?h:{};if(typeof x.type=="string"){const y=typeof x.tagName=="string"?x.tagName:typeof x.name=="string"?x.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(h.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=ej,w,N,S;if((!n||d(h,f,p[p.length-1]||void 0))&&(y=qE(s(h,p)),y[0]===jm))return y;if("children"in h&&h.children){const E=h;if(E.children&&y[0]!==UE)for(N=(i?E.children.length:-1)+c,S=p.concat(E);N>-1&&N<E.children.length;){const C=E.children[N];if(w=m(C,N,S)(),w[0]===jm)return w;N=typeof w[1]=="number"?w[1]:N+c}}return y}}}function qE(e){return Array.isArray(e)?e:typeof e=="number"?[PE,e]:e==null?ej:[e]}function hx(e,n,s,i){let o,d,c;typeof n=="function"&&typeof s!="function"?(d=void 0,c=n,o=s):(d=n,c=s,o=i),tj(e,d,m,o);function m(h,f){const p=f[f.length-1],x=p?p.children.indexOf(h):void 0;return c(h,x,p)}}const wm={}.hasOwnProperty,VE={};function FE(e,n){const s=n||VE,i=new Map,o=new Map,d=new Map,c={...TE,...s.handlers},m={all:f,applyData:GE,definitionById:i,footnoteById:o,footnoteCounts:d,footnoteOrder:[],handlers:c,one:h,options:s,patch:YE,wrap:KE};return hx(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const x=p.type==="definition"?i:o,g=String(p.identifier).toUpperCase();x.has(g)||x.set(g,p)}}),m;function h(p,x){const g=p.type,y=m.handlers[g];if(wm.call(m.handlers,g)&&y)return y(m,p,x);if(m.options.passThrough&&m.options.passThrough.includes(g)){if("children"in p){const{children:N,...S}=p,E=Od(S);return E.children=m.all(p),E}return Od(p)}return(m.options.unknownHandler||XE)(m,p,x)}function f(p){const x=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const w=m.one(g[y],p);if(w){if(y&&g[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=ny(w.value)),!Array.isArray(w)&&w.type==="element")){const N=w.children[0];N&&N.type==="text"&&(N.value=ny(N.value))}Array.isArray(w)?x.push(...w):x.push(w)}}}return x}}function YE(e,n){e.position&&(n.position=Dk(e))}function GE(e,n){let s=n;if(e&&e.data){const i=e.data.hName,o=e.data.hChildren,d=e.data.hProperties;if(typeof i=="string")if(s.type==="element")s.tagName=i;else{const c="children"in s?s.children:[s];s={type:"element",tagName:i,properties:{},children:c}}s.type==="element"&&d&&Object.assign(s.properties,Od(d)),"children"in s&&s.children&&o!==null&&o!==void 0&&(s.children=o)}return s}function XE(e,n){const s=n.data||{},i="value"in n&&!(wm.call(s,"hProperties")||wm.call(s,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function KE(e,n){const s=[];let i=-1;for(n&&s.push({type:"text",value:`
20
- `});++i<e.length;)i&&s.push({type:"text",value:`
21
- `}),s.push(e[i]);return n&&e.length>0&&s.push({type:"text",value:`
22
- `}),s}function ny(e){let n=0,s=e.charCodeAt(n);for(;s===9||s===32;)n++,s=e.charCodeAt(n);return e.slice(n)}function ry(e,n){const s=FE(e,n),i=s.one(e,void 0),o=LE(s),d=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return o&&d.children.push({type:"text",value:`
23
- `},o),d}function WE(e,n){return e&&"run"in e?async function(s,i){const o=ry(s,{file:i,...n});await e.run(o,i)}:function(s,i){return ry(s,{file:i,...e||n})}}function sy(e){if(e)throw e}var _h,ay;function ZE(){if(ay)return _h;ay=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):n.call(f)==="[object Array]"},d=function(f){if(!f||n.call(f)!=="[object Object]")return!1;var p=e.call(f,"constructor"),x=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!x)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},c=function(f,p){s&&p.name==="__proto__"?s(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},m=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(i)return i(f,p).value}else return;return f[p]};return _h=function h(){var f,p,x,g,y,w,N=arguments[0],S=1,E=arguments.length,C=!1;for(typeof N=="boolean"&&(C=N,N=arguments[1]||{},S=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});S<E;++S)if(f=arguments[S],f!=null)for(p in f)x=m(N,p),g=m(f,p),N!==g&&(C&&g&&(d(g)||(y=o(g)))?(y?(y=!1,w=x&&o(x)?x:[]):w=x&&d(x)?x:{},c(N,{name:p,newValue:h(C,w,g)})):typeof g<"u"&&c(N,{name:p,newValue:g}));return N},_h}var QE=ZE();const Ah=Zd(QE);function Nm(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function JE(){const e=[],n={run:s,use:i};return n;function s(...o){let d=-1;const c=o.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);m(null,...o);function m(h,...f){const p=e[++d];let x=-1;if(h){c(h);return}for(;++x<o.length;)(f[x]===null||f[x]===void 0)&&(f[x]=o[x]);o=f,p?e3(p,m)(...f):c(null,...f)}}function i(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),n}}function e3(e,n){let s;return i;function i(...c){const m=e.length>c.length;let h;m&&c.push(o);try{h=e.apply(this,c)}catch(f){const p=f;if(m&&s)throw p;return o(p)}m||(h&&h.then&&typeof h.then=="function"?h.then(d,o):h instanceof Error?o(h):d(h))}function o(c,...m){s||(s=!0,n(c,...m))}function d(c){o(null,c)}}const ks={basename:t3,dirname:n3,extname:r3,join:s3,sep:"/"};function t3(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');Xo(e);let s=0,i=-1,o=e.length,d;if(n===void 0||n.length===0||n.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(d){s=o+1;break}}else i<0&&(d=!0,i=o+1);return i<0?"":e.slice(s,i)}if(n===e)return"";let c=-1,m=n.length-1;for(;o--;)if(e.codePointAt(o)===47){if(d){s=o+1;break}}else c<0&&(d=!0,c=o+1),m>-1&&(e.codePointAt(o)===n.codePointAt(m--)?m<0&&(i=o):(m=-1,i=c));return s===i?i=c:i<0&&(i=e.length),e.slice(s,i)}function n3(e){if(Xo(e),e.length===0)return".";let n=-1,s=e.length,i;for(;--s;)if(e.codePointAt(s)===47){if(i){n=s;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function r3(e){Xo(e);let n=e.length,s=-1,i=0,o=-1,d=0,c;for(;n--;){const m=e.codePointAt(n);if(m===47){if(c){i=n+1;break}continue}s<0&&(c=!0,s=n+1),m===46?o<0?o=n:d!==1&&(d=1):o>-1&&(d=-1)}return o<0||s<0||d===0||d===1&&o===s-1&&o===i+1?"":e.slice(o,s)}function s3(...e){let n=-1,s;for(;++n<e.length;)Xo(e[n]),e[n]&&(s=s===void 0?e[n]:s+"/"+e[n]);return s===void 0?".":a3(s)}function a3(e){Xo(e);const n=e.codePointAt(0)===47;let s=i3(e,!n);return s.length===0&&!n&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),n?"/"+s:s}function i3(e,n){let s="",i=0,o=-1,d=0,c=-1,m,h;for(;++c<=e.length;){if(c<e.length)m=e.codePointAt(c);else{if(m===47)break;m=47}if(m===47){if(!(o===c-1||d===1))if(o!==c-1&&d===2){if(s.length<2||i!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(h=s.lastIndexOf("/"),h!==s.length-1){h<0?(s="",i=0):(s=s.slice(0,h),i=s.length-1-s.lastIndexOf("/")),o=c,d=0;continue}}else if(s.length>0){s="",i=0,o=c,d=0;continue}}n&&(s=s.length>0?s+"/..":"..",i=2)}else s.length>0?s+="/"+e.slice(o+1,c):s=e.slice(o+1,c),i=c-o-1;o=c,d=0}else m===46&&d>-1?d++:d=-1}return s}function Xo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const l3={cwd:o3};function o3(){return"/"}function km(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function c3(e){if(typeof e=="string")e=new URL(e);else if(!km(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return d3(e)}function d3(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 n=e.pathname;let s=-1;for(;++s<n.length;)if(n.codePointAt(s)===37&&n.codePointAt(s+1)===50){const i=n.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(n)}const Mh=["history","path","basename","stem","extname","dirname"];class nj{constructor(n){let s;n?km(n)?s={path:n}:typeof n=="string"||u3(n)?s={value:n}:s=n:s={},this.cwd="cwd"in s?"":l3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<Mh.length;){const d=Mh[i];d in s&&s[d]!==void 0&&s[d]!==null&&(this[d]=d==="history"?[...s[d]]:s[d])}let o;for(o in s)Mh.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?ks.basename(this.path):void 0}set basename(n){Rh(n,"basename"),Oh(n,"basename"),this.path=ks.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?ks.dirname(this.path):void 0}set dirname(n){iy(this.basename,"dirname"),this.path=ks.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?ks.extname(this.path):void 0}set extname(n){if(Oh(n,"extname"),iy(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ks.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){km(n)&&(n=c3(n)),Rh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?ks.basename(this.path,this.extname):void 0}set stem(n){Rh(n,"stem"),Oh(n,"stem"),this.path=ks.join(this.dirname||"",n+(this.extname||""))}fail(n,s,i){const o=this.message(n,s,i);throw o.fatal=!0,o}info(n,s,i){const o=this.message(n,s,i);return o.fatal=void 0,o}message(n,s,i){const o=new dr(n,s,i);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function Oh(e,n){if(e&&e.includes(ks.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+ks.sep+"`")}function Rh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function iy(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function u3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const f3=(function(e){const i=this.constructor.prototype,o=i[e],d=function(){return o.apply(d,arguments)};return Object.setPrototypeOf(d,i),d}),h3={}.hasOwnProperty;class mx extends f3{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=JE()}copy(){const n=new mx;let s=-1;for(;++s<this.attachers.length;){const i=this.attachers[s];n.use(...i)}return n.data(Ah(!0,{},this.namespace)),n}data(n,s){return typeof n=="string"?arguments.length===2?(Ih("data",this.frozen),this.namespace[n]=s,this):h3.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Ih("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const o=s.call(n,...i);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const s=cd(n),i=this.parser||this.Parser;return Dh("parse",i),i(String(s),s)}process(n,s){const i=this;return this.freeze(),Dh("process",this.parser||this.Parser),Lh("process",this.compiler||this.Compiler),s?o(void 0,s):new Promise(o);function o(d,c){const m=cd(n),h=i.parse(m);i.run(h,m,function(p,x,g){if(p||!x||!g)return f(p);const y=x,w=i.stringify(y,g);p3(w)?g.value=w:g.result=w,f(p,g)});function f(p,x){p||!x?c(p):d?d(x):s(void 0,x)}}}processSync(n){let s=!1,i;return this.freeze(),Dh("processSync",this.parser||this.Parser),Lh("processSync",this.compiler||this.Compiler),this.process(n,o),oy("processSync","process",s),i;function o(d,c){s=!0,sy(d),i=c}}run(n,s,i){ly(n),this.freeze();const o=this.transformers;return!i&&typeof s=="function"&&(i=s,s=void 0),i?d(void 0,i):new Promise(d);function d(c,m){const h=cd(s);o.run(n,h,f);function f(p,x,g){const y=x||n;p?m(p):c?c(y):i(void 0,y,g)}}}runSync(n,s){let i=!1,o;return this.run(n,s,d),oy("runSync","run",i),o;function d(c,m){sy(c),o=m,i=!0}}stringify(n,s){this.freeze();const i=cd(s),o=this.compiler||this.Compiler;return Lh("stringify",o),ly(n),o(n,i)}use(n,...s){const i=this.attachers,o=this.namespace;if(Ih("use",this.frozen),n!=null)if(typeof n=="function")h(n,s);else if(typeof n=="object")Array.isArray(n)?m(n):c(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function d(f){if(typeof f=="function")h(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[p,...x]=f;h(p,x)}else c(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function c(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");m(f.plugins),f.settings&&(o.settings=Ah(!0,o.settings,f.settings))}function m(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const x=f[p];d(x)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function h(f,p){let x=-1,g=-1;for(;++x<i.length;)if(i[x][0]===f){g=x;break}if(g===-1)i.push([f,...p]);else if(p.length>0){let[y,...w]=p;const N=i[g][1];Nm(N)&&Nm(y)&&(y=Ah(!0,N,y)),i[g]=[f,y,...w]}}}}const m3=new mx().freeze();function Dh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Lh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ih(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ly(e){if(!Nm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function oy(e,n,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function cd(e){return x3(e)?e:new nj(e)}function x3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function p3(e){return typeof e=="string"||g3(e)}function g3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const b3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",cy=[],dy={allowDangerousHtml:!0},y3=/^(https?|ircs?|mailto|xmpp)$/i,v3=[{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 uy(e){const n=j3(e),s=w3(e);return N3(n.runSync(n.parse(s),s),e)}function j3(e){const n=e.rehypePlugins||cy,s=e.remarkPlugins||cy,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dy}:dy;return m3().use(nE).use(s).use(WE,i).use(n)}function w3(e){const n=e.children||"",s=new nj;return typeof n=="string"&&(s.value=n),s}function N3(e,n){const s=n.allowedElements,i=n.allowElement,o=n.components,d=n.disallowedElements,c=n.skipHtml,m=n.unwrapDisallowed,h=n.urlTransform||k3;for(const p of v3)Object.hasOwn(n,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+b3+p.id,void 0);return hx(e,f),Bk(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(p,x,g){if(p.type==="raw"&&g&&typeof x=="number")return c?g.children.splice(x,1):g.children[x]={type:"text",value:p.value},x;if(p.type==="element"){let y;for(y in Ch)if(Object.hasOwn(Ch,y)&&Object.hasOwn(p.properties,y)){const w=p.properties[y],N=Ch[y];(N===null||N.includes(p.tagName))&&(p.properties[y]=h(String(w||""),y,p))}}if(p.type==="element"){let y=s?!s.includes(p.tagName):d?d.includes(p.tagName):!1;if(!y&&i&&typeof x=="number"&&(y=!i(p,x,g)),y&&g&&typeof x=="number")return m&&p.children?g.children.splice(x,1,...p.children):g.children.splice(x,1),x}}}function k3(e){const n=e.indexOf(":"),s=e.indexOf("?"),i=e.indexOf("#"),o=e.indexOf("/");return n===-1||o!==-1&&n>o||s!==-1&&n>s||i!==-1&&n>i||y3.test(e.slice(0,n))?e:""}function fy(e,n){const s=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,o=s.indexOf(n);for(;o!==-1;)i++,o=s.indexOf(n,o+n.length);return i}function S3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function C3(e,n,s){const o=tu((s||{}).ignore||[]),d=E3(n);let c=-1;for(;++c<d.length;)tj(e,"text",m);function m(f,p){let x=-1,g;for(;++x<p.length;){const y=p[x],w=g?g.children:void 0;if(o(y,w?w.indexOf(y):void 0,g))return;g=y}if(g)return h(f,p)}function h(f,p){const x=p[p.length-1],g=d[c][0],y=d[c][1];let w=0;const S=x.children.indexOf(f);let E=!1,C=[];g.lastIndex=0;let k=g.exec(f.value);for(;k;){const T=k.index,R={index:k.index,input:k.input,stack:[...p,f]};let z=y(...k,R);if(typeof z=="string"&&(z=z.length>0?{type:"text",value:z}:void 0),z===!1?g.lastIndex=T+1:(w!==T&&C.push({type:"text",value:f.value.slice(w,T)}),Array.isArray(z)?C.push(...z):z&&C.push(z),w=T+k[0].length,E=!0),!g.global)break;k=g.exec(f.value)}return E?(w<f.value.length&&C.push({type:"text",value:f.value.slice(w)}),x.children.splice(S,1,...C)):C=[f],S+C.length}}function E3(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const s=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<s.length;){const o=s[i];n.push([T3(o[0]),_3(o[1])])}return n}function T3(e){return typeof e=="string"?new RegExp(S3(e),"g"):e}function _3(e){return typeof e=="function"?e:function(){return e}}const zh="phrasing",$h=["autolink","link","image","label"];function A3(){return{transforms:[z3],enter:{literalAutolink:O3,literalAutolinkEmail:Bh,literalAutolinkHttp:Bh,literalAutolinkWww:Bh},exit:{literalAutolink:I3,literalAutolinkEmail:L3,literalAutolinkHttp:R3,literalAutolinkWww:D3}}}function M3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:zh,notInConstruct:$h},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:zh,notInConstruct:$h},{character:":",before:"[ps]",after:"\\/",inConstruct:zh,notInConstruct:$h}]}}function O3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Bh(e){this.config.enter.autolinkProtocol.call(this,e)}function R3(e){this.config.exit.autolinkProtocol.call(this,e)}function D3(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function L3(e){this.config.exit.autolinkEmail.call(this,e)}function I3(e){this.exit(e)}function z3(e){C3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,$3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),B3]],{ignore:["link","linkReference"]})}function $3(e,n,s,i,o){let d="";if(!rj(o)||(/^w/i.test(n)&&(s=n+s,n="",d="http://"),!H3(s)))return!1;const c=P3(s+i);if(!c[0])return!1;const m={type:"link",title:null,url:d+n+c[0],children:[{type:"text",value:n+c[0]}]};return c[1]?[m,{type:"text",value:c[1]}]:m}function B3(e,n,s,i){return!rj(i,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+s,children:[{type:"text",value:n+"@"+s}]}}function H3(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function P3(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let s=n[0],i=s.indexOf(")");const o=fy(e,"(");let d=fy(e,")");for(;i!==-1&&o>d;)e+=s.slice(0,i+1),s=s.slice(i+1),i=s.indexOf(")"),d++;return[e,s]}function rj(e,n){const s=e.input.charCodeAt(e.index-1);return(e.index===0||xi(s)||Qd(s))&&(!n||s!==47)}sj.peek=W3;function U3(){this.buffer()}function q3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function V3(){this.buffer()}function F3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Y3(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=us(this.sliceSerialize(e)).toLowerCase(),s.label=n}function G3(e){this.exit(e)}function X3(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=us(this.sliceSerialize(e)).toLowerCase(),s.label=n}function K3(e){this.exit(e)}function W3(){return"["}function sj(e,n,s,i){const o=s.createTracker(i);let d=o.move("[^");const c=s.enter("footnoteReference"),m=s.enter("reference");return d+=o.move(s.safe(s.associationId(e),{after:"]",before:d})),m(),c(),d+=o.move("]"),d}function Z3(){return{enter:{gfmFootnoteCallString:U3,gfmFootnoteCall:q3,gfmFootnoteDefinitionLabelString:V3,gfmFootnoteDefinition:F3},exit:{gfmFootnoteCallString:Y3,gfmFootnoteCall:G3,gfmFootnoteDefinitionLabelString:X3,gfmFootnoteDefinition:K3}}}function Q3(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:s,footnoteReference:sj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(i,o,d,c){const m=d.createTracker(c);let h=m.move("[^");const f=d.enter("footnoteDefinition"),p=d.enter("label");return h+=m.move(d.safe(d.associationId(i),{before:h,after:"]"})),p(),h+=m.move("]:"),i.children&&i.children.length>0&&(m.shift(4),h+=m.move((n?`
24
- `:" ")+d.indentLines(d.containerFlow(i,m.current()),n?aj:J3))),f(),h}}function J3(e,n,s){return n===0?e:aj(e,n,s)}function aj(e,n,s){return(s?"":" ")+e}const e4=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ij.peek=a4;function t4(){return{canContainEols:["delete"],enter:{strikethrough:r4},exit:{strikethrough:s4}}}function n4(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:e4}],handlers:{delete:ij}}}function r4(e){this.enter({type:"delete",children:[]},e)}function s4(e){this.exit(e)}function ij(e,n,s,i){const o=s.createTracker(i),d=s.enter("strikethrough");let c=o.move("~~");return c+=s.containerPhrasing(e,{...o.current(),before:c,after:"~"}),c+=o.move("~~"),d(),c}function a4(){return"~"}function i4(e){return e.length}function l4(e,n){const s=n||{},i=(s.align||[]).concat(),o=s.stringLength||i4,d=[],c=[],m=[],h=[];let f=0,p=-1;for(;++p<e.length;){const N=[],S=[];let E=-1;for(e[p].length>f&&(f=e[p].length);++E<e[p].length;){const C=o4(e[p][E]);if(s.alignDelimiters!==!1){const k=o(C);S[E]=k,(h[E]===void 0||k>h[E])&&(h[E]=k)}N.push(C)}c[p]=N,m[p]=S}let x=-1;if(typeof i=="object"&&"length"in i)for(;++x<f;)d[x]=hy(i[x]);else{const N=hy(i);for(;++x<f;)d[x]=N}x=-1;const g=[],y=[];for(;++x<f;){const N=d[x];let S="",E="";N===99?(S=":",E=":"):N===108?S=":":N===114&&(E=":");let C=s.alignDelimiters===!1?1:Math.max(1,h[x]-S.length-E.length);const k=S+"-".repeat(C)+E;s.alignDelimiters!==!1&&(C=S.length+C+E.length,C>h[x]&&(h[x]=C),y[x]=C),g[x]=k}c.splice(1,0,g),m.splice(1,0,y),p=-1;const w=[];for(;++p<c.length;){const N=c[p],S=m[p];x=-1;const E=[];for(;++x<f;){const C=N[x]||"";let k="",T="";if(s.alignDelimiters!==!1){const R=h[x]-(S[x]||0),z=d[x];z===114?k=" ".repeat(R):z===99?R%2?(k=" ".repeat(R/2+.5),T=" ".repeat(R/2-.5)):(k=" ".repeat(R/2),T=k):T=" ".repeat(R)}s.delimiterStart!==!1&&!x&&E.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&C==="")&&(s.delimiterStart!==!1||x)&&E.push(" "),s.alignDelimiters!==!1&&E.push(k),E.push(C),s.alignDelimiters!==!1&&E.push(T),s.padding!==!1&&E.push(" "),(s.delimiterEnd!==!1||x!==f-1)&&E.push("|")}w.push(s.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return w.join(`
25
- `)}function o4(e){return e==null?"":String(e)}function hy(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function c4(e,n,s,i){const o=s.enter("blockquote"),d=s.createTracker(i);d.move("> "),d.shift(2);const c=s.indentLines(s.containerFlow(e,d.current()),d4);return o(),c}function d4(e,n,s){return">"+(s?"":" ")+e}function u4(e,n){return my(e,n.inConstruct,!0)&&!my(e,n.notInConstruct,!1)}function my(e,n,s){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return s;let i=-1;for(;++i<n.length;)if(e.includes(n[i]))return!0;return!1}function xy(e,n,s,i){let o=-1;for(;++o<s.unsafe.length;)if(s.unsafe[o].character===`
26
- `&&u4(s.stack,s.unsafe[o]))return/[ \t]/.test(i.before)?"":" ";return`\\
27
- `}function f4(e,n){const s=String(e);let i=s.indexOf(n),o=i,d=0,c=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===o?++d>c&&(c=d):d=1,o=i+n.length,i=s.indexOf(n,o);return c}function h4(e,n){return!!(n.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function m4(e){const n=e.options.fence||"`";if(n!=="`"&&n!=="~")throw new Error("Cannot serialize code with `"+n+"` for `options.fence`, expected `` ` `` or `~`");return n}function x4(e,n,s,i){const o=m4(s),d=e.value||"",c=o==="`"?"GraveAccent":"Tilde";if(h4(e,s)){const x=s.enter("codeIndented"),g=s.indentLines(d,p4);return x(),g}const m=s.createTracker(i),h=o.repeat(Math.max(f4(d,o)+1,3)),f=s.enter("codeFenced");let p=m.move(h);if(e.lang){const x=s.enter(`codeFencedLang${c}`);p+=m.move(s.safe(e.lang,{before:p,after:" ",encode:["`"],...m.current()})),x()}if(e.lang&&e.meta){const x=s.enter(`codeFencedMeta${c}`);p+=m.move(" "),p+=m.move(s.safe(e.meta,{before:p,after:`
28
- `,encode:["`"],...m.current()})),x()}return p+=m.move(`
29
- `),d&&(p+=m.move(d+`
30
- `)),p+=m.move(h),f(),p}function p4(e,n,s){return(s?"":" ")+e}function xx(e){const n=e.options.quote||'"';if(n!=='"'&&n!=="'")throw new Error("Cannot serialize title with `"+n+"` for `options.quote`, expected `\"`, or `'`");return n}function g4(e,n,s,i){const o=xx(s),d=o==='"'?"Quote":"Apostrophe",c=s.enter("definition");let m=s.enter("label");const h=s.createTracker(i);let f=h.move("[");return f+=h.move(s.safe(s.associationId(e),{before:f,after:"]",...h.current()})),f+=h.move("]: "),m(),!e.url||/[\0- \u007F]/.test(e.url)?(m=s.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(s.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(m=s.enter("destinationRaw"),f+=h.move(s.safe(e.url,{before:f,after:e.title?" ":`
31
- `,...h.current()}))),m(),e.title&&(m=s.enter(`title${d}`),f+=h.move(" "+o),f+=h.move(s.safe(e.title,{before:f,after:o,...h.current()})),f+=h.move(o),m()),c(),f}function b4(e){const n=e.options.emphasis||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize emphasis with `"+n+"` for `options.emphasis`, expected `*`, or `_`");return n}function Do(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Rd(e,n,s){const i=ul(e),o=ul(n);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}}lj.peek=y4;function lj(e,n,s,i){const o=b4(s),d=s.enter("emphasis"),c=s.createTracker(i),m=c.move(o);let h=c.move(s.containerPhrasing(e,{after:o,before:m,...c.current()}));const f=h.charCodeAt(0),p=Rd(i.before.charCodeAt(i.before.length-1),f,o);p.inside&&(h=Do(f)+h.slice(1));const x=h.charCodeAt(h.length-1),g=Rd(i.after.charCodeAt(0),x,o);g.inside&&(h=h.slice(0,-1)+Do(x));const y=c.move(o);return d(),s.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},m+h+y}function y4(e,n,s){return s.options.emphasis||"*"}function v4(e,n){let s=!1;return hx(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return s=!0,jm}),!!((!e.depth||e.depth<3)&&ix(e)&&(n.options.setext||s))}function j4(e,n,s,i){const o=Math.max(Math.min(6,e.depth||1),1),d=s.createTracker(i);if(v4(e,s)){const p=s.enter("headingSetext"),x=s.enter("phrasing"),g=s.containerPhrasing(e,{...d.current(),before:`
32
- `,after:`
33
- `});return x(),p(),g+`
34
- `+(o===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
35
- `))+1))}const c="#".repeat(o),m=s.enter("headingAtx"),h=s.enter("phrasing");d.move(c+" ");let f=s.containerPhrasing(e,{before:"# ",after:`
36
- `,...d.current()});return/^[\t ]/.test(f)&&(f=Do(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,s.options.closeAtx&&(f+=" "+c),h(),m(),f}oj.peek=w4;function oj(e){return e.value||""}function w4(){return"<"}cj.peek=N4;function cj(e,n,s,i){const o=xx(s),d=o==='"'?"Quote":"Apostrophe",c=s.enter("image");let m=s.enter("label");const h=s.createTracker(i);let f=h.move("![");return f+=h.move(s.safe(e.alt,{before:f,after:"]",...h.current()})),f+=h.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=s.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(s.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(m=s.enter("destinationRaw"),f+=h.move(s.safe(e.url,{before:f,after:e.title?" ":")",...h.current()}))),m(),e.title&&(m=s.enter(`title${d}`),f+=h.move(" "+o),f+=h.move(s.safe(e.title,{before:f,after:o,...h.current()})),f+=h.move(o),m()),f+=h.move(")"),c(),f}function N4(){return"!"}dj.peek=k4;function dj(e,n,s,i){const o=e.referenceType,d=s.enter("imageReference");let c=s.enter("label");const m=s.createTracker(i);let h=m.move("![");const f=s.safe(e.alt,{before:h,after:"]",...m.current()});h+=m.move(f+"]["),c();const p=s.stack;s.stack=[],c=s.enter("reference");const x=s.safe(s.associationId(e),{before:h,after:"]",...m.current()});return c(),s.stack=p,d(),o==="full"||!f||f!==x?h+=m.move(x+"]"):o==="shortcut"?h=h.slice(0,-1):h+=m.move("]"),h}function k4(){return"!"}uj.peek=S4;function uj(e,n,s){let i=e.value||"",o="`",d=-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+" ");++d<s.unsafe.length;){const c=s.unsafe[d],m=s.compilePattern(c);let h;if(c.atBreak)for(;h=m.exec(i);){let f=h.index;i.charCodeAt(f)===10&&i.charCodeAt(f-1)===13&&f--,i=i.slice(0,f)+" "+i.slice(h.index+1)}}return o+i+o}function S4(){return"`"}function fj(e,n){const s=ix(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(s===e.url||"mailto:"+s===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}hj.peek=C4;function hj(e,n,s,i){const o=xx(s),d=o==='"'?"Quote":"Apostrophe",c=s.createTracker(i);let m,h;if(fj(e,s)){const p=s.stack;s.stack=[],m=s.enter("autolink");let x=c.move("<");return x+=c.move(s.containerPhrasing(e,{before:x,after:">",...c.current()})),x+=c.move(">"),m(),s.stack=p,x}m=s.enter("link"),h=s.enter("label");let f=c.move("[");return f+=c.move(s.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=s.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(s.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(h=s.enter("destinationRaw"),f+=c.move(s.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),h(),e.title&&(h=s.enter(`title${d}`),f+=c.move(" "+o),f+=c.move(s.safe(e.title,{before:f,after:o,...c.current()})),f+=c.move(o),h()),f+=c.move(")"),m(),f}function C4(e,n,s){return fj(e,s)?"<":"["}mj.peek=E4;function mj(e,n,s,i){const o=e.referenceType,d=s.enter("linkReference");let c=s.enter("label");const m=s.createTracker(i);let h=m.move("[");const f=s.containerPhrasing(e,{before:h,after:"]",...m.current()});h+=m.move(f+"]["),c();const p=s.stack;s.stack=[],c=s.enter("reference");const x=s.safe(s.associationId(e),{before:h,after:"]",...m.current()});return c(),s.stack=p,d(),o==="full"||!f||f!==x?h+=m.move(x+"]"):o==="shortcut"?h=h.slice(0,-1):h+=m.move("]"),h}function E4(){return"["}function px(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function T4(e){const n=px(e),s=e.options.bulletOther;if(!s)return n==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+s+"`) to be different");return s}function _4(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function xj(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function A4(e,n,s,i){const o=s.enter("list"),d=s.bulletCurrent;let c=e.ordered?_4(s):px(s);const m=e.ordered?c==="."?")":".":T4(s);let h=n&&s.bulletLastUsed?c===s.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&p&&(!p.children||!p.children[0])&&s.stack[s.stack.length-1]==="list"&&s.stack[s.stack.length-2]==="listItem"&&s.stack[s.stack.length-3]==="list"&&s.stack[s.stack.length-4]==="listItem"&&s.indexStack[s.indexStack.length-1]===0&&s.indexStack[s.indexStack.length-2]===0&&s.indexStack[s.indexStack.length-3]===0&&(h=!0),xj(s)===c&&p){let x=-1;for(;++x<e.children.length;){const g=e.children[x];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(c=m),s.bulletCurrent=c;const f=s.containerFlow(e,i);return s.bulletLastUsed=c,s.bulletCurrent=d,o(),f}function M4(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function O4(e,n,s,i){const o=M4(s);let d=s.bulletCurrent||px(s);n&&n.type==="list"&&n.ordered&&(d=(typeof n.start=="number"&&n.start>-1?n.start:1)+(s.options.incrementListMarker===!1?0:n.children.indexOf(e))+d);let c=d.length+1;(o==="tab"||o==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(c=Math.ceil(c/4)*4);const m=s.createTracker(i);m.move(d+" ".repeat(c-d.length)),m.shift(c);const h=s.enter("listItem"),f=s.indentLines(s.containerFlow(e,m.current()),p);return h(),f;function p(x,g,y){return g?(y?"":" ".repeat(c))+x:(y?d:d+" ".repeat(c-d.length))+x}}function R4(e,n,s,i){const o=s.enter("paragraph"),d=s.enter("phrasing"),c=s.containerPhrasing(e,i);return d(),o(),c}const D4=tu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function L4(e,n,s,i){return(e.children.some(function(c){return D4(c)})?s.containerPhrasing:s.containerFlow).call(s,e,i)}function I4(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}pj.peek=z4;function pj(e,n,s,i){const o=I4(s),d=s.enter("strong"),c=s.createTracker(i),m=c.move(o+o);let h=c.move(s.containerPhrasing(e,{after:o,before:m,...c.current()}));const f=h.charCodeAt(0),p=Rd(i.before.charCodeAt(i.before.length-1),f,o);p.inside&&(h=Do(f)+h.slice(1));const x=h.charCodeAt(h.length-1),g=Rd(i.after.charCodeAt(0),x,o);g.inside&&(h=h.slice(0,-1)+Do(x));const y=c.move(o+o);return d(),s.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},m+h+y}function z4(e,n,s){return s.options.strong||"*"}function $4(e,n,s,i){return s.safe(e.value,i)}function B4(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function H4(e,n,s){const i=(xj(s)+(s.options.ruleSpaces?" ":"")).repeat(B4(s));return s.options.ruleSpaces?i.slice(0,-1):i}const gj={blockquote:c4,break:xy,code:x4,definition:g4,emphasis:lj,hardBreak:xy,heading:j4,html:oj,image:cj,imageReference:dj,inlineCode:uj,link:hj,linkReference:mj,list:A4,listItem:O4,paragraph:R4,root:L4,strong:pj,text:$4,thematicBreak:H4};function P4(){return{enter:{table:U4,tableData:py,tableHeader:py,tableRow:V4},exit:{codeText:F4,table:q4,tableData:Hh,tableHeader:Hh,tableRow:Hh}}}function U4(e){const n=e._align;this.enter({type:"table",align:n.map(function(s){return s==="none"?null:s}),children:[]},e),this.data.inTable=!0}function q4(e){this.exit(e),this.data.inTable=void 0}function V4(e){this.enter({type:"tableRow",children:[]},e)}function Hh(e){this.exit(e)}function py(e){this.enter({type:"tableCell",children:[]},e)}function F4(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,Y4));const s=this.stack[this.stack.length-1];s.type,s.value=n,this.exit(e)}function Y4(e,n){return n==="|"?n:e}function G4(e){const n=e||{},s=n.tableCellPadding,i=n.tablePipeAlign,o=n.stringLength,d=s?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
37
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:c,tableCell:h,tableRow:m}};function c(y,w,N,S){return f(p(y,N,S),y.align)}function m(y,w,N,S){const E=x(y,N,S),C=f([E]);return C.slice(0,C.indexOf(`
38
- `))}function h(y,w,N,S){const E=N.enter("tableCell"),C=N.enter("phrasing"),k=N.containerPhrasing(y,{...S,before:d,after:d});return C(),E(),k}function f(y,w){return l4(y,{align:w,alignDelimiters:i,padding:s,stringLength:o})}function p(y,w,N){const S=y.children;let E=-1;const C=[],k=w.enter("table");for(;++E<S.length;)C[E]=x(S[E],w,N);return k(),C}function x(y,w,N){const S=y.children;let E=-1;const C=[],k=w.enter("tableRow");for(;++E<S.length;)C[E]=h(S[E],y,w,N);return k(),C}function g(y,w,N){let S=gj.inlineCode(y,w,N);return N.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function X4(){return{exit:{taskListCheckValueChecked:gy,taskListCheckValueUnchecked:gy,paragraph:W4}}}function K4(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Z4}}}function gy(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function W4(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const i=s.children[0];if(i&&i.type==="text"){const o=n.children;let d=-1,c;for(;++d<o.length;){const m=o[d];if(m.type==="paragraph"){c=m;break}}c===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 Z4(e,n,s,i){const o=e.children[0],d=typeof e.checked=="boolean"&&o&&o.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",m=s.createTracker(i);d&&m.move(c);let h=gj.listItem(e,n,s,{...i,...m.current()});return d&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),h;function f(p){return p+c}}function Q4(){return[A3(),Z3(),t4(),P4(),X4()]}function J4(e){return{extensions:[M3(),Q3(e),n4(),G4(e),K4()]}}const eT={tokenize:iT,partial:!0},bj={tokenize:lT,partial:!0},yj={tokenize:oT,partial:!0},vj={tokenize:cT,partial:!0},tT={tokenize:dT,partial:!0},jj={name:"wwwAutolink",tokenize:sT,previous:Nj},wj={name:"protocolAutolink",tokenize:aT,previous:kj},na={name:"emailAutolink",tokenize:rT,previous:Sj},_s={};function nT(){return{text:_s}}let ai=48;for(;ai<123;)_s[ai]=na,ai++,ai===58?ai=65:ai===91&&(ai=97);_s[43]=na;_s[45]=na;_s[46]=na;_s[95]=na;_s[72]=[na,wj];_s[104]=[na,wj];_s[87]=[na,jj];_s[119]=[na,jj];function rT(e,n,s){const i=this;let o,d;return c;function c(x){return!Sm(x)||!Sj.call(i,i.previous)||gx(i.events)?s(x):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),m(x))}function m(x){return Sm(x)?(e.consume(x),m):x===64?(e.consume(x),h):s(x)}function h(x){return x===46?e.check(tT,p,f)(x):x===45||x===95||cr(x)?(d=!0,e.consume(x),h):p(x)}function f(x){return e.consume(x),o=!0,h}function p(x){return d&&o&&mr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(x)):s(x)}}function sT(e,n,s){const i=this;return o;function o(c){return c!==87&&c!==119||!Nj.call(i,i.previous)||gx(i.events)?s(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(eT,e.attempt(bj,e.attempt(yj,d),s),s)(c))}function d(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function aT(e,n,s){const i=this;let o="",d=!1;return c;function c(x){return(x===72||x===104)&&kj.call(i,i.previous)&&!gx(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(x),e.consume(x),m):s(x)}function m(x){if(mr(x)&&o.length<5)return o+=String.fromCodePoint(x),e.consume(x),m;if(x===58){const g=o.toLowerCase();if(g==="http"||g==="https")return e.consume(x),h}return s(x)}function h(x){return x===47?(e.consume(x),d?f:(d=!0,h)):s(x)}function f(x){return x===null||Ad(x)||jn(x)||xi(x)||Qd(x)?s(x):e.attempt(bj,e.attempt(yj,p),s)(x)}function p(x){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(x)}}function iT(e,n,s){let i=0;return o;function o(c){return(c===87||c===119)&&i<3?(i++,e.consume(c),o):c===46&&i===3?(e.consume(c),d):s(c)}function d(c){return c===null?s(c):n(c)}}function lT(e,n,s){let i,o,d;return c;function c(f){return f===46||f===95?e.check(vj,h,m)(f):f===null||jn(f)||xi(f)||f!==45&&Qd(f)?h(f):(d=!0,e.consume(f),c)}function m(f){return f===95?i=!0:(o=i,i=void 0),e.consume(f),c}function h(f){return o||i||!d?s(f):n(f)}}function oT(e,n){let s=0,i=0;return o;function o(c){return c===40?(s++,e.consume(c),o):c===41&&i<s?d(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(vj,n,d)(c):c===null||jn(c)||xi(c)?n(c):(e.consume(c),o)}function d(c){return c===41&&i++,e.consume(c),o}}function cT(e,n,s){return i;function i(m){return m===33||m===34||m===39||m===41||m===42||m===44||m===46||m===58||m===59||m===63||m===95||m===126?(e.consume(m),i):m===38?(e.consume(m),d):m===93?(e.consume(m),o):m===60||m===null||jn(m)||xi(m)?n(m):s(m)}function o(m){return m===null||m===40||m===91||jn(m)||xi(m)?n(m):i(m)}function d(m){return mr(m)?c(m):s(m)}function c(m){return m===59?(e.consume(m),i):mr(m)?(e.consume(m),c):s(m)}}function dT(e,n,s){return i;function i(d){return e.consume(d),o}function o(d){return cr(d)?s(d):n(d)}}function Nj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||jn(e)}function kj(e){return!mr(e)}function Sj(e){return!(e===47||Sm(e))}function Sm(e){return e===43||e===45||e===46||e===95||cr(e)}function gx(e){let n=e.length,s=!1;for(;n--;){const i=e[n][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 uT={tokenize:yT,partial:!0};function fT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:pT,continuation:{tokenize:gT},exit:bT}},text:{91:{name:"gfmFootnoteCall",tokenize:xT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hT,resolveTo:mT}}}}function hT(e,n,s){const i=this;let o=i.events.length;const d=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;o--;){const h=i.events[o][1];if(h.type==="labelImage"){c=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return m;function m(h){if(!c||!c._balanced)return s(h);const f=us(i.sliceSerialize({start:c.end,end:i.now()}));return f.codePointAt(0)!==94||!d.includes(f.slice(1))?s(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),n(h))}}function mT(e,n){let s=e.length;for(;s--;)if(e[s][1].type==="labelImage"&&e[s][0]==="enter"){e[s][1];break}e[s+1][1].type="data",e[s+3][1].type="gfmFootnoteCallLabelMarker";const 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 d={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},d.start),end:Object.assign({},d.end)},m=[e[s+1],e[s+2],["enter",i,n],e[s+3],e[s+4],["enter",o,n],["exit",o,n],["enter",d,n],["enter",c,n],["exit",c,n],["exit",d,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(s,e.length-s+1,...m),e}function xT(e,n,s){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d=0,c;return m;function m(x){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),h}function h(x){return x!==94?s(x):(e.enter("gfmFootnoteCallMarker"),e.consume(x),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(x){if(d>999||x===93&&!c||x===null||x===91||jn(x))return s(x);if(x===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return o.includes(us(i.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):s(x)}return jn(x)||(c=!0),d++,e.consume(x),x===92?p:f}function p(x){return x===91||x===92||x===93?(e.consume(x),d++,f):f(x)}}function pT(e,n,s){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d,c=0,m;return h;function h(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):s(w)}function p(w){if(c>999||w===93&&!m||w===null||w===91||jn(w))return s(w);if(w===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return d=us(i.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return jn(w)||(m=!0),c++,e.consume(w),w===92?x:p}function x(w){return w===91||w===92||w===93?(e.consume(w),c++,p):p(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),o.includes(d)||o.push(d),Kt(e,y,"gfmFootnoteDefinitionWhitespace")):s(w)}function y(w){return n(w)}}function gT(e,n,s){return e.check(Go,n,e.attempt(uT,n,s))}function bT(e){e.exit("gfmFootnoteDefinition")}function yT(e,n,s){const i=this;return Kt(e,o,"gfmFootnoteDefinitionIndent",5);function o(d){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(d):s(d)}}function vT(e){let s=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:d,resolveAll:o};return s==null&&(s=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(c,m){let h=-1;for(;++h<c.length;)if(c[h][0]==="enter"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._close){let f=h;for(;f--;)if(c[f][0]==="exit"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._open&&c[h][1].end.offset-c[h][1].start.offset===c[f][1].end.offset-c[f][1].start.offset){c[h][1].type="strikethroughSequence",c[f][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},c[f][1].start),end:Object.assign({},c[h][1].end)},x={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[h][1].start)},g=[["enter",p,m],["enter",c[f][1],m],["exit",c[f][1],m],["enter",x,m]],y=m.parser.constructs.insideSpan.null;y&&Br(g,g.length,0,Jd(y,c.slice(f+1,h),m)),Br(g,g.length,0,[["exit",x,m],["enter",c[h][1],m],["exit",c[h][1],m],["exit",p,m]]),Br(c,f-1,h-f+3,g),h=f+g.length-2;break}}for(h=-1;++h<c.length;)c[h][1].type==="strikethroughSequenceTemporary"&&(c[h][1].type="data");return c}function d(c,m,h){const f=this.previous,p=this.events;let x=0;return g;function g(w){return f===126&&p[p.length-1][1].type!=="characterEscape"?h(w):(c.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const N=ul(f);if(w===126)return x>1?h(w):(c.consume(w),x++,y);if(x<2&&!s)return h(w);const S=c.exit("strikethroughSequenceTemporary"),E=ul(w);return S._open=!E||E===2&&!!N,S._close=!N||N===2&&!!E,m(w)}}}class jT{constructor(){this.map=[]}add(n,s,i){wT(this,n,s,i)}consume(n){if(this.map.sort(function(d,c){return d[0]-c[0]}),this.map.length===0)return;let s=this.map.length;const i=[];for(;s>0;)s-=1,i.push(n.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),n.length=this.map[s][0];i.push(n.slice()),n.length=0;let o=i.pop();for(;o;){for(const d of o)n.push(d);o=i.pop()}this.map.length=0}}function wT(e,n,s,i){let o=0;if(!(s===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===n){e.map[o][1]+=s,e.map[o][2].push(...i);return}o+=1}e.map.push([n,s,i])}}function NT(e,n){let s=!1;const i=[];for(;n<e.length;){const o=e[n];if(s){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const d=i.length-1;i[d]=i[d]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(s=!0);n+=1}return i}function kT(){return{flow:{null:{name:"table",tokenize:ST,resolveAll:CT}}}}function ST(e,n,s){const i=this;let o=0,d=0,c;return m;function m($){let F=i.events.length-1;for(;F>-1;){const M=i.events[F][1].type;if(M==="lineEnding"||M==="linePrefix")F--;else break}const Y=F>-1?i.events[F][1].type:null,P=Y==="tableHead"||Y==="tableRow"?z:h;return P===z&&i.parser.lazy[i.now().line]?s($):P($)}function h($){return e.enter("tableHead"),e.enter("tableRow"),f($)}function f($){return $===124||(c=!0,d+=1),p($)}function p($){return $===null?s($):vt($)?d>1?(d=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),y):s($):qt($)?Kt(e,p,"whitespace")($):(d+=1,c&&(c=!1,o+=1),$===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),c=!0,p):(e.enter("data"),x($)))}function x($){return $===null||$===124||jn($)?(e.exit("data"),p($)):(e.consume($),$===92?g:x)}function g($){return $===92||$===124?(e.consume($),x):x($)}function y($){return i.interrupt=!1,i.parser.lazy[i.now().line]?s($):(e.enter("tableDelimiterRow"),c=!1,qt($)?Kt(e,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):w($))}function w($){return $===45||$===58?S($):$===124?(c=!0,e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),N):R($)}function N($){return qt($)?Kt(e,S,"whitespace")($):S($)}function S($){return $===58?(d+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),E):$===45?(d+=1,E($)):$===null||vt($)?T($):R($)}function E($){return $===45?(e.enter("tableDelimiterFiller"),C($)):R($)}function C($){return $===45?(e.consume($),C):$===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k($))}function k($){return qt($)?Kt(e,T,"whitespace")($):T($)}function T($){return $===124?w($):$===null||vt($)?!c||o!==d?R($):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n($)):R($)}function R($){return s($)}function z($){return e.enter("tableRow"),U($)}function U($){return $===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),U):$===null||vt($)?(e.exit("tableRow"),n($)):qt($)?Kt(e,U,"whitespace")($):(e.enter("data"),G($))}function G($){return $===null||$===124||jn($)?(e.exit("data"),U($)):(e.consume($),$===92?W:G)}function W($){return $===92||$===124?(e.consume($),G):G($)}}function CT(e,n){let s=-1,i=!0,o=0,d=[0,0,0,0],c=[0,0,0,0],m=!1,h=0,f,p,x;const g=new jT;for(;++s<e.length;){const y=e[s],w=y[1];y[0]==="enter"?w.type==="tableHead"?(m=!1,h!==0&&(by(g,n,h,f,p),p=void 0,h=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(s,0,[["enter",f,n]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(i=!0,x=void 0,d=[0,0,0,0],c=[0,s+1,0,0],m&&(m=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(s,0,[["enter",p,n]])),o=w.type==="tableDelimiterRow"?2:p?3:1):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(d[1]!==0&&(c[0]=c[1],x=dd(g,n,d,o,void 0,x),d=[0,0,0,0]),c[2]=s)):w.type==="tableCellDivider"&&(i?i=!1:(d[1]!==0&&(c[0]=c[1],x=dd(g,n,d,o,void 0,x)),d=c,c=[d[1],s,0,0])):w.type==="tableHead"?(m=!0,h=s):w.type==="tableRow"||w.type==="tableDelimiterRow"?(h=s,d[1]!==0?(c[0]=c[1],x=dd(g,n,d,o,s,x)):c[1]!==0&&(x=dd(g,n,c,o,s,x)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=s)}for(h!==0&&by(g,n,h,f,p),g.consume(n.events),s=-1;++s<n.events.length;){const y=n.events[s];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=NT(n.events,s))}return e}function dd(e,n,s,i,o,d){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",m="tableContent";s[0]!==0&&(d.end=Object.assign({},rl(n.events,s[0])),e.add(s[0],0,[["exit",d,n]]));const h=rl(n.events,s[1]);if(d={type:c,start:Object.assign({},h),end:Object.assign({},h)},e.add(s[1],0,[["enter",d,n]]),s[2]!==0){const f=rl(n.events,s[2]),p=rl(n.events,s[3]),x={type:m,start:Object.assign({},f),end:Object.assign({},p)};if(e.add(s[2],0,[["enter",x,n]]),i!==2){const g=n.events[s[2]],y=n.events[s[3]];if(g[1].end=Object.assign({},y[1].end),g[1].type="chunkText",g[1].contentType="text",s[3]>s[2]+1){const w=s[2]+1,N=s[3]-s[2]-1;e.add(w,N,[])}}e.add(s[3]+1,0,[["exit",x,n]])}return o!==void 0&&(d.end=Object.assign({},rl(n.events,o)),e.add(o,0,[["exit",d,n]]),d=void 0),d}function by(e,n,s,i,o){const d=[],c=rl(n.events,s);o&&(o.end=Object.assign({},c),d.push(["exit",o,n])),i.end=Object.assign({},c),d.push(["exit",i,n]),e.add(s+1,0,d)}function rl(e,n){const s=e[n],i=s[0]==="enter"?"start":"end";return s[1][i]}const ET={name:"tasklistCheck",tokenize:_T};function TT(){return{text:{91:ET}}}function _T(e,n,s){const i=this;return o;function o(h){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?s(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),d)}function d(h){return jn(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),c):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),c):s(h)}function c(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),m):s(h)}function m(h){return vt(h)?n(h):qt(h)?e.check({tokenize:AT},n,s)(h):s(h)}}function AT(e,n,s){return Kt(e,i,"whitespace");function i(o){return o===null?s(o):n(o)}}function MT(e){return I1([nT(),fT(),vT(e),kT(),TT()])}const OT={};function yy(e){const n=this,s=e||OT,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),d=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(MT(s)),d.push(Q4()),c.push(J4(s))}const RT=/<think>([\s\S]*?)<\/think>/g;function DT(e){const n=[],s=e.replace(RT,(i,o)=>{const d=o.trim();return d&&n.push(d),""});return{thinking:n,rest:s.trim()}}const Cm="#mention:";function LT(e){return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(n,s,i)=>{const o=s??i;return`[@${o}](${Cm}${encodeURIComponent(o)})`})}const Ph={p:({children:e})=>t.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",children:e}),h1:({children:e})=>t.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0",children:e}),h2:({children:e})=>t.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0",children:e}),h3:({children:e})=>t.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0",children:e}),ul:({children:e})=>t.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e})=>t.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:e}),li:({children:e})=>t.jsx("li",{className:"leading-relaxed",children:e}),code:({children:e,className:n})=>n?.includes("language-")?t.jsx("code",{className:"text-fg-secondary font-mono",children:e}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e}),pre:({children:e})=>t.jsx("pre",{className:"bg-surface-secondary rounded-lg p-3 overflow-x-auto my-2 text-xs [&>code]:bg-transparent [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:e}),strong:({children:e})=>t.jsx("strong",{className:"font-semibold text-fg-primary",children:e}),em:({children:e})=>t.jsx("em",{className:"italic text-fg-secondary",children:e}),blockquote:({children:e})=>t.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:n})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:n}),hr:()=>t.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>t.jsx("div",{className:"overflow-x-auto my-2",children:t.jsx("table",{className:"min-w-full text-xs border-collapse border border-border-default",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-surface-elevated",children:e}),tbody:({children:e})=>t.jsx("tbody",{className:"divide-y divide-gray-700/50",children:e}),tr:({children:e})=>t.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>t.jsx("th",{className:"px-3 py-1.5 text-left text-xs font-semibold text-fg-secondary border border-border-default",children:e}),td:({children:e})=>t.jsx("td",{className:"px-3 py-1.5 text-xs text-fg-secondary border border-border-default",children:e})};function tr({content:e,className:n="",onMentionClick:s}){const{thinking:i,rest:o}=DT(e),d=v.useMemo(()=>s?LT(o):o,[o,s]),c=v.useMemo(()=>s?{...Ph,a:({href:m,children:h})=>{if(m?.startsWith(Cm)){const f=decodeURIComponent(m.slice(Cm.length));return t.jsx("span",{className:"text-brand-500 font-medium cursor-pointer hover:underline",onClick:p=>{p.preventDefault(),p.stopPropagation(),s(f,p)},title:f,children:h})}return t.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:h})}}:Ph,[s]);return t.jsxs("div",{className:`prose prose-sm max-w-none break-words ${n}`,children:[i.length>0&&(()=>{const m=i.join(`
39
-
40
- `),h=m.split(`
41
- `)[0]??"",f=h.length>80?h.slice(0,80)+"…":h;return t.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[t.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),t.jsx("span",{className:"shrink-0",children:"思考过程"}),t.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:f})]}),t.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:t.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:t.jsx(uy,{remarkPlugins:[yy],components:Ph,children:m})})})]})})(),t.jsx(uy,{remarkPlugins:[yy],components:c,children:d})]})}const vy={shell_execute:{label:"Running command",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},file_list:{label:"Listing files",icon:"📂"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},code_search:{label:"Searching code",icon:"🔍"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"}};function pi(e){const n=e.includes("__")?e.split("__").pop():e;return vy[n]??vy[e]??{label:n.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function bx(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function IT(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),o=String(n.getHours()).padStart(2,"0"),d=String(n.getMinutes()).padStart(2,"0"),c=String(n.getSeconds()).padStart(2,"0");return`${s}-${i} ${o}:${d}:${c}`}function Em(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function jy(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function zT(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 $T(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const n=e.args.command;return typeof n=="string"?n:null}function Dd(e){const n=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 d=e[o];if(d.type==="tool"&&d.info.status==="running"&&d.info.tool===i.info.tool&&!n.has(o)){n.add(o);break}}}return e.filter((s,i)=>!n.has(i))}function Ld(e){const n=IT(e.createdAt),s=e.createdAt,i=e.metadata;switch(e.type){case"text":return i?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const o=i?.action;return o&&["chat","chat_stream","task_execution","respond_in_session"].includes(o)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:i?.arguments}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${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 Cj(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const s=JSON.parse(n);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}}function Ej(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const i=s.requirement;return i.status!=="pending"?null:{requirementId:i.id,title:i.title,description:i.description,priority:i.priority}}catch{return null}}function BT(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const i=`${s.tool}_${s.ts}`;n.push({key:i,tool:s.tool,status:"running"})}else for(let i=n.length-1;i>=0;i--)if(n[i].tool===s.tool&&n[i].status==="running"){n[i]={...n[i],status:s.success===!1?"error":"done"};break}}return n}function Tj(){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 HT(){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 wy({item:e,idx:n,total:s}){const i=pi(e.tool);return t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[n>0&&t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:`w-2.5 h-2.5 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":"border-gray-600 bg-surface-elevated text-fg-tertiary"}`,children:e.status==="done"?"✓":e.status==="error"?"✗":""}),n<s-1&&t.jsx("div",{className:"w-px flex-1 bg-surface-overlay mt-0.5"})]}),t.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500 opacity-60":"text-fg-tertiary"}`,children:[t.jsx("span",{className:"opacity-70",children:i.icon}),t.jsxs("span",{children:[i.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(Tj,{})]})]})}function PT({activities:e,isActive:n,persistent:s}){const i=BT(e),[o,d]=v.useState(!1),[c,m]=v.useState(!1),h=v.useRef(null);if(v.useEffect(()=>(s||n||e.length>0?(d(!0),h.current&&clearTimeout(h.current)):h.current=setTimeout(()=>d(!1),800),()=>{h.current&&clearTimeout(h.current)}),[s,n,e.length]),!o)return null;const f=i.length>0,p=f&&i.every(y=>y.status!=="running"),x=n&&!f,g=n&&f&&p;if(s&&p){const y=i.filter(N=>N.status==="error").length,w=i.filter(N=>N.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>m(N=>!N),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[t.jsx("span",{className:`transition-transform duration-150 ${c?"rotate-90":""}`,children:"▶"}),t.jsxs("span",{className:"font-medium",children:[w," step",w!==1?"s":""]}),y>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",y," failed"]}),!c&&t.jsxs("span",{className:"ml-1 flex gap-0.5",children:[i.slice(0,5).map(N=>t.jsx("span",{className:"text-[10px] opacity-60",title:pi(N.tool).label,children:pi(N.tool).icon},N.key)),i.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",i.length-5]})]})]}),c&&t.jsx("div",{className:"mt-2 space-y-0.5",children:i.map((N,S)=>t.jsx(wy,{item:N,idx:S,total:i.length},N.key))})]})}return t.jsxs("div",{className:"mb-2 space-y-0.5",children:[i.map((y,w)=>t.jsx(wy,{item:y,idx:w,total:i.length},y.key)),x&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-fg-secondary py-0.5",children:[t.jsx("span",{className:"mr-0.5",children:"Thinking"}),t.jsx(HT,{})]}),g&&t.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-brand-500 bg-brand-500/15 shrink-0"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-brand-500",children:[t.jsx(Tj,{}),t.jsx("span",{children:"Writing response…"})]})]})]})}function Tm({label:e="Thinking"}){return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-fg-secondary py-0.5",children:[t.jsx("span",{children:e}),t.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(n=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}function _m({content:e,className:n}){return t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[t.jsx(tr,{content:e,className:n??"text-sm text-fg-secondary break-words"}),t.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}function UT({info:e,onClose:n}){const s=pi(e.tool),i=zT(e.args),o=e.status!=="error";return v.useEffect(()=>{const d=c=>{c.key==="Escape"&&n()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[n]),t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:n,children:[t.jsx("div",{className:"absolute inset-0 bg-black/60"}),t.jsxs("div",{className:"relative bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[560px] max-w-[92vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:d=>d.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-3 border-b border-border-default flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"opacity-60 text-sm",children:s.icon}),t.jsx("span",{className:`text-sm font-semibold ${o?"text-fg-primary":"text-red-500"}`,children:s.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:o?"Success":"Failed"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[e.durationMs!=null&&t.jsx("span",{className:"text-xs text-fg-tertiary",children:bx(e.durationMs)}),t.jsx("button",{onClick:n,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[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:d,value:c})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:d}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:c})]},d))})]}),e.result&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Result"}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto overflow-y-auto max-h-[60vh] whitespace-pre-wrap break-all font-mono",children:jy(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:jy(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."})]})]})]})}const _j={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},Ny={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",cancelled:"cancelled",archived:"archived"},ky={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 Aj({info:e}){const[n,s]=v.useState("loading");v.useEffect(()=>{let h=!1;return se.tasks.get(e.taskId).then(({task:f})=>{h||s(Ny[f.status]??"pending")}).catch(()=>{h||s("pending")}),()=>{h=!0}},[e.taskId]),v.useEffect(()=>an.on("task:update",h=>{const f=h.payload;f.taskId===e.taskId&&f.status&&s(Ny[f.status]??"pending")}),[e.taskId]);const i=async()=>{s("approving");try{await se.tasks.approve(e.taskId),s("in_progress")}catch{s("pending")}},o=async()=>{s("rejecting");try{await se.tasks.reject(e.taskId),s("cancelled")}catch{s("pending")}},d=n==="pending"||n==="approving"||n==="rejecting",c=ky[n]??ky.loading,m=()=>pt.navigate(xe.WORK,{openTask:e.taskId});return t.jsxs("div",{className:`my-2 rounded-lg border ${c.borderClass} ${c.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:m,onKeyDown:h=>h.key==="Enter"&&m(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:c.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${c.badgeClass}`,children:"Task"}),!d&&n!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${c.textClass}`,children:c.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!d&&n!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:_j[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.taskId.slice(0,8),"..."]})]})]})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:i,disabled:n!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:o,disabled:n!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="rejecting"?"Rejecting…":"Reject"})]})]})}const Sy={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},Cy={pending:{icon:"📋",label:"Pending Approval",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},approving:{icon:"⏳",label:"Approving…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},rejecting:{icon:"⏳",label:"Rejecting…",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},in_progress:{icon:"▶",label:"In Progress",borderClass:"border-blue-500/40",bgClass:"bg-blue-500/5",badgeClass:"bg-blue-500/15 text-blue-500",textClass:"text-blue-500"},completed:{icon:"✅",label:"Completed",borderClass:"border-green-500/30",bgClass:"bg-green-500/5",badgeClass:"bg-green-500/15 text-green-500",textClass:"text-green-500"},rejected:{icon:"❌",label:"Rejected",borderClass:"border-red-500/30",bgClass:"bg-red-500/5",badgeClass:"bg-red-500/15 text-red-500",textClass:"text-red-500"},cancelled:{icon:"⊘",label:"Cancelled",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},archived:{icon:"📦",label:"Archived",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},loading:{icon:"⏳",label:"Loading…",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:""}},qT=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function Mj({info:e}){const[n,s]=v.useState("loading"),[i,o]=v.useState(""),[d,c]=v.useState(!1);v.useEffect(()=>{let x=!1;return se.requirements.get(e.requirementId).then(({requirement:g})=>{x||s(Sy[g.status]??"pending")}).catch(()=>{x||s("pending")}),()=>{x=!0}},[e.requirementId]),v.useEffect(()=>{const x=qT.map(g=>an.on(g,y=>{const w=y.payload;w.id===e.requirementId&&w.status&&s(Sy[w.status]??"pending")}));return()=>x.forEach(g=>g())},[e.requirementId]);const m=async()=>{s("approving");try{await se.requirements.approve(e.requirementId),s("in_progress")}catch{s("pending")}},h=async()=>{if(!d){c(!0);return}if(i.trim()){s("rejecting");try{await se.requirements.reject(e.requirementId,i.trim()),s("rejected")}catch{s("pending")}}},f=n==="pending"||n==="approving"||n==="rejecting",p=Cy[n]??Cy.loading;return t.jsxs("div",{className:`my-2 rounded-lg border ${p.borderClass} ${p.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[t.jsx("span",{className:"text-sm mt-0.5",children:p.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.badgeClass}`,children:"REQ"}),!f&&n!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${p.textClass}`,children:p.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 ${!f&&n!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:_j[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.requirementId.slice(0,8),"..."]})]})]})]}),f&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default/30 space-y-2",children:[d&&t.jsx("input",{type:"text",value: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"&&h(),autoFocus:!0}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:m,disabled:n!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:h,disabled:n!=="pending"||d&&!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:n==="rejecting"?"Rejecting…":"Reject"})]})]})]})}function VT({info:e,showTime:n,time:s,isLast:i}){const o=pi(e.tool),[d,c]=v.useState(!1),m=e.status!=="running",h=e.status==="stopped",p=(e.tool==="spawn_subagent"||e.tool==="spawn_subagents")&&e.subagentLogs&&e.subagentLogs.length>0,x=m||p,g=$T(e),y=v.useRef(null);return v.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[e.liveOutput]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`relative flex items-start gap-2 py-0.5 min-w-0 ${i?"":"border-b border-border-default/30 pb-1.5 mb-0.5"} ${x?"cursor-pointer rounded hover:bg-surface-elevated/30 transition-colors":""}`,onClick:()=>m&&c(!0),children:[n&&s&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-0.5 hidden md:inline",children:s}),t.jsx("div",{className:"flex flex-col items-center shrink-0 mt-0.5",style:{width:14},children:t.jsx("div",{className:`w-3 h-3 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15 animate-pulse":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":h?"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"?"✗":h?"■":""})}),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":h?"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:bx(e.durationMs)}),p&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary ml-0.5 opacity-60",children:["(",e.subagentLogs.filter(w=>w.eventType==="tool_end").length," steps)"]})]}),g&&t.jsxs("div",{className:`mt-0.5 font-mono text-[11px] truncate max-w-full ${e.status==="running"?"text-fg-secondary":"text-fg-tertiary"}`,title:g,children:[t.jsx("span",{className:"text-fg-tertiary select-none",children:"$ "}),Em(g,120)]}),e.liveOutput&&e.status==="running"&&t.jsx("pre",{ref:y,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput})]})]}),d&&t.jsx(UT,{info:e,onClose:()=>c(!1)}),m&&(()=>{const w=Cj(e.tool,e.result);if(w)return t.jsx(Aj,{info:w});const N=Ej(e.tool,e.result);return N?t.jsx(Mj,{info:N}):null})()]})}function FT({content:e,time:n,showTime:s}){const[i,o]=v.useState(!1);return t.jsxs("div",{className:"flex items-start gap-2",children:[s&&n&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2.5 hidden md:inline",children:n}),t.jsxs("div",{className:"flex-1 min-w-0 my-1 overflow-hidden",children:[t.jsxs("button",{onClick:()=>o(!i),className:"flex items-center gap-1.5 text-xs text-purple-400 hover:text-purple-300 transition-colors",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400/60 shrink-0"}),t.jsx("span",{children:"Thinking"}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:["(",e.length," chars)"]}),t.jsx("svg",{className:`w-3 h-3 transition-transform ${i?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),i&&t.jsx("div",{className:"mt-1.5 bg-purple-500/[0.06] border border-purple-500/15 rounded-lg px-3 py-2.5 overflow-hidden",children:t.jsx(tr,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})]})}const Id=v.memo(Oj);function Oj({entry:e,showTime:n,isLast:s}){if(e.type==="tool")return t.jsx(VT,{info:e.info,showTime:n,time:e.time,isLast:s},e.key);if(e.type==="thinking")return t.jsx(FT,{content:e.content,time:e.time,showTime:n});if(e.type==="text")return t.jsxs("div",{className:"flex items-start gap-2 ",children:[n&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2.5 hidden md:inline",children:e.time}),t.jsx("div",{className:"flex-1 min-w-0 bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 overflow-hidden",children:t.jsx(tr,{content:e.content,className:"text-sm text-fg-secondary break-words"})})]});if(e.type==="status"){const i=e.content==="completed"||e.content==="execution_finished",o=e.content==="started",d=e.content==="resumed",c=i?"text-green-600":o?"text-blue-600":d?"text-amber-600":"text-fg-tertiary",m=i?"bg-green-400":o?"bg-blue-400":d?"bg-amber-400":"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 py-0.5 px-1",children:[n&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums hidden md:inline",children:e.time}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m}`}),t.jsx("span",{className:`text-xs capitalize ${c}`,children:e.content})]})}return e.type==="error"?t.jsxs("div",{className:"flex items-start gap-2 ",children:[n&&e.time&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 w-24 text-right tabular-nums mt-2 hidden md:inline",children:e.time}),t.jsxs("div",{className:"flex-1 min-w-0 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded px-2.5 py-2 my-1 leading-relaxed break-words overflow-hidden",children:[t.jsx("span",{className:"font-medium",children:"Error:"})," ",e.content]})]}):null}function yx({entries:e,streamingText:n,isActive:s,onExpand:i,showRounds:o,embedded:d}){const c=e.length>0?e[e.length-1]:null,m=e.filter(k=>k.type==="tool_end").length,h=e.filter(k=>k.type==="error").length,f=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),p=c?new Date(c.createdAt).getTime():Date.now(),x=s?Date.now()-f:p-f,g=new Set(e.filter(k=>k.executionRound!=null).map(k=>k.executionRound)),y=g.size>0?Math.max(...g):void 0,w=o&&g.size>1;let N,S,E=null;if(s)if(n)N="✍",S="Writing response...",E=Em(n.split(`
42
- `).pop()??"",80);else if(c?.type==="tool_start"){const k=pi(c.content);N=k.icon,S=`${k.label}...`;const T=c.metadata?.arguments&&typeof c.metadata.arguments=="object"?c.metadata.arguments.command:void 0;T&&(E=`$ ${Em(T,80)}`)}else if(c?.type==="tool_end"){const k=pi(c.content);N=k.icon,S=k.label}else N="💭",S="Thinking...";else if(h>0&&c?.type==="error")N="❌",S="Failed";else{const T=[...e].reverse().find(R=>R.type==="status")?.content??"";T==="completed"||T==="execution_finished"?(N="✅",S="Completed"):(N="●",S=`${m} tool${m!==1?"s":""} executed`)}const C=bx(x);return t.jsx("div",{onClick:i,className:`overflow-hidden transition-all cursor-pointer min-w-0 ${d?"hover:bg-surface-elevated/20":`rounded-lg border hover:brightness-110 ${s?"border-2 exec-card-active":"border border-border-default bg-surface-elevated/30 hover:border-brand-500/40"}`}`,children:t.jsxs("div",{className:d?"py-2":"px-3 py-2.5 bg-surface-primary/80",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s?t.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):t.jsx("span",{className:"text-sm shrink-0",children:N}),t.jsx("span",{className:`text-xs font-medium truncate ${s?"text-fg-primary":"text-fg-secondary"}`,children:S})]}),C&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:C})]}),n?t.jsx("div",{className:"mt-1.5 ml-5.5 text-xs text-fg-secondary max-h-32 overflow-y-auto whitespace-pre-wrap break-words leading-relaxed",children:t.jsx(tr,{content:n,className:"text-xs"})}):E?t.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:E}):null,t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[m>0&&t.jsxs("span",{children:["🔧 ",m," tool",m!==1?"s":""]}),e.some(k=>k.type==="text"&&!k.metadata?.isThinking)&&t.jsx("span",{children:"💬 text"}),e.some(k=>k.type==="text"&&k.metadata?.isThinking)&&t.jsx("span",{className:"text-purple-400",children:"💭 thinking"}),w&&y!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"opacity-30",children:"·"}),t.jsxs("span",{children:["Round #",y]}),t.jsx("span",{className:"opacity-30",children:"·"}),t.jsxs("span",{children:[g.size," rounds"]})]})]}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:["Show Full Log",t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]})]})})}function YT(e){const n=new Map;for(const s of e){const i=s.executionRound??1;n.has(i)||n.set(i,[]);const o=Ld(s);o&&n.get(i).push(o)}return Array.from(n.entries()).sort(([s],[i])=>s-i).map(([s,i])=>({round:s,entries:i}))}function vx({entries:e,streamingText:n,isActive:s,onCollapse:i,showRounds:o,embedded:d}){const c=v.useRef(null),[m,h]=v.useState(new Set),f=YT(e),p=o&&f.length>1;v.useEffect(()=>{f.length>0&&h(w=>{const N=new Set(w);return N.add(f[f.length-1].round),N})},[f.length]),v.useEffect(()=>{d||!c.current||!s||(c.current.scrollTop=c.current.scrollHeight)},[e.length,n,s,d]);const x=w=>{h(N=>{const S=new Set(N);return S.has(w)?S.delete(w):S.add(w),S})},g=p?null:e.map(Ld).filter(w=>w!==null),y=g?Dd(g):null;return t.jsxs("div",{className:`min-w-0 overflow-hidden ${d?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[t.jsxs("div",{onClick:i,className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${d?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:"Execution Log"}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:["Collapse",t.jsx("svg",{className:"w-3 h-3 rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),t.jsxs("div",{ref:d?void 0:c,className:`space-y-0.5 min-w-0 overflow-x-hidden ${d?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[p?f.map(w=>{const N=m.has(w.round),S=Dd(w.entries),E=w.entries.filter(C=>C.type==="tool"&&C.info?.status!=="running").length;return t.jsxs("div",{className:"border border-border-default/50 rounded-lg mb-2 overflow-hidden",children:[t.jsxs("button",{onClick:()=>x(w.round),className:"w-full flex items-center justify-between px-3 py-1.5 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",w.round]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[E," tool",E!==1?"s":""]}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${N?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),N&&t.jsx("div",{className:"px-3 py-1.5 space-y-0.5",children:S.map((C,k)=>t.jsx(Id,{entry:C,showTime:!0,isLast:k===S.length-1},k))})]},w.round)}):y&&y.map((w,N)=>t.jsx(Id,{entry:w,showTime:!0,isLast:N===y.length-1},N)),s&&n&&t.jsx(_m,{content:n}),s&&!n&&t.jsx(Tm,{})]})]})}function GT({agents:e,filter:n,anchorRef:s,onSelect:i,selectedIndex:o,onIndexChange:d}){const[c,m]=v.useState(null),h=v.useRef(null),f=e.filter(p=>p.name.toLowerCase().includes(n));return v.useEffect(()=>{const p=s.current;if(!p)return;const x=p.getBoundingClientRect();m({top:x.top+window.scrollY-4,left:x.left+window.scrollX+8})},[s,n]),v.useEffect(()=>{if(!h.current||!c)return;if(h.current.getBoundingClientRect().top<8){const x=s.current;if(!x)return;const g=x.getBoundingClientRect();m({top:g.bottom+window.scrollY+4,left:c.left})}},[c,s]),v.useEffect(()=>{o>=f.length&&d(Math.max(0,f.length-1))},[f.length,o,d]),v.useEffect(()=>{if(!h.current)return;h.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[o]),!c||f.length===0?null:Jm.createPortal(t.jsxs("div",{ref:h,style:{position:"absolute",top:c.top,left:c.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:"Mention an agent"}),f.map((p,x)=>t.jsxs("button",{"data-selected":x===o,onMouseDown:g=>{g.preventDefault(),i(p)},onMouseEnter:()=>d(x),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${x===o?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 flex items-center justify-center text-[10px] font-bold text-brand-500 shrink-0",children:p.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:p.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:p.role})]}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${p.status==="idle"||p.status==="working"?"bg-green-400":"bg-gray-500"}`})]},p.id))]}),document.body)}function XT(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const zd=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function KT(e){const n=[];let s;for(zd.lastIndex=0;(s=zd.exec(e))!==null;)n.push(s[1]??s[2]);return n}function Ey(e,n,s){const i=[],o=new RegExp(zd.source,zd.flags);let d=0,c,m=0;for(;(c=o.exec(e))!==null;){c.index>d&&i.push(t.jsx("span",{children:e.slice(d,c.index)},m++));const h=c[1]??c[2],f=n.find(p=>p.name.toLowerCase()===h.toLowerCase());i.push(t.jsxs("span",{className:"text-brand-500 font-medium ",onClick:void 0,title:f?`${f.name} (${f.role})`:void 0,children:["@",h]},m++)),d=c.index+c[0].length}return d<e.length&&i.push(t.jsx("span",{children:e.slice(d)},m++)),i.length>0?i:[t.jsx("span",{children:e},0)]}function Rj({agents:e,onSubmit:n,placeholder:s,replyTo:i,onCancelReply:o}){const[d,c]=v.useState(""),[m,h]=v.useState(!1),[f,p]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(""),[N,S]=v.useState([]),[E,C]=v.useState(0),k=v.useRef(null),T=v.useRef(null),R=e.filter(Y=>Y.name.toLowerCase().includes(y)),z=async()=>{if(d.trim()){h(!0),p(null),T.current={content:d,mentions:[...N]};try{await n(d,N,i?.id),c(""),S([]),T.current=null,o?.()}catch(Y){p(String(Y instanceof Error?Y.message:Y)||"Failed to send comment")}h(!1)}},U=async()=>{if(!T.current)return;const{content:Y,mentions:P}=T.current;h(!0),p(null);try{await n(Y,P),c(""),S([]),T.current=null}catch(M){p(String(M instanceof Error?M.message:M)||"Failed to send comment")}h(!1)},G=v.useCallback(Y=>{c(P=>{const M=P.lastIndexOf("@"),L=XT(Y.name);return M>=0?P.slice(0,M)+L+" ":P+L+" "}),N.includes(Y.id)||S(P=>[...P,Y.id]),g(!1),w(""),C(0),k.current?.focus()},[N]),W=Y=>{c(Y),p(null);const P=Y.lastIndexOf("@");if(P>=0&&(P===0||Y[P-1]===" ")){const L=Y.slice(P+1).toLowerCase();if(e.some(O=>O.name.toLowerCase().includes(L))){w(L),g(!0),C(0);return}}g(!1)},$=Y=>{if(x&&R.length>0){const P=Y.key==="ArrowUp"||Y.ctrlKey&&Y.key==="p",M=Y.key==="ArrowDown"||Y.ctrlKey&&Y.key==="n",L=Y.key==="Enter"||Y.key==="Tab",A=Y.key==="Escape";if(P){Y.preventDefault(),C(O=>(O-1+R.length)%R.length);return}if(M){Y.preventDefault(),C(O=>(O+1)%R.length);return}if(L){Y.preventDefault();const O=R[E];O&&G(O);return}if(A){Y.preventDefault(),g(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),z())},F=v.useCallback(()=>{setTimeout(()=>g(!1),200)},[]);return t.jsxs("div",{className:"relative",children:[x&&t.jsx(GT,{agents:e,filter:y,anchorRef:k,onSelect:G,selectedIndex:E,onIndexChange:C}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[i&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:i.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:i.content})]}),t.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),N.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:N.map(Y=>{const P=e.find(M=>M.id===Y);return t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded-full",children:["@",P?.name??Y,t.jsx("button",{onClick:()=>S(M=>M.filter(L=>L!==Y)),className:"hover:text-red-400",children:"×"})]},Y)})}),t.jsx("textarea",{ref:k,value:d,onChange:Y=>W(Y.target.value),onKeyDown:$,onBlur:F,placeholder:s??"Add a comment… (type @ to mention an agent)",rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:f}),t.jsxs("button",{onClick:U,disabled:m,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Retry"]})]}),t.jsx("div",{className:"flex justify-end px-2.5 pb-2",children:t.jsx("button",{onClick:z,disabled:!d.trim()||m,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:m?"Sending…":"Comment"})})]})]})}function Dj({title:e,message:n,confirmLabel:s="Confirm",checkboxes:i,onConfirm:o,onCancel:d}){const[c,m]=v.useState(()=>{const h={};for(const f of i??[])h[f.id]=f.defaultChecked??!1;return h});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:d,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] shadow-2xl",onClick:h=>h.stopPropagation(),children:[t.jsx("h3",{className:"font-semibold text-base mb-2",children:e}),t.jsx("p",{className:"text-sm text-fg-secondary mb-4 leading-relaxed",children:n}),i&&i.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:i.map(h=>t.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:c[h.id]??!1,onChange:f=>m(p=>({...p,[h.id]:f.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),h.label]},h.id))}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:d,className:"px-4 py-1.5 text-sm border border-border-default rounded-lg hover:bg-surface-elevated transition-colors",children:"Cancel"}),t.jsx("button",{onClick:()=>o(i?c:void 0),className:"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:s})]})]})})}function ru({children:e,onClose:n,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:n,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 Zs({label:e,children:n}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:e}),n]})}function WT({onClose:e,onCreate:n}){const[s,i]=v.useState(""),[o,d]=v.useState("");return t.jsx(ru,{onClose:e,title:"Create a New Team",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Zs,{label:"Team Name",children:t.jsx("input",{value:s,onChange:c=>i(c.target.value),placeholder:"e.g. Engineering, Marketing, Support",className:"input",autoFocus:!0,onKeyDown:c=>{c.key==="Enter"&&s.trim()&&n(s.trim(),o.trim()||void 0)}})}),t.jsx(Zs,{label:"Description (optional)",children:t.jsx("textarea",{value:o,onChange:c=>d(c.target.value),placeholder:"What does this team work on?",className:"input",rows:2})}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"You can add human and AI members to this team after creating it."}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:()=>s.trim()&&n(s.trim(),o.trim()||void 0),disabled:!s.trim(),className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:"Create Team"})]})]})})}function ZT({teamId:e,teams:n,onClose:s,onAdd:i}){const[o,d]=v.useState(""),[c,m]=v.useState("member"),[h,f]=v.useState(""),[p,x]=v.useState(""),[g,y]=v.useState(""),[w,N]=v.useState(e??""),[S,E]=v.useState(""),C=()=>{if(E(""),!o.trim()){E("Name is required");return}if(p&&p!==g){E("Passwords do not match");return}i(o.trim(),c,h||void 0,p||void 0,w||void 0)};return t.jsx(ru,{onClose:s,title:"Add Human Team Member",width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Zs,{label:"Name *",children:t.jsx("input",{value:o,onChange:k=>d(k.target.value),placeholder:"Full name",className:"input",autoFocus:!0})}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Zs,{label:"Role",children:t.jsxs("select",{value:c,onChange:k=>m(k.target.value),className:"input",children:[t.jsx("option",{value:"owner",children:"Owner"}),t.jsx("option",{value:"admin",children:"Admin"}),t.jsx("option",{value:"member",children:"Member"}),t.jsx("option",{value:"guest",children:"Guest"})]})}),t.jsx(Zs,{label:"Assign to Team",children:t.jsxs("select",{value:w,onChange:k=>N(k.target.value),className:"input",children:[t.jsx("option",{value:"",children:"No team"}),n.map(k=>t.jsx("option",{value:k.id,children:k.name},k.id))]})})]}),t.jsx(Zs,{label:"Email",children:t.jsx("input",{value:h,onChange:k=>f(k.target.value),type:"email",placeholder:"Optional (required for login)",className:"input"})}),t.jsxs("div",{className:"border-t border-border-default pt-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:"Set a password to allow this person to log in."}),t.jsx(Zs,{label:"Password",children:t.jsx("input",{value:p,onChange:k=>x(k.target.value),type:"password",placeholder:"Leave blank for no login access",className:"input"})}),p&&t.jsx("div",{className:"mt-3",children:t.jsx(Zs,{label:"Confirm Password",children:t.jsx("input",{value:g,onChange:k=>y(k.target.value),type:"password",placeholder:"Repeat password",className:"input"})})})]}),S&&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:S}),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 QT({teamId:e,ungrouped:n,onClose:s,onAdd:i}){return t.jsx(ru,{onClose:s,title:"Add Existing Member to Team",children:t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Select an ungrouped member to add to this team."}),n.length===0?t.jsx("div",{className:"text-center py-8 text-sm text-fg-tertiary",children:"All members are already in a team."}):t.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:n.map(o=>t.jsxs("button",{onClick:()=>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-blue-400":"bg-gray-600"}`})]},o.id))}),t.jsx("div",{className:"flex justify-end pt-2",children:t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Close"})})]})})}function JT({onClose:e,onConnected:n}){const[s,i]=v.useState(""),[o,d]=v.useState(""),[c,m]=v.useState(!1),[h,f]=v.useState(null),[p,x]=v.useState(null),g=async()=>{if(!s.trim()){d("Agent name is required");return}const w=s.trim().toLowerCase().replace(/\s+/g,"-");m(!0),d("");try{const N=await fetch("/api/external-agents/register",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({externalAgentId:w,agentName:s.trim(),orgId:"default",capabilities:["general"]})});if(!N.ok){const E=await N.json().catch(()=>({}));throw new Error(E.error??`HTTP ${N.status}`)}const S=await N.json();f({externalAgentId:w,markusAgentId:S.registration?.markusAgentId,token:S.token,gatewayUrl:S.gatewayUrl})}catch(N){d(String(N))}m(!1)},y=(w,N)=>{navigator.clipboard.writeText(w),x(N),setTimeout(()=>x(null),2e3)};return t.jsx(ru,{onClose:e,title:"Import OpenClaw Agent",width:"w-[560px]",children:h?(()=>{const w=h.gatewayUrl??`${window.location.origin}/api/gateway`,N=`Connect to the Markus AI platform as an external agent.
43
-
44
- Gateway URL: ${w}
45
- Agent ID: ${h.externalAgentId}
46
- ${h.token?`Bearer Token: ${h.token}`:""}
47
-
48
- Step 1: Read the integration handbook at GET ${w}/manual (set header Authorization: Bearer <token above>). It describes the full Markus concept model, API endpoints, and collaboration patterns.
49
- Step 2: Start a sync loop — call POST ${w}/sync every 30 seconds with your status. The response includes assigned tasks, inbox messages, team context (colleagues), and project context (requirements).
50
- Step 3: Accept and execute tasks, report progress, and communicate with teammates via the sync message system.`;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"text-3xl mb-3 text-green-600",children:"✓"}),t.jsx("div",{className:"text-base text-green-600 font-medium mb-1",children:"Agent registered"}),t.jsx("div",{className:"text-sm text-fg-secondary mt-1",children:t.jsx("strong",{children:s})})]}),t.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/30 rounded-xl p-4",children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-3",children:"Copy this prompt and paste it into your OpenClaw agent, Cursor, or any AI assistant."}),t.jsx("button",{onClick:()=>y(N,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${p==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:p==="prompt"?"Copied!":"Copy Connection Prompt"})]}),t.jsx("div",{className:"flex justify-end pt-5",children:t.jsx("button",{onClick:()=>{n()},className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:"Done"})})]})})():t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-4",children:"Register an OpenClaw agent to join your Markus organization. After registration, you'll get a ready-to-use connection config."}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Zs,{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:g,disabled:c,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-white disabled:opacity-50",children:c?"Connecting...":"Import Agent"})]})]})]})})}let Ty=new Map;function e_(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function t_({authUser:e,agents:n,teams:s,humans:i,tasks:o,externalAgents:d,groupChats:c,chatMode:m,selectedAgent:h,activeChannel:f,activeDmUserId:p,onSelectAgent:x,onSelectChannel:g,onSelectDm:y,onRefreshTeams:w,onRefreshAgents:N,onViewProfile:S,width:E,onResizeStart:C,hidden:k}){const T=Sr(),R=e?.role==="owner"||e?.role==="admin",z=v.useMemo(()=>new Set(d.map(oe=>oe.markusAgentId).filter(Boolean)),[d]),[U,G]=v.useState([]),[W,$]=v.useState(new Set),[F,Y]=v.useState(!1),[P,M]=v.useState(null),[L,A]=v.useState(null),[O,D]=v.useState(!1),[Z,B]=v.useState(null),[q,X]=v.useState(null),[I,_]=v.useState(null),[V,Q]=v.useState(!1),ee=v.useRef(null),[te,ae]=v.useState(null),me=(oe,Ve="success")=>{ae({message:oe,type:Ve}),setTimeout(()=>ae(null),3e3)},[Ne,Ie]=v.useState(!1),[je,Te]=v.useState(!1);v.useEffect(()=>{se.governance.getSystemStatus().then(ze=>Ie(ze.globalPaused)).catch(()=>{});const oe=an.on("system:pause-all",()=>Ie(!0)),Ve=an.on("system:resume-all",()=>Ie(!1));return()=>{oe(),Ve()}},[]);const Ce=v.useCallback(()=>{Ge({title:Ne?"Resume All Agents":"Pause All Agents",message:Ne?"All agents will resume processing events from their mailbox.":"All agents will be paused. Events will still enter the mailbox but will not be processed. In-progress tasks will be blocked.",confirmLabel:Ne?"Resume":"Pause",onConfirm:async()=>{Te(!0);try{Ne?(await se.governance.resumeAll(),Ie(!1)):(await se.governance.pauseAll(),Ie(!0))}catch{}Te(!1)}})},[Ne]),[Re,Ge]=v.useState(null),ot=(oe,Ve,ze,dt,it)=>{Ge({title:oe,message:Ve,onConfirm:ze,confirmLabel:dt,checkboxes:it})},[st,jt]=v.useState(null),[re,Ee]=v.useState(null),Ze=v.useRef(null),yt=v.useRef(null),[Dt,we]=v.useState(!1),[Le,Ue]=v.useState(null),[at,rt]=v.useState(""),Zt=v.useCallback(oe=>{if(!oe)return;const Ve=oe.getBoundingClientRect(),ze=8;Ve.bottom>window.innerHeight&&(oe.style.top=`${Math.max(ze,window.innerHeight-Ve.height-ze)}px`),Ve.right>window.innerWidth&&(oe.style.left=`${Math.max(ze,window.innerWidth-Ve.width-ze)}px`)},[]),[fn,zt]=v.useState(Ty),Mt=v.useMemo(()=>n.map(oe=>oe.id).sort().join(","),[n]);v.useEffect(()=>{if(!n.length)return;let oe=!1;const Ve=async()=>{const dt=[];if(await Promise.allSettled(n.map(async it=>{try{const{sessions:xt}=await se.sessions.listByAgent(it.id,1);if(!xt.length)return;const{messages:$t}=await se.sessions.getMessages(xt[0].id,1);if($t.length){const Je=$t[0],Fe=Je.metadata?.segments;let Et=Je.content;if(Fe&&Fe.length>0){const Nn=[...Fe].reverse().find(ln=>ln.type==="text");Nn&&Nn.type==="text"&&(Et=Nn.content)}const Rn=Et.replace(/<think>[\s\S]*?<\/think>/g,"").replace(/\n+/g," ").trim().slice(0,80);Rn&&dt.push([it.id,Rn])}}catch{}})),!oe){const it=new Map(dt);Ty=it,zt(it)}};Ve();const ze=setInterval(Ve,3e4);return()=>{oe=!0,clearInterval(ze)}},[Mt]);const _t=v.useCallback(()=>{se.teams.list().then(oe=>G(oe.ungrouped)).catch(()=>{})},[]);v.useEffect(()=>{_t()},[_t]),v.useEffect(()=>an.on("*",_t),[_t]),v.useEffect(()=>{if(!Z&&!q&&!V)return;const oe=Ve=>{B(null),X(null),Q(!1)};return setTimeout(()=>document.addEventListener("click",oe),0),()=>document.removeEventListener("click",oe)},[Z,q,V]);const Ct=(oe,Ve)=>{ot(`Delete "${Ve}"?`,"This team will be removed from the database. Check options below to also delete members and disk files.",async ze=>{const dt=ze?.deleteMembers??!0,it=ze?.purgeFiles??!1;await se.teams.delete(oe,dt,{purgeFiles:it}),w(),_t(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Delete Team",[{id:"deleteMembers",label:"Also delete all members in this team",defaultChecked:!0},{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},en=async(oe,Ve)=>{try{const dt=await(Ve==="start"?se.teams.startAll:Ve==="stop"?se.teams.stopAll:Ve==="pause"?se.teams.pauseAll:se.teams.resumeAll)(oe),it=dt.success?.length??0,xt=dt.failed?.length??0,$t={start:"started",stop:"stopped",pause:"paused",resume:"resumed"};xt>0?me(`${Ve}: ${it} succeeded, ${xt} failed`,"error"):it>0&&me(`${it} agent${it>1?"s":""} ${$t[Ve]}`,"success"),N()}catch(ze){me(`Failed to ${Ve}: ${ze instanceof Error?ze.message:String(ze)}`,"error")}},Ht=async(oe,Ve,ze)=>{await se.teams.update(oe,{managerId:Ve,managerType:ze}),w()},Tn=async oe=>{if(!at.trim()){Ue(null);return}await se.teams.update(oe,{name:at.trim()}),Ue(null),w()},wn=async(oe,Ve)=>{Ve==="offline"?await se.agents.start(oe):await se.agents.stop(oe),N()},ye=(oe,Ve)=>{ot("Remove from team?","This member will be moved to Ungrouped.",async()=>{await se.teams.removeMember(oe,Ve),w(),_t()},"Remove")},We=(oe,Ve,ze)=>{ot(`Remove "${Ve}"?`,"This agent will be removed from the database. Check the option below to also delete its workspace, memory, and other files from disk.",async dt=>{{const it=dt?.purgeFiles??!1;await se.agents.remove(oe,{purgeFiles:it})}N(),w(),_t(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Remove",[{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},He=(oe,Ve,ze)=>{yt.current={x:oe.clientX,y:oe.clientY},Ze.current=setTimeout(()=>{jt({agentId:Ve,fromTeamId:ze}),we(!0)},200)},wt=oe=>{if(!yt.current||!Ze.current)return;const Ve=Math.abs(oe.clientX-yt.current.x),ze=Math.abs(oe.clientY-yt.current.y);(Ve>5||ze>5)&&(Dt||(clearTimeout(Ze.current),Ze.current=null))},Tt=async()=>{if(Ze.current&&(clearTimeout(Ze.current),Ze.current=null),yt.current=null,Dt&&st&&re){const oe=re==="_ungrouped"?void 0:re;try{if(st.fromTeamId&&st.fromTeamId!==oe&&await se.teams.removeMember(st.fromTeamId,st.agentId),oe&&oe!==st.fromTeamId){const Ve=n.find(ze=>ze.id===st.agentId);await se.teams.addMember(oe,st.agentId,"agent")}w(),N(),_t()}catch(Ve){me(`Move failed: ${Ve instanceof Error?Ve.message:String(Ve)}`,"error")}}jt(null),Ee(null),we(!1)},tn=v.useMemo(()=>new Map(s.map(oe=>[oe.id,oe])),[s]),nn=v.useMemo(()=>{const oe=new Map,Ve=[];for(const ze of n)if(ze.teamId&&tn.has(ze.teamId)){const dt=oe.get(ze.teamId)??[];dt.push(ze),oe.set(ze.teamId,dt)}else Ve.push(ze);return{byTeam:oe,ungrouped:Ve}},[n,tn]);s.filter(oe=>nn.byTeam.has(oe.id)||oe.members?.length>0).map(oe=>oe.id);const hn=oe=>$(Ve=>{const ze=new Set(Ve);return ze.has(oe)?ze.delete(oe):ze.add(oe),ze}),mn=(oe,Ve)=>{const ze=m==="direct"&&h===oe.id,dt=z.has(oe.id),it=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",$t=(Ve?tn.get(Ve):void 0)?.managerId===oe.id,Je=oe.role?.toLowerCase().replace(/[-_]/g," ").trim(),Fe=oe.name.toLowerCase().trim(),Et=Je&&Je!==Fe,Rn=fn.get(oe.id)||oe.currentActivity?.label?.slice(0,60)||"",Nn=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 ${Dt&&st?.agentId===oe.id?"opacity-40":""}`,onPointerDown:ln=>He(ln,oe.id,Ve),onPointerMove:wt,onPointerUp:Tt,children:t.jsxs("button",{onClick:()=>{Dt||x(oe.id)},onContextMenu:ln=>{R&&(ln.preventDefault(),X({agentId:oe.id,teamId:Ve,x:ln.clientX,y:ln.clientY}))},className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs transition-colors select-none ${T?"":"touch-none"} ${ze?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${ze?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:e_(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}),Et&&t.jsxs("span",{className:"text-[9px] text-fg-tertiary shrink-0 truncate max-w-[60px]",children:["(",oe.role,")"]}),$t&&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"})}),dt&&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:Rn||" "})]}),t.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[oe.mailboxDepth!=null&&oe.mailboxDepth>0&&t.jsx("span",{className:"text-[8px] text-fg-tertiary bg-surface-overlay rounded-full px-1 leading-relaxed",children:oe.mailboxDepth}),t.jsx("span",{title:Nn,onClick:ln=>{ln.stopPropagation(),S(oe.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${it}`})]})]})},oe.id)},On=(oe,Ve,ze,dt)=>{const it=W.has(oe),xt=Dt&&re===oe&&st?.fromTeamId!==oe,$t=oe!=="_ungrouped"?(Nt.byTeam.get(oe)??[])[0]:void 0,Je=$t&&m==="channel"&&f===$t.channelKey;return t.jsxs("div",{className:`mb-1 rounded-lg transition-colors ${xt?"ring-1 ring-brand-500/50 bg-brand-500/5":""}`,onPointerEnter:()=>{Dt&&Ee(oe)},onPointerLeave:()=>{Dt&&re===oe&&Ee(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{$t?g($t.channelKey):hn(oe)},onContextMenu:Fe=>{!R||!Ve||(Fe.preventDefault(),B({teamId:oe,x:Fe.clientX,y:Fe.clientY}))},className:`flex-1 flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors min-w-0 ${Je?"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 ${Je?"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:at,onChange:Fe=>rt(Fe.target.value),onBlur:()=>Tn(oe),onKeyDown:Fe=>{Fe.key==="Enter"&&Tn(oe),Fe.key==="Escape"&&Ue(null)},onClick:Fe=>Fe.stopPropagation(),autoFocus:!0}):t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:dt}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:[ze.length," members"]})]})]}),t.jsx("button",{onClick:()=>hn(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:it?"Expand":"Collapse",children:t.jsx("svg",{className:`w-3 h-3 transition-transform duration-150 ${it?"":"rotate-90"}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})}),R&&Ve&&t.jsx("button",{onClick:Fe=>{Fe.stopPropagation(),B({teamId:oe,x:Fe.clientX,y:Fe.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"})]})})]}),xt&&Dt&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:"Drop here"}),!it&&t.jsx("div",{className:"ml-1",children:ze.map(Fe=>mn(Fe,oe==="_ungrouped"?void 0:oe))})]},oe)},Nt=v.useMemo(()=>{const oe=new Map,Ve=[];for(const ze of c)if(ze.teamId){const dt=oe.get(ze.teamId)??[];dt.push(ze),oe.set(ze.teamId,dt)}else{const dt=s.find(it=>ze.name.toLowerCase().includes(it.name.toLowerCase())||it.name.toLowerCase().includes(ze.name.toLowerCase()));if(dt){const it=oe.get(dt.id)??[];it.push(ze),oe.set(dt.id,it)}else Ve.push(ze)}return{byTeam:oe,unmatched:Ve}},[c,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:k?{display:"none"}:E!=null?{width:E}:void 0,children:[t.jsxs("div",{className:"px-4 h-14 flex items-center border-b border-border-default shrink-0",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Chat"}),t.jsx("div",{className:"ml-auto",children:t.jsx("button",{onClick:Ce,disabled:je,title:Ne?"Resume all agents":"Pause all agents",className:`flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md border transition-colors ${Ne?"bg-green-500/10 border-green-500/30 text-green-500 hover:bg-green-500/20":"bg-amber-500/10 border-amber-500/30 text-amber-600 hover:bg-amber-500/20"} disabled:opacity-50`,children:Ne?t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})," Resume"]}):t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),t.jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]})," Pause"]})})})]}),R&&t.jsx("div",{className:"px-3 pt-2 pb-1 flex items-center gap-1.5",ref:ee,children:t.jsxs("div",{className:"relative flex-1",children:[t.jsxs("button",{onClick:()=>Q(!V),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 ${V?"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"})})]}),V&&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:()=>{Q(!1),Y(!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:()=>{Q(!1),pt.navigate(xe.STORE)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),t.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Add Agent"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Create from templates"})]}),t.jsxs("button",{onClick:()=>{Q(!1),D(!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:()=>{Q(!1),M({})},className:"w-full text-left px-4 py-2.5 text-xs text-green-600 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),t.jsx("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]}),"Add Human"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Add a human team member"})]})]})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[n.length===0&&s.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:"No agents yet"}),Nt.unmatched.map(oe=>t.jsxs("button",{onClick:()=>g(oe.channelKey),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${m==="channel"&&f===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 ${m==="channel"&&f===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 Ve=nn.byTeam.get(oe.id)??[];return Ve.length===0&&(!oe.members||oe.members.length===0)?null:On(oe.id,oe,Ve,oe.name)}),s.filter(oe=>(nn.byTeam.get(oe.id)??[]).length===0&&oe.members&&oe.members.length>0).map(oe=>On(oe.id,oe,[],oe.name)),nn.ungrouped.length>0&&On("_ungrouped",null,nn.ungrouped,"Other"),s.length===0&&n.length>0&&n.map(oe=>mn(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:()=>y(e.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${m==="dm"&&(p===e.id||!p)?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${m==="dm"&&(p===e.id||!p)?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-500"}`,children:e.name[0]?.toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[11px] leading-tight",children:e.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:"My Notes"})]}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),i.filter(oe=>oe.id!==e?.id).map(oe=>t.jsxs("button",{onClick:()=>y(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 ${m==="dm"&&p===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 ${m==="dm"&&p===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"})}),Z&&(()=>{const oe=nn.byTeam.get(Z.teamId)??[],Ve=oe.some(xt=>xt.status==="offline"),ze=oe.some(xt=>xt.status==="idle"||xt.status==="working"),dt=oe.some(xt=>xt.status==="paused"),it=oe.some(xt=>xt.status!=="offline");return t.jsxs("div",{ref:Zt,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:Z.x,top:Z.y},onClick:xt=>xt.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{const xt=tn.get(Z.teamId);xt&&(Ue(Z.teamId),rt(xt.name)),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),"Rename Team"]}),Ve&&t.jsxs("button",{onClick:()=>{en(Z.teamId,"start"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Start All"]}),it&&t.jsxs("button",{onClick:()=>{en(Z.teamId,"stop"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),"Stop All"]}),ze&&t.jsxs("button",{onClick:()=>{en(Z.teamId,"pause"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),t.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}),"Pause All"]}),dt&&t.jsxs("button",{onClick:()=>{en(Z.teamId,"resume"),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-blue-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume All"]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:()=>{B(null),pt.navigate(xe.STORE)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Agent"]}),t.jsxs("button",{onClick:()=>{B(null),M({teamId:Z.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"]}),U.length>0&&t.jsxs("button",{onClick:()=>{B(null),A(Z.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 xt=tn.get(Z.teamId);xt&&Ct(Z.teamId,xt.name),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Delete Team"]})]})})(),q&&(()=>{const oe=n.find(it=>it.id===q.agentId);if(!oe)return null;const ze=(q.teamId?tn.get(q.teamId):void 0)?.managerId===oe.id,dt=oe.id===e?.id;return t.jsxs("div",{ref:Zt,className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44",style:{left:q.x,top:q.y},onClick:it=>it.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{X(null),S(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:()=>{wn(oe.id,"offline"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Start"]}):t.jsxs("button",{onClick:()=>{wn(oe.id,oe.status??"idle"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),"Stop"]}),q.teamId&&!ze&&t.jsxs("button",{onClick:()=>{Ht(q.teamId,oe.id,"agent"),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Set as Manager"]}),q.teamId&&t.jsxs("button",{onClick:()=>{ye(q.teamId,oe.id),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"9 14 4 9 9 4"}),t.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),"Remove from team"]}),s.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary uppercase flex items-center gap-1.5",children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 12h14"}),t.jsx("path",{d:"M12 5l7 7-7 7"})]}),"Move to"]}),s.filter(it=>it.id!==q.teamId).map(it=>t.jsx("button",{onClick:async()=>{q.teamId&&await se.teams.removeMember(q.teamId,oe.id),await se.teams.addMember(it.id,oe.id,"agent"),w(),N(),_t(),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:it.name},it.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!dt&&t.jsxs("button",{onClick:()=>{We(oe.id,oe.name),X(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Remove from org"]})]})})(),F&&t.jsx(WT,{onClose:()=>Y(!1),onCreate:async(oe,Ve)=>{await se.teams.create(oe,Ve),Y(!1),w()}}),P!==null&&t.jsx(ZT,{teamId:P.teamId,teams:s,onClose:()=>M(null),onAdd:async(oe,Ve,ze,dt,it)=>{await se.users.create(oe,Ve,void 0,ze,dt,it),M(null),w()}}),L!==null&&t.jsx(QT,{teamId:L,ungrouped:U,onClose:()=>A(null),onAdd:async(oe,Ve)=>{await se.teams.addMember(L,oe,Ve),A(null),w(),_t()}}),O&&t.jsx(JT,{onClose:()=>D(!1),onConnected:()=>{D(!1),N(),w()}}),Re&&t.jsx(Dj,{title:Re.title,message:Re.message,confirmLabel:Re.confirmLabel,checkboxes:Re.checkboxes,onConfirm:oe=>{Re.onConfirm(oe),Ge(null)},onCancel:()=>Ge(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 n_=50,r_=30;function ea(e,n,s,i){const o=v.useRef(0),d=v.useRef(0),c=v.useCallback(h=>{o.current=h.touches[0].clientX,d.current=h.touches[0].clientY},[]),m=v.useCallback(h=>{const f=h.changedTouches[0].clientX-o.current,p=h.changedTouches[0].clientY-d.current,x=Math.abs(f),g=Math.abs(p);if(x<n_||Math.atan2(g,x)*(180/Math.PI)>r_)return;if(i?.scrollContainerRef?.current){const N=i.scrollContainerRef.current,S=N.scrollLeft<=1,E=N.scrollLeft+N.clientWidth>=N.scrollWidth-1;if(f>0&&!S||f<0&&!E)return}const w=e.findIndex(N=>N.id===n);f<0&&w<e.length-1?s(e[w+1].id):f>0&&w>0?s(e[w-1].id):f>0&&w===0&&i?.onSwipeOutLeft?i.onSwipeOutLeft():f<0&&w===e.length-1&&i?.onSwipeOutRight&&i.onSwipeOutRight()},[e,n,s,i]);return{onTouchStart:c,onTouchEnd:m}}const _y=[{key:"overview",label:"Overview",icon:"▦"},{key:"mind",label:"Mind",icon:"🔮"},{key:"files",label:"Files",icon:"📄"},{key:"tools",label:"Tools",icon:"⚒"},{key:"skills",label:"Skills",icon:"◆"},{key:"memory",label:"Memory",icon:"🧠"},{key:"heartbeat",label:"Heartbeat",icon:"♡"}],s_={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function kd(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function a_({agentId:e,onBack:n,inline:s,defaultTab:i,onSwipeBack:o}){const d=Sr(),[c,m]=v.useState(null),[h,f]=v.useState(i??"overview"),[p,x]=v.useState(null),g=v.useMemo(()=>_y.map(C=>({id:C.key})),[]),y=v.useMemo(()=>({onSwipeOutLeft:o}),[o]),w=ea(g,h,f,y),N=v.useRef(null);v.useEffect(()=>{const C=N.current;if(!C)return;C.querySelector('[data-active="true"]')?.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[h]);const S=v.useCallback(()=>{se.agents.get(e).then(m).catch(()=>{})},[e]);if(v.useEffect(()=>(f(i??"overview"),x(null),S(),se.externalAgents.list().then(k=>{const T=k.agents.find(R=>R.markusAgentId===e);x(T??null)}).catch(()=>{}),an.on("agent:update",k=>{k.payload.agentId===e&&S()})),[e,S]),!c)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading agent..."});const E=s_[c.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:c.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:c.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${E}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:c.state.status}),p&&t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:"External"}),c.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:[c.role,c.roleDescription?` — ${c.roleDescription}`:""]})]}),t.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[t.jsxs("button",{onClick:()=>pt.navigate(xe.TEAM,{agentId:e}),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors flex items-center gap-1",children:[t.jsx("span",{children:"◈"})," Chat"]}),t.jsxs("button",{onClick:async()=>{if(c)try{const{filesMap:C}=await se.agents.getFilesMap(e),k={type:"agent",name:c.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||c.name,displayName:c.name,version:"1.0.0",description:c.roleDescription??c.role,author:"",category:"general",tags:[],agent:{roleName:c.role,agentRole:c.agentRole},dependencies:{skills:c.skills??[]}};await Fn.publishViaProxy({itemType:"agent",name:c.name,description:k.description,category:"general",config:k,files:C}),alert(`Published "${c.name}" to Markus Hub`)}catch(C){alert(`Failed to publish: ${C}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:n,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsx("div",{ref:N,className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto scrollbar-hide",children:_y.filter(C=>!p||["overview","mind"].includes(C.key)).map(C=>t.jsxs("button",{onClick:()=>f(C.key),"data-active":h===C.key,className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${h===C.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:C.icon}),C.label]},C.key))})]}),t.jsxs("div",{className:"p-5",onTouchStart:d?w.onTouchStart:void 0,onTouchEnd:d?w.onTouchEnd:void 0,children:[h==="overview"&&t.jsx(i_,{agent:c,onUpdate:S,externalInfo:p}),h==="mind"&&t.jsx(b_,{agentId:e}),h==="files"&&t.jsx(l_,{agentId:e}),h==="tools"&&t.jsx(d_,{tools:c.tools??[]}),h==="skills"&&t.jsx(u_,{agent:c}),h==="memory"&&t.jsx(f_,{agentId:e}),h==="heartbeat"&&t.jsx(h_,{agentId:e,initialData:c.heartbeat})]})]})}function i_({agent:e,onUpdate:n,externalInfo:s}){const[i,o]=v.useState(!1),[d,c]=v.useState(e.name),[m,h]=v.useState(e.agentRole),[f,p]=v.useState(e.config?.llmConfig?.modelMode??"default"),[x,g]=v.useState(e.config?.llmConfig.primary??""),[y,w]=v.useState(e.config?.llmConfig.fallback??""),[N,S]=v.useState(!1),[E,C]=v.useState({}),[k,T]=v.useState(""),[R,z]=v.useState([]),[U,G]=v.useState(null),[W,$]=v.useState(null),[F,Y]=v.useState([]),[P,M]=v.useState(null),[L,A]=v.useState(null),[O,D]=v.useState("");v.useEffect(()=>{se.settings.getLlm().then(_=>{C(_.providers),T(_.defaultProvider)}).catch(()=>{}),se.tasks.list({assignedAgentId:e.id}).then(_=>z(_.tasks.slice(0,5))).catch(()=>{}),se.usage.agents().then(_=>{const V=_.agents.find(Q=>Q.agentId===e.id);V&&G(V)}).catch(()=>{}),se.agents.getRecentActivities(e.id).then(_=>Y(_.activities)).catch(()=>{}),se.system.storage().then(_=>{D(_.dataDir+"/agents/"+e.id);const V=_.agents.find(Q=>Q.id===e.id);V&&A(V)}).catch(()=>{})},[e.id]);const Z=Object.entries(E).filter(([,_])=>_.configured).map(([_])=>_),B=e.config?.llmConfig?.modelMode??"default",q=async()=>{S(!0);try{await se.agents.updateConfig(e.id,{name:d,agentRole:m,llmConfig:{modelMode:f,primary:f==="custom"?x:k,fallback:y||void 0}}),n(),o(!1)}catch{}S(!1)},X=()=>{e.state.status==="offline"?se.agents.start(e.id).then(n):se.agents.stop(e.id).then(n)},I={pending:"bg-gray-400",assigned:"bg-blue-400",in_progress:"bg-brand-400",completed:"bg-green-400",failed:"bg-red-400",cancelled:"bg-gray-600"};if(s){const _=[{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(En,{title:"Identity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx($n,{label:"Name",children:e.name}),t.jsx($n,{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($n,{label:"Role Template",children:e.role}),t.jsx($n,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx($n,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx($n,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsx(En,{title:"Connection Status",children:t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Zn,{label:"Connection",value:s.connected?"Online":"Offline",color:s.connected?"green":"gray"}),t.jsx(Zn,{label:"Platform",value:"OpenClaw"}),t.jsx(Zn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Zn,{label:"Last Sync",value:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleTimeString():"Never"})]})}),t.jsx(En,{title:"External Agent Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx($n,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx($n,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx($n,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx($n,{label:"Last Heartbeat",children:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleString():"Never"})]})}),t.jsx(En,{title:"Sync Context (received every sync cycle)",children:t.jsx("div",{className:"space-y-1.5",children: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(En,{title:"Gateway API Endpoints",children:t.jsx("div",{className:"space-y-1.5",children:_.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))})}),R.length>0&&t.jsx(En,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>pt.navigate(xe.WORK),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:R.map(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 ${I[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(En,{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:q,disabled:N,className:"text-xs text-brand-500 hover:text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>{o(!0),c(e.name),h(e.agentRole),p(e.config?.llmConfig?.modelMode??"default"),g(e.config?.llmConfig.primary??""),w(e.config?.llmConfig.fallback??"")},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx($n,{label:"Name",children:i?t.jsx("input",{className:"input-sm",value:d,onChange:_=>c(_.target.value)}):e.name}),t.jsx($n,{label:"Agent Role",children:i?t.jsx("div",{className:"flex gap-1.5",children:["worker","manager"].map(_=>t.jsx("button",{onClick:()=>h(_),className:`px-2 py-1 text-[10px] rounded border transition-colors capitalize ${m===_?_==="manager"?"bg-amber-500/15 text-amber-600 border-amber-500/30":"bg-blue-500/15 text-blue-600 border-blue-500/30":"bg-surface-elevated text-fg-tertiary border-border-default"}`,children:_},_))}):t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx($n,{label:"Role Template",children:e.role}),t.jsx($n,{label:"Agent ID",mono:!0,children:e.id}),t.jsx($n,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx($n,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsxs(En,{title:"Runtime Status",children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Zn,{label:"Status",value:e.state.status,color:e.state.status==="idle"?"green":e.state.status==="working"?"blue":e.state.status==="error"?"red":"gray"}),t.jsx(Zn,{label:"Tokens Today",value:String(e.state.tokensUsedToday)}),t.jsx(Zn,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(Zn,{label:"Last Heartbeat",value:e.state.lastHeartbeat?new Date(e.state.lastHeartbeat).toLocaleTimeString():"Never"})]}),e.state.status==="error"&&t.jsxs("div",{className:"mt-3 bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),t.jsx("span",{className:"text-xs font-medium text-red-500",children:"Error Details"}),e.state.lastErrorAt&&t.jsx("span",{className:"text-[10px] text-red-500/50 ml-auto",children:new Date(e.state.lastErrorAt).toLocaleString()})]}),t.jsx("pre",{className:"text-[11px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono bg-red-500/5 rounded p-2",children:e.state.lastError||"Agent encountered an error. Check logs for more details."})]}),e.state.status==="working"&&(e.state.activeTaskIds?.length??0)>0&&t.jsxs("div",{className:"mt-3 bg-brand-500/10 border border-brand-500/20 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-brand-400 animate-pulse"}),t.jsx("span",{className:"text-xs font-medium text-brand-500",children:"Currently Working"}),t.jsxs("span",{className:"text-[10px] text-brand-500/50 ml-auto",children:[e.state.activeTaskIds.length," active task",e.state.activeTaskIds.length>1?"s":""]})]}),t.jsx("div",{className:"space-y-1",children:R.filter(_=>e.state.activeTaskIds?.includes(_.id)).map(_=>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:_.title}),t.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:_.status.replace(/_/g," ")})]},_.id))})]}),t.jsx("div",{className:"flex gap-2 mt-4 pt-3 border-t border-border-default/50",children:t.jsx("button",{onClick:X,className:"px-3 py-1.5 text-xs border border-border-default rounded-lg hover:border-brand-500 transition-colors",children:e.state.status==="offline"?"▶ Start":"⏹ Stop"})})]}),U&&t.jsx(En,{title:"Usage",children:t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Zn,{label:"Total Tokens",value:kd(U.totalTokens)}),t.jsx(Zn,{label:"Requests",value:String(U.requestCount)}),t.jsx(Zn,{label:"Tool Calls",value:String(U.toolCalls)}),t.jsx(Zn,{label:"Prompt Tokens",value:kd(U.promptTokens)}),t.jsx(Zn,{label:"Completion Tokens",value:kd(U.completionTokens)}),t.jsx(Zn,{label:"Est. Cost",value:`$${U.estimatedCost<.01?U.estimatedCost.toFixed(4):U.estimatedCost.toFixed(2)}`})]})}),L&&t.jsxs(En,{title:"Storage",action:t.jsx("button",{onClick:()=>{se.system.openPath(O)},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:Ay(L.size)}),t.jsx("span",{className:"text-xs text-fg-tertiary font-mono truncate",children:O})]}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:L.subItems.filter(_=>_.size>0).map(_=>t.jsx(Zn,{label:_.name,value:Ay(_.size)},_.name))})]}),t.jsx(En,{title:"LLM Configuration",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx($n,{label:"Model Mode",children:i?t.jsx("div",{className:"flex gap-1.5",children:["default","custom"].map(_=>t.jsx("button",{onClick:()=>p(_),className:`px-2.5 py-1 text-[10px] rounded border transition-colors capitalize ${f===_?_==="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:_==="default"?"System Default":"Custom"},_))}):t.jsx("span",{className:`text-xs ${B==="custom"?"text-amber-600":"text-brand-500"}`,children:B==="custom"?"⚙ Custom":"◎ System Default"})}),t.jsx($n,{label:"Primary Model",children:i?f==="custom"?t.jsxs("select",{className:"input-sm",value:x,onChange:_=>g(_.target.value),children:[Z.map(_=>t.jsxs("option",{value:_,children:[_," (",E[_]?.model,")"]},_)),!Z.includes(x)&&x&&t.jsx("option",{value:x,children:x})]}):t.jsxs("span",{className:"text-xs text-fg-secondary italic",children:["follows system default (",k||"...",")"]}):t.jsx("span",{className:"font-mono text-xs",children:B==="custom"?e.config?.llmConfig.primary??"—":t.jsxs("span",{className:"text-fg-secondary",children:[k||e.config?.llmConfig.primary||"—"," ",t.jsx("span",{className:"text-fg-tertiary",children:"(system default)"})]})})}),t.jsx($n,{label:"Fallback",children:i?t.jsxs("select",{className:"input-sm",value:y,onChange:_=>w(_.target.value),children:[t.jsx("option",{value:"",children:"none"}),Z.map(_=>t.jsx("option",{value:_,children:_},_))]}):t.jsx("span",{className:"font-mono text-xs",children:e.config?.llmConfig.fallback??"none"})}),t.jsx($n,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx($n,{label:"Max Tokens/Day",children:e.config?.llmConfig.maxTokensPerDay??"unlimited"})]})}),R.length>0&&t.jsx(En,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>pt.navigate(xe.WORK),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:R.map(_=>{const V=W===_.id,Q=["in_progress","failed","completed","review"].includes(_.status);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>Q?$(V?null:_.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 ${I[_.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:_.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:_.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(Lj,{taskId:_.id,isLive:_.status==="in_progress"})})]},_.id)})})}),F.filter(_=>_.type==="heartbeat").length>0&&t.jsx(En,{title:"Recent Heartbeats",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[F.filter(_=>_.type==="heartbeat").length," runs"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:F.filter(_=>_.type==="heartbeat").map(_=>{const V=P===_.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>M(V?null:_.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:_.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(_.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($d,{agentId:e.id,activityId:_.id})})]},_.id)})})}),F.filter(_=>_.type==="chat").length>0&&t.jsx(En,{title:"Recent A2A Communications",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[F.filter(_=>_.type==="chat").length," conversations"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:F.filter(_=>_.type==="chat").map(_=>{const V=P===_.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>M(V?null:_.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:_.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(_.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($d,{agentId:e.id,activityId:_.id})})]},_.id)})})})]})}function l_({agentId:e}){const[n,s]=v.useState([]),[i,o]=v.useState(!0),[d,c]=v.useState(null),[m,h]=v.useState(""),[f,p]=v.useState(!1),[x,g]=v.useState(!1),[y,w]=v.useState(null),[N,S]=v.useState(!1),[E,C]=v.useState(null),k=v.useCallback(()=>{o(!0),Promise.all([se.agents.getFiles(e),se.agents.roleStatus(e).catch(()=>null)]).then(([Y,P])=>{s(Y.files),w(P),Y.files.length>0&&!d&&(c(Y.files[0].name),h(Y.files[0].content))}).catch(()=>{}).finally(()=>o(!1))},[e]);v.useEffect(()=>{k()},[k]);const T=Y=>{const P=n.find(M=>M.name===Y);P&&(c(Y),h(P.content),g(!1),C(null))},R=async()=>{if(d){p(!0);try{await se.agents.updateFile(e,d,m),s(Y=>Y.map(P=>P.name===d?{...P,content:m}:P)),g(!1),d==="ROLE.md"&&await se.agents.updateSystemPrompt(e,m)}catch{}p(!1)}},z=async Y=>{S(!0);try{await se.agents.roleSync(e,Y?[Y]:void 0),C(null),g(!1),k()}catch{}S(!1)},U=async Y=>{if(E?.file===Y){C(null);return}try{const P=await se.agents.roleDiff(e,Y);P.agentContent!=null&&P.templateContent!=null&&C({file:Y,agent:P.agentContent,template:P.templateContent})}catch{}};if(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading files..."});const G={"ROLE.md":"System Prompt / Role Definition","HEARTBEAT.md":"Heartbeat Tasks","POLICIES.md":"Policies & Guardrails","CONTEXT.md":"Context & Instructions"},W=y?.files.filter(Y=>Y.status==="modified"||Y.status==="added_in_template")??[],$=y?.hasTemplate&&!y.isUpToDate,F=d?W.some(Y=>Y.file===d):!1;return t.jsxs("div",{className:"space-y-4",children:[$&&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:[W.length," file",W.length>1?"s":""," differ from the ",t.jsx("code",{className:"px-1 py-0.5 bg-amber-500/10 rounded text-amber-600",children:y.templateId})," template:"," ",W.map(Y=>Y.file).join(", ")]})]}),t.jsx("button",{onClick:()=>z(),disabled:N,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors shrink-0 disabled:opacity-50",children:N?"Syncing...":"Sync All"})]}),t.jsxs(En,{title:"Agent Configuration Files",action:y?.hasTemplate?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${y.isUpToDate?"bg-green-400":"bg-amber-400"}`}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["Template: ",t.jsx("span",{className:"text-fg-secondary",children:y.templateId}),y.isUpToDate?" (up to date)":" (updates available)"]})]}):t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Custom agent — no linked template"}),children:[t.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:n.map(Y=>{const P=W.some(M=>M.file===Y.name);return t.jsxs("button",{onClick:()=>T(Y.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${d===Y.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[Y.name,P&&t.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},Y.name)})}),d&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary",children:G[d]??d}),t.jsxs("div",{className:"flex gap-2 items-center",children:[F&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>U(d),className:"px-2.5 py-1 text-[11px] text-amber-600 hover:text-amber-600 border border-amber-500/30 hover:border-amber-500/50 rounded-lg transition-colors",children:E?.file===d?"Hide Diff":"View Diff"}),t.jsx("button",{onClick:()=>z(d),disabled:N,className:"px-2.5 py-1 text-[11px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:N?"Syncing...":"Sync This File"})]}),x&&t.jsx("span",{className:"text-[10px] text-amber-600",children:"unsaved"}),t.jsx("button",{onClick:R,disabled:f||!x,className:`px-3 py-1 text-xs rounded-lg transition-colors ${x?"bg-brand-600 hover:bg-brand-500 text-white":"bg-surface-elevated text-fg-tertiary cursor-default"}`,children:f?"Saving...":"Save"})]})]}),E?.file===d&&t.jsxs("div",{className:"mb-3 border border-border-default rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"grid grid-cols-2 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-elevated/80",children:[t.jsx("div",{className:"px-3 py-2 border-r border-border-default",children:"Current (Agent)"}),t.jsxs("div",{className:"px-3 py-2",children:["Template (",y?.templateId,")"]})]}),t.jsxs("div",{className:"grid grid-cols-2 max-h-60 overflow-y-auto",children:[t.jsx("pre",{className:"px-3 py-2 text-[11px] font-mono text-red-500/70 bg-red-500/5 border-r border-border-default whitespace-pre-wrap break-words overflow-x-hidden",children: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:m,onChange:Y=>{h(Y.target.value),g(!0)},className:"w-full h-80 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none",spellCheck:!1}),d==="ROLE.md"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-2",children:"Changes to ROLE.md will update the agent's runtime system prompt immediately."})]}),n.length===0&&t.jsx(al,{text:"No configuration files found for this role"})]})]})}const o_={Files:["file_read","file_write","file_edit","apply_patch"],Search:["grep_search","glob_find","list_directory"],Runtime:["shell_execute","background_exec","process"],Web:["web_search","web_fetch","web_extract"],Tasks:["task_create","task_list","task_update","task_get","task_assign","task_note","task_comment","task_submit_review","subtask_create","subtask_complete","subtask_list","task_check_duplicates","task_cleanup_duplicates","task_board_health"],Requirements:["requirement_propose","requirement_list","requirement_update_status","requirement_comment"],Projects:["list_projects","get_project","project_info"],Deliverables:["deliverable_create","deliverable_search","deliverable_list","deliverable_update"],Communication:["agent_send_message","agent_list_colleagues","agent_send_group_message","agent_create_group_chat","agent_list_group_chats","agent_broadcast_status","agent_delegate_task"],Memory:["memory_save","memory_search","memory_list","memory_update_longterm"],Planning:["todo_write","todo_read"],"Team (Manager)":["team_list","team_status","delegate_message","create_task"],Subagents:["spawn_subagent","spawn_subagents"],LLM:["llm_list_providers","llm_switch_model","llm_switch_default_provider","llm_add_provider","llm_edit_provider","llm_add_model"]};function c_(e){const n=new Map,s=new Set;for(const[d,c]of Object.entries(o_)){const m=e.filter(h=>c.some(f=>h.name.startsWith(f)));m.length>0&&(n.set(d,m),m.forEach(h=>s.add(h.name)))}const i=e.filter(d=>!s.has(d.name));for(const d of i){const c=d.name.indexOf("__");if(c>0){const h=`MCP: ${d.name.slice(0,c)}`;n.has(h)||n.set(h,[]),n.get(h).push(d),s.add(d.name)}}const o=e.filter(d=>!s.has(d.name));return o.length>0&&n.set("Other",o),[...n.entries()].map(([d,c])=>({category:d,tools:c}))}function d_({tools:e}){const n=c_(e);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[e.length," tools registered"]}),n.map(s=>t.jsx(En,{title:s.category,children:t.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.tools.map(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 u_({agent:e}){const n=e.proficiency??{},[s,i]=v.useState(null),[o,d]=v.useState(null),[c,m]=v.useState(!1),h=e.availableSkills??[],f=new Map;for(const N of h){const S=N.category||"custom";f.has(S)||f.set(S,[]),f.get(S).push(N)}const p=async N=>{if(s===N){i(null),d(null);return}i(N),m(!0);try{const S=await fetch(`/api/skills/${encodeURIComponent(N)}`);if(S.ok){const E=await S.json();d(E.skill)}else d(null)}catch{d(null)}m(!1)},x={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",productivity:"bg-amber-500/15 text-amber-600",browser:"bg-blue-500/15 text-blue-600",custom:"bg-gray-500/15 text-fg-secondary",platform:"bg-purple-500/15 text-purple-500"},g=N=>{const S=n[N.name],E=S&&S.uses>0?Math.round(S.successes/S.uses*100):null,C=s===N.name;return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-lg border cursor-pointer transition-all ${C?"bg-brand-500/10 border-brand-500/40":"bg-surface-elevated/30 border-border-default/30 hover:border-gray-600/50"}`,onClick:()=>p(N.name),children:[t.jsx("span",{className:`text-sm transition-transform ${C?"rotate-90":""}`,children:"▶"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:N.name}),N.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-green-500/15 text-green-500",children:"always-on"}),N.builtIn&&!N.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-surface-overlay/40 text-fg-tertiary",children:"built-in"}),!N.builtIn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-brand-500/15 text-brand-400",children:"installed"})]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 truncate",children:N.description}),S&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[S.uses," uses · ",S.successes," successes",S.lastUsed&&` · last ${new Date(S.lastUsed).toLocaleDateString()}`]})]}),E!==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 ${E>=80?"bg-green-400":E>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${E}%`}})}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[E,"%"]})]})]}),C&&t.jsx("div",{className:"ml-6 mt-1 mb-2 p-4 bg-surface-elevated/30 rounded-lg border border-border-default/20 space-y-3",children:c?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading skill details…"}):o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${x[o.category]??x.custom}`,children:o.category}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",o.version]}),o.author&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",o.author]}),o.requiredPermissions?.map(k=>t.jsx("span",{className:"px-1.5 py-0.5 bg-amber-500/10 text-amber-600 text-[10px] rounded",children:k},k))]}),o.description&&t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:o.description}),o.tags&&o.tags.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:o.tags.map(k=>t.jsxs("span",{className:"px-1.5 py-0.5 bg-surface-overlay/40 text-fg-tertiary text-[10px] rounded",children:["#",k]},k))}),(o.toolDetails??o.tools??[]).length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"text-[10px] text-fg-tertiary font-semibold uppercase tracking-wider mb-2",children:["Tools (",(o.toolDetails??o.tools??[]).length,")"]}),t.jsx("div",{className:"space-y-1.5",children:(o.toolDetails??o.tools??[]).map(k=>t.jsxs("div",{className:"px-3 py-2 bg-surface-secondary/50 rounded border border-border-default/20",children:[t.jsx("div",{className:"text-xs font-medium text-brand-500",children:k.name}),k.description&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:k.description})]},k.name))})]})]}):t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Skill details not available (skill may not be registered in the store)"})})]},N.name)},y=["development","productivity","browser","communication","devops","data","platform","custom"],w=[...f.entries()].sort((N,S)=>{const E=y.indexOf(N[0]),C=y.indexOf(S[0]);return(E===-1?999:E)-(C===-1?999:C)});return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[h.length," skills installed — descriptions auto-injected into agent context"]})}),w.map(([N,S])=>t.jsx(En,{title:t.jsxs("span",{className:"capitalize",children:[N," ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",S.length,")"]})]}),children:t.jsx("div",{className:"space-y-2",children:S.map(E=>g(E))})},N)),h.length===0&&t.jsx(al,{text:"No skills installed"})]})}function f_({agentId:e}){const[n,s]=v.useState(null),[i,o]=v.useState(!0),[d,c]=v.useState("entries"),[m,h]=v.useState(!1),[f,p]=v.useState(""),[x,g]=v.useState(!1),[y,w]=v.useState(""),[N,S]=v.useState(!1),[E,C]=v.useState(null),[k,T]=v.useState(null),[R,z]=v.useState([]),[U,G]=v.useState(!1),W=v.useCallback(()=>{o(!0),se.agents.getMemory(e).then(P=>{s(P),p(P.recentDailyLogs??""),w(P.longTermMemory??"")}).catch(()=>{}).finally(()=>o(!1))},[e]);v.useEffect(()=>{W()},[W]);const $=async()=>{S(!0),await se.agents.updateDailyMemory(e,f).catch(()=>{}),S(!1),h(!1),W()},F=async()=>{S(!0),await se.agents.updateLongTermMemory(e,"User-edited",y).catch(()=>{}),S(!1),g(!1),W()};if(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading memory..."});if(!n)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Failed to load memory data"});const Y=[{key:"entries",label:`Recent (${n.entries.length})`},{key:"sessions",label:`Sessions (${n.sessions.length})`},{key:"daily",label:"Daily Logs"},{key:"longterm",label:"Long-term"}];return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex gap-2",children:Y.map(P=>t.jsx("button",{onClick:()=>c(P.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${d===P.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:P.label},P.key))}),d==="entries"&&t.jsx(En,{title:"Recent Memory Entries",children:n.entries.length===0?t.jsx(al,{text:"No memory entries"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.entries.map((P,M)=>{const L=E===M;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>C(L?null:M),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 ${P.type==="fact"?"bg-blue-500/15 text-blue-600":P.type==="task"?"bg-green-500/15 text-green-600":P.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:P.type}),t.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${L?"":"line-clamp-2"}`,children:P.content}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[P.importance!=null&&t.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${P.importance>=7?"bg-red-500/15 text-red-500":P.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",P.importance]}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date(P.timestamp).toLocaleTimeString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:L?"▲":"▼"})]})]}),L&&t.jsxs("div",{className:"mx-3 mt-1 mb-2 p-3 bg-surface-elevated/30 rounded-lg border border-border-default/20",children:[t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed break-words",children:P.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: ",P.type]}),P.importance!=null&&t.jsxs("span",{children:["Importance: ",P.importance]}),t.jsx("span",{children:new Date(P.timestamp).toLocaleString()})]})]})]},M)})})}),d==="sessions"&&t.jsx(En,{title:"Chat Sessions",children:n.sessions.length===0?t.jsx(al,{text:"No sessions"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.sessions.map(P=>{const M=k===P.id,L=async()=>{if(M){T(null),z([]);return}T(P.id),G(!0);try{const A=await se.agents.getMemorySession(e,P.id);z(A.messages)}catch{z([])}G(!1)};return t.jsxs("div",{children:[t.jsxs("button",{onClick:L,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg bg-surface-elevated/20 hover:bg-surface-elevated/40 transition-colors cursor-pointer text-left",children:[t.jsx("div",{className:"text-xs text-fg-secondary font-mono flex-1 truncate",children:P.id}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[P.messageCount," msgs"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(P.updatedAt).toLocaleDateString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:M?"▲":"▼"})]}),M&&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:U?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading messages..."}):R.length===0?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"No messages in this session"}):(()=>{const A=new Map;for(const O of R)O.role==="tool"&&O.toolCallId&&A.set(O.toolCallId,O.content);return t.jsx("div",{className:"divide-y divide-gray-700/30",children:R.filter(O=>O.role!=="tool").map((O,D)=>t.jsxs("div",{className:"px-3 py-2",children:[(O.role==="user"||O.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 ${O.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:O.role}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(tr,{content:O.content,className:"text-xs text-fg-secondary"})})]}),O.role==="assistant"&&t.jsxs("div",{className:"space-y-1",children:[O.content&&t.jsxs("div",{children:[t.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 bg-green-500/15 text-green-600",children:"assistant"}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(tr,{content:O.content,className:"text-xs text-fg-secondary"})})]}),O.toolCalls&&O.toolCalls.length>0&&t.jsx("div",{className:"space-y-0.5",children:O.toolCalls.map(Z=>{let B;try{B=JSON.parse(Z.arguments)}catch{}const q={tool:Z.name,status:"done",args:B,result:A.get(Z.id)};return t.jsx(Oj,{entry:{type:"tool",info:q}},Z.id)})})]})]},D))})})()})]},P.id)})})}),d==="daily"&&t.jsx(En,{title:"Daily Logs",action:m?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>h(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:$,disabled:N,className:"text-xs text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>h(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:m?t.jsx("textarea",{value:f,onChange:P=>p(P.target.value),className:"w-full h-64 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none"}):n.recentDailyLogs?t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed bg-surface-elevated/30 rounded-lg p-4 max-h-96 overflow-y-auto",children:n.recentDailyLogs}):t.jsx(al,{text:"No daily logs"})}),d==="longterm"&&t.jsx(En,{title:"Long-term Memory",action:x?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>g(!1),className:"text-xs text-fg-tertiary",children:"Cancel"}),t.jsx("button",{onClick:F,disabled:N,className:"text-xs text-brand-500",children:N?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>g(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:x?t.jsx("textarea",{value:y,onChange:P=>w(P.target.value),className:"w-full h-64 bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none"}):n.longTermMemory?t.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed bg-surface-elevated/30 rounded-lg p-4 max-h-96 overflow-y-auto",children:n.longTermMemory}):t.jsx(al,{text:"No long-term memory stored"})})]})}function h_({agentId:e,initialData:n}){const[s,i]=v.useState(n??null),[o,d]=v.useState(!n),[c,m]=v.useState([]),[h,f]=v.useState(null),[p,x]=v.useState(!1),[g,y]=v.useState(null),w=v.useCallback(()=>{se.agents.getHeartbeat(e).then(i).catch(()=>{}),se.agents.getRecentActivities(e).then(C=>{m(C.activities.filter(k=>k.type==="heartbeat"))}).catch(()=>{})},[e]);v.useEffect(()=>{d(!0),w(),d(!1)},[w]),v.useEffect(()=>an.on("agent:update",k=>{k.payload?.agentId===e&&w()}),[e,w]);const N=async()=>{x(!0),y(null);try{const C=await se.agents.triggerHeartbeat(e);y(C.message),setTimeout(()=>y(null),4e3),setTimeout(w,2e3)}catch(C){y(String(C).replace("Error: ",""))}x(!1)};if(o)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading heartbeat data..."});if(!s)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"No heartbeat data available"});const S=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 k=Date.now()-new Date(C).getTime();if(k<0){const T=Math.abs(k);return T<6e4?`in ${Math.ceil(T/1e3)}s`:T<36e5?`in ${Math.ceil(T/6e4)}m`:`in ${(T/36e5).toFixed(1)}h`}return k<6e4?`${Math.floor(k/1e3)}s ago`:k<36e5?`${Math.floor(k/6e4)}m ago`:`${(k/36e5).toFixed(1)}h ago`};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(En,{title:"Heartbeat Scheduler",action:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:w,className:"text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Refresh"}),t.jsx("button",{onClick:N,disabled:p||!s.running,className:"text-[10px] px-2.5 py-1 rounded-md bg-blue-600/20 text-blue-600 hover:bg-blue-600/30 border border-blue-500/30 transition-colors disabled:opacity-40",children:p?"Triggering...":"Trigger Now"})]}),children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(Zn,{label:"Status",value:s.running?"Running":"Stopped",color:s.running?"green":"gray"}),t.jsx(Zn,{label:"Interval",value:S(s.intervalMs)??"—"}),t.jsx(Zn,{label:"Last Run",value:s.lastHeartbeat?E(s.lastHeartbeat)??"—":"Never"}),t.jsx(Zn,{label:"Next Run",value:s.nextRunAt?E(s.nextRunAt)??"—":s.running?"Pending":"—"})]}),g&&t.jsx("div",{className:"mt-3 text-[11px] text-blue-600 bg-blue-500/10 border border-blue-500/20 rounded-lg px-3 py-2",children:g})]}),s.lastSummary&&t.jsx(En,{title:"Last Heartbeat Summary",action:s.lastSummaryAt?t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(s.lastSummaryAt).toLocaleString()}):void 0,children:t.jsx("div",{className:"bg-surface-primary/50 rounded-lg px-4 py-3",children:t.jsx(tr,{content:s.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),c.length>0?t.jsx(En,{title:"Recent Runs",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[c.length," runs this session"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:[...c].reverse().map(C=>{const k=h===C.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>f(k?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 ${k?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 4.5l3 3 3-3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})]}),k&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx($d,{agentId:e,activityId:C.id})})]},C.id)})})}):s.lastHeartbeat?null:t.jsx(En,{title:"Recent Runs",children:t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx("div",{className:"text-xl mb-2 opacity-40",children:"♡"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No heartbeat runs yet this session."}),t.jsx("p",{className:"text-[10px] text-fg-tertiary mt-1",children:s.running?`First heartbeat will trigger in ~${S(s.intervalMs-s.uptimeMs%s.intervalMs)??"soon"}.`:"Heartbeat scheduler is stopped."}),s.running&&t.jsx("button",{onClick:N,disabled:p,className:"mt-3 text-[10px] px-3 py-1.5 rounded-md bg-blue-600/15 text-blue-600 hover:bg-blue-600/25 border border-blue-500/25 transition-colors disabled:opacity-40",children:p?"Triggering...":"Run First Heartbeat Now"})]})})]})}function Lj({taskId:e,isLive:n}){const[s,i]=v.useState([]),[o,d]=v.useState(""),[c,m]=v.useState(!0),[h,f]=v.useState("compact");if(v.useEffect(()=>{m(!0),d(""),se.tasks.getLogs(e).then(g=>{i(g.logs),m(!1)}).catch(()=>m(!1))},[e]),v.useEffect(()=>{if(!n)return;const g=an.on("task:log",w=>{const N=w.payload;if(N.taskId!==e)return;const S={id:N.id,taskId:N.taskId,agentId:N.agentId,seq:N.seq,type:N.logType,content:N.content,metadata:N.metadata,createdAt:N.createdAt};i(E=>S.id&&E.some(C=>C.id===S.id)?E:[...E,S]),S.type==="text"&&d("")}),y=an.on("task:log:delta",w=>{const N=w.payload;N.taskId===e&&d(S=>S+N.text)});return()=>{g(),y()}},[e,n]),c)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0&&!o)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No execution logs yet."});const p=s.map(g=>um(g)),x=new Set(p.filter(g=>g.executionRound!=null).map(g=>g.executionRound)).size>1;return t.jsx("div",{className:"px-3 py-2",children:h==="compact"?t.jsx(yx,{entries:p,streamingText:o,isActive:n,onExpand:()=>f("full"),showRounds:x}):t.jsx(vx,{entries:p,streamingText:o,isActive:n,onCollapse:()=>f("compact"),showRounds:x})})}function $d({agentId:e,activityId:n}){const[s,i]=v.useState([]),[o,d]=v.useState(!0),[c,m]=v.useState("compact");if(v.useEffect(()=>{d(!0),se.agents.getActivityLogs(e,n).then(f=>{i(f.logs),d(!1)}).catch(()=>d(!1))},[e,n]),o)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No activity logs available."});const h=s.map(f=>tk(f,n,e)).filter(f=>f!==null);return t.jsx("div",{className:"px-3 py-2",children:c==="compact"?t.jsx(yx,{entries:h,isActive:!1,onExpand:()=>m("full")}):t.jsx(vx,{entries:h,isActive:!1,onCollapse:()=>m("compact")})})}function En({title:e,action:n,children:s}){return t.jsxs("div",{className:"bg-surface-secondary/60 border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:e}),n]}),s]})}function $n({label:e,mono:n,children:s}){return t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-xs text-fg-secondary ${n?"font-mono text-[10px]":""}`,children:s})]})}function Zn({label:e,value:n,color:s}){const i=s==="green"?"text-green-600":s==="blue"?"text-blue-500":s==="indigo"?"text-brand-500":s==="red"?"text-red-500":"text-fg-secondary";return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-lg font-semibold ${i}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function al({text:e}){return t.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:e})}function Ay(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}const My={0:"Critical",1:"High",2:"Normal",3:"Low",4:"Background"},Oy={0:"text-red-400",1:"text-amber-400",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},m_={pick:"bg-brand-500/20 text-brand-300",continue:"bg-gray-500/20 text-gray-300",preempt:"bg-amber-500/20 text-amber-300",merge:"bg-blue-500/20 text-blue-300",defer:"bg-purple-500/20 text-purple-300",delegate:"bg-green-500/20 text-green-300",drop:"bg-red-500/20 text-red-300"},x_={idle:"bg-green-500/20 text-green-300",focused:"bg-brand-500/20 text-brand-300",deciding:"bg-amber-500/20 text-amber-300"},Uh={system_event:"⚙",human_chat:"💬",task_comment:"💬",mention:"@",session_reply:"↩",task_status_update:"📋",a2a_message:"🔗",review_request:"👀",requirement_update:"📝",daily_report:"📊",heartbeat:"♡",memory_consolidation:"🧠"},p_=[{key:"all",label:"All"},{key:"interaction",label:"Interaction"},{key:"task",label:"Task"},{key:"notification",label:"Notification"},{key:"system",label:"System"}],g_={completed:"bg-green-500",processing:"bg-brand-400 animate-pulse",deferred:"bg-purple-400",merged:"bg-blue-400",queued:"bg-amber-400",dropped:"bg-red-500"};function b_({agentId:e}){const[n,s]=v.useState(null),[i,o]=v.useState(null),[d,c]=v.useState(!0),[m,h]=v.useState("all"),[f,p]=v.useState(null),[x,g]=v.useState(!0),y=50,w=v.useCallback(async(S=!0)=>{S&&c(!0);try{const E=m==="all"?void 0:m,[C,k]=await Promise.all([se.agents.getMindState(e),se.agents.getMailbox(e,{limit:y,category:E})]);s(C),o(k),g((k.history?.length??0)>=y)}catch{}c(!1)},[e,m]),N=v.useCallback(async()=>{if(!i)return;const S=m==="all"?void 0:m;try{const E=await se.agents.getMailbox(e,{limit:y,offset:i.history.length,category:S});o(C=>C?{...C,history:[...C.history,...E.history]}:E),g((E.history?.length??0)>=y)}catch{}},[e,i,m]);return v.useEffect(()=>{p(null),w()},[w]),v.useEffect(()=>{const S=an.on("agent:mailbox",k=>{k.payload.agentId===e&&w(!1)}),E=an.on("agent:decision",k=>{k.payload.agentId===e&&w(!1)}),C=an.on("agent:attention",k=>{k.payload.agentId===e&&w(!1)});return()=>{S(),E(),C()}},[e,w]),d&&!n?t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:"Loading agent mind state..."}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsx("span",{className:`px-2.5 py-1 text-xs font-medium rounded-full ${x_[n?.attentionState??"idle"]??"bg-gray-500/20 text-gray-300"}`,children:(n?.attentionState??"idle").toUpperCase()}),n?.currentFocus?t.jsxs("span",{className:"text-sm text-fg-secondary",children:[Uh[n.currentFocus.type]??"●"," ",t.jsx("span",{className:"text-fg-primary font-medium",children:n.currentFocus.label}),t.jsxs("span",{className:"text-fg-tertiary ml-2 text-xs",children:["since ",new Date(n.currentFocus.startedAt).toLocaleTimeString()]})]}):t.jsx("span",{className:"text-sm text-fg-tertiary",children:"Idle — waiting for new mail"}),t.jsx("button",{onClick:()=>w(),className:"ml-auto text-xs text-fg-tertiary hover:text-fg-secondary",children:"↻ Refresh"})]}),(n?.queuedItems?.length??0)>0&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("h4",{className:"text-xs font-medium text-amber-400 uppercase tracking-wider mb-1.5",children:["Queue (",n.queuedItems.length,")"]}),t.jsx("div",{className:"space-y-1",children:n.queuedItems.map((S,E)=>t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded bg-amber-500/5 border border-amber-500/20 text-sm",children:[t.jsx("span",{className:"text-fg-tertiary w-4 text-right text-xs",children:E+1}),t.jsx("span",{className:"text-sm",children:Uh[S.sourceType]??"●"}),t.jsx("span",{className:`text-[10px] ${Oy[S.priority]??"text-fg-tertiary"}`,children:My[S.priority]??`P${S.priority}`}),t.jsx("span",{className:"text-fg-secondary truncate flex-1 text-xs",children:S.summary}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(S.queuedAt).toLocaleTimeString()})]},S.id))})]})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:"Mailbox History"}),t.jsx("div",{className:"flex gap-1 ml-auto flex-wrap",children:p_.map(S=>t.jsx("button",{onClick:()=>h(S.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors ${m===S.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:S.label},S.key))})]}),(!i?.history||i.history.length===0)&&!d&&t.jsx("div",{className:"text-center text-fg-tertiary text-sm py-8",children:"No mailbox history yet"}),t.jsx("div",{className:"space-y-1",children:i?.history?.map(S=>{const E=f===S.id,C=Uh[S.sourceType]??"●",k=S.payload?.summary??S.id,T=S.payload?.content,R=S.metadata?.senderName,z=S.metadata?.senderRole;return t.jsxs("div",{className:"bg-surface-2 rounded-lg border border-border-subtle",children:[t.jsxs("button",{className:"w-full px-3 py-2.5 flex items-start gap-2 text-left hover:bg-surface-3/50 transition-colors rounded-lg",onClick:()=>p(E?null:S.id),children:[t.jsx("span",{className:"text-xs mt-0.5 text-fg-tertiary",children:E?"▾":"▸"}),t.jsx("span",{className:`w-2 h-2 mt-1.5 rounded-full shrink-0 ${g_[S.status]??"bg-gray-400"}`}),t.jsx("span",{className:"text-sm",children:C}),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 ${E?"":"truncate"}`,children:k}),t.jsx("span",{className:`text-[10px] shrink-0 ${Oy[S.priority]??"text-fg-tertiary"}`,children:My[S.priority]??""})]}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2 flex-wrap",children:[t.jsx("span",{children:new Date(S.queuedAt).toLocaleString()}),S.completedAt&&t.jsxs("span",{children:["→ ",new Date(S.completedAt).toLocaleTimeString()]}),S.activity&&t.jsxs(t.Fragment,{children:[S.activity.totalTokens>0&&t.jsxs("span",{children:[kd(S.activity.totalTokens)," tokens"]}),S.activity.totalTools>0&&t.jsxs("span",{children:[S.activity.totalTools," tools"]})]})]})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-3 px-1.5 py-0.5 rounded shrink-0",children:S.sourceType})]}),E&&t.jsxs("div",{className:"border-t border-border-subtle px-3 py-3 space-y-3",children:[(T||R)&&t.jsxs("div",{className:"space-y-1.5",children:[R&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:["From: ",t.jsx("span",{className:"text-fg-secondary",children:R}),z&&t.jsxs("span",{className:"text-fg-tertiary",children:[" (",z,")"]})]}),T&&T!==k&&t.jsx("div",{className:"text-xs text-fg-secondary bg-surface-primary/50 rounded-md p-2.5 whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:T})]}),S.decisions&&S.decisions.length>0&&t.jsxs("div",{children:[t.jsx("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:"Decisions"}),t.jsx("div",{className:"space-y-1",children:S.decisions.map(U=>t.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded shrink-0 ${m_[U.decisionType]??"bg-gray-500/20 text-gray-300"}`,children:U.decisionType}),t.jsx("span",{className:"text-fg-secondary flex-1",children:U.reasoning}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:new Date(U.createdAt).toLocaleTimeString()})]},U.id))})]}),S.activity?t.jsxs("div",{children:[t.jsxs("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:["Activity — ",S.activity.label,t.jsx("span",{className:`ml-2 inline-block px-1 py-0 rounded text-[9px] ${S.activity.success?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:S.activity.success?"✓ Success":"✗ Failed"})]}),S.activity.type==="task"&&S.payload?.taskId?t.jsx(Lj,{taskId:S.payload.taskId,isLive:!S.activity.endedAt}):t.jsx($d,{agentId:e,activityId:S.activity.id})]}):S.status==="processing"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2 animate-pulse",children:"Processing..."}):S.status==="completed"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2",children:"No activity log recorded"}):null]})]},S.id)})}),x&&(i?.history?.length??0)>0&&t.jsx("div",{className:"text-center mt-3",children:t.jsx("button",{onClick:N,className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:"Load Earlier..."})})]})]})}const y_=[{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:"⚙"}],Ry={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function v_({teamId:e,onBack:n,inline:s}){const[i,o]=v.useState(null),[d,c]=v.useState("overview"),[m,h]=v.useState(""),[f,p]=v.useState(""),[x,g]=v.useState(!1),[y,w]=v.useState(!1),[N,S]=v.useState(""),[E,C]=v.useState(""),[k,T]=v.useState(!1),[R,z]=v.useState(!1),[U,G]=v.useState(""),[W,$]=v.useState(""),[F,Y]=v.useState(!1),[P,M]=v.useState([]),L=v.useRef(null),A=v.useCallback(async()=>{try{const _=(await se.teams.list()).teams.find(Q=>Q.id===e);_&&o(_);const V=await se.teams.status(e);M(V.agents)}catch{}},[e]),O=v.useCallback(async()=>{try{const I=await se.teams.getFile(e,"ANNOUNCEMENT.md");h(I.content)}catch{h("")}try{const I=await se.teams.getFile(e,"NORMS.md");p(I.content)}catch{p("")}},[e]);v.useEffect(()=>{c("overview"),A(),O()},[e,A,O]);const D=async(I,_)=>{T(!0);try{await se.teams.updateFile(e,I,_),I==="ANNOUNCEMENT.md"?(h(_),g(!1)):(p(_),w(!1))}catch{}T(!1)},Z=async()=>{U.trim()&&(await se.teams.update(e,{name:U.trim()}),z(!1),A())},B=async()=>{await se.teams.update(e,{description:W}),Y(!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 q=i.members.find(I=>I.agentRole==="manager"),X=P.filter(I=>I.status!=="offline").length;return t.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[t.jsxs("div",{className:"px-5 py-3.5 border-b border-border-default bg-surface-secondary sticky top-0 z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-white flex items-center justify-center text-lg font-bold shrink-0",children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h2",{className:"text-base font-semibold",children: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:[X," 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:I}=await se.teams.getFilesMap(i.id),_=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:_.map(Q=>({name:Q.name,roleName:Q.role,role:Q.agentRole??"worker",count:1,skills:[]}))}};await Fn.publishViaProxy({itemType:"team",name:i.name,description:i.description??"",category:"general",config:V,files:I}),alert(`Published "${i.name}" to Markus Hub`)}catch(I){alert(`Failed to publish: ${I}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:n,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]}),t.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:y_.map(I=>t.jsxs("button",{onClick:()=>c(I.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${d===I.key?"bg-surface-primary text-fg-primary border border-border-default border-b-gray-950":"text-fg-tertiary hover:text-fg-secondary"}`,children:[I.icon," ",I.label]},I.key))})]}),t.jsxs("div",{className:"p-5",children:[d==="overview"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Manager"}),t.jsx("div",{className:"text-sm font-medium",children:q?.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})]})]}),m.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:[m.slice(0,500),m.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(I=>{const _=P.find(Q=>Q.id===I.id),V=Ry[_?.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:I.name}),t.jsx("span",{className:"text-fg-tertiary",children:I.role}),I.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-amber-500/15 text-amber-600 rounded",children:"Manager"})]},I.id)})})]})]}),d==="members"&&t.jsxs("div",{className:"space-y-3",children:[i.members.map(I=>{const _=P.find(Q=>Q.id===I.id),V=Ry[_?.status??"offline"]??"bg-gray-500";return t.jsxs("div",{className:"p-3 bg-surface-secondary rounded-xl border border-border-default flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-surface-elevated flex items-center justify-center text-sm font-bold shrink-0",children:I.name.charAt(0)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:I.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${V}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:_?.status??"offline"}),I.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I.role," · ",I.type]})]})]},I.id)}),i.members.length===0&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]}),d==="announcements"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Announcements"}),!x&&t.jsx("button",{onClick:()=>{S(m),g(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),x?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:N,onChange:I=>S(I.target.value),className:"w-full h-64 bg-surface-secondary border border-border-default rounded-xl p-3 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500 font-mono",placeholder:"Write team announcements here (Markdown supported)..."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>D("ANNOUNCEMENT.md",N),disabled:k,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:k?"Saving...":"Save"}),t.jsx("button",{onClick:()=>g(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsx("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default min-h-[120px]",children:m.trim()?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:m}):t.jsx("div",{className:"text-sm text-fg-tertiary italic",children:"No announcements yet. Click Edit to add."})})]}),d==="norms"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Working Norms"}),!y&&t.jsx("button",{onClick:()=>{C(f),w(!0)},className:"px-3 py-1 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Edit"})]}),y?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:E,onChange:I=>C(I.target.value),className:"w-full h-64 bg-surface-secondary border border-border-default rounded-xl p-3 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500 font-mono",placeholder:"Define team norms and working agreements (Markdown supported)..."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>D("NORMS.md",E),disabled:k,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:k?"Saving...":"Save"}),t.jsx("button",{onClick:()=>w(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsx("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default min-h-[120px]",children:f.trim()?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:f}):t.jsx("div",{className:"text-sm text-fg-tertiary italic",children:"No norms defined yet. Click Edit to add."})})]}),d==="settings"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team Name"}),R?t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("input",{ref:L,value:U,onChange:I=>G(I.target.value),onKeyDown:I=>I.key==="Enter"&&Z(),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:Z,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:()=>z(!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:()=>{G(i.name),z(!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"}),F?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:W,onChange:I=>$(I.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500",rows:3,autoFocus:!0}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:B,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),t.jsx("button",{onClick:()=>Y(!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:()=>{$(i.description??""),Y(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(j_,{teamId:e,teamName:i.name,onDeleted:n})]})]})]})}function j_({teamId:e,teamName:n,onDeleted:s}){const[i,o]=v.useState(!1),[d,c]=v.useState(!1),[m,h]=v.useState(!1),[f,p]=v.useState(!1);return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-red-900/30 space-y-3",children:[t.jsx("div",{className:"text-sm font-medium text-red-500",children:"Danger Zone"}),i?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',n,'"? This removes the team record from the database.']}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:m,onChange:x=>h(x.target.checked),className:"rounded"}),"Also delete all members in this team"]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:d,onChange:x=>c(x.target.checked),className:"rounded"}),"Also delete disk files (workspace, memory, logs)"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:f,onClick:async()=>{p(!0);try{await se.teams.delete(e,m,{purgeFiles:d}),window.dispatchEvent(new CustomEvent("markus:data-changed")),s()}catch{p(!1)}},className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50",children:f?"Deleting...":"Confirm Delete"}),t.jsx("button",{onClick:()=>o(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors border border-border-default",children:"Cancel"})]})]}):t.jsx("button",{onClick:()=>o(!0),className:"px-4 py-1.5 text-xs bg-red-600/20 hover:bg-red-600/30 text-red-500 rounded-lg transition-colors border border-red-500/30",children:"Delete Team"})]})}function su({side:e,defaultWidth:n,minWidth:s,maxWidth:i,collapsedWidth:o=0,storageKey:d}){const[c,m]=v.useState(()=>{try{const y=localStorage.getItem(`${d}_w`);if(y)return Math.max(s,Math.min(i,parseInt(y,10)))}catch{}return n}),[h,f]=v.useState(()=>{try{return localStorage.getItem(`${d}_c`)==="1"}catch{return!1}}),p=v.useRef(!1);v.useEffect(()=>{try{localStorage.setItem(`${d}_w`,String(c))}catch{}},[c,d]),v.useEffect(()=>{try{localStorage.setItem(`${d}_c`,h?"1":"0")}catch{}},[h,d]);const x=v.useCallback(y=>{y.preventDefault(),p.current=!0;const w=y.clientX,N=c,S=C=>{if(!p.current)return;const k=e==="left"?C.clientX-w:w-C.clientX;m(Math.max(s,Math.min(i,N+k)))},E=()=>{p.current=!1,document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",E),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",S),document.addEventListener("mouseup",E),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e,s,i]),g=v.useCallback(()=>f(y=>!y),[]);return{width:h?o:c,rawWidth:c,collapsed:h,toggle:g,setCollapsed:f,onResizeStart:x}}function Dy(e){const n={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:new Date(e.createdAt).toLocaleTimeString(),agentId:e.role!=="user"?e.agentId:void 0};return e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(n.segments=e.metadata.segments.map((s,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("⚠"))&&(n.isError=!0),e.metadata?.isStopped&&(n.isStopped=!0),e.metadata?.images?.length&&(n.images=e.metadata.images),n}function po(e){const n=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),s={id:e.id,sender:e.senderType==="human"?"user":"agent",text:e.text,time:new Date(e.createdAt).toLocaleTimeString(),agentName:e.senderType!=="human"?e.senderName:void 0,agentId:e.senderType!=="human"?e.senderId:void 0,isError:n};if(e.metadata&&e.senderType==="agent"){const i=[],o=e.metadata;if(o.thinking?.length&&i.push({type:"text",content:"",thinking:o.thinking.join(`
51
-
52
- `)}),o.toolCalls?.length)for(let d=0;d<o.toolCalls.length;d++){const c=o.toolCalls[d];i.push({type:"tool",key:`${c.tool}_${d}`,tool:c.tool,status:c.status==="error"?"error":"done",args:c.arguments,result:c.result,durationMs:c.durationMs})}i.length>0&&(i.push({type:"text",content:e.text}),s.segments=i)}return s}function Ij(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function w_({name:e,agentId:n,agents:s,onViewProfile:i}){const[o,d]=v.useState(!1),c=v.useRef(null),m=n?s.find(h=>h.id===n):s.find(h=>h.name===e);return v.useEffect(()=>{if(!o)return;const h=f=>{c.current&&!c.current.contains(f.target)&&d(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o]),m?t.jsxs("span",{ref:c,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>d(!o),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),o&&t.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600",children:Ij(m.name)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:m.name}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[m.role," · ",m.agentRole??"worker"]})]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${m.status==="working"?"bg-blue-400 animate-pulse":m.status==="error"?"bg-red-400":"bg-green-400"}`})]}),t.jsx("button",{onClick:()=>{d(!1),i?.(m.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 N_({agent:e,anchorRect:n,onClose:s,onViewProfile:i}){const o=v.useRef(null);v.useEffect(()=>{const m=h=>{o.current&&!o.current.contains(h.target)&&s()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[s]);const d=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",c=e.status==="idle"?"Online":e.status==="working"?"Working":e.status==="error"?"Error":e.status==="paused"?"Paused":"Offline";return t.jsxs("div",{ref:o,className:"fixed z-50 w-64 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:n.top+40,left:n.left},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-brand-500/15 flex items-center justify-center text-sm font-bold text-brand-600",children: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 ${d}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:c}),e.agentRole&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),t.jsx("button",{onClick:()=>{s(),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 Ly(e){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let s="";const i=n.match(/\{[\s\S]*\}/);if(i)try{const o=JSON.parse(i[0]);s=o.error?.message??o.message??""}catch{}if(!s){const o=n.lastIndexOf(": ");o>=0&&(s=n.slice(o+2).trim())}return n.includes("402")||/insufficient.?balance/i.test(n)?`⚠ AI service error: ${s||"Insufficient credits"}. Please top up the API balance or contact your administrator.`:n.includes("401")||/unauthorized|invalid.?api.?key/i.test(n)?`⚠ AI service authentication failed: ${s||"Invalid API key"}. Please check the configuration.`:n.includes("429")||/rate.?limit/i.test(n)?`⚠ Rate limit exceeded: ${s||"Too many requests"}. Please wait a moment and try again.`:n.includes("503")||/service.?unavailable/i.test(n)?`⚠ AI service unavailable: ${s||"Service temporarily down"}. Please try again later.`:`⚠ AI service error: ${s||n.slice(0,120)}`}function Iy({msg:e,onCopy:n,onRetry:s,onReply:i,isCopied:o}){const d=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),c=e.isStopped;return t.jsxs("div",{className:"flex items-center gap-0.5 mt-1",children:[t.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:"Copy",children:[o?t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),o?"Copied":"Copy"]}),c&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:"Re-ask",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Re-ask"]}),d&&!c&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:"Retry",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),"Retry"]}),!d&&!c&&e.sender==="agent"&&s&&t.jsxs("button",{onClick:()=>s(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:"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"]}),i&&t.jsxs("button",{onClick:()=>i(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:"Reply",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"9 17 4 12 9 7"}),t.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),"Reply"]})]})}function k_(e,n){if(!e)return[];const s=[];let i=0;const o=new Date().toISOString(),d=n??"";for(const c of e)c.type==="tool"?(s.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:d,seq:i++,type:"tool_start",content:c.tool,metadata:{arguments:c.args},createdAt:o}),c.status!=="running"&&s.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:d,seq:i++,type:"tool_end",content:c.tool,metadata:{arguments:c.args,result:c.result,error:c.error,durationMs:c.durationMs,success:c.status!=="error"},createdAt:o})):c.content&&s.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:d,seq:i++,type:"text",content:c.content,createdAt:o});return s}function S_({msg:e,isStreaming:n,liveActivities:s,onViewModeChange:i}){const o=e.segments,d=e.isStopped,[c,m]=v.useState("compact"),h=v.useCallback(p=>{m(p),i?.(p)},[i]);if(o!==void 0){const p=o.some(C=>C.type==="tool"),x=k_(o,e.agentId),g=n?o.filter(C=>C.type==="text").map(C=>C.content).join("").slice(-200):void 0,y=o.filter(C=>C.type==="text"),w=n?null:y.map(C=>C.content).join(""),N=!n&&y.length>0?y[y.length-1].content:null,S=c==="compact"?N:w,E=[];if(c==="compact")for(const C of o){if(C.type!=="tool")continue;const k=Cj(C.tool,C.result);if(k){E.push({key:`task-${k.taskId}`,kind:"task",info:k});continue}const T=Ej(C.tool,C.result);T&&E.push({key:`req-${T.requirementId}`,kind:"req",info:T})}return t.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-hidden",children:[(p||n)&&(c==="compact"?t.jsx(yx,{entries:x,streamingText:g,isActive:n,onExpand:()=>h("full"),embedded:!0}):t.jsx(vx,{entries:x,streamingText:g,isActive:n,onCollapse:()=>h("compact"),embedded:!0})),c==="compact"&&E.map(C=>C.kind==="task"?t.jsx(Aj,{info:C.info},C.key):t.jsx(Mj,{info:C.info},C.key)),c==="compact"&&S&&t.jsx(tr,{content:S}),d&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:"Stopped"})]})]})}const f=(e.activities?.length??0)>0;return t.jsxs(t.Fragment,{children:[(n||f)&&t.jsx(PT,{activities:n?s:e.activities??[],isActive:n,persistent:!n&&f}),e.text?t.jsx(tr,{content:e.text}):null,d&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:"Stopped"})]})]})}const Am=new Set;function C_(){return window.location.hash}function E_(e){return Am.add(e),()=>{Am.delete(e)}}typeof window<"u"&&window.addEventListener("hashchange",()=>Am.forEach(e=>e()));function zy({initialAgentId:e,authUser:n}={}){const[s,i]=v.useState([]),[o,d]=v.useState([]),c=Sr(),m=v.useSyncExternalStore(E_,C_),h=c&&(m.startsWith(`#${xe.TEAM}/`)||m.startsWith("#chat/")),f=v.useCallback(()=>{window.location.hash=`${xe.TEAM}/d`},[]);v.useEffect(()=>{if(!c)return;const ne=()=>{g.current==="profile"&&x("chat")};return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[c]);const[p,x]=v.useState("chat"),g=v.useRef("chat");g.current=p;const y=su({side:"left",defaultWidth:224,minWidth:160,maxWidth:360,storageKey:"markus_chat_sidebar"}),[w,N]=v.useState(null),[S,E]=v.useState(),C=v.useCallback(ne=>{E(ne),x("profile"),c&&history.pushState({mobileProfile:!0},"",window.location.hash)},[c]),k=[{id:"chat"},{id:"profile"}],T=v.useCallback(ne=>{ne==="profile"?C():g.current==="profile"?history.back():x("chat")},[C]),R=ea(k,p,T),z=v.useCallback((ne,K)=>{G("direct"),$(ne),C(K?.tab),N(null)},[C]),[U,G]=v.useState(()=>e?"direct":localStorage.getItem("markus_chat_mode")??"direct"),[W,$]=v.useState(()=>e??localStorage.getItem("markus_chat_agent")??""),[F,Y]=v.useState(()=>localStorage.getItem("markus_chat_channel")??"#general"),[P,M]=v.useState(""),L=v.useRef(new Map),A=v.useRef(new Map),O=v.useRef(new Set),D=v.useRef(""),[Z,B]=v.useState([]),[q,X]=v.useState(""),[I,_]=v.useState(null),[V,Q]=v.useState(!1),[ee,te]=v.useState([]),[ae,me]=v.useState(!1),[Ne,Ie]=v.useState(!1),[je,Te]=v.useState([]),Ce=v.useRef(null),Re=v.useRef(null),Ge="__new_chat__",[ot,st]=v.useState([]),[jt,re]=v.useState(null),[Ee,Ze]=v.useState(!1),[yt,Dt]=v.useState([]),we=v.useRef(new Map),Le=v.useRef(new Map),Ue=v.useRef(null),at=v.useRef(null),rt=v.useRef(null),Zt=v.useRef(null),[fn,zt]=v.useState([]),[Mt,_t]=v.useState([]),[Ct,en]=v.useState([]),[Ht,Tn]=v.useState([]),[wn,ye]=v.useState(null),[We,He]=v.useState(!1),[wt,Tt]=v.useState(""),[tn,nn]=v.useState(!1),[hn,mn]=v.useState(""),[On,Nt]=v.useState(0),oe=U==="channel"?fn.find(ne=>ne.channelKey===F)?.teamId:void 0,Ve=v.useRef(null),ze=v.useRef(null),dt=v.useRef(null),it=v.useRef(void 0),xt=v.useRef(!1),$t=v.useRef(!0);v.useEffect(()=>{if(!Ee)return;const ne=K=>{at.current&&!at.current.contains(K.target)&&Ue.current&&!Ue.current.contains(K.target)&&Ze(!1)};return document.addEventListener("mousedown",ne),()=>document.removeEventListener("mousedown",ne)},[Ee]);const Je=(ne,K)=>{if(!K||ne===K)return`notes:${ne}`;const[le,he]=[ne,K].sort();return`dm:${le}:${he}`},Fe=(ne,K,le,he)=>ne==="channel"?`ch:${le}`:ne==="dm"?`dm:${he??""}`:K||"_direct",Et=v.useCallback((ne,K)=>{const le=K(L.current.get(ne)??[]);L.current.set(ne,le),D.current===ne&&B(le)},[]),Rn=(ne,K)=>{const le=[...A.current.get(ne)??[],K];A.current.set(ne,le),D.current===ne&&te(le)};v.useEffect(()=>{localStorage.setItem("markus_chat_mode",U)},[U]),v.useEffect(()=>{localStorage.setItem("markus_chat_agent",W)},[W]),v.useEffect(()=>{localStorage.setItem("markus_chat_channel",F)},[F]);const Nn=v.useCallback(()=>se.agents.list().then(ne=>i(ne.agents)).catch(()=>{}),[]),ln=v.useCallback(()=>se.teams.list().then(ne=>_t(ne.teams)).catch(()=>{}),[]);v.useEffect(()=>{Nn(),se.users.list().then($e=>d($e.users)).catch(()=>{}),se.tasks.list().then($e=>Tn($e.tasks)).catch(()=>{}),ln(),se.externalAgents.list().then($e=>en($e.agents)).catch(()=>{}),fetch("/api/group-chats").then($e=>$e.json()).then($e=>zt($e.chats)).catch(()=>{});const ne=setInterval(Nn,8e3),K=setInterval(ln,15e3),le=an.on("agent:update",Nn),he=an.on("*",ln),Me=an.on("chat:group_created",()=>{fetch("/api/group-chats").then($e=>$e.json()).then($e=>zt($e.chats)).catch(()=>{})}),Be=()=>{Nn(),ln()};return window.addEventListener("markus:data-changed",Be),()=>{clearInterval(ne),clearInterval(K),le(),he(),Me(),window.removeEventListener("markus:data-changed",Be)}},[]),v.useEffect(()=>{const ne=he=>{const Me=he.detail;if(Qs(Me.page)===xe.TEAM){if(Me.params?.agentId){if(Me.params.profileTab)z(Me.params.agentId,{tab:Me.params.profileTab});else if(G("direct"),$(Me.params.agentId),Me.params.sessionId){const Be=Me.params.sessionId;setTimeout(async()=>{try{const{sessions:$e}=await se.sessions.listByAgent(Me.params.agentId,20),Ke=$e.find(Se=>Se.id===Be);Ke&&fr(Ke)}catch{}},300)}}Me.params?.selectAgent&&z(Me.params.selectAgent),Me.params?.prefillMessage&&(X(Me.params.prefillMessage),setTimeout(()=>Re.current?.focus(),100)),Me.params?.openHire}},K=localStorage.getItem("markus_nav_agentId");if(K){localStorage.removeItem("markus_nav_agentId");const he=localStorage.getItem("markus_nav_profileTab");he?(localStorage.removeItem("markus_nav_profileTab"),z(K,{tab:he})):(G("direct"),$(K))}const le=localStorage.getItem("markus_nav_selectAgent");return le&&(localStorage.removeItem("markus_nav_selectAgent"),z(le)),window.addEventListener("markus:navigate",ne),()=>window.removeEventListener("markus:navigate",ne)},[]);const ve=v.useRef(!1);v.useEffect(()=>{const ne=ze.current;if(!ne)return;const K=()=>ne.scrollHeight-ne.scrollTop-ne.clientHeight<80,le=()=>{ve.current=!0},he=()=>{ve.current&&K()?(ve.current=!1,$t.current=!0):ve.current&&($t.current=!1)};return ne.addEventListener("wheel",le,{passive:!0}),ne.addEventListener("touchmove",le,{passive:!0}),ne.addEventListener("scroll",he,{passive:!0}),()=>{ne.removeEventListener("wheel",le),ne.removeEventListener("touchmove",le),ne.removeEventListener("scroll",he)}},[]),v.useLayoutEffect(()=>{if(xt.current){xt.current=!1;return}$t.current&&Ve.current?.scrollIntoView({behavior:"instant"})},[Z,ee]);const Xe=v.useRef(null);v.useEffect(()=>{p==="chat"?requestAnimationFrame(()=>{const ne=ze.current;ne&&(Xe.current!=null?(ne.scrollTop=Xe.current,Xe.current=null):$t.current&&Ve.current?.scrollIntoView({behavior:"instant"}))}):Xe.current=ze.current?.scrollTop??null},[p]),v.useEffect(()=>{const ne=()=>{Qs(window.location.hash.slice(1).split("/")[0])===xe.TEAM&&g.current==="chat"&&requestAnimationFrame(()=>{Ve.current?.scrollIntoView({behavior:"instant"})})};return window.addEventListener("hashchange",ne),window.addEventListener("markus:navigate",ne),()=>{window.removeEventListener("hashchange",ne),window.removeEventListener("markus:navigate",ne)}},[]);const At=v.useCallback(async ne=>{const K=`ch:${ne}`;try{const le=await se.channels.getMessages(ne,50),he=le.messages.map(po);L.current.set(K,he),D.current===K&&(B(he),me(le.hasMore),rt.current=le.messages[0]?new Date(le.messages[0].createdAt).toISOString():null)}catch{D.current===K&&(B([]),me(!1))}},[]),St=v.useCallback(async(ne,K)=>{Zt.current=ne;try{const le=await se.sessions.getMessages(ne,50),he=le.messages.map(Dy);L.current.set(K,he),D.current===K&&Zt.current===ne&&(B(he),me(le.hasMore),rt.current=le.messages[0]?new Date(le.messages[0].createdAt).toISOString():null)}catch{D.current===K&&Zt.current===ne&&(B([]),me(!1),rt.current=null)}},[]),xn=v.useCallback(async ne=>{if(!ne)return st([]),[];try{const{sessions:K}=await se.sessions.listByAgent(ne,10);return st(K),K}catch{return st([]),[]}},[]),Qn=v.useCallback(async()=>{if(!(Ne||!ae||!rt.current)){Ie(!0);try{const ne=D.current;if(U==="channel"||U==="dm"){const K=U==="dm"?Je(n?.id??"",P):F,le=await se.channels.getMessages(K,50,rt.current),he=le.messages.map(po);xt.current=!0,B(Me=>{const Be=[...he,...Me];return L.current.set(ne,Be),Be}),me(le.hasMore),le.messages[0]&&(rt.current=new Date(le.messages[0].createdAt).toISOString())}else if(jt){const K=await se.sessions.getMessages(jt,50,rt.current),le=K.messages.map(Dy);xt.current=!0,B(he=>{const Me=[...le,...he];return L.current.set(ne,Me),Me}),me(K.hasMore),K.messages[0]&&(rt.current=new Date(K.messages[0].createdAt).toISOString())}}catch{}finally{Ie(!1)}}},[Ne,ae,U,F,jt,n?.id,P]);v.useEffect(()=>{const ne=Fe(U,W,F,P),K=D.current;D.current=ne,K&&K!==ne&&(we.current.set(K,yt),Le.current.set(K,jt));const le=L.current.get(ne),he=A.current.get(ne)??[],Me=O.current.has(ne);te(he),Q(Me),U==="direct"&&W&&xn(W);const Be=we.current.get(ne),$e=Le.current.get(ne);if(Be&&Be.length>0&&Dt(Be),Ze(!1),le!==void 0)B(le),me(!1),$e!==void 0&&re($e),(!Be||Be.length===0)&&Dt([]);else if(B([]),me(!1),rt.current=null,U==="channel"||U==="dm"){const Ke=U==="dm"?Je(n?.id??"",P):F;At(Ke),(!Be||Be.length===0)&&Dt([])}else U==="direct"&&W&&xn(W).then(Ke=>{if(D.current===ne)if(Ke.length>0){const Se=Be&&Be.length>0?Be:Ke.slice(0,5),et=$e!==void 0?$e:Se[0].id,bt=et&&Se.some(Vt=>Vt.id===et)?et:Se[0].id;re(bt),Dt(Se),St(bt,ne)}else{re(null),(!Be||Be.length===0)&&Dt([]);const Se=(()=>{const et=(navigator.language||"").toLowerCase();return et.startsWith("zh")?"介绍一下你自己":et.startsWith("ja")?"自己紹介をしてください":et.startsWith("ko")?"자기소개를 해주세요":et.startsWith("fr")?"Présentez-vous":et.startsWith("de")?"Stell dich vor":et.startsWith("es")?"Preséntate":et.startsWith("pt")?"Apresente-se":et.startsWith("ru")?"Представьтесь":"Introduce yourself"})();setTimeout(()=>it.current?.(Se),150)}})},[U,W,F,P]),v.useEffect(()=>U!=="channel"?void 0:an.on("chat:message",K=>{const le=K.payload,he=le.channel??"";if(!he||he!==F)return;const Me=le.senderType??"agent",Be=le.text??le.message??"",$e=le.senderId??le.agentId??"",Ke=le.senderName??le.agentId??"Agent",Se=le.metadata,et={id:`ws_${Date.now()}_${$e}`,sender:Me==="human"?"user":"agent",text:Be,time:new Date().toLocaleTimeString(),agentName:Me==="agent"?Ke:void 0,agentId:Me==="agent"?$e:void 0};if(Se&&Me==="agent"){const Vt=[];if(Se.thinking?.length&&Vt.push({type:"text",content:"",thinking:Se.thinking.join(`
53
-
54
- `)}),Se.toolCalls?.length)for(let rn=0;rn<Se.toolCalls.length;rn++){const pn=Se.toolCalls[rn];Vt.push({type:"tool",key:`${pn.tool}_${rn}`,tool:pn.tool,status:pn.status==="error"?"error":"done",args:pn.arguments,result:pn.result,durationMs:pn.durationMs})}Vt.length>0&&(Vt.push({type:"text",content:Be}),et.segments=Vt)}const bt=Fe("channel",W,F,P);Et(bt,Vt=>[...Vt,et])}),[U,F,W,P,Et]),v.useEffect(()=>an.on("chat:proactive_message",K=>{const le=K.payload,he=le.agentId??"",Me=le.agentName??"Agent",Be=le.message??"",$e=le.sessionId??"";if(!(!he||!Be)&&U==="direct"&&W===he){const Ke={id:`proactive_${Date.now()}`,sender:"agent",text:Be,time:new Date().toLocaleTimeString(),agentName:Me,agentId:he},Se=Fe("direct",he,F,P);Et(Se,et=>[...et,Ke]),$e&&jt!==$e&&re($e)}}),[U,W,F,P,jt,Et]),Ht.find(ne=>ne.id===wn),v.useEffect(()=>{ye(null)},[W]);const lr=ne=>KT(ne),on=()=>{dt.current?.abort(),dt.current=null;const ne=D.current;O.current.delete(ne),A.current.delete(ne),Q(!1),te([])},ur=async ne=>{const K=(ne??q).trim();if(!K&&je.length===0||U==="direct"&&!W)return;if($t.current=!0,ve.current=!1,V){dt.current?.abort(),dt.current=null;const $e=D.current;O.current.delete($e),A.current.delete($e),Et($e,Ke=>{const Se=[...Ke];for(let et=Se.length-1;et>=0;et--)if(Se[et].sender==="agent"&&!Se[et].isStopped&&!Se[et].isError){const bt=Se[et],Vt=(bt.segments??[]).map(rn=>rn.type==="tool"&&rn.status==="running"?{...rn,status:"stopped"}:rn);Se[et]={...bt,isStopped:!0,segments:Vt};break}return Se}),Q(!1),te([]),await new Promise(Ke=>setTimeout(Ke,50))}const le=je.length>0?je.map($e=>$e.dataUrl):void 0,he=Fe(U,W,F,P),Me=I;ne||(X(""),Re.current&&(Re.current.style.height="auto")),Te([]),nn(!1),_(null);const Be=U==="dm";if(O.current.add(he),A.current.set(he,[]),D.current===he&&!Be&&(Q(!0),te([])),U==="dm"){const $e=Je(n?.id??"",P),Ke=`opt_${Date.now()}`,Se={id:Ke,sender:"user",text:K,time:new Date().toLocaleTimeString()};Me&&(Se.replyToId=Me.id,Se.replyToSender=Me.sender,Se.replyToText=Me.text),Et(he,et=>[...et,Se]);try{const et=await se.channels.sendMessage($e,{text:K,senderName:n?.name??"You",senderId:n?.id,mentions:[],orgId:"default",humanOnly:!0});Et(he,bt=>{const Vt=bt.filter(pn=>pn.id!==Ke),rn=[];return et.userMessage&&rn.push(po(et.userMessage)),rn.length>0?[...Vt,...rn]:bt})}catch(et){Et(he,bt=>[...bt,{id:`err_${Date.now()}`,sender:"agent",text:`Error: ${String(et)}`,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}O.current.delete(he),D.current===he&&Q(!1)}else if(U==="channel"){const $e=`opt_${Date.now()}`,Ke={id:$e,sender:"user",text:K,time:new Date().toLocaleTimeString()};Me&&(Ke.replyToId=Me.id,Ke.replyToSender=Me.sender,Ke.replyToText=Me.text),Et(he,Se=>[...Se,Ke]);try{const Se=lr(K),et=Se.length>0?s.find(Vt=>Vt.name.toLowerCase()===Se[0].toLowerCase()):null,bt=await se.channels.sendMessage(F,{text:K,senderName:n?.name??"You",mentions:Se,senderId:n?.id,targetAgentId:et?.id,orgId:"default"});Et(he,Vt=>{const rn=Vt.filter(ct=>ct.id!==$e),pn=[];return bt.userMessage&&pn.push(po(bt.userMessage)),bt.agentMessage&&pn.push(po(bt.agentMessage)),pn.length>0?[...rn,...pn]:Vt})}catch(Se){const et=Ly(Se)||`Error: ${String(Se)}`;Et(he,bt=>[...bt,{id:`err_${Date.now()}`,sender:"agent",text:et,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}O.current.delete(he),D.current===he&&Q(!1)}else{const $e=`a_${Date.now()}`,Ke={id:`u_${Date.now()}`,sender:"user",text:K,time:new Date().toLocaleTimeString()};le?.length&&(Ke.images=le),Me&&(Ke.replyToId=Me.id,Ke.replyToSender=Me.sender,Ke.replyToText=Me.text),Et(he,ct=>[...ct,Ke,{id:$e,sender:"agent",text:"",time:new Date().toLocaleTimeString(),segments:[]}]);const Se=ct=>{Et(he,ht=>{const ut=[...ht],tt=ut.findIndex(qa=>qa.id===$e);if(tt<0)return ht;const Qe=ut[tt].segments??[],Ye=Qe[Qe.length-1];let mt,Gt=ct;const Bn=ct.match(/<think>([\s\S]*?)<\/think>/);Bn&&(mt=(Ye?.type==="text"?Ye.thinking??"":"")+Bn[1],Gt=ct.replace(/<think>[\s\S]*?<\/think>/,""));const aa=Ye?.type==="text"?[...Qe.slice(0,-1),{type:"text",content:Ye.content+Gt,thinking:mt??Ye.thinking}]:[...Qe,{type:"text",content:Gt,thinking:mt}];return ut[tt]={...ut[tt],text:ut[tt].text+Gt,segments:aa},ut})},et=ct=>{(ct.phase==="start"||ct.phase==="end")&&Rn(he,{...ct,phase:ct.phase,ts:Date.now()}),ct.phase==="start"?Et(he,ht=>{const ut=[...ht],tt=ut.findIndex(mt=>mt.id===$e);if(tt<0)return ht;const Qe=[...ut[tt].segments??[]];let Ye=!1;if(ct.arguments)for(let mt=Qe.length-1;mt>=0;mt--){const Gt=Qe[mt];if(Gt.type==="tool"&&Gt.tool===ct.tool&&Gt.status==="running"){Qe[mt]={...Gt,args:ct.arguments},Ye=!0;break}}if(!Ye){const mt=`${ct.tool}_${Date.now()}`;Qe.push({type:"tool",key:mt,tool:ct.tool,status:"running",args:ct.arguments})}return ut[tt]={...ut[tt],segments:Qe},ut}):ct.phase==="output"?Et(he,ht=>{const ut=[...ht],tt=ut.findIndex(Ye=>Ye.id===$e);if(tt<0)return ht;const Qe=[...ut[tt].segments??[]];for(let Ye=Qe.length-1;Ye>=0;Ye--){const mt=Qe[Ye];if(mt.type==="tool"&&mt.tool===ct.tool&&mt.status==="running"){Qe[Ye]={...mt,liveOutput:(mt.liveOutput??"")+(ct.output??"")};break}}return ut[tt]={...ut[tt],segments:Qe},ut}):ct.phase==="subagent_progress"&&ct.subagentEvent?Et(he,ht=>{const ut=[...ht],tt=ut.findIndex(Ye=>Ye.id===$e);if(tt<0)return ht;const Qe=[...ut[tt].segments??[]];for(let Ye=Qe.length-1;Ye>=0;Ye--){const mt=Qe[Ye];if(mt.type==="tool"&&(mt.tool==="spawn_subagent"||mt.tool==="spawn_subagents")&&mt.status==="running"){Qe[Ye]={...mt,subagentLogs:[...mt.subagentLogs??[],ct.subagentEvent]};break}}return ut[tt]={...ut[tt],segments:Qe},ut}):Et(he,ht=>{const ut=[...ht],tt=ut.findIndex(Ye=>Ye.id===$e);if(tt<0)return ht;const Qe=[...ut[tt].segments??[]];for(let Ye=Qe.length-1;Ye>=0;Ye--){const mt=Qe[Ye];if(mt.type==="tool"&&mt.tool===ct.tool&&mt.status==="running"){Qe[Ye]={...mt,status:ct.success===!1?"error":"done",args:ct.arguments,result:ct.result,error:ct.error,durationMs:ct.durationMs,liveOutput:void 0};break}}return ut[tt]={...ut[tt],segments:Qe},ut})},bt=new AbortController;dt.current=bt;try{const ct=jt===Ge?null:jt,ht=await se.agents.messageStream(W,K,Se,et,bt.signal,le,ct);D.current===he&&(ht.sessionId&&(re(ht.sessionId),Dt(ut=>ut.map(tt=>tt.id===Ge?{...tt,id:ht.sessionId}:tt))),xn(W).then(ut=>{if(D.current===he&&(st(ut),ht.sessionId)){const tt=ut.find(Qe=>Qe.id===ht.sessionId);tt&&Dt(Qe=>Qe.some(mt=>mt.id===tt.id)?Qe.map(mt=>mt.id===tt.id?tt:mt):[tt,...Qe.filter(mt=>mt.id!==Ge)])}}))}catch(ct){const ht=ct?.sessionId;ht&&U==="direct"&&D.current===he&&(re(ht),Dt(tt=>tt.map(Qe=>Qe.id===Ge?{...Qe,id:ht}:Qe)),xn(W).then(tt=>{if(D.current!==he)return;st(tt);const Qe=tt.find(Ye=>Ye.id===ht);Qe&&Dt(Ye=>Ye.some(Gt=>Gt.id===Qe.id)?Ye.map(Gt=>Gt.id===Qe.id?Qe:Gt):[Qe,...Ye])}));const ut=Ly(ct);ut?Et(he,tt=>{const Qe=[...tt],Ye=Qe.findIndex(mt=>mt.id===$e);if(Ye>=0){const mt=Qe[Ye].segments??[];Qe[Ye]={...Qe[Ye],text:ut,isError:!0,segments:[...mt,{type:"text",content:ut}]}}return Qe}):Et(he,tt=>{const Qe=[...tt],Ye=Qe.findIndex(mt=>mt.id===$e);if(Ye>=0){const mt=Qe[Ye];if(!(mt.text||mt.segments&&mt.segments.length>0&&mt.segments.some(Bn=>Bn.type==="text"&&Bn.content||Bn.type==="tool")))return tt.filter(Bn=>Bn.id!==$e);Qe[Ye]={...mt,isStopped:!0}}return Qe})}Et(he,ct=>{const ht=[...ct],ut=ht.findIndex(tt=>tt.id===$e);if(ut>=0){const tt=(ht[ut].segments??[]).map(Qe=>Qe.type==="tool"&&Qe.status==="running"?{...Qe,status:"stopped"}:Qe);ht[ut]={...ht[ut],segments:tt}}return ht}),bt.signal.aborted&&Et(he,ct=>{const ht=[...ct],ut=ht.findIndex(tt=>tt.id===$e);if(ut>=0){const tt=ht[ut];if(!(tt.text||tt.segments&&tt.segments.length>0&&tt.segments.some(Ye=>Ye.type==="text"&&Ye.content||Ye.type==="tool")))return ct.filter(Ye=>Ye.id!==$e);ht[ut]={...tt,isStopped:!0}}return ht});const rn=(L.current.get(he)??[]).find(ct=>ct.id===$e),pn=jt&&jt!==Ge?jt:null;rn&&!rn.text&&U==="direct"&&pn&&!bt.signal.aborted&&(async(ht,ut)=>{for(let tt=0;tt<ht;tt++){await new Promise(Qe=>setTimeout(Qe,ut));try{const Ye=(await se.sessions.getMessages(pn,2)).messages.find(mt=>mt.role==="assistant");if(Ye?.content){Et(he,mt=>{const Gt=[...mt],Bn=Gt.findIndex(aa=>aa.id===$e);return Bn>=0&&(Gt[Bn]={...Gt[Bn],text:Ye.content,segments:[{type:"text",content:Ye.content}]}),Gt});return}}catch{}}})(5,3e3)}dt.current=null,O.current.delete(he),A.current.delete(he),D.current===he&&(Q(!1),te([]))};it.current=ur;const[Jr,de]=v.useState(null),[Ae,qe]=v.useState(new Set),Bt=v.useCallback(ne=>{const K=ne.segments?ne.segments.filter(le=>le.type==="text").map(le=>le.content).join(`
55
- `):ne.text;navigator.clipboard.writeText(K),de(ne.id),setTimeout(()=>de(le=>le===ne.id?null:le),2e3)},[]),xr=v.useCallback(ne=>{const K=D.current,le=L.current.get(K)??Z,he=le.findIndex(Se=>Se.id===ne.id);if(he<0)return;let Me=null;for(let Se=he-1;Se>=0;Se--)if(le[Se]?.sender==="user"){Me=le[Se];break}const Be=Me?.text??"";if(!Be)return;if(he<le.length-1){const Se=le.length-1-he;if(!window.confirm(`This will discard ${Se} message${Se>1?"s":""} after this point and re-generate. Continue?`))return}const Ke=Me&&he>0&&le[he-1]?.id===Me.id;Et(K,Se=>{const et=Se.findIndex(bt=>bt.id===(Ke?Me.id:ne.id));return et>=0?Se.slice(0,et):Se}),ur(Be)},[Z,Et]),es=v.useCallback(ne=>{_({id:ne.id,sender:ne.sender==="user"?n?.name??"You":ne.agentName??"Agent",text:ne.text.slice(0,120)}),Re.current?.focus()},[n?.name]),fr=async ne=>{re(ne.id),Ze(!1),me(!1),rt.current=null;const K=D.current;L.current.delete(K),B([]),Dt(le=>le.some(he=>he.id===ne.id)?le:[...le,ne]),await St(ne.id,K)},ms=ne=>{if(Dt(K=>K.filter(le=>le.id!==ne)),jt===ne){const K=yt.filter(le=>le.id!==ne);K.length>0?fr(K[K.length-1]):nr()}},nr=()=>{re(Ge);const ne=D.current;L.current.delete(ne),B([]),me(!1),rt.current=null,Ze(!1),Dt(K=>{const le=K.filter(he=>he.id!==Ge);return[{id:Ge,agentId:W??"",userId:null,title:"New Chat",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...le]})},Xn=ne=>{if(X(ne),U!=="channel"){nn(!1);return}const K=ne.lastIndexOf("@");if(K>=0&&(K===0||ne[K-1]===" ")){const he=ne.slice(K+1).toLowerCase();if(s.some(Be=>Be.name.toLowerCase().includes(he))){nn(!0),mn(he),Nt(0);return}}nn(!1)},Ms=ne=>{const K=q.lastIndexOf("@"),le=ne.includes(" ")?`@[${ne}]`:`@${ne}`;X(q.slice(0,K)+le+" "),nn(!1),Nt(0)},Ha=4*1024*1024,ts=5,Er=v.useCallback(ne=>{const K=Array.from(ne).filter(le=>le.type.startsWith("image/"));if(K.length!==0)for(const le of K){if(le.size>Ha)continue;const he=new FileReader;he.onload=()=>{const Me=he.result;Te(Be=>Be.length>=ts||Be.some($e=>$e.dataUrl===Me)?Be:[...Be,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:Me,name:le.name}])},he.readAsDataURL(le)}},[]),Pr=v.useCallback(ne=>{Te(K=>K.filter(le=>le.id!==ne))},[]),Pa=v.useCallback(ne=>{const K=ne.clipboardData?.files;if(K&&K.length>0){const le=Array.from(K).filter(he=>he.type.startsWith("image/"));le.length>0&&(ne.preventDefault(),Er(le))}},[Er]),Jn=v.useCallback(ne=>{ne.preventDefault();const K=ne.dataTransfer?.files;K&&K.length>0&&Er(Array.from(K).filter(le=>le.type.startsWith("image/")))},[Er]),ns=v.useCallback(ne=>{ne.preventDefault()},[]),Kn=s.find(ne=>ne.id===W),Tr=n?.name??"You",pr=Z[Z.length-1],xs=V&&pr?.sender==="agent",_r=s.filter(ne=>ne.name.toLowerCase().includes(hn)),Ur=o.find(ne=>ne.id===P),rs=P===n?.id||!P,ps=fn.find(ne=>ne.channelKey===F),sa=U==="channel"?ps?.name??F:U==="direct"?Kn?.name??"Select Agent":U==="dm"?rs?"My Notes":Ur?.name??"Direct Message":"Chat",Os=U==="channel"?ps?`Message ${ps.name}…`:`Message ${F}… (use @name to mention)`:U==="dm"?rs?"Write a note to yourself…":`Message ${Ur?.name??""}…`:W?"Type a message…":"Select an agent to start chatting",Ua=c&&h;return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx(t_,{authUser:n,agents:s,teams:Mt,humans:o,tasks:Ht,externalAgents:Ct,groupChats:fn,chatMode:U,selectedAgent:W,activeChannel:F,activeDmUserId:P,onSelectAgent:ne=>{G("direct"),$(ne),x("chat"),c&&f()},onSelectChannel:ne=>{G("channel"),Y(ne),x("chat"),c&&f()},onSelectDm:ne=>{G("dm"),M(ne),x("chat"),c&&f()},onRefreshTeams:ln,onRefreshAgents:Nn,onViewProfile:z,width:c?void 0:y.width,onResizeStart:c?void 0:y.onResizeStart,hidden:c&&h}),(!c||Ua)&&t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[t.jsxs("div",{className:"border-b border-border-default bg-surface-secondary shrink-0 relative",children:[c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center px-3 h-11 gap-2",children:[t.jsx("button",{onClick:()=>{window.location.hash=xe.TEAM},className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"font-semibold text-sm truncate min-w-0 flex-1",children:sa}),U==="direct"&&Kn&&t.jsx($y,{agent:Kn,tasks:Ht,onViewProfile:z})]}),t.jsxs("div",{className:"flex items-center px-3 h-9 gap-1 border-t border-border-default/40",children:[t.jsx("button",{onClick:()=>{p==="profile"?history.back():x("chat")},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${p==="chat"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>{p!=="profile"&&C()},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${p==="profile"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:U==="channel"?"Team":"Profile"}),t.jsx("div",{className:"flex-1"}),U==="direct"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:nr,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:Ue,onClick:()=>Ze(!Ee),className:`p-1 rounded-md transition-colors shrink-0 ${Ee?"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:sa}),U==="direct"&&Kn&&t.jsx($y,{agent:Kn,tasks:Ht,onViewProfile:z}),(U==="channel"||U==="dm")&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[Z.length," messages"]}),U==="dm"&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-1",children:rs?"· Private notepad":`· Direct message with ${Ur?.name??""}`}),(U==="direct"&&W||U==="channel"&&oe)&&t.jsxs("div",{className:"flex items-center gap-0.5 ml-4 -mb-px",children:[t.jsx("button",{onClick:()=>x("chat"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${p==="chat"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>x("profile"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${p==="profile"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:U==="channel"?"Team":"Profile"})]}),t.jsx("div",{className:"ml-auto flex items-center gap-2",children:U==="direct"&&Kn&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("button",{onClick:nr,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:Ue,onClick:()=>Ze(!Ee),className:`p-1.5 rounded-md transition-colors ${Ee?"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"})})})]})})]}),U==="direct"&&W&&p==="chat"&&yt.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:yt.map(ne=>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] ${ne.id===jt?"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(ne.id===Ge){re(Ge);const K=D.current;L.current.delete(K),B([])}else fr(ne)},children:[t.jsx("span",{className:"truncate",children:ne.id===Ge?"New Chat":ne.title||"Conversation"}),t.jsx("button",{onClick:K=>{K.stopPropagation(),ms(ne.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},ne.id))}),U==="direct"&&W&&Ee&&t.jsxs("div",{ref:at,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:[ot.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No conversations yet"}),(()=>{const ne=new Date,K=new Date(ne.getFullYear(),ne.getMonth(),ne.getDate()).getTime(),le=K-864e5,he=K-7*864e5,Me=[],Be=[],$e=[],Ke=[],Se=[];for(const et of ot){const bt=new Date(et.lastMessageAt).getTime();bt>=K?Be.push(et):bt>=le?$e.push(et):bt>=he?Ke.push(et):Se.push(et)}return Be.length>0&&Me.push({label:"Today",items:Be}),$e.length>0&&Me.push({label:"Yesterday",items:$e}),Ke.length>0&&Me.push({label:"Previous 7 days",items:Ke}),Se.length>0&&Me.push({label:"Older",items:Se}),Me.map(et=>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:et.label}),et.items.map(bt=>t.jsxs("button",{onClick:()=>{fr(bt)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${bt.id===jt?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("div",{className:"truncate font-medium",children:bt.title||"Conversation"}),t.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(bt.lastMessageAt).toLocaleString()})]},bt.id))]},et.label))})()]})]})]}),p==="profile"&&U==="direct"&&W&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(a_,{agentId:W,onBack:()=>x("chat"),inline:!0,defaultTab:S,onSwipeBack:()=>{g.current==="profile"?history.back():x("chat")}})}),p==="profile"&&U==="channel"&&oe&&t.jsx("div",{className:"flex-1 overflow-y-auto",onTouchStart:c?R.onTouchStart:void 0,onTouchEnd:c?R.onTouchEnd:void 0,children:t.jsx(v_,{teamId:oe,onBack:()=>x("chat"),inline:!0})}),t.jsxs("div",{ref:ze,className:`flex-1 overflow-y-auto space-y-3 ${c?"p-2.5":"p-5"} ${p!=="chat"?"hidden":""}`,onTouchStart:c?R.onTouchStart:void 0,onTouchEnd:c?R.onTouchEnd:void 0,children:[ae&&t.jsx("div",{className:"flex justify-center py-2",children:t.jsx("button",{onClick:()=>{Qn()},disabled:Ne,className:"text-xs text-brand-500 hover:text-brand-500 disabled:opacity-50 px-4 py-1.5 border border-brand-500/30 rounded-lg",children:Ne?"Loading…":"↑ Load earlier messages"})}),Z.length===0&&!V&&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:U==="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"})})}),U==="channel"&&t.jsxs("div",{children:["No messages in ",ps?.name??F," yet."]}),U==="direct"&&!W&&t.jsx("div",{children:"Select an agent from the sidebar to start."}),U==="direct"&&W&&t.jsxs("div",{children:["Start a new conversation with ",Kn?.name,"."]})]}),U==="channel"?Z.map(ne=>t.jsxs("div",{id:`msg-${ne.id}`,className:"group/msg flex gap-3 transition-colors rounded-lg",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 cursor-pointer ${ne.sender==="user"?"bg-brand-600 text-white":"bg-brand-500/15 text-brand-600 hover:ring-1 hover:ring-brand-500/40"}`,onClick:K=>{if(ne.sender==="agent"&&ne.agentId){const le=K.currentTarget.getBoundingClientRect();N({agentId:ne.agentId,top:le.top,left:le.right+8})}},children:ne.sender==="user"?Tr?.[0]??"Y":ne.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:ne.sender==="user"?Tr??"You":ne.agentName??"Agent"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:ne.time})]}),ne.replyToId&&ne.replyToSender&&t.jsxs("button",{onClick:()=>{const K=document.getElementById(`msg-${ne.replyToId}`);K&&(K.scrollIntoView({behavior:"smooth",block:"center"}),K.classList.add("bg-brand-500/10"),setTimeout(()=>K.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mt-0.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:ne.replyToSender}),t.jsx("span",{className:"truncate max-w-[250px]",children:ne.replyToText??"..."})]}),t.jsx("div",{className:ne.isError||ne.sender==="agent"&&ne.text.startsWith("⚠")?"mt-0.5 px-3 py-2 rounded-lg border-b-2 border-red-500/60":"mt-0.5",children:ne.sender==="agent"?t.jsx(tr,{content:ne.text,className:"text-sm text-fg-secondary"}):t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[ne.images&&ne.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:ne.images.map((K,le)=>t.jsx("img",{src:K,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(K,"_blank")},le))}),Ey(ne.text,s)]})}),t.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity",children:t.jsx(Iy,{msg:ne,onCopy:Bt,onRetry:xr,onReply:es,isCopied:Jr===ne.id})})]})]},ne.id)):Z.map((ne,K)=>{const he=xs&&K===Z.length-1&&V,Me=!he||ne.isStopped;return t.jsx("div",{id:`msg-${ne.id}`,className:`group/msg flex transition-colors rounded-lg ${ne.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:ne.sender==="agent"&&Ae.has(ne.id)?"max-w-full w-full":c?"max-w-[95%]":"max-w-[75%]",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:[ne.sender==="user"?Tr??"You":t.jsx(w_,{name:ne.agentName??(U==="direct"?Kn?.name??"Agent":"Agent"),agentId:ne.agentId??(U==="direct"?Kn?.id:void 0),agents:s,onViewProfile:z})," · ",ne.time]}),ne.replyToId&&ne.replyToSender&&t.jsxs("button",{onClick:()=>{const Be=document.getElementById(`msg-${ne.replyToId}`);Be&&(Be.scrollIntoView({behavior:"smooth",block:"center"}),Be.classList.add("bg-brand-500/10"),setTimeout(()=>Be.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:ne.replyToSender}),t.jsx("span",{className:"truncate max-w-[200px]",children:ne.replyToText??"..."})]}),t.jsx("div",{className:`rounded-2xl text-sm ${c?"px-3 py-2":"px-4 py-3"} ${ne.sender==="user"?"bg-brand-600 text-white rounded-br-sm":ne.isError||ne.sender==="agent"&&ne.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:ne.sender==="user"?t.jsxs(t.Fragment,{children:[ne.images&&ne.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ne.images.map((Be,$e)=>t.jsx("img",{src:Be,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(Be,"_blank")},$e))}),ne.text&&t.jsx("span",{className:"whitespace-pre-wrap leading-relaxed",children:Ey(ne.text,s)})]}):t.jsx(S_,{msg:ne,isStreaming:he,liveActivities:he?ee:[],onViewModeChange:Be=>qe($e=>{const Ke=new Set($e);return Be==="full"?Ke.add(ne.id):Ke.delete(ne.id),Ke})})}),Me&&t.jsx("div",{className:`transition-opacity ${ne.isStopped?"opacity-100":"opacity-0 group-hover/msg:opacity-100"} ${ne.sender==="user"?"flex justify-end":""}`,children:t.jsx(Iy,{msg:ne,onCopy:Bt,onRetry:xr,onReply:es,isCopied:Jr===ne.id})})]})},ne.id)}),U==="channel"&&V&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse ml-11",children:"Agent is thinking…"}),t.jsx("div",{ref:Ve})]}),w&&(()=>{const ne=s.find(K=>K.id===w.agentId);return ne?t.jsx(N_,{agent:ne,anchorRect:{top:w.top,left:w.left},onClose:()=>N(null),onViewProfile:z}):null})(),t.jsxs("div",{className:`p-4 border-t border-border-default bg-surface-secondary relative shrink-0 ${p!=="chat"?"hidden":""}`,onDrop:Jn,onDragOver:ns,children:[tn&&_r.length>0&&t.jsxs("div",{className:"absolute bottom-full left-4 mb-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden z-10 max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:"Mention an agent"}),_r.map((ne,K)=>t.jsxs("button",{onClick:()=>Ms(ne.name),onMouseEnter:()=>Nt(K),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${K===On?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-brand-500/20 flex items-center justify-center text-[10px] font-bold text-brand-500 shrink-0",children:ne.name.slice(0,2).toUpperCase()}),t.jsx("span",{className:"flex-1 min-w-0",children:ne.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:ne.role})]},ne.id))]}),je.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[je.map(ne=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:ne.dataUrl,alt:ne.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>Pr(ne.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:"×"})]},ne.id)),je.length<ts&&t.jsx("button",{onClick:()=>Ce.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:Ce,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:ne=>{ne.target.files&&Er(ne.target.files),ne.target.value=""}}),I&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:I.sender}),t.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:I.text})]}),t.jsx("button",{onClick:()=>_(null),className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("button",{onClick:()=>Ce.current?.click(),disabled:U==="direct"&&!W,className:"px-2.5 py-2.5 text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated",title:"Attach images",children:t.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),t.jsx("textarea",{ref:Re,value:q,onChange:ne=>{Xn(ne.target.value),ne.target.style.height="auto";const K=Math.min(ne.target.scrollHeight,120);ne.target.style.height=`${K}px`,ne.target.style.overflowY=K>=120?"auto":"hidden"},onKeyDown:ne=>{if(tn&&_r.length>0){const K=ne.key==="ArrowUp"||ne.ctrlKey&&ne.key==="p",le=ne.key==="ArrowDown"||ne.ctrlKey&&ne.key==="n",he=ne.key==="Enter"||ne.key==="Tab",Me=ne.key==="Escape";if(K){ne.preventDefault(),Nt(Be=>(Be-1+_r.length)%_r.length);return}if(le){ne.preventDefault(),Nt(Be=>(Be+1)%_r.length);return}if(he){ne.preventDefault();const Be=_r[On];Be&&Ms(Be.name);return}if(Me){ne.preventDefault(),nn(!1);return}}ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),ur())},onPaste:Pa,placeholder:Os,disabled:U==="direct"&&!W,rows:1,className:"flex-1 px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm focus:border-brand-500 outline-none disabled:opacity-40 transition-colors resize-none overflow-hidden leading-5",style:{maxHeight:"120px"}}),V&&U!=="dm"&&t.jsx("button",{onClick:on,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:()=>{ur()},disabled:U==="direct"&&!W||!q.trim()&&je.length===0,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:"Send"})]})]})]})]})}function $y({agent:e,tasks:n,onViewProfile:s}){const[i,o]=v.useState(!1),d=v.useRef(null),c=e.status==="working",m=e.status==="error",h=c?n.find(y=>y.assignedAgentId===e.id&&y.status==="in_progress"):null,f=e.currentActivity;v.useEffect(()=>{if(!i)return;const y=w=>{d.current&&!d.current.contains(w.target)&&o(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[i]);const p=m?"bg-red-400 animate-pulse":c?"bg-blue-400 animate-pulse":"bg-green-400",x=m?"error":c?"working":"idle",g=f?f.type==="heartbeat"?`Heartbeat: ${f.heartbeatName??f.label}`:f.type==="chat"?f.label:f.type==="task"?`Task: ${f.label}`:f.label:"Processing...";return t.jsxs("div",{className:"relative",ref:d,children:[t.jsxs("button",{onClick:()=>o(y=>!y),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${c?"bg-blue-500/10 border border-blue-500/20 hover:bg-blue-500/20":m?"bg-red-500/10 border border-red-500/20 hover:bg-red-500/20":"bg-green-500/10 border border-green-500/20 hover:bg-green-500/20"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${p}`}),t.jsx("span",{className:`text-xs ${m?"text-red-500":c?"text-blue-500":"text-green-600"}`,children:x}),e.mailboxDepth!=null&&e.mailboxDepth>0&&t.jsx("span",{className:"text-[9px] bg-fg-tertiary/20 text-fg-tertiary rounded-full px-1.5",children:e.mailboxDepth})]}),i&&m&&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&&c&&t.jsxs("div",{className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:"Current Activity"}),h?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),pt.navigate(xe.WORK,{openTask:h.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:h.title}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:"Working on task · Click to view"})]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"→"})]}):t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-surface-elevated/50",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${f?.type==="heartbeat"||f?.type==="chat","bg-blue-400 animate-pulse"}`}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-secondary",children:g}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:f?.type==="heartbeat"?"Periodic check-in task":f?.type==="chat"?"Responding to conversation":"Agent is thinking or communicating"})]})]}),t.jsx("button",{onClick:()=>{o(!1),s?.(e.id,{tab:"mind"})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1.5 transition-colors",children:"View Mind →"})]})]})}const T_=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"midnight",label:"Midnight"}],zj="markus-theme";function By(e){const n=document.documentElement;n.classList.remove("light","dark","cyberpunk","midnight"),e==="light"?n.classList.add("light"):e==="dark"?n.classList.add("dark"):e==="cyberpunk"?n.classList.add("cyberpunk"):e==="midnight"&&n.classList.add("midnight")}function __(){try{const e=localStorage.getItem(zj);if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="midnight")return e}catch{}return"system"}function A_(){const[e,n]=v.useState(__),s=v.useCallback(i=>{n(i);try{localStorage.setItem(zj,i)}catch{}By(i)},[]);return v.useEffect(()=>{By(e)},[e]),{mode:e,setMode:s}}function $j({theme:e,onThemeChange:n}={}){const[s,i]=v.useState(null),[o,d]=v.useState(null),[c,m]=v.useState(""),[h,f]=v.useState(!1),[p,x]=v.useState(null),[g,y]=v.useState(null),[w,N]=v.useState(null),[S,E]=v.useState(null),[C,k]=v.useState(!1),[T,R]=v.useState(null),[z,U]=v.useState(null),[G,W]=v.useState(!1),[$,F]=v.useState(null),[Y,P]=v.useState({}),[M,L]=v.useState(!1),[A,O]=v.useState([]),[D,Z]=v.useState([]),[B,q]=v.useState(null),[X,I]=v.useState(null),[_,V]=v.useState(""),[Q,ee]=v.useState(null),te=v.useRef(null),ae=v.useRef(!1),[me,Ne]=v.useState(!1),[Ie,je]=v.useState(200),[Te,Ce]=v.useState(!1),[Re,Ge]=v.useState(null),[ot,st]=v.useState(null),[jt,re]=v.useState(!1),[Ee,Ze]=v.useState(new Set),[yt,Dt]=v.useState(null),[we,Le]=v.useState(!1),Ue=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`}),at=v.useCallback(()=>{se.health().then(i).catch(()=>{}),fetch("/api/settings/llm").then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>{de&&typeof de=="object"&&"providers"in de&&(d(de),m(de.defaultProvider))}).catch(()=>{})},[]),rt=v.useCallback(()=>{fetch("/api/settings/oauth/providers").then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>O(de.providers??[])).catch(()=>{})},[]),Zt=v.useCallback(()=>{fetch("/api/settings/oauth/profiles",{headers:Ue()}).then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>Z(de.profiles??[])).catch(()=>{})},[]),fn=v.useCallback(()=>{se.settings.getAgent().then(de=>{de&&typeof de.maxToolIterations=="number"&&je(de.maxToolIterations)}).catch(()=>{})},[]),zt=v.useCallback(()=>{re(!0),se.system.storage().then(st).catch(()=>{}).finally(()=>re(!1)),se.system.orphans().then(Dt).catch(()=>{})},[]);v.useEffect(()=>{at(),rt(),Zt(),fn(),zt()},[at,rt,Zt,fn,zt]),v.useEffect(()=>{const de=()=>zt();return window.addEventListener("markus:data-changed",de),()=>window.removeEventListener("markus:data-changed",de)},[zt]);const Mt=v.useCallback(async()=>{W(!0),F(null),U(null),P({});try{const de=await fetch("/api/settings/env-models",{headers:Ue()});if(!de.ok){F({type:"err",text:`Detection failed (HTTP ${de.status})`});return}const Ae=await de.json();if(U(Ae),Ae.detected.length===0)F({type:"err",text:"No model API keys found in environment variables"});else{const qe={};for(const Bt of Ae.detected)qe[Bt.provider]=!0;P(qe)}}catch{F({type:"err",text:"Failed to detect environment variables"})}finally{W(!1)}},[]),_t=o?Object.values(o.providers).some(de=>de.configured):!1;v.useEffect(()=>{o&&!_t&&!ae.current&&(ae.current=!0,Mt())},[o,_t,Mt]);const Ct=async()=>{if(!(!c||c===o?.defaultProvider)){f(!0),x(null);try{const de=await fetch("/api/settings/llm",{method:"POST",headers:Ue(),body:JSON.stringify({defaultProvider:c})}),Ae=await de.json();de.ok?(d(Ae),x({type:"ok",text:`Default provider updated to ${Ae.defaultProvider}`})):x({type:"err",text:Ae.error??"Save failed"})}catch{x({type:"err",text:"Network error"})}finally{f(!1)}}},en=async(de,Ae)=>{N(de);try{const qe=await fetch(`/api/settings/llm/providers/${de}/toggle`,{method:"POST",headers:Ue(),body:JSON.stringify({enabled:Ae})});if(qe.ok){const Bt=await qe.json();d(Bt)}}catch{}finally{N(null)}},Ht=async()=>{k(!0),R(null);try{const Ae=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Ue(),body:JSON.stringify({preview:!0})})).json();"error"in Ae?R({type:"err",text:Ae.error}):E(Ae)}catch{R({type:"err",text:"Detection failed"})}finally{k(!1)}},Tn=async()=>{k(!0),R(null);try{const Ae=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:Ue(),body:JSON.stringify({preview:!1})})).json();"error"in Ae?R({type:"err",text:Ae.error}):(R({type:"ok",text:`Imported ${Ae.appliedModels} model configs from OpenClaw`}),at())}catch{R({type:"err",text:"Import failed"})}finally{k(!1)}},wn=async()=>{if(!z)return;const de=z.detected.filter(Ae=>Y[Ae.provider]);if(de.length===0){F({type:"err",text:"Select at least one provider to apply"});return}L(!0),F(null);try{const Ae=await fetch("/api/settings/env-models",{method:"POST",headers:Ue(),body:JSON.stringify({providers:de.map(Bt=>({provider:Bt.provider,model:Bt.model,baseUrl:Bt.baseUrl,enabled:!0}))})});if(!Ae.ok){F({type:"err",text:`Apply failed (HTTP ${Ae.status})`});return}const qe=await Ae.json();F({type:"ok",text:qe.message}),U(null),P({}),at()}catch{F({type:"err",text:"Failed to apply environment configs"})}finally{L(!1)}};v.useEffect(()=>()=>{te.current&&clearInterval(te.current)},[]);const[ye,We]=v.useState(!1),[He,wt]=v.useState({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),[Tt,tn]=v.useState(!1),[nn,hn]=v.useState(null),[mn,On]=v.useState(null),[Nt,oe]=v.useState({apiKey:"",baseUrl:"",model:"",contextWindow:0,maxOutputTokens:0,costInput:0,costOutput:0}),[Ve,ze]=v.useState(!1),[dt,it]=v.useState(null),[xt,$t]=v.useState(null),[Je,Fe]=v.useState({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1}),[Et,Rn]=v.useState(!1),Nn=async()=>{if(!(!He.name||!He.model)){tn(!0),hn(null);try{const de=await fetch("/api/settings/llm/providers",{method:"POST",headers:Ue(),body:JSON.stringify({name:He.name,apiKey:He.apiKey||void 0,baseUrl:He.baseUrl||void 0,model:He.model,contextWindow:He.contextWindow||void 0,maxOutputTokens:He.maxOutputTokens||void 0,cost:He.costInput||He.costOutput?{input:He.costInput,output:He.costOutput}:void 0})}),Ae=await de.json();de.ok?(d(Ae),We(!1),wt({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),hn({type:"ok",text:`Provider ${He.name} added`})):hn({type:"err",text:Ae.error??"Failed to add"})}catch{hn({type:"err",text:"Network error"})}finally{tn(!1)}}},ln=(de,Ae)=>{On(de),oe({apiKey:"",baseUrl:Ae.baseUrl??"",model:Ae.model,contextWindow:Ae.contextWindow??0,maxOutputTokens:Ae.maxOutputTokens??0,costInput:Ae.cost?.input??0,costOutput:Ae.cost?.output??0})},ve=async de=>{ze(!0);try{const Ae={};Nt.apiKey&&(Ae.apiKey=Nt.apiKey),Nt.baseUrl!==void 0&&(Ae.baseUrl=Nt.baseUrl),Nt.model&&(Ae.model=Nt.model),Nt.contextWindow&&(Ae.contextWindow=Nt.contextWindow),Nt.maxOutputTokens&&(Ae.maxOutputTokens=Nt.maxOutputTokens),(Nt.costInput||Nt.costOutput)&&(Ae.cost={input:Nt.costInput,output:Nt.costOutput});const qe=await fetch(`/api/settings/llm/providers/${de}`,{method:"PUT",headers:Ue(),body:JSON.stringify(Ae)});if(qe.ok){const Bt=await qe.json();d(Bt),On(null)}}catch{}finally{ze(!1)}},Xe=async de=>{it(de);try{const Ae=await fetch(`/api/settings/llm/providers/${de}`,{method:"DELETE",headers:Ue()});if(Ae.ok){const qe=await Ae.json();d(qe),m(qe.defaultProvider)}}catch{}finally{it(null)}},At=async de=>{if(!(!Je.id||!Je.name)){Rn(!0);try{const Ae=await fetch(`/api/settings/llm/providers/${de}/models`,{method:"POST",headers:Ue(),body:JSON.stringify({id:Je.id,name:Je.name,contextWindow:Je.contextWindow,maxOutputTokens:Je.maxOutputTokens,cost:{input:Je.costInput,output:Je.costOutput},reasoning:Je.reasoning||void 0,inputTypes:Je.vision?["text","image"]:["text"]})});if(Ae.ok){const qe=await Ae.json();d(qe),$t(null),Fe({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})}}catch{}finally{Rn(!1)}}},St=async(de,Ae)=>{try{const qe=await fetch(`/api/settings/llm/providers/${de}/models/${encodeURIComponent(Ae)}`,{method:"DELETE",headers:Ue()});if(qe.ok){const Bt=await qe.json();d(Bt)}}catch{}},xn=new Set(["claude-opus-4-6","claude-sonnet-4-20250514","claude-3-5-haiku-20241022","gpt-5.4","gpt-4o","o4-mini","gemini-3-1-pro","gemini-2.5-flash","MiniMax-M2.7","MiniMax-M2.5","xiaomi/mimo-v2-pro","anthropic/claude-opus-4-6","openai/gpt-5.4","google/gemini-3-1-pro"]),[Qn,lr]=v.useState(null),on=async(de,Ae)=>{lr(`${de}:${Ae}`);try{const qe=await fetch(`/api/settings/llm/providers/${de}/model`,{method:"POST",headers:Ue(),body:JSON.stringify({model:Ae})});if(qe.ok){const Bt=await qe.json();d(Bt)}}catch{}finally{lr(null)}},ur=o?.providers?Object.entries(o.providers).filter(([,de])=>de.configured&&de.enabled).map(([de])=>de):[],Jr=o&&!_t&&!me;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(Aa,{title:"Appearance",children:t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Theme"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Choose a visual style for the interface"})]}),t.jsx("div",{className:"flex flex-wrap gap-1 bg-surface-elevated rounded-lg p-0.5",children:T_.map(({value:de,label:Ae})=>t.jsx("button",{onClick:()=>n?.(de),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${e===de?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary"}`,children:Ae},de))})]})})}),Jr&&t.jsxs("div",{className:"relative bg-gradient-to-br from-brand-500/10 to-surface-secondary border border-brand-500/20 rounded-2xl p-6 space-y-5",children:[t.jsx("button",{onClick:()=>Ne(!0),className:"absolute top-4 right-4 text-fg-tertiary hover:text-fg-secondary text-xs",children:"Skip"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Welcome — Configure Your LLM"}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1",children:"Markus needs at least one LLM provider to work. Choose a way to get started:"})]}),t.jsxs(qh,{step:"1",title:"From Environment Variables",description:"Automatically detected API keys from .env or system environment.",active:!!(z&&z.detected.length>0),children:[G&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Detecting..."}),z&&z.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[z.detected.map(de=>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:Y[de.provider]??!1,onChange:Ae=>P({...Y,[de.provider]:Ae.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:de.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:de.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:de.apiKeyPreview})]},de.provider)),t.jsx("button",{onClick:()=>{wn()},disabled:M||Object.values(Y).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:M?"Applying...":`Apply ${Object.values(Y).filter(Boolean).length} Provider(s)`})]}),z&&z.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."]}),$&&t.jsx(ii,{type:$.type,text:$.text})]}),t.jsxs(qh,{step:"2",title:"From OpenClaw Config",description:"Import model configs from an existing OpenClaw installation.",children:[S?S.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:S.summary.configPath})]}),S.summary.models&&t.jsxs("div",{className:"text-xs text-fg-secondary",children:[S.summary.models.providerCount," providers, ",S.summary.models.providers.reduce((de,Ae)=>de+Ae.modelCount,0)," models"]}),t.jsx("button",{onClick:()=>{Tn()},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:()=>{Ht()},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"}),T&&t.jsx(ii,{type:T.type,text:T.text})]}),t.jsx(qh,{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(Aa,{title:"System Status",children:s?t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(Vh,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx(Vh,{label:"Version",value:s.version,color:"indigo"}),t.jsx(Vh,{label:"Active Agents",value:String(s.agents),color:"purple"})]}):t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Loading..."})}),t.jsx(Aa,{title:"Default LLM Provider",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Primary Provider"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Used for all agent interactions unless overridden"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[o?t.jsx("select",{value:c,onChange:de=>{m(de.target.value),x(null)},className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-48 focus:border-brand-500 outline-none",children:ur.length>0?ur.map(de=>t.jsx("option",{value:de,children:o.providers[de]?.displayName??de},de)):t.jsx("option",{value:"",children:"No providers configured"})}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading..."}),c!==o?.defaultProvider&&t.jsx("button",{onClick:()=>{Ct()},disabled:h,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:h?"Saving...":"Save"})]})]}),p&&t.jsx(ii,{type:p.type,text:p.text})]})}),t.jsxs(Aa,{title:"Model Providers & Pricing",children:[t.jsx("div",{className:"space-y-3",children:o&&Object.entries(o.providers).map(([de,Ae])=>t.jsxs("div",{className:`bg-surface-secondary border rounded-xl overflow-hidden transition-colors ${Ae.configured?"border-border-default hover:border-gray-600":"border-border-default/50 opacity-60"}`,children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 cursor-pointer",onClick:()=>y(g===de?null:de),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${Ae.configured&&Ae.enabled?"bg-green-400":Ae.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:Ae.displayName??de}),de===o.defaultProvider&&t.jsx("span",{className:"text-[10px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"default"}),Ae.configured&&!Ae.enabled&&t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded",children:"disabled"}),Ae.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:Ae.model||"Not configured"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[Ae.configured&&t.jsx("button",{onClick:qe=>{qe.stopPropagation(),en(de,!Ae.enabled)},disabled:w===de,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${Ae.enabled?"bg-green-500":"bg-gray-600"} ${w===de?"opacity-50":""}`,title:Ae.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 ${Ae.enabled?"translate-x-4":"translate-x-1"}`})}),Ae.contextWindow&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[(Ae.contextWindow/1e3).toFixed(0),"K ctx"]}),Ae.cost&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["$",Ae.cost.input,"/",Ae.cost.output," per 1M"]}),t.jsx("span",{className:"text-fg-tertiary text-xs",children:g===de?"▲":"▼"})]})]}),g===de&&t.jsxs("div",{className:"px-5 pb-4 border-t border-border-default pt-4 space-y-4",children:[Ae.configured&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(Ma,{label:"Model",value:Ae.model}),t.jsx(Ma,{label:"Context Window",value:Ae.contextWindow?`${(Ae.contextWindow/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(Ma,{label:"Max Output",value:Ae.maxOutputTokens?`${(Ae.maxOutputTokens/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(Ma,{label:"Base URL",value:Ae.baseUrl??"Default"})]}),mn===de?t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-4 space-y-3",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Edit Provider"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"API Key"}),t.jsx("input",{type:"password",value:Nt.apiKey,onChange:qe=>oe({...Nt,apiKey:qe.target.value}),placeholder:"Leave blank to keep current",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Base URL"}),t.jsx("input",{type:"text",value:Nt.baseUrl,onChange:qe=>oe({...Nt,baseUrl:qe.target.value}),placeholder:"Default",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Model"}),t.jsx("input",{type:"text",value:Nt.model,onChange:qe=>oe({...Nt,model:qe.target.value}),className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Context Window"}),t.jsx("input",{type:"number",value:Nt.contextWindow||"",onChange:qe=>oe({...Nt,contextWindow:Number(qe.target.value)}),placeholder:"e.g. 128000",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Max Output Tokens"}),t.jsx("input",{type:"number",value:Nt.maxOutputTokens||"",onChange:qe=>oe({...Nt,maxOutputTokens:Number(qe.target.value)}),placeholder:"e.g. 16384",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Input"}),t.jsx("input",{type:"number",step:"0.01",value:Nt.costInput||"",onChange:qe=>oe({...Nt,costInput:Number(qe.target.value)}),placeholder:"e.g. 1",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Output"}),t.jsx("input",{type:"number",step:"0.01",value:Nt.costOutput||"",onChange:qe=>oe({...Nt,costOutput:Number(qe.target.value)}),placeholder:"e.g. 5",className:"w-full px-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{ve(de)},disabled:Ve,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:Ve?"Saving...":"Save"}),t.jsx("button",{onClick:()=>On(null),className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:qe=>{qe.stopPropagation(),ln(de,Ae)},className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Edit"}),t.jsx("button",{onClick:qe=>{qe.stopPropagation(),confirm(`Delete provider "${Ae.displayName??de}"?`)&&Xe(de)},disabled:dt===de,className:"px-3 py-1.5 text-xs border border-red-500/30 text-red-400 hover:bg-red-500/10 rounded-lg transition-colors disabled:opacity-40",children:dt===de?"Deleting...":"Delete"})]})]}),Ae.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(Ma,{label:"Input",value:`$${Ae.cost.input}`}),t.jsx(Ma,{label:"Output",value:`$${Ae.cost.output}`}),Ae.cost.cacheRead!=null&&t.jsx(Ma,{label:"Cache Read",value:`$${Ae.cost.cacheRead}`}),Ae.cost.cacheWrite!=null&&t.jsx(Ma,{label:"Cache Write",value:`$${Ae.cost.cacheWrite}`})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Available Models"}),Ae.configured&&xt!==de&&t.jsx("button",{onClick:()=>{$t(de),Fe({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})},className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:"+ Add Model"})]}),xt===de&&t.jsxs("div",{className:"bg-surface-elevated/40 rounded-lg p-3 mb-2 space-y-2",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsx("input",{type:"text",placeholder:"Model ID",value:Je.id,onChange:qe=>Fe({...Je,id:qe.target.value}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"text",placeholder:"Display Name",value:Je.name,onChange:qe=>Fe({...Je,name:qe.target.value}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"number",placeholder:"Context (tokens)",value:Je.contextWindow,onChange:qe=>Fe({...Je,contextWindow:Number(qe.target.value)}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"}),t.jsx("input",{type:"number",placeholder:"Max Output",value:Je.maxOutputTokens,onChange:qe=>Fe({...Je,maxOutputTokens:Number(qe.target.value)}),className:"px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"$/1M in:"}),t.jsx("input",{type:"number",step:"0.01",value:Je.costInput,onChange:qe=>Fe({...Je,costInput:Number(qe.target.value)}),className:"w-16 px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"out:"}),t.jsx("input",{type:"number",step:"0.01",value:Je.costOutput,onChange:qe=>Fe({...Je,costOutput:Number(qe.target.value)}),className:"w-16 px-2 py-1 text-xs bg-surface-primary border border-border-default rounded text-fg-primary focus:border-brand-500 outline-none"})]}),t.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-fg-tertiary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:Je.reasoning,onChange:qe=>Fe({...Je,reasoning:qe.target.checked}),className:"rounded"}),"reasoning"]}),t.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-fg-tertiary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:Je.vision,onChange:qe=>Fe({...Je,vision:qe.target.checked}),className:"rounded"}),"vision"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>{At(de)},disabled:Et||!Je.id||!Je.name,className:"px-2 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded transition-colors",children:Et?"Adding...":"Add"}),t.jsx("button",{onClick:()=>$t(null),className:"px-2 py-1 text-[10px] border border-border-default text-fg-secondary hover:bg-surface-elevated rounded transition-colors",children:"Cancel"})]})]}),Ae.models&&Ae.models.length>0&&t.jsx("div",{className:"space-y-1.5",children:Ae.models.map(qe=>{const Bt=qe.id===Ae.model,xr=Qn===`${de}:${qe.id}`,es=!xn.has(qe.id);return t.jsxs("div",{className:`flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-colors ${Bt?"bg-brand-500/15 border border-brand-500/30":Ae.configured?"bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer":"bg-surface-elevated/30"}`,onClick:()=>{!Bt&&Ae.configured&&!xr&&on(de,qe.id)},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[Bt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0"}),t.jsx("span",{className:Bt?"text-brand-500 font-medium":"text-fg-secondary",children:qe.name}),qe.reasoning&&t.jsx("span",{className:"text-[9px] bg-amber-500/15 text-amber-600 px-1 py-0.5 rounded",children:"reasoning"}),qe.inputTypes?.includes("image")&&t.jsx("span",{className:"text-[9px] bg-blue-500/15 text-blue-600 px-1 py-0.5 rounded",children:"vision"}),es&&t.jsx("span",{className:"text-[9px] bg-purple-500/15 text-purple-400 px-1 py-0.5 rounded",children:"custom"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-fg-tertiary",children:[t.jsxs("span",{children:[(qe.contextWindow/1e3).toFixed(0),"K ctx"]}),t.jsxs("span",{children:["$",qe.cost.input,"/$",qe.cost.output]}),Ae.configured&&!Bt&&t.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded transition-colors ${xr?"bg-brand-500/30 text-brand-400":"bg-surface-overlay text-fg-tertiary hover:bg-brand-500/20 hover:text-brand-500"}`,children:xr?"Switching...":"Use"}),Bt&&t.jsx("span",{className:"text-[9px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"active"}),es&&!Bt&&t.jsx("button",{onClick:fr=>{fr.stopPropagation(),St(de,qe.id)},className:"text-red-400 hover:text-red-300 transition-colors",title:"Delete custom model",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},qe.id)})})]}),!Ae.configured&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:'Not configured. Use the "Add Provider" button below, or set API keys in environment variables.'})]})]},de))}),ye?t.jsxs("div",{className:"mt-3 bg-surface-secondary border border-brand-500/30 rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Add New Provider"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Provider Name"}),t.jsx("input",{type:"text",value:He.name,onChange:de=>wt({...He,name:de.target.value}),placeholder:"e.g. deepseek, openrouter, my-provider",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-1",children:"Use anthropic, openai, google, ollama for first-party; any other name uses OpenAI-compatible API"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"API Key"}),t.jsx("input",{type:"password",value:He.apiKey,onChange:de=>wt({...He,apiKey:de.target.value}),placeholder:"sk-...",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Base URL (optional)"}),t.jsx("input",{type:"text",value:He.baseUrl,onChange:de=>wt({...He,baseUrl:de.target.value}),placeholder:"https://api.example.com/v1",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Default Model"}),t.jsx("input",{type:"text",value:He.model,onChange:de=>wt({...He,model:de.target.value}),placeholder:"e.g. deepseek-chat, gpt-4o",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Context Window"}),t.jsx("input",{type:"number",value:He.contextWindow,onChange:de=>wt({...He,contextWindow:Number(de.target.value)}),placeholder:"128000",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"Max Output Tokens"}),t.jsx("input",{type:"number",value:He.maxOutputTokens,onChange:de=>wt({...He,maxOutputTokens:Number(de.target.value)}),placeholder:"16384",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Input"}),t.jsx("input",{type:"number",step:"0.01",value:He.costInput,onChange:de=>wt({...He,costInput:Number(de.target.value)}),placeholder:"1",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase block mb-1",children:"$/1M Output"}),t.jsx("input",{type:"number",step:"0.01",value:He.costOutput,onChange:de=>wt({...He,costOutput:Number(de.target.value)}),placeholder:"5",className:"w-full px-3 py-2 text-sm bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder-fg-tertiary focus:border-brand-500 outline-none"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>{Nn()},disabled:Tt||!He.name||!He.model,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded-lg transition-colors",children:Tt?"Adding...":"Add Provider"}),t.jsx("button",{onClick:()=>{We(!1),hn(null)},className:"px-4 py-2 text-sm border border-border-default text-fg-secondary hover:bg-surface-elevated rounded-lg transition-colors",children:"Cancel"})]}),nn&&t.jsx(ii,{type:nn.type,text:nn.text})]}):t.jsx("button",{onClick:()=>We(!0),className:"w-full mt-3 px-4 py-3 border border-dashed border-border-default hover:border-brand-500/50 hover:bg-brand-500/5 rounded-xl text-sm text-fg-tertiary hover:text-brand-500 transition-colors",children:"+ Add Provider"})]}),t.jsx("div",{className:"border-t border-border-default"}),t.jsx(Aa,{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:()=>{Mt()},disabled:G,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 ${G?"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"})}),G?"Detecting...":"Refresh Environment Variables"]}),z&&z.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:"}),z.detected.map(de=>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:Y[de.provider]??!1,onChange:Ae=>P({...Y,[de.provider]:Ae.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:de.displayName}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["Key: ",t.jsx("code",{className:"text-fg-secondary",children:de.apiKeyPreview})," / ","Model: ",t.jsx("code",{className:"text-fg-secondary",children:de.model}),de.baseUrl&&t.jsxs(t.Fragment,{children:[" / ","URL: ",t.jsx("code",{className:"text-fg-secondary",children:de.baseUrl})]})]})]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:Object.keys(de.envVars).map(Ae=>t.jsx("div",{children:t.jsx("code",{children:Ae})},Ae))})]},de.provider)),z.timeoutMs&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["LLM Timeout: ",t.jsxs("code",{className:"text-fg-secondary",children:[z.timeoutMs,"ms"]})," (from ",t.jsx("code",{children:"LLM_TIMEOUT_MS"}),")"]}),t.jsx("button",{onClick:()=>{wn()},disabled:M||Object.values(Y).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:M?"Applying...":`Apply ${Object.values(Y).filter(Boolean).length} Provider(s) to Config`})]}),$&&t.jsx(ii,{type:$.type,text:$.text})]})}),t.jsx(Aa,{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:()=>{Ht()},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"})}),S&&S.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:S.summary.configPath})]}),S.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:[S.summary.models.providerCount," model providers found:"]}),t.jsx("div",{className:"space-y-1",children:S.summary.models.providers.map(de=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:de.name}),t.jsxs("span",{className:"text-fg-tertiary",children:[de.modelCount," models ",de.baseUrl?`(${de.baseUrl})`:""]})]},de.name))})]}),S.summary.channels&&S.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: ",S.summary.channels.join(", ")]})}),t.jsx("button",{onClick:()=>{Tn()},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"})]}),T&&t.jsx(ii,{type:T.type,text:T.text})]})}),t.jsx(Aa,{title:"Agent Execution",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Max Tool Iterations"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Safety cap on tool call loops per agent turn (0 = unlimited, applies to all agents and subagents)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",min:0,value:Ie,onChange:de=>{je(Number(de.target.value)),Ge(null)},className:"w-24 px-3 py-1.5 text-sm border border-border-default rounded-lg bg-surface-primary text-fg-primary text-right"}),t.jsx("button",{disabled:Te,onClick:async()=>{Ce(!0),Ge(null);try{const de=await se.settings.updateAgent({maxToolIterations:Ie});je(de.maxToolIterations),Ge({type:"ok",text:"Saved"})}catch{Ge({type:"err",text:"Failed to save"})}Ce(!1)},className:"px-3 py-1.5 text-xs bg-brand-500 text-white rounded-lg hover:bg-brand-600 transition-colors disabled:opacity-40",children:Te?"Saving…":"Save"})]})]}),Re&&t.jsx(ii,{type:Re.type,text:Re.text})]})}),t.jsx(Aa,{title:"Data & Storage",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[jt&&!ot&&t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Scanning storage..."}),ot&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-lg font-semibold text-fg-primary",children:Ss(ot.totalSize)}),t.jsx("div",{className:"text-xs text-fg-tertiary font-mono mt-0.5",children:ot.dataDir})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>zt(),disabled:jt,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:jt?"Scanning...":"Refresh"}),t.jsx("button",{onClick:()=>{se.system.openPath(ot.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:ot.breakdown.filter(de=>de.size>0).map(de=>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:de.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:de.description})]}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Ss(de.size)})]},de.name))})]}),ot.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 (",ot.agents.length,")"]}),t.jsx("div",{className:"space-y-1",children:ot.agents.map(de=>{const Ae=Ee.has(de.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:()=>Ze(qe=>{const Bt=new Set(qe);return Bt.has(de.id)?Bt.delete(de.id):Bt.add(de.id),Bt}),children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Ae?"▼":"▶"}),t.jsx("button",{onClick:qe=>{qe.stopPropagation(),pt.navigate(xe.TEAM,{agentId:de.id})},className:"text-sm text-brand-500 hover:text-brand-400 truncate",children:de.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:de.id})]}),t.jsx("span",{className:"text-xs font-medium text-fg-secondary tabular-nums shrink-0 ml-3",children:Ss(de.size)})]}),Ae&&t.jsxs("div",{className:"px-3 pb-2 pt-0.5 space-y-0.5",children:[de.subItems.filter(qe=>qe.size>0).map(qe=>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:qe.name}),t.jsx("span",{className:"text-fg-secondary tabular-nums",children:Ss(qe.size)})]},qe.name)),t.jsx("div",{className:"pl-5 pt-1",children:t.jsx("button",{onClick:()=>{se.system.openPath(ot.dataDir+"/agents/"+de.id)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary underline",children:"Open folder"})})]})]},de.id)})})]}),yt&&(yt.orphanAgents.length>0||yt.orphanTeams.length>0)&&t.jsx(M_,{orphanInfo:yt,dataDir:ot.dataDir,onPurged:zt})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function qh({step:e,title:n,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:n}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s})]})]}),o&&t.jsx("div",{className:"pl-9",children:o})]})}function ii({type:e,text:n}){return t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${e==="ok"?"bg-green-500/10 text-green-600 border border-green-500/30":"bg-red-500/10 text-red-500 border border-red-500/30"}`,children:n})}function Aa({title:e,children:n}){return t.jsxs("section",{children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary uppercase tracking-wider mb-4",children:e}),t.jsx("div",{className:"space-y-4",children:n})]})}function Vh({label:e,value:n,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:n}),t.jsx("div",{className:"text-xs mt-1 opacity-70",children:e})]})}function Ma({label:e,value:n}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase",children:e}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 truncate",children:n})]})}function Ss(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}function M_({orphanInfo:e,dataDir:n,onPurged:s}){const i=[...e.orphanAgents.map(N=>({...N,kind:"agent"})),...e.orphanTeams.map(N=>({...N,kind:"team"}))],[o,d]=v.useState(new Set),[c,m]=v.useState(!1),[h,f]=v.useState(null),p=N=>d(S=>{const E=new Set(S);return E.has(N)?E.delete(N):E.add(N),E}),x=o.size===i.length&&i.length>0,g=()=>d(x?new Set:new Set(i.map(N=>N.id))),y=i.filter(N=>o.has(N.id)).reduce((N,S)=>N+S.size,0),w=async N=>{m(!0),f(null);try{const S=await se.system.purgeOrphans(N),E=S.purgedAgents.length+S.purgedTeams.length;f(`Cleaned ${E} dir${E!==1?"s":""}, freed ${Ss(S.freedBytes)}${S.failures.length?` (${S.failures.length} failed)`:""}`),d(new Set),s()}catch{f("Cleanup failed")}finally{m(!1)}};return t.jsxs("div",{className:"border-t border-border-default pt-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-amber-500 mb-2",children:"Orphaned Directories"}),t.jsxs("p",{className:"text-xs text-fg-tertiary mb-3",children:["These directories have no matching database record and were likely left behind when agents or teams were deleted. Total: ",Ss(e.totalOrphanSize)," across ",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:x,onChange:g,className:"rounded"}),"Select all"]}),o.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[o.size," selected (",Ss(y),")"]})]}),t.jsx("div",{className:"space-y-0.5 mb-3 max-h-52 overflow-y-auto",children:i.map(N=>t.jsxs("div",{className:`flex items-center gap-2 text-xs py-1.5 px-2 rounded transition-colors ${o.has(N.id)?"bg-amber-500/10":"bg-surface-elevated/30 hover:bg-surface-elevated/50"}`,children:[t.jsx("input",{type:"checkbox",checked:o.has(N.id),onChange:()=>p(N.id),className:"rounded shrink-0"}),N.kind==="team"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:"team"}),t.jsx("span",{className:"text-fg-tertiary font-mono truncate min-w-0 flex-1",children:N.id}),t.jsx("span",{className:"text-fg-secondary tabular-nums shrink-0",children:Ss(N.size)}),t.jsx("button",{onClick:()=>{se.system.openPath(N.path)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary shrink-0 underline",children:"Open"})]},N.id))}),t.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[o.size>0&&t.jsx("button",{disabled:c,onClick:()=>{w([...o])},className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:c?"Cleaning...":`Clean Selected (${Ss(y)})`}),t.jsx("button",{disabled:c,onClick:()=>{w()},className:"px-3 py-1.5 text-xs border border-amber-600/50 hover:bg-amber-600/10 text-amber-500 rounded-lg transition-colors disabled:opacity-50",children:c?"Cleaning...":`Clean All (${Ss(e.totalOrphanSize)})`})]}),h&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-2",children:h})]})}const Bd=new Map;function li(e,n){Bd.has(e)||Bd.set(e,n().catch(()=>{}))}function di(e){const n=Bd.get(e);return Bd.delete(e),n}const Nr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function Bj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function O_(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let o=0;o<Math.max(s.length,i.length);o++){const d=s[o]??0,c=i[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}const Hj={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function Mm({authUser:e}={}){const[n,s]=v.useState("all"),[i,o]=v.useState(""),[d,c]=v.useState([]),[m,h]=v.useState([]),[f,p]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(!0),[N,S]=v.useState(new Map),E=v.useCallback(async()=>{try{const[T,R]=await Promise.all([se.builder.artifacts.list().catch(()=>({artifacts:[]})),se.builder.artifacts.installed().catch(()=>({installed:{}}))]),z=new Map;for(const U of T.artifacts){if(U.type!=="agent")continue;const G=!!R.installed[`agent/${U.name}`];z.set(U.name,{installed:G,localVersion:U.meta.version||void 0,localUpdatedAt:U.updatedAt})}S(z)}catch{}},[]),C=v.useCallback(async()=>{w(!0);try{if(n==="hub"){const T=i?Fn.search({type:"agent",q:i,limit:50}):di(Nr.hubAgents)??Fn.search({type:"agent",limit:50}),[R]=await Promise.all([T.catch(()=>({items:[],total:0})),E()]);h(R?.items??[]),c([])}else{h([]);const T=new URLSearchParams;i&&T.set("q",i);const R=await fetch("/api/templates?"+T.toString()).then(z=>z.json()).catch(()=>({templates:[]}));c(Array.isArray(R.templates)?R.templates:[])}}catch{c([]),h([])}finally{w(!1)}},[n,i,E]);v.useEffect(()=>{C()},[C]);const k=async(T,R,z)=>{try{const U=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:T,name:R,orgId:"default",teamId:z})});if(!U.ok)throw new Error(`Failed: ${U.status}`);g(!1),p(null)}catch(U){alert(`Failed to create agent: ${U}`)}};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(T=>t.jsx("button",{onClick:()=>{s(T.id),p(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${n===T.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:T.label},T.id))}),n==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[d.length," agent",d.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search agents...",value:i,onChange:T=>o(T.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children:y?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading agents..."}):n==="hub"?m.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:m.map(T=>t.jsx(R_,{item:T,localInfo:N.get(Bj(T.name)),onStatusChange:E},T.id))}):d.length===0?t.jsxs("div",{className:"text-center py-20",children:[t.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),t.jsx("div",{className:"text-fg-secondary font-medium mb-1",children: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:d.map(T=>t.jsx(D_,{template:T,isSelected:f?.id===T.id,onSelect:()=>p(f?.id===T.id?null:T)},T.id))})}),f&&n==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-72 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("div",{className:"flex items-center gap-3",children:t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children:f.name}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:f.description})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>g(!0),className:"px-5 py-2 bg-brand-600 text-white text-sm rounded-lg hover:bg-brand-500 transition-colors font-medium",children:"Hire Agent"}),t.jsx("button",{onClick:()=>p(null),className:"text-fg-tertiary hover:text-fg-secondary text-lg px-2",children:"×"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Skills"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[f.skills.map(T=>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:T},T)),f.skills.length===0&&t.jsx("span",{className:"text-xs text-fg-tertiary italic",children:"No required skills"})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Role Configuration"}),t.jsxs("div",{className:"space-y-1.5 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-16",children:"Role:"}),t.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:f.roleId})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg-tertiary w-16",children:"Position:"}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${Hj[f.agentRole]??""}`,children:f.agentRole})]})]})]}),f.starterTasks&&f.starterTasks.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Starter Tasks"}),t.jsx("div",{className:"space-y-1.5",children:f.starterTasks.map((T,R)=>t.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[t.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full shrink-0 ${T.priority==="high"?"bg-red-400":T.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),T.title]},R))})]})]})]})}),x&&f&&t.jsx(L_,{template:f,onClose:()=>g(!1),onHire:k})]})}function R_({item:e,localInfo:n,onStatusChange:s}){const[i,o]=v.useState(!1),[d,c]=v.useState(""),m=n?.installed??!1,h=m&&e.version&&n?.localVersion&&O_(e.version,n.localVersion),f=async p=>{if(p.stopPropagation(),!i){o(!0),c("");try{const x=await Fn.download(e.id),g=x.name||e.name,y=Bj(g),w=x.itemType==="team"?"team":x.itemType==="skill"?"skill":"agent",N={type:"hub",hubItemId:e.id};if(x.files&&Object.keys(x.files).length>0)await se.builder.artifacts.import(w,y,x.files,N);else{const S={...x.config,name:g,description:e.description,source:N};await se.builder.artifacts.save(w,S)}await se.builder.artifacts.install(w,y),c(h?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5",children:[t.jsx("div",{className:"absolute inset-0 rounded-xl border border-border-default group-hover:border-brand-500/30 transition-colors duration-300"}),t.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-green-500/40 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2.5 mb-2.5",children:[t.jsx("h3",{className:"text-sm font-semibold truncate flex-1 group-hover:text-brand-400 transition-colors",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-400 rounded-md border border-brand-500/10",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-500 rounded-md border border-green-500/10",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-500",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3 pt-3 border-t border-border-default/50",children:[h?t.jsx("button",{onClick:p=>{f(p)},disabled:i,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:i?"Upgrading...":`Upgrade → v${e.version}`}):m?t.jsxs("span",{className:"px-3 py-1.5 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",n?.localVersion?` (v${n.localVersion})`:""]}):t.jsx("button",{onClick:p=>{f(p)},disabled:i,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Installing...":"Install"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})]})}function D_({template:e,isSelected:n,onSelect:s}){return t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:["by ",e.author]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-3",children:[e.skills.slice(0,4).map(i=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated/80 text-fg-secondary rounded-md border border-border-default/50",children:i},i)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-muted",children:["+",e.skills.length-4]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-2 text-xs",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded-md text-[10px] font-medium capitalize ${Hj[e.agentRole]??"bg-surface-overlay text-fg-secondary"}`,children:e.agentRole}),e.tags.length>0&&t.jsx("span",{className:"text-fg-muted text-[10px]",children:e.tags.slice(0,2).join(" · ")})]})]})]})}function L_({template:e,onClose:n,onHire:s}){const[i,o]=v.useState(`${e.name} Agent`),[d,c]=v.useState(""),[m,h]=v.useState([]),[f,p]=v.useState(!1);v.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(g=>g.json()).then(g=>h(g.teams??[])).catch(()=>{})},[]);const x=async()=>{if(i.trim()){p(!0);try{await s(e.id,i.trim(),d||void 0)}finally{p(!1)}}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:g=>g.stopPropagation(),children:[t.jsx("div",{className:"flex items-center gap-3 mb-5",children:t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Hire Agent"}),t.jsxs("p",{className:"text-xs text-fg-tertiary",children:['Creating agent from "',e.name,'"']})]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Agent Name"}),t.jsx("input",{type:"text",value:i,onChange:g=>o(g.target.value),className:"input-field",autoFocus:!0})]}),m.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Assign to Team (optional)"}),t.jsxs("select",{value:d,onChange:g=>c(g.target.value),className:"input-field",children:[t.jsx("option",{value:"",children:"No team"}),m.map(g=>t.jsx("option",{value:g.id,children:g.name},g.id))]})]}),t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Agent Configuration"}),t.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[t.jsx("div",{className:"text-fg-tertiary",children:"Role:"}),t.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),t.jsx("div",{className:"text-fg-tertiary",children:"Position:"}),t.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),t.jsx("div",{className:"text-fg-tertiary",children:"Skills:"}),t.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||"None"})]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:n,className:"btn-secondary",children:"Cancel"}),t.jsx("button",{onClick:x,disabled:!i.trim()||f,className:"btn-primary",children:f?"Creating...":"Create Agent"})]})]})})}function Pj(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function I_(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let o=0;o<Math.max(s.length,i.length);o++){const d=s[o]??0,c=i[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}function Om(){const[e,n]=v.useState("all"),[s,i]=v.useState(""),[o,d]=v.useState([]),[c,m]=v.useState([]),[h,f]=v.useState(null),[p,x]=v.useState(!0),[g,y]=v.useState(!1),[w,N]=v.useState(null),[S,E]=v.useState(new Map),C=v.useCallback(async()=>{try{const[R,z]=await Promise.all([se.builder.artifacts.list().catch(()=>({artifacts:[]})),se.builder.artifacts.installed().catch(()=>({installed:{}}))]),U=new Map;for(const G of R.artifacts){if(G.type!=="team")continue;const W=!!z.installed[`team/${G.name}`];U.set(G.name,{installed:W,localVersion:G.meta.version||void 0,localUpdatedAt:G.updatedAt})}E(U)}catch{}},[]),k=v.useCallback(async()=>{x(!0);try{if(e==="hub"){const R=s?Fn.search({type:"team",q:s,limit:50}):di(Nr.hubTeams)??Fn.search({type:"team",limit:50}),[z]=await Promise.all([R.catch(()=>({items:[],total:0})),C()]);m(z?.items??[]),d([])}else{m([]);const R=await se.teamTemplates.list(s||void 0);d(R?.templates??[])}}catch{d([]),m([])}finally{x(!1)}},[e,s,C]);v.useEffect(()=>{k()},[k]);const T=async R=>{y(!0),N(null);try{const U=(await se.teams.create(R.name,R.description)).team.id;let G,W=0;const $=[];for(const Y of R.members){const P=Y.count??1;for(let M=0;M<P;M++){const L=Y.name??`${R.name} Agent ${M+1}`,A=P>1?`${L} ${M+1}`:L,O=Y.roleName??Y.templateId??"developer";try{const D=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:A,roleName:O,orgId:"default",teamId:U,agentRole:Y.role??"worker",skills:Y.skills??[]})});if(D.ok){W++;const Z=await D.json();Y.role==="manager"&&!G&&(G=Z.agent?.id)}else{const Z=await D.json().catch(()=>({error:`HTTP ${D.status}`}));$.push(`${A}: ${Z.error??D.statusText}`)}}catch(D){$.push(`${A}: ${String(D)}`)}}}G&&await se.teams.update(U,{managerId:G,managerType:"agent"}).catch(()=>{});const F=$.length>0?` (${$.length} failed: ${$[0]})`:"";N({ok:W>0,message:`Team "${R.name}" deployed with ${W} agent(s)${F}`})}catch(z){N({ok:!1,message:`Failed: ${z}`})}finally{y(!1)}};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary shrink-0",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Team Store"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 py-2 border-b border-border-default/50 bg-surface-secondary/50 shrink-0",children:[t.jsx("div",{className:"flex gap-1",children:[{id:"all",label:"Built-in"},{id:"hub",label:"Markus Hub"}].map(R=>t.jsx("button",{onClick:()=>{n(R.id),f(null),N(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${e===R.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:R.label},R.id))}),e==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[o.length," team",o.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search teams...",value:s,onChange:R=>i(R.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children:p?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading teams..."}):e==="hub"?c.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx("div",{className:"text-fg-tertiary text-3xl mb-3",children:"🏪"}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No teams found on Markus Hub"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Hub may be offline or empty. Start the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:c.map(R=>t.jsx(z_,{item:R,localInfo:S.get(Pj(R.name)),onStatusChange:C},R.id))}):o.length===0?t.jsxs("div",{className:"text-center py-20",children:[t.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),t.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:s?`No teams match "${s}"`:"No teams available"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:s?"Try different search terms.":"Go to the Builder page to create a team."})]}):t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:o.map(R=>t.jsx($_,{template:R,isSelected:h?.id===R.id,onSelect:()=>f(h?.id===R.id?null:R)},R.id))})}),h&&e==="all"&&t.jsx("div",{className:"border-t border-border-default bg-surface-secondary shrink-0 max-h-80 overflow-y-auto",children:t.jsxs("div",{className:"p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("div",{className:"flex items-center gap-3",children:t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-fg-primary",children: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:()=>T(h),disabled:g,className:"px-5 py-2 bg-brand-600 text-white text-sm rounded-lg hover:bg-brand-500 transition-colors font-medium disabled:opacity-50",children:g?"Deploying...":"Deploy Team"}),t.jsx("button",{onClick:()=>{f(null),N(null)},className:"text-fg-tertiary hover:text-fg-secondary text-lg px-2",children:"×"})]})]}),w&&t.jsx("div",{className:`mb-4 px-4 py-2.5 rounded-lg text-sm ${w.ok?"bg-green-500/10 text-green-600 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,children:w.message}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:"Team Composition"}),t.jsx("div",{className:"space-y-2",children:h.members.map((R,z)=>t.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold shrink-0 ${R.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:R.role==="manager"?"★":z+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-fg-primary",children:R.name??R.roleName??R.templateId}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono",children:R.roleName??R.templateId}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize ${R.role==="manager"?"bg-brand-500/15 text-brand-500":"bg-blue-500/15 text-blue-600"}`,children:R.role??"worker"}),(R.count??1)>1&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",R.count]})]})]})]},z))})]}),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:h.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:h.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:[h.members.reduce((R,z)=>R+(z.count??1),0)," agents"]})]}),h.tags&&h.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:h.tags.map(R=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-secondary rounded-full border border-border-default",children:R},R))})]})]})]})]})]})})]})}function z_({item:e,localInfo:n,onStatusChange:s}){const[i,o]=v.useState(!1),[d,c]=v.useState(""),m=n?.installed??!1,h=m&&e.version&&n?.localVersion&&I_(e.version,n.localVersion),f=async p=>{if(p.stopPropagation(),!i){o(!0),c("");try{const x=await Fn.download(e.id),g=x.name||e.name,y=Pj(g),w={type:"hub",hubItemId:e.id};if(x.files&&Object.keys(x.files).length>0)await se.builder.artifacts.import("team",y,x.files,w);else{const N={...x.config,name:g,description:e.description,source:w};await se.builder.artifacts.save("team",N)}await se.builder.artifacts.install("team",y),c(h?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{c("Failed")}finally{o(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[h?t.jsx("button",{onClick:p=>{f(p)},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}`}):m?t.jsxs("span",{className:"px-3 py-1 text-xs bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",n?.localVersion?` (v${n.localVersion})`:""]}):t.jsx("button",{onClick:p=>{f(p)},disabled: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"}),d&&t.jsx("span",{className:`text-[10px] ${d==="Failed"?"text-red-500":"text-green-600"}`,children:d})]})]})}function $_({template:e,isSelected:n,onSelect:s}){const i=e.members.reduce((d,c)=>d+(c.count??1),0),o=e.members.some(d=>d.role==="manager");return e.category,t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:["by ",e.author]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:e.members.map((d,c)=>t.jsxs("span",{className:`px-2 py-0.5 text-[10px] rounded-md border ${d.role==="manager"?"bg-brand-500/10 text-brand-400 border-brand-500/15":"bg-blue-500/10 text-blue-400 border-blue-500/15"}`,children:[d.name??d.roleName??d.templateId,(d.count??1)>1?` x${d.count}`:""]},c))}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-3 text-xs",children:[t.jsxs("span",{className:"text-fg-muted",children:[i," agent",i!==1?"s":""]}),o&&t.jsx("span",{className:"text-brand-400/60",children:"has manager"}),e.tags&&e.tags.length>0&&t.jsx("span",{className:"text-fg-muted text-[10px]",children:e.tags.slice(0,3).join(" · ")})]})]})]})}function Uj(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let o=0;o<Math.max(s.length,i.length);o++){const d=s[o]??0,c=i[o]??0;if(d>c)return!0;if(d<c)return!1}return!1}const Fh={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"},B_=[{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 H_({item:e,installedSkills:n,onMsg:s,onRefresh:i}){const[o,d]=v.useState(!1),c=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",m=n.find(x=>x.name===e.name||x.name===c),h=!!m,f=h&&e.version&&m?.version&&Uj(e.version,m.version),p=async()=>{if(!o){d(!0);try{const x=await Fn.download(e.id),g=x.name||e.name,y=g.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",w={type:"hub",hubItemId:e.id};if(x.files&&Object.keys(x.files).length>0)await se.builder.artifacts.import("skill",y,x.files,w);else{const N={...x.config,name:g,description:e.description,source:w};await se.builder.artifacts.save("skill",N)}await se.builder.artifacts.install("skill",y),s(f?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{s("Install failed","error")}finally{d(!1)}}};return f?t.jsx("button",{onClick:()=>{p()},disabled:o,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:o?"Upgrading...":`Upgrade → v${e.version}`}):h?t.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:["Installed",m?.version?` (v${m.version})`:""]}):t.jsx("button",{onClick:()=>{p()},disabled:o,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:o?"Installing...":"Install"})}function Rm(){const e=Sr(),[n,s]=v.useState("installed"),[i,o]=v.useState(null),[d,c]=v.useState(new Set),[m,h]=v.useState([]),[f,p]=v.useState(!0),[x,g]=v.useState(""),[y,w]=v.useState([]),[N,S]=v.useState(0),[E,C]=v.useState(1),[k,T]=v.useState([]),[R,z]=v.useState(""),[U,G]=v.useState("score"),[W,$]=v.useState(""),[F,Y]=v.useState(!1),[P,M]=v.useState([]),[L,A]=v.useState(!1),[O,D]=v.useState([]),[Z,B]=v.useState(""),[q,X]=v.useState(!1),[I,_]=v.useState([]),[V,Q]=v.useState(!1),[ee,te]=v.useState(""),ae=(re,Ee="success")=>{o({text:re,type:Ee}),setTimeout(()=>o(null),Ee==="error"?1e4:4e3)},me=v.useCallback(async()=>{p(!0);try{const re=await se.skills.list();h(re.skills)}catch{}p(!1)},[]),Ne=v.useCallback(async()=>{A(!0);try{const re=await se.skills.builtin();M(re.skills)}catch{}A(!1)},[]),Ie=v.useCallback(async re=>{Y(!0);try{const Ee=await se.skills.registrySkillhub({q:re?.q,category:re?.category,page:re?.page??1,limit:24,sort:re?.sort??U});w(Ee.skills),S(Ee.total),Ee.categories?.length&&T(Ee.categories)}catch{}Y(!1)},[U]),je=v.useCallback(async re=>{X(!0);try{const Ee=await se.skills.registrySkillssh(re);D(Ee.skills)}catch{}X(!1)},[]),Te=v.useCallback(async re=>{Q(!0);try{const Ze=await(re?Fn.search({type:"skill",q:re,limit:50}):di(Nr.hubSkills)??Fn.search({type:"skill",limit:50}));_(Ze?.items??[])}catch{}Q(!1)},[]);v.useEffect(()=>{me(),Ne(),Ie(),je()},[]),v.useEffect(()=>{n==="markus-hub"&&Te(ee)},[n,ee,Te]);const Ce=async re=>{c(Ee=>new Set(Ee).add(re.name));try{const Ee=await se.skills.install({name:re.name,source:"skillhub",slug:re.slug,sourceUrl:re.homepage,description:re.description_zh??re.description,category:"custom",version:re.version});await me(),ae(`"${re.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${re.name}". You can try manually from: ${re.homepage}`,"error")}c(Ee=>{const Ze=new Set(Ee);return Ze.delete(re.name),Ze})},Re=async re=>{c(Ee=>new Set(Ee).add(re.name));try{const Ee=await se.skills.install({name:re.name,source:"skillssh",sourceUrl:re.url,githubRepo:`${re.author}/${re.repo}`,githubSkillPath:re.name});await me(),ae(`"${re.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ae(`Download failed for "${re.name}". You can try manually from: ${re.url}`,"error")}c(Ee=>{const Ze=new Set(Ee);return Ze.delete(re.name),Ze})},Ge=async re=>{c(Ee=>new Set(Ee).add(re.name));try{const Ee=await se.skills.install({name:re.name,source:"builtin"});await me(),await Ne(),ae(`"${re.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Ee){ae(`Install failed for "${re.name}": ${Ee}`,"error")}c(Ee=>{const Ze=new Set(Ee);return Ze.delete(re.name),Ze})},ot=async re=>{if(confirm(`Uninstall "${re}"? This will delete the skill files from ~/.markus/skills/.`))try{await se.skills.uninstall(re),await me(),ae(`"${re}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Ee){ae(`Uninstall failed: ${Ee}`,"error")}},st=m.filter(re=>{if(!x)return!0;const Ee=x.toLowerCase();return re.name.toLowerCase().includes(Ee)||re.description?.toLowerCase().includes(Ee)}),jt=O.filter(re=>{if(!Z)return!0;const Ee=Z.toLowerCase();return re.name.toLowerCase().includes(Ee)||re.repo.toLowerCase().includes(Ee)});return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:`${e?"px-4":"px-6"} border-b border-border-default bg-surface-secondary shrink-0`,children:[t.jsx("div",{className:"flex items-center h-14",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Skill Store"})}),t.jsx("div",{className:`flex ${e?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:B_.map(re=>t.jsx("button",{onClick:()=>s(re.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${n===re.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:re.label},re.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}),n==="installed"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("input",{value:x,onChange:re=>g(re.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:[st.length," skill",st.length!==1?"s":""]})]}),f?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:"Loading..."}):st.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:st.map(re=>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:re.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] shrink-0 ${re.type==="builtin"?"bg-blue-500/15 text-blue-600":re.type==="filesystem"?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:re.type==="builtin"?"built-in":re.type==="filesystem"?"local":"imported"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[re.author?`by ${re.author} · `:"",re.version?`v${re.version}`:"",re.sourcePath&&t.jsxs("span",{className:"ml-1 text-fg-tertiary",title:re.sourcePath,children:["📁 ",re.sourcePath.replace(/^.*\/\.([^/]+)\/skills\//,"~/.$1/skills/")]})]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Fh[re.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:re.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:re.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:re.tags?.slice(0,3).map(Ee=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Ee},Ee))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[re.tools&&re.tools.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[re.tools.length," tool",re.tools.length!==1?"s":""]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Auto-discovered by agents"})]}),re.type!=="builtin"&&t.jsx("button",{onClick:()=>{ot(re.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"})]})]},re.name))})]}),n==="builtin"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[P.length," built-in skill",P.length!==1?"s":""," available"]}),t.jsx("button",{onClick:()=>{Ne()},className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"Refresh"})]}),L?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading built-in skills..."})}):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:"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:P.map(re=>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:re.name}),re.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:[re.author?`by ${re.author} · `:"","v",re.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${Fh[re.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:re.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:re.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:re.tags.slice(0,4).map(Ee=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Ee},Ee))}),re.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:re.requiredPermissions.map(Ee=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:Ee},Ee))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[re.installed&&re.installedVersion?t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",re.installedVersion]}):t.jsx("span",{}),re.installed&&re.installedVersion&&Uj(re.version,re.installedVersion)?t.jsx("button",{onClick:()=>{Ge(re)},disabled:d.has(re.name),className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:d.has(re.name)?"Upgrading...":`Upgrade → v${re.version}`}):re.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:()=>{Ge(re)},disabled:d.has(re.name),className:"px-2.5 py-1 text-[10px] bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:d.has(re.name)?"Installing...":"Install"})]})]},re.name))})]}),n==="skillhub"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsxs("select",{value:R,onChange:re=>{z(re.target.value),C(1),Ie({q:W||void 0,category:re.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[t.jsx("option",{value:"",children:"全部分类"}),k.map(re=>t.jsx("option",{value:re,children:re},re))]}),t.jsxs("select",{value:U,onChange:re=>{G(re.target.value),C(1),Ie({q:W||void 0,category:R||void 0,page:1,sort:re.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:W,onChange:re=>$(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(C(1),Ie({q:W||void 0,category:R||void 0,page:1}))},placeholder:"搜索 SkillHub 技能...",className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),t.jsx("button",{onClick:()=>{C(1),Ie({q:W||void 0,category:R||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"正在加载 SkillHub 技能..."})}):y.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),t.jsx("div",{children:"未找到匹配的技能"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-3",children:["共 ",N.toLocaleString()," 个技能"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(re=>{const Ee=m.some(Ze=>Ze.name===re.name||Ze.name===re.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:re.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["v",re.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ml-2 ${re.tags?.[0]?Fh[re.tags[0]]??"bg-brand-500/15 text-brand-500":"bg-brand-500/15 text-brand-500"}`,children:re.tags?.[0]??"SkillHub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:re.description_zh??re.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:[re.stars>0&&t.jsxs("span",{className:"text-[10px] text-amber-600",children:["★ ",re.stars.toLocaleString()]}),re.downloads>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[re.downloads>=1e4?`${(re.downloads/1e4).toFixed(1)}万`:re.downloads.toLocaleString()," 下载"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:re.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Ee?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{Ce(re)},disabled:d.has(re.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:d.has(re.name)?"...":"Install"})]})]})]},re.slug)})}),N>24&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[t.jsx("button",{disabled:E<=1,onClick:()=>{const re=E-1;C(re),Ie({q:W||void 0,category:R||void 0,page:re})},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(N/24)," 页"]}),t.jsx("button",{disabled:E>=Math.ceil(N/24),onClick:()=>{const re=E+1;C(re),Ie({q:W||void 0,category:R||void 0,page:re})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"下一页 →"})]})]})]}),n==="skillssh"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:`flex ${e?"flex-wrap":""} items-center gap-2 mb-5`,children:[t.jsx("input",{value:Z,onChange:re=>B(re.target.value),onKeyDown:re=>{re.key==="Enter"&&Z.trim()&&je(Z)},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:()=>{Z.trim()&&je(Z)},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 →"})})]}),q?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Searching skills.sh..."})}):jt.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:jt.map(re=>{const Ee=m.some(Ze=>Ze.name===re.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:re.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[re.author," / ",re.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:re.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:re.installs&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[re.installs," installs"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:re.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Ee?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{Re(re)},disabled:d.has(re.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:d.has(re.name)?"...":"Install"})]})]})]},`${re.author}-${re.name}`)})})]}),n==="markus-hub"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("input",{value:ee,onChange:re=>te(re.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..."})}):I.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3",children:"🏪"}),t.jsx("div",{children:"No skills found on Markus Hub"}),t.jsx("div",{className:"text-xs mt-1",children:"Hub may be offline or empty. Run the hub server at port 8059."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:I.map(re=>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:re.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",re.author?.displayName??re.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:re.description}),t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["★".repeat(Math.round(parseFloat(re.avgRating))),"☆".repeat(5-Math.round(parseFloat(re.avgRating))),t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",re.ratingCount,") · ↓ ",re.downloadCount]})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-end gap-2",children:t.jsx(H_,{item:re,installedSkills:m,onMsg:ae,onRefresh:()=>{me()}})})]},re.id))})]})]})}const Yh=[{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function P_(){const e=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_storeTab"),e==="agents"||e==="teams"||e==="skills"?e:"agents"}function U_({authUser:e}){const[n,s]=v.useState(P_),i=Sr(),o=ea(Yh,n,s);return v.useEffect(()=>{const d=c=>{if(c.detail.page==="store"){const h=localStorage.getItem("markus_nav_storeTab");h&&(localStorage.removeItem("markus_nav_storeTab"),(h==="agents"||h==="teams"||h==="skills")&&s(h))}};return window.addEventListener("markus:navigate",d),()=>window.removeEventListener("markus:navigate",d)},[]),i?t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:o.onTouchStart,onTouchEnd:o.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0",children:Yh.map(d=>t.jsx("button",{onClick:()=>s(d.id),className:`flex-1 min-w-0 px-4 py-3 text-sm font-medium text-center whitespace-nowrap transition-colors border-b-2 ${n===d.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:d.label},d.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx(Mm,{authUser:e}),n==="teams"&&t.jsx(Om,{}),n==="skills"&&t.jsx(Rm,{})]})]}):t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[t.jsxs("nav",{className:"w-48 shrink-0 border-r border-border-default bg-surface-secondary/50 flex flex-col py-4 px-2 gap-1",children:[t.jsx("div",{className:"px-3 pb-3 mb-1 border-b border-border-default/50",children:t.jsx("h2",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Store"})}),Yh.map(d=>t.jsx("button",{onClick:()=>s(d.id),className:`flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-sm font-medium transition-all ${n===d.id?"bg-brand-600/15 text-brand-400 shadow-sm shadow-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:d.label},d.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx(Mm,{authUser:e}),n==="teams"&&t.jsx(Om,{}),n==="skills"&&t.jsx(Rm,{})]})]})}function q_(e){const n=e.indexOf(".markus/builder-artifacts/");return n>=0?"~/"+e.slice(n):e}const V_=[{icon:"✦",color:"from-brand-500 to-purple-600",borderColor:"border-brand-500/30 hover:border-brand-400/50",bgColor:"bg-brand-500/10",title:"Hire an Agent",desc:"Hire from templates, create custom agents, or find specialists on Markus Hub",examples:["Hire a senior React developer","Create a custom code reviewer","Find a DevOps specialist on Hub"],prompt:"I need to hire an agent: "},{icon:"◈",color:"from-blue-500 to-blue-600",borderColor:"border-blue-500/30 hover:border-blue-400/50",bgColor:"bg-blue-500/10",title:"Build a Team",desc:"Compose an optimal team for your project or deploy a team template",examples:["A web dev team with PM, devs, and QA","A data engineering squad","A content creation team"],prompt:"I need to build a team for: "},{icon:"⬡",color:"from-green-500 to-green-600",borderColor:"border-green-500/30 hover:border-green-400/50",bgColor:"bg-green-500/10",title:"Create a Skill",desc:"Design new capabilities that agents can learn and use",examples:["A Git changelog generator","A web scraping skill","A database migration tool"],prompt:"I need a skill that: "}],Hy={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 Py({message:e,onConfirm:n,onCancel:s}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick: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:n,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:"Delete"})]})]})})}function qj(){const e=Sr(),[n,s]=v.useState([]),[i,o]=v.useState([]),[d,c]=v.useState(!1),[m,h]=v.useState("all"),[f,p]=v.useState(null),[x,g]=v.useState(new Map),[y,w]=v.useState(null),[N,S]=v.useState(new Map),[E,C]=v.useState(null),[k,T]=v.useState(null),R=v.useCallback(()=>{c(!0),Promise.all([(di(Nr.builderArtifacts)??se.builder.artifacts.list()).then(P=>P?.artifacts??[]).catch(()=>[]),(di(Nr.builderAgents)??se.agents.list()).then(P=>P?.agents??[]).catch(()=>[]),(di(Nr.builderHubMyItems)??Fn.myItems()).then(P=>P?.items??[]).catch(()=>[]),(di(Nr.builderInstalled)??se.builder.artifacts.installed()).then(P=>P?.installed??{}).catch(()=>({}))]).then(([P,M,L,A])=>{if(o(P),s(M),L.length>0){const D=new Map;for(const Z of L){const B=Z.itemType==="agent"?"agent":Z.itemType==="team"?"team":"skill";for(const q of P)q.type===B&&(Z.slug===q.name||Z.name===(q.meta.displayName||q.meta.name||q.name))&&D.set(`${q.type}/${q.name}`,{id:Z.id,name:Z.name,slug:Z.slug||q.name})}D.size>0&&S(Z=>{const B=new Map(Z);for(const[q,X]of D)B.set(q,X);return B})}const O=new Map;for(const D of P){const Z=`${D.type}/${D.name}`,B=A[Z];B&&O.set(Z,{agentId:B.agentId,agentIds:B.agentIds,teamId:B.teamId})}g(O)}).finally(()=>c(!1))},[]);v.useEffect(()=>{R();const P=M=>{M.detail?.page===xe.BUILDER&&R()};return window.addEventListener("markus:navigate",P),()=>window.removeEventListener("markus:navigate",P)},[R]);const z=P=>{const M=n.find(L=>L.role==="Secretary"||L.name==="Secretary");M?pt.navigate(xe.TEAM,{agentId:M.id,prefillMessage:P}):pt.navigate(xe.TEAM,{prefillMessage:P})},U=async P=>{const M=`${P.type}/${P.name}`;if(!x.has(M)){p(M);try{const L=await se.builder.artifacts.install(P.type,P.name),A={};L.agent&&typeof L.agent=="object"&&(A.agentId=L.agent.id),L.team&&typeof L.team=="object"&&(A.teamId=L.team.id),Array.isArray(L.agents)&&(A.agentIds=L.agents.map(O=>O.id)),g(O=>new Map(O).set(M,A)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Install failed:",L),alert(`Install failed: ${L}`)}finally{p(null)}}},G=async P=>{const M=`${P.type}/${P.name}`;if(x.has(M)){p(M);try{await se.builder.artifacts.uninstall(P.type,P.name),g(L=>{const A=new Map(L);return A.delete(M),A}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Uninstall failed:",L),alert(`Uninstall failed: ${L}`)}finally{p(null)}}},W=async P=>{const M=`${P.type}/${P.name}`;if(!N.has(M)){p(M);try{const L=await se.builder.artifacts.get(P.type,P.name),A=P.meta.displayName||P.meta.name||P.name,O=P.meta.description||"",D=P.meta.category||"general",Z=Array.isArray(P.meta.tags)?P.meta.tags:[],B=P.name,q=await Fn.publishViaProxy({itemType:P.type==="team"?"team":P.type==="skill"?"skill":"agent",name:A,slug:B,description:O,category:D,tags:Z,config:P.meta,files:L.files&&Object.keys(L.files).length>0?L.files:void 0});q.id&&S(X=>{const I=new Map(X);return I.set(M,{id:q.id,name:A,slug:q.slug??B}),I})}catch(L){console.error("Share failed:",L),alert(`Share failed: ${L}`)}finally{p(null)}}},$=async()=>{if(!E)return;const{key:P}=E,M=N.get(P);if(C(null),!M)return;const L=M.id;p(P);try{await Fn.deleteItem(L),S(A=>{const O=new Map(A);return O.delete(P),O})}catch(A){console.error("Hub delete failed:",A),alert(`Failed to remove from Hub: ${A}`)}finally{p(null)}},F=async()=>{if(!y)return;const P=y,M=`${P.type}/${P.name}`;w(null),p(M);try{await se.builder.artifacts.delete(P.type,P.name),o(L=>L.filter(A=>!(A.type===P.type&&A.name===P.name))),g(L=>{const A=new Map(L);return A.delete(M),A}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(L){console.error("Delete failed:",L)}finally{p(null)}},Y=m==="all"?i:i.filter(P=>P.type===m);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:"Hire agents, build teams, and create skills. Your Secretary handles the entire process — from sourcing to onboarding."})]}),t.jsx("div",{className:"grid gap-5",children:V_.map(P=>t.jsx("button",{onClick:()=>z(P.prompt),className:`group text-left w-full rounded-xl border ${P.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 ${P.bgColor} flex items-center justify-center shrink-0`,children:P.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("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 ${P.color} bg-clip-text text-transparent`,children:P.title})}),t.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:P.desc}),t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:P.examples.map((M,L)=>t.jsxs("span",{className:"text-[11px] text-fg-tertiary bg-surface-elevated/60 rounded-full px-3 py-1 border border-border-default cursor-pointer hover:bg-surface-elevated/80 hover:text-fg-secondary transition-colors",onClick:A=>{A.stopPropagation(),z(P.prompt+M)},children:["“",M,"”"]},L))})]}),t.jsx("svg",{className:"w-5 h-5 text-fg-muted group-hover:text-fg-secondary transition-colors shrink-0 mt-1",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"9 18 15 12 9 6"})})]})},P.title))}),t.jsxs("div",{className:"mt-14 mb-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary",children:"My Creations"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:"Saved builder artifacts — install to deploy, or share to Markus Hub."})]}),t.jsx("button",{onClick:R,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:"Refresh"})]}),t.jsx("div",{className:"flex gap-2 mt-4",children:["all","agent","team","skill"].map(P=>t.jsx("button",{onClick:()=>h(P),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${m===P?"border-gray-600 bg-surface-elevated text-fg-primary":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:P==="all"?"All":P.charAt(0).toUpperCase()+P.slice(1)+"s"},P))})]}),d&&i.length===0?t.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:"Loading artifacts..."}):Y.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:Y.map(P=>{const M=Hy[P.type]??Hy.agent,L=P.meta.displayName||P.meta.name||P.name,A=P.meta.description||"",O=`${P.type}/${P.name}`,D=f===O,Z=t.jsxs("div",{className:`flex items-center gap-1.5 ${e?"flex-wrap":"shrink-0"}`,children:[x.has(O)?t.jsx("button",{onClick:()=>G(P),disabled:D,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:D?"Uninstalling...":"Uninstall"}):t.jsx("button",{onClick:()=>U(P),disabled:D,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:D?"Installing...":"Install"}),N.has(O)?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>C({key:O,name:P.meta.displayName||P.meta.name||P.name}),disabled:D,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:text-red-500 hover:border-red-500/30 hover:bg-red-500/10 transition-colors disabled:opacity-50",title:"Remove from Markus Hub",children:"Shared"}),t.jsx("button",{onClick:()=>{const B=N.get(O),q=Fn.getUser();if(!B||!q)return;const X=`${Fn.getUrl()}/${encodeURIComponent(q.username)}/${encodeURIComponent(B.slug)}`;navigator.clipboard.writeText(X).then(()=>{T(O),setTimeout(()=>T(I=>I===O?null:I),2e3)}).catch(()=>{})},className:"text-xs px-2 py-1.5 rounded-lg border border-green-600/20 text-green-500 hover:text-green-600 hover:border-green-500/40 transition-colors",title:"Copy Hub link",children:k===O?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:()=>W(P),disabled:D,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:D?"Sharing...":"Share"}),t.jsx("button",{onClick:()=>w(P),disabled:D,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 ${M.bg} flex items-center justify-center text-lg shrink-0`,children:M.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:L}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${M.color}`,children:P.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(),se.system.openPath(P.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:P.path,children:q_(P.path)}),t.jsx("span",{className:"shrink-0",children:new Date(P.updatedAt).toLocaleDateString()})]})]}),!e&&Z]}),e&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-default/50",children:Z})]},O)})}),y&&t.jsx(Py,{message:`Delete "${y.meta.displayName||y.meta.name||y.name}"? This cannot be undone.`,onConfirm:F,onCancel:()=>w(null)}),E&&t.jsx(Py,{message:`Remove "${E.name}" from Markus Hub? It will no longer be available for others to download.`,onConfirm:()=>{$()},onCancel:()=>C(null)})]})})}function Gn(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let s=0,i;s<e.length;s++)(i=Gn(e[s]))!==""&&(n+=(n&&" ")+i);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}var F_={value:()=>{}};function au(){for(var e=0,n=arguments.length,s={},i;e<n;++e){if(!(i=arguments[e]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new Sd(s)}function Sd(e){this._=e}function Y_(e,n){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&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}Sd.prototype=au.prototype={constructor:Sd,on:function(e,n){var s=this._,i=Y_(e+"",s),o,d=-1,c=i.length;if(arguments.length<2){for(;++d<c;)if((o=(e=i[d]).type)&&(o=G_(s[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++d<c;)if(o=(e=i[d]).type)s[o]=Uy(s[o],e.name,n);else if(n==null)for(o in s)s[o]=Uy(s[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var s in n)e[s]=n[s].slice();return new Sd(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var s=new Array(o),i=0,o,d;i<o;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(d=this._[e],i=0,o=d.length;i<o;++i)d[i].value.apply(n,s)},apply:function(e,n,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],o=0,d=i.length;o<d;++o)i[o].value.apply(n,s)}};function G_(e,n){for(var s=0,i=e.length,o;s<i;++s)if((o=e[s]).name===n)return o.value}function Uy(e,n,s){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=F_,e=e.slice(0,i).concat(e.slice(i+1));break}return s!=null&&e.push({name:n,value:s}),e}var Dm="http://www.w3.org/1999/xhtml";const qy={svg:"http://www.w3.org/2000/svg",xhtml:Dm,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function iu(e){var n=e+="",s=n.indexOf(":");return s>=0&&(n=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),qy.hasOwnProperty(n)?{space:qy[n],local:e}:e}function X_(e){return function(){var n=this.ownerDocument,s=this.namespaceURI;return s===Dm&&n.documentElement.namespaceURI===Dm?n.createElement(e):n.createElementNS(s,e)}}function K_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vj(e){var n=iu(e);return(n.local?K_:X_)(n)}function W_(){}function jx(e){return e==null?W_:function(){return this.querySelector(e)}}function Z_(e){typeof e!="function"&&(e=jx(e));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var d=n[o],c=d.length,m=i[o]=new Array(c),h,f,p=0;p<c;++p)(h=d[p])&&(f=e.call(h,h.__data__,p,d))&&("__data__"in h&&(f.__data__=h.__data__),m[p]=f);return new Hr(i,this._parents)}function Q_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function J_(){return[]}function Fj(e){return e==null?J_:function(){return this.querySelectorAll(e)}}function eA(e){return function(){return Q_(e.apply(this,arguments))}}function tA(e){typeof e=="function"?e=eA(e):e=Fj(e);for(var n=this._groups,s=n.length,i=[],o=[],d=0;d<s;++d)for(var c=n[d],m=c.length,h,f=0;f<m;++f)(h=c[f])&&(i.push(e.call(h,h.__data__,f,c)),o.push(h));return new Hr(i,o)}function Yj(e){return function(){return this.matches(e)}}function Gj(e){return function(n){return n.matches(e)}}var nA=Array.prototype.find;function rA(e){return function(){return nA.call(this.children,e)}}function sA(){return this.firstElementChild}function aA(e){return this.select(e==null?sA:rA(typeof e=="function"?e:Gj(e)))}var iA=Array.prototype.filter;function lA(){return Array.from(this.children)}function oA(e){return function(){return iA.call(this.children,e)}}function cA(e){return this.selectAll(e==null?lA:oA(typeof e=="function"?e:Gj(e)))}function dA(e){typeof e!="function"&&(e=Yj(e));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var d=n[o],c=d.length,m=i[o]=[],h,f=0;f<c;++f)(h=d[f])&&e.call(h,h.__data__,f,d)&&m.push(h);return new Hr(i,this._parents)}function Xj(e){return new Array(e.length)}function uA(){return new Hr(this._enter||this._groups.map(Xj),this._parents)}function Hd(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Hd.prototype={constructor:Hd,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function fA(e){return function(){return e}}function hA(e,n,s,i,o,d){for(var c=0,m,h=n.length,f=d.length;c<f;++c)(m=n[c])?(m.__data__=d[c],i[c]=m):s[c]=new Hd(e,d[c]);for(;c<h;++c)(m=n[c])&&(o[c]=m)}function mA(e,n,s,i,o,d,c){var m,h,f=new Map,p=n.length,x=d.length,g=new Array(p),y;for(m=0;m<p;++m)(h=n[m])&&(g[m]=y=c.call(h,h.__data__,m,n)+"",f.has(y)?o[m]=h:f.set(y,h));for(m=0;m<x;++m)y=c.call(e,d[m],m,d)+"",(h=f.get(y))?(i[m]=h,h.__data__=d[m],f.delete(y)):s[m]=new Hd(e,d[m]);for(m=0;m<p;++m)(h=n[m])&&f.get(g[m])===h&&(o[m]=h)}function xA(e){return e.__data__}function pA(e,n){if(!arguments.length)return Array.from(this,xA);var s=n?mA:hA,i=this._parents,o=this._groups;typeof e!="function"&&(e=fA(e));for(var d=o.length,c=new Array(d),m=new Array(d),h=new Array(d),f=0;f<d;++f){var p=i[f],x=o[f],g=x.length,y=gA(e.call(p,p&&p.__data__,f,i)),w=y.length,N=m[f]=new Array(w),S=c[f]=new Array(w),E=h[f]=new Array(g);s(p,x,N,S,E,y,n);for(var C=0,k=0,T,R;C<w;++C)if(T=N[C]){for(C>=k&&(k=C+1);!(R=S[k])&&++k<w;);T._next=R||null}}return c=new Hr(c,i),c._enter=m,c._exit=h,c}function gA(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function bA(){return new Hr(this._exit||this._groups.map(Xj),this._parents)}function yA(e,n,s){var i=this.enter(),o=this,d=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),s==null?d.remove():s(d),i&&o?i.merge(o).order():o}function vA(e){for(var n=e.selection?e.selection():e,s=this._groups,i=n._groups,o=s.length,d=i.length,c=Math.min(o,d),m=new Array(o),h=0;h<c;++h)for(var f=s[h],p=i[h],x=f.length,g=m[h]=new Array(x),y,w=0;w<x;++w)(y=f[w]||p[w])&&(g[w]=y);for(;h<o;++h)m[h]=s[h];return new Hr(m,this._parents)}function jA(){for(var e=this._groups,n=-1,s=e.length;++n<s;)for(var i=e[n],o=i.length-1,d=i[o],c;--o>=0;)(c=i[o])&&(d&&c.compareDocumentPosition(d)^4&&d.parentNode.insertBefore(c,d),d=c);return this}function wA(e){e||(e=NA);function n(x,g){return x&&g?e(x.__data__,g.__data__):!x-!g}for(var s=this._groups,i=s.length,o=new Array(i),d=0;d<i;++d){for(var c=s[d],m=c.length,h=o[d]=new Array(m),f,p=0;p<m;++p)(f=c[p])&&(h[p]=f);h.sort(n)}return new Hr(o,this._parents).order()}function NA(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function kA(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function SA(){return Array.from(this)}function CA(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var i=e[n],o=0,d=i.length;o<d;++o){var c=i[o];if(c)return c}return null}function EA(){let e=0;for(const n of this)++e;return e}function TA(){return!this.node()}function _A(e){for(var n=this._groups,s=0,i=n.length;s<i;++s)for(var o=n[s],d=0,c=o.length,m;d<c;++d)(m=o[d])&&e.call(m,m.__data__,d,o);return this}function AA(e){return function(){this.removeAttribute(e)}}function MA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function OA(e,n){return function(){this.setAttribute(e,n)}}function RA(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function DA(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function LA(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,s)}}function IA(e,n){var s=iu(e);if(arguments.length<2){var i=this.node();return s.local?i.getAttributeNS(s.space,s.local):i.getAttribute(s)}return this.each((n==null?s.local?MA:AA:typeof n=="function"?s.local?LA:DA:s.local?RA:OA)(s,n))}function Kj(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function zA(e){return function(){this.style.removeProperty(e)}}function $A(e,n,s){return function(){this.style.setProperty(e,n,s)}}function BA(e,n,s){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,s)}}function HA(e,n,s){return arguments.length>1?this.each((n==null?zA:typeof n=="function"?BA:$A)(e,n,s??"")):fl(this.node(),e)}function fl(e,n){return e.style.getPropertyValue(n)||Kj(e).getComputedStyle(e,null).getPropertyValue(n)}function PA(e){return function(){delete this[e]}}function UA(e,n){return function(){this[e]=n}}function qA(e,n){return function(){var s=n.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function VA(e,n){return arguments.length>1?this.each((n==null?PA:typeof n=="function"?qA:UA)(e,n)):this.node()[e]}function Wj(e){return e.trim().split(/^|\s+/)}function wx(e){return e.classList||new Zj(e)}function Zj(e){this._node=e,this._names=Wj(e.getAttribute("class")||"")}Zj.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Qj(e,n){for(var s=wx(e),i=-1,o=n.length;++i<o;)s.add(n[i])}function Jj(e,n){for(var s=wx(e),i=-1,o=n.length;++i<o;)s.remove(n[i])}function FA(e){return function(){Qj(this,e)}}function YA(e){return function(){Jj(this,e)}}function GA(e,n){return function(){(n.apply(this,arguments)?Qj:Jj)(this,e)}}function XA(e,n){var s=Wj(e+"");if(arguments.length<2){for(var i=wx(this.node()),o=-1,d=s.length;++o<d;)if(!i.contains(s[o]))return!1;return!0}return this.each((typeof n=="function"?GA:n?FA:YA)(s,n))}function KA(){this.textContent=""}function WA(e){return function(){this.textContent=e}}function ZA(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function QA(e){return arguments.length?this.each(e==null?KA:(typeof e=="function"?ZA:WA)(e)):this.node().textContent}function JA(){this.innerHTML=""}function eM(e){return function(){this.innerHTML=e}}function tM(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function nM(e){return arguments.length?this.each(e==null?JA:(typeof e=="function"?tM:eM)(e)):this.node().innerHTML}function rM(){this.nextSibling&&this.parentNode.appendChild(this)}function sM(){return this.each(rM)}function aM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function iM(){return this.each(aM)}function lM(e){var n=typeof e=="function"?e:Vj(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function oM(){return null}function cM(e,n){var s=typeof e=="function"?e:Vj(e),i=n==null?oM:typeof n=="function"?n:jx(n);return this.select(function(){return this.insertBefore(s.apply(this,arguments),i.apply(this,arguments)||null)})}function dM(){var e=this.parentNode;e&&e.removeChild(this)}function uM(){return this.each(dM)}function fM(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function hM(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function mM(e){return this.select(e?hM:fM)}function xM(e){return arguments.length?this.property("__data__",e):this.node().__data__}function pM(e){return function(n){e.call(this,n,this.__data__)}}function gM(e){return e.trim().split(/^|\s+/).map(function(n){var s="",i=n.indexOf(".");return i>=0&&(s=n.slice(i+1),n=n.slice(0,i)),{type:n,name:s}})}function bM(e){return function(){var n=this.__on;if(n){for(var s=0,i=-1,o=n.length,d;s<o;++s)d=n[s],(!e.type||d.type===e.type)&&d.name===e.name?this.removeEventListener(d.type,d.listener,d.options):n[++i]=d;++i?n.length=i:delete this.__on}}}function yM(e,n,s){return function(){var i=this.__on,o,d=pM(n);if(i){for(var c=0,m=i.length;c<m;++c)if((o=i[c]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=d,o.options=s),o.value=n;return}}this.addEventListener(e.type,d,s),o={type:e.type,name:e.name,value:n,listener:d,options:s},i?i.push(o):this.__on=[o]}}function vM(e,n,s){var i=gM(e+""),o,d=i.length,c;if(arguments.length<2){var m=this.node().__on;if(m){for(var h=0,f=m.length,p;h<f;++h)for(o=0,p=m[h];o<d;++o)if((c=i[o]).type===p.type&&c.name===p.name)return p.value}return}for(m=n?yM:bM,o=0;o<d;++o)this.each(m(i[o],n,s));return this}function ew(e,n,s){var i=Kj(e),o=i.CustomEvent;typeof o=="function"?o=new o(n,s):(o=i.document.createEvent("Event"),s?(o.initEvent(n,s.bubbles,s.cancelable),o.detail=s.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function jM(e,n){return function(){return ew(this,e,n)}}function wM(e,n){return function(){return ew(this,e,n.apply(this,arguments))}}function NM(e,n){return this.each((typeof n=="function"?wM:jM)(e,n))}function*kM(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var i=e[n],o=0,d=i.length,c;o<d;++o)(c=i[o])&&(yield c)}var tw=[null];function Hr(e,n){this._groups=e,this._parents=n}function Ko(){return new Hr([[document.documentElement]],tw)}function SM(){return this}Hr.prototype=Ko.prototype={constructor:Hr,select:Z_,selectAll:tA,selectChild:aA,selectChildren:cA,filter:dA,data:pA,enter:uA,exit:bA,join:yA,merge:vA,selection:SM,order:jA,sort:wA,call:kA,nodes:SA,node:CA,size:EA,empty:TA,each:_A,attr:IA,style:HA,property:VA,classed:XA,text:QA,html:nM,raise:sM,lower:iM,append:lM,insert:cM,remove:uM,clone:mM,datum:xM,on:vM,dispatch:NM,[Symbol.iterator]:kM};function $r(e){return typeof e=="string"?new Hr([[document.querySelector(e)]],[document.documentElement]):new Hr([[e]],tw)}function CM(e){let n;for(;n=e.sourceEvent;)e=n;return e}function ls(e,n){if(e=CM(e),n===void 0&&(n=e.currentTarget),n){var s=n.ownerSVGElement||n;if(s.createSVGPoint){var i=s.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const EM={passive:!1},Lo={capture:!0,passive:!1};function Gh(e){e.stopImmediatePropagation()}function cl(e){e.preventDefault(),e.stopImmediatePropagation()}function nw(e){var n=e.document.documentElement,s=$r(e).on("dragstart.drag",cl,Lo);"onselectstart"in n?s.on("selectstart.drag",cl,Lo):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function rw(e,n){var s=e.document.documentElement,i=$r(e).on("dragstart.drag",null);n&&(i.on("click.drag",cl,Lo),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 ud=e=>()=>e;function Lm(e,{sourceEvent:n,subject:s,target:i,identifier:o,active:d,x:c,y:m,dx:h,dy:f,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:d,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:m,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:p}})}Lm.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function TM(e){return!e.ctrlKey&&!e.button}function _M(){return this.parentNode}function AM(e,n){return n??{x:e.x,y:e.y}}function MM(){return navigator.maxTouchPoints||"ontouchstart"in this}function sw(){var e=TM,n=_M,s=AM,i=MM,o={},d=au("start","drag","end"),c=0,m,h,f,p,x=0;function g(T){T.on("mousedown.drag",y).filter(i).on("touchstart.drag",S).on("touchmove.drag",E,EM).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(T,R){if(!(p||!e.call(this,T,R))){var z=k(this,n.call(this,T,R),T,R,"mouse");z&&($r(T.view).on("mousemove.drag",w,Lo).on("mouseup.drag",N,Lo),nw(T.view),Gh(T),f=!1,m=T.clientX,h=T.clientY,z("start",T))}}function w(T){if(cl(T),!f){var R=T.clientX-m,z=T.clientY-h;f=R*R+z*z>x}o.mouse("drag",T)}function N(T){$r(T.view).on("mousemove.drag mouseup.drag",null),rw(T.view,f),cl(T),o.mouse("end",T)}function S(T,R){if(e.call(this,T,R)){var z=T.changedTouches,U=n.call(this,T,R),G=z.length,W,$;for(W=0;W<G;++W)($=k(this,U,T,R,z[W].identifier,z[W]))&&(Gh(T),$("start",T,z[W]))}}function E(T){var R=T.changedTouches,z=R.length,U,G;for(U=0;U<z;++U)(G=o[R[U].identifier])&&(cl(T),G("drag",T,R[U]))}function C(T){var R=T.changedTouches,z=R.length,U,G;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),U=0;U<z;++U)(G=o[R[U].identifier])&&(Gh(T),G("end",T,R[U]))}function k(T,R,z,U,G,W){var $=d.copy(),F=ls(W||z,R),Y,P,M;if((M=s.call(T,new Lm("beforestart",{sourceEvent:z,target:g,identifier:G,active:c,x:F[0],y:F[1],dx:0,dy:0,dispatch:$}),U))!=null)return Y=M.x-F[0]||0,P=M.y-F[1]||0,function L(A,O,D){var Z=F,B;switch(A){case"start":o[G]=L,B=c++;break;case"end":delete o[G],--c;case"drag":F=ls(D||O,R),B=c;break}$.call(A,T,new Lm(A,{sourceEvent:O,subject:M,target:g,identifier:G,active:B,x:F[0]+Y,y:F[1]+P,dx:F[0]-Z[0],dy:F[1]-Z[1],dispatch:$}),U)}}return g.filter=function(T){return arguments.length?(e=typeof T=="function"?T:ud(!!T),g):e},g.container=function(T){return arguments.length?(n=typeof T=="function"?T:ud(T),g):n},g.subject=function(T){return arguments.length?(s=typeof T=="function"?T:ud(T),g):s},g.touchable=function(T){return arguments.length?(i=typeof T=="function"?T:ud(!!T),g):i},g.on=function(){var T=d.on.apply(d,arguments);return T===d?g:T},g.clickDistance=function(T){return arguments.length?(x=(T=+T)*T,g):Math.sqrt(x)},g}function Nx(e,n,s){e.prototype=n.prototype=s,s.constructor=e}function aw(e,n){var s=Object.create(e.prototype);for(var i in n)s[i]=n[i];return s}function Wo(){}var Io=.7,Pd=1/Io,dl="\\s*([+-]?\\d+)\\s*",zo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Es="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",OM=/^#([0-9a-f]{3,8})$/,RM=new RegExp(`^rgb\\(${dl},${dl},${dl}\\)$`),DM=new RegExp(`^rgb\\(${Es},${Es},${Es}\\)$`),LM=new RegExp(`^rgba\\(${dl},${dl},${dl},${zo}\\)$`),IM=new RegExp(`^rgba\\(${Es},${Es},${Es},${zo}\\)$`),zM=new RegExp(`^hsl\\(${zo},${Es},${Es}\\)$`),$M=new RegExp(`^hsla\\(${zo},${Es},${Es},${zo}\\)$`),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};Nx(Wo,gi,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Fy,formatHex:Fy,formatHex8:BM,formatHsl:HM,formatRgb:Yy,toString:Yy});function Fy(){return this.rgb().formatHex()}function BM(){return this.rgb().formatHex8()}function HM(){return iw(this).formatHsl()}function Yy(){return this.rgb().formatRgb()}function gi(e){var n,s;return e=(e+"").trim().toLowerCase(),(n=OM.exec(e))?(s=n[1].length,n=parseInt(n[1],16),s===6?Gy(n):s===3?new kr(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):s===8?fd(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):s===4?fd(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=RM.exec(e))?new kr(n[1],n[2],n[3],1):(n=DM.exec(e))?new kr(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=LM.exec(e))?fd(n[1],n[2],n[3],n[4]):(n=IM.exec(e))?fd(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=zM.exec(e))?Wy(n[1],n[2]/100,n[3]/100,1):(n=$M.exec(e))?Wy(n[1],n[2]/100,n[3]/100,n[4]):Vy.hasOwnProperty(e)?Gy(Vy[e]):e==="transparent"?new kr(NaN,NaN,NaN,0):null}function Gy(e){return new kr(e>>16&255,e>>8&255,e&255,1)}function fd(e,n,s,i){return i<=0&&(e=n=s=NaN),new kr(e,n,s,i)}function PM(e){return e instanceof Wo||(e=gi(e)),e?(e=e.rgb(),new kr(e.r,e.g,e.b,e.opacity)):new kr}function Im(e,n,s,i){return arguments.length===1?PM(e):new kr(e,n,s,i??1)}function kr(e,n,s,i){this.r=+e,this.g=+n,this.b=+s,this.opacity=+i}Nx(kr,Im,aw(Wo,{brighter(e){return e=e==null?Pd:Math.pow(Pd,e),new kr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new kr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new kr(hi(this.r),hi(this.g),hi(this.b),Ud(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:Xy,formatHex:Xy,formatHex8:UM,formatRgb:Ky,toString:Ky}));function Xy(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function UM(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ky(){const e=Ud(this.opacity);return`${e===1?"rgb(":"rgba("}${hi(this.r)}, ${hi(this.g)}, ${hi(this.b)}${e===1?")":`, ${e})`}`}function Ud(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function hi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ui(e){return e=hi(e),(e<16?"0":"")+e.toString(16)}function Wy(e,n,s,i){return i<=0?e=n=s=NaN:s<=0||s>=1?e=n=NaN:n<=0&&(e=NaN),new os(e,n,s,i)}function iw(e){if(e instanceof os)return new os(e.h,e.s,e.l,e.opacity);if(e instanceof Wo||(e=gi(e)),!e)return new os;if(e instanceof os)return e;e=e.rgb();var n=e.r/255,s=e.g/255,i=e.b/255,o=Math.min(n,s,i),d=Math.max(n,s,i),c=NaN,m=d-o,h=(d+o)/2;return m?(n===d?c=(s-i)/m+(s<i)*6:s===d?c=(i-n)/m+2:c=(n-s)/m+4,m/=h<.5?d+o:2-d-o,c*=60):m=h>0&&h<1?0:c,new os(c,m,h,e.opacity)}function qM(e,n,s,i){return arguments.length===1?iw(e):new os(e,n,s,i??1)}function os(e,n,s,i){this.h=+e,this.s=+n,this.l=+s,this.opacity=+i}Nx(os,qM,aw(Wo,{brighter(e){return e=e==null?Pd:Math.pow(Pd,e),new os(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new os(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,i=s+(s<.5?s:1-s)*n,o=2*s-i;return new kr(Xh(e>=240?e-240:e+120,o,i),Xh(e,o,i),Xh(e<120?e+240:e-120,o,i),this.opacity)},clamp(){return new os(Zy(this.h),hd(this.s),hd(this.l),Ud(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=Ud(this.opacity);return`${e===1?"hsl(":"hsla("}${Zy(this.h)}, ${hd(this.s)*100}%, ${hd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Zy(e){return e=(e||0)%360,e<0?e+360:e}function hd(e){return Math.max(0,Math.min(1,e||0))}function Xh(e,n,s){return(e<60?n+(s-n)*e/60:e<180?s:e<240?n+(s-n)*(240-e)/60:n)*255}const kx=e=>()=>e;function VM(e,n){return function(s){return e+s*n}}function FM(e,n,s){return e=Math.pow(e,s),n=Math.pow(n,s)-e,s=1/s,function(i){return Math.pow(e+i*n,s)}}function YM(e){return(e=+e)==1?lw:function(n,s){return s-n?FM(n,s,e):kx(isNaN(n)?s:n)}}function lw(e,n){var s=n-e;return s?VM(e,s):kx(isNaN(e)?n:e)}const qd=(function e(n){var s=YM(n);function i(o,d){var c=s((o=Im(o)).r,(d=Im(d)).r),m=s(o.g,d.g),h=s(o.b,d.b),f=lw(o.opacity,d.opacity);return function(p){return o.r=c(p),o.g=m(p),o.b=h(p),o.opacity=f(p),o+""}}return i.gamma=e,i})(1);function GM(e,n){n||(n=[]);var s=e?Math.min(n.length,e.length):0,i=n.slice(),o;return function(d){for(o=0;o<s;++o)i[o]=e[o]*(1-d)+n[o]*d;return i}}function XM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function KM(e,n){var s=n?n.length:0,i=e?Math.min(s,e.length):0,o=new Array(i),d=new Array(s),c;for(c=0;c<i;++c)o[c]=_o(e[c],n[c]);for(;c<s;++c)d[c]=n[c];return function(m){for(c=0;c<i;++c)d[c]=o[c](m);return d}}function WM(e,n){var s=new Date;return e=+e,n=+n,function(i){return s.setTime(e*(1-i)+n*i),s}}function Cs(e,n){return e=+e,n=+n,function(s){return e*(1-s)+n*s}}function ZM(e,n){var s={},i={},o;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(o in n)o in e?s[o]=_o(e[o],n[o]):i[o]=n[o];return function(d){for(o in s)i[o]=s[o](d);return i}}var zm=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kh=new RegExp(zm.source,"g");function QM(e){return function(){return e}}function JM(e){return function(n){return e(n)+""}}function ow(e,n){var s=zm.lastIndex=Kh.lastIndex=0,i,o,d,c=-1,m=[],h=[];for(e=e+"",n=n+"";(i=zm.exec(e))&&(o=Kh.exec(n));)(d=o.index)>s&&(d=n.slice(s,d),m[c]?m[c]+=d:m[++c]=d),(i=i[0])===(o=o[0])?m[c]?m[c]+=o:m[++c]=o:(m[++c]=null,h.push({i:c,x:Cs(i,o)})),s=Kh.lastIndex;return s<n.length&&(d=n.slice(s),m[c]?m[c]+=d:m[++c]=d),m.length<2?h[0]?JM(h[0].x):QM(n):(n=h.length,function(f){for(var p=0,x;p<n;++p)m[(x=h[p]).i]=x.x(f);return m.join("")})}function _o(e,n){var s=typeof n,i;return n==null||s==="boolean"?kx(n):(s==="number"?Cs:s==="string"?(i=gi(n))?(n=i,qd):ow:n instanceof gi?qd:n instanceof Date?WM:XM(n)?GM:Array.isArray(n)?KM:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?ZM:Cs)(e,n)}var Qy=180/Math.PI,$m={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cw(e,n,s,i,o,d){var c,m,h;return(c=Math.sqrt(e*e+n*n))&&(e/=c,n/=c),(h=e*s+n*i)&&(s-=e*h,i-=n*h),(m=Math.sqrt(s*s+i*i))&&(s/=m,i/=m,h/=m),e*i<n*s&&(e=-e,n=-n,h=-h,c=-c),{translateX:o,translateY:d,rotate:Math.atan2(n,e)*Qy,skewX:Math.atan(h)*Qy,scaleX:c,scaleY:m}}var md;function e6(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?$m:cw(n.a,n.b,n.c,n.d,n.e,n.f)}function t6(e){return e==null||(md||(md=document.createElementNS("http://www.w3.org/2000/svg","g")),md.setAttribute("transform",e),!(e=md.transform.baseVal.consolidate()))?$m:(e=e.matrix,cw(e.a,e.b,e.c,e.d,e.e,e.f))}function dw(e,n,s,i){function o(f){return f.length?f.pop()+" ":""}function d(f,p,x,g,y,w){if(f!==x||p!==g){var N=y.push("translate(",null,n,null,s);w.push({i:N-4,x:Cs(f,x)},{i:N-2,x:Cs(p,g)})}else(x||g)&&y.push("translate("+x+n+g+s)}function c(f,p,x,g){f!==p?(f-p>180?p+=360:p-f>180&&(f+=360),g.push({i:x.push(o(x)+"rotate(",null,i)-2,x:Cs(f,p)})):p&&x.push(o(x)+"rotate("+p+i)}function m(f,p,x,g){f!==p?g.push({i:x.push(o(x)+"skewX(",null,i)-2,x:Cs(f,p)}):p&&x.push(o(x)+"skewX("+p+i)}function h(f,p,x,g,y,w){if(f!==x||p!==g){var N=y.push(o(y)+"scale(",null,",",null,")");w.push({i:N-4,x:Cs(f,x)},{i:N-2,x:Cs(p,g)})}else(x!==1||g!==1)&&y.push(o(y)+"scale("+x+","+g+")")}return function(f,p){var x=[],g=[];return f=e(f),p=e(p),d(f.translateX,f.translateY,p.translateX,p.translateY,x,g),c(f.rotate,p.rotate,x,g),m(f.skewX,p.skewX,x,g),h(f.scaleX,f.scaleY,p.scaleX,p.scaleY,x,g),f=p=null,function(y){for(var w=-1,N=g.length,S;++w<N;)x[(S=g[w]).i]=S.x(y);return x.join("")}}}var n6=dw(e6,"px, ","px)","deg)"),r6=dw(t6,", ",")",")"),s6=1e-12;function Jy(e){return((e=Math.exp(e))+1/e)/2}function a6(e){return((e=Math.exp(e))-1/e)/2}function i6(e){return((e=Math.exp(2*e))-1)/(e+1)}const Cd=(function e(n,s,i){function o(d,c){var m=d[0],h=d[1],f=d[2],p=c[0],x=c[1],g=c[2],y=p-m,w=x-h,N=y*y+w*w,S,E;if(N<s6)E=Math.log(g/f)/n,S=function(U){return[m+U*y,h+U*w,f*Math.exp(n*U*E)]};else{var C=Math.sqrt(N),k=(g*g-f*f+i*N)/(2*f*s*C),T=(g*g-f*f-i*N)/(2*g*s*C),R=Math.log(Math.sqrt(k*k+1)-k),z=Math.log(Math.sqrt(T*T+1)-T);E=(z-R)/n,S=function(U){var G=U*E,W=Jy(R),$=f/(s*C)*(W*i6(n*G+R)-a6(R));return[m+$*y,h+$*w,f*W/Jy(n*G+R)]}}return S.duration=E*1e3*n/Math.SQRT2,S}return o.rho=function(d){var c=Math.max(.001,+d),m=c*c,h=m*m;return e(c,m,h)},o})(Math.SQRT2,2,4);var hl=0,wo=0,go=0,uw=1e3,Vd,No,Fd=0,bi=0,lu=0,$o=typeof performance=="object"&&performance.now?performance:Date,fw=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Sx(){return bi||(fw(l6),bi=$o.now()+lu)}function l6(){bi=0}function Yd(){this._call=this._time=this._next=null}Yd.prototype=hw.prototype={constructor:Yd,restart:function(e,n,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?Sx():+s)+(n==null?0:+n),!this._next&&No!==this&&(No?No._next=this:Vd=this,No=this),this._call=e,this._time=s,Bm()},stop:function(){this._call&&(this._call=null,this._time=1/0,Bm())}};function hw(e,n,s){var i=new Yd;return i.restart(e,n,s),i}function o6(){Sx(),++hl;for(var e=Vd,n;e;)(n=bi-e._time)>=0&&e._call.call(void 0,n),e=e._next;--hl}function ev(){bi=(Fd=$o.now())+lu,hl=wo=0;try{o6()}finally{hl=0,d6(),bi=0}}function c6(){var e=$o.now(),n=e-Fd;n>uw&&(lu-=n,Fd=e)}function d6(){for(var e,n=Vd,s,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(s=n._next,n._next=null,n=e?e._next=s:Vd=s);No=e,Bm(i)}function Bm(e){if(!hl){wo&&(wo=clearTimeout(wo));var n=e-bi;n>24?(e<1/0&&(wo=setTimeout(ev,e-$o.now()-lu)),go&&(go=clearInterval(go))):(go||(Fd=$o.now(),go=setInterval(c6,uw)),hl=1,fw(ev))}}function tv(e,n,s){var i=new Yd;return n=n==null?0:+n,i.restart(o=>{i.stop(),e(o+n)},n,s),i}var u6=au("start","end","cancel","interrupt"),f6=[],mw=0,nv=1,Hm=2,Ed=3,rv=4,Pm=5,Td=6;function ou(e,n,s,i,o,d){var c=e.__transition;if(!c)e.__transition={};else if(s in c)return;h6(e,s,{name:n,index:i,group:o,on:u6,tween:f6,time:d.time,delay:d.delay,duration:d.duration,ease:d.ease,timer:null,state:mw})}function Cx(e,n){var s=hs(e,n);if(s.state>mw)throw new Error("too late; already scheduled");return s}function As(e,n){var s=hs(e,n);if(s.state>Ed)throw new Error("too late; already running");return s}function hs(e,n){var s=e.__transition;if(!s||!(s=s[n]))throw new Error("transition not found");return s}function h6(e,n,s){var i=e.__transition,o;i[n]=s,s.timer=hw(d,0,s.time);function d(f){s.state=nv,s.timer.restart(c,s.delay,s.time),s.delay<=f&&c(f-s.delay)}function c(f){var p,x,g,y;if(s.state!==nv)return h();for(p in i)if(y=i[p],y.name===s.name){if(y.state===Ed)return tv(c);y.state===rv?(y.state=Td,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete i[p]):+p<n&&(y.state=Td,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete i[p])}if(tv(function(){s.state===Ed&&(s.state=rv,s.timer.restart(m,s.delay,s.time),m(f))}),s.state=Hm,s.on.call("start",e,e.__data__,s.index,s.group),s.state===Hm){for(s.state=Ed,o=new Array(g=s.tween.length),p=0,x=-1;p<g;++p)(y=s.tween[p].value.call(e,e.__data__,s.index,s.group))&&(o[++x]=y);o.length=x+1}}function m(f){for(var p=f<s.duration?s.ease.call(null,f/s.duration):(s.timer.restart(h),s.state=Pm,1),x=-1,g=o.length;++x<g;)o[x].call(e,p);s.state===Pm&&(s.on.call("end",e,e.__data__,s.index,s.group),h())}function h(){s.state=Td,s.timer.stop(),delete i[n];for(var f in i)return;delete e.__transition}}function _d(e,n){var s=e.__transition,i,o,d=!0,c;if(s){n=n==null?null:n+"";for(c in s){if((i=s[c]).name!==n){d=!1;continue}o=i.state>Hm&&i.state<Pm,i.state=Td,i.timer.stop(),i.on.call(o?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete s[c]}d&&delete e.__transition}}function m6(e){return this.each(function(){_d(this,e)})}function x6(e,n){var s,i;return function(){var o=As(this,e),d=o.tween;if(d!==s){i=s=d;for(var c=0,m=i.length;c<m;++c)if(i[c].name===n){i=i.slice(),i.splice(c,1);break}}o.tween=i}}function p6(e,n,s){var i,o;if(typeof s!="function")throw new Error;return function(){var d=As(this,e),c=d.tween;if(c!==i){o=(i=c).slice();for(var m={name:n,value:s},h=0,f=o.length;h<f;++h)if(o[h].name===n){o[h]=m;break}h===f&&o.push(m)}d.tween=o}}function g6(e,n){var s=this._id;if(e+="",arguments.length<2){for(var i=hs(this.node(),s).tween,o=0,d=i.length,c;o<d;++o)if((c=i[o]).name===e)return c.value;return null}return this.each((n==null?x6:p6)(s,e,n))}function Ex(e,n,s){var i=e._id;return e.each(function(){var o=As(this,i);(o.value||(o.value={}))[n]=s.apply(this,arguments)}),function(o){return hs(o,i).value[n]}}function xw(e,n){var s;return(typeof n=="number"?Cs:n instanceof gi?qd:(s=gi(n))?(n=s,qd):ow)(e,n)}function b6(e){return function(){this.removeAttribute(e)}}function y6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function v6(e,n,s){var i,o=s+"",d;return function(){var c=this.getAttribute(e);return c===o?null:c===i?d:d=n(i=c,s)}}function j6(e,n,s){var i,o=s+"",d;return function(){var c=this.getAttributeNS(e.space,e.local);return c===o?null:c===i?d:d=n(i=c,s)}}function w6(e,n,s){var i,o,d;return function(){var c,m=s(this),h;return m==null?void this.removeAttribute(e):(c=this.getAttribute(e),h=m+"",c===h?null:c===i&&h===o?d:(o=h,d=n(i=c,m)))}}function N6(e,n,s){var i,o,d;return function(){var c,m=s(this),h;return m==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),h=m+"",c===h?null:c===i&&h===o?d:(o=h,d=n(i=c,m)))}}function k6(e,n){var s=iu(e),i=s==="transform"?r6:xw;return this.attrTween(e,typeof n=="function"?(s.local?N6:w6)(s,i,Ex(this,"attr."+e,n)):n==null?(s.local?y6:b6)(s):(s.local?j6:v6)(s,i,n))}function S6(e,n){return function(s){this.setAttribute(e,n.call(this,s))}}function C6(e,n){return function(s){this.setAttributeNS(e.space,e.local,n.call(this,s))}}function E6(e,n){var s,i;function o(){var d=n.apply(this,arguments);return d!==i&&(s=(i=d)&&C6(e,d)),s}return o._value=n,o}function T6(e,n){var s,i;function o(){var d=n.apply(this,arguments);return d!==i&&(s=(i=d)&&S6(e,d)),s}return o._value=n,o}function _6(e,n){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;var i=iu(e);return this.tween(s,(i.local?E6:T6)(i,n))}function A6(e,n){return function(){Cx(this,e).delay=+n.apply(this,arguments)}}function M6(e,n){return n=+n,function(){Cx(this,e).delay=n}}function O6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?A6:M6)(n,e)):hs(this.node(),n).delay}function R6(e,n){return function(){As(this,e).duration=+n.apply(this,arguments)}}function D6(e,n){return n=+n,function(){As(this,e).duration=n}}function L6(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?R6:D6)(n,e)):hs(this.node(),n).duration}function I6(e,n){if(typeof n!="function")throw new Error;return function(){As(this,e).ease=n}}function z6(e){var n=this._id;return arguments.length?this.each(I6(n,e)):hs(this.node(),n).ease}function $6(e,n){return function(){var s=n.apply(this,arguments);if(typeof s!="function")throw new Error;As(this,e).ease=s}}function B6(e){if(typeof e!="function")throw new Error;return this.each($6(this._id,e))}function H6(e){typeof e!="function"&&(e=Yj(e));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var d=n[o],c=d.length,m=i[o]=[],h,f=0;f<c;++f)(h=d[f])&&e.call(h,h.__data__,f,d)&&m.push(h);return new ta(i,this._parents,this._name,this._id)}function P6(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,s=e._groups,i=n.length,o=s.length,d=Math.min(i,o),c=new Array(i),m=0;m<d;++m)for(var h=n[m],f=s[m],p=h.length,x=c[m]=new Array(p),g,y=0;y<p;++y)(g=h[y]||f[y])&&(x[y]=g);for(;m<i;++m)c[m]=n[m];return new ta(c,this._parents,this._name,this._id)}function U6(e){return(e+"").trim().split(/^|\s+/).every(function(n){var s=n.indexOf(".");return s>=0&&(n=n.slice(0,s)),!n||n==="start"})}function q6(e,n,s){var i,o,d=U6(n)?Cx:As;return function(){var c=d(this,e),m=c.on;m!==i&&(o=(i=m).copy()).on(n,s),c.on=o}}function V6(e,n){var s=this._id;return arguments.length<2?hs(this.node(),s).on.on(e):this.each(q6(s,e,n))}function F6(e){return function(){var n=this.parentNode;for(var s in this.__transition)if(+s!==e)return;n&&n.removeChild(this)}}function Y6(){return this.on("end.remove",F6(this._id))}function G6(e){var n=this._name,s=this._id;typeof e!="function"&&(e=jx(e));for(var i=this._groups,o=i.length,d=new Array(o),c=0;c<o;++c)for(var m=i[c],h=m.length,f=d[c]=new Array(h),p,x,g=0;g<h;++g)(p=m[g])&&(x=e.call(p,p.__data__,g,m))&&("__data__"in p&&(x.__data__=p.__data__),f[g]=x,ou(f[g],n,s,g,f,hs(p,s)));return new ta(d,this._parents,n,s)}function X6(e){var n=this._name,s=this._id;typeof e!="function"&&(e=Fj(e));for(var i=this._groups,o=i.length,d=[],c=[],m=0;m<o;++m)for(var h=i[m],f=h.length,p,x=0;x<f;++x)if(p=h[x]){for(var g=e.call(p,p.__data__,x,h),y,w=hs(p,s),N=0,S=g.length;N<S;++N)(y=g[N])&&ou(y,n,s,N,g,w);d.push(g),c.push(p)}return new ta(d,c,n,s)}var K6=Ko.prototype.constructor;function W6(){return new K6(this._groups,this._parents)}function Z6(e,n){var s,i,o;return function(){var d=fl(this,e),c=(this.style.removeProperty(e),fl(this,e));return d===c?null:d===s&&c===i?o:o=n(s=d,i=c)}}function pw(e){return function(){this.style.removeProperty(e)}}function Q6(e,n,s){var i,o=s+"",d;return function(){var c=fl(this,e);return c===o?null:c===i?d:d=n(i=c,s)}}function J6(e,n,s){var i,o,d;return function(){var c=fl(this,e),m=s(this),h=m+"";return m==null&&(h=m=(this.style.removeProperty(e),fl(this,e))),c===h?null:c===i&&h===o?d:(o=h,d=n(i=c,m))}}function eO(e,n){var s,i,o,d="style."+n,c="end."+d,m;return function(){var h=As(this,e),f=h.on,p=h.value[d]==null?m||(m=pw(n)):void 0;(f!==s||o!==p)&&(i=(s=f).copy()).on(c,o=p),h.on=i}}function tO(e,n,s){var i=(e+="")=="transform"?n6:xw;return n==null?this.styleTween(e,Z6(e,i)).on("end.style."+e,pw(e)):typeof n=="function"?this.styleTween(e,J6(e,i,Ex(this,"style."+e,n))).each(eO(this._id,e)):this.styleTween(e,Q6(e,i,n),s).on("end.style."+e,null)}function nO(e,n,s){return function(i){this.style.setProperty(e,n.call(this,i),s)}}function rO(e,n,s){var i,o;function d(){var c=n.apply(this,arguments);return c!==o&&(i=(o=c)&&nO(e,c,s)),i}return d._value=n,d}function sO(e,n,s){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;return this.tween(i,rO(e,n,s??""))}function aO(e){return function(){this.textContent=e}}function iO(e){return function(){var n=e(this);this.textContent=n??""}}function lO(e){return this.tween("text",typeof e=="function"?iO(Ex(this,"text",e)):aO(e==null?"":e+""))}function oO(e){return function(n){this.textContent=e.call(this,n)}}function cO(e){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&oO(o)),n}return i._value=e,i}function dO(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,cO(e))}function uO(){for(var e=this._name,n=this._id,s=gw(),i=this._groups,o=i.length,d=0;d<o;++d)for(var c=i[d],m=c.length,h,f=0;f<m;++f)if(h=c[f]){var p=hs(h,n);ou(h,e,s,f,c,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new ta(i,this._parents,e,s)}function fO(){var e,n,s=this,i=s._id,o=s.size();return new Promise(function(d,c){var m={value:c},h={value:function(){--o===0&&d()}};s.each(function(){var f=As(this,i),p=f.on;p!==e&&(n=(e=p).copy(),n._.cancel.push(m),n._.interrupt.push(m),n._.end.push(h)),f.on=n}),o===0&&d()})}var hO=0;function ta(e,n,s,i){this._groups=e,this._parents=n,this._name=s,this._id=i}function gw(){return++hO}var Xs=Ko.prototype;ta.prototype={constructor:ta,select:G6,selectAll:X6,selectChild:Xs.selectChild,selectChildren:Xs.selectChildren,filter:H6,merge:P6,selection:W6,transition:uO,call:Xs.call,nodes:Xs.nodes,node:Xs.node,size:Xs.size,empty:Xs.empty,each:Xs.each,on:V6,attr:k6,attrTween:_6,style:tO,styleTween:sO,text:lO,textTween:dO,remove:Y6,tween:g6,delay:O6,duration:L6,ease:z6,easeVarying:B6,end:fO,[Symbol.iterator]:Xs[Symbol.iterator]};function mO(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xO={time:null,delay:0,duration:250,ease:mO};function pO(e,n){for(var s;!(s=e.__transition)||!(s=s[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return s}function gO(e){var n,s;e instanceof ta?(n=e._id,e=e._name):(n=gw(),(s=xO).time=Sx(),e=e==null?null:e+"");for(var i=this._groups,o=i.length,d=0;d<o;++d)for(var c=i[d],m=c.length,h,f=0;f<m;++f)(h=c[f])&&ou(h,e,n,f,c,s||pO(h,n));return new ta(i,this._parents,e,n)}Ko.prototype.interrupt=m6;Ko.prototype.transition=gO;const xd=e=>()=>e;function bO(e,{sourceEvent:n,target:s,transform:i,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function Js(e,n,s){this.k=e,this.x=n,this.y=s}Js.prototype={constructor:Js,scale:function(e){return e===1?this:new Js(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Js(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var cu=new Js(1,0,0);bw.prototype=Js.prototype;function bw(e){for(;!e.__zoom;)if(!(e=e.parentNode))return cu;return e.__zoom}function Wh(e){e.stopImmediatePropagation()}function bo(e){e.preventDefault(),e.stopImmediatePropagation()}function yO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function vO(){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 sv(){return this.__zoom||cu}function jO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wO(){return navigator.maxTouchPoints||"ontouchstart"in this}function NO(e,n,s){var i=e.invertX(n[0][0])-s[0][0],o=e.invertX(n[1][0])-s[1][0],d=e.invertY(n[0][1])-s[0][1],c=e.invertY(n[1][1])-s[1][1];return e.translate(o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o),c>d?(d+c)/2:Math.min(0,d)||Math.max(0,c))}function yw(){var e=yO,n=vO,s=NO,i=jO,o=wO,d=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],m=250,h=Cd,f=au("start","zoom","end"),p,x,g,y=500,w=150,N=0,S=10;function E(M){M.property("__zoom",sv).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",W).on("dblclick.zoom",$).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",Y).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(M,L,A,O){var D=M.selection?M.selection():M;D.property("__zoom",sv),M!==D?R(M,L,A,O):D.interrupt().each(function(){z(this,arguments).event(O).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},E.scaleBy=function(M,L,A,O){E.scaleTo(M,function(){var D=this.__zoom.k,Z=typeof L=="function"?L.apply(this,arguments):L;return D*Z},A,O)},E.scaleTo=function(M,L,A,O){E.transform(M,function(){var D=n.apply(this,arguments),Z=this.__zoom,B=A==null?T(D):typeof A=="function"?A.apply(this,arguments):A,q=Z.invert(B),X=typeof L=="function"?L.apply(this,arguments):L;return s(k(C(Z,X),B,q),D,c)},A,O)},E.translateBy=function(M,L,A,O){E.transform(M,function(){return s(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof A=="function"?A.apply(this,arguments):A),n.apply(this,arguments),c)},null,O)},E.translateTo=function(M,L,A,O,D){E.transform(M,function(){var Z=n.apply(this,arguments),B=this.__zoom,q=O==null?T(Z):typeof O=="function"?O.apply(this,arguments):O;return s(cu.translate(q[0],q[1]).scale(B.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof A=="function"?-A.apply(this,arguments):-A),Z,c)},O,D)};function C(M,L){return L=Math.max(d[0],Math.min(d[1],L)),L===M.k?M:new Js(L,M.x,M.y)}function k(M,L,A){var O=L[0]-A[0]*M.k,D=L[1]-A[1]*M.k;return O===M.x&&D===M.y?M:new Js(M.k,O,D)}function T(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function R(M,L,A,O){M.on("start.zoom",function(){z(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(O).end()}).tween("zoom",function(){var D=this,Z=arguments,B=z(D,Z).event(O),q=n.apply(D,Z),X=A==null?T(q):typeof A=="function"?A.apply(D,Z):A,I=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),_=D.__zoom,V=typeof L=="function"?L.apply(D,Z):L,Q=h(_.invert(X).concat(I/_.k),V.invert(X).concat(I/V.k));return function(ee){if(ee===1)ee=V;else{var te=Q(ee),ae=I/te[2];ee=new Js(ae,X[0]-te[0]*ae,X[1]-te[1]*ae)}B.zoom(null,ee)}})}function z(M,L,A){return!A&&M.__zooming||new U(M,L)}function U(M,L){this.that=M,this.args=L,this.active=0,this.sourceEvent=null,this.extent=n.apply(M,L),this.taps=0}U.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,L){return this.mouse&&M!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var L=$r(this.that).datum();f.call(M,this.that,new bO(M,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:f}),L)}};function G(M,...L){if(!e.apply(this,arguments))return;var A=z(this,L).event(M),O=this.__zoom,D=Math.max(d[0],Math.min(d[1],O.k*Math.pow(2,i.apply(this,arguments)))),Z=ls(M);if(A.wheel)(A.mouse[0][0]!==Z[0]||A.mouse[0][1]!==Z[1])&&(A.mouse[1]=O.invert(A.mouse[0]=Z)),clearTimeout(A.wheel);else{if(O.k===D)return;A.mouse=[Z,O.invert(Z)],_d(this),A.start()}bo(M),A.wheel=setTimeout(B,w),A.zoom("mouse",s(k(C(O,D),A.mouse[0],A.mouse[1]),A.extent,c));function B(){A.wheel=null,A.end()}}function W(M,...L){if(g||!e.apply(this,arguments))return;var A=M.currentTarget,O=z(this,L,!0).event(M),D=$r(M.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",I,!0),Z=ls(M,A),B=M.clientX,q=M.clientY;nw(M.view),Wh(M),O.mouse=[Z,this.__zoom.invert(Z)],_d(this),O.start();function X(_){if(bo(_),!O.moved){var V=_.clientX-B,Q=_.clientY-q;O.moved=V*V+Q*Q>N}O.event(_).zoom("mouse",s(k(O.that.__zoom,O.mouse[0]=ls(_,A),O.mouse[1]),O.extent,c))}function I(_){D.on("mousemove.zoom mouseup.zoom",null),rw(_.view,O.moved),bo(_),O.event(_).end()}}function $(M,...L){if(e.apply(this,arguments)){var A=this.__zoom,O=ls(M.changedTouches?M.changedTouches[0]:M,this),D=A.invert(O),Z=A.k*(M.shiftKey?.5:2),B=s(k(C(A,Z),O,D),n.apply(this,L),c);bo(M),m>0?$r(this).transition().duration(m).call(R,B,O,M):$r(this).call(E.transform,B,O,M)}}function F(M,...L){if(e.apply(this,arguments)){var A=M.touches,O=A.length,D=z(this,L,M.changedTouches.length===O).event(M),Z,B,q,X;for(Wh(M),B=0;B<O;++B)q=A[B],X=ls(q,this),X=[X,this.__zoom.invert(X),q.identifier],D.touch0?!D.touch1&&D.touch0[2]!==X[2]&&(D.touch1=X,D.taps=0):(D.touch0=X,Z=!0,D.taps=1+!!p);p&&(p=clearTimeout(p)),Z&&(D.taps<2&&(x=X[0],p=setTimeout(function(){p=null},y)),_d(this),D.start())}}function Y(M,...L){if(this.__zooming){var A=z(this,L).event(M),O=M.changedTouches,D=O.length,Z,B,q,X;for(bo(M),Z=0;Z<D;++Z)B=O[Z],q=ls(B,this),A.touch0&&A.touch0[2]===B.identifier?A.touch0[0]=q:A.touch1&&A.touch1[2]===B.identifier&&(A.touch1[0]=q);if(B=A.that.__zoom,A.touch1){var I=A.touch0[0],_=A.touch0[1],V=A.touch1[0],Q=A.touch1[1],ee=(ee=V[0]-I[0])*ee+(ee=V[1]-I[1])*ee,te=(te=Q[0]-_[0])*te+(te=Q[1]-_[1])*te;B=C(B,Math.sqrt(ee/te)),q=[(I[0]+V[0])/2,(I[1]+V[1])/2],X=[(_[0]+Q[0])/2,(_[1]+Q[1])/2]}else if(A.touch0)q=A.touch0[0],X=A.touch0[1];else return;A.zoom("touch",s(k(B,q,X),A.extent,c))}}function P(M,...L){if(this.__zooming){var A=z(this,L).event(M),O=M.changedTouches,D=O.length,Z,B;for(Wh(M),g&&clearTimeout(g),g=setTimeout(function(){g=null},y),Z=0;Z<D;++Z)B=O[Z],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=ls(B,this),Math.hypot(x[0]-B[0],x[1]-B[1])<S)){var q=$r(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return E.wheelDelta=function(M){return arguments.length?(i=typeof M=="function"?M:xd(+M),E):i},E.filter=function(M){return arguments.length?(e=typeof M=="function"?M:xd(!!M),E):e},E.touchable=function(M){return arguments.length?(o=typeof M=="function"?M:xd(!!M),E):o},E.extent=function(M){return arguments.length?(n=typeof M=="function"?M:xd([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),E):n},E.scaleExtent=function(M){return arguments.length?(d[0]=+M[0],d[1]=+M[1],E):[d[0],d[1]]},E.translateExtent=function(M){return arguments.length?(c[0][0]=+M[0][0],c[1][0]=+M[1][0],c[0][1]=+M[0][1],c[1][1]=+M[1][1],E):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},E.constrain=function(M){return arguments.length?(s=M,E):s},E.duration=function(M){return arguments.length?(m=+M,E):m},E.interpolate=function(M){return arguments.length?(h=M,E):h},E.on=function(){var M=f.on.apply(f,arguments);return M===f?E:M},E.clickDistance=function(M){return arguments.length?(N=(M=+M)*M,E):Math.sqrt(N)},E.tapDistance=function(M){return arguments.length?(S=+M,E):S},E}const Ts={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:s,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:i}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Bo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],vw=["Enter"," ","Escape"],jw={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:s})=>`Moved selected node ${e}. New position, x: ${n}, y: ${s}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ml;(function(e){e.Strict="strict",e.Loose="loose"})(ml||(ml={}));var mi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(mi||(mi={}));var Ho;(function(e){e.Partial="partial",e.Full="full"})(Ho||(Ho={}));const ww={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ia;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ia||(Ia={}));var xl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(xl||(xl={}));var ft;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ft||(ft={}));const av={[ft.Left]:ft.Right,[ft.Right]:ft.Left,[ft.Top]:ft.Bottom,[ft.Bottom]:ft.Top};function Nw(e){return e===null?null:e?"valid":"invalid"}const kw=e=>"id"in e&&"source"in e&&"target"in e,kO=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tx=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Zo=(e,n=[0,0])=>{const{width:s,height:i}=ra(e),o=e.origin??n,d=s*o[0],c=i*o[1];return{x:e.position.x-d,y:e.position.y-c}},SO=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((i,o)=>{const d=typeof o=="string";let c=!n.nodeLookup&&!d?o:void 0;n.nodeLookup&&(c=d?n.nodeLookup.get(o):Tx(o)?o:n.nodeLookup.get(o.id));const m=c?Gd(c,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return du(i,m)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uu(s)},Qo=(e,n={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(o=>{(n.filter===void 0||n.filter(o))&&(s=du(s,Gd(o)),i=!0)}),i?uu(s):{x:0,y:0,width:0,height:0}},_x=(e,n,[s,i,o]=[0,0,1],d=!1,c=!1)=>{const m={...ec(n,[s,i,o]),width:n.width/o,height:n.height/o},h=[];for(const f of e.values()){const{measured:p,selectable:x=!0,hidden:g=!1}=f;if(c&&!x||g)continue;const y=p.width??f.width??f.initialWidth??null,w=p.height??f.height??f.initialHeight??null,N=Po(m,gl(f)),S=(y??0)*(w??0),E=d&&N>0;(!f.internals.handleBounds||E||N>=S||f.dragging)&&h.push(f)}return h},CO=(e,n)=>{const s=new Set;return e.forEach(i=>{s.add(i.id)}),n.filter(i=>s.has(i.source)||s.has(i.target))};function EO(e,n){const s=new Map,i=n?.nodes?new Set(n.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(n?.includeHiddenNodes||!o.hidden)&&(!i||i.has(o.id))&&s.set(o.id,o)}),s}async function TO({nodes:e,width:n,height:s,panZoom:i,minZoom:o,maxZoom:d},c){if(e.size===0)return Promise.resolve(!0);const m=EO(e,c),h=Qo(m),f=Ax(h,n,s,c?.minZoom??o,c?.maxZoom??d,c?.padding??.1);return await i.setViewport(f,{duration:c?.duration,ease:c?.ease,interpolate:c?.interpolate}),Promise.resolve(!0)}function Sw({nodeId:e,nextPosition:n,nodeLookup:s,nodeOrigin:i=[0,0],nodeExtent:o,onError:d}){const c=s.get(e),m=c.parentId?s.get(c.parentId):void 0,{x:h,y:f}=m?m.internals.positionAbsolute:{x:0,y:0},p=c.origin??i;let x=c.extent||o;if(c.extent==="parent"&&!c.expandParent)if(!m)d?.("005",Ts.error005());else{const y=m.measured.width,w=m.measured.height;y&&w&&(x=[[h,f],[h+y,f+w]])}else m&&bl(c.extent)&&(x=[[c.extent[0][0]+h,c.extent[0][1]+f],[c.extent[1][0]+h,c.extent[1][1]+f]]);const g=bl(x)?yi(n,x,c.measured):n;return(c.measured.width===void 0||c.measured.height===void 0)&&d?.("015",Ts.error015()),{position:{x:g.x-h+(c.measured.width??0)*p[0],y:g.y-f+(c.measured.height??0)*p[1]},positionAbsolute:g}}async function _O({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:i,onBeforeDelete:o}){const d=new Set(e.map(g=>g.id)),c=[];for(const g of s){if(g.deletable===!1)continue;const y=d.has(g.id),w=!y&&g.parentId&&c.find(N=>N.id===g.parentId);(y||w)&&c.push(g)}const m=new Set(n.map(g=>g.id)),h=i.filter(g=>g.deletable!==!1),p=CO(c,h);for(const g of h)m.has(g.id)&&!p.find(w=>w.id===g.id)&&p.push(g);if(!o)return{edges:p,nodes:c};const x=await o({nodes:c,edges:p});return typeof x=="boolean"?x?{edges:p,nodes:c}:{edges:[],nodes:[]}:x}const pl=(e,n=0,s=1)=>Math.min(Math.max(e,n),s),yi=(e={x:0,y:0},n,s)=>({x:pl(e.x,n[0][0],n[1][0]-(s?.width??0)),y:pl(e.y,n[0][1],n[1][1]-(s?.height??0))});function Cw(e,n,s){const{width:i,height:o}=ra(s),{x:d,y:c}=s.internals.positionAbsolute;return yi(e,[[d,c],[d+i,c+o]],n)}const iv=(e,n,s)=>e<n?pl(Math.abs(e-n),1,n)/n:e>s?-pl(Math.abs(e-s),1,n)/n:0,Ew=(e,n,s=15,i=40)=>{const o=iv(e.x,i,n.width-i)*s,d=iv(e.y,i,n.height-i)*s;return[o,d]},du=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),Um=({x:e,y:n,width:s,height:i})=>({x:e,y:n,x2:e+s,y2:n+i}),uu=({x:e,y:n,x2:s,y2:i})=>({x:e,y:n,width:s-e,height:i-n}),gl=(e,n=[0,0])=>{const{x:s,y:i}=Tx(e)?e.internals.positionAbsolute:Zo(e,n);return{x:s,y:i,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Gd=(e,n=[0,0])=>{const{x:s,y:i}=Tx(e)?e.internals.positionAbsolute:Zo(e,n);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)}},Tw=(e,n)=>uu(du(Um(e),Um(n))),Po=(e,n)=>{const s=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),i=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(s*i)},lv=e=>cs(e.width)&&cs(e.height)&&cs(e.x)&&cs(e.y),cs=e=>!isNaN(e)&&isFinite(e),AO=(e,n)=>{},Jo=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),ec=({x:e,y:n},[s,i,o],d=!1,c=[1,1])=>{const m={x:(e-s)/o,y:(n-i)/o};return d?Jo(m,c):m},Xd=({x:e,y:n},[s,i,o])=>({x:e*o+s,y:n*o+i});function Ji(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(s)}if(typeof e=="string"&&e.endsWith("%")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(n*s*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function MO(e,n,s){if(typeof e=="string"||typeof e=="number"){const i=Ji(e,s),o=Ji(e,n);return{top:i,right:o,bottom:i,left:o,x:o*2,y:i*2}}if(typeof e=="object"){const i=Ji(e.top??e.y??0,s),o=Ji(e.bottom??e.y??0,s),d=Ji(e.left??e.x??0,n),c=Ji(e.right??e.x??0,n);return{top:i,right:c,bottom:o,left:d,x:d+c,y:i+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function OO(e,n,s,i,o,d){const{x:c,y:m}=Xd(e,[n,s,i]),{x:h,y:f}=Xd({x:e.x+e.width,y:e.y+e.height},[n,s,i]),p=o-h,x=d-f;return{left:Math.floor(c),top:Math.floor(m),right:Math.floor(p),bottom:Math.floor(x)}}const Ax=(e,n,s,i,o,d)=>{const c=MO(d,n,s),m=(n-c.x)/e.width,h=(s-c.y)/e.height,f=Math.min(m,h),p=pl(f,i,o),x=e.x+e.width/2,g=e.y+e.height/2,y=n/2-x*p,w=s/2-g*p,N=OO(e,y,w,p,n,s),S={left:Math.min(N.left-c.left,0),top:Math.min(N.top-c.top,0),right:Math.min(N.right-c.right,0),bottom:Math.min(N.bottom-c.bottom,0)};return{x:y-S.left+S.right,y:w-S.top+S.bottom,zoom:p}},Uo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function bl(e){return e!=null&&e!=="parent"}function ra(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function _w(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Aw(e,n={width:0,height:0},s,i,o){const d={...e},c=i.get(s);if(c){const m=c.origin||o;d.x+=c.internals.positionAbsolute.x-(n.width??0)*m[0],d.y+=c.internals.positionAbsolute.y-(n.height??0)*m[1]}return d}function ov(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function RO(){let e,n;return{promise:new Promise((i,o)=>{e=i,n=o}),resolve:e,reject:n}}function DO(e){return{...jw,...e||{}}}function Ao(e,{snapGrid:n=[0,0],snapToGrid:s=!1,transform:i,containerBounds:o}){const{x:d,y:c}=ds(e),m=ec({x:d-(o?.left??0),y:c-(o?.top??0)},i),{x:h,y:f}=s?Jo(m,n):m;return{xSnapped:h,ySnapped:f,...m}}const Mx=e=>({width:e.offsetWidth,height:e.offsetHeight}),Mw=e=>e?.getRootNode?.()||window?.document,LO=["INPUT","SELECT","TEXTAREA"];function Ow(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:LO.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const Rw=e=>"clientX"in e,ds=(e,n)=>{const s=Rw(e),i=s?e.clientX:e.touches?.[0].clientX,o=s?e.clientY:e.touches?.[0].clientY;return{x:i-(n?.left??0),y:o-(n?.top??0)}},cv=(e,n,s,i,o)=>{const d=n.querySelectorAll(`.${e}`);return!d||!d.length?null:Array.from(d).map(c=>{const m=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:o,position:c.getAttribute("data-handlepos"),x:(m.left-s.left)/i,y:(m.top-s.top)/i,...Mx(c)}})};function Dw({sourceX:e,sourceY:n,targetX:s,targetY:i,sourceControlX:o,sourceControlY:d,targetControlX:c,targetControlY:m}){const h=e*.125+o*.375+c*.375+s*.125,f=n*.125+d*.375+m*.375+i*.125,p=Math.abs(h-e),x=Math.abs(f-n);return[h,f,p,x]}function pd(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function dv({pos:e,x1:n,y1:s,x2:i,y2:o,c:d}){switch(e){case ft.Left:return[n-pd(n-i,d),s];case ft.Right:return[n+pd(i-n,d),s];case ft.Top:return[n,s-pd(s-o,d)];case ft.Bottom:return[n,s+pd(o-s,d)]}}function Lw({sourceX:e,sourceY:n,sourcePosition:s=ft.Bottom,targetX:i,targetY:o,targetPosition:d=ft.Top,curvature:c=.25}){const[m,h]=dv({pos:s,x1:e,y1:n,x2:i,y2:o,c}),[f,p]=dv({pos:d,x1:i,y1:o,x2:e,y2:n,c}),[x,g,y,w]=Dw({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:m,sourceControlY:h,targetControlX:f,targetControlY:p});return[`M${e},${n} C${m},${h} ${f},${p} ${i},${o}`,x,g,y,w]}function Iw({sourceX:e,sourceY:n,targetX:s,targetY:i}){const o=Math.abs(s-e)/2,d=s<e?s+o:s-o,c=Math.abs(i-n)/2,m=i<n?i+c:i-c;return[d,m,o,c]}function IO({sourceNode:e,targetNode:n,selected:s=!1,zIndex:i=0,elevateOnSelect:o=!1,zIndexMode:d="basic"}){if(d==="manual")return i;const c=o&&s?i+1e3:i,m=Math.max(e.parentId||o&&e.selected?e.internals.z:0,n.parentId||o&&n.selected?n.internals.z:0);return c+m}function zO({sourceNode:e,targetNode:n,width:s,height:i,transform:o}){const d=du(Gd(e),Gd(n));d.x===d.x2&&(d.x2+=1),d.y===d.y2&&(d.y2+=1);const c={x:-o[0]/o[2],y:-o[1]/o[2],width:s/o[2],height:i/o[2]};return Po(c,uu(d))>0}const $O=({source:e,sourceHandle:n,target:s,targetHandle:i})=>`xy-edge__${e}${n||""}-${s}${i||""}`,BO=(e,n)=>n.some(s=>s.source===e.source&&s.target===e.target&&(s.sourceHandle===e.sourceHandle||!s.sourceHandle&&!e.sourceHandle)&&(s.targetHandle===e.targetHandle||!s.targetHandle&&!e.targetHandle)),HO=(e,n,s={})=>{if(!e.source||!e.target)return n;const i=s.getEdgeId||$O;let o;return kw(e)?o={...e}:o={...e,id:i(e)},BO(o,n)?n:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,n.concat(o))};function zw({sourceX:e,sourceY:n,targetX:s,targetY:i}){const[o,d,c,m]=Iw({sourceX:e,sourceY:n,targetX:s,targetY:i});return[`M ${e},${n}L ${s},${i}`,o,d,c,m]}const uv={[ft.Left]:{x:-1,y:0},[ft.Right]:{x:1,y:0},[ft.Top]:{x:0,y:-1},[ft.Bottom]:{x:0,y:1}},PO=({source:e,sourcePosition:n=ft.Bottom,target:s})=>n===ft.Left||n===ft.Right?e.x<s.x?{x:1,y:0}:{x:-1,y:0}:e.y<s.y?{x:0,y:1}:{x:0,y:-1},fv=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function UO({source:e,sourcePosition:n=ft.Bottom,target:s,targetPosition:i=ft.Top,center:o,offset:d,stepPosition:c}){const m=uv[n],h=uv[i],f={x:e.x+m.x*d,y:e.y+m.y*d},p={x:s.x+h.x*d,y:s.y+h.y*d},x=PO({source:f,sourcePosition:n,target:p}),g=x.x!==0?"x":"y",y=x[g];let w=[],N,S;const E={x:0,y:0},C={x:0,y:0},[,,k,T]=Iw({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(m[g]*h[g]===-1){g==="x"?(N=o.x??f.x+(p.x-f.x)*c,S=o.y??(f.y+p.y)/2):(N=o.x??(f.x+p.x)/2,S=o.y??f.y+(p.y-f.y)*c);const z=[{x:N,y:f.y},{x:N,y:p.y}],U=[{x:f.x,y:S},{x:p.x,y:S}];m[g]===y?w=g==="x"?z:U:w=g==="x"?U:z}else{const z=[{x:f.x,y:p.y}],U=[{x:p.x,y:f.y}];if(g==="x"?w=m.x===y?U:z:w=m.y===y?z:U,n===i){const Y=Math.abs(e[g]-s[g]);if(Y<=d){const P=Math.min(d-1,d-Y);m[g]===y?E[g]=(f[g]>e[g]?-1:1)*P:C[g]=(p[g]>s[g]?-1:1)*P}}if(n!==i){const Y=g==="x"?"y":"x",P=m[g]===h[Y],M=f[Y]>p[Y],L=f[Y]<p[Y];(m[g]===1&&(!P&&M||P&&L)||m[g]!==1&&(!P&&L||P&&M))&&(w=g==="x"?z:U)}const G={x:f.x+E.x,y:f.y+E.y},W={x:p.x+C.x,y:p.y+C.y},$=Math.max(Math.abs(G.x-w[0].x),Math.abs(W.x-w[0].x)),F=Math.max(Math.abs(G.y-w[0].y),Math.abs(W.y-w[0].y));$>=F?(N=(G.x+W.x)/2,S=w[0].y):(N=w[0].x,S=(G.y+W.y)/2)}return[[e,{x:f.x+E.x,y:f.y+E.y},...w,{x:p.x+C.x,y:p.y+C.y},s],N,S,k,T]}function qO(e,n,s,i){const o=Math.min(fv(e,n)/2,fv(n,s)/2,i),{x:d,y:c}=n;if(e.x===d&&d===s.x||e.y===c&&c===s.y)return`L${d} ${c}`;if(e.y===c){const f=e.x<s.x?-1:1,p=e.y<s.y?1:-1;return`L ${d+o*f},${c}Q ${d},${c} ${d},${c+o*p}`}const m=e.x<s.x?1:-1,h=e.y<s.y?-1:1;return`L ${d},${c+o*h}Q ${d},${c} ${d+o*m},${c}`}function qm({sourceX:e,sourceY:n,sourcePosition:s=ft.Bottom,targetX:i,targetY:o,targetPosition:d=ft.Top,borderRadius:c=5,centerX:m,centerY:h,offset:f=20,stepPosition:p=.5}){const[x,g,y,w,N]=UO({source:{x:e,y:n},sourcePosition:s,target:{x:i,y:o},targetPosition:d,center:{x:m,y:h},offset:f,stepPosition:p});return[x.reduce((E,C,k)=>{let T="";return k>0&&k<x.length-1?T=qO(x[k-1],C,x[k+1],c):T=`${k===0?"M":"L"}${C.x} ${C.y}`,E+=T,E},""),g,y,w,N]}function hv(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function VO(e){const{sourceNode:n,targetNode:s}=e;if(!hv(n)||!hv(s))return null;const i=n.internals.handleBounds||mv(n.handles),o=s.internals.handleBounds||mv(s.handles),d=xv(i?.source??[],e.sourceHandle),c=xv(e.connectionMode===ml.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!d||!c)return e.onError?.("008",Ts.error008(d?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const m=d?.position||ft.Bottom,h=c?.position||ft.Top,f=vi(n,d,m),p=vi(s,c,h);return{sourceX:f.x,sourceY:f.y,targetX:p.x,targetY:p.y,sourcePosition:m,targetPosition:h}}function mv(e){if(!e)return null;const n=[],s=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?n.push(i):i.type==="target"&&s.push(i);return{source:n,target:s}}function vi(e,n,s=ft.Left,i=!1){const o=(n?.x??0)+e.internals.positionAbsolute.x,d=(n?.y??0)+e.internals.positionAbsolute.y,{width:c,height:m}=n??ra(e);if(i)return{x:o+c/2,y:d+m/2};switch(n?.position??s){case ft.Top:return{x:o+c/2,y:d};case ft.Right:return{x:o+c,y:d+m/2};case ft.Bottom:return{x:o+c/2,y:d+m};case ft.Left:return{x:o,y:d+m/2}}}function xv(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function Vm(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function FO(e,{id:n,defaultColor:s,defaultMarkerStart:i,defaultMarkerEnd:o}){const d=new Set;return e.reduce((c,m)=>([m.markerStart||i,m.markerEnd||o].forEach(h=>{if(h&&typeof h=="object"){const f=Vm(h,n);d.has(f)||(c.push({id:f,color:h.color||s,...h}),d.add(f))}}),c),[]).sort((c,m)=>c.id.localeCompare(m.id))}const $w=1e3,YO=10,Ox={nodeOrigin:[0,0],nodeExtent:Bo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},GO={...Ox,checkEquality:!0};function Rx(e,n){const s={...e};for(const i in n)n[i]!==void 0&&(s[i]=n[i]);return s}function XO(e,n,s){const i=Rx(Ox,s);for(const o of e.values())if(o.parentId)Lx(o,e,n,i);else{const d=Zo(o,i.nodeOrigin),c=bl(o.extent)?o.extent:i.nodeExtent,m=yi(d,c,ra(o));o.internals.positionAbsolute=m}}function KO(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const s=[],i=[];for(const o of e.handles){const d={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?s.push(d):o.type==="target"&&i.push(d)}return{source:s,target:i}}function Dx(e){return e==="manual"}function Fm(e,n,s,i={}){const o=Rx(GO,i),d={i:0},c=new Map(n),m=o?.elevateNodesOnSelect&&!Dx(o.zIndexMode)?$w:0;let h=e.length>0;n.clear(),s.clear();for(const f of e){let p=c.get(f.id);if(o.checkEquality&&f===p?.internals.userNode)n.set(f.id,p);else{const x=Zo(f,o.nodeOrigin),g=bl(f.extent)?f.extent:o.nodeExtent,y=yi(x,g,ra(f));p={...o.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:y,handleBounds:KO(f,p),z:Bw(f,m,o.zIndexMode),userNode:f}},n.set(f.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(h=!1),f.parentId&&Lx(p,n,s,i,d)}return h}function WO(e,n){if(!e.parentId)return;const s=n.get(e.parentId);s?s.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function Lx(e,n,s,i,o){const{elevateNodesOnSelect:d,nodeOrigin:c,nodeExtent:m,zIndexMode:h}=Rx(Ox,i),f=e.parentId,p=n.get(f);if(!p){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}WO(e,s),o&&!p.parentId&&p.internals.rootParentIndex===void 0&&h==="auto"&&(p.internals.rootParentIndex=++o.i,p.internals.z=p.internals.z+o.i*YO),o&&p.internals.rootParentIndex!==void 0&&(o.i=p.internals.rootParentIndex);const x=d&&!Dx(h)?$w:0,{x:g,y,z:w}=ZO(e,p,c,m,x,h),{positionAbsolute:N}=e.internals,S=g!==N.x||y!==N.y;(S||w!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:g,y}:N,z:w}})}function Bw(e,n,s){const i=cs(e.zIndex)?e.zIndex:0;return Dx(s)?i:i+(e.selected?n:0)}function ZO(e,n,s,i,o,d){const{x:c,y:m}=n.internals.positionAbsolute,h=ra(e),f=Zo(e,s),p=bl(e.extent)?yi(f,e.extent,h):f;let x=yi({x:c+p.x,y:m+p.y},i,h);e.extent==="parent"&&(x=Cw(x,h,n));const g=Bw(e,o,d),y=n.internals.z??0;return{x:x.x,y:x.y,z:y>=g?y+1:g}}function Ix(e,n,s,i=[0,0]){const o=[],d=new Map;for(const c of e){const m=n.get(c.parentId);if(!m)continue;const h=d.get(c.parentId)?.expandedRect??gl(m),f=Tw(h,c.rect);d.set(c.parentId,{expandedRect:f,parent:m})}return d.size>0&&d.forEach(({expandedRect:c,parent:m},h)=>{const f=m.internals.positionAbsolute,p=ra(m),x=m.origin??i,g=c.x<f.x?Math.round(Math.abs(f.x-c.x)):0,y=c.y<f.y?Math.round(Math.abs(f.y-c.y)):0,w=Math.max(p.width,Math.round(c.width)),N=Math.max(p.height,Math.round(c.height)),S=(w-p.width)*x[0],E=(N-p.height)*x[1];(g>0||y>0||S||E)&&(o.push({id:h,type:"position",position:{x:m.position.x-g+S,y:m.position.y-y+E}}),s.get(h)?.forEach(C=>{e.some(k=>k.id===C.id)||o.push({id:C.id,type:"position",position:{x:C.position.x+g,y:C.position.y+y}})})),(p.width<c.width||p.height<c.height||g||y)&&o.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?x[0]*g-S:0),height:N+(y?x[1]*y-E:0)}})}),o}function QO(e,n,s,i,o,d,c){const m=i?.querySelector(".xyflow__viewport");let h=!1;if(!m)return{changes:[],updatedInternals:h};const f=[],p=window.getComputedStyle(m),{m22:x}=new window.DOMMatrixReadOnly(p.transform),g=[];for(const y of e.values()){const w=n.get(y.id);if(!w)continue;if(w.hidden){n.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),h=!0;continue}const N=Mx(y.nodeElement),S=w.measured.width!==N.width||w.measured.height!==N.height;if(!!(N.width&&N.height&&(S||!w.internals.handleBounds||y.force))){const C=y.nodeElement.getBoundingClientRect(),k=bl(w.extent)?w.extent:d;let{positionAbsolute:T}=w.internals;w.parentId&&w.extent==="parent"?T=Cw(T,N,n.get(w.parentId)):k&&(T=yi(T,k,N));const R={...w,measured:N,internals:{...w.internals,positionAbsolute:T,handleBounds:{source:cv("source",y.nodeElement,C,x,w.id),target:cv("target",y.nodeElement,C,x,w.id)}}};n.set(w.id,R),w.parentId&&Lx(R,n,s,{nodeOrigin:o,zIndexMode:c}),h=!0,S&&(f.push({id:w.id,type:"dimensions",dimensions:N}),w.expandParent&&w.parentId&&g.push({id:w.id,parentId:w.parentId,rect:gl(R,o)}))}}if(g.length>0){const y=Ix(g,n,s,o);f.push(...y)}return{changes:f,updatedInternals:h}}async function JO({delta:e,panZoom:n,transform:s,translateExtent:i,width:o,height:d}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const c=await n.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[o,d]],i),m=!!c&&(c.x!==s[0]||c.y!==s[1]||c.k!==s[2]);return Promise.resolve(m)}function pv(e,n,s,i,o,d){let c=o;const m=i.get(c)||new Map;i.set(c,m.set(s,n)),c=`${o}-${e}`;const h=i.get(c)||new Map;if(i.set(c,h.set(s,n)),d){c=`${o}-${e}-${d}`;const f=i.get(c)||new Map;i.set(c,f.set(s,n))}}function Hw(e,n,s){e.clear(),n.clear();for(const i of s){const{source:o,target:d,sourceHandle:c=null,targetHandle:m=null}=i,h={edgeId:i.id,source:o,target:d,sourceHandle:c,targetHandle:m},f=`${o}-${c}--${d}-${m}`,p=`${d}-${m}--${o}-${c}`;pv("source",h,p,e,o,c),pv("target",h,f,e,d,m),n.set(i.id,i)}}function Pw(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:Pw(s,n):!1}function gv(e,n,s){let i=e;do{if(i?.matches?.(n))return!0;if(i===s)return!1;i=i?.parentElement}while(i);return!1}function eR(e,n,s,i){const o=new Map;for(const[d,c]of e)if((c.selected||c.id===i)&&(!c.parentId||!Pw(c,e))&&(c.draggable||n&&typeof c.draggable>"u")){const m=e.get(d);m&&o.set(d,{id:d,position:m.position||{x:0,y:0},distance:{x:s.x-m.internals.positionAbsolute.x,y:s.y-m.internals.positionAbsolute.y},extent:m.extent,parentId:m.parentId,origin:m.origin,expandParent:m.expandParent,internals:{positionAbsolute:m.internals.positionAbsolute||{x:0,y:0}},measured:{width:m.measured.width??0,height:m.measured.height??0}})}return o}function Zh({nodeId:e,dragItems:n,nodeLookup:s,dragging:i=!0}){const o=[];for(const[c,m]of n){const h=s.get(c)?.internals.userNode;h&&o.push({...h,position:m.position,dragging:i})}if(!e)return[o[0],o];const d=s.get(e)?.internals.userNode;return[d?{...d,position:n.get(e)?.position||d.position,dragging:i}:o[0],o]}function tR({dragItems:e,snapGrid:n,x:s,y:i}){const o=e.values().next().value;if(!o)return null;const d={x:s-o.distance.x,y:i-o.distance.y},c=Jo(d,n);return{x:c.x-d.x,y:c.y-d.y}}function nR({onNodeMouseDown:e,getStoreItems:n,onDragStart:s,onDrag:i,onDragStop:o}){let d={x:null,y:null},c=0,m=new Map,h=!1,f={x:0,y:0},p=null,x=!1,g=null,y=!1,w=!1,N=null;function S({noDragClassName:C,handleSelector:k,domNode:T,isSelectable:R,nodeId:z,nodeClickDistance:U=0}){g=$r(T);function G({x:Y,y:P}){const{nodeLookup:M,nodeExtent:L,snapGrid:A,snapToGrid:O,nodeOrigin:D,onNodeDrag:Z,onSelectionDrag:B,onError:q,updateNodePositions:X}=n();d={x:Y,y:P};let I=!1;const _=m.size>1,V=_&&L?Um(Qo(m)):null,Q=_&&O?tR({dragItems:m,snapGrid:A,x:Y,y:P}):null;for(const[ee,te]of m){if(!M.has(ee))continue;let ae={x:Y-te.distance.x,y:P-te.distance.y};O&&(ae=Q?{x:Math.round(ae.x+Q.x),y:Math.round(ae.y+Q.y)}:Jo(ae,A));let me=null;if(_&&L&&!te.extent&&V){const{positionAbsolute:je}=te.internals,Te=je.x-V.x+L[0][0],Ce=je.x+te.measured.width-V.x2+L[1][0],Re=je.y-V.y+L[0][1],Ge=je.y+te.measured.height-V.y2+L[1][1];me=[[Te,Re],[Ce,Ge]]}const{position:Ne,positionAbsolute:Ie}=Sw({nodeId:ee,nextPosition:ae,nodeLookup:M,nodeExtent:me||L,nodeOrigin:D,onError:q});I=I||te.position.x!==Ne.x||te.position.y!==Ne.y,te.position=Ne,te.internals.positionAbsolute=Ie}if(w=w||I,!!I&&(X(m,!0),N&&(i||Z||!z&&B))){const[ee,te]=Zh({nodeId:z,dragItems:m,nodeLookup:M});i?.(N,m,ee,te),Z?.(N,ee,te),z||B?.(N,te)}}async function W(){if(!p)return;const{transform:Y,panBy:P,autoPanSpeed:M,autoPanOnNodeDrag:L}=n();if(!L){h=!1,cancelAnimationFrame(c);return}const[A,O]=Ew(f,p,M);(A!==0||O!==0)&&(d.x=(d.x??0)-A/Y[2],d.y=(d.y??0)-O/Y[2],await P({x:A,y:O})&&G(d)),c=requestAnimationFrame(W)}function $(Y){const{nodeLookup:P,multiSelectionActive:M,nodesDraggable:L,transform:A,snapGrid:O,snapToGrid:D,selectNodesOnDrag:Z,onNodeDragStart:B,onSelectionDragStart:q,unselectNodesAndEdges:X}=n();x=!0,(!Z||!R)&&!M&&z&&(P.get(z)?.selected||X()),R&&Z&&z&&e?.(z);const I=Ao(Y.sourceEvent,{transform:A,snapGrid:O,snapToGrid:D,containerBounds:p});if(d=I,m=eR(P,L,I,z),m.size>0&&(s||B||!z&&q)){const[_,V]=Zh({nodeId:z,dragItems:m,nodeLookup:P});s?.(Y.sourceEvent,m,_,V),B?.(Y.sourceEvent,_,V),z||q?.(Y.sourceEvent,V)}}const F=sw().clickDistance(U).on("start",Y=>{const{domNode:P,nodeDragThreshold:M,transform:L,snapGrid:A,snapToGrid:O}=n();p=P?.getBoundingClientRect()||null,y=!1,w=!1,N=Y.sourceEvent,M===0&&$(Y),d=Ao(Y.sourceEvent,{transform:L,snapGrid:A,snapToGrid:O,containerBounds:p}),f=ds(Y.sourceEvent,p)}).on("drag",Y=>{const{autoPanOnNodeDrag:P,transform:M,snapGrid:L,snapToGrid:A,nodeDragThreshold:O,nodeLookup:D}=n(),Z=Ao(Y.sourceEvent,{transform:M,snapGrid:L,snapToGrid:A,containerBounds:p});if(N=Y.sourceEvent,(Y.sourceEvent.type==="touchmove"&&Y.sourceEvent.touches.length>1||z&&!D.has(z))&&(y=!0),!y){if(!h&&P&&x&&(h=!0,W()),!x){const B=ds(Y.sourceEvent,p),q=B.x-f.x,X=B.y-f.y;Math.sqrt(q*q+X*X)>O&&$(Y)}(d.x!==Z.xSnapped||d.y!==Z.ySnapped)&&m&&x&&(f=ds(Y.sourceEvent,p),G(Z))}}).on("end",Y=>{if(!(!x||y)&&(h=!1,x=!1,cancelAnimationFrame(c),m.size>0)){const{nodeLookup:P,updateNodePositions:M,onNodeDragStop:L,onSelectionDragStop:A}=n();if(w&&(M(m,!1),w=!1),o||L||!z&&A){const[O,D]=Zh({nodeId:z,dragItems:m,nodeLookup:P,dragging:!1});o?.(Y.sourceEvent,m,O,D),L?.(Y.sourceEvent,O,D),z||A?.(Y.sourceEvent,D)}}}).filter(Y=>{const P=Y.target;return!Y.button&&(!C||!gv(P,`.${C}`,T))&&(!k||gv(P,k,T))});g.call(F)}function E(){g?.on(".drag",null)}return{update:S,destroy:E}}function rR(e,n,s){const i=[],o={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const d of n.values())Po(o,gl(d))>0&&i.push(d);return i}const sR=250;function aR(e,n,s,i){let o=[],d=1/0;const c=rR(e,s,n+sR);for(const m of c){const h=[...m.internals.handleBounds?.source??[],...m.internals.handleBounds?.target??[]];for(const f of h){if(i.nodeId===f.nodeId&&i.type===f.type&&i.id===f.id)continue;const{x:p,y:x}=vi(m,f,f.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(x-e.y,2));g>n||(g<d?(o=[{...f,x:p,y:x}],d=g):g===d&&o.push({...f,x:p,y:x}))}}if(!o.length)return null;if(o.length>1){const m=i.type==="source"?"target":"source";return o.find(h=>h.type===m)??o[0]}return o[0]}function Uw(e,n,s,i,o,d=!1){const c=i.get(e);if(!c)return null;const m=o==="strict"?c.internals.handleBounds?.[n]:[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]],h=(s?m?.find(f=>f.id===s):m?.[0])??null;return h&&d?{...h,...vi(c,h,h.position,!0)}:h}function qw(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function iR(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const Vw=()=>!0;function lR(e,{connectionMode:n,connectionRadius:s,handleId:i,nodeId:o,edgeUpdaterType:d,isTarget:c,domNode:m,nodeLookup:h,lib:f,autoPanOnConnect:p,flowId:x,panBy:g,cancelConnection:y,onConnectStart:w,onConnect:N,onConnectEnd:S,isValidConnection:E=Vw,onReconnectEnd:C,updateConnection:k,getTransform:T,getFromHandle:R,autoPanSpeed:z,dragThreshold:U=1,handleDomNode:G}){const W=Mw(e.target);let $=0,F;const{x:Y,y:P}=ds(e),M=qw(d,G),L=m?.getBoundingClientRect();let A=!1;if(!L||!M)return;const O=Uw(o,M,i,h,n);if(!O)return;let D=ds(e,L),Z=!1,B=null,q=!1,X=null;function I(){if(!p||!L)return;const[Ne,Ie]=Ew(D,L,z);g({x:Ne,y:Ie}),$=requestAnimationFrame(I)}const _={...O,nodeId:o,type:M,position:O.position},V=h.get(o);let ee={inProgress:!0,isValid:null,from:vi(V,_,ft.Left,!0),fromHandle:_,fromPosition:_.position,fromNode:V,to:D,toHandle:null,toPosition:av[_.position],toNode:null,pointer:D};function te(){A=!0,k(ee),w?.(e,{nodeId:o,handleId:i,handleType:M})}U===0&&te();function ae(Ne){if(!A){const{x:Ge,y:ot}=ds(Ne),st=Ge-Y,jt=ot-P;if(!(st*st+jt*jt>U*U))return;te()}if(!R()||!_){me(Ne);return}const Ie=T();D=ds(Ne,L),F=aR(ec(D,Ie,!1,[1,1]),s,h,_),Z||(I(),Z=!0);const je=Fw(Ne,{handle:F,connectionMode:n,fromNodeId:o,fromHandleId:i,fromType:c?"target":"source",isValidConnection:E,doc:W,lib:f,flowId:x,nodeLookup:h});X=je.handleDomNode,B=je.connection,q=iR(!!F,je.isValid);const Te=h.get(o),Ce=Te?vi(Te,_,ft.Left,!0):ee.from,Re={...ee,from:Ce,isValid:q,to:je.toHandle&&q?Xd({x:je.toHandle.x,y:je.toHandle.y},Ie):D,toHandle:je.toHandle,toPosition:q&&je.toHandle?je.toHandle.position:av[_.position],toNode:je.toHandle?h.get(je.toHandle.nodeId):null,pointer:D};k(Re),ee=Re}function me(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(A){(F||X)&&B&&q&&N?.(B);const{inProgress:Ie,...je}=ee,Te={...je,toPosition:ee.toHandle?ee.toPosition:null};S?.(Ne,Te),d&&C?.(Ne,Te)}y(),cancelAnimationFrame($),Z=!1,q=!1,B=null,X=null,W.removeEventListener("mousemove",ae),W.removeEventListener("mouseup",me),W.removeEventListener("touchmove",ae),W.removeEventListener("touchend",me)}}W.addEventListener("mousemove",ae),W.addEventListener("mouseup",me),W.addEventListener("touchmove",ae),W.addEventListener("touchend",me)}function Fw(e,{handle:n,connectionMode:s,fromNodeId:i,fromHandleId:o,fromType:d,doc:c,lib:m,flowId:h,isValidConnection:f=Vw,nodeLookup:p}){const x=d==="target",g=n?c.querySelector(`.${m}-flow__handle[data-id="${h}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:y,y:w}=ds(e),N=c.elementFromPoint(y,w),S=N?.classList.contains(`${m}-flow__handle`)?N:g,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const C=qw(void 0,S),k=S.getAttribute("data-nodeid"),T=S.getAttribute("data-handleid"),R=S.classList.contains("connectable"),z=S.classList.contains("connectableend");if(!k||!C)return E;const U={source:x?k:i,sourceHandle:x?T:o,target:x?i:k,targetHandle:x?o:T};E.connection=U;const W=R&&z&&(s===ml.Strict?x&&C==="source"||!x&&C==="target":k!==i||T!==o);E.isValid=W&&f(U),E.toHandle=Uw(k,C,T,p,s,!0)}return E}const Ym={onPointerDown:lR,isValid:Fw};function oR({domNode:e,panZoom:n,getTransform:s,getViewScale:i}){const o=$r(e);function d({translateExtent:m,width:h,height:f,zoomStep:p=1,pannable:x=!0,zoomable:g=!0,inversePan:y=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!n)return;const T=s(),R=k.sourceEvent.ctrlKey&&Uo()?10:1,z=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*p,U=T[2]*Math.pow(2,z*R);n.scaleTo(U)};let N=[0,0];const S=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(N=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},E=k=>{const T=s();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!n)return;const R=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],z=[R[0]-N[0],R[1]-N[1]];N=R;const U=i()*Math.max(T[2],Math.log(T[2]))*(y?-1:1),G={x:T[0]-z[0]*U,y:T[1]-z[1]*U},W=[[0,0],[h,f]];n.setViewportConstrained({x:G.x,y:G.y,zoom:T[2]},W,m)},C=yw().on("start",S).on("zoom",x?E:null).on("zoom.wheel",g?w:null);o.call(C,{})}function c(){o.on("zoom",null)}return{update:d,destroy:c,pointer:ls}}const fu=e=>({x:e.x,y:e.y,zoom:e.k}),Qh=({x:e,y:n,zoom:s})=>cu.translate(e,n).scale(s),il=(e,n)=>e.target.closest(`.${n}`),Yw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),cR=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Jh=(e,n=0,s=cR,i=()=>{})=>{const o=typeof n=="number"&&n>0;return o||i(),o?e.transition().duration(n).ease(s).on("end",i):e},Gw=e=>{const n=e.ctrlKey&&Uo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function dR({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:i,panOnScrollMode:o,panOnScrollSpeed:d,zoomOnPinch:c,onPanZoomStart:m,onPanZoom:h,onPanZoomEnd:f}){return p=>{if(il(p,n))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const x=s.property("__zoom").k||1;if(p.ctrlKey&&c){const S=ls(p),E=Gw(p),C=x*Math.pow(2,E);i.scaleTo(s,C,S,p);return}const g=p.deltaMode===1?20:1;let y=o===mi.Vertical?0:p.deltaX*g,w=o===mi.Horizontal?0:p.deltaY*g;!Uo()&&p.shiftKey&&o!==mi.Vertical&&(y=p.deltaY*g,w=0),i.translateBy(s,-(y/x)*d,-(w/x)*d,{internal:!0});const N=fu(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(h?.(p,N),e.panScrollTimeout=setTimeout(()=>{f?.(p,N),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,m?.(p,N))}}function uR({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:s}){return function(i,o){const d=i.type==="wheel",c=!n&&d&&!i.ctrlKey,m=il(i,e);if(i.ctrlKey&&d&&m&&i.preventDefault(),c||m)return null;i.preventDefault(),s.call(this,i,o)}}function fR({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return i=>{if(i.sourceEvent?.internal)return;const o=fu(i.transform);e.mouseButton=i.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,i.sourceEvent?.type==="mousedown"&&n(!0),s&&s?.(i.sourceEvent,o)}}function hR({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:i,onPanZoom:o}){return d=>{e.usedRightMouseButton=!!(s&&Yw(n,e.mouseButton??0)),d.sourceEvent?.sync||i([d.transform.x,d.transform.y,d.transform.k]),o&&!d.sourceEvent?.internal&&o?.(d.sourceEvent,fu(d.transform))}}function mR({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:i,onPanZoomEnd:o,onPaneContextMenu:d}){return c=>{if(!c.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,d&&Yw(n,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&d(c.sourceEvent),e.usedRightMouseButton=!1,i(!1),o)){const m=fu(c.transform);e.prevViewport=m,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(c.sourceEvent,m)},s?150:0)}}}function xR({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:i,panOnScroll:o,zoomOnDoubleClick:d,userSelectionActive:c,noWheelClassName:m,noPanClassName:h,lib:f,connectionInProgress:p}){return x=>{const g=e||n,y=s&&x.ctrlKey,w=x.type==="wheel";if(x.button===1&&x.type==="mousedown"&&(il(x,`${f}-flow__node`)||il(x,`${f}-flow__edge`)))return!0;if(!i&&!g&&!o&&!d&&!s||c||p&&!w||il(x,m)&&w||il(x,h)&&(!w||o&&w&&!e)||!s&&x.ctrlKey&&w)return!1;if(!s&&x.type==="touchstart"&&x.touches?.length>1)return x.preventDefault(),!1;if(!g&&!o&&!y&&w||!i&&(x.type==="mousedown"||x.type==="touchstart")||Array.isArray(i)&&!i.includes(x.button)&&x.type==="mousedown")return!1;const N=Array.isArray(i)&&i.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||w)&&N}}function pR({domNode:e,minZoom:n,maxZoom:s,translateExtent:i,viewport:o,onPanZoom:d,onPanZoomStart:c,onPanZoomEnd:m,onDraggingChange:h}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),x=yw().scaleExtent([n,s]).translateExtent(i),g=$r(e).call(x);C({x:o.x,y:o.y,zoom:pl(o.zoom,n,s)},[[0,0],[p.width,p.height]],i);const y=g.on("wheel.zoom"),w=g.on("dblclick.zoom");x.wheelDelta(Gw);function N(F,Y){return g?new Promise(P=>{x?.interpolate(Y?.interpolate==="linear"?_o:Cd).transform(Jh(g,Y?.duration,Y?.ease,()=>P(!0)),F)}):Promise.resolve(!1)}function S({noWheelClassName:F,noPanClassName:Y,onPaneContextMenu:P,userSelectionActive:M,panOnScroll:L,panOnDrag:A,panOnScrollMode:O,panOnScrollSpeed:D,preventScrolling:Z,zoomOnPinch:B,zoomOnScroll:q,zoomOnDoubleClick:X,zoomActivationKeyPressed:I,lib:_,onTransformChange:V,connectionInProgress:Q,paneClickDistance:ee,selectionOnDrag:te}){M&&!f.isZoomingOrPanning&&E();const ae=L&&!I&&!M;x.clickDistance(te?1/0:!cs(ee)||ee<0?0:ee);const me=ae?dR({zoomPanValues:f,noWheelClassName:F,d3Selection:g,d3Zoom:x,panOnScrollMode:O,panOnScrollSpeed:D,zoomOnPinch:B,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:m}):uR({noWheelClassName:F,preventScrolling:Z,d3ZoomHandler:y});if(g.on("wheel.zoom",me,{passive:!1}),!M){const Ie=fR({zoomPanValues:f,onDraggingChange:h,onPanZoomStart:c});x.on("start",Ie);const je=hR({zoomPanValues:f,panOnDrag:A,onPaneContextMenu:!!P,onPanZoom:d,onTransformChange:V});x.on("zoom",je);const Te=mR({zoomPanValues:f,panOnDrag:A,panOnScroll:L,onPaneContextMenu:P,onPanZoomEnd:m,onDraggingChange:h});x.on("end",Te)}const Ne=xR({zoomActivationKeyPressed:I,panOnDrag:A,zoomOnScroll:q,panOnScroll:L,zoomOnDoubleClick:X,zoomOnPinch:B,userSelectionActive:M,noPanClassName:Y,noWheelClassName:F,lib:_,connectionInProgress:Q});x.filter(Ne),X?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function E(){x.on("zoom",null)}async function C(F,Y,P){const M=Qh(F),L=x?.constrain()(M,Y,P);return L&&await N(L),new Promise(A=>A(L))}async function k(F,Y){const P=Qh(F);return await N(P,Y),new Promise(M=>M(P))}function T(F){if(g){const Y=Qh(F),P=g.property("__zoom");(P.k!==F.zoom||P.x!==F.x||P.y!==F.y)&&x?.transform(g,Y,null,{sync:!0})}}function R(){const F=g?bw(g.node()):{x:0,y:0,k:1};return{x:F.x,y:F.y,zoom:F.k}}function z(F,Y){return g?new Promise(P=>{x?.interpolate(Y?.interpolate==="linear"?_o:Cd).scaleTo(Jh(g,Y?.duration,Y?.ease,()=>P(!0)),F)}):Promise.resolve(!1)}function U(F,Y){return g?new Promise(P=>{x?.interpolate(Y?.interpolate==="linear"?_o:Cd).scaleBy(Jh(g,Y?.duration,Y?.ease,()=>P(!0)),F)}):Promise.resolve(!1)}function G(F){x?.scaleExtent(F)}function W(F){x?.translateExtent(F)}function $(F){const Y=!cs(F)||F<0?0:F;x?.clickDistance(Y)}return{update:S,destroy:E,setViewport:k,setViewportConstrained:C,getViewport:R,scaleTo:z,scaleBy:U,setScaleExtent:G,setTranslateExtent:W,syncViewport:T,setClickDistance:$}}var yl;(function(e){e.Line="line",e.Handle="handle"})(yl||(yl={}));function gR({width:e,prevWidth:n,height:s,prevHeight:i,affectsX:o,affectsY:d}){const c=e-n,m=s-i,h=[c>0?1:c<0?-1:0,m>0?1:m<0?-1:0];return c&&o&&(h[0]=h[0]*-1),m&&d&&(h[1]=h[1]*-1),h}function bv(e){const n=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),i=e.includes("left"),o=e.includes("top");return{isHorizontal:n,isVertical:s,affectsX:i,affectsY:o}}function Oa(e,n){return Math.max(0,n-e)}function Ra(e,n){return Math.max(0,e-n)}function gd(e,n,s){return Math.max(0,n-e,e-s)}function yv(e,n){return e?!n:n}function bR(e,n,s,i,o,d,c,m){let{affectsX:h,affectsY:f}=n;const{isHorizontal:p,isVertical:x}=n,g=p&&x,{xSnapped:y,ySnapped:w}=s,{minWidth:N,maxWidth:S,minHeight:E,maxHeight:C}=i,{x:k,y:T,width:R,height:z,aspectRatio:U}=e;let G=Math.floor(p?y-e.pointerX:0),W=Math.floor(x?w-e.pointerY:0);const $=R+(h?-G:G),F=z+(f?-W:W),Y=-d[0]*R,P=-d[1]*z;let M=gd($,N,S),L=gd(F,E,C);if(c){let D=0,Z=0;h&&G<0?D=Oa(k+G+Y,c[0][0]):!h&&G>0&&(D=Ra(k+$+Y,c[1][0])),f&&W<0?Z=Oa(T+W+P,c[0][1]):!f&&W>0&&(Z=Ra(T+F+P,c[1][1])),M=Math.max(M,D),L=Math.max(L,Z)}if(m){let D=0,Z=0;h&&G>0?D=Ra(k+G,m[0][0]):!h&&G<0&&(D=Oa(k+$,m[1][0])),f&&W>0?Z=Ra(T+W,m[0][1]):!f&&W<0&&(Z=Oa(T+F,m[1][1])),M=Math.max(M,D),L=Math.max(L,Z)}if(o){if(p){const D=gd($/U,E,C)*U;if(M=Math.max(M,D),c){let Z=0;!h&&!f||h&&!f&&g?Z=Ra(T+P+$/U,c[1][1])*U:Z=Oa(T+P+(h?G:-G)/U,c[0][1])*U,M=Math.max(M,Z)}if(m){let Z=0;!h&&!f||h&&!f&&g?Z=Oa(T+$/U,m[1][1])*U:Z=Ra(T+(h?G:-G)/U,m[0][1])*U,M=Math.max(M,Z)}}if(x){const D=gd(F*U,N,S)/U;if(L=Math.max(L,D),c){let Z=0;!h&&!f||f&&!h&&g?Z=Ra(k+F*U+Y,c[1][0])/U:Z=Oa(k+(f?W:-W)*U+Y,c[0][0])/U,L=Math.max(L,Z)}if(m){let Z=0;!h&&!f||f&&!h&&g?Z=Oa(k+F*U,m[1][0])/U:Z=Ra(k+(f?W:-W)*U,m[0][0])/U,L=Math.max(L,Z)}}}W=W+(W<0?L:-L),G=G+(G<0?M:-M),o&&(g?$>F*U?W=(yv(h,f)?-G:G)/U:G=(yv(h,f)?-W:W)*U:p?(W=G/U,f=h):(G=W*U,h=f));const A=h?k+G:k,O=f?T+W:T;return{width:R+(h?-G:G),height:z+(f?-W:W),x:d[0]*G*(h?-1:1)+A,y:d[1]*W*(f?-1:1)+O}}const Xw={width:0,height:0,x:0,y:0},yR={...Xw,pointerX:0,pointerY:0,aspectRatio:1};function vR(e){return[[0,0],[e.measured.width,e.measured.height]]}function jR(e,n,s){const i=n.position.x+e.position.x,o=n.position.y+e.position.y,d=e.measured.width??0,c=e.measured.height??0,m=s[0]*d,h=s[1]*c;return[[i-m,o-h],[i+d-m,o+c-h]]}function wR({domNode:e,nodeId:n,getStoreItems:s,onChange:i,onEnd:o}){const d=$r(e);let c={controlDirection:bv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function m({controlPosition:f,boundaries:p,keepAspectRatio:x,resizeDirection:g,onResizeStart:y,onResize:w,onResizeEnd:N,shouldResize:S}){let E={...Xw},C={...yR};c={boundaries:p,resizeDirection:g,keepAspectRatio:x,controlDirection:bv(f)};let k,T=null,R=[],z,U,G,W=!1;const $=sw().on("start",F=>{const{nodeLookup:Y,transform:P,snapGrid:M,snapToGrid:L,nodeOrigin:A,paneDomNode:O}=s();if(k=Y.get(n),!k)return;T=O?.getBoundingClientRect()??null;const{xSnapped:D,ySnapped:Z}=Ao(F.sourceEvent,{transform:P,snapGrid:M,snapToGrid:L,containerBounds:T});E={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},C={...E,pointerX:D,pointerY:Z,aspectRatio:E.width/E.height},z=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(z=Y.get(k.parentId),U=z&&k.extent==="parent"?vR(z):void 0),R=[],G=void 0;for(const[B,q]of Y)if(q.parentId===n&&(R.push({id:B,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const X=jR(q,k,q.origin??A);G?G=[[Math.min(X[0][0],G[0][0]),Math.min(X[0][1],G[0][1])],[Math.max(X[1][0],G[1][0]),Math.max(X[1][1],G[1][1])]]:G=X}y?.(F,{...E})}).on("drag",F=>{const{transform:Y,snapGrid:P,snapToGrid:M,nodeOrigin:L}=s(),A=Ao(F.sourceEvent,{transform:Y,snapGrid:P,snapToGrid:M,containerBounds:T}),O=[];if(!k)return;const{x:D,y:Z,width:B,height:q}=E,X={},I=k.origin??L,{width:_,height:V,x:Q,y:ee}=bR(C,c.controlDirection,A,c.boundaries,c.keepAspectRatio,I,U,G),te=_!==B,ae=V!==q,me=Q!==D&&te,Ne=ee!==Z&&ae;if(!me&&!Ne&&!te&&!ae)return;if((me||Ne||I[0]===1||I[1]===1)&&(X.x=me?Q:E.x,X.y=Ne?ee:E.y,E.x=X.x,E.y=X.y,R.length>0)){const Ce=Q-D,Re=ee-Z;for(const Ge of R)Ge.position={x:Ge.position.x-Ce+I[0]*(_-B),y:Ge.position.y-Re+I[1]*(V-q)},O.push(Ge)}if((te||ae)&&(X.width=te&&(!c.resizeDirection||c.resizeDirection==="horizontal")?_:E.width,X.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?V:E.height,E.width=X.width,E.height=X.height),z&&k.expandParent){const Ce=I[0]*(X.width??0);X.x&&X.x<Ce&&(E.x=Ce,C.x=C.x-(X.x-Ce));const Re=I[1]*(X.height??0);X.y&&X.y<Re&&(E.y=Re,C.y=C.y-(X.y-Re))}const Ie=gR({width:E.width,prevWidth:B,height:E.height,prevHeight:q,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),je={...E,direction:Ie};S?.(F,je)!==!1&&(W=!0,w?.(F,je),i(X,O))}).on("end",F=>{W&&(N?.(F,{...E}),o?.({...E}),W=!1)});d.call($)}function h(){d.on(".drag",null)}return{update:m,destroy:h}}var em={exports:{}},tm={},nm={exports:{}},rm={};var vv;function NR(){if(vv)return rm;vv=1;var e=Fo();function n(x,g){return x===g&&(x!==0||1/x===1/g)||x!==x&&g!==g}var s=typeof Object.is=="function"?Object.is:n,i=e.useState,o=e.useEffect,d=e.useLayoutEffect,c=e.useDebugValue;function m(x,g){var y=g(),w=i({inst:{value:y,getSnapshot:g}}),N=w[0].inst,S=w[1];return d(function(){N.value=y,N.getSnapshot=g,h(N)&&S({inst:N})},[x,y,g]),o(function(){return h(N)&&S({inst:N}),x(function(){h(N)&&S({inst:N})})},[x]),c(y),y}function h(x){var g=x.getSnapshot;x=x.value;try{var y=g();return!s(x,y)}catch{return!0}}function f(x,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:m;return rm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,rm}var jv;function kR(){return jv||(jv=1,nm.exports=NR()),nm.exports}var wv;function SR(){if(wv)return tm;wv=1;var e=Fo(),n=kR();function s(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var i=typeof Object.is=="function"?Object.is:s,o=n.useSyncExternalStore,d=e.useRef,c=e.useEffect,m=e.useMemo,h=e.useDebugValue;return tm.useSyncExternalStoreWithSelector=function(f,p,x,g,y){var w=d(null);if(w.current===null){var N={hasValue:!1,value:null};w.current=N}else N=w.current;w=m(function(){function E(z){if(!C){if(C=!0,k=z,z=g(z),y!==void 0&&N.hasValue){var U=N.value;if(y(U,z))return T=U}return T=z}if(U=T,i(k,z))return U;var G=g(z);return y!==void 0&&y(U,G)?(k=z,U):(k=z,T=G)}var C=!1,k,T,R=x===void 0?null:x;return[function(){return E(p())},R===null?void 0:function(){return E(R())}]},[p,x,g,y]);var S=o(f,w[0],w[1]);return c(function(){N.hasValue=!0,N.value=S},[S]),h(S),S},tm}var Nv;function CR(){return Nv||(Nv=1,em.exports=SR()),em.exports}var ER=CR();const TR=Zd(ER),_R={},kv=e=>{let n;const s=new Set,i=(p,x)=>{const g=typeof p=="function"?p(n):p;if(!Object.is(g,n)){const y=n;n=x??(typeof g!="object"||g===null)?g:Object.assign({},n,g),s.forEach(w=>w(n,y))}},o=()=>n,h={setState:i,getState:o,getInitialState:()=>f,subscribe:p=>(s.add(p),()=>s.delete(p)),destroy:()=>{(_R?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),s.clear()}},f=n=e(i,o,h);return h},AR=e=>e?kv(e):kv,{useDebugValue:MR}=U2,{useSyncExternalStoreWithSelector:OR}=TR,RR=e=>e;function Kw(e,n=RR,s){const i=OR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return MR(i),i}const Sv=(e,n)=>{const s=AR(e),i=(o,d=n)=>Kw(s,o,d);return Object.assign(i,s),i},DR=(e,n)=>e?Sv(e,n):Sv;function An(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[i,o]of e)if(!Object.is(o,n.get(i)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(n).length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(n,i)||!Object.is(e[i],n[i]))return!1;return!0}const hu=v.createContext(null),LR=hu.Provider,Ww=Ts.error001();function Wt(e,n){const s=v.useContext(hu);if(s===null)throw new Error(Ww);return Kw(s,e,n)}function Mn(){const e=v.useContext(hu);if(e===null)throw new Error(Ww);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Cv={display:"none"},IR={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Zw="react-flow__node-desc",Qw="react-flow__edge-desc",zR="react-flow__aria-live",$R=e=>e.ariaLiveMessage,BR=e=>e.ariaLabelConfig;function HR({rfId:e}){const n=Wt($R);return t.jsx("div",{id:`${zR}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:IR,children:n})}function PR({rfId:e,disableKeyboardA11y:n}){const s=Wt(BR);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${Zw}-${e}`,style:Cv,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${Qw}-${e}`,style:Cv,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(HR,{rfId:e})]})}const mu=v.forwardRef(({position:e="top-left",children:n,className:s,style:i,...o},d)=>{const c=`${e}`.split("-");return t.jsx("div",{className:Gn(["react-flow__panel",s,...c]),style:i,ref:d,...o,children:n})});mu.displayName="Panel";function UR({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(mu,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const qR=e=>{const n=[],s=[];for(const[,i]of e.nodeLookup)i.selected&&n.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&s.push(i);return{selectedNodes:n,selectedEdges:s}},bd=e=>e.id;function VR(e,n){return An(e.selectedNodes.map(bd),n.selectedNodes.map(bd))&&An(e.selectedEdges.map(bd),n.selectedEdges.map(bd))}function FR({onSelectionChange:e}){const n=Mn(),{selectedNodes:s,selectedEdges:i}=Wt(qR,VR);return v.useEffect(()=>{const o={nodes:s,edges:i};e?.(o),n.getState().onSelectionChangeHandlers.forEach(d=>d(o))},[s,i,e]),null}const YR=e=>!!e.onSelectionChangeHandlers;function GR({onSelectionChange:e}){const n=Wt(YR);return e||n?t.jsx(FR,{onSelectionChange:e}):null}const Jw=[0,0],XR={x:0,y:0,zoom:1},KR=["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"],Ev=[...KR,"rfId"],WR=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}),Tv={translateExtent:Bo,nodeOrigin:Jw,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ZR(e){const{setNodes:n,setEdges:s,setMinZoom:i,setMaxZoom:o,setTranslateExtent:d,setNodeExtent:c,reset:m,setDefaultNodesAndEdges:h}=Wt(WR,An),f=Mn();v.useEffect(()=>(h(e.defaultNodes,e.defaultEdges),()=>{p.current=Tv,m()}),[]);const p=v.useRef(Tv);return v.useEffect(()=>{for(const x of Ev){const g=e[x],y=p.current[x];g!==y&&(typeof e[x]>"u"||(x==="nodes"?n(g):x==="edges"?s(g):x==="minZoom"?i(g):x==="maxZoom"?o(g):x==="translateExtent"?d(g):x==="nodeExtent"?c(g):x==="ariaLabelConfig"?f.setState({ariaLabelConfig:DO(g)}):x==="fitView"?f.setState({fitViewQueued:g}):x==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[x]:g})))}p.current=e},Ev.map(x=>e[x])),null}function _v(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function QR(e){const[n,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const i=_v(),o=()=>s(i?.matches?"dark":"light");return o(),i?.addEventListener("change",o),()=>{i?.removeEventListener("change",o)}},[e]),n!==null?n:_v()?.matches?"dark":"light"}const Av=typeof document<"u"?document:null;function qo(e=null,n={target:Av,actInsideInputWithModifier:!0}){const[s,i]=v.useState(!1),o=v.useRef(!1),d=v.useRef(new Set([])),[c,m]=v.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(x=>typeof x=="string").map(x=>x.replace("+",`
56
- `).replace(`
57
-
58
- `,`
59
- +`).split(`
60
- `)),p=f.reduce((x,g)=>x.concat(...g),[]);return[f,p]}return[[],[]]},[e]);return v.useEffect(()=>{const h=n?.target??Av,f=n?.actInsideInputWithModifier??!0;if(e!==null){const p=y=>{if(o.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!o.current||o.current&&!f)&&Ow(y))return!1;const N=Ov(y.code,m);if(d.current.add(y[N]),Mv(c,d.current,!1)){const S=y.composedPath?.()?.[0]||y.target,E=S?.nodeName==="BUTTON"||S?.nodeName==="A";n.preventDefault!==!1&&(o.current||!E)&&y.preventDefault(),i(!0)}},x=y=>{const w=Ov(y.code,m);Mv(c,d.current,!0)?(i(!1),d.current.clear()):d.current.delete(y[w]),y.key==="Meta"&&d.current.clear(),o.current=!1},g=()=>{d.current.clear(),i(!1)};return h?.addEventListener("keydown",p),h?.addEventListener("keyup",x),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{h?.removeEventListener("keydown",p),h?.removeEventListener("keyup",x),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,i]),s}function Mv(e,n,s){return e.filter(i=>s||i.length===n.size).some(i=>i.every(o=>n.has(o)))}function Ov(e,n){return n.includes(e)?"code":"key"}const JR=()=>{const e=Mn();return v.useMemo(()=>({zoomIn:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomOut:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1/1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomTo:(n,s)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(n,{duration:s?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,s)=>{const{transform:[i,o,d],panZoom:c}=e.getState();return c?(await c.setViewport({x:n.x??i,y:n.y??o,zoom:n.zoom??d},s),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,s,i]=e.getState().transform;return{x:n,y:s,zoom:i}},setCenter:async(n,s,i)=>e.getState().setCenter(n,s,i),fitBounds:async(n,s)=>{const{width:i,height:o,minZoom:d,maxZoom:c,panZoom:m}=e.getState(),h=Ax(n,i,o,d,c,s?.padding??.1);return m?(await m.setViewport(h,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(n,s={})=>{const{transform:i,snapGrid:o,snapToGrid:d,domNode:c}=e.getState();if(!c)return n;const{x:m,y:h}=c.getBoundingClientRect(),f={x:n.x-m,y:n.y-h},p=s.snapGrid??o,x=s.snapToGrid??d;return ec(f,i,x,p)},flowToScreenPosition:n=>{const{transform:s,domNode:i}=e.getState();if(!i)return n;const{x:o,y:d}=i.getBoundingClientRect(),c=Xd(n,s);return{x:c.x+o,y:c.y+d}}}),[])};function eN(e,n){const s=[],i=new Map,o=[];for(const d of e)if(d.type==="add"){o.push(d);continue}else if(d.type==="remove"||d.type==="replace")i.set(d.id,[d]);else{const c=i.get(d.id);c?c.push(d):i.set(d.id,[d])}for(const d of n){const c=i.get(d.id);if(!c){s.push(d);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){s.push({...c[0].item});continue}const m={...d};for(const h of c)eD(h,m);s.push(m)}return o.length&&o.forEach(d=>{d.index!==void 0?s.splice(d.index,0,{...d.item}):s.push({...d.item})}),s}function eD(e,n){switch(e.type){case"select":{n.selected=e.selected;break}case"position":{typeof e.position<"u"&&(n.position=e.position),typeof e.dragging<"u"&&(n.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(n.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(n.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(n.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(n.resizing=e.resizing);break}}}function tN(e,n){return eN(e,n)}function nN(e,n){return eN(e,n)}function ci(e,n){return{id:e,type:"select",selected:n}}function ll(e,n=new Set,s=!1){const i=[];for(const[o,d]of e){const c=n.has(o);!(d.selected===void 0&&!c)&&d.selected!==c&&(s&&(d.selected=c),i.push(ci(d.id,c)))}return i}function Rv({items:e=[],lookup:n}){const s=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,d]of e.entries()){const c=n.get(d.id),m=c?.internals?.userNode??c;m!==void 0&&m!==d&&s.push({id:d.id,item:d,type:"replace"}),m===void 0&&s.push({item:d,type:"add",index:o})}for(const[o]of n)i.get(o)===void 0&&s.push({id:o,type:"remove"});return s}function Dv(e){return{id:e.id,type:"remove"}}const Lv=e=>kO(e),tD=e=>kw(e);function rN(e){return v.forwardRef(e)}const nD=typeof window<"u"?v.useLayoutEffect:v.useEffect;function Iv(e){const[n,s]=v.useState(BigInt(0)),[i]=v.useState(()=>rD(()=>s(o=>o+BigInt(1))));return nD(()=>{const o=i.get();o.length&&(e(o),i.reset())},[n]),i}function rD(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:s=>{n.push(s),e()}}}const sN=v.createContext(null);function sD({children:e}){const n=Mn(),s=v.useCallback(m=>{const{nodes:h=[],setNodes:f,hasDefaultNodes:p,onNodesChange:x,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:w}=n.getState();let N=h;for(const E of m)N=typeof E=="function"?E(N):E;let S=Rv({items:N,lookup:g});for(const E of w.values())S=E(S);p&&f(N),S.length>0?x?.(S):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:C,setNodes:k}=n.getState();E&&k(C)})},[]),i=Iv(s),o=v.useCallback(m=>{const{edges:h=[],setEdges:f,hasDefaultEdges:p,onEdgesChange:x,edgeLookup:g}=n.getState();let y=h;for(const w of m)y=typeof w=="function"?w(y):w;p?f(y):x&&x(Rv({items:y,lookup:g}))},[]),d=Iv(o),c=v.useMemo(()=>({nodeQueue:i,edgeQueue:d}),[]);return t.jsx(sN.Provider,{value:c,children:e})}function aD(){const e=v.useContext(sN);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const iD=e=>!!e.panZoom;function zx(){const e=JR(),n=Mn(),s=aD(),i=Wt(iD),o=v.useMemo(()=>{const d=x=>n.getState().nodeLookup.get(x),c=x=>{s.nodeQueue.push(x)},m=x=>{s.edgeQueue.push(x)},h=x=>{const{nodeLookup:g,nodeOrigin:y}=n.getState(),w=Lv(x)?x:g.get(x.id),N=w.parentId?Aw(w.position,w.measured,w.parentId,g,y):w.position,S={...w,position:N,width:w.measured?.width??w.width,height:w.measured?.height??w.height};return gl(S)},f=(x,g,y={replace:!1})=>{c(w=>w.map(N=>{if(N.id===x){const S=typeof g=="function"?g(N):g;return y.replace&&Lv(S)?S:{...N,...S}}return N}))},p=(x,g,y={replace:!1})=>{m(w=>w.map(N=>{if(N.id===x){const S=typeof g=="function"?g(N):g;return y.replace&&tD(S)?S:{...N,...S}}return N}))};return{getNodes:()=>n.getState().nodes.map(x=>({...x})),getNode:x=>d(x)?.internals.userNode,getInternalNode:d,getEdges:()=>{const{edges:x=[]}=n.getState();return x.map(g=>({...g}))},getEdge:x=>n.getState().edgeLookup.get(x),setNodes:c,setEdges:m,addNodes:x=>{const g=Array.isArray(x)?x:[x];s.nodeQueue.push(y=>[...y,...g])},addEdges:x=>{const g=Array.isArray(x)?x:[x];s.edgeQueue.push(y=>[...y,...g])},toObject:()=>{const{nodes:x=[],edges:g=[],transform:y}=n.getState(),[w,N,S]=y;return{nodes:x.map(E=>({...E})),edges:g.map(E=>({...E})),viewport:{x:w,y:N,zoom:S}}},deleteElements:async({nodes:x=[],edges:g=[]})=>{const{nodes:y,edges:w,onNodesDelete:N,onEdgesDelete:S,triggerNodeChanges:E,triggerEdgeChanges:C,onDelete:k,onBeforeDelete:T}=n.getState(),{nodes:R,edges:z}=await _O({nodesToRemove:x,edgesToRemove:g,nodes:y,edges:w,onBeforeDelete:T}),U=z.length>0,G=R.length>0;if(U){const W=z.map(Dv);S?.(z),C(W)}if(G){const W=R.map(Dv);N?.(R),E(W)}return(G||U)&&k?.({nodes:R,edges:z}),{deletedNodes:R,deletedEdges:z}},getIntersectingNodes:(x,g=!0,y)=>{const w=lv(x),N=w?x:h(x),S=y!==void 0;return N?(y||n.getState().nodes).filter(E=>{const C=n.getState().nodeLookup.get(E.id);if(C&&!w&&(E.id===x.id||!C.internals.positionAbsolute))return!1;const k=gl(S?E:C),T=Po(k,N);return g&&T>0||T>=k.width*k.height||T>=N.width*N.height}):[]},isNodeIntersecting:(x,g,y=!0)=>{const N=lv(x)?x:h(x);if(!N)return!1;const S=Po(N,g);return y&&S>0||S>=g.width*g.height||S>=N.width*N.height},updateNode:f,updateNodeData:(x,g,y={replace:!1})=>{f(x,w=>{const N=typeof g=="function"?g(w):g;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},updateEdge:p,updateEdgeData:(x,g,y={replace:!1})=>{p(x,w=>{const N=typeof g=="function"?g(w):g;return y.replace?{...w,data:N}:{...w,data:{...w.data,...N}}},y)},getNodesBounds:x=>{const{nodeLookup:g,nodeOrigin:y}=n.getState();return SO(x,{nodeLookup:g,nodeOrigin:y})},getHandleConnections:({type:x,id:g,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}-${x}${g?`-${g}`:""}`)?.values()??[]),getNodeConnections:({type:x,handleId:g,nodeId:y})=>Array.from(n.getState().connectionLookup.get(`${y}${x?g?`-${x}-${g}`:`-${x}`:""}`)?.values()??[]),fitView:async x=>{const g=n.getState().fitViewResolver??RO();return n.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:g}),s.nodeQueue.push(y=>[...y]),g.promise}}},[]);return v.useMemo(()=>({...o,...e,viewportInitialized:i}),[i])}const zv=e=>e.selected,lD=typeof window<"u"?window:void 0;function oD({deleteKeyCode:e,multiSelectionKeyCode:n}){const s=Mn(),{deleteElements:i}=zx(),o=qo(e,{actInsideInputWithModifier:!1}),d=qo(n,{target:lD});v.useEffect(()=>{if(o){const{edges:c,nodes:m}=s.getState();i({nodes:m.filter(zv),edges:c.filter(zv)}),s.setState({nodesSelectionActive:!1})}},[o]),v.useEffect(()=>{s.setState({multiSelectionActive:d})},[d])}function cD(e){const n=Mn();v.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const i=Mx(e.current);(i.height===0||i.width===0)&&n.getState().onError?.("004",Ts.error004()),n.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 xu={position:"absolute",width:"100%",height:"100%",top:0,left:0},dD=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function uD({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:o=.5,panOnScrollMode:d=mi.Free,zoomOnDoubleClick:c=!0,panOnDrag:m=!0,defaultViewport:h,translateExtent:f,minZoom:p,maxZoom:x,zoomActivationKeyCode:g,preventScrolling:y=!0,children:w,noWheelClassName:N,noPanClassName:S,onViewportChange:E,isControlledViewport:C,paneClickDistance:k,selectionOnDrag:T}){const R=Mn(),z=v.useRef(null),{userSelectionActive:U,lib:G,connectionInProgress:W}=Wt(dD,An),$=qo(g),F=v.useRef();cD(z);const Y=v.useCallback(P=>{E?.({x:P[0],y:P[1],zoom:P[2]}),C||R.setState({transform:P})},[E,C]);return v.useEffect(()=>{if(z.current){F.current=pR({domNode:z.current,minZoom:p,maxZoom:x,translateExtent:f,viewport:h,onDraggingChange:A=>R.setState(O=>O.paneDragging===A?O:{paneDragging:A}),onPanZoomStart:(A,O)=>{const{onViewportChangeStart:D,onMoveStart:Z}=R.getState();Z?.(A,O),D?.(O)},onPanZoom:(A,O)=>{const{onViewportChange:D,onMove:Z}=R.getState();Z?.(A,O),D?.(O)},onPanZoomEnd:(A,O)=>{const{onViewportChangeEnd:D,onMoveEnd:Z}=R.getState();Z?.(A,O),D?.(O)}});const{x:P,y:M,zoom:L}=F.current.getViewport();return R.setState({panZoom:F.current,transform:[P,M,L],domNode:z.current.closest(".react-flow")}),()=>{F.current?.destroy()}}},[]),v.useEffect(()=>{F.current?.update({onPaneContextMenu:e,zoomOnScroll:n,zoomOnPinch:s,panOnScroll:i,panOnScrollSpeed:o,panOnScrollMode:d,zoomOnDoubleClick:c,panOnDrag:m,zoomActivationKeyPressed:$,preventScrolling:y,noPanClassName:S,userSelectionActive:U,noWheelClassName:N,lib:G,onTransformChange:Y,connectionInProgress:W,selectionOnDrag:T,paneClickDistance:k})},[e,n,s,i,o,d,c,m,$,y,S,U,N,G,Y,W,T,k]),t.jsx("div",{className:"react-flow__renderer",ref:z,style:xu,children:w})}const fD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function hD(){const{userSelectionActive:e,userSelectionRect:n}=Wt(fD,An);return e&&n?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const sm=(e,n)=>s=>{s.target===n.current&&e?.(s)},mD=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function xD({isSelecting:e,selectionKeyPressed:n,selectionMode:s=Ho.Full,panOnDrag:i,paneClickDistance:o,selectionOnDrag:d,onSelectionStart:c,onSelectionEnd:m,onPaneClick:h,onPaneContextMenu:f,onPaneScroll:p,onPaneMouseEnter:x,onPaneMouseMove:g,onPaneMouseLeave:y,children:w}){const N=Mn(),{userSelectionActive:S,elementsSelectable:E,dragging:C,connectionInProgress:k}=Wt(mD,An),T=E&&(e||S),R=v.useRef(null),z=v.useRef(),U=v.useRef(new Set),G=v.useRef(new Set),W=v.useRef(!1),$=D=>{if(W.current||k){W.current=!1;return}h?.(D),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},F=D=>{if(Array.isArray(i)&&i?.includes(2)){D.preventDefault();return}f?.(D)},Y=p?D=>p(D):void 0,P=D=>{W.current&&(D.stopPropagation(),W.current=!1)},M=D=>{const{domNode:Z}=N.getState();if(z.current=Z?.getBoundingClientRect(),!z.current)return;const B=D.target===R.current;if(!B&&!!D.target.closest(".nokey")||!e||!(d&&B||n)||D.button!==0||!D.isPrimary)return;D.target?.setPointerCapture?.(D.pointerId),W.current=!1;const{x:I,y:_}=ds(D.nativeEvent,z.current);N.setState({userSelectionRect:{width:0,height:0,startX:I,startY:_,x:I,y:_}}),B||(D.stopPropagation(),D.preventDefault())},L=D=>{const{userSelectionRect:Z,transform:B,nodeLookup:q,edgeLookup:X,connectionLookup:I,triggerNodeChanges:_,triggerEdgeChanges:V,defaultEdgeOptions:Q,resetSelectedElements:ee}=N.getState();if(!z.current||!Z)return;const{x:te,y:ae}=ds(D.nativeEvent,z.current),{startX:me,startY:Ne}=Z;if(!W.current){const Re=n?0:o;if(Math.hypot(te-me,ae-Ne)<=Re)return;ee(),c?.(D)}W.current=!0;const Ie={startX:me,startY:Ne,x:te<me?te:me,y:ae<Ne?ae:Ne,width:Math.abs(te-me),height:Math.abs(ae-Ne)},je=U.current,Te=G.current;U.current=new Set(_x(q,Ie,B,s===Ho.Partial,!0).map(Re=>Re.id)),G.current=new Set;const Ce=Q?.selectable??!0;for(const Re of U.current){const Ge=I.get(Re);if(Ge)for(const{edgeId:ot}of Ge.values()){const st=X.get(ot);st&&(st.selectable??Ce)&&G.current.add(ot)}}if(!ov(je,U.current)){const Re=ll(q,U.current,!0);_(Re)}if(!ov(Te,G.current)){const Re=ll(X,G.current);V(Re)}N.setState({userSelectionRect:Ie,userSelectionActive:!0,nodesSelectionActive:!1})},A=D=>{D.button===0&&(D.target?.releasePointerCapture?.(D.pointerId),!S&&D.target===R.current&&N.getState().userSelectionRect&&$?.(D),N.setState({userSelectionActive:!1,userSelectionRect:null}),W.current&&(m?.(D),N.setState({nodesSelectionActive:U.current.size>0})))},O=i===!0||Array.isArray(i)&&i.includes(0);return t.jsxs("div",{className:Gn(["react-flow__pane",{draggable:O,dragging:C,selection:e}]),onClick:T?void 0:sm($,R),onContextMenu:sm(F,R),onWheel:sm(Y,R),onPointerEnter:T?void 0:x,onPointerMove:T?L:g,onPointerUp:T?A:void 0,onPointerDownCapture:T?M:void 0,onClickCapture:T?P:void 0,onPointerLeave:y,ref:R,style:xu,children:[w,t.jsx(hD,{})]})}function Gm({id:e,store:n,unselect:s=!1,nodeRef:i}){const{addSelectedNodes:o,unselectNodesAndEdges:d,multiSelectionActive:c,nodeLookup:m,onError:h}=n.getState(),f=m.get(e);if(!f){h?.("012",Ts.error012(e));return}n.setState({nodesSelectionActive:!1}),f.selected?(s||f.selected&&c)&&(d({nodes:[f],edges:[]}),requestAnimationFrame(()=>i?.current?.blur())):o([e])}function aN({nodeRef:e,disabled:n=!1,noDragClassName:s,handleSelector:i,nodeId:o,isSelectable:d,nodeClickDistance:c}){const m=Mn(),[h,f]=v.useState(!1),p=v.useRef();return v.useEffect(()=>{p.current=nR({getStoreItems:()=>m.getState(),onNodeMouseDown:x=>{Gm({id:x,store:m,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),v.useEffect(()=>{if(!(n||!e.current||!p.current))return p.current.update({noDragClassName:s,handleSelector:i,domNode:e.current,isSelectable:d,nodeId:o,nodeClickDistance:c}),()=>{p.current?.destroy()}},[s,i,n,d,e,o,c]),h}const pD=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function iN(){const e=Mn();return v.useCallback(s=>{const{nodeExtent:i,snapToGrid:o,snapGrid:d,nodesDraggable:c,onError:m,updateNodePositions:h,nodeLookup:f,nodeOrigin:p}=e.getState(),x=new Map,g=pD(c),y=o?d[0]:5,w=o?d[1]:5,N=s.direction.x*y*s.factor,S=s.direction.y*w*s.factor;for(const[,E]of f){if(!g(E))continue;let C={x:E.internals.positionAbsolute.x+N,y:E.internals.positionAbsolute.y+S};o&&(C=Jo(C,d));const{position:k,positionAbsolute:T}=Sw({nodeId:E.id,nextPosition:C,nodeLookup:f,nodeExtent:i,nodeOrigin:p,onError:m});E.position=k,E.internals.positionAbsolute=T,x.set(E.id,E)}h(x)},[])}const $x=v.createContext(null),gD=$x.Provider;$x.Consumer;const lN=()=>v.useContext($x),bD=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),yD=(e,n,s)=>i=>{const{connectionClickStartHandle:o,connectionMode:d,connection:c}=i,{fromHandle:m,toHandle:h,isValid:f}=c,p=h?.nodeId===e&&h?.id===n&&h?.type===s;return{connectingFrom:m?.nodeId===e&&m?.id===n&&m?.type===s,connectingTo:p,clickConnecting:o?.nodeId===e&&o?.id===n&&o?.type===s,isPossibleEndHandle:d===ml.Strict?m?.type!==s:e!==m?.nodeId||n!==m?.id,connectionInProcess:!!m,clickConnectionInProcess:!!o,valid:p&&f}};function vD({type:e="source",position:n=ft.Top,isValidConnection:s,isConnectable:i=!0,isConnectableStart:o=!0,isConnectableEnd:d=!0,id:c,onConnect:m,children:h,className:f,onMouseDown:p,onTouchStart:x,...g},y){const w=c||null,N=e==="target",S=Mn(),E=lN(),{connectOnClick:C,noPanClassName:k,rfId:T}=Wt(bD,An),{connectingFrom:R,connectingTo:z,clickConnecting:U,isPossibleEndHandle:G,connectionInProcess:W,clickConnectionInProcess:$,valid:F}=Wt(yD(E,w,e),An);E||S.getState().onError?.("010",Ts.error010());const Y=L=>{const{defaultEdgeOptions:A,onConnect:O,hasDefaultEdges:D}=S.getState(),Z={...A,...L};if(D){const{edges:B,setEdges:q}=S.getState();q(HO(Z,B))}O?.(Z),m?.(Z)},P=L=>{if(!E)return;const A=Rw(L.nativeEvent);if(o&&(A&&L.button===0||!A)){const O=S.getState();Ym.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:O.autoPanOnConnect,connectionMode:O.connectionMode,connectionRadius:O.connectionRadius,domNode:O.domNode,nodeLookup:O.nodeLookup,lib:O.lib,isTarget:N,handleId:w,nodeId:E,flowId:O.rfId,panBy:O.panBy,cancelConnection:O.cancelConnection,onConnectStart:O.onConnectStart,onConnectEnd:(...D)=>S.getState().onConnectEnd?.(...D),updateConnection:O.updateConnection,onConnect:Y,isValidConnection:s||((...D)=>S.getState().isValidConnection?.(...D)??!0),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:O.autoPanSpeed,dragThreshold:O.connectionDragThreshold})}A?p?.(L):x?.(L)},M=L=>{const{onClickConnectStart:A,onClickConnectEnd:O,connectionClickStartHandle:D,connectionMode:Z,isValidConnection:B,lib:q,rfId:X,nodeLookup:I,connection:_}=S.getState();if(!E||!D&&!o)return;if(!D){A?.(L.nativeEvent,{nodeId:E,handleId:w,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:E,type:e,id:w}});return}const V=Mw(L.target),Q=s||B,{connection:ee,isValid:te}=Ym.isValid(L.nativeEvent,{handle:{nodeId:E,id:w,type:e},connectionMode:Z,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:Q,flowId:X,doc:V,lib:q,nodeLookup:I});te&&ee&&Y(ee);const ae=structuredClone(_);delete ae.inProgress,ae.toPosition=ae.toHandle?ae.toHandle.position:null,O?.(L,ae),S.setState({connectionClickStartHandle:null})};return t.jsx("div",{"data-handleid":w,"data-nodeid":E,"data-handlepos":n,"data-id":`${T}-${E}-${w}-${e}`,className:Gn(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",k,f,{source:!N,target:N,connectable:i,connectablestart:o,connectableend:d,clickconnecting:U,connectingfrom:R,connectingto:z,valid:F,connectionindicator:i&&(!W||G)&&(W||$?d:o)}]),onMouseDown:P,onTouchStart:P,onClick:C?M:void 0,ref:y,...g,children:h})}const $a=v.memo(rN(vD));function jD({data:e,isConnectable:n,sourcePosition:s=ft.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx($a,{type:"source",position:s,isConnectable:n})]})}function wD({data:e,isConnectable:n,targetPosition:s=ft.Top,sourcePosition:i=ft.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx($a,{type:"target",position:s,isConnectable:n}),e?.label,t.jsx($a,{type:"source",position:i,isConnectable:n})]})}function ND(){return null}function kD({data:e,isConnectable:n,targetPosition:s=ft.Top}){return t.jsxs(t.Fragment,{children:[t.jsx($a,{type:"target",position:s,isConnectable:n}),e?.label]})}const Kd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},$v={input:jD,default:wD,output:kD,group:ND};function SD(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 CD=e=>{const{width:n,height:s,x:i,y:o}=Qo(e.nodeLookup,{filter:d=>!!d.selected});return{width:cs(n)?n:null,height:cs(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 ED({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:s}){const i=Mn(),{width:o,height:d,transformString:c,userSelectionActive:m}=Wt(CD,An),h=iN(),f=v.useRef(null);v.useEffect(()=>{s||f.current?.focus({preventScroll:!0})},[s]);const p=!m&&o!==null&&d!==null;if(aN({nodeRef:f,disabled:!p}),!p)return null;const x=e?y=>{const w=i.getState().nodes.filter(N=>N.selected);e(y,w)}:void 0,g=y=>{Object.prototype.hasOwnProperty.call(Kd,y.key)&&(y.preventDefault(),h({direction:Kd[y.key],factor:y.shiftKey?4:1}))};return t.jsx("div",{className:Gn(["react-flow__nodesselection","react-flow__container",n]),style:{transform:c},children:t.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:s?void 0:-1,onKeyDown:s?void 0:g,style:{width:o,height:d}})})}const Bv=typeof window<"u"?window:void 0,TD=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function oN({children:e,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:d,onPaneScroll:c,paneClickDistance:m,deleteKeyCode:h,selectionKeyCode:f,selectionOnDrag:p,selectionMode:x,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:w,panActivationKeyCode:N,zoomActivationKeyCode:S,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:T,panOnScrollSpeed:R,panOnScrollMode:z,zoomOnDoubleClick:U,panOnDrag:G,defaultViewport:W,translateExtent:$,minZoom:F,maxZoom:Y,preventScrolling:P,onSelectionContextMenu:M,noWheelClassName:L,noPanClassName:A,disableKeyboardA11y:O,onViewportChange:D,isControlledViewport:Z}){const{nodesSelectionActive:B,userSelectionActive:q}=Wt(TD,An),X=qo(f,{target:Bv}),I=qo(N,{target:Bv}),_=I||G,V=I||T,Q=p&&_!==!0,ee=X||q||Q;return oD({deleteKeyCode:h,multiSelectionKeyCode:w}),t.jsx(uD,{onPaneContextMenu:d,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:V,panOnScrollSpeed:R,panOnScrollMode:z,zoomOnDoubleClick:U,panOnDrag:!X&&_,defaultViewport:W,translateExtent:$,minZoom:F,maxZoom:Y,zoomActivationKeyCode:S,preventScrolling:P,noWheelClassName:L,noPanClassName:A,onViewportChange:D,isControlledViewport:Z,paneClickDistance:m,selectionOnDrag:Q,children:t.jsxs(xD,{onSelectionStart:g,onSelectionEnd:y,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:d,onPaneScroll:c,panOnDrag:_,isSelecting:!!ee,selectionMode:x,selectionKeyPressed:X,paneClickDistance:m,selectionOnDrag:Q,children:[e,B&&t.jsx(ED,{onSelectionContextMenu:M,noPanClassName:A,disableKeyboardA11y:O})]})})}oN.displayName="FlowRenderer";const _D=v.memo(oN),AD=e=>n=>e?_x(n.nodeLookup,{x:0,y:0,width:n.width,height:n.height},n.transform,!0).map(s=>s.id):Array.from(n.nodeLookup.keys());function MD(e){return Wt(v.useCallback(AD(e),[e]),An)}const OD=e=>e.updateNodeInternals;function RD(){const e=Wt(OD),[n]=v.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const i=new Map;s.forEach(o=>{const d=o.target.getAttribute("data-id");i.set(d,{id:d,nodeElement:o.target,force:!0})}),e(i)}));return v.useEffect(()=>()=>{n?.disconnect()},[n]),n}function DD({node:e,nodeType:n,hasDimensions:s,resizeObserver:i}){const o=Mn(),d=v.useRef(null),c=v.useRef(null),m=v.useRef(e.sourcePosition),h=v.useRef(e.targetPosition),f=v.useRef(n),p=s&&!!e.internals.handleBounds;return v.useEffect(()=>{d.current&&!e.hidden&&(!p||c.current!==d.current)&&(c.current&&i?.unobserve(c.current),i?.observe(d.current),c.current=d.current)},[p,e.hidden]),v.useEffect(()=>()=>{c.current&&(i?.unobserve(c.current),c.current=null)},[]),v.useEffect(()=>{if(d.current){const x=f.current!==n,g=m.current!==e.sourcePosition,y=h.current!==e.targetPosition;(x||g||y)&&(f.current=n,m.current=e.sourcePosition,h.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:d.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),d}function LD({id:e,onClick:n,onMouseEnter:s,onMouseMove:i,onMouseLeave:o,onContextMenu:d,onDoubleClick:c,nodesDraggable:m,elementsSelectable:h,nodesConnectable:f,nodesFocusable:p,resizeObserver:x,noDragClassName:g,noPanClassName:y,disableKeyboardA11y:w,rfId:N,nodeTypes:S,nodeClickDistance:E,onError:C}){const{node:k,internals:T,isParent:R}=Wt(te=>{const ae=te.nodeLookup.get(e),me=te.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:me}},An);let z=k.type||"default",U=S?.[z]||$v[z];U===void 0&&(C?.("003",Ts.error003(z)),z="default",U=S?.default||$v.default);const G=!!(k.draggable||m&&typeof k.draggable>"u"),W=!!(k.selectable||h&&typeof k.selectable>"u"),$=!!(k.connectable||f&&typeof k.connectable>"u"),F=!!(k.focusable||p&&typeof k.focusable>"u"),Y=Mn(),P=_w(k),M=DD({node:k,nodeType:z,hasDimensions:P,resizeObserver:x}),L=aN({nodeRef:M,disabled:k.hidden||!G,noDragClassName:g,handleSelector:k.dragHandle,nodeId:e,isSelectable:W,nodeClickDistance:E}),A=iN();if(k.hidden)return null;const O=ra(k),D=SD(k),Z=W||G||n||s||i||o,B=s?te=>s(te,{...T.userNode}):void 0,q=i?te=>i(te,{...T.userNode}):void 0,X=o?te=>o(te,{...T.userNode}):void 0,I=d?te=>d(te,{...T.userNode}):void 0,_=c?te=>c(te,{...T.userNode}):void 0,V=te=>{const{selectNodesOnDrag:ae,nodeDragThreshold:me}=Y.getState();W&&(!ae||!G||me>0)&&Gm({id:e,store:Y,nodeRef:M}),n&&n(te,{...T.userNode})},Q=te=>{if(!(Ow(te.nativeEvent)||w)){if(vw.includes(te.key)&&W){const ae=te.key==="Escape";Gm({id:e,store:Y,unselect:ae,nodeRef:M})}else if(G&&k.selected&&Object.prototype.hasOwnProperty.call(Kd,te.key)){te.preventDefault();const{ariaLabelConfig:ae}=Y.getState();Y.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),A({direction:Kd[te.key],factor:te.shiftKey?4:1})}}},ee=()=>{if(w||!M.current?.matches(":focus-visible"))return;const{transform:te,width:ae,height:me,autoPanOnNodeFocus:Ne,setCenter:Ie}=Y.getState();if(!Ne)return;_x(new Map([[e,k]]),{x:0,y:0,width:ae,height:me},te,!0).length>0||Ie(k.position.x+O.width/2,k.position.y+O.height/2,{zoom:te[2]})};return t.jsx("div",{className:Gn(["react-flow__node",`react-flow__node-${z}`,{[y]:G},k.className,{selected:k.selected,selectable:W,parent:R,draggable:G,dragging:L}]),ref:M,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:Z?"all":"none",visibility:P?"visible":"hidden",...k.style,...D},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:q,onMouseLeave:X,onContextMenu:I,onClick:V,onDoubleClick:_,onKeyDown:F?Q:void 0,tabIndex:F?0:void 0,onFocus:F?ee:void 0,role:k.ariaRole??(F?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${Zw}-${N}`,"aria-label":k.ariaLabel,...k.domAttributes,children:t.jsx(gD,{value:e,children:t.jsx(U,{id:e,data:k.data,type:z,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:k.selected??!1,selectable:W,draggable:G,deletable:k.deletable??!0,isConnectable:$,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:L,dragHandle:k.dragHandle,zIndex:T.z,parentId:k.parentId,...O})})})}var ID=v.memo(LD);const zD=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function cN(e){const{nodesDraggable:n,nodesConnectable:s,nodesFocusable:i,elementsSelectable:o,onError:d}=Wt(zD,An),c=MD(e.onlyRenderVisibleElements),m=RD();return t.jsx("div",{className:"react-flow__nodes",style:xu,children:c.map(h=>t.jsx(ID,{id:h,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:m,nodesDraggable:n,nodesConnectable:s,nodesFocusable:i,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:d},h))})}cN.displayName="NodeRenderer";const $D=v.memo(cN);function BD(e){return Wt(v.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 d=s.nodeLookup.get(o.source),c=s.nodeLookup.get(o.target);d&&c&&zO({sourceNode:d,targetNode:c,width:s.width,height:s.height,transform:s.transform})&&i.push(o.id)}return i},[e]),An)}const HD=({color:e="none",strokeWidth:n=1})=>{const s={strokeWidth:n,...e&&{stroke:e}};return t.jsx("polyline",{className:"arrow",style:s,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},PD=({color:e="none",strokeWidth:n=1})=>{const s={strokeWidth:n,...e&&{stroke:e,fill:e}};return t.jsx("polyline",{className:"arrowclosed",style:s,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Hv={[xl.Arrow]:HD,[xl.ArrowClosed]:PD};function UD(e){const n=Mn();return v.useMemo(()=>Object.prototype.hasOwnProperty.call(Hv,e)?Hv[e]:(n.getState().onError?.("009",Ts.error009(e)),null),[e])}const qD=({id:e,type:n,color:s,width:i=12.5,height:o=12.5,markerUnits:d="strokeWidth",strokeWidth:c,orient:m="auto-start-reverse"})=>{const h=UD(n);return h?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:d,orient:m,refX:"0",refY:"0",children:t.jsx(h,{color:s,strokeWidth:c})}):null},dN=({defaultColor:e,rfId:n})=>{const s=Wt(d=>d.edges),i=Wt(d=>d.defaultEdgeOptions),o=v.useMemo(()=>FO(s,{id:n,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd}),[s,i,n,e]);return o.length?t.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:t.jsx("defs",{children:o.map(d=>t.jsx(qD,{id:d.id,type:d.type,color:d.color,width:d.width,height:d.height,markerUnits:d.markerUnits,strokeWidth:d.strokeWidth,orient:d.orient},d.id))})}):null};dN.displayName="MarkerDefinitions";var VD=v.memo(dN);function uN({x:e,y:n,label:s,labelStyle:i,labelShowBg:o=!0,labelBgStyle:d,labelBgPadding:c=[2,4],labelBgBorderRadius:m=2,children:h,className:f,...p}){const[x,g]=v.useState({x:1,y:0,width:0,height:0}),y=Gn(["react-flow__edge-textwrapper",f]),w=v.useRef(null);return v.useEffect(()=>{if(w.current){const N=w.current.getBBox();g({x:N.x,y:N.y,width:N.width,height:N.height})}},[s]),s?t.jsxs("g",{transform:`translate(${e-x.width/2} ${n-x.height/2})`,className:y,visibility:x.width?"visible":"hidden",...p,children:[o&&t.jsx("rect",{width:x.width+2*c[0],x:-c[0],y:-c[1],height:x.height+2*c[1],className:"react-flow__edge-textbg",style:d,rx:m,ry:m}),t.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:w,style:i,children:s}),h]}):null}uN.displayName="EdgeText";const FD=v.memo(uN);function pu({path:e,labelX:n,labelY:s,label:i,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:m,labelBgBorderRadius:h,interactionWidth:f=20,...p}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{...p,d:e,fill:"none",className:Gn(["react-flow__edge-path",p.className])}),f?t.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,i&&cs(n)&&cs(s)?t.jsx(FD,{x:n,y:s,label:i,labelStyle:o,labelShowBg:d,labelBgStyle:c,labelBgPadding:m,labelBgBorderRadius:h}):null]})}function Pv({pos:e,x1:n,y1:s,x2:i,y2:o}){return e===ft.Left||e===ft.Right?[.5*(n+i),s]:[n,.5*(s+o)]}function fN({sourceX:e,sourceY:n,sourcePosition:s=ft.Bottom,targetX:i,targetY:o,targetPosition:d=ft.Top}){const[c,m]=Pv({pos:s,x1:e,y1:n,x2:i,y2:o}),[h,f]=Pv({pos:d,x1:i,y1:o,x2:e,y2:n}),[p,x,g,y]=Dw({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:c,sourceControlY:m,targetControlX:h,targetControlY:f});return[`M${e},${n} C${c},${m} ${h},${f} ${i},${o}`,p,x,g,y]}function hN(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:o,targetY:d,sourcePosition:c,targetPosition:m,label:h,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:S,interactionWidth:E})=>{const[C,k,T]=fN({sourceX:s,sourceY:i,sourcePosition:c,targetX:o,targetY:d,targetPosition:m}),R=e.isInternal?void 0:n;return t.jsx(pu,{id:R,path:C,labelX:k,labelY:T,label:h,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:S,interactionWidth:E})})}const YD=hN({isInternal:!1}),mN=hN({isInternal:!0});YD.displayName="SimpleBezierEdge";mN.displayName="SimpleBezierEdgeInternal";function xN(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:o,targetY:d,label:c,labelStyle:m,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,sourcePosition:y=ft.Bottom,targetPosition:w=ft.Top,markerEnd:N,markerStart:S,pathOptions:E,interactionWidth:C})=>{const[k,T,R]=qm({sourceX:s,sourceY:i,sourcePosition:y,targetX:o,targetY:d,targetPosition:w,borderRadius:E?.borderRadius,offset:E?.offset,stepPosition:E?.stepPosition}),z=e.isInternal?void 0:n;return t.jsx(pu,{id:z,path:k,labelX:T,labelY:R,label:c,labelStyle:m,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,markerEnd:N,markerStart:S,interactionWidth:C})})}const pN=xN({isInternal:!1}),gN=xN({isInternal:!0});pN.displayName="SmoothStepEdge";gN.displayName="SmoothStepEdgeInternal";function bN(e){return v.memo(({id:n,...s})=>{const i=e.isInternal?void 0:n;return t.jsx(pN,{...s,id:i,pathOptions:v.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const GD=bN({isInternal:!1}),yN=bN({isInternal:!0});GD.displayName="StepEdge";yN.displayName="StepEdgeInternal";function vN(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:o,targetY:d,label:c,labelStyle:m,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,markerEnd:y,markerStart:w,interactionWidth:N})=>{const[S,E,C]=zw({sourceX:s,sourceY:i,targetX:o,targetY:d}),k=e.isInternal?void 0:n;return t.jsx(pu,{id:k,path:S,labelX:E,labelY:C,label:c,labelStyle:m,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:x,style:g,markerEnd:y,markerStart:w,interactionWidth:N})})}const XD=vN({isInternal:!1}),jN=vN({isInternal:!0});XD.displayName="StraightEdge";jN.displayName="StraightEdgeInternal";function wN(e){return v.memo(({id:n,sourceX:s,sourceY:i,targetX:o,targetY:d,sourcePosition:c=ft.Bottom,targetPosition:m=ft.Top,label:h,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:S,pathOptions:E,interactionWidth:C})=>{const[k,T,R]=Lw({sourceX:s,sourceY:i,sourcePosition:c,targetX:o,targetY:d,targetPosition:m,curvature:E?.curvature}),z=e.isInternal?void 0:n;return t.jsx(pu,{id:z,path:k,labelX:T,labelY:R,label:h,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:y,style:w,markerEnd:N,markerStart:S,interactionWidth:C})})}const KD=wN({isInternal:!1}),NN=wN({isInternal:!0});KD.displayName="BezierEdge";NN.displayName="BezierEdgeInternal";const Uv={default:NN,straight:jN,step:yN,smoothstep:gN,simplebezier:mN},qv={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},WD=(e,n,s)=>s===ft.Left?e-n:s===ft.Right?e+n:e,ZD=(e,n,s)=>s===ft.Top?e-n:s===ft.Bottom?e+n:e,Vv="react-flow__edgeupdater";function Fv({position:e,centerX:n,centerY:s,radius:i=10,onMouseDown:o,onMouseEnter:d,onMouseOut:c,type:m}){return t.jsx("circle",{onMouseDown:o,onMouseEnter:d,onMouseOut:c,className:Gn([Vv,`${Vv}-${m}`]),cx:WD(n,i,e),cy:ZD(s,i,e),r:i,stroke:"transparent",fill:"transparent"})}function QD({isReconnectable:e,reconnectRadius:n,edge:s,sourceX:i,sourceY:o,targetX:d,targetY:c,sourcePosition:m,targetPosition:h,onReconnect:f,onReconnectStart:p,onReconnectEnd:x,setReconnecting:g,setUpdateHover:y}){const w=Mn(),N=(T,R)=>{if(T.button!==0)return;const{autoPanOnConnect:z,domNode:U,connectionMode:G,connectionRadius:W,lib:$,onConnectStart:F,cancelConnection:Y,nodeLookup:P,rfId:M,panBy:L,updateConnection:A}=w.getState(),O=R.type==="target",D=(q,X)=>{g(!1),x?.(q,s,R.type,X)},Z=q=>f?.(s,q),B=(q,X)=>{g(!0),p?.(T,s,R.type),F?.(q,X)};Ym.onPointerDown(T.nativeEvent,{autoPanOnConnect:z,connectionMode:G,connectionRadius:W,domNode:U,handleId:R.id,nodeId:R.nodeId,nodeLookup:P,isTarget:O,edgeUpdaterType:R.type,lib:$,flowId:M,cancelConnection:Y,panBy:L,isValidConnection:(...q)=>w.getState().isValidConnection?.(...q)??!0,onConnect:Z,onConnectStart:B,onConnectEnd:(...q)=>w.getState().onConnectEnd?.(...q),onReconnectEnd:D,updateConnection:A,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},S=T=>N(T,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),E=T=>N(T,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),C=()=>y(!0),k=()=>y(!1);return t.jsxs(t.Fragment,{children:[(e===!0||e==="source")&&t.jsx(Fv,{position:m,centerX:i,centerY:o,radius:n,onMouseDown:S,onMouseEnter:C,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&t.jsx(Fv,{position:h,centerX:d,centerY:c,radius:n,onMouseDown:E,onMouseEnter:C,onMouseOut:k,type:"target"})]})}function JD({id:e,edgesFocusable:n,edgesReconnectable:s,elementsSelectable:i,onClick:o,onDoubleClick:d,onContextMenu:c,onMouseEnter:m,onMouseMove:h,onMouseLeave:f,reconnectRadius:p,onReconnect:x,onReconnectStart:g,onReconnectEnd:y,rfId:w,edgeTypes:N,noPanClassName:S,onError:E,disableKeyboardA11y:C}){let k=Wt(Ie=>Ie.edgeLookup.get(e));const T=Wt(Ie=>Ie.defaultEdgeOptions);k=T?{...T,...k}:k;let R=k.type||"default",z=N?.[R]||Uv[R];z===void 0&&(E?.("011",Ts.error011(R)),R="default",z=N?.default||Uv.default);const U=!!(k.focusable||n&&typeof k.focusable>"u"),G=typeof x<"u"&&(k.reconnectable||s&&typeof k.reconnectable>"u"),W=!!(k.selectable||i&&typeof k.selectable>"u"),$=v.useRef(null),[F,Y]=v.useState(!1),[P,M]=v.useState(!1),L=Mn(),{zIndex:A,sourceX:O,sourceY:D,targetX:Z,targetY:B,sourcePosition:q,targetPosition:X}=Wt(v.useCallback(Ie=>{const je=Ie.nodeLookup.get(k.source),Te=Ie.nodeLookup.get(k.target);if(!je||!Te)return{zIndex:k.zIndex,...qv};const Ce=VO({id:e,sourceNode:je,targetNode:Te,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:Ie.connectionMode,onError:E});return{zIndex:IO({selected:k.selected,zIndex:k.zIndex,sourceNode:je,targetNode:Te,elevateOnSelect:Ie.elevateEdgesOnSelect,zIndexMode:Ie.zIndexMode}),...Ce||qv}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),An),I=v.useMemo(()=>k.markerStart?`url('#${Vm(k.markerStart,w)}')`:void 0,[k.markerStart,w]),_=v.useMemo(()=>k.markerEnd?`url('#${Vm(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||O===null||D===null||Z===null||B===null)return null;const V=Ie=>{const{addSelectedEdges:je,unselectNodesAndEdges:Te,multiSelectionActive:Ce}=L.getState();W&&(L.setState({nodesSelectionActive:!1}),k.selected&&Ce?(Te({nodes:[],edges:[k]}),$.current?.blur()):je([e])),o&&o(Ie,k)},Q=d?Ie=>{d(Ie,{...k})}:void 0,ee=c?Ie=>{c(Ie,{...k})}:void 0,te=m?Ie=>{m(Ie,{...k})}:void 0,ae=h?Ie=>{h(Ie,{...k})}:void 0,me=f?Ie=>{f(Ie,{...k})}:void 0,Ne=Ie=>{if(!C&&vw.includes(Ie.key)&&W){const{unselectNodesAndEdges:je,addSelectedEdges:Te}=L.getState();Ie.key==="Escape"?($.current?.blur(),je({edges:[k]})):Te([e])}};return t.jsx("svg",{style:{zIndex:A},children:t.jsxs("g",{className:Gn(["react-flow__edge",`react-flow__edge-${R}`,k.className,S,{selected:k.selected,animated:k.animated,inactive:!W&&!o,updating:F,selectable:W}]),onClick:V,onDoubleClick:Q,onContextMenu:ee,onMouseEnter:te,onMouseMove:ae,onMouseLeave:me,onKeyDown:U?Ne:void 0,tabIndex:U?0:void 0,role:k.ariaRole??(U?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":U?`${Qw}-${w}`:void 0,ref:$,...k.domAttributes,children:[!P&&t.jsx(z,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:W,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:O,sourceY:D,targetX:Z,targetY:B,sourcePosition:q,targetPosition:X,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:I,markerEnd:_,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),G&&t.jsx(QD,{edge:k,isReconnectable:G,reconnectRadius:p,onReconnect:x,onReconnectStart:g,onReconnectEnd:y,sourceX:O,sourceY:D,targetX:Z,targetY:B,sourcePosition:q,targetPosition:X,setUpdateHover:Y,setReconnecting:M})]})})}var eL=v.memo(JD);const tL=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function kN({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:s,edgeTypes:i,noPanClassName:o,onReconnect:d,onEdgeContextMenu:c,onEdgeMouseEnter:m,onEdgeMouseMove:h,onEdgeMouseLeave:f,onEdgeClick:p,reconnectRadius:x,onEdgeDoubleClick:g,onReconnectStart:y,onReconnectEnd:w,disableKeyboardA11y:N}){const{edgesFocusable:S,edgesReconnectable:E,elementsSelectable:C,onError:k}=Wt(tL,An),T=BD(n);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(VD,{defaultColor:e,rfId:s}),T.map(R=>t.jsx(eL,{id:R,edgesFocusable:S,edgesReconnectable:E,elementsSelectable:C,noPanClassName:o,onReconnect:d,onContextMenu:c,onMouseEnter:m,onMouseMove:h,onMouseLeave:f,onClick:p,reconnectRadius:x,onDoubleClick:g,onReconnectStart:y,onReconnectEnd:w,rfId:s,onError:k,edgeTypes:i,disableKeyboardA11y:N},R))]})}kN.displayName="EdgeRenderer";const nL=v.memo(kN),rL=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function sL({children:e}){const n=Wt(rL);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function aL(e){const n=zx(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),s.current=!0)},[e,n.viewportInitialized])}const iL=e=>e.panZoom?.syncViewport;function lL(e){const n=Wt(iL),s=Mn();return v.useEffect(()=>{e&&(n?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function oL(e){return e.connection.inProgress?{...e.connection,to:ec(e.connection.to,e.transform)}:{...e.connection}}function cL(e){return oL}function dL(e){const n=cL();return Wt(n,An)}const uL=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function fL({containerStyle:e,style:n,type:s,component:i}){const{nodesConnectable:o,width:d,height:c,isValid:m,inProgress:h}=Wt(uL,An);return!(d&&o&&h)?null:t.jsx("svg",{style:e,width:d,height:c,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:Gn(["react-flow__connection",Nw(m)]),children:t.jsx(SN,{style:n,type:s,CustomComponent:i,isValid:m})})})}const SN=({style:e,type:n=Ia.Bezier,CustomComponent:s,isValid:i})=>{const{inProgress:o,from:d,fromNode:c,fromHandle:m,fromPosition:h,to:f,toNode:p,toHandle:x,toPosition:g,pointer:y}=dL();if(!o)return;if(s)return t.jsx(s,{connectionLineType:n,connectionLineStyle:e,fromNode:c,fromHandle:m,fromX:d.x,fromY:d.y,toX:f.x,toY:f.y,fromPosition:h,toPosition:g,connectionStatus:Nw(i),toNode:p,toHandle:x,pointer:y});let w="";const N={sourceX:d.x,sourceY:d.y,sourcePosition:h,targetX:f.x,targetY:f.y,targetPosition:g};switch(n){case Ia.Bezier:[w]=Lw(N);break;case Ia.SimpleBezier:[w]=fN(N);break;case Ia.Step:[w]=qm({...N,borderRadius:0});break;case Ia.SmoothStep:[w]=qm(N);break;default:[w]=zw(N)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};SN.displayName="ConnectionLine";const hL={};function Yv(e=hL){v.useRef(e),Mn(),v.useEffect(()=>{},[e])}function mL(){Mn(),v.useRef(!1),v.useEffect(()=>{},[])}function CN({nodeTypes:e,edgeTypes:n,onInit:s,onNodeClick:i,onEdgeClick:o,onNodeDoubleClick:d,onEdgeDoubleClick:c,onNodeMouseEnter:m,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:x,onSelectionStart:g,onSelectionEnd:y,connectionLineType:w,connectionLineStyle:N,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:C,selectionOnDrag:k,selectionMode:T,multiSelectionKeyCode:R,panActivationKeyCode:z,zoomActivationKeyCode:U,deleteKeyCode:G,onlyRenderVisibleElements:W,elementsSelectable:$,defaultViewport:F,translateExtent:Y,minZoom:P,maxZoom:M,preventScrolling:L,defaultMarkerColor:A,zoomOnScroll:O,zoomOnPinch:D,panOnScroll:Z,panOnScrollSpeed:B,panOnScrollMode:q,zoomOnDoubleClick:X,panOnDrag:I,onPaneClick:_,onPaneMouseEnter:V,onPaneMouseMove:Q,onPaneMouseLeave:ee,onPaneScroll:te,onPaneContextMenu:ae,paneClickDistance:me,nodeClickDistance:Ne,onEdgeContextMenu:Ie,onEdgeMouseEnter:je,onEdgeMouseMove:Te,onEdgeMouseLeave:Ce,reconnectRadius:Re,onReconnect:Ge,onReconnectStart:ot,onReconnectEnd:st,noDragClassName:jt,noWheelClassName:re,noPanClassName:Ee,disableKeyboardA11y:Ze,nodeExtent:yt,rfId:Dt,viewport:we,onViewportChange:Le}){return Yv(e),Yv(n),mL(),aL(s),lL(we),t.jsx(_D,{onPaneClick:_,onPaneMouseEnter:V,onPaneMouseMove:Q,onPaneMouseLeave:ee,onPaneContextMenu:ae,onPaneScroll:te,paneClickDistance:me,deleteKeyCode:G,selectionKeyCode:C,selectionOnDrag:k,selectionMode:T,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:R,panActivationKeyCode:z,zoomActivationKeyCode:U,elementsSelectable:$,zoomOnScroll:O,zoomOnPinch:D,zoomOnDoubleClick:X,panOnScroll:Z,panOnScrollSpeed:B,panOnScrollMode:q,panOnDrag:I,defaultViewport:F,translateExtent:Y,minZoom:P,maxZoom:M,onSelectionContextMenu:x,preventScrolling:L,noDragClassName:jt,noWheelClassName:re,noPanClassName:Ee,disableKeyboardA11y:Ze,onViewportChange:Le,isControlledViewport:!!we,children:t.jsxs(sL,{children:[t.jsx(nL,{edgeTypes:n,onEdgeClick:o,onEdgeDoubleClick:c,onReconnect:Ge,onReconnectStart:ot,onReconnectEnd:st,onlyRenderVisibleElements:W,onEdgeContextMenu:Ie,onEdgeMouseEnter:je,onEdgeMouseMove:Te,onEdgeMouseLeave:Ce,reconnectRadius:Re,defaultMarkerColor:A,noPanClassName:Ee,disableKeyboardA11y:Ze,rfId:Dt}),t.jsx(fL,{style:N,type:w,component:S,containerStyle:E}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx($D,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:d,onNodeMouseEnter:m,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:p,nodeClickDistance:Ne,onlyRenderVisibleElements:W,noPanClassName:Ee,noDragClassName:jt,disableKeyboardA11y:Ze,nodeExtent:yt,rfId:Dt}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}CN.displayName="GraphView";const xL=v.memo(CN),Gv=({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:o,height:d,fitView:c,fitViewOptions:m,minZoom:h=.5,maxZoom:f=2,nodeOrigin:p,nodeExtent:x,zIndexMode:g="basic"}={})=>{const y=new Map,w=new Map,N=new Map,S=new Map,E=i??n??[],C=s??e??[],k=p??[0,0],T=x??Bo;Hw(N,S,E);const R=Fm(C,y,w,{nodeOrigin:k,nodeExtent:T,zIndexMode:g});let z=[0,0,1];if(c&&o&&d){const U=Qo(y,{filter:F=>!!((F.width||F.initialWidth)&&(F.height||F.initialHeight))}),{x:G,y:W,zoom:$}=Ax(U,o,d,h,f,m?.padding??.1);z=[G,W,$]}return{rfId:"1",width:o??0,height:d??0,transform:z,nodes:C,nodesInitialized:R,nodeLookup:y,parentLookup:w,edges:E,edgeLookup:S,connectionLookup:N,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:h,maxZoom:f,translateExtent:Bo,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ml.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:m,fitViewResolver:null,connection:{...ww},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:AO,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:jw,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},pL=({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:o,height:d,fitView:c,fitViewOptions:m,minZoom:h,maxZoom:f,nodeOrigin:p,nodeExtent:x,zIndexMode:g})=>DR((y,w)=>{async function N(){const{nodeLookup:S,panZoom:E,fitViewOptions:C,fitViewResolver:k,width:T,height:R,minZoom:z,maxZoom:U}=w();E&&(await TO({nodes:S,width:T,height:R,panZoom:E,minZoom:z,maxZoom:U},C),k?.resolve(!0),y({fitViewResolver:null}))}return{...Gv({nodes:e,edges:n,width:o,height:d,fitView:c,fitViewOptions:m,minZoom:h,maxZoom:f,nodeOrigin:p,nodeExtent:x,defaultNodes:s,defaultEdges:i,zIndexMode:g}),setNodes:S=>{const{nodeLookup:E,parentLookup:C,nodeOrigin:k,elevateNodesOnSelect:T,fitViewQueued:R,zIndexMode:z}=w(),U=Fm(S,E,C,{nodeOrigin:k,nodeExtent:x,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:z});R&&U?(N(),y({nodes:S,nodesInitialized:U,fitViewQueued:!1,fitViewOptions:void 0})):y({nodes:S,nodesInitialized:U})},setEdges:S=>{const{connectionLookup:E,edgeLookup:C}=w();Hw(E,C,S),y({edges:S})},setDefaultNodesAndEdges:(S,E)=>{if(S){const{setNodes:C}=w();C(S),y({hasDefaultNodes:!0})}if(E){const{setEdges:C}=w();C(E),y({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:E,nodeLookup:C,parentLookup:k,domNode:T,nodeOrigin:R,nodeExtent:z,debug:U,fitViewQueued:G,zIndexMode:W}=w(),{changes:$,updatedInternals:F}=QO(S,C,k,T,R,z,W);F&&(XO(C,k,{nodeOrigin:R,nodeExtent:z,zIndexMode:W}),G?(N(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),$?.length>0&&(U&&console.log("React Flow: trigger node changes",$),E?.($)))},updateNodePositions:(S,E=!1)=>{const C=[];let k=[];const{nodeLookup:T,triggerNodeChanges:R,connection:z,updateConnection:U,onNodesChangeMiddlewareMap:G}=w();for(const[W,$]of S){const F=T.get(W),Y=!!(F?.expandParent&&F?.parentId&&$?.position),P={id:W,type:"position",position:Y?{x:Math.max(0,$.position.x),y:Math.max(0,$.position.y)}:$.position,dragging:E};if(F&&z.inProgress&&z.fromNode.id===F.id){const M=vi(F,z.fromHandle,ft.Left,!0);U({...z,from:M})}Y&&F.parentId&&C.push({id:W,parentId:F.parentId,rect:{...$.internals.positionAbsolute,width:$.measured.width??0,height:$.measured.height??0}}),k.push(P)}if(C.length>0){const{parentLookup:W,nodeOrigin:$}=w(),F=Ix(C,T,W,$);k.push(...F)}for(const W of G.values())k=W(k);R(k)},triggerNodeChanges:S=>{const{onNodesChange:E,setNodes:C,nodes:k,hasDefaultNodes:T,debug:R}=w();if(S?.length){if(T){const z=tN(S,k);C(z)}R&&console.log("React Flow: trigger node changes",S),E?.(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:E,setEdges:C,edges:k,hasDefaultEdges:T,debug:R}=w();if(S?.length){if(T){const z=nN(S,k);C(z)}R&&console.log("React Flow: trigger edge changes",S),E?.(S)}},addSelectedNodes:S=>{const{multiSelectionActive:E,edgeLookup:C,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:R}=w();if(E){const z=S.map(U=>ci(U,!0));T(z);return}T(ll(k,new Set([...S]),!0)),R(ll(C))},addSelectedEdges:S=>{const{multiSelectionActive:E,edgeLookup:C,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:R}=w();if(E){const z=S.map(U=>ci(U,!0));R(z);return}R(ll(C,new Set([...S]))),T(ll(k,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:E}={})=>{const{edges:C,nodes:k,nodeLookup:T,triggerNodeChanges:R,triggerEdgeChanges:z}=w(),U=S||k,G=E||C,W=[];for(const F of U){if(!F.selected)continue;const Y=T.get(F.id);Y&&(Y.selected=!1),W.push(ci(F.id,!1))}const $=[];for(const F of G)F.selected&&$.push(ci(F.id,!1));R(W),z($)},setMinZoom:S=>{const{panZoom:E,maxZoom:C}=w();E?.setScaleExtent([S,C]),y({minZoom:S})},setMaxZoom:S=>{const{panZoom:E,minZoom:C}=w();E?.setScaleExtent([C,S]),y({maxZoom:S})},setTranslateExtent:S=>{w().panZoom?.setTranslateExtent(S),y({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:E,triggerNodeChanges:C,triggerEdgeChanges:k,elementsSelectable:T}=w();if(!T)return;const R=E.reduce((U,G)=>G.selected?[...U,ci(G.id,!1)]:U,[]),z=S.reduce((U,G)=>G.selected?[...U,ci(G.id,!1)]:U,[]);C(R),k(z)},setNodeExtent:S=>{const{nodes:E,nodeLookup:C,parentLookup:k,nodeOrigin:T,elevateNodesOnSelect:R,nodeExtent:z,zIndexMode:U}=w();S[0][0]===z[0][0]&&S[0][1]===z[0][1]&&S[1][0]===z[1][0]&&S[1][1]===z[1][1]||(Fm(E,C,k,{nodeOrigin:T,nodeExtent:S,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:U}),y({nodeExtent:S}))},panBy:S=>{const{transform:E,width:C,height:k,panZoom:T,translateExtent:R}=w();return JO({delta:S,panZoom:T,transform:E,translateExtent:R,width:C,height:k})},setCenter:async(S,E,C)=>{const{width:k,height:T,maxZoom:R,panZoom:z}=w();if(!z)return Promise.resolve(!1);const U=typeof C?.zoom<"u"?C.zoom:R;return await z.setViewport({x:k/2-S*U,y:T/2-E*U,zoom:U},{duration:C?.duration,ease:C?.ease,interpolate:C?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...ww}})},updateConnection:S=>{y({connection:S})},reset:()=>y({...Gv()})}},Object.is);function gL({initialNodes:e,initialEdges:n,defaultNodes:s,defaultEdges:i,initialWidth:o,initialHeight:d,initialMinZoom:c,initialMaxZoom:m,initialFitViewOptions:h,fitView:f,nodeOrigin:p,nodeExtent:x,zIndexMode:g,children:y}){const[w]=v.useState(()=>pL({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:o,height:d,fitView:f,minZoom:c,maxZoom:m,fitViewOptions:h,nodeOrigin:p,nodeExtent:x,zIndexMode:g}));return t.jsx(LR,{value:w,children:t.jsx(sD,{children:y})})}function bL({children:e,nodes:n,edges:s,defaultNodes:i,defaultEdges:o,width:d,height:c,fitView:m,fitViewOptions:h,minZoom:f,maxZoom:p,nodeOrigin:x,nodeExtent:g,zIndexMode:y}){return v.useContext(hu)?t.jsx(t.Fragment,{children:e}):t.jsx(gL,{initialNodes:n,initialEdges:s,defaultNodes:i,defaultEdges:o,initialWidth:d,initialHeight:c,fitView:m,initialFitViewOptions:h,initialMinZoom:f,initialMaxZoom:p,nodeOrigin:x,nodeExtent:g,zIndexMode:y,children:e})}const yL={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function vL({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,className:o,nodeTypes:d,edgeTypes:c,onNodeClick:m,onEdgeClick:h,onInit:f,onMove:p,onMoveStart:x,onMoveEnd:g,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:S,onClickConnectEnd:E,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:R,onNodeDoubleClick:z,onNodeDragStart:U,onNodeDrag:G,onNodeDragStop:W,onNodesDelete:$,onEdgesDelete:F,onDelete:Y,onSelectionChange:P,onSelectionDragStart:M,onSelectionDrag:L,onSelectionDragStop:A,onSelectionContextMenu:O,onSelectionStart:D,onSelectionEnd:Z,onBeforeDelete:B,connectionMode:q,connectionLineType:X=Ia.Bezier,connectionLineStyle:I,connectionLineComponent:_,connectionLineContainerStyle:V,deleteKeyCode:Q="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:te=!1,selectionMode:ae=Ho.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=Uo()?"Meta":"Control",zoomActivationKeyCode:Ie=Uo()?"Meta":"Control",snapToGrid:je,snapGrid:Te,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:Re,nodesDraggable:Ge,autoPanOnNodeFocus:ot,nodesConnectable:st,nodesFocusable:jt,nodeOrigin:re=Jw,edgesFocusable:Ee,edgesReconnectable:Ze,elementsSelectable:yt=!0,defaultViewport:Dt=XR,minZoom:we=.5,maxZoom:Le=2,translateExtent:Ue=Bo,preventScrolling:at=!0,nodeExtent:rt,defaultMarkerColor:Zt="#b1b1b7",zoomOnScroll:fn=!0,zoomOnPinch:zt=!0,panOnScroll:Mt=!1,panOnScrollSpeed:_t=.5,panOnScrollMode:Ct=mi.Free,zoomOnDoubleClick:en=!0,panOnDrag:Ht=!0,onPaneClick:Tn,onPaneMouseEnter:wn,onPaneMouseMove:ye,onPaneMouseLeave:We,onPaneScroll:He,onPaneContextMenu:wt,paneClickDistance:Tt=1,nodeClickDistance:tn=0,children:nn,onReconnect:hn,onReconnectStart:mn,onReconnectEnd:On,onEdgeContextMenu:Nt,onEdgeDoubleClick:oe,onEdgeMouseEnter:Ve,onEdgeMouseMove:ze,onEdgeMouseLeave:dt,reconnectRadius:it=10,onNodesChange:xt,onEdgesChange:$t,noDragClassName:Je="nodrag",noWheelClassName:Fe="nowheel",noPanClassName:Et="nopan",fitView:Rn,fitViewOptions:Nn,connectOnClick:ln,attributionPosition:ve,proOptions:Xe,defaultEdgeOptions:At,elevateNodesOnSelect:St=!0,elevateEdgesOnSelect:xn=!1,disableKeyboardA11y:Qn=!1,autoPanOnConnect:lr,autoPanOnNodeDrag:on,autoPanSpeed:ur,connectionRadius:Jr,isValidConnection:de,onError:Ae,style:qe,id:Bt,nodeDragThreshold:xr,connectionDragThreshold:es,viewport:fr,onViewportChange:ms,width:nr,height:Xn,colorMode:Ms="light",debug:Ha,onScroll:ts,ariaLabelConfig:Er,zIndexMode:Pr="basic",...Pa},Jn){const ns=Bt||"1",Kn=QR(Ms),Tr=v.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ts?.(pr)},[ts]);return t.jsx("div",{"data-testid":"rf__wrapper",...Pa,onScroll:Tr,style:{...qe,...yL},ref:Jn,className:Gn(["react-flow",o,Kn]),id:Bt,role:"application",children:t.jsxs(bL,{nodes:e,edges:n,width:nr,height:Xn,fitView:Rn,fitViewOptions:Nn,minZoom:we,maxZoom:Le,nodeOrigin:re,nodeExtent:rt,zIndexMode:Pr,children:[t.jsx(xL,{onInit:f,onNodeClick:m,onEdgeClick:h,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:R,onNodeDoubleClick:z,nodeTypes:d,edgeTypes:c,connectionLineType:X,connectionLineStyle:I,connectionLineComponent:_,connectionLineContainerStyle:V,selectionKeyCode:ee,selectionOnDrag:te,selectionMode:ae,deleteKeyCode:Q,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:Ie,onlyRenderVisibleElements:Ce,defaultViewport:Dt,translateExtent:Ue,minZoom:we,maxZoom:Le,preventScrolling:at,zoomOnScroll:fn,zoomOnPinch:zt,zoomOnDoubleClick:en,panOnScroll:Mt,panOnScrollSpeed:_t,panOnScrollMode:Ct,panOnDrag:Ht,onPaneClick:Tn,onPaneMouseEnter:wn,onPaneMouseMove:ye,onPaneMouseLeave:We,onPaneScroll:He,onPaneContextMenu:wt,paneClickDistance:Tt,nodeClickDistance:tn,onSelectionContextMenu:O,onSelectionStart:D,onSelectionEnd:Z,onReconnect:hn,onReconnectStart:mn,onReconnectEnd:On,onEdgeContextMenu:Nt,onEdgeDoubleClick:oe,onEdgeMouseEnter:Ve,onEdgeMouseMove:ze,onEdgeMouseLeave:dt,reconnectRadius:it,defaultMarkerColor:Zt,noDragClassName:Je,noWheelClassName:Fe,noPanClassName:Et,rfId:ns,disableKeyboardA11y:Qn,nodeExtent:rt,viewport:fr,onViewportChange:ms}),t.jsx(ZR,{nodes:e,edges:n,defaultNodes:s,defaultEdges:i,onConnect:y,onConnectStart:w,onConnectEnd:N,onClickConnectStart:S,onClickConnectEnd:E,nodesDraggable:Ge,autoPanOnNodeFocus:ot,nodesConnectable:st,nodesFocusable:jt,edgesFocusable:Ee,edgesReconnectable:Ze,elementsSelectable:yt,elevateNodesOnSelect:St,elevateEdgesOnSelect:xn,minZoom:we,maxZoom:Le,nodeExtent:rt,onNodesChange:xt,onEdgesChange:$t,snapToGrid:je,snapGrid:Te,connectionMode:q,translateExtent:Ue,connectOnClick:ln,defaultEdgeOptions:At,fitView:Rn,fitViewOptions:Nn,onNodesDelete:$,onEdgesDelete:F,onDelete:Y,onNodeDragStart:U,onNodeDrag:G,onNodeDragStop:W,onSelectionDrag:L,onSelectionDragStart:M,onSelectionDragStop:A,onMove:p,onMoveStart:x,onMoveEnd:g,noPanClassName:Et,nodeOrigin:re,rfId:ns,autoPanOnConnect:lr,autoPanOnNodeDrag:on,autoPanSpeed:ur,onError:Ae,connectionRadius:Jr,isValidConnection:de,selectNodesOnDrag:Re,nodeDragThreshold:xr,connectionDragThreshold:es,onBeforeDelete:B,debug:Ha,ariaLabelConfig:Er,zIndexMode:Pr}),t.jsx(GR,{onSelectionChange:P}),nn,t.jsx(UR,{proOptions:Xe,position:ve}),t.jsx(PR,{rfId:ns,disableKeyboardA11y:Qn})]})})}var jL=rN(vL);function wL(e){const[n,s]=v.useState(e),i=v.useCallback(o=>s(d=>tN(o,d)),[]);return[n,s,i]}function NL(e){const[n,s]=v.useState(e),i=v.useCallback(o=>s(d=>nN(o,d)),[]);return[n,s,i]}function kL({dimensions:e,lineWidth:n,variant:s,className:i}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Gn(["react-flow__background-pattern",s,i])})}function SL({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:Gn(["react-flow__background-pattern","dots",n])})}var za;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(za||(za={}));const CL={[za.Dots]:1,[za.Lines]:1,[za.Cross]:6},EL=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function EN({id:e,variant:n=za.Dots,gap:s=20,size:i,lineWidth:o=1,offset:d=0,color:c,bgColor:m,style:h,className:f,patternClassName:p}){const x=v.useRef(null),{transform:g,patternId:y}=Wt(EL,An),w=i||CL[n],N=n===za.Dots,S=n===za.Cross,E=Array.isArray(s)?s:[s,s],C=[E[0]*g[2]||1,E[1]*g[2]||1],k=w*g[2],T=Array.isArray(d)?d:[d,d],R=S?[k,k]:C,z=[T[0]*g[2]||1+R[0]/2,T[1]*g[2]||1+R[1]/2],U=`${y}${e||""}`;return t.jsxs("svg",{className:Gn(["react-flow__background",f]),style:{...h,...xu,"--xy-background-color-props":m,"--xy-background-pattern-color-props":c},ref:x,"data-testid":"rf__background",children:[t.jsx("pattern",{id:U,x:g[0]%C[0],y:g[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:N?t.jsx(SL,{radius:k/2,className:p}):t.jsx(kL,{dimensions:R,lineWidth:o,variant:n,className:p})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${U})`})]})}EN.displayName="Background";const TL=v.memo(EN);function _L(){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 AL(){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 ML(){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 OL(){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 RL(){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 yd({children:e,className:n,...s}){return t.jsx("button",{type:"button",className:Gn(["react-flow__controls-button",n]),...s,children:e})}const DL=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function TN({style:e,showZoom:n=!0,showFitView:s=!0,showInteractive:i=!0,fitViewOptions:o,onZoomIn:d,onZoomOut:c,onFitView:m,onInteractiveChange:h,className:f,children:p,position:x="bottom-left",orientation:g="vertical","aria-label":y}){const w=Mn(),{isInteractive:N,minZoomReached:S,maxZoomReached:E,ariaLabelConfig:C}=Wt(DL,An),{zoomIn:k,zoomOut:T,fitView:R}=zx(),z=()=>{k(),d?.()},U=()=>{T(),c?.()},G=()=>{R(o),m?.()},W=()=>{w.setState({nodesDraggable:!N,nodesConnectable:!N,elementsSelectable:!N}),h?.(!N)},$=g==="horizontal"?"horizontal":"vertical";return t.jsxs(mu,{className:Gn(["react-flow__controls",$,f]),position:x,style:e,"data-testid":"rf__controls","aria-label":y??C["controls.ariaLabel"],children:[n&&t.jsxs(t.Fragment,{children:[t.jsx(yd,{onClick:z,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:E,children:t.jsx(_L,{})}),t.jsx(yd,{onClick:U,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:S,children:t.jsx(AL,{})})]}),s&&t.jsx(yd,{className:"react-flow__controls-fitview",onClick:G,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:t.jsx(ML,{})}),i&&t.jsx(yd,{className:"react-flow__controls-interactive",onClick:W,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:N?t.jsx(RL,{}):t.jsx(OL,{})}),p]})}TN.displayName="Controls";const LL=v.memo(TN);function IL({id:e,x:n,y:s,width:i,height:o,style:d,color:c,strokeColor:m,strokeWidth:h,className:f,borderRadius:p,shapeRendering:x,selected:g,onClick:y}){const{background:w,backgroundColor:N}=d||{},S=c||w||N;return t.jsx("rect",{className:Gn(["react-flow__minimap-node",{selected:g},f]),x:n,y:s,rx:p,ry:p,width:i,height:o,style:{fill:S,stroke:m,strokeWidth:h},shapeRendering:x,onClick:y?E=>y(E,e):void 0})}const zL=v.memo(IL),$L=e=>e.nodes.map(n=>n.id),am=e=>e instanceof Function?e:()=>e;function BL({nodeStrokeColor:e,nodeColor:n,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:d=zL,onClick:c}){const m=Wt($L,An),h=am(n),f=am(e),p=am(s),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:m.map(g=>t.jsx(PL,{id:g,nodeColorFunc:h,nodeStrokeColorFunc:f,nodeClassNameFunc:p,nodeBorderRadius:i,nodeStrokeWidth:o,NodeComponent:d,onClick:c,shapeRendering:x},g))})}function HL({id:e,nodeColorFunc:n,nodeStrokeColorFunc:s,nodeClassNameFunc:i,nodeBorderRadius:o,nodeStrokeWidth:d,shapeRendering:c,NodeComponent:m,onClick:h}){const{node:f,x:p,y:x,width:g,height:y}=Wt(w=>{const N=w.nodeLookup.get(e);if(!N)return{node:void 0,x:0,y:0,width:0,height:0};const S=N.internals.userNode,{x:E,y:C}=N.internals.positionAbsolute,{width:k,height:T}=ra(S);return{node:S,x:E,y:C,width:k,height:T}},An);return!f||f.hidden||!_w(f)?null:t.jsx(m,{x:p,y:x,width:g,height:y,style:f.style,selected:!!f.selected,className:i(f),color:n(f),borderRadius:o,strokeColor:s(f),strokeWidth:d,shapeRendering:c,onClick:h,id:f.id})}const PL=v.memo(HL);var UL=v.memo(BL);const qL=200,VL=150,FL=e=>!e.hidden,YL=e=>{const n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:e.nodeLookup.size>0?Tw(Qo(e.nodeLookup,{filter:FL}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},GL="react-flow__minimap-desc";function _N({style:e,className:n,nodeStrokeColor:s,nodeColor:i,nodeClassName:o="",nodeBorderRadius:d=5,nodeStrokeWidth:c,nodeComponent:m,bgColor:h,maskColor:f,maskStrokeColor:p,maskStrokeWidth:x,position:g="bottom-right",onClick:y,onNodeClick:w,pannable:N=!1,zoomable:S=!1,ariaLabel:E,inversePan:C,zoomStep:k=1,offsetScale:T=5}){const R=Mn(),z=v.useRef(null),{boundingRect:U,viewBB:G,rfId:W,panZoom:$,translateExtent:F,flowWidth:Y,flowHeight:P,ariaLabelConfig:M}=Wt(YL,An),L=e?.width??qL,A=e?.height??VL,O=U.width/L,D=U.height/A,Z=Math.max(O,D),B=Z*L,q=Z*A,X=T*Z,I=U.x-(B-U.width)/2-X,_=U.y-(q-U.height)/2-X,V=B+X*2,Q=q+X*2,ee=`${GL}-${W}`,te=v.useRef(0),ae=v.useRef();te.current=Z,v.useEffect(()=>{if(z.current&&$)return ae.current=oR({domNode:z.current,panZoom:$,getTransform:()=>R.getState().transform,getViewScale:()=>te.current}),()=>{ae.current?.destroy()}},[$]),v.useEffect(()=>{ae.current?.update({translateExtent:F,width:Y,height:P,inversePan:C,pannable:N,zoomStep:k,zoomable:S})},[N,S,C,k,F,Y,P]);const me=y?je=>{const[Te,Ce]=ae.current?.pointer(je)||[0,0];y(je,{x:Te,y:Ce})}:void 0,Ne=w?v.useCallback((je,Te)=>{const Ce=R.getState().nodeLookup.get(Te).internals.userNode;w(je,Ce)},[]):void 0,Ie=E??M["minimap.ariaLabel"];return t.jsx(mu,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*Z: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 c=="number"?c:void 0},className:Gn(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:L,height:A,viewBox:`${I} ${_} ${V} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:z,onClick:me,children:[Ie&&t.jsx("title",{id:ee,children:Ie}),t.jsx(UL,{onClick:Ne,nodeColor:i,nodeStrokeColor:s,nodeBorderRadius:d,nodeClassName:o,nodeStrokeWidth:c,nodeComponent:m}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${I-X},${_-X}h${V+X*2}v${Q+X*2}h${-V-X*2}z
61
- M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}_N.displayName="MiniMap";const XL=v.memo(_N),KL=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,WL={[yl.Line]:"right",[yl.Handle]:"bottom-right"};function ZL({nodeId:e,position:n,variant:s=yl.Handle,className:i,style:o=void 0,children:d,color:c,minWidth:m=10,minHeight:h=10,maxWidth:f=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:g,autoScale:y=!0,shouldResize:w,onResizeStart:N,onResize:S,onResizeEnd:E}){const C=lN(),k=typeof e=="string"?e:C,T=Mn(),R=v.useRef(null),z=s===yl.Handle,U=Wt(v.useCallback(KL(z&&y),[z,y]),An),G=v.useRef(null),W=n??WL[s];v.useEffect(()=>{if(!(!R.current||!k))return G.current||(G.current=wR({domNode:R.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:F,transform:Y,snapGrid:P,snapToGrid:M,nodeOrigin:L,domNode:A}=T.getState();return{nodeLookup:F,transform:Y,snapGrid:P,snapToGrid:M,nodeOrigin:L,paneDomNode:A}},onChange:(F,Y)=>{const{triggerNodeChanges:P,nodeLookup:M,parentLookup:L,nodeOrigin:A}=T.getState(),O=[],D={x:F.x,y:F.y},Z=M.get(k);if(Z&&Z.expandParent&&Z.parentId){const B=Z.origin??A,q=F.width??Z.measured.width??0,X=F.height??Z.measured.height??0,I={id:Z.id,parentId:Z.parentId,rect:{width:q,height:X,...Aw({x:F.x??Z.position.x,y:F.y??Z.position.y},{width:q,height:X},Z.parentId,M,B)}},_=Ix([I],M,L,A);O.push(..._),D.x=F.x?Math.max(B[0]*q,F.x):void 0,D.y=F.y?Math.max(B[1]*X,F.y):void 0}if(D.x!==void 0&&D.y!==void 0){const B={id:k,type:"position",position:{...D}};O.push(B)}if(F.width!==void 0&&F.height!==void 0){const q={id:k,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:F.width,height:F.height}};O.push(q)}for(const B of Y){const q={...B,type:"position"};O.push(q)}P(O)},onEnd:({width:F,height:Y})=>{const P={id:k,type:"dimensions",resizing:!1,dimensions:{width:F,height:Y}};T.getState().triggerNodeChanges([P])}})),G.current.update({controlPosition:W,boundaries:{minWidth:m,minHeight:h,maxWidth:f,maxHeight:p},keepAspectRatio:x,resizeDirection:g,onResizeStart:N,onResize:S,onResizeEnd:E,shouldResize:w}),()=>{G.current?.destroy()}},[W,m,h,f,p,x,N,S,E,w]);const $=W.split("-");return t.jsx("div",{className:Gn(["react-flow__resize-control","nodrag",...$,s,i]),ref:R,style:{...o,scale:U,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:d})}v.memo(ZL);var un=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),fs=un((e,n)=>{var s=Object.defineProperty,i=(P,M,L)=>M in P?s(P,M,{enumerable:!0,configurable:!0,writable:!0,value:L}):P[M]=L,o=(P,M)=>()=>(M||P((M={exports:{}}).exports,M),M.exports),d=(P,M,L)=>i(P,typeof M!="symbol"?M+"":M,L),c=o((P,M)=>{var L="\0",A="\0",O="",D=class{constructor(_){d(this,"_isDirected",!0),d(this,"_isMultigraph",!1),d(this,"_isCompound",!1),d(this,"_label"),d(this,"_defaultNodeLabelFn",()=>{}),d(this,"_defaultEdgeLabelFn",()=>{}),d(this,"_nodes",{}),d(this,"_in",{}),d(this,"_preds",{}),d(this,"_out",{}),d(this,"_sucs",{}),d(this,"_edgeObjs",{}),d(this,"_edgeLabels",{}),d(this,"_nodeCount",0),d(this,"_edgeCount",0),d(this,"_parent"),d(this,"_children"),_&&(this._isDirected=Object.hasOwn(_,"directed")?_.directed:!0,this._isMultigraph=Object.hasOwn(_,"multigraph")?_.multigraph:!1,this._isCompound=Object.hasOwn(_,"compound")?_.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[A]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(_){return this._label=_,this}graph(){return this._label}setDefaultNodeLabel(_){return this._defaultNodeLabelFn=_,typeof _!="function"&&(this._defaultNodeLabelFn=()=>_),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var _=this;return this.nodes().filter(V=>Object.keys(_._in[V]).length===0)}sinks(){var _=this;return this.nodes().filter(V=>Object.keys(_._out[V]).length===0)}setNodes(_,V){var Q=arguments,ee=this;return _.forEach(function(te){Q.length>1?ee.setNode(te,V):ee.setNode(te)}),this}setNode(_,V){return Object.hasOwn(this._nodes,_)?(arguments.length>1&&(this._nodes[_]=V),this):(this._nodes[_]=arguments.length>1?V:this._defaultNodeLabelFn(_),this._isCompound&&(this._parent[_]=A,this._children[_]={},this._children[A][_]=!0),this._in[_]={},this._preds[_]={},this._out[_]={},this._sucs[_]={},++this._nodeCount,this)}node(_){return this._nodes[_]}hasNode(_){return Object.hasOwn(this._nodes,_)}removeNode(_){var V=this;if(Object.hasOwn(this._nodes,_)){var Q=ee=>V.removeEdge(V._edgeObjs[ee]);delete this._nodes[_],this._isCompound&&(this._removeFromParentsChildList(_),delete this._parent[_],this.children(_).forEach(function(ee){V.setParent(ee)}),delete this._children[_]),Object.keys(this._in[_]).forEach(Q),delete this._in[_],delete this._preds[_],Object.keys(this._out[_]).forEach(Q),delete this._out[_],delete this._sucs[_],--this._nodeCount}return this}setParent(_,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===_)throw new Error("Setting "+V+" as parent of "+_+" would create a cycle");this.setNode(V)}return this.setNode(_),this._removeFromParentsChildList(_),this._parent[_]=V,this._children[V][_]=!0,this}_removeFromParentsChildList(_){delete this._children[this._parent[_]][_]}parent(_){if(this._isCompound){var V=this._parent[_];if(V!==A)return V}}children(_=A){if(this._isCompound){var V=this._children[_];if(V)return Object.keys(V)}else{if(_===A)return this.nodes();if(this.hasNode(_))return[]}}predecessors(_){var V=this._preds[_];if(V)return Object.keys(V)}successors(_){var V=this._sucs[_];if(V)return Object.keys(V)}neighbors(_){var V=this.predecessors(_);if(V){let ee=new Set(V);for(var Q of this.successors(_))ee.add(Q);return Array.from(ee.values())}}isLeaf(_){var V;return this.isDirected()?V=this.successors(_):V=this.neighbors(_),V.length===0}filterNodes(_){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([ae,me]){_(ae)&&V.setNode(ae,me)}),Object.values(this._edgeObjs).forEach(function(ae){V.hasNode(ae.v)&&V.hasNode(ae.w)&&V.setEdge(ae,Q.edge(ae))});var ee={};function te(ae){var me=Q.parent(ae);return me===void 0||V.hasNode(me)?(ee[ae]=me,me):me in ee?ee[me]:te(me)}return this._isCompound&&V.nodes().forEach(ae=>V.setParent(ae,te(ae))),V}setDefaultEdgeLabel(_){return this._defaultEdgeLabelFn=_,typeof _!="function"&&(this._defaultEdgeLabelFn=()=>_),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(_,V){var Q=this,ee=arguments;return _.reduce(function(te,ae){return ee.length>1?Q.setEdge(te,ae,V):Q.setEdge(te,ae),ae}),this}setEdge(){var _,V,Q,ee,te=!1,ae=arguments[0];typeof ae=="object"&&ae!==null&&"v"in ae?(_=ae.v,V=ae.w,Q=ae.name,arguments.length===2&&(ee=arguments[1],te=!0)):(_=ae,V=arguments[1],Q=arguments[3],arguments.length>2&&(ee=arguments[2],te=!0)),_=""+_,V=""+V,Q!==void 0&&(Q=""+Q);var me=q(this._isDirected,_,V,Q);if(Object.hasOwn(this._edgeLabels,me))return te&&(this._edgeLabels[me]=ee),this;if(Q!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(_),this.setNode(V),this._edgeLabels[me]=te?ee:this._defaultEdgeLabelFn(_,V,Q);var Ne=X(this._isDirected,_,V,Q);return _=Ne.v,V=Ne.w,Object.freeze(Ne),this._edgeObjs[me]=Ne,Z(this._preds[V],_),Z(this._sucs[_],V),this._in[V][me]=Ne,this._out[_][me]=Ne,this._edgeCount++,this}edge(_,V,Q){var ee=arguments.length===1?I(this._isDirected,arguments[0]):q(this._isDirected,_,V,Q);return this._edgeLabels[ee]}edgeAsObj(){let _=this.edge(...arguments);return typeof _!="object"?{label:_}:_}hasEdge(_,V,Q){var ee=arguments.length===1?I(this._isDirected,arguments[0]):q(this._isDirected,_,V,Q);return Object.hasOwn(this._edgeLabels,ee)}removeEdge(_,V,Q){var ee=arguments.length===1?I(this._isDirected,arguments[0]):q(this._isDirected,_,V,Q),te=this._edgeObjs[ee];return te&&(_=te.v,V=te.w,delete this._edgeLabels[ee],delete this._edgeObjs[ee],B(this._preds[V],_),B(this._sucs[_],V),delete this._in[V][ee],delete this._out[_][ee],this._edgeCount--),this}inEdges(_,V){return this.isDirected()?this.filterEdges(this._in[_],_,V):this.nodeEdges(_,V)}outEdges(_,V){return this.isDirected()?this.filterEdges(this._out[_],_,V):this.nodeEdges(_,V)}nodeEdges(_,V){if(_ in this._nodes)return this.filterEdges({...this._in[_],...this._out[_]},_,V)}filterEdges(_,V,Q){if(_){var ee=Object.values(_);return Q?ee.filter(function(te){return te.v===V&&te.w===Q||te.v===Q&&te.w===V}):ee}}};function Z(_,V){_[V]?_[V]++:_[V]=1}function B(_,V){--_[V]||delete _[V]}function q(_,V,Q,ee){var te=""+V,ae=""+Q;if(!_&&te>ae){var me=te;te=ae,ae=me}return te+O+ae+O+(ee===void 0?L:ee)}function X(_,V,Q,ee){var te=""+V,ae=""+Q;if(!_&&te>ae){var me=te;te=ae,ae=me}var Ne={v:te,w:ae};return ee&&(Ne.name=ee),Ne}function I(_,V){return q(_,V.v,V.w,V.name)}M.exports=D}),m=o((P,M)=>{M.exports="3.0.2"}),h=o((P,M)=>{M.exports={Graph:c(),version:m()}}),f=o((P,M)=>{var L=c();M.exports={write:A,read:Z};function A(B){var q={options:{directed:B.isDirected(),multigraph:B.isMultigraph(),compound:B.isCompound()},nodes:O(B),edges:D(B)};return B.graph()!==void 0&&(q.value=structuredClone(B.graph())),q}function O(B){return B.nodes().map(function(q){var X=B.node(q),I=B.parent(q),_={v:q};return X!==void 0&&(_.value=X),I!==void 0&&(_.parent=I),_})}function D(B){return B.edges().map(function(q){var X=B.edge(q),I={v:q.v,w:q.w};return q.name!==void 0&&(I.name=q.name),X!==void 0&&(I.value=X),I})}function Z(B){var q=new L(B.options).setGraph(B.value);return B.nodes.forEach(function(X){q.setNode(X.v,X.value),X.parent&&q.setParent(X.v,X.parent)}),B.edges.forEach(function(X){q.setEdge({v:X.v,w:X.w,name:X.name},X.value)}),q}}),p=o((P,M)=>{M.exports=A;var L=()=>1;function A(D,Z,B,q){return O(D,String(Z),B||L,q||function(X){return D.outEdges(X)})}function O(D,Z,B,q){var X={},I=!0,_=0,V=D.nodes(),Q=function(me){var Ne=B(me);X[me.v].distance+Ne<X[me.w].distance&&(X[me.w]={distance:X[me.v].distance+Ne,predecessor:me.v},I=!0)},ee=function(){V.forEach(function(me){q(me).forEach(function(Ne){var Ie=Ne.v===me?Ne.v:Ne.w,je=Ie===Ne.v?Ne.w:Ne.v;Q({v:Ie,w:je})})})};V.forEach(function(me){var Ne=me===Z?0:Number.POSITIVE_INFINITY;X[me]={distance:Ne}});for(var te=V.length,ae=1;ae<te&&(I=!1,_++,ee(),!!I);ae++);if(_===te-1&&(I=!1,ee(),I))throw new Error("The graph contains a negative weight cycle");return X}}),x=o((P,M)=>{M.exports=L;function L(A){var O={},D=[],Z;function B(q){Object.hasOwn(O,q)||(O[q]=!0,Z.push(q),A.successors(q).forEach(B),A.predecessors(q).forEach(B))}return A.nodes().forEach(function(q){Z=[],B(q),Z.length&&D.push(Z)}),D}}),g=o((P,M)=>{var L=class{constructor(){d(this,"_arr",[]),d(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(A){return A.key})}has(A){return Object.hasOwn(this._keyIndices,A)}priority(A){var O=this._keyIndices[A];if(O!==void 0)return this._arr[O].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(A,O){var D=this._keyIndices;if(A=String(A),!Object.hasOwn(D,A)){var Z=this._arr,B=Z.length;return D[A]=B,Z.push({key:A,priority:O}),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,O){var D=this._keyIndices[A];if(O>this._arr[D].priority)throw new Error("New priority is greater than current priority. Key: "+A+" Old: "+this._arr[D].priority+" New: "+O);this._arr[D].priority=O,this._decrease(D)}_heapify(A){var O=this._arr,D=2*A,Z=D+1,B=A;D<O.length&&(B=O[D].priority<O[B].priority?D:B,Z<O.length&&(B=O[Z].priority<O[B].priority?Z:B),B!==A&&(this._swap(A,B),this._heapify(B)))}_decrease(A){for(var O=this._arr,D=O[A].priority,Z;A!==0&&(Z=A>>1,!(O[Z].priority<D));)this._swap(A,Z),A=Z}_swap(A,O){var D=this._arr,Z=this._keyIndices,B=D[A],q=D[O];D[A]=q,D[O]=B,Z[q.key]=A,Z[B.key]=O}};M.exports=L}),y=o((P,M)=>{var L=g();M.exports=O;var A=()=>1;function O(Z,B,q,X){var I=function(_){return Z.outEdges(_)};return D(Z,String(B),q||A,X||I)}function D(Z,B,q,X){var I={},_=new L,V,Q,ee=function(te){var ae=te.v!==V?te.v:te.w,me=I[ae],Ne=q(te),Ie=Q.distance+Ne;if(Ne<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+te+" Weight: "+Ne);Ie<me.distance&&(me.distance=Ie,me.predecessor=V,_.decrease(ae,Ie))};for(Z.nodes().forEach(function(te){var ae=te===B?0:Number.POSITIVE_INFINITY;I[te]={distance:ae},_.add(te,ae)});_.size()>0&&(V=_.removeMin(),Q=I[V],Q.distance!==Number.POSITIVE_INFINITY);)X(V).forEach(ee);return I}}),w=o((P,M)=>{var L=y();M.exports=A;function A(O,D,Z){return O.nodes().reduce(function(B,q){return B[q]=L(O,q,D,Z),B},{})}}),N=o((P,M)=>{M.exports=L;function L(O,D,Z){if(O[D].predecessor!==void 0)throw new Error("Invalid source vertex");if(O[Z].predecessor===void 0&&Z!==D)throw new Error("Invalid destination vertex");return{weight:O[Z].distance,path:A(O,D,Z)}}function A(O,D,Z){for(var B=[],q=Z;q!==D;)B.push(q),q=O[q].predecessor;return B.push(D),B.reverse()}}),S=o((P,M)=>{M.exports=L;function L(A){var O=0,D=[],Z={},B=[];function q(X){var I=Z[X]={onStack:!0,lowlink:O,index:O++};if(D.push(X),A.successors(X).forEach(function(Q){Object.hasOwn(Z,Q)?Z[Q].onStack&&(I.lowlink=Math.min(I.lowlink,Z[Q].index)):(q(Q),I.lowlink=Math.min(I.lowlink,Z[Q].lowlink))}),I.lowlink===I.index){var _=[],V;do V=D.pop(),Z[V].onStack=!1,_.push(V);while(X!==V);B.push(_)}}return A.nodes().forEach(function(X){Object.hasOwn(Z,X)||q(X)}),B}}),E=o((P,M)=>{var L=S();M.exports=A;function A(O){return L(O).filter(function(D){return D.length>1||D.length===1&&O.hasEdge(D[0],D[0])})}}),C=o((P,M)=>{M.exports=A;var L=()=>1;function A(D,Z,B){return O(D,Z||L,B||function(q){return D.outEdges(q)})}function O(D,Z,B){var q={},X=D.nodes();return X.forEach(function(I){q[I]={},q[I][I]={distance:0},X.forEach(function(_){I!==_&&(q[I][_]={distance:Number.POSITIVE_INFINITY})}),B(I).forEach(function(_){var V=_.v===I?_.w:_.v,Q=Z(_);q[I][V]={distance:Q,predecessor:I}})}),X.forEach(function(I){var _=q[I];X.forEach(function(V){var Q=q[V];X.forEach(function(ee){var te=Q[I],ae=_[ee],me=Q[ee],Ne=te.distance+ae.distance;Ne<me.distance&&(me.distance=Ne,me.predecessor=ae.predecessor)})})}),q}}),k=o((P,M)=>{function L(O){var D={},Z={},B=[];function q(X){if(Object.hasOwn(Z,X))throw new A;Object.hasOwn(D,X)||(Z[X]=!0,D[X]=!0,O.predecessors(X).forEach(q),delete Z[X],B.push(X))}if(O.sinks().forEach(q),Object.keys(D).length!==O.nodeCount())throw new A;return B}var A=class extends Error{constructor(){super(...arguments)}};M.exports=L,L.CycleException=A}),T=o((P,M)=>{var L=k();M.exports=A;function A(O){try{L(O)}catch(D){if(D instanceof L.CycleException)return!1;throw D}return!0}}),R=o((P,M)=>{M.exports=L;function L(O,D,Z,B,q){Array.isArray(D)||(D=[D]);var X=(O.isDirected()?O.successors:O.neighbors).bind(O),I={};return D.forEach(function(_){if(!O.hasNode(_))throw new Error("Graph does not have node: "+_);q=A(O,_,Z==="post",I,X,B,q)}),q}function A(O,D,Z,B,q,X,I){return Object.hasOwn(B,D)||(B[D]=!0,Z||(I=X(I,D)),q(D).forEach(function(_){I=A(O,_,Z,B,q,X,I)}),Z&&(I=X(I,D))),I}}),z=o((P,M)=>{var L=R();M.exports=A;function A(O,D,Z){return L(O,D,Z,function(B,q){return B.push(q),B},[])}}),U=o((P,M)=>{var L=z();M.exports=A;function A(O,D){return L(O,D,"post")}}),G=o((P,M)=>{var L=z();M.exports=A;function A(O,D){return L(O,D,"pre")}}),W=o((P,M)=>{var L=c(),A=g();M.exports=O;function O(D,Z){var B=new L,q={},X=new A,I;function _(Q){var ee=Q.v===I?Q.w:Q.v,te=X.priority(ee);if(te!==void 0){var ae=Z(Q);ae<te&&(q[ee]=I,X.decrease(ee,ae))}}if(D.nodeCount()===0)return B;D.nodes().forEach(function(Q){X.add(Q,Number.POSITIVE_INFINITY),B.setNode(Q)}),X.decrease(D.nodes()[0],0);for(var V=!1;X.size()>0;){if(I=X.removeMin(),Object.hasOwn(q,I))B.setEdge(I,q[I]);else{if(V)throw new Error("Input graph is not connected: "+D);V=!0}D.nodeEdges(I).forEach(_)}return B}}),$=o((P,M)=>{var L=y(),A=p();M.exports=O;function O(Z,B,q,X){return D(Z,B,q,X||function(I){return Z.outEdges(I)})}function D(Z,B,q,X){if(q===void 0)return L(Z,B,q,X);for(var I=!1,_=Z.nodes(),V=0;V<_.length;V++){for(var Q=X(_[V]),ee=0;ee<Q.length;ee++){var te=Q[ee],ae=te.v===_[V]?te.v:te.w,me=ae===te.v?te.w:te.v;q({v:ae,w:me})<0&&(I=!0)}if(I)return A(Z,B,q,X)}return L(Z,B,q,X)}}),F=o((P,M)=>{M.exports={bellmanFord:p(),components:x(),dijkstra:y(),dijkstraAll:w(),extractPath:N(),findCycles:E(),floydWarshall:C(),isAcyclic:T(),postorder:U(),preorder:G(),prim:W(),shortestPaths:$(),reduce:R(),tarjan:S(),topsort:k()}}),Y=h();n.exports={Graph:Y.Graph,json:f(),alg:F(),version:Y.version}}),QL=un((e,n)=>{var s=class{constructor(){let d={};d._next=d._prev=d,this._sentinel=d}dequeue(){let d=this._sentinel,c=d._prev;if(c!==d)return i(c),c}enqueue(d){let c=this._sentinel;d._prev&&d._next&&i(d),d._next=c._next,c._next._prev=d,c._next=d,d._prev=c}toString(){let d=[],c=this._sentinel,m=c._prev;for(;m!==c;)d.push(JSON.stringify(m,o)),m=m._prev;return"["+d.join(", ")+"]"}};function i(d){d._prev._next=d._next,d._next._prev=d._prev,delete d._next,delete d._prev}function o(d,c){if(d!=="_next"&&d!=="_prev")return c}n.exports=s}),JL=un((e,n)=>{var s=fs().Graph,i=QL();n.exports=d;var o=()=>1;function d(x,g){if(x.nodeCount()<=1)return[];let y=h(x,g||o);return c(y.graph,y.buckets,y.zeroIdx).flatMap(w=>x.outEdges(w.v,w.w))}function c(x,g,y){let w=[],N=g[g.length-1],S=g[0],E;for(;x.nodeCount();){for(;E=S.dequeue();)m(x,g,y,E);for(;E=N.dequeue();)m(x,g,y,E);if(x.nodeCount()){for(let C=g.length-2;C>0;--C)if(E=g[C].dequeue(),E){w=w.concat(m(x,g,y,E,!0));break}}}return w}function m(x,g,y,w,N){let S=N?[]:void 0;return x.inEdges(w.v).forEach(E=>{let C=x.edge(E),k=x.node(E.v);N&&S.push({v:E.v,w:E.w}),k.out-=C,f(g,y,k)}),x.outEdges(w.v).forEach(E=>{let C=x.edge(E),k=E.w,T=x.node(k);T.in-=C,f(g,y,T)}),x.removeNode(w.v),S}function h(x,g){let y=new s,w=0,N=0;x.nodes().forEach(C=>{y.setNode(C,{v:C,in:0,out:0})}),x.edges().forEach(C=>{let k=y.edge(C.v,C.w)||0,T=g(C),R=k+T;y.setEdge(C.v,C.w,R),N=Math.max(N,y.node(C.v).out+=T),w=Math.max(w,y.node(C.w).in+=T)});let S=p(N+w+3).map(()=>new i),E=w+1;return y.nodes().forEach(C=>{f(S,E,y.node(C))}),{graph:y,buckets:S,zeroIdx:E}}function f(x,g,y){y.out?y.in?x[y.out-y.in+g].enqueue(y):x[x.length-1].enqueue(y):x[0].enqueue(y)}function p(x){let g=[];for(let y=0;y<x;y++)g.push(y);return g}}),Yn=un((e,n)=>{var s=fs().Graph;n.exports={addBorderNode:g,addDummyNode:i,applyWithChunking:N,asNonCompoundGraph:d,buildLayerMatrix:f,intersectRect:h,mapValues:G,maxRank:S,normalizeRanks:p,notime:k,partition:E,pick:U,predecessorWeights:m,range:z,removeEmptyRanks:x,simplify:o,successorWeights:c,time:C,uniqueId:R,zipObject:W};function i($,F,Y,P){for(var M=P;$.hasNode(M);)M=R(P);return Y.dummy=F,$.setNode(M,Y),M}function o($){let F=new s().setGraph($.graph());return $.nodes().forEach(Y=>F.setNode(Y,$.node(Y))),$.edges().forEach(Y=>{let P=F.edge(Y.v,Y.w)||{weight:0,minlen:1},M=$.edge(Y);F.setEdge(Y.v,Y.w,{weight:P.weight+M.weight,minlen:Math.max(P.minlen,M.minlen)})}),F}function d($){let F=new s({multigraph:$.isMultigraph()}).setGraph($.graph());return $.nodes().forEach(Y=>{$.children(Y).length||F.setNode(Y,$.node(Y))}),$.edges().forEach(Y=>{F.setEdge(Y,$.edge(Y))}),F}function c($){let F=$.nodes().map(Y=>{let P={};return $.outEdges(Y).forEach(M=>{P[M.w]=(P[M.w]||0)+$.edge(M).weight}),P});return W($.nodes(),F)}function m($){let F=$.nodes().map(Y=>{let P={};return $.inEdges(Y).forEach(M=>{P[M.v]=(P[M.v]||0)+$.edge(M).weight}),P});return W($.nodes(),F)}function h($,F){let Y=$.x,P=$.y,M=F.x-Y,L=F.y-P,A=$.width/2,O=$.height/2;if(!M&&!L)throw new Error("Not possible to find intersection inside of the rectangle");let D,Z;return Math.abs(L)*A>Math.abs(M)*O?(L<0&&(O=-O),D=O*M/L,Z=O):(M<0&&(A=-A),D=A,Z=A*L/M),{x:Y+D,y:P+Z}}function f($){let F=z(S($)+1).map(()=>[]);return $.nodes().forEach(Y=>{let P=$.node(Y),M=P.rank;M!==void 0&&(F[M][P.order]=Y)}),F}function p($){let F=$.nodes().map(P=>{let M=$.node(P).rank;return M===void 0?Number.MAX_VALUE:M}),Y=N(Math.min,F);$.nodes().forEach(P=>{let M=$.node(P);Object.hasOwn(M,"rank")&&(M.rank-=Y)})}function x($){let F=$.nodes().map(A=>$.node(A).rank).filter(A=>A!==void 0),Y=N(Math.min,F),P=[];$.nodes().forEach(A=>{let O=$.node(A).rank-Y;P[O]||(P[O]=[]),P[O].push(A)});let M=0,L=$.graph().nodeRankFactor;Array.from(P).forEach((A,O)=>{A===void 0&&O%L!==0?--M:A!==void 0&&M&&A.forEach(D=>$.node(D).rank+=M)})}function g($,F,Y,P){let M={width:0,height:0};return arguments.length>=4&&(M.rank=Y,M.order=P),i($,"border",M,F)}function y($,F=w){let Y=[];for(let P=0;P<$.length;P+=F){let M=$.slice(P,P+F);Y.push(M)}return Y}var w=65535;function N($,F){if(F.length>w){let Y=y(F);return $.apply(null,Y.map(P=>$.apply(null,P)))}else return $.apply(null,F)}function S($){let F=$.nodes().map(Y=>{let P=$.node(Y).rank;return P===void 0?Number.MIN_VALUE:P});return N(Math.max,F)}function E($,F){let Y={lhs:[],rhs:[]};return $.forEach(P=>{F(P)?Y.lhs.push(P):Y.rhs.push(P)}),Y}function C($,F){let Y=Date.now();try{return F()}finally{console.log($+" time: "+(Date.now()-Y)+"ms")}}function k($,F){return F()}var T=0;function R($){var F=++T;return $+(""+F)}function z($,F,Y=1){F==null&&(F=$,$=0);let P=L=>L<F;Y<0&&(P=L=>F<L);let M=[];for(let L=$;P(L);L+=Y)M.push(L);return M}function U($,F){let Y={};for(let P of F)$[P]!==void 0&&(Y[P]=$[P]);return Y}function G($,F){let Y=F;return typeof F=="string"&&(Y=P=>P[F]),Object.entries($).reduce((P,[M,L])=>(P[M]=Y(L,M),P),{})}function W($,F){return $.reduce((Y,P,M)=>(Y[P]=F[M],Y),{})}}),eI=un((e,n)=>{var s=JL(),i=Yn().uniqueId;n.exports={run:o,undo:c};function o(m){(m.graph().acyclicer==="greedy"?s(m,h(m)):d(m)).forEach(f=>{let p=m.edge(f);m.removeEdge(f),p.forwardName=f.name,p.reversed=!0,m.setEdge(f.w,f.v,p,i("rev"))});function h(f){return p=>f.edge(p).weight}}function d(m){let h=[],f={},p={};function x(g){Object.hasOwn(p,g)||(p[g]=!0,f[g]=!0,m.outEdges(g).forEach(y=>{Object.hasOwn(f,y.w)?h.push(y):x(y.w)}),delete f[g])}return m.nodes().forEach(x),h}function c(m){m.edges().forEach(h=>{let f=m.edge(h);if(f.reversed){m.removeEdge(h);let p=f.forwardName;delete f.reversed,delete f.forwardName,m.setEdge(h.w,h.v,f,p)}})}}),tI=un((e,n)=>{var s=Yn();n.exports={run:i,undo:d};function i(c){c.graph().dummyChains=[],c.edges().forEach(m=>o(c,m))}function o(c,m){let h=m.v,f=c.node(h).rank,p=m.w,x=c.node(p).rank,g=m.name,y=c.edge(m),w=y.labelRank;if(x===f+1)return;c.removeEdge(m);let N,S,E;for(E=0,++f;f<x;++E,++f)y.points=[],S={width:0,height:0,edgeLabel:y,edgeObj:m,rank:f},N=s.addDummyNode(c,"edge",S,"_d"),f===w&&(S.width=y.width,S.height=y.height,S.dummy="edge-label",S.labelpos=y.labelpos),c.setEdge(h,N,{weight:y.weight},g),E===0&&c.graph().dummyChains.push(N),h=N;c.setEdge(h,p,{weight:y.weight},g)}function d(c){c.graph().dummyChains.forEach(m=>{let h=c.node(m),f=h.edgeLabel,p;for(c.setEdge(h.edgeObj,f);h.dummy;)p=c.successors(m)[0],c.removeNode(m),f.points.push({x:h.x,y:h.y}),h.dummy==="edge-label"&&(f.x=h.x,f.y=h.y,f.width=h.width,f.height=h.height),m=p,h=c.node(m)})}}),Wd=un((e,n)=>{var{applyWithChunking:s}=Yn();n.exports={longestPath:i,slack:o};function i(d){var c={};function m(h){var f=d.node(h);if(Object.hasOwn(c,h))return f.rank;c[h]=!0;let p=d.outEdges(h).map(g=>g==null?Number.POSITIVE_INFINITY:m(g.w)-d.edge(g).minlen);var x=s(Math.min,p);return x===Number.POSITIVE_INFINITY&&(x=0),f.rank=x}d.sources().forEach(m)}function o(d,c){return d.node(c.w).rank-d.node(c.v).rank-d.edge(c).minlen}}),AN=un((e,n)=>{var s=fs().Graph,i=Wd().slack;n.exports=o;function o(h){var f=new s({directed:!1}),p=h.nodes()[0],x=h.nodeCount();f.setNode(p,{});for(var g,y;d(f,h)<x;)g=c(f,h),y=f.hasNode(g.v)?i(h,g):-i(h,g),m(f,h,y);return f}function d(h,f){function p(x){f.nodeEdges(x).forEach(g=>{var y=g.v,w=x===y?g.w:y;!h.hasNode(w)&&!i(f,g)&&(h.setNode(w,{}),h.setEdge(x,w,{}),p(w))})}return h.nodes().forEach(p),h.nodeCount()}function c(h,f){return f.edges().reduce((p,x)=>{let g=Number.POSITIVE_INFINITY;return h.hasNode(x.v)!==h.hasNode(x.w)&&(g=i(f,x)),g<p[0]?[g,x]:p},[Number.POSITIVE_INFINITY,null])[1]}function m(h,f,p){h.nodes().forEach(x=>f.node(x).rank+=p)}}),nI=un((e,n)=>{var s=AN(),i=Wd().slack,o=Wd().longestPath,d=fs().alg.preorder,c=fs().alg.postorder,m=Yn().simplify;n.exports=h,h.initLowLimValues=g,h.initCutValues=f,h.calcCutValue=x,h.leaveEdge=w,h.enterEdge=N,h.exchangeEdges=S;function h(T){T=m(T),o(T);var R=s(T);g(R),f(R,T);for(var z,U;z=w(R);)U=N(R,T,z),S(R,T,z,U)}function f(T,R){var z=c(T,T.nodes());z=z.slice(0,z.length-1),z.forEach(U=>p(T,R,U))}function p(T,R,z){var U=T.node(z),G=U.parent;T.edge(z,G).cutvalue=x(T,R,z)}function x(T,R,z){var U=T.node(z),G=U.parent,W=!0,$=R.edge(z,G),F=0;return $||(W=!1,$=R.edge(G,z)),F=$.weight,R.nodeEdges(z).forEach(Y=>{var P=Y.v===z,M=P?Y.w:Y.v;if(M!==G){var L=P===W,A=R.edge(Y).weight;if(F+=L?A:-A,C(T,z,M)){var O=T.edge(z,M).cutvalue;F+=L?-O:O}}}),F}function g(T,R){arguments.length<2&&(R=T.nodes()[0]),y(T,{},1,R)}function y(T,R,z,U,G){var W=z,$=T.node(U);return R[U]=!0,T.neighbors(U).forEach(F=>{Object.hasOwn(R,F)||(z=y(T,R,z,F,U))}),$.low=W,$.lim=z++,G?$.parent=G:delete $.parent,z}function w(T){return T.edges().find(R=>T.edge(R).cutvalue<0)}function N(T,R,z){var U=z.v,G=z.w;R.hasEdge(U,G)||(U=z.w,G=z.v);var W=T.node(U),$=T.node(G),F=W,Y=!1;W.lim>$.lim&&(F=$,Y=!0);var P=R.edges().filter(M=>Y===k(T,T.node(M.v),F)&&Y!==k(T,T.node(M.w),F));return P.reduce((M,L)=>i(R,L)<i(R,M)?L:M)}function S(T,R,z,U){var G=z.v,W=z.w;T.removeEdge(G,W),T.setEdge(U.v,U.w,{}),g(T),f(T,R),E(T,R)}function E(T,R){var z=T.nodes().find(G=>!R.node(G).parent),U=d(T,z);U=U.slice(1),U.forEach(G=>{var W=T.node(G).parent,$=R.edge(G,W),F=!1;$||($=R.edge(W,G),F=!0),R.node(G).rank=R.node(W).rank+(F?$.minlen:-$.minlen)})}function C(T,R,z){return T.hasEdge(R,z)}function k(T,R,z){return z.low<=R.lim&&R.lim<=z.lim}}),rI=un((e,n)=>{var s=Wd(),i=s.longestPath,o=AN(),d=nI();n.exports=c;function c(p){var x=p.graph().ranker;if(x instanceof Function)return x(p);switch(p.graph().ranker){case"network-simplex":f(p);break;case"tight-tree":h(p);break;case"longest-path":m(p);break;case"none":break;default:f(p)}}var m=i;function h(p){i(p),o(p)}function f(p){d(p)}}),sI=un((e,n)=>{n.exports=s;function s(d){let c=o(d);d.graph().dummyChains.forEach(m=>{let h=d.node(m),f=h.edgeObj,p=i(d,c,f.v,f.w),x=p.path,g=p.lca,y=0,w=x[y],N=!0;for(;m!==f.w;){if(h=d.node(m),N){for(;(w=x[y])!==g&&d.node(w).maxRank<h.rank;)y++;w===g&&(N=!1)}if(!N){for(;y<x.length-1&&d.node(w=x[y+1]).minRank<=h.rank;)y++;w=x[y]}d.setParent(m,w),m=d.successors(m)[0]}})}function i(d,c,m,h){let f=[],p=[],x=Math.min(c[m].low,c[h].low),g=Math.max(c[m].lim,c[h].lim),y,w;y=m;do y=d.parent(y),f.push(y);while(y&&(c[y].low>x||g>c[y].lim));for(w=y,y=h;(y=d.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function o(d){let c={},m=0;function h(f){let p=m;d.children(f).forEach(h),c[f]={low:p,lim:m++}}return d.children().forEach(h),c}}),aI=un((e,n)=>{var s=Yn();n.exports={run:i,cleanup:m};function i(h){let f=s.addDummyNode(h,"root",{},"_root"),p=d(h),x=Object.values(p),g=s.applyWithChunking(Math.max,x)-1,y=2*g+1;h.graph().nestingRoot=f,h.edges().forEach(N=>h.edge(N).minlen*=y);let w=c(h)+1;h.children().forEach(N=>o(h,f,y,w,g,p,N)),h.graph().nodeRankFactor=y}function o(h,f,p,x,g,y,w){let N=h.children(w);if(!N.length){w!==f&&h.setEdge(f,w,{weight:0,minlen:p});return}let S=s.addBorderNode(h,"_bt"),E=s.addBorderNode(h,"_bb"),C=h.node(w);h.setParent(S,w),C.borderTop=S,h.setParent(E,w),C.borderBottom=E,N.forEach(k=>{o(h,f,p,x,g,y,k);let T=h.node(k),R=T.borderTop?T.borderTop:k,z=T.borderBottom?T.borderBottom:k,U=T.borderTop?x:2*x,G=R!==z?1:g-y[w]+1;h.setEdge(S,R,{weight:U,minlen:G,nestingEdge:!0}),h.setEdge(z,E,{weight:U,minlen:G,nestingEdge:!0})}),h.parent(w)||h.setEdge(f,S,{weight:0,minlen:g+y[w]})}function d(h){var f={};function p(x,g){var y=h.children(x);y&&y.length&&y.forEach(w=>p(w,g+1)),f[x]=g}return h.children().forEach(x=>p(x,1)),f}function c(h){return h.edges().reduce((f,p)=>f+h.edge(p).weight,0)}function m(h){var f=h.graph();h.removeNode(f.nestingRoot),delete f.nestingRoot,h.edges().forEach(p=>{var x=h.edge(p);x.nestingEdge&&h.removeEdge(p)})}}),iI=un((e,n)=>{var s=Yn();n.exports=i;function i(d){function c(m){let h=d.children(m),f=d.node(m);if(h.length&&h.forEach(c),Object.hasOwn(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(let p=f.minRank,x=f.maxRank+1;p<x;++p)o(d,"borderLeft","_bl",m,f,p),o(d,"borderRight","_br",m,f,p)}}d.children().forEach(c)}function o(d,c,m,h,f,p){let x={width:0,height:0,rank:p,borderType:c},g=f[c][p-1],y=s.addDummyNode(d,"border",x,m);f[c][p]=y,d.setParent(y,h),g&&d.setEdge(g,y,{weight:1})}}),lI=un((e,n)=>{n.exports={adjust:s,undo:i};function s(p){let x=p.graph().rankdir.toLowerCase();(x==="lr"||x==="rl")&&o(p)}function i(p){let x=p.graph().rankdir.toLowerCase();(x==="bt"||x==="rl")&&c(p),(x==="lr"||x==="rl")&&(h(p),o(p))}function o(p){p.nodes().forEach(x=>d(p.node(x))),p.edges().forEach(x=>d(p.edge(x)))}function d(p){let x=p.width;p.width=p.height,p.height=x}function c(p){p.nodes().forEach(x=>m(p.node(x))),p.edges().forEach(x=>{let g=p.edge(x);g.points.forEach(m),Object.hasOwn(g,"y")&&m(g)})}function m(p){p.y=-p.y}function h(p){p.nodes().forEach(x=>f(p.node(x))),p.edges().forEach(x=>{let g=p.edge(x);g.points.forEach(f),Object.hasOwn(g,"x")&&f(g)})}function f(p){let x=p.x;p.x=p.y,p.y=x}}),oI=un((e,n)=>{var s=Yn();n.exports=i;function i(o){let d={},c=o.nodes().filter(x=>!o.children(x).length),m=c.map(x=>o.node(x).rank),h=s.applyWithChunking(Math.max,m),f=s.range(h+1).map(()=>[]);function p(x){if(d[x])return;d[x]=!0;let g=o.node(x);f[g.rank].push(x),o.successors(x).forEach(p)}return c.sort((x,g)=>o.node(x).rank-o.node(g).rank).forEach(p),f}}),cI=un((e,n)=>{var s=Yn().zipObject;n.exports=i;function i(d,c){let m=0;for(let h=1;h<c.length;++h)m+=o(d,c[h-1],c[h]);return m}function o(d,c,m){let h=s(m,m.map((w,N)=>N)),f=c.flatMap(w=>d.outEdges(w).map(N=>({pos:h[N.w],weight:d.edge(N).weight})).sort((N,S)=>N.pos-S.pos)),p=1;for(;p<m.length;)p<<=1;let x=2*p-1;p-=1;let g=new Array(x).fill(0),y=0;return f.forEach(w=>{let N=w.pos+p;g[N]+=w.weight;let S=0;for(;N>0;)N%2&&(S+=g[N+1]),N=N-1>>1,g[N]+=w.weight;y+=w.weight*S}),y}}),dI=un((e,n)=>{n.exports=s;function s(i,o=[]){return o.map(d=>{let c=i.inEdges(d);if(c.length){let m=c.reduce((h,f)=>{let p=i.edge(f),x=i.node(f.v);return{sum:h.sum+p.weight*x.order,weight:h.weight+p.weight}},{sum:0,weight:0});return{v:d,barycenter:m.sum/m.weight,weight:m.weight}}else return{v:d}})}}),uI=un((e,n)=>{var s=Yn();n.exports=i;function i(c,m){let h={};c.forEach((p,x)=>{let g=h[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:x};p.barycenter!==void 0&&(g.barycenter=p.barycenter,g.weight=p.weight)}),m.edges().forEach(p=>{let x=h[p.v],g=h[p.w];x!==void 0&&g!==void 0&&(g.indegree++,x.out.push(h[p.w]))});let f=Object.values(h).filter(p=>!p.indegree);return o(f)}function o(c){let m=[];function h(p){return x=>{x.merged||(x.barycenter===void 0||p.barycenter===void 0||x.barycenter>=p.barycenter)&&d(p,x)}}function f(p){return x=>{x.in.push(p),--x.indegree===0&&c.push(x)}}for(;c.length;){let p=c.pop();m.push(p),p.in.reverse().forEach(h(p)),p.out.forEach(f(p))}return m.filter(p=>!p.merged).map(p=>s.pick(p,["vs","i","barycenter","weight"]))}function d(c,m){let h=0,f=0;c.weight&&(h+=c.barycenter*c.weight,f+=c.weight),m.weight&&(h+=m.barycenter*m.weight,f+=m.weight),c.vs=m.vs.concat(c.vs),c.barycenter=h/f,c.weight=f,c.i=Math.min(m.i,c.i),m.merged=!0}}),fI=un((e,n)=>{var s=Yn();n.exports=i;function i(c,m){let h=s.partition(c,S=>Object.hasOwn(S,"barycenter")),f=h.lhs,p=h.rhs.sort((S,E)=>E.i-S.i),x=[],g=0,y=0,w=0;f.sort(d(!!m)),w=o(x,p,w),f.forEach(S=>{w+=S.vs.length,x.push(S.vs),g+=S.barycenter*S.weight,y+=S.weight,w=o(x,p,w)});let N={vs:x.flat(!0)};return y&&(N.barycenter=g/y,N.weight=y),N}function o(c,m,h){let f;for(;m.length&&(f=m[m.length-1]).i<=h;)m.pop(),c.push(f.vs),h++;return h}function d(c){return(m,h)=>m.barycenter<h.barycenter?-1:m.barycenter>h.barycenter?1:c?h.i-m.i:m.i-h.i}}),hI=un((e,n)=>{var s=dI(),i=uI(),o=fI();n.exports=d;function d(h,f,p,x){let g=h.children(f),y=h.node(f),w=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,S={};w&&(g=g.filter(T=>T!==w&&T!==N));let E=s(h,g);E.forEach(T=>{if(h.children(T.v).length){let R=d(h,T.v,p,x);S[T.v]=R,Object.hasOwn(R,"barycenter")&&m(T,R)}});let C=i(E,p);c(C,S);let k=o(C,x);if(w&&(k.vs=[w,k.vs,N].flat(!0),h.predecessors(w).length)){let T=h.node(h.predecessors(w)[0]),R=h.node(h.predecessors(N)[0]);Object.hasOwn(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+T.order+R.order)/(k.weight+2),k.weight+=2}return k}function c(h,f){h.forEach(p=>{p.vs=p.vs.flatMap(x=>f[x]?f[x].vs:x)})}function m(h,f){h.barycenter!==void 0?(h.barycenter=(h.barycenter*h.weight+f.barycenter*f.weight)/(h.weight+f.weight),h.weight+=f.weight):(h.barycenter=f.barycenter,h.weight=f.weight)}}),mI=un((e,n)=>{var s=fs().Graph,i=Yn();n.exports=o;function o(c,m,h,f){f||(f=c.nodes());let p=d(c),x=new s({compound:!0}).setGraph({root:p}).setDefaultNodeLabel(g=>c.node(g));return f.forEach(g=>{let y=c.node(g),w=c.parent(g);(y.rank===m||y.minRank<=m&&m<=y.maxRank)&&(x.setNode(g),x.setParent(g,w||p),c[h](g).forEach(N=>{let S=N.v===g?N.w:N.v,E=x.edge(S,g),C=E!==void 0?E.weight:0;x.setEdge(S,g,{weight:c.edge(N).weight+C})}),Object.hasOwn(y,"minRank")&&x.setNode(g,{borderLeft:y.borderLeft[m],borderRight:y.borderRight[m]}))}),x}function d(c){for(var m;c.hasNode(m=i.uniqueId("_root")););return m}}),xI=un((e,n)=>{n.exports=s;function s(i,o,d){let c={},m;d.forEach(h=>{let f=i.parent(h),p,x;for(;f;){if(p=i.parent(f),p?(x=c[p],c[p]=f):(x=m,m=f),x&&x!==f){o.setEdge(x,f);return}f=p}})}}),pI=un((e,n)=>{var s=oI(),i=cI(),o=hI(),d=mI(),c=xI(),m=fs().Graph,h=Yn();n.exports=f;function f(y,w={}){if(typeof w.customOrder=="function"){w.customOrder(y,f);return}let N=h.maxRank(y),S=p(y,h.range(1,N+1),"inEdges"),E=p(y,h.range(N-1,-1,-1),"outEdges"),C=s(y);if(g(y,C),w.disableOptimalOrderHeuristic)return;let k=Number.POSITIVE_INFINITY,T,R=w.constraints||[];for(let z=0,U=0;U<4;++z,++U){x(z%2?S:E,z%4>=2,R),C=h.buildLayerMatrix(y);let G=i(y,C);G<k?(U=0,T=Object.assign({},C),k=G):G===k&&(T=structuredClone(C))}g(y,T)}function p(y,w,N){let S=new Map,E=(C,k)=>{S.has(C)||S.set(C,[]),S.get(C).push(k)};for(let C of y.nodes()){let k=y.node(C);if(typeof k.rank=="number"&&E(k.rank,C),typeof k.minRank=="number"&&typeof k.maxRank=="number")for(let T=k.minRank;T<=k.maxRank;T++)T!==k.rank&&E(T,C)}return w.map(function(C){return d(y,C,N,S.get(C)||[])})}function x(y,w,N){let S=new m;y.forEach(function(E){N.forEach(T=>S.setEdge(T.left,T.right));let C=E.graph().root,k=o(E,C,S,w);k.vs.forEach((T,R)=>E.node(T).order=R),c(E,S,k.vs)})}function g(y,w){Object.values(w).forEach(N=>N.forEach((S,E)=>y.node(S).order=E))}}),gI=un((e,n)=>{var s=fs().Graph,i=Yn();n.exports={positionX:N,findType1Conflicts:o,findType2Conflicts:d,addConflict:m,hasConflict:h,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function o(C,k){let T={};function R(z,U){let G=0,W=0,$=z.length,F=U[U.length-1];return U.forEach((Y,P)=>{let M=c(C,Y),L=M?C.node(M).order:$;(M||Y===F)&&(U.slice(W,P+1).forEach(A=>{C.predecessors(A).forEach(O=>{let D=C.node(O),Z=D.order;(Z<G||L<Z)&&!(D.dummy&&C.node(A).dummy)&&m(T,O,A)})}),W=P+1,G=L)}),U}return k.length&&k.reduce(R),T}function d(C,k){let T={};function R(U,G,W,$,F){let Y;i.range(G,W).forEach(P=>{Y=U[P],C.node(Y).dummy&&C.predecessors(Y).forEach(M=>{let L=C.node(M);L.dummy&&(L.order<$||L.order>F)&&m(T,M,Y)})})}function z(U,G){let W=-1,$,F=0;return G.forEach((Y,P)=>{if(C.node(Y).dummy==="border"){let M=C.predecessors(Y);M.length&&($=C.node(M[0]).order,R(G,F,P,W,$),F=P,W=$)}R(G,F,G.length,$,U.length)}),G}return k.length&&k.reduce(z),T}function c(C,k){if(C.node(k).dummy)return C.predecessors(k).find(T=>C.node(T).dummy)}function m(C,k,T){if(k>T){let z=k;k=T,T=z}let R=C[k];R||(C[k]=R={}),R[T]=!0}function h(C,k,T){if(k>T){let R=k;k=T,T=R}return!!C[k]&&Object.hasOwn(C[k],T)}function f(C,k,T,R){let z={},U={},G={};return k.forEach(W=>{W.forEach(($,F)=>{z[$]=$,U[$]=$,G[$]=F})}),k.forEach(W=>{let $=-1;W.forEach(F=>{let Y=R(F);if(Y.length){Y=Y.sort((M,L)=>G[M]-G[L]);let P=(Y.length-1)/2;for(let M=Math.floor(P),L=Math.ceil(P);M<=L;++M){let A=Y[M];U[F]===F&&$<G[A]&&!h(T,F,A)&&(U[A]=F,U[F]=z[F]=z[A],$=G[A])}}})}),{root:z,align:U}}function p(C,k,T,R,z){let U={},G=x(C,k,T,z),W=z?"borderLeft":"borderRight";function $(P,M){let L=G.nodes().slice(),A={},O=L.pop();for(;O;){if(A[O])P(O);else{A[O]=!0,L.push(O);for(let D of M(O))L.push(D)}O=L.pop()}}function F(P){U[P]=G.inEdges(P).reduce((M,L)=>Math.max(M,U[L.v]+G.edge(L)),0)}function Y(P){let M=G.outEdges(P).reduce((A,O)=>Math.min(A,U[O.w]-G.edge(O)),Number.POSITIVE_INFINITY),L=C.node(P);M!==Number.POSITIVE_INFINITY&&L.borderType!==W&&(U[P]=Math.max(U[P],M))}return $(F,G.predecessors.bind(G)),$(Y,G.successors.bind(G)),Object.keys(R).forEach(P=>U[P]=U[T[P]]),U}function x(C,k,T,R){let z=new s,U=C.graph(),G=S(U.nodesep,U.edgesep,R);return k.forEach(W=>{let $;W.forEach(F=>{let Y=T[F];if(z.setNode(Y),$){var P=T[$],M=z.edge(P,Y);z.setEdge(P,Y,Math.max(G(C,F,$),M||0))}$=F})}),z}function g(C,k){return Object.values(k).reduce((T,R)=>{let z=Number.NEGATIVE_INFINITY,U=Number.POSITIVE_INFINITY;Object.entries(R).forEach(([W,$])=>{let F=E(C,W)/2;z=Math.max($+F,z),U=Math.min($-F,U)});let G=z-U;return G<T[0]&&(T=[G,R]),T},[Number.POSITIVE_INFINITY,null])[1]}function y(C,k){let T=Object.values(k),R=i.applyWithChunking(Math.min,T),z=i.applyWithChunking(Math.max,T);["u","d"].forEach(U=>{["l","r"].forEach(G=>{let W=U+G,$=C[W];if($===k)return;let F=Object.values($),Y=R-i.applyWithChunking(Math.min,F);G!=="l"&&(Y=z-i.applyWithChunking(Math.max,F)),Y&&(C[W]=i.mapValues($,P=>P+Y))})})}function w(C,k){return i.mapValues(C.ul,(T,R)=>{if(k)return C[k.toLowerCase()][R];{let z=Object.values(C).map(U=>U[R]).sort((U,G)=>U-G);return(z[1]+z[2])/2}})}function N(C){let k=i.buildLayerMatrix(C),T=Object.assign(o(C,k),d(C,k)),R={},z;["u","d"].forEach(G=>{z=G==="u"?k:Object.values(k).reverse(),["l","r"].forEach(W=>{W==="r"&&(z=z.map(P=>Object.values(P).reverse()));let $=(G==="u"?C.predecessors:C.successors).bind(C),F=f(C,z,T,$),Y=p(C,z,F.root,F.align,W==="r");W==="r"&&(Y=i.mapValues(Y,P=>-P)),R[G+W]=Y})});let U=g(C,R);return y(R,U),w(R,C.graph().align)}function S(C,k,T){return(R,z,U)=>{let G=R.node(z),W=R.node(U),$=0,F;if($+=G.width/2,Object.hasOwn(G,"labelpos"))switch(G.labelpos.toLowerCase()){case"l":F=-G.width/2;break;case"r":F=G.width/2;break}if(F&&($+=T?F:-F),F=0,$+=(G.dummy?k:C)/2,$+=(W.dummy?k:C)/2,$+=W.width/2,Object.hasOwn(W,"labelpos"))switch(W.labelpos.toLowerCase()){case"l":F=W.width/2;break;case"r":F=-W.width/2;break}return F&&($+=T?F:-F),F=0,$}}function E(C,k){return C.node(k).width}}),bI=un((e,n)=>{var s=Yn(),i=gI().positionX;n.exports=o;function o(c){c=s.asNonCompoundGraph(c),d(c),Object.entries(i(c)).forEach(([m,h])=>c.node(m).x=h)}function d(c){let m=s.buildLayerMatrix(c),h=c.graph().ranksep,f=c.graph().rankalign,p=0;m.forEach(x=>{let g=x.reduce((y,w)=>{let N=c.node(w).height;return y>N?y:N},0);x.forEach(y=>{let w=c.node(y);f==="top"?w.y=p+w.height/2:f==="bottom"?w.y=p+g-w.height/2:w.y=p+g/2}),p+=g+h})}}),yI=un((e,n)=>{var s=eI(),i=tI(),o=rI(),d=Yn().normalizeRanks,c=sI(),m=Yn().removeEmptyRanks,h=aI(),f=iI(),p=lI(),x=pI(),g=bI(),y=Yn(),w=fs().Graph;n.exports=N;function N(V,Q={}){let ee=Q.debugTiming?y.time:y.notime;return ee("layout",()=>{let te=ee(" buildLayoutGraph",()=>$(V));return ee(" runLayout",()=>S(te,ee,Q)),ee(" updateInputGraph",()=>E(V,te)),te})}function S(V,Q,ee){Q(" makeSpaceForEdgeLabels",()=>F(V)),Q(" removeSelfEdges",()=>B(V)),Q(" acyclic",()=>s.run(V)),Q(" nestingGraph.run",()=>h.run(V)),Q(" rank",()=>o(y.asNonCompoundGraph(V))),Q(" injectEdgeLabelProxies",()=>Y(V)),Q(" removeEmptyRanks",()=>m(V)),Q(" nestingGraph.cleanup",()=>h.cleanup(V)),Q(" normalizeRanks",()=>d(V)),Q(" assignRankMinMax",()=>P(V)),Q(" removeEdgeLabelProxies",()=>M(V)),Q(" normalize.run",()=>i.run(V)),Q(" parentDummyChains",()=>c(V)),Q(" addBorderSegments",()=>f(V)),Q(" order",()=>x(V,ee)),Q(" insertSelfEdges",()=>q(V)),Q(" adjustCoordinateSystem",()=>p.adjust(V)),Q(" position",()=>g(V)),Q(" positionSelfEdges",()=>X(V)),Q(" removeBorderNodes",()=>Z(V)),Q(" normalize.undo",()=>i.undo(V)),Q(" fixupEdgeLabelCoords",()=>O(V)),Q(" undoCoordinateSystem",()=>p.undo(V)),Q(" translateGraph",()=>L(V)),Q(" assignNodeIntersects",()=>A(V)),Q(" reversePoints",()=>D(V)),Q(" acyclic.undo",()=>s.undo(V))}function E(V,Q){V.nodes().forEach(ee=>{let te=V.node(ee),ae=Q.node(ee);te&&(te.x=ae.x,te.y=ae.y,te.order=ae.order,te.rank=ae.rank,Q.children(ee).length&&(te.width=ae.width,te.height=ae.height))}),V.edges().forEach(ee=>{let te=V.edge(ee),ae=Q.edge(ee);te.points=ae.points,Object.hasOwn(ae,"x")&&(te.x=ae.x,te.y=ae.y)}),V.graph().width=Q.graph().width,V.graph().height=Q.graph().height}var C=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},T=["acyclicer","ranker","rankdir","align","rankalign"],R=["width","height","rank"],z={width:0,height:0},U=["minlen","weight","width","height","labeloffset"],G={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},W=["labelpos"];function $(V){let Q=new w({multigraph:!0,compound:!0}),ee=_(V.graph());return Q.setGraph(Object.assign({},k,I(ee,C),y.pick(ee,T))),V.nodes().forEach(te=>{let ae=_(V.node(te)),me=I(ae,R);Object.keys(z).forEach(Ne=>{me[Ne]===void 0&&(me[Ne]=z[Ne])}),Q.setNode(te,me),Q.setParent(te,V.parent(te))}),V.edges().forEach(te=>{let ae=_(V.edge(te));Q.setEdge(te,Object.assign({},G,I(ae,U),y.pick(ae,W)))}),Q}function F(V){let Q=V.graph();Q.ranksep/=2,V.edges().forEach(ee=>{let te=V.edge(ee);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function Y(V){V.edges().forEach(Q=>{let ee=V.edge(Q);if(ee.width&&ee.height){let te=V.node(Q.v),ae={rank:(V.node(Q.w).rank-te.rank)/2+te.rank,e:Q};y.addDummyNode(V,"edge-proxy",ae,"_ep")}})}function P(V){let Q=0;V.nodes().forEach(ee=>{let te=V.node(ee);te.borderTop&&(te.minRank=V.node(te.borderTop).rank,te.maxRank=V.node(te.borderBottom).rank,Q=Math.max(Q,te.maxRank))}),V.graph().maxRank=Q}function M(V){V.nodes().forEach(Q=>{let ee=V.node(Q);ee.dummy==="edge-proxy"&&(V.edge(ee.e).labelRank=ee.rank,V.removeNode(Q))})}function L(V){let Q=Number.POSITIVE_INFINITY,ee=0,te=Number.POSITIVE_INFINITY,ae=0,me=V.graph(),Ne=me.marginx||0,Ie=me.marginy||0;function je(Te){let Ce=Te.x,Re=Te.y,Ge=Te.width,ot=Te.height;Q=Math.min(Q,Ce-Ge/2),ee=Math.max(ee,Ce+Ge/2),te=Math.min(te,Re-ot/2),ae=Math.max(ae,Re+ot/2)}V.nodes().forEach(Te=>je(V.node(Te))),V.edges().forEach(Te=>{let Ce=V.edge(Te);Object.hasOwn(Ce,"x")&&je(Ce)}),Q-=Ne,te-=Ie,V.nodes().forEach(Te=>{let Ce=V.node(Te);Ce.x-=Q,Ce.y-=te}),V.edges().forEach(Te=>{let Ce=V.edge(Te);Ce.points.forEach(Re=>{Re.x-=Q,Re.y-=te}),Object.hasOwn(Ce,"x")&&(Ce.x-=Q),Object.hasOwn(Ce,"y")&&(Ce.y-=te)}),me.width=ee-Q+Ne,me.height=ae-te+Ie}function A(V){V.edges().forEach(Q=>{let ee=V.edge(Q),te=V.node(Q.v),ae=V.node(Q.w),me,Ne;ee.points?(me=ee.points[0],Ne=ee.points[ee.points.length-1]):(ee.points=[],me=ae,Ne=te),ee.points.unshift(y.intersectRect(te,me)),ee.points.push(y.intersectRect(ae,Ne))})}function O(V){V.edges().forEach(Q=>{let ee=V.edge(Q);if(Object.hasOwn(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function D(V){V.edges().forEach(Q=>{let ee=V.edge(Q);ee.reversed&&ee.points.reverse()})}function Z(V){V.nodes().forEach(Q=>{if(V.children(Q).length){let ee=V.node(Q),te=V.node(ee.borderTop),ae=V.node(ee.borderBottom),me=V.node(ee.borderLeft[ee.borderLeft.length-1]),Ne=V.node(ee.borderRight[ee.borderRight.length-1]);ee.width=Math.abs(Ne.x-me.x),ee.height=Math.abs(ae.y-te.y),ee.x=me.x+ee.width/2,ee.y=te.y+ee.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 ee=V.node(Q.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:Q,label:V.edge(Q)}),V.removeEdge(Q)}})}function q(V){var Q=y.buildLayerMatrix(V);Q.forEach(ee=>{var te=0;ee.forEach((ae,me)=>{var Ne=V.node(ae);Ne.order=me+te,(Ne.selfEdges||[]).forEach(Ie=>{y.addDummyNode(V,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:Ne.rank,order:me+ ++te,e:Ie.e,label:Ie.label},"_se")}),delete Ne.selfEdges})})}function X(V){V.nodes().forEach(Q=>{var ee=V.node(Q);if(ee.dummy==="selfedge"){var te=V.node(ee.e.v),ae=te.x+te.width/2,me=te.y,Ne=ee.x-ae,Ie=te.height/2;V.setEdge(ee.e,ee.label),V.removeNode(Q),ee.label.points=[{x:ae+2*Ne/3,y:me-Ie},{x:ae+5*Ne/6,y:me-Ie},{x:ae+Ne,y:me},{x:ae+5*Ne/6,y:me+Ie},{x:ae+2*Ne/3,y:me+Ie}],ee.label.x=ee.x,ee.label.y=ee.y}})}function I(V,Q){return y.mapValues(y.pick(V,Q),Number)}function _(V){var Q={};return V&&Object.entries(V).forEach(([ee,te])=>{typeof ee=="string"&&(ee=ee.toLowerCase()),Q[ee]=te}),Q}}),vI=un((e,n)=>{var s=Yn(),i=fs().Graph;n.exports={debugOrdering:o};function o(d){let c=s.buildLayerMatrix(d),m=new i({compound:!0,multigraph:!0}).setGraph({});return d.nodes().forEach(h=>{m.setNode(h,{label:h}),m.setParent(h,"layer"+d.node(h).rank)}),d.edges().forEach(h=>m.setEdge(h.v,h.w,{},h.name)),c.forEach((h,f)=>{let p="layer"+f;m.setNode(p,{rank:"same"}),h.reduce((x,g)=>(m.setEdge(x,g,{style:"invis"}),g))}),m}}),jI=un((e,n)=>{n.exports="2.0.4"}),wI=un((e,n)=>{n.exports={graphlib:fs(),layout:yI(),debug:vI(),util:{time:Yn().time,notime:Yn().notime},version:jI()}});const Xv=wI();const Kv={pending:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"},in_progress:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},blocked:{bg:"bg-red-500/8",border:"border-red-500/25",text:"text-red-500"},review:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"},completed:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"},failed:{bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-500"},rejected:{bg:"bg-red-500/8",border:"border-red-500/25",text:"text-red-500"},cancelled:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-tertiary"},archived:{bg:"bg-gray-500/5",border:"border-gray-500/15",text:"text-fg-tertiary"}},NI={critical:"bg-red-500",high:"bg-amber-500",medium:"bg-amber-500",low:"bg-blue-500"};function kI({data:e}){const{task:n,agentName:s,selected:i}=e,o=Kv[n.status]??Kv.pending,d=n.taskType==="scheduled"&&!!n.scheduleConfig,c=d?n.scheduleConfig.every?`Every ${n.scheduleConfig.every}`:n.scheduleConfig.cron?"Cron":"":"";return t.jsxs("div",{className:`rounded-lg border px-3 py-2 min-w-[180px] max-w-[220px] shadow-md backdrop-blur-sm ${d?`${o.bg} border-blue-500/40 ring-1 ring-blue-500/20`:`${o.bg} ${o.border}`} ${i?"ring-2 ring-brand-500 shadow-brand-500/25 shadow-lg":""}`,children:[t.jsx($a,{type:"target",position:ft.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${NI[n.priority]??"bg-gray-500"}`}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${o.text}`,children:n.status.replace("_"," ")}),d&&t.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/15 text-blue-600 ml-auto whitespace-nowrap inline-flex items-center gap-0.5",children:[t.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})}),c]})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:n.title}),s&&t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:s}),n.blockedBy&&n.blockedBy.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[n.blockedBy.length," dep",n.blockedBy.length>1?"s":""]}),t.jsx($a,{type:"source",position:ft.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const Wv={pending:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"},in_progress:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"},completed:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"},rejected:{bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-500"},cancelled:{bg:"bg-gray-500/8",border:"border-gray-500/20",text:"text-fg-tertiary"}},Zv={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done"};function SI({data:e}){const{req:n,selected:s}=e,i=Wv[n.status]??Wv.pending;return t.jsxs("div",{className:`rounded-lg border-2 border-dashed px-3 py-2 min-w-[180px] max-w-[220px] shadow-lg ${i.bg} ${i.border} ${s?"ring-2 ring-brand-500 shadow-brand-500/25":""}`,children:[t.jsx($a,{type:"target",position:ft.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded font-semibold bg-amber-500/15 text-amber-600",children:"REQ"}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${i.text}`,children:n.status.replace("_"," ")})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:n.title}),n.taskIds.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[n.taskIds.length," task",n.taskIds.length>1?"s":""]}),t.jsx($a,{type:"source",position:ft.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const CI={task:kI,requirement:SI},EI=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,TI=e=>{const n=new MutationObserver(e);n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const s=window.matchMedia("(prefers-color-scheme: light)");return s.addEventListener("change",e),()=>{n.disconnect(),s.removeEventListener("change",e)}};function _I(){return v.useSyncExternalStore(TI,EI,()=>!1)}const Xm=200,Km=80;function Qv(e,n,s="TB"){const i=new Xv.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const o of e)i.setNode(o.id,{width:Xm,height:Km});for(const o of n)i.setEdge(o.source,o.target);return Xv.layout(i),e.map(o=>{const d=i.node(o.id);return{...o,position:{x:(d?.x??0)-Xm/2,y:(d?.y??0)-Km/2}}})}function AI(e,n){const s=new Map,i=new Map;for(const c of e)i.set(c.id,c),s.set(c.id,new Set);for(const c of n)s.get(c.source)?.add(c.target),s.get(c.target)?.add(c.source);const o=new Set,d=[];for(const c of e){if(o.has(c.id))continue;const m=new Set,h=[c.id];for(;h.length>0;){const f=h.pop();if(!o.has(f)){o.add(f),m.add(f);for(const p of s.get(f)??[])o.has(p)||h.push(p)}}d.push({nodes:e.filter(f=>m.has(f.id)),edges:n.filter(f=>m.has(f.source)&&m.has(f.target))})}return d}function MI(e,n){if(e.length===0)return[];const s=AI(e,n);if(s.length===1)return Qv(e,n);const i=s.map(x=>{const g=Qv(x.nodes,x.edges);let y=1/0,w=-1/0,N=1/0,S=-1/0;for(const E of g)y=Math.min(y,E.position.x),w=Math.max(w,E.position.x+Xm),N=Math.min(N,E.position.y),S=Math.max(S,E.position.y+Km);for(const E of g)E.position.x-=y,E.position.y-=N;return{nodes:g,w:w-y,h:S-N}});i.sort((x,g)=>g.h-x.h);const o=60,d=i.reduce((x,g)=>x+(g.w+o)*(g.h+o),0),c=Math.sqrt(d)*1.1,m=[];let h=0,f=0,p=0;for(const x of i){h>0&&h+x.w>c&&(h=0,f+=p+o,p=0);for(const g of x.nodes)m.push({...g,position:{x:g.position.x+h,y:g.position.y+f}});h+=x.w+o,p=Math.max(p,x.h)}return m}function OI(e,n,s){const i=new Set,o=[n];for(;o.length>0;){const d=o.pop();if(d===s)return!0;if(i.has(d))continue;i.add(d);const c=e.get(d);if(c?.blockedBy)for(const m of c.blockedBy)o.push(m)}return!1}const ko=[{id:"todo",label:"To Do",statuses:new Set(["pending"]),color:{bg:"bg-blue-500/10",border:"border-blue-500/30",text:"text-blue-500"}},{id:"in_progress",label:"In Progress",statuses:new Set(["in_progress","blocked"]),color:{bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-600"}},{id:"review",label:"In Review",statuses:new Set(["review"]),color:{bg:"bg-brand-500/10",border:"border-brand-500/30",text:"text-brand-500"}},{id:"done",label:"Done",statuses:new Set(["completed","failed","rejected","cancelled"]),color:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"}}],im=new Set(ko.map(e=>e.id)),RI=1440*60*1e3,Jv=e=>e.status==="completed"&&e.updatedAt&&Date.now()-new Date(e.updatedAt).getTime()>RI;function DI({tasks:e,requirements:n=[],agents:s,showArchived:i,onShowArchivedChange:o,onTaskClick:d,onReqClick:c,onDependencyChange:m,selectedTaskId:h,selectedReqId:f}){const p=_I(),[x,g]=v.useState(null),[y,w]=v.useState(null),[N,S]=v.useState(new Set(im)),[E,C]=v.useState(i??!1),k=i??E,T=v.useCallback(je=>{const Te=typeof je=="function"?je(k):je;C(Te),o?.(Te)},[k,o]);v.useEffect(()=>{i!==void 0&&C(i)},[i]);const R=v.useMemo(()=>e.filter(je=>Jv(je)).length,[e]),z=v.useMemo(()=>{const je=new Set;for(const Te of ko)if(N.has(Te.id))for(const Ce of Te.statuses)je.add(Ce);return je},[N]),U=v.useMemo(()=>{const je=new Set;for(const Te of e)for(const Ce of ko)if(Ce.statuses.has(Te.status)){je.add(Ce.id);break}for(const Te of n){const Ce=Zv[Te.status];Ce&&je.add(Ce)}return ko.filter(Te=>je.has(Te.id))},[e,n]),G=v.useCallback(je=>{S(Te=>{const Ce=new Set(Te);return Ce.has(je)?Ce.delete(je):Ce.add(je),Ce})},[]),W=v.useCallback((je,Te="success")=>{g({msg:je,type:Te}),setTimeout(()=>g(null),2500)},[]),$=v.useMemo(()=>{const je=new Map;for(const Te of s)je.set(Te.id,Te.name);return je},[s]),F=v.useMemo(()=>{const je=new Map;for(const Te of e)je.set(Te.id,Te);return je},[e]),Y=v.useMemo(()=>{const je=new Map;for(const Te of n)je.set(Te.id,Te);return je},[n]),P=p?"#94a3b8":"#6b7280",M=v.useCallback((je,Te,Ce)=>({id:`${je}->${Te}`,source:je,target:Te,animated:Ce==="blocked",markerEnd:{type:xl.ArrowClosed,width:14,height:14,color:Ce==="blocked"?"#ef4444":P},style:{stroke:Ce==="blocked"?"#ef4444":P,strokeWidth:1.5,cursor:"pointer"}}),[P]),{initialNodes:L,initialEdges:A}=v.useMemo(()=>{const je=e.filter(Ee=>z.has(Ee.status)&&(k||!Jv(Ee))),Te=je.map(Ee=>({id:Ee.id,type:"task",data:{task:Ee,agentName:Ee.assignedAgentId?$.get(Ee.assignedAgentId):void 0,selected:Ee.id===h},position:{x:0,y:0}})),Ce=new Set(Te.map(Ee=>Ee.id)),Re=new Set;for(const Ee of ko)N.has(Ee.id)&&Re.add(Ee.id);const Ge=n.filter(Ee=>{const Ze=Zv[Ee.status];return Ze&&Re.has(Ze)});for(const Ee of Ge){const Ze=`req-${Ee.id}`;Te.push({id:Ze,type:"requirement",data:{req:Ee,selected:Ee.id===f},position:{x:0,y:0}}),Ce.add(Ze)}const ot=[];for(const Ee of je)if(Ee.blockedBy)for(const Ze of Ee.blockedBy)Ce.has(Ze)&&ot.push(M(Ze,Ee.id,Ee.status));const st=new Set,jt=(Ee,Ze)=>{const yt=`${Ee}->${Ze}`;st.has(yt)||(st.add(yt),ot.push({id:yt,source:Ee,target:Ze,markerEnd:{type:xl.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const Ee of Ge){const Ze=`req-${Ee.id}`;for(const yt of Ee.taskIds)Ce.has(yt)&&jt(Ze,yt)}for(const Ee of je)if(Ee.requirementId){const Ze=`req-${Ee.requirementId}`;Ce.has(Ze)&&jt(Ze,Ee.id)}return{initialNodes:MI(Te,ot),initialEdges:ot}},[e,n,$,F,M,z,N,k,h,f]),[O,D,Z]=wL(L),[B,q,X]=NL(A),I=v.useRef(null),_=v.useRef(!1),V=v.useRef({groupFilter:N,showArchived:k});v.useEffect(()=>{const je=V.current;(je.groupFilter!==N||je.showArchived!==k)&&(_.current=!1,V.current={groupFilter:N,showArchived:k})},[N,k]),v.useEffect(()=>{D(L),q(A),_.current||requestAnimationFrame(()=>{I.current?.fitView({padding:.2,duration:300})})},[L,A,D,q]);const Q=v.useCallback(je=>{je&&(_.current=!0)},[]),ee=v.useCallback((je,Te)=>{if(Te.id.startsWith("req-")){const Ce=Y.get(Te.id.slice(4));Ce&&c&&c(Ce)}else{const Ce=F.get(Te.id);Ce&&d&&d(Ce)}},[F,Y,d,c]),te=v.useCallback(async je=>{const{source:Te,target:Ce}=je;if(!Te||!Ce||Te===Ce)return;const Re=F.get(Ce);if(!Re)return;if(Re.blockedBy?.includes(Te)){W("Dependency already exists","error");return}if(OI(F,Te,Ce)){W("Cannot add: would create a cycle","error");return}const Ge=[...Re.blockedBy??[],Te];try{await se.tasks.update(Ce,{blockedBy:Ge}),W("Dependency added"),m?.()}catch(ot){W(`Failed: ${ot instanceof Error?ot.message:String(ot)}`,"error")}},[F,W,m]),ae=v.useCallback((je,Te)=>{w(Te)},[]),me=v.useCallback(async()=>{if(!y)return;const je=F.get(y.target);if(!je){w(null);return}const Te=(je.blockedBy??[]).filter(Ce=>Ce!==y.source);try{await se.tasks.update(y.target,{blockedBy:Te}),W("Dependency removed"),m?.()}catch(Ce){W(`Failed: ${Ce instanceof Error?Ce.message:String(Ce)}`,"error")}w(null)},[y,F,W,m]);if(e.length===0)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"No tasks to display"});const Ne=y?F.get(y.source):null,Ie=y?F.get(y.target):null;return t.jsxs("div",{className:"flex-1 min-h-0 relative",style:{height:"100%"},children:[t.jsxs(jL,{nodes:O,edges:B,onNodesChange:Z,onEdgesChange:X,onNodeClick:ee,onConnect:te,onEdgeClick:ae,onMoveEnd:Q,onInit:je=>{I.current=je},nodeTypes:CI,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(TL,{color:p?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(LL,{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(XL,{nodeColor:je=>{const Te=je.data?.task,Ce=Te?.status;return Te?.taskType==="scheduled"?"#06b6d4":Ce==="completed"||Ce==="accepted"?"#10b981":Ce==="in_progress"?"#f59e0b":Ce==="blocked"||Ce==="failed"?"#ef4444":p?"#94a3b8":"#6b7280"},maskColor:p?"rgba(255,255,255,0.7)":"rgba(0,0,0,0.7)",className:"!bg-surface-secondary !border-border-default"})]}),t.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-surface-secondary/90 border border-border-default rounded-lg backdrop-blur-sm z-10 flex flex-col items-center gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-center",children:[U.map(je=>{const Te=N.has(je.id);return t.jsx("button",{onClick:()=>G(je.id),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${Te?`${je.color.bg} ${je.color.border} ${je.color.text}`:"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:je.label},je.id)}),R>0&&t.jsxs("button",{onClick:()=>T(je=>!je),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${k?"bg-surface-overlay/60 border-gray-500/50 text-fg-secondary":"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:["Archived ",R]}),N.size<im.size&&t.jsx("button",{onClick:()=>{S(new Set(im)),T(!1)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary px-1",children:"Reset"})]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary select-none",children:"Drag to add dependency · Click edge to remove"})]}),x&&t.jsx("div",{className:`absolute bottom-4 left-1/2 -translate-x-1/2 px-4 py-2 rounded-lg text-xs font-medium shadow-xl border backdrop-blur-sm transition-opacity ${x.type==="success"?"bg-green-500/15 border-green-500/30 text-green-600":"bg-red-500/15 border-red-500/30 text-red-600"}`,children:x.msg}),y&&t.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center z-50 backdrop-blur-[2px]",onClick:()=>w(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 shadow-2xl max-w-sm",onClick:je=>je.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:Ie?.title??y.target.slice(-8)})," ","will no longer be blocked by"," ",t.jsx("span",{className:"text-fg-secondary font-medium",children:Ne?.title??y.source.slice(-8)}),"."]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>w(null),className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary bg-surface-elevated rounded-lg border border-border-default hover:border-gray-600 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:me,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 MN({orgId:e,onCreated:n,onClose:s}){const[i,o]=v.useState(""),[d,c]=v.useState(""),[m,h]=v.useState(""),[f,p]=v.useState("main"),[x,g]=v.useState([]),[y,w]=v.useState([]),[N,S]=v.useState(!1),[E,C]=v.useState(""),[k,T]=v.useState(!1),R=Sr();v.useEffect(()=>{se.teams.list().then(G=>w(G.teams)).catch(()=>{})},[]);const z=v.useCallback(async G=>{if(G?.preventDefault(),T(!0),!(!i.trim()||N)){S(!0),C("");try{const W=m.trim()?[{url:m.trim(),defaultBranch:f.trim()||"main"}]:[],$=await se.projects.create({name:i.trim(),description:d.trim()||void 0,repositories:W.length>0?W:void 0,teamIds:x.length>0?x:void 0,orgId:e??"default"});n($.project)}catch(W){C(W instanceof Error?W.message:"Failed to create project")}S(!1)}},[i,d,m,f,x,e,N,n]),U=k&&!i.trim();return Jm.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-3",onClick:s,children:t.jsxs("form",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 shadow-2xl max-h-[90dvh] overflow-y-auto ${R?"w-full":"w-[520px]"}`,onClick:G=>G.stopPropagation(),onSubmit:z,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:G=>{o(G.target.value),C("")},onBlur:()=>T(!0),placeholder:"e.g. Mobile App, Website Redesign",className:`input ${U?"!border-red-500 focus:!ring-red-500/25":""}`,autoFocus:!R}),U&&t.jsx("p",{className:"text-[11px] text-red-400 mt-1",children:"Project name is required"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Description"}),t.jsx("textarea",{value:d,onChange:G=>c(G.target.value),placeholder:"What is this project about?",className:"input",rows:3})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Assign Teams"}),y.length===0?t.jsx("div",{className:"text-[11px] text-fg-tertiary py-2",children:"No teams available"}):t.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:y.map(G=>{const W=x.includes(G.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:W,onChange:()=>g($=>W?$.filter(F=>F!==G.id):[...$,G.id]),className:"accent-brand-500"}),t.jsx("span",{className:"truncate",children:G.name})]},G.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:m,onChange:G=>h(G.target.value),placeholder:"https://github.com/org/repo (optional)",className:"input"})]}),m.trim()&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Branch"}),t.jsx("input",{value:f,onChange:G=>p(G.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()||N,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:N?"Creating...":"Create Project"})]})]})]})}),document.body)}function vl(e,n,s){if(!e)return null;const i=n.find(d=>d.id===e);if(i)return i.name;const o=s.find(d=>d.id===e);return o?o.name:e==="anonymous"?"Admin":null}function LI({value:e,onSave:n,className:s,placeholder:i}){const[o,d]=v.useState(!1),[c,m]=v.useState(e),h=v.useRef(null);v.useEffect(()=>{m(e)},[e]),v.useEffect(()=>{o&&h.current?.focus()},[o]);const f=async()=>{d(!1);const p=c.trim();if(p&&p!==e)try{await n(p)}catch{m(e)}else m(e)};return o?t.jsx("input",{ref:h,value:c,onChange:p=>m(p.target.value),onBlur:()=>{f()},onKeyDown:p=>{p.key==="Enter"&&f(),p.key==="Escape"&&(m(e),d(!1))},className:`bg-transparent border-b border-brand-500/50 outline-none ${s??""}`,placeholder:i}):t.jsx("span",{onClick:()=>d(!0),className:`cursor-pointer hover:border-b hover:border-gray-600 transition-colors ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:i??"Click to edit"})})}function II({value:e,onSave:n,className:s,placeholder:i}){const[o,d]=v.useState(!1),[c,m]=v.useState(e),h=v.useRef(null);v.useEffect(()=>{m(e)},[e]),v.useEffect(()=>{o&&h.current&&(h.current.focus(),h.current.style.height="auto",h.current.style.height=h.current.scrollHeight+"px")},[o]);const f=async()=>{d(!1);const p=c.trim();if(p!==e)try{await n(p)}catch{m(e)}else m(e)};return o?t.jsx("textarea",{ref:h,value:c,onChange:p=>{m(p.target.value),p.target.style.height="auto",p.target.style.height=p.target.scrollHeight+"px"},onBlur:()=>{f()},onKeyDown:p=>{p.key==="Escape"&&(m(e),d(!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:()=>d(!0),className:`cursor-pointer hover:bg-surface-elevated/50 rounded-lg transition-colors px-2 py-1 -mx-2 -my-1 ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:i??"Add a description…"})})}const zI=/^\[([^\]]+?)(?:\s+by\s+([^\]]+))?\]\s*([\s\S]*)$/;function ON(e){const n=e.match(zI);return n?{timestamp:n[1].trim(),author:n[2]?.trim()??"System",content:n[3].trim()}:{timestamp:"",author:"",content:e}}function $I(e){if(!e)return"";const n=e.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);if(!n)return e;const s=new Date,i=+n[1],o=+n[2]-1,d=+n[3],c=+n[4],m=+n[5],h=new Date(i,o,d,c,m),f=s.getTime()-h.getTime();return f<6e4?"just now":f<36e5?`${Math.floor(f/6e4)}m ago`:f<864e5?`${Math.floor(f/36e5)}h ago`:f<6048e5?`${Math.floor(f/864e5)}d ago`:`${i}-${String(o+1).padStart(2,"0")}-${String(d).padStart(2,"0")}`}const e1=[{bg:"bg-brand-600/30",text:"text-brand-500",border:"border-brand-500/30"},{bg:"bg-blue-600/30",text:"text-blue-400",border:"border-blue-500/30"},{bg:"bg-green-600/30",text:"text-green-400",border:"border-green-500/30"},{bg:"bg-amber-600/30",text:"text-amber-400",border:"border-amber-500/30"},{bg:"bg-purple-600/30",text:"text-purple-400",border:"border-purple-500/30"},{bg:"bg-pink-600/30",text:"text-pink-400",border:"border-pink-500/30"}];function BI(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s)|0;return e1[Math.abs(n)%e1.length]}function HI({note:e,compact:n}){const s=ON(e),i=BI(s.author||"System"),o=s.author?s.author.split(/[\s_-]+/).map(m=>m[0]).join("").slice(0,2).toUpperCase():"SY",d=$I(s.timestamp),c=!s.author||s.author==="System";return n?t.jsxs("div",{className:"flex gap-2.5 group",children:[t.jsx("div",{className:`w-6 h-6 rounded-full ${i.bg} flex items-center justify-center text-[9px] font-bold ${i.text} shrink-0 mt-0.5`,children:o}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium ${c?"text-fg-tertiary":i.text}`,children:s.author||"System"}),d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d})]}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(tr,{content:s.content,className:"text-xs text-fg-secondary"})})]})]}):t.jsxs("div",{className:"flex gap-3 group",children:[t.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[t.jsx("div",{className:`w-7 h-7 rounded-full ${i.bg} flex items-center justify-center text-[10px] font-bold ${i.text}`,children:o}),t.jsx("div",{className:"w-px flex-1 bg-border-default/60 mt-1.5"})]}),t.jsx("div",{className:"flex-1 min-w-0 pb-4",children:t.jsxs("div",{className:`border ${i.border} rounded-lg overflow-hidden`,children:[t.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 ${i.bg} border-b ${i.border}`,children:[t.jsx("span",{className:`text-[11px] font-medium ${c?"text-fg-secondary":i.text}`,children:s.author||"System"}),d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d})]}),t.jsx("div",{className:"px-3 py-2.5",children:t.jsx(tr,{content:s.content,className:"text-xs text-fg-secondary"})})]})})]})}const Vo=[{id:"failed",label:"Failed",statuses:["failed"],accent:"border-t-red-500",dropStatus:"failed"},{id:"todo",label:"To Do",statuses:["pending"],accent:"border-t-amber-500",dropStatus:"pending"},{id:"in_progress",label:"In Progress",statuses:["in_progress","blocked"],accent:"border-t-brand-500",dropStatus:"in_progress"},{id:"review",label:"In Review",statuses:["review"],accent:"border-t-purple-500",dropStatus:"review"},{id:"done",label:"Done",statuses:["completed"],accent:"border-t-green-500",dropStatus:"completed"},{id:"closed",label:"Closed",statuses:["rejected","cancelled"],accent:"border-t-gray-500",dropStatus:"cancelled"}],RN={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},blocked:{label:"Blocked",cls:"bg-amber-500/15 text-amber-600"},failed:{label:"Failed",cls:"bg-red-500/15 text-red-500"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"}},So={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},in_progress:{label:"In Progress",cls:"bg-blue-500/15 text-blue-500"},blocked:{label:"Blocked",cls:"bg-orange-500/15 text-orange-500"},review:{label:"In Review",cls:"bg-purple-500/15 text-purple-500"},completed:{label:"Completed",cls:"bg-green-500/15 text-green-600"},failed:{label:"Failed",cls:"bg-red-500/15 text-red-500"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"},cancelled:{label:"Cancelled",cls:"bg-gray-500/15 text-fg-tertiary"},archived:{label:"Archived",cls:"bg-gray-500/15 text-fg-tertiary"}},PI={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},vd={low:{label:"Low",cls:"bg-gray-500/15 text-fg-tertiary"},medium:{label:"Medium",cls:"bg-blue-500/15 text-blue-500"},high:{label:"High",cls:"bg-amber-500/15 text-amber-600"},urgent:{label:"Urgent",cls:"bg-red-500/15 text-red-500"}},t1=["low","medium","high","urgent"],n1=["pending","in_progress","blocked","review","completed","failed","rejected","cancelled"],r1=["pending","in_progress","completed","rejected","cancelled"],Wm={idle:"bg-green-400",working:"bg-blue-400",error:"bg-red-400",paused:"bg-amber-400",offline:"bg-gray-600",pending:"bg-amber-400",in_progress:"bg-brand-400",blocked:"bg-amber-400",review:"bg-brand-400",completed:"bg-green-400",failed:"bg-red-400",rejected:"bg-red-400",cancelled:"bg-gray-600",archived:"bg-surface-overlay"},s1={idle:"text-green-500",working:"text-blue-500",error:"text-red-500",paused:"text-amber-500",offline:"text-fg-muted"};function UI({agent:e,anchorRect:n,onClose:s}){const i=v.useRef(null);v.useEffect(()=>{const c=m=>{i.current&&!i.current.contains(m.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const o=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?"Online":e.status==="working"?"Working":e.status==="error"?"Error":e.status==="paused"?"Paused":"Offline";return t.jsxs("div",{ref:i,className:"fixed z-50 w-56 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-3 space-y-2",style:{top:n.top+4,left:n.left},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600 shrink-0",children:e.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:d})]})]})]}),t.jsx("button",{onClick:()=>{s(),pt.navigate(xe.TEAM,{selectAgent:e.id})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:"View Profile →"})]})}function Mo({comment:e,agents:n,onReply:s}){const i=e.authorType==="agent"||e.authorType==="system",o=new Date(e.createdAt),d=o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),c=o.toLocaleDateString([],{month:"short",day:"numeric"}),[m,h]=v.useState(null),f=v.useCallback((x,g)=>{const y=n.find(w=>w.name.toLowerCase()===x.toLowerCase());if(y){const w=g.target.getBoundingClientRect();h({agent:y,top:w.bottom,left:w.left})}},[n]),p=v.useCallback(x=>{const g=n.find(y=>y.name.toLowerCase()===e.authorName.toLowerCase());if(g){const y=x.currentTarget.getBoundingClientRect();h({agent:g,top:y.bottom,left:y.left})}},[n,e.authorName]);return t.jsxs("div",{className:"flex gap-2.5 group py-1",id:`comment-${e.id}`,children:[t.jsx("div",{onClick:p,className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-[10px] mt-0.5 cursor-pointer transition-all hover:ring-1 hover:ring-brand-500/40 ${i?"bg-indigo-500/20 text-indigo-400":"bg-blue-500/20 text-blue-400"}`,children:e.authorName.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium cursor-pointer hover:underline ${i?"text-indigo-400":"text-blue-400"}`,onClick:p,children:e.authorName}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:[c," ",d]}),s&&t.jsx("button",{onClick:()=>s(e),className:"text-fg-tertiary hover:text-fg-secondary text-[10px] opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:"Reply"})]}),e.replyTo&&e.replyToAuthor&&t.jsxs("button",{onClick:()=>{const x=document.getElementById(`comment-${e.replyTo}`);x&&(x.scrollIntoView({behavior:"smooth",block:"center"}),x.classList.add("bg-brand-500/10"),setTimeout(()=>x.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[t.jsx("span",{className:"font-medium text-brand-500/70",children:e.replyToAuthor}),t.jsx("span",{className:"truncate max-w-[200px]",children:e.replyToContent??"..."})]}),t.jsx(tr,{content:e.content,className:"text-xs text-fg-primary",onMentionClick:f}),e.attachments?.map((x,g)=>x.type==="image"?t.jsx("img",{src:x.url,alt:x.name,className:"mt-1 max-w-[200px] rounded"},g):null)]}),m&&t.jsx(UI,{agent:m.agent,anchorRect:{top:m.top,left:m.left},onClose:()=>h(null)})]})}function qI({task:e,agents:n,users:s,authUser:i}){const[o,d]=v.useState([]);v.useEffect(()=>{se.tasks.getComments(e.id).then(x=>d(x.comments)).catch(()=>{})},[e.id]),v.useEffect(()=>an.on("task:comment",g=>{g.payload?.taskId===e.id&&g.payload.comment&&d(y=>y.some(w=>w.id===g.payload.comment.id)?y:[...y,g.payload.comment])}),[e.id]);const c=v.useMemo(()=>{const x=[];for(const g of e.notes??[]){const y=ON(g);let w;if(y.timestamp){const N=y.timestamp.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);w=N?new Date(+N[1],+N[2]-1,+N[3],+N[4],+N[5],+(N[6]??0)):new Date(0)}else w=new Date(0);x.push({type:"note",note:g,ts:w})}for(const g of o)x.push({type:"comment",comment:g,ts:new Date(g.createdAt)});return x.sort((g,y)=>g.ts.getTime()-y.ts.getTime()),x},[e.notes,o]),[m,h]=v.useState(null),f=async(x,g,y)=>{await se.tasks.addComment(e.id,x,i?.name,void 0,i?.id,g.length>0?g:void 0,y)},p=v.useCallback(x=>{h({id:x.id,authorName:x.authorName,content:x.content.slice(0,100)})},[]);return t.jsxs("div",{className:"mt-5",children:[t.jsx("p",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:"Activity & Comments"}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[c.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No activity yet. Post the first comment below."}),c.map((x,g)=>x.type==="note"?t.jsx(HI,{note:x.note,compact:!0},`n-${g}`):t.jsx(Mo,{comment:x.comment,agents:n,onReply:p},`c-${x.comment.id}`))]}),t.jsx(Rj,{agents:n,onSubmit:f,replyTo:m,onCancelReply:()=>h(null)})]})}function VI({taskId:e,isRunning:n,authUser:s,agents:i}){const[o,d]=v.useState([]),[c,m]=v.useState(new Map),[h,f]=v.useState(new Set),[p,x]=v.useState([]),[g,y]=v.useState(""),[w,N]=v.useState(n),[S,E]=v.useState(!0),[C,k]=v.useState(new Set),[T,R]=v.useState(""),[z,U]=v.useState(!1),[G,W]=v.useState([]),$=v.useRef(null),F=v.useRef(null);v.useEffect(()=>{N(n)},[n]),v.useEffect(()=>{E(!0),Promise.all([se.tasks.getLogsSummary(e).catch(()=>({rounds:[]})),se.tasks.getComments(e).catch(()=>({comments:[]}))]).then(([X,I])=>{const _=X.rounds;if(d(_),x(I.comments),_.length===0){E(!1);return}const V=_[_.length-1].round;k(new Set([V])),se.tasks.getLogs(e,V).catch(()=>({logs:[]})).then(Q=>{m(new Map([[V,Q.logs]])),E(!1)})})},[e]);const Y=v.useCallback(X=>{c.has(X)||h.has(X)||(f(I=>new Set(I).add(X)),se.tasks.getLogs(e,X).catch(()=>({logs:[]})).then(I=>{m(_=>new Map(_).set(X,I.logs)),f(_=>{const V=new Set(_);return V.delete(X),V})}))},[e,c,h]),P=v.useCallback(X=>{k(I=>{const _=new Set(I);return _.has(X)?_.delete(X):(_.add(X),c.has(X)||Y(X)),_})},[c,Y]);v.useEffect(()=>{const X=an.on("task:log",V=>{const Q=V.payload;if(Q.taskId!==e)return;const ee={id:Q.id,taskId:Q.taskId,agentId:Q.agentId,seq:Q.seq,type:Q.logType,content:Q.content,metadata:Q.metadata,executionRound:Q.executionRound,createdAt:Q.createdAt},te=ee.executionRound??1;d(ae=>ae.find(Ne=>Ne.round===te)?ae:[...ae,{round:te,logCount:0,toolCount:0,firstAt:ee.createdAt,lastAt:ee.createdAt,status:"running"}]),k(ae=>ae.has(te)?ae:new Set(ae).add(te)),m(ae=>{const me=ae.get(te)??[];return ee.id&&me.some(Ne=>Ne.id===ee.id)?ae:new Map(ae).set(te,[...me,ee])}),ee.type==="text"&&y(""),ee.type==="status"&&(ee.content==="started"||ee.content==="resumed"?N(!0):["completed","failed","cancelled","execution_finished"].includes(ee.content)&&(N(!1),d(ae=>ae.map(me=>me.round===te?{...me,status:ee.content}:me)))),ee.type==="error"&&N(!1)}),I=an.on("task:log:delta",V=>{const Q=V.payload;Q.taskId===e&&y(ee=>ee+Q.text)}),_=an.on("task:comment",V=>{const Q=V.payload;if(Q.taskId!==e)return;const ee=Q.comment;x(te=>te.some(ae=>ae.id===ee.id)?te:[...te,ee])});return()=>{X(),I(),_()}},[e]);const M=v.useMemo(()=>{const X=[];for(const[,I]of c)X.push(...I);return X.sort((I,_)=>I.seq-_.seq),X},[c]),L=v.useMemo(()=>M.map(X=>um(X)),[M]),A=o.length>1,O=X=>{const I=X.target.files;if(I){for(const _ of Array.from(I)){if(!_.type.startsWith("image/"))continue;const V=new FileReader;V.onload=()=>{W(Q=>[...Q,{type:"image",url:V.result,name:_.name}])},V.readAsDataURL(_)}X.target.value=""}},D=async()=>{if(!(!T.trim()&&G.length===0)){U(!0);try{const X=await se.tasks.addComment(e,T,s?.name,G.length>0?G:void 0,s?.id);X.comment&&x(I=>I.some(_=>_.id===X.comment.id)?I:[...I,X.comment]),R(""),W([])}catch{}U(!1)}},Z=t.jsxs("div",{className:"border-t border-border-default px-4 py-3 sticky bottom-0 bg-surface-secondary z-10",children:[G.length>0&&t.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:G.map((X,I)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:X.url,alt:X.name,className:"w-16 h-16 object-cover rounded-lg border border-border-default"}),t.jsx("button",{onClick:()=>W(_=>_.filter((V,Q)=>Q!==I)),className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-600 text-white text-[10px] flex items-center justify-center opacity-0 group-hover:opacity-100",children:"×"})]},I))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:T,onChange:X=>R(X.target.value),onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),D())},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:$,accept:"image/*",multiple:!0,onChange:O,className:"hidden"}),t.jsx("button",{onClick:()=>$.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:()=>{D()},disabled:z||!T.trim()&&G.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(S)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-fg-tertiary",children:"Loading logs…"});if(o.length===0&&!g)return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-fg-tertiary",children:[t.jsx("div",{className:"text-2xl mb-2",children:"📋"}),t.jsxs("div",{className:"text-xs",children:["No execution logs yet.",t.jsx("br",{}),'Click "Run with Agent" to start.']})]})}),Z]});if(!A){const X=L.map(V=>Ld(V)).filter(V=>V!==null),I=Dd(X),_=[...I.map(V=>({kind:"entry",entry:V,ts:V.timestamp?new Date(V.timestamp).getTime():0})),...p.map(V=>({kind:"comment",comment:V,ts:new Date(V.createdAt).getTime()}))];return _.sort((V,Q)=>V.ts-Q.ts),t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-0.5",children:[_.map((V,Q)=>V.kind==="comment"?t.jsx(Mo,{comment:V.comment,agents:i},`c-${V.comment.id}`):t.jsx(Id,{entry:V.entry,showTime:!0,isLast:Q===_.length-1},`e-${Q}`)),w&&g&&t.jsx(_m,{content:g}),w&&!g&&I.length>0&&t.jsx(Tm,{})]}),Z]})}const B=(X,I)=>{const _=X.firstAt?new Date(X.firstAt).getTime():0,V=I?.firstAt?new Date(I.firstAt).getTime():1/0;return p.filter(Q=>{const ee=new Date(Q.createdAt).getTime();return ee>=_&&ee<V})},q=o.length>0?p.filter(X=>new Date(X.createdAt).getTime()<new Date(o[0].firstAt).getTime()):[];return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{ref:F}),t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-2",children:[q.length>0&&t.jsx("div",{className:"space-y-0.5",children:q.map(X=>t.jsx(Mo,{comment:X,agents:i},X.id))}),o.map((X,I)=>{const _=C.has(X.round),V=X.round===o[o.length-1].round,Q=c.get(X.round),ee=h.has(X.round),te=B(X,o[I+1]),ae=X.status==="completed"||X.status==="execution_finished"?"✅":X.status==="failed"?"❌":X.status==="cancelled"?"⏹":"🔄",me=X.lastAt&&X.firstAt?Math.max(0,new Date(X.lastAt).getTime()-new Date(X.firstAt).getTime()):0,Ne=me>=6e4?`${Math.floor(me/6e4)}m ${Math.floor(me%6e4/1e3)}s`:me>=1e3?`${Math.floor(me/1e3)}s`:"";return t.jsxs("div",{className:"border border-border-default/50 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>P(X.round),className:"w-full flex items-center justify-between px-3 py-2 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm",children:ae}),t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",X.round]}),te.length>0&&t.jsxs("span",{className:"text-[10px] text-blue-400",children:["💬 ",te.length]}),V&&w&&t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[X.toolCount," tool",X.toolCount!==1?"s":""]}),Ne&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Ne}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${_?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),_&&t.jsxs("div",{className:"px-3 py-1.5 space-y-0.5",children:[ee&&t.jsxs("div",{className:"text-xs text-fg-tertiary py-2 text-center",children:["Loading round #",X.round,"…"]}),Q&&(()=>{const je=Q.map(Re=>um(Re)).map(Re=>Ld(Re)).filter(Re=>Re!==null),Ce=[...Dd(je).map(Re=>({kind:"entry",entry:Re,ts:Re.timestamp?new Date(Re.timestamp).getTime():0})),...te.map(Re=>({kind:"comment",comment:Re,ts:new Date(Re.createdAt).getTime()}))];return Ce.sort((Re,Ge)=>Re.ts-Ge.ts),Ce.map((Re,Ge)=>Re.kind==="comment"?t.jsx(Mo,{comment:Re.comment,agents:i},`c-${Re.comment.id}`):t.jsx(Id,{entry:Re.entry,showTime:!0,isLast:Ge===Ce.length-1},`e-${Ge}`))})(),V&&w&&g&&t.jsx(_m,{content:g}),V&&w&&!g&&!ee&&t.jsx(Tm,{})]})]},X.round)})]}),Z]})}function FI({filePath:e,onClose:n}){const[s,i]=v.useState(null),[o,d]=v.useState(null),[c,m]=v.useState(!0);v.useEffect(()=>{m(!0),d(null),se.files.preview(e).then(f=>i(f)).catch(f=>d(String(f))).finally(()=>m(!1))},[e]);const h=e.split("/").pop()??e;return t.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl w-[720px] max-w-[92vw] max-h-[85vh] flex flex-col shadow-2xl",onClick:f=>f.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-default shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t.jsx("path",{d:"M3 1h7l4 4v10H3V1zm7 1H4v12h10V5.5L10 2z"}),t.jsx("path",{d:"M10 1v4h4",fill:"none",stroke:"currentColor",strokeWidth:"1"})]}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:h})]}),t.jsx("button",{onClick:n,className:"text-fg-tertiary hover:text-fg-secondary text-lg shrink-0 ml-3",children:"×"})]}),t.jsx("div",{className:"px-4 py-1 border-b border-border-default/60",children:t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate",children:e})}),t.jsxs("div",{className:"flex-1 overflow-auto min-h-0 p-5",children:[c&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"Loading..."}),o&&t.jsx("div",{className:"text-sm text-red-500 text-center py-8",children:o}),s&&s.type==="image"&&t.jsx("div",{className:"flex justify-center",children:t.jsx("img",{src:`data:${s.mimeType};base64,${s.content}`,alt:s.name,className:"max-w-full max-h-[60vh] rounded-lg"})}),s&&s.type==="markdown"&&t.jsx(tr,{content:s.content,className:"text-sm text-fg-secondary leading-relaxed"}),s&&s.type==="text"&&t.jsx("pre",{className:"text-xs text-fg-secondary font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed",children:s.content})]})]})})}function YI({task:e,agents:n,projects:s,requirements:i,allTasks:o,users:d,onClose:c,onRefresh:m,authUser:h}){const[f,p]=v.useState([]),[x,g]=v.useState(""),[y,w]=v.useState(!1),[N,S]=v.useState(!1),[E,C]=v.useState(null),[k,T]=v.useState(null),[R,z]=v.useState(!1),[U,G]=v.useState("details"),W=v.useRef(null),[$,F]=v.useState("none"),Y=v.useCallback(ye=>{G(ye),requestAnimationFrame(()=>{W.current?.scrollTo({top:0,behavior:"instant"})})},[]),P=v.useMemo(()=>[{id:"details"},{id:"logs"},{id:"deliverables"}],[]),M=ea(P,U,Y);v.useEffect(()=>{const ye=W.current;if(!ye)return;const We=()=>{const{scrollTop:wt,scrollHeight:Tt,clientHeight:tn}=ye;if(!(Tt>tn+50)){F("none");return}const hn=wt<30,mn=wt+tn>=Tt-30;F(hn?"top":mn?"bottom":"middle")};We(),ye.addEventListener("scroll",We,{passive:!0});const He=new ResizeObserver(We);return He.observe(ye),()=>{ye.removeEventListener("scroll",We),He.disconnect()}},[U]);const[L,A]=v.useState(!1),[O,D]=v.useState(null),[Z,B]=v.useState(null),[q,X]=v.useState(!1),[I,_]=v.useState(e.description),[V,Q]=v.useState(!1),[ee,te]=v.useState(""),[ae,me]=v.useState(1),[Ne,Ie]=v.useState(!1),je=Sr(),Te=20,Ce=v.useCallback(async()=>{try{const ye=await se.tasks.listSubtasks(e.id);p(ye.subtasks)}catch{}},[e.id]);v.useEffect(()=>{Ce()},[Ce]);const Re=async ye=>{if(!R){z(!0);try{await ye(),m(),await Ce()}catch(We){D(String(We).replace("Error: ",""))}finally{z(!1)}}},Ge=ye=>Re(()=>se.tasks.update(e.id,{priority:ye})),ot=ye=>Re(()=>se.tasks.assign(e.id,ye||null)),st=ye=>Re(()=>se.tasks.update(e.id,{projectId:ye||null})),jt=async()=>{if(!R){z(!0);try{await se.tasks.pause(e.id),m()}finally{z(!1)}}},re=async()=>{if(!L){A(!0),D(null),Y("logs");try{await se.tasks.resume(e.id),m()}catch(ye){D(String(ye).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{A(!1)}}},Ee=async()=>{x.trim()&&(await se.tasks.createSubtask(e.id,x.trim()),g(""),w(!1),Ce(),m())},Ze=async ye=>{ye.status==="completed"?await se.tasks.cancelSubtask(e.id,ye.id):await se.tasks.completeSubtask(e.id,ye.id),Ce(),m()},yt=async ye=>{await se.tasks.deleteSubtask(e.id,ye.id),C(null),Ce(),m()},Dt=async()=>{if(!R){z(!0);try{await se.tasks.updateStatus(e.id,"pending"),m()}finally{z(!1)}}},we=async()=>{if(!R){z(!0),D(null),Y("logs");try{await se.tasks.retry(e.id),m()}catch(ye){D(String(ye).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{z(!1)}}},Le=async()=>{if(!L){A(!0),D(null),Y("logs");try{await se.tasks.runNow(e.id),m()}catch(ye){D(String(ye).replace("Error: API error: 400","Server error").replace("Error: ","")),m()}finally{A(!1)}}},Ue=v.useRef(m);Ue.current=m,v.useEffect(()=>an.on("task:update",We=>{We.payload.taskId===e.id&&(Ce(),Ue.current())}),[e.id,Ce]);const at=f.filter(ye=>ye.status==="completed").length,rt=e.status==="in_progress",Zt=e.status==="blocked",fn=e.status==="completed",zt=e.status==="failed",Mt=e.status==="cancelled",_t=e.status==="archived",Ct=fn||zt||Mt||_t,en=e.taskType==="scheduled"&&!!e.scheduleConfig,Ht=en&&!!e.scheduleConfig?.paused,Tn=s.find(ye=>ye.id===e.projectId),wn=i.find(ye=>ye.id===e.requirementId);return n.find(ye=>ye.id===e.assignedAgentId),t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3 border-b border-border-default shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 pr-4",children:[je&&t.jsx("button",{onClick:c,className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[t.jsx("h3",{className:"text-base font-semibold leading-snug truncate",children:e.title}),(()=>{const ye=So[e.status];return ye?t.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium whitespace-nowrap ${ye.cls}`,children:ye.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," ")})})()]})]}),!je&&t.jsx("button",{onClick:c,className:"text-fg-tertiary hover:text-fg-secondary text-lg shrink-0",children:"×"})]}),t.jsxs("div",{className:"flex gap-1 px-6 pt-2 pb-0 border-b border-border-default shrink-0 bg-surface-secondary",children:[t.jsx("button",{onClick:()=>Y("details"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors ${U==="details"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Details"}),t.jsxs("button",{onClick:()=>Y("logs"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${U==="logs"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Execution Log",rt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse"})]}),t.jsxs("button",{onClick:()=>Y("deliverables"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${U==="deliverables"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Deliverables",(()=>{const ye=(e.deliverables??[]).filter(We=>We.type!=="branch"&&typeof We.reference=="string"&&We.reference.length>0).length;return ye>0?t.jsx("span",{className:"text-[10px] text-fg-tertiary font-normal",children:ye}):null})()]})]}),t.jsxs("div",{className:"flex-1 min-h-0 relative",children:[t.jsxs("div",{ref:W,className:"h-full overflow-y-auto",onTouchStart:M.onTouchStart,onTouchEnd:M.onTouchEnd,children:[U==="logs"&&t.jsxs("div",{className:"overflow-x-hidden min-w-0",children:[O&&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:"})," ",O]}),t.jsx(VI,{taskId:e.id,isRunning:e.status==="in_progress",authUser:h,agents:n})]}),U==="details"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-6 pt-4 pb-3 border-b border-border-default",children:q?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:I,onChange:ye=>_(ye.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:()=>{X(!1),_(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:()=>{Re(()=>se.tasks.update(e.id,{description:I})),X(!1)},disabled:R,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Save"})]})]}):t.jsxs("div",{className:"group relative",children:[e.description?t.jsxs("div",{children:[t.jsx("div",{className:je&&!Ne?"line-clamp-3":"",children:t.jsx(tr,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})}),je&&e.description.length>150&&t.jsx("button",{onClick:()=>Ie(!Ne),className:"text-[11px] text-brand-500 mt-1 font-medium",children:Ne?"Collapse":"Show more"})]}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),t.jsx("button",{onClick:()=>{_(e.description),X(!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"})]})}),(Tn||wn)&&t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default flex flex-wrap items-center gap-2",children:[Tn&&t.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-2 py-0.5 bg-brand-500/10 text-brand-500 rounded-full",children:[t.jsx("span",{className:"text-[9px] text-brand-500/60",children:"Project"}),Tn.name]}),wn&&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"}),wn.title.length>40?wn.title.slice(0,40)+"…":wn.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(ye=>{const We=o.find(wt=>wt.id===ye),He=We&&(We.status==="completed"||We.status==="cancelled");return t.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-full ${He?"bg-green-500/10 text-green-600":"bg-amber-500/10 text-amber-600"}`,children:[t.jsx("span",{className:"text-[9px]",children:He?"✓":"⏳"}),t.jsx("span",{className:`font-mono ${He?"line-through opacity-60":""}`,children:We?We.title.slice(0,30):ye.slice(-8)}),!Ct&&t.jsx("button",{onClick:async()=>{const wt=(e.blockedBy??[]).filter(Tt=>Tt!==ye);await se.tasks.update(e.id,{blockedBy:wt}),m()},className:"ml-0.5 text-current opacity-40 hover:opacity-100 transition-opacity",title:"Remove dependency",children:"×"})]},ye)})}):t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-2",children:"No dependencies"}),!Ct&&t.jsxs("select",{value:"",onChange:async ye=>{const We=ye.target.value;if(!We)return;const He=[...e.blockedBy??[],We];await se.tasks.update(e.id,{blockedBy:He}),m()},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(ye=>ye.id!==e.id&&!(e.blockedBy??[]).includes(ye.id)).map(ye=>t.jsx("option",{value:ye.id,children:ye.title},ye.id))]})]}),t.jsxs("div",{className:"px-6 py-4 border-b border-border-default/60 space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Project"}),t.jsxs("select",{value:e.projectId??"",onChange:ye=>{st(ye.target.value)},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"No Project"}),s.map(ye=>t.jsx("option",{value:ye.id,children:ye.name},ye.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:ye=>Re(()=>se.tasks.update(e.id,{requirementId:ye.target.value||null})),disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"No Requirement"}),i.filter(ye=>!e.projectId||ye.projectId===e.projectId).map(ye=>t.jsx("option",{value:ye.id,children:ye.title},ye.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:ye=>{ot(ye.target.value)},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"Unassigned"}),n.map(ye=>t.jsxs("option",{value:ye.id,children:[ye.name," (",ye.status,")"]},ye.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:ye=>{ye.target.value&&ye.target.value!==e.reviewerAgentId&&Re(()=>se.tasks.update(e.id,{reviewerAgentId:ye.target.value}))},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:n.map(ye=>t.jsx("option",{value:ye.id,children:ye.name},ye.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:ye=>{Ge(ye.target.value)},disabled:R,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]})]})]}),t.jsxs("div",{className:"px-6 py-3 border-b border-border-default/60 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[11px] text-fg-tertiary",children:[e.createdBy&&t.jsxs("span",{children:["Created by ",t.jsx("span",{className:"text-fg-secondary",children:vl(e.createdBy,n,d)??e.createdBy})]}),e.updatedBy&&t.jsxs("span",{children:["Updated by ",t.jsx("span",{className:"text-fg-secondary",children:vl(e.updatedBy,n,d)??e.updatedBy})]}),e.createdAt&&t.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()}),e.startedAt&&t.jsxs("span",{children:["Started ",new Date(e.startedAt).toLocaleDateString()]}),e.updatedAt&&t.jsxs("span",{children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]}),e.projectId&&t.jsxs("span",{className:"font-mono text-blue-600/70",children:["task/",e.id]}),(e.executionRound??1)>1&&t.jsxs("span",{className:"text-amber-600",children:["Round ",e.executionRound]})]}),t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:["Subtasks ",f.length>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal normal-case",children:[at,"/",f.length," done"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[at>0&&t.jsx("button",{onClick:()=>S(ye=>!ye),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${N?"bg-brand-500/15 text-brand-500 border-brand-500/30":"text-fg-tertiary border-border-default hover:text-fg-secondary"}`,children:N?"Hide completed":`Show completed (${at})`}),t.jsx("button",{onClick:()=>w(!0),className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"+ Add subtask"})]})]}),(()=>{const ye=N?f:f.filter(We=>We.status!=="completed");return ye.length>0?t.jsx("div",{className:"space-y-1.5 mb-3",children:ye.map(We=>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:()=>{Ze(We)},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${We.status==="completed"?"bg-green-600 border-green-600 text-white":"border-gray-600 hover:border-brand-500"}`,children:We.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 ${We.status==="completed"?"line-through text-fg-tertiary":"text-fg-secondary"}`,children:We.title}),t.jsx("button",{onClick:()=>C(We),className:"shrink-0 opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-red-500 transition-all text-xs",children:"✕"})]},We.id))}):null})(),f.length===0&&!y&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:"No subtasks yet."}),y&&t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("input",{autoFocus:!0,value:x,onChange:ye=>g(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&Ee(),ye.key==="Escape"&&(w(!1),g(""))},placeholder:"Subtask title...",className:"flex-1 px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none"}),t.jsx("button",{onClick:()=>{Ee()},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg",children:"Add"}),t.jsx("button",{onClick:()=>{w(!1),g("")},className:"px-3 py-1.5 border border-border-default text-xs rounded-lg hover:bg-surface-elevated",children:"Cancel"})]}),(()=>{const ye=(e.deliverables??[]).filter(wt=>wt.type!=="branch"&&typeof wt.reference=="string"&&wt.reference.length>0);if(ye.length===0)return null;const We={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"},He=ye.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:["(",ye.length,")"]})]}),ye.length>3&&t.jsx("button",{onClick:()=>Y("deliverables"),className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:He.map((wt,Tt)=>{const tn=wt.reference.split("/").pop()??wt.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 ${We[wt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:wt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>B(wt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:wt.reference,children:tn}),wt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:wt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:wt.reference})]})]},Tt)})})]})})(),t.jsx(qI,{task:e,agents:n,users:d,authUser:h})]})]}),U==="deliverables"&&t.jsx("div",{className:"px-6 py-4",children:(()=>{const ye=(e.deliverables??[]).filter(Tt=>Tt.type!=="branch"&&typeof Tt.reference=="string"&&Tt.reference.length>0);if(ye.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12 text-xs text-fg-tertiary",children:"No deliverables yet."});const We={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"},He=Math.ceil(ye.length/Te),wt=ye.slice((ae-1)*Te,ae*Te);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:["(",ye.length,")"]})]}),He>1&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:ae<=1,onClick:()=>me(Tt=>Tt-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"‹"}),t.jsxs("span",{children:[ae,"/",He]}),t.jsx("button",{disabled:ae>=He,onClick:()=>me(Tt=>Tt+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:wt.map((Tt,tn)=>{const nn=Tt.reference.split("/").pop()??Tt.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 ${We[Tt.type]??"bg-gray-500/15 text-fg-secondary"}`,children:Tt.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>B(Tt.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:Tt.reference,children:nn}),Tt.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:Tt.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:Tt.reference})]})]},tn)})})]})})()})]}),$!=="none"&&$!=="top"&&t.jsx("button",{onClick:()=>W.current?.scrollTo({top:0,behavior:"smooth"}),className:"absolute bottom-20 right-4 md:bottom-14 md:right-3 z-10 w-12 h-12 md:w-8 md:h-8 rounded-full bg-brand-500 md:bg-brand-600/90 border border-brand-400/60 shadow-xl shadow-brand-500/30 md:shadow-lg md:shadow-brand-500/20 flex items-center justify-center text-white hover:bg-brand-400 transition-colors backdrop-blur-sm",title:"Scroll to top",children:t.jsx("svg",{className:"w-6 h-6 md:w-4 md:h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M14.77 12.79a.75.75 0 01-1.06-.02L10 8.832l-3.71 3.938a.75.75 0 11-1.08-1.04l4.25-4.5a.75.75 0 011.08 0l4.25 4.5a.75.75 0 01-.02 1.06z",clipRule:"evenodd"})})}),$!=="none"&&$!=="bottom"&&t.jsx("button",{onClick:()=>{const ye=W.current;ye&&ye.scrollTo({top:ye.scrollHeight,behavior:"smooth"})},className:"absolute bottom-6 right-4 md:bottom-4 md:right-3 z-10 w-12 h-12 md:w-8 md:h-8 rounded-full bg-brand-500 md:bg-brand-600/90 border border-brand-400/60 shadow-xl shadow-brand-500/30 md:shadow-lg md:shadow-brand-500/20 flex items-center justify-center text-white hover:bg-brand-400 transition-colors backdrop-blur-sm",title:"Scroll to bottom",children:t.jsx("svg",{className:"w-6 h-6 md:w-4 md:h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})})]}),en&&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 ye=new Date(e.scheduleConfig.nextRunAt).getTime()-Date.now();if(ye<=0)return"due now";const We=Math.floor(ye/6e4);if(We<60)return`in ${We}m`;const He=Math.floor(We/60);return He<24?`in ${He}h ${We%60}m`:`in ${Math.floor(He/24)}d ${He%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 ye=Date.now()-new Date(e.scheduleConfig.lastRunAt).getTime(),We=Math.floor(ye/6e4);if(We<1)return"just now";if(We<60)return`${We}m ago`;const He=Math.floor(We/60);return He<24?`${He}h ${We%60}m ago`:`${Math.floor(He/24)}d ago`})()]})]})]})]}),t.jsx("div",{className:"px-6 py-4 border-t border-border-default flex items-center justify-between gap-2",children:t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.status==="pending"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>Re(()=>se.tasks.approve(e.id)),disabled:R,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"Approve"}),t.jsx("button",{onClick:()=>Re(()=>se.tasks.reject(e.id)),disabled:R,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 rounded-lg hover:bg-red-500/10 disabled:opacity-50",children:"Reject"})]}),e.status==="review"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{Re(()=>se.tasks.accept(e.id,h?.id))},disabled:R,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"✓ Approve"}),V?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"text",value:ee,onChange:ye=>te(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&ee.trim()&&(Re(()=>se.tasks.revision(e.id,ee.trim(),h?.id)),Q(!1),te(""))},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:()=>{Re(()=>se.tasks.revision(e.id,ee.trim()||"Revisions needed",h?.id)),Q(!1),te("")},disabled:R,className:"px-2.5 py-1 text-xs bg-amber-600 hover:bg-amber-500 rounded-lg text-white disabled:opacity-50",children:"Send"}),t.jsx("button",{onClick:()=>{Q(!1),te("")},className:"px-1.5 py-1 text-xs text-fg-secondary hover:text-fg-primary",children:"✕"})]}):t.jsx("button",{onClick:()=>Q(!0),disabled:R,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 rounded-lg text-white disabled:opacity-50",children:"↻ Request Revision"})]}),rt&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>{jt()},disabled:R,className:"px-3 py-1.5 text-xs border border-amber-500/30 text-amber-600 rounded-lg hover:bg-amber-500/10 disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:[t.jsx("rect",{x:"2",y:"1.5",width:"3",height:"9",rx:"0.5"}),t.jsx("rect",{x:"7",y:"1.5",width:"3",height:"9",rx:"0.5"})]}),"Pause"]}),t.jsxs("button",{onClick:()=>{we()},disabled:R,className:"px-3 py-1.5 text-xs border border-blue-500/30 text-blue-600 rounded-lg hover:bg-blue-500/10 disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("path",{d:"M1.5 6a4.5 4.5 0 1 1 1.3 3.2",strokeLinecap:"round"}),t.jsx("path",{d:"M1 3.5V6h2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Retry"]})]}),Zt&&t.jsx("button",{onClick:()=>{re()},disabled:L,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:L?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"]})}),zt&&t.jsxs("button",{onClick:()=>{we()},disabled:R,className:"px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("path",{d:"M1.5 6a4.5 4.5 0 1 1 1.3 3.2",strokeLinecap:"round"}),t.jsx("path",{d:"M1 3.5V6h2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Retry"]}),en&&(fn||zt)&&t.jsx("button",{onClick:()=>{Le()},disabled:L,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:L?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"]})}),en&&!rt&&(Ht?t.jsx("button",{onClick:()=>{Re(()=>se.tasks.resumeSchedule(e.id))},disabled:R,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"▶ Resume Schedule"}):t.jsx("button",{onClick:()=>{Re(()=>se.tasks.pauseSchedule(e.id))},disabled:R,className:"px-3 py-1.5 text-xs border border-amber-500/30 text-amber-600 rounded-lg hover:bg-amber-500/10 disabled:opacity-50",children:"⏸ Pause Schedule"})),fn&&t.jsx("button",{onClick:()=>Re(()=>se.tasks.archive(e.id)),disabled:R,className:"px-3 py-1.5 text-xs bg-gray-600 hover:bg-gray-500 rounded-lg text-white disabled:opacity-50",children:"Archive"}),Ct&&t.jsx("button",{onClick:()=>{Dt()},disabled:R,className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary disabled:opacity-50",children:"Reopen"}),!Ct&&e.status!=="pending"&&t.jsx("button",{onClick:async()=>{const{count:ye}=await se.tasks.getDependentCount(e.id);ye>0?T({dependentCount:ye}):Re(()=>se.tasks.cancel(e.id))},disabled:R,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 rounded-lg hover:bg-red-500/10 disabled:opacity-50",children:"Cancel"})]})}),E&&t.jsx(Dj,{title:`Delete subtask "${E.title}"?`,message:"This subtask will be permanently deleted.",confirmLabel:"Delete",onConfirm:()=>{yt(E)},onCancel:()=>C(null)}),k&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>T(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:ye=>ye.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:"Cancel Task"}),t.jsxs("p",{className:"text-sm text-fg-secondary mb-4",children:["This task has ",t.jsx("span",{className:"text-amber-600 font-medium",children:k.dependentCount})," dependent task",k.dependentCount>1?"s":""," that ",k.dependentCount>1?"are":"is"," currently blocked by it."]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{onClick:()=>{T(null),Re(()=>se.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:()=>{T(null),Re(()=>se.tasks.cancel(e.id,!0))},className:"w-full px-4 py-2.5 text-sm bg-red-500/10 border border-red-500/30 rounded-lg hover:bg-red-500/20 text-red-500 text-left",children:[t.jsx("span",{className:"font-medium",children:"Cancel with all dependents"}),t.jsxs("span",{className:"block text-xs text-red-500/70 mt-0.5",children:["Also cancels ",k.dependentCount," blocked task",k.dependentCount>1?"s":""]})]}),t.jsx("button",{onClick:()=>T(null),className:"w-full px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary",children:"Keep task running"})]})]})}),Z&&t.jsx(FI,{filePath:Z,onClose:()=>B(null)})]})}function GI({project:e,tasks:n,requirements:s,agents:i,onDeleteProject:o,onUpdateProject:d,onRefresh:c}){const m=v.useMemo(()=>n.filter(G=>G.projectId===e.id),[n,e.id]),h=v.useMemo(()=>s.filter(G=>G.projectId===e.id),[s,e.id]),f=v.useMemo(()=>{const G={total:m.length,completed:0,inProgress:0,inReview:0,blocked:0,pending:0,failed:0,reqs:h.length,reqsDone:0};for(const W of m)W.status==="completed"||W.status==="accepted"?G.completed++:W.status==="in_progress"?G.inProgress++:W.status==="review"||W.status==="revision"?G.inReview++:W.status==="blocked"?G.blocked++:W.status==="failed"?G.failed++:G.pending++;for(const W of h)W.status==="completed"&&G.reqsDone++;return G},[m,h]),p=v.useMemo(()=>new Set(m.map(G=>G.assignedAgentId).filter(Boolean)),[m]),x=v.useMemo(()=>i.filter(G=>p.has(G.id)),[i,p]),[g,y]=v.useState(!1),[w,N]=v.useState(""),[S,E]=v.useState("main"),[C,k]=v.useState(!1),T=[{value:"active",label:"Active",desc:"Work is ongoing"},{value:"paused",label:"Paused",desc:"Temporarily on hold"},{value:"archived",label:"Archived",desc:"No longer active"}],R=async G=>{if(G!==e.status){k(!0);try{await d({status:G}),c()}finally{k(!1)}}},z=async()=>{const G=w.trim();if(!G)return;const W=[...e.repositories??[],{url:"",localPath:G,defaultBranch:S||"main"}];await d({repositories:W}),N(""),E("main"),y(!1),c()},U=async G=>{const W=(e.repositories??[]).filter(($,F)=>F!==G);await d({repositories:W}),c()};return t.jsxs("div",{className:"p-5 space-y-5 max-w-3xl",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(II,{value:e.description??"",onSave:async G=>{await d({description:G}),c()},className:"text-sm text-fg-secondary",placeholder:"Add a project description…"}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[e.createdAt&&t.jsxs("span",{children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),e.updatedAt&&t.jsxs("span",{children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]})]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Project Status"}),t.jsx("div",{className:"flex gap-2",children:T.map(G=>t.jsxs("button",{disabled:C,onClick:()=>R(G.value),className:`flex-1 px-3 py-2 rounded-lg text-xs font-medium transition-all ${e.status===G.value?G.value==="active"?"bg-green-500/15 text-green-600 ring-1 ring-green-500/30":G.value==="paused"?"bg-amber-500/15 text-amber-600 ring-1 ring-amber-500/30":"bg-gray-500/15 text-fg-tertiary ring-1 ring-gray-500/30":"bg-surface-elevated text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"} ${C?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[t.jsx("div",{children:G.label}),t.jsx("div",{className:"text-[10px] opacity-70 mt-0.5",children:G.desc})]},G.value))})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Overview"}),t.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-3",children:[t.jsx(Ks,{label:"Total",value:f.total,color:"text-fg-primary"}),t.jsx(Ks,{label:"Completed",value:f.completed,color:"text-green-600"}),t.jsx(Ks,{label:"In Progress",value:f.inProgress,color:"text-brand-500"}),t.jsx(Ks,{label:"In Review",value:f.inReview,color:"text-brand-500"}),t.jsx(Ks,{label:"Blocked",value:f.blocked,color:"text-amber-600"}),t.jsx(Ks,{label:"Failed",value:f.failed,color:"text-red-500"})]}),f.total>0&&t.jsxs("div",{className:"mt-3 flex h-2 rounded-full overflow-hidden bg-surface-elevated",children:[f.completed>0&&t.jsx("div",{className:"bg-green-500",style:{width:`${f.completed/f.total*100}%`}}),f.inProgress>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${f.inProgress/f.total*100}%`}}),f.inReview>0&&t.jsx("div",{className:"bg-brand-500",style:{width:`${f.inReview/f.total*100}%`}}),f.blocked>0&&t.jsx("div",{className:"bg-amber-500",style:{width:`${f.blocked/f.total*100}%`}}),f.pending>0&&t.jsx("div",{className:"bg-blue-500/40",style:{width:`${f.pending/f.total*100}%`}}),f.failed>0&&t.jsx("div",{className:"bg-red-500",style:{width:`${f.failed/f.total*100}%`}})]})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Requirements"}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsx(Ks,{label:"Total",value:f.reqs,color:"text-fg-primary"}),t.jsx(Ks,{label:"Completed",value:f.reqsDone,color:"text-green-600"}),t.jsx(Ks,{label:"Active",value:f.reqs-f.reqsDone,color:"text-brand-500"})]})]}),x.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsxs("h4",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Agents (",x.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(G=>{const W=m.filter(F=>F.assignedAgentId===G.id),$=W.filter(F=>!["completed","failed","cancelled","archived"].includes(F.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 ${G.status==="working"?"bg-blue-500":G.status==="idle"?"bg-green-500":"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary",children:G.name}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.length," active / ",W.length," total"]})]},G.id)})})]}),t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"text-xs font-semibold text-fg-secondary",children:"Repositories"}),t.jsx("button",{onClick:()=>y(!g),className:"text-[10px] text-brand-500 hover:text-brand-500",children:g?"Cancel":"+ Add"})]}),(e.repositories??[]).length===0&&!g&&t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No repositories linked."}),(e.repositories??[]).map((G,W)=>t.jsxs("div",{className:"flex items-center gap-2 py-1.5 group",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:[t.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),t.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 min-w-0 truncate",children:G.url||G.localPath}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:G.defaultBranch}),t.jsx("button",{onClick:()=>U(W),className:"text-fg-tertiary hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",title:"Remove repository",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},W)),g&&t.jsxs("div",{className:"mt-2 space-y-2 p-3 bg-surface-elevated rounded-lg border border-border-default",children:[t.jsx("input",{value:w,onChange:G=>N(G.target.value),placeholder:"Local path (e.g. /Users/me/project)",className:"w-full px-2.5 py-1.5 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:S,onChange:G=>E(G.target.value),placeholder:"Branch (default: main)",className:"flex-1 px-2.5 py-1.5 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary"}),t.jsx("button",{onClick:z,disabled:!w.trim(),className:"px-3 py-1.5 text-xs bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Add"})]})]})]}),t.jsxs("div",{className:"border border-red-500/20 rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-semibold text-red-500/80 mb-2",children:"Danger Zone"}),t.jsx("p",{className:"text-[11px] text-fg-tertiary mb-3",children:"Deleting a project is permanent and cannot be undone. Tasks and requirements will be unlinked."}),t.jsx("button",{onClick:o,className:"px-3 py-1.5 text-xs text-red-500 border border-red-500/30 hover:bg-red-500/10 rounded-lg transition-colors",children:"Delete Project"})]})]})}function Ks({label:e,value:n,color:s}){return t.jsxs("div",{className:"text-center py-2",children:[t.jsx("div",{className:`text-xl font-bold ${s}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}const fi={pending:{label:"Pending",cls:"bg-amber-500/15 text-amber-600"},in_progress:{label:"Active",cls:"bg-brand-500/15 text-brand-500"},completed:{label:"Done",cls:"bg-green-500/15 text-green-600"},rejected:{label:"Rejected",cls:"bg-red-500/15 text-red-500"},cancelled:{label:"Cancelled",cls:"bg-gray-600/15 text-fg-tertiary"}},DN={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed"},LN={failed:"rejected",todo:"pending",in_progress:"in_progress",review:"in_progress",done:"completed",closed:"cancelled"},XI={urgent:0,high:1,medium:2,low:3},a1={failed:0,todo:1,in_progress:2,review:3,done:4,closed:5},i1={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"},KI={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"},WI=["pending","in_progress","completed","rejected","cancelled"];function ZI(e){for(const n of Vo)if(n.statuses.includes(e))return n.id;return"closed"}function l1(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function jd({value:e,options:n,onSelect:s}){const[i,o]=v.useState(!1),d=v.useRef(null),c=v.useRef(null),m=n.find(h=>h.value===e);return v.useEffect(()=>{if(!i)return;const h=f=>{c.current&&!c.current.contains(f.target)&&d.current&&!d.current.contains(f.target)&&o(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]),t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:d,onClick:()=>o(h=>!h),className:`text-[11px] px-2 py-0.5 rounded-full font-medium transition-colors cursor-pointer hover:ring-1 hover:ring-current/30 ${m?.cls??"bg-gray-500/15 text-fg-tertiary"}`,children:m?.label??e}),i&&t.jsx("div",{ref:c,className:"absolute top-full left-0 mt-1 w-40 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-50 py-1 max-h-64 overflow-y-auto",children:n.map(h=>t.jsxs("button",{onClick:()=>{h.value!==e&&s(h.value),o(!1)},className:`w-full text-left px-3 py-1.5 text-[11px] flex items-center gap-2 transition-colors ${h.value===e?"bg-surface-elevated":"hover:bg-surface-elevated/60"}`,children:[t.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 ${h.cls.split(" ")[0]}`}),t.jsx("span",{className:`font-medium ${h.value===e?"text-fg-primary":"text-fg-secondary"}`,children:h.label}),h.value===e&&t.jsx("svg",{className:"w-3 h-3 ml-auto text-brand-500",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M2 6l3 3 5-5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]},h.value))})]})}function o1({row:e,idx:n,dragIdx:s,agentMap:i,projMap:o,onTaskClick:d,onReqClick:c,onRowDragStart:m,onRowDragEnd:h,handleStatusChange:f,handlePriorityChange:p,selected:x,isMobile:g}){const y=e.data.status,w=e.data.priority,N=e.kind==="task"?i.get(e.data.assignedAgentId??""):void 0,S=o.get((e.kind==="task",e.data.projectId??"")),E=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",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"});return g?t.jsxs("div",{onClick:()=>e.kind==="task"?d(e.data):c(e.data),className:`px-3 py-2 border-b border-border-default/40 cursor-pointer transition-colors border-l-2 ${i1[e.group]??"border-l-gray-700"} ${x?"bg-brand-500/10 border-l-brand-500":"active:bg-surface-elevated/50"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[E,t.jsx("span",{className:"text-sm text-fg-primary truncate flex-1",children:e.data.title})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.jsx("div",{onClick:C=>C.stopPropagation(),children:t.jsx(jd,{value:y,options:e.kind==="task"?n1.map(C=>({value:C,label:So[C]?.label??C,cls:So[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})):r1.map(C=>({value:C,label:fi[C]?.label??C,cls:fi[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:C=>{f(e,C)}})}),t.jsx("div",{onClick:C=>C.stopPropagation(),children:t.jsx(jd,{value:w,options:t1.map(C=>({value:C,label:vd[C]?.label??C,cls:vd[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:C=>{p(e,C)}})}),N&&t.jsxs("span",{className:"flex items-center gap-1 text-[10px]",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Wm[N.status]??"bg-gray-500"}`}),t.jsx("span",{className:`${s1[N.status]??"text-fg-secondary"}`,children:N.name})]}),S?.name&&t.jsx("span",{className:"text-[10px] text-brand-400/70 truncate max-w-[80px]",children:S.name}),t.jsx("span",{className:"text-[9px] text-fg-muted ml-auto",children:l1(e.data.updatedAt??"")})]})]}):t.jsxs("div",{draggable:!0,onDragStart:C=>m(C,n),onDragEnd:h,onClick:()=>e.kind==="task"?d(e.data):c(e.data),className:`flex items-center gap-2 px-6 py-2 border-b border-border-default/40 cursor-pointer transition-colors border-l-2 ${i1[e.group]??"border-l-gray-700"} ${s===n?"opacity-40":""} ${x?"bg-brand-500/10 border-l-brand-500 hover:bg-brand-500/15":"hover:bg-surface-elevated/50"}`,children:[t.jsx("div",{className:"w-12 shrink-0",children:E}),t.jsx("div",{className:"flex-1 min-w-[200px] text-sm text-fg-primary truncate",children:e.data.title}),t.jsx("div",{className:"w-[130px] shrink-0",onClick:C=>C.stopPropagation(),children:t.jsx(jd,{value:y,options:e.kind==="task"?n1.map(C=>({value:C,label:So[C]?.label??C,cls:So[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})):r1.map(C=>({value:C,label:fi[C]?.label??C,cls:fi[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:C=>{f(e,C)}})}),t.jsx("div",{className:"w-[100px] shrink-0",onClick:C=>C.stopPropagation(),children:t.jsx(jd,{value:w,options:t1.map(C=>({value:C,label:vd[C]?.label??C,cls:vd[C]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:C=>{p(e,C)}})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:N?t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Wm[N.status]??"bg-gray-500"}`}),t.jsx("span",{className:`font-medium ${s1[N.status]??"text-fg-secondary"}`,children:N.name})]}):t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:S?.name?t.jsx("span",{className:"text-brand-400/70",children:S.name}):t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[90px] shrink-0 text-[10px] text-fg-muted text-right",children:l1(e.data.updatedAt??"")})]})}function QI({tasks:e,requirements:n,agents:s,projects:i,onTaskClick:o,onReqClick:d,onRefresh:c,selectedTaskId:m,selectedReqId:h}){const f=Sr(),[p,x]=v.useState("status"),[g,y]=v.useState(null),[w,N]=v.useState(null),S=v.useMemo(()=>{const M=[];for(const L of e){const A=ZI(L.status);M.push({kind:"task",data:L,group:A,groupOrder:a1[A]??5})}for(const L of n){const A=DN[L.status]??"todo";M.push({kind:"req",data:L,group:A,groupOrder:a1[A]??5})}if(p==="status")M.sort((L,A)=>{if(L.groupOrder!==A.groupOrder)return L.groupOrder-A.groupOrder;const O=new Date(L.data.updatedAt??0).getTime();return new Date(A.data.updatedAt??0).getTime()-O});else{const L=A=>XI[A.data.priority]??2;M.sort((A,O)=>{const D=L(A),Z=L(O);return D!==Z?D-Z:new Date(O.data.updatedAt??0).getTime()-new Date(A.data.updatedAt??0).getTime()})}return M},[e,n,p]),E=async(M,L)=>{try{M.kind==="task"?await se.tasks.updateStatus(M.data.id,L):await se.requirements.updateStatus(M.data.id,L),c()}catch{}},C=async(M,L)=>{try{M.kind==="task"?await se.tasks.update(M.data.id,{priority:L}):await se.requirements.update(M.data.id,{priority:L}),c()}catch{}},k=(M,L)=>{y(L),M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",String(L)),M.currentTarget.style.opacity="0.4"},T=M=>{M.currentTarget.style.opacity="1",y(null),N(null)},R=(M,L)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",w!==L&&N(L)},z=async(M,L)=>{if(M.preventDefault(),N(null),g==null)return;const A=S[g];if(!A||A.group===L)return;const O=Vo.find(D=>D.id===L);if(O){try{if(A.kind==="task"){if(A.data.status==="pending")return;await se.tasks.updateStatus(A.data.id,O.dropStatus)}else{const D=LN[L];D&&await se.requirements.updateStatus(A.data.id,D)}c()}catch{}y(null)}},U=v.useMemo(()=>new Map(s.map(M=>[M.id,M])),[s]),G=v.useMemo(()=>new Map(i.map(M=>[M.id,M])),[i]),W=["todo","in_progress","review","done"],$=v.useMemo(()=>{const M={};for(const L of S)M[L.group]=(M[L.group]??0)+1;return M},[S]),{rowsByGroup:F,rowIndexMap:Y}=v.useMemo(()=>{const M=new Map,L=new Map;for(let A=0;A<S.length;A++){const O=S[A];L.set(O,A);const D=M.get(O.group)??[];D.push(O),M.set(O.group,D)}return{rowsByGroup:M,rowIndexMap:L}},[S]),P=v.useMemo(()=>{if(p!=="status")return null;const M=new Set(S.map(O=>O.group)),L=[],A=new Set;M.has("failed")&&(L.push("failed"),A.add("failed"));for(const O of W)L.push(O),A.add(O);for(const O of S)A.has(O.group)||(L.push(O.group),A.add(O.group));return L},[S,p]);return t.jsx("div",{className:`flex-1 min-h-0 overflow-auto bg-surface-secondary ${f?"overflow-x-hidden w-full":""}`,children:t.jsxs("div",{className:f?"w-full":"w-fit min-w-full",children:[!f&&t.jsxs("div",{className:"flex items-center gap-2 px-6 py-2 border-b border-border-default text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider sticky top-0 z-20 bg-surface-secondary",children:[t.jsx("div",{className:"w-12 shrink-0 text-fg-muted normal-case font-normal",children:S.length}),t.jsx("div",{className:"flex-1 min-w-[200px]",children:"Title"}),t.jsxs("button",{onClick:()=>x("status"),className:`w-[130px] shrink-0 text-left flex items-center gap-1 transition-colors ${p==="status"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Status ",p==="status"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsxs("button",{onClick:()=>x("priority"),className:`w-[100px] shrink-0 text-left flex items-center gap-1 transition-colors ${p==="priority"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Priority ",p==="priority"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsx("div",{className:"w-[120px] shrink-0",children:"Assignee"}),t.jsx("div",{className:"w-[120px] shrink-0",children:"Project"}),t.jsx("div",{className:"w-[90px] shrink-0 text-right",children:"Updated"})]}),t.jsxs("div",{children:[p==="status"&&P?P.map(M=>{const L=Vo.find(O=>O.id===M),A=F.get(M)??[];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 ${KI[M]??""} ${w===M?"ring-1 ring-brand-500/40":""}`,onDragOver:O=>R(O,M),onDragLeave:()=>N(null),onDrop:O=>{z(O,M)},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",children:L?.label??M}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:$[M]??0})]}),A.map(O=>t.jsx(o1,{row:O,idx:Y.get(O)??0,dragIdx:g,agentMap:U,projMap:G,onTaskClick:o,onReqClick:d,onRowDragStart:k,onRowDragEnd:T,handleStatusChange:E,handlePriorityChange:C,selected:O.kind==="task"?O.data.id===m:O.data.id===h,isMobile:f},`${O.kind}-${O.data.id}`))]},M)}):S.map((M,L)=>t.jsx(o1,{row:M,idx:L,dragIdx:g,agentMap:U,projMap:G,onTaskClick:o,onReqClick:d,onRowDragStart:k,onRowDragEnd:T,handleStatusChange:E,handlePriorityChange:C,selected:M.kind==="task"?M.data.id===m:M.data.id===h,isMobile:f},`${M.kind}-${M.data.id}`)),S.length===0&&t.jsx("div",{className:"flex items-center justify-center py-16 text-sm text-fg-tertiary",children:"No items"})]})]})})}function c1({authUser:e}){const n=Sr(),s=su({side:"right",defaultWidth:Math.round(window.innerWidth*2/3),minWidth:380,maxWidth:Math.round(window.innerWidth*.8),storageKey:"markus_projects_detail_v3"}),[i,o]=v.useState(!1),d=v.useRef(i);d.current=i;const[c,m]=v.useState([]),[h,f]=v.useState("all"),[p,x]=v.useState(null),[g,y]=v.useState({}),[w,N]=v.useState([]),[S,E]=v.useState([]),[C,k]=v.useState([]),[T,R]=v.useState(!0),[z,U]=v.useState(""),[G,W]=v.useState(!1),$=v.useCallback(()=>{mn(p??""),ye(!0)},[p]),[F,Y]=v.useState(!1),[P,M]=v.useState(!1),[L,A]=v.useState(""),[O,D]=v.useState(""),[Z,B]=v.useState("medium"),[q,X]=v.useState(""),[I,_]=v.useState(""),[V,Q]=v.useState(""),[ee,te]=v.useState(""),[ae,me]=v.useState([]),[Ne,Ie]=v.useState("standard"),[je,Te]=v.useState("4h"),[Ce,Re]=v.useState(null),[Ge,ot]=v.useState(null),[st,jt]=v.useState(new Set),[re,Ee]=v.useState(new Set),Ze=v.useRef(new Set),yt=v.useRef(new Set),[Dt,we]=v.useState(null),[Le,Ue]=v.useState("backlog"),at=v.useMemo(()=>[{id:"backlog"},{id:"kanban"},{id:"dag"}],[]),rt=ea(at,Le,Ue),Zt=v.useRef(null),fn=v.useMemo(()=>({scrollContainerRef:Zt}),[]),zt=ea(at,Le,Ue,fn),[Mt,_t]=v.useState(!1),[Ct,en]=v.useState(!1),Ht=v.useRef(null),Tn=v.useRef(null),[wn,ye]=v.useState(!1),[We,He]=v.useState(""),[wt,Tt]=v.useState(""),[tn,nn]=v.useState("medium"),[hn,mn]=v.useState(""),[On,Nt]=v.useState(null),[oe,Ve]=v.useState(""),ze=K=>{U(K),setTimeout(()=>U(""),3e3)},dt=c.find(K=>K.id===p)??null;v.useEffect(()=>{yt.current=re},[re]);const it=v.useCallback(async()=>{try{const{projects:K}=await se.projects.list();m(K)}catch{}},[]),xt=v.useCallback(async()=>{const K={};h==="project"&&p&&(K.projectId=p);try{const{board:le}=await se.tasks.board(K);y(le)}catch{}},[h,p]),$t=v.useCallback(async()=>{try{const{agents:K}=await se.agents.list();N(K)}catch{}},[]),Je=v.useCallback(async()=>{try{const{users:K}=await se.users.list(e?.orgId);E(K)}catch{}},[e?.orgId]),Fe=v.useCallback(async()=>{try{const{requirements:K}=await se.requirements.list({});k(K)}catch{}},[]),Et=v.useCallback(async()=>{await Promise.all([it(),xt(),$t(),Je(),Fe()]),R(!1)},[it,xt,$t,Je,Fe]);v.useEffect(()=>{Et()},[Et]);const Rn=v.useCallback(K=>{Re(le=>le?.id===K.id?(n&&d.current&&o(!1),null):(n&&(o(!0),history.pushState({mobileDetail:xe.WORK},"",window.location.hash)),K)),ot(null)},[n]),Nn=v.useCallback(K=>{ot(le=>le?.id===K.id?(n&&d.current&&o(!1),null):(n&&(o(!0),history.pushState({mobileDetail:xe.WORK},"",window.location.hash)),K)),Re(null)},[n]),ln=v.useCallback(()=>{Re(null),ot(null),n&&d.current&&o(!1)},[n]);v.useEffect(()=>{if(!n)return;const K=()=>{d.current&&(o(!1),Re(null),ot(null))};return window.addEventListener("popstate",K),()=>window.removeEventListener("popstate",K)},[n]);const ve=v.useRef(Ce);ve.current=Ce,v.useEffect(()=>{const le=setInterval(()=>{xt(),$t(),Fe()},Ce?6e4:15e3),he=an.on("task:update",Ke=>{ve.current||(xt(),Fe());const Se=Ke?.payload;Se?.taskId&&Re(et=>{if(!et||et.id!==Se.taskId)return et;const bt={};return typeof Se.status=="string"&&(bt.status=Se.status),Array.isArray(Se.deliverables)&&(bt.deliverables=Se.deliverables),Array.isArray(Se.notes)&&(bt.notes=Se.notes),Se.result!==void 0&&(bt.result=Se.result),{...et,...bt}})}),Me=an.on("task:create",()=>{xt()}),$e=["requirement:created","requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"].map(Ke=>an.on(Ke,()=>{Fe()}));return()=>{clearInterval(le),he(),Me(),$e.forEach(Ke=>Ke())}},[xt,$t,Fe,Ce]);const Xe=v.useRef(g);Xe.current=g;const At=v.useRef(C);At.current=C;const St=v.useCallback(K=>{if(!K)return;const le=yt.current;le.size>0&&!le.has(K)&&Ee(he=>new Set([...he,K]))},[]),xn=v.useCallback(K=>{Re(K),ot(null),n&&(o(!0),history.pushState({mobileDetail:xe.WORK},"",window.location.hash))},[n]),Qn=v.useCallback(K=>{ot(K),Re(null),n&&(o(!0),history.pushState({mobileDetail:xe.WORK},"",window.location.hash))},[n]);v.useEffect(()=>{const K=localStorage.getItem("markus_nav_openTask");if(!K)return;const he=Object.values(g).flat().find(Me=>Me.id===K);he&&(St(he.projectId),xn(he),localStorage.removeItem("markus_nav_openTask"))},[g,xn,St]),v.useEffect(()=>{const K=window.location.hash.slice(1).split("/");if(Qs(K[0])===xe.WORK&&K[1])on(K[1]);else{const le=localStorage.getItem("markus_nav_projectId");le&&(localStorage.removeItem("markus_nav_projectId"),on(le))}},[]);const lr=v.useRef(Qs(window.location.hash.slice(1).split("/")[0]));v.useEffect(()=>{const K=()=>{const he=window.location.hash.slice(1).split("/"),Me=Qs(he[0]),Be=lr.current===xe.WORK;lr.current=Me,Me===xe.WORK&&(Me===xe.WORK&&he[1]?on(he[1]):Be&&ur())},le=he=>{const Me=he.detail;if(Qs(Me.page)===xe.WORK){if(Me.params?.openTask){const $e=Object.values(Xe.current).flat().find(Ke=>Ke.id===Me.params.openTask);$e&&(St($e.projectId),xn($e),localStorage.removeItem("markus_nav_openTask"))}if(Me.params?.openRequirement){const Be=At.current.find($e=>$e.id===Me.params.openRequirement);Be&&(St(Be.projectId),Qn(Be))}Me.params?.projectId&&on(Me.params.projectId)}};return window.addEventListener("markus:navigate",le),window.addEventListener("hashchange",K),()=>{window.removeEventListener("markus:navigate",le),window.removeEventListener("hashchange",K)}},[]);const on=K=>{yt.current.size>0&&(Ze.current=new Set(yt.current)),Ee(new Set),x(K),f("project"),W(!1),history.replaceState(null,"",dm(xe.WORK,K))},ur=()=>{Ee(Ze.current),x(null),f("all"),W(!1),history.replaceState(null,"",dm(xe.WORK))},Jr=()=>{Y(!1),ze("Project created"),it()},de=async K=>{if(confirm("Delete this project and unlink all its tasks?"))try{await se.projects.delete(K),p===K&&ur(),ze("Project deleted"),it(),xt()}catch(le){ze(`Error: ${le}`)}},Ae=async()=>{if(!L||!q||!I)return;if(q===I){ze("Assigned agent and reviewer must be different");return}const K=V||void 0,le=ee||void 0;try{await se.tasks.create(L,O,q,I,Z,K,ae.length>0?ae:void 0,le,Ne!=="standard"?Ne:void 0,Ne==="scheduled"?{every:je}:void 0),A(""),D(""),me([]),te(""),Ie("standard"),Te("4h"),M(!1),xt()}catch(he){ze(`Error creating task: ${he}`)}},qe=()=>{xt(),Ce&&setTimeout(()=>{const K={};h==="project"&&p&&(K.projectId=p),se.tasks.board(K).then(le=>{const Me=Object.values(le.board).flat().find(Be=>Be.id===Ce.id);Re(Me||null)}).catch(()=>{})},150)},Bt=async()=>{if(!We.trim()){ze("Please enter a title for this requirement");return}if(!wt.trim()){ze("Please enter a description for this requirement");return}if(!hn){ze("Please select a project for this requirement");return}try{await se.requirements.create({title:We.trim(),description:wt.trim(),priority:tn,projectId:hn}),ze("Requirement created"),He(""),Tt(""),ye(!1),Fe()}catch(K){ze(`Error: ${K}`)}},xr=async K=>{try{await se.requirements.approve(K),ze("Requirement approved"),Fe(),xt()}catch(le){ze(`Error: ${le}`)}},es=async()=>{if(On)try{await se.requirements.reject(On,oe),ze("Requirement rejected"),Nt(null),Ve(""),Fe()}catch(K){ze(`Error: ${K}`)}},fr=async K=>{try{await se.requirements.cancel(K),ze("Requirement cancelled"),Fe()}catch(le){ze(`Error: ${le}`)}},ms=(K,le)=>{Ht.current=le,Tn.current=null,K.dataTransfer.effectAllowed="move",K.dataTransfer.setData("text/plain",`task:${le.id}`),K.currentTarget.style.opacity="0.4"},nr=(K,le)=>{Tn.current=le,Ht.current=null,K.dataTransfer.effectAllowed="move",K.dataTransfer.setData("text/plain",`req:${le.id}`),K.currentTarget.style.opacity="0.4"},Xn=K=>{K.currentTarget.style.opacity="1",Ht.current=null,Tn.current=null,we(null)},Ms=(K,le)=>{K.preventDefault(),K.dataTransfer.dropEffect="move",Dt!==le&&we(le)},Ha=(K,le)=>{const he=K.currentTarget.getBoundingClientRect(),{clientX:Me,clientY:Be}=K;(Me<he.left||Me>he.right||Be<he.top||Be>he.bottom)&&Dt===le&&we(null)},ts=async(K,le)=>{K.preventDefault(),we(null);const he=Ht.current,Me=Tn.current;if(he){const Be=Vo.find(Ke=>Ke.id===le);if(!Be)return;const $e=Be.dropStatus;if(he.status===$e||he.status==="pending")return;try{await se.tasks.updateStatus(he.id,$e),xt()}catch{}}else if(Me){const Be=LN[le];if(!Be||Me.status===Be)return;try{await se.requirements.updateStatus(Me.id,Be),Fe()}catch{}}},Er=K=>{jt(le=>{const he=new Set(le);return he.has(K)?he.delete(K):he.add(K),he})},Pr=K=>{Ee(le=>{const he=new Set(le);return he.has(K)?he.delete(K):he.add(K),he})},Pa=1440*60*1e3,Jn=Date.now(),ns=K=>K.updatedAt&&Jn-new Date(K.updatedAt).getTime()>Pa,Kn=K=>(K.status==="completed"||K.status==="cancelled")&&ns(K),Tr=(K,le=!1)=>{let he=K.filter(Me=>Mt||le||!Kn(Me));return h==="project"&&p&&(he=he.filter(Me=>Me.projectId===p)),re.size>0&&(he=he.filter(Me=>Me.projectId&&re.has(Me.projectId))),st.size>0&&(he=he.filter(Me=>Me.assignedAgentId&&st.has(Me.assignedAgentId))),he},pr=K=>K.statuses.flatMap(le=>Tr(g[le]??[])),xs=v.useMemo(()=>{let K=C;return Mt||(K=K.filter(le=>!Kn(le))),h==="project"&&p&&(K=K.filter(le=>le.projectId===p)),re.size>0&&(K=K.filter(le=>le.projectId&&re.has(le.projectId))),st.size>0&&(K=K.filter(le=>st.has(le.createdBy))),K},[C,Mt,h,p,re,st]),_r=v.useCallback(K=>xs.filter(le=>DN[le.status]===K.id),[xs]),Ur=Vo.filter(K=>{if(K.id==="failed"||K.id==="closed"){const le=pr(K),he=_r(K);return le.length+he.length>0}return!0}),rs=Object.values(g).flat().filter(K=>Kn(K)).length+C.filter(K=>Kn(K)).length,ps=v.useMemo(()=>{const K=new Set(["completed","failed","cancelled","archived"]),le=Object.values(g).flat(),he=new Set;for(const Me of le)Me.assignedAgentId&&!K.has(Me.status)&&(!p||Me.projectId===p)&&he.add(Me.assignedAgentId);return[...w].sort((Me,Be)=>{const $e=he.has(Me.id)?0:1,Ke=he.has(Be.id)?0:1;return $e-Ke})},[w,g,p]),sa=v.useMemo(()=>{const K=new Set(["completed","failed","cancelled","archived"]),le=Object.values(g).flat(),he=new Set;for(const Me of le)Me.projectId&&!K.has(Me.status)&&he.add(Me.projectId);return[...c].sort((Me,Be)=>{const $e=he.has(Me.id)?0:1,Ke=he.has(Be.id)?0:1;return $e-Ke})},[c,g]),Os=v.useMemo(()=>{const K={};for(const le of Object.values(g))for(const he of le){const Me=he.projectId??"__none__";K[Me]=(K[Me]??0)+1}return K},[g]),Ua=Object.values(Os).reduce((K,le)=>K+le,0);if(T)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"});const ne=!!(Ce||Ge);return t.jsxs("div",{className:"flex-1 overflow-hidden flex bg-surface-secondary",children:[t.jsxs("div",{className:`${n?"flex-1 min-w-0":ne?"shrink-0":"flex-1"} overflow-hidden flex flex-col bg-surface-secondary`,style:n?i?{display:"none"}:void 0:ne?{width:`calc(100% - ${s.width}px - 4px)`}:void 0,children:[z&&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:z}),n?t.jsxs("div",{className:"border-b border-border-default bg-surface-secondary/80 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 h-11",children:[dt?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:dt.name}),t.jsx("button",{onClick:()=>W(!G),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors shrink-0 ${G?"bg-surface-overlay text-fg-primary":"text-fg-tertiary"}`,children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]}):t.jsx("h2",{className:"text-sm font-semibold text-fg-primary min-w-0 flex-1 truncate",children:c.length===1?c[0].name:`${c.length} Projects`}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx("button",{onClick:()=>Y(!0),className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Project"}),t.jsx("button",{onClick:$,className:"px-2 py-1 text-[11px] bg-brand-600 text-white rounded-md",children:"+ Req"}),t.jsx("button",{onClick:()=>{Q(p??""),M(!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(K=>t.jsx("button",{onClick:()=>Ue(K),className:`px-2 py-0.5 text-[10px] font-medium transition-colors ${Le===K?"bg-brand-600/25 text-brand-500":"text-fg-tertiary"}`,children:K==="backlog"?"Backlog":K==="kanban"?"Kanban":"DAG"},K))}),rs>0&&t.jsx("button",{onClick:()=>_t(K=>!K),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Mt?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary"}`,children:Mt?"Hide archived":`${rs} archived`}),t.jsx("div",{className:"flex-1"}),(re.size>0||st.size>0||c.length>1||w.length>0)&&t.jsxs("button",{onClick:()=>en(!0),className:`px-2 py-1 text-[11px] rounded-md font-medium transition-colors flex items-center gap-1 ${re.size>0||st.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",re.size+st.size>0?` (${re.size+st.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:[dt?t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(LI,{value:dt.name,onSave:async K=>{await se.projects.update(dt.id,{name:K}),it()},className:"text-sm font-semibold text-fg-primary"}),t.jsx("button",{onClick:()=>W(!G),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors ${G?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:"Project settings",children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]}):t.jsx("h2",{className:"text-sm font-semibold text-fg-primary shrink-0",children:c.length===1?c[0].name:`${c.length} Projects`}),rs>0&&t.jsx("button",{onClick:()=>_t(K=>!K),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${Mt?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary hover:text-fg-secondary"}`,children:Mt?`Hide ${rs} archived`:`${rs} archived`}),t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(K=>t.jsx("button",{onClick:()=>Ue(K),className:`px-2.5 py-1 text-[10px] font-medium transition-colors ${Le===K?"bg-brand-600/25 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:K==="backlog"?"Backlog":K==="kanban"?"Kanban":"DAG"},K))}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("button",{onClick:$,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:()=>{Q(p??""),M(!0)},className:"px-3 py-1.5 border border-border-default hover:bg-surface-elevated text-fg-secondary text-xs rounded-lg font-medium transition-colors",children:"+ Task"})]}),t.jsx("div",{className:"flex-1"})]}),!n&&c.length>1&&!p&&!G&&(Ua>0||C.length>0)&&t.jsxs("div",{className:"px-6 py-1.5 border-b border-border-default/60 flex items-center gap-1.5 overflow-x-auto scrollbar-hide shrink-0",children:[t.jsx("button",{onClick:()=>Ee(new Set),className:`text-[10px] text-fg-tertiary hover:text-fg-secondary px-2 py-1 rounded-md bg-surface-elevated/60 hover:bg-surface-overlay shrink-0 transition-all ${re.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),sa.map(K=>{const le=re.has(K.id),he=Os[K.id]??0;return t.jsxs("button",{onClick:()=>Pr(K.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${le?"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 ${le?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:K.name[0]?.toUpperCase()}),K.name,he>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary ml-0.5",children:he})]},K.id)})]}),!n&&w.length>0&&!G&&(Ua>0||C.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:()=>jt(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 ${st.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),ps.map(K=>{const le=st.has(K.id);return t.jsxs("button",{onClick:()=>Er(K.id),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] shrink-0 transition-all ${le?"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 ${le?"bg-brand-600 text-white":"bg-surface-overlay text-fg-secondary"}`,children:K.name[0]?.toUpperCase()}),K.name]},K.id)})]}),G&&dt?t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(GI,{project:dt,tasks:Object.values(g).flat(),requirements:C,agents:w,onDeleteProject:()=>de(dt.id),onUpdateProject:async K=>{await se.projects.update(dt.id,K)},onRefresh:()=>{it()}})}):Ua===0&&xs.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:$,className:"text-xs text-brand-500 hover:text-brand-500 font-medium",children:"+ Create a requirement"})]})}):Le==="backlog"?t.jsx("div",{className:"flex-1 min-h-0 flex flex-col",onTouchStart:n?rt.onTouchStart:void 0,onTouchEnd:n?rt.onTouchEnd:void 0,children:t.jsx(QI,{tasks:Tr(Object.values(g).flat()),requirements:xs,agents:w,projects:c,onTaskClick:K=>Rn(K),onReqClick:K=>Nn(K),onRefresh:()=>{xt(),Fe()},selectedTaskId:Ce?.id,selectedReqId:Ge?.id})}):Le==="dag"?t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col relative",onTouchStart:n?rt.onTouchStart:void 0,onTouchEnd:n?rt.onTouchEnd:void 0,children:[t.jsx(DI,{tasks:Tr(Object.values(g).flat(),!0),requirements:xs,agents:w,showArchived:Mt,onShowArchivedChange:_t,onTaskClick:K=>Rn(K),onReqClick:K=>Nn(K),onDependencyChange:xt,selectedTaskId:Ce?.id,selectedReqId:Ge?.id}),n&&t.jsx("button",{onClick:()=>Ue("kanban"),className:"absolute left-3 top-1/2 -translate-y-1/2 w-11 h-11 rounded-full bg-brand-500 border border-brand-400/60 shadow-xl shadow-brand-500/30 flex items-center justify-center text-white active:bg-brand-400 backdrop-blur-sm z-10",title:"Back to Kanban",children:t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})})})]}):t.jsx("div",{ref:Zt,className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden px-4 py-5",onTouchStart:n?zt.onTouchStart:void 0,onTouchEnd:n?zt.onTouchEnd:void 0,children:t.jsx("div",{className:"flex gap-3 h-full",children:Ur.map(K=>{const le=pr(K),he=_r(K),Me=le.length+he.length,Be=Dt===K.id;return t.jsxs("div",{className:`w-[280px] shrink-0 rounded-xl flex flex-col h-full transition-colors ${Be?"bg-surface-elevated/60 ring-1 ring-brand-500/30":"bg-surface-secondary/50"}`,onDragOver:$e=>Ms($e,K.id),onDragLeave:$e=>Ha($e,K.id),onDrop:$e=>{ts($e,K.id)},children:[t.jsxs("div",{className:"flex justify-between items-center px-3 py-2.5 shrink-0 border-b border-border-default/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${K.accent.replace("border-t-","bg-")}`}),t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:K.label})]}),t.jsx("span",{className:"text-[11px] text-fg-tertiary font-medium tabular-nums",children:Me})]}),t.jsx("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto scrollbar-thin px-2 py-2",children:(()=>{const $e=[...he.map(Ke=>({kind:"req",data:Ke,time:new Date(Ke.updatedAt??Ke.createdAt).getTime()})),...le.map(Ke=>({kind:"task",data:Ke,time:new Date(Ke.updatedAt??Ke.createdAt??0).getTime()}))];return $e.sort((Ke,Se)=>Se.time-Ke.time),$e.map(Ke=>{if(Ke.kind==="req"){const Se=Ke.data,et=fi[Se.status]??{label:Se.status,cls:"bg-gray-500/15 text-fg-secondary"},Vt=Se.source==="agent"&&Se.status==="pending",rn=h==="all"&&Se.projectId?c.find(ht=>ht.id===Se.projectId):null,pn=vl(Se.createdBy,w,S)??Se.createdBy.slice(0,10),ct=Ge?.id===Se.id;return t.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:ht=>nr(ht,Se),onDragEnd:Xn,onClick:()=>Nn(Se),onKeyDown:ht=>ht.key==="Enter"&&Nn(Se),className:`group rounded-lg p-2.5 border border-transparent transition-all cursor-grab active:cursor-grabbing
62
- ${Vt?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15":"bg-surface-elevated/80 hover:bg-surface-elevated border-border-default/50 hover:border-brand-400/40"}
63
- ${ct?"ring-2 ring-brand-500/50 border-brand-500/40":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:"w-1 h-1 rounded-full bg-purple-500 shrink-0"}),t.jsx("span",{className:"text-[10px] font-semibold text-purple-500 uppercase tracking-wide shrink-0",children:"REQ"}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md shrink-0 ml-auto ${et.cls}`,children:et.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:Se.title}),Se.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Se.description}),t.jsxs("div",{className:"flex items-center justify-between mt-auto pt-1.5 border-t border-border-default/20",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[rn&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded truncate max-w-[90px]",title:rn.name,children:rn.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Se.priority}),t.jsxs("span",{className:"text-[10px] text-fg-quaternary",children:["by ",pn]})]}),t.jsx("div",{className:"flex items-center gap-1",children:Se.taskIds.length>0&&t.jsxs("span",{className:"text-[10px] text-brand-500/70 bg-brand-500/8 px-1.5 py-0.5 rounded-md",children:["📋 ",Se.taskIds.length]})})]}),Vt&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-amber-500/15",children:[t.jsx("button",{onClick:ht=>{ht.stopPropagation(),xr(Se.id)},className:"flex-1 py-1 bg-green-600 hover:bg-green-500 text-white text-[10px] rounded-md font-medium transition-colors",children:"Approve"}),t.jsx("button",{onClick:ht=>{ht.stopPropagation(),Nt(Se.id)},className:"flex-1 py-1 border border-red-500/30 hover:bg-red-500/10 text-red-500 text-[10px] rounded-md font-medium transition-colors",children:"Reject"})]})]},`req-${Se.id}`)}else{const Se=Ke.data,et=Se.subtasks?.length??0,bt=RN[Se.status],Vt=Se.status==="pending",rn=Se.taskType==="scheduled"&&!!Se.scheduleConfig,pn=rn?Se.scheduleConfig.every?`Every ${Se.scheduleConfig.every}`:Se.scheduleConfig.cron?"Cron":"Scheduled":null,ct=h==="all"&&Se.projectId?c.find(Ye=>Ye.id===Se.projectId)?.name:null,ht=Se.requirementId?C.find(Ye=>Ye.id===Se.requirementId)?.title:null,ut=Se.createdBy?vl(Se.createdBy,w,S)??Se.createdBy:null,tt=Ce?.id===Se.id,Qe={urgent:"bg-red-500",high:"bg-amber-500",medium:"bg-blue-500",low:"bg-gray-400"};return t.jsxs("div",{role:"button",tabIndex:0,"aria-label":Se.title,draggable:!Vt,onDragStart:Ye=>!Vt&&ms(Ye,Se),onDragEnd:Xn,onClick:()=>Rn(Se),onKeyDown:Ye=>Ye.key==="Enter"&&Rn(Se),className:`group rounded-lg p-2.5 border border-transparent transition-all ${Vt?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15 cursor-pointer":rn?"bg-blue-500/[0.04] border-blue-500/20 hover:border-blue-400/40 cursor-pointer":"bg-surface-elevated/80 hover:bg-surface-elevated border-border-default/50 hover:border-brand-400/40 cursor-grab active:cursor-grabbing"} ${tt?"ring-2 ring-brand-500/50 border-brand-500/40":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Qe[Se.priority]??"bg-gray-400"}`,title:Se.priority}),rn&&t.jsx("span",{className:"text-blue-500 shrink-0",title:pn??"Scheduled",children:t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})}),rn&&pn&&t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-blue-500/10 text-blue-500 whitespace-nowrap",children:pn}),bt&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md ml-auto shrink-0 ${bt.cls}`,children:bt.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:Se.title}),Se.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:Se.description}),(ct||ht||Se.blockedBy&&Se.blockedBy.length>0)&&t.jsxs("div",{className:"flex flex-wrap gap-1 mb-1.5",children:[ct&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-overlay/60 text-fg-secondary rounded-md truncate max-w-[100px]",title:ct,children:ct}),ht&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/8 text-brand-500 rounded-md truncate max-w-[110px]",title:ht,children:["# ",ht]}),Se.blockedBy&&Se.blockedBy.length>0&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/10 text-amber-600 rounded-md",children:["⏳ ",Se.blockedBy.length," dep",Se.blockedBy.length>1?"s":""]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-auto pt-1.5 border-t border-border-default/20",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:ut&&t.jsxs("span",{className:"text-[10px] text-fg-quaternary",title:`by ${ut}`,children:["by ",ut]})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[et>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["⋮ ",et]}),Se.notes&&Se.notes.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["📝 ",Se.notes.length]}),Se.assignedAgentId&&t.jsxs("span",{className:"text-[10px] text-brand-500 bg-brand-500/8 px-1.5 py-0.5 rounded-md flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Wm[w.find(Ye=>Ye.id===Se.assignedAgentId)?.status??""]??"bg-gray-500"}`}),w.find(Ye=>Ye.id===Se.assignedAgentId)?.name??Se.assignedAgentId.slice(0,8)]})]})]})]},Se.id)}})})()}),Be&&t.jsx("div",{className:"mx-2 mb-2 border-2 border-dashed border-brand-500/25 rounded-lg h-10 flex items-center justify-center shrink-0",children:t.jsx("span",{className:"text-[11px] text-brand-500/50",children:"Drop here"})})]},K.id)})})})]}),!n&&ne&&t.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-border-default/40 hover:bg-brand-500/30 active:bg-brand-500/50 transition-colors",onMouseDown:s.onResizeStart}),(!n||i)&&ne&&t.jsx("div",{className:`${n?"flex-1":"shrink-0"} overflow-hidden min-w-0 border-l border-border-default`,style:n?void 0:{width:s.width},children:Ce?t.jsx(YI,{task:Ce,agents:w,projects:c,requirements:C,allTasks:Object.values(g).flat(),users:S,onClose:ln,onRefresh:qe,authUser:e}):Ge?t.jsx(ez,{req:Ge,agents:w,projects:c,allTasks:Object.values(g).flat(),users:S,onClose:ln,onApprove:K=>{xr(K),ln()},onReject:K=>{Nt(K),ln()},onCancel:K=>{fr(K),ln()},onStatusChange:async(K,le)=>{try{await se.requirements.updateStatus(K,le),ze(`Requirement status → ${le}`),Fe(),xt()}catch(he){ze(`Error: ${he}`)}},onRefresh:Fe,authUser:e}):null}),F&&t.jsx(MN,{orgId:e?.orgId,onCreated:Jr,onClose:()=>Y(!1)}),P&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>M(!1),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 max-h-[90dvh] overflow-y-auto ${n?"w-full":"w-[28rem]"}`,onClick:K=>K.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:V,onChange:K=>Q(K.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"No Project"}),c.map(K=>t.jsx("option",{value:K.id,children:K.name},K.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Requirement"}),t.jsxs("select",{value:ee,onChange:K=>te(K.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…"}),C.filter(K=>K.status==="in_progress"&&(!V||K.projectId===V)).map(K=>t.jsx("option",{value:K.id,children:K.title},K.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{autoFocus:!n,value:L,onChange:K=>A(K.target.value),onKeyDown:K=>{K.key==="Enter"&&Ae()},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:O,onChange:K=>D(K.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:Z,onChange:K=>B(K.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:q,onChange:K=>X(K.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select agent…"}),w.map(K=>t.jsx("option",{value:K.id,children:K.name},K.id))]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-fg-secondary mb-1.5",children:["Reviewer ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:I,onChange:K=>_(K.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select reviewer…"}),w.filter(K=>K.id!==q).map(K=>t.jsx("option",{value:K.id,children:K.name},K.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Task Type"}),t.jsxs("select",{value:Ne,onChange:K=>Ie(K.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"standard",children:"Standard"}),t.jsx("option",{value:"scheduled",children:"Scheduled (recurring)"})]})]}),Ne==="scheduled"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Frequency"}),t.jsxs("select",{value:je,onChange:K=>Te(K.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:K=>{const le=K.target.value;le&&!ae.includes(le)&&me([...ae,le])},className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a task to depend on…"}),Object.values(g).flat().filter(K=>K.status!=="completed"&&K.status!=="cancelled"&&!ae.includes(K.id)).map(K=>t.jsx("option",{value:K.id,children:K.title},K.id))]}),ae.length>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ae.map(K=>{const le=Object.values(g).flat().find(he=>he.id===K);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:["⏳ ",le?le.title.slice(0,30):K.slice(-8),t.jsx("button",{onClick:()=>me(ae.filter(he=>he!==K)),className:"ml-0.5 text-amber-600/60 hover:text-amber-600",children:"×"})]},K)})})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>M(!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:()=>{Ae()},disabled:!q||!I,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Create"})]})]})}),wn&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>{ye(!1),He(""),Tt("")},children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 max-h-[90dvh] overflow-y-auto ${n?"w-full":"w-[28rem]"}`,onClick:K=>K.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:hn,onChange:K=>mn(K.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a project…"}),c.map(K=>t.jsx("option",{value:K.id,children:K.name},K.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{value:We,onChange:K=>He(K.target.value),placeholder:"e.g. Add user authentication",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",autoFocus:!n,onKeyDown:K=>{K.key==="Enter"&&We.trim()&&Bt()}})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:wt,onChange:K=>Tt(K.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:tn,onChange:K=>nn(K.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:()=>{ye(!1),He(""),Tt("")},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:()=>{Bt()},disabled:!We.trim()||!wt.trim()||!hn,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-40 disabled:cursor-not-allowed",children:"Create"})]})]})}),On&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>Nt(null),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 ${n?"w-full":"w-96"}`,onClick:K=>K.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:oe,onChange:K=>Ve(K.target.value),placeholder:"Why is this being rejected...",rows:3,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-red-500 outline-none resize-none",autoFocus:!n})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>Nt(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:()=>{es()},className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 rounded-lg text-white",children:"Reject"})]})]})}),Ct&&t.jsxs("div",{className:"fixed inset-0 z-[60] flex flex-col justify-end",onClick:()=>en(!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:K=>K.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:[(re.size>0||st.size>0)&&t.jsx("button",{onClick:()=>{Ee(new Set),jt(new Set)},className:"text-[11px] text-brand-500 font-medium",children:"Clear all"}),t.jsx("button",{onClick:()=>en(!1),className:"w-7 h-7 flex items-center justify-center rounded-full bg-surface-elevated text-fg-tertiary",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),c.length>1&&t.jsxs("div",{className:"px-4 py-3",children:[t.jsx("div",{className:"text-[11px] text-fg-tertiary font-medium uppercase tracking-wider mb-2",children:"Projects"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:sa.map(K=>{const le=re.has(K.id),he=Os[K.id]??0;return t.jsxs("button",{onClick:()=>Pr(K.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${le?"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 ${le?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:K.name[0]?.toUpperCase()}),K.name,he>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary",children:he})]},K.id)})})]}),w.length>0&&t.jsxs("div",{className:"px-4 py-3 border-t border-border-default/40",children:[t.jsx("div",{className:"text-[11px] text-fg-tertiary font-medium uppercase tracking-wider mb-2",children:"Agents"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:ps.map(K=>{const le=st.has(K.id);return t.jsxs("button",{onClick:()=>Er(K.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[11px] transition-all ${le?"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 ${le?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:K.name[0]?.toUpperCase()}),K.name]},K.id)})})]}),t.jsx("div",{className:"h-[env(safe-area-inset-bottom,0px)]"})]})]})]})}function JI({requirementId:e,agents:n,authUser:s}){const[i,o]=v.useState([]);v.useEffect(()=>{se.requirements.getComments(e).then(f=>o(f.comments)).catch(()=>{})},[e]),v.useEffect(()=>an.on("requirement:comment",p=>{p.payload?.requirementId===e&&p.payload.comment&&o(x=>x.some(g=>g.id===p.payload.comment.id)?x:[...x,p.payload.comment])}),[e]);const[d,c]=v.useState(null),m=async(f,p,x)=>{await se.requirements.addComment(e,f,s?.name,s?.id,p.length>0?p:void 0,x)},h=v.useCallback(f=>{c({id:f.id,authorName:f.authorName,content:f.content.slice(0,100)})},[]);return t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 block",children:["Comments ",i.length>0&&t.jsxs("span",{className:"font-normal",children:["(",i.length,")"]})]}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[i.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary text-center py-4",children:"No comments yet."}),i.map(f=>t.jsx(Mo,{comment:f,agents:n,onReply:h},f.id))]}),t.jsx(Rj,{agents:n,onSubmit:m,replyTo:d,onCancelReply:()=>c(null)})]})}function ez({req:e,agents:n,projects:s,allTasks:i,users:o,onClose:d,onApprove:c,onReject:m,onCancel:h,onStatusChange:f,onRefresh:p,authUser:x}){const g=Sr(),[y,w]=v.useState(!1),[N,S]=v.useState(e.description),[E,C]=v.useState(!1),k=fi[e.status]??{label:e.status,cls:"bg-gray-500/15 text-fg-secondary"},T=e.source==="agent",R=T&&e.status==="pending",z=e.status==="pending"||e.status==="in_progress",U=e.status==="completed"||e.status==="rejected"||e.status==="cancelled",G=e.projectId?s.find(F=>F.id===e.projectId):null,W=vl(e.createdBy,n,o)??e.createdBy.slice(0,12),$=i.filter(F=>e.taskIds.includes(F.id));return v.useEffect(()=>{S(e.description),w(!1)},[e.id,e.description]),t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 p-5 pb-0 border-b border-border-default",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[g&&t.jsx("button",{onClick:d,className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsxs("div",{className:"flex-1 min-w-0 pb-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-[10px] font-bold text-brand-500 bg-brand-500/15 px-2 py-0.5 rounded",children:"REQ"}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full font-medium ${k.cls}`,children:k.label}),e.priority==="high"||e.priority==="urgent"?t.jsx("span",{className:`text-[10px] font-medium ${e.priority==="urgent"?"text-red-500":"text-amber-600"}`,children:e.priority}):t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.priority})]}),t.jsx("h2",{className:"text-lg font-semibold text-fg-primary leading-snug",children:e.title})]})]}),!g&&t.jsx("button",{onClick:d,className:"text-fg-tertiary hover:text-fg-secondary text-xl leading-none shrink-0 mt-1",children:"×"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1 block",children:"Description"}),y?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:N,onChange:F=>S(F.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-y min-h-[80px]",rows:4,autoFocus:!0}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{onClick:()=>{w(!1),S(e.description)},className:"px-2.5 py-1 text-xs border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:async()=>{C(!0);try{await se.requirements.update(e.id,{description:N}),w(!1),p?.()}catch{}finally{C(!1)}},disabled:E,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Save"})]})]}):t.jsxs("div",{className:"group relative",children:[e.description?t.jsx(tr,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),!U&&t.jsx("button",{onClick:()=>{S(e.description),w(!0)},className:"absolute top-0 right-0 text-[10px] text-fg-tertiary hover:text-brand-500 opacity-0 group-hover:opacity-100 transition-opacity",children:"Edit"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[t.jsxs("div",{className:"bg-surface-elevated/60 rounded-lg p-2.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary block mb-1",children:"Created by"}),t.jsx("span",{className:"text-fg-secondary",children:W}),T&&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()})]}),G&&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:G.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:vl(e.approvedBy,n,o)??e.approvedBy.slice(0,12)}),e.approvedAt&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-1",children:new Date(e.approvedAt).toLocaleDateString()})]})]}),e.rejectedReason&&t.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsx("span",{className:"text-[10px] font-semibold text-red-500 uppercase tracking-wider block mb-1",children:"Rejection Reason"}),t.jsx("p",{className:"text-sm text-red-500/80",children:e.rejectedReason})]}),Array.isArray(e.tags)&&e.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(F=>t.jsxs("span",{className:"text-[10px] bg-surface-elevated text-fg-secondary px-2 py-0.5 rounded-full",children:["#",F]},F))}),$.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 (",$.length,")"]}),t.jsx("div",{className:"space-y-1.5",children:$.map(F=>{const Y=RN[F.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 ${PI[F.priority]?.replace("border-l-","bg-")??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:F.title}),Y&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${Y.cls}`,children:Y.label})]},F.id)})})]}),t.jsx(JI,{requirementId:e.id,agents:n,authUser:x})]}),t.jsxs("div",{className:"flex items-center gap-2 p-5 pt-3 border-t border-border-default",children:[R&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>c(e.id),className:"px-4 py-2 bg-green-600 hover:bg-green-500 text-white text-sm rounded-lg font-medium transition-colors",children:"Approve"}),t.jsx("button",{onClick:()=>m(e.id),className:"px-4 py-2 border border-red-500/30 hover:bg-red-500/10 text-red-500 text-sm rounded-lg font-medium transition-colors",children:"Reject"})]}),!R&&f&&!U&&t.jsx("select",{value:e.status,onChange:F=>{F.target.value!==e.status&&f(e.id,F.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:WI.map(F=>{const Y=fi[F];return t.jsx("option",{value:F,children:Y?.label??F},F)})}),U&&f&&t.jsx("button",{onClick:()=>f(e.id,"in_progress"),className:"px-3 py-1.5 text-xs border border-border-default hover:bg-surface-elevated rounded-lg text-fg-secondary transition-colors",children:"Reopen"}),t.jsx("div",{className:"flex-1"}),z&&!R&&t.jsx("button",{onClick:()=>h(e.id),className:"px-3 py-1.5 text-xs text-red-500/70 hover:text-red-500 hover:bg-red-500/10 border border-transparent hover:border-red-500/20 rounded-lg transition-colors",children:"Cancel Requirement"})]})]})}function js(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"&&e?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function tz(e){return e.files&&typeof e.files=="object"&&!Array.isArray(e.files)?e.files:null}function oi({label:e,value:n}){return n?t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:e}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:n})]}):null}function el({label:e,value:n,color:s}){if(!n)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:n})]})}function lm({files:e}){const[n,s]=v.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 ${n===o?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:o},o))}),n&&e[n]!=null&&t.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:e[n]})]})]})}function nz({artifact:e,mode:n}){const s=tz(e),i=e.agent,o=e.team,d=e.dependencies,c=e.displayName??e.name;if(n==="agent"){const m=i?.roleName,h=i?.agentRole,f=i?.llmProvider,p=i?.llmModel,x=js(d?.env),g=js(d?.skills);return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(oi,{label:"Name",value:c}),t.jsx(oi,{label:"Description",value:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(el,{label:"Role Template",value:m,color:"indigo"}),t.jsx(el,{label:"Agent Role",value:h,color:h==="manager"?"purple":"cyan"})]}),js(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:js(e.tags).map(y=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:y},y))}),(f||p)&&t.jsxs("div",{className:"flex gap-2",children:[f&&t.jsx(el,{label:"LLM Provider",value:f,color:"gray"}),p&&t.jsx(el,{label:"LLM Model",value:p,color:"gray"})]}),x.length>0&&t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:"Required Env"}),t.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:x.map(y=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:y},y))})]}),g.length>0&&t.jsx(oi,{label:"Skills",value:g.join(", ")}),s&&t.jsx(lm,{files:s})]})}if(n==="team"){const h=o?.members??[];return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(oi,{label:"Name",value:c}),t.jsx(oi,{label:"Description",value:e.description}),t.jsx("div",{className:"flex flex-wrap gap-2",children:t.jsx(el,{label:"Category",value:e.category,color:"indigo"})}),js(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:js(e.tags).map(f=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:f},f))}),s&&t.jsx(lm,{files:s}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Members (",h.length,")"]}),t.jsx("div",{className:"mt-1.5 space-y-1.5",children:h.map((f,p)=>t.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${f.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:f.role==="manager"?"★":p+1}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:f.name}),typeof f.roleName=="string"&&f.roleName&&t.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:f.roleName}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(f.count??1)]})]}),js(f.skills).length>0&&t.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:js(f.skills).map(x=>t.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:x},x))})]},p))})]})]})}return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(oi,{label:"Name",value:c}),t.jsx(oi,{label:"Description",value:e.description}),t.jsx("div",{className:"flex gap-2",children:t.jsx(el,{label:"Category",value:e.category,color:"indigo"})}),s&&t.jsx(lm,{files:s}),js(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:js(e.tags).map(m=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:m},m))})]})}const yo={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},d1={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"}},u1=["file","directory"],ws={agent:{icon:"✦",label:"Agent",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",label:"Team",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",label:"Skill",color:"bg-amber-500/10 text-amber-600"}};function f1(){const e=Sr(),n=su({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[s,i]=v.useState(!1),o=v.useRef(s);o.current=s,v.useEffect(()=>{if(!e)return;const ve=()=>{o.current&&i(!1)};return window.addEventListener("popstate",ve),()=>window.removeEventListener("popstate",ve)},[e]);const d=100,[c,m]=v.useState([]),[h,f]=v.useState(0),[p,x]=v.useState(!1),[g,y]=v.useState([]),[w,N]=v.useState([]),[S,E]=v.useState(!0),[C,k]=v.useState(""),[T,R]=v.useState(""),[z,U]=v.useState(""),[G,W]=v.useState(""),[$,F]=v.useState(""),[Y,P]=v.useState(""),[M,L]=v.useState(""),[A,O]=v.useState("date"),[D,Z]=v.useState(null),[B,q]=v.useState(null),[X,I]=v.useState(""),[_,V]=v.useState(!1),[Q,ee]=v.useState(!1),[te,ae]=v.useState(new Set),me=v.useMemo(()=>[{id:"date"},{id:"project"},{id:"agent"},{id:"type"}],[]),Ne=v.useCallback(ve=>{O(ve),ae(new Set)},[]),Ie=ea(me,A,Ne),je=v.useRef(null),[Te,Ce]=v.useState("file"),[Re,Ge]=v.useState(""),[ot,st]=v.useState(""),[jt,re]=v.useState(""),[Ee,Ze]=v.useState(""),[yt,Dt]=v.useState(""),[we,Le]=v.useState(null),[Ue,at]=v.useState(null),[rt,Zt]=v.useState(!1),[fn,zt]=v.useState(!1),[Mt,_t]=v.useState(!1),[Ct,en]=v.useState(!1),Ht=v.useRef(null),Tn=v.useRef(null),[wn,ye]=v.useState(""),We=v.useRef(void 0),He=(ve,Xe)=>{q({type:ve,text:Xe}),setTimeout(()=>q(null),3e3)},wt=async ve=>{try{return await navigator.clipboard.writeText(ve),!0}catch{try{const Xe=document.createElement("textarea");Xe.value=ve,Xe.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(Xe),Xe.select();const At=document.execCommand("copy");return document.body.removeChild(Xe),At}catch{return!1}}},Tt=async ve=>{await wt(ve)?(en(!0),setTimeout(()=>en(!1),1500)):He("error","Copy failed — try long-pressing to copy manually")},tn=v.useMemo(()=>new Map(w.map(ve=>[ve.id,ve])),[w]),nn=v.useMemo(()=>new Map(g.map(ve=>[ve.id,ve])),[g]);v.useEffect(()=>{se.projects.list().then(ve=>y(ve.projects)).catch(()=>{}),se.agents.list().then(ve=>N(ve.agents??[])).catch(()=>{}),se.system.storage().then(ve=>ye(ve.dataDir+"/shared")).catch(()=>{})},[]),v.useEffect(()=>(We.current=setTimeout(()=>R(C),300),()=>clearTimeout(We.current)),[C]);const hn=v.useMemo(()=>({q:T||void 0,projectId:G||void 0,agentId:$||void 0,type:z||void 0,status:Y||void 0,artifactType:M||void 0}),[T,G,$,z,Y,M]),mn=v.useCallback(async()=>{E(!0);try{const{results:ve,total:Xe}=await se.deliverables.search({...hn,offset:0,limit:d});m(ve),f(Xe)}catch{m([]),f(0)}E(!1)},[hn]),On=v.useCallback(async()=>{if(!(p||c.length>=h)){x(!0);try{const{results:ve,total:Xe}=await se.deliverables.search({...hn,offset:c.length,limit:d});m(At=>[...At,...ve]),f(Xe)}catch{}x(!1)}},[hn,c.length,h,p]);v.useEffect(()=>{mn()},[mn]),v.useEffect(()=>an.on("deliverable:created",()=>mn()),[mn]);const Nt=v.useCallback(()=>{const ve=je.current;!ve||S||p||c.length>=h||ve.scrollHeight<=ve.clientHeight+100&&On()},[S,p,c.length,h,On]);v.useEffect(()=>{const ve=je.current;if(!ve)return;const Xe=()=>{ve.scrollTop+ve.clientHeight>=ve.scrollHeight-100&&On()};return ve.addEventListener("scroll",Xe,{passive:!0}),()=>ve.removeEventListener("scroll",Xe)},[On]),v.useEffect(()=>{Nt()},[Nt,te]);const oe=v.useMemo(()=>{const ve=new Map;for(const At of c){let St,xn;if(A==="project")St=At.projectId??"_none",xn=At.projectId?nn.get(At.projectId)?.name??At.projectId:"No Project";else if(A==="agent")St=At.agentId??"_none",xn=At.agentId?tn.get(At.agentId)?.name??At.agentId:"Unknown";else if(A==="type")St=At.type,xn=At.type.charAt(0).toUpperCase()+At.type.slice(1);else{const Qn=new Date(At.updatedAt);St=`${Qn.getFullYear()}-${String(Qn.getMonth()+1).padStart(2,"0")}-${String(Qn.getDate()).padStart(2,"0")}`,xn=St}ve.has(St)||ve.set(St,{label:xn,items:[]}),ve.get(St).items.push(At)}const Xe=[...ve.entries()];return A==="date"?Xe.sort((At,St)=>St[0].localeCompare(At[0])):Xe.sort((At,St)=>At[1].label.localeCompare(St[1].label)),Xe},[c,A,nn,tn]),Ve=async()=>{if(!(!Re.trim()||!ot.trim())){ee(!0);try{await se.deliverables.create({type:Te,title:Re,summary:ot,reference:jt,projectId:Ee||void 0,tags:yt.split(",").map(ve=>ve.trim()).filter(Boolean)}),V(!1),He("success","Deliverable created"),mn()}catch(ve){He("error",`Error: ${ve}`)}ee(!1)}},ze=async ve=>{I("verify");try{await se.deliverables.verify(ve.id),He("success","Verified"),Z({...ve,status:"verified"}),mn()}catch(Xe){He("error",`Error: ${Xe}`)}I("")},dt=async ve=>{I("flag");try{await se.deliverables.update(ve.id,{status:"outdated"}),He("success","Flagged as outdated"),Z({...ve,status:"outdated"}),mn()}catch(Xe){He("error",`Error: ${Xe}`)}I("")},it=async ve=>{I("remove");try{await se.deliverables.remove(ve.id),He("success","Removed"),Z(null),mn()}catch(Xe){He("error",`Error: ${Xe}`)}I("")},xt=()=>{pt.navigate(xe.BUILDER)},$t=async ve=>{if(ve.reference){if(ve.type==="directory"){zt(!0);return}Zt(!0);try{const Xe=await se.files.preview(ve.reference);Xe.type==="image"&&Xe.mimeType?at({src:`data:${Xe.mimeType};base64,${Xe.content}`,name:Xe.name}):Le(Xe.content)}catch{Le(null),ve.type==="file"&&zt(!0)}Zt(!1)}};v.useEffect(()=>{Le(null),at(null),zt(!1),_t(!1),D&&$t(D)},[D?.id]),v.useEffect(()=>{if(!Mt)return;const ve=Xe=>{Tn.current&&!Tn.current.contains(Xe.target)&&_t(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[Mt]);const Je=async(ve,Xe)=>{const At=Ht.current?.firstElementChild;if(!At)return;const St=rz(At,ve);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([St],{type:"text/html"}),"text/plain":new Blob([Xe],{type:"text/plain"})})]),He("success",ve==="light"?"HTML (light) copied":"HTML (dark) copied")}catch{const xn=await wt(Xe);He(xn?"success":"error",xn?"Text copied (HTML not supported)":"Copy failed")}_t(!1)},Fe=ve=>t.jsxs("div",{className:"relative group/preview",children:[t.jsxs("div",{className:"absolute -top-1 -right-1 z-10",ref:Tn,children:[t.jsx("button",{onClick:()=>_t(Xe=>!Xe),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"})})}),Mt&&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 Xe=await wt(ve);He(Xe?"success":"error",Xe?"Markdown source copied":"Copy failed"),_t(!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:()=>Je("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:()=>Je("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:Ht,children:t.jsx(tr,{content:ve,className:"text-fg-secondary text-sm"})})]}),Et=v.useCallback(ve=>{ae(Xe=>{const At=new Set(Xe);return At.has(ve)?At.delete(ve):At.add(ve),At})},[]),Rn=v.useCallback(()=>{te.size===oe.length?ae(new Set):ae(new Set(oe.map(([ve])=>ve)))},[te.size,oe]),Nn=()=>{Ge(""),st(""),re(""),Dt(""),Ce("file"),g.length>0&&Ze(g[0].id),V(!0)},ln=ve=>{Z(ve),e&&(i(!0),history.pushState({mobileDetail:xe.DELIVERABLES},"",window.location.hash))};return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${e?"flex-1 min-w-0":"shrink-0"} border-r border-border-default flex flex-col bg-surface-primary`,style:e?s?{display:"none"}:void 0:{width:n.width},children:[t.jsxs("div",{className:"p-4 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary",children:["Deliverables",h>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",h,")"]})]}),t.jsx("button",{onClick:Nn,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=>k(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"}),wn&&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:wn}),t.jsx("button",{onClick:()=>{se.system.openPath(wn)},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(Da,{label:"All types",value:"",current:z||M||"",onClick:()=>{U(""),L("")}}),u1.map(ve=>t.jsx(Da,{label:`${yo[ve]?.icon??""} ${ve}`,value:ve,current:z,onClick:Xe=>{U(Xe),L("")}},ve)),["agent","team","skill"].map(ve=>t.jsx(Da,{label:`${ws[ve].icon} ${ws[ve].label}`,value:ve,current:M,onClick:Xe=>{L(Xe),U("")}},ve))]}),g.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Da,{label:"All projects",value:"",current:G,onClick:W}),g.map(ve=>t.jsx(Da,{label:ve.name,value:ve.id,current:G,onClick:W},ve.id))]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(Da,{label:"Active",value:"",current:Y,onClick:P}),t.jsx(Da,{label:"Verified",value:"verified",current:Y,onClick:P}),t.jsx(Da,{label:"Outdated",value:"outdated",current:Y,onClick:P})]}),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:()=>{O(ve),ae(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)),oe.length>1&&t.jsx("button",{onClick:Rn,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:te.size===oe.length?"Expand all":"Collapse all",children:te.size===oe.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:je,className:"flex-1 overflow-y-auto p-2 space-y-1",onTouchStart:e?Ie.onTouchStart:void 0,onTouchEnd:e?Ie.onTouchEnd:void 0,children:[S?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))}):c.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[t.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),t.jsx("p",{className:"text-sm text-fg-secondary",children:"No deliverables yet"}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:"Deliverables are created when tasks complete or manually"}),t.jsx("button",{onClick:Nn,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create first"})]}):oe.map(([ve,Xe])=>{const At=te.has(ve);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>Et(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 ${At?"":"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:Xe.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",Xe.items.length,")"]})]}),!At&&Xe.items.map(St=>t.jsxs("button",{onClick:()=>ln(St),className:`w-full text-left p-3 rounded-lg transition-colors ${D?.id===St.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:St.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[St.artifactType&&ws[St.artifactType]?t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${ws[St.artifactType].color}`,children:[ws[St.artifactType].icon," ",ws[St.artifactType].label]}):t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium uppercase ${yo[St.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:St.type}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${d1[St.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:St.status}),St.agentId&&t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:tn.get(St.agentId)?.name??"Agent"})]})]},St.id))]},ve)}),p&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(om,{})," ",t.jsx("span",{className:"text-[10px]",children:"Loading more..."})]}),!S&&c.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:c.length<h?`${c.length} / ${h} deliverables`:`${h} deliverables`})]})]}),!e&&t.jsx("div",{className:"w-1 shrink-0 cursor-col-resize hover:bg-brand-500/30 active:bg-brand-500/50 transition-colors",onMouseDown:n.onResizeStart}),(!e||s)&&t.jsxs("div",{className:"flex-1 overflow-y-auto min-w-0",children:[e&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary border-b border-border-default px-4 py-2.5 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"text-sm font-medium truncate",children:D?.title??"Details"})]}),D?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:D.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[D.status!=="verified"&&t.jsx("button",{onClick:()=>ze(D),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-green-600/20 text-green-600 hover:bg-green-600/30 disabled:opacity-50 transition-colors",children:X==="verify"?"Verifying...":"Verify"}),D.status!=="outdated"&&t.jsx("button",{onClick:()=>dt(D),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-amber-600/20 text-amber-600 hover:bg-amber-600/30 disabled:opacity-50 transition-colors",children:X==="flag"?"Flagging...":"Flag Outdated"}),t.jsx("button",{onClick:()=>it(D),disabled:!!X,className:"px-3 py-1.5 text-xs rounded-lg bg-red-600/20 text-red-500 hover:bg-red-600/30 disabled:opacity-50 transition-colors",children:X==="remove"?"Removing...":"Remove"})]}),t.jsxs("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${yo[D.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[yo[D.type]?.icon??""," ",D.type]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${d1[D.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:D.status}),D.artifactType&&ws[D.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${ws[D.artifactType].color}`,children:[ws[D.artifactType].icon," Builder ",ws[D.artifactType].label]})]}),D.reference&&(D.type==="file"||D.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:()=>{se.files.reveal(D.reference).catch(()=>He("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:D.reference}),t.jsx("button",{onClick:()=>{se.files.reveal(D.reference).catch(()=>He("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:()=>Tt(D.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Ct?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:"Copy path to clipboard",children:Ct?"Copied!":"Copy"})]}),D.reference&&D.type!=="file"&&D.type!=="directory"&&t.jsx("div",{className:"mt-2",children:t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:D.reference})})]}),D.artifactType&&D.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(nz,{artifact:D.artifactData,mode:D.artifactType})}),D.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:D.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:xt,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"})}),D.summary&&t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(tr,{content:D.summary,className:"text-fg-secondary text-sm"})})]}):t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:rt?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(om,{})," Loading preview..."]}):Ue?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Ue.src,alt:Ue.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Ue.name})]}):we?Fe(we):fn?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-fg-secondary",children:["This ",D.type," cannot be previewed in the browser."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{se.files.reveal(D.reference).catch(()=>He("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:D.reference}),t.jsx("button",{onClick:()=>{se.files.reveal(D.reference).catch(()=>He("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:()=>Tt(D.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Ct?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:Ct?"Copied!":"Copy"})]})]}):D.summary?Fe(D.summary):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No content"})}),(D.diffStats||D.testResults)&&t.jsxs("div",{className:"flex gap-4 flex-wrap",children:[D.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:[D.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-600",children:["+",D.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",D.diffStats.deletions]})]})]}),D.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:[D.testResults.passed," passed"]}),t.jsxs("span",{className:"text-red-500",children:[D.testResults.failed," failed"]}),t.jsxs("span",{className:"text-fg-secondary",children:[D.testResults.skipped," skipped"]})]})]})]}),D.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:D.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:[D.taskId&&t.jsxs("button",{onClick:()=>pt.navigate(xe.WORK,{openTask:D.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2.5 py-1 rounded",children:["Task: ",D.taskId.slice(0,12),"..."]}),D.agentId&&t.jsxs("button",{onClick:()=>pt.navigate(xe.TEAM,{selectAgent:D.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Agent: ",tn.get(D.agentId)?.name??D.agentId.slice(0,12)]}),D.projectId&&t.jsxs("button",{onClick:()=>pt.navigate(xe.WORK,{projectId:D.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Project: ",nn.get(D.projectId)?.name??D.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(D.createdAt).toLocaleString()})]}),t.jsxs("span",{children:["Updated: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(D.updatedAt).toLocaleString()})]}),t.jsxs("span",{children:["Accessed: ",t.jsxs("span",{className:"text-fg-secondary",children:[D.accessCount,"x"]})]})]}),t.jsxs("div",{className:"text-fg-muted select-all",children:["ID: ",D.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"})]})})]}),_&&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:Te,onChange:ve=>Ce(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:u1.map(ve=>t.jsxs("option",{value:ve,children:[yo[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:Re,onChange:ve=>Ge(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:jt,onChange:ve=>re(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:ot,onChange:ve=>st(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:yt,onChange:ve=>Dt(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:Ee,onChange:ve=>Ze(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"}),g.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:Ve,disabled:Q||!Re.trim()||!ot.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(om,{}),Q?"Creating...":"Create"]})]})]})})]})}function rz(e,n){const s=e.cloneNode(!0),i=n==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},o={p:`margin:0 0 10px;color:${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 d(c){c.removeAttribute("class");const m=c.tagName.toLowerCase();if(m==="pre"){c.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 h=c.querySelector("code");h&&(h.removeAttribute("class"),h.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}m==="code"?c.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[m]&&c.setAttribute("style",o[m]),Array.from(c.children).forEach(d)}return s.removeAttribute("class"),Array.from(s.children).forEach(c=>d(c)),`<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 Da({label:e,value:n,current:s,onClick:i}){return t.jsx("button",{onClick:()=>i(s===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${s===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function om(){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 Ws(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function sl(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function sz(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 IN({authUser:e}){const[n,s]=v.useState("weekly"),[i,o]=v.useState(null),[d,c]=v.useState(!0),[m,h]=v.useState(""),[f,p]=v.useState(null),[x,g]=v.useState([]),[y,w]=v.useState("totalTokens"),[N,S]=v.useState(!0),[E,C]=v.useState("generate"),[k,T]=v.useState([]),[R,z]=v.useState(null),[U,G]=v.useState([]),[W,$]=v.useState(""),[F,Y]=v.useState(""),P=_=>{Y(_),setTimeout(()=>Y(""),3e3)},M=v.useCallback(async _=>{c(!0),h("");try{const{report:V}=await se.reports.generate({period:_,scope:"org",orgId:"default"});o(V)}catch(V){h(String(V)),o(null)}c(!1)},[]),L=v.useCallback(()=>{se.usage.summary().then(_=>p(_.usage)).catch(()=>{}),se.usage.agents().then(_=>g(_.agents)).catch(()=>{})},[]),A=v.useCallback(async()=>{try{const{reports:_}=await se.reports.list();T(_)}catch{}},[]),O=v.useCallback(async _=>{z(_);try{const{feedback:V}=await se.reports.getFeedback(_.id);G(V)}catch{G([])}},[]);v.useEffect(()=>{M(n)},[n,M]),v.useEffect(()=>{L();const _=setInterval(L,3e4);return()=>clearInterval(_)},[L]),v.useEffect(()=>{E==="history"&&A()},[E,A]);const D=v.useMemo(()=>[...x].sort((_,V)=>{const Q=_[y],ee=V[y];return N?ee-Q:Q-ee}),[x,y,N]),Z=x.reduce((_,V)=>_+V.estimatedCost,0),B=x.reduce((_,V)=>_+V.tokensUsedToday,0),q=Math.max(1,...x.map(_=>_.totalTokens)),X=_=>{y===_?S(!N):(w(_),S(!0))},I={daily:"Today",weekly:"This Week",monthly:"This Month"};return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl p-6 space-y-6",children:[t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:"Reports"}),t.jsxs("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[t.jsx("button",{onClick:()=>C("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${E==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Generate"}),t.jsxs("button",{onClick:()=>C("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${E==="history"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:["History",k.length>0?` (${k.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[F&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:F}),E==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(_=>t.jsx("button",{onClick:()=>s(_),className:`px-3 py-1.5 text-xs rounded-md transition-colors capitalize ${n===_?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:_},_))})]})]}),E==="history"&&!R&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:k.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:"No reports generated yet. Use the Generate tab to create one."}):t.jsx("div",{className:"divide-y divide-border-default/50",children:k.map(_=>t.jsxs("button",{onClick:()=>O(_),className:"w-full text-left px-5 py-3 flex items-center gap-4 hover:bg-surface-elevated/30 transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm font-medium text-fg-primary",children:[_.type," Report"]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(_.periodStart).toLocaleDateString()," — ",new Date(_.periodEnd).toLocaleDateString()]})]}),_.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${_.plan.status==="approved"?"bg-green-500/10 text-green-600":_.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:_.plan.status==="pending"?"Plan pending":`Plan ${_.plan.status}`}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(_.generatedAt).toLocaleDateString()})]},_.id))})}),E==="history"&&R&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{z(null),G([])},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"← Back to list"}),t.jsxs("span",{className:"text-sm font-medium text-fg-primary",children:[R.type," Report"]}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(R.periodStart).toLocaleDateString()," — ",new Date(R.periodEnd).toLocaleDateString()]})]}),R.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Ns,{label:"Completed",value:R.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Ns,{label:"In Progress",value:R.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Ns,{label:"Created",value:R.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Ns,{label:"Blocked",value:R.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Ns,{label:"Failed",value:R.metrics.tasksFailed,color:"text-red-500"})]})]}),R.costSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Cost Overview"}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:R.costSummary.totalTokens.toLocaleString()}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Total Tokens"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:sl(R.costSummary.totalEstimatedCost)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Estimated Cost"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:`text-2xl font-bold ${R.costSummary.trend==="decreasing"?"text-green-600":R.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[R.costSummary.trend==="decreasing"?"↓":R.costSummary.trend==="increasing"?"↑":"→"," ",R.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Trend"})]})]}),R.costSummary.byAgent&&R.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:R.costSummary.byAgent.map((_,V)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:_.agentId}),t.jsxs("span",{className:"text-fg-tertiary tabular-nums",children:[Ws(_.tokens)," tokens · ",sl(_.cost)]})]},V))})]}),R.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 overflow-hidden",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4 min-w-0",children:[R.taskSummary.completed.length>0&&t.jsx(tl,{title:`Completed (${R.taskSummary.completed.length})`,color:"emerald",items:R.taskSummary.completed.map(_=>({id:_.id,label:_.title,sub:_.agent}))}),R.taskSummary.inProgress.length>0&&t.jsx(tl,{title:`In Progress (${R.taskSummary.inProgress.length})`,color:"indigo",items:R.taskSummary.inProgress.map(_=>({id:_.id,label:_.title,sub:_.agent}))}),R.taskSummary.blocked.length>0&&t.jsx(tl,{title:`Blocked (${R.taskSummary.blocked.length})`,color:"amber",items:R.taskSummary.blocked.map(_=>({id:_.id,label:_.title,sub:_.reason||_.agent}))}),R.taskSummary.completed.length===0&&R.taskSummary.inProgress.length===0&&R.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]}),R.highlights&&R.highlights.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-2",children:"Highlights"}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:R.highlights.map((_,V)=>t.jsx("li",{children:_},V))})]}),R.blockers&&R.blockers.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-amber-500/20 rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-amber-600 mb-2",children:"Blockers"}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:R.blockers.map((_,V)=>t.jsx("li",{children:_},V))})]}),R.plan&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary",children:["Upcoming Plan",t.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${R.plan.status==="approved"?"bg-green-500/10 text-green-600":R.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:R.plan.status})]}),R.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:_}=await se.reports.approvePlan(R.id,{approvedBy:e?.id??"admin"});z(_),P("Plan approved"),A()}catch(_){P(`Error: ${_}`)}},className:"px-3 py-1.5 text-xs font-medium bg-green-600 text-white rounded-lg hover:bg-green-500 transition-colors",children:"Approve Plan"}),t.jsx("button",{onClick:async()=>{const _=prompt("Rejection reason:");if(_)try{const{report:V}=await se.reports.rejectPlan(R.id,{rejectedBy:e?.id??"admin",reason:_});z(V),P("Plan rejected"),A()}catch(V){P(`Error: ${V}`)}},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-lg hover:bg-surface-overlay transition-colors",children:"Reject Plan"})]})]}),R.plan.items&&R.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:R.plan.items.map((_,V)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-secondary",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${_.priority==="high"?"bg-red-500/10 text-red-500":_.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:_.priority}),t.jsx("span",{children:_.title}),_.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:_.assignee})]},V))})]}),!R.metrics&&!R.taskSummary&&!R.costSummary&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:"This report does not contain detailed metrics data."})}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Feedback (",U.length,")"]}),U.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:U.map(_=>t.jsxs("div",{className:"p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary mb-1",children:[t.jsx("span",{className:"font-medium text-fg-secondary",children:_.authorName}),t.jsx("span",{children:_.type}),t.jsx("span",{children:new Date(_.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:_.content})]},_.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:W,onChange:_=>$(_.target.value),placeholder:"Add feedback or instructions…",className:"flex-1 px-3 py-2 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary",onKeyDown:_=>{_.key==="Enter"&&W.trim()&&se.reports.addFeedback(R.id,{author:e?.id??"admin",type:"comment",content:W.trim()}).then(({feedback:V})=>{G(Q=>[...Q,V]),$(""),P("Feedback added")}).catch(V=>P(`Error: ${V}`))}}),t.jsx("button",{onClick:()=>{W.trim()&&se.reports.addFeedback(R.id,{author:e?.id??"admin",type:"comment",content:W.trim()}).then(({feedback:_})=>{G(V=>[...V,_]),$(""),P("Feedback added")}).catch(_=>P(`Error: ${_}`))},disabled:!W.trim(),className:"px-3 py-2 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Send"})]})]})]}),E==="generate"&&f&&t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(wd,{label:"LLM Tokens (this month)",value:Ws(f.llmTokens),color:"text-brand-500"}),t.jsx(wd,{label:"Tool Calls (today)",value:Ws(f.toolCalls),color:"text-blue-600"}),t.jsx(wd,{label:"Messages (today)",value:Ws(f.messages),color:"text-green-600"}),t.jsx(wd,{label:"Storage",value:sz(f.storageBytes),color:"text-amber-600"})]}),E==="generate"&&(d?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:"Loading…"}):m?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:m}):i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I[n]," · ",new Date(i.periodStart).toLocaleDateString()," — ",new Date(i.periodEnd).toLocaleDateString()]}),i.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Ns,{label:"Completed",value:i.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Ns,{label:"In Progress",value:i.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Ns,{label:"Created",value:i.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Ns,{label:"Blocked",value:i.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Ns,{label:"Failed",value:i.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:sl(Z)}),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:Ws(B)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Tokens Today"})]}),i.costSummary&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:i.costSummary.totalTokens.toLocaleString()}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Tokens (",I[n],")"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:sl(i.costSummary.totalEstimatedCost)}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Cost (",I[n],")"]})]})]})]})]}),i.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:[i.taskSummary.completed.length>0&&t.jsx(tl,{title:`Completed (${i.taskSummary.completed.length})`,color:"emerald",items:i.taskSummary.completed.map(_=>({id:_.id,label:_.title,sub:_.agent}))}),i.taskSummary.inProgress.length>0&&t.jsx(tl,{title:`In Progress (${i.taskSummary.inProgress.length})`,color:"indigo",items:i.taskSummary.inProgress.map(_=>({id:_.id,label:_.title,sub:_.agent}))}),i.taskSummary.blocked.length>0&&t.jsx(tl,{title:`Blocked (${i.taskSummary.blocked.length})`,color:"amber",items:i.taskSummary.blocked.map(_=>({id:_.id,label:_.title,sub:_.reason||_.agent}))}),i.taskSummary.completed.length===0&&i.taskSummary.inProgress.length===0&&i.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]})]}):null),E==="generate"&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"Per-Agent Usage"})}),x.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:"No agent usage data yet."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium",children:"Agent"}),t.jsx(vo,{label:"Total Tokens",col:"totalTokens",current:y,desc:N,onSort:X}),t.jsx(vo,{label:"Today",col:"tokensUsedToday",current:y,desc:N,onSort:X}),t.jsx(vo,{label:"Requests",col:"requestCount",current:y,desc:N,onSort:X}),t.jsx(vo,{label:"Tool Calls",col:"toolCalls",current:y,desc:N,onSort:X}),t.jsx(vo,{label:"Est. Cost",col:"estimatedCost",current:y,desc:N,onSort:X,align:"right"})]})}),t.jsx("tbody",{children:D.map(_=>t.jsx(az,{agent:_,maxTokens:q},_.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:Ws(x.reduce((_,V)=>_+V.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Ws(B)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:x.reduce((_,V)=>_+V.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:x.reduce((_,V)=>_+V.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:sl(Z)})]})})]})})]})]})})}function Ns({label:e,value:n,color:s}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${s}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function tl({title:e,color:n,items:s}){return t.jsxs("div",{className:"min-w-0 overflow-hidden",children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1.5",children:s.map((i,o)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${i.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:i.id?()=>pt.navigate(xe.WORK,{openTask:i.id}):void 0,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate min-w-0 ${i.id?"group-hover:text-brand-500 transition-colors":""}`,children:i.label})]}),i.sub&&i.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:i.sub})]},i.id??o))})]})}function wd({label:e,value:n,color:s}){return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary mb-2",children:e}),t.jsx("div",{className:`text-2xl font-bold ${s}`,children:n})]})}function vo({label:e,col:n,current:s,desc:i,onSort:o,align:d}){const c=s===n?i?"↓":"↑":"↕",m=s===n?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${d==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>o(n),children:[e,t.jsx("span",{className:`ml-1 ${m}`,children:c})]})}function az({agent:e,maxTokens:n}){const s=n>0?Math.min(100,e.totalTokens/n*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:()=>pt.navigate(xe.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:Ws(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:Ws(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:sl(e.estimatedCost)})]})}function jo({d:e,size:n=18}){return t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:e})})}const iz={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"},h1=5;function lz({currentPage:e,onNavigate:n,authUser:s,onLogout:i,collapsed:o,onToggleCollapse:d}){const[c,m]=v.useState([]),[h,f]=v.useState(!1),[p,x]=v.useState(null),[g,y]=v.useState(!1),w=v.useCallback(()=>{se.projects.list().then(C=>m(C.projects)).catch(()=>{})},[]);v.useEffect(()=>{w();const C=setInterval(w,3e4);return()=>clearInterval(C)},[w]),v.useEffect(()=>{if(e!==xe.WORK){x(null);return}const k=window.location.hash.slice(1).split("/");Qs(k[0])===xe.WORK&&k[1]&&x(k[1])},[e]);const N=async()=>{try{await se.auth.logout()}catch{}i?.()},S=h?c:c.slice(0,h1),E=c.length>h1;return t.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden border-r border-border-subtle",children:[t.jsx("div",{className:`flex items-center ${o?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:o?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("button",{onClick:d,title:"Expand sidebar",className:"group",children:t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg group-hover:ring-2 group-hover:ring-brand-500/40 transition-all"})}),t.jsx(hm,{collapsed:!0,userId:s?.id})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:d,className:"flex items-center gap-2.5 min-w-0 group",title:"Collapse sidebar",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shadow-md shadow-black/30 shrink-0 group-hover:ring-2 group-hover:ring-brand-500/40 transition-all"}),t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(hm,{userId:s?.id}),t.jsx("button",{onClick:d,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1 rounded-md hover:bg-surface-overlay",title:"Collapse sidebar",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"11 17 6 12 11 7"}),t.jsx("polyline",{points:"18 17 13 12 18 7"})]})})]})]})}),t.jsx("nav",{className:`${o?"p-1.5":"p-3"} flex-1 overflow-y-auto`,children:Q2.map((C,k)=>t.jsx("div",{children:t.jsxs("div",{className:"mb-3",children:[!o&&t.jsx("div",{className:"px-3 py-1.5 text-[11px] font-semibold text-fg-tertiary uppercase tracking-widest",children:C.label}),o&&k>0&&t.jsx("div",{className:"my-2 mx-1"}),J2.filter(T=>T.section===C.key&&!(C.key==="workspace"&&T.id===xe.DELIVERABLES)).map(T=>{const R=e===T.id;return t.jsxs("button",{onClick:()=>n(T.id),title:o?T.label:void 0,className:`w-full flex items-center ${o?"justify-center px-2 py-2":"gap-3 px-3 py-2"} rounded-lg text-sm mb-0.5 transition-all ${R?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":"text-fg-primary hover:bg-surface-overlay"}`,children:[t.jsx(jo,{d:nl[T.id]??""}),!o&&T.label]},T.id)}),C.key==="workspace"&&o&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{x(null),n(xe.WORK)},title:"Work",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-all ${e===xe.WORK&&!p?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":e===xe.WORK?"bg-brand-600/15 text-fg-primary":"text-fg-primary hover:bg-surface-overlay"}`,children:t.jsx(jo,{d:nl[xe.WORK]})}),t.jsx("button",{onClick:()=>n(xe.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===xe.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(jo,{d:nl[xe.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:()=>{x(null),n(xe.WORK)},className:`flex-1 flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${e===xe.WORK&&!p?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(jo,{d:nl[xe.WORK]}),"Work"]}),t.jsx("button",{onClick:()=>y(!0),className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1.5 rounded hover:bg-surface-elevated shrink-0",title:"New Project",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),c.length===0&&t.jsxs("button",{onClick:()=>y(!0),className:"w-full flex items-center gap-2 pl-9 pr-3 py-1.5 text-xs text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50 rounded-lg transition-colors",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create your first project"]}),S.map(T=>{const R=e===xe.WORK&&p===T.id;return t.jsxs("button",{onClick:()=>{x(T.id),e!==xe.WORK&&n(xe.WORK),window.location.hash=dm(xe.WORK,T.id).slice(1)},className:`w-full flex items-center gap-2.5 pl-9 pr-3 py-1.5 rounded-lg text-sm mb-0.5 transition-colors ${R?"bg-brand-600 text-white":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${iz[T.status]??"bg-gray-600"}`}),t.jsx("span",{className:"truncate text-xs",children:T.name})]},T.id)}),E&&!h&&t.jsxs("button",{onClick:()=>f(!0),className:"w-full pl-9 pr-3 py-1 text-[11px] text-fg-tertiary hover:text-fg-secondary transition-colors text-left",children:["Show all ",c.length," projects..."]}),t.jsxs("button",{onClick:()=>n(xe.DELIVERABLES),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===xe.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(jo,{d:nl[xe.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:N,title:`${s.name??s.email} — Sign out`,className:"w-7 h-7 rounded-full bg-brand-600 flex items-center justify-center text-white text-xs font-bold shrink-0 hover:ring-2 hover:ring-brand-500/50 transition-all",children:s.name?.[0]?.toUpperCase()??"A"}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-600 flex items-center justify-center text-white text-xs font-bold shrink-0",children:s.name?.[0]?.toUpperCase()??"A"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-secondary truncate",children:s.name??s.email}),t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate",children:s.email??s.role?.[0]?.toUpperCase()+s.role?.slice(1)})]}),t.jsx("button",{onClick:N,title:"Sign out",className:"text-fg-tertiary hover:text-fg-secondary transition-colors text-sm",children:"⇥"})]})),!o&&t.jsxs("div",{className:"text-[10px] text-fg-muted",children:["v","0.4.16"]})]}),g&&t.jsx(MN,{orgId:s?.orgId,onCreated:()=>{y(!1),w()},onClose:()=>y(!1)})]})}function oz({currentPage:e,onNavigate:n}){return t.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary border-t border-border-default flex items-stretch h-14 safe-area-bottom",children:ek.map(s=>{const i=s.group.includes(e);return t.jsxs("button",{onClick:()=>n(s.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${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:nl[s.id]})}),t.jsx("span",{className:`text-[10px] leading-tight ${i?"font-semibold":""}`,children:s.label})]},s.id)})})}const m1=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function cz({authUser:e}){const[n,s]=v.useState("builder"),i=ea(m1,n,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:m1.map(o=>t.jsx("button",{onClick:()=>s(o.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${n===o.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:o.label},o.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="builder"&&t.jsx(qj,{}),n==="agents"&&t.jsx(Mm,{authUser:e}),n==="teams"&&t.jsx(Om,{}),n==="skills"&&t.jsx(Rm,{})]})]})}const x1=[{id:"settings",label:"Settings"},{id:"reports",label:"Reports"}];function dz({theme:e,onThemeChange:n}){const[s,i]=v.useState("settings"),o=ea(x1,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:x1.map(d=>t.jsx("button",{onClick:()=>i(d.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===d.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:d.label},d.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="settings"&&t.jsx($j,{theme:e,onThemeChange:n}),s==="reports"&&t.jsx(IN,{})]})]})}const p1=2;function uz({onComplete:e,theme:n,onThemeChange:s}){const[i,o]=v.useState(0),[d,c]=v.useState(null),[m,h]=v.useState(!1),[f,p]=v.useState({}),[x,g]=v.useState(!1),[y,w]=v.useState(null),[N,S]=v.useState(!1),[E,C]=v.useState(!1),[k,T]=v.useState(null),R=v.useRef(!1),z=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`});v.useEffect(()=>{fetch("/api/settings/llm").then(L=>L.ok?L.json():null).then(L=>{L?.providers&&Object.values(L.providers).some(A=>A.configured)&&C(!0)}).catch(()=>{})},[]),v.useEffect(()=>{i===p1&&!R.current&&!E&&(R.current=!0,U())},[i,E]);const U=async()=>{h(!0);try{const L=await fetch("/api/settings/env-models",{headers:z()});if(L.ok){const A=await L.json();if(c(A),A.detected.length>0){const O={};for(const D of A.detected)O[D.provider]=!0;p(O)}}}catch{}finally{h(!1)}},G=async()=>{if(!d)return;const L=d.detected.filter(A=>f[A.provider]);if(L.length!==0){g(!0),T(null);try{const A=await fetch("/api/settings/env-models",{method:"POST",headers:z(),body:JSON.stringify({providers:L.map(O=>({provider:O.provider,model:O.model,baseUrl:O.baseUrl,enabled:!0}))})});if(A.ok){const O=await A.json();T({type:"ok",text:O.message}),C(!0)}else T({type:"err",text:"Failed to apply"})}catch{T({type:"err",text:"Network error"})}finally{g(!1)}}},W=async()=>{S(!0);try{const A=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:z(),body:JSON.stringify({preview:!0})})).json();"error"in A||w(A)}catch{}finally{S(!1)}},$=async()=>{S(!0),T(null);try{const A=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:z(),body:JSON.stringify({preview:!1})})).json();"error"in A?T({type:"err",text:A.error}):(T({type:"ok",text:`Imported ${A.appliedModels} model configs`}),C(!0))}catch{T({type:"err",text:"Import failed"})}finally{S(!1)}},F=[{value:"system",label:"System",icon:"💻",desc:"Follow your OS setting"},{value:"light",label:"Light",icon:"☀️",desc:"Always light background"},{value:"dark",label:"Dark",icon:"🌙",desc:"Always dark background"},{value:"cyberpunk",label:"Cyberpunk",icon:"🔮",desc:"Neon pink, dark violet"},{value:"midnight",label:"Midnight",icon:"🌊",desc:"Deep ocean, teal accents"}],Y=[{title:"Welcome to Markus",subtitle:"Your AI workforce, ready in minutes",content:t.jsxs("div",{className:"space-y-4 text-fg-secondary text-sm leading-relaxed",children:[t.jsxs("p",{children:["Markus runs ",t.jsx("strong",{className:"text-fg-primary",children:"complete AI teams"})," — developers, researchers, writers, analysts that work autonomously, collaborate with each other, and deliver results around the clock."]}),t.jsx("div",{className:"grid grid-cols-2 gap-3 mt-6",children:[["24/7 Operation","Agents work while you sleep via heartbeat"],["Team Collaboration","Agents delegate, review, and coordinate"],["Persistent Memory","Five memory layers survive restarts"],["Any LLM Provider","Anthropic, OpenAI, Google, Ollama & more"]].map(([L,A])=>t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:L}),t.jsx("div",{className:"text-fg-secondary text-xs mt-1",children:A})]},L))})]})},{title:"Choose Your Theme",subtitle:"You can change this anytime in Settings",content:t.jsx("div",{className:"grid grid-cols-3 gap-3",children:F.map(L=>t.jsxs("button",{onClick:()=>s(L.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===L.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:L.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:L.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:L.desc})]},L.value))})},{title:"Configure LLM",subtitle:"Agents need an LLM to think and act",content: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"}),m&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse",children:"Detecting API keys..."}),d&&d.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[d.detected.map(L=>t.jsxs("label",{className:"flex items-center gap-3 bg-surface-elevated/40 rounded-lg px-3 py-2.5 cursor-pointer hover:bg-surface-elevated/60 transition-colors",children:[t.jsx("input",{type:"checkbox",checked:f[L.provider]??!1,onChange:A=>p({...f,[L.provider]:A.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:L.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:L.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:L.apiKeyPreview})]},L.provider)),t.jsx("button",{onClick:()=>{G()},disabled:x||Object.values(f).filter(Boolean).length===0,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:x?"Applying...":`Apply ${Object.values(f).filter(Boolean).length} Provider(s)`})]}),d&&d.detected.length===0&&!m&&t.jsxs("div",{className:"text-xs text-fg-tertiary bg-surface-elevated/30 rounded-lg p-3",children:["No API keys found. Set ",t.jsx("code",{className:"text-fg-secondary",children:"ANTHROPIC_API_KEY"}),", ",t.jsx("code",{className:"text-fg-secondary",children:"OPENAI_API_KEY"}),", etc. in your ",t.jsx("code",{className:"text-fg-secondary",children:".env"})," file and restart."]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 h-px bg-border-default"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:"or"}),t.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary uppercase tracking-wider",children:"From OpenClaw"}),y?y.found?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found: ",t.jsx("code",{className:"text-fg-secondary",children:y.summary.configPath}),y.summary.models&&t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",y.summary.models.providerCount," providers)"]})]}),t.jsx("button",{onClick:()=>{$()},disabled:N,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:N?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary bg-surface-elevated/30 rounded-lg p-3",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{W()},disabled:N,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors w-full",children:N?"Detecting...":"Detect OpenClaw Config"})]}),k&&t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${k.type==="ok"?"bg-green-500/10 text-green-600 border border-green-500/30":"bg-red-500/10 text-red-500 border border-red-500/30"}`,children:k.text})]})},{title:"You're All Set",subtitle:"Start building your AI workforce",content:t.jsx("div",{className:"space-y-2 text-fg-secondary text-sm",children:[["Chat","Talk to agents or use Smart Route to auto-delegate tasks"],["Projects","Create projects with requirements, tasks, and deliverables"],["Builder","Hire new agents from templates or build custom roles"],["Settings","Manage LLM providers, integrations, and governance"]].map(([L,A])=>t.jsxs("div",{className:"flex gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[t.jsx("div",{className:"text-brand-500 mt-0.5 shrink-0",children:"→"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-xs",children:L}),t.jsx("div",{className:"text-fg-secondary text-xs",children:A})]})]},L))})}],P=()=>{i<Y.length-1?o(i+1):e()},M=Y[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:Y.map((L,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:M.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:M.subtitle}),M.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===p1&&!E&&t.jsx("button",{onClick:P,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),t.jsx("button",{onClick:P,className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-xl transition-colors",children:i===Y.length-1?"Get Started":"Next"})]})]})]})})})}const fz="markus123";function hz({onLogin:e}){const[n,s]=v.useState("admin@markus.local"),[i,o]=v.useState(""),[d,c]=v.useState(""),[m,h]=v.useState(!1),f=async p=>{if(p.preventDefault(),!(!n.trim()||!i)){c(""),h(!0);try{const{user:x}=await se.auth.login(n.trim(),i);e(x,i===fz)}catch{c("Invalid email or password")}finally{h(!1)}}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:"AI Digital Employee Platform"})]}),t.jsxs("form",{onSubmit:f,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:"Sign in"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Email"}),t.jsx("input",{type:"email",value:n,onChange:p=>s(p.target.value),autoComplete:"email",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Password"}),t.jsx("input",{type:"password",value:i,onChange:p=>o(p.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),d&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:d}),t.jsx("button",{type:"submit",disabled:m||!n||!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:m?"Signing in…":"Sign in"}),t.jsx("p",{className:"text-center text-xs text-fg-tertiary",children:"Default: admin@markus.local / markus123"})]})]})]})}function mz({onComplete:e,isFirstTime:n}){const[s,i]=v.useState(""),[o,d]=v.useState(""),[c,m]=v.useState(""),[h,f]=v.useState(""),[p,x]=v.useState(!1),g=async y=>{if(y.preventDefault(),f(""),o.length<6){f("Password must be at least 6 characters");return}if(o!==c){f("Passwords do not match");return}x(!0);try{await se.auth.changePassword(s,o),e()}catch{f("Failed to change password. Check your current password.")}finally{x(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:"AI Digital Employee Platform"})]}),t.jsxs("form",{onSubmit:g,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n?"Set Your Password":"Change Password"}),n&&t.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:"You're using the default password. Please set a new one before continuing."})]}),!n&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Current Password"}),t.jsx("input",{type:"password",value:s,onChange:y=>i(y.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"New Password"}),t.jsx("input",{type:"password",value:o,onChange:y=>d(y.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Confirm New Password"}),t.jsx("input",{type:"password",value:c,onChange:y=>m(y.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),h&&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:h}),t.jsx("button",{type:"submit",disabled:p||!o||!c,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:p?"Saving…":n?"Set Password & Continue":"Change Password"})]})]})]})}const cm={};function xz(){const[e,n]=v.useState(ad),[s,i]=v.useState(()=>!localStorage.getItem("markus_onboarded")),[o,d]=v.useState(!0),c=Sr(),m=A_(),h=su({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[f,p]=v.useState(()=>new Set([ad()])),[x,g]=v.useState("loading"),[y,w]=v.useState(!1),[N,S]=v.useState(null),[E,C]=v.useState(!1),k=v.useCallback(U=>{let G=Qs(U);c&&(G=Z2[G]??G);const W=ad(),$=window.location.hash.slice(1);$!==W?cm[W]=$:delete cm[W];const F=G!==xe.WORK?cm[G]:void 0;F&&F!==G?(history.pushState(null,"","#"+G),history.pushState(null,"","#"+F)):history.pushState(null,"","#"+G),window.dispatchEvent(new HashChangeEvent("hashchange")),n(G),p(Y=>Y.has(G)?Y:new Set([...Y,G]))},[c]);v.useEffect(()=>{pt.setHandler(U=>k(U))},[k]);const T=v.useCallback(()=>{fetch("/api/settings/llm").then(U=>U.ok?U.json():null).then(U=>{if(U?.providers){const G=Object.values(U.providers).some(W=>W.configured);S(G)}}).catch(()=>{})},[]);v.useEffect(()=>{se.auth.me().then(({user:W})=>{g(W),T(),li(Nr.builderArtifacts,()=>se.builder.artifacts.list()),li(Nr.builderAgents,()=>se.agents.list()),li(Nr.builderHubMyItems,()=>Fn.myItems()),li(Nr.builderInstalled,()=>se.builder.artifacts.installed()),li(Nr.hubAgents,()=>Fn.search({type:"agent",limit:50})),li(Nr.hubTeams,()=>Fn.search({type:"team",limit:50})),li(Nr.hubSkills,()=>Fn.search({type:"skill",limit:50}))}).catch(()=>g(null)),an.connect();const U=an.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),G=()=>{const W=ad();n(W),p($=>$.has(W)?$:new Set([...$,W]))};return window.addEventListener("hashchange",G),()=>{U(),an.disconnect(),window.removeEventListener("hashchange",G)}},[]);const R=x!=="loading"&&x!==null?x:void 0,z=v.useMemo(()=>c?{[xe.HOME]:t.jsx(Eb,{authUser:R}),[xe.TEAM]:t.jsx(zy,{authUser:R}),[xe.BUILDER]:t.jsx(cz,{authUser:R}),[xe.SETTINGS]:t.jsx(dz,{theme:m.mode,onThemeChange:m.setMode}),[xe.WORK]:t.jsx(c1,{authUser:R}),[xe.DELIVERABLES]:t.jsx(f1,{})}:{[xe.HOME]:t.jsx(Eb,{}),[xe.TEAM]:t.jsx(zy,{authUser:R}),[xe.SETTINGS]:t.jsx($j,{theme:m.mode,onThemeChange:m.setMode}),[xe.STORE]:t.jsx(U_,{authUser:R}),[xe.BUILDER]:t.jsx(qj,{}),[xe.WORK]:t.jsx(c1,{authUser:R}),[xe.DELIVERABLES]:t.jsx(f1,{}),[xe.REPORTS]:t.jsx(IN,{authUser:R})},[R?.id,m.mode,c]);return x==="loading"?t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:"Loading…"})}):x===null?t.jsx(hz,{onLogin:(U,G)=>{g(U),G&&w(!0)}}):y?t.jsx(mz,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(uz,{theme:m.mode,onThemeChange:m.setMode,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),i(!1),T()}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary ${c?"flex-col":""}`,children:[!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:h.width},children:t.jsx(lz,{currentPage:e,onNavigate:U=>{k(U),d(!1)},authUser:x,onLogout:()=>g(null),collapsed:h.collapsed,onToggleCollapse:h.toggle})}),!h.collapsed&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative z-10",onMouseDown:h.onResizeStart,children:t.jsx("div",{className:"absolute inset-y-0 -left-0.5 -right-0.5 group-hover:bg-brand-500/30 group-active:bg-brand-500/50 transition-colors"})})]}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${c?"pb-14":""}`,children:[N===!1&&!E&&e!==xe.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:"No LLM provider configured — agents cannot process requests."}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{k(xe.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(z).map(U=>f.has(U)?t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:{display:U===e?"flex":"none"},children:z[U]},U):null)})]}),c&&t.jsx(oz,{currentPage:e,onNavigate:k})]})}X2.createRoot(document.getElementById("root")).render(t.jsx(v.StrictMode,{children:t.jsx(xz,{})}));