@markus-global/cli 0.4.20 → 0.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/start.js +2 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +1657 -1053
- package/dist/web-ui/assets/index-DEkXd9d7.css +1 -0
- package/dist/web-ui/assets/index-HAWGXtTM.js +66 -0
- package/dist/web-ui/index.html +2 -2
- package/package.json +1 -1
- package/templates/roles/SHARED.md +7 -6
- package/templates/roles/org-manager/HEARTBEAT.md +1 -1
- package/templates/roles/secretary/HEARTBEAT.md +1 -1
- package/templates/skills/agent-building/SKILL.md +5 -5
- package/templates/skills/markitdown/SKILL.md +56 -0
- package/templates/skills/markitdown/skill.json +20 -0
- package/templates/skills/self-evolution/SKILL.md +43 -7
- package/templates/skills/team-building/SKILL.md +4 -5
- package/dist/web-ui/assets/index-Bm8JwOPl.js +0 -66
- package/dist/web-ui/assets/index-CRfXZ2wF.css +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))l(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function s(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(i){if(i.ep)return;i.ep=!0;const c=s(i);fetch(i.href,c)}})();function yu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $m={exports:{}},Eo={};var $b;function ik(){if($b)return Eo;$b=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(l,i,c){var d=null;if(c!==void 0&&(d=""+c),i.key!==void 0&&(d=""+i.key),"key"in i){c={};for(var u in i)u!=="key"&&(c[u]=i[u])}else c=i;return i=c.ref,{$$typeof:e,type:l,key:d,ref:i!==void 0?i:null,props:c}}return Eo.Fragment=n,Eo.jsx=s,Eo.jsxs=s,Eo}var Bb;function ok(){return Bb||(Bb=1,$m.exports=ik()),$m.exports}var t=ok(),Bm={exports:{}},Dt={};var Hb;function ck(){if(Hb)return Dt;Hb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),g=Symbol.iterator;function b(F){return F===null||typeof F!="object"?null:(F=g&&F[g]||F["@@iterator"],typeof F=="function"?F:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,C={};function E(F,K,I){this.props=F,this.context=K,this.refs=C,this.updater=I||w}E.prototype.isReactComponent={},E.prototype.setState=function(F,K){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,K,"setState")},E.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function M(){}M.prototype=E.prototype;function N(F,K,I){this.props=F,this.context=K,this.refs=C,this.updater=I||w}var A=N.prototype=new M;A.constructor=N,k(A,E.prototype),A.isPureReactComponent=!0;var R=Array.isArray;function _(){}var Y={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function X(F,K,I){var S=I.ref;return{$$typeof:e,type:F,key:K,ref:S!==void 0?S:null,props:I}}function L(F,K){return X(F.type,K,F.props)}function P(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function G(F){var K={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(I){return K[I]})}var $=/\/+/g;function T(F,K){return typeof F=="object"&&F!==null&&F.key!=null?G(""+F.key):K.toString(36)}function z(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(_,_):(F.status="pending",F.then(function(K){F.status==="pending"&&(F.status="fulfilled",F.value=K)},function(K){F.status==="pending"&&(F.status="rejected",F.reason=K)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function O(F,K,I,S,D){var W=typeof F;(W==="undefined"||W==="boolean")&&(F=null);var J=!1;if(F===null)J=!0;else switch(W){case"bigint":case"string":case"number":J=!0;break;case"object":switch(F.$$typeof){case e:case n:J=!0;break;case x:return J=F._init,O(J(F._payload),K,I,S,D)}}if(J)return D=D(F),J=S===""?"."+T(F,0):S,R(D)?(I="",J!=null&&(I=J.replace($,"$&/")+"/"),O(D,K,I,"",function(oe){return oe})):D!=null&&(P(D)&&(D=L(D,I+(D.key==null||F&&F.key===D.key?"":(""+D.key).replace($,"$&/")+"/")+J)),K.push(D)),1;J=0;var te=S===""?".":S+":";if(R(F))for(var re=0;re<F.length;re++)S=F[re],W=te+T(S,re),J+=O(S,K,I,W,D);else if(re=b(F),typeof re=="function")for(F=re.call(F),re=0;!(S=F.next()).done;)S=S.value,W=te+T(S,re++),J+=O(S,K,I,W,D);else if(W==="object"){if(typeof F.then=="function")return O(z(F),K,I,S,D);throw K=String(F),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.")}return J}function V(F,K,I){if(F==null)return F;var S=[],D=0;return O(F,S,"","",function(W){return K.call(I,W,D++)}),S}function H(F){if(F._status===-1){var K=F._result;K=K(),K.then(function(I){(F._status===0||F._status===-1)&&(F._status=1,F._result=I)},function(I){(F._status===0||F._status===-1)&&(F._status=2,F._result=I)}),F._status===-1&&(F._status=0,F._result=K)}if(F._status===1)return F._result.default;throw F._result}var Z=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var K=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(K))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},B={map:V,forEach:function(F,K,I){V(F,function(){K.apply(this,arguments)},I)},count:function(F){var K=0;return V(F,function(){K++}),K},toArray:function(F){return V(F,function(K){return K})||[]},only:function(F){if(!P(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return Dt.Activity=p,Dt.Children=B,Dt.Component=E,Dt.Fragment=s,Dt.Profiler=i,Dt.PureComponent=N,Dt.StrictMode=l,Dt.Suspense=h,Dt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Y,Dt.__COMPILER_RUNTIME={__proto__:null,c:function(F){return Y.H.useMemoCache(F)}},Dt.cache=function(F){return function(){return F.apply(null,arguments)}},Dt.cacheSignal=function(){return null},Dt.cloneElement=function(F,K,I){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var S=k({},F.props),D=F.key;if(K!=null)for(W in K.key!==void 0&&(D=""+K.key),K)!q.call(K,W)||W==="key"||W==="__self"||W==="__source"||W==="ref"&&K.ref===void 0||(S[W]=K[W]);var W=arguments.length-2;if(W===1)S.children=I;else if(1<W){for(var J=Array(W),te=0;te<W;te++)J[te]=arguments[te+2];S.children=J}return X(F.type,D,S)},Dt.createContext=function(F){return F={$$typeof:d,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:c,_context:F},F},Dt.createElement=function(F,K,I){var S,D={},W=null;if(K!=null)for(S in K.key!==void 0&&(W=""+K.key),K)q.call(K,S)&&S!=="key"&&S!=="__self"&&S!=="__source"&&(D[S]=K[S]);var J=arguments.length-2;if(J===1)D.children=I;else if(1<J){for(var te=Array(J),re=0;re<J;re++)te[re]=arguments[re+2];D.children=te}if(F&&F.defaultProps)for(S in J=F.defaultProps,J)D[S]===void 0&&(D[S]=J[S]);return X(F,W,D)},Dt.createRef=function(){return{current:null}},Dt.forwardRef=function(F){return{$$typeof:u,render:F}},Dt.isValidElement=P,Dt.lazy=function(F){return{$$typeof:x,_payload:{_status:-1,_result:F},_init:H}},Dt.memo=function(F,K){return{$$typeof:f,type:F,compare:K===void 0?null:K}},Dt.startTransition=function(F){var K=Y.T,I={};Y.T=I;try{var S=F(),D=Y.S;D!==null&&D(I,S),typeof S=="object"&&S!==null&&typeof S.then=="function"&&S.then(_,Z)}catch(W){Z(W)}finally{K!==null&&I.types!==null&&(K.types=I.types),Y.T=K}},Dt.unstable_useCacheRefresh=function(){return Y.H.useCacheRefresh()},Dt.use=function(F){return Y.H.use(F)},Dt.useActionState=function(F,K,I){return Y.H.useActionState(F,K,I)},Dt.useCallback=function(F,K){return Y.H.useCallback(F,K)},Dt.useContext=function(F){return Y.H.useContext(F)},Dt.useDebugValue=function(){},Dt.useDeferredValue=function(F,K){return Y.H.useDeferredValue(F,K)},Dt.useEffect=function(F,K){return Y.H.useEffect(F,K)},Dt.useEffectEvent=function(F){return Y.H.useEffectEvent(F)},Dt.useId=function(){return Y.H.useId()},Dt.useImperativeHandle=function(F,K,I){return Y.H.useImperativeHandle(F,K,I)},Dt.useInsertionEffect=function(F,K){return Y.H.useInsertionEffect(F,K)},Dt.useLayoutEffect=function(F,K){return Y.H.useLayoutEffect(F,K)},Dt.useMemo=function(F,K){return Y.H.useMemo(F,K)},Dt.useOptimistic=function(F,K){return Y.H.useOptimistic(F,K)},Dt.useReducer=function(F,K,I){return Y.H.useReducer(F,K,I)},Dt.useRef=function(F){return Y.H.useRef(F)},Dt.useState=function(F){return Y.H.useState(F)},Dt.useSyncExternalStore=function(F,K,I){return Y.H.useSyncExternalStore(F,K,I)},Dt.useTransition=function(){return Y.H.useTransition()},Dt.version="19.2.4",Dt}var Pb;function uc(){return Pb||(Pb=1,Bm.exports=ck()),Bm.exports}var y=uc();const dk=yu(y);var Hm={exports:{}},To={},Pm={exports:{}},Um={};var Ub;function uk(){return Ub||(Ub=1,(function(e){function n(O,V){var H=O.length;O.push(V);e:for(;0<H;){var Z=H-1>>>1,B=O[Z];if(0<i(B,V))O[Z]=V,O[H]=B,H=Z;else break e}}function s(O){return O.length===0?null:O[0]}function l(O){if(O.length===0)return null;var V=O[0],H=O.pop();if(H!==V){O[0]=H;e:for(var Z=0,B=O.length,F=B>>>1;Z<F;){var K=2*(Z+1)-1,I=O[K],S=K+1,D=O[S];if(0>i(I,H))S<B&&0>i(D,I)?(O[Z]=D,O[S]=H,Z=S):(O[Z]=I,O[K]=H,Z=K);else if(S<B&&0>i(D,H))O[Z]=D,O[S]=H,Z=S;else break e}}return V}function i(O,V){var H=O.sortIndex-V.sortIndex;return H!==0?H:O.id-V.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var h=[],f=[],x=1,p=null,g=3,b=!1,w=!1,k=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function A(O){for(var V=s(f);V!==null;){if(V.callback===null)l(f);else if(V.startTime<=O)l(f),V.sortIndex=V.expirationTime,n(h,V);else break;V=s(f)}}function R(O){if(k=!1,A(O),!w)if(s(h)!==null)w=!0,_||(_=!0,G());else{var V=s(f);V!==null&&z(R,V.startTime-O)}}var _=!1,Y=-1,q=5,X=-1;function L(){return C?!0:!(e.unstable_now()-X<q)}function P(){if(C=!1,_){var O=e.unstable_now();X=O;var V=!0;try{e:{w=!1,k&&(k=!1,M(Y),Y=-1),b=!0;var H=g;try{t:{for(A(O),p=s(h);p!==null&&!(p.expirationTime>O&&L());){var Z=p.callback;if(typeof Z=="function"){p.callback=null,g=p.priorityLevel;var B=Z(p.expirationTime<=O);if(O=e.unstable_now(),typeof B=="function"){p.callback=B,A(O),V=!0;break t}p===s(h)&&l(h),A(O)}else l(h);p=s(h)}if(p!==null)V=!0;else{var F=s(f);F!==null&&z(R,F.startTime-O),V=!1}}break e}finally{p=null,g=H,b=!1}V=void 0}}finally{V?G():_=!1}}}var G;if(typeof N=="function")G=function(){N(P)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,T=$.port2;$.port1.onmessage=P,G=function(){T.postMessage(null)}}else G=function(){E(P,0)};function z(O,V){Y=E(function(){O(e.unstable_now())},V)}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(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(O){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var H=g;g=V;try{return O()}finally{g=H}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(O,V){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var H=g;g=O;try{return V()}finally{g=H}},e.unstable_scheduleCallback=function(O,V,H){var Z=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?Z+H:Z):H=Z,O){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=H+B,O={id:x++,callback:V,priorityLevel:O,startTime:H,expirationTime:B,sortIndex:-1},H>Z?(O.sortIndex=H,n(f,O),s(h)===null&&O===s(f)&&(k?(M(Y),Y=-1):k=!0,z(R,H-Z))):(O.sortIndex=B,n(h,O),w||b||(w=!0,_||(_=!0,G()))),O},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(O){var V=g;return function(){var H=g;g=V;try{return O.apply(this,arguments)}finally{g=H}}}})(Um)),Um}var qb;function fk(){return qb||(qb=1,Pm.exports=uk()),Pm.exports}var qm={exports:{}},Cr={};var Fb;function mk(){if(Fb)return Cr;Fb=1;var e=uc();function n(h){var f="https://react.dev/errors/"+h;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)f+="&args[]="+encodeURIComponent(arguments[x])}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 l={d:{f:s,r:function(){throw Error(n(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},i=Symbol.for("react.portal");function c(h,f,x){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:p==null?null:""+p,children:h,containerInfo:f,implementation:x}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(h,f){if(h==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Cr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,Cr.createPortal=function(h,f){var x=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 c(h,f,null,x)},Cr.flushSync=function(h){var f=d.T,x=l.p;try{if(d.T=null,l.p=2,h)return h()}finally{d.T=f,l.p=x,l.d.f()}},Cr.preconnect=function(h,f){typeof h=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,l.d.C(h,f))},Cr.prefetchDNS=function(h){typeof h=="string"&&l.d.D(h)},Cr.preinit=function(h,f){if(typeof h=="string"&&f&&typeof f.as=="string"){var x=f.as,p=u(x,f.crossOrigin),g=typeof f.integrity=="string"?f.integrity:void 0,b=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;x==="style"?l.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:p,integrity:g,fetchPriority:b}):x==="script"&&l.d.X(h,{crossOrigin:p,integrity:g,fetchPriority:b,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Cr.preinitModule=function(h,f){if(typeof h=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var x=u(f.as,f.crossOrigin);l.d.M(h,{crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&l.d.M(h)},Cr.preload=function(h,f){if(typeof h=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var x=f.as,p=u(x,f.crossOrigin);l.d.L(h,x,{crossOrigin:p,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})}},Cr.preloadModule=function(h,f){if(typeof h=="string")if(f){var x=u(f.as,f.crossOrigin);l.d.m(h,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else l.d.m(h)},Cr.requestFormReset=function(h){l.d.r(h)},Cr.unstable_batchedUpdates=function(h,f){return h(f)},Cr.useFormState=function(h,f,x){return d.H.useFormState(h,f,x)},Cr.useFormStatus=function(){return d.H.useHostTransitionStatus()},Cr.version="19.2.4",Cr}var Vb;function Z1(){if(Vb)return qm.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(),qm.exports=mk(),qm.exports}var Yb;function hk(){if(Yb)return To;Yb=1;var e=fk(),n=uc(),s=Z1();function l(r){var a="https://react.dev/errors/"+r;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)a+="&args[]="+encodeURIComponent(arguments[o])}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 i(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function c(r){var a=r,o=r;if(r.alternate)for(;a.return;)a=a.return;else{r=a;do a=r,(a.flags&4098)!==0&&(o=a.return),r=a.return;while(r)}return a.tag===3?o:null}function d(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 u(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(c(r)!==r)throw Error(l(188))}function f(r){var a=r.alternate;if(!a){if(a=c(r),a===null)throw Error(l(188));return a!==r?null:r}for(var o=r,m=a;;){var v=o.return;if(v===null)break;var j=v.alternate;if(j===null){if(m=v.return,m!==null){o=m;continue}break}if(v.child===j.child){for(j=v.child;j;){if(j===o)return h(v),r;if(j===m)return h(v),a;j=j.sibling}throw Error(l(188))}if(o.return!==m.return)o=v,m=j;else{for(var U=!1,Q=v.child;Q;){if(Q===o){U=!0,o=v,m=j;break}if(Q===m){U=!0,m=v,o=j;break}Q=Q.sibling}if(!U){for(Q=j.child;Q;){if(Q===o){U=!0,o=j,m=v;break}if(Q===m){U=!0,m=j,o=v;break}Q=Q.sibling}if(!U)throw Error(l(189))}}if(o.alternate!==m)throw Error(l(190))}if(o.tag!==3)throw Error(l(188));return o.stateNode.current===o?r:a}function x(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r;for(r=r.child;r!==null;){if(a=x(r),a!==null)return a;r=r.sibling}return null}var p=Object.assign,g=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),N=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),L=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function G(r){return r===null||typeof r!="object"?null:(r=P&&r[P]||r["@@iterator"],typeof r=="function"?r:null)}var $=Symbol.for("react.client.reference");function T(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===$?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case k:return"Fragment";case E:return"Profiler";case C:return"StrictMode";case R:return"Suspense";case _:return"SuspenseList";case X:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case N:return r.displayName||"Context";case M:return(r._context.displayName||"Context")+".Consumer";case A:var a=r.render;return r=r.displayName,r||(r=a.displayName||a.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Y:return a=r.displayName||null,a!==null?a:T(r.type)||"Memo";case q:a=r._payload,r=r._init;try{return T(r(a))}catch{}}return null}var z=Array.isArray,O=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},Z=[],B=-1;function F(r){return{current:r}}function K(r){0>B||(r.current=Z[B],Z[B]=null,B--)}function I(r,a){B++,Z[B]=r.current,r.current=a}var S=F(null),D=F(null),W=F(null),J=F(null);function te(r,a){switch(I(W,a),I(D,r),I(S,null),a.nodeType){case 9:case 11:r=(r=a.documentElement)&&(r=r.namespaceURI)?ib(r):0;break;default:if(r=a.tagName,a=a.namespaceURI)a=ib(a),r=ob(a,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}K(S),I(S,r)}function re(){K(S),K(D),K(W)}function oe(r){r.memoizedState!==null&&I(J,r);var a=S.current,o=ob(a,r.type);a!==o&&(I(D,r),I(S,o))}function me(r){D.current===r&&(K(S),K(D)),J.current===r&&(K(J),No._currentValue=H)}var Oe,ve;function ke(r){if(Oe===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);Oe=a&&a[1]||"",ve=-1<o.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+Oe+r+ve}var Ee=!1;function Me(r,a){if(!r||Ee)return"";Ee=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={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(we){var je=we}Reflect.construct(r,[],De)}else{try{De.call()}catch(we){je=we}r.call(De.prototype)}}else{try{throw Error()}catch(we){je=we}(De=r())&&typeof De.catch=="function"&&De.catch(function(){})}}catch(we){if(we&&je&&typeof we.stack=="string")return[we.stack,je.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=m.DetermineComponentFrameRoot(),U=j[0],Q=j[1];if(U&&Q){var ie=U.split(`
|
|
4
|
+
`),be=Q.split(`
|
|
5
|
+
`);for(v=m=0;m<ie.length&&!ie[m].includes("DetermineComponentFrameRoot");)m++;for(;v<be.length&&!be[v].includes("DetermineComponentFrameRoot");)v++;if(m===ie.length||v===be.length)for(m=ie.length-1,v=be.length-1;1<=m&&0<=v&&ie[m]!==be[v];)v--;for(;1<=m&&0<=v;m--,v--)if(ie[m]!==be[v]){if(m!==1||v!==1)do if(m--,v--,0>v||ie[m]!==be[v]){var Ae=`
|
|
6
|
+
`+ie[m].replace(" at new "," at ");return r.displayName&&Ae.includes("<anonymous>")&&(Ae=Ae.replace("<anonymous>",r.displayName)),Ae}while(1<=m&&0<=v);break}}}finally{Ee=!1,Error.prepareStackTrace=o}return(o=r?r.displayName||r.name:"")?ke(o):""}function dt(r,a){switch(r.tag){case 26:case 27:case 5:return ke(r.type);case 16:return ke("Lazy");case 13:return r.child!==a&&a!==null?ke("Suspense Fallback"):ke("Suspense");case 19:return ke("SuspenseList");case 0:case 15:return Me(r.type,!1);case 11:return Me(r.type.render,!1);case 1:return Me(r.type,!0);case 31:return ke("Activity");default:return""}}function pt(r){try{var a="",o=null;do a+=dt(r,o),o=r,r=r.return;while(r);return a}catch(m){return`
|
|
7
|
+
Error generating stack: `+m.message+`
|
|
8
|
+
`+m.stack}}var et=Object.prototype.hasOwnProperty,Pt=e.unstable_scheduleCallback,le=e.unstable_cancelCallback,Se=e.unstable_shouldYield,We=e.unstable_requestPaint,kt=e.unstable_now,Ft=e.unstable_getCurrentPriorityLevel,xe=e.unstable_ImmediatePriority,Ce=e.unstable_UserBlockingPriority,Fe=e.unstable_NormalPriority,lt=e.unstable_LowPriority,ut=e.unstable_IdlePriority,Lt=e.log,bn=e.unstable_setDisableYieldValue,Ut=null,St=null;function Jt(r){if(typeof Lt=="function"&&bn(r),St&&typeof St.setStrictMode=="function")try{St.setStrictMode(Ut,r)}catch{}}var yt=Math.clz32?Math.clz32:$t,Xt=Math.log,_t=Math.LN2;function $t(r){return r>>>=0,r===0?32:31-(Xt(r)/_t|0)|0}var Hn=256,dn=262144,ye=4194304;function Ge(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 it(r,a,o){var m=r.pendingLanes;if(m===0)return 0;var v=0,j=r.suspendedLanes,U=r.pingedLanes;r=r.warmLanes;var Q=m&134217727;return Q!==0?(m=Q&~j,m!==0?v=Ge(m):(U&=Q,U!==0?v=Ge(U):o||(o=Q&~r,o!==0&&(v=Ge(o))))):(Q=m&~j,Q!==0?v=Ge(Q):U!==0?v=Ge(U):o||(o=m&~r,o!==0&&(v=Ge(o)))),v===0?0:a!==0&&a!==v&&(a&j)===0&&(j=v&-v,o=a&-a,j>=o||j===32&&(o&4194048)!==0)?a:v}function Et(r,a){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&a)===0}function It(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 kn(){var r=ye;return ye<<=1,(ye&62914560)===0&&(ye=4194304),r}function _n(r){for(var a=[],o=0;31>o;o++)a.push(r);return a}function Mn(r,a){r.pendingLanes|=a,a!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function dr(r,a,o,m,v,j){var U=r.pendingLanes;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=o,r.entangledLanes&=o,r.errorRecoveryDisabledLanes&=o,r.shellSuspendCounter=0;var Q=r.entanglements,ie=r.expirationTimes,be=r.hiddenUpdates;for(o=U&~o;0<o;){var Ae=31-yt(o),De=1<<Ae;Q[Ae]=0,ie[Ae]=-1;var je=be[Ae];if(je!==null)for(be[Ae]=null,Ae=0;Ae<je.length;Ae++){var we=je[Ae];we!==null&&(we.lane&=-536870913)}o&=~De}m!==0&&sr(r,m,0),j!==0&&v===0&&r.tag!==0&&(r.suspendedLanes|=j&~(U&~a))}function sr(r,a,o){r.pendingLanes|=a,r.suspendedLanes&=~a;var m=31-yt(a);r.entangledLanes|=a,r.entanglements[m]=r.entanglements[m]|1073741824|o&261930}function ur(r,a){var o=r.entangledLanes|=a;for(r=r.entanglements;o;){var m=31-yt(o),v=1<<m;v&a|r[m]&a&&(r[m]|=a),o&=~v}}function $n(r,a){var o=a&-a;return o=(o&42)!==0?1:ae(o),(o&(r.suspendedLanes|a))!==0?0:o}function ae(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 Ie(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function qe(){var r=V.p;return r!==0?r:(r=window.event,r===void 0?32:Mb(r.type))}function Qe(r,a){var o=V.p;try{return V.p=r,a()}finally{V.p=o}}var ue=Math.random().toString(36).slice(2),ze="__reactFiber$"+ue,Ve="__reactProps$"+ue,tt="__reactContainer$"+ue,ot="__reactEvents$"+ue,At="__reactListeners$"+ue,Sn="__reactHandles$"+ue,ar="__reactResources$"+ue,mn="__reactMarker$"+ue;function Wn(r){delete r[ze],delete r[Ve],delete r[ot],delete r[At],delete r[Sn]}function Ot(r){var a=r[ze];if(a)return a;for(var o=r.parentNode;o;){if(a=o[tt]||o[ze]){if(o=a.alternate,a.child!==null||o!==null&&o.child!==null)for(r=xb(r);r!==null;){if(o=r[ze])return o;r=xb(r)}return a}r=o,o=r.parentNode}return null}function pr(r){if(r=r[ze]||r[tt]){var a=r.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return r}return null}function Tt(r){var a=r.tag;if(a===5||a===26||a===27||a===6)return r.stateNode;throw Error(l(33))}function hn(r){var a=r[ar];return a||(a=r[ar]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function ln(r){r[mn]=!0}var ss=new Set,Rr={};function lr(r,a){Or(r,a),Or(r+"Capture",a)}function Or(r,a){for(Rr[r]=a,r=0;r<a.length;r++)ss.add(a[r])}var gs=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]*$"),as={},Os={};function Ds(r){return et.call(Os,r)?!0:et.call(as,r)?!1:gs.test(r)?Os[r]=!0:(as[r]=!0,!1)}function gr(r,a,o){if(Ds(a))if(o===null)r.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":r.removeAttribute(a);return;case"boolean":var m=a.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){r.removeAttribute(a);return}}r.setAttribute(a,""+o)}}function Dr(r,a,o){if(o===null)r.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(a);return}r.setAttribute(a,""+o)}}function fr(r,a,o,m){if(m===null)r.removeAttribute(o);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(o);return}r.setAttributeNS(a,o,""+m)}}function Vn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function bs(r){var a=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function de(r,a,o){var m=Object.getOwnPropertyDescriptor(r.constructor.prototype,a);if(!r.hasOwnProperty(a)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var v=m.get,j=m.set;return Object.defineProperty(r,a,{configurable:!0,get:function(){return v.call(this)},set:function(U){o=""+U,j.call(this,U)}}),Object.defineProperty(r,a,{enumerable:m.enumerable}),{getValue:function(){return o},setValue:function(U){o=""+U},stopTracking:function(){r._valueTracker=null,delete r[a]}}}}function Te(r){if(!r._valueTracker){var a=bs(r)?"checked":"value";r._valueTracker=de(r,a,""+r[a])}}function Ue(r){if(!r)return!1;var a=r._valueTracker;if(!a)return!0;var o=a.getValue(),m="";return r&&(m=bs(r)?r.checked?"true":"false":r.value),r=m,r!==o?(a.setValue(r),!0):!1}function qt(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 Ar=/[\n"\\]/g;function Pn(r){return r.replace(Ar,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function mr(r,a,o,m,v,j,U,Q){r.name="",U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"?r.type=U:r.removeAttribute("type"),a!=null?U==="number"?(a===0&&r.value===""||r.value!=a)&&(r.value=""+Vn(a)):r.value!==""+Vn(a)&&(r.value=""+Vn(a)):U!=="submit"&&U!=="reset"||r.removeAttribute("value"),a!=null?ys(r,U,Vn(a)):o!=null?ys(r,U,Vn(o)):m!=null&&r.removeAttribute("value"),v==null&&j!=null&&(r.defaultChecked=!!j),v!=null&&(r.checked=v&&typeof v!="function"&&typeof v!="symbol"),Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"?r.name=""+Vn(Q):r.removeAttribute("name")}function Ls(r,a,o,m,v,j,U,Q){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.type=j),a!=null||o!=null){if(!(j!=="submit"&&j!=="reset"||a!=null)){Te(r);return}o=o!=null?""+Vn(o):"",a=a!=null?""+Vn(a):o,Q||a===r.value||(r.value=a),r.defaultValue=a}m=m??v,m=typeof m!="function"&&typeof m!="symbol"&&!!m,r.checked=Q?r.checked:!!m,r.defaultChecked=!!m,U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"&&(r.name=U),Te(r)}function ys(r,a,o){a==="number"&&qt(r.ownerDocument)===r||r.defaultValue===""+o||(r.defaultValue=""+o)}function br(r,a,o,m){if(r=r.options,a){a={};for(var v=0;v<o.length;v++)a["$"+o[v]]=!0;for(o=0;o<r.length;o++)v=a.hasOwnProperty("$"+r[o].value),r[o].selected!==v&&(r[o].selected=v),v&&m&&(r[o].defaultSelected=!0)}else{for(o=""+Vn(o),a=null,v=0;v<r.length;v++){if(r[v].value===o){r[v].selected=!0,m&&(r[v].defaultSelected=!0);return}a!==null||r[v].disabled||(a=r[v])}a!==null&&(a.selected=!0)}}function ka(r,a,o){if(a!=null&&(a=""+Vn(a),a!==r.value&&(r.value=a),o==null)){r.defaultValue!==a&&(r.defaultValue=a);return}r.defaultValue=o!=null?""+Vn(o):""}function Hl(r,a,o,m){if(a==null){if(m!=null){if(o!=null)throw Error(l(92));if(z(m)){if(1<m.length)throw Error(l(93));m=m[0]}o=m}o==null&&(o=""),a=o}o=Vn(a),r.defaultValue=o,m=r.textContent,m===o&&m!==""&&m!==null&&(r.value=m),Te(r)}function ir(r,a){if(a){var o=r.firstChild;if(o&&o===r.lastChild&&o.nodeType===3){o.nodeValue=a;return}}r.textContent=a}var Sa=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 il(r,a,o){var m=a.indexOf("--")===0;o==null||typeof o=="boolean"||o===""?m?r.setProperty(a,""):a==="float"?r.cssFloat="":r[a]="":m?r.setProperty(a,o):typeof o!="number"||o===0||Sa.has(a)?a==="float"?r.cssFloat=o:r[a]=(""+o).trim():r[a]=o+"px"}function ls(r,a,o){if(a!=null&&typeof a!="object")throw Error(l(62));if(r=r.style,o!=null){for(var m in o)!o.hasOwnProperty(m)||a!=null&&a.hasOwnProperty(m)||(m.indexOf("--")===0?r.setProperty(m,""):m==="float"?r.cssFloat="":r[m]="");for(var v in a)m=a[v],a.hasOwnProperty(v)&&o[v]!==m&&il(r,v,m)}else for(var j in a)a.hasOwnProperty(j)&&il(r,j,a[j])}function Zs(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 Ca=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 Le(r){return ne.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Be(){}var st=null;function en(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var un=null,Mt=null;function He(r){var a=pr(r);if(a&&(r=a.stateNode)){var o=r[Ve]||null;e:switch(r=a.stateNode,a.type){case"input":if(mr(r,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name),a=o.name,o.type==="radio"&&a!=null){for(o=r;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll('input[name="'+Pn(""+a)+'"][type="radio"]'),a=0;a<o.length;a++){var m=o[a];if(m!==r&&m.form===r.form){var v=m[Ve]||null;if(!v)throw Error(l(90));mr(m,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(a=0;a<o.length;a++)m=o[a],m.form===r.form&&Ue(m)}break e;case"textarea":ka(r,o.value,o.defaultValue);break e;case"select":a=o.value,a!=null&&br(r,!!o.multiple,a,!1)}}}var hr=!1;function yr(r,a,o){if(hr)return r(a,o);hr=!0;try{var m=r(a);return m}finally{if(hr=!1,(un!==null||Mt!==null)&&(nd(),un&&(a=un,r=Mt,Mt=un=null,He(a),r)))for(a=0;a<r.length;a++)He(r[a])}}function vr(r,a){var o=r.stateNode;if(o===null)return null;var m=o[Ve]||null;if(m===null)return null;o=m[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":(m=!m.disabled)||(r=r.type,m=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!m;break e;default:r=!1}if(r)return null;if(o&&typeof o!="function")throw Error(l(231,a,typeof o));return o}var Yn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vs=!1;if(Yn)try{var Lr={};Object.defineProperty(Lr,"passive",{get:function(){vs=!0}}),window.addEventListener("test",Lr,Lr),window.removeEventListener("test",Lr,Lr)}catch{vs=!1}var ee=null,Ne=null,Re=null;function Ke(){if(Re)return Re;var r,a=Ne,o=a.length,m,v="value"in ee?ee.value:ee.textContent,j=v.length;for(r=0;r<o&&a[r]===v[r];r++);var U=o-r;for(m=1;m<=U&&a[o-m]===v[j-m];m++);return Re=v.slice(r,1<m?1-m:void 0)}function Xe(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 $e(){return!0}function Ze(){return!1}function Rt(r){function a(o,m,v,j,U){this._reactName=o,this._targetInst=v,this.type=m,this.nativeEvent=j,this.target=U,this.currentTarget=null;for(var Q in r)r.hasOwnProperty(Q)&&(o=r[Q],this[Q]=o?o(j):j[Q]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?$e:Ze,this.isPropagationStopped=Ze,this}return p(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=$e)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=$e)},persist:function(){},isPersistent:$e}),a}var Ye={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ht=Rt(Ye),vt=p({},Ye,{view:0,detail:0}),tn=Rt(vt),yn,fn,jr,Ir=p({},vt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Uu,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!==jr&&(jr&&r.type==="mousemove"?(yn=r.screenX-jr.screenX,fn=r.screenY-jr.screenY):fn=yn=0,jr=r),yn)},movementY:function(r){return"movementY"in r?r.movementY:fn}}),ol=Rt(Ir),ft=p({},Ir,{dataTransfer:0}),wt=Rt(ft),at=p({},vt,{relatedTarget:0}),Je=Rt(at),nt=p({},Ye,{animationName:0,elapsedTime:0,pseudoElement:0}),xt=Rt(nt),Ct=p({},Ye,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),vn=Rt(Ct),on=p({},Ye,{data:0}),Cn=Rt(on),js={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Pu={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"},ws={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function g5(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=ws[r])?!!a[r]:!1}function Uu(){return g5}var b5=p({},vt,{key:function(r){if(r.key){var a=js[r.key]||r.key;if(a!=="Unidentified")return a}return r.type==="keypress"?(r=Xe(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Pu[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Uu,charCode:function(r){return r.type==="keypress"?Xe(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Xe(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),y5=Rt(b5),v5=p({},Ir,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),fp=Rt(v5),j5=p({},vt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Uu}),w5=Rt(j5),N5=p({},Ye,{propertyName:0,elapsedTime:0,pseudoElement:0}),k5=Rt(N5),S5=p({},Ir,{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}),C5=Rt(S5),E5=p({},Ye,{newState:0,oldState:0}),T5=Rt(E5),A5=[9,13,27,32],qu=Yn&&"CompositionEvent"in window,qi=null;Yn&&"documentMode"in document&&(qi=document.documentMode);var _5=Yn&&"TextEvent"in window&&!qi,mp=Yn&&(!qu||qi&&8<qi&&11>=qi),hp=" ",xp=!1;function pp(r,a){switch(r){case"keyup":return A5.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gp(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Pl=!1;function M5(r,a){switch(r){case"compositionend":return gp(a);case"keypress":return a.which!==32?null:(xp=!0,hp);case"textInput":return r=a.data,r===hp&&xp?null:r;default:return null}}function R5(r,a){if(Pl)return r==="compositionend"||!qu&&pp(r,a)?(r=Ke(),Re=Ne=ee=null,Pl=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return mp&&a.locale!=="ko"?null:a.data;default:return null}}var O5={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 bp(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!O5[r.type]:a==="textarea"}function yp(r,a,o,m){un?Mt?Mt.push(m):Mt=[m]:un=m,a=cd(a,"onChange"),0<a.length&&(o=new ht("onChange","change",null,o,m),r.push({event:o,listeners:a}))}var Fi=null,Vi=null;function D5(r){tb(r,0)}function jc(r){var a=Tt(r);if(Ue(a))return r}function vp(r,a){if(r==="change")return a}var jp=!1;if(Yn){var Fu;if(Yn){var Vu="oninput"in document;if(!Vu){var wp=document.createElement("div");wp.setAttribute("oninput","return;"),Vu=typeof wp.oninput=="function"}Fu=Vu}else Fu=!1;jp=Fu&&(!document.documentMode||9<document.documentMode)}function Np(){Fi&&(Fi.detachEvent("onpropertychange",kp),Vi=Fi=null)}function kp(r){if(r.propertyName==="value"&&jc(Vi)){var a=[];yp(a,Vi,r,en(r)),yr(D5,a)}}function L5(r,a,o){r==="focusin"?(Np(),Fi=a,Vi=o,Fi.attachEvent("onpropertychange",kp)):r==="focusout"&&Np()}function I5(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return jc(Vi)}function z5(r,a){if(r==="click")return jc(a)}function $5(r,a){if(r==="input"||r==="change")return jc(a)}function B5(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Gr=typeof Object.is=="function"?Object.is:B5;function Yi(r,a){if(Gr(r,a))return!0;if(typeof r!="object"||r===null||typeof a!="object"||a===null)return!1;var o=Object.keys(r),m=Object.keys(a);if(o.length!==m.length)return!1;for(m=0;m<o.length;m++){var v=o[m];if(!et.call(a,v)||!Gr(r[v],a[v]))return!1}return!0}function Sp(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Cp(r,a){var o=Sp(r);r=0;for(var m;o;){if(o.nodeType===3){if(m=r+o.textContent.length,r<=a&&m>=a)return{node:o,offset:a-r};r=m}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Sp(o)}}function Ep(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?Ep(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function Tp(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var a=qt(r.document);a instanceof r.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)r=a.contentWindow;else break;a=qt(r.document)}return a}function Yu(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 H5=Yn&&"documentMode"in document&&11>=document.documentMode,Ul=null,Gu=null,Gi=null,Xu=!1;function Ap(r,a,o){var m=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Xu||Ul==null||Ul!==qt(m)||(m=Ul,"selectionStart"in m&&Yu(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),Gi&&Yi(Gi,m)||(Gi=m,m=cd(Gu,"onSelect"),0<m.length&&(a=new ht("onSelect","select",null,a,o),r.push({event:a,listeners:m}),a.target=Ul)))}function cl(r,a){var o={};return o[r.toLowerCase()]=a.toLowerCase(),o["Webkit"+r]="webkit"+a,o["Moz"+r]="moz"+a,o}var ql={animationend:cl("Animation","AnimationEnd"),animationiteration:cl("Animation","AnimationIteration"),animationstart:cl("Animation","AnimationStart"),transitionrun:cl("Transition","TransitionRun"),transitionstart:cl("Transition","TransitionStart"),transitioncancel:cl("Transition","TransitionCancel"),transitionend:cl("Transition","TransitionEnd")},Ku={},_p={};Yn&&(_p=document.createElement("div").style,"AnimationEvent"in window||(delete ql.animationend.animation,delete ql.animationiteration.animation,delete ql.animationstart.animation),"TransitionEvent"in window||delete ql.transitionend.transition);function dl(r){if(Ku[r])return Ku[r];if(!ql[r])return r;var a=ql[r],o;for(o in a)if(a.hasOwnProperty(o)&&o in _p)return Ku[r]=a[o];return r}var Mp=dl("animationend"),Rp=dl("animationiteration"),Op=dl("animationstart"),P5=dl("transitionrun"),U5=dl("transitionstart"),q5=dl("transitioncancel"),Dp=dl("transitionend"),Lp=new Map,Wu="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(" ");Wu.push("scrollEnd");function Ns(r,a){Lp.set(r,a),lr(a,[r])}var wc=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)},is=[],Fl=0,Zu=0;function Nc(){for(var r=Fl,a=Zu=Fl=0;a<r;){var o=is[a];is[a++]=null;var m=is[a];is[a++]=null;var v=is[a];is[a++]=null;var j=is[a];if(is[a++]=null,m!==null&&v!==null){var U=m.pending;U===null?v.next=v:(v.next=U.next,U.next=v),m.pending=v}j!==0&&Ip(o,v,j)}}function kc(r,a,o,m){is[Fl++]=r,is[Fl++]=a,is[Fl++]=o,is[Fl++]=m,Zu|=m,r.lanes|=m,r=r.alternate,r!==null&&(r.lanes|=m)}function Qu(r,a,o,m){return kc(r,a,o,m),Sc(r)}function ul(r,a){return kc(r,null,null,a),Sc(r)}function Ip(r,a,o){r.lanes|=o;var m=r.alternate;m!==null&&(m.lanes|=o);for(var v=!1,j=r.return;j!==null;)j.childLanes|=o,m=j.alternate,m!==null&&(m.childLanes|=o),j.tag===22&&(r=j.stateNode,r===null||r._visibility&1||(v=!0)),r=j,j=j.return;return r.tag===3?(j=r.stateNode,v&&a!==null&&(v=31-yt(o),r=j.hiddenUpdates,m=r[v],m===null?r[v]=[a]:m.push(a),a.lane=o|536870912),j):null}function Sc(r){if(50<po)throw po=0,om=null,Error(l(185));for(var a=r.return;a!==null;)r=a,a=r.return;return r.tag===3?r.stateNode:null}var Vl={};function F5(r,a,o,m){this.tag=r,this.key=o,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=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xr(r,a,o,m){return new F5(r,a,o,m)}function Ju(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Qs(r,a){var o=r.alternate;return o===null?(o=Xr(r.tag,a,r.key,r.mode),o.elementType=r.elementType,o.type=r.type,o.stateNode=r.stateNode,o.alternate=r,r.alternate=o):(o.pendingProps=a,o.type=r.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=r.flags&65011712,o.childLanes=r.childLanes,o.lanes=r.lanes,o.child=r.child,o.memoizedProps=r.memoizedProps,o.memoizedState=r.memoizedState,o.updateQueue=r.updateQueue,a=r.dependencies,o.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},o.sibling=r.sibling,o.index=r.index,o.ref=r.ref,o.refCleanup=r.refCleanup,o}function zp(r,a){r.flags&=65011714;var o=r.alternate;return o===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=o.childLanes,r.lanes=o.lanes,r.child=o.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=o.memoizedProps,r.memoizedState=o.memoizedState,r.updateQueue=o.updateQueue,r.type=o.type,a=o.dependencies,r.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),r}function Cc(r,a,o,m,v,j){var U=0;if(m=r,typeof r=="function")Ju(r)&&(U=1);else if(typeof r=="string")U=K2(r,o,S.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case X:return r=Xr(31,o,a,v),r.elementType=X,r.lanes=j,r;case k:return fl(o.children,v,j,a);case C:U=8,v|=24;break;case E:return r=Xr(12,o,a,v|2),r.elementType=E,r.lanes=j,r;case R:return r=Xr(13,o,a,v),r.elementType=R,r.lanes=j,r;case _:return r=Xr(19,o,a,v),r.elementType=_,r.lanes=j,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case N:U=10;break e;case M:U=9;break e;case A:U=11;break e;case Y:U=14;break e;case q:U=16,m=null;break e}U=29,o=Error(l(130,r===null?"null":typeof r,"")),m=null}return a=Xr(U,o,a,v),a.elementType=r,a.type=m,a.lanes=j,a}function fl(r,a,o,m){return r=Xr(7,r,m,a),r.lanes=o,r}function ef(r,a,o){return r=Xr(6,r,null,a),r.lanes=o,r}function $p(r){var a=Xr(18,null,null,0);return a.stateNode=r,a}function tf(r,a,o){return a=Xr(4,r.children!==null?r.children:[],r.key,a),a.lanes=o,a.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},a}var Bp=new WeakMap;function os(r,a){if(typeof r=="object"&&r!==null){var o=Bp.get(r);return o!==void 0?o:(a={value:r,source:a,stack:pt(a)},Bp.set(r,a),a)}return{value:r,source:a,stack:pt(a)}}var Yl=[],Gl=0,Ec=null,Xi=0,cs=[],ds=0,Ea=null,Is=1,zs="";function Js(r,a){Yl[Gl++]=Xi,Yl[Gl++]=Ec,Ec=r,Xi=a}function Hp(r,a,o){cs[ds++]=Is,cs[ds++]=zs,cs[ds++]=Ea,Ea=r;var m=Is;r=zs;var v=32-yt(m)-1;m&=~(1<<v),o+=1;var j=32-yt(a)+v;if(30<j){var U=v-v%5;j=(m&(1<<U)-1).toString(32),m>>=U,v-=U,Is=1<<32-yt(a)+v|o<<v|m,zs=j+r}else Is=1<<j|o<<v|m,zs=r}function nf(r){r.return!==null&&(Js(r,1),Hp(r,1,0))}function rf(r){for(;r===Ec;)Ec=Yl[--Gl],Yl[Gl]=null,Xi=Yl[--Gl],Yl[Gl]=null;for(;r===Ea;)Ea=cs[--ds],cs[ds]=null,zs=cs[--ds],cs[ds]=null,Is=cs[--ds],cs[ds]=null}function Pp(r,a){cs[ds++]=Is,cs[ds++]=zs,cs[ds++]=Ea,Is=a.id,zs=a.overflow,Ea=r}var wr=null,Rn=null,Qt=!1,Ta=null,us=!1,sf=Error(l(519));function Aa(r){var a=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ki(os(a,r)),sf}function Up(r){var a=r.stateNode,o=r.type,m=r.memoizedProps;switch(a[ze]=r,a[Ve]=m,o){case"dialog":Yt("cancel",a),Yt("close",a);break;case"iframe":case"object":case"embed":Yt("load",a);break;case"video":case"audio":for(o=0;o<bo.length;o++)Yt(bo[o],a);break;case"source":Yt("error",a);break;case"img":case"image":case"link":Yt("error",a),Yt("load",a);break;case"details":Yt("toggle",a);break;case"input":Yt("invalid",a),Ls(a,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":Yt("invalid",a);break;case"textarea":Yt("invalid",a),Hl(a,m.value,m.defaultValue,m.children)}o=m.children,typeof o!="string"&&typeof o!="number"&&typeof o!="bigint"||a.textContent===""+o||m.suppressHydrationWarning===!0||ab(a.textContent,o)?(m.popover!=null&&(Yt("beforetoggle",a),Yt("toggle",a)),m.onScroll!=null&&Yt("scroll",a),m.onScrollEnd!=null&&Yt("scrollend",a),m.onClick!=null&&(a.onclick=Be),a=!0):a=!1,a||Aa(r,!0)}function qp(r){for(wr=r.return;wr;)switch(wr.tag){case 5:case 31:case 13:us=!1;return;case 27:case 3:us=!0;return;default:wr=wr.return}}function Xl(r){if(r!==wr)return!1;if(!Qt)return qp(r),Qt=!0,!1;var a=r.tag,o;if((o=a!==3&&a!==27)&&((o=a===5)&&(o=r.type,o=!(o!=="form"&&o!=="button")||Nm(r.type,r.memoizedProps)),o=!o),o&&Rn&&Aa(r),qp(r),a===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(317));Rn=hb(r)}else if(a===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(317));Rn=hb(r)}else a===27?(a=Rn,qa(r.type)?(r=Tm,Tm=null,Rn=r):Rn=a):Rn=wr?ms(r.stateNode.nextSibling):null;return!0}function ml(){Rn=wr=null,Qt=!1}function af(){var r=Ta;return r!==null&&(Hr===null?Hr=r:Hr.push.apply(Hr,r),Ta=null),r}function Ki(r){Ta===null?Ta=[r]:Ta.push(r)}var lf=F(null),hl=null,ea=null;function _a(r,a,o){I(lf,a._currentValue),a._currentValue=o}function ta(r){r._currentValue=lf.current,K(lf)}function of(r,a,o){for(;r!==null;){var m=r.alternate;if((r.childLanes&a)!==a?(r.childLanes|=a,m!==null&&(m.childLanes|=a)):m!==null&&(m.childLanes&a)!==a&&(m.childLanes|=a),r===o)break;r=r.return}}function cf(r,a,o,m){var v=r.child;for(v!==null&&(v.return=r);v!==null;){var j=v.dependencies;if(j!==null){var U=v.child;j=j.firstContext;e:for(;j!==null;){var Q=j;j=v;for(var ie=0;ie<a.length;ie++)if(Q.context===a[ie]){j.lanes|=o,Q=j.alternate,Q!==null&&(Q.lanes|=o),of(j.return,o,r),m||(U=null);break e}j=Q.next}}else if(v.tag===18){if(U=v.return,U===null)throw Error(l(341));U.lanes|=o,j=U.alternate,j!==null&&(j.lanes|=o),of(U,o,r),U=null}else U=v.child;if(U!==null)U.return=v;else for(U=v;U!==null;){if(U===r){U=null;break}if(v=U.sibling,v!==null){v.return=U.return,U=v;break}U=U.return}v=U}}function Kl(r,a,o,m){r=null;for(var v=a,j=!1;v!==null;){if(!j){if((v.flags&524288)!==0)j=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var U=v.alternate;if(U===null)throw Error(l(387));if(U=U.memoizedProps,U!==null){var Q=v.type;Gr(v.pendingProps.value,U.value)||(r!==null?r.push(Q):r=[Q])}}else if(v===J.current){if(U=v.alternate,U===null)throw Error(l(387));U.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(r!==null?r.push(No):r=[No])}v=v.return}r!==null&&cf(a,r,o,m),a.flags|=262144}function Tc(r){for(r=r.firstContext;r!==null;){if(!Gr(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function xl(r){hl=r,ea=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function Nr(r){return Fp(hl,r)}function Ac(r,a){return hl===null&&xl(r),Fp(r,a)}function Fp(r,a){var o=a._currentValue;if(a={context:a,memoizedValue:o,next:null},ea===null){if(r===null)throw Error(l(308));ea=a,r.dependencies={lanes:0,firstContext:a},r.flags|=524288}else ea=ea.next=a;return o}var V5=typeof AbortController<"u"?AbortController:function(){var r=[],a=this.signal={aborted:!1,addEventListener:function(o,m){r.push(m)}};this.abort=function(){a.aborted=!0,r.forEach(function(o){return o()})}},Y5=e.unstable_scheduleCallback,G5=e.unstable_NormalPriority,Zn={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function df(){return{controller:new V5,data:new Map,refCount:0}}function Wi(r){r.refCount--,r.refCount===0&&Y5(G5,function(){r.controller.abort()})}var Zi=null,uf=0,Wl=0,Zl=null;function X5(r,a){if(Zi===null){var o=Zi=[];uf=0,Wl=hm(),Zl={status:"pending",value:void 0,then:function(m){o.push(m)}}}return uf++,a.then(Vp,Vp),a}function Vp(){if(--uf===0&&Zi!==null){Zl!==null&&(Zl.status="fulfilled");var r=Zi;Zi=null,Wl=0,Zl=null;for(var a=0;a<r.length;a++)(0,r[a])()}}function K5(r,a){var o=[],m={status:"pending",value:null,reason:null,then:function(v){o.push(v)}};return r.then(function(){m.status="fulfilled",m.value=a;for(var v=0;v<o.length;v++)(0,o[v])(a)},function(v){for(m.status="rejected",m.reason=v,v=0;v<o.length;v++)(0,o[v])(void 0)}),m}var Yp=O.S;O.S=function(r,a){A0=kt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&X5(r,a),Yp!==null&&Yp(r,a)};var pl=F(null);function ff(){var r=pl.current;return r!==null?r:En.pooledCache}function _c(r,a){a===null?I(pl,pl.current):I(pl,a.pool)}function Gp(){var r=ff();return r===null?null:{parent:Zn._currentValue,pool:r}}var Ql=Error(l(460)),mf=Error(l(474)),Mc=Error(l(542)),Rc={then:function(){}};function Xp(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Kp(r,a,o){switch(o=r[o],o===void 0?r.push(a):o!==a&&(a.then(Be,Be),a=o),a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Zp(r),r;default:if(typeof a.status=="string")a.then(Be,Be);else{if(r=En,r!==null&&100<r.shellSuspendCounter)throw Error(l(482));r=a,r.status="pending",r.then(function(m){if(a.status==="pending"){var v=a;v.status="fulfilled",v.value=m}},function(m){if(a.status==="pending"){var v=a;v.status="rejected",v.reason=m}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw r=a.reason,Zp(r),r}throw bl=a,Ql}}function gl(r){try{var a=r._init;return a(r._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(bl=o,Ql):o}}var bl=null;function Wp(){if(bl===null)throw Error(l(459));var r=bl;return bl=null,r}function Zp(r){if(r===Ql||r===Mc)throw Error(l(483))}var Jl=null,Qi=0;function Oc(r){var a=Qi;return Qi+=1,Jl===null&&(Jl=[]),Kp(Jl,r,a)}function Ji(r,a){a=a.props.ref,r.ref=a!==void 0?a:null}function Dc(r,a){throw a.$$typeof===g?Error(l(525)):(r=Object.prototype.toString.call(a),Error(l(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r)))}function Qp(r){function a(he,ce){if(r){var pe=he.deletions;pe===null?(he.deletions=[ce],he.flags|=16):pe.push(ce)}}function o(he,ce){if(!r)return null;for(;ce!==null;)a(he,ce),ce=ce.sibling;return null}function m(he){for(var ce=new Map;he!==null;)he.key!==null?ce.set(he.key,he):ce.set(he.index,he),he=he.sibling;return ce}function v(he,ce){return he=Qs(he,ce),he.index=0,he.sibling=null,he}function j(he,ce,pe){return he.index=pe,r?(pe=he.alternate,pe!==null?(pe=pe.index,pe<ce?(he.flags|=67108866,ce):pe):(he.flags|=67108866,ce)):(he.flags|=1048576,ce)}function U(he){return r&&he.alternate===null&&(he.flags|=67108866),he}function Q(he,ce,pe,_e){return ce===null||ce.tag!==6?(ce=ef(pe,he.mode,_e),ce.return=he,ce):(ce=v(ce,pe),ce.return=he,ce)}function ie(he,ce,pe,_e){var gt=pe.type;return gt===k?Ae(he,ce,pe.props.children,_e,pe.key):ce!==null&&(ce.elementType===gt||typeof gt=="object"&>!==null&>.$$typeof===q&&gl(gt)===ce.type)?(ce=v(ce,pe.props),Ji(ce,pe),ce.return=he,ce):(ce=Cc(pe.type,pe.key,pe.props,null,he.mode,_e),Ji(ce,pe),ce.return=he,ce)}function be(he,ce,pe,_e){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==pe.containerInfo||ce.stateNode.implementation!==pe.implementation?(ce=tf(pe,he.mode,_e),ce.return=he,ce):(ce=v(ce,pe.children||[]),ce.return=he,ce)}function Ae(he,ce,pe,_e,gt){return ce===null||ce.tag!==7?(ce=fl(pe,he.mode,_e,gt),ce.return=he,ce):(ce=v(ce,pe),ce.return=he,ce)}function De(he,ce,pe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=ef(""+ce,he.mode,pe),ce.return=he,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case b:return pe=Cc(ce.type,ce.key,ce.props,null,he.mode,pe),Ji(pe,ce),pe.return=he,pe;case w:return ce=tf(ce,he.mode,pe),ce.return=he,ce;case q:return ce=gl(ce),De(he,ce,pe)}if(z(ce)||G(ce))return ce=fl(ce,he.mode,pe,null),ce.return=he,ce;if(typeof ce.then=="function")return De(he,Oc(ce),pe);if(ce.$$typeof===N)return De(he,Ac(he,ce),pe);Dc(he,ce)}return null}function je(he,ce,pe,_e){var gt=ce!==null?ce.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return gt!==null?null:Q(he,ce,""+pe,_e);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case b:return pe.key===gt?ie(he,ce,pe,_e):null;case w:return pe.key===gt?be(he,ce,pe,_e):null;case q:return pe=gl(pe),je(he,ce,pe,_e)}if(z(pe)||G(pe))return gt!==null?null:Ae(he,ce,pe,_e,null);if(typeof pe.then=="function")return je(he,ce,Oc(pe),_e);if(pe.$$typeof===N)return je(he,ce,Ac(he,pe),_e);Dc(he,pe)}return null}function we(he,ce,pe,_e,gt){if(typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint")return he=he.get(pe)||null,Q(ce,he,""+_e,gt);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case b:return he=he.get(_e.key===null?pe:_e.key)||null,ie(ce,he,_e,gt);case w:return he=he.get(_e.key===null?pe:_e.key)||null,be(ce,he,_e,gt);case q:return _e=gl(_e),we(he,ce,pe,_e,gt)}if(z(_e)||G(_e))return he=he.get(pe)||null,Ae(ce,he,_e,gt,null);if(typeof _e.then=="function")return we(he,ce,pe,Oc(_e),gt);if(_e.$$typeof===N)return we(he,ce,pe,Ac(ce,_e),gt);Dc(ce,_e)}return null}function rt(he,ce,pe,_e){for(var gt=null,sn=null,ct=ce,Bt=ce=0,Wt=null;ct!==null&&Bt<pe.length;Bt++){ct.index>Bt?(Wt=ct,ct=null):Wt=ct.sibling;var an=je(he,ct,pe[Bt],_e);if(an===null){ct===null&&(ct=Wt);break}r&&ct&&an.alternate===null&&a(he,ct),ce=j(an,ce,Bt),sn===null?gt=an:sn.sibling=an,sn=an,ct=Wt}if(Bt===pe.length)return o(he,ct),Qt&&Js(he,Bt),gt;if(ct===null){for(;Bt<pe.length;Bt++)ct=De(he,pe[Bt],_e),ct!==null&&(ce=j(ct,ce,Bt),sn===null?gt=ct:sn.sibling=ct,sn=ct);return Qt&&Js(he,Bt),gt}for(ct=m(ct);Bt<pe.length;Bt++)Wt=we(ct,he,Bt,pe[Bt],_e),Wt!==null&&(r&&Wt.alternate!==null&&ct.delete(Wt.key===null?Bt:Wt.key),ce=j(Wt,ce,Bt),sn===null?gt=Wt:sn.sibling=Wt,sn=Wt);return r&&ct.forEach(function(Xa){return a(he,Xa)}),Qt&&Js(he,Bt),gt}function Nt(he,ce,pe,_e){if(pe==null)throw Error(l(151));for(var gt=null,sn=null,ct=ce,Bt=ce=0,Wt=null,an=pe.next();ct!==null&&!an.done;Bt++,an=pe.next()){ct.index>Bt?(Wt=ct,ct=null):Wt=ct.sibling;var Xa=je(he,ct,an.value,_e);if(Xa===null){ct===null&&(ct=Wt);break}r&&ct&&Xa.alternate===null&&a(he,ct),ce=j(Xa,ce,Bt),sn===null?gt=Xa:sn.sibling=Xa,sn=Xa,ct=Wt}if(an.done)return o(he,ct),Qt&&Js(he,Bt),gt;if(ct===null){for(;!an.done;Bt++,an=pe.next())an=De(he,an.value,_e),an!==null&&(ce=j(an,ce,Bt),sn===null?gt=an:sn.sibling=an,sn=an);return Qt&&Js(he,Bt),gt}for(ct=m(ct);!an.done;Bt++,an=pe.next())an=we(ct,he,Bt,an.value,_e),an!==null&&(r&&an.alternate!==null&&ct.delete(an.key===null?Bt:an.key),ce=j(an,ce,Bt),sn===null?gt=an:sn.sibling=an,sn=an);return r&&ct.forEach(function(lk){return a(he,lk)}),Qt&&Js(he,Bt),gt}function Nn(he,ce,pe,_e){if(typeof pe=="object"&&pe!==null&&pe.type===k&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case b:e:{for(var gt=pe.key;ce!==null;){if(ce.key===gt){if(gt=pe.type,gt===k){if(ce.tag===7){o(he,ce.sibling),_e=v(ce,pe.props.children),_e.return=he,he=_e;break e}}else if(ce.elementType===gt||typeof gt=="object"&>!==null&>.$$typeof===q&&gl(gt)===ce.type){o(he,ce.sibling),_e=v(ce,pe.props),Ji(_e,pe),_e.return=he,he=_e;break e}o(he,ce);break}else a(he,ce);ce=ce.sibling}pe.type===k?(_e=fl(pe.props.children,he.mode,_e,pe.key),_e.return=he,he=_e):(_e=Cc(pe.type,pe.key,pe.props,null,he.mode,_e),Ji(_e,pe),_e.return=he,he=_e)}return U(he);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){o(he,ce.sibling),_e=v(ce,pe.children||[]),_e.return=he,he=_e;break e}else{o(he,ce);break}else a(he,ce);ce=ce.sibling}_e=tf(pe,he.mode,_e),_e.return=he,he=_e}return U(he);case q:return pe=gl(pe),Nn(he,ce,pe,_e)}if(z(pe))return rt(he,ce,pe,_e);if(G(pe)){if(gt=G(pe),typeof gt!="function")throw Error(l(150));return pe=gt.call(pe),Nt(he,ce,pe,_e)}if(typeof pe.then=="function")return Nn(he,ce,Oc(pe),_e);if(pe.$$typeof===N)return Nn(he,ce,Ac(he,pe),_e);Dc(he,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint"?(pe=""+pe,ce!==null&&ce.tag===6?(o(he,ce.sibling),_e=v(ce,pe),_e.return=he,he=_e):(o(he,ce),_e=ef(pe,he.mode,_e),_e.return=he,he=_e),U(he)):o(he,ce)}return function(he,ce,pe,_e){try{Qi=0;var gt=Nn(he,ce,pe,_e);return Jl=null,gt}catch(ct){if(ct===Ql||ct===Mc)throw ct;var sn=Xr(29,ct,null,he.mode);return sn.lanes=_e,sn.return=he,sn}}}var yl=Qp(!0),Jp=Qp(!1),Ma=!1;function hf(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xf(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 Ra(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function Oa(r,a,o){var m=r.updateQueue;if(m===null)return null;if(m=m.shared,(cn&2)!==0){var v=m.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),m.pending=a,a=Sc(r),Ip(r,null,o),a}return kc(r,m,a,o),Sc(r)}function eo(r,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194048)!==0)){var m=a.lanes;m&=r.pendingLanes,o|=m,a.lanes=o,ur(r,o)}}function pf(r,a){var o=r.updateQueue,m=r.alternate;if(m!==null&&(m=m.updateQueue,o===m)){var v=null,j=null;if(o=o.firstBaseUpdate,o!==null){do{var U={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};j===null?v=j=U:j=j.next=U,o=o.next}while(o!==null);j===null?v=j=a:j=j.next=a}else v=j=a;o={baseState:m.baseState,firstBaseUpdate:v,lastBaseUpdate:j,shared:m.shared,callbacks:m.callbacks},r.updateQueue=o;return}r=o.lastBaseUpdate,r===null?o.firstBaseUpdate=a:r.next=a,o.lastBaseUpdate=a}var gf=!1;function to(){if(gf){var r=Zl;if(r!==null)throw r}}function no(r,a,o,m){gf=!1;var v=r.updateQueue;Ma=!1;var j=v.firstBaseUpdate,U=v.lastBaseUpdate,Q=v.shared.pending;if(Q!==null){v.shared.pending=null;var ie=Q,be=ie.next;ie.next=null,U===null?j=be:U.next=be,U=ie;var Ae=r.alternate;Ae!==null&&(Ae=Ae.updateQueue,Q=Ae.lastBaseUpdate,Q!==U&&(Q===null?Ae.firstBaseUpdate=be:Q.next=be,Ae.lastBaseUpdate=ie))}if(j!==null){var De=v.baseState;U=0,Ae=be=ie=null,Q=j;do{var je=Q.lane&-536870913,we=je!==Q.lane;if(we?(Kt&je)===je:(m&je)===je){je!==0&&je===Wl&&(gf=!0),Ae!==null&&(Ae=Ae.next={lane:0,tag:Q.tag,payload:Q.payload,callback:null,next:null});e:{var rt=r,Nt=Q;je=a;var Nn=o;switch(Nt.tag){case 1:if(rt=Nt.payload,typeof rt=="function"){De=rt.call(Nn,De,je);break e}De=rt;break e;case 3:rt.flags=rt.flags&-65537|128;case 0:if(rt=Nt.payload,je=typeof rt=="function"?rt.call(Nn,De,je):rt,je==null)break e;De=p({},De,je);break e;case 2:Ma=!0}}je=Q.callback,je!==null&&(r.flags|=64,we&&(r.flags|=8192),we=v.callbacks,we===null?v.callbacks=[je]:we.push(je))}else we={lane:je,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},Ae===null?(be=Ae=we,ie=De):Ae=Ae.next=we,U|=je;if(Q=Q.next,Q===null){if(Q=v.shared.pending,Q===null)break;we=Q,Q=we.next,we.next=null,v.lastBaseUpdate=we,v.shared.pending=null}}while(!0);Ae===null&&(ie=De),v.baseState=ie,v.firstBaseUpdate=be,v.lastBaseUpdate=Ae,j===null&&(v.shared.lanes=0),$a|=U,r.lanes=U,r.memoizedState=De}}function eg(r,a){if(typeof r!="function")throw Error(l(191,r));r.call(a)}function tg(r,a){var o=r.callbacks;if(o!==null)for(r.callbacks=null,r=0;r<o.length;r++)eg(o[r],a)}var ei=F(null),Lc=F(0);function ng(r,a){r=da,I(Lc,r),I(ei,a),da=r|a.baseLanes}function bf(){I(Lc,da),I(ei,ei.current)}function yf(){da=Lc.current,K(ei),K(Lc)}var Kr=F(null),fs=null;function Da(r){var a=r.alternate;I(Gn,Gn.current&1),I(Kr,r),fs===null&&(a===null||ei.current!==null||a.memoizedState!==null)&&(fs=r)}function vf(r){I(Gn,Gn.current),I(Kr,r),fs===null&&(fs=r)}function rg(r){r.tag===22?(I(Gn,Gn.current),I(Kr,r),fs===null&&(fs=r)):La()}function La(){I(Gn,Gn.current),I(Kr,Kr.current)}function Wr(r){K(Kr),fs===r&&(fs=null),K(Gn)}var Gn=F(0);function Ic(r){for(var a=r;a!==null;){if(a.tag===13){var o=a.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||Cm(o)||Em(o)))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 na=0,zt=null,jn=null,Qn=null,zc=!1,ti=!1,vl=!1,$c=0,ro=0,ni=null,W5=0;function Un(){throw Error(l(321))}function jf(r,a){if(a===null)return!1;for(var o=0;o<a.length&&o<r.length;o++)if(!Gr(r[o],a[o]))return!1;return!0}function wf(r,a,o,m,v,j){return na=j,zt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,O.H=r===null||r.memoizedState===null?Hg:zf,vl=!1,j=o(m,v),vl=!1,ti&&(j=ag(a,o,m,v)),sg(r),j}function sg(r){O.H=lo;var a=jn!==null&&jn.next!==null;if(na=0,Qn=jn=zt=null,zc=!1,ro=0,ni=null,a)throw Error(l(300));r===null||Jn||(r=r.dependencies,r!==null&&Tc(r)&&(Jn=!0))}function ag(r,a,o,m){zt=r;var v=0;do{if(ti&&(ni=null),ro=0,ti=!1,25<=v)throw Error(l(301));if(v+=1,Qn=jn=null,r.updateQueue!=null){var j=r.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}O.H=Pg,j=a(o,m)}while(ti);return j}function Z5(){var r=O.H,a=r.useState()[0];return a=typeof a.then=="function"?so(a):a,r=r.useState()[0],(jn!==null?jn.memoizedState:null)!==r&&(zt.flags|=1024),a}function Nf(){var r=$c!==0;return $c=0,r}function kf(r,a,o){a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~o}function Sf(r){if(zc){for(r=r.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}zc=!1}na=0,Qn=jn=zt=null,ti=!1,ro=$c=0,ni=null}function _r(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qn===null?zt.memoizedState=Qn=r:Qn=Qn.next=r,Qn}function Xn(){if(jn===null){var r=zt.alternate;r=r!==null?r.memoizedState:null}else r=jn.next;var a=Qn===null?zt.memoizedState:Qn.next;if(a!==null)Qn=a,jn=r;else{if(r===null)throw zt.alternate===null?Error(l(467)):Error(l(310));jn=r,r={memoizedState:jn.memoizedState,baseState:jn.baseState,baseQueue:jn.baseQueue,queue:jn.queue,next:null},Qn===null?zt.memoizedState=Qn=r:Qn=Qn.next=r}return Qn}function Bc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function so(r){var a=ro;return ro+=1,ni===null&&(ni=[]),r=Kp(ni,r,a),a=zt,(Qn===null?a.memoizedState:Qn.next)===null&&(a=a.alternate,O.H=a===null||a.memoizedState===null?Hg:zf),r}function Hc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return so(r);if(r.$$typeof===N)return Nr(r)}throw Error(l(438,String(r)))}function Cf(r){var a=null,o=zt.updateQueue;if(o!==null&&(a=o.memoCache),a==null){var m=zt.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(a={data:m.data.map(function(v){return v.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),o===null&&(o=Bc(),zt.updateQueue=o),o.memoCache=a,o=a.data[a.index],o===void 0)for(o=a.data[a.index]=Array(r),m=0;m<r;m++)o[m]=L;return a.index++,o}function ra(r,a){return typeof a=="function"?a(r):a}function Pc(r){var a=Xn();return Ef(a,jn,r)}function Ef(r,a,o){var m=r.queue;if(m===null)throw Error(l(311));m.lastRenderedReducer=o;var v=r.baseQueue,j=m.pending;if(j!==null){if(v!==null){var U=v.next;v.next=j.next,j.next=U}a.baseQueue=v=j,m.pending=null}if(j=r.baseState,v===null)r.memoizedState=j;else{a=v.next;var Q=U=null,ie=null,be=a,Ae=!1;do{var De=be.lane&-536870913;if(De!==be.lane?(Kt&De)===De:(na&De)===De){var je=be.revertLane;if(je===0)ie!==null&&(ie=ie.next={lane:0,revertLane:0,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null}),De===Wl&&(Ae=!0);else if((na&je)===je){be=be.next,je===Wl&&(Ae=!0);continue}else De={lane:0,revertLane:be.revertLane,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null},ie===null?(Q=ie=De,U=j):ie=ie.next=De,zt.lanes|=je,$a|=je;De=be.action,vl&&o(j,De),j=be.hasEagerState?be.eagerState:o(j,De)}else je={lane:De,revertLane:be.revertLane,gesture:be.gesture,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null},ie===null?(Q=ie=je,U=j):ie=ie.next=je,zt.lanes|=De,$a|=De;be=be.next}while(be!==null&&be!==a);if(ie===null?U=j:ie.next=Q,!Gr(j,r.memoizedState)&&(Jn=!0,Ae&&(o=Zl,o!==null)))throw o;r.memoizedState=j,r.baseState=U,r.baseQueue=ie,m.lastRenderedState=j}return v===null&&(m.lanes=0),[r.memoizedState,m.dispatch]}function Tf(r){var a=Xn(),o=a.queue;if(o===null)throw Error(l(311));o.lastRenderedReducer=r;var m=o.dispatch,v=o.pending,j=a.memoizedState;if(v!==null){o.pending=null;var U=v=v.next;do j=r(j,U.action),U=U.next;while(U!==v);Gr(j,a.memoizedState)||(Jn=!0),a.memoizedState=j,a.baseQueue===null&&(a.baseState=j),o.lastRenderedState=j}return[j,m]}function lg(r,a,o){var m=zt,v=Xn(),j=Qt;if(j){if(o===void 0)throw Error(l(407));o=o()}else o=a();var U=!Gr((jn||v).memoizedState,o);if(U&&(v.memoizedState=o,Jn=!0),v=v.queue,Mf(cg.bind(null,m,v,r),[r]),v.getSnapshot!==a||U||Qn!==null&&Qn.memoizedState.tag&1){if(m.flags|=2048,ri(9,{destroy:void 0},og.bind(null,m,v,o,a),null),En===null)throw Error(l(349));j||(na&127)!==0||ig(m,a,o)}return o}function ig(r,a,o){r.flags|=16384,r={getSnapshot:a,value:o},a=zt.updateQueue,a===null?(a=Bc(),zt.updateQueue=a,a.stores=[r]):(o=a.stores,o===null?a.stores=[r]:o.push(r))}function og(r,a,o,m){a.value=o,a.getSnapshot=m,dg(a)&&ug(r)}function cg(r,a,o){return o(function(){dg(a)&&ug(r)})}function dg(r){var a=r.getSnapshot;r=r.value;try{var o=a();return!Gr(r,o)}catch{return!0}}function ug(r){var a=ul(r,2);a!==null&&Pr(a,r,2)}function Af(r){var a=_r();if(typeof r=="function"){var o=r;if(r=o(),vl){Jt(!0);try{o()}finally{Jt(!1)}}}return a.memoizedState=a.baseState=r,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ra,lastRenderedState:r},a}function fg(r,a,o,m){return r.baseState=o,Ef(r,jn,typeof m=="function"?m:ra)}function Q5(r,a,o,m,v){if(Fc(r))throw Error(l(485));if(r=a.action,r!==null){var j={payload:v,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(U){j.listeners.push(U)}};O.T!==null?o(!0):j.isTransition=!1,m(j),o=a.pending,o===null?(j.next=a.pending=j,mg(a,j)):(j.next=o.next,a.pending=o.next=j)}}function mg(r,a){var o=a.action,m=a.payload,v=r.state;if(a.isTransition){var j=O.T,U={};O.T=U;try{var Q=o(v,m),ie=O.S;ie!==null&&ie(U,Q),hg(r,a,Q)}catch(be){_f(r,a,be)}finally{j!==null&&U.types!==null&&(j.types=U.types),O.T=j}}else try{j=o(v,m),hg(r,a,j)}catch(be){_f(r,a,be)}}function hg(r,a,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(m){xg(r,a,m)},function(m){return _f(r,a,m)}):xg(r,a,o)}function xg(r,a,o){a.status="fulfilled",a.value=o,pg(a),r.state=o,a=r.pending,a!==null&&(o=a.next,o===a?r.pending=null:(o=o.next,a.next=o,mg(r,o)))}function _f(r,a,o){var m=r.pending;if(r.pending=null,m!==null){m=m.next;do a.status="rejected",a.reason=o,pg(a),a=a.next;while(a!==m)}r.action=null}function pg(r){r=r.listeners;for(var a=0;a<r.length;a++)(0,r[a])()}function gg(r,a){return a}function bg(r,a){if(Qt){var o=En.formState;if(o!==null){e:{var m=zt;if(Qt){if(Rn){t:{for(var v=Rn,j=us;v.nodeType!==8;){if(!j){v=null;break t}if(v=ms(v.nextSibling),v===null){v=null;break t}}j=v.data,v=j==="F!"||j==="F"?v:null}if(v){Rn=ms(v.nextSibling),m=v.data==="F!";break e}}Aa(m)}m=!1}m&&(a=o[0])}}return o=_r(),o.memoizedState=o.baseState=a,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gg,lastRenderedState:a},o.queue=m,o=zg.bind(null,zt,m),m.dispatch=o,m=Af(!1),j=If.bind(null,zt,!1,m.queue),m=_r(),v={state:a,dispatch:null,action:r,pending:null},m.queue=v,o=Q5.bind(null,zt,v,j,o),v.dispatch=o,m.memoizedState=r,[a,o,!1]}function yg(r){var a=Xn();return vg(a,jn,r)}function vg(r,a,o){if(a=Ef(r,a,gg)[0],r=Pc(ra)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var m=so(a)}catch(U){throw U===Ql?Mc:U}else m=a;a=Xn();var v=a.queue,j=v.dispatch;return o!==a.memoizedState&&(zt.flags|=2048,ri(9,{destroy:void 0},J5.bind(null,v,o),null)),[m,j,r]}function J5(r,a){r.action=a}function jg(r){var a=Xn(),o=jn;if(o!==null)return vg(a,o,r);Xn(),a=a.memoizedState,o=Xn();var m=o.queue.dispatch;return o.memoizedState=r,[a,m,!1]}function ri(r,a,o,m){return r={tag:r,create:o,deps:m,inst:a,next:null},a=zt.updateQueue,a===null&&(a=Bc(),zt.updateQueue=a),o=a.lastEffect,o===null?a.lastEffect=r.next=r:(m=o.next,o.next=r,r.next=m,a.lastEffect=r),r}function wg(){return Xn().memoizedState}function Uc(r,a,o,m){var v=_r();zt.flags|=r,v.memoizedState=ri(1|a,{destroy:void 0},o,m===void 0?null:m)}function qc(r,a,o,m){var v=Xn();m=m===void 0?null:m;var j=v.memoizedState.inst;jn!==null&&m!==null&&jf(m,jn.memoizedState.deps)?v.memoizedState=ri(a,j,o,m):(zt.flags|=r,v.memoizedState=ri(1|a,j,o,m))}function Ng(r,a){Uc(8390656,8,r,a)}function Mf(r,a){qc(2048,8,r,a)}function e2(r){zt.flags|=4;var a=zt.updateQueue;if(a===null)a=Bc(),zt.updateQueue=a,a.events=[r];else{var o=a.events;o===null?a.events=[r]:o.push(r)}}function kg(r){var a=Xn().memoizedState;return e2({ref:a,nextImpl:r}),function(){if((cn&2)!==0)throw Error(l(440));return a.impl.apply(void 0,arguments)}}function Sg(r,a){return qc(4,2,r,a)}function Cg(r,a){return qc(4,4,r,a)}function Eg(r,a){if(typeof a=="function"){r=r();var o=a(r);return function(){typeof o=="function"?o():a(null)}}if(a!=null)return r=r(),a.current=r,function(){a.current=null}}function Tg(r,a,o){o=o!=null?o.concat([r]):null,qc(4,4,Eg.bind(null,a,r),o)}function Rf(){}function Ag(r,a){var o=Xn();a=a===void 0?null:a;var m=o.memoizedState;return a!==null&&jf(a,m[1])?m[0]:(o.memoizedState=[r,a],r)}function _g(r,a){var o=Xn();a=a===void 0?null:a;var m=o.memoizedState;if(a!==null&&jf(a,m[1]))return m[0];if(m=r(),vl){Jt(!0);try{r()}finally{Jt(!1)}}return o.memoizedState=[m,a],m}function Of(r,a,o){return o===void 0||(na&1073741824)!==0&&(Kt&261930)===0?r.memoizedState=a:(r.memoizedState=o,r=M0(),zt.lanes|=r,$a|=r,o)}function Mg(r,a,o,m){return Gr(o,a)?o:ei.current!==null?(r=Of(r,o,m),Gr(r,a)||(Jn=!0),r):(na&42)===0||(na&1073741824)!==0&&(Kt&261930)===0?(Jn=!0,r.memoizedState=o):(r=M0(),zt.lanes|=r,$a|=r,a)}function Rg(r,a,o,m,v){var j=V.p;V.p=j!==0&&8>j?j:8;var U=O.T,Q={};O.T=Q,If(r,!1,a,o);try{var ie=v(),be=O.S;if(be!==null&&be(Q,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var Ae=K5(ie,m);ao(r,a,Ae,Jr(r))}else ao(r,a,m,Jr(r))}catch(De){ao(r,a,{then:function(){},status:"rejected",reason:De},Jr())}finally{V.p=j,U!==null&&Q.types!==null&&(U.types=Q.types),O.T=U}}function t2(){}function Df(r,a,o,m){if(r.tag!==5)throw Error(l(476));var v=Og(r).queue;Rg(r,v,a,H,o===null?t2:function(){return Dg(r),o(m)})}function Og(r){var a=r.memoizedState;if(a!==null)return a;a={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ra,lastRenderedState:H},next:null};var o={};return a.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ra,lastRenderedState:o},next:null},r.memoizedState=a,r=r.alternate,r!==null&&(r.memoizedState=a),a}function Dg(r){var a=Og(r);a.next===null&&(a=r.alternate.memoizedState),ao(r,a.next.queue,{},Jr())}function Lf(){return Nr(No)}function Lg(){return Xn().memoizedState}function Ig(){return Xn().memoizedState}function n2(r){for(var a=r.return;a!==null;){switch(a.tag){case 24:case 3:var o=Jr();r=Ra(o);var m=Oa(a,r,o);m!==null&&(Pr(m,a,o),eo(m,a,o)),a={cache:df()},r.payload=a;return}a=a.return}}function r2(r,a,o){var m=Jr();o={lane:m,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Fc(r)?$g(a,o):(o=Qu(r,a,o,m),o!==null&&(Pr(o,r,m),Bg(o,a,m)))}function zg(r,a,o){var m=Jr();ao(r,a,o,m)}function ao(r,a,o,m){var v={lane:m,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Fc(r))$g(a,v);else{var j=r.alternate;if(r.lanes===0&&(j===null||j.lanes===0)&&(j=a.lastRenderedReducer,j!==null))try{var U=a.lastRenderedState,Q=j(U,o);if(v.hasEagerState=!0,v.eagerState=Q,Gr(Q,U))return kc(r,a,v,0),En===null&&Nc(),!1}catch{}if(o=Qu(r,a,v,m),o!==null)return Pr(o,r,m),Bg(o,a,m),!0}return!1}function If(r,a,o,m){if(m={lane:2,revertLane:hm(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Fc(r)){if(a)throw Error(l(479))}else a=Qu(r,o,m,2),a!==null&&Pr(a,r,2)}function Fc(r){var a=r.alternate;return r===zt||a!==null&&a===zt}function $g(r,a){ti=zc=!0;var o=r.pending;o===null?a.next=a:(a.next=o.next,o.next=a),r.pending=a}function Bg(r,a,o){if((o&4194048)!==0){var m=a.lanes;m&=r.pendingLanes,o|=m,a.lanes=o,ur(r,o)}}var lo={readContext:Nr,use:Hc,useCallback:Un,useContext:Un,useEffect:Un,useImperativeHandle:Un,useLayoutEffect:Un,useInsertionEffect:Un,useMemo:Un,useReducer:Un,useRef:Un,useState:Un,useDebugValue:Un,useDeferredValue:Un,useTransition:Un,useSyncExternalStore:Un,useId:Un,useHostTransitionStatus:Un,useFormState:Un,useActionState:Un,useOptimistic:Un,useMemoCache:Un,useCacheRefresh:Un};lo.useEffectEvent=Un;var Hg={readContext:Nr,use:Hc,useCallback:function(r,a){return _r().memoizedState=[r,a===void 0?null:a],r},useContext:Nr,useEffect:Ng,useImperativeHandle:function(r,a,o){o=o!=null?o.concat([r]):null,Uc(4194308,4,Eg.bind(null,a,r),o)},useLayoutEffect:function(r,a){return Uc(4194308,4,r,a)},useInsertionEffect:function(r,a){Uc(4,2,r,a)},useMemo:function(r,a){var o=_r();a=a===void 0?null:a;var m=r();if(vl){Jt(!0);try{r()}finally{Jt(!1)}}return o.memoizedState=[m,a],m},useReducer:function(r,a,o){var m=_r();if(o!==void 0){var v=o(a);if(vl){Jt(!0);try{o(a)}finally{Jt(!1)}}}else v=a;return m.memoizedState=m.baseState=v,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:v},m.queue=r,r=r.dispatch=r2.bind(null,zt,r),[m.memoizedState,r]},useRef:function(r){var a=_r();return r={current:r},a.memoizedState=r},useState:function(r){r=Af(r);var a=r.queue,o=zg.bind(null,zt,a);return a.dispatch=o,[r.memoizedState,o]},useDebugValue:Rf,useDeferredValue:function(r,a){var o=_r();return Of(o,r,a)},useTransition:function(){var r=Af(!1);return r=Rg.bind(null,zt,r.queue,!0,!1),_r().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,a,o){var m=zt,v=_r();if(Qt){if(o===void 0)throw Error(l(407));o=o()}else{if(o=a(),En===null)throw Error(l(349));(Kt&127)!==0||ig(m,a,o)}v.memoizedState=o;var j={value:o,getSnapshot:a};return v.queue=j,Ng(cg.bind(null,m,j,r),[r]),m.flags|=2048,ri(9,{destroy:void 0},og.bind(null,m,j,o,a),null),o},useId:function(){var r=_r(),a=En.identifierPrefix;if(Qt){var o=zs,m=Is;o=(m&~(1<<32-yt(m)-1)).toString(32)+o,a="_"+a+"R_"+o,o=$c++,0<o&&(a+="H"+o.toString(32)),a+="_"}else o=W5++,a="_"+a+"r_"+o.toString(32)+"_";return r.memoizedState=a},useHostTransitionStatus:Lf,useFormState:bg,useActionState:bg,useOptimistic:function(r){var a=_r();a.memoizedState=a.baseState=r;var o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=o,a=If.bind(null,zt,!0,o),o.dispatch=a,[r,a]},useMemoCache:Cf,useCacheRefresh:function(){return _r().memoizedState=n2.bind(null,zt)},useEffectEvent:function(r){var a=_r(),o={impl:r};return a.memoizedState=o,function(){if((cn&2)!==0)throw Error(l(440));return o.impl.apply(void 0,arguments)}}},zf={readContext:Nr,use:Hc,useCallback:Ag,useContext:Nr,useEffect:Mf,useImperativeHandle:Tg,useInsertionEffect:Sg,useLayoutEffect:Cg,useMemo:_g,useReducer:Pc,useRef:wg,useState:function(){return Pc(ra)},useDebugValue:Rf,useDeferredValue:function(r,a){var o=Xn();return Mg(o,jn.memoizedState,r,a)},useTransition:function(){var r=Pc(ra)[0],a=Xn().memoizedState;return[typeof r=="boolean"?r:so(r),a]},useSyncExternalStore:lg,useId:Lg,useHostTransitionStatus:Lf,useFormState:yg,useActionState:yg,useOptimistic:function(r,a){var o=Xn();return fg(o,jn,r,a)},useMemoCache:Cf,useCacheRefresh:Ig};zf.useEffectEvent=kg;var Pg={readContext:Nr,use:Hc,useCallback:Ag,useContext:Nr,useEffect:Mf,useImperativeHandle:Tg,useInsertionEffect:Sg,useLayoutEffect:Cg,useMemo:_g,useReducer:Tf,useRef:wg,useState:function(){return Tf(ra)},useDebugValue:Rf,useDeferredValue:function(r,a){var o=Xn();return jn===null?Of(o,r,a):Mg(o,jn.memoizedState,r,a)},useTransition:function(){var r=Tf(ra)[0],a=Xn().memoizedState;return[typeof r=="boolean"?r:so(r),a]},useSyncExternalStore:lg,useId:Lg,useHostTransitionStatus:Lf,useFormState:jg,useActionState:jg,useOptimistic:function(r,a){var o=Xn();return jn!==null?fg(o,jn,r,a):(o.baseState=r,[r,o.queue.dispatch])},useMemoCache:Cf,useCacheRefresh:Ig};Pg.useEffectEvent=kg;function $f(r,a,o,m){a=r.memoizedState,o=o(m,a),o=o==null?a:p({},a,o),r.memoizedState=o,r.lanes===0&&(r.updateQueue.baseState=o)}var Bf={enqueueSetState:function(r,a,o){r=r._reactInternals;var m=Jr(),v=Ra(m);v.payload=a,o!=null&&(v.callback=o),a=Oa(r,v,m),a!==null&&(Pr(a,r,m),eo(a,r,m))},enqueueReplaceState:function(r,a,o){r=r._reactInternals;var m=Jr(),v=Ra(m);v.tag=1,v.payload=a,o!=null&&(v.callback=o),a=Oa(r,v,m),a!==null&&(Pr(a,r,m),eo(a,r,m))},enqueueForceUpdate:function(r,a){r=r._reactInternals;var o=Jr(),m=Ra(o);m.tag=2,a!=null&&(m.callback=a),a=Oa(r,m,o),a!==null&&(Pr(a,r,o),eo(a,r,o))}};function Ug(r,a,o,m,v,j,U){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(m,j,U):a.prototype&&a.prototype.isPureReactComponent?!Yi(o,m)||!Yi(v,j):!0}function qg(r,a,o,m){r=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(o,m),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(o,m),a.state!==r&&Bf.enqueueReplaceState(a,a.state,null)}function jl(r,a){var o=a;if("ref"in a){o={};for(var m in a)m!=="ref"&&(o[m]=a[m])}if(r=r.defaultProps){o===a&&(o=p({},o));for(var v in r)o[v]===void 0&&(o[v]=r[v])}return o}function Fg(r){wc(r)}function Vg(r){console.error(r)}function Yg(r){wc(r)}function Vc(r,a){try{var o=r.onUncaughtError;o(a.value,{componentStack:a.stack})}catch(m){setTimeout(function(){throw m})}}function Gg(r,a,o){try{var m=r.onCaughtError;m(o.value,{componentStack:o.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function Hf(r,a,o){return o=Ra(o),o.tag=3,o.payload={element:null},o.callback=function(){Vc(r,a)},o}function Xg(r){return r=Ra(r),r.tag=3,r}function Kg(r,a,o,m){var v=o.type.getDerivedStateFromError;if(typeof v=="function"){var j=m.value;r.payload=function(){return v(j)},r.callback=function(){Gg(a,o,m)}}var U=o.stateNode;U!==null&&typeof U.componentDidCatch=="function"&&(r.callback=function(){Gg(a,o,m),typeof v!="function"&&(Ba===null?Ba=new Set([this]):Ba.add(this));var Q=m.stack;this.componentDidCatch(m.value,{componentStack:Q!==null?Q:""})})}function s2(r,a,o,m,v){if(o.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(a=o.alternate,a!==null&&Kl(a,o,v,!0),o=Kr.current,o!==null){switch(o.tag){case 31:case 13:return fs===null?rd():o.alternate===null&&qn===0&&(qn=3),o.flags&=-257,o.flags|=65536,o.lanes=v,m===Rc?o.flags|=16384:(a=o.updateQueue,a===null?o.updateQueue=new Set([m]):a.add(m),um(r,m,v)),!1;case 22:return o.flags|=65536,m===Rc?o.flags|=16384:(a=o.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([m])},o.updateQueue=a):(o=a.retryQueue,o===null?a.retryQueue=new Set([m]):o.add(m)),um(r,m,v)),!1}throw Error(l(435,o.tag))}return um(r,m,v),rd(),!1}if(Qt)return a=Kr.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=v,m!==sf&&(r=Error(l(422),{cause:m}),Ki(os(r,o)))):(m!==sf&&(a=Error(l(423),{cause:m}),Ki(os(a,o))),r=r.current.alternate,r.flags|=65536,v&=-v,r.lanes|=v,m=os(m,o),v=Hf(r.stateNode,m,v),pf(r,v),qn!==4&&(qn=2)),!1;var j=Error(l(520),{cause:m});if(j=os(j,o),xo===null?xo=[j]:xo.push(j),qn!==4&&(qn=2),a===null)return!0;m=os(m,o),o=a;do{switch(o.tag){case 3:return o.flags|=65536,r=v&-v,o.lanes|=r,r=Hf(o.stateNode,m,r),pf(o,r),!1;case 1:if(a=o.type,j=o.stateNode,(o.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(Ba===null||!Ba.has(j))))return o.flags|=65536,v&=-v,o.lanes|=v,v=Xg(v),Kg(v,r,o,m),pf(o,v),!1}o=o.return}while(o!==null);return!1}var Pf=Error(l(461)),Jn=!1;function kr(r,a,o,m){a.child=r===null?Jp(a,null,o,m):yl(a,r.child,o,m)}function Wg(r,a,o,m,v){o=o.render;var j=a.ref;if("ref"in m){var U={};for(var Q in m)Q!=="ref"&&(U[Q]=m[Q])}else U=m;return xl(a),m=wf(r,a,o,U,j,v),Q=Nf(),r!==null&&!Jn?(kf(r,a,v),sa(r,a,v)):(Qt&&Q&&nf(a),a.flags|=1,kr(r,a,m,v),a.child)}function Zg(r,a,o,m,v){if(r===null){var j=o.type;return typeof j=="function"&&!Ju(j)&&j.defaultProps===void 0&&o.compare===null?(a.tag=15,a.type=j,Qg(r,a,j,m,v)):(r=Cc(o.type,null,m,a,a.mode,v),r.ref=a.ref,r.return=a,a.child=r)}if(j=r.child,!Kf(r,v)){var U=j.memoizedProps;if(o=o.compare,o=o!==null?o:Yi,o(U,m)&&r.ref===a.ref)return sa(r,a,v)}return a.flags|=1,r=Qs(j,m),r.ref=a.ref,r.return=a,a.child=r}function Qg(r,a,o,m,v){if(r!==null){var j=r.memoizedProps;if(Yi(j,m)&&r.ref===a.ref)if(Jn=!1,a.pendingProps=m=j,Kf(r,v))(r.flags&131072)!==0&&(Jn=!0);else return a.lanes=r.lanes,sa(r,a,v)}return Uf(r,a,o,m,v)}function Jg(r,a,o,m){var v=m.children,j=r!==null?r.memoizedState:null;if(r===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((a.flags&128)!==0){if(j=j!==null?j.baseLanes|o:o,r!==null){for(m=a.child=r.child,v=0;m!==null;)v=v|m.lanes|m.childLanes,m=m.sibling;m=v&~j}else m=0,a.child=null;return e0(r,a,j,o,m)}if((o&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},r!==null&&_c(a,j!==null?j.cachePool:null),j!==null?ng(a,j):bf(),rg(a);else return m=a.lanes=536870912,e0(r,a,j!==null?j.baseLanes|o:o,o,m)}else j!==null?(_c(a,j.cachePool),ng(a,j),La(),a.memoizedState=null):(r!==null&&_c(a,null),bf(),La());return kr(r,a,v,o),a.child}function io(r,a){return r!==null&&r.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function e0(r,a,o,m,v){var j=ff();return j=j===null?null:{parent:Zn._currentValue,pool:j},a.memoizedState={baseLanes:o,cachePool:j},r!==null&&_c(a,null),bf(),rg(a),r!==null&&Kl(r,a,m,!0),a.childLanes=v,null}function Yc(r,a){return a=Xc({mode:a.mode,children:a.children},r.mode),a.ref=r.ref,r.child=a,a.return=r,a}function t0(r,a,o){return yl(a,r.child,null,o),r=Yc(a,a.pendingProps),r.flags|=2,Wr(a),a.memoizedState=null,r}function a2(r,a,o){var m=a.pendingProps,v=(a.flags&128)!==0;if(a.flags&=-129,r===null){if(Qt){if(m.mode==="hidden")return r=Yc(a,m),a.lanes=536870912,io(null,r);if(vf(a),(r=Rn)?(r=mb(r,us),r=r!==null&&r.data==="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:Ea!==null?{id:Is,overflow:zs}:null,retryLane:536870912,hydrationErrors:null},o=$p(r),o.return=a,a.child=o,wr=a,Rn=null)):r=null,r===null)throw Aa(a);return a.lanes=536870912,null}return Yc(a,m)}var j=r.memoizedState;if(j!==null){var U=j.dehydrated;if(vf(a),v)if(a.flags&256)a.flags&=-257,a=t0(r,a,o);else if(a.memoizedState!==null)a.child=r.child,a.flags|=128,a=null;else throw Error(l(558));else if(Jn||Kl(r,a,o,!1),v=(o&r.childLanes)!==0,Jn||v){if(m=En,m!==null&&(U=$n(m,o),U!==0&&U!==j.retryLane))throw j.retryLane=U,ul(r,U),Pr(m,r,U),Pf;rd(),a=t0(r,a,o)}else r=j.treeContext,Rn=ms(U.nextSibling),wr=a,Qt=!0,Ta=null,us=!1,r!==null&&Pp(a,r),a=Yc(a,m),a.flags|=4096;return a}return r=Qs(r.child,{mode:m.mode,children:m.children}),r.ref=a.ref,a.child=r,r.return=a,r}function Gc(r,a){var o=a.ref;if(o===null)r!==null&&r.ref!==null&&(a.flags|=4194816);else{if(typeof o!="function"&&typeof o!="object")throw Error(l(284));(r===null||r.ref!==o)&&(a.flags|=4194816)}}function Uf(r,a,o,m,v){return xl(a),o=wf(r,a,o,m,void 0,v),m=Nf(),r!==null&&!Jn?(kf(r,a,v),sa(r,a,v)):(Qt&&m&&nf(a),a.flags|=1,kr(r,a,o,v),a.child)}function n0(r,a,o,m,v,j){return xl(a),a.updateQueue=null,o=ag(a,m,o,v),sg(r),m=Nf(),r!==null&&!Jn?(kf(r,a,j),sa(r,a,j)):(Qt&&m&&nf(a),a.flags|=1,kr(r,a,o,j),a.child)}function r0(r,a,o,m,v){if(xl(a),a.stateNode===null){var j=Vl,U=o.contextType;typeof U=="object"&&U!==null&&(j=Nr(U)),j=new o(m,j),a.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=Bf,a.stateNode=j,j._reactInternals=a,j=a.stateNode,j.props=m,j.state=a.memoizedState,j.refs={},hf(a),U=o.contextType,j.context=typeof U=="object"&&U!==null?Nr(U):Vl,j.state=a.memoizedState,U=o.getDerivedStateFromProps,typeof U=="function"&&($f(a,o,U,m),j.state=a.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(U=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),U!==j.state&&Bf.enqueueReplaceState(j,j.state,null),no(a,m,j,v),to(),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308),m=!0}else if(r===null){j=a.stateNode;var Q=a.memoizedProps,ie=jl(o,Q);j.props=ie;var be=j.context,Ae=o.contextType;U=Vl,typeof Ae=="object"&&Ae!==null&&(U=Nr(Ae));var De=o.getDerivedStateFromProps;Ae=typeof De=="function"||typeof j.getSnapshotBeforeUpdate=="function",Q=a.pendingProps!==Q,Ae||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(Q||be!==U)&&qg(a,j,m,U),Ma=!1;var je=a.memoizedState;j.state=je,no(a,m,j,v),to(),be=a.memoizedState,Q||je!==be||Ma?(typeof De=="function"&&($f(a,o,De,m),be=a.memoizedState),(ie=Ma||Ug(a,o,ie,m,je,be,U))?(Ae||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(a.flags|=4194308)):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=m,a.memoizedState=be),j.props=m,j.state=be,j.context=U,m=ie):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),m=!1)}else{j=a.stateNode,xf(r,a),U=a.memoizedProps,Ae=jl(o,U),j.props=Ae,De=a.pendingProps,je=j.context,be=o.contextType,ie=Vl,typeof be=="object"&&be!==null&&(ie=Nr(be)),Q=o.getDerivedStateFromProps,(be=typeof Q=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(U!==De||je!==ie)&&qg(a,j,m,ie),Ma=!1,je=a.memoizedState,j.state=je,no(a,m,j,v),to();var we=a.memoizedState;U!==De||je!==we||Ma||r!==null&&r.dependencies!==null&&Tc(r.dependencies)?(typeof Q=="function"&&($f(a,o,Q,m),we=a.memoizedState),(Ae=Ma||Ug(a,o,Ae,m,je,we,ie)||r!==null&&r.dependencies!==null&&Tc(r.dependencies))?(be||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(m,we,ie),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(m,we,ie)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||U===r.memoizedProps&&je===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||U===r.memoizedProps&&je===r.memoizedState||(a.flags|=1024),a.memoizedProps=m,a.memoizedState=we),j.props=m,j.state=we,j.context=ie,m=Ae):(typeof j.componentDidUpdate!="function"||U===r.memoizedProps&&je===r.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||U===r.memoizedProps&&je===r.memoizedState||(a.flags|=1024),m=!1)}return j=m,Gc(r,a),m=(a.flags&128)!==0,j||m?(j=a.stateNode,o=m&&typeof o.getDerivedStateFromError!="function"?null:j.render(),a.flags|=1,r!==null&&m?(a.child=yl(a,r.child,null,v),a.child=yl(a,null,o,v)):kr(r,a,o,v),a.memoizedState=j.state,r=a.child):r=sa(r,a,v),r}function s0(r,a,o,m){return ml(),a.flags|=256,kr(r,a,o,m),a.child}var qf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ff(r){return{baseLanes:r,cachePool:Gp()}}function Vf(r,a,o){return r=r!==null?r.childLanes&~o:0,a&&(r|=Qr),r}function a0(r,a,o){var m=a.pendingProps,v=!1,j=(a.flags&128)!==0,U;if((U=j)||(U=r!==null&&r.memoizedState===null?!1:(Gn.current&2)!==0),U&&(v=!0,a.flags&=-129),U=(a.flags&32)!==0,a.flags&=-33,r===null){if(Qt){if(v?Da(a):La(),(r=Rn)?(r=mb(r,us),r=r!==null&&r.data!=="&"?r:null,r!==null&&(a.memoizedState={dehydrated:r,treeContext:Ea!==null?{id:Is,overflow:zs}:null,retryLane:536870912,hydrationErrors:null},o=$p(r),o.return=a,a.child=o,wr=a,Rn=null)):r=null,r===null)throw Aa(a);return Em(r)?a.lanes=32:a.lanes=536870912,null}var Q=m.children;return m=m.fallback,v?(La(),v=a.mode,Q=Xc({mode:"hidden",children:Q},v),m=fl(m,v,o,null),Q.return=a,m.return=a,Q.sibling=m,a.child=Q,m=a.child,m.memoizedState=Ff(o),m.childLanes=Vf(r,U,o),a.memoizedState=qf,io(null,m)):(Da(a),Yf(a,Q))}var ie=r.memoizedState;if(ie!==null&&(Q=ie.dehydrated,Q!==null)){if(j)a.flags&256?(Da(a),a.flags&=-257,a=Gf(r,a,o)):a.memoizedState!==null?(La(),a.child=r.child,a.flags|=128,a=null):(La(),Q=m.fallback,v=a.mode,m=Xc({mode:"visible",children:m.children},v),Q=fl(Q,v,o,null),Q.flags|=2,m.return=a,Q.return=a,m.sibling=Q,a.child=m,yl(a,r.child,null,o),m=a.child,m.memoizedState=Ff(o),m.childLanes=Vf(r,U,o),a.memoizedState=qf,a=io(null,m));else if(Da(a),Em(Q)){if(U=Q.nextSibling&&Q.nextSibling.dataset,U)var be=U.dgst;U=be,m=Error(l(419)),m.stack="",m.digest=U,Ki({value:m,source:null,stack:null}),a=Gf(r,a,o)}else if(Jn||Kl(r,a,o,!1),U=(o&r.childLanes)!==0,Jn||U){if(U=En,U!==null&&(m=$n(U,o),m!==0&&m!==ie.retryLane))throw ie.retryLane=m,ul(r,m),Pr(U,r,m),Pf;Cm(Q)||rd(),a=Gf(r,a,o)}else Cm(Q)?(a.flags|=192,a.child=r.child,a=null):(r=ie.treeContext,Rn=ms(Q.nextSibling),wr=a,Qt=!0,Ta=null,us=!1,r!==null&&Pp(a,r),a=Yf(a,m.children),a.flags|=4096);return a}return v?(La(),Q=m.fallback,v=a.mode,ie=r.child,be=ie.sibling,m=Qs(ie,{mode:"hidden",children:m.children}),m.subtreeFlags=ie.subtreeFlags&65011712,be!==null?Q=Qs(be,Q):(Q=fl(Q,v,o,null),Q.flags|=2),Q.return=a,m.return=a,m.sibling=Q,a.child=m,io(null,m),m=a.child,Q=r.child.memoizedState,Q===null?Q=Ff(o):(v=Q.cachePool,v!==null?(ie=Zn._currentValue,v=v.parent!==ie?{parent:ie,pool:ie}:v):v=Gp(),Q={baseLanes:Q.baseLanes|o,cachePool:v}),m.memoizedState=Q,m.childLanes=Vf(r,U,o),a.memoizedState=qf,io(r.child,m)):(Da(a),o=r.child,r=o.sibling,o=Qs(o,{mode:"visible",children:m.children}),o.return=a,o.sibling=null,r!==null&&(U=a.deletions,U===null?(a.deletions=[r],a.flags|=16):U.push(r)),a.child=o,a.memoizedState=null,o)}function Yf(r,a){return a=Xc({mode:"visible",children:a},r.mode),a.return=r,r.child=a}function Xc(r,a){return r=Xr(22,r,null,a),r.lanes=0,r}function Gf(r,a,o){return yl(a,r.child,null,o),r=Yf(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function l0(r,a,o){r.lanes|=a;var m=r.alternate;m!==null&&(m.lanes|=a),of(r.return,a,o)}function Xf(r,a,o,m,v,j){var U=r.memoizedState;U===null?r.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:m,tail:o,tailMode:v,treeForkCount:j}:(U.isBackwards=a,U.rendering=null,U.renderingStartTime=0,U.last=m,U.tail=o,U.tailMode=v,U.treeForkCount=j)}function i0(r,a,o){var m=a.pendingProps,v=m.revealOrder,j=m.tail;m=m.children;var U=Gn.current,Q=(U&2)!==0;if(Q?(U=U&1|2,a.flags|=128):U&=1,I(Gn,U),kr(r,a,m,o),m=Qt?Xi:0,!Q&&r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&l0(r,o,a);else if(r.tag===19)l0(r,o,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(v){case"forwards":for(o=a.child,v=null;o!==null;)r=o.alternate,r!==null&&Ic(r)===null&&(v=o),o=o.sibling;o=v,o===null?(v=a.child,a.child=null):(v=o.sibling,o.sibling=null),Xf(a,!1,v,o,j,m);break;case"backwards":case"unstable_legacy-backwards":for(o=null,v=a.child,a.child=null;v!==null;){if(r=v.alternate,r!==null&&Ic(r)===null){a.child=v;break}r=v.sibling,v.sibling=o,o=v,v=r}Xf(a,!0,o,null,j,m);break;case"together":Xf(a,!1,null,null,void 0,m);break;default:a.memoizedState=null}return a.child}function sa(r,a,o){if(r!==null&&(a.dependencies=r.dependencies),$a|=a.lanes,(o&a.childLanes)===0)if(r!==null){if(Kl(r,a,o,!1),(o&a.childLanes)===0)return null}else return null;if(r!==null&&a.child!==r.child)throw Error(l(153));if(a.child!==null){for(r=a.child,o=Qs(r,r.pendingProps),a.child=o,o.return=a;r.sibling!==null;)r=r.sibling,o=o.sibling=Qs(r,r.pendingProps),o.return=a;o.sibling=null}return a.child}function Kf(r,a){return(r.lanes&a)!==0?!0:(r=r.dependencies,!!(r!==null&&Tc(r)))}function l2(r,a,o){switch(a.tag){case 3:te(a,a.stateNode.containerInfo),_a(a,Zn,r.memoizedState.cache),ml();break;case 27:case 5:oe(a);break;case 4:te(a,a.stateNode.containerInfo);break;case 10:_a(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,vf(a),null;break;case 13:var m=a.memoizedState;if(m!==null)return m.dehydrated!==null?(Da(a),a.flags|=128,null):(o&a.child.childLanes)!==0?a0(r,a,o):(Da(a),r=sa(r,a,o),r!==null?r.sibling:null);Da(a);break;case 19:var v=(r.flags&128)!==0;if(m=(o&a.childLanes)!==0,m||(Kl(r,a,o,!1),m=(o&a.childLanes)!==0),v){if(m)return i0(r,a,o);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),I(Gn,Gn.current),m)break;return null;case 22:return a.lanes=0,Jg(r,a,o,a.pendingProps);case 24:_a(a,Zn,r.memoizedState.cache)}return sa(r,a,o)}function o0(r,a,o){if(r!==null)if(r.memoizedProps!==a.pendingProps)Jn=!0;else{if(!Kf(r,o)&&(a.flags&128)===0)return Jn=!1,l2(r,a,o);Jn=(r.flags&131072)!==0}else Jn=!1,Qt&&(a.flags&1048576)!==0&&Hp(a,Xi,a.index);switch(a.lanes=0,a.tag){case 16:e:{var m=a.pendingProps;if(r=gl(a.elementType),a.type=r,typeof r=="function")Ju(r)?(m=jl(r,m),a.tag=1,a=r0(null,a,r,m,o)):(a.tag=0,a=Uf(null,a,r,m,o));else{if(r!=null){var v=r.$$typeof;if(v===A){a.tag=11,a=Wg(null,a,r,m,o);break e}else if(v===Y){a.tag=14,a=Zg(null,a,r,m,o);break e}}throw a=T(r)||r,Error(l(306,a,""))}}return a;case 0:return Uf(r,a,a.type,a.pendingProps,o);case 1:return m=a.type,v=jl(m,a.pendingProps),r0(r,a,m,v,o);case 3:e:{if(te(a,a.stateNode.containerInfo),r===null)throw Error(l(387));m=a.pendingProps;var j=a.memoizedState;v=j.element,xf(r,a),no(a,m,null,o);var U=a.memoizedState;if(m=U.cache,_a(a,Zn,m),m!==j.cache&&cf(a,[Zn],o,!0),to(),m=U.element,j.isDehydrated)if(j={element:m,isDehydrated:!1,cache:U.cache},a.updateQueue.baseState=j,a.memoizedState=j,a.flags&256){a=s0(r,a,m,o);break e}else if(m!==v){v=os(Error(l(424)),a),Ki(v),a=s0(r,a,m,o);break e}else for(r=a.stateNode.containerInfo,r.nodeType===9?r=r.body:r=r.nodeName==="HTML"?r.ownerDocument.body:r,Rn=ms(r.firstChild),wr=a,Qt=!0,Ta=null,us=!0,o=Jp(a,null,m,o),a.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(ml(),m===v){a=sa(r,a,o);break e}kr(r,a,m,o)}a=a.child}return a;case 26:return Gc(r,a),r===null?(o=yb(a.type,null,a.pendingProps,null))?a.memoizedState=o:Qt||(o=a.type,r=a.pendingProps,m=dd(W.current).createElement(o),m[ze]=a,m[Ve]=r,Sr(m,o,r),ln(m),a.stateNode=m):a.memoizedState=yb(a.type,r.memoizedProps,a.pendingProps,r.memoizedState),null;case 27:return oe(a),r===null&&Qt&&(m=a.stateNode=pb(a.type,a.pendingProps,W.current),wr=a,us=!0,v=Rn,qa(a.type)?(Tm=v,Rn=ms(m.firstChild)):Rn=v),kr(r,a,a.pendingProps.children,o),Gc(r,a),r===null&&(a.flags|=4194304),a.child;case 5:return r===null&&Qt&&((v=m=Rn)&&(m=I2(m,a.type,a.pendingProps,us),m!==null?(a.stateNode=m,wr=a,Rn=ms(m.firstChild),us=!1,v=!0):v=!1),v||Aa(a)),oe(a),v=a.type,j=a.pendingProps,U=r!==null?r.memoizedProps:null,m=j.children,Nm(v,j)?m=null:U!==null&&Nm(v,U)&&(a.flags|=32),a.memoizedState!==null&&(v=wf(r,a,Z5,null,null,o),No._currentValue=v),Gc(r,a),kr(r,a,m,o),a.child;case 6:return r===null&&Qt&&((r=o=Rn)&&(o=z2(o,a.pendingProps,us),o!==null?(a.stateNode=o,wr=a,Rn=null,r=!0):r=!1),r||Aa(a)),null;case 13:return a0(r,a,o);case 4:return te(a,a.stateNode.containerInfo),m=a.pendingProps,r===null?a.child=yl(a,null,m,o):kr(r,a,m,o),a.child;case 11:return Wg(r,a,a.type,a.pendingProps,o);case 7:return kr(r,a,a.pendingProps,o),a.child;case 8:return kr(r,a,a.pendingProps.children,o),a.child;case 12:return kr(r,a,a.pendingProps.children,o),a.child;case 10:return m=a.pendingProps,_a(a,a.type,m.value),kr(r,a,m.children,o),a.child;case 9:return v=a.type._context,m=a.pendingProps.children,xl(a),v=Nr(v),m=m(v),a.flags|=1,kr(r,a,m,o),a.child;case 14:return Zg(r,a,a.type,a.pendingProps,o);case 15:return Qg(r,a,a.type,a.pendingProps,o);case 19:return i0(r,a,o);case 31:return a2(r,a,o);case 22:return Jg(r,a,o,a.pendingProps);case 24:return xl(a),m=Nr(Zn),r===null?(v=ff(),v===null&&(v=En,j=df(),v.pooledCache=j,j.refCount++,j!==null&&(v.pooledCacheLanes|=o),v=j),a.memoizedState={parent:m,cache:v},hf(a),_a(a,Zn,v)):((r.lanes&o)!==0&&(xf(r,a),no(a,null,null,o),to()),v=r.memoizedState,j=a.memoizedState,v.parent!==m?(v={parent:m,cache:m},a.memoizedState=v,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=v),_a(a,Zn,m)):(m=j.cache,_a(a,Zn,m),m!==v.cache&&cf(a,[Zn],o,!0))),kr(r,a,a.pendingProps.children,o),a.child;case 29:throw a.pendingProps}throw Error(l(156,a.tag))}function aa(r){r.flags|=4}function Wf(r,a,o,m,v){if((a=(r.mode&32)!==0)&&(a=!1),a){if(r.flags|=16777216,(v&335544128)===v)if(r.stateNode.complete)r.flags|=8192;else if(L0())r.flags|=8192;else throw bl=Rc,mf}else r.flags&=-16777217}function c0(r,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!kb(a))if(L0())r.flags|=8192;else throw bl=Rc,mf}function Kc(r,a){a!==null&&(r.flags|=4),r.flags&16384&&(a=r.tag!==22?kn():536870912,r.lanes|=a,ii|=a)}function oo(r,a){if(!Qt)switch(r.tailMode){case"hidden":a=r.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?r.tail=null:o.sibling=null;break;case"collapsed":o=r.tail;for(var m=null;o!==null;)o.alternate!==null&&(m=o),o=o.sibling;m===null?a||r.tail===null?r.tail=null:r.tail.sibling=null:m.sibling=null}}function On(r){var a=r.alternate!==null&&r.alternate.child===r.child,o=0,m=0;if(a)for(var v=r.child;v!==null;)o|=v.lanes|v.childLanes,m|=v.subtreeFlags&65011712,m|=v.flags&65011712,v.return=r,v=v.sibling;else for(v=r.child;v!==null;)o|=v.lanes|v.childLanes,m|=v.subtreeFlags,m|=v.flags,v.return=r,v=v.sibling;return r.subtreeFlags|=m,r.childLanes=o,a}function i2(r,a,o){var m=a.pendingProps;switch(rf(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return On(a),null;case 1:return On(a),null;case 3:return o=a.stateNode,m=null,r!==null&&(m=r.memoizedState.cache),a.memoizedState.cache!==m&&(a.flags|=2048),ta(Zn),re(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(r===null||r.child===null)&&(Xl(a)?aa(a):r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,af())),On(a),null;case 26:var v=a.type,j=a.memoizedState;return r===null?(aa(a),j!==null?(On(a),c0(a,j)):(On(a),Wf(a,v,null,m,o))):j?j!==r.memoizedState?(aa(a),On(a),c0(a,j)):(On(a),a.flags&=-16777217):(r=r.memoizedProps,r!==m&&aa(a),On(a),Wf(a,v,r,m,o)),null;case 27:if(me(a),o=W.current,v=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==m&&aa(a);else{if(!m){if(a.stateNode===null)throw Error(l(166));return On(a),null}r=S.current,Xl(a)?Up(a):(r=pb(v,m,o),a.stateNode=r,aa(a))}return On(a),null;case 5:if(me(a),v=a.type,r!==null&&a.stateNode!=null)r.memoizedProps!==m&&aa(a);else{if(!m){if(a.stateNode===null)throw Error(l(166));return On(a),null}if(j=S.current,Xl(a))Up(a);else{var U=dd(W.current);switch(j){case 1:j=U.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:j=U.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":j=U.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":j=U.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":j=U.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof m.is=="string"?U.createElement("select",{is:m.is}):U.createElement("select"),m.multiple?j.multiple=!0:m.size&&(j.size=m.size);break;default:j=typeof m.is=="string"?U.createElement(v,{is:m.is}):U.createElement(v)}}j[ze]=a,j[Ve]=m;e:for(U=a.child;U!==null;){if(U.tag===5||U.tag===6)j.appendChild(U.stateNode);else if(U.tag!==4&&U.tag!==27&&U.child!==null){U.child.return=U,U=U.child;continue}if(U===a)break e;for(;U.sibling===null;){if(U.return===null||U.return===a)break e;U=U.return}U.sibling.return=U.return,U=U.sibling}a.stateNode=j;e:switch(Sr(j,v,m),v){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&aa(a)}}return On(a),Wf(a,a.type,r===null?null:r.memoizedProps,a.pendingProps,o),null;case 6:if(r&&a.stateNode!=null)r.memoizedProps!==m&&aa(a);else{if(typeof m!="string"&&a.stateNode===null)throw Error(l(166));if(r=W.current,Xl(a)){if(r=a.stateNode,o=a.memoizedProps,m=null,v=wr,v!==null)switch(v.tag){case 27:case 5:m=v.memoizedProps}r[ze]=a,r=!!(r.nodeValue===o||m!==null&&m.suppressHydrationWarning===!0||ab(r.nodeValue,o)),r||Aa(a,!0)}else r=dd(r).createTextNode(m),r[ze]=a,a.stateNode=r}return On(a),null;case 31:if(o=a.memoizedState,r===null||r.memoizedState!==null){if(m=Xl(a),o!==null){if(r===null){if(!m)throw Error(l(318));if(r=a.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(l(557));r[ze]=a}else ml(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;On(a),r=!1}else o=af(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=o),r=!0;if(!r)return a.flags&256?(Wr(a),a):(Wr(a),null);if((a.flags&128)!==0)throw Error(l(558))}return On(a),null;case 13:if(m=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(v=Xl(a),m!==null&&m.dehydrated!==null){if(r===null){if(!v)throw Error(l(318));if(v=a.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(l(317));v[ze]=a}else ml(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;On(a),v=!1}else v=af(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=v),v=!0;if(!v)return a.flags&256?(Wr(a),a):(Wr(a),null)}return Wr(a),(a.flags&128)!==0?(a.lanes=o,a):(o=m!==null,r=r!==null&&r.memoizedState!==null,o&&(m=a.child,v=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(v=m.alternate.memoizedState.cachePool.pool),j=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(j=m.memoizedState.cachePool.pool),j!==v&&(m.flags|=2048)),o!==r&&o&&(a.child.flags|=8192),Kc(a,a.updateQueue),On(a),null);case 4:return re(),r===null&&bm(a.stateNode.containerInfo),On(a),null;case 10:return ta(a.type),On(a),null;case 19:if(K(Gn),m=a.memoizedState,m===null)return On(a),null;if(v=(a.flags&128)!==0,j=m.rendering,j===null)if(v)oo(m,!1);else{if(qn!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(j=Ic(r),j!==null){for(a.flags|=128,oo(m,!1),r=j.updateQueue,a.updateQueue=r,Kc(a,r),a.subtreeFlags=0,r=o,o=a.child;o!==null;)zp(o,r),o=o.sibling;return I(Gn,Gn.current&1|2),Qt&&Js(a,m.treeForkCount),a.child}r=r.sibling}m.tail!==null&&kt()>ed&&(a.flags|=128,v=!0,oo(m,!1),a.lanes=4194304)}else{if(!v)if(r=Ic(j),r!==null){if(a.flags|=128,v=!0,r=r.updateQueue,a.updateQueue=r,Kc(a,r),oo(m,!0),m.tail===null&&m.tailMode==="hidden"&&!j.alternate&&!Qt)return On(a),null}else 2*kt()-m.renderingStartTime>ed&&o!==536870912&&(a.flags|=128,v=!0,oo(m,!1),a.lanes=4194304);m.isBackwards?(j.sibling=a.child,a.child=j):(r=m.last,r!==null?r.sibling=j:a.child=j,m.last=j)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=kt(),r.sibling=null,o=Gn.current,I(Gn,v?o&1|2:o&1),Qt&&Js(a,m.treeForkCount),r):(On(a),null);case 22:case 23:return Wr(a),yf(),m=a.memoizedState!==null,r!==null?r.memoizedState!==null!==m&&(a.flags|=8192):m&&(a.flags|=8192),m?(o&536870912)!==0&&(a.flags&128)===0&&(On(a),a.subtreeFlags&6&&(a.flags|=8192)):On(a),o=a.updateQueue,o!==null&&Kc(a,o.retryQueue),o=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),m=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(m=a.memoizedState.cachePool.pool),m!==o&&(a.flags|=2048),r!==null&&K(pl),null;case 24:return o=null,r!==null&&(o=r.memoizedState.cache),a.memoizedState.cache!==o&&(a.flags|=2048),ta(Zn),On(a),null;case 25:return null;case 30:return null}throw Error(l(156,a.tag))}function o2(r,a){switch(rf(a),a.tag){case 1:return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return ta(Zn),re(),r=a.flags,(r&65536)!==0&&(r&128)===0?(a.flags=r&-65537|128,a):null;case 26:case 27:case 5:return me(a),null;case 31:if(a.memoizedState!==null){if(Wr(a),a.alternate===null)throw Error(l(340));ml()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 13:if(Wr(a),r=a.memoizedState,r!==null&&r.dehydrated!==null){if(a.alternate===null)throw Error(l(340));ml()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return K(Gn),null;case 4:return re(),null;case 10:return ta(a.type),null;case 22:case 23:return Wr(a),yf(),r!==null&&K(pl),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 24:return ta(Zn),null;case 25:return null;default:return null}}function d0(r,a){switch(rf(a),a.tag){case 3:ta(Zn),re();break;case 26:case 27:case 5:me(a);break;case 4:re();break;case 31:a.memoizedState!==null&&Wr(a);break;case 13:Wr(a);break;case 19:K(Gn);break;case 10:ta(a.type);break;case 22:case 23:Wr(a),yf(),r!==null&&K(pl);break;case 24:ta(Zn)}}function co(r,a){try{var o=a.updateQueue,m=o!==null?o.lastEffect:null;if(m!==null){var v=m.next;o=v;do{if((o.tag&r)===r){m=void 0;var j=o.create,U=o.inst;m=j(),U.destroy=m}o=o.next}while(o!==v)}}catch(Q){pn(a,a.return,Q)}}function Ia(r,a,o){try{var m=a.updateQueue,v=m!==null?m.lastEffect:null;if(v!==null){var j=v.next;m=j;do{if((m.tag&r)===r){var U=m.inst,Q=U.destroy;if(Q!==void 0){U.destroy=void 0,v=a;var ie=o,be=Q;try{be()}catch(Ae){pn(v,ie,Ae)}}}m=m.next}while(m!==j)}}catch(Ae){pn(a,a.return,Ae)}}function u0(r){var a=r.updateQueue;if(a!==null){var o=r.stateNode;try{tg(a,o)}catch(m){pn(r,r.return,m)}}}function f0(r,a,o){o.props=jl(r.type,r.memoizedProps),o.state=r.memoizedState;try{o.componentWillUnmount()}catch(m){pn(r,a,m)}}function uo(r,a){try{var o=r.ref;if(o!==null){switch(r.tag){case 26:case 27:case 5:var m=r.stateNode;break;case 30:m=r.stateNode;break;default:m=r.stateNode}typeof o=="function"?r.refCleanup=o(m):o.current=m}}catch(v){pn(r,a,v)}}function $s(r,a){var o=r.ref,m=r.refCleanup;if(o!==null)if(typeof m=="function")try{m()}catch(v){pn(r,a,v)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(v){pn(r,a,v)}else o.current=null}function m0(r){var a=r.type,o=r.memoizedProps,m=r.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":o.autoFocus&&m.focus();break e;case"img":o.src?m.src=o.src:o.srcSet&&(m.srcset=o.srcSet)}}catch(v){pn(r,r.return,v)}}function Zf(r,a,o){try{var m=r.stateNode;_2(m,r.type,o,a),m[Ve]=a}catch(v){pn(r,r.return,v)}}function h0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&qa(r.type)||r.tag===4}function Qf(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||h0(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&&qa(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 Jf(r,a,o){var m=r.tag;if(m===5||m===6)r=r.stateNode,a?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(r,a):(a=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,a.appendChild(r),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=Be));else if(m!==4&&(m===27&&qa(r.type)&&(o=r.stateNode,a=null),r=r.child,r!==null))for(Jf(r,a,o),r=r.sibling;r!==null;)Jf(r,a,o),r=r.sibling}function Wc(r,a,o){var m=r.tag;if(m===5||m===6)r=r.stateNode,a?o.insertBefore(r,a):o.appendChild(r);else if(m!==4&&(m===27&&qa(r.type)&&(o=r.stateNode),r=r.child,r!==null))for(Wc(r,a,o),r=r.sibling;r!==null;)Wc(r,a,o),r=r.sibling}function x0(r){var a=r.stateNode,o=r.memoizedProps;try{for(var m=r.type,v=a.attributes;v.length;)a.removeAttributeNode(v[0]);Sr(a,m,o),a[ze]=r,a[Ve]=o}catch(j){pn(r,r.return,j)}}var la=!1,er=!1,em=!1,p0=typeof WeakSet=="function"?WeakSet:Set,xr=null;function c2(r,a){if(r=r.containerInfo,jm=gd,r=Tp(r),Yu(r)){if("selectionStart"in r)var o={start:r.selectionStart,end:r.selectionEnd};else e:{o=(o=r.ownerDocument)&&o.defaultView||window;var m=o.getSelection&&o.getSelection();if(m&&m.rangeCount!==0){o=m.anchorNode;var v=m.anchorOffset,j=m.focusNode;m=m.focusOffset;try{o.nodeType,j.nodeType}catch{o=null;break e}var U=0,Q=-1,ie=-1,be=0,Ae=0,De=r,je=null;t:for(;;){for(var we;De!==o||v!==0&&De.nodeType!==3||(Q=U+v),De!==j||m!==0&&De.nodeType!==3||(ie=U+m),De.nodeType===3&&(U+=De.nodeValue.length),(we=De.firstChild)!==null;)je=De,De=we;for(;;){if(De===r)break t;if(je===o&&++be===v&&(Q=U),je===j&&++Ae===m&&(ie=U),(we=De.nextSibling)!==null)break;De=je,je=De.parentNode}De=we}o=Q===-1||ie===-1?null:{start:Q,end:ie}}else o=null}o=o||{start:0,end:0}}else o=null;for(wm={focusedElem:r,selectionRange:o},gd=!1,xr=a;xr!==null;)if(a=xr,r=a.child,(a.subtreeFlags&1028)!==0&&r!==null)r.return=a,xr=r;else for(;xr!==null;){switch(a=xr,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(o=0;o<r.length;o++)v=r[o],v.ref.impl=v.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&j!==null){r=void 0,o=a,v=j.memoizedProps,j=j.memoizedState,m=o.stateNode;try{var rt=jl(o.type,v);r=m.getSnapshotBeforeUpdate(rt,j),m.__reactInternalSnapshotBeforeUpdate=r}catch(Nt){pn(o,o.return,Nt)}}break;case 3:if((r&1024)!==0){if(r=a.stateNode.containerInfo,o=r.nodeType,o===9)Sm(r);else if(o===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":Sm(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(l(163))}if(r=a.sibling,r!==null){r.return=a.return,xr=r;break}xr=a.return}}function g0(r,a,o){var m=o.flags;switch(o.tag){case 0:case 11:case 15:oa(r,o),m&4&&co(5,o);break;case 1:if(oa(r,o),m&4)if(r=o.stateNode,a===null)try{r.componentDidMount()}catch(U){pn(o,o.return,U)}else{var v=jl(o.type,a.memoizedProps);a=a.memoizedState;try{r.componentDidUpdate(v,a,r.__reactInternalSnapshotBeforeUpdate)}catch(U){pn(o,o.return,U)}}m&64&&u0(o),m&512&&uo(o,o.return);break;case 3:if(oa(r,o),m&64&&(r=o.updateQueue,r!==null)){if(a=null,o.child!==null)switch(o.child.tag){case 27:case 5:a=o.child.stateNode;break;case 1:a=o.child.stateNode}try{tg(r,a)}catch(U){pn(o,o.return,U)}}break;case 27:a===null&&m&4&&x0(o);case 26:case 5:oa(r,o),a===null&&m&4&&m0(o),m&512&&uo(o,o.return);break;case 12:oa(r,o);break;case 31:oa(r,o),m&4&&v0(r,o);break;case 13:oa(r,o),m&4&&j0(r,o),m&64&&(r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(o=b2.bind(null,o),$2(r,o))));break;case 22:if(m=o.memoizedState!==null||la,!m){a=a!==null&&a.memoizedState!==null||er,v=la;var j=er;la=m,(er=a)&&!j?ca(r,o,(o.subtreeFlags&8772)!==0):oa(r,o),la=v,er=j}break;case 30:break;default:oa(r,o)}}function b0(r){var a=r.alternate;a!==null&&(r.alternate=null,b0(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&Wn(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 Ln=null,zr=!1;function ia(r,a,o){for(o=o.child;o!==null;)y0(r,a,o),o=o.sibling}function y0(r,a,o){if(St&&typeof St.onCommitFiberUnmount=="function")try{St.onCommitFiberUnmount(Ut,o)}catch{}switch(o.tag){case 26:er||$s(o,a),ia(r,a,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:er||$s(o,a);var m=Ln,v=zr;qa(o.type)&&(Ln=o.stateNode,zr=!1),ia(r,a,o),vo(o.stateNode),Ln=m,zr=v;break;case 5:er||$s(o,a);case 6:if(m=Ln,v=zr,Ln=null,ia(r,a,o),Ln=m,zr=v,Ln!==null)if(zr)try{(Ln.nodeType===9?Ln.body:Ln.nodeName==="HTML"?Ln.ownerDocument.body:Ln).removeChild(o.stateNode)}catch(j){pn(o,a,j)}else try{Ln.removeChild(o.stateNode)}catch(j){pn(o,a,j)}break;case 18:Ln!==null&&(zr?(r=Ln,ub(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,o.stateNode),xi(r)):ub(Ln,o.stateNode));break;case 4:m=Ln,v=zr,Ln=o.stateNode.containerInfo,zr=!0,ia(r,a,o),Ln=m,zr=v;break;case 0:case 11:case 14:case 15:Ia(2,o,a),er||Ia(4,o,a),ia(r,a,o);break;case 1:er||($s(o,a),m=o.stateNode,typeof m.componentWillUnmount=="function"&&f0(o,a,m)),ia(r,a,o);break;case 21:ia(r,a,o);break;case 22:er=(m=er)||o.memoizedState!==null,ia(r,a,o),er=m;break;default:ia(r,a,o)}}function v0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{xi(r)}catch(o){pn(a,a.return,o)}}}function j0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{xi(r)}catch(o){pn(a,a.return,o)}}function d2(r){switch(r.tag){case 31:case 13:case 19:var a=r.stateNode;return a===null&&(a=r.stateNode=new p0),a;case 22:return r=r.stateNode,a=r._retryCache,a===null&&(a=r._retryCache=new p0),a;default:throw Error(l(435,r.tag))}}function Zc(r,a){var o=d2(r);a.forEach(function(m){if(!o.has(m)){o.add(m);var v=y2.bind(null,r,m);m.then(v,v)}})}function $r(r,a){var o=a.deletions;if(o!==null)for(var m=0;m<o.length;m++){var v=o[m],j=r,U=a,Q=U;e:for(;Q!==null;){switch(Q.tag){case 27:if(qa(Q.type)){Ln=Q.stateNode,zr=!1;break e}break;case 5:Ln=Q.stateNode,zr=!1;break e;case 3:case 4:Ln=Q.stateNode.containerInfo,zr=!0;break e}Q=Q.return}if(Ln===null)throw Error(l(160));y0(j,U,v),Ln=null,zr=!1,j=v.alternate,j!==null&&(j.return=null),v.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)w0(a,r),a=a.sibling}var ks=null;function w0(r,a){var o=r.alternate,m=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:$r(a,r),Br(r),m&4&&(Ia(3,r,r.return),co(3,r),Ia(5,r,r.return));break;case 1:$r(a,r),Br(r),m&512&&(er||o===null||$s(o,o.return)),m&64&&la&&(r=r.updateQueue,r!==null&&(m=r.callbacks,m!==null&&(o=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=o===null?m:o.concat(m))));break;case 26:var v=ks;if($r(a,r),Br(r),m&512&&(er||o===null||$s(o,o.return)),m&4){var j=o!==null?o.memoizedState:null;if(m=r.memoizedState,o===null)if(m===null)if(r.stateNode===null){e:{m=r.type,o=r.memoizedProps,v=v.ownerDocument||v;t:switch(m){case"title":j=v.getElementsByTagName("title")[0],(!j||j[mn]||j[ze]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=v.createElement(m),v.head.insertBefore(j,v.querySelector("head > title"))),Sr(j,m,o),j[ze]=r,ln(j),m=j;break e;case"link":var U=wb("link","href",v).get(m+(o.href||""));if(U){for(var Q=0;Q<U.length;Q++)if(j=U[Q],j.getAttribute("href")===(o.href==null||o.href===""?null:o.href)&&j.getAttribute("rel")===(o.rel==null?null:o.rel)&&j.getAttribute("title")===(o.title==null?null:o.title)&&j.getAttribute("crossorigin")===(o.crossOrigin==null?null:o.crossOrigin)){U.splice(Q,1);break t}}j=v.createElement(m),Sr(j,m,o),v.head.appendChild(j);break;case"meta":if(U=wb("meta","content",v).get(m+(o.content||""))){for(Q=0;Q<U.length;Q++)if(j=U[Q],j.getAttribute("content")===(o.content==null?null:""+o.content)&&j.getAttribute("name")===(o.name==null?null:o.name)&&j.getAttribute("property")===(o.property==null?null:o.property)&&j.getAttribute("http-equiv")===(o.httpEquiv==null?null:o.httpEquiv)&&j.getAttribute("charset")===(o.charSet==null?null:o.charSet)){U.splice(Q,1);break t}}j=v.createElement(m),Sr(j,m,o),v.head.appendChild(j);break;default:throw Error(l(468,m))}j[ze]=r,ln(j),m=j}r.stateNode=m}else Nb(v,r.type,r.stateNode);else r.stateNode=jb(v,m,r.memoizedProps);else j!==m?(j===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):j.count--,m===null?Nb(v,r.type,r.stateNode):jb(v,m,r.memoizedProps)):m===null&&r.stateNode!==null&&Zf(r,r.memoizedProps,o.memoizedProps)}break;case 27:$r(a,r),Br(r),m&512&&(er||o===null||$s(o,o.return)),o!==null&&m&4&&Zf(r,r.memoizedProps,o.memoizedProps);break;case 5:if($r(a,r),Br(r),m&512&&(er||o===null||$s(o,o.return)),r.flags&32){v=r.stateNode;try{ir(v,"")}catch(rt){pn(r,r.return,rt)}}m&4&&r.stateNode!=null&&(v=r.memoizedProps,Zf(r,v,o!==null?o.memoizedProps:v)),m&1024&&(em=!0);break;case 6:if($r(a,r),Br(r),m&4){if(r.stateNode===null)throw Error(l(162));m=r.memoizedProps,o=r.stateNode;try{o.nodeValue=m}catch(rt){pn(r,r.return,rt)}}break;case 3:if(md=null,v=ks,ks=ud(a.containerInfo),$r(a,r),ks=v,Br(r),m&4&&o!==null&&o.memoizedState.isDehydrated)try{xi(a.containerInfo)}catch(rt){pn(r,r.return,rt)}em&&(em=!1,N0(r));break;case 4:m=ks,ks=ud(r.stateNode.containerInfo),$r(a,r),Br(r),ks=m;break;case 12:$r(a,r),Br(r);break;case 31:$r(a,r),Br(r),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Zc(r,m)));break;case 13:$r(a,r),Br(r),r.child.flags&8192&&r.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(Jc=kt()),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Zc(r,m)));break;case 22:v=r.memoizedState!==null;var ie=o!==null&&o.memoizedState!==null,be=la,Ae=er;if(la=be||v,er=Ae||ie,$r(a,r),er=Ae,la=be,Br(r),m&8192)e:for(a=r.stateNode,a._visibility=v?a._visibility&-2:a._visibility|1,v&&(o===null||ie||la||er||wl(r)),o=null,a=r;;){if(a.tag===5||a.tag===26){if(o===null){ie=o=a;try{if(j=ie.stateNode,v)U=j.style,typeof U.setProperty=="function"?U.setProperty("display","none","important"):U.display="none";else{Q=ie.stateNode;var De=ie.memoizedProps.style,je=De!=null&&De.hasOwnProperty("display")?De.display:null;Q.style.display=je==null||typeof je=="boolean"?"":(""+je).trim()}}catch(rt){pn(ie,ie.return,rt)}}}else if(a.tag===6){if(o===null){ie=a;try{ie.stateNode.nodeValue=v?"":ie.memoizedProps}catch(rt){pn(ie,ie.return,rt)}}}else if(a.tag===18){if(o===null){ie=a;try{var we=ie.stateNode;v?fb(we,!0):fb(ie.stateNode,!1)}catch(rt){pn(ie,ie.return,rt)}}}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;o===a&&(o=null),a=a.return}o===a&&(o=null),a.sibling.return=a.return,a=a.sibling}m&4&&(m=r.updateQueue,m!==null&&(o=m.retryQueue,o!==null&&(m.retryQueue=null,Zc(r,o))));break;case 19:$r(a,r),Br(r),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Zc(r,m)));break;case 30:break;case 21:break;default:$r(a,r),Br(r)}}function Br(r){var a=r.flags;if(a&2){try{for(var o,m=r.return;m!==null;){if(h0(m)){o=m;break}m=m.return}if(o==null)throw Error(l(160));switch(o.tag){case 27:var v=o.stateNode,j=Qf(r);Wc(r,j,v);break;case 5:var U=o.stateNode;o.flags&32&&(ir(U,""),o.flags&=-33);var Q=Qf(r);Wc(r,Q,U);break;case 3:case 4:var ie=o.stateNode.containerInfo,be=Qf(r);Jf(r,be,ie);break;default:throw Error(l(161))}}catch(Ae){pn(r,r.return,Ae)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function N0(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var a=r;N0(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),r=r.sibling}}function oa(r,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)g0(r,a.alternate,a),a=a.sibling}function wl(r){for(r=r.child;r!==null;){var a=r;switch(a.tag){case 0:case 11:case 14:case 15:Ia(4,a,a.return),wl(a);break;case 1:$s(a,a.return);var o=a.stateNode;typeof o.componentWillUnmount=="function"&&f0(a,a.return,o),wl(a);break;case 27:vo(a.stateNode);case 26:case 5:$s(a,a.return),wl(a);break;case 22:a.memoizedState===null&&wl(a);break;case 30:wl(a);break;default:wl(a)}r=r.sibling}}function ca(r,a,o){for(o=o&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var m=a.alternate,v=r,j=a,U=j.flags;switch(j.tag){case 0:case 11:case 15:ca(v,j,o),co(4,j);break;case 1:if(ca(v,j,o),m=j,v=m.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(be){pn(m,m.return,be)}if(m=j,v=m.updateQueue,v!==null){var Q=m.stateNode;try{var ie=v.shared.hiddenCallbacks;if(ie!==null)for(v.shared.hiddenCallbacks=null,v=0;v<ie.length;v++)eg(ie[v],Q)}catch(be){pn(m,m.return,be)}}o&&U&64&&u0(j),uo(j,j.return);break;case 27:x0(j);case 26:case 5:ca(v,j,o),o&&m===null&&U&4&&m0(j),uo(j,j.return);break;case 12:ca(v,j,o);break;case 31:ca(v,j,o),o&&U&4&&v0(v,j);break;case 13:ca(v,j,o),o&&U&4&&j0(v,j);break;case 22:j.memoizedState===null&&ca(v,j,o),uo(j,j.return);break;case 30:break;default:ca(v,j,o)}a=a.sibling}}function tm(r,a){var o=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),r=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(r=a.memoizedState.cachePool.pool),r!==o&&(r!=null&&r.refCount++,o!=null&&Wi(o))}function nm(r,a){r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Wi(r))}function Ss(r,a,o,m){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)k0(r,a,o,m),a=a.sibling}function k0(r,a,o,m){var v=a.flags;switch(a.tag){case 0:case 11:case 15:Ss(r,a,o,m),v&2048&&co(9,a);break;case 1:Ss(r,a,o,m);break;case 3:Ss(r,a,o,m),v&2048&&(r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Wi(r)));break;case 12:if(v&2048){Ss(r,a,o,m),r=a.stateNode;try{var j=a.memoizedProps,U=j.id,Q=j.onPostCommit;typeof Q=="function"&&Q(U,a.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(ie){pn(a,a.return,ie)}}else Ss(r,a,o,m);break;case 31:Ss(r,a,o,m);break;case 13:Ss(r,a,o,m);break;case 23:break;case 22:j=a.stateNode,U=a.alternate,a.memoizedState!==null?j._visibility&2?Ss(r,a,o,m):fo(r,a):j._visibility&2?Ss(r,a,o,m):(j._visibility|=2,si(r,a,o,m,(a.subtreeFlags&10256)!==0||!1)),v&2048&&tm(U,a);break;case 24:Ss(r,a,o,m),v&2048&&nm(a.alternate,a);break;default:Ss(r,a,o,m)}}function si(r,a,o,m,v){for(v=v&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var j=r,U=a,Q=o,ie=m,be=U.flags;switch(U.tag){case 0:case 11:case 15:si(j,U,Q,ie,v),co(8,U);break;case 23:break;case 22:var Ae=U.stateNode;U.memoizedState!==null?Ae._visibility&2?si(j,U,Q,ie,v):fo(j,U):(Ae._visibility|=2,si(j,U,Q,ie,v)),v&&be&2048&&tm(U.alternate,U);break;case 24:si(j,U,Q,ie,v),v&&be&2048&&nm(U.alternate,U);break;default:si(j,U,Q,ie,v)}a=a.sibling}}function fo(r,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var o=r,m=a,v=m.flags;switch(m.tag){case 22:fo(o,m),v&2048&&tm(m.alternate,m);break;case 24:fo(o,m),v&2048&&nm(m.alternate,m);break;default:fo(o,m)}a=a.sibling}}var mo=8192;function ai(r,a,o){if(r.subtreeFlags&mo)for(r=r.child;r!==null;)S0(r,a,o),r=r.sibling}function S0(r,a,o){switch(r.tag){case 26:ai(r,a,o),r.flags&mo&&r.memoizedState!==null&&W2(o,ks,r.memoizedState,r.memoizedProps);break;case 5:ai(r,a,o);break;case 3:case 4:var m=ks;ks=ud(r.stateNode.containerInfo),ai(r,a,o),ks=m;break;case 22:r.memoizedState===null&&(m=r.alternate,m!==null&&m.memoizedState!==null?(m=mo,mo=16777216,ai(r,a,o),mo=m):ai(r,a,o));break;default:ai(r,a,o)}}function C0(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 ho(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var o=0;o<a.length;o++){var m=a[o];xr=m,T0(m,r)}C0(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)E0(r),r=r.sibling}function E0(r){switch(r.tag){case 0:case 11:case 15:ho(r),r.flags&2048&&Ia(9,r,r.return);break;case 3:ho(r);break;case 12:ho(r);break;case 22:var a=r.stateNode;r.memoizedState!==null&&a._visibility&2&&(r.return===null||r.return.tag!==13)?(a._visibility&=-3,Qc(r)):ho(r);break;default:ho(r)}}function Qc(r){var a=r.deletions;if((r.flags&16)!==0){if(a!==null)for(var o=0;o<a.length;o++){var m=a[o];xr=m,T0(m,r)}C0(r)}for(r=r.child;r!==null;){switch(a=r,a.tag){case 0:case 11:case 15:Ia(8,a,a.return),Qc(a);break;case 22:o=a.stateNode,o._visibility&2&&(o._visibility&=-3,Qc(a));break;default:Qc(a)}r=r.sibling}}function T0(r,a){for(;xr!==null;){var o=xr;switch(o.tag){case 0:case 11:case 15:Ia(8,o,a);break;case 23:case 22:if(o.memoizedState!==null&&o.memoizedState.cachePool!==null){var m=o.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:Wi(o.memoizedState.cache)}if(m=o.child,m!==null)m.return=o,xr=m;else e:for(o=r;xr!==null;){m=xr;var v=m.sibling,j=m.return;if(b0(m),m===o){xr=null;break e}if(v!==null){v.return=j,xr=v;break e}xr=j}}}var u2={getCacheForType:function(r){var a=Nr(Zn),o=a.data.get(r);return o===void 0&&(o=r(),a.data.set(r,o)),o},cacheSignal:function(){return Nr(Zn).controller.signal}},f2=typeof WeakMap=="function"?WeakMap:Map,cn=0,En=null,Vt=null,Kt=0,xn=0,Zr=null,za=!1,li=!1,rm=!1,da=0,qn=0,$a=0,Nl=0,sm=0,Qr=0,ii=0,xo=null,Hr=null,am=!1,Jc=0,A0=0,ed=1/0,td=null,Ba=null,or=0,Ha=null,oi=null,ua=0,lm=0,im=null,_0=null,po=0,om=null;function Jr(){return(cn&2)!==0&&Kt!==0?Kt&-Kt:O.T!==null?hm():qe()}function M0(){if(Qr===0)if((Kt&536870912)===0||Qt){var r=dn;dn<<=1,(dn&3932160)===0&&(dn=262144),Qr=r}else Qr=536870912;return r=Kr.current,r!==null&&(r.flags|=32),Qr}function Pr(r,a,o){(r===En&&(xn===2||xn===9)||r.cancelPendingCommit!==null)&&(ci(r,0),Pa(r,Kt,Qr,!1)),Mn(r,o),((cn&2)===0||r!==En)&&(r===En&&((cn&2)===0&&(Nl|=o),qn===4&&Pa(r,Kt,Qr,!1)),Bs(r))}function R0(r,a,o){if((cn&6)!==0)throw Error(l(327));var m=!o&&(a&127)===0&&(a&r.expiredLanes)===0||Et(r,a),v=m?x2(r,a):dm(r,a,!0),j=m;do{if(v===0){li&&!m&&Pa(r,a,0,!1);break}else{if(o=r.current.alternate,j&&!m2(o)){v=dm(r,a,!1),j=!1;continue}if(v===2){if(j=a,r.errorRecoveryDisabledLanes&j)var U=0;else U=r.pendingLanes&-536870913,U=U!==0?U:U&536870912?536870912:0;if(U!==0){a=U;e:{var Q=r;v=xo;var ie=Q.current.memoizedState.isDehydrated;if(ie&&(ci(Q,U).flags|=256),U=dm(Q,U,!1),U!==2){if(rm&&!ie){Q.errorRecoveryDisabledLanes|=j,Nl|=j,v=4;break e}j=Hr,Hr=v,j!==null&&(Hr===null?Hr=j:Hr.push.apply(Hr,j))}v=U}if(j=!1,v!==2)continue}}if(v===1){ci(r,0),Pa(r,a,0,!0);break}e:{switch(m=r,j=v,j){case 0:case 1:throw Error(l(345));case 4:if((a&4194048)!==a)break;case 6:Pa(m,a,Qr,!za);break e;case 2:Hr=null;break;case 3:case 5:break;default:throw Error(l(329))}if((a&62914560)===a&&(v=Jc+300-kt(),10<v)){if(Pa(m,a,Qr,!za),it(m,0,!0)!==0)break e;ua=a,m.timeoutHandle=cb(O0.bind(null,m,o,Hr,td,am,a,Qr,Nl,ii,za,j,"Throttled",-0,0),v);break e}O0(m,o,Hr,td,am,a,Qr,Nl,ii,za,j,null,-0,0)}}break}while(!0);Bs(r)}function O0(r,a,o,m,v,j,U,Q,ie,be,Ae,De,je,we){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:Be},S0(a,j,De);var rt=(j&62914560)===j?Jc-kt():(j&4194048)===j?A0-kt():0;if(rt=Z2(De,rt),rt!==null){ua=j,r.cancelPendingCommit=rt(P0.bind(null,r,a,j,o,m,v,U,Q,ie,Ae,De,null,je,we)),Pa(r,j,U,!be);return}}P0(r,a,j,o,m,v,U,Q,ie)}function m2(r){for(var a=r;;){var o=a.tag;if((o===0||o===11||o===15)&&a.flags&16384&&(o=a.updateQueue,o!==null&&(o=o.stores,o!==null)))for(var m=0;m<o.length;m++){var v=o[m],j=v.getSnapshot;v=v.value;try{if(!Gr(j(),v))return!1}catch{return!1}}if(o=a.child,a.subtreeFlags&16384&&o!==null)o.return=a,a=o;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 Pa(r,a,o,m){a&=~sm,a&=~Nl,r.suspendedLanes|=a,r.pingedLanes&=~a,m&&(r.warmLanes|=a),m=r.expirationTimes;for(var v=a;0<v;){var j=31-yt(v),U=1<<j;m[j]=-1,v&=~U}o!==0&&sr(r,o,a)}function nd(){return(cn&6)===0?(go(0),!1):!0}function cm(){if(Vt!==null){if(xn===0)var r=Vt.return;else r=Vt,ea=hl=null,Sf(r),Jl=null,Qi=0,r=Vt;for(;r!==null;)d0(r.alternate,r),r=r.return;Vt=null}}function ci(r,a){var o=r.timeoutHandle;o!==-1&&(r.timeoutHandle=-1,O2(o)),o=r.cancelPendingCommit,o!==null&&(r.cancelPendingCommit=null,o()),ua=0,cm(),En=r,Vt=o=Qs(r.current,null),Kt=a,xn=0,Zr=null,za=!1,li=Et(r,a),rm=!1,ii=Qr=sm=Nl=$a=qn=0,Hr=xo=null,am=!1,(a&8)!==0&&(a|=a&32);var m=r.entangledLanes;if(m!==0)for(r=r.entanglements,m&=a;0<m;){var v=31-yt(m),j=1<<v;a|=r[v],m&=~j}return da=a,Nc(),o}function D0(r,a){zt=null,O.H=lo,a===Ql||a===Mc?(a=Wp(),xn=3):a===mf?(a=Wp(),xn=4):xn=a===Pf?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Zr=a,Vt===null&&(qn=1,Vc(r,os(a,r.current)))}function L0(){var r=Kr.current;return r===null?!0:(Kt&4194048)===Kt?fs===null:(Kt&62914560)===Kt||(Kt&536870912)!==0?r===fs:!1}function I0(){var r=O.H;return O.H=lo,r===null?lo:r}function z0(){var r=O.A;return O.A=u2,r}function rd(){qn=4,za||(Kt&4194048)!==Kt&&Kr.current!==null||(li=!0),($a&134217727)===0&&(Nl&134217727)===0||En===null||Pa(En,Kt,Qr,!1)}function dm(r,a,o){var m=cn;cn|=2;var v=I0(),j=z0();(En!==r||Kt!==a)&&(td=null,ci(r,a)),a=!1;var U=qn;e:do try{if(xn!==0&&Vt!==null){var Q=Vt,ie=Zr;switch(xn){case 8:cm(),U=6;break e;case 3:case 2:case 9:case 6:Kr.current===null&&(a=!0);var be=xn;if(xn=0,Zr=null,di(r,Q,ie,be),o&&li){U=0;break e}break;default:be=xn,xn=0,Zr=null,di(r,Q,ie,be)}}h2(),U=qn;break}catch(Ae){D0(r,Ae)}while(!0);return a&&r.shellSuspendCounter++,ea=hl=null,cn=m,O.H=v,O.A=j,Vt===null&&(En=null,Kt=0,Nc()),U}function h2(){for(;Vt!==null;)$0(Vt)}function x2(r,a){var o=cn;cn|=2;var m=I0(),v=z0();En!==r||Kt!==a?(td=null,ed=kt()+500,ci(r,a)):li=Et(r,a);e:do try{if(xn!==0&&Vt!==null){a=Vt;var j=Zr;t:switch(xn){case 1:xn=0,Zr=null,di(r,a,j,1);break;case 2:case 9:if(Xp(j)){xn=0,Zr=null,B0(a);break}a=function(){xn!==2&&xn!==9||En!==r||(xn=7),Bs(r)},j.then(a,a);break e;case 3:xn=7;break e;case 4:xn=5;break e;case 7:Xp(j)?(xn=0,Zr=null,B0(a)):(xn=0,Zr=null,di(r,a,j,7));break;case 5:var U=null;switch(Vt.tag){case 26:U=Vt.memoizedState;case 5:case 27:var Q=Vt;if(U?kb(U):Q.stateNode.complete){xn=0,Zr=null;var ie=Q.sibling;if(ie!==null)Vt=ie;else{var be=Q.return;be!==null?(Vt=be,sd(be)):Vt=null}break t}}xn=0,Zr=null,di(r,a,j,5);break;case 6:xn=0,Zr=null,di(r,a,j,6);break;case 8:cm(),qn=6;break e;default:throw Error(l(462))}}p2();break}catch(Ae){D0(r,Ae)}while(!0);return ea=hl=null,O.H=m,O.A=v,cn=o,Vt!==null?0:(En=null,Kt=0,Nc(),qn)}function p2(){for(;Vt!==null&&!Se();)$0(Vt)}function $0(r){var a=o0(r.alternate,r,da);r.memoizedProps=r.pendingProps,a===null?sd(r):Vt=a}function B0(r){var a=r,o=a.alternate;switch(a.tag){case 15:case 0:a=n0(o,a,a.pendingProps,a.type,void 0,Kt);break;case 11:a=n0(o,a,a.pendingProps,a.type.render,a.ref,Kt);break;case 5:Sf(a);default:d0(o,a),a=Vt=zp(a,da),a=o0(o,a,da)}r.memoizedProps=r.pendingProps,a===null?sd(r):Vt=a}function di(r,a,o,m){ea=hl=null,Sf(a),Jl=null,Qi=0;var v=a.return;try{if(s2(r,v,a,o,Kt)){qn=1,Vc(r,os(o,r.current)),Vt=null;return}}catch(j){if(v!==null)throw Vt=v,j;qn=1,Vc(r,os(o,r.current)),Vt=null;return}a.flags&32768?(Qt||m===1?r=!0:li||(Kt&536870912)!==0?r=!1:(za=r=!0,(m===2||m===9||m===3||m===6)&&(m=Kr.current,m!==null&&m.tag===13&&(m.flags|=16384))),H0(a,r)):sd(a)}function sd(r){var a=r;do{if((a.flags&32768)!==0){H0(a,za);return}r=a.return;var o=i2(a.alternate,a,da);if(o!==null){Vt=o;return}if(a=a.sibling,a!==null){Vt=a;return}Vt=a=r}while(a!==null);qn===0&&(qn=5)}function H0(r,a){do{var o=o2(r.alternate,r);if(o!==null){o.flags&=32767,Vt=o;return}if(o=r.return,o!==null&&(o.flags|=32768,o.subtreeFlags=0,o.deletions=null),!a&&(r=r.sibling,r!==null)){Vt=r;return}Vt=r=o}while(r!==null);qn=6,Vt=null}function P0(r,a,o,m,v,j,U,Q,ie){r.cancelPendingCommit=null;do ad();while(or!==0);if((cn&6)!==0)throw Error(l(327));if(a!==null){if(a===r.current)throw Error(l(177));if(j=a.lanes|a.childLanes,j|=Zu,dr(r,o,j,U,Q,ie),r===En&&(Vt=En=null,Kt=0),oi=a,Ha=r,ua=o,lm=j,im=v,_0=m,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,v2(Fe,function(){return Y0(),null})):(r.callbackNode=null,r.callbackPriority=0),m=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||m){m=O.T,O.T=null,v=V.p,V.p=2,U=cn,cn|=4;try{c2(r,a,o)}finally{cn=U,V.p=v,O.T=m}}or=1,U0(),q0(),F0()}}function U0(){if(or===1){or=0;var r=Ha,a=oi,o=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||o){o=O.T,O.T=null;var m=V.p;V.p=2;var v=cn;cn|=4;try{w0(a,r);var j=wm,U=Tp(r.containerInfo),Q=j.focusedElem,ie=j.selectionRange;if(U!==Q&&Q&&Q.ownerDocument&&Ep(Q.ownerDocument.documentElement,Q)){if(ie!==null&&Yu(Q)){var be=ie.start,Ae=ie.end;if(Ae===void 0&&(Ae=be),"selectionStart"in Q)Q.selectionStart=be,Q.selectionEnd=Math.min(Ae,Q.value.length);else{var De=Q.ownerDocument||document,je=De&&De.defaultView||window;if(je.getSelection){var we=je.getSelection(),rt=Q.textContent.length,Nt=Math.min(ie.start,rt),Nn=ie.end===void 0?Nt:Math.min(ie.end,rt);!we.extend&&Nt>Nn&&(U=Nn,Nn=Nt,Nt=U);var he=Cp(Q,Nt),ce=Cp(Q,Nn);if(he&&ce&&(we.rangeCount!==1||we.anchorNode!==he.node||we.anchorOffset!==he.offset||we.focusNode!==ce.node||we.focusOffset!==ce.offset)){var pe=De.createRange();pe.setStart(he.node,he.offset),we.removeAllRanges(),Nt>Nn?(we.addRange(pe),we.extend(ce.node,ce.offset)):(pe.setEnd(ce.node,ce.offset),we.addRange(pe))}}}}for(De=[],we=Q;we=we.parentNode;)we.nodeType===1&&De.push({element:we,left:we.scrollLeft,top:we.scrollTop});for(typeof Q.focus=="function"&&Q.focus(),Q=0;Q<De.length;Q++){var _e=De[Q];_e.element.scrollLeft=_e.left,_e.element.scrollTop=_e.top}}gd=!!jm,wm=jm=null}finally{cn=v,V.p=m,O.T=o}}r.current=a,or=2}}function q0(){if(or===2){or=0;var r=Ha,a=oi,o=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||o){o=O.T,O.T=null;var m=V.p;V.p=2;var v=cn;cn|=4;try{g0(r,a.alternate,a)}finally{cn=v,V.p=m,O.T=o}}or=3}}function F0(){if(or===4||or===3){or=0,We();var r=Ha,a=oi,o=ua,m=_0;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?or=5:(or=0,oi=Ha=null,V0(r,r.pendingLanes));var v=r.pendingLanes;if(v===0&&(Ba=null),Ie(o),a=a.stateNode,St&&typeof St.onCommitFiberRoot=="function")try{St.onCommitFiberRoot(Ut,a,void 0,(a.current.flags&128)===128)}catch{}if(m!==null){a=O.T,v=V.p,V.p=2,O.T=null;try{for(var j=r.onRecoverableError,U=0;U<m.length;U++){var Q=m[U];j(Q.value,{componentStack:Q.stack})}}finally{O.T=a,V.p=v}}(ua&3)!==0&&ad(),Bs(r),v=r.pendingLanes,(o&261930)!==0&&(v&42)!==0?r===om?po++:(po=0,om=r):po=0,go(0)}}function V0(r,a){(r.pooledCacheLanes&=a)===0&&(a=r.pooledCache,a!=null&&(r.pooledCache=null,Wi(a)))}function ad(){return U0(),q0(),F0(),Y0()}function Y0(){if(or!==5)return!1;var r=Ha,a=lm;lm=0;var o=Ie(ua),m=O.T,v=V.p;try{V.p=32>o?32:o,O.T=null,o=im,im=null;var j=Ha,U=ua;if(or=0,oi=Ha=null,ua=0,(cn&6)!==0)throw Error(l(331));var Q=cn;if(cn|=4,E0(j.current),k0(j,j.current,U,o),cn=Q,go(0,!1),St&&typeof St.onPostCommitFiberRoot=="function")try{St.onPostCommitFiberRoot(Ut,j)}catch{}return!0}finally{V.p=v,O.T=m,V0(r,a)}}function G0(r,a,o){a=os(o,a),a=Hf(r.stateNode,a,2),r=Oa(r,a,2),r!==null&&(Mn(r,2),Bs(r))}function pn(r,a,o){if(r.tag===3)G0(r,r,o);else for(;a!==null;){if(a.tag===3){G0(a,r,o);break}else if(a.tag===1){var m=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Ba===null||!Ba.has(m))){r=os(o,r),o=Xg(2),m=Oa(a,o,2),m!==null&&(Kg(o,m,a,r),Mn(m,2),Bs(m));break}}a=a.return}}function um(r,a,o){var m=r.pingCache;if(m===null){m=r.pingCache=new f2;var v=new Set;m.set(a,v)}else v=m.get(a),v===void 0&&(v=new Set,m.set(a,v));v.has(o)||(rm=!0,v.add(o),r=g2.bind(null,r,a,o),a.then(r,r))}function g2(r,a,o){var m=r.pingCache;m!==null&&m.delete(a),r.pingedLanes|=r.suspendedLanes&o,r.warmLanes&=~o,En===r&&(Kt&o)===o&&(qn===4||qn===3&&(Kt&62914560)===Kt&&300>kt()-Jc?(cn&2)===0&&ci(r,0):sm|=o,ii===Kt&&(ii=0)),Bs(r)}function X0(r,a){a===0&&(a=kn()),r=ul(r,a),r!==null&&(Mn(r,a),Bs(r))}function b2(r){var a=r.memoizedState,o=0;a!==null&&(o=a.retryLane),X0(r,o)}function y2(r,a){var o=0;switch(r.tag){case 31:case 13:var m=r.stateNode,v=r.memoizedState;v!==null&&(o=v.retryLane);break;case 19:m=r.stateNode;break;case 22:m=r.stateNode._retryCache;break;default:throw Error(l(314))}m!==null&&m.delete(a),X0(r,o)}function v2(r,a){return Pt(r,a)}var ld=null,ui=null,fm=!1,id=!1,mm=!1,Ua=0;function Bs(r){r!==ui&&r.next===null&&(ui===null?ld=ui=r:ui=ui.next=r),id=!0,fm||(fm=!0,w2())}function go(r,a){if(!mm&&id){mm=!0;do for(var o=!1,m=ld;m!==null;){if(r!==0){var v=m.pendingLanes;if(v===0)var j=0;else{var U=m.suspendedLanes,Q=m.pingedLanes;j=(1<<31-yt(42|r)+1)-1,j&=v&~(U&~Q),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(o=!0,Q0(m,j))}else j=Kt,j=it(m,m===En?j:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(j&3)===0||Et(m,j)||(o=!0,Q0(m,j));m=m.next}while(o);mm=!1}}function j2(){K0()}function K0(){id=fm=!1;var r=0;Ua!==0&&R2()&&(r=Ua);for(var a=kt(),o=null,m=ld;m!==null;){var v=m.next,j=W0(m,a);j===0?(m.next=null,o===null?ld=v:o.next=v,v===null&&(ui=o)):(o=m,(r!==0||(j&3)!==0)&&(id=!0)),m=v}or!==0&&or!==5||go(r),Ua!==0&&(Ua=0)}function W0(r,a){for(var o=r.suspendedLanes,m=r.pingedLanes,v=r.expirationTimes,j=r.pendingLanes&-62914561;0<j;){var U=31-yt(j),Q=1<<U,ie=v[U];ie===-1?((Q&o)===0||(Q&m)!==0)&&(v[U]=It(Q,a)):ie<=a&&(r.expiredLanes|=Q),j&=~Q}if(a=En,o=Kt,o=it(r,r===a?o:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),m=r.callbackNode,o===0||r===a&&(xn===2||xn===9)||r.cancelPendingCommit!==null)return m!==null&&m!==null&&le(m),r.callbackNode=null,r.callbackPriority=0;if((o&3)===0||Et(r,o)){if(a=o&-o,a===r.callbackPriority)return a;switch(m!==null&&le(m),Ie(o)){case 2:case 8:o=Ce;break;case 32:o=Fe;break;case 268435456:o=ut;break;default:o=Fe}return m=Z0.bind(null,r),o=Pt(o,m),r.callbackPriority=a,r.callbackNode=o,a}return m!==null&&m!==null&&le(m),r.callbackPriority=2,r.callbackNode=null,2}function Z0(r,a){if(or!==0&&or!==5)return r.callbackNode=null,r.callbackPriority=0,null;var o=r.callbackNode;if(ad()&&r.callbackNode!==o)return null;var m=Kt;return m=it(r,r===En?m:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),m===0?null:(R0(r,m,a),W0(r,kt()),r.callbackNode!=null&&r.callbackNode===o?Z0.bind(null,r):null)}function Q0(r,a){if(ad())return null;R0(r,a,!0)}function w2(){D2(function(){(cn&6)!==0?Pt(xe,j2):K0()})}function hm(){if(Ua===0){var r=Wl;r===0&&(r=Hn,Hn<<=1,(Hn&261888)===0&&(Hn=256)),Ua=r}return Ua}function J0(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Le(""+r)}function eb(r,a){var o=a.ownerDocument.createElement("input");return o.name=a.name,o.value=a.value,r.id&&o.setAttribute("form",r.id),a.parentNode.insertBefore(o,a),r=new FormData(r),o.parentNode.removeChild(o),r}function N2(r,a,o,m,v){if(a==="submit"&&o&&o.stateNode===v){var j=J0((v[Ve]||null).action),U=m.submitter;U&&(a=(a=U[Ve]||null)?J0(a.formAction):U.getAttribute("formAction"),a!==null&&(j=a,U=null));var Q=new ht("action","action",null,m,v);r.push({event:Q,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(Ua!==0){var ie=U?eb(v,U):new FormData(v);Df(o,{pending:!0,data:ie,method:v.method,action:j},null,ie)}}else typeof j=="function"&&(Q.preventDefault(),ie=U?eb(v,U):new FormData(v),Df(o,{pending:!0,data:ie,method:v.method,action:j},j,ie))},currentTarget:v}]})}}for(var xm=0;xm<Wu.length;xm++){var pm=Wu[xm],k2=pm.toLowerCase(),S2=pm[0].toUpperCase()+pm.slice(1);Ns(k2,"on"+S2)}Ns(Mp,"onAnimationEnd"),Ns(Rp,"onAnimationIteration"),Ns(Op,"onAnimationStart"),Ns("dblclick","onDoubleClick"),Ns("focusin","onFocus"),Ns("focusout","onBlur"),Ns(P5,"onTransitionRun"),Ns(U5,"onTransitionStart"),Ns(q5,"onTransitionCancel"),Ns(Dp,"onTransitionEnd"),Or("onMouseEnter",["mouseout","mouseover"]),Or("onMouseLeave",["mouseout","mouseover"]),Or("onPointerEnter",["pointerout","pointerover"]),Or("onPointerLeave",["pointerout","pointerover"]),lr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),lr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),lr("onBeforeInput",["compositionend","keypress","textInput","paste"]),lr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),lr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),lr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bo="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(" "),C2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bo));function tb(r,a){a=(a&4)!==0;for(var o=0;o<r.length;o++){var m=r[o],v=m.event;m=m.listeners;e:{var j=void 0;if(a)for(var U=m.length-1;0<=U;U--){var Q=m[U],ie=Q.instance,be=Q.currentTarget;if(Q=Q.listener,ie!==j&&v.isPropagationStopped())break e;j=Q,v.currentTarget=be;try{j(v)}catch(Ae){wc(Ae)}v.currentTarget=null,j=ie}else for(U=0;U<m.length;U++){if(Q=m[U],ie=Q.instance,be=Q.currentTarget,Q=Q.listener,ie!==j&&v.isPropagationStopped())break e;j=Q,v.currentTarget=be;try{j(v)}catch(Ae){wc(Ae)}v.currentTarget=null,j=ie}}}}function Yt(r,a){var o=a[ot];o===void 0&&(o=a[ot]=new Set);var m=r+"__bubble";o.has(m)||(nb(a,r,2,!1),o.add(m))}function gm(r,a,o){var m=0;a&&(m|=4),nb(o,r,m,a)}var od="_reactListening"+Math.random().toString(36).slice(2);function bm(r){if(!r[od]){r[od]=!0,ss.forEach(function(o){o!=="selectionchange"&&(C2.has(o)||gm(o,!1,r),gm(o,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[od]||(a[od]=!0,gm("selectionchange",!1,a))}}function nb(r,a,o,m){switch(Mb(a)){case 2:var v=ek;break;case 8:v=tk;break;default:v=Om}o=v.bind(null,a,o,r),v=void 0,!vs||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),m?v!==void 0?r.addEventListener(a,o,{capture:!0,passive:v}):r.addEventListener(a,o,!0):v!==void 0?r.addEventListener(a,o,{passive:v}):r.addEventListener(a,o,!1)}function ym(r,a,o,m,v){var j=m;if((a&1)===0&&(a&2)===0&&m!==null)e:for(;;){if(m===null)return;var U=m.tag;if(U===3||U===4){var Q=m.stateNode.containerInfo;if(Q===v)break;if(U===4)for(U=m.return;U!==null;){var ie=U.tag;if((ie===3||ie===4)&&U.stateNode.containerInfo===v)return;U=U.return}for(;Q!==null;){if(U=Ot(Q),U===null)return;if(ie=U.tag,ie===5||ie===6||ie===26||ie===27){m=j=U;continue e}Q=Q.parentNode}}m=m.return}yr(function(){var be=j,Ae=en(o),De=[];e:{var je=Lp.get(r);if(je!==void 0){var we=ht,rt=r;switch(r){case"keypress":if(Xe(o)===0)break e;case"keydown":case"keyup":we=y5;break;case"focusin":rt="focus",we=Je;break;case"focusout":rt="blur",we=Je;break;case"beforeblur":case"afterblur":we=Je;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":we=ol;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":we=wt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":we=w5;break;case Mp:case Rp:case Op:we=xt;break;case Dp:we=k5;break;case"scroll":case"scrollend":we=tn;break;case"wheel":we=C5;break;case"copy":case"cut":case"paste":we=vn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":we=fp;break;case"toggle":case"beforetoggle":we=T5}var Nt=(a&4)!==0,Nn=!Nt&&(r==="scroll"||r==="scrollend"),he=Nt?je!==null?je+"Capture":null:je;Nt=[];for(var ce=be,pe;ce!==null;){var _e=ce;if(pe=_e.stateNode,_e=_e.tag,_e!==5&&_e!==26&&_e!==27||pe===null||he===null||(_e=vr(ce,he),_e!=null&&Nt.push(yo(ce,_e,pe))),Nn)break;ce=ce.return}0<Nt.length&&(je=new we(je,rt,null,o,Ae),De.push({event:je,listeners:Nt}))}}if((a&7)===0){e:{if(je=r==="mouseover"||r==="pointerover",we=r==="mouseout"||r==="pointerout",je&&o!==st&&(rt=o.relatedTarget||o.fromElement)&&(Ot(rt)||rt[tt]))break e;if((we||je)&&(je=Ae.window===Ae?Ae:(je=Ae.ownerDocument)?je.defaultView||je.parentWindow:window,we?(rt=o.relatedTarget||o.toElement,we=be,rt=rt?Ot(rt):null,rt!==null&&(Nn=c(rt),Nt=rt.tag,rt!==Nn||Nt!==5&&Nt!==27&&Nt!==6)&&(rt=null)):(we=null,rt=be),we!==rt)){if(Nt=ol,_e="onMouseLeave",he="onMouseEnter",ce="mouse",(r==="pointerout"||r==="pointerover")&&(Nt=fp,_e="onPointerLeave",he="onPointerEnter",ce="pointer"),Nn=we==null?je:Tt(we),pe=rt==null?je:Tt(rt),je=new Nt(_e,ce+"leave",we,o,Ae),je.target=Nn,je.relatedTarget=pe,_e=null,Ot(Ae)===be&&(Nt=new Nt(he,ce+"enter",rt,o,Ae),Nt.target=pe,Nt.relatedTarget=Nn,_e=Nt),Nn=_e,we&&rt)t:{for(Nt=E2,he=we,ce=rt,pe=0,_e=he;_e;_e=Nt(_e))pe++;_e=0;for(var gt=ce;gt;gt=Nt(gt))_e++;for(;0<pe-_e;)he=Nt(he),pe--;for(;0<_e-pe;)ce=Nt(ce),_e--;for(;pe--;){if(he===ce||ce!==null&&he===ce.alternate){Nt=he;break t}he=Nt(he),ce=Nt(ce)}Nt=null}else Nt=null;we!==null&&rb(De,je,we,Nt,!1),rt!==null&&Nn!==null&&rb(De,Nn,rt,Nt,!0)}}e:{if(je=be?Tt(be):window,we=je.nodeName&&je.nodeName.toLowerCase(),we==="select"||we==="input"&&je.type==="file")var sn=vp;else if(bp(je))if(jp)sn=$5;else{sn=I5;var ct=L5}else we=je.nodeName,!we||we.toLowerCase()!=="input"||je.type!=="checkbox"&&je.type!=="radio"?be&&Zs(be.elementType)&&(sn=vp):sn=z5;if(sn&&(sn=sn(r,be))){yp(De,sn,o,Ae);break e}ct&&ct(r,je,be),r==="focusout"&&be&&je.type==="number"&&be.memoizedProps.value!=null&&ys(je,"number",je.value)}switch(ct=be?Tt(be):window,r){case"focusin":(bp(ct)||ct.contentEditable==="true")&&(Ul=ct,Gu=be,Gi=null);break;case"focusout":Gi=Gu=Ul=null;break;case"mousedown":Xu=!0;break;case"contextmenu":case"mouseup":case"dragend":Xu=!1,Ap(De,o,Ae);break;case"selectionchange":if(H5)break;case"keydown":case"keyup":Ap(De,o,Ae)}var Bt;if(qu)e:{switch(r){case"compositionstart":var Wt="onCompositionStart";break e;case"compositionend":Wt="onCompositionEnd";break e;case"compositionupdate":Wt="onCompositionUpdate";break e}Wt=void 0}else Pl?pp(r,o)&&(Wt="onCompositionEnd"):r==="keydown"&&o.keyCode===229&&(Wt="onCompositionStart");Wt&&(mp&&o.locale!=="ko"&&(Pl||Wt!=="onCompositionStart"?Wt==="onCompositionEnd"&&Pl&&(Bt=Ke()):(ee=Ae,Ne="value"in ee?ee.value:ee.textContent,Pl=!0)),ct=cd(be,Wt),0<ct.length&&(Wt=new Cn(Wt,r,null,o,Ae),De.push({event:Wt,listeners:ct}),Bt?Wt.data=Bt:(Bt=gp(o),Bt!==null&&(Wt.data=Bt)))),(Bt=_5?M5(r,o):R5(r,o))&&(Wt=cd(be,"onBeforeInput"),0<Wt.length&&(ct=new Cn("onBeforeInput","beforeinput",null,o,Ae),De.push({event:ct,listeners:Wt}),ct.data=Bt)),N2(De,r,be,o,Ae)}tb(De,a)})}function yo(r,a,o){return{instance:r,listener:a,currentTarget:o}}function cd(r,a){for(var o=a+"Capture",m=[];r!==null;){var v=r,j=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||j===null||(v=vr(r,o),v!=null&&m.unshift(yo(r,v,j)),v=vr(r,a),v!=null&&m.push(yo(r,v,j))),r.tag===3)return m;r=r.return}return[]}function E2(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function rb(r,a,o,m,v){for(var j=a._reactName,U=[];o!==null&&o!==m;){var Q=o,ie=Q.alternate,be=Q.stateNode;if(Q=Q.tag,ie!==null&&ie===m)break;Q!==5&&Q!==26&&Q!==27||be===null||(ie=be,v?(be=vr(o,j),be!=null&&U.unshift(yo(o,be,ie))):v||(be=vr(o,j),be!=null&&U.push(yo(o,be,ie)))),o=o.return}U.length!==0&&r.push({event:a,listeners:U})}var T2=/\r\n?/g,A2=/\u0000|\uFFFD/g;function sb(r){return(typeof r=="string"?r:""+r).replace(T2,`
|
|
9
|
+
`).replace(A2,"")}function ab(r,a){return a=sb(a),sb(r)===a}function wn(r,a,o,m,v,j){switch(o){case"children":typeof m=="string"?a==="body"||a==="textarea"&&m===""||ir(r,m):(typeof m=="number"||typeof m=="bigint")&&a!=="body"&&ir(r,""+m);break;case"className":Dr(r,"class",m);break;case"tabIndex":Dr(r,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":Dr(r,o,m);break;case"style":ls(r,m,j);break;case"data":if(a!=="object"){Dr(r,"data",m);break}case"src":case"href":if(m===""&&(a!=="a"||o!=="href")){r.removeAttribute(o);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){r.removeAttribute(o);break}m=Le(""+m),r.setAttribute(o,m);break;case"action":case"formAction":if(typeof m=="function"){r.setAttribute(o,"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"&&(o==="formAction"?(a!=="input"&&wn(r,a,"name",v.name,v,null),wn(r,a,"formEncType",v.formEncType,v,null),wn(r,a,"formMethod",v.formMethod,v,null),wn(r,a,"formTarget",v.formTarget,v,null)):(wn(r,a,"encType",v.encType,v,null),wn(r,a,"method",v.method,v,null),wn(r,a,"target",v.target,v,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){r.removeAttribute(o);break}m=Le(""+m),r.setAttribute(o,m);break;case"onClick":m!=null&&(r.onclick=Be);break;case"onScroll":m!=null&&Yt("scroll",r);break;case"onScrollEnd":m!=null&&Yt("scrollend",r);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(l(61));if(o=m.__html,o!=null){if(v.children!=null)throw Error(l(60));r.innerHTML=o}}break;case"multiple":r.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":r.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){r.removeAttribute("xlink:href");break}o=Le(""+m),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":m!=null&&typeof m!="function"&&typeof m!="symbol"?r.setAttribute(o,""+m):r.removeAttribute(o);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":m&&typeof m!="function"&&typeof m!="symbol"?r.setAttribute(o,""):r.removeAttribute(o);break;case"capture":case"download":m===!0?r.setAttribute(o,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?r.setAttribute(o,m):r.removeAttribute(o);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?r.setAttribute(o,m):r.removeAttribute(o);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?r.removeAttribute(o):r.setAttribute(o,m);break;case"popover":Yt("beforetoggle",r),Yt("toggle",r),gr(r,"popover",m);break;case"xlinkActuate":fr(r,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":fr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":fr(r,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":fr(r,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":fr(r,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":fr(r,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":fr(r,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":fr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":fr(r,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":gr(r,"is",m);break;case"innerText":case"textContent":break;default:(!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(o=Ca.get(o)||o,gr(r,o,m))}}function vm(r,a,o,m,v,j){switch(o){case"style":ls(r,m,j);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(l(61));if(o=m.__html,o!=null){if(v.children!=null)throw Error(l(60));r.innerHTML=o}}break;case"children":typeof m=="string"?ir(r,m):(typeof m=="number"||typeof m=="bigint")&&ir(r,""+m);break;case"onScroll":m!=null&&Yt("scroll",r);break;case"onScrollEnd":m!=null&&Yt("scrollend",r);break;case"onClick":m!=null&&(r.onclick=Be);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Rr.hasOwnProperty(o))e:{if(o[0]==="o"&&o[1]==="n"&&(v=o.endsWith("Capture"),a=o.slice(2,v?o.length-7:void 0),j=r[Ve]||null,j=j!=null?j[o]:null,typeof j=="function"&&r.removeEventListener(a,j,v),typeof m=="function")){typeof j!="function"&&j!==null&&(o in r?r[o]=null:r.hasAttribute(o)&&r.removeAttribute(o)),r.addEventListener(a,m,v);break e}o in r?r[o]=m:m===!0?r.setAttribute(o,""):gr(r,o,m)}}}function Sr(r,a,o){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Yt("error",r),Yt("load",r);var m=!1,v=!1,j;for(j in o)if(o.hasOwnProperty(j)){var U=o[j];if(U!=null)switch(j){case"src":m=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,a));default:wn(r,a,j,U,o,null)}}v&&wn(r,a,"srcSet",o.srcSet,o,null),m&&wn(r,a,"src",o.src,o,null);return;case"input":Yt("invalid",r);var Q=j=U=v=null,ie=null,be=null;for(m in o)if(o.hasOwnProperty(m)){var Ae=o[m];if(Ae!=null)switch(m){case"name":v=Ae;break;case"type":U=Ae;break;case"checked":ie=Ae;break;case"defaultChecked":be=Ae;break;case"value":j=Ae;break;case"defaultValue":Q=Ae;break;case"children":case"dangerouslySetInnerHTML":if(Ae!=null)throw Error(l(137,a));break;default:wn(r,a,m,Ae,o,null)}}Ls(r,j,Q,ie,be,U,v,!1);return;case"select":Yt("invalid",r),m=U=j=null;for(v in o)if(o.hasOwnProperty(v)&&(Q=o[v],Q!=null))switch(v){case"value":j=Q;break;case"defaultValue":U=Q;break;case"multiple":m=Q;default:wn(r,a,v,Q,o,null)}a=j,o=U,r.multiple=!!m,a!=null?br(r,!!m,a,!1):o!=null&&br(r,!!m,o,!0);return;case"textarea":Yt("invalid",r),j=v=m=null;for(U in o)if(o.hasOwnProperty(U)&&(Q=o[U],Q!=null))switch(U){case"value":m=Q;break;case"defaultValue":v=Q;break;case"children":j=Q;break;case"dangerouslySetInnerHTML":if(Q!=null)throw Error(l(91));break;default:wn(r,a,U,Q,o,null)}Hl(r,m,v,j);return;case"option":for(ie in o)o.hasOwnProperty(ie)&&(m=o[ie],m!=null)&&(ie==="selected"?r.selected=m&&typeof m!="function"&&typeof m!="symbol":wn(r,a,ie,m,o,null));return;case"dialog":Yt("beforetoggle",r),Yt("toggle",r),Yt("cancel",r),Yt("close",r);break;case"iframe":case"object":Yt("load",r);break;case"video":case"audio":for(m=0;m<bo.length;m++)Yt(bo[m],r);break;case"image":Yt("error",r),Yt("load",r);break;case"details":Yt("toggle",r);break;case"embed":case"source":case"link":Yt("error",r),Yt("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(be in o)if(o.hasOwnProperty(be)&&(m=o[be],m!=null))switch(be){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,a));default:wn(r,a,be,m,o,null)}return;default:if(Zs(a)){for(Ae in o)o.hasOwnProperty(Ae)&&(m=o[Ae],m!==void 0&&vm(r,a,Ae,m,o,void 0));return}}for(Q in o)o.hasOwnProperty(Q)&&(m=o[Q],m!=null&&wn(r,a,Q,m,o,null))}function _2(r,a,o,m){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var v=null,j=null,U=null,Q=null,ie=null,be=null,Ae=null;for(we in o){var De=o[we];if(o.hasOwnProperty(we)&&De!=null)switch(we){case"checked":break;case"value":break;case"defaultValue":ie=De;default:m.hasOwnProperty(we)||wn(r,a,we,null,m,De)}}for(var je in m){var we=m[je];if(De=o[je],m.hasOwnProperty(je)&&(we!=null||De!=null))switch(je){case"type":j=we;break;case"name":v=we;break;case"checked":be=we;break;case"defaultChecked":Ae=we;break;case"value":U=we;break;case"defaultValue":Q=we;break;case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(l(137,a));break;default:we!==De&&wn(r,a,je,we,m,De)}}mr(r,U,Q,ie,be,Ae,j,v);return;case"select":we=U=Q=je=null;for(j in o)if(ie=o[j],o.hasOwnProperty(j)&&ie!=null)switch(j){case"value":break;case"multiple":we=ie;default:m.hasOwnProperty(j)||wn(r,a,j,null,m,ie)}for(v in m)if(j=m[v],ie=o[v],m.hasOwnProperty(v)&&(j!=null||ie!=null))switch(v){case"value":je=j;break;case"defaultValue":Q=j;break;case"multiple":U=j;default:j!==ie&&wn(r,a,v,j,m,ie)}a=Q,o=U,m=we,je!=null?br(r,!!o,je,!1):!!m!=!!o&&(a!=null?br(r,!!o,a,!0):br(r,!!o,o?[]:"",!1));return;case"textarea":we=je=null;for(Q in o)if(v=o[Q],o.hasOwnProperty(Q)&&v!=null&&!m.hasOwnProperty(Q))switch(Q){case"value":break;case"children":break;default:wn(r,a,Q,null,m,v)}for(U in m)if(v=m[U],j=o[U],m.hasOwnProperty(U)&&(v!=null||j!=null))switch(U){case"value":je=v;break;case"defaultValue":we=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(l(91));break;default:v!==j&&wn(r,a,U,v,m,j)}ka(r,je,we);return;case"option":for(var rt in o)je=o[rt],o.hasOwnProperty(rt)&&je!=null&&!m.hasOwnProperty(rt)&&(rt==="selected"?r.selected=!1:wn(r,a,rt,null,m,je));for(ie in m)je=m[ie],we=o[ie],m.hasOwnProperty(ie)&&je!==we&&(je!=null||we!=null)&&(ie==="selected"?r.selected=je&&typeof je!="function"&&typeof je!="symbol":wn(r,a,ie,je,m,we));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Nt in o)je=o[Nt],o.hasOwnProperty(Nt)&&je!=null&&!m.hasOwnProperty(Nt)&&wn(r,a,Nt,null,m,je);for(be in m)if(je=m[be],we=o[be],m.hasOwnProperty(be)&&je!==we&&(je!=null||we!=null))switch(be){case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(l(137,a));break;default:wn(r,a,be,je,m,we)}return;default:if(Zs(a)){for(var Nn in o)je=o[Nn],o.hasOwnProperty(Nn)&&je!==void 0&&!m.hasOwnProperty(Nn)&&vm(r,a,Nn,void 0,m,je);for(Ae in m)je=m[Ae],we=o[Ae],!m.hasOwnProperty(Ae)||je===we||je===void 0&&we===void 0||vm(r,a,Ae,je,m,we);return}}for(var he in o)je=o[he],o.hasOwnProperty(he)&&je!=null&&!m.hasOwnProperty(he)&&wn(r,a,he,null,m,je);for(De in m)je=m[De],we=o[De],!m.hasOwnProperty(De)||je===we||je==null&&we==null||wn(r,a,De,je,m,we)}function lb(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function M2(){if(typeof performance.getEntriesByType=="function"){for(var r=0,a=0,o=performance.getEntriesByType("resource"),m=0;m<o.length;m++){var v=o[m],j=v.transferSize,U=v.initiatorType,Q=v.duration;if(j&&Q&&lb(U)){for(U=0,Q=v.responseEnd,m+=1;m<o.length;m++){var ie=o[m],be=ie.startTime;if(be>Q)break;var Ae=ie.transferSize,De=ie.initiatorType;Ae&&lb(De)&&(ie=ie.responseEnd,U+=Ae*(ie<Q?1:(Q-be)/(ie-be)))}if(--m,a+=8*(j+U)/(v.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 jm=null,wm=null;function dd(r){return r.nodeType===9?r:r.ownerDocument}function ib(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 ob(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 Nm(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 km=null;function R2(){var r=window.event;return r&&r.type==="popstate"?r===km?!1:(km=r,!0):(km=null,!1)}var cb=typeof setTimeout=="function"?setTimeout:void 0,O2=typeof clearTimeout=="function"?clearTimeout:void 0,db=typeof Promise=="function"?Promise:void 0,D2=typeof queueMicrotask=="function"?queueMicrotask:typeof db<"u"?function(r){return db.resolve(null).then(r).catch(L2)}:cb;function L2(r){setTimeout(function(){throw r})}function qa(r){return r==="head"}function ub(r,a){var o=a,m=0;do{var v=o.nextSibling;if(r.removeChild(o),v&&v.nodeType===8)if(o=v.data,o==="/$"||o==="/&"){if(m===0){r.removeChild(v),xi(a);return}m--}else if(o==="$"||o==="$?"||o==="$~"||o==="$!"||o==="&")m++;else if(o==="html")vo(r.ownerDocument.documentElement);else if(o==="head"){o=r.ownerDocument.head,vo(o);for(var j=o.firstChild;j;){var U=j.nextSibling,Q=j.nodeName;j[mn]||Q==="SCRIPT"||Q==="STYLE"||Q==="LINK"&&j.rel.toLowerCase()==="stylesheet"||o.removeChild(j),j=U}}else o==="body"&&vo(r.ownerDocument.body);o=v}while(o);xi(a)}function fb(r,a){var o=r;r=0;do{var m=o.nextSibling;if(o.nodeType===1?a?(o._stashedDisplay=o.style.display,o.style.display="none"):(o.style.display=o._stashedDisplay||"",o.getAttribute("style")===""&&o.removeAttribute("style")):o.nodeType===3&&(a?(o._stashedText=o.nodeValue,o.nodeValue=""):o.nodeValue=o._stashedText||""),m&&m.nodeType===8)if(o=m.data,o==="/$"){if(r===0)break;r--}else o!=="$"&&o!=="$?"&&o!=="$~"&&o!=="$!"||r++;o=m}while(o)}function Sm(r){var a=r.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var o=a;switch(a=a.nextSibling,o.nodeName){case"HTML":case"HEAD":case"BODY":Sm(o),Wn(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}r.removeChild(o)}}function I2(r,a,o,m){for(;r.nodeType===1;){var v=o;if(r.nodeName.toLowerCase()!==a.toLowerCase()){if(!m&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(m){if(!r[mn])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!==v.rel||r.getAttribute("href")!==(v.href==null||v.href===""?null:v.href)||r.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin)||r.getAttribute("title")!==(v.title==null?null:v.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(j=r.getAttribute("src"),(j!==(v.src==null?null:v.src)||r.getAttribute("type")!==(v.type==null?null:v.type)||r.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&j&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(a==="input"&&r.type==="hidden"){var j=v.name==null?null:""+v.name;if(v.type==="hidden"&&r.getAttribute("name")===j)return r}else return r;if(r=ms(r.nextSibling),r===null)break}return null}function z2(r,a,o){if(a==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!o||(r=ms(r.nextSibling),r===null))return null;return r}function mb(r,a){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!a||(r=ms(r.nextSibling),r===null))return null;return r}function Cm(r){return r.data==="$?"||r.data==="$~"}function Em(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function $2(r,a){var o=r.ownerDocument;if(r.data==="$~")r._reactRetry=a;else if(r.data!=="$?"||o.readyState!=="loading")a();else{var m=function(){a(),o.removeEventListener("DOMContentLoaded",m)};o.addEventListener("DOMContentLoaded",m),r._reactRetry=m}}function ms(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 Tm=null;function hb(r){r=r.nextSibling;for(var a=0;r;){if(r.nodeType===8){var o=r.data;if(o==="/$"||o==="/&"){if(a===0)return ms(r.nextSibling);a--}else o!=="$"&&o!=="$!"&&o!=="$?"&&o!=="$~"&&o!=="&"||a++}r=r.nextSibling}return null}function xb(r){r=r.previousSibling;for(var a=0;r;){if(r.nodeType===8){var o=r.data;if(o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"){if(a===0)return r;a--}else o!=="/$"&&o!=="/&"||a++}r=r.previousSibling}return null}function pb(r,a,o){switch(a=dd(o),r){case"html":if(r=a.documentElement,!r)throw Error(l(452));return r;case"head":if(r=a.head,!r)throw Error(l(453));return r;case"body":if(r=a.body,!r)throw Error(l(454));return r;default:throw Error(l(451))}}function vo(r){for(var a=r.attributes;a.length;)r.removeAttributeNode(a[0]);Wn(r)}var hs=new Map,gb=new Set;function ud(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var fa=V.d;V.d={f:B2,r:H2,D:P2,C:U2,L:q2,m:F2,X:Y2,S:V2,M:G2};function B2(){var r=fa.f(),a=nd();return r||a}function H2(r){var a=pr(r);a!==null&&a.tag===5&&a.type==="form"?Dg(a):fa.r(r)}var fi=typeof document>"u"?null:document;function bb(r,a,o){var m=fi;if(m&&typeof a=="string"&&a){var v=Pn(a);v='link[rel="'+r+'"][href="'+v+'"]',typeof o=="string"&&(v+='[crossorigin="'+o+'"]'),gb.has(v)||(gb.add(v),r={rel:r,crossOrigin:o,href:a},m.querySelector(v)===null&&(a=m.createElement("link"),Sr(a,"link",r),ln(a),m.head.appendChild(a)))}}function P2(r){fa.D(r),bb("dns-prefetch",r,null)}function U2(r,a){fa.C(r,a),bb("preconnect",r,a)}function q2(r,a,o){fa.L(r,a,o);var m=fi;if(m&&r&&a){var v='link[rel="preload"][as="'+Pn(a)+'"]';a==="image"&&o&&o.imageSrcSet?(v+='[imagesrcset="'+Pn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(v+='[imagesizes="'+Pn(o.imageSizes)+'"]')):v+='[href="'+Pn(r)+'"]';var j=v;switch(a){case"style":j=mi(r);break;case"script":j=hi(r)}hs.has(j)||(r=p({rel:"preload",href:a==="image"&&o&&o.imageSrcSet?void 0:r,as:a},o),hs.set(j,r),m.querySelector(v)!==null||a==="style"&&m.querySelector(jo(j))||a==="script"&&m.querySelector(wo(j))||(a=m.createElement("link"),Sr(a,"link",r),ln(a),m.head.appendChild(a)))}}function F2(r,a){fa.m(r,a);var o=fi;if(o&&r){var m=a&&typeof a.as=="string"?a.as:"script",v='link[rel="modulepreload"][as="'+Pn(m)+'"][href="'+Pn(r)+'"]',j=v;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=hi(r)}if(!hs.has(j)&&(r=p({rel:"modulepreload",href:r},a),hs.set(j,r),o.querySelector(v)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(wo(j)))return}m=o.createElement("link"),Sr(m,"link",r),ln(m),o.head.appendChild(m)}}}function V2(r,a,o){fa.S(r,a,o);var m=fi;if(m&&r){var v=hn(m).hoistableStyles,j=mi(r);a=a||"default";var U=v.get(j);if(!U){var Q={loading:0,preload:null};if(U=m.querySelector(jo(j)))Q.loading=5;else{r=p({rel:"stylesheet",href:r,"data-precedence":a},o),(o=hs.get(j))&&Am(r,o);var ie=U=m.createElement("link");ln(ie),Sr(ie,"link",r),ie._p=new Promise(function(be,Ae){ie.onload=be,ie.onerror=Ae}),ie.addEventListener("load",function(){Q.loading|=1}),ie.addEventListener("error",function(){Q.loading|=2}),Q.loading|=4,fd(U,a,m)}U={type:"stylesheet",instance:U,count:1,state:Q},v.set(j,U)}}}function Y2(r,a){fa.X(r,a);var o=fi;if(o&&r){var m=hn(o).hoistableScripts,v=hi(r),j=m.get(v);j||(j=o.querySelector(wo(v)),j||(r=p({src:r,async:!0},a),(a=hs.get(v))&&_m(r,a),j=o.createElement("script"),ln(j),Sr(j,"link",r),o.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},m.set(v,j))}}function G2(r,a){fa.M(r,a);var o=fi;if(o&&r){var m=hn(o).hoistableScripts,v=hi(r),j=m.get(v);j||(j=o.querySelector(wo(v)),j||(r=p({src:r,async:!0,type:"module"},a),(a=hs.get(v))&&_m(r,a),j=o.createElement("script"),ln(j),Sr(j,"link",r),o.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},m.set(v,j))}}function yb(r,a,o,m){var v=(v=W.current)?ud(v):null;if(!v)throw Error(l(446));switch(r){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(a=mi(o.href),o=hn(v).hoistableStyles,m=o.get(a),m||(m={type:"style",instance:null,count:0,state:null},o.set(a,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){r=mi(o.href);var j=hn(v).hoistableStyles,U=j.get(r);if(U||(v=v.ownerDocument||v,U={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(r,U),(j=v.querySelector(jo(r)))&&!j._p&&(U.instance=j,U.state.loading=5),hs.has(r)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},hs.set(r,o),j||X2(v,r,o,U.state))),a&&m===null)throw Error(l(528,""));return U}if(a&&m!==null)throw Error(l(529,""));return null;case"script":return a=o.async,o=o.src,typeof o=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=hi(o),o=hn(v).hoistableScripts,m=o.get(a),m||(m={type:"script",instance:null,count:0,state:null},o.set(a,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,r))}}function mi(r){return'href="'+Pn(r)+'"'}function jo(r){return'link[rel="stylesheet"]['+r+"]"}function vb(r){return p({},r,{"data-precedence":r.precedence,precedence:null})}function X2(r,a,o,m){r.querySelector('link[rel="preload"][as="style"]['+a+"]")?m.loading=1:(a=r.createElement("link"),m.preload=a,a.addEventListener("load",function(){return m.loading|=1}),a.addEventListener("error",function(){return m.loading|=2}),Sr(a,"link",o),ln(a),r.head.appendChild(a))}function hi(r){return'[src="'+Pn(r)+'"]'}function wo(r){return"script[async]"+r}function jb(r,a,o){if(a.count++,a.instance===null)switch(a.type){case"style":var m=r.querySelector('style[data-href~="'+Pn(o.href)+'"]');if(m)return a.instance=m,ln(m),m;var v=p({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return m=(r.ownerDocument||r).createElement("style"),ln(m),Sr(m,"style",v),fd(m,o.precedence,r),a.instance=m;case"stylesheet":v=mi(o.href);var j=r.querySelector(jo(v));if(j)return a.state.loading|=4,a.instance=j,ln(j),j;m=vb(o),(v=hs.get(v))&&Am(m,v),j=(r.ownerDocument||r).createElement("link"),ln(j);var U=j;return U._p=new Promise(function(Q,ie){U.onload=Q,U.onerror=ie}),Sr(j,"link",m),a.state.loading|=4,fd(j,o.precedence,r),a.instance=j;case"script":return j=hi(o.src),(v=r.querySelector(wo(j)))?(a.instance=v,ln(v),v):(m=o,(v=hs.get(j))&&(m=p({},o),_m(m,v)),r=r.ownerDocument||r,v=r.createElement("script"),ln(v),Sr(v,"link",m),r.head.appendChild(v),a.instance=v);case"void":return null;default:throw Error(l(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(m=a.instance,a.state.loading|=4,fd(m,o.precedence,r));return a.instance}function fd(r,a,o){for(var m=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=m.length?m[m.length-1]:null,j=v,U=0;U<m.length;U++){var Q=m[U];if(Q.dataset.precedence===a)j=Q;else if(j!==v)break}j?j.parentNode.insertBefore(r,j.nextSibling):(a=o.nodeType===9?o.head:o,a.insertBefore(r,a.firstChild))}function Am(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.title==null&&(r.title=a.title)}function _m(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.integrity==null&&(r.integrity=a.integrity)}var md=null;function wb(r,a,o){if(md===null){var m=new Map,v=md=new Map;v.set(o,m)}else v=md,m=v.get(o),m||(m=new Map,v.set(o,m));if(m.has(r))return m;for(m.set(r,null),o=o.getElementsByTagName(r),v=0;v<o.length;v++){var j=o[v];if(!(j[mn]||j[ze]||r==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var U=j.getAttribute(a)||"";U=r+U;var Q=m.get(U);Q?Q.push(j):m.set(U,[j])}}return m}function Nb(r,a,o){r=r.ownerDocument||r,r.head.insertBefore(o,a==="title"?r.querySelector("head > title"):null)}function K2(r,a,o){if(o===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 kb(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function W2(r,a,o,m){if(o.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var v=mi(m.href),j=a.querySelector(jo(v));if(j){a=j._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(r.count++,r=hd.bind(r),a.then(r,r)),o.state.loading|=4,o.instance=j,ln(j);return}j=a.ownerDocument||a,m=vb(m),(v=hs.get(v))&&Am(m,v),j=j.createElement("link"),ln(j);var U=j;U._p=new Promise(function(Q,ie){U.onload=Q,U.onerror=ie}),Sr(j,"link",m),o.instance=j}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(o,a),(a=o.state.preload)&&(o.state.loading&3)===0&&(r.count++,o=hd.bind(r),a.addEventListener("load",o),a.addEventListener("error",o))}}var Mm=0;function Z2(r,a){return r.stylesheets&&r.count===0&&pd(r,r.stylesheets),0<r.count||0<r.imgCount?function(o){var m=setTimeout(function(){if(r.stylesheets&&pd(r,r.stylesheets),r.unsuspend){var j=r.unsuspend;r.unsuspend=null,j()}},6e4+a);0<r.imgBytes&&Mm===0&&(Mm=62500*M2());var v=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&pd(r,r.stylesheets),r.unsuspend)){var j=r.unsuspend;r.unsuspend=null,j()}},(r.imgBytes>Mm?50:800)+a);return r.unsuspend=o,function(){r.unsuspend=null,clearTimeout(m),clearTimeout(v)}}:null}function hd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)pd(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var xd=null;function pd(r,a){r.stylesheets=null,r.unsuspend!==null&&(r.count++,xd=new Map,a.forEach(Q2,r),xd=null,hd.call(r))}function Q2(r,a){if(!(a.state.loading&4)){var o=xd.get(r);if(o)var m=o.get(null);else{o=new Map,xd.set(r,o);for(var v=r.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<v.length;j++){var U=v[j];(U.nodeName==="LINK"||U.getAttribute("media")!=="not all")&&(o.set(U.dataset.precedence,U),m=U)}m&&o.set(null,m)}v=a.instance,U=v.getAttribute("data-precedence"),j=o.get(U)||m,j===m&&o.set(null,v),o.set(U,v),this.count++,m=hd.bind(this),v.addEventListener("load",m),v.addEventListener("error",m),j?j.parentNode.insertBefore(v,j.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(v,r.firstChild)),a.state.loading|=4}}var No={$$typeof:N,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function J2(r,a,o,m,v,j,U,Q,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=_n(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_n(0),this.hiddenUpdates=_n(null),this.identifierPrefix=m,this.onUncaughtError=v,this.onCaughtError=j,this.onRecoverableError=U,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function Sb(r,a,o,m,v,j,U,Q,ie,be,Ae,De){return r=new J2(r,a,o,U,ie,be,Ae,De,Q),a=1,j===!0&&(a|=24),j=Xr(3,null,null,a),r.current=j,j.stateNode=r,a=df(),a.refCount++,r.pooledCache=a,a.refCount++,j.memoizedState={element:m,isDehydrated:o,cache:a},hf(j),r}function Cb(r){return r?(r=Vl,r):Vl}function Eb(r,a,o,m,v,j){v=Cb(v),m.context===null?m.context=v:m.pendingContext=v,m=Ra(a),m.payload={element:o},j=j===void 0?null:j,j!==null&&(m.callback=j),o=Oa(r,m,a),o!==null&&(Pr(o,r,a),eo(o,r,a))}function Tb(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var o=r.retryLane;r.retryLane=o!==0&&o<a?o:a}}function Rm(r,a){Tb(r,a),(r=r.alternate)&&Tb(r,a)}function Ab(r){if(r.tag===13||r.tag===31){var a=ul(r,67108864);a!==null&&Pr(a,r,67108864),Rm(r,67108864)}}function _b(r){if(r.tag===13||r.tag===31){var a=Jr();a=ae(a);var o=ul(r,a);o!==null&&Pr(o,r,a),Rm(r,a)}}var gd=!0;function ek(r,a,o,m){var v=O.T;O.T=null;var j=V.p;try{V.p=2,Om(r,a,o,m)}finally{V.p=j,O.T=v}}function tk(r,a,o,m){var v=O.T;O.T=null;var j=V.p;try{V.p=8,Om(r,a,o,m)}finally{V.p=j,O.T=v}}function Om(r,a,o,m){if(gd){var v=Dm(m);if(v===null)ym(r,a,m,bd,o),Rb(r,m);else if(rk(v,r,a,o,m))m.stopPropagation();else if(Rb(r,m),a&4&&-1<nk.indexOf(r)){for(;v!==null;){var j=pr(v);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var U=Ge(j.pendingLanes);if(U!==0){var Q=j;for(Q.pendingLanes|=2,Q.entangledLanes|=2;U;){var ie=1<<31-yt(U);Q.entanglements[1]|=ie,U&=~ie}Bs(j),(cn&6)===0&&(ed=kt()+500,go(0))}}break;case 31:case 13:Q=ul(j,2),Q!==null&&Pr(Q,j,2),nd(),Rm(j,2)}if(j=Dm(m),j===null&&ym(r,a,m,bd,o),j===v)break;v=j}v!==null&&m.stopPropagation()}else ym(r,a,m,null,o)}}function Dm(r){return r=en(r),Lm(r)}var bd=null;function Lm(r){if(bd=null,r=Ot(r),r!==null){var a=c(r);if(a===null)r=null;else{var o=a.tag;if(o===13){if(r=d(a),r!==null)return r;r=null}else if(o===31){if(r=u(a),r!==null)return r;r=null}else if(o===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;r=null}else a!==r&&(r=null)}}return bd=r,null}function Mb(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(Ft()){case xe:return 2;case Ce:return 8;case Fe:case lt:return 32;case ut:return 268435456;default:return 32}default:return 32}}var Im=!1,Fa=null,Va=null,Ya=null,ko=new Map,So=new Map,Ga=[],nk="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Rb(r,a){switch(r){case"focusin":case"focusout":Fa=null;break;case"dragenter":case"dragleave":Va=null;break;case"mouseover":case"mouseout":Ya=null;break;case"pointerover":case"pointerout":ko.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":So.delete(a.pointerId)}}function Co(r,a,o,m,v,j){return r===null||r.nativeEvent!==j?(r={blockedOn:a,domEventName:o,eventSystemFlags:m,nativeEvent:j,targetContainers:[v]},a!==null&&(a=pr(a),a!==null&&Ab(a)),r):(r.eventSystemFlags|=m,a=r.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),r)}function rk(r,a,o,m,v){switch(a){case"focusin":return Fa=Co(Fa,r,a,o,m,v),!0;case"dragenter":return Va=Co(Va,r,a,o,m,v),!0;case"mouseover":return Ya=Co(Ya,r,a,o,m,v),!0;case"pointerover":var j=v.pointerId;return ko.set(j,Co(ko.get(j)||null,r,a,o,m,v)),!0;case"gotpointercapture":return j=v.pointerId,So.set(j,Co(So.get(j)||null,r,a,o,m,v)),!0}return!1}function Ob(r){var a=Ot(r.target);if(a!==null){var o=c(a);if(o!==null){if(a=o.tag,a===13){if(a=d(o),a!==null){r.blockedOn=a,Qe(r.priority,function(){_b(o)});return}}else if(a===31){if(a=u(o),a!==null){r.blockedOn=a,Qe(r.priority,function(){_b(o)});return}}else if(a===3&&o.stateNode.current.memoizedState.isDehydrated){r.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}r.blockedOn=null}function yd(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var o=Dm(r.nativeEvent);if(o===null){o=r.nativeEvent;var m=new o.constructor(o.type,o);st=m,o.target.dispatchEvent(m),st=null}else return a=pr(o),a!==null&&Ab(a),r.blockedOn=o,!1;a.shift()}return!0}function Db(r,a,o){yd(r)&&o.delete(a)}function sk(){Im=!1,Fa!==null&&yd(Fa)&&(Fa=null),Va!==null&&yd(Va)&&(Va=null),Ya!==null&&yd(Ya)&&(Ya=null),ko.forEach(Db),So.forEach(Db)}function vd(r,a){r.blockedOn===a&&(r.blockedOn=null,Im||(Im=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,sk)))}var jd=null;function Lb(r){jd!==r&&(jd=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){jd===r&&(jd=null);for(var a=0;a<r.length;a+=3){var o=r[a],m=r[a+1],v=r[a+2];if(typeof m!="function"){if(Lm(m||o)===null)continue;break}var j=pr(o);j!==null&&(r.splice(a,3),a-=3,Df(j,{pending:!0,data:v,method:o.method,action:m},m,v))}}))}function xi(r){function a(ie){return vd(ie,r)}Fa!==null&&vd(Fa,r),Va!==null&&vd(Va,r),Ya!==null&&vd(Ya,r),ko.forEach(a),So.forEach(a);for(var o=0;o<Ga.length;o++){var m=Ga[o];m.blockedOn===r&&(m.blockedOn=null)}for(;0<Ga.length&&(o=Ga[0],o.blockedOn===null);)Ob(o),o.blockedOn===null&&Ga.shift();if(o=(r.ownerDocument||r).$$reactFormReplay,o!=null)for(m=0;m<o.length;m+=3){var v=o[m],j=o[m+1],U=v[Ve]||null;if(typeof j=="function")U||Lb(o);else if(U){var Q=null;if(j&&j.hasAttribute("formAction")){if(v=j,U=j[Ve]||null)Q=U.formAction;else if(Lm(v)!==null)continue}else Q=U.action;typeof Q=="function"?o[m+1]=Q:(o.splice(m,3),m-=3),Lb(o)}}}function Ib(){function r(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(U){return v=U})},focusReset:"manual",scroll:"manual"})}function a(){v!==null&&(v(),v=null),m||setTimeout(o,20)}function o(){if(!m&&!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 m=!1,v=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(o,100),function(){m=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),v!==null&&(v(),v=null)}}}function zm(r){this._internalRoot=r}wd.prototype.render=zm.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(l(409));var o=a.current,m=Jr();Eb(o,m,r,a,null,null)},wd.prototype.unmount=zm.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;Eb(r.current,2,null,r,null,null),nd(),a[tt]=null}};function wd(r){this._internalRoot=r}wd.prototype.unstable_scheduleHydration=function(r){if(r){var a=qe();r={blockedOn:null,target:r,priority:a};for(var o=0;o<Ga.length&&a!==0&&a<Ga[o].priority;o++);Ga.splice(o,0,r),o===0&&Ob(r)}};var zb=n.version;if(zb!=="19.2.4")throw Error(l(527,zb,"19.2.4"));V.findDOMNode=function(r){var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(l(188)):(r=Object.keys(r).join(","),Error(l(268,r)));return r=f(a),r=r!==null?x(r):null,r=r===null?null:r.stateNode,r};var ak={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Nd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nd.isDisabled&&Nd.supportsFiber)try{Ut=Nd.inject(ak),St=Nd}catch{}}return To.createRoot=function(r,a){if(!i(r))throw Error(l(299));var o=!1,m="",v=Fg,j=Vg,U=Yg;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(m=a.identifierPrefix),a.onUncaughtError!==void 0&&(v=a.onUncaughtError),a.onCaughtError!==void 0&&(j=a.onCaughtError),a.onRecoverableError!==void 0&&(U=a.onRecoverableError)),a=Sb(r,1,!1,null,null,o,m,null,v,j,U,Ib),r[tt]=a.current,bm(r),new zm(a)},To.hydrateRoot=function(r,a,o){if(!i(r))throw Error(l(299));var m=!1,v="",j=Fg,U=Vg,Q=Yg,ie=null;return o!=null&&(o.unstable_strictMode===!0&&(m=!0),o.identifierPrefix!==void 0&&(v=o.identifierPrefix),o.onUncaughtError!==void 0&&(j=o.onUncaughtError),o.onCaughtError!==void 0&&(U=o.onCaughtError),o.onRecoverableError!==void 0&&(Q=o.onRecoverableError),o.formState!==void 0&&(ie=o.formState)),a=Sb(r,1,!0,a,o??null,m,v,ie,j,U,Q,Ib),a.context=Cb(null),o=a.current,m=Jr(),m=ae(m),v=Ra(m),v.callback=null,Oa(o,v,m),o=m,a.current.lanes=o,Mn(a,o),Bs(a),r[tt]=a.current,bm(r),new wd(a)},To.version="19.2.4",To}var Gb;function xk(){if(Gb)return Hm.exports;Gb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Hm.exports=hk(),Hm.exports}var pk=xk();const ge={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",REPORTS:"reports",SETTINGS:"settings"},gk=new Set(Object.values(ge)),bk={dashboard:ge.HOME,overview:ge.HOME,chat:ge.TEAM,projects:ge.WORK,tasks:ge.WORK,usage:ge.REPORTS,prompts:ge.BUILDER,templates:ge.STORE,agents:ge.STORE,skills:ge.STORE,teams:ge.STORE,knowledge:ge.DELIVERABLES,governance:ge.SETTINGS};function ba(e){return gk.has(e)?e:bk[e]??ge.HOME}function kd(){const e=window.location.hash.slice(1).split("/")[0];return ba(e)}function Dh(e,n){return n?`#${e}/${n}`:`#${e}`}const yk={[ge.STORE]:ge.BUILDER,[ge.REPORTS]:ge.SETTINGS},wi={[ge.HOME]:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",[ge.WORK]:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",[ge.TEAM]:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",[ge.REPORTS]:"M18 20V10 M12 20V4 M6 20v-6",[ge.DELIVERABLES]:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z",[ge.BUILDER]:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",[ge.STORE]:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",[ge.SETTINGS]:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"},vk=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],jk=[{id:ge.HOME,label:"Home",section:"workspace"},{id:ge.TEAM,label:"Team",section:"workspace"},{id:ge.DELIVERABLES,label:"Deliverables",section:"workspace"},{id:ge.BUILDER,label:"Builder",section:"build"},{id:ge.STORE,label:"Store",section:"build"},{id:ge.REPORTS,label:"Reports",section:"system"},{id:ge.SETTINGS,label:"Settings",section:"system"}],wk=[{id:ge.HOME,label:"Home",group:[ge.HOME]},{id:ge.TEAM,label:"Team",group:[ge.TEAM]},{id:ge.WORK,label:"Work",group:[ge.WORK]},{id:ge.DELIVERABLES,label:"Deliverables",group:[ge.DELIVERABLES]},{id:ge.BUILDER,label:"Builder",group:[ge.BUILDER,ge.STORE]},{id:ge.SETTINGS,label:"Settings",group:[ge.SETTINGS,ge.REPORTS]}],wx="/api";async function fe(e,n){const s=await fetch(`${wx}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...n,body:n?.body?typeof n.body=="string"?n.body:JSON.stringify(n.body):void 0});if(!s.ok){let l="";try{const i=await s.json();l=i.error??i.message??""}catch{}throw new Error(l||`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,l)=>fe("/agents",{method:"POST",body:JSON.stringify({name:e,...n?{roleName:n}:{},agentRole:s,teamId:l})}),start:e=>fe(`/agents/${e}/start`,{method:"POST"}),stop:e=>fe(`/agents/${e}/stop`,{method:"POST"}),remove:(e,n)=>fe(`/agents/${e}${n?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,n)=>fe(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(n)}),getMemory:e=>fe(`/agents/${e}/memory`),getMemorySession:(e,n)=>fe(`/agents/${e}/memory/sessions/${encodeURIComponent(n)}`),updateDailyMemory:(e,n)=>fe(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:n})}),updateLongTermMemory:(e,n,s)=>fe(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:n,content:s})}),getFiles:e=>fe(`/agents/${e}/files`),getFilesMap:e=>fe(`/agents/${e}/files`),updateFile:(e,n,s)=>fe(`/agents/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,n)=>fe(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:n})}),roleStatus:e=>fe(`/agents/${e}/role-status`),roleDiff:(e,n="ROLE.md")=>fe(`/agents/${e}/role-diff?file=${encodeURIComponent(n)}`),roleSync:(e,n)=>fe(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(n?{files:n}:{})}),roleSmartSync:(e,n)=>fe(`/agents/${e}/role-smart-sync`,{method:"POST",body:JSON.stringify({file:n})}),roleUpdates:()=>fe("/agents/role-updates"),addSkill:(e,n)=>fe(`/agents/${e}/skills`,{method:"POST",body:JSON.stringify({skillName:n})}),removeSkill:(e,n)=>fe(`/agents/${e}/skills/${encodeURIComponent(n)}`,{method:"DELETE"}),getHeartbeat:e=>fe(`/agents/${e}/heartbeat`),triggerHeartbeat:e=>fe(`/agents/${e}/heartbeat/trigger`,{method:"POST"}),getRecentActivities:e=>fe(`/agents/${e}/recent-activities`),getActivityLogs:(e,n)=>fe(`/agents/${e}/activity-logs?activityId=${encodeURIComponent(n)}`),getActivities:(e,n)=>{const s=new URLSearchParams;n?.type&&s.set("type",n.type),n?.limit&&s.set("limit",String(n.limit)),n?.before&&s.set("before",n.before);const l=s.toString();return fe(`/agents/${e}/activities${l?"?"+l:""}`)},getMindState:e=>fe(`/agents/${e}/mind`),getMailbox:(e,n)=>{const s=new URLSearchParams;n?.limit&&s.set("limit",String(n.limit)),n?.offset&&s.set("offset",String(n.offset)),n?.category&&s.set("category",n.category),n?.sourceType&&s.set("sourceType",n.sourceType),n?.status&&s.set("status",n.status);const l=s.toString();return fe(`/agents/${e}/mailbox${l?"?"+l:""}`)},getDecisions:(e,n=50)=>fe(`/agents/${e}/decisions?limit=${n}`),message:(e,n,s,l,i)=>fe(`/agents/${e}/message`,{method:"POST",body:JSON.stringify({text:n,images:s,fileNames:i,sessionId:l??void 0})}),messageStream:(e,n,s,l,i,c,d,u,h,f,x)=>new Promise(async(p,g)=>{let b="",w;try{const k=await fetch(`${wx}/agents/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:n,stream:!0,images:c,fileNames:x,sessionId:d??void 0,isRetry:u||void 0,isResume:h||void 0}),signal:i});if(!k.ok){g(new Error(`API error: ${k.status}`));return}const C=k.body?.getReader();if(!C){g(new Error("No reader"));return}const E=new TextDecoder;let M="";for(;;){const{done:N,value:A}=await C.read();if(N)break;M+=E.decode(A,{stream:!0});const R=M.split(`
|
|
10
|
+
`);M=R.pop()??"";for(const _ of R){const Y=_.trim();if(Y.startsWith("data: "))try{const q=JSON.parse(Y.slice(6));if(q.type==="text_delta"&&q.text)b+=q.text,s(q.text);else if(q.type==="thinking_delta"&&q.thinking)s?.(`<think>${q.thinking}</think>`);else if(q.type==="done")b=q.content??b,q.sessionId&&(w=q.sessionId);else if(q.type==="error"){const X=q;X.sessionId&&(w=X.sessionId);const L=new Error(X.message??X.error??"Unknown stream error");L.sessionId=X.sessionId,g(L),C.cancel().catch(()=>{});return}else q.type==="thinking_commit"&&q.thinking?f?.({type:"thinking_commit",content:q.thinking,createdAt:q.createdAt??new Date().toISOString()}):q.type==="text_commit"&&q.text?f?.({type:"text_commit",content:q.text,createdAt:q.createdAt??new Date().toISOString()}):q.type==="tool_call_start"&&q.toolCall?.name?l?.({tool:q.toolCall.name,phase:"start"}):q.type==="agent_tool"&&q.tool&&q.phase?q.phase==="start"?l?.({tool:q.tool,phase:"start",arguments:q.arguments}):q.phase==="end"&&l?.({tool:q.tool,phase:"end",success:q.success,arguments:q.arguments,result:q.result,error:q.error,durationMs:q.durationMs}):q.type==="tool_output"&&q.tool?l?.({tool:q.tool,phase:"output",output:q.text}):q.type==="subagent_progress"&&q.tool&&l?.({tool:q.tool,phase:"subagent_progress",subagentEvent:q.subagentEvent})}catch{}}}p({content:b,sessionId:w})}catch(k){k instanceof Error&&k.name==="AbortError"?p({content:b,sessionId:w}):g(k)}})},roles:{list:()=>fe("/roles")},teams:{list:e=>fe(`/teams?orgId=${e??"default"}`),create:(e,n)=>fe("/teams",{method:"POST",body:JSON.stringify({name:e,description:n})}),update:(e,n)=>fe(`/teams/${e}`,{method:"PATCH",body:JSON.stringify(n)}),delete:(e,n,s)=>fe(`/teams/${e}?deleteMembers=${n?"true":"false"}${s?.purgeFiles?"&purgeFiles=true":""}`,{method:"DELETE"}),addMember:(e,n,s)=>fe(`/teams/${e}/members`,{method:"POST",body:JSON.stringify({memberId:n,memberType:s})}),removeMember:(e,n)=>fe(`/teams/${e}/members/${n}`,{method:"DELETE"}),startAll:e=>fe(`/teams/${e}/start`,{method:"POST"}),stopAll:e=>fe(`/teams/${e}/stop`,{method:"POST"}),pauseAll:(e,n)=>fe(`/teams/${e}/pause`,{method:"POST",body:JSON.stringify({reason:n})}),resumeAll:e=>fe(`/teams/${e}/resume`,{method:"POST"}),status:e=>fe(`/teams/${e}/status`),getFiles:e=>fe(`/teams/${e}/files`),getFile:(e,n)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`),updateFile:(e,n,s)=>fe(`/teams/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),exportTeam:e=>fe(`/teams/${e}/export`,{method:"POST"}),getFilesMap:e=>fe(`/teams/${e}/export`)},externalAgents:{list:e=>fe(`/external-agents?orgId=${e??"default"}`)},tasks:{list:e=>{const n=new URLSearchParams;e?.assignedAgentId&&n.set("assignedAgentId",e.assignedAgentId),e?.status&&n.set("status",e.status),e?.projectId&&n.set("projectId",e.projectId),e?.requirementId&&n.set("requirementId",e.requirementId),e?.priority&&n.set("priority",e.priority),e?.search&&n.set("search",e.search),e?.sortBy&&n.set("sortBy",e.sortBy),e?.sortOrder&&n.set("sortOrder",e.sortOrder),e?.page!==null&&e?.page!==void 0&&n.set("page",String(e.page)),e?.pageSize!==null&&e?.pageSize!==void 0&&n.set("pageSize",String(e.pageSize));const s=n.toString();return fe(`/tasks${s?`?${s}`:""}`)},get:e=>fe(`/tasks/${e}`),create:(e,n,s,l,i,c,d,u,h,f)=>fe("/tasks",{method:"POST",body:JSON.stringify({title:e,description:n,assignedAgentId:s,reviewerAgentId:l,priority:i,projectId:c,blockedBy:d,requirementId:u,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,l,i,c,d)=>fe(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:i??"human",authorName:s??"User",authorType:"human",attachments:l,mentions:c,replyTo:d})}),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})}),check:e=>fe("/files/check",{method:"POST",body:JSON.stringify({paths:e})})},requirements:{list:e=>{const n=new URLSearchParams;e?.orgId&&n.set("orgId",e.orgId),e?.status&&n.set("status",e.status),e?.source&&n.set("source",e.source),e?.projectId&&n.set("projectId",e.projectId);const s=n.toString();return fe(`/requirements${s?`?${s}`:""}`)},get:e=>fe(`/requirements/${e}`),create:e=>fe("/requirements",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/requirements/${e}`,{method:"PUT",body:JSON.stringify(n)}),updateStatus:(e,n)=>fe(`/requirements/${e}/status`,{method:"POST",body:JSON.stringify({status:n})}),approve:e=>fe(`/requirements/${e}/approve`,{method:"POST"}),reject:(e,n)=>fe(`/requirements/${e}/reject`,{method:"POST",body:JSON.stringify({reason:n})}),cancel:e=>fe(`/requirements/${e}/cancel`,{method:"POST"}),delete:e=>fe(`/requirements/${e}`,{method:"DELETE"}),getComments:e=>fe(`/requirements/${e}/comments`),addComment:(e,n,s,l,i,c)=>fe(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:l??"human",authorName:s??"User",authorType:"human",mentions:i,replyTo:c})})},users:{list:e=>fe(`/users?orgId=${e??"default"}`),create:(e,n,s,l,i,c)=>fe("/users",{method:"POST",body:JSON.stringify({name:e,role:n,orgId:s,email:l,password:i,teamId:c})}),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)}),getBrowser:()=>fe("/settings/browser"),updateBrowser:e=>fe("/settings/browser",{method:"POST",body:JSON.stringify(e)})},skills:{list:()=>fe("/skills"),builtin:()=>fe("/skills/builtin"),registry:e=>fe(`/skills/registry${e?`?source=${e}`:""}`),registrySkillhub:e=>{const n=new URLSearchParams;e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit)),e?.sort&&n.set("sort",e.sort);const s=n.toString();return fe(`/skills/registry/skillhub${s?`?${s}`:""}`)},registrySkillssh:e=>fe(`/skills/registry/skillssh${e?`?q=${encodeURIComponent(e)}`:""}`),import:(e,n,s,l)=>fe("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:n,description:s,category:l})}),install:e=>fe("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>fe(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>fe(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>fe("/builder/artifacts"),get:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`),save:(e,n)=>fe("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:n})}),import:(e,n,s,l)=>fe("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:n,files:s,source:l})}),install:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/install`,{method:"POST"}),uninstall:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/uninstall`,{method:"POST"}),delete:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`,{method:"DELETE"}),installed:()=>fe("/builder/artifacts/installed")}},auth:{login:(e,n)=>fe("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})}),logout:()=>fe("/auth/logout",{method:"POST"}),me:()=>fe("/auth/me"),changePassword:(e,n)=>fe("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:n})}),updateProfile:(e,n)=>fe("/auth/profile",{method:"PUT",body:JSON.stringify({name:e,email:n})}),uploadAvatar:(e,n="user",s)=>fe("/avatars/upload",{method:"POST",body:JSON.stringify({image:e,type:n,id:s})})},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,l,i)=>fe(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:n,respondedBy:s,comment:l,selectedOption:i})})},notifications:{list:(e,n,s)=>{const l=new URLSearchParams;return e&&l.set("userId",e),n&&l.set("unread","true"),s?.type&&l.set("type",s.type),s?.limit&&l.set("limit",String(s.limit)),s?.offset&&l.set("offset",String(s.offset)),fe(`/notifications?${l}`)},markRead:e=>fe(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>fe("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},projects:{list:e=>{const n=e?`?orgId=${e}`:"";return fe(`/projects${n}`)},get:e=>fe(`/projects/${e}`),create:e=>fe("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/projects/${e}`,{method:"PUT",body:JSON.stringify(n)}),delete:e=>fe(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,n,s)=>{const l=new URLSearchParams;return e&&l.set("query",e),n&&l.set("scope",n),s&&l.set("category",s),fe(`/knowledge/search?${l}`)},contribute:e=>fe("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,n)=>fe(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:n})}),verify:e=>fe(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>fe(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const n=new URLSearchParams;return e?.q&&n.set("q",e.q),e?.projectId&&n.set("projectId",e.projectId),e?.agentId&&n.set("agentId",e.agentId),e?.taskId&&n.set("taskId",e.taskId),e?.type&&n.set("type",e.type),e?.status&&n.set("status",e.status),e?.artifactType&&n.set("artifactType",e.artifactType),e?.offset&&n.set("offset",String(e.offset)),e?.limit&&n.set("limit",String(e.limit)),fe(`/deliverables?${n}`)},create:e=>fe("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(n)}),remove:e=>fe(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})})},codeReviews:{list:(e,n=20)=>{const s=new URLSearchParams;return e&&s.set("taskId",e),s.set("limit",String(n)),fe(`/reviews?${s}`)},get:e=>fe(`/reviews/${e}`),run:e=>fe("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>fe("/reports"),get:e=>fe(`/reports/${e}`),generate:e=>fe("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,n)=>fe(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(n)}),rejectPlan:(e,n)=>fe(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(n)}),addFeedback:(e,n)=>fe(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(n)}),getFeedback:e=>fe(`/reports/${e}/feedback`)},executionLogs:{get:(e,n)=>fe(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(n)}`)}};function Lh(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 Q1(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`,l=new WebSocket(s);this.ws=l,l.onmessage=i=>{if(this.ws===l)try{const c=JSON.parse(i.data),d=this.handlers.get(c.type);if(d)for(const h of d)h(c);const u=this.handlers.get("*");if(u)for(const h of u)h(c)}catch{}},l.onclose=()=>{this.intentionalClose||(this.reconnectTimer=setTimeout(()=>this.connect(),3e3))},l.onerror=()=>{l.close()}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(n,s){return this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n).add(s),()=>this.handlers.get(n)?.delete(s)}}const Zt=new Nk;let Nx=window.__MARKUS_HUB_URL__??"https://markus.global";fe("/settings/hub").then(e=>{e.hubUrl&&(Nx=e.hubUrl);const n=localStorage.getItem("markus_hub_token");n&&fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:n})}).catch(()=>{})}).catch(()=>{});const kx="markus_hub_token",Sx="markus_hub_user";function nl(){return localStorage.getItem(kx)}function kk(){try{const e=localStorage.getItem(Sx);return e?JSON.parse(e):null}catch{return null}}function J1(){localStorage.removeItem(kx),localStorage.removeItem(Sx),ej(null)}function Ih(e,n){localStorage.setItem(kx,e),localStorage.setItem(Sx,JSON.stringify(n)),ej(e)}function ej(e){fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:e})}).catch(()=>{})}let Ao=null;function Ka(){if(nl())return Promise.resolve();if(Ao)return Ao;const e=`cs_${Date.now()}_${Math.random().toString(36).slice(2,10)}`;return Ao=new Promise((n,s)=>{const l=`${Nx}/auth/connect?session=${encodeURIComponent(e)}`,i=460,c=580,d=Math.round(window.screenX+(window.outerWidth-i)/2),u=Math.round(window.screenY+(window.outerHeight-c)/2),h=window.open(l,"markus_hub_auth",`popup=yes,width=${i},height=${c},left=${d},top=${u}`);let f=!1;const x=()=>{clearInterval(p),clearInterval(g),Ao=null},p=setInterval(async()=>{if(!f)try{const b=await fe(`/hub/auth/connect-status?session=${encodeURIComponent(e)}`);b.ready&&b.token&&b.user&&(f=!0,Ih(b.token,b.user),x(),h?.close(),n())}catch{}},1500),g=setInterval(()=>{f||h?.closed&&(f=!0,x(),nl()?n():s(new Error("Hub login cancelled")))},500)}),Ao}async function xs(e,n){const s=nl(),l={"Content-Type":"application/json",...n?.headers};s&&(l.Authorization=`Bearer ${s}`);const i=await fetch(`${wx}/hub${e}`,{...n,headers:l,credentials:"include"}),c=await i.json();if(i.status===401&&s&&J1(),!i.ok)throw new Error(c.error??`Hub HTTP ${i.status}`);return c}const Bn={getUrl:()=>Nx,isAuthenticated:()=>!!nl(),getUser:kk,logout:()=>{J1()},ensureAuth:Ka,login:async(e,n)=>{const s=await xs("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})});return Ih(s.token,s.user),s},register:async(e,n,s)=>{const l=await xs("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:n,password:s})});return Ih(l.token,l.user),l},search:e=>{const n=new URLSearchParams;e?.type&&n.set("type",e.type),e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.sort&&n.set("sort",e.sort),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit));const s=n.toString();return xs(`/items${s?`?${s}`:""}`)},getItem:e=>xs(`/items/${e}`),download:async e=>{await Ka();try{return await xs(`/items/${e}/download`,{method:"POST"})}catch(n){if(!nl())return await Ka(),xs(`/items/${e}/download`,{method:"POST"});throw n}},publish:async e=>{await Ka();try{return await xs("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!nl())return await Ka(),xs("/items",{method:"POST",body:JSON.stringify(e)});throw n}},publishViaProxy:async e=>{await Ka();try{return await xs("/items",{method:"POST",body:JSON.stringify(e)})}catch(n){if(!nl())return await Ka(),xs("/items",{method:"POST",body:JSON.stringify(e)});throw n}},myItems:async()=>nl()?xs("/items/mine"):{items:[]},deleteItem:async e=>(await Ka(),xs(`/items/${e}`,{method:"DELETE"}))};function tj(e,n){const s=e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/^-+|-+$/g,"");if(s)return s;if(n)return n;let l=0;for(let i=0;i<e.length;i++)l=(l<<5)-l+e.charCodeAt(i)|0;return`pkg-${Math.abs(l).toString(36)}`}let Xb=null;const bt={setHandler(e){Xb=e},navigate(e,n){n&&Object.entries(n).forEach(([s,l])=>localStorage.setItem(`markus_nav_${s}`,l)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:n}})),Xb?.(e,n)}};var vu=Z1();function Sk(e,n){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const Ck=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ek=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Tk={};function Kb(e,n){return(Tk.jsx?Ek:Ck).test(e)}const Ak=/[ \t\n\f\r]/g;function _k(e){return typeof e=="object"?e.type==="text"?Wb(e.value):!1:Wb(e)}function Wb(e){return e.replace(Ak,"")===""}class fc{constructor(n,s,l){this.normal=s,this.property=n,l&&(this.space=l)}}fc.prototype.normal={};fc.prototype.property={};fc.prototype.space=void 0;function nj(e,n){const s={},l={};for(const i of e)Object.assign(s,i.property),Object.assign(l,i.normal);return new fc(s,l,n)}function zh(e){return e.toLowerCase()}class Vr{constructor(n,s){this.attribute=s,this.property=n}}Vr.prototype.attribute="";Vr.prototype.booleanish=!1;Vr.prototype.boolean=!1;Vr.prototype.commaOrSpaceSeparated=!1;Vr.prototype.commaSeparated=!1;Vr.prototype.defined=!1;Vr.prototype.mustUseProperty=!1;Vr.prototype.number=!1;Vr.prototype.overloadedBoolean=!1;Vr.prototype.property="";Vr.prototype.spaceSeparated=!1;Vr.prototype.space=void 0;let Mk=0;const Ht=Bl(),tr=Bl(),$h=Bl(),Pe=Bl(),An=Bl(),Ti=Bl(),es=Bl();function Bl(){return 2**++Mk}const Bh=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ht,booleanish:tr,commaOrSpaceSeparated:es,commaSeparated:Ti,number:Pe,overloadedBoolean:$h,spaceSeparated:An},Symbol.toStringTag,{value:"Module"})),Fm=Object.keys(Bh);class Cx extends Vr{constructor(n,s,l,i){let c=-1;if(super(n,s),Zb(this,"space",i),typeof l=="number")for(;++c<Fm.length;){const d=Fm[c];Zb(this,Fm[c],(l&Bh[d])===Bh[d])}}}Cx.prototype.defined=!0;function Zb(e,n,s){s&&(e[n]=s)}function Pi(e){const n={},s={};for(const[l,i]of Object.entries(e.properties)){const c=new Cx(l,e.transform(e.attributes||{},l),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(l)&&(c.mustUseProperty=!0),n[l]=c,s[zh(l)]=l,s[zh(c.attribute)]=l}return new fc(n,s,e.space)}const rj=Pi({properties:{ariaActiveDescendant:null,ariaAtomic:tr,ariaAutoComplete:null,ariaBusy:tr,ariaChecked:tr,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:An,ariaCurrent:null,ariaDescribedBy:An,ariaDetails:null,ariaDisabled:tr,ariaDropEffect:An,ariaErrorMessage:null,ariaExpanded:tr,ariaFlowTo:An,ariaGrabbed:tr,ariaHasPopup:null,ariaHidden:tr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:An,ariaLevel:Pe,ariaLive:null,ariaModal:tr,ariaMultiLine:tr,ariaMultiSelectable:tr,ariaOrientation:null,ariaOwns:An,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:tr,ariaReadOnly:tr,ariaRelevant:null,ariaRequired:tr,ariaRoleDescription:An,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:tr,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 sj(e,n){return n in e?e[n]:n}function aj(e,n){return sj(e,n.toLowerCase())}const Rk=Pi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ti,acceptCharset:An,accessKey:An,action:null,allow:null,allowFullScreen:Ht,allowPaymentRequest:Ht,allowUserMedia:Ht,alt:null,as:null,async:Ht,autoCapitalize:null,autoComplete:An,autoFocus:Ht,autoPlay:Ht,blocking:An,capture:null,charSet:null,checked:Ht,cite:null,className:An,cols:Pe,colSpan:null,content:null,contentEditable:tr,controls:Ht,controlsList:An,coords:Pe|Ti,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ht,defer:Ht,dir:null,dirName:null,disabled:Ht,download:$h,draggable:tr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ht,formTarget:null,headers:An,height:Pe,hidden:$h,high:Pe,href:null,hrefLang:null,htmlFor:An,httpEquiv:An,id:null,imageSizes:null,imageSrcSet:null,inert:Ht,inputMode:null,integrity:null,is:null,isMap:Ht,itemId:null,itemProp:An,itemRef:An,itemScope:Ht,itemType:An,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ht,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:Ht,muted:Ht,name:null,nonce:null,noModule:Ht,noValidate:Ht,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:Ht,optimum:Pe,pattern:null,ping:An,placeholder:null,playsInline:Ht,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ht,referrerPolicy:null,rel:An,required:Ht,reversed:Ht,rows:Pe,rowSpan:Pe,sandbox:An,scope:null,scoped:Ht,seamless:Ht,selected:Ht,shadowRootClonable:Ht,shadowRootDelegatesFocus:Ht,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:tr,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:Ht,useMap:null,value:tr,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:An,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:Ht,declare:Ht,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:Ht,noHref:Ht,noShade:Ht,noWrap:Ht,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:tr,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:Ht,disableRemotePlayback:Ht,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:aj}),Ok=Pi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:es,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:An,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:Ht,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:Ti,g2:Ti,glyphName:Ti,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:es,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:An,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:es,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:es,rev:es,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:es,requiredFeatures:es,requiredFonts:es,requiredFormats:es,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:es,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:es,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:es,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:sj}),lj=Pi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),ij=Pi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:aj}),oj=Pi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),Dk={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"},Lk=/[A-Z]/g,Qb=/-[a-z]/g,Ik=/^data[-\w.:]+$/i;function zk(e,n){const s=zh(n);let l=n,i=Vr;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&Ik.test(n)){if(n.charAt(4)==="-"){const c=n.slice(5).replace(Qb,Bk);l="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=n.slice(4);if(!Qb.test(c)){let d=c.replace(Lk,$k);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}i=Cx}return new i(l,n)}function $k(e){return"-"+e.toLowerCase()}function Bk(e){return e.charAt(1).toUpperCase()}const Hk=nj([rj,Rk,lj,ij,oj],"html"),Ex=nj([rj,Ok,lj,ij,oj],"svg");function Pk(e){return e.join(" ").trim()}var pi={},Vm,Jb;function Uk(){if(Jb)return Vm;Jb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,s=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,u=/^\s+|\s+$/g,h=`
|
|
11
|
+
`,f="/",x="*",p="",g="comment",b="declaration";function w(C,E){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];E=E||{};var M=1,N=1;function A(T){var z=T.match(n);z&&(M+=z.length);var O=T.lastIndexOf(h);N=~O?T.length-O:N+T.length}function R(){var T={line:M,column:N};return function(z){return z.position=new _(T),X(),z}}function _(T){this.start=T,this.end={line:M,column:N},this.source=E.source}_.prototype.content=C;function Y(T){var z=new Error(E.source+":"+M+":"+N+": "+T);if(z.reason=T,z.filename=E.source,z.line=M,z.column=N,z.source=C,!E.silent)throw z}function q(T){var z=T.exec(C);if(z){var O=z[0];return A(O),C=C.slice(O.length),z}}function X(){q(s)}function L(T){var z;for(T=T||[];z=P();)z!==!1&&T.push(z);return T}function P(){var T=R();if(!(f!=C.charAt(0)||x!=C.charAt(1))){for(var z=2;p!=C.charAt(z)&&(x!=C.charAt(z)||f!=C.charAt(z+1));)++z;if(z+=2,p===C.charAt(z-1))return Y("End of comment missing");var O=C.slice(2,z-2);return N+=2,A(O),C=C.slice(z),N+=2,T({type:g,comment:O})}}function G(){var T=R(),z=q(l);if(z){if(P(),!q(i))return Y("property missing ':'");var O=q(c),V=T({type:b,property:k(z[0].replace(e,p)),value:O?k(O[0].replace(e,p)):p});return q(d),V}}function $(){var T=[];L(T);for(var z;z=G();)z!==!1&&(T.push(z),L(T));return T}return X(),$()}function k(C){return C?C.replace(u,p):p}return Vm=w,Vm}var ey;function qk(){if(ey)return pi;ey=1;var e=pi&&pi.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(pi,"__esModule",{value:!0}),pi.default=s;const n=e(Uk());function s(l,i){let c=null;if(!l||typeof l!="string")return c;const d=(0,n.default)(l),u=typeof i=="function";return d.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:x}=h;u?i(f,x,h):x&&(c=c||{},c[f]=x)}),c}return pi}var _o={},ty;function Fk(){if(ty)return _o;ty=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,s=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,c=function(f){return!f||s.test(f)||e.test(f)},d=function(f,x){return x.toUpperCase()},u=function(f,x){return"".concat(x,"-")},h=function(f,x){return x===void 0&&(x={}),c(f)?f:(f=f.toLowerCase(),x.reactCompat?f=f.replace(i,u):f=f.replace(l,u),f.replace(n,d))};return _o.camelCase=h,_o}var Mo,ny;function Vk(){if(ny)return Mo;ny=1;var e=Mo&&Mo.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},n=e(qk()),s=Fk();function l(i,c){var d={};return!i||typeof i!="string"||(0,n.default)(i,function(u,h){u&&h&&(d[(0,s.camelCase)(u,c)]=h)}),d}return l.default=l,Mo=l,Mo}var Yk=Vk();const Gk=yu(Yk),cj=dj("end"),Tx=dj("start");function dj(e){return n;function n(s){const l=s&&s.position&&s.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function Xk(e){const n=Tx(e),s=cj(e);if(n&&s)return{start:n,end:s}}function Vo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ry(e.position):"start"in e||"end"in e?ry(e):"line"in e||"column"in e?Hh(e):""}function Hh(e){return sy(e&&e.line)+":"+sy(e&&e.column)}function ry(e){return Hh(e&&e.start)+"-"+Hh(e&&e.end)}function sy(e){return e&&typeof e=="number"?e:1}class Tr extends Error{constructor(n,s,l){super(),typeof s=="string"&&(l=s,s=void 0);let i="",c={},d=!1;if(s&&("line"in s&&"column"in s?c={place:s}:"start"in s&&"end"in s?c={place:s}:"type"in s?c={ancestors:[s],place:s.position}:c={...s}),typeof n=="string"?i=n:!c.cause&&n&&(d=!0,i=n.message,c.cause=n),!c.ruleId&&!c.source&&typeof l=="string"){const h=l.indexOf(":");h===-1?c.ruleId=l:(c.source=l.slice(0,h),c.ruleId=l.slice(h+1))}if(!c.place&&c.ancestors&&c.ancestors){const h=c.ancestors[c.ancestors.length-1];h&&(c.place=h.position)}const u=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=u?u.line:void 0,this.name=Vo(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=d&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Tr.prototype.file="";Tr.prototype.name="";Tr.prototype.reason="";Tr.prototype.message="";Tr.prototype.stack="";Tr.prototype.column=void 0;Tr.prototype.line=void 0;Tr.prototype.ancestors=void 0;Tr.prototype.cause=void 0;Tr.prototype.fatal=void 0;Tr.prototype.place=void 0;Tr.prototype.ruleId=void 0;Tr.prototype.source=void 0;const Ax={}.hasOwnProperty,Kk=new Map,Wk=/[A-Z]/g,Zk=new Set(["table","tbody","thead","tfoot","tr"]),Qk=new Set(["td","th"]),uj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Jk(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=n.filePath||void 0;let l;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=iS(s,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=lS(s,n.jsx,n.jsxs)}const i={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:l,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Ex:Hk,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},c=fj(i,e,void 0);return c&&typeof c!="string"?c:i.create(e,i.Fragment,{children:c||void 0},void 0)}function fj(e,n,s){if(n.type==="element")return eS(e,n,s);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return tS(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return rS(e,n,s);if(n.type==="mdxjsEsm")return nS(e,n);if(n.type==="root")return sS(e,n,s);if(n.type==="text")return aS(e,n)}function eS(e,n,s){const l=e.schema;let i=l;n.tagName.toLowerCase()==="svg"&&l.space==="html"&&(i=Ex,e.schema=i),e.ancestors.push(n);const c=hj(e,n.tagName,!1),d=oS(e,n);let u=Mx(e,n);return Zk.has(n.tagName)&&(u=u.filter(function(h){return typeof h=="string"?!_k(h):!0})),mj(e,d,c,n),_x(d,u),e.ancestors.pop(),e.schema=l,e.create(n,c,d,s)}function tS(e,n){if(n.data&&n.data.estree&&e.evaluater){const l=n.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Zo(e,n.position)}function nS(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Zo(e,n.position)}function rS(e,n,s){const l=e.schema;let i=l;n.name==="svg"&&l.space==="html"&&(i=Ex,e.schema=i),e.ancestors.push(n);const c=n.name===null?e.Fragment:hj(e,n.name,!0),d=cS(e,n),u=Mx(e,n);return mj(e,d,c,n),_x(d,u),e.ancestors.pop(),e.schema=l,e.create(n,c,d,s)}function sS(e,n,s){const l={};return _x(l,Mx(e,n)),e.create(n,e.Fragment,l,s)}function aS(e,n){return n.value}function mj(e,n,s,l){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(n.node=l)}function _x(e,n){if(n.length>0){const s=n.length>1?n:n[0];s&&(e.children=s)}}function lS(e,n,s){return l;function l(i,c,d,u){const f=Array.isArray(d.children)?s:n;return u?f(c,d,u):f(c,d)}}function iS(e,n){return s;function s(l,i,c,d){const u=Array.isArray(c.children),h=Tx(l);return n(i,c,d,u,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function oS(e,n){const s={};let l,i;for(i in n.properties)if(i!=="children"&&Ax.call(n.properties,i)){const c=dS(e,i,n.properties[i]);if(c){const[d,u]=c;e.tableCellAlignToStyle&&d==="align"&&typeof u=="string"&&Qk.has(n.tagName)?l=u:s[d]=u}}if(l){const c=s.style||(s.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return s}function cS(e,n){const s={};for(const l of n.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const c=l.data.estree.body[0];c.type;const d=c.expression;d.type;const u=d.properties[0];u.type,Object.assign(s,e.evaluater.evaluateExpression(u.argument))}else Zo(e,n.position);else{const i=l.name;let c;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const u=l.value.data.estree.body[0];u.type,c=e.evaluater.evaluateExpression(u.expression)}else Zo(e,n.position);else c=l.value===null?!0:l.value;s[i]=c}return s}function Mx(e,n){const s=[];let l=-1;const i=e.passKeys?new Map:Kk;for(;++l<n.children.length;){const c=n.children[l];let d;if(e.passKeys){const h=c.type==="element"?c.tagName:c.type==="mdxJsxFlowElement"||c.type==="mdxJsxTextElement"?c.name:void 0;if(h){const f=i.get(h)||0;d=h+"-"+f,i.set(h,f+1)}}const u=fj(e,c,d);u!==void 0&&s.push(u)}return s}function dS(e,n,s){const l=zk(e.schema,n);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=l.commaSeparated?Sk(s):Pk(s)),l.property==="style"){let i=typeof s=="object"?s:uS(e,String(s));return e.stylePropertyNameCase==="css"&&(i=fS(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&l.space?Dk[l.property]||l.property:l.attribute,s]}}function uS(e,n){try{return Gk(n,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const l=s,i=new Tr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:l,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=uj+"#cannot-parse-style-attribute",i}}function hj(e,n,s){let l;if(!s)l={type:"Literal",value:n};else if(n.includes(".")){const i=n.split(".");let c=-1,d;for(;++c<i.length;){const u=Kb(i[c])?{type:"Identifier",name:i[c]}:{type:"Literal",value:i[c]};d=d?{type:"MemberExpression",object:d,property:u,computed:!!(c&&u.type==="Literal"),optional:!1}:u}l=d}else l=Kb(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(l.type==="Literal"){const i=l.value;return Ax.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(l);Zo(e)}function Zo(e,n){const s=new Tr("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=uj+"#cannot-handle-mdx-estrees-without-createevaluater",s}function fS(e){const n={};let s;for(s in e)Ax.call(e,s)&&(n[mS(s)]=e[s]);return n}function mS(e){let n=e.replace(Wk,hS);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function hS(e){return"-"+e.toLowerCase()}const Ym={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"]},xS={};function Rx(e,n){const s=xS,l=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,i=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return xj(e,l,i)}function xj(e,n,s){if(pS(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 ay(e.children,n,s)}return Array.isArray(e)?ay(e,n,s):""}function ay(e,n,s){const l=[];let i=-1;for(;++i<e.length;)l[i]=xj(e[i],n,s);return l.join("")}function pS(e){return!!(e&&typeof e=="object")}const ly=document.createElement("i");function Ox(e){const n="&"+e+";";ly.innerHTML=n;const s=ly.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===n?!1:s}function ns(e,n,s,l){const i=e.length;let c=0,d;if(n<0?n=-n>i?0:i+n:n=n>i?i:n,s=s>0?s:0,l.length<1e4)d=Array.from(l),d.unshift(n,s),e.splice(...d);else for(s&&e.splice(n,s);c<l.length;)d=l.slice(c,c+1e4),d.unshift(n,0),e.splice(...d),c+=1e4,n+=1e4}function ps(e,n){return e.length>0?(ns(e,e.length,0,n),e):n}const iy={}.hasOwnProperty;function pj(e){const n={};let s=-1;for(;++s<e.length;)gS(n,e[s]);return n}function gS(e,n){let s;for(s in n){const i=(iy.call(e,s)?e[s]:void 0)||(e[s]={}),c=n[s];let d;if(c)for(d in c){iy.call(i,d)||(i[d]=[]);const u=c[d];bS(i[d],Array.isArray(u)?u:u?[u]:[])}}}function bS(e,n){let s=-1;const l=[];for(;++s<n.length;)(n[s].add==="after"?e:l).push(n[s]);ns(e,0,0,l)}function gj(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 _s(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Mr=ll(/[A-Za-z]/),Er=ll(/[\dA-Za-z]/),yS=ll(/[#-'*+\--9=?A-Z^-~]/);function Qd(e){return e!==null&&(e<32||e===127)}const Ph=ll(/\d/),vS=ll(/[\dA-Fa-f]/),jS=ll(/[!-/:-@[-`{-~]/);function jt(e){return e!==null&&e<-2}function Tn(e){return e!==null&&(e<0||e===32)}function Gt(e){return e===-2||e===-1||e===32}const ju=ll(new RegExp("\\p{P}|\\p{S}","u")),Ol=ll(/\s/);function ll(e){return n;function n(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function Ui(e){const n=[];let s=-1,l=0,i=0;for(;++s<e.length;){const c=e.charCodeAt(s);let d="";if(c===37&&Er(e.charCodeAt(s+1))&&Er(e.charCodeAt(s+2)))i=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(d=String.fromCharCode(c));else if(c>55295&&c<57344){const u=e.charCodeAt(s+1);c<56320&&u>56319&&u<57344?(d=String.fromCharCode(c,u),i=1):d="�"}else d=String.fromCharCode(c);d&&(n.push(e.slice(l,s),encodeURIComponent(d)),l=s+i+1,d=""),i&&(s+=i,i=0)}return n.join("")+e.slice(l)}function nn(e,n,s,l){const i=l?l-1:Number.POSITIVE_INFINITY;let c=0;return d;function d(h){return Gt(h)?(e.enter(s),u(h)):n(h)}function u(h){return Gt(h)&&c++<i?(e.consume(h),u):(e.exit(s),n(h))}}const wS={tokenize:NS};function NS(e){const n=e.attempt(this.parser.constructs.contentInitial,l,i);let s;return n;function l(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),nn(e,n,"linePrefix")}function i(u){return e.enter("paragraph"),c(u)}function c(u){const h=e.enter("chunkText",{contentType:"text",previous:s});return s&&(s.next=h),s=h,d(u)}function d(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return jt(u)?(e.consume(u),e.exit("chunkText"),c):(e.consume(u),d)}}const kS={tokenize:SS},oy={tokenize:CS};function SS(e){const n=this,s=[];let l=0,i,c,d;return u;function u(N){if(l<s.length){const A=s[l];return n.containerState=A[1],e.attempt(A[0].continuation,h,f)(N)}return f(N)}function h(N){if(l++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,i&&M();const A=n.events.length;let R=A,_;for(;R--;)if(n.events[R][0]==="exit"&&n.events[R][1].type==="chunkFlow"){_=n.events[R][1].end;break}E(l);let Y=A;for(;Y<n.events.length;)n.events[Y][1].end={..._},Y++;return ns(n.events,R+1,0,n.events.slice(A)),n.events.length=Y,f(N)}return u(N)}function f(N){if(l===s.length){if(!i)return g(N);if(i.currentConstruct&&i.currentConstruct.concrete)return w(N);n.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(oy,x,p)(N)}function x(N){return i&&M(),E(l),g(N)}function p(N){return n.parser.lazy[n.now().line]=l!==s.length,d=n.now().offset,w(N)}function g(N){return n.containerState={},e.attempt(oy,b,w)(N)}function b(N){return l++,s.push([n.currentConstruct,n.containerState]),g(N)}function w(N){if(N===null){i&&M(),E(0),e.consume(N);return}return i=i||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:c}),k(N)}function k(N){if(N===null){C(e.exit("chunkFlow"),!0),E(0),e.consume(N);return}return jt(N)?(e.consume(N),C(e.exit("chunkFlow")),l=0,n.interrupt=void 0,u):(e.consume(N),k)}function C(N,A){const R=n.sliceStream(N);if(A&&R.push(null),N.previous=c,c&&(c.next=N),c=N,i.defineSkip(N.start),i.write(R),n.parser.lazy[N.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<d&&(!i.events[_][1].end||i.events[_][1].end.offset>d))return;const Y=n.events.length;let q=Y,X,L;for(;q--;)if(n.events[q][0]==="exit"&&n.events[q][1].type==="chunkFlow"){if(X){L=n.events[q][1].end;break}X=!0}for(E(l),_=Y;_<n.events.length;)n.events[_][1].end={...L},_++;ns(n.events,q+1,0,n.events.slice(Y)),n.events.length=_}}function E(N){let A=s.length;for(;A-- >N;){const R=s[A];n.containerState=R[1],R[0].exit.call(n,e)}s.length=N}function M(){i.write([null]),c=void 0,i=void 0,n.containerState._closeFlow=void 0}}function CS(e,n,s){return nn(e,e.attempt(this.parser.constructs.document,n,s),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Mi(e){if(e===null||Tn(e)||Ol(e))return 1;if(ju(e))return 2}function wu(e,n,s){const l=[];let i=-1;for(;++i<e.length;){const c=e[i].resolveAll;c&&!l.includes(c)&&(n=c(n,s),l.push(c))}return n}const Uh={name:"attention",resolveAll:ES,tokenize:TS};function ES(e,n){let s=-1,l,i,c,d,u,h,f,x;for(;++s<e.length;)if(e[s][0]==="enter"&&e[s][1].type==="attentionSequence"&&e[s][1]._close){for(l=s;l--;)if(e[l][0]==="exit"&&e[l][1].type==="attentionSequence"&&e[l][1]._open&&n.sliceSerialize(e[l][1]).charCodeAt(0)===n.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[l][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[l][1].end.offset-e[l][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;h=e[l][1].end.offset-e[l][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const p={...e[l][1].end},g={...e[s][1].start};cy(p,-h),cy(g,h),d={type:h>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},u={type:h>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:g},c={type:h>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[s][1].start}},i={type:h>1?"strong":"emphasis",start:{...d.start},end:{...u.end}},e[l][1].end={...d.start},e[s][1].start={...u.end},f=[],e[l][1].end.offset-e[l][1].start.offset&&(f=ps(f,[["enter",e[l][1],n],["exit",e[l][1],n]])),f=ps(f,[["enter",i,n],["enter",d,n],["exit",d,n],["enter",c,n]]),f=ps(f,wu(n.parser.constructs.insideSpan.null,e.slice(l+1,s),n)),f=ps(f,[["exit",c,n],["enter",u,n],["exit",u,n],["exit",i,n]]),e[s][1].end.offset-e[s][1].start.offset?(x=2,f=ps(f,[["enter",e[s][1],n],["exit",e[s][1],n]])):x=0,ns(e,l-1,s-l+3,f),s=l+f.length-x-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function TS(e,n){const s=this.parser.constructs.attentionMarkers.null,l=this.previous,i=Mi(l);let c;return d;function d(h){return c=h,e.enter("attentionSequence"),u(h)}function u(h){if(h===c)return e.consume(h),u;const f=e.exit("attentionSequence"),x=Mi(h),p=!x||x===2&&i||s.includes(h),g=!i||i===2&&x||s.includes(l);return f._open=!!(c===42?p:p&&(i||!g)),f._close=!!(c===42?g:g&&(x||!p)),n(h)}}function cy(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const AS={name:"autolink",tokenize:_S};function _S(e,n,s){let l=0;return i;function i(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),c}function c(b){return Mr(b)?(e.consume(b),d):b===64?s(b):f(b)}function d(b){return b===43||b===45||b===46||Er(b)?(l=1,u(b)):f(b)}function u(b){return b===58?(e.consume(b),l=0,h):(b===43||b===45||b===46||Er(b))&&l++<32?(e.consume(b),u):(l=0,f(b))}function h(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):b===null||b===32||b===60||Qd(b)?s(b):(e.consume(b),h)}function f(b){return b===64?(e.consume(b),x):yS(b)?(e.consume(b),f):s(b)}function x(b){return Er(b)?p(b):s(b)}function p(b){return b===46?(e.consume(b),l=0,x):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):g(b)}function g(b){if((b===45||Er(b))&&l++<63){const w=b===45?g:p;return e.consume(b),w}return s(b)}}const mc={partial:!0,tokenize:MS};function MS(e,n,s){return l;function l(c){return Gt(c)?nn(e,i,"linePrefix")(c):i(c)}function i(c){return c===null||jt(c)?n(c):s(c)}}const bj={continuation:{tokenize:OS},exit:DS,name:"blockQuote",tokenize:RS};function RS(e,n,s){const l=this;return i;function i(d){if(d===62){const u=l.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),c}return s(d)}function c(d){return Gt(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(d))}}function OS(e,n,s){const l=this;return i;function i(d){return Gt(d)?nn(e,c,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):c(d)}function c(d){return e.attempt(bj,n,s)(d)}}function DS(e){e.exit("blockQuote")}const yj={name:"characterEscape",tokenize:LS};function LS(e,n,s){return l;function l(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),i}function i(c){return jS(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):s(c)}}const vj={name:"characterReference",tokenize:IS};function IS(e,n,s){const l=this;let i=0,c,d;return u;function u(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),h}function h(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),c=31,d=Er,x(p))}function f(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),c=6,d=vS,x):(e.enter("characterReferenceValue"),c=7,d=Ph,x(p))}function x(p){if(p===59&&i){const g=e.exit("characterReferenceValue");return d===Er&&!Ox(l.sliceSerialize(g))?s(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(p)&&i++<c?(e.consume(p),x):s(p)}}const dy={partial:!0,tokenize:$S},uy={concrete:!0,name:"codeFenced",tokenize:zS};function zS(e,n,s){const l=this,i={partial:!0,tokenize:R};let c=0,d=0,u;return h;function h(_){return f(_)}function f(_){const Y=l.events[l.events.length-1];return c=Y&&Y[1].type==="linePrefix"?Y[2].sliceSerialize(Y[1],!0).length:0,u=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(_)}function x(_){return _===u?(d++,e.consume(_),x):d<3?s(_):(e.exit("codeFencedFenceSequence"),Gt(_)?nn(e,p,"whitespace")(_):p(_))}function p(_){return _===null||jt(_)?(e.exit("codeFencedFence"),l.interrupt?n(_):e.check(dy,k,A)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===null||jt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(_)):Gt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),nn(e,b,"whitespace")(_)):_===96&&_===u?s(_):(e.consume(_),g)}function b(_){return _===null||jt(_)?p(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(_))}function w(_){return _===null||jt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(_)):_===96&&_===u?s(_):(e.consume(_),w)}function k(_){return e.attempt(i,A,C)(_)}function C(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),E}function E(_){return c>0&&Gt(_)?nn(e,M,"linePrefix",c+1)(_):M(_)}function M(_){return _===null||jt(_)?e.check(dy,k,A)(_):(e.enter("codeFlowValue"),N(_))}function N(_){return _===null||jt(_)?(e.exit("codeFlowValue"),M(_)):(e.consume(_),N)}function A(_){return e.exit("codeFenced"),n(_)}function R(_,Y,q){let X=0;return L;function L(z){return _.enter("lineEnding"),_.consume(z),_.exit("lineEnding"),P}function P(z){return _.enter("codeFencedFence"),Gt(z)?nn(_,G,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):G(z)}function G(z){return z===u?(_.enter("codeFencedFenceSequence"),$(z)):q(z)}function $(z){return z===u?(X++,_.consume(z),$):X>=d?(_.exit("codeFencedFenceSequence"),Gt(z)?nn(_,T,"whitespace")(z):T(z)):q(z)}function T(z){return z===null||jt(z)?(_.exit("codeFencedFence"),Y(z)):q(z)}}}function $S(e,n,s){const l=this;return i;function i(d){return d===null?s(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c)}function c(d){return l.parser.lazy[l.now().line]?s(d):n(d)}}const Gm={name:"codeIndented",tokenize:HS},BS={partial:!0,tokenize:PS};function HS(e,n,s){const l=this;return i;function i(f){return e.enter("codeIndented"),nn(e,c,"linePrefix",5)(f)}function c(f){const x=l.events[l.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(f):s(f)}function d(f){return f===null?h(f):jt(f)?e.attempt(BS,d,h)(f):(e.enter("codeFlowValue"),u(f))}function u(f){return f===null||jt(f)?(e.exit("codeFlowValue"),d(f)):(e.consume(f),u)}function h(f){return e.exit("codeIndented"),n(f)}}function PS(e,n,s){const l=this;return i;function i(d){return l.parser.lazy[l.now().line]?s(d):jt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),i):nn(e,c,"linePrefix",5)(d)}function c(d){const u=l.events[l.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?n(d):jt(d)?i(d):s(d)}}const US={name:"codeText",previous:FS,resolve:qS,tokenize:VS};function qS(e){let n=e.length-4,s=3,l,i;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(l=s;++l<n;)if(e[l][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[n][1].type="codeTextPadding",s+=2,n-=2;break}}for(l=s-1,n++;++l<=n;)i===void 0?l!==n&&e[l][1].type!=="lineEnding"&&(i=l):(l===n||e[l][1].type==="lineEnding")&&(e[i][1].type="codeTextData",l!==i+2&&(e[i][1].end=e[l-1][1].end,e.splice(i+2,l-i-2),n-=l-i-2,l=i+2),i=void 0);return e}function FS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function VS(e,n,s){let l=0,i,c;return d;function d(p){return e.enter("codeText"),e.enter("codeTextSequence"),u(p)}function u(p){return p===96?(e.consume(p),l++,u):(e.exit("codeTextSequence"),h(p))}function h(p){return p===null?s(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),h):p===96?(c=e.enter("codeTextSequence"),i=0,x(p)):jt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),h):(e.enter("codeTextData"),f(p))}function f(p){return p===null||p===32||p===96||jt(p)?(e.exit("codeTextData"),h(p)):(e.consume(p),f)}function x(p){return p===96?(e.consume(p),i++,x):i===l?(e.exit("codeTextSequence"),e.exit("codeText"),n(p)):(c.type="codeTextData",f(p))}}class YS{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,s){const l=s??Number.POSITIVE_INFINITY;return l<this.left.length?this.left.slice(n,l):n>this.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(n,s,l){const i=s||0;this.setCursor(Math.trunc(n));const c=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return l&&Ro(this.left,l),c.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),Ro(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Ro(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);Ro(this.right,s.reverse())}else{const s=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);Ro(this.left,s.reverse())}}}function Ro(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 jj(e){const n={};let s=-1,l,i,c,d,u,h,f;const x=new YS(e);for(;++s<x.length;){for(;s in n;)s=n[s];if(l=x.get(s),s&&l[1].type==="chunkFlow"&&x.get(s-1)[1].type==="listItemPrefix"&&(h=l[1]._tokenizer.events,c=0,c<h.length&&h[c][1].type==="lineEndingBlank"&&(c+=2),c<h.length&&h[c][1].type==="content"))for(;++c<h.length&&h[c][1].type!=="content";)h[c][1].type==="chunkText"&&(h[c][1]._isInFirstContentOfListItem=!0,c++);if(l[0]==="enter")l[1].contentType&&(Object.assign(n,GS(x,s)),s=n[s],f=!0);else if(l[1]._container){for(c=s,i=void 0;c--;)if(d=x.get(c),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(i&&(x.get(i)[1].type="lineEndingBlank"),d[1].type="lineEnding",i=c);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;i&&(l[1].end={...x.get(i)[1].start},u=x.slice(i,s),u.unshift(l),x.splice(i,s-i+1,u))}}return ns(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function GS(e,n){const s=e.get(n)[1],l=e.get(n)[2];let i=n-1;const c=[];let d=s._tokenizer;d||(d=l.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const u=d.events,h=[],f={};let x,p,g=-1,b=s,w=0,k=0;const C=[k];for(;b;){for(;e.get(++i)[1]!==b;);c.push(i),b._tokenizer||(x=l.sliceStream(b),b.next||x.push(null),p&&d.defineSkip(b.start),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),b._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),p=b,b=b.next}for(b=s;++g<u.length;)u[g][0]==="exit"&&u[g-1][0]==="enter"&&u[g][1].type===u[g-1][1].type&&u[g][1].start.line!==u[g][1].end.line&&(k=g+1,C.push(k),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(d.events=[],b?(b._tokenizer=void 0,b.previous=void 0):C.pop(),g=C.length;g--;){const E=u.slice(C[g],C[g+1]),M=c.pop();h.push([M,M+E.length-1]),e.splice(M,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 XS={resolve:WS,tokenize:ZS},KS={partial:!0,tokenize:QS};function WS(e){return jj(e),e}function ZS(e,n){let s;return l;function l(u){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),i(u)}function i(u){return u===null?c(u):jt(u)?e.check(KS,d,c)(u):(e.consume(u),i)}function c(u){return e.exit("chunkContent"),e.exit("content"),n(u)}function d(u){return e.consume(u),e.exit("chunkContent"),s.next=e.enter("chunkContent",{contentType:"content",previous:s}),s=s.next,i}}function QS(e,n,s){const l=this;return i;function i(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),nn(e,c,"linePrefix")}function c(d){if(d===null||jt(d))return s(d);const u=l.events[l.events.length-1];return!l.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?n(d):e.interrupt(l.parser.constructs.flow,s,n)(d)}}function wj(e,n,s,l,i,c,d,u,h){const f=h||Number.POSITIVE_INFINITY;let x=0;return p;function p(E){return E===60?(e.enter(l),e.enter(i),e.enter(c),e.consume(E),e.exit(c),g):E===null||E===32||E===41||Qd(E)?s(E):(e.enter(l),e.enter(d),e.enter(u),e.enter("chunkString",{contentType:"string"}),k(E))}function g(E){return E===62?(e.enter(c),e.consume(E),e.exit(c),e.exit(i),e.exit(l),n):(e.enter(u),e.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===62?(e.exit("chunkString"),e.exit(u),g(E)):E===null||E===60||jt(E)?s(E):(e.consume(E),E===92?w:b)}function w(E){return E===60||E===62||E===92?(e.consume(E),b):b(E)}function k(E){return!x&&(E===null||E===41||Tn(E))?(e.exit("chunkString"),e.exit(u),e.exit(d),e.exit(l),n(E)):x<f&&E===40?(e.consume(E),x++,k):E===41?(e.consume(E),x--,k):E===null||E===32||E===40||Qd(E)?s(E):(e.consume(E),E===92?C:k)}function C(E){return E===40||E===41||E===92?(e.consume(E),k):k(E)}}function Nj(e,n,s,l,i,c){const d=this;let u=0,h;return f;function f(b){return e.enter(l),e.enter(i),e.consume(b),e.exit(i),e.enter(c),x}function x(b){return u>999||b===null||b===91||b===93&&!h||b===94&&!u&&"_hiddenFootnoteSupport"in d.parser.constructs?s(b):b===93?(e.exit(c),e.enter(i),e.consume(b),e.exit(i),e.exit(l),n):jt(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||jt(b)||u++>999?(e.exit("chunkString"),x(b)):(e.consume(b),h||(h=!Gt(b)),b===92?g:p)}function g(b){return b===91||b===92||b===93?(e.consume(b),u++,p):p(b)}}function kj(e,n,s,l,i,c){let d;return u;function u(g){return g===34||g===39||g===40?(e.enter(l),e.enter(i),e.consume(g),e.exit(i),d=g===40?41:g,h):s(g)}function h(g){return g===d?(e.enter(i),e.consume(g),e.exit(i),e.exit(l),n):(e.enter(c),f(g))}function f(g){return g===d?(e.exit(c),h(d)):g===null?s(g):jt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),nn(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(g))}function x(g){return g===d||g===null||jt(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?p:x)}function p(g){return g===d||g===92?(e.consume(g),x):x(g)}}function Yo(e,n){let s;return l;function l(i){return jt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s=!0,l):Gt(i)?nn(e,l,s?"linePrefix":"lineSuffix")(i):n(i)}}const JS={name:"definition",tokenize:tC},eC={partial:!0,tokenize:nC};function tC(e,n,s){const l=this;let i;return c;function c(b){return e.enter("definition"),d(b)}function d(b){return Nj.call(l,e,u,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function u(b){return i=_s(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),h):s(b)}function h(b){return Tn(b)?Yo(e,f)(b):f(b)}function f(b){return wj(e,x,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(eC,p,p)(b)}function p(b){return Gt(b)?nn(e,g,"whitespace")(b):g(b)}function g(b){return b===null||jt(b)?(e.exit("definition"),l.parser.defined.push(i),n(b)):s(b)}}function nC(e,n,s){return l;function l(u){return Tn(u)?Yo(e,i)(u):s(u)}function i(u){return kj(e,c,s,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function c(u){return Gt(u)?nn(e,d,"whitespace")(u):d(u)}function d(u){return u===null||jt(u)?n(u):s(u)}}const rC={name:"hardBreakEscape",tokenize:sC};function sC(e,n,s){return l;function l(c){return e.enter("hardBreakEscape"),e.consume(c),i}function i(c){return jt(c)?(e.exit("hardBreakEscape"),n(c)):s(c)}}const aC={name:"headingAtx",resolve:lC,tokenize:iC};function lC(e,n){let s=e.length-2,l=3,i,c;return e[l][1].type==="whitespace"&&(l+=2),s-2>l&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(l===s-1||s-4>l&&e[s-2][1].type==="whitespace")&&(s-=l+1===s?2:4),s>l&&(i={type:"atxHeadingText",start:e[l][1].start,end:e[s][1].end},c={type:"chunkText",start:e[l][1].start,end:e[s][1].end,contentType:"text"},ns(e,l,s-l+1,[["enter",i,n],["enter",c,n],["exit",c,n],["exit",i,n]])),e}function iC(e,n,s){let l=0;return i;function i(x){return e.enter("atxHeading"),c(x)}function c(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&l++<6?(e.consume(x),d):x===null||Tn(x)?(e.exit("atxHeadingSequence"),u(x)):s(x)}function u(x){return x===35?(e.enter("atxHeadingSequence"),h(x)):x===null||jt(x)?(e.exit("atxHeading"),n(x)):Gt(x)?nn(e,u,"whitespace")(x):(e.enter("atxHeadingText"),f(x))}function h(x){return x===35?(e.consume(x),h):(e.exit("atxHeadingSequence"),u(x))}function f(x){return x===null||x===35||Tn(x)?(e.exit("atxHeadingText"),u(x)):(e.consume(x),f)}}const oC=["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"],fy=["pre","script","style","textarea"],cC={concrete:!0,name:"htmlFlow",resolveTo:fC,tokenize:mC},dC={partial:!0,tokenize:xC},uC={partial:!0,tokenize:hC};function fC(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 mC(e,n,s){const l=this;let i,c,d,u,h;return f;function f(I){return x(I)}function x(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),p}function p(I){return I===33?(e.consume(I),g):I===47?(e.consume(I),c=!0,k):I===63?(e.consume(I),i=3,l.interrupt?n:B):Mr(I)?(e.consume(I),d=String.fromCharCode(I),C):s(I)}function g(I){return I===45?(e.consume(I),i=2,b):I===91?(e.consume(I),i=5,u=0,w):Mr(I)?(e.consume(I),i=4,l.interrupt?n:B):s(I)}function b(I){return I===45?(e.consume(I),l.interrupt?n:B):s(I)}function w(I){const S="CDATA[";return I===S.charCodeAt(u++)?(e.consume(I),u===S.length?l.interrupt?n:G:w):s(I)}function k(I){return Mr(I)?(e.consume(I),d=String.fromCharCode(I),C):s(I)}function C(I){if(I===null||I===47||I===62||Tn(I)){const S=I===47,D=d.toLowerCase();return!S&&!c&&fy.includes(D)?(i=1,l.interrupt?n(I):G(I)):oC.includes(d.toLowerCase())?(i=6,S?(e.consume(I),E):l.interrupt?n(I):G(I)):(i=7,l.interrupt&&!l.parser.lazy[l.now().line]?s(I):c?M(I):N(I))}return I===45||Er(I)?(e.consume(I),d+=String.fromCharCode(I),C):s(I)}function E(I){return I===62?(e.consume(I),l.interrupt?n:G):s(I)}function M(I){return Gt(I)?(e.consume(I),M):L(I)}function N(I){return I===47?(e.consume(I),L):I===58||I===95||Mr(I)?(e.consume(I),A):Gt(I)?(e.consume(I),N):L(I)}function A(I){return I===45||I===46||I===58||I===95||Er(I)?(e.consume(I),A):R(I)}function R(I){return I===61?(e.consume(I),_):Gt(I)?(e.consume(I),R):N(I)}function _(I){return I===null||I===60||I===61||I===62||I===96?s(I):I===34||I===39?(e.consume(I),h=I,Y):Gt(I)?(e.consume(I),_):q(I)}function Y(I){return I===h?(e.consume(I),h=null,X):I===null||jt(I)?s(I):(e.consume(I),Y)}function q(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||Tn(I)?R(I):(e.consume(I),q)}function X(I){return I===47||I===62||Gt(I)?N(I):s(I)}function L(I){return I===62?(e.consume(I),P):s(I)}function P(I){return I===null||jt(I)?G(I):Gt(I)?(e.consume(I),P):s(I)}function G(I){return I===45&&i===2?(e.consume(I),O):I===60&&i===1?(e.consume(I),V):I===62&&i===4?(e.consume(I),F):I===63&&i===3?(e.consume(I),B):I===93&&i===5?(e.consume(I),Z):jt(I)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(dC,K,$)(I)):I===null||jt(I)?(e.exit("htmlFlowData"),$(I)):(e.consume(I),G)}function $(I){return e.check(uC,T,K)(I)}function T(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),z}function z(I){return I===null||jt(I)?$(I):(e.enter("htmlFlowData"),G(I))}function O(I){return I===45?(e.consume(I),B):G(I)}function V(I){return I===47?(e.consume(I),d="",H):G(I)}function H(I){if(I===62){const S=d.toLowerCase();return fy.includes(S)?(e.consume(I),F):G(I)}return Mr(I)&&d.length<8?(e.consume(I),d+=String.fromCharCode(I),H):G(I)}function Z(I){return I===93?(e.consume(I),B):G(I)}function B(I){return I===62?(e.consume(I),F):I===45&&i===2?(e.consume(I),B):G(I)}function F(I){return I===null||jt(I)?(e.exit("htmlFlowData"),K(I)):(e.consume(I),F)}function K(I){return e.exit("htmlFlow"),n(I)}}function hC(e,n,s){const l=this;return i;function i(d){return jt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):s(d)}function c(d){return l.parser.lazy[l.now().line]?s(d):n(d)}}function xC(e,n,s){return l;function l(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(mc,n,s)}}const pC={name:"htmlText",tokenize:gC};function gC(e,n,s){const l=this;let i,c,d;return u;function u(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),N):Mr(B)?(e.consume(B),q):s(B)}function f(B){return B===45?(e.consume(B),x):B===91?(e.consume(B),c=0,w):Mr(B)?(e.consume(B),M):s(B)}function x(B){return B===45?(e.consume(B),b):s(B)}function p(B){return B===null?s(B):B===45?(e.consume(B),g):jt(B)?(d=p,V(B)):(e.consume(B),p)}function g(B){return B===45?(e.consume(B),b):p(B)}function b(B){return B===62?O(B):B===45?g(B):p(B)}function w(B){const F="CDATA[";return B===F.charCodeAt(c++)?(e.consume(B),c===F.length?k:w):s(B)}function k(B){return B===null?s(B):B===93?(e.consume(B),C):jt(B)?(d=k,V(B)):(e.consume(B),k)}function C(B){return B===93?(e.consume(B),E):k(B)}function E(B){return B===62?O(B):B===93?(e.consume(B),E):k(B)}function M(B){return B===null||B===62?O(B):jt(B)?(d=M,V(B)):(e.consume(B),M)}function N(B){return B===null?s(B):B===63?(e.consume(B),A):jt(B)?(d=N,V(B)):(e.consume(B),N)}function A(B){return B===62?O(B):N(B)}function R(B){return Mr(B)?(e.consume(B),_):s(B)}function _(B){return B===45||Er(B)?(e.consume(B),_):Y(B)}function Y(B){return jt(B)?(d=Y,V(B)):Gt(B)?(e.consume(B),Y):O(B)}function q(B){return B===45||Er(B)?(e.consume(B),q):B===47||B===62||Tn(B)?X(B):s(B)}function X(B){return B===47?(e.consume(B),O):B===58||B===95||Mr(B)?(e.consume(B),L):jt(B)?(d=X,V(B)):Gt(B)?(e.consume(B),X):O(B)}function L(B){return B===45||B===46||B===58||B===95||Er(B)?(e.consume(B),L):P(B)}function P(B){return B===61?(e.consume(B),G):jt(B)?(d=P,V(B)):Gt(B)?(e.consume(B),P):X(B)}function G(B){return B===null||B===60||B===61||B===62||B===96?s(B):B===34||B===39?(e.consume(B),i=B,$):jt(B)?(d=G,V(B)):Gt(B)?(e.consume(B),G):(e.consume(B),T)}function $(B){return B===i?(e.consume(B),i=void 0,z):B===null?s(B):jt(B)?(d=$,V(B)):(e.consume(B),$)}function T(B){return B===null||B===34||B===39||B===60||B===61||B===96?s(B):B===47||B===62||Tn(B)?X(B):(e.consume(B),T)}function z(B){return B===47||B===62||Tn(B)?X(B):s(B)}function O(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),n):s(B)}function V(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),H}function H(B){return Gt(B)?nn(e,Z,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):Z(B)}function Z(B){return e.enter("htmlTextData"),d(B)}}const Dx={name:"labelEnd",resolveAll:jC,resolveTo:wC,tokenize:NC},bC={tokenize:kC},yC={tokenize:SC},vC={tokenize:CC};function jC(e){let n=-1;const s=[];for(;++n<e.length;){const l=e[n][1];if(s.push(e[n]),l.type==="labelImage"||l.type==="labelLink"||l.type==="labelEnd"){const i=l.type==="labelImage"?4:2;l.type="data",n+=i}}return e.length!==s.length&&ns(e,0,e.length,s),e}function wC(e,n){let s=e.length,l=0,i,c,d,u;for(;s--;)if(i=e[s][1],c){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[s][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(d){if(e[s][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(c=s,i.type!=="labelLink")){l=2;break}}else i.type==="labelEnd"&&(d=s);const h={type:e[c][1].type==="labelLink"?"link":"image",start:{...e[c][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[c][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[c+l+2][1].end},end:{...e[d-2][1].start}};return u=[["enter",h,n],["enter",f,n]],u=ps(u,e.slice(c+1,c+l+3)),u=ps(u,[["enter",x,n]]),u=ps(u,wu(n.parser.constructs.insideSpan.null,e.slice(c+l+4,d-3),n)),u=ps(u,[["exit",x,n],e[d-2],e[d-1],["exit",f,n]]),u=ps(u,e.slice(d+1)),u=ps(u,[["exit",h,n]]),ns(e,c,e.length,u),e}function NC(e,n,s){const l=this;let i=l.events.length,c,d;for(;i--;)if((l.events[i][1].type==="labelImage"||l.events[i][1].type==="labelLink")&&!l.events[i][1]._balanced){c=l.events[i][1];break}return u;function u(g){return c?c._inactive?p(g):(d=l.parser.defined.includes(_s(l.sliceSerialize({start:c.end,end:l.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(bC,x,d?x:p)(g):g===91?e.attempt(yC,x,d?f:p)(g):d?x(g):p(g)}function f(g){return e.attempt(vC,x,p)(g)}function x(g){return n(g)}function p(g){return c._balanced=!0,s(g)}}function kC(e,n,s){return l;function l(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return Tn(p)?Yo(e,c)(p):c(p)}function c(p){return p===41?x(p):wj(e,d,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function d(p){return Tn(p)?Yo(e,h)(p):x(p)}function u(p){return s(p)}function h(p){return p===34||p===39||p===40?kj(e,f,s,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):x(p)}function f(p){return Tn(p)?Yo(e,x)(p):x(p)}function x(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),n):s(p)}}function SC(e,n,s){const l=this;return i;function i(u){return Nj.call(l,e,c,d,"reference","referenceMarker","referenceString")(u)}function c(u){return l.parser.defined.includes(_s(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)))?n(u):s(u)}function d(u){return s(u)}}function CC(e,n,s){return l;function l(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),i}function i(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),n):s(c)}}const EC={name:"labelStartImage",resolveAll:Dx.resolveAll,tokenize:TC};function TC(e,n,s){const l=this;return i;function i(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),c}function c(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),d):s(u)}function d(u){return u===94&&"_hiddenFootnoteSupport"in l.parser.constructs?s(u):n(u)}}const AC={name:"labelStartLink",resolveAll:Dx.resolveAll,tokenize:_C};function _C(e,n,s){const l=this;return i;function i(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),c}function c(d){return d===94&&"_hiddenFootnoteSupport"in l.parser.constructs?s(d):n(d)}}const Xm={name:"lineEnding",tokenize:MC};function MC(e,n){return s;function s(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),nn(e,n,"linePrefix")}}const qd={name:"thematicBreak",tokenize:RC};function RC(e,n,s){let l=0,i;return c;function c(f){return e.enter("thematicBreak"),d(f)}function d(f){return i=f,u(f)}function u(f){return f===i?(e.enter("thematicBreakSequence"),h(f)):l>=3&&(f===null||jt(f))?(e.exit("thematicBreak"),n(f)):s(f)}function h(f){return f===i?(e.consume(f),l++,h):(e.exit("thematicBreakSequence"),Gt(f)?nn(e,u,"whitespace")(f):u(f))}}const Ur={continuation:{tokenize:IC},exit:$C,name:"list",tokenize:LC},OC={partial:!0,tokenize:BC},DC={partial:!0,tokenize:zC};function LC(e,n,s){const l=this,i=l.events[l.events.length-1];let c=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,d=0;return u;function u(b){const w=l.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||b===l.containerState.marker:Ph(b)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(qd,s,f)(b):f(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(b)}return s(b)}function h(b){return Ph(b)&&++d<10?(e.consume(b),h):(!l.interrupt||d<2)&&(l.containerState.marker?b===l.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),f(b)):s(b)}function f(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(mc,l.interrupt?s:x,e.attempt(OC,g,p))}function x(b){return l.containerState.initialBlankLine=!0,c++,g(b)}function p(b){return Gt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),g):s(b)}function g(b){return l.containerState.size=c+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function IC(e,n,s){const l=this;return l.containerState._closeFlow=void 0,e.check(mc,i,c);function i(u){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,nn(e,n,"listItemIndent",l.containerState.size+1)(u)}function c(u){return l.containerState.furtherBlankLines||!Gt(u)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,d(u)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(DC,n,d)(u))}function d(u){return l.containerState._closeFlow=!0,l.interrupt=void 0,nn(e,e.attempt(Ur,n,s),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function zC(e,n,s){const l=this;return nn(e,i,"listItemIndent",l.containerState.size+1);function i(c){const d=l.events[l.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===l.containerState.size?n(c):s(c)}}function $C(e){e.exit(this.containerState.type)}function BC(e,n,s){const l=this;return nn(e,i,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(c){const d=l.events[l.events.length-1];return!Gt(c)&&d&&d[1].type==="listItemPrefixWhitespace"?n(c):s(c)}}const my={name:"setextUnderline",resolveTo:HC,tokenize:PC};function HC(e,n){let s=e.length,l,i,c;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){l=s;break}e[s][1].type==="paragraph"&&(i=s)}else e[s][1].type==="content"&&e.splice(s,1),!c&&e[s][1].type==="definition"&&(c=s);const d={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",c?(e.splice(i,0,["enter",d,n]),e.splice(c+1,0,["exit",e[l][1],n]),e[l][1].end={...e[c][1].end}):e[l][1]=d,e.push(["exit",d,n]),e}function PC(e,n,s){const l=this;let i;return c;function c(f){let x=l.events.length,p;for(;x--;)if(l.events[x][1].type!=="lineEnding"&&l.events[x][1].type!=="linePrefix"&&l.events[x][1].type!=="content"){p=l.events[x][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||p)?(e.enter("setextHeadingLine"),i=f,d(f)):s(f)}function d(f){return e.enter("setextHeadingLineSequence"),u(f)}function u(f){return f===i?(e.consume(f),u):(e.exit("setextHeadingLineSequence"),Gt(f)?nn(e,h,"lineSuffix")(f):h(f))}function h(f){return f===null||jt(f)?(e.exit("setextHeadingLine"),n(f)):s(f)}}const UC={tokenize:qC};function qC(e){const n=this,s=e.attempt(mc,l,e.attempt(this.parser.constructs.flowInitial,i,nn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(XS,i)),"linePrefix")));return s;function l(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),n.currentConstruct=void 0,s}function i(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),n.currentConstruct=void 0,s}}const FC={resolveAll:Cj()},VC=Sj("string"),YC=Sj("text");function Sj(e){return{resolveAll:Cj(e==="text"?GC:void 0),tokenize:n};function n(s){const l=this,i=this.parser.constructs[e],c=s.attempt(i,d,u);return d;function d(x){return f(x)?c(x):u(x)}function u(x){if(x===null){s.consume(x);return}return s.enter("data"),s.consume(x),h}function h(x){return f(x)?(s.exit("data"),c(x)):(s.consume(x),h)}function f(x){if(x===null)return!0;const p=i[x];let g=-1;if(p)for(;++g<p.length;){const b=p[g];if(!b.previous||b.previous.call(l,l.previous))return!0}return!1}}}function Cj(e){return n;function n(s,l){let i=-1,c;for(;++i<=s.length;)c===void 0?s[i]&&s[i][1].type==="data"&&(c=i,i++):(!s[i]||s[i][1].type!=="data")&&(i!==c+2&&(s[c][1].end=s[i-1][1].end,s.splice(c+2,i-c-2),i=c+2),c=void 0);return e?e(s,l):s}}function GC(e,n){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const l=e[s-1][1],i=n.sliceStream(l);let c=i.length,d=-1,u=0,h;for(;c--;){const f=i[c];if(typeof f=="string"){for(d=f.length;f.charCodeAt(d-1)===32;)u++,d--;if(d)break;d=-1}else if(f===-2)h=!0,u++;else if(f!==-1){c++;break}}if(n._contentTypeTextTrailing&&s===e.length&&(u=0),u){const f={type:s===e.length||h||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?d:l.start._bufferIndex+d,_index:l.start._index+c,line:l.end.line,column:l.end.column-u,offset:l.end.offset-u},end:{...l.end}};l.end={...f.start},l.start.offset===l.end.offset?Object.assign(l,f):(e.splice(s,0,["enter",f,n],["exit",f,n]),s+=2)}s++}return e}const XC={42:Ur,43:Ur,45:Ur,48:Ur,49:Ur,50:Ur,51:Ur,52:Ur,53:Ur,54:Ur,55:Ur,56:Ur,57:Ur,62:bj},KC={91:JS},WC={[-2]:Gm,[-1]:Gm,32:Gm},ZC={35:aC,42:qd,45:[my,qd],60:cC,61:my,95:qd,96:uy,126:uy},QC={38:vj,92:yj},JC={[-5]:Xm,[-4]:Xm,[-3]:Xm,33:EC,38:vj,42:Uh,60:[AS,pC],91:AC,92:[rC,yj],93:Dx,95:Uh,96:US},eE={null:[Uh,FC]},tE={null:[42,95]},nE={null:[]},rE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:tE,contentInitial:KC,disable:nE,document:XC,flow:ZC,flowInitial:WC,insideSpan:eE,string:QC,text:JC},Symbol.toStringTag,{value:"Module"}));function sE(e,n,s){let l={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const i={},c=[];let d=[],u=[];const h={attempt:Y(R),check:Y(_),consume:M,enter:N,exit:A,interrupt:Y(_,{interrupt:!0})},f={code:null,containerState:{},defineSkip:k,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:b,write:p};let x=n.tokenize.call(f,h);return n.resolveAll&&c.push(n),f;function p(P){return d=ps(d,P),C(),d[d.length-1]!==null?[]:(q(n,0),f.events=wu(c,f.events,f),f.events)}function g(P,G){return lE(b(P),G)}function b(P){return aE(d,P)}function w(){const{_bufferIndex:P,_index:G,line:$,column:T,offset:z}=l;return{_bufferIndex:P,_index:G,line:$,column:T,offset:z}}function k(P){i[P.line]=P.column,L()}function C(){let P;for(;l._index<d.length;){const G=d[l._index];if(typeof G=="string")for(P=l._index,l._bufferIndex<0&&(l._bufferIndex=0);l._index===P&&l._bufferIndex<G.length;)E(G.charCodeAt(l._bufferIndex));else E(G)}}function E(P){x=x(P)}function M(P){jt(P)?(l.line++,l.column=1,l.offset+=P===-3?2:1,L()):P!==-1&&(l.column++,l.offset++),l._bufferIndex<0?l._index++:(l._bufferIndex++,l._bufferIndex===d[l._index].length&&(l._bufferIndex=-1,l._index++)),f.previous=P}function N(P,G){const $=G||{};return $.type=P,$.start=w(),f.events.push(["enter",$,f]),u.push($),$}function A(P){const G=u.pop();return G.end=w(),f.events.push(["exit",G,f]),G}function R(P,G){q(P,G.from)}function _(P,G){G.restore()}function Y(P,G){return $;function $(T,z,O){let V,H,Z,B;return Array.isArray(T)?K(T):"tokenize"in T?K([T]):F(T);function F(W){return J;function J(te){const re=te!==null&&W[te],oe=te!==null&&W.null,me=[...Array.isArray(re)?re:re?[re]:[],...Array.isArray(oe)?oe:oe?[oe]:[]];return K(me)(te)}}function K(W){return V=W,H=0,W.length===0?O:I(W[H])}function I(W){return J;function J(te){return B=X(),Z=W,W.partial||(f.currentConstruct=W),W.name&&f.parser.constructs.disable.null.includes(W.name)?D():W.tokenize.call(G?Object.assign(Object.create(f),G):f,h,S,D)(te)}}function S(W){return P(Z,B),z}function D(W){return B.restore(),++H<V.length?I(V[H]):O}}}function q(P,G){P.resolveAll&&!c.includes(P)&&c.push(P),P.resolve&&ns(f.events,G,f.events.length-G,P.resolve(f.events.slice(G),f)),P.resolveTo&&(f.events=P.resolveTo(f.events,f))}function X(){const P=w(),G=f.previous,$=f.currentConstruct,T=f.events.length,z=Array.from(u);return{from:T,restore:O};function O(){l=P,f.previous=G,f.currentConstruct=$,f.events.length=T,u=z,L()}}function L(){l.line in i&&l.column<2&&(l.column=i[l.line],l.offset+=i[l.line]-1)}}function aE(e,n){const s=n.start._index,l=n.start._bufferIndex,i=n.end._index,c=n.end._bufferIndex;let d;if(s===i)d=[e[s].slice(l,c)];else{if(d=e.slice(s,i),l>-1){const u=d[0];typeof u=="string"?d[0]=u.slice(l):d.shift()}c>0&&d.push(e[i].slice(0,c))}return d}function lE(e,n){let s=-1;const l=[];let i;for(;++s<e.length;){const c=e[s];let d;if(typeof c=="string")d=c;else switch(c){case-5:{d="\r";break}case-4:{d=`
|
|
12
|
+
`;break}case-3:{d=`\r
|
|
13
|
+
`;break}case-2:{d=n?" ":" ";break}case-1:{if(!n&&i)continue;d=" ";break}default:d=String.fromCharCode(c)}i=c===-2,l.push(d)}return l.join("")}function iE(e){const l={constructs:pj([rE,...(e||{}).extensions||[]]),content:i(wS),defined:[],document:i(kS),flow:i(UC),lazy:{},string:i(VC),text:i(YC)};return l;function i(c){return d;function d(u){return sE(l,c,u)}}}function oE(e){for(;!jj(e););return e}const hy=/[\0\t\n\r]/g;function cE(){let e=1,n="",s=!0,l;return i;function i(c,d,u){const h=[];let f,x,p,g,b;for(c=n+(typeof c=="string"?c.toString():new TextDecoder(d||void 0).decode(c)),p=0,n="",s&&(c.charCodeAt(0)===65279&&p++,s=void 0);p<c.length;){if(hy.lastIndex=p,f=hy.exec(c),g=f&&f.index!==void 0?f.index:c.length,b=c.charCodeAt(g),!f){n=c.slice(p);break}if(b===10&&p===g&&l)h.push(-3),l=void 0;else switch(l&&(h.push(-5),l=void 0),p<g&&(h.push(c.slice(p,g)),e+=g-p),b){case 0:{h.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,h.push(-2);e++<x;)h.push(-1);break}case 10:{h.push(-4),e=1;break}default:l=!0,e=1}p=g+1}return u&&(l&&h.push(-5),n&&h.push(n),h.push(null)),h}}const dE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function uE(e){return e.replace(dE,fE)}function fE(e,n,s){if(n)return n;if(s.charCodeAt(0)===35){const i=s.charCodeAt(1),c=i===120||i===88;return gj(s.slice(c?2:1),c?16:10)}return Ox(s)||e}const Ej={}.hasOwnProperty;function mE(e,n,s){return n&&typeof n=="object"&&(s=n,n=void 0),hE(s)(oE(iE(s).document().write(cE()(e,n,!0))))}function hE(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(et),autolinkProtocol:X,autolinkEmail:X,atxHeading:c(Ee),blockQuote:c(oe),characterEscape:X,characterReference:X,codeFenced:c(me),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:c(me,d),codeText:c(Oe,d),codeTextData:X,data:X,codeFlowValue:X,definition:c(ve),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:c(ke),hardBreakEscape:c(Me),hardBreakTrailing:c(Me),htmlFlow:c(dt,d),htmlFlowData:X,htmlText:c(dt,d),htmlTextData:X,image:c(pt),label:d,link:c(et),listItem:c(le),listItemValue:g,listOrdered:c(Pt,p),listUnordered:c(Pt),paragraph:c(Se),reference:I,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:c(Ee),strong:c(We),thematicBreak:c(Ft)},exit:{atxHeading:h(),atxHeadingSequence:R,autolink:h(),autolinkEmail:re,autolinkProtocol:te,blockQuote:h(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:D,characterReferenceMarkerNumeric:D,characterReferenceValue:W,characterReference:J,codeFenced:h(C),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:w,codeFlowValue:L,codeIndented:h(E),codeText:h(z),codeTextData:L,data:L,definition:h(),definitionDestinationString:A,definitionLabelString:M,definitionTitleString:N,emphasis:h(),hardBreakEscape:h(G),hardBreakTrailing:h(G),htmlFlow:h($),htmlFlowData:L,htmlText:h(T),htmlTextData:L,image:h(V),label:Z,labelText:H,lineEnding:P,link:h(O),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:S,resourceDestinationString:B,resourceTitleString:F,resource:K,setextHeading:h(q),setextHeadingLineSequence:Y,setextHeadingText:_,strong:h(),thematicBreak:h()}};Tj(n,(e||{}).mdastExtensions||[]);const s={};return l;function l(xe){let Ce={type:"root",children:[]};const Fe={stack:[Ce],tokenStack:[],config:n,enter:u,exit:f,buffer:d,resume:x,data:s},lt=[];let ut=-1;for(;++ut<xe.length;)if(xe[ut][1].type==="listOrdered"||xe[ut][1].type==="listUnordered")if(xe[ut][0]==="enter")lt.push(ut);else{const Lt=lt.pop();ut=i(xe,Lt,ut)}for(ut=-1;++ut<xe.length;){const Lt=n[xe[ut][0]];Ej.call(Lt,xe[ut][1].type)&&Lt[xe[ut][1].type].call(Object.assign({sliceSerialize:xe[ut][2].sliceSerialize},Fe),xe[ut][1])}if(Fe.tokenStack.length>0){const Lt=Fe.tokenStack[Fe.tokenStack.length-1];(Lt[1]||xy).call(Fe,void 0,Lt[0])}for(Ce.position={start:Wa(xe.length>0?xe[0][1].start:{line:1,column:1,offset:0}),end:Wa(xe.length>0?xe[xe.length-2][1].end:{line:1,column:1,offset:0})},ut=-1;++ut<n.transforms.length;)Ce=n.transforms[ut](Ce)||Ce;return Ce}function i(xe,Ce,Fe){let lt=Ce-1,ut=-1,Lt=!1,bn,Ut,St,Jt;for(;++lt<=Fe;){const yt=xe[lt];switch(yt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{yt[0]==="enter"?ut++:ut--,Jt=void 0;break}case"lineEndingBlank":{yt[0]==="enter"&&(bn&&!Jt&&!ut&&!St&&(St=lt),Jt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Jt=void 0}if(!ut&&yt[0]==="enter"&&yt[1].type==="listItemPrefix"||ut===-1&&yt[0]==="exit"&&(yt[1].type==="listUnordered"||yt[1].type==="listOrdered")){if(bn){let Xt=lt;for(Ut=void 0;Xt--;){const _t=xe[Xt];if(_t[1].type==="lineEnding"||_t[1].type==="lineEndingBlank"){if(_t[0]==="exit")continue;Ut&&(xe[Ut][1].type="lineEndingBlank",Lt=!0),_t[1].type="lineEnding",Ut=Xt}else if(!(_t[1].type==="linePrefix"||_t[1].type==="blockQuotePrefix"||_t[1].type==="blockQuotePrefixWhitespace"||_t[1].type==="blockQuoteMarker"||_t[1].type==="listItemIndent"))break}St&&(!Ut||St<Ut)&&(bn._spread=!0),bn.end=Object.assign({},Ut?xe[Ut][1].start:yt[1].end),xe.splice(Ut||lt,0,["exit",bn,yt[2]]),lt++,Fe++}if(yt[1].type==="listItemPrefix"){const Xt={type:"listItem",_spread:!1,start:Object.assign({},yt[1].start),end:void 0};bn=Xt,xe.splice(lt,0,["enter",Xt,yt[2]]),lt++,Fe++,St=void 0,Jt=!0}}}return xe[Ce][1]._spread=Lt,Fe}function c(xe,Ce){return Fe;function Fe(lt){u.call(this,xe(lt),lt),Ce&&Ce.call(this,lt)}}function d(){this.stack.push({type:"fragment",children:[]})}function u(xe,Ce,Fe){this.stack[this.stack.length-1].children.push(xe),this.stack.push(xe),this.tokenStack.push([Ce,Fe||void 0]),xe.position={start:Wa(Ce.start),end:void 0}}function h(xe){return Ce;function Ce(Fe){xe&&xe.call(this,Fe),f.call(this,Fe)}}function f(xe,Ce){const Fe=this.stack.pop(),lt=this.tokenStack.pop();if(lt)lt[0].type!==xe.type&&(Ce?Ce.call(this,xe,lt[0]):(lt[1]||xy).call(this,xe,lt[0]));else throw new Error("Cannot close `"+xe.type+"` ("+Vo({start:xe.start,end:xe.end})+"): it’s not open");Fe.position.end=Wa(xe.end)}function x(){return Rx(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g(xe){if(this.data.expectingFirstListItemValue){const Ce=this.stack[this.stack.length-2];Ce.start=Number.parseInt(this.sliceSerialize(xe),10),this.data.expectingFirstListItemValue=void 0}}function b(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.lang=xe}function w(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.meta=xe}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=xe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=xe.replace(/(\r?\n|\r)$/g,"")}function M(xe){const Ce=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Ce,Fe.identifier=_s(this.sliceSerialize(xe)).toLowerCase()}function N(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.title=xe}function A(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.url=xe}function R(xe){const Ce=this.stack[this.stack.length-1];if(!Ce.depth){const Fe=this.sliceSerialize(xe).length;Ce.depth=Fe}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function Y(xe){const Ce=this.stack[this.stack.length-1];Ce.depth=this.sliceSerialize(xe).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function X(xe){const Fe=this.stack[this.stack.length-1].children;let lt=Fe[Fe.length-1];(!lt||lt.type!=="text")&&(lt=kt(),lt.position={start:Wa(xe.start),end:void 0},Fe.push(lt)),this.stack.push(lt)}function L(xe){const Ce=this.stack.pop();Ce.value+=this.sliceSerialize(xe),Ce.position.end=Wa(xe.end)}function P(xe){const Ce=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Fe=Ce.children[Ce.children.length-1];Fe.position.end=Wa(xe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(Ce.type)&&(X.call(this,xe),L.call(this,xe))}function G(){this.data.atHardBreak=!0}function $(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=xe}function T(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=xe}function z(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.value=xe}function O(){const xe=this.stack[this.stack.length-1];if(this.data.inReference){const Ce=this.data.referenceType||"shortcut";xe.type+="Reference",xe.referenceType=Ce,delete xe.url,delete xe.title}else delete xe.identifier,delete xe.label;this.data.referenceType=void 0}function V(){const xe=this.stack[this.stack.length-1];if(this.data.inReference){const Ce=this.data.referenceType||"shortcut";xe.type+="Reference",xe.referenceType=Ce,delete xe.url,delete xe.title}else delete xe.identifier,delete xe.label;this.data.referenceType=void 0}function H(xe){const Ce=this.sliceSerialize(xe),Fe=this.stack[this.stack.length-2];Fe.label=uE(Ce),Fe.identifier=_s(Ce).toLowerCase()}function Z(){const xe=this.stack[this.stack.length-1],Ce=this.resume(),Fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Fe.type==="link"){const lt=xe.children;Fe.children=lt}else Fe.alt=Ce}function B(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.url=xe}function F(){const xe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.title=xe}function K(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function S(xe){const Ce=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Ce,Fe.identifier=_s(this.sliceSerialize(xe)).toLowerCase(),this.data.referenceType="full"}function D(xe){this.data.characterReferenceType=xe.type}function W(xe){const Ce=this.sliceSerialize(xe),Fe=this.data.characterReferenceType;let lt;Fe?(lt=gj(Ce,Fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):lt=Ox(Ce);const ut=this.stack[this.stack.length-1];ut.value+=lt}function J(xe){const Ce=this.stack.pop();Ce.position.end=Wa(xe.end)}function te(xe){L.call(this,xe);const Ce=this.stack[this.stack.length-1];Ce.url=this.sliceSerialize(xe)}function re(xe){L.call(this,xe);const Ce=this.stack[this.stack.length-1];Ce.url="mailto:"+this.sliceSerialize(xe)}function oe(){return{type:"blockquote",children:[]}}function me(){return{type:"code",lang:null,meta:null,value:""}}function Oe(){return{type:"inlineCode",value:""}}function ve(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ke(){return{type:"emphasis",children:[]}}function Ee(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function dt(){return{type:"html",value:""}}function pt(){return{type:"image",title:null,url:"",alt:null}}function et(){return{type:"link",title:null,url:"",children:[]}}function Pt(xe){return{type:"list",ordered:xe.type==="listOrdered",start:null,spread:xe._spread,children:[]}}function le(xe){return{type:"listItem",spread:xe._spread,checked:null,children:[]}}function Se(){return{type:"paragraph",children:[]}}function We(){return{type:"strong",children:[]}}function kt(){return{type:"text",value:""}}function Ft(){return{type:"thematicBreak"}}}function Wa(e){return{line:e.line,column:e.column,offset:e.offset}}function Tj(e,n){let s=-1;for(;++s<n.length;){const l=n[s];Array.isArray(l)?Tj(e,l):xE(e,l)}}function xE(e,n){let s;for(s in n)if(Ej.call(n,s))switch(s){case"canContainEols":{const l=n[s];l&&e[s].push(...l);break}case"transforms":{const l=n[s];l&&e[s].push(...l);break}case"enter":case"exit":{const l=n[s];l&&Object.assign(e[s],l);break}}}function xy(e,n){throw e?new Error("Cannot close `"+e.type+"` ("+Vo({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+Vo({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Vo({start:n.start,end:n.end})+") is still open")}function pE(e){const n=this;n.parser=s;function s(l){return mE(l,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function gE(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 bE(e,n){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,s),[e.applyData(n,s),{type:"text",value:`
|
|
14
|
+
`}]}function yE(e,n){const s=n.value?n.value+`
|
|
15
|
+
`:"",l={},i=n.lang?n.lang.split(/\s+/):[];i.length>0&&(l.className=["language-"+i[0]]);let c={type:"element",tagName:"code",properties:l,children:[{type:"text",value:s}]};return n.meta&&(c.data={meta:n.meta}),e.patch(n,c),c=e.applyData(n,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(n,c),c}function vE(e,n){const s={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function jE(e,n){const s={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function wE(e,n){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(n.identifier).toUpperCase(),i=Ui(l.toLowerCase()),c=e.footnoteOrder.indexOf(l);let d,u=e.footnoteCounts.get(l);u===void 0?(u=0,e.footnoteOrder.push(l),d=e.footnoteOrder.length):d=c+1,u+=1,e.footnoteCounts.set(l,u);const h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+i,id:s+"fnref-"+i+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(n,h);const f={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(n,f),e.applyData(n,f)}function NE(e,n){const s={type:"element",tagName:"h"+n.depth,properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function kE(e,n){if(e.options.allowDangerousHtml){const s={type:"raw",value:n.value};return e.patch(n,s),e.applyData(n,s)}}function Aj(e,n){const s=n.referenceType;let l="]";if(s==="collapsed"?l+="[]":s==="full"&&(l+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+l}];const i=e.all(n),c=i[0];c&&c.type==="text"?c.value="["+c.value:i.unshift({type:"text",value:"["});const d=i[i.length-1];return d&&d.type==="text"?d.value+=l:i.push({type:"text",value:l}),i}function SE(e,n){const s=String(n.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return Aj(e,n);const i={src:Ui(l.url||""),alt:n.alt};l.title!==null&&l.title!==void 0&&(i.title=l.title);const c={type:"element",tagName:"img",properties:i,children:[]};return e.patch(n,c),e.applyData(n,c)}function CE(e,n){const s={src:Ui(n.url)};n.alt!==null&&n.alt!==void 0&&(s.alt=n.alt),n.title!==null&&n.title!==void 0&&(s.title=n.title);const l={type:"element",tagName:"img",properties:s,children:[]};return e.patch(n,l),e.applyData(n,l)}function EE(e,n){const s={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,s);const l={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(n,l),e.applyData(n,l)}function TE(e,n){const s=String(n.identifier).toUpperCase(),l=e.definitionById.get(s);if(!l)return Aj(e,n);const i={href:Ui(l.url||"")};l.title!==null&&l.title!==void 0&&(i.title=l.title);const c={type:"element",tagName:"a",properties:i,children:e.all(n)};return e.patch(n,c),e.applyData(n,c)}function AE(e,n){const s={href:Ui(n.url)};n.title!==null&&n.title!==void 0&&(s.title=n.title);const l={type:"element",tagName:"a",properties:s,children:e.all(n)};return e.patch(n,l),e.applyData(n,l)}function _E(e,n,s){const l=e.all(n),i=s?ME(s):_j(n),c={},d=[];if(typeof n.checked=="boolean"){const x=l[0];let p;x&&x.type==="element"&&x.tagName==="p"?p=x:(p={type:"element",tagName:"p",properties:{},children:[]},l.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let u=-1;for(;++u<l.length;){const x=l[u];(i||u!==0||x.type!=="element"||x.tagName!=="p")&&d.push({type:"text",value:`
|
|
16
|
+
`}),x.type==="element"&&x.tagName==="p"&&!i?d.push(...x.children):d.push(x)}const h=l[l.length-1];h&&(i||h.type!=="element"||h.tagName!=="p")&&d.push({type:"text",value:`
|
|
17
|
+
`});const f={type:"element",tagName:"li",properties:c,children:d};return e.patch(n,f),e.applyData(n,f)}function ME(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const s=e.children;let l=-1;for(;!n&&++l<s.length;)n=_j(s[l])}return n}function _j(e){const n=e.spread;return n??e.children.length>1}function RE(e,n){const s={},l=e.all(n);let i=-1;for(typeof n.start=="number"&&n.start!==1&&(s.start=n.start);++i<l.length;){const d=l[i];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const c={type:"element",tagName:n.ordered?"ol":"ul",properties:s,children:e.wrap(l,!0)};return e.patch(n,c),e.applyData(n,c)}function OE(e,n){const s={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function DE(e,n){const s={type:"root",children:e.wrap(e.all(n))};return e.patch(n,s),e.applyData(n,s)}function LE(e,n){const s={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function IE(e,n){const s=e.all(n),l=s.shift(),i=[];if(l){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([l],!0)};e.patch(n.children[0],d),i.push(d)}if(s.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},u=Tx(n.children[1]),h=cj(n.children[n.children.length-1]);u&&h&&(d.position={start:u,end:h}),i.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(n,c),e.applyData(n,c)}function zE(e,n,s){const l=s?s.children:void 0,c=(l?l.indexOf(n):1)===0?"th":"td",d=s&&s.type==="table"?s.align:void 0,u=d?d.length:n.children.length;let h=-1;const f=[];for(;++h<u;){const p=n.children[h],g={},b=d?d[h]:void 0;b&&(g.align=b);let w={type:"element",tagName:c,properties:g,children:[]};p&&(w.children=e.all(p),e.patch(p,w),w=e.applyData(p,w)),f.push(w)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(n,x),e.applyData(n,x)}function $E(e,n){const s={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}const py=9,gy=32;function BE(e){const n=String(e),s=/\r?\n|\r/g;let l=s.exec(n),i=0;const c=[];for(;l;)c.push(by(n.slice(i,l.index),i>0,!0),l[0]),i=l.index+l[0].length,l=s.exec(n);return c.push(by(n.slice(i),i>0,!1)),c.join("")}function by(e,n,s){let l=0,i=e.length;if(n){let c=e.codePointAt(l);for(;c===py||c===gy;)l++,c=e.codePointAt(l)}if(s){let c=e.codePointAt(i-1);for(;c===py||c===gy;)i--,c=e.codePointAt(i-1)}return i>l?e.slice(l,i):""}function HE(e,n){const s={type:"text",value:BE(String(n.value))};return e.patch(n,s),e.applyData(n,s)}function PE(e,n){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,s),e.applyData(n,s)}const UE={blockquote:gE,break:bE,code:yE,delete:vE,emphasis:jE,footnoteReference:wE,heading:NE,html:kE,imageReference:SE,image:CE,inlineCode:EE,linkReference:TE,link:AE,listItem:_E,list:RE,paragraph:OE,root:DE,strong:LE,table:IE,tableCell:$E,tableRow:zE,text:HE,thematicBreak:PE,toml:Sd,yaml:Sd,definition:Sd,footnoteDefinition:Sd};function Sd(){}const Mj=-1,Nu=0,Go=1,Jd=2,Lx=3,Ix=4,zx=5,$x=6,Rj=7,Oj=8,yy=typeof self=="object"?self:globalThis,qE=(e,n)=>{const s=(i,c)=>(e.set(c,i),i),l=i=>{if(e.has(i))return e.get(i);const[c,d]=n[i];switch(c){case Nu:case Mj:return s(d,i);case Go:{const u=s([],i);for(const h of d)u.push(l(h));return u}case Jd:{const u=s({},i);for(const[h,f]of d)u[l(h)]=l(f);return u}case Lx:return s(new Date(d),i);case Ix:{const{source:u,flags:h}=d;return s(new RegExp(u,h),i)}case zx:{const u=s(new Map,i);for(const[h,f]of d)u.set(l(h),l(f));return u}case $x:{const u=s(new Set,i);for(const h of d)u.add(l(h));return u}case Rj:{const{name:u,message:h}=d;return s(new yy[u](h),i)}case Oj:return s(BigInt(d),i);case"BigInt":return s(Object(BigInt(d)),i);case"ArrayBuffer":return s(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:u}=new Uint8Array(d);return s(new DataView(u),d)}}return s(new yy[c](d),i)};return l},vy=e=>qE(new Map,e)(0),gi="",{toString:FE}={},{keys:VE}=Object,Oo=e=>{const n=typeof e;if(n!=="object"||!e)return[Nu,n];const s=FE.call(e).slice(8,-1);switch(s){case"Array":return[Go,gi];case"Object":return[Jd,gi];case"Date":return[Lx,gi];case"RegExp":return[Ix,gi];case"Map":return[zx,gi];case"Set":return[$x,gi];case"DataView":return[Go,s]}return s.includes("Array")?[Go,s]:s.includes("Error")?[Rj,s]:[Jd,s]},Cd=([e,n])=>e===Nu&&(n==="function"||n==="symbol"),YE=(e,n,s,l)=>{const i=(d,u)=>{const h=l.push(d)-1;return s.set(u,h),h},c=d=>{if(s.has(d))return s.get(d);let[u,h]=Oo(d);switch(u){case Nu:{let x=d;switch(h){case"bigint":u=Oj,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);x=null;break;case"undefined":return i([Mj],d)}return i([u,x],d)}case Go:{if(h){let g=d;return h==="DataView"?g=new Uint8Array(d.buffer):h==="ArrayBuffer"&&(g=new Uint8Array(d)),i([h,[...g]],d)}const x=[],p=i([u,x],d);for(const g of d)x.push(c(g));return p}case Jd:{if(h)switch(h){case"BigInt":return i([h,d.toString()],d);case"Boolean":case"Number":case"String":return i([h,d.valueOf()],d)}if(n&&"toJSON"in d)return c(d.toJSON());const x=[],p=i([u,x],d);for(const g of VE(d))(e||!Cd(Oo(d[g])))&&x.push([c(g),c(d[g])]);return p}case Lx:return i([u,d.toISOString()],d);case Ix:{const{source:x,flags:p}=d;return i([u,{source:x,flags:p}],d)}case zx:{const x=[],p=i([u,x],d);for(const[g,b]of d)(e||!(Cd(Oo(g))||Cd(Oo(b))))&&x.push([c(g),c(b)]);return p}case $x:{const x=[],p=i([u,x],d);for(const g of d)(e||!Cd(Oo(g)))&&x.push(c(g));return p}}const{message:f}=d;return i([u,{name:h,message:f}],d)};return c},jy=(e,{json:n,lossy:s}={})=>{const l=[];return YE(!(n||s),!!n,new Map,l)(e),l},eu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?vy(jy(e,n)):structuredClone(e):(e,n)=>vy(jy(e,n));function GE(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 XE(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function KE(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||GE,l=e.options.footnoteBackLabel||XE,i=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let h=-1;for(;++h<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[h]);if(!f)continue;const x=e.all(f),p=String(f.identifier).toUpperCase(),g=Ui(p.toLowerCase());let b=0;const w=[],k=e.footnoteCounts.get(p);for(;k!==void 0&&++b<=k;){w.length>0&&w.push({type:"text",value:" "});let M=typeof s=="string"?s:s(h,b);typeof M=="string"&&(M={type:"text",value:M}),w.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+g+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(h,b),className:["data-footnote-backref"]},children:Array.isArray(M)?M:[M]})}const C=x[x.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const M=C.children[C.children.length-1];M&&M.type==="text"?M.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...w)}else x.push(...w);const E={type:"element",tagName:"li",properties:{id:n+"fn-"+g},children:e.wrap(x,!0)};e.patch(f,E),u.push(E)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...eu(d),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
18
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
|
|
19
|
+
`}]}}const ku=(function(e){if(e==null)return JE;if(typeof e=="function")return Su(e);if(typeof e=="object")return Array.isArray(e)?WE(e):ZE(e);if(typeof e=="string")return QE(e);throw new Error("Expected function, string, or object as test")});function WE(e){const n=[];let s=-1;for(;++s<e.length;)n[s]=ku(e[s]);return Su(l);function l(...i){let c=-1;for(;++c<n.length;)if(n[c].apply(this,i))return!0;return!1}}function ZE(e){const n=e;return Su(s);function s(l){const i=l;let c;for(c in e)if(i[c]!==n[c])return!1;return!0}}function QE(e){return Su(n);function n(s){return s&&s.type===e}}function Su(e){return n;function n(s,l,i){return!!(e3(s)&&e.call(this,s,typeof l=="number"?l:void 0,i||void 0))}}function JE(){return!0}function e3(e){return e!==null&&typeof e=="object"&&"type"in e}const Dj=[],t3=!0,qh=!1,n3="skip";function Lj(e,n,s,l){let i;typeof n=="function"&&typeof s!="function"?(l=s,s=n):i=n;const c=ku(i),d=l?-1:1;u(e,void 0,[])();function u(h,f,x){const p=h&&typeof h=="object"?h:{};if(typeof p.type=="string"){const b=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(h.type+(b?"<"+b+">":""))+")"})}return g;function g(){let b=Dj,w,k,C;if((!n||c(h,f,x[x.length-1]||void 0))&&(b=r3(s(h,x)),b[0]===qh))return b;if("children"in h&&h.children){const E=h;if(E.children&&b[0]!==n3)for(k=(l?E.children.length:-1)+d,C=x.concat(E);k>-1&&k<E.children.length;){const M=E.children[k];if(w=u(M,k,C)(),w[0]===qh)return w;k=typeof w[1]=="number"?w[1]:k+d}}return b}}}function r3(e){return Array.isArray(e)?e:typeof e=="number"?[t3,e]:e==null?Dj:[e]}function Bx(e,n,s,l){let i,c,d;typeof n=="function"&&typeof s!="function"?(c=void 0,d=n,i=s):(c=n,d=s,i=l),Lj(e,c,u,i);function u(h,f){const x=f[f.length-1],p=x?x.children.indexOf(h):void 0;return d(h,p,x)}}const Fh={}.hasOwnProperty,s3={};function a3(e,n){const s=n||s3,l=new Map,i=new Map,c=new Map,d={...UE,...s.handlers},u={all:f,applyData:i3,definitionById:l,footnoteById:i,footnoteCounts:c,footnoteOrder:[],handlers:d,one:h,options:s,patch:l3,wrap:c3};return Bx(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const p=x.type==="definition"?l:i,g=String(x.identifier).toUpperCase();p.has(g)||p.set(g,x)}}),u;function h(x,p){const g=x.type,b=u.handlers[g];if(Fh.call(u.handlers,g)&&b)return b(u,x,p);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in x){const{children:k,...C}=x,E=eu(C);return E.children=u.all(x),E}return eu(x)}return(u.options.unknownHandler||o3)(u,x,p)}function f(x){const p=[];if("children"in x){const g=x.children;let b=-1;for(;++b<g.length;){const w=u.one(g[b],x);if(w){if(b&&g[b-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=wy(w.value)),!Array.isArray(w)&&w.type==="element")){const k=w.children[0];k&&k.type==="text"&&(k.value=wy(k.value))}Array.isArray(w)?p.push(...w):p.push(w)}}}return p}}function l3(e,n){e.position&&(n.position=Xk(e))}function i3(e,n){let s=n;if(e&&e.data){const l=e.data.hName,i=e.data.hChildren,c=e.data.hProperties;if(typeof l=="string")if(s.type==="element")s.tagName=l;else{const d="children"in s?s.children:[s];s={type:"element",tagName:l,properties:{},children:d}}s.type==="element"&&c&&Object.assign(s.properties,eu(c)),"children"in s&&s.children&&i!==null&&i!==void 0&&(s.children=i)}return s}function o3(e,n){const s=n.data||{},l="value"in n&&!(Fh.call(s,"hProperties")||Fh.call(s,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,l),e.applyData(n,l)}function c3(e,n){const s=[];let l=-1;for(n&&s.push({type:"text",value:`
|
|
20
|
+
`});++l<e.length;)l&&s.push({type:"text",value:`
|
|
21
|
+
`}),s.push(e[l]);return n&&e.length>0&&s.push({type:"text",value:`
|
|
22
|
+
`}),s}function wy(e){let n=0,s=e.charCodeAt(n);for(;s===9||s===32;)n++,s=e.charCodeAt(n);return e.slice(n)}function Ny(e,n){const s=a3(e,n),l=s.one(e,void 0),i=KE(s),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return i&&c.children.push({type:"text",value:`
|
|
23
|
+
`},i),c}function d3(e,n){return e&&"run"in e?async function(s,l){const i=Ny(s,{file:l,...n});await e.run(i,l)}:function(s,l){return Ny(s,{file:l,...e||n})}}function ky(e){if(e)throw e}var Km,Sy;function u3(){if(Sy)return Km;Sy=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,s=Object.defineProperty,l=Object.getOwnPropertyDescriptor,i=function(f){return typeof Array.isArray=="function"?Array.isArray(f):n.call(f)==="[object Array]"},c=function(f){if(!f||n.call(f)!=="[object Object]")return!1;var x=e.call(f,"constructor"),p=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!x&&!p)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},d=function(f,x){s&&x.name==="__proto__"?s(f,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):f[x.name]=x.newValue},u=function(f,x){if(x==="__proto__")if(e.call(f,x)){if(l)return l(f,x).value}else return;return f[x]};return Km=function h(){var f,x,p,g,b,w,k=arguments[0],C=1,E=arguments.length,M=!1;for(typeof k=="boolean"&&(M=k,k=arguments[1]||{},C=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});C<E;++C)if(f=arguments[C],f!=null)for(x in f)p=u(k,x),g=u(f,x),k!==g&&(M&&g&&(c(g)||(b=i(g)))?(b?(b=!1,w=p&&i(p)?p:[]):w=p&&c(p)?p:{},d(k,{name:x,newValue:h(M,w,g)})):typeof g<"u"&&d(k,{name:x,newValue:g}));return k},Km}var f3=u3();const Wm=yu(f3);function Vh(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 m3(){const e=[],n={run:s,use:l};return n;function s(...i){let c=-1;const d=i.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);u(null,...i);function u(h,...f){const x=e[++c];let p=-1;if(h){d(h);return}for(;++p<i.length;)(f[p]===null||f[p]===void 0)&&(f[p]=i[p]);i=f,x?h3(x,u)(...f):d(null,...f)}}function l(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),n}}function h3(e,n){let s;return l;function l(...d){const u=e.length>d.length;let h;u&&d.push(i);try{h=e.apply(this,d)}catch(f){const x=f;if(u&&s)throw x;return i(x)}u||(h&&h.then&&typeof h.then=="function"?h.then(c,i):h instanceof Error?i(h):c(h))}function i(d,...u){s||(s=!0,n(d,...u))}function c(d){i(null,d)}}const qs={basename:x3,dirname:p3,extname:g3,join:b3,sep:"/"};function x3(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');hc(e);let s=0,l=-1,i=e.length,c;if(n===void 0||n.length===0||n.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(c){s=i+1;break}}else l<0&&(c=!0,l=i+1);return l<0?"":e.slice(s,l)}if(n===e)return"";let d=-1,u=n.length-1;for(;i--;)if(e.codePointAt(i)===47){if(c){s=i+1;break}}else d<0&&(c=!0,d=i+1),u>-1&&(e.codePointAt(i)===n.codePointAt(u--)?u<0&&(l=i):(u=-1,l=d));return s===l?l=d:l<0&&(l=e.length),e.slice(s,l)}function p3(e){if(hc(e),e.length===0)return".";let n=-1,s=e.length,l;for(;--s;)if(e.codePointAt(s)===47){if(l){n=s;break}}else l||(l=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function g3(e){hc(e);let n=e.length,s=-1,l=0,i=-1,c=0,d;for(;n--;){const u=e.codePointAt(n);if(u===47){if(d){l=n+1;break}continue}s<0&&(d=!0,s=n+1),u===46?i<0?i=n:c!==1&&(c=1):i>-1&&(c=-1)}return i<0||s<0||c===0||c===1&&i===s-1&&i===l+1?"":e.slice(i,s)}function b3(...e){let n=-1,s;for(;++n<e.length;)hc(e[n]),e[n]&&(s=s===void 0?e[n]:s+"/"+e[n]);return s===void 0?".":y3(s)}function y3(e){hc(e);const n=e.codePointAt(0)===47;let s=v3(e,!n);return s.length===0&&!n&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),n?"/"+s:s}function v3(e,n){let s="",l=0,i=-1,c=0,d=-1,u,h;for(;++d<=e.length;){if(d<e.length)u=e.codePointAt(d);else{if(u===47)break;u=47}if(u===47){if(!(i===d-1||c===1))if(i!==d-1&&c===2){if(s.length<2||l!==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="",l=0):(s=s.slice(0,h),l=s.length-1-s.lastIndexOf("/")),i=d,c=0;continue}}else if(s.length>0){s="",l=0,i=d,c=0;continue}}n&&(s=s.length>0?s+"/..":"..",l=2)}else s.length>0?s+="/"+e.slice(i+1,d):s=e.slice(i+1,d),l=d-i-1;i=d,c=0}else u===46&&c>-1?c++:c=-1}return s}function hc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const j3={cwd:w3};function w3(){return"/"}function Yh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function N3(e){if(typeof e=="string")e=new URL(e);else if(!Yh(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 k3(e)}function k3(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const n=e.pathname;let s=-1;for(;++s<n.length;)if(n.codePointAt(s)===37&&n.codePointAt(s+1)===50){const l=n.codePointAt(s+2);if(l===70||l===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(n)}const Zm=["history","path","basename","stem","extname","dirname"];class Ij{constructor(n){let s;n?Yh(n)?s={path:n}:typeof n=="string"||S3(n)?s={value:n}:s=n:s={},this.cwd="cwd"in s?"":j3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Zm.length;){const c=Zm[l];c in s&&s[c]!==void 0&&s[c]!==null&&(this[c]=c==="history"?[...s[c]]:s[c])}let i;for(i in s)Zm.includes(i)||(this[i]=s[i])}get basename(){return typeof this.path=="string"?qs.basename(this.path):void 0}set basename(n){Jm(n,"basename"),Qm(n,"basename"),this.path=qs.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?qs.dirname(this.path):void 0}set dirname(n){Cy(this.basename,"dirname"),this.path=qs.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?qs.extname(this.path):void 0}set extname(n){if(Qm(n,"extname"),Cy(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=qs.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){Yh(n)&&(n=N3(n)),Jm(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?qs.basename(this.path,this.extname):void 0}set stem(n){Jm(n,"stem"),Qm(n,"stem"),this.path=qs.join(this.dirname||"",n+(this.extname||""))}fail(n,s,l){const i=this.message(n,s,l);throw i.fatal=!0,i}info(n,s,l){const i=this.message(n,s,l);return i.fatal=void 0,i}message(n,s,l){const i=new Tr(n,s,l);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function Qm(e,n){if(e&&e.includes(qs.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+qs.sep+"`")}function Jm(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function Cy(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function S3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const C3=(function(e){const l=this.constructor.prototype,i=l[e],c=function(){return i.apply(c,arguments)};return Object.setPrototypeOf(c,l),c}),E3={}.hasOwnProperty;class Hx extends C3{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=m3()}copy(){const n=new Hx;let s=-1;for(;++s<this.attachers.length;){const l=this.attachers[s];n.use(...l)}return n.data(Wm(!0,{},this.namespace)),n}data(n,s){return typeof n=="string"?arguments.length===2?(nh("data",this.frozen),this.namespace[n]=s,this):E3.call(this.namespace,n)&&this.namespace[n]||void 0:n?(nh("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const i=s.call(n,...l);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const s=Ed(n),l=this.parser||this.Parser;return eh("parse",l),l(String(s),s)}process(n,s){const l=this;return this.freeze(),eh("process",this.parser||this.Parser),th("process",this.compiler||this.Compiler),s?i(void 0,s):new Promise(i);function i(c,d){const u=Ed(n),h=l.parse(u);l.run(h,u,function(x,p,g){if(x||!p||!g)return f(x);const b=p,w=l.stringify(b,g);_3(w)?g.value=w:g.result=w,f(x,g)});function f(x,p){x||!p?d(x):c?c(p):s(void 0,p)}}}processSync(n){let s=!1,l;return this.freeze(),eh("processSync",this.parser||this.Parser),th("processSync",this.compiler||this.Compiler),this.process(n,i),Ty("processSync","process",s),l;function i(c,d){s=!0,ky(c),l=d}}run(n,s,l){Ey(n),this.freeze();const i=this.transformers;return!l&&typeof s=="function"&&(l=s,s=void 0),l?c(void 0,l):new Promise(c);function c(d,u){const h=Ed(s);i.run(n,h,f);function f(x,p,g){const b=p||n;x?u(x):d?d(b):l(void 0,b,g)}}}runSync(n,s){let l=!1,i;return this.run(n,s,c),Ty("runSync","run",l),i;function c(d,u){ky(d),i=u,l=!0}}stringify(n,s){this.freeze();const l=Ed(s),i=this.compiler||this.Compiler;return th("stringify",i),Ey(n),i(n,l)}use(n,...s){const l=this.attachers,i=this.namespace;if(nh("use",this.frozen),n!=null)if(typeof n=="function")h(n,s);else if(typeof n=="object")Array.isArray(n)?u(n):d(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function c(f){if(typeof f=="function")h(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[x,...p]=f;h(x,p)}else d(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function d(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");u(f.plugins),f.settings&&(i.settings=Wm(!0,i.settings,f.settings))}function u(f){let x=-1;if(f!=null)if(Array.isArray(f))for(;++x<f.length;){const p=f[x];c(p)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function h(f,x){let p=-1,g=-1;for(;++p<l.length;)if(l[p][0]===f){g=p;break}if(g===-1)l.push([f,...x]);else if(x.length>0){let[b,...w]=x;const k=l[g][1];Vh(k)&&Vh(b)&&(b=Wm(!0,k,b)),l[g]=[f,b,...w]}}}}const T3=new Hx().freeze();function eh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function th(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function nh(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ey(e){if(!Vh(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ty(e,n,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Ed(e){return A3(e)?e:new Ij(e)}function A3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function _3(e){return typeof e=="string"||M3(e)}function M3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const R3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ay=[],_y={allowDangerousHtml:!0},O3=/^(https?|ircs?|mailto|xmpp)$/i,D3=[{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 My(e){const n=L3(e),s=I3(e);return z3(n.runSync(n.parse(s),s),e)}function L3(e){const n=e.rehypePlugins||Ay,s=e.remarkPlugins||Ay,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,..._y}:_y;return T3().use(pE).use(s).use(d3,l).use(n)}function I3(e){const n=e.children||"",s=new Ij;return typeof n=="string"&&(s.value=n),s}function z3(e,n){const s=n.allowedElements,l=n.allowElement,i=n.components,c=n.disallowedElements,d=n.skipHtml,u=n.unwrapDisallowed,h=n.urlTransform||$3;for(const x of D3)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+R3+x.id,void 0);return Bx(e,f),Jk(e,{Fragment:t.Fragment,components:i,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(x,p,g){if(x.type==="raw"&&g&&typeof p=="number")return d?g.children.splice(p,1):g.children[p]={type:"text",value:x.value},p;if(x.type==="element"){let b;for(b in Ym)if(Object.hasOwn(Ym,b)&&Object.hasOwn(x.properties,b)){const w=x.properties[b],k=Ym[b];(k===null||k.includes(x.tagName))&&(x.properties[b]=h(String(w||""),b,x))}}if(x.type==="element"){let b=s?!s.includes(x.tagName):c?c.includes(x.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(x,p,g)),b&&g&&typeof p=="number")return u&&x.children?g.children.splice(p,1,...x.children):g.children.splice(p,1),p}}}function $3(e){const n=e.indexOf(":"),s=e.indexOf("?"),l=e.indexOf("#"),i=e.indexOf("/");return n===-1||i!==-1&&n>i||s!==-1&&n>s||l!==-1&&n>l||O3.test(e.slice(0,n))?e:""}function Ry(e,n){const s=String(e);if(typeof n!="string")throw new TypeError("Expected character");let l=0,i=s.indexOf(n);for(;i!==-1;)l++,i=s.indexOf(n,i+n.length);return l}function B3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function H3(e,n,s){const i=ku((s||{}).ignore||[]),c=P3(n);let d=-1;for(;++d<c.length;)Lj(e,"text",u);function u(f,x){let p=-1,g;for(;++p<x.length;){const b=x[p],w=g?g.children:void 0;if(i(b,w?w.indexOf(b):void 0,g))return;g=b}if(g)return h(f,x)}function h(f,x){const p=x[x.length-1],g=c[d][0],b=c[d][1];let w=0;const C=p.children.indexOf(f);let E=!1,M=[];g.lastIndex=0;let N=g.exec(f.value);for(;N;){const A=N.index,R={index:N.index,input:N.input,stack:[...x,f]};let _=b(...N,R);if(typeof _=="string"&&(_=_.length>0?{type:"text",value:_}:void 0),_===!1?g.lastIndex=A+1:(w!==A&&M.push({type:"text",value:f.value.slice(w,A)}),Array.isArray(_)?M.push(..._):_&&M.push(_),w=A+N[0].length,E=!0),!g.global)break;N=g.exec(f.value)}return E?(w<f.value.length&&M.push({type:"text",value:f.value.slice(w)}),p.children.splice(C,1,...M)):M=[f],C+M.length}}function P3(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const s=!e[0]||Array.isArray(e[0])?e:[e];let l=-1;for(;++l<s.length;){const i=s[l];n.push([U3(i[0]),q3(i[1])])}return n}function U3(e){return typeof e=="string"?new RegExp(B3(e),"g"):e}function q3(e){return typeof e=="function"?e:function(){return e}}const rh="phrasing",sh=["autolink","link","image","label"];function F3(){return{transforms:[Z3],enter:{literalAutolink:Y3,literalAutolinkEmail:ah,literalAutolinkHttp:ah,literalAutolinkWww:ah},exit:{literalAutolink:W3,literalAutolinkEmail:K3,literalAutolinkHttp:G3,literalAutolinkWww:X3}}}function V3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:rh,notInConstruct:sh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:rh,notInConstruct:sh},{character:":",before:"[ps]",after:"\\/",inConstruct:rh,notInConstruct:sh}]}}function Y3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ah(e){this.config.enter.autolinkProtocol.call(this,e)}function G3(e){this.config.exit.autolinkProtocol.call(this,e)}function X3(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function K3(e){this.config.exit.autolinkEmail.call(this,e)}function W3(e){this.exit(e)}function Z3(e){H3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Q3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),J3]],{ignore:["link","linkReference"]})}function Q3(e,n,s,l,i){let c="";if(!zj(i)||(/^w/i.test(n)&&(s=n+s,n="",c="http://"),!e4(s)))return!1;const d=t4(s+l);if(!d[0])return!1;const u={type:"link",title:null,url:c+n+d[0],children:[{type:"text",value:n+d[0]}]};return d[1]?[u,{type:"text",value:d[1]}]:u}function J3(e,n,s,l){return!zj(l,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+s,children:[{type:"text",value:n+"@"+s}]}}function e4(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 t4(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let s=n[0],l=s.indexOf(")");const i=Ry(e,"(");let c=Ry(e,")");for(;l!==-1&&i>c;)e+=s.slice(0,l+1),s=s.slice(l+1),l=s.indexOf(")"),c++;return[e,s]}function zj(e,n){const s=e.input.charCodeAt(e.index-1);return(e.index===0||Ol(s)||ju(s))&&(!n||s!==47)}$j.peek=d4;function n4(){this.buffer()}function r4(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function s4(){this.buffer()}function a4(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function l4(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=_s(this.sliceSerialize(e)).toLowerCase(),s.label=n}function i4(e){this.exit(e)}function o4(e){const n=this.resume(),s=this.stack[this.stack.length-1];s.type,s.identifier=_s(this.sliceSerialize(e)).toLowerCase(),s.label=n}function c4(e){this.exit(e)}function d4(){return"["}function $j(e,n,s,l){const i=s.createTracker(l);let c=i.move("[^");const d=s.enter("footnoteReference"),u=s.enter("reference");return c+=i.move(s.safe(s.associationId(e),{after:"]",before:c})),u(),d(),c+=i.move("]"),c}function u4(){return{enter:{gfmFootnoteCallString:n4,gfmFootnoteCall:r4,gfmFootnoteDefinitionLabelString:s4,gfmFootnoteDefinition:a4},exit:{gfmFootnoteCallString:l4,gfmFootnoteCall:i4,gfmFootnoteDefinitionLabelString:o4,gfmFootnoteDefinition:c4}}}function f4(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:s,footnoteReference:$j},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(l,i,c,d){const u=c.createTracker(d);let h=u.move("[^");const f=c.enter("footnoteDefinition"),x=c.enter("label");return h+=u.move(c.safe(c.associationId(l),{before:h,after:"]"})),x(),h+=u.move("]:"),l.children&&l.children.length>0&&(u.shift(4),h+=u.move((n?`
|
|
24
|
+
`:" ")+c.indentLines(c.containerFlow(l,u.current()),n?Bj:m4))),f(),h}}function m4(e,n,s){return n===0?e:Bj(e,n,s)}function Bj(e,n,s){return(s?"":" ")+e}const h4=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Hj.peek=y4;function x4(){return{canContainEols:["delete"],enter:{strikethrough:g4},exit:{strikethrough:b4}}}function p4(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:h4}],handlers:{delete:Hj}}}function g4(e){this.enter({type:"delete",children:[]},e)}function b4(e){this.exit(e)}function Hj(e,n,s,l){const i=s.createTracker(l),c=s.enter("strikethrough");let d=i.move("~~");return d+=s.containerPhrasing(e,{...i.current(),before:d,after:"~"}),d+=i.move("~~"),c(),d}function y4(){return"~"}function v4(e){return e.length}function j4(e,n){const s=n||{},l=(s.align||[]).concat(),i=s.stringLength||v4,c=[],d=[],u=[],h=[];let f=0,x=-1;for(;++x<e.length;){const k=[],C=[];let E=-1;for(e[x].length>f&&(f=e[x].length);++E<e[x].length;){const M=w4(e[x][E]);if(s.alignDelimiters!==!1){const N=i(M);C[E]=N,(h[E]===void 0||N>h[E])&&(h[E]=N)}k.push(M)}d[x]=k,u[x]=C}let p=-1;if(typeof l=="object"&&"length"in l)for(;++p<f;)c[p]=Oy(l[p]);else{const k=Oy(l);for(;++p<f;)c[p]=k}p=-1;const g=[],b=[];for(;++p<f;){const k=c[p];let C="",E="";k===99?(C=":",E=":"):k===108?C=":":k===114&&(E=":");let M=s.alignDelimiters===!1?1:Math.max(1,h[p]-C.length-E.length);const N=C+"-".repeat(M)+E;s.alignDelimiters!==!1&&(M=C.length+M+E.length,M>h[p]&&(h[p]=M),b[p]=M),g[p]=N}d.splice(1,0,g),u.splice(1,0,b),x=-1;const w=[];for(;++x<d.length;){const k=d[x],C=u[x];p=-1;const E=[];for(;++p<f;){const M=k[p]||"";let N="",A="";if(s.alignDelimiters!==!1){const R=h[p]-(C[p]||0),_=c[p];_===114?N=" ".repeat(R):_===99?R%2?(N=" ".repeat(R/2+.5),A=" ".repeat(R/2-.5)):(N=" ".repeat(R/2),A=N):A=" ".repeat(R)}s.delimiterStart!==!1&&!p&&E.push("|"),s.padding!==!1&&!(s.alignDelimiters===!1&&M==="")&&(s.delimiterStart!==!1||p)&&E.push(" "),s.alignDelimiters!==!1&&E.push(N),E.push(M),s.alignDelimiters!==!1&&E.push(A),s.padding!==!1&&E.push(" "),(s.delimiterEnd!==!1||p!==f-1)&&E.push("|")}w.push(s.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return w.join(`
|
|
25
|
+
`)}function w4(e){return e==null?"":String(e)}function Oy(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function N4(e,n,s,l){const i=s.enter("blockquote"),c=s.createTracker(l);c.move("> "),c.shift(2);const d=s.indentLines(s.containerFlow(e,c.current()),k4);return i(),d}function k4(e,n,s){return">"+(s?"":" ")+e}function S4(e,n){return Dy(e,n.inConstruct,!0)&&!Dy(e,n.notInConstruct,!1)}function Dy(e,n,s){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return s;let l=-1;for(;++l<n.length;)if(e.includes(n[l]))return!0;return!1}function Ly(e,n,s,l){let i=-1;for(;++i<s.unsafe.length;)if(s.unsafe[i].character===`
|
|
26
|
+
`&&S4(s.stack,s.unsafe[i]))return/[ \t]/.test(l.before)?"":" ";return`\\
|
|
27
|
+
`}function C4(e,n){const s=String(e);let l=s.indexOf(n),i=l,c=0,d=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;l!==-1;)l===i?++c>d&&(d=c):c=1,i=l+n.length,l=s.indexOf(n,i);return d}function E4(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 T4(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 A4(e,n,s,l){const i=T4(s),c=e.value||"",d=i==="`"?"GraveAccent":"Tilde";if(E4(e,s)){const p=s.enter("codeIndented"),g=s.indentLines(c,_4);return p(),g}const u=s.createTracker(l),h=i.repeat(Math.max(C4(c,i)+1,3)),f=s.enter("codeFenced");let x=u.move(h);if(e.lang){const p=s.enter(`codeFencedLang${d}`);x+=u.move(s.safe(e.lang,{before:x,after:" ",encode:["`"],...u.current()})),p()}if(e.lang&&e.meta){const p=s.enter(`codeFencedMeta${d}`);x+=u.move(" "),x+=u.move(s.safe(e.meta,{before:x,after:`
|
|
28
|
+
`,encode:["`"],...u.current()})),p()}return x+=u.move(`
|
|
29
|
+
`),c&&(x+=u.move(c+`
|
|
30
|
+
`)),x+=u.move(h),f(),x}function _4(e,n,s){return(s?"":" ")+e}function Px(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 M4(e,n,s,l){const i=Px(s),c=i==='"'?"Quote":"Apostrophe",d=s.enter("definition");let u=s.enter("label");const h=s.createTracker(l);let f=h.move("[");return f+=h.move(s.safe(s.associationId(e),{before:f,after:"]",...h.current()})),f+=h.move("]: "),u(),!e.url||/[\0- \u007F]/.test(e.url)?(u=s.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(s.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(u=s.enter("destinationRaw"),f+=h.move(s.safe(e.url,{before:f,after:e.title?" ":`
|
|
31
|
+
`,...h.current()}))),u(),e.title&&(u=s.enter(`title${c}`),f+=h.move(" "+i),f+=h.move(s.safe(e.title,{before:f,after:i,...h.current()})),f+=h.move(i),u()),d(),f}function R4(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 Qo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function tu(e,n,s){const l=Mi(e),i=Mi(n);return l===void 0?i===void 0?s==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Pj.peek=O4;function Pj(e,n,s,l){const i=R4(s),c=s.enter("emphasis"),d=s.createTracker(l),u=d.move(i);let h=d.move(s.containerPhrasing(e,{after:i,before:u,...d.current()}));const f=h.charCodeAt(0),x=tu(l.before.charCodeAt(l.before.length-1),f,i);x.inside&&(h=Qo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=tu(l.after.charCodeAt(0),p,i);g.inside&&(h=h.slice(0,-1)+Qo(p));const b=d.move(i);return c(),s.attentionEncodeSurroundingInfo={after:g.outside,before:x.outside},u+h+b}function O4(e,n,s){return s.options.emphasis||"*"}function D4(e,n){let s=!1;return Bx(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return s=!0,qh}),!!((!e.depth||e.depth<3)&&Rx(e)&&(n.options.setext||s))}function L4(e,n,s,l){const i=Math.max(Math.min(6,e.depth||1),1),c=s.createTracker(l);if(D4(e,s)){const x=s.enter("headingSetext"),p=s.enter("phrasing"),g=s.containerPhrasing(e,{...c.current(),before:`
|
|
32
|
+
`,after:`
|
|
33
|
+
`});return p(),x(),g+`
|
|
34
|
+
`+(i===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
|
|
35
|
+
`))+1))}const d="#".repeat(i),u=s.enter("headingAtx"),h=s.enter("phrasing");c.move(d+" ");let f=s.containerPhrasing(e,{before:"# ",after:`
|
|
36
|
+
`,...c.current()});return/^[\t ]/.test(f)&&(f=Qo(f.charCodeAt(0))+f.slice(1)),f=f?d+" "+f:d,s.options.closeAtx&&(f+=" "+d),h(),u(),f}Uj.peek=I4;function Uj(e){return e.value||""}function I4(){return"<"}qj.peek=z4;function qj(e,n,s,l){const i=Px(s),c=i==='"'?"Quote":"Apostrophe",d=s.enter("image");let u=s.enter("label");const h=s.createTracker(l);let f=h.move("![");return f+=h.move(s.safe(e.alt,{before:f,after:"]",...h.current()})),f+=h.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=s.enter("destinationLiteral"),f+=h.move("<"),f+=h.move(s.safe(e.url,{before:f,after:">",...h.current()})),f+=h.move(">")):(u=s.enter("destinationRaw"),f+=h.move(s.safe(e.url,{before:f,after:e.title?" ":")",...h.current()}))),u(),e.title&&(u=s.enter(`title${c}`),f+=h.move(" "+i),f+=h.move(s.safe(e.title,{before:f,after:i,...h.current()})),f+=h.move(i),u()),f+=h.move(")"),d(),f}function z4(){return"!"}Fj.peek=$4;function Fj(e,n,s,l){const i=e.referenceType,c=s.enter("imageReference");let d=s.enter("label");const u=s.createTracker(l);let h=u.move("![");const f=s.safe(e.alt,{before:h,after:"]",...u.current()});h+=u.move(f+"]["),d();const x=s.stack;s.stack=[],d=s.enter("reference");const p=s.safe(s.associationId(e),{before:h,after:"]",...u.current()});return d(),s.stack=x,c(),i==="full"||!f||f!==p?h+=u.move(p+"]"):i==="shortcut"?h=h.slice(0,-1):h+=u.move("]"),h}function $4(){return"!"}Vj.peek=B4;function Vj(e,n,s){let l=e.value||"",i="`",c=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(l);)i+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++c<s.unsafe.length;){const d=s.unsafe[c],u=s.compilePattern(d);let h;if(d.atBreak)for(;h=u.exec(l);){let f=h.index;l.charCodeAt(f)===10&&l.charCodeAt(f-1)===13&&f--,l=l.slice(0,f)+" "+l.slice(h.index+1)}}return i+l+i}function B4(){return"`"}function Yj(e,n){const s=Rx(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))}Gj.peek=H4;function Gj(e,n,s,l){const i=Px(s),c=i==='"'?"Quote":"Apostrophe",d=s.createTracker(l);let u,h;if(Yj(e,s)){const x=s.stack;s.stack=[],u=s.enter("autolink");let p=d.move("<");return p+=d.move(s.containerPhrasing(e,{before:p,after:">",...d.current()})),p+=d.move(">"),u(),s.stack=x,p}u=s.enter("link"),h=s.enter("label");let f=d.move("[");return f+=d.move(s.containerPhrasing(e,{before:f,after:"](",...d.current()})),f+=d.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=s.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(s.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(h=s.enter("destinationRaw"),f+=d.move(s.safe(e.url,{before:f,after:e.title?" ":")",...d.current()}))),h(),e.title&&(h=s.enter(`title${c}`),f+=d.move(" "+i),f+=d.move(s.safe(e.title,{before:f,after:i,...d.current()})),f+=d.move(i),h()),f+=d.move(")"),u(),f}function H4(e,n,s){return Yj(e,s)?"<":"["}Xj.peek=P4;function Xj(e,n,s,l){const i=e.referenceType,c=s.enter("linkReference");let d=s.enter("label");const u=s.createTracker(l);let h=u.move("[");const f=s.containerPhrasing(e,{before:h,after:"]",...u.current()});h+=u.move(f+"]["),d();const x=s.stack;s.stack=[],d=s.enter("reference");const p=s.safe(s.associationId(e),{before:h,after:"]",...u.current()});return d(),s.stack=x,c(),i==="full"||!f||f!==p?h+=u.move(p+"]"):i==="shortcut"?h=h.slice(0,-1):h+=u.move("]"),h}function P4(){return"["}function Ux(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function U4(e){const n=Ux(e),s=e.options.bulletOther;if(!s)return n==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+s+"`) to be different");return s}function q4(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 Kj(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 F4(e,n,s,l){const i=s.enter("list"),c=s.bulletCurrent;let d=e.ordered?q4(s):Ux(s);const u=e.ordered?d==="."?")":".":U4(s);let h=n&&s.bulletLastUsed?d===s.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&x&&(!x.children||!x.children[0])&&s.stack[s.stack.length-1]==="list"&&s.stack[s.stack.length-2]==="listItem"&&s.stack[s.stack.length-3]==="list"&&s.stack[s.stack.length-4]==="listItem"&&s.indexStack[s.indexStack.length-1]===0&&s.indexStack[s.indexStack.length-2]===0&&s.indexStack[s.indexStack.length-3]===0&&(h=!0),Kj(s)===d&&x){let p=-1;for(;++p<e.children.length;){const g=e.children[p];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(d=u),s.bulletCurrent=d;const f=s.containerFlow(e,l);return s.bulletLastUsed=d,s.bulletCurrent=c,i(),f}function V4(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function Y4(e,n,s,l){const i=V4(s);let c=s.bulletCurrent||Ux(s);n&&n.type==="list"&&n.ordered&&(c=(typeof n.start=="number"&&n.start>-1?n.start:1)+(s.options.incrementListMarker===!1?0:n.children.indexOf(e))+c);let d=c.length+1;(i==="tab"||i==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(d=Math.ceil(d/4)*4);const u=s.createTracker(l);u.move(c+" ".repeat(d-c.length)),u.shift(d);const h=s.enter("listItem"),f=s.indentLines(s.containerFlow(e,u.current()),x);return h(),f;function x(p,g,b){return g?(b?"":" ".repeat(d))+p:(b?c:c+" ".repeat(d-c.length))+p}}function G4(e,n,s,l){const i=s.enter("paragraph"),c=s.enter("phrasing"),d=s.containerPhrasing(e,l);return c(),i(),d}const X4=ku(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function K4(e,n,s,l){return(e.children.some(function(d){return X4(d)})?s.containerPhrasing:s.containerFlow).call(s,e,l)}function W4(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}Wj.peek=Z4;function Wj(e,n,s,l){const i=W4(s),c=s.enter("strong"),d=s.createTracker(l),u=d.move(i+i);let h=d.move(s.containerPhrasing(e,{after:i,before:u,...d.current()}));const f=h.charCodeAt(0),x=tu(l.before.charCodeAt(l.before.length-1),f,i);x.inside&&(h=Qo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=tu(l.after.charCodeAt(0),p,i);g.inside&&(h=h.slice(0,-1)+Qo(p));const b=d.move(i+i);return c(),s.attentionEncodeSurroundingInfo={after:g.outside,before:x.outside},u+h+b}function Z4(e,n,s){return s.options.strong||"*"}function Q4(e,n,s,l){return s.safe(e.value,l)}function J4(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 eT(e,n,s){const l=(Kj(s)+(s.options.ruleSpaces?" ":"")).repeat(J4(s));return s.options.ruleSpaces?l.slice(0,-1):l}const Zj={blockquote:N4,break:Ly,code:A4,definition:M4,emphasis:Pj,hardBreak:Ly,heading:L4,html:Uj,image:qj,imageReference:Fj,inlineCode:Vj,link:Gj,linkReference:Xj,list:F4,listItem:Y4,paragraph:G4,root:K4,strong:Wj,text:Q4,thematicBreak:eT};function tT(){return{enter:{table:nT,tableData:Iy,tableHeader:Iy,tableRow:sT},exit:{codeText:aT,table:rT,tableData:lh,tableHeader:lh,tableRow:lh}}}function nT(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 rT(e){this.exit(e),this.data.inTable=void 0}function sT(e){this.enter({type:"tableRow",children:[]},e)}function lh(e){this.exit(e)}function Iy(e){this.enter({type:"tableCell",children:[]},e)}function aT(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,lT));const s=this.stack[this.stack.length-1];s.type,s.value=n,this.exit(e)}function lT(e,n){return n==="|"?n:e}function iT(e){const n=e||{},s=n.tableCellPadding,l=n.tablePipeAlign,i=n.stringLength,c=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:d,tableCell:h,tableRow:u}};function d(b,w,k,C){return f(x(b,k,C),b.align)}function u(b,w,k,C){const E=p(b,k,C),M=f([E]);return M.slice(0,M.indexOf(`
|
|
38
|
+
`))}function h(b,w,k,C){const E=k.enter("tableCell"),M=k.enter("phrasing"),N=k.containerPhrasing(b,{...C,before:c,after:c});return M(),E(),N}function f(b,w){return j4(b,{align:w,alignDelimiters:l,padding:s,stringLength:i})}function x(b,w,k){const C=b.children;let E=-1;const M=[],N=w.enter("table");for(;++E<C.length;)M[E]=p(C[E],w,k);return N(),M}function p(b,w,k){const C=b.children;let E=-1;const M=[],N=w.enter("tableRow");for(;++E<C.length;)M[E]=h(C[E],b,w,k);return N(),M}function g(b,w,k){let C=Zj.inlineCode(b,w,k);return k.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function oT(){return{exit:{taskListCheckValueChecked:zy,taskListCheckValueUnchecked:zy,paragraph:dT}}}function cT(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:uT}}}function zy(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function dT(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const l=s.children[0];if(l&&l.type==="text"){const i=n.children;let c=-1,d;for(;++c<i.length;){const u=i[c];if(u.type==="paragraph"){d=u;break}}d===s&&(l.value=l.value.slice(1),l.value.length===0?s.children.shift():s.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,s.position.start=Object.assign({},l.position.start)))}}this.exit(e)}function uT(e,n,s,l){const i=e.children[0],c=typeof e.checked=="boolean"&&i&&i.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",u=s.createTracker(l);c&&u.move(d);let h=Zj.listItem(e,n,s,{...l,...u.current()});return c&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),h;function f(x){return x+d}}function fT(){return[F3(),u4(),x4(),tT(),oT()]}function mT(e){return{extensions:[V3(),f4(e),p4(),iT(e),cT()]}}const hT={tokenize:vT,partial:!0},Qj={tokenize:jT,partial:!0},Jj={tokenize:wT,partial:!0},ew={tokenize:NT,partial:!0},xT={tokenize:kT,partial:!0},tw={name:"wwwAutolink",tokenize:bT,previous:rw},nw={name:"protocolAutolink",tokenize:yT,previous:sw},wa={name:"emailAutolink",tokenize:gT,previous:aw},Ks={};function pT(){return{text:Ks}}let kl=48;for(;kl<123;)Ks[kl]=wa,kl++,kl===58?kl=65:kl===91&&(kl=97);Ks[43]=wa;Ks[45]=wa;Ks[46]=wa;Ks[95]=wa;Ks[72]=[wa,nw];Ks[104]=[wa,nw];Ks[87]=[wa,tw];Ks[119]=[wa,tw];function gT(e,n,s){const l=this;let i,c;return d;function d(p){return!Gh(p)||!aw.call(l,l.previous)||qx(l.events)?s(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(p))}function u(p){return Gh(p)?(e.consume(p),u):p===64?(e.consume(p),h):s(p)}function h(p){return p===46?e.check(xT,x,f)(p):p===45||p===95||Er(p)?(c=!0,e.consume(p),h):x(p)}function f(p){return e.consume(p),i=!0,h}function x(p){return c&&i&&Mr(l.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(p)):s(p)}}function bT(e,n,s){const l=this;return i;function i(d){return d!==87&&d!==119||!rw.call(l,l.previous)||qx(l.events)?s(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(hT,e.attempt(Qj,e.attempt(Jj,c),s),s)(d))}function c(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function yT(e,n,s){const l=this;let i="",c=!1;return d;function d(p){return(p===72||p===104)&&sw.call(l,l.previous)&&!qx(l.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),u):s(p)}function u(p){if(Mr(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),u;if(p===58){const g=i.toLowerCase();if(g==="http"||g==="https")return e.consume(p),h}return s(p)}function h(p){return p===47?(e.consume(p),c?f:(c=!0,h)):s(p)}function f(p){return p===null||Qd(p)||Tn(p)||Ol(p)||ju(p)?s(p):e.attempt(Qj,e.attempt(Jj,x),s)(p)}function x(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(p)}}function vT(e,n,s){let l=0;return i;function i(d){return(d===87||d===119)&&l<3?(l++,e.consume(d),i):d===46&&l===3?(e.consume(d),c):s(d)}function c(d){return d===null?s(d):n(d)}}function jT(e,n,s){let l,i,c;return d;function d(f){return f===46||f===95?e.check(ew,h,u)(f):f===null||Tn(f)||Ol(f)||f!==45&&ju(f)?h(f):(c=!0,e.consume(f),d)}function u(f){return f===95?l=!0:(i=l,l=void 0),e.consume(f),d}function h(f){return i||l||!c?s(f):n(f)}}function wT(e,n){let s=0,l=0;return i;function i(d){return d===40?(s++,e.consume(d),i):d===41&&l<s?c(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(ew,n,c)(d):d===null||Tn(d)||Ol(d)?n(d):(e.consume(d),i)}function c(d){return d===41&&l++,e.consume(d),i}}function NT(e,n,s){return l;function l(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),l):u===38?(e.consume(u),c):u===93?(e.consume(u),i):u===60||u===null||Tn(u)||Ol(u)?n(u):s(u)}function i(u){return u===null||u===40||u===91||Tn(u)||Ol(u)?n(u):l(u)}function c(u){return Mr(u)?d(u):s(u)}function d(u){return u===59?(e.consume(u),l):Mr(u)?(e.consume(u),d):s(u)}}function kT(e,n,s){return l;function l(c){return e.consume(c),i}function i(c){return Er(c)?s(c):n(c)}}function rw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tn(e)}function sw(e){return!Mr(e)}function aw(e){return!(e===47||Gh(e))}function Gh(e){return e===43||e===45||e===46||e===95||Er(e)}function qx(e){let n=e.length,s=!1;for(;n--;){const l=e[n][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){s=!0;break}if(l._gfmAutolinkLiteralWalkedInto){s=!1;break}}return e.length>0&&!s&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const ST={tokenize:OT,partial:!0};function CT(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:_T,continuation:{tokenize:MT},exit:RT}},text:{91:{name:"gfmFootnoteCall",tokenize:AT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ET,resolveTo:TT}}}}function ET(e,n,s){const l=this;let i=l.events.length;const c=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d;for(;i--;){const h=l.events[i][1];if(h.type==="labelImage"){d=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return u;function u(h){if(!d||!d._balanced)return s(h);const f=_s(l.sliceSerialize({start:d.end,end:l.now()}));return f.codePointAt(0)!==94||!c.includes(f.slice(1))?s(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),n(h))}}function TT(e,n){let s=e.length;for(;s--;)if(e[s][1].type==="labelImage"&&e[s][0]==="enter"){e[s][1];break}e[s+1][1].type="data",e[s+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[s+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[s+3][1].end),end:Object.assign({},e[s+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},u=[e[s+1],e[s+2],["enter",l,n],e[s+3],e[s+4],["enter",i,n],["exit",i,n],["enter",c,n],["enter",d,n],["exit",d,n],["exit",c,n],e[e.length-2],e[e.length-1],["exit",l,n]];return e.splice(s,e.length-s+1,...u),e}function AT(e,n,s){const l=this,i=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c=0,d;return u;function u(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),h}function h(p){return p!==94?s(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(c>999||p===93&&!d||p===null||p===91||Tn(p))return s(p);if(p===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return i.includes(_s(l.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):s(p)}return Tn(p)||(d=!0),c++,e.consume(p),p===92?x:f}function x(p){return p===91||p===92||p===93?(e.consume(p),c++,f):f(p)}}function _T(e,n,s){const l=this,i=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c,d=0,u;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",x):s(w)}function x(w){if(d>999||w===93&&!u||w===null||w===91||Tn(w))return s(w);if(w===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return c=_s(l.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return Tn(w)||(u=!0),d++,e.consume(w),w===92?p:x}function p(w){return w===91||w===92||w===93?(e.consume(w),d++,x):x(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),i.includes(c)||i.push(c),nn(e,b,"gfmFootnoteDefinitionWhitespace")):s(w)}function b(w){return n(w)}}function MT(e,n,s){return e.check(mc,n,e.attempt(ST,n,s))}function RT(e){e.exit("gfmFootnoteDefinition")}function OT(e,n,s){const l=this;return nn(e,i,"gfmFootnoteDefinitionIndent",5);function i(c){const d=l.events[l.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?n(c):s(c)}}function DT(e){let s=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:c,resolveAll:i};return s==null&&(s=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function i(d,u){let h=-1;for(;++h<d.length;)if(d[h][0]==="enter"&&d[h][1].type==="strikethroughSequenceTemporary"&&d[h][1]._close){let f=h;for(;f--;)if(d[f][0]==="exit"&&d[f][1].type==="strikethroughSequenceTemporary"&&d[f][1]._open&&d[h][1].end.offset-d[h][1].start.offset===d[f][1].end.offset-d[f][1].start.offset){d[h][1].type="strikethroughSequence",d[f][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},d[f][1].start),end:Object.assign({},d[h][1].end)},p={type:"strikethroughText",start:Object.assign({},d[f][1].end),end:Object.assign({},d[h][1].start)},g=[["enter",x,u],["enter",d[f][1],u],["exit",d[f][1],u],["enter",p,u]],b=u.parser.constructs.insideSpan.null;b&&ns(g,g.length,0,wu(b,d.slice(f+1,h),u)),ns(g,g.length,0,[["exit",p,u],["enter",d[h][1],u],["exit",d[h][1],u],["exit",x,u]]),ns(d,f-1,h-f+3,g),h=f+g.length-2;break}}for(h=-1;++h<d.length;)d[h][1].type==="strikethroughSequenceTemporary"&&(d[h][1].type="data");return d}function c(d,u,h){const f=this.previous,x=this.events;let p=0;return g;function g(w){return f===126&&x[x.length-1][1].type!=="characterEscape"?h(w):(d.enter("strikethroughSequenceTemporary"),b(w))}function b(w){const k=Mi(f);if(w===126)return p>1?h(w):(d.consume(w),p++,b);if(p<2&&!s)return h(w);const C=d.exit("strikethroughSequenceTemporary"),E=Mi(w);return C._open=!E||E===2&&!!k,C._close=!k||k===2&&!!E,u(w)}}}class LT{constructor(){this.map=[]}add(n,s,l){IT(this,n,s,l)}consume(n){if(this.map.sort(function(c,d){return c[0]-d[0]}),this.map.length===0)return;let s=this.map.length;const l=[];for(;s>0;)s-=1,l.push(n.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),n.length=this.map[s][0];l.push(n.slice()),n.length=0;let i=l.pop();for(;i;){for(const c of i)n.push(c);i=l.pop()}this.map.length=0}}function IT(e,n,s,l){let i=0;if(!(s===0&&l.length===0)){for(;i<e.map.length;){if(e.map[i][0]===n){e.map[i][1]+=s,e.map[i][2].push(...l);return}i+=1}e.map.push([n,s,l])}}function zT(e,n){let s=!1;const l=[];for(;n<e.length;){const i=e[n];if(s){if(i[0]==="enter")i[1].type==="tableContent"&&l.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const c=l.length-1;l[c]=l[c]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(s=!0);n+=1}return l}function $T(){return{flow:{null:{name:"table",tokenize:BT,resolveAll:HT}}}}function BT(e,n,s){const l=this;let i=0,c=0,d;return u;function u(L){let P=l.events.length-1;for(;P>-1;){const T=l.events[P][1].type;if(T==="lineEnding"||T==="linePrefix")P--;else break}const G=P>-1?l.events[P][1].type:null,$=G==="tableHead"||G==="tableRow"?_:h;return $===_&&l.parser.lazy[l.now().line]?s(L):$(L)}function h(L){return e.enter("tableHead"),e.enter("tableRow"),f(L)}function f(L){return L===124||(d=!0,c+=1),x(L)}function x(L){return L===null?s(L):jt(L)?c>1?(c=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),b):s(L):Gt(L)?nn(e,x,"whitespace")(L):(c+=1,d&&(d=!1,i+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),p(L)))}function p(L){return L===null||L===124||Tn(L)?(e.exit("data"),x(L)):(e.consume(L),L===92?g:p)}function g(L){return L===92||L===124?(e.consume(L),p):p(L)}function b(L){return l.interrupt=!1,l.parser.lazy[l.now().line]?s(L):(e.enter("tableDelimiterRow"),d=!1,Gt(L)?nn(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):w(L))}function w(L){return L===45||L===58?C(L):L===124?(d=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),k):R(L)}function k(L){return Gt(L)?nn(e,C,"whitespace")(L):C(L)}function C(L){return L===58?(c+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),E):L===45?(c+=1,E(L)):L===null||jt(L)?A(L):R(L)}function E(L){return L===45?(e.enter("tableDelimiterFiller"),M(L)):R(L)}function M(L){return L===45?(e.consume(L),M):L===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),N):(e.exit("tableDelimiterFiller"),N(L))}function N(L){return Gt(L)?nn(e,A,"whitespace")(L):A(L)}function A(L){return L===124?w(L):L===null||jt(L)?!d||i!==c?R(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(L)):R(L)}function R(L){return s(L)}function _(L){return e.enter("tableRow"),Y(L)}function Y(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),Y):L===null||jt(L)?(e.exit("tableRow"),n(L)):Gt(L)?nn(e,Y,"whitespace")(L):(e.enter("data"),q(L))}function q(L){return L===null||L===124||Tn(L)?(e.exit("data"),Y(L)):(e.consume(L),L===92?X:q)}function X(L){return L===92||L===124?(e.consume(L),q):q(L)}}function HT(e,n){let s=-1,l=!0,i=0,c=[0,0,0,0],d=[0,0,0,0],u=!1,h=0,f,x,p;const g=new LT;for(;++s<e.length;){const b=e[s],w=b[1];b[0]==="enter"?w.type==="tableHead"?(u=!1,h!==0&&($y(g,n,h,f,x),x=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"?(l=!0,p=void 0,c=[0,0,0,0],d=[0,s+1,0,0],u&&(u=!1,x={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(s,0,[["enter",x,n]])),i=w.type==="tableDelimiterRow"?2:x?3:1):i&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(l=!1,d[2]===0&&(c[1]!==0&&(d[0]=d[1],p=Td(g,n,c,i,void 0,p),c=[0,0,0,0]),d[2]=s)):w.type==="tableCellDivider"&&(l?l=!1:(c[1]!==0&&(d[0]=d[1],p=Td(g,n,c,i,void 0,p)),c=d,d=[c[1],s,0,0])):w.type==="tableHead"?(u=!0,h=s):w.type==="tableRow"||w.type==="tableDelimiterRow"?(h=s,c[1]!==0?(d[0]=d[1],p=Td(g,n,c,i,s,p)):d[1]!==0&&(p=Td(g,n,d,i,s,p)),i=0):i&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(d[3]=s)}for(h!==0&&$y(g,n,h,f,x),g.consume(n.events),s=-1;++s<n.events.length;){const b=n.events[s];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=zT(n.events,s))}return e}function Td(e,n,s,l,i,c){const d=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",u="tableContent";s[0]!==0&&(c.end=Object.assign({},Ni(n.events,s[0])),e.add(s[0],0,[["exit",c,n]]));const h=Ni(n.events,s[1]);if(c={type:d,start:Object.assign({},h),end:Object.assign({},h)},e.add(s[1],0,[["enter",c,n]]),s[2]!==0){const f=Ni(n.events,s[2]),x=Ni(n.events,s[3]),p={type:u,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(s[2],0,[["enter",p,n]]),l!==2){const g=n.events[s[2]],b=n.events[s[3]];if(g[1].end=Object.assign({},b[1].end),g[1].type="chunkText",g[1].contentType="text",s[3]>s[2]+1){const w=s[2]+1,k=s[3]-s[2]-1;e.add(w,k,[])}}e.add(s[3]+1,0,[["exit",p,n]])}return i!==void 0&&(c.end=Object.assign({},Ni(n.events,i)),e.add(i,0,[["exit",c,n]]),c=void 0),c}function $y(e,n,s,l,i){const c=[],d=Ni(n.events,s);i&&(i.end=Object.assign({},d),c.push(["exit",i,n])),l.end=Object.assign({},d),c.push(["exit",l,n]),e.add(s+1,0,c)}function Ni(e,n){const s=e[n],l=s[0]==="enter"?"start":"end";return s[1][l]}const PT={name:"tasklistCheck",tokenize:qT};function UT(){return{text:{91:PT}}}function qT(e,n,s){const l=this;return i;function i(h){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?s(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),c)}function c(h){return Tn(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),d):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),d):s(h)}function d(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),u):s(h)}function u(h){return jt(h)?n(h):Gt(h)?e.check({tokenize:FT},n,s)(h):s(h)}}function FT(e,n,s){return nn(e,l,"whitespace");function l(i){return i===null?s(i):n(i)}}function VT(e){return pj([pT(),CT(),DT(e),$T(),UT()])}const YT={};function By(e){const n=this,s=e||YT,l=n.data(),i=l.micromarkExtensions||(l.micromarkExtensions=[]),c=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),d=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);i.push(VT(s)),c.push(fT()),d.push(mT(s))}const GT="modulepreload",XT=function(e){return"/"+e},Hy={},KT=function(n,s,l){let i=Promise.resolve();if(s&&s.length>0){let f=function(x){return Promise.all(x.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};var d=f;document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),h=u?.nonce||u?.getAttribute("nonce");i=f(s.map(x=>{if(x=XT(x),x in Hy)return;Hy[x]=!0;const p=x.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${g}`))return;const b=document.createElement("link");if(b.rel=p?"stylesheet":GT,p||(b.as="script"),b.crossOrigin="",b.href=x,h&&b.setAttribute("nonce",h),document.head.appendChild(b),p)return new Promise((w,k)=>{b.addEventListener("load",w),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${x}`)))})}))}function c(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return i.then(u=>{for(const h of u||[])h.status==="rejected"&&c(h.reason);return n().catch(c)})},WT=y.lazy(()=>KT(()=>Promise.resolve().then(()=>fA),void 0).then(e=>({default:e.MarkdownMessage})));let bi=[],Py=60;function ZT(e){const n=y.useRef(e);n.current=e;const[s]=y.useState(()=>++Py);return y.useEffect(()=>{const l=()=>n.current();bi.push(l);const i=c=>{c.key==="Escape"&&bi[bi.length-1]===l&&(c.preventDefault(),l())};return window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("keydown",i,!0),bi=bi.filter(c=>c!==l),bi.length===0&&(Py=60)}},[]),s}const nu=new Map,ru=new Set,Fd=new Map;let Vd=null;function Uy(e){const n=Fd.get(e);if(n)for(const s of n)s()}function QT(){Vd=null;const e=[...ru];ru.clear(),e.length!==0&&se.files.check(e).then(({results:n})=>{for(const[s,l]of Object.entries(n))nu.set(s,l),Uy(s)}).catch(()=>{for(const n of e)nu.set(n,{exists:!1,isFile:!1,type:"unknown"}),Uy(n)})}function JT(e){nu.has(e)||ru.has(e)||(ru.add(e),Vd&&clearTimeout(Vd),Vd=setTimeout(QT,30))}function eA(e,n){let s=Fd.get(e);return s||(s=new Set,Fd.set(e,s)),s.add(n),()=>{s.delete(n),s.size===0&&Fd.delete(e)}}function tA(e){const n=y.useCallback(i=>eA(e,i),[e]),s=y.useCallback(()=>nu.get(e),[e]),l=y.useSyncExternalStore(n,s,s);return y.useEffect(()=>{JT(e)},[e]),l}const nA=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function rA(e){return e.length<2||e.length>500?!1:nA.test(e)}function sA({filePath:e,onClose:n}){const s=ZT(n),[l,i]=y.useState(!0),[c,d]=y.useState(null),[u,h]=y.useState(""),[f,x]=y.useState(""),[p,g]=y.useState("");y.useEffect(()=>{i(!0),d(null),se.files.preview(e).then(w=>{h(w.content),x(w.type),g(w.name)}).catch(w=>{d(String(w?.message||w))}).finally(()=>{i(!1)})},[e]);const b=p||e.split(/[/\\]/).pop()||e;return vu.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:s},onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:w=>w.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:b}),t.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>se.files.reveal(e),title:"Reveal in file explorer",children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),t.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:n,children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[l&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),c&&t.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[t.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:c})]}),!l&&!c&&f==="markdown"&&t.jsx(y.Suspense,{fallback:t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:t.jsx(WT,{content:u,className:"text-sm"})}),!l&&!c&&f==="image"&&t.jsx("div",{className:"flex justify-center",children:t.jsx("img",{src:`data:image/png;base64,${u}`,alt:b,className:"max-w-full rounded"})}),!l&&!c&&f==="text"&&t.jsx("pre",{className:"text-xs text-fg-secondary font-mono whitespace-pre-wrap break-all leading-relaxed",children:u})]})]})}),document.body)}function aA({path:e}){const n=tA(e),[s,l]=y.useState(null),i=n?.exists??!1,c=n?.type==="markdown",d=y.useCallback(f=>{f.preventDefault(),f.stopPropagation(),i&&(c?l(e):se.files.reveal(e))},[i,c,e]),u="inline w-3 h-3 align-[-0.125em]",h=c?t.jsx("svg",{className:u,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):t.jsx("svg",{className:u,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return n?i?t.jsxs(t.Fragment,{children:[t.jsxs("code",{className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:d,title:c?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[t.jsxs("span",{className:"whitespace-nowrap",children:[h,e.charAt(0)]}),e.slice(1)]}),s&&t.jsx(sA,{filePath:s,onClose:()=>l(null)})]}):t.jsx("code",{className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}function lA(e,n){const s=e.cloneNode(!0),l=n==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},i={p:`margin:0 0 10px;color:${l.text};line-height:1.7;`,h1:`font-size:1.6em;font-weight:700;color:${l.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${l.border};padding-bottom:6px;`,h2:`font-size:1.35em;font-weight:700;color:${l.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:1.15em;font-weight:600;color:${l.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:1em;font-weight:600;color:${l.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${l.strong};`,em:"font-style:italic;",a:`color:${l.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${l.text};`,blockquote:`border-left:3px solid ${l.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${l.blockquoteText};`,hr:`border:none;border-top:1px solid ${l.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${l.tableHeaderBg};`,th:`border:1px solid ${l.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${l.tableHeaderText};`,td:`border:1px solid ${l.tableBorder};padding:8px 12px;color:${l.text};`,img:"max-width:100%;height:auto;"};function c(d){d.removeAttribute("class");const u=d.tagName.toLowerCase();if(u==="pre"){d.setAttribute("style",`background:${l.preBg};color:${l.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${l.preBorder};`);const h=d.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}u==="code"?d.setAttribute("style",`background:${l.codeBg};color:${l.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):i[u]&&d.setAttribute("style",i[u]),Array.from(d.children).forEach(c)}return s.removeAttribute("class"),Array.from(s.children).forEach(d=>c(d)),`<div style="background:${l.bg};color:${l.text};padding:20px 24px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.7;max-width:800px;">${s.innerHTML}</div>`}async function Fx(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const n=document.createElement("textarea");n.value=e,n.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(n),n.select();const s=document.execCommand("copy");return document.body.removeChild(n),s}catch{return!1}}}async function iA(e,n,s){const l=lA(e,n);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([l],{type:"text/html"}),"text/plain":new Blob([s],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Fx(s),method:"text"}}}const oA=/<think>([\s\S]*?)(<\/think>|$)/g;function cA(e){const n=[];let s=e.replace(oA,(l,i)=>{const c=i.trim();return c&&n.push(c),""});return s=s.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:n,rest:s.trim()}}const Xh="#mention:";function dA(e){return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(n,s,l)=>{const i=s??l;return`[@${i}](${Xh}${encodeURIComponent(i)})`})}const ih={p:({children:e})=>t.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",children:e}),h1:({children:e})=>t.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0",children:e}),h2:({children:e})=>t.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0",children:e}),h3:({children:e})=>t.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0",children:e}),ul:({children:e})=>t.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e})=>t.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:e}),li:({children:e})=>t.jsx("li",{className:"leading-relaxed",children:e}),code:({children:e,className:n})=>{if(n?.includes("language-"))return t.jsx("code",{className:"text-fg-secondary font-mono",children:e});const s=typeof e=="string"?e:String(e??"");return rA(s)?t.jsx(aA,{path:s}):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 uA({content:e,contentRef:n}){const[s,l]=y.useState(!1),[i,c]=y.useState(null),d=y.useRef(null);y.useEffect(()=>{if(!s)return;const x=p=>{d.current&&!d.current.contains(p.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[s]);const u=y.useCallback(x=>{c(x),setTimeout(()=>c(null),1500)},[]),h=async()=>{const x=await Fx(e);u(x?"Copied!":"Failed"),l(!1)},f=async x=>{const p=n.current?.firstElementChild;if(!p)return;const g=await iA(p,x,e);u(g.ok?g.method==="html"?`HTML (${x}) copied`:"Text copied":"Failed"),l(!1)};return t.jsxs("div",{className:"absolute -top-1 -right-1 z-10",ref:d,children:[i&&t.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:i}),t.jsx("button",{onClick:()=>l(x=>!x),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"})})}),s&&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:h,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:()=>f("light"),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 text-[10px]",children:"☀️"}),"Copy HTML (Light)"]}),t.jsxs("button",{onClick:()=>f("dark"),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 text-[10px]",children:"🌙"}),"Copy HTML (Dark)"]})]})]})}function Fn({content:e,className:n="",onMentionClick:s}){const{thinking:l,rest:i}=cA(e),c=y.useRef(null),d=y.useMemo(()=>s?dA(i):i,[i,s]),u=y.useMemo(()=>s?{...ih,a:({href:h,children:f})=>{if(h?.startsWith(Xh)){const x=decodeURIComponent(h.slice(Xh.length));return t.jsx("span",{className:"text-brand-500 font-medium cursor-pointer hover:underline",onClick:p=>{p.preventDefault(),p.stopPropagation(),s(x,p)},title:x,children:f})}return t.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:f})}}:ih,[s]);return t.jsxs("div",{className:"relative group/md",children:[t.jsx(uA,{content:e,contentRef:c}),t.jsx("div",{ref:c,children:t.jsxs("div",{className:`prose prose-sm max-w-none break-words ${n}`,children:[l.length>0&&(()=>{const h=l.join(`
|
|
39
|
+
|
|
40
|
+
`),f=h.split(`
|
|
41
|
+
`)[0]??"",x=f.length>80?f.slice(0,80)+"…":f;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:"Thinking"}),t.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:x})]}),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(My,{remarkPlugins:[By],components:ih,children:h})})})]})})(),t.jsx(My,{remarkPlugins:[By],components:u,children:d})]})})]})}const fA=Object.freeze(Object.defineProperty({__proto__:null,MarkdownMessage:Fn},Symbol.toStringTag,{value:"Module"})),qy={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},oh={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_review:"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_failed:"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",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_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",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},mA={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",system:"text-fg-tertiary"};function Fy(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const l=Math.floor(s/60);return l<24?`${l}h`:`${Math.floor(l/24)}d`}function Vy(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":return s.taskId?"View task →":null;case"requirement_created":case"requirement_decision":return s.requirementId?"View requirement →":null;case"agent_report":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 hA(){try{const e=new AudioContext,n=e.currentTime,s=e.createGain();s.connect(e.destination),s.gain.setValueAtTime(.15,n),s.gain.exponentialRampToValueAtTime(.01,n+.6);const l=e.createOscillator();l.type="sine",l.frequency.setValueAtTime(880,n),l.frequency.setValueAtTime(1174.66,n+.15),l.connect(s),l.start(n),l.stop(n+.6),l.onended=()=>e.close()}catch{}}function Kh({collapsed:e,userId:n}){const[s,l]=y.useState(!1),[i,c]=y.useState("approvals"),[d,u]=y.useState([]),[h,f]=y.useState([]),[x,p]=y.useState(null),[g,b]=y.useState(null),[w,k]=y.useState(""),[C,E]=y.useState({}),[M,N]=y.useState(0),A=y.useRef(null),R=y.useRef(null),[_,Y]=y.useState({top:0,left:0,width:448,maxHeight:576}),q=y.useRef(null),X=y.useCallback(async()=>{try{const[S,D]=await Promise.all([se.notifications.list(n,!1),se.approvals.list()]);u(S.notifications),N(S.unreadCount??S.notifications.filter(W=>!W.read).length),f(D.approvals)}catch{}},[n]);y.useEffect(()=>{X();const S=setInterval(X,15e3),D=()=>X();return window.addEventListener("markus:notifications-changed",D),()=>{clearInterval(S),window.removeEventListener("markus:notifications-changed",D)}},[X]);const L=y.useCallback(()=>{if(!A.current)return;const S=A.current.getBoundingClientRect(),D=window.innerWidth,W=window.innerHeight,J=Math.min(448,D-16),te=Math.min(576,W-16);let re=S.right+8,oe=S.top;re+J>D-8&&(re=Math.max(8,D-J-8)),oe+te>W-8&&(oe=Math.max(8,W-te-8)),Y({top:oe,left:re,width:J,maxHeight:te})},[]);y.useLayoutEffect(()=>{s&&L()},[s,L]),y.useEffect(()=>{if(s)return window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[s,L]),y.useEffect(()=>{if(!s)return;const S=D=>{A.current?.contains(D.target)||R.current?.contains(D.target)||l(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[s]);const P=new Set(h.filter(S=>S.status==="pending").map(S=>S.id)),G=new Set(h.map(S=>S.id)),$=d.filter(S=>!(S.type==="approval_request"&&S.metadata?.approvalId&&G.has(S.metadata.approvalId))),T=d.filter(S=>S.type==="approval_request"&&!S.read&&S.metadata?.approvalId&&P.has(S.metadata.approvalId)).length,z=Math.max(0,M-T),O=P.size,V=z+O;y.useEffect(()=>{q.current!==null&&O>q.current&&hA(),q.current=O},[O]);const H=async S=>{await se.notifications.markRead(S),u(D=>D.map(W=>W.id===S?{...W,read:!0}:W)),N(D=>Math.max(0,D-1))},Z=S=>{const D=S.metadata??{},W=S.actionType,J=S.actionTarget;if(W==="open_chat"&&J)try{const te=typeof J=="string"?JSON.parse(J):J;if(te.agentId){const re={agentId:te.agentId};te.sessionId&&(re.sessionId=te.sessionId),bt.navigate(ge.TEAM,re);return}}catch{}if(W==="navigate"&&J)try{const te=typeof J=="string"?JSON.parse(J):J;if(te.path&&te.path.startsWith("/work")){const re={},oe=new URLSearchParams(te.path.split("?")[1]||"");for(const[me,Oe]of oe.entries())re[me]=Oe;bt.navigate(ge.WORK,re);return}}catch{}switch(S.type){case"approval_request":{const te=D.approvalId,re=te?h.find(Oe=>Oe.id===te):void 0,oe=re?.details?.taskId??D.taskId,me=re?.details?.agentId??re?.agentId;oe?bt.navigate(ge.WORK,{openTask:oe}):me?bt.navigate(ge.TEAM,{agentId:me}):bt.navigate(ge.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":D.taskId?bt.navigate(ge.WORK,{openTask:D.taskId}):bt.navigate(ge.WORK);break;case"requirement_created":case"requirement_decision":D.requirementId?bt.navigate(ge.WORK,{openRequirement:D.requirementId}):bt.navigate(ge.WORK);break;case"agent_report":case"system":{if(D.agentId){const te={agentId:D.agentId};D.sessionId&&(te.sessionId=D.sessionId),bt.navigate(ge.TEAM,te)}else bt.navigate(ge.TEAM);break}default:D.taskId?bt.navigate(ge.WORK,{openTask:D.taskId}):D.requirementId?bt.navigate(ge.WORK,{openRequirement:D.requirementId}):D.projectId?bt.navigate(ge.WORK,{projectId:D.projectId}):D.agentId&&bt.navigate(ge.TEAM,{agentId:D.agentId});break}},B=async S=>{S.read||H(S.id);const D=S.metadata??{},W=D.taskId,J=D.requirementId;if(W||J){const te=d.filter(re=>re.id!==S.id&&!re.read&&(W&&re.metadata?.taskId===W||J&&re.metadata?.requirementId===J));for(const re of te)H(re.id)}Z(S)},F=async(S,D,W,J)=>{p(S);try{const{approval:te}=await se.approvals.respond(S,D,n,W,J);f(oe=>oe.map(me=>me.id===S?te:me)),b(null),k(""),E(oe=>{const me={...oe};return delete me[S],me});const re=d.find(oe=>oe.type==="approval_request"&&oe.metadata?.approvalId===S);re&&!re.read&&(se.notifications.markRead(re.id),u(oe=>oe.map(me=>me.id===re.id?{...me,read:!0}:me)),N(oe=>Math.max(0,oe-1))),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}p(null)},K=async()=>{try{await se.notifications.markAllRead(n??"default"),u(S=>S.map(D=>({...D,read:!0}))),N(0)}catch{const S=$.filter(D=>!D.read);await Promise.all(S.map(D=>se.notifications.markRead(D.id))),u(D=>D.map(W=>({...W,read:!0}))),N(0)}},I=S=>{const D=S.details?.taskId,W=S.details?.agentId??S.agentId;D?bt.navigate(ge.WORK,{openTask:D}):W?bt.navigate(ge.TEAM,{agentId:W}):bt.navigate(ge.WORK)};return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:A,onClick:()=>{l(!s),s||X()},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"})]}),V>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:V>99?"99+":V})]}),s&&vu.createPortal(t.jsxs("div",{ref:R,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:_.top,left:_.left,width:_.width,maxHeight:_.maxHeight},children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>c("approvals"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${i==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Approvals",O>0?` (${O})`:""]}),t.jsxs("button",{onClick:()=>c("notifications"),className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${i==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Notifications",z>0?` (${z})`:""]}),t.jsx("button",{onClick:()=>l(!1),className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:"Close",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),i==="notifications"&&M>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:K,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:[i==="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(S=>S.status==="pending").map(S=>{const D=S.details?.command,W=D?S.description.replace(/\s*Command:.*$/,""):S.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>I(S),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:oh.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:S.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Fy(S.requestedAt)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:S.agentName})]})]}),t.jsx("div",{className:"mt-2.5 max-h-48 overflow-y-auto text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(Fn,{content:W,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),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 mt-2",children:D})]}),S.options&&S.options.length>0?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"flex flex-wrap gap-1.5",children:S.options.map(J=>t.jsx("button",{disabled:x===S.id,onClick:()=>F(S.id,!0,void 0,J.id),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",title:J.description,children:J.label},J.id))}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("input",{type:"text",placeholder:"Or type your own instruction...",value:C[S.id]??"",onChange:J=>E(te=>({...te,[S.id]:J.target.value})),onKeyDown:J=>{J.key==="Enter"&&(C[S.id]??"").trim()&&F(S.id,!0,(C[S.id]??"").trim(),"custom")},className:"flex-1 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-brand-500/50"}),t.jsx("button",{disabled:x===S.id||!(C[S.id]??"").trim(),onClick:()=>F(S.id,!0,(C[S.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:"Send"})]})]}):g===S.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:J=>k(J.target.value),onKeyDown:J=>{J.key==="Enter"&&F(S.id,!1,w||void 0,"reject"),J.key==="Escape"&&(b(null),k(""))},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:x===S.id,onClick:()=>F(S.id,!1,w||void 0,"reject"),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:()=>{b(null),k("")},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-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:"Or type your own instruction...",value:C[S.id]??"",onChange:J=>E(te=>({...te,[S.id]:J.target.value})),onKeyDown:J=>{J.key==="Enter"&&(C[S.id]??"").trim()&&F(S.id,!0,(C[S.id]??"").trim(),"custom")},className:"flex-1 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-brand-500/50"}),t.jsx("button",{disabled:x===S.id||!(C[S.id]??"").trim(),onClick:()=>F(S.id,!0,(C[S.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:"Send"})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:x===S.id,onClick:()=>F(S.id,!0,void 0,"approve"),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:x===S.id,onClick:()=>{b(S.id),k("")},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"})]}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("input",{type:"text",placeholder:"Or type your own instruction...",value:C[S.id]??"",onChange:J=>E(te=>({...te,[S.id]:J.target.value})),onKeyDown:J=>{J.key==="Enter"&&(C[S.id]??"").trim()&&F(S.id,!0,(C[S.id]??"").trim(),"custom")},className:"flex-1 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-brand-500/50"}),t.jsx("button",{disabled:x===S.id||!(C[S.id]??"").trim(),onClick:()=>F(S.id,!0,(C[S.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:"Send"})]})]})]},S.id)}),h.filter(S=>S.status!=="pending").slice(0,20).map(S=>t.jsxs("button",{onClick:()=>I(S),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 ${S.status==="approved"?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:S.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:S.status})]}),S.responseComment&&t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-3.5 truncate",children:["“",S.responseComment,"”"]})]},S.id))]})),i==="notifications"&&($.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:$.slice(0,50).map(S=>{const D=mA[S.type]??"text-fg-tertiary";return t.jsxs("button",{onClick:()=>B(S),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${S.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:oh[S.type]??oh.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!S.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${qy[S.priority]??qy.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:S.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 max-h-32 overflow-y-auto",children:t.jsx(Fn,{content:S.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Fy(S.createdAt)}),Vy(S)&&t.jsx("span",{className:`text-[10px] font-medium ${D}`,children:Vy(S)})]})]})]},S.id)})}))]})]}),document.body)]})}const xA="(max-width: 767px)";let ch=null;function lw(){return ch||(ch=window.matchMedia(xA)),ch}function pA(e){const n=lw();return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function gA(){return lw().matches}function bA(){return!1}function Yr(){return y.useSyncExternalStore(pA,gA,bA)}function Yy({authUser:e}={}){const n=Yr(),[s,l]=y.useState([]),[i,c]=y.useState([]),[d,u]=y.useState({}),[h,f]=y.useState(null),x="7d",[p,g]=y.useState([]),[b,w]=y.useState(null),k=()=>{se.agents.list().then(L=>l(L.agents)).catch(()=>{}),se.teams.list().then(L=>c(L.teams)).catch(()=>{}),se.tasks.board().then(L=>u(L.board)).catch(()=>{}),se.ops.dashboard(x).then(f).catch(()=>{}),se.requirements.list({source:"agent"}).then(L=>{g(L.requirements.filter(P=>P.status==="pending"))}).catch(()=>{}),se.system.storage().then(w).catch(()=>{})};y.useEffect(()=>{k();const L=setInterval(k,3e4),P=()=>k();return window.addEventListener("markus:data-changed",P),()=>{clearInterval(L),window.removeEventListener("markus:data-changed",P)}},[x]);const C=L=>L,E={};for(const[L,P]of Object.entries(d)){const G=C(P).length;G>0&&(E[L]=G)}const M=E.pending??0,N=E.in_progress??0,A=E.completed??0;E.failed;const R=Object.values(E).reduce((L,P)=>L+P,0),_=s.filter(L=>L.status==="idle"||L.status==="working").length,Y=s.filter(L=>L.status==="working").length,q=s.reduce((L,P)=>L+(P.mailboxDepth??0),0),X=y.useMemo(()=>{const L=new Map(s.map(P=>[P.id,P]));return i.map(P=>{const G=P.members.filter(z=>z.type==="agent").map(z=>L.get(z.id)).filter(z=>!!z),$=G.filter(z=>z.status==="working").length,T=G.filter(z=>z.status==="idle"||z.status==="working").length;return{team:P,agents:G,working:$,active:T,total:G.length}})},[i,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(Kh,{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:()=>bt.navigate(ge.STORE,{storeTab:"agents"}),className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 text-white text-sm rounded-lg transition-colors",children:"+ Hire Agent"})})]}),t.jsxs("div",{className:"p-7 space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsx(Ad,{label:"Active Agents",value:_,total:s.length,color:"indigo",onClick:()=>bt.navigate(ge.TEAM)}),t.jsx(Ad,{label:"Tasks In Progress",value:N,color:"blue",onClick:()=>bt.navigate(ge.WORK)}),t.jsx(Ad,{label:"Pending Queue",value:M,color:"amber",onClick:()=>bt.navigate(ge.WORK)}),t.jsx(Ad,{label:"Completed",value:A,total:R>0?R:void 0,color:"green",onClick:()=>bt.navigate(ge.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:ge.TEAM},{label:"Hire Agents",desc:"Browse templates: developers, researchers, writers, analysts, and more",page:ge.STORE},{label:"Create a Project",desc:"Set up requirements and let agents plan, execute, and deliver",page:ge.WORK}].map(L=>t.jsxs("button",{onClick:()=>bt.navigate(L.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:L.label}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1",children:L.desc})]},L.label))})]}),Y>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"}),q>0&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[q," total queued"]})]}),t.jsx("div",{className:"space-y-1.5",children:s.filter(L=>L.status==="working").map(L=>t.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer transition-colors",onClick:()=>bt.navigate(ge.TEAM,{agentId:L.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:L.name.charAt(0)}),t.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:L.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate flex-1",children:L.currentActivity?.label??"Working..."}),(L.mailboxDepth??0)>0&&t.jsxs("span",{className:"text-[9px] bg-amber-500/20 text-amber-400 rounded-full px-1.5 shrink-0",children:[L.mailboxDepth," queued"]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${L.attentionState==="focused"?"bg-brand-400 animate-pulse":L.attentionState==="deciding"?"bg-amber-400 animate-pulse":"bg-green-400"}`})]},L.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:()=>bt.navigate(ge.WORK),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-4",children:"Task Distribution"}),t.jsx(vA,{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:()=>bt.navigate(ge.TEAM),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),X.length===0&&s.length===0?t.jsx("div",{className:"text-sm text-fg-tertiary py-4 text-center cursor-pointer",onClick:()=>bt.navigate(ge.TEAM),children:"No teams yet. Create a team or hire agents to get started."}):t.jsxs("div",{className:"space-y-4",children:[X.map(L=>t.jsxs("div",{className:"bg-surface-elevated/30 border border-border-default/30 rounded-lg p-4 hover:border-brand-500/20 transition-colors cursor-pointer",onClick:()=>bt.navigate(ge.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:L.team.name.charAt(0)}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium",children:L.team.name}),L.team.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate max-w-[260px]",children:L.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:[L.total," members"]}),L.working>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-500",children:[L.working," working"]}),t.jsxs("span",{className:`px-1.5 py-0.5 rounded ${L.active===L.total?"bg-green-500/15 text-green-600":"bg-surface-overlay/50"}`,children:[L.active," active"]})]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[L.agents.slice(0,6).map(P=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30",onClick:G=>{G.stopPropagation(),bt.navigate(ge.TEAM,{selectAgent:P.id})},children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${P.status==="idle"?"bg-green-400":P.status==="working"?"bg-blue-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:P.name})]},P.id)),L.agents.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",L.agents.length-6," more"]})]})]},L.team.id)),(()=>{const L=new Set(i.flatMap(G=>G.members.filter($=>$.type==="agent").map($=>$.id))),P=s.filter(G=>!L.has(G.id));return P.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:[P.length," agents"]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[P.slice(0,6).map(G=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-surface-overlay/30 cursor-pointer",onClick:()=>bt.navigate(ge.TEAM,{selectAgent:G.id}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${G.status==="idle"?"bg-green-400":G.status==="working"?"bg-blue-400 animate-pulse":"bg-gray-600"}`}),t.jsx("span",{className:"text-[11px] text-fg-secondary",children:G.name})]},G.id)),P.length>6&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary self-center",children:["+",P.length-6," more"]})]})]})})()]})]})]}),t.jsxs("div",{className:"space-y-6",children:[p.length>0&&t.jsxs("div",{className:"bg-surface-secondary border border-amber-500/30 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse"}),t.jsx("h3",{className:"text-xs font-semibold text-amber-600 uppercase tracking-wider",children:"Pending Reviews"})]}),t.jsx("button",{onClick:()=>bt.navigate(ge.WORK),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"Review →"})]}),t.jsxs("div",{className:"space-y-2",children:[p.slice(0,5).map(L=>t.jsxs("div",{className:"flex items-start gap-2.5 py-2 px-2.5 rounded-lg bg-surface-elevated/40 hover:bg-surface-elevated/60 transition-colors cursor-pointer",onClick:()=>bt.navigate(ge.WORK),children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:L.title}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:["proposed by ",L.createdBy," · ",L.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:L.source==="agent"?"Agent":"User"})]},L.id)),p.length>5&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary text-center pt-1",children:["+",p.length-5," more"]})]}),t.jsxs("p",{className:"text-[10px] text-fg-tertiary mt-3",children:["Agents proposed ",p.length," requirement",p.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:()=>bt.navigate(ge.WORK),className:"text-[11px] text-fg-tertiary hover:text-fg-secondary",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:h.taskKPI.recentActivity.slice(0,8).map(L=>t.jsxs("div",{className:"flex items-center gap-2.5 py-1.5 px-2 rounded-lg hover:bg-surface-elevated/40 transition-colors cursor-pointer",onClick:()=>bt.navigate(ge.WORK,{openTask:L.taskId}),children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Wh[L.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:L.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(L.updatedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},L.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(Do,{label:"Health Score",value:h.systemHealth.overallScore,max:100,unit:"%",color:h.systemHealth.overallScore>=80?"green":h.systemHealth.overallScore>=50?"amber":"red"}),t.jsx(Do,{label:"Success Rate",value:h.taskKPI.successRate,max:100,unit:"%",color:h.taskKPI.successRate>=80?"green":"amber"}),t.jsx(Do,{label:"Active / Total",value:_,max:s.length||1,unit:`/${s.length}`,color:"brand"}),t.jsx(Do,{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(Do,{label:"Working Now",value:Y,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(L=>t.jsxs("span",{className:"px-2 py-0.5 bg-red-500/10 rounded text-red-500 cursor-pointer hover:bg-red-500/20",onClick:()=>bt.navigate(ge.TEAM,{selectAgent:L.id}),children:[L.name," (",L.score,"%)"]},L.id))]})})]}),b&&t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>bt.navigate(ge.SETTINGS),children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:"Storage"}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-2xl font-bold text-fg-primary",children:Gy(b.totalSize)}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:"total"})]}),t.jsxs("div",{className:"mt-2 flex gap-4 text-xs text-fg-tertiary",children:[t.jsxs("span",{children:["DB: ",Gy(b.database.size)]}),t.jsxs("span",{children:["Agents: ",b.agents.length]})]}),t.jsx("div",{className:"mt-2 text-[10px] text-fg-tertiary",children:"Click to view details in Settings"})]})]})]})]})]})}const Wh={pending:"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"},yA={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 vA({statusCounts:e,total:n}){const s=Object.entries(e).filter(([,l])=>l>0).sort(([,l],[,i])=>i-l);return t.jsxs("div",{children:[t.jsx("div",{className:"flex h-4 rounded-full overflow-hidden gap-0.5 mb-4",children:s.map(([l,i])=>t.jsx("div",{className:`${Wh[l]??"bg-gray-600"} transition-all`,style:{width:`${i/n*100}%`},title:`${l}: ${i}`},l))}),t.jsx("div",{className:"flex gap-4 flex-wrap",children:s.map(([l,i])=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-sm ${Wh[l]??"bg-gray-600"}`}),t.jsx("span",{className:"text-xs text-fg-secondary capitalize",children:l.replace(/_/g," ")}),t.jsx("span",{className:`text-xs font-semibold ${yA[l]??"text-fg-secondary"}`,children:i})]},l))})]})}function Ad({label:e,value:n,total:s,color:l,onClick:i}){const c={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"}},d=c[l]??c.indigo;return t.jsxs("div",{onClick:i,className:`bg-surface-secondary border border-border-default ${d.border} border-l-2 rounded-xl p-5 cursor-pointer hover:bg-surface-elevated/80 hover:shadow-lg ${d.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 ${d.text}`,children:[n,s!==void 0&&t.jsxs("span",{className:"text-base font-normal text-fg-muted",children:["/",s]})]})]})}function Do({label:e,value:n,max:s,unit:l,color:i,raw:c}){const d=s>0?Math.min(n/s*100,100):0,u={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=u[i]??"bg-gray-400",x=h[i]??"text-fg-secondary";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-sm font-semibold ${x}`,children:c?`${l}${n}`:t.jsxs(t.Fragment,{children:[n,t.jsx("span",{className:"text-[10px] font-normal text-fg-tertiary",children:l})]})})]}),t.jsx("div",{className:"w-full h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${f} transition-all`,style:{width:`${d}%`}})})]})}function Gy(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${n[s]}`}const Xy={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 Dl(e){const n=e.includes("__")?e.split("__").pop():e;return Xy[n]??Xy[e]??{label:n.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function Vx(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function jA(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0"),i=String(n.getHours()).padStart(2,"0"),c=String(n.getMinutes()).padStart(2,"0"),d=String(n.getSeconds()).padStart(2,"0");return`${s}-${l} ${i}:${c}:${d}`}function Zh(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function Ky(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function wA(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,l])=>({key:s,value:typeof l=="string"?l:JSON.stringify(l,null,2)}))}function NA(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 Wy(e,n){const s=new Map;let l=null;for(const i of e)if(i.type==="tool_start"&&(i.content==="spawn_subagent"||i.content==="spawn_subagents"))l=i.seq,s.set(i.seq,[]);else if(i.type==="tool_end"&&(i.content==="spawn_subagent"||i.content==="spawn_subagents")){if(l!==null){const c=s.get(l);c&&s.set(i.seq,c)}l=null}else if(l!==null&&i.type.startsWith("subagent_")){const c=i.type.replace("subagent_",""),d=i.metadata;s.get(l)?.push({eventType:c,content:i.content,metadata:d})}return n.map(i=>{if(i.type!=="tool")return i;const c=i.key;if(!c)return i;const d=c.replace(/^t[se]_/,""),u=parseInt(d,10);if(isNaN(u))return i;const h=s.get(u);return!h||h.length===0?i:{...i,info:{...i.info,subagentLogs:h}}})}function Jo(e){const n=new Set;for(let s=0;s<e.length;s++){const l=e[s];if(l.type==="tool"&&(l.info.status==="done"||l.info.status==="error"))for(let i=s-1;i>=0;i--){const c=e[i];if(c.type==="tool"&&c.info.status==="running"&&c.info.tool===l.info.tool&&!n.has(i)){n.add(i);break}}}return e.filter((s,l)=>!n.has(l))}function ec(e){const n=jA(e.createdAt),s=e.createdAt,l=e.metadata;switch(e.type){case"text":return l?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const i=l?.action;return i&&["chat","chat_stream","task_execution","respond_in_session"].includes(i)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:l?.arguments}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:l?.success===!1?"error":"done",args:l?.arguments,result:l?.result,error:l?.error,durationMs:l?.durationMs,subagentLogs:l?.subagentLogs}};default:return null}}function iw(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const s=JSON.parse(n);if(!s.task)return null;const l=s.task;return{taskId:l.id,title:l.title,description:l.description,assignedAgentId:l.assignedAgentId,priority:l.priority}}catch{return null}}function ow(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const l=s.requirement;return l.status!=="pending"?null:{requirementId:l.id,title:l.title,description:l.description,priority:l.priority}}catch{return null}}function kA(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const l=`${s.tool}_${s.ts}`;n.push({key:l,tool:s.tool,status:"running"})}else for(let l=n.length-1;l>=0;l--)if(n[l].tool===s.tool&&n[l].status==="running"){n[l]={...n[l],status:s.success===!1?"error":"done"};break}}return n}function cw(){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 SA(){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 Zy({item:e,idx:n,total:s}){const l=Dl(e.tool);return t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[n>0&&t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:`w-2.5 h-2.5 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":"border-gray-600 bg-surface-elevated text-fg-tertiary"}`,children:e.status==="done"?"✓":e.status==="error"?"✗":""}),n<s-1&&t.jsx("div",{className:"w-px flex-1 bg-surface-overlay mt-0.5"})]}),t.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500 opacity-60":"text-fg-tertiary"}`,children:[t.jsx("span",{className:"opacity-70",children:l.icon}),t.jsxs("span",{children:[l.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(cw,{})]})]})}function CA({activities:e,isActive:n,persistent:s}){const l=kA(e),[i,c]=y.useState(!1),[d,u]=y.useState(!1),h=y.useRef(null);if(y.useEffect(()=>(s||n||e.length>0?(c(!0),h.current&&clearTimeout(h.current)):h.current=setTimeout(()=>c(!1),800),()=>{h.current&&clearTimeout(h.current)}),[s,n,e.length]),!i)return null;const f=l.length>0,x=f&&l.every(b=>b.status!=="running"),p=n&&!f,g=n&&f&&x;if(s&&x){const b=l.filter(k=>k.status==="error").length,w=l.filter(k=>k.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>u(k=>!k),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 ${d?"rotate-90":""}`,children:"▶"}),t.jsxs("span",{className:"font-medium",children:[w," step",w!==1?"s":""]}),b>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",b," failed"]}),!d&&t.jsxs("span",{className:"ml-1 flex gap-0.5",children:[l.slice(0,5).map(k=>t.jsx("span",{className:"text-[10px] opacity-60",title:Dl(k.tool).label,children:Dl(k.tool).icon},k.key)),l.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",l.length-5]})]})]}),d&&t.jsx("div",{className:"mt-2 space-y-0.5",children:l.map((k,C)=>t.jsx(Zy,{item:k,idx:C,total:l.length},k.key))})]})}return t.jsxs("div",{className:"mb-2 space-y-0.5",children:[l.map((b,w)=>t.jsx(Zy,{item:b,idx:w,total:l.length},b.key)),p&&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(SA,{})]}),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(cw,{}),t.jsx("span",{children:"Writing response…"})]})]})]})}function Qh({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 Jh({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(Fn,{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 EA({info:e,onClose:n}){const s=Dl(e.tool),l=wA(e.args),i=e.status==="running",c=e.status!=="error";return y.useEffect(()=>{const d=u=>{u.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 ${i?"text-brand-500":c?"text-fg-primary":"text-red-500"}`,children:s.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${i?"bg-brand-500/15 text-brand-500":c?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:i?"Running":c?"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:Vx(e.durationMs)}),t.jsx("button",{onClick:n,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Arguments"}),t.jsx("div",{className:"space-y-2",children:l.map(({key:d,value:u})=>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:u})]},d))})]}),!i&&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:Ky(e.result)})]}),!i&&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:Ky(String(e.error))})]}),e.subagentLogs&&e.subagentLogs.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Sub-agent Execution"}),t.jsx("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2 space-y-1 max-h-[50vh] overflow-y-auto",children:e.subagentLogs.map((d,u)=>{const h=d.eventType==="started"?"▶":d.eventType==="completed"?"✓":d.eventType==="error"?"✗":d.eventType==="tool_start"?"◎":d.eventType==="tool_end"?"●":d.eventType==="thinking"?"💭":"→",f=d.eventType==="error"?"text-red-500":d.eventType==="completed"?"text-green-500":d.eventType==="started"?"text-brand-500":"text-fg-tertiary";return t.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[t.jsx("span",{className:`shrink-0 ${f}`,children:h}),t.jsx("span",{className:`font-mono break-all ${f}`,children:d.content})]},u)})})]}),!l.length&&!i&&!e.result&&!e.error&&!e.subagentLogs?.length&&t.jsx("div",{className:"text-sm text-fg-tertiary italic py-4 text-center",children:"No detailed data recorded for this tool call."})]})]})]})}const dw={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},Qy={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",cancelled:"cancelled",archived:"archived"},Jy={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 uw({info:e}){const[n,s]=y.useState("loading");y.useEffect(()=>{let h=!1;return se.tasks.get(e.taskId).then(({task:f})=>{h||s(Qy[f.status]??"pending")}).catch(()=>{h||s("pending")}),()=>{h=!0}},[e.taskId]),y.useEffect(()=>Zt.on("task:update",h=>{const f=h.payload;f.taskId===e.taskId&&f.status&&s(Qy[f.status]??"pending")}),[e.taskId]);const l=async()=>{s("approving");try{await se.tasks.approve(e.taskId),s("in_progress")}catch{s("pending")}},i=async()=>{s("rejecting");try{await se.tasks.reject(e.taskId),s("cancelled")}catch{s("pending")}},c=n==="pending"||n==="approving"||n==="rejecting",d=Jy[n]??Jy.loading,u=()=>bt.navigate(ge.WORK,{openTask:e.taskId});return t.jsxs("div",{className:`my-2 rounded-lg border ${d.borderClass} ${d.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:u,onKeyDown:h=>h.key==="Enter"&&u(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:d.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 ${d.badgeClass}`,children:"Task"}),!c&&n!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${d.textClass}`,children:d.label})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!c&&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:dw[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.taskId.slice(0,8),"..."]})]})]})]}),c&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:l,disabled:n!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="approving"?"Approving…":"Approve"}),t.jsx("button",{onClick:i,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 ev={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},tv={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:""}},TA=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function fw({info:e}){const[n,s]=y.useState("loading"),[l,i]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{let p=!1;return se.requirements.get(e.requirementId).then(({requirement:g})=>{p||s(ev[g.status]??"pending")}).catch(()=>{p||s("pending")}),()=>{p=!0}},[e.requirementId]),y.useEffect(()=>{const p=TA.map(g=>Zt.on(g,b=>{const w=b.payload;w.id===e.requirementId&&w.status&&s(ev[w.status]??"pending")}));return()=>p.forEach(g=>g())},[e.requirementId]);const u=async()=>{s("approving");try{await se.requirements.approve(e.requirementId),s("in_progress")}catch{s("pending")}},h=async()=>{if(!c){d(!0);return}if(l.trim()){s("rejecting");try{await se.requirements.reject(e.requirementId,l.trim()),s("rejected")}catch{s("pending")}}},f=n==="pending"||n==="approving"||n==="rejecting",x=tv[n]??tv.loading;return t.jsxs("div",{className:`my-2 rounded-lg border ${x.borderClass} ${x.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:x.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 ${x.badgeClass}`,children:"REQ"}),!f&&n!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${x.textClass}`,children:x.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:dw[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:[c&&t.jsx("input",{type:"text",value:l,onChange:p=>i(p.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:p=>p.key==="Enter"&&h(),autoFocus:!0}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:u,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"||c&&!l.trim(),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="rejecting"?"Rejecting…":"Reject"})]})]})]})}function AA({info:e,showTime:n,time:s,isLast:l}){const i=Dl(e.tool),[c,d]=y.useState(!1),u=e.status!=="running",h=e.status==="stopped",x=(e.tool==="spawn_subagent"||e.tool==="spawn_subagents")&&e.subagentLogs&&e.subagentLogs.length>0,p=NA(e),g=y.useRef(null);return y.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[e.liveOutput]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`relative flex items-start gap-2 py-0.5 min-w-0 ${l?"":"border-b border-border-default/30 pb-1.5 mb-0.5"} cursor-pointer rounded hover:bg-surface-elevated/30 transition-colors`,onClick:()=>d(!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:i.icon}),t.jsxs("span",{children:[i.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:Vx(e.durationMs)}),x&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary ml-0.5 opacity-60",children:["(",e.subagentLogs.filter(b=>b.eventType==="tool_end").length," steps)"]})]}),p&&t.jsxs("div",{className:`mt-0.5 font-mono text-[11px] truncate max-w-full ${e.status==="running"?"text-fg-secondary":"text-fg-tertiary"}`,title:p,children:[t.jsx("span",{className:"text-fg-tertiary select-none",children:"$ "}),Zh(p,120)]}),e.liveOutput&&e.status==="running"&&t.jsx("pre",{ref:g,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput})]})]}),c&&t.jsx(EA,{info:e,onClose:()=>d(!1)}),u&&(()=>{const b=iw(e.tool,e.result);if(b)return t.jsx(uw,{info:b});const w=ow(e.tool,e.result);return w?t.jsx(fw,{info:w}):null})()]})}function _A({content:e,time:n,showTime:s}){const[l,i]=y.useState(!1),c=e.split(`
|
|
42
|
+
`)[0]??"";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 bg-purple-500/[0.06] border border-purple-500/15 rounded-lg px-3 py-2 transition-colors hover:bg-purple-500/[0.1]",children:[t.jsxs("button",{onClick:()=>i(!l),className:"flex items-center gap-1.5 text-xs text-purple-400 w-full",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform shrink-0 ${l?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"font-medium shrink-0",children:"Thinking"}),!l&&t.jsx("span",{className:"text-fg-tertiary text-[11px] truncate",children:c})]}),l&&t.jsx("div",{className:"mt-2 pt-2 border-t border-purple-500/15 overflow-hidden",children:t.jsx(Fn,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})]})}const su=y.memo(mw);function mw({entry:e,showTime:n,isLast:s}){if(e.type==="tool")return t.jsx(AA,{info:e.info,showTime:n,time:e.time,isLast:s},e.key);if(e.type==="thinking")return t.jsx(_A,{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(Fn,{content:e.content,className:"text-sm text-fg-secondary break-words"})})]});if(e.type==="status"){const l=e.content==="completed"||e.content==="execution_finished",i=e.content==="started",c=e.content==="resumed",d=l?"text-green-600":i?"text-blue-600":c?"text-amber-600":"text-fg-tertiary",u=l?"bg-green-400":i?"bg-blue-400":c?"bg-amber-400":"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 py-0.5 px-1",children:[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 ${u}`}),t.jsx("span",{className:`text-xs capitalize ${d}`,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:l,showRounds:i,embedded:c}){const d=e.length>0?e[e.length-1]:null,u=e.filter(N=>N.type==="tool_end").length,h=e.filter(N=>N.type==="error").length,f=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),x=d?new Date(d.createdAt).getTime():Date.now(),p=s?Date.now()-f:x-f,g=new Set(e.filter(N=>N.executionRound!=null).map(N=>N.executionRound)),b=g.size>0?Math.max(...g):void 0,w=i&&g.size>1;let k,C,E=null;if(s)if(n)k="✍",C="Writing response...",E=Zh(n.split(`
|
|
43
|
+
`).pop()??"",80);else if(d?.type==="tool_start"){const N=Dl(d.content);k=N.icon,C=`${N.label}...`;const A=d.metadata?.arguments&&typeof d.metadata.arguments=="object"?d.metadata.arguments.command:void 0;A&&(E=`$ ${Zh(A,80)}`)}else if(d?.type==="tool_end"){const N=Dl(d.content);k=N.icon,C=N.label}else k="💭",C="Thinking...";else if(h>0&&d?.type==="error")k="❌",C="Failed";else{const A=[...e].reverse().find(R=>R.type==="status")?.content??"";A==="completed"||A==="execution_finished"?(k="✅",C="Completed"):(k="●",C=`${u} tool${u!==1?"s":""} executed`)}const M=Vx(p);return t.jsx("div",{onClick:l,className:`overflow-hidden transition-all cursor-pointer min-w-0 ${c?"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:c?"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:k}),t.jsx("span",{className:`text-xs font-medium truncate ${s?"text-fg-primary":"text-fg-secondary"}`,children:C})]}),M&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:M})]}),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(Fn,{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:[u>0&&t.jsxs("span",{children:["🔧 ",u," tool",u!==1?"s":""]}),e.some(N=>N.type==="text"&&!N.metadata?.isThinking)&&t.jsx("span",{children:"💬 text"}),e.some(N=>N.type==="text"&&N.metadata?.isThinking)&&t.jsx("span",{className:"text-purple-400",children:"💭 thinking"}),w&&b!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"opacity-30",children:"·"}),t.jsxs("span",{children:["Round #",b]}),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 MA(e){const n=new Map;for(const s of e){const l=s.executionRound??1;n.has(l)||n.set(l,[]);const i=ec(s);i&&n.get(l).push(i)}return Array.from(n.entries()).sort(([s],[l])=>s-l).map(([s,l])=>({round:s,entries:l}))}function Cu({entries:e,streamingText:n,isActive:s,onCollapse:l,showRounds:i,embedded:c}){const d=y.useRef(null),[u,h]=y.useState(new Set),f=MA(e),x=i&&f.length>1;y.useEffect(()=>{f.length>0&&h(w=>{const k=new Set(w);return k.add(f[f.length-1].round),k})},[f.length]),y.useEffect(()=>{c||!d.current||!s||(d.current.scrollTop=d.current.scrollHeight)},[e.length,n,s,c]);const p=w=>{h(k=>{const C=new Set(k);return C.has(w)?C.delete(w):C.add(w),C})},g=x?null:e.map(ec).filter(w=>w!==null),b=g?Jo(g):null;return t.jsxs("div",{className:`min-w-0 overflow-hidden ${c?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[t.jsxs("div",{onClick:l,className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${c?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!c&&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:c?void 0:d,className:`space-y-0.5 min-w-0 overflow-x-hidden ${c?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[x?f.map(w=>{const k=u.has(w.round),C=Jo(w.entries),E=w.entries.filter(M=>M.type==="tool"&&M.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:()=>p(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 ${k?"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"})})]})]}),k&&t.jsx("div",{className:"px-3 py-1.5 space-y-0.5",children:C.map((M,N)=>t.jsx(su,{entry:M,showTime:!0,isLast:N===C.length-1},N))})]},w.round)}):b&&b.map((w,k)=>t.jsx(su,{entry:w,showTime:!0,isLast:k===b.length-1},k)),s&&n&&t.jsx(Jh,{content:n}),s&&!n&&t.jsx(Qh,{})]})]})}function RA({agents:e,filter:n,anchorRef:s,onSelect:l,selectedIndex:i,onIndexChange:c}){const[d,u]=y.useState(null),h=y.useRef(null),f=e.filter(x=>x.name.toLowerCase().includes(n));return y.useEffect(()=>{const x=s.current;if(!x)return;const p=x.getBoundingClientRect();u({top:p.top+window.scrollY-4,left:p.left+window.scrollX+8})},[s,n]),y.useEffect(()=>{if(!h.current||!d)return;if(h.current.getBoundingClientRect().top<8){const p=s.current;if(!p)return;const g=p.getBoundingClientRect();u({top:g.bottom+window.scrollY+4,left:d.left})}},[d,s]),y.useEffect(()=>{i>=f.length&&c(Math.max(0,f.length-1))},[f.length,i,c]),y.useEffect(()=>{if(!h.current)return;h.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[i]),!d||f.length===0?null:vu.createPortal(t.jsxs("div",{ref:h,style:{position:"absolute",top:d.top,left:d.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((x,p)=>t.jsxs("button",{"data-selected":p===i,onMouseDown:g=>{g.preventDefault(),l(x)},onMouseEnter:()=>c(p),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${p===i?"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:x.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:x.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:x.role})]}),t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${x.status==="idle"||x.status==="working"?"bg-green-400":"bg-gray-500"}`})]},x.id))]}),document.body)}function OA(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const au=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function DA(e){const n=[];let s;for(au.lastIndex=0;(s=au.exec(e))!==null;)n.push(s[1]??s[2]);return n}function nv(e,n,s){const l=[],i=new RegExp(au.source,au.flags);let c=0,d,u=0;for(;(d=i.exec(e))!==null;){d.index>c&&l.push(t.jsx("span",{children:e.slice(c,d.index)},u++));const h=d[1]??d[2],f=n.find(x=>x.name.toLowerCase()===h.toLowerCase());l.push(t.jsxs("span",{className:"text-brand-500 font-medium ",onClick:void 0,title:f?`${f.name} (${f.role})`:void 0,children:["@",h]},u++)),c=d.index+d[0].length}return c<e.length&&l.push(t.jsx("span",{children:e.slice(c)},u++)),l.length>0?l:[t.jsx("span",{children:e},0)]}function hw({agents:e,onSubmit:n,placeholder:s,replyTo:l,onCancelReply:i}){const[c,d]=y.useState(""),[u,h]=y.useState(!1),[f,x]=y.useState(null),[p,g]=y.useState(!1),[b,w]=y.useState(""),[k,C]=y.useState([]),[E,M]=y.useState(0),N=y.useRef(null),A=y.useRef(null),R=e.filter(G=>G.name.toLowerCase().includes(b)),_=async()=>{if(c.trim()){h(!0),x(null),A.current={content:c,mentions:[...k]};try{await n(c,k,l?.id),d(""),C([]),A.current=null,i?.()}catch(G){x(String(G instanceof Error?G.message:G)||"Failed to send comment")}h(!1)}},Y=async()=>{if(!A.current)return;const{content:G,mentions:$}=A.current;h(!0),x(null);try{await n(G,$),d(""),C([]),A.current=null}catch(T){x(String(T instanceof Error?T.message:T)||"Failed to send comment")}h(!1)},q=y.useCallback(G=>{d($=>{const T=$.lastIndexOf("@"),z=OA(G.name);return T>=0?$.slice(0,T)+z+" ":$+z+" "}),k.includes(G.id)||C($=>[...$,G.id]),g(!1),w(""),M(0),N.current?.focus()},[k]),X=G=>{d(G),x(null);const $=G.lastIndexOf("@");if($>=0&&($===0||G[$-1]===" ")){const z=G.slice($+1).toLowerCase();if(e.some(V=>V.name.toLowerCase().includes(z))){w(z),g(!0),M(0);return}}g(!1)},L=G=>{if(p&&R.length>0){const $=G.key==="ArrowUp"||G.ctrlKey&&G.key==="p",T=G.key==="ArrowDown"||G.ctrlKey&&G.key==="n",z=G.key==="Enter"||G.key==="Tab",O=G.key==="Escape";if($){G.preventDefault(),M(V=>(V-1+R.length)%R.length);return}if(T){G.preventDefault(),M(V=>(V+1)%R.length);return}if(z){G.preventDefault();const V=R[E];V&&q(V);return}if(O){G.preventDefault(),g(!1);return}}G.key==="Enter"&&!G.shiftKey&&(G.preventDefault(),_())},P=y.useCallback(()=>{setTimeout(()=>g(!1),200)},[]);return t.jsxs("div",{className:"relative",children:[p&&t.jsx(RA,{agents:e,filter:b,anchorRef:N,onSelect:q,selectedIndex:E,onIndexChange:M}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[l&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:l.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:l.content})]}),t.jsx("button",{onClick:i,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"})]})})]}),k.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:k.map(G=>{const $=e.find(T=>T.id===G);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:["@",$?.name??G,t.jsx("button",{onClick:()=>C(T=>T.filter(z=>z!==G)),className:"hover:text-red-400",children:"×"})]},G)})}),t.jsx("textarea",{ref:N,value:c,onChange:G=>X(G.target.value),onKeyDown:L,onBlur:P,placeholder:s??"Add a comment… (type @ to mention an agent)",rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:f}),t.jsxs("button",{onClick:Y,disabled:u,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:_,disabled:!c.trim()||u,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:u?"Sending…":"Comment"})})]})]})}function xw({title:e,message:n,confirmLabel:s="Confirm",checkboxes:l,onConfirm:i,onCancel:c}){const[d,u]=y.useState(()=>{const h={};for(const f of l??[])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:c,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}),l&&l.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:l.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:d[h.id]??!1,onChange:f=>u(x=>({...x,[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:c,className:"px-4 py-1.5 text-sm border border-border-default rounded-lg hover:bg-surface-elevated transition-colors",children:"Cancel"}),t.jsx("button",{onClick:()=>i(l?d:void 0),className:"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:s})]})]})})}function Eu({children:e,onClose:n,title:s,width:l="w-[440px]"}){return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${l} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:i=>i.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:s}),e]})})}function ga({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 LA({onClose:e,onCreate:n}){const[s,l]=y.useState(""),[i,c]=y.useState("");return t.jsx(Eu,{onClose:e,title:"Create a New Team",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(ga,{label:"Team Name",children:t.jsx("input",{value:s,onChange:d=>l(d.target.value),placeholder:"e.g. Engineering, Marketing, Support",className:"input",autoFocus:!0,onKeyDown:d=>{d.key==="Enter"&&s.trim()&&n(s.trim(),i.trim()||void 0)}})}),t.jsx(ga,{label:"Description (optional)",children:t.jsx("textarea",{value:i,onChange:d=>c(d.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:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:[t.jsx("span",{className:"text-brand-400 font-medium",children:"Tip:"})," For more advanced team creation (with roles, skills, and auto-hiring), just tell your ",t.jsx("span",{className:"text-brand-400",children:"Secretary"})," what kind of team you need."]}),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(),i.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 IA({teamId:e,teams:n,onClose:s,onAdd:l}){const[i,c]=y.useState(""),[d,u]=y.useState("member"),[h,f]=y.useState(""),[x,p]=y.useState(""),[g,b]=y.useState(""),[w,k]=y.useState(e??""),[C,E]=y.useState(""),M=()=>{if(E(""),!i.trim()){E("Name is required");return}if(x&&!h.trim()){E("Email is required when setting a password");return}if(h.trim()&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){E("Please enter a valid email address");return}if(x&&x.length<6){E("Password must be at least 6 characters");return}if(x&&x!==g){E("Passwords do not match");return}l(i.trim(),d,h.trim()||void 0,x||void 0,w||void 0)};return t.jsx(Eu,{onClose:s,title:"Add Human Team Member",width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(ga,{label:"Name *",children:t.jsx("input",{value:i,onChange:N=>c(N.target.value),placeholder:"Full name",className:"input",autoFocus:!0})}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(ga,{label:"Role",children:t.jsxs("select",{value:d,onChange:N=>u(N.target.value),className:"input",children:[t.jsx("option",{value:"owner",children:"Owner"}),t.jsx("option",{value:"admin",children:"Admin"}),t.jsx("option",{value:"member",children:"Member"}),t.jsx("option",{value:"guest",children:"Guest"})]})}),t.jsx(ga,{label:"Assign to Team",children:t.jsxs("select",{value:w,onChange:N=>k(N.target.value),className:"input",children:[t.jsx("option",{value:"",children:"No team"}),n.map(N=>t.jsx("option",{value:N.id,children:N.name},N.id))]})})]}),t.jsx(ga,{label:"Email",children:t.jsx("input",{value:h,onChange:N=>f(N.target.value),type:"email",placeholder:"Required for login access",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(ga,{label:"Password",children:t.jsx("input",{value:x,onChange:N=>p(N.target.value),type:"password",placeholder:"Leave blank for no login access",className:"input"})}),x&&t.jsx("div",{className:"mt-3",children:t.jsx(ga,{label:"Confirm Password",children:t.jsx("input",{value:g,onChange:N=>b(N.target.value),type:"password",placeholder:"Repeat password",className:"input"})})})]}),C&&t.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:C}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{onClick:M,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 rounded-lg text-white",children:"Add Member"})]})]})})}function zA({teamId:e,ungrouped:n,onClose:s,onAdd:l}){return t.jsx(Eu,{onClose:s,title:"Add Existing Member to Team",children:t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Select an ungrouped member to add to this team."}),n.length===0?t.jsx("div",{className:"text-center py-8 text-sm text-fg-tertiary",children:"All members are already in a team."}):t.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:n.map(i=>t.jsxs("button",{onClick:()=>l(i.id,i.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 ${i.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:i.name.charAt(0)}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-sm",children:i.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[i.role," · ",i.type==="agent"?"AI":"Human"]})]}),i.status&&t.jsx("span",{className:`w-2 h-2 rounded-full ${i.status==="idle"?"bg-green-400":i.status==="working"?"bg-blue-400":"bg-gray-600"}`})]},i.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 $A({onClose:e,onConnected:n}){const[s,l]=y.useState(""),[i,c]=y.useState(""),[d,u]=y.useState(!1),[h,f]=y.useState(null),[x,p]=y.useState(null),g=async()=>{if(!s.trim()){c("Agent name is required");return}const w=s.trim().toLowerCase().replace(/\s+/g,"-");u(!0),c("");try{const k=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(!k.ok){const E=await k.json().catch(()=>({}));throw new Error(E.error??`HTTP ${k.status}`)}const C=await k.json();f({externalAgentId:w,markusAgentId:C.registration?.markusAgentId,token:C.token,gatewayUrl:C.gatewayUrl})}catch(k){c(String(k))}u(!1)},b=(w,k)=>{navigator.clipboard.writeText(w),p(k),setTimeout(()=>p(null),2e3)};return t.jsx(Eu,{onClose:e,title:"Import OpenClaw Agent",width:"w-[560px]",children:h?(()=>{const w=h.gatewayUrl??`${window.location.origin}/api/gateway`,k=`Connect to the Markus AI platform as an external agent.
|
|
44
|
+
|
|
45
|
+
Gateway URL: ${w}
|
|
46
|
+
Agent ID: ${h.externalAgentId}
|
|
47
|
+
${h.token?`Bearer Token: ${h.token}`:""}
|
|
48
|
+
|
|
49
|
+
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.
|
|
50
|
+
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).
|
|
51
|
+
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:()=>b(k,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${x==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:x==="prompt"?"Copied!":"Copy Connection Prompt"})]}),t.jsx("div",{className:"flex justify-end pt-5",children:t.jsx("button",{onClick:()=>{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(ga,{label:"Agent Name *",children:t.jsx("input",{className:"input",placeholder:"e.g. Alice",value:s,onChange:w=>l(w.target.value),autoFocus:!0})}),i&&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:i}),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:d,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-white disabled:opacity-50",children:d?"Connecting...":"Import Agent"})]})]})]})})}function Ys({name:e,avatarUrl:n,size:s=28,className:l="",bgClass:i="bg-brand-600"}){const c=e?.[0]?.toUpperCase()??"?",d=s<=20?"text-[8px]":s<=28?"text-xs":s<=40?"text-sm":"text-lg";return n?t.jsx("img",{src:n,alt:e??"",className:`rounded-full object-cover shrink-0 ${l}`,style:{width:s,height:s},onError:u=>{u.target.style.display="none"}}):t.jsx("div",{className:`rounded-full ${i} flex items-center justify-center text-white ${d} font-bold shrink-0 ${l}`,style:{width:s,height:s},children:c})}function Gx({currentUrl:e,name:n,size:s=64,targetType:l="user",targetId:i,onUploaded:c}){const[d,u]=y.useState(null),[h,f]=y.useState(!1),x=y.useRef(null),p=d??e,g=y.useCallback(async k=>{if(!k.type.startsWith("image/"))return;if(k.size>2*1024*1024){alert("Image must be under 2MB");return}const C=new FileReader;C.onload=async()=>{const E=C.result;u(E),f(!0);try{const{avatarUrl:M}=await se.auth.uploadAvatar(E,l,i);c?.(M)}catch{u(null)}finally{f(!1)}},C.readAsDataURL(k)},[l,i,c]),b=n?.[0]?.toUpperCase()??"?",w=s<=32?"text-sm":s<=48?"text-lg":"text-2xl";return t.jsxs("div",{className:"relative inline-block group",children:[t.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:k=>{const C=k.target.files?.[0];C&&g(C)}}),t.jsxs("button",{type:"button",onClick:()=>x.current?.click(),className:"relative rounded-full overflow-hidden focus:outline-none focus:ring-2 focus:ring-brand-500/50",style:{width:s,height:s},title:"Click to upload avatar",children:[p?t.jsx("img",{src:p,alt:n??"",className:"w-full h-full object-cover"}):t.jsx("div",{className:`w-full h-full bg-brand-600 flex items-center justify-center text-white ${w} font-bold`,children:b}),t.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:h?t.jsx("div",{className:"w-5 h-5 border-2 border-white/60 border-t-white rounded-full animate-spin"}):t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),t.jsx("circle",{cx:"12",cy:"13",r:"4"})]})})]})]})}let rv=new Map;function BA({authUser:e,agents:n,teams:s,humans:l,tasks:i,externalAgents:c,groupChats:d,chatMode:u,selectedAgent:h,activeChannel:f,activeDmUserId:x,onSelectAgent:p,onSelectChannel:g,onSelectDm:b,onRefreshTeams:w,onRefreshAgents:k,onViewProfile:C,width:E,onResizeStart:M,hidden:N}){const A=Yr(),R=e?.role==="owner"||e?.role==="admin",_=y.useMemo(()=>new Set(c.map(ae=>ae.markusAgentId).filter(Boolean)),[c]),[Y,q]=y.useState([]),[X,L]=y.useState(new Set),[P,G]=y.useState(!1),[$,T]=y.useState(null),[z,O]=y.useState(null),[V,H]=y.useState(!1),[Z,B]=y.useState(null),[F,K]=y.useState(null),[I,S]=y.useState(null),[D,W]=y.useState(!1),J=y.useRef(null),[te,re]=y.useState(null),[oe,me]=y.useState(null),Oe=(ae,Ie="success")=>{me({message:ae,type:Ie}),setTimeout(()=>me(null),3e3)},[ve,ke]=y.useState(!1),[Ee,Me]=y.useState(!1);y.useEffect(()=>{se.governance.getSystemStatus().then(qe=>ke(qe.globalPaused)).catch(()=>{});const ae=Zt.on("system:pause-all",()=>ke(!0)),Ie=Zt.on("system:resume-all",()=>ke(!1));return()=>{ae(),Ie()}},[]);const dt=y.useCallback(()=>{et({title:ve?"Resume All Agents":"Pause All Agents",message:ve?"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:ve?"Resume":"Pause",onConfirm:async()=>{Me(!0);try{ve?(await se.governance.resumeAll(),ke(!1)):(await se.governance.pauseAll(),ke(!0))}catch{}Me(!1)}})},[ve]),[pt,et]=y.useState(null),Pt=(ae,Ie,qe,Qe,ue)=>{et({title:ae,message:Ie,onConfirm:qe,confirmLabel:Qe,checkboxes:ue})},[le,Se]=y.useState(null),[We,kt]=y.useState(null),Ft=y.useRef(null),xe=y.useRef(null),[Ce,Fe]=y.useState(!1),[lt,ut]=y.useState(null),[Lt,bn]=y.useState(""),Ut=y.useCallback((ae,Ie=176,qe=320)=>{const Qe=ae.currentTarget.getBoundingClientRect(),ue=window.innerWidth,ze=window.innerHeight,Ve=8;let tt=Qe.left,ot=Qe.bottom+4;return tt+Ie>ue-Ve&&(tt=Math.max(Ve,ue-Ie-Ve)),ot+qe>ze-Ve&&(ot=Math.max(Ve,Qe.top-qe-4)),{x:tt,y:ot}},[]),[St,Jt]=y.useState(rv),yt=y.useMemo(()=>n.map(ae=>ae.id).sort().join(","),[n]);y.useEffect(()=>{if(!n.length)return;let ae=!1;const Ie=async()=>{const Qe=[];if(await Promise.allSettled(n.map(async ue=>{try{const{sessions:ze}=await se.sessions.listByAgent(ue.id,1);if(!ze.length)return;const{messages:Ve}=await se.sessions.getMessages(ze[0].id,1);if(Ve.length){const tt=Ve[0],ot=tt.metadata?.segments;let At=tt.content;if(ot&&ot.length>0){const ar=[...ot].reverse().find(mn=>mn.type==="text");ar&&ar.type==="text"&&(At=ar.content)}const Sn=At.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80);Sn&&Qe.push([ue.id,Sn])}}catch{}})),!ae){const ue=new Map(Qe);rv=ue,Jt(ue)}};Ie();const qe=setInterval(Ie,3e4);return()=>{ae=!0,clearInterval(qe)}},[yt]);const Xt=y.useCallback(()=>{se.teams.list().then(ae=>q(ae.ungrouped)).catch(()=>{})},[]);y.useEffect(()=>{Xt()},[Xt]),y.useEffect(()=>Zt.on("*",Xt),[Xt]),y.useEffect(()=>{if(!Z&&!F&&!D)return;const ae=Ie=>{B(null),K(null),W(!1)};return setTimeout(()=>document.addEventListener("click",ae),0),()=>document.removeEventListener("click",ae)},[Z,F,D]);const _t=(ae,Ie)=>{Pt(`Delete "${Ie}"?`,"This team will be removed from the database. Check options below to also delete members and disk files.",async qe=>{const Qe=qe?.deleteMembers??!0,ue=qe?.purgeFiles??!1;await se.teams.delete(ae,Qe,{purgeFiles:ue}),w(),Xt(),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}])},$t=async(ae,Ie)=>{try{const Qe=await(Ie==="start"?se.teams.startAll:Ie==="stop"?se.teams.stopAll:Ie==="pause"?se.teams.pauseAll:se.teams.resumeAll)(ae),ue=Qe.success?.length??0,ze=Qe.failed?.length??0,Ve={start:"started",stop:"stopped",pause:"paused",resume:"resumed"};ze>0?Oe(`${Ie}: ${ue} succeeded, ${ze} failed`,"error"):ue>0&&Oe(`${ue} agent${ue>1?"s":""} ${Ve[Ie]}`,"success"),k()}catch(qe){Oe(`Failed to ${Ie}: ${qe instanceof Error?qe.message:String(qe)}`,"error")}},Hn=async(ae,Ie,qe)=>{await se.teams.update(ae,{managerId:Ie,managerType:qe}),w()},dn=async ae=>{if(!Lt.trim()){ut(null);return}await se.teams.update(ae,{name:Lt.trim()}),ut(null),w()},ye=async(ae,Ie)=>{Ie==="offline"?await se.agents.start(ae):await se.agents.stop(ae),k()},Ge=(ae,Ie)=>{Pt("Remove from team?","This member will be moved to Ungrouped.",async()=>{await se.teams.removeMember(ae,Ie),w(),Xt()},"Remove")},it=(ae,Ie,qe)=>{Pt(`Remove "${Ie}"?`,"This agent will be removed from the database. Check the option below to also delete its workspace, memory, and other files from disk.",async Qe=>{{const ue=Qe?.purgeFiles??!1;await se.agents.remove(ae,{purgeFiles:ue})}k(),w(),Xt(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},"Remove",[{id:"purgeFiles",label:"Also delete disk files (workspace, memory, logs)",defaultChecked:!1}])},Et=(ae,Ie,qe)=>{xe.current={x:ae.clientX,y:ae.clientY},Ft.current=setTimeout(()=>{Se({agentId:Ie,fromTeamId:qe}),Fe(!0)},200)},It=ae=>{if(!xe.current||!Ft.current)return;const Ie=Math.abs(ae.clientX-xe.current.x),qe=Math.abs(ae.clientY-xe.current.y);(Ie>5||qe>5)&&(Ce||(clearTimeout(Ft.current),Ft.current=null))},kn=async()=>{if(Ft.current&&(clearTimeout(Ft.current),Ft.current=null),xe.current=null,Ce&&le&&We){const ae=We==="_ungrouped"?void 0:We;try{if(le.fromTeamId&&le.fromTeamId!==ae&&await se.teams.removeMember(le.fromTeamId,le.agentId),ae&&ae!==le.fromTeamId){const Ie=n.find(qe=>qe.id===le.agentId);await se.teams.addMember(ae,le.agentId,"agent")}w(),k(),Xt()}catch(Ie){Oe(`Move failed: ${Ie instanceof Error?Ie.message:String(Ie)}`,"error")}}Se(null),kt(null),Fe(!1)},_n=y.useMemo(()=>new Map(s.map(ae=>[ae.id,ae])),[s]),Mn=y.useMemo(()=>{const ae=new Map,Ie=[];for(const qe of n)if(qe.teamId&&_n.has(qe.teamId)){const Qe=ae.get(qe.teamId)??[];Qe.push(qe),ae.set(qe.teamId,Qe)}else Ie.push(qe);return{byTeam:ae,ungrouped:Ie}},[n,_n]);s.filter(ae=>Mn.byTeam.has(ae.id)||ae.members?.length>0).map(ae=>ae.id);const dr=ae=>L(Ie=>{const qe=new Set(Ie);return qe.has(ae)?qe.delete(ae):qe.add(ae),qe}),sr=(ae,Ie)=>{const qe=u==="direct"&&h===ae.id,Qe=_.has(ae.id),ue=ae.status==="idle"?"bg-green-500":ae.status==="working"?"bg-blue-500 animate-pulse":ae.status==="error"?"bg-red-500":ae.status==="paused"?"bg-amber-500":"bg-gray-600",Ve=(Ie?_n.get(Ie):void 0)?.managerId===ae.id,tt=ae.role?.toLowerCase().replace(/[-_]/g," ").trim(),ot=ae.name.toLowerCase().trim(),At=tt&&tt!==ot,Sn=St.get(ae.id)||ae.currentActivity?.label?.slice(0,60)||"",ar=ae.status==="idle"?"Online":ae.status==="working"?"Working":ae.status==="error"?"Error":ae.status==="paused"?"Paused":"Offline";return t.jsx("div",{className:`relative mb-0.5 ${Ce&&le?.agentId===ae.id?"opacity-40":""}`,onPointerDown:mn=>Et(mn,ae.id,Ie),onPointerMove:It,onPointerUp:kn,children:t.jsxs("button",{onClick:()=>{Ce||p(ae.id)},onContextMenu:mn=>{if(!R)return;mn.preventDefault();const Wn=Ut(mn);K({agentId:ae.id,teamId:Ie,...Wn})},className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs transition-colors select-none ${A?"":"touch-none"} ${qe?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx(Ys,{name:ae.name,avatarUrl:ae.avatarUrl,size:24,bgClass:qe?"bg-brand-600":"bg-surface-overlay text-fg-secondary"}),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:ae.name}),At&&t.jsxs("span",{className:"text-[9px] text-fg-tertiary shrink-0 truncate max-w-[60px]",children:["(",ae.role,")"]}),Ve&&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"})}),Qe&&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:Sn||" "})]}),t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[ae.mailboxDepth!=null&&ae.mailboxDepth>0&&t.jsx("span",{className:"text-[8px] text-fg-tertiary bg-surface-overlay rounded-full px-1 leading-relaxed",children:ae.mailboxDepth}),t.jsx("span",{title:ar,onClick:mn=>{mn.stopPropagation(),C(ae.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${ue}`}),A&&R&&t.jsx("span",{role:"button",tabIndex:0,onClick:mn=>{if(mn.stopPropagation(),F?.agentId===ae.id)K(null);else{const Wn=Ut(mn);K({agentId:ae.id,teamId:Ie,...Wn})}},className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors",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"})]})})]})]})},ae.id)},ur=(ae,Ie,qe,Qe)=>{const ue=X.has(ae),ze=Ce&&We===ae&&le?.fromTeamId!==ae,Ve=ae!=="_ungrouped"?($n.byTeam.get(ae)??[])[0]:void 0,tt=Ve&&u==="channel"&&f===Ve.channelKey,ot=te===ae;return t.jsxs("div",{"data-team-id":ae,className:`mb-1 rounded-lg transition-all duration-500 ${ze?"ring-1 ring-brand-500/50 bg-brand-500/5":""} ${ot?"ring-2 ring-brand-500 bg-brand-500/10":""}`,onPointerEnter:()=>{Ce&&kt(ae)},onPointerLeave:()=>{Ce&&We===ae&&kt(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{Ve?g(Ve.channelKey):dr(ae)},onContextMenu:At=>{if(!R||!Ie)return;At.preventDefault();const Sn=Ut(At);B({teamId:ae,...Sn})},className:`flex-1 flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs transition-colors min-w-0 ${tt?"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 ${tt?"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:[lt===ae?t.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-secondary text-[11px] font-medium outline-none w-full",value:Lt,onChange:At=>bn(At.target.value),onBlur:()=>dn(ae),onKeyDown:At=>{At.key==="Enter"&&dn(ae),At.key==="Escape"&&ut(null)},onClick:At=>At.stopPropagation(),autoFocus:!0}):t.jsx("span",{className:"truncate font-medium text-[11px] leading-tight block",children:Qe}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:[qe.length," members"]})]})]}),t.jsx("button",{onClick:()=>dr(ae),className:"w-7 h-7 flex items-center justify-center text-fg-secondary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:ue?"Expand":"Collapse",children:t.jsx("svg",{className:`w-3.5 h-3.5 transition-transform duration-150 ${ue?"":"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&&Ie&&t.jsx("button",{onClick:At=>{if(At.stopPropagation(),Z?.teamId===ae)B(null);else{const Sn=Ut(At);B({teamId:ae,...Sn})}},className:"w-7 h-7 flex items-center justify-center text-fg-secondary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:"More options",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("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"})]})})]}),ze&&Ce&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:"Drop here"}),!ue&&t.jsx("div",{className:"ml-1",children:qe.map(At=>sr(At,ae==="_ungrouped"?void 0:ae))})]},ae)},$n=y.useMemo(()=>{const ae=new Map,Ie=[];for(const qe of d)if(qe.teamId){const Qe=ae.get(qe.teamId)??[];Qe.push(qe),ae.set(qe.teamId,Qe)}else{const Qe=s.find(ue=>qe.name.toLowerCase().includes(ue.name.toLowerCase())||ue.name.toLowerCase().includes(qe.name.toLowerCase()));if(Qe){const ue=ae.get(Qe.id)??[];ue.push(qe),ae.set(Qe.id,ue)}else Ie.push(qe)}return{byTeam:ae,unmatched:Ie}},[d,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:N?{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:dt,disabled:Ee,title:ve?"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 ${ve?"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:ve?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:J,children:t.jsxs("div",{className:"relative flex-1",children:[t.jsxs("button",{onClick:()=>W(!D),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 ${D?"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"})})]}),D&&t.jsxs("div",{ref:ae=>{if(!ae)return;const Ie=ae.getBoundingClientRect(),qe=window.innerWidth,Qe=8;Ie.right>qe-Qe&&(ae.style.left="auto"),Ie.right>qe-Qe&&(ae.style.right="0"),Ie.left<Qe&&(ae.style.left="0",ae.style.right="auto")},className:"absolute left-0 top-full mt-1 w-48 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-lg shadow-xl z-30 overflow-hidden",children:[t.jsxs("button",{onClick:()=>{W(!1),G(!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:()=>{W(!1),bt.navigate(ge.STORE)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),t.jsx("rect",{x:"14",y:"14",width:"7",height:"7"}),t.jsx("rect",{x:"3",y:"14",width:"7",height:"7"})]}),"Add Agent"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Create from templates"})]}),t.jsxs("button",{onClick:()=>{W(!1),H(!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:()=>{W(!1),T({})},className:"w-full text-left px-4 py-2.5 text-xs text-green-600 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),t.jsx("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]}),"Add Human"]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:"Add a human team member"})]})]})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[n.length===0&&s.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:"No agents yet"}),$n.unmatched.map(ae=>t.jsxs("button",{onClick:()=>g(ae.channelKey),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${u==="channel"&&f===ae.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 ${u==="channel"&&f===ae.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:ae.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary leading-tight mt-0.5",children:"Group Chat"})]}),ae.memberCount!==void 0&&ae.memberCount>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary shrink-0",children:ae.memberCount})]},ae.id)),s.map(ae=>{const Ie=Mn.byTeam.get(ae.id)??[];return Ie.length===0&&(!ae.members||ae.members.length===0)?null:ur(ae.id,ae,Ie,ae.name)}),s.filter(ae=>(Mn.byTeam.get(ae.id)??[]).length===0&&(!ae.members||ae.members.length===0)).map(ae=>ur(ae.id,ae,[],ae.name)),Mn.ungrouped.length>0&&ur("_ungrouped",null,Mn.ungrouped,"Other"),s.length===0&&n.length>0&&n.map(ae=>sr(ae)),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:()=>b(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 ${u==="dm"&&(x===e.id||!x)?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx(Ys,{name:e.name,avatarUrl:e.avatarUrl,size:24,bgClass:u==="dm"&&(x===e.id||!x)?"bg-brand-600":"bg-brand-500/15 text-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[11px] leading-tight",children:e.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:"My Notes"})]}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),l.filter(ae=>ae.id!==e?.id).map(ae=>t.jsxs("button",{onClick:()=>b(ae.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${u==="dm"&&x===ae.id?"bg-green-500/10 text-green-600":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsx(Ys,{name:ae.name,avatarUrl:ae.avatarUrl,size:24,bgClass:u==="dm"&&x===ae.id?"bg-green-600":"bg-green-500/10 text-green-600"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[11px] leading-tight",children:ae.name}),t.jsx("div",{className:"text-fg-tertiary truncate text-[10px] leading-tight mt-0.5",children:ae.email||ae.role})]}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shrink-0"})]},ae.id))]})]})]}),M&&t.jsx("div",{className:"w-1 cursor-col-resize shrink-0 group relative",onMouseDown:M,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 ae=Mn.byTeam.get(Z.teamId)??[],Ie=ae.some(ze=>ze.status==="offline"),qe=ae.some(ze=>ze.status==="idle"||ze.status==="working"),Qe=ae.some(ze=>ze.status==="paused"),ue=ae.some(ze=>ze.status!=="offline");return t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)]",style:{left:Z.x,top:Z.y},onClick:ze=>ze.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{const ze=_n.get(Z.teamId);ze&&(ut(Z.teamId),bn(ze.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"]}),Ie&&t.jsxs("button",{onClick:()=>{$t(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"]}),ue&&t.jsxs("button",{onClick:()=>{$t(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"]}),qe&&t.jsxs("button",{onClick:()=>{$t(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"]}),Qe&&t.jsxs("button",{onClick:()=>{$t(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),bt.navigate(ge.STORE)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Agent"]}),t.jsxs("button",{onClick:()=>{B(null),T({teamId: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"]}),Y.length>0&&t.jsxs("button",{onClick:()=>{B(null),O(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 ze=_n.get(Z.teamId);ze&&_t(Z.teamId,ze.name),B(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Delete Team"]})]})})(),F&&(()=>{const ae=n.find(ue=>ue.id===F.agentId);if(!ae)return null;const qe=(F.teamId?_n.get(F.teamId):void 0)?.managerId===ae.id,Qe=ae.id===e?.id;return t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)]",style:{left:F.x,top:F.y},onClick:ue=>ue.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{K(null),C(ae.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"]}),ae.status==="offline"?t.jsxs("button",{onClick:()=>{ye(ae.id,"offline"),K(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Start"]}):t.jsxs("button",{onClick:()=>{ye(ae.id,ae.status??"idle"),K(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),"Stop"]}),F.teamId&&!qe&&t.jsxs("button",{onClick:()=>{Hn(F.teamId,ae.id,"agent"),K(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Set as Manager"]}),F.teamId&&t.jsxs("button",{onClick:()=>{Ge(F.teamId,ae.id),K(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("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(ue=>ue.id!==F.teamId).map(ue=>t.jsx("button",{onClick:async()=>{F.teamId&&await se.teams.removeMember(F.teamId,ae.id),await se.teams.addMember(ue.id,ae.id,"agent"),w(),k(),Xt(),K(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:ue.name},ue.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!Qe&&t.jsxs("button",{onClick:()=>{it(ae.id,ae.name),K(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Remove from org"]})]})})(),P&&t.jsx(LA,{onClose:()=>G(!1),onCreate:async(ae,Ie)=>{try{const{team:qe}=await se.teams.create(ae,Ie);G(!1),w(),re(qe.id),setTimeout(()=>{document.querySelector(`[data-team-id="${qe.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},300),setTimeout(()=>re(null),3e3)}catch(qe){alert(`Failed to create team: ${qe instanceof Error?qe.message:String(qe)}`)}}}),$!==null&&t.jsx(IA,{teamId:$.teamId,teams:s,onClose:()=>T(null),onAdd:async(ae,Ie,qe,Qe,ue)=>{await se.users.create(ae,Ie,void 0,qe,Qe,ue),T(null),w()}}),z!==null&&t.jsx(zA,{teamId:z,ungrouped:Y,onClose:()=>O(null),onAdd:async(ae,Ie)=>{await se.teams.addMember(z,ae,Ie),O(null),w(),Xt()}}),V&&t.jsx($A,{onClose:()=>H(!1),onConnected:()=>{H(!1),k(),w()}}),pt&&t.jsx(xw,{title:pt.title,message:pt.message,confirmLabel:pt.confirmLabel,checkboxes:pt.checkboxes,onConfirm:ae=>{pt.onConfirm(ae),et(null)},onCancel:()=>et(null)}),oe&&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 ${oe.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:oe.message})]})}const HA=50,PA=30;function va(e,n,s,l){const i=y.useRef(0),c=y.useRef(0),d=y.useCallback(h=>{i.current=h.touches[0].clientX,c.current=h.touches[0].clientY},[]),u=y.useCallback(h=>{const f=h.changedTouches[0].clientX-i.current,x=h.changedTouches[0].clientY-c.current,p=Math.abs(f),g=Math.abs(x);if(p<HA||Math.atan2(g,p)*(180/Math.PI)>PA)return;if(l?.scrollContainerRef?.current){const k=l.scrollContainerRef.current,C=k.scrollLeft<=1,E=k.scrollLeft+k.clientWidth>=k.scrollWidth-1;if(f>0&&!C||f<0&&!E)return}const w=e.findIndex(k=>k.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&&l?.onSwipeOutLeft?l.onSwipeOutLeft():f<0&&w===e.length-1&&l?.onSwipeOutRight&&l.onSwipeOutRight()},[e,n,s,l]);return{onTouchStart:d,onTouchEnd:u}}const sv=[{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:"♡"}],UA={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function Yd(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function qA({agentId:e,onBack:n,inline:s,defaultTab:l,onSwipeBack:i,highlightMailboxId:c}){const d=Yr(),[u,h]=y.useState(null),[f,x]=y.useState(l??"overview"),[p,g]=y.useState(null),b=y.useMemo(()=>sv.map(N=>({id:N.key})),[]),w=y.useMemo(()=>({onSwipeOutLeft:i}),[i]),k=va(b,f,x,w),C=y.useRef(null);y.useEffect(()=>{const N=C.current;if(!N)return;N.querySelector('[data-active="true"]')?.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[f]);const E=y.useCallback(()=>{se.agents.get(e).then(h).catch(()=>{})},[e]);if(y.useEffect(()=>(x(l??"overview"),g(null),E(),se.externalAgents.list().then(A=>{const R=A.agents.find(_=>_.markusAgentId===e);g(R??null)}).catch(()=>{}),Zt.on("agent:update",A=>{A.payload.agentId===e&&E()})),[e,E]),!u)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading agent..."});const M=UA[u.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(Ys,{name:u.name,avatarUrl:u.avatarUrl,size:40,className:"rounded-xl"}),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:u.name}),t.jsx("span",{className:`w-2 h-2 rounded-full ${M}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:u.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"}),u.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:[u.role,u.roleDescription?` — ${u.roleDescription}`:""]})]}),t.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[!s&&t.jsxs("button",{onClick:()=>bt.navigate(ge.TEAM,{agentId:e}),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors flex items-center gap-1",children:[t.jsx("span",{children:"◈"})," Chat"]}),t.jsxs("button",{onClick:async()=>{if(u)try{const{filesMap:N}=await se.agents.getFilesMap(e),A={type:"agent",name:tj(u.name,u.name),displayName:u.name,version:"1.0.0",description:u.roleDescription??u.role,author:"",category:"general",tags:[],agent:{roleName:u.role,agentRole:u.agentRole},dependencies:{skills:u.skills??[]}};await Bn.publishViaProxy({itemType:"agent",name:u.name,description:A.description,category:"general",config:A,files:N}),alert(`Published "${u.name}" to Markus Hub`)}catch(N){alert(`Failed to publish: ${N}`)}},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:C,className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto scrollbar-hide",children:sv.filter(N=>!p||["overview","mind"].includes(N.key)).map(N=>t.jsxs("button",{onClick:()=>x(N.key),"data-active":f===N.key,className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${f===N.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:N.icon}),N.label]},N.key))})]}),t.jsxs("div",{className:"p-5",onTouchStart:d?k.onTouchStart:void 0,onTouchEnd:d?k.onTouchEnd:void 0,children:[f==="overview"&&t.jsx(FA,{agent:u,onUpdate:E,externalInfo:p}),f==="mind"&&t.jsx(s_,{agentId:e,highlightId:c}),f==="files"&&t.jsx(GA,{agentId:e}),f==="tools"&&t.jsx(WA,{tools:u.tools??[]}),f==="skills"&&t.jsx(ZA,{agent:u}),f==="memory"&&t.jsx(QA,{agentId:e}),f==="heartbeat"&&t.jsx(JA,{agentId:e,initialData:u.heartbeat})]})]})}function FA({agent:e,onUpdate:n,externalInfo:s}){const[l,i]=y.useState(!1),[c,d]=y.useState(e.name),[u,h]=y.useState(e.agentRole),[f,x]=y.useState(e.config?.llmConfig?.modelMode??"default"),[p,g]=y.useState(e.config?.llmConfig.primary??""),[b,w]=y.useState(e.config?.llmConfig.fallback??""),[k,C]=y.useState(!1),[E,M]=y.useState({}),[N,A]=y.useState(""),[R,_]=y.useState([]),[Y,q]=y.useState(null),[X,L]=y.useState(null),[P,G]=y.useState([]),[$,T]=y.useState(null),[z,O]=y.useState(null),[V,H]=y.useState("");y.useEffect(()=>{se.settings.getLlm().then(S=>{M(S.providers),A(S.defaultProvider)}).catch(()=>{}),se.tasks.list({assignedAgentId:e.id}).then(S=>_(S.tasks.slice(0,5))).catch(()=>{}),se.usage.agents().then(S=>{const D=S.agents.find(W=>W.agentId===e.id);D&&q(D)}).catch(()=>{}),se.agents.getRecentActivities(e.id).then(S=>G(S.activities)).catch(()=>{}),se.system.storage().then(S=>{H(S.dataDir+"/agents/"+e.id);const D=S.agents.find(W=>W.id===e.id);D&&O(D)}).catch(()=>{})},[e.id]);const Z=Object.entries(E).filter(([,S])=>S.configured).map(([S])=>S),B=e.config?.llmConfig?.modelMode??"default",F=async()=>{C(!0);try{await se.agents.updateConfig(e.id,{name:c,agentRole:u,llmConfig:{modelMode:f,primary:f==="custom"?p:N,fallback:b||void 0}}),n(),i(!1)}catch{}C(!1)},K=()=>{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 S=[{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)"}],D=[{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(Dn,{title:"Identity",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Kn,{label:"Name",children:e.name}),t.jsx(Kn,{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(Kn,{label:"Role Template",children:e.role}),t.jsx(Kn,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx(Kn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Kn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})}),t.jsx(Dn,{title:"Connection Status",children:t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(cr,{label:"Connection",value:s.connected?"Online":"Offline",color:s.connected?"green":"gray"}),t.jsx(cr,{label:"Platform",value:"OpenClaw"}),t.jsx(cr,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(cr,{label:"Last Sync",value:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleTimeString():"Never"})]})}),t.jsx(Dn,{title:"External Agent Details",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Kn,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx(Kn,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx(Kn,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx(Kn,{label:"Last Heartbeat",children:s.lastHeartbeat?new Date(s.lastHeartbeat).toLocaleString():"Never"})]})}),t.jsx(Dn,{title:"Sync Context (received every sync cycle)",children:t.jsx("div",{className:"space-y-1.5",children:D.map(W=>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:W.field}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:W.desc})]},W.field))})}),t.jsx(Dn,{title:"Gateway API Endpoints",children:t.jsx("div",{className:"space-y-1.5",children:S.map(W=>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 ${W.method==="POST"?"text-amber-600":"text-green-600"}`,children:W.method}),t.jsx("span",{className:"font-mono text-[10px] text-fg-secondary shrink-0 pt-0.5",children:W.path}),t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:W.desc})]},W.path))})}),R.length>0&&t.jsx(Dn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>bt.navigate(ge.WORK),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:R.map(W=>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[W.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:W.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:W.status.replace(/_/g," ")})]},W.id))})})]})}return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(Dn,{title:"Identity",action:l?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>i(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:F,disabled:k,className:"text-xs text-brand-500 hover:text-brand-500",children:k?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>{i(!0),d(e.name),h(e.agentRole),x(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:"flex items-start gap-4 mb-3",children:[t.jsx(Gx,{currentUrl:e.avatarUrl,name:e.name,size:48,targetType:"agent",targetId:e.id,onUploaded:()=>n()}),t.jsxs("div",{className:"flex-1 min-w-0 pt-1",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:e.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[e.role," · ",e.agentRole??"worker"]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Kn,{label:"Name",children:l?t.jsx("input",{className:"input-sm",value:c,onChange:S=>d(S.target.value)}):e.name}),t.jsx(Kn,{label:"Agent Role",children:l?t.jsx("div",{className:"flex gap-1.5",children:["worker","manager"].map(S=>t.jsx("button",{onClick:()=>h(S),className:`px-2 py-1 text-[10px] rounded border transition-colors capitalize ${u===S?S==="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:S},S))}):t.jsx("span",{className:e.agentRole==="manager"?"text-amber-600":"text-blue-600",children:e.agentRole==="manager"?"★ Manager":"◆ Worker"})}),t.jsx(Kn,{label:"Role Template",children:e.role}),t.jsx(Kn,{label:"Agent ID",mono:!0,children:e.id}),t.jsx(Kn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Kn,{label:"Created",children:e.config?.createdAt?new Date(e.config.createdAt).toLocaleDateString():"—"})]})]}),t.jsxs(Dn,{title:"Runtime Status",children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(cr,{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(cr,{label:"Tokens Today",value:String(e.state.tokensUsedToday)}),t.jsx(cr,{label:"Active Tasks",value:String(e.state.activeTaskIds?.length??0)}),t.jsx(cr,{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(S=>e.state.activeTaskIds?.includes(S.id)).map(S=>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:S.title}),t.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:S.status.replace(/_/g," ")})]},S.id))})]}),t.jsx("div",{className:"flex gap-2 mt-4 pt-3 border-t border-border-default/50",children:t.jsx("button",{onClick:K,className:"px-3 py-1.5 text-xs border border-border-default rounded-lg hover:border-brand-500 transition-colors",children:e.state.status==="offline"?"▶ Start":"⏹ Stop"})})]}),Y&&t.jsx(Dn,{title:"Usage",children:t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(cr,{label:"Total Tokens",value:Yd(Y.totalTokens)}),t.jsx(cr,{label:"Requests",value:String(Y.requestCount)}),t.jsx(cr,{label:"Tool Calls",value:String(Y.toolCalls)}),t.jsx(cr,{label:"Prompt Tokens",value:Yd(Y.promptTokens)}),t.jsx(cr,{label:"Completion Tokens",value:Yd(Y.completionTokens)}),t.jsx(cr,{label:"Est. Cost",value:`$${Y.estimatedCost<.01?Y.estimatedCost.toFixed(4):Y.estimatedCost.toFixed(2)}`})]})}),z&&t.jsxs(Dn,{title:"Storage",action:t.jsx("button",{onClick:()=>{se.system.openPath(V)},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:iv(z.size)}),t.jsx("span",{className:"text-xs text-fg-tertiary font-mono truncate",children:V})]}),t.jsx("div",{className:"grid grid-cols-3 gap-3",children:z.subItems.filter(S=>S.size>0).map(S=>t.jsx(cr,{label:S.name,value:iv(S.size)},S.name))})]}),t.jsx(Dn,{title:"LLM Configuration",children:t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[t.jsx(Kn,{label:"Model Mode",children:l?t.jsx("div",{className:"flex gap-1.5",children:["default","custom"].map(S=>t.jsx("button",{onClick:()=>x(S),className:`px-2.5 py-1 text-[10px] rounded border transition-colors capitalize ${f===S?S==="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:S==="default"?"System Default":"Custom"},S))}):t.jsx("span",{className:`text-xs ${B==="custom"?"text-amber-600":"text-brand-500"}`,children:B==="custom"?"⚙ Custom":"◎ System Default"})}),t.jsx(Kn,{label:"Primary Model",children:l?f==="custom"?t.jsxs("select",{className:"input-sm",value:p,onChange:S=>g(S.target.value),children:[Z.map(S=>t.jsxs("option",{value:S,children:[S," (",E[S]?.model,")"]},S)),!Z.includes(p)&&p&&t.jsx("option",{value:p,children:p})]}):t.jsxs("span",{className:"text-xs text-fg-secondary italic",children:["follows system default (",N||"...",")"]}):t.jsx("span",{className:"font-mono text-xs",children:B==="custom"?e.config?.llmConfig.primary??"—":t.jsxs("span",{className:"text-fg-secondary",children:[N||e.config?.llmConfig.primary||"—"," ",t.jsx("span",{className:"text-fg-tertiary",children:"(system default)"})]})})}),t.jsx(Kn,{label:"Fallback",children:l?t.jsxs("select",{className:"input-sm",value:b,onChange:S=>w(S.target.value),children:[t.jsx("option",{value:"",children:"none"}),Z.map(S=>t.jsx("option",{value:S,children:S},S))]}):t.jsx("span",{className:"font-mono text-xs",children:e.config?.llmConfig.fallback??"none"})}),t.jsx(Kn,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx(Kn,{label:"Max Tokens/Day",children:e.config?.llmConfig.maxTokensPerDay??"unlimited"})]})}),R.length>0&&t.jsx(Dn,{title:"Recent Tasks",action:t.jsx("button",{onClick:()=>bt.navigate(ge.WORK),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"View all →"}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:R.map(S=>{const D=X===S.id,W=["in_progress","failed","completed","review"].includes(S.status);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>W?L(D?null:S.id):void 0,className:`w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors ${W?"hover:bg-surface-elevated/40 cursor-pointer":"cursor-default"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${I[S.status]??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:S.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary capitalize shrink-0",children:S.status.replace(/_/g," ")}),W&&t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:D?"▲":"▼"})]}),D&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(pw,{taskId:S.id,isLive:S.status==="in_progress"})})]},S.id)})})}),P.filter(S=>S.type==="heartbeat").length>0&&t.jsx(Dn,{title:"Recent Heartbeats",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[P.filter(S=>S.type==="heartbeat").length," runs"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:P.filter(S=>S.type==="heartbeat").map(S=>{const D=$===S.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>T(D?null:S.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:S.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(S.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:D?"▲":"▼"})]}),D&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(lu,{agentId:e.id,activityId:S.id})})]},S.id)})})}),P.filter(S=>S.type==="chat").length>0&&t.jsx(Dn,{title:"Recent A2A Communications",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[P.filter(S=>S.type==="chat").length," conversations"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:P.filter(S=>S.type==="chat").map(S=>{const D=$===S.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>T(D?null:S.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:S.label}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(S.startedAt).toLocaleString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:D?"▲":"▼"})]}),D&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(lu,{agentId:e.id,activityId:S.id})})]},S.id)})})})]})}function VA(e,n){const s=e.split(`
|
|
52
|
+
`),l=n.split(`
|
|
53
|
+
`),i=s.length,c=l.length,d=Array.from({length:i+1},()=>new Array(c+1).fill(0));for(let g=i-1;g>=0;g--)for(let b=c-1;b>=0;b--)d[g][b]=s[g]===l[b]?d[g+1][b+1]+1:Math.max(d[g+1][b],d[g][b+1]);const u=[];let h=0,f=0,x=1,p=1;for(;h<i||f<c;)h<i&&f<c&&s[h]===l[f]?(u.push({type:"equal",content:s[h],oldLineNum:x++,lineNum:p++}),h++,f++):f<c&&(h>=i||d[h][f+1]>=d[h+1][f])?(u.push({type:"add",content:l[f],lineNum:p++}),f++):(u.push({type:"remove",content:s[h],oldLineNum:x++}),h++);return u}function av(e){return e.match(/\S+|\s+/g)??[""]}function lv({oldText:e,newText:n,mode:s}){const l=av(e),i=av(n),c=l.length,d=i.length,u=Array.from({length:c+1},()=>new Array(d+1).fill(0));for(let p=c-1;p>=0;p--)for(let g=d-1;g>=0;g--)u[p][g]=l[p]===i[g]?u[p+1][g+1]+1:Math.max(u[p+1][g],u[p][g+1]);const h=[];let f=0,x=0;for(;f<c||x<d;)f<c&&x<d&&l[f]===i[x]?(h.push({text:s==="remove"?l[f]:i[x],changed:!1}),f++,x++):x<d&&(f>=c||u[f][x+1]>=u[f+1][x])?(s==="add"&&h.push({text:i[x],changed:!0}),x++):(s==="remove"&&h.push({text:l[f],changed:!0}),f++);return t.jsx("span",{children:h.map((p,g)=>p.changed?t.jsx("span",{className:s==="add"?"bg-green-500/30 rounded-sm":"bg-red-500/30 rounded-sm",children:p.text},g):t.jsx("span",{children:p.text},g))})}function YA({agent:e,template:n,templateId:s}){const l=y.useMemo(()=>VA(e,n),[e,n]),[i,c]=y.useState(!0),d=3,u=y.useMemo(()=>{const g=l.map((C,E)=>C.type!=="equal"?E:-1).filter(C=>C>=0);if(g.length===0)return[];const b=[];let w=Math.max(0,g[0]-d),k=Math.min(l.length-1,g[0]+d);for(let C=1;C<g.length;C++){const E=Math.max(0,g[C]-d),M=Math.min(l.length-1,g[C]+d);E<=k+1||(b.push({start:w,end:k}),w=E),k=M}return b.push({start:w,end:k}),b},[l]),h=(g,b,w)=>{const k=g.type==="add"?"+":g.type==="remove"?"-":" ",C=g.type==="add"?"bg-green-500/8":g.type==="remove"?"bg-red-500/8":"",E=g.type==="add"?"text-green-600/90":g.type==="remove"?"text-red-500/80":"text-fg-tertiary",M=g.type==="add"?"text-green-500":g.type==="remove"?"text-red-500":"text-fg-muted",N=g.type==="remove"?g.oldLineNum:g.lineNum;let A=null;return g.type==="remove"&&b+1<w.length&&w[b+1].type==="add"?A=t.jsx(lv,{oldText:g.content,newText:w[b+1].content,mode:"remove"}):g.type==="add"&&b>0&&w[b-1].type==="remove"&&(A=t.jsx(lv,{oldText:w[b-1].content,newText:g.content,mode:"add"})),t.jsxs("div",{className:`flex ${C} hover:brightness-95 transition-colors`,children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-[10px] text-fg-muted/50 select-none leading-[20px]",children:N??""}),t.jsx("span",{className:`w-4 shrink-0 text-center text-[11px] font-mono ${M} select-none leading-[20px]`,children:k}),t.jsxs("span",{className:`flex-1 text-[11px] font-mono ${E} whitespace-pre-wrap break-words leading-[20px]`,children:[A??g.content,g.content===""&&" "]})]},b)},f=l.filter(g=>g.type==="add").length,x=l.filter(g=>g.type==="remove").length,p=i?u.flatMap(g=>{const b=[];for(let w=g.start;w<=g.end;w++)b.push({...l[w],_idx:w});return b}):l.map((g,b)=>({...g,_idx:b}));return t.jsxs("div",{className:"mb-3 border border-border-default rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-elevated/80 border-b border-border-default",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:["Diff: Current vs Template (",s,")"]}),t.jsxs("span",{className:"text-[10px] text-green-500 font-mono",children:["+",f]}),t.jsxs("span",{className:"text-[10px] text-red-500 font-mono",children:["-",x]})]}),t.jsx("button",{onClick:()=>c(g=>!g),className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:i?"Show full file":"Show changes only"})]}),t.jsxs("div",{className:"max-h-72 overflow-y-auto bg-surface-primary/50",children:[i&&u.length>0&&u[0].start>0&&t.jsxs("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-b border-border-default/30",children:["··· ",u[0].start," lines hidden ···"]}),p.map((g,b)=>{const w=b>0?p[b-1]:null,k=i&&w&&g._idx-w._idx>1;return t.jsxs("div",{children:[k&&t.jsx("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-y border-border-default/30",children:"···"}),h(g,g._idx,l)]},b)}),i&&u.length>0&&u[u.length-1].end<l.length-1&&t.jsxs("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-t border-border-default/30",children:["··· ",l.length-1-u[u.length-1].end," lines hidden ···"]}),u.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:"Files are identical"})]})]})}function GA({agentId:e}){const[n,s]=y.useState([]),[l,i]=y.useState(!0),[c,d]=y.useState(null),[u,h]=y.useState(""),[f,x]=y.useState(!1),[p,g]=y.useState(!1),[b,w]=y.useState(null),[k,C]=y.useState(!1),[E,M]=y.useState(null),[N,A]=y.useState(!1),[R,_]=y.useState(null),Y=y.useCallback(()=>{i(!0),Promise.all([se.agents.getFiles(e),se.agents.roleStatus(e).catch(()=>null)]).then(([H,Z])=>{s(H.files),w(Z),H.files.length>0&&!c&&(d(H.files[0].name),h(H.files[0].content))}).catch(()=>{}).finally(()=>i(!1))},[e]);y.useEffect(()=>{Y()},[Y]);const q=H=>{const Z=n.find(B=>B.name===H);Z&&(d(H),h(Z.content),g(!1),M(null))},X=async()=>{if(c){x(!0);try{await se.agents.updateFile(e,c,u),s(H=>H.map(Z=>Z.name===c?{...Z,content:u}:Z)),g(!1),c==="ROLE.md"&&await se.agents.updateSystemPrompt(e,u)}catch{}x(!1)}},L=async H=>{C(!0);try{await se.agents.roleSync(e,H?[H]:void 0),M(null),g(!1),_(null),Y()}catch{}C(!1)},P=async H=>{A(!0);try{const Z=await se.agents.roleSmartSync(e,H);if(Z.success&&Z.mergedContent){const B=n.find(F=>F.name===H);_({file:H,mergedContent:Z.mergedContent,explanation:Z.explanation,previousContent:B?.content??u}),h(Z.mergedContent),g(!0),M(null)}}catch{}A(!1)},G=()=>{R&&(h(R.previousContent),s(H=>H.map(Z=>Z.name===R.file?{...Z,content:R.previousContent}:Z)),g(!1),_(null))},$=async H=>{if(E?.file===H){M(null);return}try{const Z=await se.agents.roleDiff(e,H);Z.agentContent!=null&&Z.templateContent!=null&&M({file:H,agent:Z.agentContent,template:Z.templateContent})}catch{}};if(l)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading files..."});const T={"ROLE.md":"System Prompt / Role Definition","HEARTBEAT.md":"Heartbeat Tasks","POLICIES.md":"Policies & Guardrails","CONTEXT.md":"Context & Instructions"},z=b?.files.filter(H=>H.status==="modified"||H.status==="added_in_template")??[],O=b?.hasTemplate&&!b.isUpToDate,V=c?z.some(H=>H.file===c):!1;return t.jsxs("div",{className:"space-y-4",children:[O&&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:[z.length," file",z.length>1?"s":""," differ from the ",t.jsx("code",{className:"px-1 py-0.5 bg-amber-500/10 rounded text-amber-600",children:b.templateId})," template:"," ",z.map(H=>H.file).join(", ")]})]}),t.jsx("button",{onClick:()=>L(),disabled:k,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:k?"Syncing...":"Sync All"})]}),t.jsxs(Dn,{title:"Agent Configuration Files",action:b?.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 ${b.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:b.templateId}),b.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(H=>{const Z=z.some(B=>B.file===H.name);return t.jsxs("button",{onClick:()=>q(H.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${c===H.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[H.name,Z&&t.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},H.name)})}),c&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary",children:T[c]??c}),t.jsxs("div",{className:"flex gap-2 items-center",children:[V&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>$(c),className:"px-2.5 py-1 text-[11px] text-amber-600 hover:text-amber-600 border border-amber-500/30 hover:border-amber-500/50 rounded-lg transition-colors",children:E?.file===c?"Hide Diff":"View Diff"}),t.jsx("button",{onClick:()=>P(c),disabled:N||k,className:"px-2.5 py-1 text-[11px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",title:"Use AI to intelligently merge template changes while preserving your customizations",children:N?"Merging...":"Smart Sync"}),t.jsx("button",{onClick:()=>L(c),disabled:k,className:"px-2.5 py-1 text-[11px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",title:"Overwrite with template content",children:k?"Syncing...":"Sync This File"})]}),R?.file===c&&t.jsx("button",{onClick:G,className:"px-2.5 py-1 text-[11px] text-red-500 hover:text-red-400 border border-red-500/30 hover:border-red-500/50 rounded-lg transition-colors",title:"Undo smart sync and restore previous content",children:"Undo Merge"}),p&&t.jsx("span",{className:"text-[10px] text-amber-600",children:"unsaved"}),t.jsx("button",{onClick:X,disabled:f||!p,className:`px-3 py-1 text-xs rounded-lg transition-colors ${p?"bg-brand-600 hover:bg-brand-500 text-white":"bg-surface-elevated text-fg-tertiary cursor-default"}`,children:f?"Saving...":"Save"})]})]}),E?.file===c&&t.jsx(YA,{agent:E.agent,template:E.template,templateId:b?.templateId??""}),R?.file===c&&t.jsxs("div",{className:"mb-3 bg-brand-600/8 border border-brand-500/25 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t.jsx("span",{className:"text-[10px] font-semibold text-brand-500 uppercase tracking-wider",children:"Smart Sync Result"}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"— review and save to apply"})]}),t.jsx("p",{className:"text-[11px] text-fg-secondary whitespace-pre-wrap leading-relaxed",children:R.explanation})]}),t.jsx("textarea",{value:u,onChange:H=>{h(H.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}),c==="ROLE.md"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-2",children:"Changes to ROLE.md will update the agent's runtime system prompt immediately."})]}),n.length===0&&t.jsx(Si,{text:"No configuration files found for this role"})]})]})}const XA={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 KA(e){const n=new Map,s=new Set;for(const[c,d]of Object.entries(XA)){const u=e.filter(h=>d.some(f=>h.name.startsWith(f)));u.length>0&&(n.set(c,u),u.forEach(h=>s.add(h.name)))}const l=e.filter(c=>!s.has(c.name));for(const c of l){const d=c.name.indexOf("__");if(d>0){const h=`MCP: ${c.name.slice(0,d)}`;n.has(h)||n.set(h,[]),n.get(h).push(c),s.add(c.name)}}const i=e.filter(c=>!s.has(c.name));return i.length>0&&n.set("Other",i),[...n.entries()].map(([c,d])=>({category:c,tools:d}))}function WA({tools:e}){const n=KA(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(Dn,{title:s.category,children:t.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.tools.map(l=>t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium font-mono",children:l.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:l.description})]})]},l.name))})},s.category)),e.length===0&&t.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:"No tools registered"})]})}function ZA({agent:e}){const n=e.proficiency??{},[s,l]=y.useState(null),[i,c]=y.useState(null),[d,u]=y.useState(!1),h=e.availableSkills??[],f=new Map;for(const k of h){const C=k.category||"custom";f.has(C)||f.set(C,[]),f.get(C).push(k)}const x=async k=>{if(s===k){l(null),c(null);return}l(k),u(!0);try{const C=await fetch(`/api/skills/${encodeURIComponent(k)}`);if(C.ok){const E=await C.json();c(E.skill)}else c(null)}catch{c(null)}u(!1)},p={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=k=>{const C=n[k.name],E=C&&C.uses>0?Math.round(C.successes/C.uses*100):null,M=s===k.name;return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-lg border cursor-pointer transition-all ${M?"bg-brand-500/10 border-brand-500/40":"bg-surface-elevated/30 border-border-default/30 hover:border-gray-600/50"}`,onClick:()=>x(k.name),children:[t.jsx("span",{className:`text-sm transition-transform ${M?"rotate-90":""}`,children:"▶"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:k.name}),k.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-green-500/15 text-green-500",children:"always-on"}),k.builtIn&&!k.alwaysOn&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-surface-overlay/40 text-fg-tertiary",children:"built-in"}),!k.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:k.description}),C&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[C.uses," uses · ",C.successes," successes",C.lastUsed&&` · last ${new Date(C.lastUsed).toLocaleDateString()}`]})]}),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,"%"]})]})]}),M&&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:d?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading skill details…"}):i?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 ${p[i.category]??p.custom}`,children:i.category}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",i.version]}),i.author&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",i.author]}),i.requiredPermissions?.map(N=>t.jsx("span",{className:"px-1.5 py-0.5 bg-amber-500/10 text-amber-600 text-[10px] rounded",children:N},N))]}),i.description&&t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:i.description}),i.tags&&i.tags.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:i.tags.map(N=>t.jsxs("span",{className:"px-1.5 py-0.5 bg-surface-overlay/40 text-fg-tertiary text-[10px] rounded",children:["#",N]},N))}),(i.toolDetails??i.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 (",(i.toolDetails??i.tools??[]).length,")"]}),t.jsx("div",{className:"space-y-1.5",children:(i.toolDetails??i.tools??[]).map(N=>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:N.name}),N.description&&t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:N.description})]},N.name))})]})]}):t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Skill details not available (skill may not be registered in the store)"})})]},k.name)},b=["development","productivity","browser","communication","devops","data","platform","custom"],w=[...f.entries()].sort((k,C)=>{const E=b.indexOf(k[0]),M=b.indexOf(C[0]);return(E===-1?999:E)-(M===-1?999:M)});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(([k,C])=>t.jsx(Dn,{title:t.jsxs("span",{className:"capitalize",children:[k," ",t.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",C.length,")"]})]}),children:t.jsx("div",{className:"space-y-2",children:C.map(E=>g(E))})},k)),h.length===0&&t.jsx(Si,{text:"No skills installed"})]})}function QA({agentId:e}){const[n,s]=y.useState(null),[l,i]=y.useState(!0),[c,d]=y.useState("entries"),[u,h]=y.useState(!1),[f,x]=y.useState(""),[p,g]=y.useState(!1),[b,w]=y.useState(""),[k,C]=y.useState(!1),[E,M]=y.useState(null),[N,A]=y.useState(null),[R,_]=y.useState([]),[Y,q]=y.useState(!1),X=y.useCallback(()=>{i(!0),se.agents.getMemory(e).then($=>{s($),x($.recentDailyLogs??""),w($.longTermMemory??"")}).catch(()=>{}).finally(()=>i(!1))},[e]);y.useEffect(()=>{X()},[X]);const L=async()=>{C(!0),await se.agents.updateDailyMemory(e,f).catch(()=>{}),C(!1),h(!1),X()},P=async()=>{C(!0),await se.agents.updateLongTermMemory(e,"User-edited",b).catch(()=>{}),C(!1),g(!1),X()};if(l)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading memory..."});if(!n)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Failed to load memory data"});const G=[{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:G.map($=>t.jsx("button",{onClick:()=>d($.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${c===$.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:$.label},$.key))}),c==="entries"&&t.jsx(Dn,{title:"Recent Memory Entries",children:n.entries.length===0?t.jsx(Si,{text:"No memory entries"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.entries.map(($,T)=>{const z=E===T;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>M(z?null:T),className:"w-full flex gap-2 px-3 py-2 rounded-lg bg-surface-elevated/20 text-xs text-left hover:bg-surface-elevated/40 transition-colors cursor-pointer",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 ${$.type==="fact"?"bg-blue-500/15 text-blue-600":$.type==="task"?"bg-green-500/15 text-green-600":$.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:$.type}),t.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${z?"":"line-clamp-2"}`,children:$.content}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[$.importance!=null&&t.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${$.importance>=7?"bg-red-500/15 text-red-500":$.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",$.importance]}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date($.timestamp).toLocaleTimeString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:z?"▲":"▼"})]})]}),z&&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:$.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: ",$.type]}),$.importance!=null&&t.jsxs("span",{children:["Importance: ",$.importance]}),t.jsx("span",{children:new Date($.timestamp).toLocaleString()})]})]})]},T)})})}),c==="sessions"&&t.jsx(Dn,{title:"Chat Sessions",children:n.sessions.length===0?t.jsx(Si,{text:"No sessions"}):t.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:n.sessions.map($=>{const T=N===$.id,z=async()=>{if(T){A(null),_([]);return}A($.id),q(!0);try{const O=await se.agents.getMemorySession(e,$.id);_(O.messages)}catch{_([])}q(!1)};return t.jsxs("div",{children:[t.jsxs("button",{onClick:z,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:$.id}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.messageCount," msgs"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date($.updatedAt).toLocaleDateString()}),t.jsx("span",{className:"text-fg-tertiary text-[10px]",children:T?"▲":"▼"})]}),T&&t.jsx("div",{className:"mx-3 mt-1 mb-2 bg-surface-elevated/30 rounded-lg border border-border-default/20 max-h-96 overflow-y-auto",children:Y?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"Loading messages..."}):R.length===0?t.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:"No messages in this session"}):(()=>{const O=new Map;for(const V of R)V.role==="tool"&&V.toolCallId&&O.set(V.toolCallId,V.content);return t.jsx("div",{className:"divide-y divide-gray-700/30",children:R.filter(V=>V.role!=="tool").map((V,H)=>t.jsxs("div",{className:"px-3 py-2",children:[(V.role==="user"||V.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 ${V.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:V.role}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(Fn,{content:V.content,className:"text-xs text-fg-secondary"})})]}),V.role==="assistant"&&t.jsxs("div",{className:"space-y-1",children:[V.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(Fn,{content:V.content,className:"text-xs text-fg-secondary"})})]}),V.toolCalls&&V.toolCalls.length>0&&t.jsx("div",{className:"space-y-0.5",children:V.toolCalls.map(Z=>{let B;try{B=JSON.parse(Z.arguments)}catch{}const F={tool:Z.name,status:"done",args:B,result:O.get(Z.id)};return t.jsx(mw,{entry:{type:"tool",info:F}},Z.id)})})]})]},H))})})()})]},$.id)})})}),c==="daily"&&t.jsx(Dn,{title:"Daily Logs",action:u?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:L,disabled:k,className:"text-xs text-brand-500",children:k?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>h(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:u?t.jsx("textarea",{value:f,onChange:$=>x($.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(Si,{text:"No daily logs"})}),c==="longterm"&&t.jsx(Dn,{title:"Long-term Memory",action:p?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:P,disabled:k,className:"text-xs text-brand-500",children:k?"Saving...":"Save"})]}):t.jsx("button",{onClick:()=>g(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"}),children:p?t.jsx("textarea",{value:b,onChange:$=>w($.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(Si,{text:"No long-term memory stored"})})]})}function JA({agentId:e,initialData:n}){const[s,l]=y.useState(n??null),[i,c]=y.useState(!n),[d,u]=y.useState([]),[h,f]=y.useState(null),[x,p]=y.useState(!1),[g,b]=y.useState(null),w=y.useCallback(()=>{se.agents.getHeartbeat(e).then(l).catch(()=>{}),se.agents.getRecentActivities(e).then(M=>{u(M.activities.filter(N=>N.type==="heartbeat"))}).catch(()=>{})},[e]);y.useEffect(()=>{c(!0),w(),c(!1)},[w]),y.useEffect(()=>Zt.on("agent:update",N=>{N.payload?.agentId===e&&w()}),[e,w]);const k=async()=>{p(!0),b(null);try{const M=await se.agents.triggerHeartbeat(e);b(M.message),setTimeout(()=>b(null),4e3),setTimeout(w,2e3)}catch(M){b(String(M).replace("Error: ",""))}p(!1)};if(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading heartbeat data..."});if(!s)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"No heartbeat data available"});const C=M=>M?M<1e3?`${M}ms`:M<6e4?`${(M/1e3).toFixed(1)}s`:`${(M/6e4).toFixed(1)}m`:null,E=M=>{if(!M)return null;const N=Date.now()-new Date(M).getTime();if(N<0){const A=Math.abs(N);return A<6e4?`in ${Math.ceil(A/1e3)}s`:A<36e5?`in ${Math.ceil(A/6e4)}m`:`in ${(A/36e5).toFixed(1)}h`}return N<6e4?`${Math.floor(N/1e3)}s ago`:N<36e5?`${Math.floor(N/6e4)}m ago`:`${(N/36e5).toFixed(1)}h ago`};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(Dn,{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:k,disabled:x||!s.running,className:"text-[10px] px-2.5 py-1 rounded-md bg-blue-600/20 text-blue-600 hover:bg-blue-600/30 border border-blue-500/30 transition-colors disabled:opacity-40",children:x?"Triggering...":"Trigger Now"})]}),children:[t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(cr,{label:"Status",value:s.running?"Running":"Stopped",color:s.running?"green":"gray"}),t.jsx(cr,{label:"Interval",value:C(s.intervalMs)??"—"}),t.jsx(cr,{label:"Last Run",value:s.lastHeartbeat?E(s.lastHeartbeat)??"—":"Never"}),t.jsx(cr,{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(Dn,{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(Fn,{content:s.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),d.length>0?t.jsx(Dn,{title:"Recent Runs",action:t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[d.length," runs this session"]}),children:t.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:[...d].reverse().map(M=>{const N=h===M.id;return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>f(N?null:M.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[t.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-blue-400"}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:[M.logCount," actions"]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(M.startedAt).toLocaleString()}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary shrink-0 transition-transform ${N?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 4.5l3 3 3-3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})]}),N&&t.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:t.jsx(lu,{agentId:e,activityId:M.id})})]},M.id)})})}):s.lastHeartbeat?null:t.jsx(Dn,{title:"Recent Runs",children:t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx("div",{className:"text-xl mb-2 opacity-40",children:"♡"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:"No heartbeat runs yet this session."}),t.jsx("p",{className:"text-[10px] text-fg-tertiary mt-1",children:s.running?`First heartbeat will trigger in ~${C(s.intervalMs-s.uptimeMs%s.intervalMs)??"soon"}.`:"Heartbeat scheduler is stopped."}),s.running&&t.jsx("button",{onClick:k,disabled:x,className:"mt-3 text-[10px] px-3 py-1.5 rounded-md bg-blue-600/15 text-blue-600 hover:bg-blue-600/25 border border-blue-500/25 transition-colors disabled:opacity-40",children:x?"Triggering...":"Run First Heartbeat Now"})]})})]})}function pw({taskId:e,isLive:n}){const[s,l]=y.useState([]),[i,c]=y.useState(""),[d,u]=y.useState(!0),[h,f]=y.useState("compact");if(y.useEffect(()=>{u(!0),c(""),se.tasks.getLogs(e).then(g=>{l(g.logs),u(!1)}).catch(()=>u(!1))},[e]),y.useEffect(()=>{if(!n)return;const g=Zt.on("task:log",w=>{const k=w.payload;if(k.taskId!==e)return;const C={id:k.id,taskId:k.taskId,agentId:k.agentId,seq:k.seq,type:k.logType,content:k.content,metadata:k.metadata,createdAt:k.createdAt};l(E=>C.id&&E.some(M=>M.id===C.id)?E:[...E,C]),C.type==="text"&&c("")}),b=Zt.on("task:log:delta",w=>{const k=w.payload;k.taskId===e&&c(C=>C+k.text)});return()=>{g(),b()}},[e,n]),d)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(s.length===0&&!i)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No execution logs yet."});const x=s.map(g=>Lh(g)),p=new Set(x.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:x,streamingText:i,isActive:n,onExpand:()=>f("full"),showRounds:p}):t.jsx(Cu,{entries:x,streamingText:i,isActive:n,onCollapse:()=>f("compact"),showRounds:p})})}function lu({agentId:e,activityId:n,isLive:s=!1}){const[l,i]=y.useState([]),[c,d]=y.useState(!0),[u,h]=y.useState("compact");if(y.useEffect(()=>{d(!0),se.agents.getActivityLogs(e,n).then(x=>{i(x.logs),d(!1)}).catch(()=>d(!1))},[e,n]),y.useEffect(()=>s?Zt.on("agent:activity_log",p=>{const g=p.payload;if(g.agentId!==e||g.activityId!==n)return;const b={seq:g.seq,type:g.type,content:g.content,metadata:g.metadata,createdAt:g.createdAt};i(w=>w.some(k=>k.seq===b.seq)?w:[...w,b])}):void 0,[e,n,s]),c)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"Loading..."});if(l.length===0)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No activity logs available."});const f=l.map(x=>Q1(x,n,e)).filter(x=>x!==null);return t.jsx("div",{className:"px-3 py-2",children:u==="compact"?t.jsx(Yx,{entries:f,isActive:s,onExpand:()=>h("full")}):t.jsx(Cu,{entries:f,isActive:s,onCollapse:()=>h("compact")})})}function Dn({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 Kn({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 cr({label:e,value:n,color:s}){const l=s==="green"?"text-green-600":s==="blue"?"text-blue-500":s==="indigo"?"text-brand-500":s==="red"?"text-red-500":"text-fg-secondary";return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-lg font-semibold ${l}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function Si({text:e}){return t.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:e})}function iv(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${n[s]}`}const ov={0:"Critical",1:"High",2:"Normal",3:"Low",4:"Background"},cv={0:"text-red-400",1:"text-amber-400",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},e_={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"},t_={idle:"bg-green-500/20 text-green-300",focused:"bg-brand-500/20 text-brand-300",deciding:"bg-amber-500/20 text-amber-300"},dh={system_event:"⚙",human_chat:"💬",task_comment:"💬",mention:"@",session_reply:"↩",task_status_update:"📋",a2a_message:"🔗",review_request:"👀",requirement_update:"📝",requirement_comment:"💬",daily_report:"📊",heartbeat:"♡",memory_consolidation:"🧠"},n_=[{key:"all",label:"All"},{key:"interaction",label:"Interaction"},{key:"task",label:"Task"},{key:"notification",label:"Notification"},{key:"system",label:"System"}],r_={completed:"bg-green-500",processing:"bg-blue-400 animate-pulse",deferred:"bg-purple-400",merged:"bg-cyan-400",queued:"bg-amber-400",dropped:"bg-red-500"},dv={pending:{label:"Pending",color:"text-gray-400"},assigned:{label:"Assigned",color:"text-blue-400"},in_progress:{label:"In Progress",color:"text-brand-400"},completed:{label:"Completed",color:"text-green-400"},failed:{label:"Failed",color:"text-red-400"},cancelled:{label:"Cancelled",color:"text-gray-500"},review:{label:"Review",color:"text-amber-400"},approved:{label:"Approved",color:"text-green-500"},rejected:{label:"Rejected",color:"text-red-500"},draft:{label:"Draft",color:"text-gray-400"}};function uh(e){const n=e.match(/Comment from .+?:\s*(.+?)(?:\n\n\*\*MANDATORY|\n\n---|\n\n\[|$)/s);if(n?.[1]){const s=n[1].trim().replace(/\n/g," ");return s.length>80?s.slice(0,80)+"…":s}}function uv(e){const n=e.payload,s=n?.summary??"",l=n?.content??"",i=e.metadata?.senderName;switch(e.sourceType){case"task_status_update":{const c=s.match(/^Task "(.+?)" status:/),d=s.match(/status:\s*(\S+)\s*→\s*(\S+)/),u=c?.[1]??s;if(d){const f=d[1],x=d[2],p=dv[f]??{label:f},g=dv[x]??{label:x,color:"text-fg-secondary"};return{title:u,subtitle:`${p.label} → ${g.label}`,badge:g}}const h=s.match(/^Task:\s*(.+)/);return h?{title:h[1]}:{title:u}}case"task_comment":{const c=s.match(/^Comment on task "(.+?)" from (.+?)(\s*\(\+\d+\))?$/),d=uh(l);if(c){const u=d?`${c[2]}: ${d}`:`Comment from ${c[2]}`;return{title:c[1],subtitle:u}}return{title:s}}case"requirement_update":{const c=s.match(/^Requirement "(.+?)"\s+(.*)/);return c?{title:c[1],subtitle:c[2]}:{title:s}}case"requirement_comment":{const c=s.match(/^Comment on requirement "(.+?)" from (.+?)(\s*\(\+\d+\))?$/),d=uh(l);if(c){const u=d?`${c[2]}: ${d}`:`Comment from ${c[2]}`;return{title:c[1],subtitle:u}}return{title:s}}case"human_chat":{const c=l.slice(0,120).replace(/\n/g," ");return{title:i?`Chat from ${i}`:"Human Chat",subtitle:c+(l.length>120?"…":"")}}case"a2a_message":{const c=l.slice(0,120).replace(/\n/g," ");return{title:i?`Message from ${i}`:"Agent Message",subtitle:c+(l.length>120?"…":"")}}case"mention":{const c=s.match(/from (.+)$/),d=uh(l);return{title:c?`Mentioned by ${c[1]}`:"Mention",subtitle:d||void 0}}case"review_request":{const c=l.slice(0,120).replace(/\n/g," ");return{title:i?`Review request from ${i}`:"Review Request",subtitle:c+(l.length>120?"…":"")}}case"session_reply":{const c=l.slice(0,120).replace(/\n/g," ");return{title:i?`Reply in session (${i})`:"Session Reply",subtitle:c+(l.length>120?"…":"")}}case"heartbeat":return{title:"Scheduled heartbeat check-in"};case"daily_report":return{title:"Daily Report"};case"memory_consolidation":return{title:"Memory Consolidation"};case"system_event":{const c=s.match(/^\[Announcement]\s*(.+)/);return c?{title:c[1],subtitle:"System Announcement"}:{title:s||"System Event"}}default:return{title:s||e.sourceType}}}function s_({agentId:e,highlightId:n}){const[s,l]=y.useState(null),[i,c]=y.useState(null),[d,u]=y.useState(!0),[h,f]=y.useState("all"),[x,p]=y.useState("all"),[g,b]=y.useState(n??null),[w,k]=y.useState(n??null),[C,E]=y.useState(!0),M=50,N=y.useCallback(async(_=!0)=>{_&&u(!0);try{const Y=h==="all"?void 0:h,q=x==="all"?void 0:x,[X,L]=await Promise.all([se.agents.getMindState(e),se.agents.getMailbox(e,{limit:M,category:Y,status:q})]);l(X),c(L),E((L.history?.length??0)>=M)}catch{}u(!1)},[e,h,x]),A=y.useCallback(async()=>{if(!i)return;const _=h==="all"?void 0:h,Y=x==="all"?void 0:x;try{const q=await se.agents.getMailbox(e,{limit:M,offset:i.history.length,category:_,status:Y});c(X=>X?{...X,history:[...X.history,...q.history]}:q),E((q.history?.length??0)>=M)}catch{}},[e,i,h,x]);y.useEffect(()=>{b(n??null),k(n??null),N()},[N,n]);const R=y.useRef(!1);return y.useEffect(()=>{if(!w||d)return;if(i?.history?.some(Y=>Y.id===w)){R.current=!1;const Y=document.getElementById(`mbx-${w}`);if(Y){setTimeout(()=>Y.scrollIntoView({behavior:"smooth",block:"center"}),100);const q=setTimeout(()=>k(null),3e3);return()=>clearTimeout(q)}}else C&&!R.current&&(R.current=!0,(async()=>{let Y=i?.history??[],q=C;for(;q;)try{const X=await se.agents.getMailbox(e,{limit:M,offset:Y.length}),L=[...Y,...X.history];Y=L,q=(X.history?.length??0)>=M;const P=X.history.some(G=>G.id===w);if(c(G=>G?{...G,history:L}:X),E(q),P||!q)break}catch{break}R.current=!1})())},[w,d,i,C,e]),y.useEffect(()=>{const _=q=>{q.payload?.agentId===e&&N(!1)},Y=[Zt.on("agent:mailbox",_),Zt.on("agent:decision",_),Zt.on("agent:attention",_),Zt.on("agent:focus",_),Zt.on("agent:update",_),Zt.on("agent:triage",_)];return()=>Y.forEach(q=>q())},[e,N]),d&&!s?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 ${t_[s?.attentionState??"idle"]??"bg-gray-500/20 text-gray-300"}`,children:(s?.attentionState??"idle").toUpperCase()}),s?.currentFocus?(()=>{const _=uv({id:s.currentFocus.mailboxItemId,sourceType:s.currentFocus.type,payload:{summary:s.currentFocus.label,taskId:s.currentFocus.taskId},metadata:{},queuedAt:s.currentFocus.startedAt});return t.jsxs("span",{className:"text-sm text-fg-secondary",children:[dh[s.currentFocus.type]??"●"," ",t.jsx("span",{className:"text-fg-primary font-medium",children:_.title}),_.subtitle&&t.jsx("span",{className:"text-fg-tertiary ml-1.5 text-xs",children:_.subtitle}),t.jsxs("span",{className:"text-fg-tertiary ml-2 text-xs",children:["since ",new Date(s.currentFocus.startedAt).toLocaleTimeString()]})]})})():t.jsx("span",{className:"text-sm text-fg-tertiary",children:"Idle — waiting for new mail"}),t.jsx("button",{onClick:()=>{N()},className:"ml-auto text-xs text-fg-tertiary hover:text-fg-secondary active:text-fg-primary transition-colors",children:"↻ Refresh"})]}),(s?.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 (",s.queuedItems.length,")"]}),t.jsx("div",{className:"space-y-1",children:s.queuedItems.map((_,Y)=>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:Y+1}),t.jsx("span",{className:"text-sm",children:dh[_.sourceType]??"●"}),t.jsx("span",{className:`text-[10px] ${cv[_.priority]??"text-fg-tertiary"}`,children:ov[_.priority]??`P${_.priority}`}),t.jsx("span",{className:"text-fg-secondary truncate flex-1 text-xs",children:_.summary}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(_.queuedAt).toLocaleTimeString()})]},_.id))})]})]}),s?.lastTriage&&t.jsxs("section",{className:"bg-surface-2 rounded-lg border border-indigo-500/20 p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"text-sm",children:"🧠"}),t.jsx("h4",{className:"text-xs font-medium text-indigo-400 uppercase tracking-wider",children:"Triage Decision"}),t.jsx("span",{className:"text-[10px] text-fg-quaternary ml-auto",children:new Date(s.lastTriage.timestamp).toLocaleTimeString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:s.lastTriage.reasoning}),t.jsxs("div",{className:"flex flex-wrap gap-2 mt-2 text-[10px]",children:[t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-green-500/10 text-green-400",children:["Processing: ",s.lastTriage.processedItemId.slice(0,12),"…"]}),s.lastTriage.deferredItemIds.length>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400",children:["Deferred: ",s.lastTriage.deferredItemIds.length]}),s.lastTriage.droppedItemIds.length>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-red-500/10 text-red-400",children:["Dropped: ",s.lastTriage.droppedItemIds.length]})]})]}),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:n_.map(_=>t.jsx("button",{onClick:()=>f(_.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors ${h===_.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:_.label},_.key))})]}),t.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:[{key:"all",label:"All",dot:""},{key:"queued",label:"Queued",dot:"bg-amber-400"},{key:"processing",label:"Processing",dot:"bg-blue-400"},{key:"completed",label:"Completed",dot:"bg-green-500"},{key:"merged",label:"Merged",dot:"bg-cyan-400"},{key:"deferred",label:"Deferred",dot:"bg-purple-400"},{key:"dropped",label:"Dropped",dot:"bg-red-500"}].map(_=>t.jsxs("button",{onClick:()=>p(_.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors flex items-center gap-1 ${x===_.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:[_.dot&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${_.dot}`}),_.label]},_.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(_=>{const Y=g===_.id,q=dh[_.sourceType]??"●",X=uv(_),L=_.metadata?.senderName,P=_.metadata?.senderRole,G=w===_.id;return t.jsxs("div",{id:`mbx-${_.id}`,className:`bg-surface-2 rounded-lg border transition-colors duration-1000 ${G?"border-brand-500 ring-1 ring-brand-500/40":"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:()=>b(Y?null:_.id),children:[t.jsx("span",{className:"text-xs mt-0.5 text-fg-tertiary",children:Y?"▾":"▸"}),t.jsx("span",{className:`w-2 h-2 mt-1.5 rounded-full shrink-0 ${r_[_.status]??"bg-gray-400"}`}),t.jsx("span",{className:"text-sm",children:q}),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 ${Y?"":"truncate"}`,children:X.title}),X.badge&&t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${X.badge.color}`,children:X.badge.label}),t.jsx("span",{className:`text-[10px] shrink-0 ${cv[_.priority]??"text-fg-tertiary"}`,children:ov[_.priority]??""})]}),X.subtitle&&t.jsx("div",{className:`text-[11px] text-fg-secondary mt-0.5 ${Y?"":"truncate"}`,children:X.subtitle}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2 flex-wrap",children:[t.jsx("span",{children:new Date(_.queuedAt).toLocaleString()}),_.completedAt&&t.jsxs("span",{children:["→ ",new Date(_.completedAt).toLocaleTimeString()]}),_.activity&&t.jsxs(t.Fragment,{children:[_.activity.totalTokens>0&&t.jsxs("span",{children:[Yd(_.activity.totalTokens)," tokens"]}),_.activity.totalTools>0&&t.jsxs("span",{children:[_.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:_.sourceType})]}),Y&&t.jsxs("div",{className:"border-t border-border-subtle px-3 py-3 space-y-3",children:[L&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:["From: ",t.jsx("span",{className:"text-fg-secondary",children:L}),P&&t.jsxs("span",{className:"text-fg-tertiary",children:[" (",P,")"]})]}),_.payload?.content&&["human_chat","a2a_message","task_comment","requirement_comment","review_request","session_reply","mention"].includes(_.sourceType)&&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:_.payload.content}),_.decisions&&_.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:_.decisions.map($=>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 ${e_[$.decisionType]??"bg-gray-500/20 text-gray-300"}`,children:$.decisionType}),t.jsx("span",{className:"text-fg-secondary flex-1",children:$.reasoning}),t.jsx("span",{className:"text-fg-tertiary shrink-0",children:new Date($.createdAt).toLocaleTimeString()})]},$.id))})]}),_.activity?t.jsxs("div",{children:[t.jsxs("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:["Activity — ",_.activity.label,t.jsx("span",{className:`ml-2 inline-block px-1 py-0 rounded text-[9px] ${_.activity.success?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:_.activity.success?"✓ Success":"✗ Failed"})]}),_.activity.type==="task"&&_.payload?.taskId?t.jsx(pw,{taskId:_.payload.taskId,isLive:!_.activity.endedAt}):t.jsx(lu,{agentId:e,activityId:_.activity.id,isLive:!_.activity.endedAt})]}):_.status==="processing"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2 animate-pulse",children:"Processing..."}):_.status==="completed"?t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2",children:"No activity log recorded"}):null]})]},_.id)})}),C&&(i?.history?.length??0)>0&&t.jsx("div",{className:"text-center mt-3",children:t.jsx("button",{onClick:A,className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:"Load Earlier..."})})]})]})}const a_=[{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:"⚙"}],fv={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function l_({teamId:e,onBack:n,inline:s}){const[l,i]=y.useState(null),[c,d]=y.useState("overview"),[u,h]=y.useState(""),[f,x]=y.useState(""),[p,g]=y.useState(!1),[b,w]=y.useState(!1),[k,C]=y.useState(""),[E,M]=y.useState(""),[N,A]=y.useState(!1),[R,_]=y.useState(!1),[Y,q]=y.useState(""),[X,L]=y.useState(""),[P,G]=y.useState(!1),[$,T]=y.useState([]),z=y.useRef(null),O=y.useCallback(async()=>{try{const S=(await se.teams.list()).teams.find(W=>W.id===e);S&&i(S);const D=await se.teams.status(e);T(D.agents)}catch{}},[e]),V=y.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");x(I.content)}catch{x("")}},[e]);y.useEffect(()=>{d("overview"),O(),V()},[e,O,V]);const H=async(I,S)=>{A(!0);try{await se.teams.updateFile(e,I,S),I==="ANNOUNCEMENT.md"?(h(S),g(!1)):(x(S),w(!1))}catch{}A(!1)},Z=async()=>{Y.trim()&&(await se.teams.update(e,{name:Y.trim()}),_(!1),O())},B=async()=>{await se.teams.update(e,{description:X}),G(!1),O()};if(!l)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading team..."});const F=l.members.find(I=>I.agentRole==="manager"),K=$.filter(I=>I.status!=="offline").length;return t.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[t.jsxs("div",{className:"px-5 py-3.5 border-b border-border-default bg-surface-secondary sticky top-0 z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-white flex items-center justify-center text-lg font-bold shrink-0",children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h2",{className:"text-base font-semibold",children:l.name}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:[l.members.length," members"]}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-green-500/15 text-green-600 rounded font-medium",children:[K," online"]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:l.description||"No description"})]}),t.jsxs("button",{onClick:async()=>{if(l)try{const{files:I}=await se.teams.getFilesMap(l.id),S=l.members.filter(W=>W.type==="agent"),D={type:"team",name:tj(l.name,l.name),displayName:l.name,version:"1.0.0",description:l.description??"",author:"",category:"general",tags:[],team:{members:S.map(W=>({name:W.name,roleName:W.role,role:W.agentRole??"worker",count:1,skills:[]}))}};await Bn.publishViaProxy({itemType:"team",name:l.name,description:l.description??"",category:"general",config:D,files:I}),alert(`Published "${l.name}" to Markus Hub`)}catch(I){alert(`Failed to publish: ${I}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:n,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]}),t.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:a_.map(I=>t.jsxs("button",{onClick:()=>d(I.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${c===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:[c==="overview"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Manager"}),t.jsx("div",{className:"text-sm font-medium",children:F?.name??l.managerName??"None"})]}),t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team ID"}),t.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:l.id})]})]}),u.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:[u.slice(0,500),u.length>500?"...":""]})]}),t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:"Members"}),t.jsx("div",{className:"space-y-2",children:l.members.map(I=>{const S=$.find(W=>W.id===I.id),D=fv[S?.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 ${D}`}),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)})})]})]}),c==="members"&&t.jsxs("div",{className:"space-y-3",children:[l.members.map(I=>{const S=$.find(W=>W.id===I.id),D=fv[S?.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(Ys,{name:I.name,avatarUrl:I.avatarUrl,size:32,className:"rounded-lg",bgClass:"bg-surface-elevated"}),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 ${D}`}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:S?.status??"offline"}),I.agentRole==="manager"&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I.role," · ",I.type]})]})]},I.id)}),l.members.length===0&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]}),c==="announcements"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Announcements"}),!p&&t.jsx("button",{onClick:()=>{C(u),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"})]}),p?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:k,onChange:I=>C(I.target.value),className:"w-full h-64 bg-surface-secondary border border-border-default rounded-xl p-3 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500 font-mono",placeholder:"Write team announcements here (Markdown supported)..."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>H("ANNOUNCEMENT.md",k),disabled:N,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:N?"Saving...":"Save"}),t.jsx("button",{onClick:()=>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:u.trim()?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:u}):t.jsx("div",{className:"text-sm text-fg-tertiary italic",children:"No announcements yet. Click Edit to add."})})]}),c==="norms"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Working Norms"}),!b&&t.jsx("button",{onClick:()=>{M(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"})]}),b?t.jsxs("div",{className:"space-y-3",children:[t.jsx("textarea",{value:E,onChange:I=>M(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:()=>H("NORMS.md",E),disabled:N,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:N?"Saving...":"Save"}),t.jsx("button",{onClick:()=>w(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors",children:"Cancel"})]})]}):t.jsx("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default min-h-[120px]",children: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."})})]}),c==="settings"&&t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team Name"}),R?t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("input",{ref:z,value:Y,onChange:I=>q(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:()=>_(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm",children:l.name}),t.jsx("button",{onClick:()=>{q(l.name),_(!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"}),P?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:X,onChange:I=>L(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:()=>G(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-fg-secondary",children:l.description||"No description"}),t.jsx("button",{onClick:()=>{L(l.description??""),G(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(i_,{teamId:e,teamName:l.name,onDeleted:n})]})]})]})}function i_({teamId:e,teamName:n,onDeleted:s}){const[l,i]=y.useState(!1),[c,d]=y.useState(!1),[u,h]=y.useState(!1),[f,x]=y.useState(!1);return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-red-900/30 space-y-3",children:[t.jsx("div",{className:"text-sm font-medium text-red-500",children:"Danger Zone"}),l?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',n,'"? This removes the team record from the database.']}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:u,onChange:p=>h(p.target.checked),className:"rounded"}),"Also delete all members in this team"]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:c,onChange:p=>d(p.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()=>{x(!0);try{await se.teams.delete(e,u,{purgeFiles:c}),window.dispatchEvent(new CustomEvent("markus:data-changed")),s()}catch{x(!1)}},className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50",children:f?"Deleting...":"Confirm Delete"}),t.jsx("button",{onClick:()=>i(!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:()=>i(!0),className:"px-4 py-1.5 text-xs bg-red-600/20 hover:bg-red-600/30 text-red-500 rounded-lg transition-colors border border-red-500/30",children:"Delete Team"})]})}function Tu({side:e,defaultWidth:n,minWidth:s,maxWidth:l,collapsedWidth:i=0,storageKey:c}){const[d,u]=y.useState(()=>{try{const b=localStorage.getItem(`${c}_w`);if(b)return Math.max(s,Math.min(l,parseInt(b,10)))}catch{}return n}),[h,f]=y.useState(()=>{try{return localStorage.getItem(`${c}_c`)==="1"}catch{return!1}}),x=y.useRef(!1);y.useEffect(()=>{try{localStorage.setItem(`${c}_w`,String(d))}catch{}},[d,c]),y.useEffect(()=>{try{localStorage.setItem(`${c}_c`,h?"1":"0")}catch{}},[h,c]);const p=y.useCallback(b=>{b.preventDefault(),x.current=!0;const w=b.clientX,k=d,C=M=>{if(!x.current)return;const N=e==="left"?M.clientX-w:w-M.clientX;u(Math.max(s,Math.min(l,k+N)))},E=()=>{x.current=!1,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",E),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",C),document.addEventListener("mouseup",E),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[d,e,s,l]),g=y.useCallback(()=>f(b=>!b),[]);return{width:h?i:d,rawWidth:d,collapsed:h,toggle:g,setCollapsed:f,onResizeStart:p}}function fh(e){const n={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:new Date(e.createdAt).toLocaleTimeString(),rawCreatedAt:e.createdAt,agentId:e.role!=="user"?e.agentId:void 0};if(e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(n.segments=e.metadata.segments.map((s,l)=>s.type==="tool"?{type:"tool",key:`${s.tool}_${l}`,tool:s.tool,status:s.status,args:s.arguments,result:s.result,error:s.error,durationMs:s.durationMs,createdAt:s.createdAt}:{type:"text",content:s.content,thinking:s.thinking,createdAt:s.createdAt})),(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),e.metadata?.activityLog&&(n.isActivityLog=!0,n.activityType=e.metadata.activityType,n.outcome=e.metadata.outcome,n.mailboxItemId=e.metadata.mailboxItemId,n.taskId=e.metadata.taskId,n.requirementId=e.metadata.requirementId,!n.outcome&&n.text.startsWith("[ACTIVITY:"))){const s=n.text.lastIndexOf(" → ");s!==-1&&(n.outcome=n.text.slice(s+3)),n.text=n.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}return n}function Lo(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(),rawCreatedAt:e.createdAt,agentName:e.senderType!=="human"?e.senderName:void 0,agentId:e.senderType!=="human"?e.senderId:void 0,isError:n};if(e.metadata&&e.senderType==="agent"){const l=[],i=e.metadata;if(i.thinking?.length&&l.push({type:"text",content:"",thinking:i.thinking.join(`
|
|
54
|
+
|
|
55
|
+
`)}),i.toolCalls?.length)for(let c=0;c<i.toolCalls.length;c++){const d=i.toolCalls[c];l.push({type:"tool",key:`${d.tool}_${c}`,tool:d.tool,status:d.status==="error"?"error":"done",args:d.arguments,result:d.result,durationMs:d.durationMs})}l.length>0&&(l.push({type:"text",content:e.text}),s.segments=l)}return s}function o_({name:e,agentId:n,agents:s,onViewProfile:l}){const[i,c]=y.useState(!1),d=y.useRef(null),u=n?s.find(h=>h.id===n):s.find(h=>h.name===e);return y.useEffect(()=>{if(!i)return;const h=f=>{d.current&&!d.current.contains(f.target)&&c(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]),u?t.jsxs("span",{ref:d,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>c(!i),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),i&&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(Ys,{name:u.name,avatarUrl:u.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:u.name}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[u.role," · ",u.agentRole??"worker"]})]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u.status==="working"?"bg-blue-400 animate-pulse":u.status==="error"?"bg-red-400":"bg-green-400"}`})]}),t.jsx("button",{onClick:()=>{c(!1),l?.(u.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 c_({agent:e,anchorRect:n,onClose:s,onViewProfile:l}){const i=y.useRef(null);y.useEffect(()=>{const h=f=>{i.current&&!i.current.contains(f.target)&&s()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s]);const c=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?"Online":e.status==="working"?"Working":e.status==="error"?"Error":e.status==="paused"?"Paused":"Offline",u=y.useCallback(h=>{if(!h)return;i.current=h;const f=h.getBoundingClientRect(),x=window.innerWidth,p=window.innerHeight,g=8;f.right>x-g&&(h.style.left=`${Math.max(g,x-f.width-g)}px`),f.left<g&&(h.style.left=`${g}px`),f.bottom>p-g&&(h.style.top=`${Math.max(g,p-f.height-g)}px`)},[]);return t.jsxs("div",{ref:u,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] 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(Ys,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:d}),e.agentRole&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),t.jsx("button",{onClick:()=>{s(),l(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:"View Profile →"})]})}function mv(e){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let s="";const l=n.match(/\{[\s\S]*\}/);if(l)try{const i=JSON.parse(l[0]);s=i.error?.message??i.message??""}catch{}if(!s){const i=n.lastIndexOf(": ");i>=0&&(s=n.slice(i+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 hv({msg:e,onCopy:n,onRetry:s,onResume:l,onReply:i,isCopied:c,isLastAgentMsg:d}){const u=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),h=e.isStopped,f=d!==!1;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:[c?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"})]}),c?"Copied":"Copy"]}),f&&l&&t.jsxs("button",{onClick:()=>l(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-green-500 hover:text-green-400 hover:bg-green-500/10 transition-colors",title:"Resume",children:[t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume"]}),f&&h&&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"]}),f&&u&&!h&&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"]}),f&&!u&&!h&&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 xv(e,n,s){if(!e)return[];const l=[];let i=0;const c=n??"";let u=s?new Date(s).getTime():Date.now();const h=e.some(N=>N.createdAt),f=N=>{if(N.createdAt)return N.createdAt;if(h)return new Date(u).toISOString();const A=new Date(u).toISOString();return N.type==="tool"&&N.durationMs?u+=N.durationMs:u+=1e3,A};let x=!1,p="",g="",b="";const w=()=>{const N=p.trim();N&&l.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:c,seq:i++,type:"text",content:N,createdAt:b,metadata:{isThinking:!0}}),p=""},k=()=>{const N=g.trim();N&&l.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:c,seq:i++,type:"text",content:N,createdAt:b}),g=""},C="<think>",E="</think>",M=N=>{let A=0;for(;A<N.length;)if(x){const R=N.indexOf(E,A);R===-1?(p+=N.slice(A),A=N.length):(p+=N.slice(A,R),x=!1,w(),A=R+E.length)}else{const R=N.indexOf(C,A);R===-1?(g+=N.slice(A),A=N.length):(g+=N.slice(A,R),k(),x=!0,A=R+C.length)}};for(const N of e)if(b=f(N),N.type==="tool"){x||k();const A=N.createdAt&&N.durationMs?new Date(new Date(N.createdAt).getTime()-N.durationMs).toISOString():b;l.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:c,seq:i++,type:"tool_start",content:N.tool,metadata:{arguments:N.args},createdAt:A}),N.status!=="running"&&l.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:c,seq:i++,type:"tool_end",content:N.tool,metadata:{arguments:N.args,result:N.result,error:N.error,durationMs:N.durationMs,success:N.status!=="error",...N.subagentLogs?.length?{subagentLogs:N.subagentLogs}:{}},createdAt:b})}else N.thinking&&(x||k(),p+=N.thinking,w()),M(N.content);return x?w():k(),l}function d_({msg:e,isStreaming:n,liveActivities:s,onViewModeChange:l}){const i=e.segments,c=e.isStopped,[d,u]=y.useState("compact"),h=y.useCallback(p=>{u(p),l?.(p)},[l]);if(i!==void 0&&i.length>0){const p=i.some(A=>A.type==="tool"),g=xv(i,e.agentId,e.rawCreatedAt),b=n?(()=>{const R=i.filter(_=>_.type==="text").map(_=>_.content).join("").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").trim();return R?R.slice(-200):void 0})():void 0,w=i.filter(A=>A.type==="text"),k=n?null:w.map(A=>A.content).join(""),C=k&&k.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,E=e.committedSegments,M=E&&E.length>0?xv(E,e.agentId,e.rawCreatedAt):g,N=[];if(d==="compact")for(const A of i){if(A.type!=="tool")continue;const R=iw(A.tool,A.result);if(R){N.push({key:`task-${R.taskId}`,kind:"task",info:R});continue}const _=ow(A.tool,A.result);_&&N.push({key:`req-${_.requirementId}`,kind:"req",info:_})}return t.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-hidden",children:[(p||n)&&(d==="compact"?t.jsx(Yx,{entries:g,streamingText:b,isActive:n,onExpand:()=>h("full"),embedded:!0}):t.jsx(Cu,{entries:M,isActive:n,onCollapse:()=>h("compact"),embedded:!0})),d==="compact"&&N.map(A=>A.kind==="task"?t.jsx(uw,{info:A.info},A.key):t.jsx(fw,{info:A.info},A.key)),d==="compact"&&C&&t.jsx(Fn,{content:C}),c&&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,x=e.text?e.text.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim():"";return t.jsxs(t.Fragment,{children:[(n||f)&&t.jsx(CA,{activities:n?s:e.activities??[],isActive:n,persistent:!n&&f}),x?t.jsx(Fn,{content:x}):null,c&&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 ex=new Set;function u_(){return window.location.hash}function f_(e){return ex.add(e),()=>{ex.delete(e)}}typeof window<"u"&&window.addEventListener("hashchange",()=>ex.forEach(e=>e()));function pv({initialAgentId:e,authUser:n}={}){const[s,l]=y.useState([]),[i,c]=y.useState([]),d=Yr(),u=y.useSyncExternalStore(f_,u_),h=d&&(u.startsWith(`#${ge.TEAM}/`)||u.startsWith("#chat/")),f=y.useCallback(()=>{window.location.hash=`${ge.TEAM}/d`},[]);y.useEffect(()=>{if(!d)return;const ee=()=>{g.current==="profile"&&p("chat")};return window.addEventListener("popstate",ee),()=>window.removeEventListener("popstate",ee)},[d]);const[x,p]=y.useState("chat"),g=y.useRef("chat");g.current=x;const b=Tu({side:"left",defaultWidth:224,minWidth:160,maxWidth:360,storageKey:"markus_chat_sidebar"}),[w,k]=y.useState(null),[C,E]=y.useState(),[M,N]=y.useState(),A=y.useCallback((ee,Ne)=>{E(ee),N(Ne),p("profile"),d&&history.pushState({mobileProfile:!0},"",window.location.hash)},[d]),R=[{id:"chat"},{id:"profile"}],_=y.useCallback(ee=>{ee==="profile"?A():g.current==="profile"?history.back():p("chat")},[A]),Y=va(R,x,_),q=y.useCallback((ee,Ne)=>{L("direct"),G(ee),d&&f(),A(Ne?.tab,Ne?.highlightMailboxId),k(null)},[d,f,A]),[X,L]=y.useState(()=>e?"direct":localStorage.getItem("markus_chat_mode")??"direct"),[P,G]=y.useState(()=>e??localStorage.getItem("markus_chat_agent")??""),[$,T]=y.useState(()=>localStorage.getItem("markus_chat_channel")??"#general"),[z,O]=y.useState(""),V=y.useRef(new Map),H=y.useRef(new Map),Z=y.useRef(new Set),B=y.useRef(""),[F,K]=y.useState([]),[I,S]=y.useState(""),[D,W]=y.useState(null),[J,te]=y.useState(!1),[re,oe]=y.useState(!1),me=y.useRef(null),Oe=1500;y.useEffect(()=>(J?(me.current&&(clearTimeout(me.current),me.current=null),oe(!0)):re&&(me.current=setTimeout(()=>{oe(!1),me.current=null},Oe)),()=>{me.current&&clearTimeout(me.current)}),[J]);const[ve,ke]=y.useState([]),[Ee,Me]=y.useState(!1),[dt,pt]=y.useState(!1),[et,Pt]=y.useState([]),le=y.useRef(null),Se=y.useRef(null),We="__new_chat__",[kt,Ft]=y.useState([]),[xe,Ce]=y.useState(null),[Fe,lt]=y.useState(!1),[ut,Lt]=y.useState([]),bn=y.useRef(new Map),Ut=y.useRef(new Map),St=y.useRef(null),Jt=y.useRef(null),yt=y.useRef(null),Xt=y.useRef(null),[_t,$t]=y.useState([]),[Hn,dn]=y.useState([]),[ye,Ge]=y.useState([]),[it,Et]=y.useState([]),[It,kn]=y.useState(null),[_n,Mn]=y.useState(!1),[dr,sr]=y.useState(""),[ur,$n]=y.useState(!1),[ae,Ie]=y.useState(""),[qe,Qe]=y.useState(0),ue=X==="channel"?_t.find(ee=>ee.channelKey===$)?.teamId:void 0,ze=y.useRef(null),Ve=y.useRef(null),tt=y.useRef(null),ot=y.useRef(void 0),At=y.useRef(!1),Sn=y.useRef(!0),ar=y.useRef(void 0);y.useEffect(()=>{if(!Fe)return;const ee=Ne=>{Jt.current&&!Jt.current.contains(Ne.target)&&St.current&&!St.current.contains(Ne.target)&<(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[Fe]);const mn=(ee,Ne)=>{if(!Ne||ee===Ne)return`notes:${ee}`;const[Re,Ke]=[ee,Ne].sort();return`dm:${Re}:${Ke}`},Wn=(ee,Ne,Re,Ke)=>ee==="channel"?`ch:${Re}`:ee==="dm"?`dm:${Ke??""}`:Ne||"_direct",Ot=y.useCallback((ee,Ne)=>{const Re=Ne(V.current.get(ee)??[]);V.current.set(ee,Re),B.current===ee&&K(Re)},[]),pr=(ee,Ne)=>{const Re=[...H.current.get(ee)??[],Ne];H.current.set(ee,Re),B.current===ee&&ke(Re)};y.useEffect(()=>{localStorage.setItem("markus_chat_mode",X)},[X]),y.useEffect(()=>{localStorage.setItem("markus_chat_agent",P)},[P]),y.useEffect(()=>{localStorage.setItem("markus_chat_channel",$)},[$]);const Tt=y.useCallback(()=>se.agents.list().then(ee=>l(ee.agents)).catch(()=>{}),[]),hn=y.useCallback(()=>se.teams.list().then(ee=>dn(ee.teams)).catch(()=>{}),[]);y.useEffect(()=>{Tt(),se.users.list().then(Ze=>c(Ze.users)).catch(()=>{}),se.tasks.list().then(Ze=>Et(Ze.tasks)).catch(()=>{}),hn(),se.externalAgents.list().then(Ze=>Ge(Ze.agents)).catch(()=>{}),fetch("/api/group-chats").then(Ze=>Ze.json()).then(Ze=>$t(Ze.chats)).catch(()=>{});const ee=setInterval(Tt,8e3),Ne=setInterval(hn,15e3),Re=Zt.on("agent:update",Tt),Ke=Zt.on("*",hn),Xe=Zt.on("chat:group_created",()=>{fetch("/api/group-chats").then(Ze=>Ze.json()).then(Ze=>$t(Ze.chats)).catch(()=>{})}),$e=()=>{Tt(),hn()};return window.addEventListener("markus:data-changed",$e),()=>{clearInterval(ee),clearInterval(Ne),Re(),Ke(),Xe(),window.removeEventListener("markus:data-changed",$e)}},[]),y.useEffect(()=>{const ee=Ke=>{const Xe=Ke.detail;if(ba(Xe.page)===ge.TEAM){if(Xe.params?.agentId){if(Xe.params.profileTab)q(Xe.params.agentId,{tab:Xe.params.profileTab});else if(L("direct"),G(Xe.params.agentId),Xe.params.sessionId){const $e=Xe.params.sessionId;setTimeout(async()=>{try{const{sessions:Ze}=await se.sessions.listByAgent(Xe.params.agentId,20),Rt=Ze.find(Ye=>Ye.id===$e);Rt&&Ar(Rt)}catch{}},300)}}Xe.params?.selectAgent&&q(Xe.params.selectAgent),Xe.params?.prefillMessage&&(S(Xe.params.prefillMessage),setTimeout(()=>Se.current?.focus(),100)),Xe.params?.openHire}},Ne=localStorage.getItem("markus_nav_agentId");if(Ne){localStorage.removeItem("markus_nav_agentId");const Ke=localStorage.getItem("markus_nav_profileTab");Ke?(localStorage.removeItem("markus_nav_profileTab"),q(Ne,{tab:Ke})):(L("direct"),G(Ne))}const Re=localStorage.getItem("markus_nav_selectAgent");return Re&&(localStorage.removeItem("markus_nav_selectAgent"),q(Re)),window.addEventListener("markus:navigate",ee),()=>window.removeEventListener("markus:navigate",ee)},[]),y.useEffect(()=>{if(P||s.length===0)return;const ee=s.find(Ne=>Ne.role==="secretary")??s.find(Ne=>Ne.name?.toLowerCase().includes("secretary"));ee?(L("direct"),G(ee.id),p("chat")):s.length>0&&(L("direct"),G(s[0].id),p("chat"))},[s,P]);const ln=y.useRef(!1);y.useEffect(()=>{const ee=Ve.current;if(!ee)return;const Ne=()=>ee.scrollHeight-ee.scrollTop-ee.clientHeight<80,Re=()=>{ln.current=!0},Ke=()=>{ln.current&&Ne()?(ln.current=!1,Sn.current=!0):ln.current&&(Sn.current=!1)};return ee.addEventListener("wheel",Re,{passive:!0}),ee.addEventListener("touchmove",Re,{passive:!0}),ee.addEventListener("scroll",Ke,{passive:!0}),()=>{ee.removeEventListener("wheel",Re),ee.removeEventListener("touchmove",Re),ee.removeEventListener("scroll",Ke)}},[]),y.useLayoutEffect(()=>{if(At.current){At.current=!1;return}Sn.current&&ze.current?.scrollIntoView({behavior:"instant"})},[F,ve]),y.useEffect(()=>{x==="chat"&&requestAnimationFrame(()=>{ze.current?.scrollIntoView({behavior:"instant"}),Sn.current=!0})},[x]),y.useEffect(()=>{const ee=()=>{ba(window.location.hash.slice(1).split("/")[0])===ge.TEAM&&g.current==="chat"&&requestAnimationFrame(()=>{ze.current?.scrollIntoView({behavior:"instant"})})};return window.addEventListener("hashchange",ee),window.addEventListener("markus:navigate",ee),()=>{window.removeEventListener("hashchange",ee),window.removeEventListener("markus:navigate",ee)}},[]);const ss=y.useCallback(async ee=>{const Ne=`ch:${ee}`;try{const Re=await se.channels.getMessages(ee,50),Ke=Re.messages.map(Lo);V.current.set(Ne,Ke),B.current===Ne&&(K(Ke),Me(Re.hasMore),yt.current=Re.messages[0]?new Date(Re.messages[0].createdAt).toISOString():null)}catch{B.current===Ne&&(K([]),Me(!1))}},[]),Rr=y.useCallback(async(ee,Ne)=>{Xt.current=ee;try{const Re=await se.sessions.getMessages(ee,50),Ke=Re.messages.map(fh);V.current.set(Ne,Ke),B.current===Ne&&Xt.current===ee&&(K(Ke),Me(Re.hasMore),yt.current=Re.messages[0]?new Date(Re.messages[0].createdAt).toISOString():null)}catch{B.current===Ne&&Xt.current===ee&&(K([]),Me(!1),yt.current=null)}},[]),lr=y.useCallback(async ee=>{if(!ee)return Ft([]),[];try{const{sessions:Ne}=await se.sessions.listByAgent(ee,10);return Ft(Ne),Ne}catch{return Ft([]),[]}},[]),Or=y.useCallback(async()=>{if(dt||!Ee||!yt.current)return;pt(!0);const ee=Ve.current,Ne=ee?.scrollHeight??0;try{const Re=B.current;if(X==="channel"||X==="dm"){const Ke=X==="dm"?mn(n?.id??"",z):$,Xe=await se.channels.getMessages(Ke,50,yt.current),$e=Xe.messages.map(Lo);At.current=!0,K(Ze=>{const Rt=[...$e,...Ze];return V.current.set(Re,Rt),Rt}),Me(Xe.hasMore),Xe.messages[0]&&(yt.current=new Date(Xe.messages[0].createdAt).toISOString())}else if(xe){const Ke=await se.sessions.getMessages(xe,50,yt.current),Xe=Ke.messages.map(fh);At.current=!0,K($e=>{const Ze=[...Xe,...$e];return V.current.set(Re,Ze),Ze}),Me(Ke.hasMore),Ke.messages[0]&&(yt.current=new Date(Ke.messages[0].createdAt).toISOString())}}catch{}finally{pt(!1),requestAnimationFrame(()=>{if(ee){const Re=ee.scrollHeight;ee.scrollTop+=Re-Ne}})}},[dt,Ee,X,$,xe,n?.id,z]);ar.current=Or;const gs=y.useRef(!1),as=y.useCallback(ee=>{gs.current||(gs.current=!0,requestAnimationFrame(()=>{gs.current=!1,ee.target.scrollTop<100&&ar.current?.()}))},[]);y.useEffect(()=>{const ee=Wn(X,P,$,z),Ne=B.current;B.current=ee,Ne&&Ne!==ee&&(bn.current.set(Ne,ut),Ut.current.set(Ne,xe));const Re=V.current.get(ee),Ke=H.current.get(ee)??[],Xe=Z.current.has(ee);ke(Ke),te(Xe),X==="direct"&&P&&lr(P);const $e=bn.current.get(ee),Ze=Ut.current.get(ee);if($e&&$e.length>0&&Lt($e),lt(!1),Re!==void 0)K(Re),Me(!1),Ze!==void 0&&Ce(Ze),(!$e||$e.length===0)&&Lt([]);else if(K([]),Me(!1),yt.current=null,X==="channel"||X==="dm"){const Rt=X==="dm"?mn(n?.id??"",z):$;ss(Rt),(!$e||$e.length===0)&&Lt([])}else X==="direct"&&P&&lr(P).then(Rt=>{if(B.current===ee)if(Rt.length>0){const Ye=Rt.find(fn=>fn.isMain),ht=Ye?[Ye,...Rt.filter(fn=>!fn.isMain).slice(0,4)]:Rt.slice(0,5),vt=$e&&$e.length>0?$e:ht,tn=Ze!==void 0?Ze:Ye?.id??vt[0].id,yn=tn&&vt.some(fn=>fn.id===tn)?tn:vt[0].id;Ce(yn),Lt(vt),Rr(yn,ee)}else{Ce(null),(!$e||$e.length===0)&&Lt([]);const Ye=(()=>{const ht=(navigator.language||"").toLowerCase();return ht.startsWith("zh")?"介绍一下你自己":ht.startsWith("ja")?"自己紹介をしてください":ht.startsWith("ko")?"자기소개를 해주세요":ht.startsWith("fr")?"Présentez-vous":ht.startsWith("de")?"Stell dich vor":ht.startsWith("es")?"Preséntate":ht.startsWith("pt")?"Apresente-se":ht.startsWith("ru")?"Представьтесь":"Introduce yourself"})();setTimeout(()=>ot.current?.(Ye),150)}})},[X,P,$,z]),y.useEffect(()=>X!=="channel"?void 0:Zt.on("chat:message",Ne=>{const Re=Ne.payload,Ke=Re.channel??"";if(!Ke||Ke!==$)return;const Xe=Re.senderType??"agent",$e=Re.text??Re.message??"",Ze=Re.senderId??Re.agentId??"",Rt=Re.senderName??Re.agentId??"Agent",Ye=Re.metadata,ht={id:`ws_${Date.now()}_${Ze}`,sender:Xe==="human"?"user":"agent",text:$e,time:new Date().toLocaleTimeString(),agentName:Xe==="agent"?Rt:void 0,agentId:Xe==="agent"?Ze:void 0};if(Ye&&Xe==="agent"){const tn=[];if(Ye.thinking?.length&&tn.push({type:"text",content:"",thinking:Ye.thinking.join(`
|
|
56
|
+
|
|
57
|
+
`)}),Ye.toolCalls?.length)for(let yn=0;yn<Ye.toolCalls.length;yn++){const fn=Ye.toolCalls[yn];tn.push({type:"tool",key:`${fn.tool}_${yn}`,tool:fn.tool,status:fn.status==="error"?"error":"done",args:fn.arguments,result:fn.result,durationMs:fn.durationMs})}tn.length>0&&(tn.push({type:"text",content:$e}),ht.segments=tn)}const vt=Wn("channel",P,$,z);Ot(vt,tn=>[...tn,ht])}),[X,$,P,z,Ot]),y.useEffect(()=>Zt.on("chat:proactive_message",Ne=>{const Re=Ne.payload,Ke=Re.agentId??"",Xe=Re.agentName??"Agent",$e=Re.message??"";Re.sessionId;const Ze=Re.metadata??{};if(!Ke||!$e)return;const Rt=!!Ze.activityLog||$e.startsWith("[ACTIVITY:");if(X==="direct"&&P===Ke){const Ye={id:`proactive_${Date.now()}`,sender:"agent",text:$e,time:new Date().toLocaleTimeString(),agentName:Xe,agentId:Ke,...Rt?{isActivityLog:!0,activityType:Ze.activityType,outcome:Ze.outcome,mailboxItemId:Ze.mailboxItemId,taskId:Ze.taskId,requirementId:Ze.requirementId}:{}},ht=Wn("direct",Ke,$,z);Ot(ht,vt=>[...vt,Ye])}}),[X,P,$,z,xe,Ot]),it.find(ee=>ee.id===It),y.useEffect(()=>{kn(null)},[P]);const Os=ee=>DA(ee),Ds=()=>{tt.current?.abort(),tt.current=null;const ee=B.current;Z.current.delete(ee),H.current.delete(ee),te(!1),ke([])},gr=async(ee,Ne)=>{const Re=(ee??I).trim();if(!Re&&et.length===0||X==="direct"&&!P)return;if(Sn.current=!0,ln.current=!1,J){tt.current?.abort(),tt.current=null;const Ye=B.current;Z.current.delete(Ye),H.current.delete(Ye),Ot(Ye,ht=>{const vt=[...ht];for(let tn=vt.length-1;tn>=0;tn--)if(vt[tn].sender==="agent"&&!vt[tn].isStopped&&!vt[tn].isError){const yn=vt[tn],fn=(yn.segments??[]).map(jr=>jr.type==="tool"&&jr.status==="running"?{...jr,status:"stopped"}:jr);vt[tn]={...yn,isStopped:!0,segments:fn};break}return vt}),te(!1),ke([]),await new Promise(ht=>setTimeout(ht,50))}const Ke=et.length>0?et.map(Ye=>Ye.dataUrl):void 0,Xe=et.length>0?et.map(Ye=>Ye.name):void 0,$e=Wn(X,P,$,z),Ze=D;ee||(S(""),Se.current&&(Se.current.style.height="auto")),Pt([]),$n(!1),W(null);const Rt=X==="dm";if(Z.current.add($e),H.current.set($e,[]),B.current===$e&&!Rt&&(te(!0),ke([])),X==="dm"){const Ye=mn(n?.id??"",z),ht=`opt_${Date.now()}`,vt={id:ht,sender:"user",text:Re,time:new Date().toLocaleTimeString()};Ze&&(vt.replyToId=Ze.id,vt.replyToSender=Ze.sender,vt.replyToText=Ze.text),Ot($e,tn=>[...tn,vt]);try{const tn=await se.channels.sendMessage(Ye,{text:Re,senderName:n?.name??"You",senderId:n?.id,mentions:[],orgId:"default",humanOnly:!0});Ot($e,yn=>{const fn=yn.filter(Ir=>Ir.id!==ht),jr=[];return tn.userMessage&&jr.push(Lo(tn.userMessage)),jr.length>0?[...fn,...jr]:yn})}catch(tn){Ot($e,yn=>[...yn,{id:`err_${Date.now()}`,sender:"agent",text:`Error: ${String(tn)}`,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}Z.current.delete($e),B.current===$e&&te(!1)}else if(X==="channel"){const Ye=`opt_${Date.now()}`,ht={id:Ye,sender:"user",text:Re,time:new Date().toLocaleTimeString()};Ze&&(ht.replyToId=Ze.id,ht.replyToSender=Ze.sender,ht.replyToText=Ze.text),Ot($e,vt=>[...vt,ht]);try{const vt=Os(Re),tn=vt.length>0?s.find(fn=>fn.name.toLowerCase()===vt[0].toLowerCase()):null,yn=await se.channels.sendMessage($,{text:Re,senderName:n?.name??"You",mentions:vt,senderId:n?.id,targetAgentId:tn?.id,orgId:"default"});Ot($e,fn=>{const jr=fn.filter(ol=>ol.id!==Ye),Ir=[];return yn.userMessage&&Ir.push(Lo(yn.userMessage)),yn.agentMessage&&Ir.push(Lo(yn.agentMessage)),Ir.length>0?[...jr,...Ir]:fn})}catch(vt){const tn=mv(vt)||`Error: ${String(vt)}`;Ot($e,yn=>[...yn,{id:`err_${Date.now()}`,sender:"agent",text:tn,time:new Date().toLocaleTimeString(),agentName:"System",isError:!0}])}Z.current.delete($e),B.current===$e&&te(!1)}else{const Ye=`a_${Date.now()}`;if(Ne?.isResume){const ft=new Date().toISOString();Ot($e,wt=>[...wt,{id:Ye,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:ft,segments:[]}])}else{const ft=new Date().toISOString(),wt={id:`u_${Date.now()}`,sender:"user",text:Re,time:new Date().toLocaleTimeString()};Ke?.length&&(wt.images=Ke),Ze&&(wt.replyToId=Ze.id,wt.replyToSender=Ze.sender,wt.replyToText=Ze.text),Ot($e,at=>[...at,wt,{id:Ye,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:ft,segments:[]}])}let ht=!1;const vt=ft=>{Ot($e,wt=>{const at=[...wt],Je=at.findIndex(ws=>ws.id===Ye);if(Je<0)return wt;const nt=at[Je].segments??[],xt=nt[nt.length-1],Ct=xt?.type==="text"?xt.thinking??"":"";let vn="",on="",Cn=ft;for(;Cn.length>0;)if(ht){const ws=Cn.indexOf("</think>");ws>=0?(vn+=Cn.slice(0,ws),Cn=Cn.slice(ws+8),ht=!1):(vn+=Cn,Cn="")}else{const ws=Cn.indexOf("<think>");ws>=0?(on+=Cn.slice(0,ws),Cn=Cn.slice(ws+7),ht=!0):(on+=Cn,Cn="")}const js=Ct+vn||void 0,Pu=xt?.type==="text"?[...nt.slice(0,-1),{type:"text",content:xt.content+on,thinking:js,createdAt:xt.createdAt}]:[...nt,{type:"text",content:on,thinking:js,createdAt:new Date().toISOString()}];return at[Je]={...at[Je],text:at[Je].text+on,segments:Pu},at})},tn=ft=>{Ot($e,wt=>{const at=[...wt],Je=at.findIndex(xt=>xt.id===Ye);if(Je<0)return wt;const nt=[...at[Je].committedSegments??[]];return ft.type==="thinking_commit"?nt.push({type:"text",content:"",thinking:ft.content,createdAt:ft.createdAt}):nt.push({type:"text",content:ft.content,createdAt:ft.createdAt}),at[Je]={...at[Je],committedSegments:nt},at})},yn=ft=>{(ft.phase==="start"||ft.phase==="end")&&pr($e,{...ft,phase:ft.phase,ts:Date.now()}),ft.phase==="start"?Ot($e,wt=>{const at=[...wt],Je=at.findIndex(Cn=>Cn.id===Ye);if(Je<0)return wt;const nt=[...at[Je].segments??[]];let xt=!1;if(ft.arguments)for(let Cn=nt.length-1;Cn>=0;Cn--){const js=nt[Cn];if(js.type==="tool"&&js.tool===ft.tool&&js.status==="running"){nt[Cn]={...js,args:ft.arguments},xt=!0;break}}const Ct=`${ft.tool}_${Date.now()}`,vn=new Date().toISOString();xt||nt.push({type:"tool",key:Ct,tool:ft.tool,status:"running",args:ft.arguments,createdAt:vn});const on=[...at[Je].committedSegments??[]];return ft.arguments!==void 0&&on.push({type:"tool",key:Ct,tool:ft.tool,status:"running",args:ft.arguments,createdAt:vn}),at[Je]={...at[Je],segments:nt,committedSegments:on},at}):ft.phase==="output"?Ot($e,wt=>{const at=[...wt],Je=at.findIndex(xt=>xt.id===Ye);if(Je<0)return wt;const nt=[...at[Je].segments??[]];for(let xt=nt.length-1;xt>=0;xt--){const Ct=nt[xt];if(Ct.type==="tool"&&Ct.tool===ft.tool&&Ct.status==="running"){nt[xt]={...Ct,liveOutput:(Ct.liveOutput??"")+(ft.output??"")};break}}return at[Je]={...at[Je],segments:nt},at}):ft.phase==="subagent_progress"&&ft.subagentEvent?Ot($e,wt=>{const at=[...wt],Je=at.findIndex(xt=>xt.id===Ye);if(Je<0)return wt;const nt=[...at[Je].segments??[]];for(let xt=nt.length-1;xt>=0;xt--){const Ct=nt[xt];if(Ct.type==="tool"&&(Ct.tool==="spawn_subagent"||Ct.tool==="spawn_subagents")&&Ct.status==="running"){nt[xt]={...Ct,subagentLogs:[...Ct.subagentLogs??[],ft.subagentEvent]};break}}return at[Je]={...at[Je],segments:nt},at}):Ot($e,wt=>{const at=[...wt],Je=at.findIndex(vn=>vn.id===Ye);if(Je<0)return wt;const nt=new Date().toISOString(),xt=[...at[Je].segments??[]];for(let vn=xt.length-1;vn>=0;vn--){const on=xt[vn];if(on.type==="tool"&&on.tool===ft.tool&&on.status==="running"){xt[vn]={...on,status:ft.success===!1?"error":"done",args:ft.arguments,result:ft.result,error:ft.error,durationMs:ft.durationMs,liveOutput:void 0,createdAt:nt};break}}const Ct=[...at[Je].committedSegments??[]];for(let vn=Ct.length-1;vn>=0;vn--){const on=Ct[vn];if(on.type==="tool"&&on.tool===ft.tool&&on.status==="running"){Ct[vn]={...on,status:ft.success===!1?"error":"done",args:ft.arguments,result:ft.result,error:ft.error,durationMs:ft.durationMs,liveOutput:void 0,createdAt:nt};break}}return at[Je]={...at[Je],segments:xt,committedSegments:Ct},at})},fn=new AbortController;tt.current=fn;try{const ft=xe===We?null:xe,wt=await se.agents.messageStream(P,Re,vt,yn,fn.signal,Ke,ft,Ne?.isRetry,Ne?.isResume,tn,Xe);B.current===$e&&(wt.sessionId&&(Ce(wt.sessionId),Lt(at=>at.map(Je=>Je.id===We?{...Je,id:wt.sessionId}:Je))),lr(P).then(at=>{if(B.current===$e&&(Ft(at),wt.sessionId)){const Je=at.find(nt=>nt.id===wt.sessionId);Je&&Lt(nt=>nt.some(Ct=>Ct.id===Je.id)?nt.map(Ct=>Ct.id===Je.id?Je:Ct):[Je,...nt.filter(Ct=>Ct.id!==We)])}}))}catch(ft){const wt=ft?.sessionId;wt&&X==="direct"&&B.current===$e&&(Ce(wt),Lt(Je=>Je.map(nt=>nt.id===We?{...nt,id:wt}:nt)),lr(P).then(Je=>{if(B.current!==$e)return;Ft(Je);const nt=Je.find(xt=>xt.id===wt);nt&&Lt(xt=>xt.some(vn=>vn.id===nt.id)?xt.map(vn=>vn.id===nt.id?nt:vn):[nt,...xt])}));const at=mv(ft);at?Ot($e,Je=>{const nt=[...Je],xt=nt.findIndex(Ct=>Ct.id===Ye);if(xt>=0){const Ct=nt[xt].segments??[];nt[xt]={...nt[xt],text:at,isError:!0,segments:[...Ct,{type:"text",content:at}]}}return nt}):Ot($e,Je=>{const nt=[...Je],xt=nt.findIndex(Ct=>Ct.id===Ye);if(xt>=0){const Ct=nt[xt];if(!(Ct.text||Ct.segments&&Ct.segments.length>0&&Ct.segments.some(on=>on.type==="text"&&on.content||on.type==="tool")))return Je.filter(on=>on.id!==Ye);nt[xt]={...Ct,isStopped:!0}}return nt})}Ot($e,ft=>{const wt=[...ft],at=wt.findIndex(Je=>Je.id===Ye);if(at>=0){const Je=(wt[at].segments??[]).map(nt=>nt.type==="tool"&&nt.status==="running"?{...nt,status:"stopped"}:nt);wt[at]={...wt[at],segments:Je}}return wt}),fn.signal.aborted&&Ot($e,ft=>{const wt=[...ft],at=wt.findIndex(Je=>Je.id===Ye);if(at>=0){const Je=wt[at];if(!(Je.text||Je.segments&&Je.segments.length>0&&Je.segments.some(xt=>xt.type==="text"&&xt.content||xt.type==="tool")))return ft.filter(xt=>xt.id!==Ye);wt[at]={...Je,isStopped:!0}}return wt});const Ir=(V.current.get($e)??[]).find(ft=>ft.id===Ye),ol=xe&&xe!==We?xe:null;Ir&&!Ir.text&&X==="direct"&&ol&&!fn.signal.aborted&&await(async(wt,at)=>{for(let Je=0;Je<wt;Je++){await new Promise(nt=>setTimeout(nt,at));try{const xt=(await se.sessions.getMessages(ol,2)).messages.find(Ct=>Ct.role==="assistant");if(xt?.content){const Ct=fh(xt);Ot($e,vn=>{const on=[...vn],Cn=on.findIndex(js=>js.id===Ye);return Cn>=0&&(on[Cn]={...on[Cn],text:Ct.text,segments:Ct.segments}),on});return}}catch{}}})(5,3e3)}tt.current=null,Z.current.delete($e),H.current.delete($e),B.current===$e&&(te(!1),ke([]))};ot.current=gr;const[Dr,fr]=y.useState(null),[,Vn]=y.useState(new Set),bs=y.useMemo(()=>{for(let ee=F.length-1;ee>=0;ee--)if(F[ee]?.sender==="agent"&&!F[ee]?.isActivityLog)return F[ee].id;return null},[F]),de=y.useCallback(ee=>{const Ne=ee.segments?ee.segments.filter(Re=>Re.type==="text").map(Re=>Re.content).join(`
|
|
58
|
+
`):ee.text;navigator.clipboard.writeText(Ne),fr(ee.id),setTimeout(()=>fr(Re=>Re===ee.id?null:Re),2e3)},[]),Te=y.useCallback(ee=>{const Ne=B.current,Re=V.current.get(Ne)??F,Ke=Re.findIndex(Ye=>Ye.id===ee.id);if(Ke<0)return;let Xe=null;for(let Ye=Ke-1;Ye>=0;Ye--)if(Re[Ye]?.sender==="user"){Xe=Re[Ye];break}const $e=Xe?.text??"";if(!$e)return;if(Ke<Re.length-1){const Ye=Re.length-1-Ke;if(!window.confirm(`This will discard ${Ye} message${Ye>1?"s":""} after this point and re-generate. Continue?`))return}const Rt=Xe&&Ke>0&&Re[Ke-1]?.id===Xe.id;Ot(Ne,Ye=>{const ht=Ye.findIndex(vt=>vt.id===(Rt?Xe.id:ee.id));return ht>=0?Ye.slice(0,ht):Ye}),gr($e,{isRetry:!0})},[F,Ot]),Ue=y.useCallback(ee=>{const Ne=B.current;(V.current.get(Ne)??F).findIndex(Xe=>Xe.id===ee.id)<0||(Ot(Ne,Xe=>{const $e=[...Xe],Ze=$e.findIndex(ht=>ht.id===ee.id);if(Ze<0)return Xe;const Rt=$e[Ze],Ye=[...Rt.segments??[]];for(;Ye.length>0;){const ht=Ye[Ye.length-1];if(ht.type==="tool"&&(ht.status==="stopped"||ht.status==="running"))Ye.pop();else if(ht.type==="text"&&!ht.content)Ye.pop();else break}return $e[Ze]={...Rt,segments:Ye,isStopped:!1,isError:!1},$e}),gr("[Continue from where you left off. Do not repeat content already generated.]",{isResume:!0}))},[F,Ot]),qt=y.useCallback(ee=>{W({id:ee.id,sender:ee.sender==="user"?n?.name??"You":ee.agentName??"Agent",text:ee.text.slice(0,120)}),Se.current?.focus()},[n?.name]),Ar=async ee=>{Ce(ee.id),lt(!1),Me(!1),yt.current=null;const Ne=B.current;V.current.delete(Ne),K([]),Lt(Re=>Re.some(Ke=>Ke.id===ee.id)?Re:[...Re,ee]),await Rr(ee.id,Ne)},Pn=ee=>{if(Lt(Ne=>Ne.filter(Re=>Re.id!==ee)),xe===ee){const Ne=ut.filter(Re=>Re.id!==ee);Ne.length>0?Ar(Ne[Ne.length-1]):mr()}},mr=()=>{Ce(We);const ee=B.current;V.current.delete(ee),K([]),Me(!1),yt.current=null,lt(!1),Lt(Ne=>{const Re=Ne.filter(Ke=>Ke.id!==We);return[{id:We,agentId:P??"",userId:null,title:"New Chat",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...Re]})},Ls=ee=>{if(S(ee),X!=="channel"){$n(!1);return}const Ne=ee.lastIndexOf("@");if(Ne>=0&&(Ne===0||ee[Ne-1]===" ")){const Ke=ee.slice(Ne+1).toLowerCase();if(s.some($e=>$e.name.toLowerCase().includes(Ke))){$n(!0),Ie(Ke),Qe(0);return}}$n(!1)},ys=ee=>{const Ne=I.lastIndexOf("@"),Re=ee.includes(" ")?`@[${ee}]`:`@${ee}`;S(I.slice(0,Ne)+Re+" "),$n(!1),Qe(0)},br=10*1024*1024,ka=5,Hl=new Set(["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.ms-excel","application/msword","text/csv","text/html","application/json","application/xml","text/xml","application/epub+zip"]),ir=y.useCallback(ee=>ee.type.startsWith("image/")||Hl.has(ee.type),[]),Sa=ee=>ee.dataUrl.startsWith("data:image/"),il=(ee,Ne)=>{if(Sa({dataUrl:Ne}))return null;const Re=ee.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[Re]??"📁"},ls=y.useCallback(ee=>{const Ne=Array.from(ee).filter(ir);if(Ne.length!==0)for(const Re of Ne){if(Re.size>br)continue;const Ke=new FileReader;Ke.onload=()=>{const Xe=Ke.result;Pt($e=>$e.length>=ka||$e.some(Ze=>Ze.dataUrl===Xe)?$e:[...$e,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:Xe,name:Re.name}])},Ke.readAsDataURL(Re)}},[ir]),Zs=y.useCallback(ee=>{Pt(Ne=>Ne.filter(Re=>Re.id!==ee))},[]),Ca=y.useCallback(ee=>{const Ne=ee.clipboardData?.files;if(Ne&&Ne.length>0){const Re=Array.from(Ne).filter(ir);Re.length>0&&(ee.preventDefault(),ls(Re))}},[ls,ir]),ne=y.useCallback(ee=>{ee.preventDefault();const Ne=ee.dataTransfer?.files;Ne&&Ne.length>0&&ls(Array.from(Ne).filter(ir))},[ls,ir]),Le=y.useCallback(ee=>{ee.preventDefault()},[]),Be=s.find(ee=>ee.id===P),st=n?.name??"You",en=F[F.length-1],un=J&&en?.sender==="agent",Mt=re&&en?.sender==="agent",He=s.filter(ee=>ee.name.toLowerCase().includes(ae)),hr=i.find(ee=>ee.id===z),yr=z===n?.id||!z,vr=_t.find(ee=>ee.channelKey===$),Yn=X==="channel"?vr?.name??$:X==="direct"?Be?.name??"Select Agent":X==="dm"?yr?"My Notes":hr?.name??"Direct Message":"Chat",vs=X==="channel"?vr?`Message ${vr.name}…`:`Message ${$}… (use @name to mention)`:X==="dm"?yr?"Write a note to yourself…":`Message ${hr?.name??""}…`:P?"Type a message…":"Select an agent to start chatting",Lr=d&&h;return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx(BA,{authUser:n,agents:s,teams:Hn,humans:i,tasks:it,externalAgents:ye,groupChats:_t,chatMode:X,selectedAgent:P,activeChannel:$,activeDmUserId:z,onSelectAgent:ee=>{L("direct"),G(ee),p("chat"),d&&f()},onSelectChannel:ee=>{L("channel"),T(ee),p("chat"),d&&f()},onSelectDm:ee=>{L("dm"),O(ee),p("chat"),d&&f()},onRefreshTeams:hn,onRefreshAgents:Tt,onViewProfile:q,width:d?void 0:b.width,onResizeStart:d?void 0:b.onResizeStart,hidden:d&&h}),(!d||Lr)&&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:[d?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center px-3 h-11 gap-2",children:[t.jsx("button",{onClick:()=>{window.location.hash=ge.TEAM},className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"font-semibold text-sm truncate min-w-0 flex-1",children:Yn}),X==="direct"&&Be&&t.jsx(gv,{agent:Be,tasks:it,onViewProfile:q})]}),t.jsxs("div",{className:"flex items-center px-3 h-9 gap-1 border-t border-border-default/40",children:[t.jsx("button",{onClick:()=>{x==="profile"?history.back():p("chat")},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${x==="chat"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>{x!=="profile"&&A()},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${x==="profile"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:X==="channel"?"Team":"Profile"}),t.jsx("div",{className:"flex-1"}),X==="direct"&&x!=="profile"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:mr,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:St,onClick:()=>lt(!Fe),className:`p-1 rounded-md transition-colors shrink-0 ${Fe?"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:Yn}),X==="direct"&&Be&&t.jsx(gv,{agent:Be,tasks:it,onViewProfile:q}),(X==="channel"||X==="dm")&&t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[F.length," messages"]}),X==="dm"&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-1",children:yr?"· Private notepad":`· Direct message with ${hr?.name??""}`}),(X==="direct"&&P||X==="channel"&&ue)&&t.jsxs("div",{className:"flex items-center gap-0.5 ml-4 -mb-px",children:[t.jsx("button",{onClick:()=>p("chat"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${x==="chat"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:"Chat"}),t.jsx("button",{onClick:()=>p("profile"),className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${x==="profile"?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:X==="channel"?"Team":"Profile"})]}),t.jsx("div",{className:"ml-auto flex items-center gap-2",children:X==="direct"&&Be&&x!=="profile"&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("button",{onClick:mr,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:St,onClick:()=>lt(!Fe),className:`p-1.5 rounded-md transition-colors ${Fe?"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"})})})]})})]}),X==="direct"&&P&&x==="chat"&&ut.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:ut.map(ee=>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] ${ee.id===xe?"border-brand-500 text-brand-500 bg-brand-500/5":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,onClick:()=>{if(ee.id===We){Ce(We);const Ne=B.current;V.current.delete(Ne),K([])}else Ar(ee)},children:[ee.isMain&&t.jsx("span",{className:"text-[10px] opacity-50 shrink-0",children:"●"}),t.jsx("span",{className:"truncate",children:ee.id===We?"New Chat":ee.isMain?"Main":ee.title||"Conversation"}),!ee.isMain&&t.jsx("button",{onClick:Ne=>{Ne.stopPropagation(),Pn(ee.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},ee.id))}),X==="direct"&&P&&Fe&&t.jsxs("div",{ref:Jt,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:()=>lt(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[kt.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No conversations yet"}),(()=>{const ee=new Date,Ne=new Date(ee.getFullYear(),ee.getMonth(),ee.getDate()).getTime(),Re=Ne-864e5,Ke=Ne-7*864e5,Xe=[],$e=[],Ze=[],Rt=[],Ye=[];for(const ht of kt){const vt=new Date(ht.lastMessageAt).getTime();vt>=Ne?$e.push(ht):vt>=Re?Ze.push(ht):vt>=Ke?Rt.push(ht):Ye.push(ht)}return $e.length>0&&Xe.push({label:"Today",items:$e}),Ze.length>0&&Xe.push({label:"Yesterday",items:Ze}),Rt.length>0&&Xe.push({label:"Previous 7 days",items:Rt}),Ye.length>0&&Xe.push({label:"Older",items:Ye}),Xe.map(ht=>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:ht.label}),ht.items.map(vt=>t.jsxs("button",{onClick:()=>{Ar(vt)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${vt.id===xe?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[t.jsxs("div",{className:"truncate font-medium flex items-center gap-1",children:[vt.isMain&&t.jsx("span",{className:"text-[10px] text-brand-500 opacity-60",children:"●"}),vt.isMain?"Main":vt.title||"Conversation"]}),t.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(vt.lastMessageAt).toLocaleString()})]},vt.id))]},ht.label))})()]})]})]}),x==="profile"&&X==="direct"&&P&&t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(qA,{agentId:P,onBack:()=>p("chat"),inline:!0,defaultTab:C,highlightMailboxId:M,onSwipeBack:()=>{g.current==="profile"?history.back():p("chat")}})}),x==="profile"&&X==="channel"&&ue&&t.jsx("div",{className:"flex-1 overflow-y-auto",onTouchStart:d?Y.onTouchStart:void 0,onTouchEnd:d?Y.onTouchEnd:void 0,children:t.jsx(l_,{teamId:ue,onBack:()=>p("chat"),inline:!0})}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col relative ${x!=="chat"?"hidden":""}`,children:[dt&&t.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 flex justify-center items-center gap-2 py-2 bg-gradient-to-b from-surface-primary/90 to-transparent pointer-events-none",children:[t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 text-brand-400",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-xs text-fg-tertiary",children:"Loading earlier messages…"})]}),t.jsxs("div",{ref:Ve,className:`flex-1 overflow-y-auto space-y-3 ${d?"p-2.5":"p-5"}`,onScroll:as,onTouchStart:d?Y.onTouchStart:void 0,onTouchEnd:d?Y.onTouchEnd:void 0,children:[F.length===0&&!J&&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:X==="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"})})}),X==="channel"&&t.jsxs("div",{children:["No messages in ",vr?.name??$," yet."]}),X==="direct"&&!P&&t.jsx("div",{children:"Select an agent from the sidebar to start."}),X==="direct"&&P&&t.jsxs("div",{children:["Start a new conversation with ",Be?.name,"."]})]}),X==="channel"?F.map(ee=>t.jsxs("div",{id:`msg-${ee.id}`,className:"group/msg flex gap-3 transition-colors rounded-lg",children:[t.jsx("div",{className:"shrink-0 cursor-pointer",onClick:Ne=>{if(ee.sender==="agent"&&ee.agentId){const Re=Ne.currentTarget.getBoundingClientRect();k({agentId:ee.agentId,top:Re.top,left:Re.right+8})}},children:t.jsx(Ys,{name:ee.sender==="user"?st??"You":ee.agentName??"Agent",avatarUrl:ee.sender==="user"?n?.avatarUrl:s.find(Ne=>Ne.id===ee.agentId)?.avatarUrl,size:32,bgClass:ee.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:ee.sender==="agent"?"hover:ring-1 hover:ring-brand-500/40 rounded-lg":"rounded-lg"})}),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:ee.sender==="user"?st??"You":ee.agentName??"Agent"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:ee.time})]}),ee.replyToId&&ee.replyToSender&&t.jsxs("button",{onClick:()=>{const Ne=document.getElementById(`msg-${ee.replyToId}`);Ne&&(Ne.scrollIntoView({behavior:"smooth",block:"center"}),Ne.classList.add("bg-brand-500/10"),setTimeout(()=>Ne.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:ee.replyToSender}),t.jsx("span",{className:"truncate max-w-[250px]",children:ee.replyToText??"..."})]}),t.jsx("div",{className:ee.isError||ee.sender==="agent"&&ee.text.startsWith("⚠")?"mt-0.5 px-3 py-2 rounded-lg border-b-2 border-red-500/60":"mt-0.5",children:ee.sender==="agent"?t.jsx(Fn,{content:ee.text,className:"text-sm text-fg-secondary"}):t.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[ee.images&&ee.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:ee.images.map((Ne,Re)=>t.jsx("img",{src:Ne,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(Ne,"_blank")},Re))}),nv(ee.text,s)]})}),t.jsx("div",{className:`transition-opacity ${d?"opacity-100":"opacity-0 group-hover/msg:opacity-100"}`,children:t.jsx(hv,{msg:ee,onCopy:de,onRetry:Te,onResume:Ue,onReply:qt,isCopied:Dr===ee.id,isLastAgentMsg:ee.id===bs})})]})]},ee.id)):F.map((ee,Ne)=>{const Ke=un&&Ne===F.length-1&&J,Xe=Mt&&Ne===F.length-1||Ke,$e=!Ke||ee.isStopped;return ee.isActivityLog?null:t.jsx("div",{id:`msg-${ee.id}`,className:`group/msg flex transition-colors rounded-lg ${ee.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:[d?"max-w-[95%]":"max-w-[85%]",ee.sender==="agent"?d?"min-w-[200px]":"min-w-[280px]":""].join(" "),children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:[ee.sender==="user"?st??"You":t.jsx(o_,{name:ee.agentName??(X==="direct"?Be?.name??"Agent":"Agent"),agentId:ee.agentId??(X==="direct"?Be?.id:void 0),agents:s,onViewProfile:q})," · ",ee.time]}),ee.replyToId&&ee.replyToSender&&t.jsxs("button",{onClick:()=>{const Ze=document.getElementById(`msg-${ee.replyToId}`);Ze&&(Ze.scrollIntoView({behavior:"smooth",block:"center"}),Ze.classList.add("bg-brand-500/10"),setTimeout(()=>Ze.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:ee.replyToSender}),t.jsx("span",{className:"truncate max-w-[200px]",children:ee.replyToText??"..."})]}),t.jsx("div",{className:`rounded-2xl text-sm ${d?"px-3 py-2":"px-4 py-3"} ${ee.sender==="user"?"bg-brand-600 text-white rounded-br-sm":ee.isError||ee.sender==="agent"&&ee.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"} ${Xe&&ee.sender==="agent"?"streaming-bubble":""}`,children:ee.sender==="user"?t.jsxs(t.Fragment,{children:[ee.images&&ee.images.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:ee.images.map((Ze,Rt)=>t.jsx("img",{src:Ze,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>window.open(Ze,"_blank")},Rt))}),ee.text&&t.jsx("span",{className:"whitespace-pre-wrap leading-relaxed",children:nv(ee.text,s)})]}):t.jsx(d_,{msg:ee,isStreaming:Ke,liveActivities:Ke?ve:[],onViewModeChange:Ze=>Vn(Rt=>{const Ye=new Set(Rt);return Ze==="full"?Ye.add(ee.id):Ye.delete(ee.id),Ye})})}),$e&&t.jsx("div",{className:`transition-opacity ${ee.isStopped||d?"opacity-100":"opacity-0 group-hover/msg:opacity-100"} ${ee.sender==="user"?"flex justify-end":""}`,children:t.jsx(hv,{msg:ee,onCopy:de,onRetry:Te,onResume:Ue,onReply:qt,isCopied:Dr===ee.id,isLastAgentMsg:ee.id===bs})})]})},ee.id)}),X==="channel"&&J&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse ml-11",children:"Agent is thinking…"}),t.jsx("div",{ref:ze})]})]}),w&&(()=>{const ee=s.find(Ne=>Ne.id===w.agentId);return ee?t.jsx(c_,{agent:ee,anchorRect:{top:w.top,left:w.left},onClose:()=>k(null),onViewProfile:q}):null})(),t.jsxs("div",{className:`p-4 border-t border-border-default bg-surface-secondary relative shrink-0 ${x!=="chat"?"hidden":""}`,onDrop:ne,onDragOver:Le,children:[ur&&He.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"}),He.map((ee,Ne)=>t.jsxs("button",{onClick:()=>ys(ee.name),onMouseEnter:()=>Qe(Ne),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${Ne===qe?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[t.jsx(Ys,{name:ee.name,avatarUrl:ee.avatarUrl,size:24,bgClass:"bg-brand-500/20 text-brand-500"}),t.jsx("span",{className:"flex-1 min-w-0",children:ee.name}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:ee.role})]},ee.id))]}),et.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[et.map(ee=>t.jsxs("div",{className:"relative group/img shrink-0",children:[Sa(ee)?t.jsx("img",{src:ee.dataUrl,alt:ee.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}):t.jsxs("div",{className:"w-16 h-16 rounded-lg border border-border-default bg-surface-elevated flex flex-col items-center justify-center gap-0.5",title:ee.name,children:[t.jsx("span",{className:"text-xl leading-none",children:il(ee.name,ee.dataUrl)}),t.jsx("span",{className:"text-[9px] text-fg-tertiary truncate max-w-[56px] px-0.5",children:ee.name.split(".").pop()?.toUpperCase()})]}),t.jsx("button",{onClick:()=>Zs(ee.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:"×"})]},ee.id)),et.length<ka&&t.jsx("button",{onClick:()=>le.current?.click(),className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:"Add more files",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"})})})]}),et.length>0&&et.some(ee=>Sa(ee))&&Be&&Be.modelSupportsVision===!1&&t.jsxs("div",{className:"text-[10px] text-amber-500/80 mb-1.5 flex items-center gap-1",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("path",{d:"M12 9v4m0 4h.01M12 2L2 22h20L12 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),"Images will be converted to text (model does not support vision)"]}),t.jsx("input",{ref:le,type:"file",accept:"image/*,.pdf,.docx,.xlsx,.pptx,.xls,.doc,.csv,.json,.xml,.html,.epub",multiple:!0,className:"hidden",onChange:ee=>{ee.target.files&&ls(ee.target.files),ee.target.value=""}}),D&&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:D.sender}),t.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:D.text})]}),t.jsx("button",{onClick:()=>W(null),className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsxs("div",{className:"flex gap-2 items-end",children:[t.jsx("button",{onClick:()=>le.current?.click(),disabled:X==="direct"&&!P,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 files (images, PDF, Word, Excel, PowerPoint...)",children:t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:t.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48",strokeLinecap:"round",strokeLinejoin:"round"})})}),t.jsx("textarea",{ref:Se,value:I,onChange:ee=>{Ls(ee.target.value),ee.target.style.height="auto";const Ne=Math.min(ee.target.scrollHeight,120);ee.target.style.height=`${Ne}px`,ee.target.style.overflowY=Ne>=120?"auto":"hidden"},onKeyDown:ee=>{if(ur&&He.length>0){const Ne=ee.key==="ArrowUp"||ee.ctrlKey&&ee.key==="p",Re=ee.key==="ArrowDown"||ee.ctrlKey&&ee.key==="n",Ke=ee.key==="Enter"||ee.key==="Tab",Xe=ee.key==="Escape";if(Ne){ee.preventDefault(),Qe($e=>($e-1+He.length)%He.length);return}if(Re){ee.preventDefault(),Qe($e=>($e+1)%He.length);return}if(Ke){ee.preventDefault();const $e=He[qe];$e&&ys($e.name);return}if(Xe){ee.preventDefault(),$n(!1);return}}ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),gr())},onPaste:Ca,placeholder:vs,disabled:X==="direct"&&!P,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"}}),J&&X!=="dm"&&t.jsx("button",{onClick:Ds,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:()=>{gr()},disabled:X==="direct"&&!P||!I.trim()&&et.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 gv({agent:e,tasks:n,onViewProfile:s}){const[l,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),u=e.status==="working",h=e.status==="error",f=u?n.find(w=>w.assignedAgentId===e.id&&w.status==="in_progress"):null,x=e.currentActivity;y.useEffect(()=>{if(!l)return;const w=k=>{c.current&&!c.current.contains(k.target)&&i(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]),y.useLayoutEffect(()=>{if(!l||!d.current)return;const w=d.current,k=w.getBoundingClientRect(),C=window.innerWidth;k.right>C-8&&(w.style.left="auto",w.style.right="0"),k.left<8&&(w.style.left="0",w.style.right="auto");const E=C-16;k.width>E&&(w.style.width=`${E}px`)},[l]);const p=h?"bg-red-400 animate-pulse":u?"bg-blue-400 animate-pulse":"bg-green-400",g=h?"error":u?"working":"idle",b=x?x.type==="heartbeat"?`Heartbeat: ${x.heartbeatName??x.label}`:x.type==="chat"?x.label:x.type==="task"?`Task: ${x.label}`:x.label:"Processing...";return t.jsxs("div",{className:"relative",ref:c,children:[t.jsxs("button",{onClick:()=>i(w=>!w),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${u?"bg-blue-500/10 border border-blue-500/20 hover:bg-blue-500/20":h?"bg-red-500/10 border border-red-500/20 hover:bg-red-500/20":"bg-green-500/10 border border-green-500/20 hover:bg-green-500/20"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${p}`}),t.jsx("span",{className:`text-xs ${h?"text-red-500":u?"text-blue-500":"text-green-600"}`,children:g}),e.mailboxDepth!=null&&e.mailboxDepth>0&&t.jsx("span",{className:"text-[9px] bg-fg-tertiary/20 text-fg-tertiary rounded-full px-1.5",children:e.mailboxDepth})]}),l&&h&&t.jsxs("div",{ref:d,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 max-w-[calc(100vw-1rem)] 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:()=>{i(!1),s?.(e.id)},className:"w-full text-center text-[10px] text-red-500 hover:text-red-500 border border-red-500/30 hover:border-red-500/50 rounded-lg py-1 transition-colors",children:"View Agent Profile →"})]}),l&&u&&t.jsxs("div",{ref:d,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:"Current Activity"}),f?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:()=>{i(!1),bt.navigate(ge.WORK,{openTask:f.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:f.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 ${x?.type==="heartbeat"||x?.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:b}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:x?.type==="heartbeat"?"Periodic check-in task":x?.type==="chat"?"Responding to conversation":"Agent is thinking or communicating"})]})]}),t.jsx("button",{onClick:()=>{i(!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 m_=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"midnight",label:"Midnight"}],gw="markus-theme";function bv(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 h_(){try{const e=localStorage.getItem(gw);if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="midnight")return e}catch{}return"system"}function x_(){const[e,n]=y.useState(h_),s=y.useCallback(l=>{n(l);try{localStorage.setItem(gw,l)}catch{}bv(l)},[]);return y.useEffect(()=>{bv(e)},[e]),{mode:e,setMode:s}}function bw({theme:e,onThemeChange:n}={}){const[s,l]=y.useState(null),[i,c]=y.useState(null),[d,u]=y.useState(""),[h,f]=y.useState(!1),[x,p]=y.useState(null),[g,b]=y.useState(null),[w,k]=y.useState(null),[C,E]=y.useState(null),[M,N]=y.useState(!1),[A,R]=y.useState(null),[_,Y]=y.useState(null),[q,X]=y.useState(!1),[L,P]=y.useState(null),[G,$]=y.useState({}),[T,z]=y.useState(!1),[O,V]=y.useState([]),[H,Z]=y.useState([]),[B,F]=y.useState(null),[K,I]=y.useState(null),[S,D]=y.useState(""),[W,J]=y.useState(null),te=y.useRef(null),re=y.useRef(!1),[oe,me]=y.useState(!1),[Oe,ve]=y.useState(200),[ke,Ee]=y.useState(!1),[Me,dt]=y.useState(null),[pt,et]=y.useState(!1),[Pt,le]=y.useState(0),[Se,We]=y.useState(!0),[kt,Ft]=y.useState(!1),[xe,Ce]=y.useState(null),[Fe,lt]=y.useState(null),[ut,Lt]=y.useState(!1),[bn,Ut]=y.useState(new Set),[St,Jt]=y.useState(null),[yt,Xt]=y.useState(!1),_t=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`}),$t=y.useCallback(()=>{se.health().then(l).catch(()=>{}),fetch("/api/settings/llm").then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>{de&&typeof de=="object"&&"providers"in de&&(c(de),u(de.defaultProvider))}).catch(()=>{})},[]),Hn=y.useCallback(()=>{fetch("/api/settings/oauth/providers").then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>V(de.providers??[])).catch(()=>{})},[]),dn=y.useCallback(()=>{fetch("/api/settings/oauth/profiles",{headers:_t()}).then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>Z(de.profiles??[])).catch(()=>{})},[]),ye=y.useCallback(()=>{se.settings.getAgent().then(de=>{de&&typeof de.maxToolIterations=="number"&&ve(de.maxToolIterations)}).catch(()=>{})},[]),Ge=y.useCallback(()=>{se.settings.getBrowser().then(de=>{de&&(et(de.bringToFront??!1),le(de.remoteDebuggingPort??0),We(de.autoCloseTabs??!0))}).catch(()=>{})},[]),it=y.useCallback(()=>{Lt(!0),se.system.storage().then(lt).catch(()=>{}).finally(()=>Lt(!1)),se.system.orphans().then(Jt).catch(()=>{})},[]);y.useEffect(()=>{$t(),Hn(),dn(),ye(),Ge(),it()},[$t,Hn,dn,ye,Ge,it]),y.useEffect(()=>{const de=()=>it();return window.addEventListener("markus:data-changed",de),()=>window.removeEventListener("markus:data-changed",de)},[it]);const Et=y.useCallback(async()=>{X(!0),P(null),Y(null),$({});try{const de=await fetch("/api/settings/env-models",{headers:_t()});if(!de.ok){P({type:"err",text:`Detection failed (HTTP ${de.status})`});return}const Te=await de.json();if(Y(Te),Te.detected.length===0)P({type:"err",text:"No model API keys found in environment variables"});else{const Ue={};for(const qt of Te.detected)Ue[qt.provider]=!0;$(Ue)}}catch{P({type:"err",text:"Failed to detect environment variables"})}finally{X(!1)}},[]),It=i?Object.values(i.providers).some(de=>de.configured):!1;y.useEffect(()=>{i&&!It&&!re.current&&(re.current=!0,Et())},[i,It,Et]);const kn=async()=>{if(!(!d||d===i?.defaultProvider)){f(!0),p(null);try{const de=await fetch("/api/settings/llm",{method:"POST",headers:_t(),body:JSON.stringify({defaultProvider:d})}),Te=await de.json();de.ok?(c(Te),p({type:"ok",text:`Default provider updated to ${Te.defaultProvider}`})):p({type:"err",text:Te.error??"Save failed"})}catch{p({type:"err",text:"Network error"})}finally{f(!1)}}},_n=async(de,Te)=>{k(de);try{const Ue=await fetch(`/api/settings/llm/providers/${de}/toggle`,{method:"POST",headers:_t(),body:JSON.stringify({enabled:Te})});if(Ue.ok){const qt=await Ue.json();c(qt)}}catch{}finally{k(null)}},Mn=async()=>{N(!0),R(null);try{const Te=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:_t(),body:JSON.stringify({preview:!0})})).json();"error"in Te?R({type:"err",text:Te.error}):E(Te)}catch{R({type:"err",text:"Detection failed"})}finally{N(!1)}},dr=async()=>{N(!0),R(null);try{const Te=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:_t(),body:JSON.stringify({preview:!1})})).json();"error"in Te?R({type:"err",text:Te.error}):(R({type:"ok",text:`Imported ${Te.appliedModels} model configs from OpenClaw`}),$t())}catch{R({type:"err",text:"Import failed"})}finally{N(!1)}},sr=async()=>{if(!_)return;const de=_.detected.filter(Te=>G[Te.provider]);if(de.length===0){P({type:"err",text:"Select at least one provider to apply"});return}z(!0),P(null);try{const Te=await fetch("/api/settings/env-models",{method:"POST",headers:_t(),body:JSON.stringify({providers:de.map(qt=>({provider:qt.provider,model:qt.model,baseUrl:qt.baseUrl,enabled:!0}))})});if(!Te.ok){P({type:"err",text:`Apply failed (HTTP ${Te.status})`});return}const Ue=await Te.json();P({type:"ok",text:Ue.message}),Y(null),$({}),$t()}catch{P({type:"err",text:"Failed to apply environment configs"})}finally{z(!1)}};y.useEffect(()=>()=>{te.current&&clearInterval(te.current)},[]);const[ur,$n]=y.useState(!1),[ae,Ie]=y.useState({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),[qe,Qe]=y.useState(!1),[ue,ze]=y.useState(null),[Ve,tt]=y.useState(null),[ot,At]=y.useState({apiKey:"",baseUrl:"",model:"",contextWindow:0,maxOutputTokens:0,costInput:0,costOutput:0}),[Sn,ar]=y.useState(!1),[mn,Wn]=y.useState(null),[Ot,pr]=y.useState(null),[Tt,hn]=y.useState({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1}),[ln,ss]=y.useState(!1),Rr=async()=>{if(!(!ae.name||!ae.model)){Qe(!0),ze(null);try{const de=await fetch("/api/settings/llm/providers",{method:"POST",headers:_t(),body:JSON.stringify({name:ae.name,apiKey:ae.apiKey||void 0,baseUrl:ae.baseUrl||void 0,model:ae.model,contextWindow:ae.contextWindow||void 0,maxOutputTokens:ae.maxOutputTokens||void 0,cost:ae.costInput||ae.costOutput?{input:ae.costInput,output:ae.costOutput}:void 0})}),Te=await de.json();de.ok?(c(Te),$n(!1),Ie({name:"",apiKey:"",baseUrl:"",model:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5}),ze({type:"ok",text:`Provider ${ae.name} added`})):ze({type:"err",text:Te.error??"Failed to add"})}catch{ze({type:"err",text:"Network error"})}finally{Qe(!1)}}},lr=(de,Te)=>{tt(de),At({apiKey:"",baseUrl:Te.baseUrl??"",model:Te.model,contextWindow:Te.contextWindow??0,maxOutputTokens:Te.maxOutputTokens??0,costInput:Te.cost?.input??0,costOutput:Te.cost?.output??0})},Or=async de=>{ar(!0);try{const Te={};ot.apiKey&&(Te.apiKey=ot.apiKey),ot.baseUrl!==void 0&&(Te.baseUrl=ot.baseUrl),ot.model&&(Te.model=ot.model),ot.contextWindow&&(Te.contextWindow=ot.contextWindow),ot.maxOutputTokens&&(Te.maxOutputTokens=ot.maxOutputTokens),(ot.costInput||ot.costOutput)&&(Te.cost={input:ot.costInput,output:ot.costOutput});const Ue=await fetch(`/api/settings/llm/providers/${de}`,{method:"PUT",headers:_t(),body:JSON.stringify(Te)});if(Ue.ok){const qt=await Ue.json();c(qt),tt(null)}}catch{}finally{ar(!1)}},gs=async de=>{Wn(de);try{const Te=await fetch(`/api/settings/llm/providers/${de}`,{method:"DELETE",headers:_t()});if(Te.ok){const Ue=await Te.json();c(Ue),u(Ue.defaultProvider)}}catch{}finally{Wn(null)}},as=async de=>{if(!(!Tt.id||!Tt.name)){ss(!0);try{const Te=await fetch(`/api/settings/llm/providers/${de}/models`,{method:"POST",headers:_t(),body:JSON.stringify({id:Tt.id,name:Tt.name,contextWindow:Tt.contextWindow,maxOutputTokens:Tt.maxOutputTokens,cost:{input:Tt.costInput,output:Tt.costOutput},reasoning:Tt.reasoning||void 0,inputTypes:Tt.vision?["text","image"]:["text"]})});if(Te.ok){const Ue=await Te.json();c(Ue),pr(null),hn({id:"",name:"",contextWindow:128e3,maxOutputTokens:16384,costInput:1,costOutput:5,reasoning:!1,vision:!1})}}catch{}finally{ss(!1)}}},Os=async(de,Te)=>{try{const Ue=await fetch(`/api/settings/llm/providers/${de}/models/${encodeURIComponent(Te)}`,{method:"DELETE",headers:_t()});if(Ue.ok){const qt=await Ue.json();c(qt)}}catch{}},Ds=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"]),[gr,Dr]=y.useState(null),fr=async(de,Te)=>{Dr(`${de}:${Te}`);try{const Ue=await fetch(`/api/settings/llm/providers/${de}/model`,{method:"POST",headers:_t(),body:JSON.stringify({model:Te})});if(Ue.ok){const qt=await Ue.json();c(qt)}}catch{}finally{Dr(null)}},Vn=i?.providers?Object.entries(i.providers).filter(([,de])=>de.configured&&de.enabled).map(([de])=>de):[],bs=i&&!It&&!oe;return t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Settings"})}),t.jsxs("div",{className:"p-7 space-y-10 max-w-4xl",children:[t.jsx(ma,{title:"Appearance",children:t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsxs("div",{className:"flex 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:m_.map(({value:de,label:Te})=>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:Te},de))})]})})}),bs&&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:()=>me(!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(mh,{step:"1",title:"From Environment Variables",description:"Automatically detected API keys from .env or system environment.",active:!!(_&&_.detected.length>0),children:[q&&t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Detecting..."}),_&&_.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[_.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:G[de.provider]??!1,onChange:Te=>$({...G,[de.provider]:Te.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:()=>{sr()},disabled:T||Object.values(G).filter(Boolean).length===0,className:"w-full px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:T?"Applying...":`Apply ${Object.values(G).filter(Boolean).length} Provider(s)`})]}),_&&_.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."]}),L&&t.jsx(Za,{type:L.type,text:L.text})]}),t.jsxs(mh,{step:"2",title:"From OpenClaw Config",description:"Import model configs from an existing OpenClaw installation.",children:[C?C.found?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found: ",t.jsx("code",{className:"text-fg-secondary",children:C.summary.configPath})]}),C.summary.models&&t.jsxs("div",{className:"text-xs text-fg-secondary",children:[C.summary.models.providerCount," providers, ",C.summary.models.providers.reduce((de,Te)=>de+Te.modelCount,0)," models"]}),t.jsx("button",{onClick:()=>{dr()},disabled:M,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?"Importing...":"Import Model Configs"})]}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"No OpenClaw config found."}):t.jsx("button",{onClick:()=>{Mn()},disabled:M,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:M?"Detecting...":"Detect OpenClaw"}),A&&t.jsx(Za,{type:A.type,text:A.text})]}),t.jsx(mh,{step:"3",title:"Manual Configuration",description:t.jsxs(t.Fragment,{children:["Edit ",t.jsx("code",{className:"text-fg-secondary",children:"~/.markus/markus.json"})," directly, then restart the server."]})})]}),t.jsx(ma,{title:"System Status",children:s?t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsx(hh,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx(hh,{label:"Version",value:s.version,color:"indigo"}),t.jsx(hh,{label:"Active Agents",value:String(s.agents),color:"purple"})]}):t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Loading..."})}),t.jsx(ma,{title:"Default LLM Provider",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium",children:"Primary Provider"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Used for all agent interactions unless overridden"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[i?t.jsx("select",{value:d,onChange:de=>{u(de.target.value),p(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:Vn.length>0?Vn.map(de=>t.jsx("option",{value:de,children:i.providers[de]?.displayName??de},de)):t.jsx("option",{value:"",children:"No providers configured"})}):t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading..."}),d!==i?.defaultProvider&&t.jsx("button",{onClick:()=>{kn()},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"})]})]}),x&&t.jsx(Za,{type:x.type,text:x.text})]})}),t.jsxs(ma,{title:"Model Providers & Pricing",children:[t.jsx("div",{className:"space-y-3",children:i&&Object.entries(i.providers).map(([de,Te])=>t.jsxs("div",{className:`bg-surface-secondary border rounded-xl overflow-hidden transition-colors ${Te.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:()=>b(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 ${Te.configured&&Te.enabled?"bg-green-400":Te.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:Te.displayName??de}),de===i.defaultProvider&&t.jsx("span",{className:"text-[10px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"default"}),Te.configured&&!Te.enabled&&t.jsx("span",{className:"text-[10px] bg-amber-500/15 text-amber-600 px-1.5 py-0.5 rounded",children:"disabled"}),Te.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:Te.model||"Not configured"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[Te.configured&&t.jsx("button",{onClick:Ue=>{Ue.stopPropagation(),_n(de,!Te.enabled)},disabled:w===de,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${Te.enabled?"bg-green-500":"bg-gray-600"} ${w===de?"opacity-50":""}`,title:Te.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 ${Te.enabled?"translate-x-4":"translate-x-1"}`})}),Te.contextWindow&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[(Te.contextWindow/1e3).toFixed(0),"K ctx"]}),Te.cost&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["$",Te.cost.input,"/",Te.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:[Te.configured&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[t.jsx(Qa,{label:"Model",value:Te.model}),t.jsx(Qa,{label:"Context Window",value:Te.contextWindow?`${(Te.contextWindow/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(Qa,{label:"Max Output",value:Te.maxOutputTokens?`${(Te.maxOutputTokens/1e3).toFixed(0)}K tokens`:"N/A"}),t.jsx(Qa,{label:"Base URL",value:Te.baseUrl??"Default"})]}),Ve===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:ot.apiKey,onChange:Ue=>At({...ot,apiKey:Ue.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:ot.baseUrl,onChange:Ue=>At({...ot,baseUrl:Ue.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:ot.model,onChange:Ue=>At({...ot,model:Ue.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:ot.contextWindow||"",onChange:Ue=>At({...ot,contextWindow:Number(Ue.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:ot.maxOutputTokens||"",onChange:Ue=>At({...ot,maxOutputTokens:Number(Ue.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:ot.costInput||"",onChange:Ue=>At({...ot,costInput:Number(Ue.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:ot.costOutput||"",onChange:Ue=>At({...ot,costOutput:Number(Ue.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:()=>{Or(de)},disabled:Sn,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:Sn?"Saving...":"Save"}),t.jsx("button",{onClick:()=>tt(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:Ue=>{Ue.stopPropagation(),lr(de,Te)},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:Ue=>{Ue.stopPropagation(),confirm(`Delete provider "${Te.displayName??de}"?`)&&gs(de)},disabled:mn===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:mn===de?"Deleting...":"Delete"})]})]}),Te.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(Qa,{label:"Input",value:`$${Te.cost.input}`}),t.jsx(Qa,{label:"Output",value:`$${Te.cost.output}`}),Te.cost.cacheRead!=null&&t.jsx(Qa,{label:"Cache Read",value:`$${Te.cost.cacheRead}`}),Te.cost.cacheWrite!=null&&t.jsx(Qa,{label:"Cache Write",value:`$${Te.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"}),Te.configured&&Ot!==de&&t.jsx("button",{onClick:()=>{pr(de),hn({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"})]}),Ot===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:Tt.id,onChange:Ue=>hn({...Tt,id:Ue.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:Tt.name,onChange:Ue=>hn({...Tt,name:Ue.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:Tt.contextWindow,onChange:Ue=>hn({...Tt,contextWindow:Number(Ue.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:Tt.maxOutputTokens,onChange:Ue=>hn({...Tt,maxOutputTokens:Number(Ue.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:Tt.costInput,onChange:Ue=>hn({...Tt,costInput:Number(Ue.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:Tt.costOutput,onChange:Ue=>hn({...Tt,costOutput:Number(Ue.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:Tt.reasoning,onChange:Ue=>hn({...Tt,reasoning:Ue.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:Tt.vision,onChange:Ue=>hn({...Tt,vision:Ue.target.checked}),className:"rounded"}),"vision"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{onClick:()=>{as(de)},disabled:ln||!Tt.id||!Tt.name,className:"px-2 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white rounded transition-colors",children:ln?"Adding...":"Add"}),t.jsx("button",{onClick:()=>pr(null),className:"px-2 py-1 text-[10px] border border-border-default text-fg-secondary hover:bg-surface-elevated rounded transition-colors",children:"Cancel"})]})]}),Te.models&&Te.models.length>0&&t.jsx("div",{className:"space-y-1.5",children:Te.models.map(Ue=>{const qt=Ue.id===Te.model,Ar=gr===`${de}:${Ue.id}`,Pn=!Ds.has(Ue.id);return t.jsxs("div",{className:`flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-colors ${qt?"bg-brand-500/15 border border-brand-500/30":Te.configured?"bg-surface-elevated/30 hover:bg-surface-elevated/60 cursor-pointer":"bg-surface-elevated/30"}`,onClick:()=>{!qt&&Te.configured&&!Ar&&fr(de,Ue.id)},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[qt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0"}),t.jsx("span",{className:qt?"text-brand-500 font-medium":"text-fg-secondary",children:Ue.name}),Ue.reasoning&&t.jsx("span",{className:"text-[9px] bg-amber-500/15 text-amber-600 px-1 py-0.5 rounded",children:"reasoning"}),Ue.inputTypes?.includes("image")&&t.jsx("span",{className:"text-[9px] bg-blue-500/15 text-blue-600 px-1 py-0.5 rounded",children:"vision"}),Pn&&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:[(Ue.contextWindow/1e3).toFixed(0),"K ctx"]}),t.jsxs("span",{children:["$",Ue.cost.input,"/$",Ue.cost.output]}),Te.configured&&!qt&&t.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded transition-colors ${Ar?"bg-brand-500/30 text-brand-400":"bg-surface-overlay text-fg-tertiary hover:bg-brand-500/20 hover:text-brand-500"}`,children:Ar?"Switching...":"Use"}),qt&&t.jsx("span",{className:"text-[9px] bg-brand-500/15 text-brand-500 px-1.5 py-0.5 rounded",children:"active"}),Pn&&!qt&&t.jsx("button",{onClick:mr=>{mr.stopPropagation(),Os(de,Ue.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"})})})]})]},Ue.id)})})]}),!Te.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))}),ur?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:ae.name,onChange:de=>Ie({...ae,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:ae.apiKey,onChange:de=>Ie({...ae,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:ae.baseUrl,onChange:de=>Ie({...ae,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:ae.model,onChange:de=>Ie({...ae,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:ae.contextWindow,onChange:de=>Ie({...ae,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:ae.maxOutputTokens,onChange:de=>Ie({...ae,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:ae.costInput,onChange:de=>Ie({...ae,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:ae.costOutput,onChange:de=>Ie({...ae,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:()=>{Rr()},disabled:qe||!ae.name||!ae.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:qe?"Adding...":"Add Provider"}),t.jsx("button",{onClick:()=>{$n(!1),ze(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"})]}),ue&&t.jsx(Za,{type:ue.type,text:ue.text})]}):t.jsx("button",{onClick:()=>$n(!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(ma,{title:"Environment Variable Configuration",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Detect model API keys from environment variables and write them to the config file."}),t.jsxs("button",{onClick:()=>{Et()},disabled:q,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 ${q?"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"})}),q?"Detecting...":"Refresh Environment Variables"]}),_&&_.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:"}),_.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:G[de.provider]??!1,onChange:Te=>$({...G,[de.provider]:Te.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(Te=>t.jsx("div",{children:t.jsx("code",{children:Te})},Te))})]},de.provider)),_.timeoutMs&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["LLM Timeout: ",t.jsxs("code",{className:"text-fg-secondary",children:[_.timeoutMs,"ms"]})," (from ",t.jsx("code",{children:"LLM_TIMEOUT_MS"}),")"]}),t.jsx("button",{onClick:()=>{sr()},disabled:T||Object.values(G).filter(Boolean).length===0,className:"px-4 py-2 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-lg transition-colors",children:T?"Applying...":`Apply ${Object.values(G).filter(Boolean).length} Provider(s) to Config`})]}),L&&t.jsx(Za,{type:L.type,text:L.text})]})}),t.jsx(ma,{title:"Import from OpenClaw",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-4",children:[t.jsx("div",{className:"text-sm text-fg-secondary",children:"Detect and import LLM configurations from an existing OpenClaw installation."}),t.jsx("div",{className:"flex gap-3",children:t.jsx("button",{onClick:()=>{Mn()},disabled:M,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:M?"Detecting...":"Detect OpenClaw Config"})}),C&&C.found&&t.jsxs("div",{className:"border-t border-border-default pt-4 space-y-3",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found OpenClaw config at: ",t.jsx("code",{className:"text-fg-secondary",children:C.summary.configPath})]}),C.summary.models&&t.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg p-3",children:[t.jsxs("div",{className:"text-xs text-fg-tertiary mb-2",children:[C.summary.models.providerCount," model providers found:"]}),t.jsx("div",{className:"space-y-1",children:C.summary.models.providers.map(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))})]}),C.summary.channels&&C.summary.channels.length>0&&t.jsx("div",{className:"bg-surface-elevated/30 rounded-lg p-3",children:t.jsxs("div",{className:"text-xs text-fg-tertiary mb-1",children:["Channels: ",C.summary.channels.join(", ")]})}),t.jsx("button",{onClick:()=>{dr()},disabled:M,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?"Importing...":"Import Model Configs"})]}),A&&t.jsx(Za,{type:A.type,text:A.text})]})}),t.jsx(ma,{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:Oe,onChange:de=>{ve(Number(de.target.value)),dt(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:ke,onClick:async()=>{Ee(!0),dt(null);try{const de=await se.settings.updateAgent({maxToolIterations:Oe});ve(de.maxToolIterations),dt({type:"ok",text:"Saved"})}catch{dt({type:"err",text:"Failed to save"})}Ee(!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:ke?"Saving…":"Save"})]})]}),Me&&t.jsx(Za,{type:Me.type,text:Me.text})]})}),t.jsx(ma,{title:"Browser Automation",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Settings for the Chrome DevTools browser skill. Agents use Chrome to browse, test web apps, and inspect pages."}),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:"Bring to Foreground"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"When enabled, Chrome tabs will be brought to the foreground when agents navigate. When disabled (default), agents work silently in the background without stealing focus."})]}),t.jsx("button",{onClick:async()=>{const de=!pt;et(de),Ft(!0),Ce(null);try{const Te=await se.settings.updateBrowser({bringToFront:de});et(Te.bringToFront),Ce({type:"ok",text:de?"Tabs will be brought to foreground":"Tabs will stay in background"})}catch{Ce({type:"err",text:"Failed to save"}),et(!de)}Ft(!1)},disabled:kt,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${pt?"bg-green-500":"bg-gray-600"} ${kt?"opacity-50":""}`,children:t.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${pt?"translate-x-4":"translate-x-1"}`})})]}),t.jsxs("div",{className:"flex items-center justify-between border-t border-border-default pt-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Auto-close Tabs"}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:"Automatically close agent-owned browser tabs when the agent task completes or the agent is removed."})]}),t.jsx("button",{onClick:async()=>{const de=!Se;We(de),Ft(!0),Ce(null);try{const Te=await se.settings.updateBrowser({autoCloseTabs:de});We(Te.autoCloseTabs),Ce({type:"ok",text:"Saved"})}catch{Ce({type:"err",text:"Failed to save"}),We(!de)}Ft(!1)},disabled:kt,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${Se?"bg-green-500":"bg-gray-600"} ${kt?"opacity-50":""}`,children:t.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${Se?"translate-x-4":"translate-x-1"}`})})]}),t.jsx("div",{className:"border-t border-border-default pt-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:"Remote Debugging Port"}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["Set a persistent debugging port (e.g. 9222) to avoid Chrome's permission dialog every time an agent connects. Start Chrome with"," ",t.jsx("code",{className:"text-fg-secondary bg-surface-elevated px-1 rounded",children:"--remote-debugging-port=9222"})," ","then set the same port here. Set to 0 to use auto-connect (requires manual permission approval)."]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"number",min:0,max:65535,value:Pt,onChange:de=>{le(Number(de.target.value)),Ce(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",placeholder:"0"}),t.jsx("button",{disabled:kt,onClick:async()=>{Ft(!0),Ce(null);try{const de=await se.settings.updateBrowser({remoteDebuggingPort:Pt});le(de.remoteDebuggingPort),Ce({type:"ok",text:de.remoteDebuggingPort>0?`Using persistent connection on port ${de.remoteDebuggingPort} (no more permission dialogs)`:"Using auto-connect mode (permission dialog required on each connection)"})}catch{Ce({type:"err",text:"Failed to save"})}Ft(!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:kt?"Saving...":"Save"})]})]})}),xe&&t.jsx(Za,{type:xe.type,text:xe.text})]})}),t.jsx(ma,{title:"Data & Storage",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 space-y-5",children:[ut&&!Fe&&t.jsx("div",{className:"text-sm text-fg-tertiary",children:"Scanning storage..."}),Fe&&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:Fs(Fe.totalSize)}),t.jsx("div",{className:"text-xs text-fg-tertiary font-mono mt-0.5",children:Fe.dataDir})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>it(),disabled:ut,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:ut?"Scanning...":"Refresh"}),t.jsx("button",{onClick:()=>{se.system.openPath(Fe.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:Fe.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:Fs(de.size)})]},de.name))})]}),Fe.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 (",Fe.agents.length,")"]}),t.jsx("div",{className:"space-y-1",children:Fe.agents.map(de=>{const Te=bn.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:()=>Ut(Ue=>{const qt=new Set(Ue);return qt.has(de.id)?qt.delete(de.id):qt.add(de.id),qt}),children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:Te?"▼":"▶"}),t.jsx("button",{onClick:Ue=>{Ue.stopPropagation(),bt.navigate(ge.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:Fs(de.size)})]}),Te&&t.jsxs("div",{className:"px-3 pb-2 pt-0.5 space-y-0.5",children:[de.subItems.filter(Ue=>Ue.size>0).map(Ue=>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:Ue.name}),t.jsx("span",{className:"text-fg-secondary tabular-nums",children:Fs(Ue.size)})]},Ue.name)),t.jsx("div",{className:"pl-5 pt-1",children:t.jsx("button",{onClick:()=>{se.system.openPath(Fe.dataDir+"/agents/"+de.id)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary underline",children:"Open folder"})})]})]},de.id)})})]}),St&&(St.orphanAgents.length>0||St.orphanTeams.length>0)&&t.jsx(p_,{orphanInfo:St,dataDir:Fe.dataDir,onPurged:it})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function mh({step:e,title:n,description:s,active:l,children:i}){return t.jsxs("div",{className:`rounded-xl border p-4 space-y-3 transition-colors ${l?"border-brand-500/60 bg-brand-500/10":"border-border-default bg-surface-secondary/60"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"flex-none w-6 h-6 rounded-full bg-surface-overlay flex items-center justify-center text-xs font-bold text-fg-secondary",children:e}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s})]})]}),i&&t.jsx("div",{className:"pl-9",children:i})]})}function Za({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 ma({title:e,children:n}){return t.jsxs("section",{children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary uppercase tracking-wider mb-4",children:e}),t.jsx("div",{className:"space-y-4",children:n})]})}function hh({label:e,value:n,color:s}){const l=s==="green"?"bg-green-500/10 text-green-600":"bg-brand-500/10 text-brand-500";return t.jsxs("div",{className:`rounded-xl px-5 py-4 ${l}`,children:[t.jsx("div",{className:"text-2xl font-bold",children:n}),t.jsx("div",{className:"text-xs mt-1 opacity-70",children:e})]})}function Qa({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 Fs(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),l=e/Math.pow(1024,s);return`${l<10?l.toFixed(1):Math.round(l)} ${n[s]}`}function p_({orphanInfo:e,dataDir:n,onPurged:s}){const l=[...e.orphanAgents.map(k=>({...k,kind:"agent"})),...e.orphanTeams.map(k=>({...k,kind:"team"}))],[i,c]=y.useState(new Set),[d,u]=y.useState(!1),[h,f]=y.useState(null),x=k=>c(C=>{const E=new Set(C);return E.has(k)?E.delete(k):E.add(k),E}),p=i.size===l.length&&l.length>0,g=()=>c(p?new Set:new Set(l.map(k=>k.id))),b=l.filter(k=>i.has(k.id)).reduce((k,C)=>k+C.size,0),w=async k=>{u(!0),f(null);try{const C=await se.system.purgeOrphans(k),E=C.purgedAgents.length+C.purgedTeams.length;f(`Cleaned ${E} dir${E!==1?"s":""}, freed ${Fs(C.freedBytes)}${C.failures.length?` (${C.failures.length} failed)`:""}`),c(new Set),s()}catch{f("Cleanup failed")}finally{u(!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: ",Fs(e.totalOrphanSize)," across ",l.length," director",l.length===1?"y":"ies","."]}),t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:p,onChange:g,className:"rounded"}),"Select all"]}),i.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[i.size," selected (",Fs(b),")"]})]}),t.jsx("div",{className:"space-y-0.5 mb-3 max-h-52 overflow-y-auto",children:l.map(k=>t.jsxs("div",{className:`flex items-center gap-2 text-xs py-1.5 px-2 rounded transition-colors ${i.has(k.id)?"bg-amber-500/10":"bg-surface-elevated/30 hover:bg-surface-elevated/50"}`,children:[t.jsx("input",{type:"checkbox",checked:i.has(k.id),onChange:()=>x(k.id),className:"rounded shrink-0"}),k.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:k.id}),t.jsx("span",{className:"text-fg-secondary tabular-nums shrink-0",children:Fs(k.size)}),t.jsx("button",{onClick:()=>{se.system.openPath(k.path)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary shrink-0 underline",children:"Open"})]},k.id))}),t.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[i.size>0&&t.jsx("button",{disabled:d,onClick:()=>{w([...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:d?"Cleaning...":`Clean Selected (${Fs(b)})`}),t.jsx("button",{disabled:d,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:d?"Cleaning...":`Clean All (${Fs(e.totalOrphanSize)})`})]}),h&&t.jsx("div",{className:"text-xs text-fg-tertiary mt-2",children:h})]})}const iu=new Map;function Sl(e,n){iu.has(e)||iu.set(e,n().catch(()=>{}))}function Tl(e){const n=iu.get(e);return iu.delete(e),n}const qr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"};function yw(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function g_(e,n){const s=e.split(".").map(Number),l=n.split(".").map(Number);for(let i=0;i<Math.max(s.length,l.length);i++){const c=s[i]??0,d=l[i]??0;if(c>d)return!0;if(c<d)return!1}return!1}const vw={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function tx({authUser:e}={}){const[n,s]=y.useState("all"),[l,i]=y.useState(""),[c,d]=y.useState([]),[u,h]=y.useState([]),[f,x]=y.useState(null),[p,g]=y.useState(!1),[b,w]=y.useState(!0),[k,C]=y.useState(new Map),E=y.useCallback(async()=>{try{const[A,R]=await Promise.all([se.builder.artifacts.list().catch(()=>({artifacts:[]})),se.builder.artifacts.installed().catch(()=>({installed:{}}))]),_=new Map;for(const Y of A.artifacts){if(Y.type!=="agent")continue;const q=!!R.installed[`agent/${Y.name}`];_.set(Y.name,{installed:q,localVersion:Y.meta.version||void 0,localUpdatedAt:Y.updatedAt})}C(_)}catch{}},[]),M=y.useCallback(async()=>{w(!0);try{if(n==="hub"){const A=l?Bn.search({type:"agent",q:l,limit:50}):Tl(qr.hubAgents)??Bn.search({type:"agent",limit:50}),[R]=await Promise.all([A.catch(()=>({items:[],total:0})),E()]);h(R?.items??[]),d([])}else{h([]);const A=new URLSearchParams;l&&A.set("q",l);const R=await fetch("/api/templates?"+A.toString()).then(_=>_.json()).catch(()=>({templates:[]}));d(Array.isArray(R.templates)?R.templates:[])}}catch{d([]),h([])}finally{w(!1)}},[n,l,E]);y.useEffect(()=>{M()},[M]);const N=async(A,R,_)=>{try{const Y=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:A,name:R,orgId:"default",teamId:_})});if(!Y.ok)throw new Error(`Failed: ${Y.status}`);g(!1),x(null)}catch(Y){alert(`Failed to create agent: ${Y}`)}};return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:"px-6 h-14 flex items-center border-b border-border-default bg-surface-secondary shrink-0",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Agent Store"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 py-2 border-b border-border-default/50 bg-surface-secondary/50 shrink-0",children:[t.jsx("div",{className:"flex gap-1",children:[{id:"all",label:"Built-in"},{id:"hub",label:"Markus Hub"}].map(A=>t.jsx("button",{onClick:()=>{s(A.id),x(null)},className:`px-3 py-1 text-xs rounded-md transition-colors ${n===A.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:A.label},A.id))}),n==="all"&&t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[c.length," agent",c.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search agents...",value:l,onChange:A=>i(A.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:b?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading agents..."}):n==="hub"?u.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx("div",{className:"text-fg-tertiary text-3xl mb-3",children:"🏪"}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No 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:u.map(A=>t.jsx(b_,{item:A,localInfo:k.get(yw(A.name)),onStatusChange:E},A.id))}):c.length===0?t.jsxs("div",{className:"text-center py-20",children:[t.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),t.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?`No agents match "${l}"`:"No agents found"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:l?"Try different search terms.":"Agents come from the built-in registry."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:c.map(A=>t.jsx(y_,{template:A,isSelected:f?.id===A.id,onSelect:()=>x(f?.id===A.id?null:A)},A.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:()=>x(null),className:"text-fg-tertiary hover:text-fg-secondary text-lg px-2",children:"×"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-2",children:"Skills"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[f.skills.map(A=>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:A},A)),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 ${vw[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((A,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 ${A.priority==="high"?"bg-red-400":A.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),A.title]},R))})]})]})]})}),p&&f&&t.jsx(v_,{template:f,onClose:()=>g(!1),onHire:N})]})}function b_({item:e,localInfo:n,onStatusChange:s}){const[l,i]=y.useState(!1),[c,d]=y.useState(""),u=n?.installed??!1,h=u&&e.version&&n?.localVersion&&g_(e.version,n.localVersion),f=async x=>{if(x.stopPropagation(),!l){i(!0),d("");try{const p=await Bn.download(e.id),g=p.name||e.name,b=yw(g),w=p.itemType==="team"?"team":p.itemType==="skill"?"skill":"agent",k={type:"hub",hubItemId:e.id};if(p.files&&Object.keys(p.files).length>0)await se.builder.artifacts.import(w,b,p.files,k);else{const C={...p.config,name:g,description:e.description,source:k};await se.builder.artifacts.save(w,C)}await se.builder.artifacts.install(w,b),d(h?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{d("Failed")}finally{i(!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:[e.slug&&e.author?.username&&t.jsx("a",{href:`${Bn.getUrl()}/${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"text-[10px] text-brand-500 hover:text-brand-400 mr-auto",children:"View on Hub →"}),h?t.jsx("button",{onClick:x=>{f(x)},disabled:l,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Upgrading...":`Upgrade → v${e.version}`}):u?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:x=>{f(x)},disabled:l,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Installing...":"Install"}),c&&t.jsx("span",{className:`text-[10px] ${c==="Failed"?"text-red-500":"text-green-600"}`,children:c})]})]})]})}function y_({template:e,isSelected:n,onSelect:s}){return t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:["by ",e.author]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-3",children:[e.skills.slice(0,4).map(l=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated/80 text-fg-secondary rounded-md border border-border-default/50",children:l},l)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-muted",children:["+",e.skills.length-4]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-2 text-xs",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded-md text-[10px] font-medium capitalize ${vw[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 v_({template:e,onClose:n,onHire:s}){const[l,i]=y.useState(`${e.name} Agent`),[c,d]=y.useState(""),[u,h]=y.useState([]),[f,x]=y.useState(!1);y.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(g=>g.json()).then(g=>h(g.teams??[])).catch(()=>{})},[]);const p=async()=>{if(l.trim()){x(!0);try{await s(e.id,l.trim(),c||void 0)}finally{x(!1)}}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:g=>g.stopPropagation(),children:[t.jsx("div",{className:"flex items-center gap-3 mb-5",children:t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Hire Agent"}),t.jsxs("p",{className:"text-xs text-fg-tertiary",children:['Creating agent from "',e.name,'"']})]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Agent Name"}),t.jsx("input",{type:"text",value:l,onChange:g=>i(g.target.value),className:"input-field",autoFocus:!0})]}),u.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Assign to Team (optional)"}),t.jsxs("select",{value:c,onChange:g=>d(g.target.value),className:"input-field",children:[t.jsx("option",{value:"",children:"No team"}),u.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:p,disabled:!l.trim()||f,className:"btn-primary",children:f?"Creating...":"Create Agent"})]})]})})}function jw(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function j_(e,n){const s=e.split(".").map(Number),l=n.split(".").map(Number);for(let i=0;i<Math.max(s.length,l.length);i++){const c=s[i]??0,d=l[i]??0;if(c>d)return!0;if(c<d)return!1}return!1}function nx(){const[e,n]=y.useState("all"),[s,l]=y.useState(""),[i,c]=y.useState([]),[d,u]=y.useState([]),[h,f]=y.useState(null),[x,p]=y.useState(!0),[g,b]=y.useState(!1),[w,k]=y.useState(null),[C,E]=y.useState(new Map),M=y.useCallback(async()=>{try{const[R,_]=await Promise.all([se.builder.artifacts.list().catch(()=>({artifacts:[]})),se.builder.artifacts.installed().catch(()=>({installed:{}}))]),Y=new Map;for(const q of R.artifacts){if(q.type!=="team")continue;const X=!!_.installed[`team/${q.name}`];Y.set(q.name,{installed:X,localVersion:q.meta.version||void 0,localUpdatedAt:q.updatedAt})}E(Y)}catch{}},[]),N=y.useCallback(async()=>{p(!0);try{if(e==="hub"){const R=s?Bn.search({type:"team",q:s,limit:50}):Tl(qr.hubTeams)??Bn.search({type:"team",limit:50}),[_]=await Promise.all([R.catch(()=>({items:[],total:0})),M()]);u(_?.items??[]),c([])}else{u([]);const R=await se.teamTemplates.list(s||void 0);c(R?.templates??[])}}catch{c([]),u([])}finally{p(!1)}},[e,s,M]);y.useEffect(()=>{N()},[N]);const A=async R=>{b(!0),k(null);try{const Y=(await se.teams.create(R.name,R.description)).team.id;let q,X=0;const L=[];for(const G of R.members){const $=G.count??1;for(let T=0;T<$;T++){const z=G.name??`${R.name} Agent ${T+1}`,O=$>1?`${z} ${T+1}`:z,V=G.roleName??G.templateId;try{const H=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:O,...V?{roleName:V}:{},orgId:"default",teamId:Y,agentRole:G.role??"worker",skills:G.skills??[]})});if(H.ok){X++;const Z=await H.json();G.role==="manager"&&!q&&(q=Z.agent?.id)}else{const Z=await H.json().catch(()=>({error:`HTTP ${H.status}`}));L.push(`${O}: ${Z.error??H.statusText}`)}}catch(H){L.push(`${O}: ${String(H)}`)}}}q&&await se.teams.update(Y,{managerId:q,managerType:"agent"}).catch(()=>{});const P=L.length>0?` (${L.length} failed: ${L[0]})`:"";k({ok:X>0,message:`Team "${R.name}" deployed with ${X} agent(s)${P}`})}catch(_){k({ok:!1,message:`Failed: ${_}`})}finally{b(!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),k(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:[i.length," team",i.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search teams...",value:s,onChange:R=>l(R.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children:x?t.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:"Loading teams..."}):e==="hub"?d.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:d.map(R=>t.jsx(w_,{item:R,localInfo:C.get(jw(R.name)),onStatusChange:M},R.id))}):i.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:i.map(R=>t.jsx(N_,{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:()=>A(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),k(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,_)=>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"?"★":_+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??"Agent"}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[(R.roleName||R.templateId)&&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]})]})]})]},_))})]}),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,_)=>R+(_.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 w_({item:e,localInfo:n,onStatusChange:s}){const[l,i]=y.useState(!1),[c,d]=y.useState(""),u=n?.installed??!1,h=u&&e.version&&n?.localVersion&&j_(e.version,n.localVersion),f=async x=>{if(x.stopPropagation(),!l){i(!0),d("");try{const p=await Bn.download(e.id),g=p.name||e.name,b=jw(g),w={type:"hub",hubItemId:e.id};if(p.files&&Object.keys(p.files).length>0)await se.builder.artifacts.import("team",b,p.files,w);else{const k={...p.config,name:g,description:e.description,source:w};await se.builder.artifacts.save("team",k)}await se.builder.artifacts.install("team",b),d(h?"Upgraded!":"Installed!"),s(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{d("Failed")}finally{i(!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:[e.slug&&e.author?.username&&t.jsx("a",{href:`${Bn.getUrl()}/${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"text-[10px] text-brand-500 hover:text-brand-400 mr-auto",children:"View on Hub →"}),h?t.jsx("button",{onClick:x=>{f(x)},disabled:l,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Upgrading...":`Upgrade → v${e.version}`}):u?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:x=>{f(x)},disabled:l,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:l?"Installing...":"Install"}),c&&t.jsx("span",{className:`text-[10px] ${c==="Failed"?"text-red-500":"text-green-600"}`,children:c})]})]})}function N_({template:e,isSelected:n,onSelect:s}){const l=e.members.reduce((c,d)=>c+(d.count??1),0),i=e.members.some(c=>c.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((c,d)=>t.jsxs("span",{className:`px-2 py-0.5 text-[10px] rounded-md border ${c.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:[c.name??c.roleName??c.templateId??"Agent",(c.count??1)>1?` x${c.count}`:""]},d))}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-3 text-xs",children:[t.jsxs("span",{className:"text-fg-muted",children:[l," agent",l!==1?"s":""]}),i&&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 ww(e,n){const s=e.split(".").map(Number),l=n.split(".").map(Number);for(let i=0;i<Math.max(s.length,l.length);i++){const c=s[i]??0,d=l[i]??0;if(c>d)return!0;if(c<d)return!1}return!1}const xh={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"},k_=[{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 S_({item:e,installedSkills:n,onMsg:s,onRefresh:l}){const[i,c]=y.useState(!1),d=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",u=n.find(p=>p.name===e.name||p.name===d),h=!!u,f=h&&e.version&&u?.version&&ww(e.version,u.version),x=async()=>{if(!i){c(!0);try{const p=await Bn.download(e.id),g=p.name||e.name,b=g.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",w={type:"hub",hubItemId:e.id};if(p.files&&Object.keys(p.files).length>0)await se.builder.artifacts.import("skill",b,p.files,w);else{const k={...p.config,name:g,description:e.description,source:w};await se.builder.artifacts.save("skill",k)}await se.builder.artifacts.install("skill",b),s(f?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),l(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{s("Install failed","error")}finally{c(!1)}}};return f?t.jsx("button",{onClick:()=>{x()},disabled:i,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:i?"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",u?.version?` (v${u.version})`:""]}):t.jsx("button",{onClick:()=>{x()},disabled:i,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:i?"Installing...":"Install"})}function rx(){const e=Yr(),[n,s]=y.useState("installed"),[l,i]=y.useState(null),[c,d]=y.useState(new Set),[u,h]=y.useState([]),[f,x]=y.useState(!0),[p,g]=y.useState(""),[b,w]=y.useState([]),[k,C]=y.useState(0),[E,M]=y.useState(1),[N,A]=y.useState([]),[R,_]=y.useState(""),[Y,q]=y.useState("score"),[X,L]=y.useState(""),[P,G]=y.useState(!1),[$,T]=y.useState([]),[z,O]=y.useState(!1),[V,H]=y.useState([]),[Z,B]=y.useState(""),[F,K]=y.useState(!1),[I,S]=y.useState([]),[D,W]=y.useState(!1),[J,te]=y.useState(""),re=(le,Se="success")=>{i({text:le,type:Se}),setTimeout(()=>i(null),Se==="error"?1e4:4e3)},oe=y.useCallback(async()=>{x(!0);try{const le=await se.skills.list();h(le.skills)}catch{}x(!1)},[]),me=y.useCallback(async()=>{O(!0);try{const le=await se.skills.builtin();T(le.skills)}catch{}O(!1)},[]),Oe=y.useCallback(async le=>{G(!0);try{const Se=await se.skills.registrySkillhub({q:le?.q,category:le?.category,page:le?.page??1,limit:24,sort:le?.sort??Y});w(Se.skills),C(Se.total),Se.categories?.length&&A(Se.categories)}catch{}G(!1)},[Y]),ve=y.useCallback(async le=>{K(!0);try{const Se=await se.skills.registrySkillssh(le);H(Se.skills)}catch{}K(!1)},[]),ke=y.useCallback(async le=>{W(!0);try{const We=await(le?Bn.search({type:"skill",q:le,limit:50}):Tl(qr.hubSkills)??Bn.search({type:"skill",limit:50}));S(We?.items??[])}catch{}W(!1)},[]);y.useEffect(()=>{oe(),me(),Oe(),ve()},[]),y.useEffect(()=>{n==="markus-hub"&&ke(J)},[n,J,ke]);const Ee=async le=>{d(Se=>new Set(Se).add(le.name));try{const Se=await se.skills.install({name:le.name,source:"skillhub",slug:le.slug,sourceUrl:le.homepage,description:le.description_zh??le.description,category:"custom",version:le.version});await oe(),re(`"${le.name}" installed (${Se.method}) → ${Se.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{re(`Download failed for "${le.name}". You can try manually from: ${le.homepage}`,"error")}d(Se=>{const We=new Set(Se);return We.delete(le.name),We})},Me=async le=>{d(Se=>new Set(Se).add(le.name));try{const Se=await se.skills.install({name:le.name,source:"skillssh",sourceUrl:le.url,githubRepo:`${le.author}/${le.repo}`,githubSkillPath:le.name});await oe(),re(`"${le.name}" installed (${Se.method}) → ${Se.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{re(`Download failed for "${le.name}". You can try manually from: ${le.url}`,"error")}d(Se=>{const We=new Set(Se);return We.delete(le.name),We})},dt=async le=>{d(Se=>new Set(Se).add(le.name));try{const Se=await se.skills.install({name:le.name,source:"builtin"});await oe(),await me(),re(`"${le.name}" installed (${Se.method}) → ${Se.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Se){re(`Install failed for "${le.name}": ${Se}`,"error")}d(Se=>{const We=new Set(Se);return We.delete(le.name),We})},pt=async le=>{if(confirm(`Uninstall "${le}"? This will delete the skill files from ~/.markus/skills/.`))try{await se.skills.uninstall(le),await oe(),re(`"${le}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Se){re(`Uninstall failed: ${Se}`,"error")}},et=u.filter(le=>{if(!p)return!0;const Se=p.toLowerCase();return le.name.toLowerCase().includes(Se)||le.description?.toLowerCase().includes(Se)}),Pt=V.filter(le=>{if(!Z)return!0;const Se=Z.toLowerCase();return le.name.toLowerCase().includes(Se)||le.repo.toLowerCase().includes(Se)});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:k_.map(le=>t.jsx("button",{onClick:()=>s(le.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${n===le.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:le.label},le.id))})]}),l&&t.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${l.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:l.text}),n==="installed"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("input",{value:p,onChange:le=>g(le.target.value),placeholder:"Search installed skills...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),t.jsxs("span",{className:"text-xs text-fg-tertiary shrink-0",children:[et.length," skill",et.length!==1?"s":""]})]}),f?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:"Loading..."}):et.length===0?t.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[t.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◆"}),t.jsx("div",{children:"No installed skills found."}),t.jsx("div",{className:"text-xs mt-1",children:"Browse SkillHub or skills.sh to discover and install skills."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:et.map(le=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:le.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] shrink-0 ${le.type==="builtin"?"bg-blue-500/15 text-blue-600":le.type==="filesystem"?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:le.type==="builtin"?"built-in":le.type==="filesystem"?"local":"imported"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[le.author?`by ${le.author} · `:"",le.version?`v${le.version}`:"",le.sourcePath&&t.jsxs("span",{className:"ml-1 text-fg-tertiary",title:le.sourcePath,children:["📁 ",le.sourcePath.replace(/^.*\/\.([^/]+)\/skills\//,"~/.$1/skills/")]})]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${xh[le.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:le.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:le.tags?.slice(0,3).map(Se=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Se},Se))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[le.tools&&le.tools.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[le.tools.length," tool",le.tools.length!==1?"s":""]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Auto-discovered by agents"})]}),le.type!=="builtin"&&t.jsx("button",{onClick:()=>{pt(le.name)},className:"px-2 py-0.5 text-[10px] text-red-500 hover:text-red-500 hover:bg-red-500/10 rounded transition-colors",children:"Uninstall"})]})]},le.name))})]}),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:[$.length," built-in skill",$.length!==1?"s":""," available"]}),t.jsx("button",{onClick:()=>{me()},className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"Refresh"})]}),z?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Loading built-in skills..."})}):$.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:$.map(le=>t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:le.name}),le.hasMcpServers&&t.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] bg-blue-500/15 text-blue-600 shrink-0",children:"MCP"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[le.author?`by ${le.author} · `:"","v",le.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${xh[le.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:le.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:le.tags.slice(0,4).map(Se=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Se},Se))}),le.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:le.requiredPermissions.map(Se=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:Se},Se))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[le.installed&&le.installedVersion?t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",le.installedVersion]}):t.jsx("span",{}),le.installed&&le.installedVersion&&ww(le.version,le.installedVersion)?t.jsx("button",{onClick:()=>{dt(le)},disabled:c.has(le.name),className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:c.has(le.name)?"Upgrading...":`Upgrade → v${le.version}`}):le.installed?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{dt(le)},disabled:c.has(le.name),className:"px-2.5 py-1 text-[10px] bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:c.has(le.name)?"Installing...":"Install"})]})]},le.name))})]}),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:le=>{_(le.target.value),M(1),Oe({q:X||void 0,category:le.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[t.jsx("option",{value:"",children:"全部分类"}),N.map(le=>t.jsx("option",{value:le,children:le},le))]}),t.jsxs("select",{value:Y,onChange:le=>{q(le.target.value),M(1),Oe({q:X||void 0,category:R||void 0,page:1,sort:le.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[t.jsx("option",{value:"score",children:"综合排序"}),t.jsx("option",{value:"downloads",children:"下载量"}),t.jsx("option",{value:"stars",children:"收藏数"}),t.jsx("option",{value:"installs",children:"安装量"})]}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:t.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:"Visit site →"})})]}),t.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[t.jsx("input",{value:X,onChange:le=>L(le.target.value),onKeyDown:le=>{le.key==="Enter"&&(M(1),Oe({q:X||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:()=>{M(1),Oe({q:X||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"})]}),P?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"正在加载 SkillHub 技能..."})}):b.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:["共 ",k.toLocaleString()," 个技能"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:b.map(le=>{const Se=u.some(We=>We.name===le.name||We.name===le.slug);return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:le.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["v",le.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ml-2 ${le.tags?.[0]?xh[le.tags[0]]??"bg-brand-500/15 text-brand-500":"bg-brand-500/15 text-brand-500"}`,children:le.tags?.[0]??"SkillHub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description_zh??le.description??"No description"}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[le.stars>0&&t.jsxs("span",{className:"text-[10px] text-amber-600",children:["★ ",le.stars.toLocaleString()]}),le.downloads>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[le.downloads>=1e4?`${(le.downloads/1e4).toFixed(1)}万`:le.downloads.toLocaleString()," 下载"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:le.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Se?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:()=>{Ee(le)},disabled:c.has(le.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:c.has(le.name)?"...":"Install"})]})]})]},le.slug)})}),k>24&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[t.jsx("button",{disabled:E<=1,onClick:()=>{const le=E-1;M(le),Oe({q:X||void 0,category:R||void 0,page:le})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"← 上一页"}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:["第 ",E," / ",Math.ceil(k/24)," 页"]}),t.jsx("button",{disabled:E>=Math.ceil(k/24),onClick:()=>{const le=E+1;M(le),Oe({q:X||void 0,category:R||void 0,page:le})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:"下一页 →"})]})]})]}),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:le=>B(le.target.value),onKeyDown:le=>{le.key==="Enter"&&Z.trim()&&ve(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()&&ve(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 →"})})]}),F?t.jsx("div",{className:"text-center text-fg-tertiary py-20",children:t.jsx("div",{className:"animate-pulse",children:"Searching skills.sh..."})}):Pt.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:Pt.map(le=>{const Se=u.some(We=>We.name===le.name);return t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5 hover:border-gray-600 transition-colors",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm truncate",children:le.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[le.author," / ",le.repo]})]}),t.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-gray-500/15 text-fg-secondary shrink-0 ml-2",children:"skills.sh"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description||"No description"}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-3",children:le.installs&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[le.installs," installs"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:le.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Se?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:()=>{Me(le)},disabled:c.has(le.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:c.has(le.name)?"...":"Install"})]})]})]},`${le.author}-${le.name}`)})})]}),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:J,onChange:le=>te(le.target.value),placeholder:"Search Markus Hub skills...",className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${e?"flex-1 min-w-0":"w-72"}`}),!e&&t.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:"Community skills from Markus Hub"})]}),D?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(le=>{const Se=le.slug&&le.author?.username?`${Bn.getUrl()}/${encodeURIComponent(le.author.username)}/${encodeURIComponent(le.slug)}`:null;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:[Se?t.jsx("a",{href:Se,target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-sm truncate block hover:text-brand-400 transition-colors",children:le.name}):t.jsx("div",{className:"font-semibold text-sm truncate",children:le.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",le.author?.displayName??le.author?.username]})]}),t.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-green-500/15 text-green-600 shrink-0 ml-2",children:"Hub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:le.description}),t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["★".repeat(Math.round(parseFloat(le.avgRating))),"☆".repeat(5-Math.round(parseFloat(le.avgRating))),t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",le.ratingCount,") · ↓ ",le.downloadCount]})]}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-between gap-2",children:[Se?t.jsx("a",{href:Se,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-400",children:"View on Hub →"}):t.jsx("span",{}),t.jsx(S_,{item:le,installedSkills:u,onMsg:re,onRefresh:()=>{oe()}})]})]},le.id)})})]})]})}const ph=[{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function C_(){const e=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_storeTab"),e==="agents"||e==="teams"||e==="skills"?e:"agents"}function E_({authUser:e}){const[n,s]=y.useState(C_),l=Yr(),i=va(ph,n,s);return y.useEffect(()=>{const c=d=>{if(d.detail.page==="store"){const h=localStorage.getItem("markus_nav_storeTab");h&&(localStorage.removeItem("markus_nav_storeTab"),(h==="agents"||h==="teams"||h==="skills")&&s(h))}};return window.addEventListener("markus:navigate",c),()=>window.removeEventListener("markus:navigate",c)},[]),l?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",children:ph.map(c=>t.jsx("button",{onClick:()=>s(c.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===c.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary hover:text-fg-secondary"}`,children:c.label},c.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx(tx,{authUser:e}),n==="teams"&&t.jsx(nx,{}),n==="skills"&&t.jsx(rx,{})]})]}):t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[t.jsxs("nav",{className:"w-48 shrink-0 border-r border-border-default bg-surface-secondary/50 flex flex-col py-4 px-2 gap-1",children:[t.jsx("div",{className:"px-3 pb-3 mb-1 border-b border-border-default/50",children:t.jsx("h2",{className:"text-xs font-semibold text-fg-tertiary uppercase tracking-wider",children:"Store"})}),ph.map(c=>t.jsx("button",{onClick:()=>s(c.id),className:`flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-sm font-medium transition-all ${n===c.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:c.label},c.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="agents"&&t.jsx(tx,{authUser:e}),n==="teams"&&t.jsx(nx,{}),n==="skills"&&t.jsx(rx,{})]})]})}function T_(e){const n=e.indexOf(".markus/builder-artifacts/");return n>=0?"~/"+e.slice(n):e}const A_=[{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: "}],yv={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 vv({message:e,onConfirm:n,onCancel:s}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:l=>l.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),t.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Confirm Delete"}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:e})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:s,className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:"Cancel"}),t.jsx("button",{onClick:n,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:"Delete"})]})]})})}function Nw(){const e=Yr(),[n,s]=y.useState([]),[l,i]=y.useState([]),[c,d]=y.useState(!1),[u,h]=y.useState("all"),[f,x]=y.useState(null),[p,g]=y.useState(new Map),[b,w]=y.useState(null),[k,C]=y.useState(new Map),[E,M]=y.useState(null),[N,A]=y.useState(null),R=y.useCallback(()=>{d(!0),Promise.all([(Tl(qr.builderArtifacts)??se.builder.artifacts.list()).then($=>$?.artifacts??[]).catch(()=>[]),(Tl(qr.builderAgents)??se.agents.list()).then($=>$?.agents??[]).catch(()=>[]),(Tl(qr.builderHubMyItems)??Bn.myItems()).then($=>$?.items??[]).catch(()=>[]),(Tl(qr.builderInstalled)??se.builder.artifacts.installed()).then($=>$?.installed??{}).catch(()=>({}))]).then(([$,T,z,O])=>{if(i($),s(T),z.length>0){const H=new Map;for(const Z of z){const B=Z.itemType==="agent"?"agent":Z.itemType==="team"?"team":"skill";for(const F of $)F.type===B&&(Z.slug===F.name||Z.name===(F.meta.displayName||F.meta.name||F.name))&&H.set(`${F.type}/${F.name}`,{id:Z.id,name:Z.name,slug:Z.slug||F.name})}H.size>0&&C(Z=>{const B=new Map(Z);for(const[F,K]of H)B.set(F,K);return B})}const V=new Map;for(const H of $){const Z=`${H.type}/${H.name}`,B=O[Z];B&&V.set(Z,{agentId:B.agentId,agentIds:B.agentIds,teamId:B.teamId})}g(V)}).finally(()=>d(!1))},[]);y.useEffect(()=>{R();const $=T=>{T.detail?.page===ge.BUILDER&&R()};return window.addEventListener("markus:navigate",$),()=>window.removeEventListener("markus:navigate",$)},[R]);const _=$=>{const T=n.find(z=>z.role==="Secretary"||z.name==="Secretary");T?bt.navigate(ge.TEAM,{agentId:T.id,prefillMessage:$}):bt.navigate(ge.TEAM,{prefillMessage:$})},Y=async $=>{const T=`${$.type}/${$.name}`;if(!p.has(T)){x({key:T,action:"install"});try{const z=await se.builder.artifacts.install($.type,$.name),O={};z.agent&&typeof z.agent=="object"&&(O.agentId=z.agent.id),z.team&&typeof z.team=="object"&&(O.teamId=z.team.id),Array.isArray(z.agents)&&(O.agentIds=z.agents.map(V=>V.id)),g(V=>new Map(V).set(T,O)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(z){console.error("Install failed:",z),alert(`Install failed: ${z}`)}finally{x(null)}}},q=async $=>{const T=`${$.type}/${$.name}`;if(p.has(T)){x({key:T,action:"uninstall"});try{await se.builder.artifacts.uninstall($.type,$.name),g(z=>{const O=new Map(z);return O.delete(T),O}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(z){console.error("Uninstall failed:",z),alert(`Uninstall failed: ${z}`)}finally{x(null)}}},X=async $=>{const T=`${$.type}/${$.name}`;if(!k.has(T)){x({key:T,action:"share"});try{const z=await se.builder.artifacts.get($.type,$.name),O=$.meta.displayName||$.meta.name||$.name,V=$.meta.description||"",H=$.meta.category||"general",Z=Array.isArray($.meta.tags)?$.meta.tags:[],B=$.name,F=await Bn.publishViaProxy({itemType:$.type==="team"?"team":$.type==="skill"?"skill":"agent",name:O,slug:B,description:V,category:H,tags:Z,config:$.meta,files:z.files&&Object.keys(z.files).length>0?z.files:void 0});F.id&&C(K=>{const I=new Map(K);return I.set(T,{id:F.id,name:O,slug:F.slug??B}),I})}catch(z){console.error("Share failed:",z),alert(`Share failed: ${z}`)}finally{x(null)}}},L=async()=>{if(!E)return;const{key:$}=E,T=k.get($);if(M(null),!T)return;const z=T.id;x({key:$,action:"hubDelete"});try{await Bn.deleteItem(z),C(O=>{const V=new Map(O);return V.delete($),V})}catch(O){console.error("Hub delete failed:",O),alert(`Failed to remove from Hub: ${O}`)}finally{x(null)}},P=async()=>{if(!b)return;const $=b,T=`${$.type}/${$.name}`;w(null),x({key:T,action:"delete"});try{await se.builder.artifacts.delete($.type,$.name),i(z=>z.filter(O=>!(O.type===$.type&&O.name===$.name))),g(z=>{const O=new Map(z);return O.delete(T),O}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(z){console.error("Delete failed:",z)}finally{x(null)}},G=u==="all"?l:l.filter($=>$.type===u);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:A_.map($=>t.jsx("button",{onClick:()=>_($.prompt),className:`group text-left w-full rounded-xl border ${$.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 ${$.bgColor} flex items-center justify-center shrink-0`,children:$.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 ${$.color} bg-clip-text text-transparent`,children:$.title})}),t.jsx("p",{className:"text-sm text-fg-secondary leading-relaxed",children:$.desc}),t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:$.examples.map((T,z)=>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:O=>{O.stopPropagation(),_($.prompt+T)},children:["“",T,"”"]},z))})]}),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"})})]})},$.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($=>t.jsx("button",{onClick:()=>h($),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${u===$?"border-gray-600 bg-surface-elevated text-fg-primary":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:$==="all"?"All":$.charAt(0).toUpperCase()+$.slice(1)+"s"},$))})]}),c&&l.length===0?t.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:"Loading artifacts..."}):G.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:G.map($=>{const T=yv[$.type]??yv.agent,z=$.meta.displayName||$.meta.name||$.name,O=$.meta.description||"",V=`${$.type}/${$.name}`,H=f?.key===V?f.action:null,Z=t.jsxs("div",{className:`flex items-center gap-1.5 ${e?"flex-wrap":"shrink-0"}`,children:[p.has(V)?t.jsx("button",{onClick:()=>q($),disabled:!!H,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:H==="uninstall"?"Uninstalling...":"Uninstall"}):t.jsx("button",{onClick:()=>Y($),disabled:!!H,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:H==="install"?"Installing...":"Install"}),k.has(V)?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>M({key:V,name:$.meta.displayName||$.meta.name||$.name}),disabled:!!H,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=k.get(V),F=Bn.getUser();if(!B||!F)return;const K=`${Bn.getUrl()}/${encodeURIComponent(F.username)}/${encodeURIComponent(B.slug)}`;navigator.clipboard.writeText(K).then(()=>{A(V),setTimeout(()=>A(I=>I===V?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:N===V?t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),t.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})]}):t.jsx("button",{onClick:()=>X($),disabled:!!H,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:H==="share"?"Sharing...":"Share"}),t.jsx("button",{onClick:()=>w($),disabled:!!H,className:"text-xs px-2 py-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50",title:"Delete",children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]});return t.jsxs("div",{className:"group rounded-lg border border-border-default bg-surface-secondary/60 p-4 hover:border-gray-600 transition-all overflow-hidden",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("div",{className:`w-9 h-9 rounded-lg ${T.bg} flex items-center justify-center text-lg shrink-0`,children:T.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:z}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${T.color}`,children:$.type})]}),O&&t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2",children:O}),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($.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:$.path,children:T_($.path)}),t.jsx("span",{className:"shrink-0",children:new Date($.updatedAt).toLocaleDateString()})]})]}),!e&&Z]}),e&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-default/50",children:Z})]},V)})}),b&&t.jsx(vv,{message:`Delete "${b.meta.displayName||b.meta.name||b.name}"? This cannot be undone.`,onConfirm:P,onCancel:()=>w(null)}),E&&t.jsx(vv,{message:`Remove "${E.name}" from Markus Hub? It will no longer be available for others to download.`,onConfirm:()=>{L()},onCancel:()=>M(null)})]})})}function rr(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let s=0,l;s<e.length;s++)(l=rr(e[s]))!==""&&(n+=(n&&" ")+l);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}var __={value:()=>{}};function Au(){for(var e=0,n=arguments.length,s={},l;e<n;++e){if(!(l=arguments[e]+"")||l in s||/[\s.]/.test(l))throw new Error("illegal type: "+l);s[l]=[]}return new Gd(s)}function Gd(e){this._=e}function M_(e,n){return e.trim().split(/^|\s+/).map(function(s){var l="",i=s.indexOf(".");if(i>=0&&(l=s.slice(i+1),s=s.slice(0,i)),s&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:l}})}Gd.prototype=Au.prototype={constructor:Gd,on:function(e,n){var s=this._,l=M_(e+"",s),i,c=-1,d=l.length;if(arguments.length<2){for(;++c<d;)if((i=(e=l[c]).type)&&(i=R_(s[i],e.name)))return i;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++c<d;)if(i=(e=l[c]).type)s[i]=jv(s[i],e.name,n);else if(n==null)for(i in s)s[i]=jv(s[i],e.name,null);return this},copy:function(){var e={},n=this._;for(var s in n)e[s]=n[s].slice();return new Gd(e)},call:function(e,n){if((i=arguments.length-2)>0)for(var s=new Array(i),l=0,i,c;l<i;++l)s[l]=arguments[l+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(c=this._[e],l=0,i=c.length;l<i;++l)c[l].value.apply(n,s)},apply:function(e,n,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var l=this._[e],i=0,c=l.length;i<c;++i)l[i].value.apply(n,s)}};function R_(e,n){for(var s=0,l=e.length,i;s<l;++s)if((i=e[s]).name===n)return i.value}function jv(e,n,s){for(var l=0,i=e.length;l<i;++l)if(e[l].name===n){e[l]=__,e=e.slice(0,l).concat(e.slice(l+1));break}return s!=null&&e.push({name:n,value:s}),e}var sx="http://www.w3.org/1999/xhtml";const wv={svg:"http://www.w3.org/2000/svg",xhtml:sx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _u(e){var n=e+="",s=n.indexOf(":");return s>=0&&(n=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),wv.hasOwnProperty(n)?{space:wv[n],local:e}:e}function O_(e){return function(){var n=this.ownerDocument,s=this.namespaceURI;return s===sx&&n.documentElement.namespaceURI===sx?n.createElement(e):n.createElementNS(s,e)}}function D_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function kw(e){var n=_u(e);return(n.local?D_:O_)(n)}function L_(){}function Xx(e){return e==null?L_:function(){return this.querySelector(e)}}function I_(e){typeof e!="function"&&(e=Xx(e));for(var n=this._groups,s=n.length,l=new Array(s),i=0;i<s;++i)for(var c=n[i],d=c.length,u=l[i]=new Array(d),h,f,x=0;x<d;++x)(h=c[x])&&(f=e.call(h,h.__data__,x,c))&&("__data__"in h&&(f.__data__=h.__data__),u[x]=f);return new rs(l,this._parents)}function z_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function $_(){return[]}function Sw(e){return e==null?$_:function(){return this.querySelectorAll(e)}}function B_(e){return function(){return z_(e.apply(this,arguments))}}function H_(e){typeof e=="function"?e=B_(e):e=Sw(e);for(var n=this._groups,s=n.length,l=[],i=[],c=0;c<s;++c)for(var d=n[c],u=d.length,h,f=0;f<u;++f)(h=d[f])&&(l.push(e.call(h,h.__data__,f,d)),i.push(h));return new rs(l,i)}function Cw(e){return function(){return this.matches(e)}}function Ew(e){return function(n){return n.matches(e)}}var P_=Array.prototype.find;function U_(e){return function(){return P_.call(this.children,e)}}function q_(){return this.firstElementChild}function F_(e){return this.select(e==null?q_:U_(typeof e=="function"?e:Ew(e)))}var V_=Array.prototype.filter;function Y_(){return Array.from(this.children)}function G_(e){return function(){return V_.call(this.children,e)}}function X_(e){return this.selectAll(e==null?Y_:G_(typeof e=="function"?e:Ew(e)))}function K_(e){typeof e!="function"&&(e=Cw(e));for(var n=this._groups,s=n.length,l=new Array(s),i=0;i<s;++i)for(var c=n[i],d=c.length,u=l[i]=[],h,f=0;f<d;++f)(h=c[f])&&e.call(h,h.__data__,f,c)&&u.push(h);return new rs(l,this._parents)}function Tw(e){return new Array(e.length)}function W_(){return new rs(this._enter||this._groups.map(Tw),this._parents)}function ou(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}ou.prototype={constructor:ou,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 Z_(e){return function(){return e}}function Q_(e,n,s,l,i,c){for(var d=0,u,h=n.length,f=c.length;d<f;++d)(u=n[d])?(u.__data__=c[d],l[d]=u):s[d]=new ou(e,c[d]);for(;d<h;++d)(u=n[d])&&(i[d]=u)}function J_(e,n,s,l,i,c,d){var u,h,f=new Map,x=n.length,p=c.length,g=new Array(x),b;for(u=0;u<x;++u)(h=n[u])&&(g[u]=b=d.call(h,h.__data__,u,n)+"",f.has(b)?i[u]=h:f.set(b,h));for(u=0;u<p;++u)b=d.call(e,c[u],u,c)+"",(h=f.get(b))?(l[u]=h,h.__data__=c[u],f.delete(b)):s[u]=new ou(e,c[u]);for(u=0;u<x;++u)(h=n[u])&&f.get(g[u])===h&&(i[u]=h)}function eM(e){return e.__data__}function tM(e,n){if(!arguments.length)return Array.from(this,eM);var s=n?J_:Q_,l=this._parents,i=this._groups;typeof e!="function"&&(e=Z_(e));for(var c=i.length,d=new Array(c),u=new Array(c),h=new Array(c),f=0;f<c;++f){var x=l[f],p=i[f],g=p.length,b=nM(e.call(x,x&&x.__data__,f,l)),w=b.length,k=u[f]=new Array(w),C=d[f]=new Array(w),E=h[f]=new Array(g);s(x,p,k,C,E,b,n);for(var M=0,N=0,A,R;M<w;++M)if(A=k[M]){for(M>=N&&(N=M+1);!(R=C[N])&&++N<w;);A._next=R||null}}return d=new rs(d,l),d._enter=u,d._exit=h,d}function nM(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rM(){return new rs(this._exit||this._groups.map(Tw),this._parents)}function sM(e,n,s){var l=this.enter(),i=this,c=this.exit();return typeof e=="function"?(l=e(l),l&&(l=l.selection())):l=l.append(e+""),n!=null&&(i=n(i),i&&(i=i.selection())),s==null?c.remove():s(c),l&&i?l.merge(i).order():i}function aM(e){for(var n=e.selection?e.selection():e,s=this._groups,l=n._groups,i=s.length,c=l.length,d=Math.min(i,c),u=new Array(i),h=0;h<d;++h)for(var f=s[h],x=l[h],p=f.length,g=u[h]=new Array(p),b,w=0;w<p;++w)(b=f[w]||x[w])&&(g[w]=b);for(;h<i;++h)u[h]=s[h];return new rs(u,this._parents)}function lM(){for(var e=this._groups,n=-1,s=e.length;++n<s;)for(var l=e[n],i=l.length-1,c=l[i],d;--i>=0;)(d=l[i])&&(c&&d.compareDocumentPosition(c)^4&&c.parentNode.insertBefore(d,c),c=d);return this}function iM(e){e||(e=oM);function n(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var s=this._groups,l=s.length,i=new Array(l),c=0;c<l;++c){for(var d=s[c],u=d.length,h=i[c]=new Array(u),f,x=0;x<u;++x)(f=d[x])&&(h[x]=f);h.sort(n)}return new rs(i,this._parents).order()}function oM(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function cM(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function dM(){return Array.from(this)}function uM(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var l=e[n],i=0,c=l.length;i<c;++i){var d=l[i];if(d)return d}return null}function fM(){let e=0;for(const n of this)++e;return e}function mM(){return!this.node()}function hM(e){for(var n=this._groups,s=0,l=n.length;s<l;++s)for(var i=n[s],c=0,d=i.length,u;c<d;++c)(u=i[c])&&e.call(u,u.__data__,c,i);return this}function xM(e){return function(){this.removeAttribute(e)}}function pM(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gM(e,n){return function(){this.setAttribute(e,n)}}function bM(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function yM(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function vM(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 jM(e,n){var s=_u(e);if(arguments.length<2){var l=this.node();return s.local?l.getAttributeNS(s.space,s.local):l.getAttribute(s)}return this.each((n==null?s.local?pM:xM:typeof n=="function"?s.local?vM:yM:s.local?bM:gM)(s,n))}function Aw(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wM(e){return function(){this.style.removeProperty(e)}}function NM(e,n,s){return function(){this.style.setProperty(e,n,s)}}function kM(e,n,s){return function(){var l=n.apply(this,arguments);l==null?this.style.removeProperty(e):this.style.setProperty(e,l,s)}}function SM(e,n,s){return arguments.length>1?this.each((n==null?wM:typeof n=="function"?kM:NM)(e,n,s??"")):Ri(this.node(),e)}function Ri(e,n){return e.style.getPropertyValue(n)||Aw(e).getComputedStyle(e,null).getPropertyValue(n)}function CM(e){return function(){delete this[e]}}function EM(e,n){return function(){this[e]=n}}function TM(e,n){return function(){var s=n.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function AM(e,n){return arguments.length>1?this.each((n==null?CM:typeof n=="function"?TM:EM)(e,n)):this.node()[e]}function _w(e){return e.trim().split(/^|\s+/)}function Kx(e){return e.classList||new Mw(e)}function Mw(e){this._node=e,this._names=_w(e.getAttribute("class")||"")}Mw.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 Rw(e,n){for(var s=Kx(e),l=-1,i=n.length;++l<i;)s.add(n[l])}function Ow(e,n){for(var s=Kx(e),l=-1,i=n.length;++l<i;)s.remove(n[l])}function _M(e){return function(){Rw(this,e)}}function MM(e){return function(){Ow(this,e)}}function RM(e,n){return function(){(n.apply(this,arguments)?Rw:Ow)(this,e)}}function OM(e,n){var s=_w(e+"");if(arguments.length<2){for(var l=Kx(this.node()),i=-1,c=s.length;++i<c;)if(!l.contains(s[i]))return!1;return!0}return this.each((typeof n=="function"?RM:n?_M:MM)(s,n))}function DM(){this.textContent=""}function LM(e){return function(){this.textContent=e}}function IM(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function zM(e){return arguments.length?this.each(e==null?DM:(typeof e=="function"?IM:LM)(e)):this.node().textContent}function $M(){this.innerHTML=""}function BM(e){return function(){this.innerHTML=e}}function HM(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function PM(e){return arguments.length?this.each(e==null?$M:(typeof e=="function"?HM:BM)(e)):this.node().innerHTML}function UM(){this.nextSibling&&this.parentNode.appendChild(this)}function qM(){return this.each(UM)}function FM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function VM(){return this.each(FM)}function YM(e){var n=typeof e=="function"?e:kw(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function GM(){return null}function XM(e,n){var s=typeof e=="function"?e:kw(e),l=n==null?GM:typeof n=="function"?n:Xx(n);return this.select(function(){return this.insertBefore(s.apply(this,arguments),l.apply(this,arguments)||null)})}function KM(){var e=this.parentNode;e&&e.removeChild(this)}function WM(){return this.each(KM)}function ZM(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function QM(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function JM(e){return this.select(e?QM:ZM)}function e6(e){return arguments.length?this.property("__data__",e):this.node().__data__}function t6(e){return function(n){e.call(this,n,this.__data__)}}function n6(e){return e.trim().split(/^|\s+/).map(function(n){var s="",l=n.indexOf(".");return l>=0&&(s=n.slice(l+1),n=n.slice(0,l)),{type:n,name:s}})}function r6(e){return function(){var n=this.__on;if(n){for(var s=0,l=-1,i=n.length,c;s<i;++s)c=n[s],(!e.type||c.type===e.type)&&c.name===e.name?this.removeEventListener(c.type,c.listener,c.options):n[++l]=c;++l?n.length=l:delete this.__on}}}function s6(e,n,s){return function(){var l=this.__on,i,c=t6(n);if(l){for(var d=0,u=l.length;d<u;++d)if((i=l[d]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=c,i.options=s),i.value=n;return}}this.addEventListener(e.type,c,s),i={type:e.type,name:e.name,value:n,listener:c,options:s},l?l.push(i):this.__on=[i]}}function a6(e,n,s){var l=n6(e+""),i,c=l.length,d;if(arguments.length<2){var u=this.node().__on;if(u){for(var h=0,f=u.length,x;h<f;++h)for(i=0,x=u[h];i<c;++i)if((d=l[i]).type===x.type&&d.name===x.name)return x.value}return}for(u=n?s6:r6,i=0;i<c;++i)this.each(u(l[i],n,s));return this}function Dw(e,n,s){var l=Aw(e),i=l.CustomEvent;typeof i=="function"?i=new i(n,s):(i=l.document.createEvent("Event"),s?(i.initEvent(n,s.bubbles,s.cancelable),i.detail=s.detail):i.initEvent(n,!1,!1)),e.dispatchEvent(i)}function l6(e,n){return function(){return Dw(this,e,n)}}function i6(e,n){return function(){return Dw(this,e,n.apply(this,arguments))}}function o6(e,n){return this.each((typeof n=="function"?i6:l6)(e,n))}function*c6(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var l=e[n],i=0,c=l.length,d;i<c;++i)(d=l[i])&&(yield d)}var Lw=[null];function rs(e,n){this._groups=e,this._parents=n}function xc(){return new rs([[document.documentElement]],Lw)}function d6(){return this}rs.prototype=xc.prototype={constructor:rs,select:I_,selectAll:H_,selectChild:F_,selectChildren:X_,filter:K_,data:tM,enter:W_,exit:rM,join:sM,merge:aM,selection:d6,order:lM,sort:iM,call:cM,nodes:dM,node:uM,size:fM,empty:mM,each:hM,attr:jM,style:SM,property:AM,classed:OM,text:zM,html:PM,raise:qM,lower:VM,append:YM,insert:XM,remove:WM,clone:JM,datum:e6,on:a6,dispatch:o6,[Symbol.iterator]:c6};function ts(e){return typeof e=="string"?new rs([[document.querySelector(e)]],[document.documentElement]):new rs([[e]],Lw)}function u6(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Cs(e,n){if(e=u6(e),n===void 0&&(n=e.currentTarget),n){var s=n.ownerSVGElement||n;if(s.createSVGPoint){var l=s.createSVGPoint();return l.x=e.clientX,l.y=e.clientY,l=l.matrixTransform(n.getScreenCTM().inverse()),[l.x,l.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}}return[e.pageX,e.pageY]}const f6={passive:!1},tc={capture:!0,passive:!1};function gh(e){e.stopImmediatePropagation()}function Ai(e){e.preventDefault(),e.stopImmediatePropagation()}function Iw(e){var n=e.document.documentElement,s=ts(e).on("dragstart.drag",Ai,tc);"onselectstart"in n?s.on("selectstart.drag",Ai,tc):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function zw(e,n){var s=e.document.documentElement,l=ts(e).on("dragstart.drag",null);n&&(l.on("click.drag",Ai,tc),setTimeout(function(){l.on("click.drag",null)},0)),"onselectstart"in s?l.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const _d=e=>()=>e;function ax(e,{sourceEvent:n,subject:s,target:l,identifier:i,active:c,x:d,y:u,dx:h,dy:f,dispatch:x}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:c,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:x}})}ax.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function m6(e){return!e.ctrlKey&&!e.button}function h6(){return this.parentNode}function x6(e,n){return n??{x:e.x,y:e.y}}function p6(){return navigator.maxTouchPoints||"ontouchstart"in this}function $w(){var e=m6,n=h6,s=x6,l=p6,i={},c=Au("start","drag","end"),d=0,u,h,f,x,p=0;function g(A){A.on("mousedown.drag",b).filter(l).on("touchstart.drag",C).on("touchmove.drag",E,f6).on("touchend.drag touchcancel.drag",M).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(A,R){if(!(x||!e.call(this,A,R))){var _=N(this,n.call(this,A,R),A,R,"mouse");_&&(ts(A.view).on("mousemove.drag",w,tc).on("mouseup.drag",k,tc),Iw(A.view),gh(A),f=!1,u=A.clientX,h=A.clientY,_("start",A))}}function w(A){if(Ai(A),!f){var R=A.clientX-u,_=A.clientY-h;f=R*R+_*_>p}i.mouse("drag",A)}function k(A){ts(A.view).on("mousemove.drag mouseup.drag",null),zw(A.view,f),Ai(A),i.mouse("end",A)}function C(A,R){if(e.call(this,A,R)){var _=A.changedTouches,Y=n.call(this,A,R),q=_.length,X,L;for(X=0;X<q;++X)(L=N(this,Y,A,R,_[X].identifier,_[X]))&&(gh(A),L("start",A,_[X]))}}function E(A){var R=A.changedTouches,_=R.length,Y,q;for(Y=0;Y<_;++Y)(q=i[R[Y].identifier])&&(Ai(A),q("drag",A,R[Y]))}function M(A){var R=A.changedTouches,_=R.length,Y,q;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),Y=0;Y<_;++Y)(q=i[R[Y].identifier])&&(gh(A),q("end",A,R[Y]))}function N(A,R,_,Y,q,X){var L=c.copy(),P=Cs(X||_,R),G,$,T;if((T=s.call(A,new ax("beforestart",{sourceEvent:_,target:g,identifier:q,active:d,x:P[0],y:P[1],dx:0,dy:0,dispatch:L}),Y))!=null)return G=T.x-P[0]||0,$=T.y-P[1]||0,function z(O,V,H){var Z=P,B;switch(O){case"start":i[q]=z,B=d++;break;case"end":delete i[q],--d;case"drag":P=Cs(H||V,R),B=d;break}L.call(O,A,new ax(O,{sourceEvent:V,subject:T,target:g,identifier:q,active:B,x:P[0]+G,y:P[1]+$,dx:P[0]-Z[0],dy:P[1]-Z[1],dispatch:L}),Y)}}return g.filter=function(A){return arguments.length?(e=typeof A=="function"?A:_d(!!A),g):e},g.container=function(A){return arguments.length?(n=typeof A=="function"?A:_d(A),g):n},g.subject=function(A){return arguments.length?(s=typeof A=="function"?A:_d(A),g):s},g.touchable=function(A){return arguments.length?(l=typeof A=="function"?A:_d(!!A),g):l},g.on=function(){var A=c.on.apply(c,arguments);return A===c?g:A},g.clickDistance=function(A){return arguments.length?(p=(A=+A)*A,g):Math.sqrt(p)},g}function Wx(e,n,s){e.prototype=n.prototype=s,s.constructor=e}function Bw(e,n){var s=Object.create(e.prototype);for(var l in n)s[l]=n[l];return s}function pc(){}var nc=.7,cu=1/nc,_i="\\s*([+-]?\\d+)\\s*",rc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",g6=/^#([0-9a-f]{3,8})$/,b6=new RegExp(`^rgb\\(${_i},${_i},${_i}\\)$`),y6=new RegExp(`^rgb\\(${Gs},${Gs},${Gs}\\)$`),v6=new RegExp(`^rgba\\(${_i},${_i},${_i},${rc}\\)$`),j6=new RegExp(`^rgba\\(${Gs},${Gs},${Gs},${rc}\\)$`),w6=new RegExp(`^hsl\\(${rc},${Gs},${Gs}\\)$`),N6=new RegExp(`^hsla\\(${rc},${Gs},${Gs},${rc}\\)$`),Nv={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};Wx(pc,Ll,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:kv,formatHex:kv,formatHex8:k6,formatHsl:S6,formatRgb:Sv,toString:Sv});function kv(){return this.rgb().formatHex()}function k6(){return this.rgb().formatHex8()}function S6(){return Hw(this).formatHsl()}function Sv(){return this.rgb().formatRgb()}function Ll(e){var n,s;return e=(e+"").trim().toLowerCase(),(n=g6.exec(e))?(s=n[1].length,n=parseInt(n[1],16),s===6?Cv(n):s===3?new Fr(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):s===8?Md(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):s===4?Md(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=b6.exec(e))?new Fr(n[1],n[2],n[3],1):(n=y6.exec(e))?new Fr(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=v6.exec(e))?Md(n[1],n[2],n[3],n[4]):(n=j6.exec(e))?Md(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=w6.exec(e))?Av(n[1],n[2]/100,n[3]/100,1):(n=N6.exec(e))?Av(n[1],n[2]/100,n[3]/100,n[4]):Nv.hasOwnProperty(e)?Cv(Nv[e]):e==="transparent"?new Fr(NaN,NaN,NaN,0):null}function Cv(e){return new Fr(e>>16&255,e>>8&255,e&255,1)}function Md(e,n,s,l){return l<=0&&(e=n=s=NaN),new Fr(e,n,s,l)}function C6(e){return e instanceof pc||(e=Ll(e)),e?(e=e.rgb(),new Fr(e.r,e.g,e.b,e.opacity)):new Fr}function lx(e,n,s,l){return arguments.length===1?C6(e):new Fr(e,n,s,l??1)}function Fr(e,n,s,l){this.r=+e,this.g=+n,this.b=+s,this.opacity=+l}Wx(Fr,lx,Bw(pc,{brighter(e){return e=e==null?cu:Math.pow(cu,e),new Fr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?nc:Math.pow(nc,e),new Fr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Fr(Ml(this.r),Ml(this.g),Ml(this.b),du(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:Ev,formatHex:Ev,formatHex8:E6,formatRgb:Tv,toString:Tv}));function Ev(){return`#${Al(this.r)}${Al(this.g)}${Al(this.b)}`}function E6(){return`#${Al(this.r)}${Al(this.g)}${Al(this.b)}${Al((isNaN(this.opacity)?1:this.opacity)*255)}`}function Tv(){const e=du(this.opacity);return`${e===1?"rgb(":"rgba("}${Ml(this.r)}, ${Ml(this.g)}, ${Ml(this.b)}${e===1?")":`, ${e})`}`}function du(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ml(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Al(e){return e=Ml(e),(e<16?"0":"")+e.toString(16)}function Av(e,n,s,l){return l<=0?e=n=s=NaN:s<=0||s>=1?e=n=NaN:n<=0&&(e=NaN),new Es(e,n,s,l)}function Hw(e){if(e instanceof Es)return new Es(e.h,e.s,e.l,e.opacity);if(e instanceof pc||(e=Ll(e)),!e)return new Es;if(e instanceof Es)return e;e=e.rgb();var n=e.r/255,s=e.g/255,l=e.b/255,i=Math.min(n,s,l),c=Math.max(n,s,l),d=NaN,u=c-i,h=(c+i)/2;return u?(n===c?d=(s-l)/u+(s<l)*6:s===c?d=(l-n)/u+2:d=(n-s)/u+4,u/=h<.5?c+i:2-c-i,d*=60):u=h>0&&h<1?0:d,new Es(d,u,h,e.opacity)}function T6(e,n,s,l){return arguments.length===1?Hw(e):new Es(e,n,s,l??1)}function Es(e,n,s,l){this.h=+e,this.s=+n,this.l=+s,this.opacity=+l}Wx(Es,T6,Bw(pc,{brighter(e){return e=e==null?cu:Math.pow(cu,e),new Es(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?nc:Math.pow(nc,e),new Es(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,l=s+(s<.5?s:1-s)*n,i=2*s-l;return new Fr(bh(e>=240?e-240:e+120,i,l),bh(e,i,l),bh(e<120?e+240:e-120,i,l),this.opacity)},clamp(){return new Es(_v(this.h),Rd(this.s),Rd(this.l),du(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=du(this.opacity);return`${e===1?"hsl(":"hsla("}${_v(this.h)}, ${Rd(this.s)*100}%, ${Rd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _v(e){return e=(e||0)%360,e<0?e+360:e}function Rd(e){return Math.max(0,Math.min(1,e||0))}function bh(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 Zx=e=>()=>e;function A6(e,n){return function(s){return e+s*n}}function _6(e,n,s){return e=Math.pow(e,s),n=Math.pow(n,s)-e,s=1/s,function(l){return Math.pow(e+l*n,s)}}function M6(e){return(e=+e)==1?Pw:function(n,s){return s-n?_6(n,s,e):Zx(isNaN(n)?s:n)}}function Pw(e,n){var s=n-e;return s?A6(e,s):Zx(isNaN(e)?n:e)}const uu=(function e(n){var s=M6(n);function l(i,c){var d=s((i=lx(i)).r,(c=lx(c)).r),u=s(i.g,c.g),h=s(i.b,c.b),f=Pw(i.opacity,c.opacity);return function(x){return i.r=d(x),i.g=u(x),i.b=h(x),i.opacity=f(x),i+""}}return l.gamma=e,l})(1);function R6(e,n){n||(n=[]);var s=e?Math.min(n.length,e.length):0,l=n.slice(),i;return function(c){for(i=0;i<s;++i)l[i]=e[i]*(1-c)+n[i]*c;return l}}function O6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function D6(e,n){var s=n?n.length:0,l=e?Math.min(s,e.length):0,i=new Array(l),c=new Array(s),d;for(d=0;d<l;++d)i[d]=Xo(e[d],n[d]);for(;d<s;++d)c[d]=n[d];return function(u){for(d=0;d<l;++d)c[d]=i[d](u);return c}}function L6(e,n){var s=new Date;return e=+e,n=+n,function(l){return s.setTime(e*(1-l)+n*l),s}}function Vs(e,n){return e=+e,n=+n,function(s){return e*(1-s)+n*s}}function I6(e,n){var s={},l={},i;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(i in n)i in e?s[i]=Xo(e[i],n[i]):l[i]=n[i];return function(c){for(i in s)l[i]=s[i](c);return l}}var ix=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yh=new RegExp(ix.source,"g");function z6(e){return function(){return e}}function $6(e){return function(n){return e(n)+""}}function Uw(e,n){var s=ix.lastIndex=yh.lastIndex=0,l,i,c,d=-1,u=[],h=[];for(e=e+"",n=n+"";(l=ix.exec(e))&&(i=yh.exec(n));)(c=i.index)>s&&(c=n.slice(s,c),u[d]?u[d]+=c:u[++d]=c),(l=l[0])===(i=i[0])?u[d]?u[d]+=i:u[++d]=i:(u[++d]=null,h.push({i:d,x:Vs(l,i)})),s=yh.lastIndex;return s<n.length&&(c=n.slice(s),u[d]?u[d]+=c:u[++d]=c),u.length<2?h[0]?$6(h[0].x):z6(n):(n=h.length,function(f){for(var x=0,p;x<n;++x)u[(p=h[x]).i]=p.x(f);return u.join("")})}function Xo(e,n){var s=typeof n,l;return n==null||s==="boolean"?Zx(n):(s==="number"?Vs:s==="string"?(l=Ll(n))?(n=l,uu):Uw:n instanceof Ll?uu:n instanceof Date?L6:O6(n)?R6:Array.isArray(n)?D6:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?I6:Vs)(e,n)}var Mv=180/Math.PI,ox={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function qw(e,n,s,l,i,c){var d,u,h;return(d=Math.sqrt(e*e+n*n))&&(e/=d,n/=d),(h=e*s+n*l)&&(s-=e*h,l-=n*h),(u=Math.sqrt(s*s+l*l))&&(s/=u,l/=u,h/=u),e*l<n*s&&(e=-e,n=-n,h=-h,d=-d),{translateX:i,translateY:c,rotate:Math.atan2(n,e)*Mv,skewX:Math.atan(h)*Mv,scaleX:d,scaleY:u}}var Od;function B6(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?ox:qw(n.a,n.b,n.c,n.d,n.e,n.f)}function H6(e){return e==null||(Od||(Od=document.createElementNS("http://www.w3.org/2000/svg","g")),Od.setAttribute("transform",e),!(e=Od.transform.baseVal.consolidate()))?ox:(e=e.matrix,qw(e.a,e.b,e.c,e.d,e.e,e.f))}function Fw(e,n,s,l){function i(f){return f.length?f.pop()+" ":""}function c(f,x,p,g,b,w){if(f!==p||x!==g){var k=b.push("translate(",null,n,null,s);w.push({i:k-4,x:Vs(f,p)},{i:k-2,x:Vs(x,g)})}else(p||g)&&b.push("translate("+p+n+g+s)}function d(f,x,p,g){f!==x?(f-x>180?x+=360:x-f>180&&(f+=360),g.push({i:p.push(i(p)+"rotate(",null,l)-2,x:Vs(f,x)})):x&&p.push(i(p)+"rotate("+x+l)}function u(f,x,p,g){f!==x?g.push({i:p.push(i(p)+"skewX(",null,l)-2,x:Vs(f,x)}):x&&p.push(i(p)+"skewX("+x+l)}function h(f,x,p,g,b,w){if(f!==p||x!==g){var k=b.push(i(b)+"scale(",null,",",null,")");w.push({i:k-4,x:Vs(f,p)},{i:k-2,x:Vs(x,g)})}else(p!==1||g!==1)&&b.push(i(b)+"scale("+p+","+g+")")}return function(f,x){var p=[],g=[];return f=e(f),x=e(x),c(f.translateX,f.translateY,x.translateX,x.translateY,p,g),d(f.rotate,x.rotate,p,g),u(f.skewX,x.skewX,p,g),h(f.scaleX,f.scaleY,x.scaleX,x.scaleY,p,g),f=x=null,function(b){for(var w=-1,k=g.length,C;++w<k;)p[(C=g[w]).i]=C.x(b);return p.join("")}}}var P6=Fw(B6,"px, ","px)","deg)"),U6=Fw(H6,", ",")",")"),q6=1e-12;function Rv(e){return((e=Math.exp(e))+1/e)/2}function F6(e){return((e=Math.exp(e))-1/e)/2}function V6(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xd=(function e(n,s,l){function i(c,d){var u=c[0],h=c[1],f=c[2],x=d[0],p=d[1],g=d[2],b=x-u,w=p-h,k=b*b+w*w,C,E;if(k<q6)E=Math.log(g/f)/n,C=function(Y){return[u+Y*b,h+Y*w,f*Math.exp(n*Y*E)]};else{var M=Math.sqrt(k),N=(g*g-f*f+l*k)/(2*f*s*M),A=(g*g-f*f-l*k)/(2*g*s*M),R=Math.log(Math.sqrt(N*N+1)-N),_=Math.log(Math.sqrt(A*A+1)-A);E=(_-R)/n,C=function(Y){var q=Y*E,X=Rv(R),L=f/(s*M)*(X*V6(n*q+R)-F6(R));return[u+L*b,h+L*w,f*X/Rv(n*q+R)]}}return C.duration=E*1e3*n/Math.SQRT2,C}return i.rho=function(c){var d=Math.max(.001,+c),u=d*d,h=u*u;return e(d,u,h)},i})(Math.SQRT2,2,4);var Oi=0,Po=0,Io=0,Vw=1e3,fu,Uo,mu=0,Il=0,Mu=0,sc=typeof performance=="object"&&performance.now?performance:Date,Yw=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Qx(){return Il||(Yw(Y6),Il=sc.now()+Mu)}function Y6(){Il=0}function hu(){this._call=this._time=this._next=null}hu.prototype=Gw.prototype={constructor:hu,restart:function(e,n,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?Qx():+s)+(n==null?0:+n),!this._next&&Uo!==this&&(Uo?Uo._next=this:fu=this,Uo=this),this._call=e,this._time=s,cx()},stop:function(){this._call&&(this._call=null,this._time=1/0,cx())}};function Gw(e,n,s){var l=new hu;return l.restart(e,n,s),l}function G6(){Qx(),++Oi;for(var e=fu,n;e;)(n=Il-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Oi}function Ov(){Il=(mu=sc.now())+Mu,Oi=Po=0;try{G6()}finally{Oi=0,K6(),Il=0}}function X6(){var e=sc.now(),n=e-mu;n>Vw&&(Mu-=n,mu=e)}function K6(){for(var e,n=fu,s,l=1/0;n;)n._call?(l>n._time&&(l=n._time),e=n,n=n._next):(s=n._next,n._next=null,n=e?e._next=s:fu=s);Uo=e,cx(l)}function cx(e){if(!Oi){Po&&(Po=clearTimeout(Po));var n=e-Il;n>24?(e<1/0&&(Po=setTimeout(Ov,e-sc.now()-Mu)),Io&&(Io=clearInterval(Io))):(Io||(mu=sc.now(),Io=setInterval(X6,Vw)),Oi=1,Yw(Ov))}}function Dv(e,n,s){var l=new hu;return n=n==null?0:+n,l.restart(i=>{l.stop(),e(i+n)},n,s),l}var W6=Au("start","end","cancel","interrupt"),Z6=[],Xw=0,Lv=1,dx=2,Kd=3,Iv=4,ux=5,Wd=6;function Ru(e,n,s,l,i,c){var d=e.__transition;if(!d)e.__transition={};else if(s in d)return;Q6(e,s,{name:n,index:l,group:i,on:W6,tween:Z6,time:c.time,delay:c.delay,duration:c.duration,ease:c.ease,timer:null,state:Xw})}function Jx(e,n){var s=Rs(e,n);if(s.state>Xw)throw new Error("too late; already scheduled");return s}function Ws(e,n){var s=Rs(e,n);if(s.state>Kd)throw new Error("too late; already running");return s}function Rs(e,n){var s=e.__transition;if(!s||!(s=s[n]))throw new Error("transition not found");return s}function Q6(e,n,s){var l=e.__transition,i;l[n]=s,s.timer=Gw(c,0,s.time);function c(f){s.state=Lv,s.timer.restart(d,s.delay,s.time),s.delay<=f&&d(f-s.delay)}function d(f){var x,p,g,b;if(s.state!==Lv)return h();for(x in l)if(b=l[x],b.name===s.name){if(b.state===Kd)return Dv(d);b.state===Iv?(b.state=Wd,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete l[x]):+x<n&&(b.state=Wd,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete l[x])}if(Dv(function(){s.state===Kd&&(s.state=Iv,s.timer.restart(u,s.delay,s.time),u(f))}),s.state=dx,s.on.call("start",e,e.__data__,s.index,s.group),s.state===dx){for(s.state=Kd,i=new Array(g=s.tween.length),x=0,p=-1;x<g;++x)(b=s.tween[x].value.call(e,e.__data__,s.index,s.group))&&(i[++p]=b);i.length=p+1}}function u(f){for(var x=f<s.duration?s.ease.call(null,f/s.duration):(s.timer.restart(h),s.state=ux,1),p=-1,g=i.length;++p<g;)i[p].call(e,x);s.state===ux&&(s.on.call("end",e,e.__data__,s.index,s.group),h())}function h(){s.state=Wd,s.timer.stop(),delete l[n];for(var f in l)return;delete e.__transition}}function Zd(e,n){var s=e.__transition,l,i,c=!0,d;if(s){n=n==null?null:n+"";for(d in s){if((l=s[d]).name!==n){c=!1;continue}i=l.state>dx&&l.state<ux,l.state=Wd,l.timer.stop(),l.on.call(i?"interrupt":"cancel",e,e.__data__,l.index,l.group),delete s[d]}c&&delete e.__transition}}function J6(e){return this.each(function(){Zd(this,e)})}function eR(e,n){var s,l;return function(){var i=Ws(this,e),c=i.tween;if(c!==s){l=s=c;for(var d=0,u=l.length;d<u;++d)if(l[d].name===n){l=l.slice(),l.splice(d,1);break}}i.tween=l}}function tR(e,n,s){var l,i;if(typeof s!="function")throw new Error;return function(){var c=Ws(this,e),d=c.tween;if(d!==l){i=(l=d).slice();for(var u={name:n,value:s},h=0,f=i.length;h<f;++h)if(i[h].name===n){i[h]=u;break}h===f&&i.push(u)}c.tween=i}}function nR(e,n){var s=this._id;if(e+="",arguments.length<2){for(var l=Rs(this.node(),s).tween,i=0,c=l.length,d;i<c;++i)if((d=l[i]).name===e)return d.value;return null}return this.each((n==null?eR:tR)(s,e,n))}function ep(e,n,s){var l=e._id;return e.each(function(){var i=Ws(this,l);(i.value||(i.value={}))[n]=s.apply(this,arguments)}),function(i){return Rs(i,l).value[n]}}function Kw(e,n){var s;return(typeof n=="number"?Vs:n instanceof Ll?uu:(s=Ll(n))?(n=s,uu):Uw)(e,n)}function rR(e){return function(){this.removeAttribute(e)}}function sR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aR(e,n,s){var l,i=s+"",c;return function(){var d=this.getAttribute(e);return d===i?null:d===l?c:c=n(l=d,s)}}function lR(e,n,s){var l,i=s+"",c;return function(){var d=this.getAttributeNS(e.space,e.local);return d===i?null:d===l?c:c=n(l=d,s)}}function iR(e,n,s){var l,i,c;return function(){var d,u=s(this),h;return u==null?void this.removeAttribute(e):(d=this.getAttribute(e),h=u+"",d===h?null:d===l&&h===i?c:(i=h,c=n(l=d,u)))}}function oR(e,n,s){var l,i,c;return function(){var d,u=s(this),h;return u==null?void this.removeAttributeNS(e.space,e.local):(d=this.getAttributeNS(e.space,e.local),h=u+"",d===h?null:d===l&&h===i?c:(i=h,c=n(l=d,u)))}}function cR(e,n){var s=_u(e),l=s==="transform"?U6:Kw;return this.attrTween(e,typeof n=="function"?(s.local?oR:iR)(s,l,ep(this,"attr."+e,n)):n==null?(s.local?sR:rR)(s):(s.local?lR:aR)(s,l,n))}function dR(e,n){return function(s){this.setAttribute(e,n.call(this,s))}}function uR(e,n){return function(s){this.setAttributeNS(e.space,e.local,n.call(this,s))}}function fR(e,n){var s,l;function i(){var c=n.apply(this,arguments);return c!==l&&(s=(l=c)&&uR(e,c)),s}return i._value=n,i}function mR(e,n){var s,l;function i(){var c=n.apply(this,arguments);return c!==l&&(s=(l=c)&&dR(e,c)),s}return i._value=n,i}function hR(e,n){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;var l=_u(e);return this.tween(s,(l.local?fR:mR)(l,n))}function xR(e,n){return function(){Jx(this,e).delay=+n.apply(this,arguments)}}function pR(e,n){return n=+n,function(){Jx(this,e).delay=n}}function gR(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?xR:pR)(n,e)):Rs(this.node(),n).delay}function bR(e,n){return function(){Ws(this,e).duration=+n.apply(this,arguments)}}function yR(e,n){return n=+n,function(){Ws(this,e).duration=n}}function vR(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?bR:yR)(n,e)):Rs(this.node(),n).duration}function jR(e,n){if(typeof n!="function")throw new Error;return function(){Ws(this,e).ease=n}}function wR(e){var n=this._id;return arguments.length?this.each(jR(n,e)):Rs(this.node(),n).ease}function NR(e,n){return function(){var s=n.apply(this,arguments);if(typeof s!="function")throw new Error;Ws(this,e).ease=s}}function kR(e){if(typeof e!="function")throw new Error;return this.each(NR(this._id,e))}function SR(e){typeof e!="function"&&(e=Cw(e));for(var n=this._groups,s=n.length,l=new Array(s),i=0;i<s;++i)for(var c=n[i],d=c.length,u=l[i]=[],h,f=0;f<d;++f)(h=c[f])&&e.call(h,h.__data__,f,c)&&u.push(h);return new ja(l,this._parents,this._name,this._id)}function CR(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,s=e._groups,l=n.length,i=s.length,c=Math.min(l,i),d=new Array(l),u=0;u<c;++u)for(var h=n[u],f=s[u],x=h.length,p=d[u]=new Array(x),g,b=0;b<x;++b)(g=h[b]||f[b])&&(p[b]=g);for(;u<l;++u)d[u]=n[u];return new ja(d,this._parents,this._name,this._id)}function ER(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 TR(e,n,s){var l,i,c=ER(n)?Jx:Ws;return function(){var d=c(this,e),u=d.on;u!==l&&(i=(l=u).copy()).on(n,s),d.on=i}}function AR(e,n){var s=this._id;return arguments.length<2?Rs(this.node(),s).on.on(e):this.each(TR(s,e,n))}function _R(e){return function(){var n=this.parentNode;for(var s in this.__transition)if(+s!==e)return;n&&n.removeChild(this)}}function MR(){return this.on("end.remove",_R(this._id))}function RR(e){var n=this._name,s=this._id;typeof e!="function"&&(e=Xx(e));for(var l=this._groups,i=l.length,c=new Array(i),d=0;d<i;++d)for(var u=l[d],h=u.length,f=c[d]=new Array(h),x,p,g=0;g<h;++g)(x=u[g])&&(p=e.call(x,x.__data__,g,u))&&("__data__"in x&&(p.__data__=x.__data__),f[g]=p,Ru(f[g],n,s,g,f,Rs(x,s)));return new ja(c,this._parents,n,s)}function OR(e){var n=this._name,s=this._id;typeof e!="function"&&(e=Sw(e));for(var l=this._groups,i=l.length,c=[],d=[],u=0;u<i;++u)for(var h=l[u],f=h.length,x,p=0;p<f;++p)if(x=h[p]){for(var g=e.call(x,x.__data__,p,h),b,w=Rs(x,s),k=0,C=g.length;k<C;++k)(b=g[k])&&Ru(b,n,s,k,g,w);c.push(g),d.push(x)}return new ja(c,d,n,s)}var DR=xc.prototype.constructor;function LR(){return new DR(this._groups,this._parents)}function IR(e,n){var s,l,i;return function(){var c=Ri(this,e),d=(this.style.removeProperty(e),Ri(this,e));return c===d?null:c===s&&d===l?i:i=n(s=c,l=d)}}function Ww(e){return function(){this.style.removeProperty(e)}}function zR(e,n,s){var l,i=s+"",c;return function(){var d=Ri(this,e);return d===i?null:d===l?c:c=n(l=d,s)}}function $R(e,n,s){var l,i,c;return function(){var d=Ri(this,e),u=s(this),h=u+"";return u==null&&(h=u=(this.style.removeProperty(e),Ri(this,e))),d===h?null:d===l&&h===i?c:(i=h,c=n(l=d,u))}}function BR(e,n){var s,l,i,c="style."+n,d="end."+c,u;return function(){var h=Ws(this,e),f=h.on,x=h.value[c]==null?u||(u=Ww(n)):void 0;(f!==s||i!==x)&&(l=(s=f).copy()).on(d,i=x),h.on=l}}function HR(e,n,s){var l=(e+="")=="transform"?P6:Kw;return n==null?this.styleTween(e,IR(e,l)).on("end.style."+e,Ww(e)):typeof n=="function"?this.styleTween(e,$R(e,l,ep(this,"style."+e,n))).each(BR(this._id,e)):this.styleTween(e,zR(e,l,n),s).on("end.style."+e,null)}function PR(e,n,s){return function(l){this.style.setProperty(e,n.call(this,l),s)}}function UR(e,n,s){var l,i;function c(){var d=n.apply(this,arguments);return d!==i&&(l=(i=d)&&PR(e,d,s)),l}return c._value=n,c}function qR(e,n,s){var l="style."+(e+="");if(arguments.length<2)return(l=this.tween(l))&&l._value;if(n==null)return this.tween(l,null);if(typeof n!="function")throw new Error;return this.tween(l,UR(e,n,s??""))}function FR(e){return function(){this.textContent=e}}function VR(e){return function(){var n=e(this);this.textContent=n??""}}function YR(e){return this.tween("text",typeof e=="function"?VR(ep(this,"text",e)):FR(e==null?"":e+""))}function GR(e){return function(n){this.textContent=e.call(this,n)}}function XR(e){var n,s;function l(){var i=e.apply(this,arguments);return i!==s&&(n=(s=i)&&GR(i)),n}return l._value=e,l}function KR(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,XR(e))}function WR(){for(var e=this._name,n=this._id,s=Zw(),l=this._groups,i=l.length,c=0;c<i;++c)for(var d=l[c],u=d.length,h,f=0;f<u;++f)if(h=d[f]){var x=Rs(h,n);Ru(h,e,s,f,d,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new ja(l,this._parents,e,s)}function ZR(){var e,n,s=this,l=s._id,i=s.size();return new Promise(function(c,d){var u={value:d},h={value:function(){--i===0&&c()}};s.each(function(){var f=Ws(this,l),x=f.on;x!==e&&(n=(e=x).copy(),n._.cancel.push(u),n._.interrupt.push(u),n._.end.push(h)),f.on=n}),i===0&&c()})}var QR=0;function ja(e,n,s,l){this._groups=e,this._parents=n,this._name=s,this._id=l}function Zw(){return++QR}var ha=xc.prototype;ja.prototype={constructor:ja,select:RR,selectAll:OR,selectChild:ha.selectChild,selectChildren:ha.selectChildren,filter:SR,merge:CR,selection:LR,transition:WR,call:ha.call,nodes:ha.nodes,node:ha.node,size:ha.size,empty:ha.empty,each:ha.each,on:AR,attr:cR,attrTween:hR,style:HR,styleTween:qR,text:YR,textTween:KR,remove:MR,tween:nR,delay:gR,duration:vR,ease:wR,easeVarying:kR,end:ZR,[Symbol.iterator]:ha[Symbol.iterator]};function JR(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var eO={time:null,delay:0,duration:250,ease:JR};function tO(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 nO(e){var n,s;e instanceof ja?(n=e._id,e=e._name):(n=Zw(),(s=eO).time=Qx(),e=e==null?null:e+"");for(var l=this._groups,i=l.length,c=0;c<i;++c)for(var d=l[c],u=d.length,h,f=0;f<u;++f)(h=d[f])&&Ru(h,e,n,f,d,s||tO(h,n));return new ja(l,this._parents,e,n)}xc.prototype.interrupt=J6;xc.prototype.transition=nO;const Dd=e=>()=>e;function rO(e,{sourceEvent:n,target:s,transform:l,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:i}})}function ya(e,n,s){this.k=e,this.x=n,this.y=s}ya.prototype={constructor:ya,scale:function(e){return e===1?this:new ya(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new ya(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 Ou=new ya(1,0,0);Qw.prototype=ya.prototype;function Qw(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ou;return e.__zoom}function vh(e){e.stopImmediatePropagation()}function zo(e){e.preventDefault(),e.stopImmediatePropagation()}function sO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function aO(){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 zv(){return this.__zoom||Ou}function lO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function iO(){return navigator.maxTouchPoints||"ontouchstart"in this}function oO(e,n,s){var l=e.invertX(n[0][0])-s[0][0],i=e.invertX(n[1][0])-s[1][0],c=e.invertY(n[0][1])-s[0][1],d=e.invertY(n[1][1])-s[1][1];return e.translate(i>l?(l+i)/2:Math.min(0,l)||Math.max(0,i),d>c?(c+d)/2:Math.min(0,c)||Math.max(0,d))}function Jw(){var e=sO,n=aO,s=oO,l=lO,i=iO,c=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],u=250,h=Xd,f=Au("start","zoom","end"),x,p,g,b=500,w=150,k=0,C=10;function E(T){T.property("__zoom",zv).on("wheel.zoom",q,{passive:!1}).on("mousedown.zoom",X).on("dblclick.zoom",L).filter(i).on("touchstart.zoom",P).on("touchmove.zoom",G).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(T,z,O,V){var H=T.selection?T.selection():T;H.property("__zoom",zv),T!==H?R(T,z,O,V):H.interrupt().each(function(){_(this,arguments).event(V).start().zoom(null,typeof z=="function"?z.apply(this,arguments):z).end()})},E.scaleBy=function(T,z,O,V){E.scaleTo(T,function(){var H=this.__zoom.k,Z=typeof z=="function"?z.apply(this,arguments):z;return H*Z},O,V)},E.scaleTo=function(T,z,O,V){E.transform(T,function(){var H=n.apply(this,arguments),Z=this.__zoom,B=O==null?A(H):typeof O=="function"?O.apply(this,arguments):O,F=Z.invert(B),K=typeof z=="function"?z.apply(this,arguments):z;return s(N(M(Z,K),B,F),H,d)},O,V)},E.translateBy=function(T,z,O,V){E.transform(T,function(){return s(this.__zoom.translate(typeof z=="function"?z.apply(this,arguments):z,typeof O=="function"?O.apply(this,arguments):O),n.apply(this,arguments),d)},null,V)},E.translateTo=function(T,z,O,V,H){E.transform(T,function(){var Z=n.apply(this,arguments),B=this.__zoom,F=V==null?A(Z):typeof V=="function"?V.apply(this,arguments):V;return s(Ou.translate(F[0],F[1]).scale(B.k).translate(typeof z=="function"?-z.apply(this,arguments):-z,typeof O=="function"?-O.apply(this,arguments):-O),Z,d)},V,H)};function M(T,z){return z=Math.max(c[0],Math.min(c[1],z)),z===T.k?T:new ya(z,T.x,T.y)}function N(T,z,O){var V=z[0]-O[0]*T.k,H=z[1]-O[1]*T.k;return V===T.x&&H===T.y?T:new ya(T.k,V,H)}function A(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function R(T,z,O,V){T.on("start.zoom",function(){_(this,arguments).event(V).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(V).end()}).tween("zoom",function(){var H=this,Z=arguments,B=_(H,Z).event(V),F=n.apply(H,Z),K=O==null?A(F):typeof O=="function"?O.apply(H,Z):O,I=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),S=H.__zoom,D=typeof z=="function"?z.apply(H,Z):z,W=h(S.invert(K).concat(I/S.k),D.invert(K).concat(I/D.k));return function(J){if(J===1)J=D;else{var te=W(J),re=I/te[2];J=new ya(re,K[0]-te[0]*re,K[1]-te[1]*re)}B.zoom(null,J)}})}function _(T,z,O){return!O&&T.__zooming||new Y(T,z)}function Y(T,z){this.that=T,this.args=z,this.active=0,this.sourceEvent=null,this.extent=n.apply(T,z),this.taps=0}Y.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,z){return this.mouse&&T!=="mouse"&&(this.mouse[1]=z.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=z.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=z.invert(this.touch1[0])),this.that.__zoom=z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var z=ts(this.that).datum();f.call(T,this.that,new rO(T,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:f}),z)}};function q(T,...z){if(!e.apply(this,arguments))return;var O=_(this,z).event(T),V=this.__zoom,H=Math.max(c[0],Math.min(c[1],V.k*Math.pow(2,l.apply(this,arguments)))),Z=Cs(T);if(O.wheel)(O.mouse[0][0]!==Z[0]||O.mouse[0][1]!==Z[1])&&(O.mouse[1]=V.invert(O.mouse[0]=Z)),clearTimeout(O.wheel);else{if(V.k===H)return;O.mouse=[Z,V.invert(Z)],Zd(this),O.start()}zo(T),O.wheel=setTimeout(B,w),O.zoom("mouse",s(N(M(V,H),O.mouse[0],O.mouse[1]),O.extent,d));function B(){O.wheel=null,O.end()}}function X(T,...z){if(g||!e.apply(this,arguments))return;var O=T.currentTarget,V=_(this,z,!0).event(T),H=ts(T.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",I,!0),Z=Cs(T,O),B=T.clientX,F=T.clientY;Iw(T.view),vh(T),V.mouse=[Z,this.__zoom.invert(Z)],Zd(this),V.start();function K(S){if(zo(S),!V.moved){var D=S.clientX-B,W=S.clientY-F;V.moved=D*D+W*W>k}V.event(S).zoom("mouse",s(N(V.that.__zoom,V.mouse[0]=Cs(S,O),V.mouse[1]),V.extent,d))}function I(S){H.on("mousemove.zoom mouseup.zoom",null),zw(S.view,V.moved),zo(S),V.event(S).end()}}function L(T,...z){if(e.apply(this,arguments)){var O=this.__zoom,V=Cs(T.changedTouches?T.changedTouches[0]:T,this),H=O.invert(V),Z=O.k*(T.shiftKey?.5:2),B=s(N(M(O,Z),V,H),n.apply(this,z),d);zo(T),u>0?ts(this).transition().duration(u).call(R,B,V,T):ts(this).call(E.transform,B,V,T)}}function P(T,...z){if(e.apply(this,arguments)){var O=T.touches,V=O.length,H=_(this,z,T.changedTouches.length===V).event(T),Z,B,F,K;for(vh(T),B=0;B<V;++B)F=O[B],K=Cs(F,this),K=[K,this.__zoom.invert(K),F.identifier],H.touch0?!H.touch1&&H.touch0[2]!==K[2]&&(H.touch1=K,H.taps=0):(H.touch0=K,Z=!0,H.taps=1+!!x);x&&(x=clearTimeout(x)),Z&&(H.taps<2&&(p=K[0],x=setTimeout(function(){x=null},b)),Zd(this),H.start())}}function G(T,...z){if(this.__zooming){var O=_(this,z).event(T),V=T.changedTouches,H=V.length,Z,B,F,K;for(zo(T),Z=0;Z<H;++Z)B=V[Z],F=Cs(B,this),O.touch0&&O.touch0[2]===B.identifier?O.touch0[0]=F:O.touch1&&O.touch1[2]===B.identifier&&(O.touch1[0]=F);if(B=O.that.__zoom,O.touch1){var I=O.touch0[0],S=O.touch0[1],D=O.touch1[0],W=O.touch1[1],J=(J=D[0]-I[0])*J+(J=D[1]-I[1])*J,te=(te=W[0]-S[0])*te+(te=W[1]-S[1])*te;B=M(B,Math.sqrt(J/te)),F=[(I[0]+D[0])/2,(I[1]+D[1])/2],K=[(S[0]+W[0])/2,(S[1]+W[1])/2]}else if(O.touch0)F=O.touch0[0],K=O.touch0[1];else return;O.zoom("touch",s(N(B,F,K),O.extent,d))}}function $(T,...z){if(this.__zooming){var O=_(this,z).event(T),V=T.changedTouches,H=V.length,Z,B;for(vh(T),g&&clearTimeout(g),g=setTimeout(function(){g=null},b),Z=0;Z<H;++Z)B=V[Z],O.touch0&&O.touch0[2]===B.identifier?delete O.touch0:O.touch1&&O.touch1[2]===B.identifier&&delete O.touch1;if(O.touch1&&!O.touch0&&(O.touch0=O.touch1,delete O.touch1),O.touch0)O.touch0[1]=this.__zoom.invert(O.touch0[0]);else if(O.end(),O.taps===2&&(B=Cs(B,this),Math.hypot(p[0]-B[0],p[1]-B[1])<C)){var F=ts(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return E.wheelDelta=function(T){return arguments.length?(l=typeof T=="function"?T:Dd(+T),E):l},E.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Dd(!!T),E):e},E.touchable=function(T){return arguments.length?(i=typeof T=="function"?T:Dd(!!T),E):i},E.extent=function(T){return arguments.length?(n=typeof T=="function"?T:Dd([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),E):n},E.scaleExtent=function(T){return arguments.length?(c[0]=+T[0],c[1]=+T[1],E):[c[0],c[1]]},E.translateExtent=function(T){return arguments.length?(d[0][0]=+T[0][0],d[1][0]=+T[1][0],d[0][1]=+T[0][1],d[1][1]=+T[1][1],E):[[d[0][0],d[0][1]],[d[1][0],d[1][1]]]},E.constrain=function(T){return arguments.length?(s=T,E):s},E.duration=function(T){return arguments.length?(u=+T,E):u},E.interpolate=function(T){return arguments.length?(h=T,E):h},E.on=function(){var T=f.on.apply(f,arguments);return T===f?E:T},E.clickDistance=function(T){return arguments.length?(k=(T=+T)*T,E):Math.sqrt(k)},E.tapDistance=function(T){return arguments.length?(C=+T,E):C},E}const Xs={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:s,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:l}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ac=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eN=["Enter"," ","Escape"],tN={"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 Di;(function(e){e.Strict="strict",e.Loose="loose"})(Di||(Di={}));var Rl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Rl||(Rl={}));var lc;(function(e){e.Partial="partial",e.Full="full"})(lc||(lc={}));const nN={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var rl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(rl||(rl={}));var Li;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Li||(Li={}));var mt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(mt||(mt={}));const $v={[mt.Left]:mt.Right,[mt.Right]:mt.Left,[mt.Top]:mt.Bottom,[mt.Bottom]:mt.Top};function rN(e){return e===null?null:e?"valid":"invalid"}const sN=e=>"id"in e&&"source"in e&&"target"in e,cO=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),tp=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),gc=(e,n=[0,0])=>{const{width:s,height:l}=Na(e),i=e.origin??n,c=s*i[0],d=l*i[1];return{x:e.position.x-c,y:e.position.y-d}},dO=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((l,i)=>{const c=typeof i=="string";let d=!n.nodeLookup&&!c?i:void 0;n.nodeLookup&&(d=c?n.nodeLookup.get(i):tp(i)?i:n.nodeLookup.get(i.id));const u=d?xu(d,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Du(l,u)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Lu(s)},bc=(e,n={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(i=>{(n.filter===void 0||n.filter(i))&&(s=Du(s,xu(i)),l=!0)}),l?Lu(s):{x:0,y:0,width:0,height:0}},np=(e,n,[s,l,i]=[0,0,1],c=!1,d=!1)=>{const u={...vc(n,[s,l,i]),width:n.width/i,height:n.height/i},h=[];for(const f of e.values()){const{measured:x,selectable:p=!0,hidden:g=!1}=f;if(d&&!p||g)continue;const b=x.width??f.width??f.initialWidth??null,w=x.height??f.height??f.initialHeight??null,k=ic(u,zi(f)),C=(b??0)*(w??0),E=c&&k>0;(!f.internals.handleBounds||E||k>=C||f.dragging)&&h.push(f)}return h},uO=(e,n)=>{const s=new Set;return e.forEach(l=>{s.add(l.id)}),n.filter(l=>s.has(l.source)||s.has(l.target))};function fO(e,n){const s=new Map,l=n?.nodes?new Set(n.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&(n?.includeHiddenNodes||!i.hidden)&&(!l||l.has(i.id))&&s.set(i.id,i)}),s}async function mO({nodes:e,width:n,height:s,panZoom:l,minZoom:i,maxZoom:c},d){if(e.size===0)return Promise.resolve(!0);const u=fO(e,d),h=bc(u),f=rp(h,n,s,d?.minZoom??i,d?.maxZoom??c,d?.padding??.1);return await l.setViewport(f,{duration:d?.duration,ease:d?.ease,interpolate:d?.interpolate}),Promise.resolve(!0)}function aN({nodeId:e,nextPosition:n,nodeLookup:s,nodeOrigin:l=[0,0],nodeExtent:i,onError:c}){const d=s.get(e),u=d.parentId?s.get(d.parentId):void 0,{x:h,y:f}=u?u.internals.positionAbsolute:{x:0,y:0},x=d.origin??l;let p=d.extent||i;if(d.extent==="parent"&&!d.expandParent)if(!u)c?.("005",Xs.error005());else{const b=u.measured.width,w=u.measured.height;b&&w&&(p=[[h,f],[h+b,f+w]])}else u&&$i(d.extent)&&(p=[[d.extent[0][0]+h,d.extent[0][1]+f],[d.extent[1][0]+h,d.extent[1][1]+f]]);const g=$i(p)?zl(n,p,d.measured):n;return(d.measured.width===void 0||d.measured.height===void 0)&&c?.("015",Xs.error015()),{position:{x:g.x-h+(d.measured.width??0)*x[0],y:g.y-f+(d.measured.height??0)*x[1]},positionAbsolute:g}}async function hO({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:l,onBeforeDelete:i}){const c=new Set(e.map(g=>g.id)),d=[];for(const g of s){if(g.deletable===!1)continue;const b=c.has(g.id),w=!b&&g.parentId&&d.find(k=>k.id===g.parentId);(b||w)&&d.push(g)}const u=new Set(n.map(g=>g.id)),h=l.filter(g=>g.deletable!==!1),x=uO(d,h);for(const g of h)u.has(g.id)&&!x.find(w=>w.id===g.id)&&x.push(g);if(!i)return{edges:x,nodes:d};const p=await i({nodes:d,edges:x});return typeof p=="boolean"?p?{edges:x,nodes:d}:{edges:[],nodes:[]}:p}const Ii=(e,n=0,s=1)=>Math.min(Math.max(e,n),s),zl=(e={x:0,y:0},n,s)=>({x:Ii(e.x,n[0][0],n[1][0]-(s?.width??0)),y:Ii(e.y,n[0][1],n[1][1]-(s?.height??0))});function lN(e,n,s){const{width:l,height:i}=Na(s),{x:c,y:d}=s.internals.positionAbsolute;return zl(e,[[c,d],[c+l,d+i]],n)}const Bv=(e,n,s)=>e<n?Ii(Math.abs(e-n),1,n)/n:e>s?-Ii(Math.abs(e-s),1,n)/n:0,iN=(e,n,s=15,l=40)=>{const i=Bv(e.x,l,n.width-l)*s,c=Bv(e.y,l,n.height-l)*s;return[i,c]},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)}),fx=({x:e,y:n,width:s,height:l})=>({x:e,y:n,x2:e+s,y2:n+l}),Lu=({x:e,y:n,x2:s,y2:l})=>({x:e,y:n,width:s-e,height:l-n}),zi=(e,n=[0,0])=>{const{x:s,y:l}=tp(e)?e.internals.positionAbsolute:gc(e,n);return{x:s,y:l,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},xu=(e,n=[0,0])=>{const{x:s,y:l}=tp(e)?e.internals.positionAbsolute:gc(e,n);return{x:s,y:l,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:l+(e.measured?.height??e.height??e.initialHeight??0)}},oN=(e,n)=>Lu(Du(fx(e),fx(n))),ic=(e,n)=>{const s=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),l=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(s*l)},Hv=e=>Ts(e.width)&&Ts(e.height)&&Ts(e.x)&&Ts(e.y),Ts=e=>!isNaN(e)&&isFinite(e),xO=(e,n)=>{},yc=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),vc=({x:e,y:n},[s,l,i],c=!1,d=[1,1])=>{const u={x:(e-s)/i,y:(n-l)/i};return c?yc(u,d):u},pu=({x:e,y:n},[s,l,i])=>({x:e*i+s,y:n*i+l});function yi(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 pO(e,n,s){if(typeof e=="string"||typeof e=="number"){const l=yi(e,s),i=yi(e,n);return{top:l,right:i,bottom:l,left:i,x:i*2,y:l*2}}if(typeof e=="object"){const l=yi(e.top??e.y??0,s),i=yi(e.bottom??e.y??0,s),c=yi(e.left??e.x??0,n),d=yi(e.right??e.x??0,n);return{top:l,right:d,bottom:i,left:c,x:c+d,y:l+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function gO(e,n,s,l,i,c){const{x:d,y:u}=pu(e,[n,s,l]),{x:h,y:f}=pu({x:e.x+e.width,y:e.y+e.height},[n,s,l]),x=i-h,p=c-f;return{left:Math.floor(d),top:Math.floor(u),right:Math.floor(x),bottom:Math.floor(p)}}const rp=(e,n,s,l,i,c)=>{const d=pO(c,n,s),u=(n-d.x)/e.width,h=(s-d.y)/e.height,f=Math.min(u,h),x=Ii(f,l,i),p=e.x+e.width/2,g=e.y+e.height/2,b=n/2-p*x,w=s/2-g*x,k=gO(e,b,w,x,n,s),C={left:Math.min(k.left-d.left,0),top:Math.min(k.top-d.top,0),right:Math.min(k.right-d.right,0),bottom:Math.min(k.bottom-d.bottom,0)};return{x:b-C.left+C.right,y:w-C.top+C.bottom,zoom:x}},oc=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function $i(e){return e!=null&&e!=="parent"}function Na(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function cN(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function dN(e,n={width:0,height:0},s,l,i){const c={...e},d=l.get(s);if(d){const u=d.origin||i;c.x+=d.internals.positionAbsolute.x-(n.width??0)*u[0],c.y+=d.internals.positionAbsolute.y-(n.height??0)*u[1]}return c}function Pv(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function bO(){let e,n;return{promise:new Promise((l,i)=>{e=l,n=i}),resolve:e,reject:n}}function yO(e){return{...tN,...e||{}}}function Ko(e,{snapGrid:n=[0,0],snapToGrid:s=!1,transform:l,containerBounds:i}){const{x:c,y:d}=As(e),u=vc({x:c-(i?.left??0),y:d-(i?.top??0)},l),{x:h,y:f}=s?yc(u,n):u;return{xSnapped:h,ySnapped:f,...u}}const sp=e=>({width:e.offsetWidth,height:e.offsetHeight}),uN=e=>e?.getRootNode?.()||window?.document,vO=["INPUT","SELECT","TEXTAREA"];function fN(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:vO.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const mN=e=>"clientX"in e,As=(e,n)=>{const s=mN(e),l=s?e.clientX:e.touches?.[0].clientX,i=s?e.clientY:e.touches?.[0].clientY;return{x:l-(n?.left??0),y:i-(n?.top??0)}},Uv=(e,n,s,l,i)=>{const c=n.querySelectorAll(`.${e}`);return!c||!c.length?null:Array.from(c).map(d=>{const u=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),type:e,nodeId:i,position:d.getAttribute("data-handlepos"),x:(u.left-s.left)/l,y:(u.top-s.top)/l,...sp(d)}})};function hN({sourceX:e,sourceY:n,targetX:s,targetY:l,sourceControlX:i,sourceControlY:c,targetControlX:d,targetControlY:u}){const h=e*.125+i*.375+d*.375+s*.125,f=n*.125+c*.375+u*.375+l*.125,x=Math.abs(h-e),p=Math.abs(f-n);return[h,f,x,p]}function Ld(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function qv({pos:e,x1:n,y1:s,x2:l,y2:i,c}){switch(e){case mt.Left:return[n-Ld(n-l,c),s];case mt.Right:return[n+Ld(l-n,c),s];case mt.Top:return[n,s-Ld(s-i,c)];case mt.Bottom:return[n,s+Ld(i-s,c)]}}function xN({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:l,targetY:i,targetPosition:c=mt.Top,curvature:d=.25}){const[u,h]=qv({pos:s,x1:e,y1:n,x2:l,y2:i,c:d}),[f,x]=qv({pos:c,x1:l,y1:i,x2:e,y2:n,c:d}),[p,g,b,w]=hN({sourceX:e,sourceY:n,targetX:l,targetY:i,sourceControlX:u,sourceControlY:h,targetControlX:f,targetControlY:x});return[`M${e},${n} C${u},${h} ${f},${x} ${l},${i}`,p,g,b,w]}function pN({sourceX:e,sourceY:n,targetX:s,targetY:l}){const i=Math.abs(s-e)/2,c=s<e?s+i:s-i,d=Math.abs(l-n)/2,u=l<n?l+d:l-d;return[c,u,i,d]}function jO({sourceNode:e,targetNode:n,selected:s=!1,zIndex:l=0,elevateOnSelect:i=!1,zIndexMode:c="basic"}){if(c==="manual")return l;const d=i&&s?l+1e3:l,u=Math.max(e.parentId||i&&e.selected?e.internals.z:0,n.parentId||i&&n.selected?n.internals.z:0);return d+u}function wO({sourceNode:e,targetNode:n,width:s,height:l,transform:i}){const c=Du(xu(e),xu(n));c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d={x:-i[0]/i[2],y:-i[1]/i[2],width:s/i[2],height:l/i[2]};return ic(d,Lu(c))>0}const NO=({source:e,sourceHandle:n,target:s,targetHandle:l})=>`xy-edge__${e}${n||""}-${s}${l||""}`,kO=(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)),SO=(e,n,s={})=>{if(!e.source||!e.target)return n;const l=s.getEdgeId||NO;let i;return sN(e)?i={...e}:i={...e,id:l(e)},kO(i,n)?n:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,n.concat(i))};function gN({sourceX:e,sourceY:n,targetX:s,targetY:l}){const[i,c,d,u]=pN({sourceX:e,sourceY:n,targetX:s,targetY:l});return[`M ${e},${n}L ${s},${l}`,i,c,d,u]}const Fv={[mt.Left]:{x:-1,y:0},[mt.Right]:{x:1,y:0},[mt.Top]:{x:0,y:-1},[mt.Bottom]:{x:0,y:1}},CO=({source:e,sourcePosition:n=mt.Bottom,target:s})=>n===mt.Left||n===mt.Right?e.x<s.x?{x:1,y:0}:{x:-1,y:0}:e.y<s.y?{x:0,y:1}:{x:0,y:-1},Vv=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function EO({source:e,sourcePosition:n=mt.Bottom,target:s,targetPosition:l=mt.Top,center:i,offset:c,stepPosition:d}){const u=Fv[n],h=Fv[l],f={x:e.x+u.x*c,y:e.y+u.y*c},x={x:s.x+h.x*c,y:s.y+h.y*c},p=CO({source:f,sourcePosition:n,target:x}),g=p.x!==0?"x":"y",b=p[g];let w=[],k,C;const E={x:0,y:0},M={x:0,y:0},[,,N,A]=pN({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(u[g]*h[g]===-1){g==="x"?(k=i.x??f.x+(x.x-f.x)*d,C=i.y??(f.y+x.y)/2):(k=i.x??(f.x+x.x)/2,C=i.y??f.y+(x.y-f.y)*d);const _=[{x:k,y:f.y},{x:k,y:x.y}],Y=[{x:f.x,y:C},{x:x.x,y:C}];u[g]===b?w=g==="x"?_:Y:w=g==="x"?Y:_}else{const _=[{x:f.x,y:x.y}],Y=[{x:x.x,y:f.y}];if(g==="x"?w=u.x===b?Y:_:w=u.y===b?_:Y,n===l){const G=Math.abs(e[g]-s[g]);if(G<=c){const $=Math.min(c-1,c-G);u[g]===b?E[g]=(f[g]>e[g]?-1:1)*$:M[g]=(x[g]>s[g]?-1:1)*$}}if(n!==l){const G=g==="x"?"y":"x",$=u[g]===h[G],T=f[G]>x[G],z=f[G]<x[G];(u[g]===1&&(!$&&T||$&&z)||u[g]!==1&&(!$&&z||$&&T))&&(w=g==="x"?_:Y)}const q={x:f.x+E.x,y:f.y+E.y},X={x:x.x+M.x,y:x.y+M.y},L=Math.max(Math.abs(q.x-w[0].x),Math.abs(X.x-w[0].x)),P=Math.max(Math.abs(q.y-w[0].y),Math.abs(X.y-w[0].y));L>=P?(k=(q.x+X.x)/2,C=w[0].y):(k=w[0].x,C=(q.y+X.y)/2)}return[[e,{x:f.x+E.x,y:f.y+E.y},...w,{x:x.x+M.x,y:x.y+M.y},s],k,C,N,A]}function TO(e,n,s,l){const i=Math.min(Vv(e,n)/2,Vv(n,s)/2,l),{x:c,y:d}=n;if(e.x===c&&c===s.x||e.y===d&&d===s.y)return`L${c} ${d}`;if(e.y===d){const f=e.x<s.x?-1:1,x=e.y<s.y?1:-1;return`L ${c+i*f},${d}Q ${c},${d} ${c},${d+i*x}`}const u=e.x<s.x?1:-1,h=e.y<s.y?-1:1;return`L ${c},${d+i*h}Q ${c},${d} ${c+i*u},${d}`}function mx({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:l,targetY:i,targetPosition:c=mt.Top,borderRadius:d=5,centerX:u,centerY:h,offset:f=20,stepPosition:x=.5}){const[p,g,b,w,k]=EO({source:{x:e,y:n},sourcePosition:s,target:{x:l,y:i},targetPosition:c,center:{x:u,y:h},offset:f,stepPosition:x});return[p.reduce((E,M,N)=>{let A="";return N>0&&N<p.length-1?A=TO(p[N-1],M,p[N+1],d):A=`${N===0?"M":"L"}${M.x} ${M.y}`,E+=A,E},""),g,b,w,k]}function Yv(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function AO(e){const{sourceNode:n,targetNode:s}=e;if(!Yv(n)||!Yv(s))return null;const l=n.internals.handleBounds||Gv(n.handles),i=s.internals.handleBounds||Gv(s.handles),c=Xv(l?.source??[],e.sourceHandle),d=Xv(e.connectionMode===Di.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!c||!d)return e.onError?.("008",Xs.error008(c?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=c?.position||mt.Bottom,h=d?.position||mt.Top,f=$l(n,c,u),x=$l(s,d,h);return{sourceX:f.x,sourceY:f.y,targetX:x.x,targetY:x.y,sourcePosition:u,targetPosition:h}}function Gv(e){if(!e)return null;const n=[],s=[];for(const l of e)l.width=l.width??1,l.height=l.height??1,l.type==="source"?n.push(l):l.type==="target"&&s.push(l);return{source:n,target:s}}function $l(e,n,s=mt.Left,l=!1){const i=(n?.x??0)+e.internals.positionAbsolute.x,c=(n?.y??0)+e.internals.positionAbsolute.y,{width:d,height:u}=n??Na(e);if(l)return{x:i+d/2,y:c+u/2};switch(n?.position??s){case mt.Top:return{x:i+d/2,y:c};case mt.Right:return{x:i+d,y:c+u/2};case mt.Bottom:return{x:i+d/2,y:c+u};case mt.Left:return{x:i,y:c+u/2}}}function Xv(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function hx(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function _O(e,{id:n,defaultColor:s,defaultMarkerStart:l,defaultMarkerEnd:i}){const c=new Set;return e.reduce((d,u)=>([u.markerStart||l,u.markerEnd||i].forEach(h=>{if(h&&typeof h=="object"){const f=hx(h,n);c.has(f)||(d.push({id:f,color:h.color||s,...h}),c.add(f))}}),d),[]).sort((d,u)=>d.id.localeCompare(u.id))}const bN=1e3,MO=10,ap={nodeOrigin:[0,0],nodeExtent:ac,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},RO={...ap,checkEquality:!0};function lp(e,n){const s={...e};for(const l in n)n[l]!==void 0&&(s[l]=n[l]);return s}function OO(e,n,s){const l=lp(ap,s);for(const i of e.values())if(i.parentId)op(i,e,n,l);else{const c=gc(i,l.nodeOrigin),d=$i(i.extent)?i.extent:l.nodeExtent,u=zl(c,d,Na(i));i.internals.positionAbsolute=u}}function DO(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const s=[],l=[];for(const i of e.handles){const c={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?s.push(c):i.type==="target"&&l.push(c)}return{source:s,target:l}}function ip(e){return e==="manual"}function xx(e,n,s,l={}){const i=lp(RO,l),c={i:0},d=new Map(n),u=i?.elevateNodesOnSelect&&!ip(i.zIndexMode)?bN:0;let h=e.length>0;n.clear(),s.clear();for(const f of e){let x=d.get(f.id);if(i.checkEquality&&f===x?.internals.userNode)n.set(f.id,x);else{const p=gc(f,i.nodeOrigin),g=$i(f.extent)?f.extent:i.nodeExtent,b=zl(p,g,Na(f));x={...i.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:b,handleBounds:DO(f,x),z:yN(f,u,i.zIndexMode),userNode:f}},n.set(f.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(h=!1),f.parentId&&op(x,n,s,l,c)}return h}function LO(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 op(e,n,s,l,i){const{elevateNodesOnSelect:c,nodeOrigin:d,nodeExtent:u,zIndexMode:h}=lp(ap,l),f=e.parentId,x=n.get(f);if(!x){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}LO(e,s),i&&!x.parentId&&x.internals.rootParentIndex===void 0&&h==="auto"&&(x.internals.rootParentIndex=++i.i,x.internals.z=x.internals.z+i.i*MO),i&&x.internals.rootParentIndex!==void 0&&(i.i=x.internals.rootParentIndex);const p=c&&!ip(h)?bN:0,{x:g,y:b,z:w}=IO(e,x,d,u,p,h),{positionAbsolute:k}=e.internals,C=g!==k.x||b!==k.y;(C||w!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:g,y:b}:k,z:w}})}function yN(e,n,s){const l=Ts(e.zIndex)?e.zIndex:0;return ip(s)?l:l+(e.selected?n:0)}function IO(e,n,s,l,i,c){const{x:d,y:u}=n.internals.positionAbsolute,h=Na(e),f=gc(e,s),x=$i(e.extent)?zl(f,e.extent,h):f;let p=zl({x:d+x.x,y:u+x.y},l,h);e.extent==="parent"&&(p=lN(p,h,n));const g=yN(e,i,c),b=n.internals.z??0;return{x:p.x,y:p.y,z:b>=g?b+1:g}}function cp(e,n,s,l=[0,0]){const i=[],c=new Map;for(const d of e){const u=n.get(d.parentId);if(!u)continue;const h=c.get(d.parentId)?.expandedRect??zi(u),f=oN(h,d.rect);c.set(d.parentId,{expandedRect:f,parent:u})}return c.size>0&&c.forEach(({expandedRect:d,parent:u},h)=>{const f=u.internals.positionAbsolute,x=Na(u),p=u.origin??l,g=d.x<f.x?Math.round(Math.abs(f.x-d.x)):0,b=d.y<f.y?Math.round(Math.abs(f.y-d.y)):0,w=Math.max(x.width,Math.round(d.width)),k=Math.max(x.height,Math.round(d.height)),C=(w-x.width)*p[0],E=(k-x.height)*p[1];(g>0||b>0||C||E)&&(i.push({id:h,type:"position",position:{x:u.position.x-g+C,y:u.position.y-b+E}}),s.get(h)?.forEach(M=>{e.some(N=>N.id===M.id)||i.push({id:M.id,type:"position",position:{x:M.position.x+g,y:M.position.y+b}})})),(x.width<d.width||x.height<d.height||g||b)&&i.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?p[0]*g-C:0),height:k+(b?p[1]*b-E:0)}})}),i}function zO(e,n,s,l,i,c,d){const u=l?.querySelector(".xyflow__viewport");let h=!1;if(!u)return{changes:[],updatedInternals:h};const f=[],x=window.getComputedStyle(u),{m22:p}=new window.DOMMatrixReadOnly(x.transform),g=[];for(const b of e.values()){const w=n.get(b.id);if(!w)continue;if(w.hidden){n.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),h=!0;continue}const k=sp(b.nodeElement),C=w.measured.width!==k.width||w.measured.height!==k.height;if(!!(k.width&&k.height&&(C||!w.internals.handleBounds||b.force))){const M=b.nodeElement.getBoundingClientRect(),N=$i(w.extent)?w.extent:c;let{positionAbsolute:A}=w.internals;w.parentId&&w.extent==="parent"?A=lN(A,k,n.get(w.parentId)):N&&(A=zl(A,N,k));const R={...w,measured:k,internals:{...w.internals,positionAbsolute:A,handleBounds:{source:Uv("source",b.nodeElement,M,p,w.id),target:Uv("target",b.nodeElement,M,p,w.id)}}};n.set(w.id,R),w.parentId&&op(R,n,s,{nodeOrigin:i,zIndexMode:d}),h=!0,C&&(f.push({id:w.id,type:"dimensions",dimensions:k}),w.expandParent&&w.parentId&&g.push({id:w.id,parentId:w.parentId,rect:zi(R,i)}))}}if(g.length>0){const b=cp(g,n,s,i);f.push(...b)}return{changes:f,updatedInternals:h}}async function $O({delta:e,panZoom:n,transform:s,translateExtent:l,width:i,height:c}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const d=await n.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[i,c]],l),u=!!d&&(d.x!==s[0]||d.y!==s[1]||d.k!==s[2]);return Promise.resolve(u)}function Kv(e,n,s,l,i,c){let d=i;const u=l.get(d)||new Map;l.set(d,u.set(s,n)),d=`${i}-${e}`;const h=l.get(d)||new Map;if(l.set(d,h.set(s,n)),c){d=`${i}-${e}-${c}`;const f=l.get(d)||new Map;l.set(d,f.set(s,n))}}function vN(e,n,s){e.clear(),n.clear();for(const l of s){const{source:i,target:c,sourceHandle:d=null,targetHandle:u=null}=l,h={edgeId:l.id,source:i,target:c,sourceHandle:d,targetHandle:u},f=`${i}-${d}--${c}-${u}`,x=`${c}-${u}--${i}-${d}`;Kv("source",h,x,e,i,d),Kv("target",h,f,e,c,u),n.set(l.id,l)}}function jN(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:jN(s,n):!1}function Wv(e,n,s){let l=e;do{if(l?.matches?.(n))return!0;if(l===s)return!1;l=l?.parentElement}while(l);return!1}function BO(e,n,s,l){const i=new Map;for(const[c,d]of e)if((d.selected||d.id===l)&&(!d.parentId||!jN(d,e))&&(d.draggable||n&&typeof d.draggable>"u")){const u=e.get(c);u&&i.set(c,{id:c,position:u.position||{x:0,y:0},distance:{x:s.x-u.internals.positionAbsolute.x,y:s.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:u.measured.width??0,height:u.measured.height??0}})}return i}function jh({nodeId:e,dragItems:n,nodeLookup:s,dragging:l=!0}){const i=[];for(const[d,u]of n){const h=s.get(d)?.internals.userNode;h&&i.push({...h,position:u.position,dragging:l})}if(!e)return[i[0],i];const c=s.get(e)?.internals.userNode;return[c?{...c,position:n.get(e)?.position||c.position,dragging:l}:i[0],i]}function HO({dragItems:e,snapGrid:n,x:s,y:l}){const i=e.values().next().value;if(!i)return null;const c={x:s-i.distance.x,y:l-i.distance.y},d=yc(c,n);return{x:d.x-c.x,y:d.y-c.y}}function PO({onNodeMouseDown:e,getStoreItems:n,onDragStart:s,onDrag:l,onDragStop:i}){let c={x:null,y:null},d=0,u=new Map,h=!1,f={x:0,y:0},x=null,p=!1,g=null,b=!1,w=!1,k=null;function C({noDragClassName:M,handleSelector:N,domNode:A,isSelectable:R,nodeId:_,nodeClickDistance:Y=0}){g=ts(A);function q({x:G,y:$}){const{nodeLookup:T,nodeExtent:z,snapGrid:O,snapToGrid:V,nodeOrigin:H,onNodeDrag:Z,onSelectionDrag:B,onError:F,updateNodePositions:K}=n();c={x:G,y:$};let I=!1;const S=u.size>1,D=S&&z?fx(bc(u)):null,W=S&&V?HO({dragItems:u,snapGrid:O,x:G,y:$}):null;for(const[J,te]of u){if(!T.has(J))continue;let re={x:G-te.distance.x,y:$-te.distance.y};V&&(re=W?{x:Math.round(re.x+W.x),y:Math.round(re.y+W.y)}:yc(re,O));let oe=null;if(S&&z&&!te.extent&&D){const{positionAbsolute:ve}=te.internals,ke=ve.x-D.x+z[0][0],Ee=ve.x+te.measured.width-D.x2+z[1][0],Me=ve.y-D.y+z[0][1],dt=ve.y+te.measured.height-D.y2+z[1][1];oe=[[ke,Me],[Ee,dt]]}const{position:me,positionAbsolute:Oe}=aN({nodeId:J,nextPosition:re,nodeLookup:T,nodeExtent:oe||z,nodeOrigin:H,onError:F});I=I||te.position.x!==me.x||te.position.y!==me.y,te.position=me,te.internals.positionAbsolute=Oe}if(w=w||I,!!I&&(K(u,!0),k&&(l||Z||!_&&B))){const[J,te]=jh({nodeId:_,dragItems:u,nodeLookup:T});l?.(k,u,J,te),Z?.(k,J,te),_||B?.(k,te)}}async function X(){if(!x)return;const{transform:G,panBy:$,autoPanSpeed:T,autoPanOnNodeDrag:z}=n();if(!z){h=!1,cancelAnimationFrame(d);return}const[O,V]=iN(f,x,T);(O!==0||V!==0)&&(c.x=(c.x??0)-O/G[2],c.y=(c.y??0)-V/G[2],await $({x:O,y:V})&&q(c)),d=requestAnimationFrame(X)}function L(G){const{nodeLookup:$,multiSelectionActive:T,nodesDraggable:z,transform:O,snapGrid:V,snapToGrid:H,selectNodesOnDrag:Z,onNodeDragStart:B,onSelectionDragStart:F,unselectNodesAndEdges:K}=n();p=!0,(!Z||!R)&&!T&&_&&($.get(_)?.selected||K()),R&&Z&&_&&e?.(_);const I=Ko(G.sourceEvent,{transform:O,snapGrid:V,snapToGrid:H,containerBounds:x});if(c=I,u=BO($,z,I,_),u.size>0&&(s||B||!_&&F)){const[S,D]=jh({nodeId:_,dragItems:u,nodeLookup:$});s?.(G.sourceEvent,u,S,D),B?.(G.sourceEvent,S,D),_||F?.(G.sourceEvent,D)}}const P=$w().clickDistance(Y).on("start",G=>{const{domNode:$,nodeDragThreshold:T,transform:z,snapGrid:O,snapToGrid:V}=n();x=$?.getBoundingClientRect()||null,b=!1,w=!1,k=G.sourceEvent,T===0&&L(G),c=Ko(G.sourceEvent,{transform:z,snapGrid:O,snapToGrid:V,containerBounds:x}),f=As(G.sourceEvent,x)}).on("drag",G=>{const{autoPanOnNodeDrag:$,transform:T,snapGrid:z,snapToGrid:O,nodeDragThreshold:V,nodeLookup:H}=n(),Z=Ko(G.sourceEvent,{transform:T,snapGrid:z,snapToGrid:O,containerBounds:x});if(k=G.sourceEvent,(G.sourceEvent.type==="touchmove"&&G.sourceEvent.touches.length>1||_&&!H.has(_))&&(b=!0),!b){if(!h&&$&&p&&(h=!0,X()),!p){const B=As(G.sourceEvent,x),F=B.x-f.x,K=B.y-f.y;Math.sqrt(F*F+K*K)>V&&L(G)}(c.x!==Z.xSnapped||c.y!==Z.ySnapped)&&u&&p&&(f=As(G.sourceEvent,x),q(Z))}}).on("end",G=>{if(!(!p||b)&&(h=!1,p=!1,cancelAnimationFrame(d),u.size>0)){const{nodeLookup:$,updateNodePositions:T,onNodeDragStop:z,onSelectionDragStop:O}=n();if(w&&(T(u,!1),w=!1),i||z||!_&&O){const[V,H]=jh({nodeId:_,dragItems:u,nodeLookup:$,dragging:!1});i?.(G.sourceEvent,u,V,H),z?.(G.sourceEvent,V,H),_||O?.(G.sourceEvent,H)}}}).filter(G=>{const $=G.target;return!G.button&&(!M||!Wv($,`.${M}`,A))&&(!N||Wv($,N,A))});g.call(P)}function E(){g?.on(".drag",null)}return{update:C,destroy:E}}function UO(e,n,s){const l=[],i={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const c of n.values())ic(i,zi(c))>0&&l.push(c);return l}const qO=250;function FO(e,n,s,l){let i=[],c=1/0;const d=UO(e,s,n+qO);for(const u of d){const h=[...u.internals.handleBounds?.source??[],...u.internals.handleBounds?.target??[]];for(const f of h){if(l.nodeId===f.nodeId&&l.type===f.type&&l.id===f.id)continue;const{x,y:p}=$l(u,f,f.position,!0),g=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(p-e.y,2));g>n||(g<c?(i=[{...f,x,y:p}],c=g):g===c&&i.push({...f,x,y:p}))}}if(!i.length)return null;if(i.length>1){const u=l.type==="source"?"target":"source";return i.find(h=>h.type===u)??i[0]}return i[0]}function wN(e,n,s,l,i,c=!1){const d=l.get(e);if(!d)return null;const u=i==="strict"?d.internals.handleBounds?.[n]:[...d.internals.handleBounds?.source??[],...d.internals.handleBounds?.target??[]],h=(s?u?.find(f=>f.id===s):u?.[0])??null;return h&&c?{...h,...$l(d,h,h.position,!0)}:h}function NN(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function VO(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const kN=()=>!0;function YO(e,{connectionMode:n,connectionRadius:s,handleId:l,nodeId:i,edgeUpdaterType:c,isTarget:d,domNode:u,nodeLookup:h,lib:f,autoPanOnConnect:x,flowId:p,panBy:g,cancelConnection:b,onConnectStart:w,onConnect:k,onConnectEnd:C,isValidConnection:E=kN,onReconnectEnd:M,updateConnection:N,getTransform:A,getFromHandle:R,autoPanSpeed:_,dragThreshold:Y=1,handleDomNode:q}){const X=uN(e.target);let L=0,P;const{x:G,y:$}=As(e),T=NN(c,q),z=u?.getBoundingClientRect();let O=!1;if(!z||!T)return;const V=wN(i,T,l,h,n);if(!V)return;let H=As(e,z),Z=!1,B=null,F=!1,K=null;function I(){if(!x||!z)return;const[me,Oe]=iN(H,z,_);g({x:me,y:Oe}),L=requestAnimationFrame(I)}const S={...V,nodeId:i,type:T,position:V.position},D=h.get(i);let J={inProgress:!0,isValid:null,from:$l(D,S,mt.Left,!0),fromHandle:S,fromPosition:S.position,fromNode:D,to:H,toHandle:null,toPosition:$v[S.position],toNode:null,pointer:H};function te(){O=!0,N(J),w?.(e,{nodeId:i,handleId:l,handleType:T})}Y===0&&te();function re(me){if(!O){const{x:dt,y:pt}=As(me),et=dt-G,Pt=pt-$;if(!(et*et+Pt*Pt>Y*Y))return;te()}if(!R()||!S){oe(me);return}const Oe=A();H=As(me,z),P=FO(vc(H,Oe,!1,[1,1]),s,h,S),Z||(I(),Z=!0);const ve=SN(me,{handle:P,connectionMode:n,fromNodeId:i,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:X,lib:f,flowId:p,nodeLookup:h});K=ve.handleDomNode,B=ve.connection,F=VO(!!P,ve.isValid);const ke=h.get(i),Ee=ke?$l(ke,S,mt.Left,!0):J.from,Me={...J,from:Ee,isValid:F,to:ve.toHandle&&F?pu({x:ve.toHandle.x,y:ve.toHandle.y},Oe):H,toHandle:ve.toHandle,toPosition:F&&ve.toHandle?ve.toHandle.position:$v[S.position],toNode:ve.toHandle?h.get(ve.toHandle.nodeId):null,pointer:H};N(Me),J=Me}function oe(me){if(!("touches"in me&&me.touches.length>0)){if(O){(P||K)&&B&&F&&k?.(B);const{inProgress:Oe,...ve}=J,ke={...ve,toPosition:J.toHandle?J.toPosition:null};C?.(me,ke),c&&M?.(me,ke)}b(),cancelAnimationFrame(L),Z=!1,F=!1,B=null,K=null,X.removeEventListener("mousemove",re),X.removeEventListener("mouseup",oe),X.removeEventListener("touchmove",re),X.removeEventListener("touchend",oe)}}X.addEventListener("mousemove",re),X.addEventListener("mouseup",oe),X.addEventListener("touchmove",re),X.addEventListener("touchend",oe)}function SN(e,{handle:n,connectionMode:s,fromNodeId:l,fromHandleId:i,fromType:c,doc:d,lib:u,flowId:h,isValidConnection:f=kN,nodeLookup:x}){const p=c==="target",g=n?d.querySelector(`.${u}-flow__handle[data-id="${h}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:b,y:w}=As(e),k=d.elementFromPoint(b,w),C=k?.classList.contains(`${u}-flow__handle`)?k:g,E={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const M=NN(void 0,C),N=C.getAttribute("data-nodeid"),A=C.getAttribute("data-handleid"),R=C.classList.contains("connectable"),_=C.classList.contains("connectableend");if(!N||!M)return E;const Y={source:p?N:l,sourceHandle:p?A:i,target:p?l:N,targetHandle:p?i:A};E.connection=Y;const X=R&&_&&(s===Di.Strict?p&&M==="source"||!p&&M==="target":N!==l||A!==i);E.isValid=X&&f(Y),E.toHandle=wN(N,M,A,x,s,!0)}return E}const px={onPointerDown:YO,isValid:SN};function GO({domNode:e,panZoom:n,getTransform:s,getViewScale:l}){const i=ts(e);function c({translateExtent:u,width:h,height:f,zoomStep:x=1,pannable:p=!0,zoomable:g=!0,inversePan:b=!1}){const w=N=>{if(N.sourceEvent.type!=="wheel"||!n)return;const A=s(),R=N.sourceEvent.ctrlKey&&oc()?10:1,_=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*x,Y=A[2]*Math.pow(2,_*R);n.scaleTo(Y)};let k=[0,0];const C=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(k=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},E=N=>{const A=s();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!n)return;const R=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],_=[R[0]-k[0],R[1]-k[1]];k=R;const Y=l()*Math.max(A[2],Math.log(A[2]))*(b?-1:1),q={x:A[0]-_[0]*Y,y:A[1]-_[1]*Y},X=[[0,0],[h,f]];n.setViewportConstrained({x:q.x,y:q.y,zoom:A[2]},X,u)},M=Jw().on("start",C).on("zoom",p?E:null).on("zoom.wheel",g?w:null);i.call(M,{})}function d(){i.on("zoom",null)}return{update:c,destroy:d,pointer:Cs}}const Iu=e=>({x:e.x,y:e.y,zoom:e.k}),wh=({x:e,y:n,zoom:s})=>Ou.translate(e,n).scale(s),Ci=(e,n)=>e.target.closest(`.${n}`),CN=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),XO=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Nh=(e,n=0,s=XO,l=()=>{})=>{const i=typeof n=="number"&&n>0;return i||l(),i?e.transition().duration(n).ease(s).on("end",l):e},EN=e=>{const n=e.ctrlKey&&oc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function KO({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:l,panOnScrollMode:i,panOnScrollSpeed:c,zoomOnPinch:d,onPanZoomStart:u,onPanZoom:h,onPanZoomEnd:f}){return x=>{if(Ci(x,n))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const p=s.property("__zoom").k||1;if(x.ctrlKey&&d){const C=Cs(x),E=EN(x),M=p*Math.pow(2,E);l.scaleTo(s,M,C,x);return}const g=x.deltaMode===1?20:1;let b=i===Rl.Vertical?0:x.deltaX*g,w=i===Rl.Horizontal?0:x.deltaY*g;!oc()&&x.shiftKey&&i!==Rl.Vertical&&(b=x.deltaY*g,w=0),l.translateBy(s,-(b/p)*c,-(w/p)*c,{internal:!0});const k=Iu(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(h?.(x,k),e.panScrollTimeout=setTimeout(()=>{f?.(x,k),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,u?.(x,k))}}function WO({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:s}){return function(l,i){const c=l.type==="wheel",d=!n&&c&&!l.ctrlKey,u=Ci(l,e);if(l.ctrlKey&&c&&u&&l.preventDefault(),d||u)return null;l.preventDefault(),s.call(this,l,i)}}function ZO({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return l=>{if(l.sourceEvent?.internal)return;const i=Iu(l.transform);e.mouseButton=l.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,l.sourceEvent?.type==="mousedown"&&n(!0),s&&s?.(l.sourceEvent,i)}}function QO({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:l,onPanZoom:i}){return c=>{e.usedRightMouseButton=!!(s&&CN(n,e.mouseButton??0)),c.sourceEvent?.sync||l([c.transform.x,c.transform.y,c.transform.k]),i&&!c.sourceEvent?.internal&&i?.(c.sourceEvent,Iu(c.transform))}}function JO({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:l,onPanZoomEnd:i,onPaneContextMenu:c}){return d=>{if(!d.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,c&&CN(n,e.mouseButton??0)&&!e.usedRightMouseButton&&d.sourceEvent&&c(d.sourceEvent),e.usedRightMouseButton=!1,l(!1),i)){const u=Iu(d.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(d.sourceEvent,u)},s?150:0)}}}function eD({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:l,panOnScroll:i,zoomOnDoubleClick:c,userSelectionActive:d,noWheelClassName:u,noPanClassName:h,lib:f,connectionInProgress:x}){return p=>{const g=e||n,b=s&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(Ci(p,`${f}-flow__node`)||Ci(p,`${f}-flow__edge`)))return!0;if(!l&&!g&&!i&&!c&&!s||d||x&&!w||Ci(p,u)&&w||Ci(p,h)&&(!w||i&&w&&!e)||!s&&p.ctrlKey&&w)return!1;if(!s&&p.type==="touchstart"&&p.touches?.length>1)return p.preventDefault(),!1;if(!g&&!i&&!b&&w||!l&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(l)&&!l.includes(p.button)&&p.type==="mousedown")return!1;const k=Array.isArray(l)&&l.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&k}}function tD({domNode:e,minZoom:n,maxZoom:s,translateExtent:l,viewport:i,onPanZoom:c,onPanZoomStart:d,onPanZoomEnd:u,onDraggingChange:h}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=e.getBoundingClientRect(),p=Jw().scaleExtent([n,s]).translateExtent(l),g=ts(e).call(p);M({x:i.x,y:i.y,zoom:Ii(i.zoom,n,s)},[[0,0],[x.width,x.height]],l);const b=g.on("wheel.zoom"),w=g.on("dblclick.zoom");p.wheelDelta(EN);function k(P,G){return g?new Promise($=>{p?.interpolate(G?.interpolate==="linear"?Xo:Xd).transform(Nh(g,G?.duration,G?.ease,()=>$(!0)),P)}):Promise.resolve(!1)}function C({noWheelClassName:P,noPanClassName:G,onPaneContextMenu:$,userSelectionActive:T,panOnScroll:z,panOnDrag:O,panOnScrollMode:V,panOnScrollSpeed:H,preventScrolling:Z,zoomOnPinch:B,zoomOnScroll:F,zoomOnDoubleClick:K,zoomActivationKeyPressed:I,lib:S,onTransformChange:D,connectionInProgress:W,paneClickDistance:J,selectionOnDrag:te}){T&&!f.isZoomingOrPanning&&E();const re=z&&!I&&!T;p.clickDistance(te?1/0:!Ts(J)||J<0?0:J);const oe=re?KO({zoomPanValues:f,noWheelClassName:P,d3Selection:g,d3Zoom:p,panOnScrollMode:V,panOnScrollSpeed:H,zoomOnPinch:B,onPanZoomStart:d,onPanZoom:c,onPanZoomEnd:u}):WO({noWheelClassName:P,preventScrolling:Z,d3ZoomHandler:b});if(g.on("wheel.zoom",oe,{passive:!1}),!T){const Oe=ZO({zoomPanValues:f,onDraggingChange:h,onPanZoomStart:d});p.on("start",Oe);const ve=QO({zoomPanValues:f,panOnDrag:O,onPaneContextMenu:!!$,onPanZoom:c,onTransformChange:D});p.on("zoom",ve);const ke=JO({zoomPanValues:f,panOnDrag:O,panOnScroll:z,onPaneContextMenu:$,onPanZoomEnd:u,onDraggingChange:h});p.on("end",ke)}const me=eD({zoomActivationKeyPressed:I,panOnDrag:O,zoomOnScroll:F,panOnScroll:z,zoomOnDoubleClick:K,zoomOnPinch:B,userSelectionActive:T,noPanClassName:G,noWheelClassName:P,lib:S,connectionInProgress:W});p.filter(me),K?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function E(){p.on("zoom",null)}async function M(P,G,$){const T=wh(P),z=p?.constrain()(T,G,$);return z&&await k(z),new Promise(O=>O(z))}async function N(P,G){const $=wh(P);return await k($,G),new Promise(T=>T($))}function A(P){if(g){const G=wh(P),$=g.property("__zoom");($.k!==P.zoom||$.x!==P.x||$.y!==P.y)&&p?.transform(g,G,null,{sync:!0})}}function R(){const P=g?Qw(g.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}function _(P,G){return g?new Promise($=>{p?.interpolate(G?.interpolate==="linear"?Xo:Xd).scaleTo(Nh(g,G?.duration,G?.ease,()=>$(!0)),P)}):Promise.resolve(!1)}function Y(P,G){return g?new Promise($=>{p?.interpolate(G?.interpolate==="linear"?Xo:Xd).scaleBy(Nh(g,G?.duration,G?.ease,()=>$(!0)),P)}):Promise.resolve(!1)}function q(P){p?.scaleExtent(P)}function X(P){p?.translateExtent(P)}function L(P){const G=!Ts(P)||P<0?0:P;p?.clickDistance(G)}return{update:C,destroy:E,setViewport:N,setViewportConstrained:M,getViewport:R,scaleTo:_,scaleBy:Y,setScaleExtent:q,setTranslateExtent:X,syncViewport:A,setClickDistance:L}}var Bi;(function(e){e.Line="line",e.Handle="handle"})(Bi||(Bi={}));function nD({width:e,prevWidth:n,height:s,prevHeight:l,affectsX:i,affectsY:c}){const d=e-n,u=s-l,h=[d>0?1:d<0?-1:0,u>0?1:u<0?-1:0];return d&&i&&(h[0]=h[0]*-1),u&&c&&(h[1]=h[1]*-1),h}function Zv(e){const n=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),l=e.includes("left"),i=e.includes("top");return{isHorizontal:n,isVertical:s,affectsX:l,affectsY:i}}function Ja(e,n){return Math.max(0,n-e)}function el(e,n){return Math.max(0,e-n)}function Id(e,n,s){return Math.max(0,n-e,e-s)}function Qv(e,n){return e?!n:n}function rD(e,n,s,l,i,c,d,u){let{affectsX:h,affectsY:f}=n;const{isHorizontal:x,isVertical:p}=n,g=x&&p,{xSnapped:b,ySnapped:w}=s,{minWidth:k,maxWidth:C,minHeight:E,maxHeight:M}=l,{x:N,y:A,width:R,height:_,aspectRatio:Y}=e;let q=Math.floor(x?b-e.pointerX:0),X=Math.floor(p?w-e.pointerY:0);const L=R+(h?-q:q),P=_+(f?-X:X),G=-c[0]*R,$=-c[1]*_;let T=Id(L,k,C),z=Id(P,E,M);if(d){let H=0,Z=0;h&&q<0?H=Ja(N+q+G,d[0][0]):!h&&q>0&&(H=el(N+L+G,d[1][0])),f&&X<0?Z=Ja(A+X+$,d[0][1]):!f&&X>0&&(Z=el(A+P+$,d[1][1])),T=Math.max(T,H),z=Math.max(z,Z)}if(u){let H=0,Z=0;h&&q>0?H=el(N+q,u[0][0]):!h&&q<0&&(H=Ja(N+L,u[1][0])),f&&X>0?Z=el(A+X,u[0][1]):!f&&X<0&&(Z=Ja(A+P,u[1][1])),T=Math.max(T,H),z=Math.max(z,Z)}if(i){if(x){const H=Id(L/Y,E,M)*Y;if(T=Math.max(T,H),d){let Z=0;!h&&!f||h&&!f&&g?Z=el(A+$+L/Y,d[1][1])*Y:Z=Ja(A+$+(h?q:-q)/Y,d[0][1])*Y,T=Math.max(T,Z)}if(u){let Z=0;!h&&!f||h&&!f&&g?Z=Ja(A+L/Y,u[1][1])*Y:Z=el(A+(h?q:-q)/Y,u[0][1])*Y,T=Math.max(T,Z)}}if(p){const H=Id(P*Y,k,C)/Y;if(z=Math.max(z,H),d){let Z=0;!h&&!f||f&&!h&&g?Z=el(N+P*Y+G,d[1][0])/Y:Z=Ja(N+(f?X:-X)*Y+G,d[0][0])/Y,z=Math.max(z,Z)}if(u){let Z=0;!h&&!f||f&&!h&&g?Z=Ja(N+P*Y,u[1][0])/Y:Z=el(N+(f?X:-X)*Y,u[0][0])/Y,z=Math.max(z,Z)}}}X=X+(X<0?z:-z),q=q+(q<0?T:-T),i&&(g?L>P*Y?X=(Qv(h,f)?-q:q)/Y:q=(Qv(h,f)?-X:X)*Y:x?(X=q/Y,f=h):(q=X*Y,h=f));const O=h?N+q:N,V=f?A+X:A;return{width:R+(h?-q:q),height:_+(f?-X:X),x:c[0]*q*(h?-1:1)+O,y:c[1]*X*(f?-1:1)+V}}const TN={width:0,height:0,x:0,y:0},sD={...TN,pointerX:0,pointerY:0,aspectRatio:1};function aD(e){return[[0,0],[e.measured.width,e.measured.height]]}function lD(e,n,s){const l=n.position.x+e.position.x,i=n.position.y+e.position.y,c=e.measured.width??0,d=e.measured.height??0,u=s[0]*c,h=s[1]*d;return[[l-u,i-h],[l+c-u,i+d-h]]}function iD({domNode:e,nodeId:n,getStoreItems:s,onChange:l,onEnd:i}){const c=ts(e);let d={controlDirection:Zv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function u({controlPosition:f,boundaries:x,keepAspectRatio:p,resizeDirection:g,onResizeStart:b,onResize:w,onResizeEnd:k,shouldResize:C}){let E={...TN},M={...sD};d={boundaries:x,resizeDirection:g,keepAspectRatio:p,controlDirection:Zv(f)};let N,A=null,R=[],_,Y,q,X=!1;const L=$w().on("start",P=>{const{nodeLookup:G,transform:$,snapGrid:T,snapToGrid:z,nodeOrigin:O,paneDomNode:V}=s();if(N=G.get(n),!N)return;A=V?.getBoundingClientRect()??null;const{xSnapped:H,ySnapped:Z}=Ko(P.sourceEvent,{transform:$,snapGrid:T,snapToGrid:z,containerBounds:A});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},M={...E,pointerX:H,pointerY:Z,aspectRatio:E.width/E.height},_=void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(_=G.get(N.parentId),Y=_&&N.extent==="parent"?aD(_):void 0),R=[],q=void 0;for(const[B,F]of G)if(F.parentId===n&&(R.push({id:B,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const K=lD(F,N,F.origin??O);q?q=[[Math.min(K[0][0],q[0][0]),Math.min(K[0][1],q[0][1])],[Math.max(K[1][0],q[1][0]),Math.max(K[1][1],q[1][1])]]:q=K}b?.(P,{...E})}).on("drag",P=>{const{transform:G,snapGrid:$,snapToGrid:T,nodeOrigin:z}=s(),O=Ko(P.sourceEvent,{transform:G,snapGrid:$,snapToGrid:T,containerBounds:A}),V=[];if(!N)return;const{x:H,y:Z,width:B,height:F}=E,K={},I=N.origin??z,{width:S,height:D,x:W,y:J}=rD(M,d.controlDirection,O,d.boundaries,d.keepAspectRatio,I,Y,q),te=S!==B,re=D!==F,oe=W!==H&&te,me=J!==Z&&re;if(!oe&&!me&&!te&&!re)return;if((oe||me||I[0]===1||I[1]===1)&&(K.x=oe?W:E.x,K.y=me?J:E.y,E.x=K.x,E.y=K.y,R.length>0)){const Ee=W-H,Me=J-Z;for(const dt of R)dt.position={x:dt.position.x-Ee+I[0]*(S-B),y:dt.position.y-Me+I[1]*(D-F)},V.push(dt)}if((te||re)&&(K.width=te&&(!d.resizeDirection||d.resizeDirection==="horizontal")?S:E.width,K.height=re&&(!d.resizeDirection||d.resizeDirection==="vertical")?D:E.height,E.width=K.width,E.height=K.height),_&&N.expandParent){const Ee=I[0]*(K.width??0);K.x&&K.x<Ee&&(E.x=Ee,M.x=M.x-(K.x-Ee));const Me=I[1]*(K.height??0);K.y&&K.y<Me&&(E.y=Me,M.y=M.y-(K.y-Me))}const Oe=nD({width:E.width,prevWidth:B,height:E.height,prevHeight:F,affectsX:d.controlDirection.affectsX,affectsY:d.controlDirection.affectsY}),ve={...E,direction:Oe};C?.(P,ve)!==!1&&(X=!0,w?.(P,ve),l(K,V))}).on("end",P=>{X&&(k?.(P,{...E}),i?.({...E}),X=!1)});c.call(L)}function h(){c.on(".drag",null)}return{update:u,destroy:h}}var kh={exports:{}},Sh={},Ch={exports:{}},Eh={};var Jv;function oD(){if(Jv)return Eh;Jv=1;var e=uc();function n(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var s=typeof Object.is=="function"?Object.is:n,l=e.useState,i=e.useEffect,c=e.useLayoutEffect,d=e.useDebugValue;function u(p,g){var b=g(),w=l({inst:{value:b,getSnapshot:g}}),k=w[0].inst,C=w[1];return c(function(){k.value=b,k.getSnapshot=g,h(k)&&C({inst:k})},[p,b,g]),i(function(){return h(k)&&C({inst:k}),p(function(){h(k)&&C({inst:k})})},[p]),d(b),b}function h(p){var g=p.getSnapshot;p=p.value;try{var b=g();return!s(p,b)}catch{return!0}}function f(p,g){return g()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return Eh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,Eh}var e1;function cD(){return e1||(e1=1,Ch.exports=oD()),Ch.exports}var t1;function dD(){if(t1)return Sh;t1=1;var e=uc(),n=cD();function s(f,x){return f===x&&(f!==0||1/f===1/x)||f!==f&&x!==x}var l=typeof Object.is=="function"?Object.is:s,i=n.useSyncExternalStore,c=e.useRef,d=e.useEffect,u=e.useMemo,h=e.useDebugValue;return Sh.useSyncExternalStoreWithSelector=function(f,x,p,g,b){var w=c(null);if(w.current===null){var k={hasValue:!1,value:null};w.current=k}else k=w.current;w=u(function(){function E(_){if(!M){if(M=!0,N=_,_=g(_),b!==void 0&&k.hasValue){var Y=k.value;if(b(Y,_))return A=Y}return A=_}if(Y=A,l(N,_))return Y;var q=g(_);return b!==void 0&&b(Y,q)?(N=_,Y):(N=_,A=q)}var M=!1,N,A,R=p===void 0?null:p;return[function(){return E(x())},R===null?void 0:function(){return E(R())}]},[x,p,g,b]);var C=i(f,w[0],w[1]);return d(function(){k.hasValue=!0,k.value=C},[C]),h(C),C},Sh}var n1;function uD(){return n1||(n1=1,kh.exports=dD()),kh.exports}var fD=uD();const mD=yu(fD),hD={},r1=e=>{let n;const s=new Set,l=(x,p)=>{const g=typeof x=="function"?x(n):x;if(!Object.is(g,n)){const b=n;n=p??(typeof g!="object"||g===null)?g:Object.assign({},n,g),s.forEach(w=>w(n,b))}},i=()=>n,h={setState:l,getState:i,getInitialState:()=>f,subscribe:x=>(s.add(x),()=>s.delete(x)),destroy:()=>{(hD?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),s.clear()}},f=n=e(l,i,h);return h},xD=e=>e?r1(e):r1,{useDebugValue:pD}=dk,{useSyncExternalStoreWithSelector:gD}=mD,bD=e=>e;function AN(e,n=bD,s){const l=gD(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return pD(l),l}const s1=(e,n)=>{const s=xD(e),l=(i,c=n)=>AN(s,i,c);return Object.assign(l,s),l},yD=(e,n)=>e?s1(e,n):s1;function In(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[l,i]of e)if(!Object.is(i,n.get(l)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const l of e)if(!n.has(l))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(n).length)return!1;for(const l of s)if(!Object.prototype.hasOwnProperty.call(n,l)||!Object.is(e[l],n[l]))return!1;return!0}const zu=y.createContext(null),vD=zu.Provider,_N=Xs.error001();function rn(e,n){const s=y.useContext(zu);if(s===null)throw new Error(_N);return AN(s,e,n)}function zn(){const e=y.useContext(zu);if(e===null)throw new Error(_N);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const a1={display:"none"},jD={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},MN="react-flow__node-desc",RN="react-flow__edge-desc",wD="react-flow__aria-live",ND=e=>e.ariaLiveMessage,kD=e=>e.ariaLabelConfig;function SD({rfId:e}){const n=rn(ND);return t.jsx("div",{id:`${wD}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:jD,children:n})}function CD({rfId:e,disableKeyboardA11y:n}){const s=rn(kD);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${MN}-${e}`,style:a1,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${RN}-${e}`,style:a1,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(SD,{rfId:e})]})}const $u=y.forwardRef(({position:e="top-left",children:n,className:s,style:l,...i},c)=>{const d=`${e}`.split("-");return t.jsx("div",{className:rr(["react-flow__panel",s,...d]),style:l,ref:c,...i,children:n})});$u.displayName="Panel";function ED({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx($u,{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 TD=e=>{const n=[],s=[];for(const[,l]of e.nodeLookup)l.selected&&n.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&s.push(l);return{selectedNodes:n,selectedEdges:s}},zd=e=>e.id;function AD(e,n){return In(e.selectedNodes.map(zd),n.selectedNodes.map(zd))&&In(e.selectedEdges.map(zd),n.selectedEdges.map(zd))}function _D({onSelectionChange:e}){const n=zn(),{selectedNodes:s,selectedEdges:l}=rn(TD,AD);return y.useEffect(()=>{const i={nodes:s,edges:l};e?.(i),n.getState().onSelectionChangeHandlers.forEach(c=>c(i))},[s,l,e]),null}const MD=e=>!!e.onSelectionChangeHandlers;function RD({onSelectionChange:e}){const n=rn(MD);return e||n?t.jsx(_D,{onSelectionChange:e}):null}const ON=[0,0],OD={x:0,y:0,zoom:1},DD=["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"],l1=[...DD,"rfId"],LD=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}),i1={translateExtent:ac,nodeOrigin:ON,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ID(e){const{setNodes:n,setEdges:s,setMinZoom:l,setMaxZoom:i,setTranslateExtent:c,setNodeExtent:d,reset:u,setDefaultNodesAndEdges:h}=rn(LD,In),f=zn();y.useEffect(()=>(h(e.defaultNodes,e.defaultEdges),()=>{x.current=i1,u()}),[]);const x=y.useRef(i1);return y.useEffect(()=>{for(const p of l1){const g=e[p],b=x.current[p];g!==b&&(typeof e[p]>"u"||(p==="nodes"?n(g):p==="edges"?s(g):p==="minZoom"?l(g):p==="maxZoom"?i(g):p==="translateExtent"?c(g):p==="nodeExtent"?d(g):p==="ariaLabelConfig"?f.setState({ariaLabelConfig:yO(g)}):p==="fitView"?f.setState({fitViewQueued:g}):p==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[p]:g})))}x.current=e},l1.map(p=>e[p])),null}function o1(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function zD(e){const[n,s]=y.useState(e==="system"?null:e);return y.useEffect(()=>{if(e!=="system"){s(e);return}const l=o1(),i=()=>s(l?.matches?"dark":"light");return i(),l?.addEventListener("change",i),()=>{l?.removeEventListener("change",i)}},[e]),n!==null?n:o1()?.matches?"dark":"light"}const c1=typeof document<"u"?document:null;function cc(e=null,n={target:c1,actInsideInputWithModifier:!0}){const[s,l]=y.useState(!1),i=y.useRef(!1),c=y.useRef(new Set([])),[d,u]=y.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
59
|
+
`).replace(`
|
|
60
|
+
|
|
61
|
+
`,`
|
|
62
|
+
+`).split(`
|
|
63
|
+
`)),x=f.reduce((p,g)=>p.concat(...g),[]);return[f,x]}return[[],[]]},[e]);return y.useEffect(()=>{const h=n?.target??c1,f=n?.actInsideInputWithModifier??!0;if(e!==null){const x=b=>{if(i.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!i.current||i.current&&!f)&&fN(b))return!1;const k=u1(b.code,u);if(c.current.add(b[k]),d1(d,c.current,!1)){const C=b.composedPath?.()?.[0]||b.target,E=C?.nodeName==="BUTTON"||C?.nodeName==="A";n.preventDefault!==!1&&(i.current||!E)&&b.preventDefault(),l(!0)}},p=b=>{const w=u1(b.code,u);d1(d,c.current,!0)?(l(!1),c.current.clear()):c.current.delete(b[w]),b.key==="Meta"&&c.current.clear(),i.current=!1},g=()=>{c.current.clear(),l(!1)};return h?.addEventListener("keydown",x),h?.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{h?.removeEventListener("keydown",x),h?.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,l]),s}function d1(e,n,s){return e.filter(l=>s||l.length===n.size).some(l=>l.every(i=>n.has(i)))}function u1(e,n){return n.includes(e)?"code":"key"}const $D=()=>{const e=zn();return y.useMemo(()=>({zoomIn:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomOut:n=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1/1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomTo:(n,s)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(n,{duration:s?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,s)=>{const{transform:[l,i,c],panZoom:d}=e.getState();return d?(await d.setViewport({x:n.x??l,y:n.y??i,zoom:n.zoom??c},s),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,s,l]=e.getState().transform;return{x:n,y:s,zoom:l}},setCenter:async(n,s,l)=>e.getState().setCenter(n,s,l),fitBounds:async(n,s)=>{const{width:l,height:i,minZoom:c,maxZoom:d,panZoom:u}=e.getState(),h=rp(n,l,i,c,d,s?.padding??.1);return u?(await u.setViewport(h,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(n,s={})=>{const{transform:l,snapGrid:i,snapToGrid:c,domNode:d}=e.getState();if(!d)return n;const{x:u,y:h}=d.getBoundingClientRect(),f={x:n.x-u,y:n.y-h},x=s.snapGrid??i,p=s.snapToGrid??c;return vc(f,l,p,x)},flowToScreenPosition:n=>{const{transform:s,domNode:l}=e.getState();if(!l)return n;const{x:i,y:c}=l.getBoundingClientRect(),d=pu(n,s);return{x:d.x+i,y:d.y+c}}}),[])};function DN(e,n){const s=[],l=new Map,i=[];for(const c of e)if(c.type==="add"){i.push(c);continue}else if(c.type==="remove"||c.type==="replace")l.set(c.id,[c]);else{const d=l.get(c.id);d?d.push(c):l.set(c.id,[c])}for(const c of n){const d=l.get(c.id);if(!d){s.push(c);continue}if(d[0].type==="remove")continue;if(d[0].type==="replace"){s.push({...d[0].item});continue}const u={...c};for(const h of d)BD(h,u);s.push(u)}return i.length&&i.forEach(c=>{c.index!==void 0?s.splice(c.index,0,{...c.item}):s.push({...c.item})}),s}function BD(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 LN(e,n){return DN(e,n)}function IN(e,n){return DN(e,n)}function El(e,n){return{id:e,type:"select",selected:n}}function Ei(e,n=new Set,s=!1){const l=[];for(const[i,c]of e){const d=n.has(i);!(c.selected===void 0&&!d)&&c.selected!==d&&(s&&(c.selected=d),l.push(El(c.id,d)))}return l}function f1({items:e=[],lookup:n}){const s=[],l=new Map(e.map(i=>[i.id,i]));for(const[i,c]of e.entries()){const d=n.get(c.id),u=d?.internals?.userNode??d;u!==void 0&&u!==c&&s.push({id:c.id,item:c,type:"replace"}),u===void 0&&s.push({item:c,type:"add",index:i})}for(const[i]of n)l.get(i)===void 0&&s.push({id:i,type:"remove"});return s}function m1(e){return{id:e.id,type:"remove"}}const h1=e=>cO(e),HD=e=>sN(e);function zN(e){return y.forwardRef(e)}const PD=typeof window<"u"?y.useLayoutEffect:y.useEffect;function x1(e){const[n,s]=y.useState(BigInt(0)),[l]=y.useState(()=>UD(()=>s(i=>i+BigInt(1))));return PD(()=>{const i=l.get();i.length&&(e(i),l.reset())},[n]),l}function UD(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:s=>{n.push(s),e()}}}const $N=y.createContext(null);function qD({children:e}){const n=zn(),s=y.useCallback(u=>{const{nodes:h=[],setNodes:f,hasDefaultNodes:x,onNodesChange:p,nodeLookup:g,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=n.getState();let k=h;for(const E of u)k=typeof E=="function"?E(k):E;let C=f1({items:k,lookup:g});for(const E of w.values())C=E(C);x&&f(k),C.length>0?p?.(C):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:M,setNodes:N}=n.getState();E&&N(M)})},[]),l=x1(s),i=y.useCallback(u=>{const{edges:h=[],setEdges:f,hasDefaultEdges:x,onEdgesChange:p,edgeLookup:g}=n.getState();let b=h;for(const w of u)b=typeof w=="function"?w(b):w;x?f(b):p&&p(f1({items:b,lookup:g}))},[]),c=x1(i),d=y.useMemo(()=>({nodeQueue:l,edgeQueue:c}),[]);return t.jsx($N.Provider,{value:d,children:e})}function FD(){const e=y.useContext($N);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const VD=e=>!!e.panZoom;function dp(){const e=$D(),n=zn(),s=FD(),l=rn(VD),i=y.useMemo(()=>{const c=p=>n.getState().nodeLookup.get(p),d=p=>{s.nodeQueue.push(p)},u=p=>{s.edgeQueue.push(p)},h=p=>{const{nodeLookup:g,nodeOrigin:b}=n.getState(),w=h1(p)?p:g.get(p.id),k=w.parentId?dN(w.position,w.measured,w.parentId,g,b):w.position,C={...w,position:k,width:w.measured?.width??w.width,height:w.measured?.height??w.height};return zi(C)},f=(p,g,b={replace:!1})=>{d(w=>w.map(k=>{if(k.id===p){const C=typeof g=="function"?g(k):g;return b.replace&&h1(C)?C:{...k,...C}}return k}))},x=(p,g,b={replace:!1})=>{u(w=>w.map(k=>{if(k.id===p){const C=typeof g=="function"?g(k):g;return b.replace&&HD(C)?C:{...k,...C}}return k}))};return{getNodes:()=>n.getState().nodes.map(p=>({...p})),getNode:p=>c(p)?.internals.userNode,getInternalNode:c,getEdges:()=>{const{edges:p=[]}=n.getState();return p.map(g=>({...g}))},getEdge:p=>n.getState().edgeLookup.get(p),setNodes:d,setEdges:u,addNodes:p=>{const g=Array.isArray(p)?p:[p];s.nodeQueue.push(b=>[...b,...g])},addEdges:p=>{const g=Array.isArray(p)?p:[p];s.edgeQueue.push(b=>[...b,...g])},toObject:()=>{const{nodes:p=[],edges:g=[],transform:b}=n.getState(),[w,k,C]=b;return{nodes:p.map(E=>({...E})),edges:g.map(E=>({...E})),viewport:{x:w,y:k,zoom:C}}},deleteElements:async({nodes:p=[],edges:g=[]})=>{const{nodes:b,edges:w,onNodesDelete:k,onEdgesDelete:C,triggerNodeChanges:E,triggerEdgeChanges:M,onDelete:N,onBeforeDelete:A}=n.getState(),{nodes:R,edges:_}=await hO({nodesToRemove:p,edgesToRemove:g,nodes:b,edges:w,onBeforeDelete:A}),Y=_.length>0,q=R.length>0;if(Y){const X=_.map(m1);C?.(_),M(X)}if(q){const X=R.map(m1);k?.(R),E(X)}return(q||Y)&&N?.({nodes:R,edges:_}),{deletedNodes:R,deletedEdges:_}},getIntersectingNodes:(p,g=!0,b)=>{const w=Hv(p),k=w?p:h(p),C=b!==void 0;return k?(b||n.getState().nodes).filter(E=>{const M=n.getState().nodeLookup.get(E.id);if(M&&!w&&(E.id===p.id||!M.internals.positionAbsolute))return!1;const N=zi(C?E:M),A=ic(N,k);return g&&A>0||A>=N.width*N.height||A>=k.width*k.height}):[]},isNodeIntersecting:(p,g,b=!0)=>{const k=Hv(p)?p:h(p);if(!k)return!1;const C=ic(k,g);return b&&C>0||C>=g.width*g.height||C>=k.width*k.height},updateNode:f,updateNodeData:(p,g,b={replace:!1})=>{f(p,w=>{const k=typeof g=="function"?g(w):g;return b.replace?{...w,data:k}:{...w,data:{...w.data,...k}}},b)},updateEdge:x,updateEdgeData:(p,g,b={replace:!1})=>{x(p,w=>{const k=typeof g=="function"?g(w):g;return b.replace?{...w,data:k}:{...w,data:{...w.data,...k}}},b)},getNodesBounds:p=>{const{nodeLookup:g,nodeOrigin:b}=n.getState();return dO(p,{nodeLookup:g,nodeOrigin:b})},getHandleConnections:({type:p,id:g,nodeId:b})=>Array.from(n.getState().connectionLookup.get(`${b}-${p}${g?`-${g}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:g,nodeId:b})=>Array.from(n.getState().connectionLookup.get(`${b}${p?g?`-${p}-${g}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{const g=n.getState().fitViewResolver??bO();return n.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:g}),s.nodeQueue.push(b=>[...b]),g.promise}}},[]);return y.useMemo(()=>({...i,...e,viewportInitialized:l}),[l])}const p1=e=>e.selected,YD=typeof window<"u"?window:void 0;function GD({deleteKeyCode:e,multiSelectionKeyCode:n}){const s=zn(),{deleteElements:l}=dp(),i=cc(e,{actInsideInputWithModifier:!1}),c=cc(n,{target:YD});y.useEffect(()=>{if(i){const{edges:d,nodes:u}=s.getState();l({nodes:u.filter(p1),edges:d.filter(p1)}),s.setState({nodesSelectionActive:!1})}},[i]),y.useEffect(()=>{s.setState({multiSelectionActive:c})},[c])}function XD(e){const n=zn();y.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const l=sp(e.current);(l.height===0||l.width===0)&&n.getState().onError?.("004",Xs.error004()),n.setState({width:l.width||500,height:l.height||500})};if(e.current){s(),window.addEventListener("resize",s);const l=new ResizeObserver(()=>s());return l.observe(e.current),()=>{window.removeEventListener("resize",s),l&&e.current&&l.unobserve(e.current)}}},[])}const Bu={position:"absolute",width:"100%",height:"100%",top:0,left:0},KD=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function WD({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:s=!0,panOnScroll:l=!1,panOnScrollSpeed:i=.5,panOnScrollMode:c=Rl.Free,zoomOnDoubleClick:d=!0,panOnDrag:u=!0,defaultViewport:h,translateExtent:f,minZoom:x,maxZoom:p,zoomActivationKeyCode:g,preventScrolling:b=!0,children:w,noWheelClassName:k,noPanClassName:C,onViewportChange:E,isControlledViewport:M,paneClickDistance:N,selectionOnDrag:A}){const R=zn(),_=y.useRef(null),{userSelectionActive:Y,lib:q,connectionInProgress:X}=rn(KD,In),L=cc(g),P=y.useRef();XD(_);const G=y.useCallback($=>{E?.({x:$[0],y:$[1],zoom:$[2]}),M||R.setState({transform:$})},[E,M]);return y.useEffect(()=>{if(_.current){P.current=tD({domNode:_.current,minZoom:x,maxZoom:p,translateExtent:f,viewport:h,onDraggingChange:O=>R.setState(V=>V.paneDragging===O?V:{paneDragging:O}),onPanZoomStart:(O,V)=>{const{onViewportChangeStart:H,onMoveStart:Z}=R.getState();Z?.(O,V),H?.(V)},onPanZoom:(O,V)=>{const{onViewportChange:H,onMove:Z}=R.getState();Z?.(O,V),H?.(V)},onPanZoomEnd:(O,V)=>{const{onViewportChangeEnd:H,onMoveEnd:Z}=R.getState();Z?.(O,V),H?.(V)}});const{x:$,y:T,zoom:z}=P.current.getViewport();return R.setState({panZoom:P.current,transform:[$,T,z],domNode:_.current.closest(".react-flow")}),()=>{P.current?.destroy()}}},[]),y.useEffect(()=>{P.current?.update({onPaneContextMenu:e,zoomOnScroll:n,zoomOnPinch:s,panOnScroll:l,panOnScrollSpeed:i,panOnScrollMode:c,zoomOnDoubleClick:d,panOnDrag:u,zoomActivationKeyPressed:L,preventScrolling:b,noPanClassName:C,userSelectionActive:Y,noWheelClassName:k,lib:q,onTransformChange:G,connectionInProgress:X,selectionOnDrag:A,paneClickDistance:N})},[e,n,s,l,i,c,d,u,L,b,C,Y,k,q,G,X,A,N]),t.jsx("div",{className:"react-flow__renderer",ref:_,style:Bu,children:w})}const ZD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function QD(){const{userSelectionActive:e,userSelectionRect:n}=rn(ZD,In);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 Th=(e,n)=>s=>{s.target===n.current&&e?.(s)},JD=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function eL({isSelecting:e,selectionKeyPressed:n,selectionMode:s=lc.Full,panOnDrag:l,paneClickDistance:i,selectionOnDrag:c,onSelectionStart:d,onSelectionEnd:u,onPaneClick:h,onPaneContextMenu:f,onPaneScroll:x,onPaneMouseEnter:p,onPaneMouseMove:g,onPaneMouseLeave:b,children:w}){const k=zn(),{userSelectionActive:C,elementsSelectable:E,dragging:M,connectionInProgress:N}=rn(JD,In),A=E&&(e||C),R=y.useRef(null),_=y.useRef(),Y=y.useRef(new Set),q=y.useRef(new Set),X=y.useRef(!1),L=H=>{if(X.current||N){X.current=!1;return}h?.(H),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},P=H=>{if(Array.isArray(l)&&l?.includes(2)){H.preventDefault();return}f?.(H)},G=x?H=>x(H):void 0,$=H=>{X.current&&(H.stopPropagation(),X.current=!1)},T=H=>{const{domNode:Z}=k.getState();if(_.current=Z?.getBoundingClientRect(),!_.current)return;const B=H.target===R.current;if(!B&&!!H.target.closest(".nokey")||!e||!(c&&B||n)||H.button!==0||!H.isPrimary)return;H.target?.setPointerCapture?.(H.pointerId),X.current=!1;const{x:I,y:S}=As(H.nativeEvent,_.current);k.setState({userSelectionRect:{width:0,height:0,startX:I,startY:S,x:I,y:S}}),B||(H.stopPropagation(),H.preventDefault())},z=H=>{const{userSelectionRect:Z,transform:B,nodeLookup:F,edgeLookup:K,connectionLookup:I,triggerNodeChanges:S,triggerEdgeChanges:D,defaultEdgeOptions:W,resetSelectedElements:J}=k.getState();if(!_.current||!Z)return;const{x:te,y:re}=As(H.nativeEvent,_.current),{startX:oe,startY:me}=Z;if(!X.current){const Me=n?0:i;if(Math.hypot(te-oe,re-me)<=Me)return;J(),d?.(H)}X.current=!0;const Oe={startX:oe,startY:me,x:te<oe?te:oe,y:re<me?re:me,width:Math.abs(te-oe),height:Math.abs(re-me)},ve=Y.current,ke=q.current;Y.current=new Set(np(F,Oe,B,s===lc.Partial,!0).map(Me=>Me.id)),q.current=new Set;const Ee=W?.selectable??!0;for(const Me of Y.current){const dt=I.get(Me);if(dt)for(const{edgeId:pt}of dt.values()){const et=K.get(pt);et&&(et.selectable??Ee)&&q.current.add(pt)}}if(!Pv(ve,Y.current)){const Me=Ei(F,Y.current,!0);S(Me)}if(!Pv(ke,q.current)){const Me=Ei(K,q.current);D(Me)}k.setState({userSelectionRect:Oe,userSelectionActive:!0,nodesSelectionActive:!1})},O=H=>{H.button===0&&(H.target?.releasePointerCapture?.(H.pointerId),!C&&H.target===R.current&&k.getState().userSelectionRect&&L?.(H),k.setState({userSelectionActive:!1,userSelectionRect:null}),X.current&&(u?.(H),k.setState({nodesSelectionActive:Y.current.size>0})))},V=l===!0||Array.isArray(l)&&l.includes(0);return t.jsxs("div",{className:rr(["react-flow__pane",{draggable:V,dragging:M,selection:e}]),onClick:A?void 0:Th(L,R),onContextMenu:Th(P,R),onWheel:Th(G,R),onPointerEnter:A?void 0:p,onPointerMove:A?z:g,onPointerUp:A?O:void 0,onPointerDownCapture:A?T:void 0,onClickCapture:A?$:void 0,onPointerLeave:b,ref:R,style:Bu,children:[w,t.jsx(QD,{})]})}function gx({id:e,store:n,unselect:s=!1,nodeRef:l}){const{addSelectedNodes:i,unselectNodesAndEdges:c,multiSelectionActive:d,nodeLookup:u,onError:h}=n.getState(),f=u.get(e);if(!f){h?.("012",Xs.error012(e));return}n.setState({nodesSelectionActive:!1}),f.selected?(s||f.selected&&d)&&(c({nodes:[f],edges:[]}),requestAnimationFrame(()=>l?.current?.blur())):i([e])}function BN({nodeRef:e,disabled:n=!1,noDragClassName:s,handleSelector:l,nodeId:i,isSelectable:c,nodeClickDistance:d}){const u=zn(),[h,f]=y.useState(!1),x=y.useRef();return y.useEffect(()=>{x.current=PO({getStoreItems:()=>u.getState(),onNodeMouseDown:p=>{gx({id:p,store:u,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),y.useEffect(()=>{if(!(n||!e.current||!x.current))return x.current.update({noDragClassName:s,handleSelector:l,domNode:e.current,isSelectable:c,nodeId:i,nodeClickDistance:d}),()=>{x.current?.destroy()}},[s,l,n,c,e,i,d]),h}const tL=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function HN(){const e=zn();return y.useCallback(s=>{const{nodeExtent:l,snapToGrid:i,snapGrid:c,nodesDraggable:d,onError:u,updateNodePositions:h,nodeLookup:f,nodeOrigin:x}=e.getState(),p=new Map,g=tL(d),b=i?c[0]:5,w=i?c[1]:5,k=s.direction.x*b*s.factor,C=s.direction.y*w*s.factor;for(const[,E]of f){if(!g(E))continue;let M={x:E.internals.positionAbsolute.x+k,y:E.internals.positionAbsolute.y+C};i&&(M=yc(M,c));const{position:N,positionAbsolute:A}=aN({nodeId:E.id,nextPosition:M,nodeLookup:f,nodeExtent:l,nodeOrigin:x,onError:u});E.position=N,E.internals.positionAbsolute=A,p.set(E.id,E)}h(p)},[])}const up=y.createContext(null),nL=up.Provider;up.Consumer;const PN=()=>y.useContext(up),rL=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),sL=(e,n,s)=>l=>{const{connectionClickStartHandle:i,connectionMode:c,connection:d}=l,{fromHandle:u,toHandle:h,isValid:f}=d,x=h?.nodeId===e&&h?.id===n&&h?.type===s;return{connectingFrom:u?.nodeId===e&&u?.id===n&&u?.type===s,connectingTo:x,clickConnecting:i?.nodeId===e&&i?.id===n&&i?.type===s,isPossibleEndHandle:c===Di.Strict?u?.type!==s:e!==u?.nodeId||n!==u?.id,connectionInProcess:!!u,clickConnectionInProcess:!!i,valid:x&&f}};function aL({type:e="source",position:n=mt.Top,isValidConnection:s,isConnectable:l=!0,isConnectableStart:i=!0,isConnectableEnd:c=!0,id:d,onConnect:u,children:h,className:f,onMouseDown:x,onTouchStart:p,...g},b){const w=d||null,k=e==="target",C=zn(),E=PN(),{connectOnClick:M,noPanClassName:N,rfId:A}=rn(rL,In),{connectingFrom:R,connectingTo:_,clickConnecting:Y,isPossibleEndHandle:q,connectionInProcess:X,clickConnectionInProcess:L,valid:P}=rn(sL(E,w,e),In);E||C.getState().onError?.("010",Xs.error010());const G=z=>{const{defaultEdgeOptions:O,onConnect:V,hasDefaultEdges:H}=C.getState(),Z={...O,...z};if(H){const{edges:B,setEdges:F}=C.getState();F(SO(Z,B))}V?.(Z),u?.(Z)},$=z=>{if(!E)return;const O=mN(z.nativeEvent);if(i&&(O&&z.button===0||!O)){const V=C.getState();px.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:V.autoPanOnConnect,connectionMode:V.connectionMode,connectionRadius:V.connectionRadius,domNode:V.domNode,nodeLookup:V.nodeLookup,lib:V.lib,isTarget:k,handleId:w,nodeId:E,flowId:V.rfId,panBy:V.panBy,cancelConnection:V.cancelConnection,onConnectStart:V.onConnectStart,onConnectEnd:(...H)=>C.getState().onConnectEnd?.(...H),updateConnection:V.updateConnection,onConnect:G,isValidConnection:s||((...H)=>C.getState().isValidConnection?.(...H)??!0),getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:V.autoPanSpeed,dragThreshold:V.connectionDragThreshold})}O?x?.(z):p?.(z)},T=z=>{const{onClickConnectStart:O,onClickConnectEnd:V,connectionClickStartHandle:H,connectionMode:Z,isValidConnection:B,lib:F,rfId:K,nodeLookup:I,connection:S}=C.getState();if(!E||!H&&!i)return;if(!H){O?.(z.nativeEvent,{nodeId:E,handleId:w,handleType:e}),C.setState({connectionClickStartHandle:{nodeId:E,type:e,id:w}});return}const D=uN(z.target),W=s||B,{connection:J,isValid:te}=px.isValid(z.nativeEvent,{handle:{nodeId:E,id:w,type:e},connectionMode:Z,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:W,flowId:K,doc:D,lib:F,nodeLookup:I});te&&J&&G(J);const re=structuredClone(S);delete re.inProgress,re.toPosition=re.toHandle?re.toHandle.position:null,V?.(z,re),C.setState({connectionClickStartHandle:null})};return t.jsx("div",{"data-handleid":w,"data-nodeid":E,"data-handlepos":n,"data-id":`${A}-${E}-${w}-${e}`,className:rr(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",N,f,{source:!k,target:k,connectable:l,connectablestart:i,connectableend:c,clickconnecting:Y,connectingfrom:R,connectingto:_,valid:P,connectionindicator:l&&(!X||q)&&(X||L?c:i)}]),onMouseDown:$,onTouchStart:$,onClick:M?T:void 0,ref:b,...g,children:h})}const al=y.memo(zN(aL));function lL({data:e,isConnectable:n,sourcePosition:s=mt.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx(al,{type:"source",position:s,isConnectable:n})]})}function iL({data:e,isConnectable:n,targetPosition:s=mt.Top,sourcePosition:l=mt.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(al,{type:"target",position:s,isConnectable:n}),e?.label,t.jsx(al,{type:"source",position:l,isConnectable:n})]})}function oL(){return null}function cL({data:e,isConnectable:n,targetPosition:s=mt.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(al,{type:"target",position:s,isConnectable:n}),e?.label]})}const gu={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},g1={input:lL,default:iL,output:cL,group:oL};function dL(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 uL=e=>{const{width:n,height:s,x:l,y:i}=bc(e.nodeLookup,{filter:c=>!!c.selected});return{width:Ts(n)?n:null,height:Ts(s)?s:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${i}px)`}};function fL({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:s}){const l=zn(),{width:i,height:c,transformString:d,userSelectionActive:u}=rn(uL,In),h=HN(),f=y.useRef(null);y.useEffect(()=>{s||f.current?.focus({preventScroll:!0})},[s]);const x=!u&&i!==null&&c!==null;if(BN({nodeRef:f,disabled:!x}),!x)return null;const p=e?b=>{const w=l.getState().nodes.filter(k=>k.selected);e(b,w)}:void 0,g=b=>{Object.prototype.hasOwnProperty.call(gu,b.key)&&(b.preventDefault(),h({direction:gu[b.key],factor:b.shiftKey?4:1}))};return t.jsx("div",{className:rr(["react-flow__nodesselection","react-flow__container",n]),style:{transform:d},children:t.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:s?void 0:-1,onKeyDown:s?void 0:g,style:{width:i,height:c}})})}const b1=typeof window<"u"?window:void 0,mL=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function UN({children:e,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:l,onPaneMouseLeave:i,onPaneContextMenu:c,onPaneScroll:d,paneClickDistance:u,deleteKeyCode:h,selectionKeyCode:f,selectionOnDrag:x,selectionMode:p,onSelectionStart:g,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:k,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:M,zoomOnPinch:N,panOnScroll:A,panOnScrollSpeed:R,panOnScrollMode:_,zoomOnDoubleClick:Y,panOnDrag:q,defaultViewport:X,translateExtent:L,minZoom:P,maxZoom:G,preventScrolling:$,onSelectionContextMenu:T,noWheelClassName:z,noPanClassName:O,disableKeyboardA11y:V,onViewportChange:H,isControlledViewport:Z}){const{nodesSelectionActive:B,userSelectionActive:F}=rn(mL,In),K=cc(f,{target:b1}),I=cc(k,{target:b1}),S=I||q,D=I||A,W=x&&S!==!0,J=K||F||W;return GD({deleteKeyCode:h,multiSelectionKeyCode:w}),t.jsx(WD,{onPaneContextMenu:c,elementsSelectable:E,zoomOnScroll:M,zoomOnPinch:N,panOnScroll:D,panOnScrollSpeed:R,panOnScrollMode:_,zoomOnDoubleClick:Y,panOnDrag:!K&&S,defaultViewport:X,translateExtent:L,minZoom:P,maxZoom:G,zoomActivationKeyCode:C,preventScrolling:$,noWheelClassName:z,noPanClassName:O,onViewportChange:H,isControlledViewport:Z,paneClickDistance:u,selectionOnDrag:W,children:t.jsxs(eL,{onSelectionStart:g,onSelectionEnd:b,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:l,onPaneMouseLeave:i,onPaneContextMenu:c,onPaneScroll:d,panOnDrag:S,isSelecting:!!J,selectionMode:p,selectionKeyPressed:K,paneClickDistance:u,selectionOnDrag:W,children:[e,B&&t.jsx(fL,{onSelectionContextMenu:T,noPanClassName:O,disableKeyboardA11y:V})]})})}UN.displayName="FlowRenderer";const hL=y.memo(UN),xL=e=>n=>e?np(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 pL(e){return rn(y.useCallback(xL(e),[e]),In)}const gL=e=>e.updateNodeInternals;function bL(){const e=rn(gL),[n]=y.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const l=new Map;s.forEach(i=>{const c=i.target.getAttribute("data-id");l.set(c,{id:c,nodeElement:i.target,force:!0})}),e(l)}));return y.useEffect(()=>()=>{n?.disconnect()},[n]),n}function yL({node:e,nodeType:n,hasDimensions:s,resizeObserver:l}){const i=zn(),c=y.useRef(null),d=y.useRef(null),u=y.useRef(e.sourcePosition),h=y.useRef(e.targetPosition),f=y.useRef(n),x=s&&!!e.internals.handleBounds;return y.useEffect(()=>{c.current&&!e.hidden&&(!x||d.current!==c.current)&&(d.current&&l?.unobserve(d.current),l?.observe(c.current),d.current=c.current)},[x,e.hidden]),y.useEffect(()=>()=>{d.current&&(l?.unobserve(d.current),d.current=null)},[]),y.useEffect(()=>{if(c.current){const p=f.current!==n,g=u.current!==e.sourcePosition,b=h.current!==e.targetPosition;(p||g||b)&&(f.current=n,u.current=e.sourcePosition,h.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:c.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),c}function vL({id:e,onClick:n,onMouseEnter:s,onMouseMove:l,onMouseLeave:i,onContextMenu:c,onDoubleClick:d,nodesDraggable:u,elementsSelectable:h,nodesConnectable:f,nodesFocusable:x,resizeObserver:p,noDragClassName:g,noPanClassName:b,disableKeyboardA11y:w,rfId:k,nodeTypes:C,nodeClickDistance:E,onError:M}){const{node:N,internals:A,isParent:R}=rn(te=>{const re=te.nodeLookup.get(e),oe=te.parentLookup.has(e);return{node:re,internals:re.internals,isParent:oe}},In);let _=N.type||"default",Y=C?.[_]||g1[_];Y===void 0&&(M?.("003",Xs.error003(_)),_="default",Y=C?.default||g1.default);const q=!!(N.draggable||u&&typeof N.draggable>"u"),X=!!(N.selectable||h&&typeof N.selectable>"u"),L=!!(N.connectable||f&&typeof N.connectable>"u"),P=!!(N.focusable||x&&typeof N.focusable>"u"),G=zn(),$=cN(N),T=yL({node:N,nodeType:_,hasDimensions:$,resizeObserver:p}),z=BN({nodeRef:T,disabled:N.hidden||!q,noDragClassName:g,handleSelector:N.dragHandle,nodeId:e,isSelectable:X,nodeClickDistance:E}),O=HN();if(N.hidden)return null;const V=Na(N),H=dL(N),Z=X||q||n||s||l||i,B=s?te=>s(te,{...A.userNode}):void 0,F=l?te=>l(te,{...A.userNode}):void 0,K=i?te=>i(te,{...A.userNode}):void 0,I=c?te=>c(te,{...A.userNode}):void 0,S=d?te=>d(te,{...A.userNode}):void 0,D=te=>{const{selectNodesOnDrag:re,nodeDragThreshold:oe}=G.getState();X&&(!re||!q||oe>0)&&gx({id:e,store:G,nodeRef:T}),n&&n(te,{...A.userNode})},W=te=>{if(!(fN(te.nativeEvent)||w)){if(eN.includes(te.key)&&X){const re=te.key==="Escape";gx({id:e,store:G,unselect:re,nodeRef:T})}else if(q&&N.selected&&Object.prototype.hasOwnProperty.call(gu,te.key)){te.preventDefault();const{ariaLabelConfig:re}=G.getState();G.setState({ariaLiveMessage:re["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),O({direction:gu[te.key],factor:te.shiftKey?4:1})}}},J=()=>{if(w||!T.current?.matches(":focus-visible"))return;const{transform:te,width:re,height:oe,autoPanOnNodeFocus:me,setCenter:Oe}=G.getState();if(!me)return;np(new Map([[e,N]]),{x:0,y:0,width:re,height:oe},te,!0).length>0||Oe(N.position.x+V.width/2,N.position.y+V.height/2,{zoom:te[2]})};return t.jsx("div",{className:rr(["react-flow__node",`react-flow__node-${_}`,{[b]:q},N.className,{selected:N.selected,selectable:X,parent:R,draggable:q,dragging:z}]),ref:T,style:{zIndex:A.z,transform:`translate(${A.positionAbsolute.x}px,${A.positionAbsolute.y}px)`,pointerEvents:Z?"all":"none",visibility:$?"visible":"hidden",...N.style,...H},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:F,onMouseLeave:K,onContextMenu:I,onClick:D,onDoubleClick:S,onKeyDown:P?W:void 0,tabIndex:P?0:void 0,onFocus:P?J:void 0,role:N.ariaRole??(P?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${MN}-${k}`,"aria-label":N.ariaLabel,...N.domAttributes,children:t.jsx(nL,{value:e,children:t.jsx(Y,{id:e,data:N.data,type:_,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.positionAbsolute.y,selected:N.selected??!1,selectable:X,draggable:q,deletable:N.deletable??!0,isConnectable:L,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:z,dragHandle:N.dragHandle,zIndex:A.z,parentId:N.parentId,...V})})})}var jL=y.memo(vL);const wL=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function qN(e){const{nodesDraggable:n,nodesConnectable:s,nodesFocusable:l,elementsSelectable:i,onError:c}=rn(wL,In),d=pL(e.onlyRenderVisibleElements),u=bL();return t.jsx("div",{className:"react-flow__nodes",style:Bu,children:d.map(h=>t.jsx(jL,{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:u,nodesDraggable:n,nodesConnectable:s,nodesFocusable:l,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:c},h))})}qN.displayName="NodeRenderer";const NL=y.memo(qN);function kL(e){return rn(y.useCallback(s=>{if(!e)return s.edges.map(i=>i.id);const l=[];if(s.width&&s.height)for(const i of s.edges){const c=s.nodeLookup.get(i.source),d=s.nodeLookup.get(i.target);c&&d&&wO({sourceNode:c,targetNode:d,width:s.width,height:s.height,transform:s.transform})&&l.push(i.id)}return l},[e]),In)}const SL=({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"})},CL=({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"})},y1={[Li.Arrow]:SL,[Li.ArrowClosed]:CL};function EL(e){const n=zn();return y.useMemo(()=>Object.prototype.hasOwnProperty.call(y1,e)?y1[e]:(n.getState().onError?.("009",Xs.error009(e)),null),[e])}const TL=({id:e,type:n,color:s,width:l=12.5,height:i=12.5,markerUnits:c="strokeWidth",strokeWidth:d,orient:u="auto-start-reverse"})=>{const h=EL(n);return h?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:u,refX:"0",refY:"0",children:t.jsx(h,{color:s,strokeWidth:d})}):null},FN=({defaultColor:e,rfId:n})=>{const s=rn(c=>c.edges),l=rn(c=>c.defaultEdgeOptions),i=y.useMemo(()=>_O(s,{id:n,defaultColor:e,defaultMarkerStart:l?.markerStart,defaultMarkerEnd:l?.markerEnd}),[s,l,n,e]);return i.length?t.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:t.jsx("defs",{children:i.map(c=>t.jsx(TL,{id:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,strokeWidth:c.strokeWidth,orient:c.orient},c.id))})}):null};FN.displayName="MarkerDefinitions";var AL=y.memo(FN);function VN({x:e,y:n,label:s,labelStyle:l,labelShowBg:i=!0,labelBgStyle:c,labelBgPadding:d=[2,4],labelBgBorderRadius:u=2,children:h,className:f,...x}){const[p,g]=y.useState({x:1,y:0,width:0,height:0}),b=rr(["react-flow__edge-textwrapper",f]),w=y.useRef(null);return y.useEffect(()=>{if(w.current){const k=w.current.getBBox();g({x:k.x,y:k.y,width:k.width,height:k.height})}},[s]),s?t.jsxs("g",{transform:`translate(${e-p.width/2} ${n-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...x,children:[i&&t.jsx("rect",{width:p.width+2*d[0],x:-d[0],y:-d[1],height:p.height+2*d[1],className:"react-flow__edge-textbg",style:c,rx:u,ry:u}),t.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:l,children:s}),h]}):null}VN.displayName="EdgeText";const _L=y.memo(VN);function Hu({path:e,labelX:n,labelY:s,label:l,labelStyle:i,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,interactionWidth:f=20,...x}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{...x,d:e,fill:"none",className:rr(["react-flow__edge-path",x.className])}),f?t.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,l&&Ts(n)&&Ts(s)?t.jsx(_L,{x:n,y:s,label:l,labelStyle:i,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h}):null]})}function v1({pos:e,x1:n,y1:s,x2:l,y2:i}){return e===mt.Left||e===mt.Right?[.5*(n+l),s]:[n,.5*(s+i)]}function YN({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:l,targetY:i,targetPosition:c=mt.Top}){const[d,u]=v1({pos:s,x1:e,y1:n,x2:l,y2:i}),[h,f]=v1({pos:c,x1:l,y1:i,x2:e,y2:n}),[x,p,g,b]=hN({sourceX:e,sourceY:n,targetX:l,targetY:i,sourceControlX:d,sourceControlY:u,targetControlX:h,targetControlY:f});return[`M${e},${n} C${d},${u} ${h},${f} ${l},${i}`,x,p,g,b]}function GN(e){return y.memo(({id:n,sourceX:s,sourceY:l,targetX:i,targetY:c,sourcePosition:d,targetPosition:u,label:h,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:C,interactionWidth:E})=>{const[M,N,A]=YN({sourceX:s,sourceY:l,sourcePosition:d,targetX:i,targetY:c,targetPosition:u}),R=e.isInternal?void 0:n;return t.jsx(Hu,{id:R,path:M,labelX:N,labelY:A,label:h,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:C,interactionWidth:E})})}const ML=GN({isInternal:!1}),XN=GN({isInternal:!0});ML.displayName="SimpleBezierEdge";XN.displayName="SimpleBezierEdgeInternal";function KN(e){return y.memo(({id:n,sourceX:s,sourceY:l,targetX:i,targetY:c,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,sourcePosition:b=mt.Bottom,targetPosition:w=mt.Top,markerEnd:k,markerStart:C,pathOptions:E,interactionWidth:M})=>{const[N,A,R]=mx({sourceX:s,sourceY:l,sourcePosition:b,targetX:i,targetY:c,targetPosition:w,borderRadius:E?.borderRadius,offset:E?.offset,stepPosition:E?.stepPosition}),_=e.isInternal?void 0:n;return t.jsx(Hu,{id:_,path:N,labelX:A,labelY:R,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,markerEnd:k,markerStart:C,interactionWidth:M})})}const WN=KN({isInternal:!1}),ZN=KN({isInternal:!0});WN.displayName="SmoothStepEdge";ZN.displayName="SmoothStepEdgeInternal";function QN(e){return y.memo(({id:n,...s})=>{const l=e.isInternal?void 0:n;return t.jsx(WN,{...s,id:l,pathOptions:y.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const RL=QN({isInternal:!1}),JN=QN({isInternal:!0});RL.displayName="StepEdge";JN.displayName="StepEdgeInternal";function e5(e){return y.memo(({id:n,sourceX:s,sourceY:l,targetX:i,targetY:c,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:w,interactionWidth:k})=>{const[C,E,M]=gN({sourceX:s,sourceY:l,targetX:i,targetY:c}),N=e.isInternal?void 0:n;return t.jsx(Hu,{id:N,path:C,labelX:E,labelY:M,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:w,interactionWidth:k})})}const OL=e5({isInternal:!1}),t5=e5({isInternal:!0});OL.displayName="StraightEdge";t5.displayName="StraightEdgeInternal";function n5(e){return y.memo(({id:n,sourceX:s,sourceY:l,targetX:i,targetY:c,sourcePosition:d=mt.Bottom,targetPosition:u=mt.Top,label:h,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:C,pathOptions:E,interactionWidth:M})=>{const[N,A,R]=xN({sourceX:s,sourceY:l,sourcePosition:d,targetX:i,targetY:c,targetPosition:u,curvature:E?.curvature}),_=e.isInternal?void 0:n;return t.jsx(Hu,{id:_,path:N,labelX:A,labelY:R,label:h,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:C,interactionWidth:M})})}const DL=n5({isInternal:!1}),r5=n5({isInternal:!0});DL.displayName="BezierEdge";r5.displayName="BezierEdgeInternal";const j1={default:r5,straight:t5,step:JN,smoothstep:ZN,simplebezier:XN},w1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},LL=(e,n,s)=>s===mt.Left?e-n:s===mt.Right?e+n:e,IL=(e,n,s)=>s===mt.Top?e-n:s===mt.Bottom?e+n:e,N1="react-flow__edgeupdater";function k1({position:e,centerX:n,centerY:s,radius:l=10,onMouseDown:i,onMouseEnter:c,onMouseOut:d,type:u}){return t.jsx("circle",{onMouseDown:i,onMouseEnter:c,onMouseOut:d,className:rr([N1,`${N1}-${u}`]),cx:LL(n,l,e),cy:IL(s,l,e),r:l,stroke:"transparent",fill:"transparent"})}function zL({isReconnectable:e,reconnectRadius:n,edge:s,sourceX:l,sourceY:i,targetX:c,targetY:d,sourcePosition:u,targetPosition:h,onReconnect:f,onReconnectStart:x,onReconnectEnd:p,setReconnecting:g,setUpdateHover:b}){const w=zn(),k=(A,R)=>{if(A.button!==0)return;const{autoPanOnConnect:_,domNode:Y,connectionMode:q,connectionRadius:X,lib:L,onConnectStart:P,cancelConnection:G,nodeLookup:$,rfId:T,panBy:z,updateConnection:O}=w.getState(),V=R.type==="target",H=(F,K)=>{g(!1),p?.(F,s,R.type,K)},Z=F=>f?.(s,F),B=(F,K)=>{g(!0),x?.(A,s,R.type),P?.(F,K)};px.onPointerDown(A.nativeEvent,{autoPanOnConnect:_,connectionMode:q,connectionRadius:X,domNode:Y,handleId:R.id,nodeId:R.nodeId,nodeLookup:$,isTarget:V,edgeUpdaterType:R.type,lib:L,flowId:T,cancelConnection:G,panBy:z,isValidConnection:(...F)=>w.getState().isValidConnection?.(...F)??!0,onConnect:Z,onConnectStart:B,onConnectEnd:(...F)=>w.getState().onConnectEnd?.(...F),onReconnectEnd:H,updateConnection:O,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},C=A=>k(A,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),E=A=>k(A,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),M=()=>b(!0),N=()=>b(!1);return t.jsxs(t.Fragment,{children:[(e===!0||e==="source")&&t.jsx(k1,{position:u,centerX:l,centerY:i,radius:n,onMouseDown:C,onMouseEnter:M,onMouseOut:N,type:"source"}),(e===!0||e==="target")&&t.jsx(k1,{position:h,centerX:c,centerY:d,radius:n,onMouseDown:E,onMouseEnter:M,onMouseOut:N,type:"target"})]})}function $L({id:e,edgesFocusable:n,edgesReconnectable:s,elementsSelectable:l,onClick:i,onDoubleClick:c,onContextMenu:d,onMouseEnter:u,onMouseMove:h,onMouseLeave:f,reconnectRadius:x,onReconnect:p,onReconnectStart:g,onReconnectEnd:b,rfId:w,edgeTypes:k,noPanClassName:C,onError:E,disableKeyboardA11y:M}){let N=rn(Oe=>Oe.edgeLookup.get(e));const A=rn(Oe=>Oe.defaultEdgeOptions);N=A?{...A,...N}:N;let R=N.type||"default",_=k?.[R]||j1[R];_===void 0&&(E?.("011",Xs.error011(R)),R="default",_=k?.default||j1.default);const Y=!!(N.focusable||n&&typeof N.focusable>"u"),q=typeof p<"u"&&(N.reconnectable||s&&typeof N.reconnectable>"u"),X=!!(N.selectable||l&&typeof N.selectable>"u"),L=y.useRef(null),[P,G]=y.useState(!1),[$,T]=y.useState(!1),z=zn(),{zIndex:O,sourceX:V,sourceY:H,targetX:Z,targetY:B,sourcePosition:F,targetPosition:K}=rn(y.useCallback(Oe=>{const ve=Oe.nodeLookup.get(N.source),ke=Oe.nodeLookup.get(N.target);if(!ve||!ke)return{zIndex:N.zIndex,...w1};const Ee=AO({id:e,sourceNode:ve,targetNode:ke,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:Oe.connectionMode,onError:E});return{zIndex:jO({selected:N.selected,zIndex:N.zIndex,sourceNode:ve,targetNode:ke,elevateOnSelect:Oe.elevateEdgesOnSelect,zIndexMode:Oe.zIndexMode}),...Ee||w1}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex]),In),I=y.useMemo(()=>N.markerStart?`url('#${hx(N.markerStart,w)}')`:void 0,[N.markerStart,w]),S=y.useMemo(()=>N.markerEnd?`url('#${hx(N.markerEnd,w)}')`:void 0,[N.markerEnd,w]);if(N.hidden||V===null||H===null||Z===null||B===null)return null;const D=Oe=>{const{addSelectedEdges:ve,unselectNodesAndEdges:ke,multiSelectionActive:Ee}=z.getState();X&&(z.setState({nodesSelectionActive:!1}),N.selected&&Ee?(ke({nodes:[],edges:[N]}),L.current?.blur()):ve([e])),i&&i(Oe,N)},W=c?Oe=>{c(Oe,{...N})}:void 0,J=d?Oe=>{d(Oe,{...N})}:void 0,te=u?Oe=>{u(Oe,{...N})}:void 0,re=h?Oe=>{h(Oe,{...N})}:void 0,oe=f?Oe=>{f(Oe,{...N})}:void 0,me=Oe=>{if(!M&&eN.includes(Oe.key)&&X){const{unselectNodesAndEdges:ve,addSelectedEdges:ke}=z.getState();Oe.key==="Escape"?(L.current?.blur(),ve({edges:[N]})):ke([e])}};return t.jsx("svg",{style:{zIndex:O},children:t.jsxs("g",{className:rr(["react-flow__edge",`react-flow__edge-${R}`,N.className,C,{selected:N.selected,animated:N.animated,inactive:!X&&!i,updating:P,selectable:X}]),onClick:D,onDoubleClick:W,onContextMenu:J,onMouseEnter:te,onMouseMove:re,onMouseLeave:oe,onKeyDown:Y?me:void 0,tabIndex:Y?0:void 0,role:N.ariaRole??(Y?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":Y?`${RN}-${w}`:void 0,ref:L,...N.domAttributes,children:[!$&&t.jsx(_,{id:e,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:X,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:V,sourceY:H,targetX:Z,targetY:B,sourcePosition:F,targetPosition:K,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:I,markerEnd:S,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),q&&t.jsx(zL,{edge:N,isReconnectable:q,reconnectRadius:x,onReconnect:p,onReconnectStart:g,onReconnectEnd:b,sourceX:V,sourceY:H,targetX:Z,targetY:B,sourcePosition:F,targetPosition:K,setUpdateHover:G,setReconnecting:T})]})})}var BL=y.memo($L);const HL=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function s5({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:s,edgeTypes:l,noPanClassName:i,onReconnect:c,onEdgeContextMenu:d,onEdgeMouseEnter:u,onEdgeMouseMove:h,onEdgeMouseLeave:f,onEdgeClick:x,reconnectRadius:p,onEdgeDoubleClick:g,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:k}){const{edgesFocusable:C,edgesReconnectable:E,elementsSelectable:M,onError:N}=rn(HL,In),A=kL(n);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(AL,{defaultColor:e,rfId:s}),A.map(R=>t.jsx(BL,{id:R,edgesFocusable:C,edgesReconnectable:E,elementsSelectable:M,noPanClassName:i,onReconnect:c,onContextMenu:d,onMouseEnter:u,onMouseMove:h,onMouseLeave:f,onClick:x,reconnectRadius:p,onDoubleClick:g,onReconnectStart:b,onReconnectEnd:w,rfId:s,onError:N,edgeTypes:l,disableKeyboardA11y:k},R))]})}s5.displayName="EdgeRenderer";const PL=y.memo(s5),UL=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function qL({children:e}){const n=rn(UL);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function FL(e){const n=dp(),s=y.useRef(!1);y.useEffect(()=>{!s.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),s.current=!0)},[e,n.viewportInitialized])}const VL=e=>e.panZoom?.syncViewport;function YL(e){const n=rn(VL),s=zn();return y.useEffect(()=>{e&&(n?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function GL(e){return e.connection.inProgress?{...e.connection,to:vc(e.connection.to,e.transform)}:{...e.connection}}function XL(e){return GL}function KL(e){const n=XL();return rn(n,In)}const WL=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ZL({containerStyle:e,style:n,type:s,component:l}){const{nodesConnectable:i,width:c,height:d,isValid:u,inProgress:h}=rn(WL,In);return!(c&&i&&h)?null:t.jsx("svg",{style:e,width:c,height:d,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:rr(["react-flow__connection",rN(u)]),children:t.jsx(a5,{style:n,type:s,CustomComponent:l,isValid:u})})})}const a5=({style:e,type:n=rl.Bezier,CustomComponent:s,isValid:l})=>{const{inProgress:i,from:c,fromNode:d,fromHandle:u,fromPosition:h,to:f,toNode:x,toHandle:p,toPosition:g,pointer:b}=KL();if(!i)return;if(s)return t.jsx(s,{connectionLineType:n,connectionLineStyle:e,fromNode:d,fromHandle:u,fromX:c.x,fromY:c.y,toX:f.x,toY:f.y,fromPosition:h,toPosition:g,connectionStatus:rN(l),toNode:x,toHandle:p,pointer:b});let w="";const k={sourceX:c.x,sourceY:c.y,sourcePosition:h,targetX:f.x,targetY:f.y,targetPosition:g};switch(n){case rl.Bezier:[w]=xN(k);break;case rl.SimpleBezier:[w]=YN(k);break;case rl.Step:[w]=mx({...k,borderRadius:0});break;case rl.SmoothStep:[w]=mx(k);break;default:[w]=gN(k)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};a5.displayName="ConnectionLine";const QL={};function S1(e=QL){y.useRef(e),zn(),y.useEffect(()=>{},[e])}function JL(){zn(),y.useRef(!1),y.useEffect(()=>{},[])}function l5({nodeTypes:e,edgeTypes:n,onInit:s,onNodeClick:l,onEdgeClick:i,onNodeDoubleClick:c,onEdgeDoubleClick:d,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:x,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:k,connectionLineComponent:C,connectionLineContainerStyle:E,selectionKeyCode:M,selectionOnDrag:N,selectionMode:A,multiSelectionKeyCode:R,panActivationKeyCode:_,zoomActivationKeyCode:Y,deleteKeyCode:q,onlyRenderVisibleElements:X,elementsSelectable:L,defaultViewport:P,translateExtent:G,minZoom:$,maxZoom:T,preventScrolling:z,defaultMarkerColor:O,zoomOnScroll:V,zoomOnPinch:H,panOnScroll:Z,panOnScrollSpeed:B,panOnScrollMode:F,zoomOnDoubleClick:K,panOnDrag:I,onPaneClick:S,onPaneMouseEnter:D,onPaneMouseMove:W,onPaneMouseLeave:J,onPaneScroll:te,onPaneContextMenu:re,paneClickDistance:oe,nodeClickDistance:me,onEdgeContextMenu:Oe,onEdgeMouseEnter:ve,onEdgeMouseMove:ke,onEdgeMouseLeave:Ee,reconnectRadius:Me,onReconnect:dt,onReconnectStart:pt,onReconnectEnd:et,noDragClassName:Pt,noWheelClassName:le,noPanClassName:Se,disableKeyboardA11y:We,nodeExtent:kt,rfId:Ft,viewport:xe,onViewportChange:Ce}){return S1(e),S1(n),JL(),FL(s),YL(xe),t.jsx(hL,{onPaneClick:S,onPaneMouseEnter:D,onPaneMouseMove:W,onPaneMouseLeave:J,onPaneContextMenu:re,onPaneScroll:te,paneClickDistance:oe,deleteKeyCode:q,selectionKeyCode:M,selectionOnDrag:N,selectionMode:A,onSelectionStart:g,onSelectionEnd:b,multiSelectionKeyCode:R,panActivationKeyCode:_,zoomActivationKeyCode:Y,elementsSelectable:L,zoomOnScroll:V,zoomOnPinch:H,zoomOnDoubleClick:K,panOnScroll:Z,panOnScrollSpeed:B,panOnScrollMode:F,panOnDrag:I,defaultViewport:P,translateExtent:G,minZoom:$,maxZoom:T,onSelectionContextMenu:p,preventScrolling:z,noDragClassName:Pt,noWheelClassName:le,noPanClassName:Se,disableKeyboardA11y:We,onViewportChange:Ce,isControlledViewport:!!xe,children:t.jsxs(qL,{children:[t.jsx(PL,{edgeTypes:n,onEdgeClick:i,onEdgeDoubleClick:d,onReconnect:dt,onReconnectStart:pt,onReconnectEnd:et,onlyRenderVisibleElements:X,onEdgeContextMenu:Oe,onEdgeMouseEnter:ve,onEdgeMouseMove:ke,onEdgeMouseLeave:Ee,reconnectRadius:Me,defaultMarkerColor:O,noPanClassName:Se,disableKeyboardA11y:We,rfId:Ft}),t.jsx(ZL,{style:k,type:w,component:C,containerStyle:E}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(NL,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:x,nodeClickDistance:me,onlyRenderVisibleElements:X,noPanClassName:Se,noDragClassName:Pt,disableKeyboardA11y:We,nodeExtent:kt,rfId:Ft}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}l5.displayName="GraphView";const eI=y.memo(l5),C1=({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:i,height:c,fitView:d,fitViewOptions:u,minZoom:h=.5,maxZoom:f=2,nodeOrigin:x,nodeExtent:p,zIndexMode:g="basic"}={})=>{const b=new Map,w=new Map,k=new Map,C=new Map,E=l??n??[],M=s??e??[],N=x??[0,0],A=p??ac;vN(k,C,E);const R=xx(M,b,w,{nodeOrigin:N,nodeExtent:A,zIndexMode:g});let _=[0,0,1];if(d&&i&&c){const Y=bc(b,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:q,y:X,zoom:L}=rp(Y,i,c,h,f,u?.padding??.1);_=[q,X,L]}return{rfId:"1",width:i??0,height:c??0,transform:_,nodes:M,nodesInitialized:R,nodeLookup:b,parentLookup:w,edges:E,edgeLookup:C,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:h,maxZoom:f,translateExtent:ac,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Di.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:d??!1,fitViewOptions:u,fitViewResolver:null,connection:{...nN},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:xO,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tN,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},tI=({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:i,height:c,fitView:d,fitViewOptions:u,minZoom:h,maxZoom:f,nodeOrigin:x,nodeExtent:p,zIndexMode:g})=>yD((b,w)=>{async function k(){const{nodeLookup:C,panZoom:E,fitViewOptions:M,fitViewResolver:N,width:A,height:R,minZoom:_,maxZoom:Y}=w();E&&(await mO({nodes:C,width:A,height:R,panZoom:E,minZoom:_,maxZoom:Y},M),N?.resolve(!0),b({fitViewResolver:null}))}return{...C1({nodes:e,edges:n,width:i,height:c,fitView:d,fitViewOptions:u,minZoom:h,maxZoom:f,nodeOrigin:x,nodeExtent:p,defaultNodes:s,defaultEdges:l,zIndexMode:g}),setNodes:C=>{const{nodeLookup:E,parentLookup:M,nodeOrigin:N,elevateNodesOnSelect:A,fitViewQueued:R,zIndexMode:_}=w(),Y=xx(C,E,M,{nodeOrigin:N,nodeExtent:p,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:_});R&&Y?(k(),b({nodes:C,nodesInitialized:Y,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:C,nodesInitialized:Y})},setEdges:C=>{const{connectionLookup:E,edgeLookup:M}=w();vN(E,M,C),b({edges:C})},setDefaultNodesAndEdges:(C,E)=>{if(C){const{setNodes:M}=w();M(C),b({hasDefaultNodes:!0})}if(E){const{setEdges:M}=w();M(E),b({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:E,nodeLookup:M,parentLookup:N,domNode:A,nodeOrigin:R,nodeExtent:_,debug:Y,fitViewQueued:q,zIndexMode:X}=w(),{changes:L,updatedInternals:P}=zO(C,M,N,A,R,_,X);P&&(OO(M,N,{nodeOrigin:R,nodeExtent:_,zIndexMode:X}),q?(k(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),L?.length>0&&(Y&&console.log("React Flow: trigger node changes",L),E?.(L)))},updateNodePositions:(C,E=!1)=>{const M=[];let N=[];const{nodeLookup:A,triggerNodeChanges:R,connection:_,updateConnection:Y,onNodesChangeMiddlewareMap:q}=w();for(const[X,L]of C){const P=A.get(X),G=!!(P?.expandParent&&P?.parentId&&L?.position),$={id:X,type:"position",position:G?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:E};if(P&&_.inProgress&&_.fromNode.id===P.id){const T=$l(P,_.fromHandle,mt.Left,!0);Y({..._,from:T})}G&&P.parentId&&M.push({id:X,parentId:P.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),N.push($)}if(M.length>0){const{parentLookup:X,nodeOrigin:L}=w(),P=cp(M,A,X,L);N.push(...P)}for(const X of q.values())N=X(N);R(N)},triggerNodeChanges:C=>{const{onNodesChange:E,setNodes:M,nodes:N,hasDefaultNodes:A,debug:R}=w();if(C?.length){if(A){const _=LN(C,N);M(_)}R&&console.log("React Flow: trigger node changes",C),E?.(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:E,setEdges:M,edges:N,hasDefaultEdges:A,debug:R}=w();if(C?.length){if(A){const _=IN(C,N);M(_)}R&&console.log("React Flow: trigger edge changes",C),E?.(C)}},addSelectedNodes:C=>{const{multiSelectionActive:E,edgeLookup:M,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:R}=w();if(E){const _=C.map(Y=>El(Y,!0));A(_);return}A(Ei(N,new Set([...C]),!0)),R(Ei(M))},addSelectedEdges:C=>{const{multiSelectionActive:E,edgeLookup:M,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:R}=w();if(E){const _=C.map(Y=>El(Y,!0));R(_);return}R(Ei(M,new Set([...C]))),A(Ei(N,new Set,!0))},unselectNodesAndEdges:({nodes:C,edges:E}={})=>{const{edges:M,nodes:N,nodeLookup:A,triggerNodeChanges:R,triggerEdgeChanges:_}=w(),Y=C||N,q=E||M,X=[];for(const P of Y){if(!P.selected)continue;const G=A.get(P.id);G&&(G.selected=!1),X.push(El(P.id,!1))}const L=[];for(const P of q)P.selected&&L.push(El(P.id,!1));R(X),_(L)},setMinZoom:C=>{const{panZoom:E,maxZoom:M}=w();E?.setScaleExtent([C,M]),b({minZoom:C})},setMaxZoom:C=>{const{panZoom:E,minZoom:M}=w();E?.setScaleExtent([M,C]),b({maxZoom:C})},setTranslateExtent:C=>{w().panZoom?.setTranslateExtent(C),b({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:E,triggerNodeChanges:M,triggerEdgeChanges:N,elementsSelectable:A}=w();if(!A)return;const R=E.reduce((Y,q)=>q.selected?[...Y,El(q.id,!1)]:Y,[]),_=C.reduce((Y,q)=>q.selected?[...Y,El(q.id,!1)]:Y,[]);M(R),N(_)},setNodeExtent:C=>{const{nodes:E,nodeLookup:M,parentLookup:N,nodeOrigin:A,elevateNodesOnSelect:R,nodeExtent:_,zIndexMode:Y}=w();C[0][0]===_[0][0]&&C[0][1]===_[0][1]&&C[1][0]===_[1][0]&&C[1][1]===_[1][1]||(xx(E,M,N,{nodeOrigin:A,nodeExtent:C,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:Y}),b({nodeExtent:C}))},panBy:C=>{const{transform:E,width:M,height:N,panZoom:A,translateExtent:R}=w();return $O({delta:C,panZoom:A,transform:E,translateExtent:R,width:M,height:N})},setCenter:async(C,E,M)=>{const{width:N,height:A,maxZoom:R,panZoom:_}=w();if(!_)return Promise.resolve(!1);const Y=typeof M?.zoom<"u"?M.zoom:R;return await _.setViewport({x:N/2-C*Y,y:A/2-E*Y,zoom:Y},{duration:M?.duration,ease:M?.ease,interpolate:M?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...nN}})},updateConnection:C=>{b({connection:C})},reset:()=>b({...C1()})}},Object.is);function nI({initialNodes:e,initialEdges:n,defaultNodes:s,defaultEdges:l,initialWidth:i,initialHeight:c,initialMinZoom:d,initialMaxZoom:u,initialFitViewOptions:h,fitView:f,nodeOrigin:x,nodeExtent:p,zIndexMode:g,children:b}){const[w]=y.useState(()=>tI({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,width:i,height:c,fitView:f,minZoom:d,maxZoom:u,fitViewOptions:h,nodeOrigin:x,nodeExtent:p,zIndexMode:g}));return t.jsx(vD,{value:w,children:t.jsx(qD,{children:b})})}function rI({children:e,nodes:n,edges:s,defaultNodes:l,defaultEdges:i,width:c,height:d,fitView:u,fitViewOptions:h,minZoom:f,maxZoom:x,nodeOrigin:p,nodeExtent:g,zIndexMode:b}){return y.useContext(zu)?t.jsx(t.Fragment,{children:e}):t.jsx(nI,{initialNodes:n,initialEdges:s,defaultNodes:l,defaultEdges:i,initialWidth:c,initialHeight:d,fitView:u,initialFitViewOptions:h,initialMinZoom:f,initialMaxZoom:x,nodeOrigin:p,nodeExtent:g,zIndexMode:b,children:e})}const sI={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function aI({nodes:e,edges:n,defaultNodes:s,defaultEdges:l,className:i,nodeTypes:c,edgeTypes:d,onNodeClick:u,onEdgeClick:h,onInit:f,onMove:x,onMoveStart:p,onMoveEnd:g,onConnect:b,onConnectStart:w,onConnectEnd:k,onClickConnectStart:C,onClickConnectEnd:E,onNodeMouseEnter:M,onNodeMouseMove:N,onNodeMouseLeave:A,onNodeContextMenu:R,onNodeDoubleClick:_,onNodeDragStart:Y,onNodeDrag:q,onNodeDragStop:X,onNodesDelete:L,onEdgesDelete:P,onDelete:G,onSelectionChange:$,onSelectionDragStart:T,onSelectionDrag:z,onSelectionDragStop:O,onSelectionContextMenu:V,onSelectionStart:H,onSelectionEnd:Z,onBeforeDelete:B,connectionMode:F,connectionLineType:K=rl.Bezier,connectionLineStyle:I,connectionLineComponent:S,connectionLineContainerStyle:D,deleteKeyCode:W="Backspace",selectionKeyCode:J="Shift",selectionOnDrag:te=!1,selectionMode:re=lc.Full,panActivationKeyCode:oe="Space",multiSelectionKeyCode:me=oc()?"Meta":"Control",zoomActivationKeyCode:Oe=oc()?"Meta":"Control",snapToGrid:ve,snapGrid:ke,onlyRenderVisibleElements:Ee=!1,selectNodesOnDrag:Me,nodesDraggable:dt,autoPanOnNodeFocus:pt,nodesConnectable:et,nodesFocusable:Pt,nodeOrigin:le=ON,edgesFocusable:Se,edgesReconnectable:We,elementsSelectable:kt=!0,defaultViewport:Ft=OD,minZoom:xe=.5,maxZoom:Ce=2,translateExtent:Fe=ac,preventScrolling:lt=!0,nodeExtent:ut,defaultMarkerColor:Lt="#b1b1b7",zoomOnScroll:bn=!0,zoomOnPinch:Ut=!0,panOnScroll:St=!1,panOnScrollSpeed:Jt=.5,panOnScrollMode:yt=Rl.Free,zoomOnDoubleClick:Xt=!0,panOnDrag:_t=!0,onPaneClick:$t,onPaneMouseEnter:Hn,onPaneMouseMove:dn,onPaneMouseLeave:ye,onPaneScroll:Ge,onPaneContextMenu:it,paneClickDistance:Et=1,nodeClickDistance:It=0,children:kn,onReconnect:_n,onReconnectStart:Mn,onReconnectEnd:dr,onEdgeContextMenu:sr,onEdgeDoubleClick:ur,onEdgeMouseEnter:$n,onEdgeMouseMove:ae,onEdgeMouseLeave:Ie,reconnectRadius:qe=10,onNodesChange:Qe,onEdgesChange:ue,noDragClassName:ze="nodrag",noWheelClassName:Ve="nowheel",noPanClassName:tt="nopan",fitView:ot,fitViewOptions:At,connectOnClick:Sn,attributionPosition:ar,proOptions:mn,defaultEdgeOptions:Wn,elevateNodesOnSelect:Ot=!0,elevateEdgesOnSelect:pr=!1,disableKeyboardA11y:Tt=!1,autoPanOnConnect:hn,autoPanOnNodeDrag:ln,autoPanSpeed:ss,connectionRadius:Rr,isValidConnection:lr,onError:Or,style:gs,id:as,nodeDragThreshold:Os,connectionDragThreshold:Ds,viewport:gr,onViewportChange:Dr,width:fr,height:Vn,colorMode:bs="light",debug:de,onScroll:Te,ariaLabelConfig:Ue,zIndexMode:qt="basic",...Ar},Pn){const mr=as||"1",Ls=zD(bs),ys=y.useCallback(br=>{br.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Te?.(br)},[Te]);return t.jsx("div",{"data-testid":"rf__wrapper",...Ar,onScroll:ys,style:{...gs,...sI},ref:Pn,className:rr(["react-flow",i,Ls]),id:as,role:"application",children:t.jsxs(rI,{nodes:e,edges:n,width:fr,height:Vn,fitView:ot,fitViewOptions:At,minZoom:xe,maxZoom:Ce,nodeOrigin:le,nodeExtent:ut,zIndexMode:qt,children:[t.jsx(eI,{onInit:f,onNodeClick:u,onEdgeClick:h,onNodeMouseEnter:M,onNodeMouseMove:N,onNodeMouseLeave:A,onNodeContextMenu:R,onNodeDoubleClick:_,nodeTypes:c,edgeTypes:d,connectionLineType:K,connectionLineStyle:I,connectionLineComponent:S,connectionLineContainerStyle:D,selectionKeyCode:J,selectionOnDrag:te,selectionMode:re,deleteKeyCode:W,multiSelectionKeyCode:me,panActivationKeyCode:oe,zoomActivationKeyCode:Oe,onlyRenderVisibleElements:Ee,defaultViewport:Ft,translateExtent:Fe,minZoom:xe,maxZoom:Ce,preventScrolling:lt,zoomOnScroll:bn,zoomOnPinch:Ut,zoomOnDoubleClick:Xt,panOnScroll:St,panOnScrollSpeed:Jt,panOnScrollMode:yt,panOnDrag:_t,onPaneClick:$t,onPaneMouseEnter:Hn,onPaneMouseMove:dn,onPaneMouseLeave:ye,onPaneScroll:Ge,onPaneContextMenu:it,paneClickDistance:Et,nodeClickDistance:It,onSelectionContextMenu:V,onSelectionStart:H,onSelectionEnd:Z,onReconnect:_n,onReconnectStart:Mn,onReconnectEnd:dr,onEdgeContextMenu:sr,onEdgeDoubleClick:ur,onEdgeMouseEnter:$n,onEdgeMouseMove:ae,onEdgeMouseLeave:Ie,reconnectRadius:qe,defaultMarkerColor:Lt,noDragClassName:ze,noWheelClassName:Ve,noPanClassName:tt,rfId:mr,disableKeyboardA11y:Tt,nodeExtent:ut,viewport:gr,onViewportChange:Dr}),t.jsx(ID,{nodes:e,edges:n,defaultNodes:s,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:k,onClickConnectStart:C,onClickConnectEnd:E,nodesDraggable:dt,autoPanOnNodeFocus:pt,nodesConnectable:et,nodesFocusable:Pt,edgesFocusable:Se,edgesReconnectable:We,elementsSelectable:kt,elevateNodesOnSelect:Ot,elevateEdgesOnSelect:pr,minZoom:xe,maxZoom:Ce,nodeExtent:ut,onNodesChange:Qe,onEdgesChange:ue,snapToGrid:ve,snapGrid:ke,connectionMode:F,translateExtent:Fe,connectOnClick:Sn,defaultEdgeOptions:Wn,fitView:ot,fitViewOptions:At,onNodesDelete:L,onEdgesDelete:P,onDelete:G,onNodeDragStart:Y,onNodeDrag:q,onNodeDragStop:X,onSelectionDrag:z,onSelectionDragStart:T,onSelectionDragStop:O,onMove:x,onMoveStart:p,onMoveEnd:g,noPanClassName:tt,nodeOrigin:le,rfId:mr,autoPanOnConnect:hn,autoPanOnNodeDrag:ln,autoPanSpeed:ss,onError:Or,connectionRadius:Rr,isValidConnection:lr,selectNodesOnDrag:Me,nodeDragThreshold:Os,connectionDragThreshold:Ds,onBeforeDelete:B,debug:de,ariaLabelConfig:Ue,zIndexMode:qt}),t.jsx(RD,{onSelectionChange:$}),kn,t.jsx(ED,{proOptions:mn,position:ar}),t.jsx(CD,{rfId:mr,disableKeyboardA11y:Tt})]})})}var lI=zN(aI);function iI(e){const[n,s]=y.useState(e),l=y.useCallback(i=>s(c=>LN(i,c)),[]);return[n,s,l]}function oI(e){const[n,s]=y.useState(e),l=y.useCallback(i=>s(c=>IN(i,c)),[]);return[n,s,l]}function cI({dimensions:e,lineWidth:n,variant:s,className:l}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:rr(["react-flow__background-pattern",s,l])})}function dI({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:rr(["react-flow__background-pattern","dots",n])})}var sl;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(sl||(sl={}));const uI={[sl.Dots]:1,[sl.Lines]:1,[sl.Cross]:6},fI=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function i5({id:e,variant:n=sl.Dots,gap:s=20,size:l,lineWidth:i=1,offset:c=0,color:d,bgColor:u,style:h,className:f,patternClassName:x}){const p=y.useRef(null),{transform:g,patternId:b}=rn(fI,In),w=l||uI[n],k=n===sl.Dots,C=n===sl.Cross,E=Array.isArray(s)?s:[s,s],M=[E[0]*g[2]||1,E[1]*g[2]||1],N=w*g[2],A=Array.isArray(c)?c:[c,c],R=C?[N,N]:M,_=[A[0]*g[2]||1+R[0]/2,A[1]*g[2]||1+R[1]/2],Y=`${b}${e||""}`;return t.jsxs("svg",{className:rr(["react-flow__background",f]),style:{...h,...Bu,"--xy-background-color-props":u,"--xy-background-pattern-color-props":d},ref:p,"data-testid":"rf__background",children:[t.jsx("pattern",{id:Y,x:g[0]%M[0],y:g[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:k?t.jsx(dI,{radius:N/2,className:x}):t.jsx(cI,{dimensions:R,lineWidth:i,variant:n,className:x})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${Y})`})]})}i5.displayName="Background";const mI=y.memo(i5);function hI(){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 xI(){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 pI(){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 gI(){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 bI(){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 $d({children:e,className:n,...s}){return t.jsx("button",{type:"button",className:rr(["react-flow__controls-button",n]),...s,children:e})}const yI=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function o5({style:e,showZoom:n=!0,showFitView:s=!0,showInteractive:l=!0,fitViewOptions:i,onZoomIn:c,onZoomOut:d,onFitView:u,onInteractiveChange:h,className:f,children:x,position:p="bottom-left",orientation:g="vertical","aria-label":b}){const w=zn(),{isInteractive:k,minZoomReached:C,maxZoomReached:E,ariaLabelConfig:M}=rn(yI,In),{zoomIn:N,zoomOut:A,fitView:R}=dp(),_=()=>{N(),c?.()},Y=()=>{A(),d?.()},q=()=>{R(i),u?.()},X=()=>{w.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),h?.(!k)},L=g==="horizontal"?"horizontal":"vertical";return t.jsxs($u,{className:rr(["react-flow__controls",L,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??M["controls.ariaLabel"],children:[n&&t.jsxs(t.Fragment,{children:[t.jsx($d,{onClick:_,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:E,children:t.jsx(hI,{})}),t.jsx($d,{onClick:Y,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:C,children:t.jsx(xI,{})})]}),s&&t.jsx($d,{className:"react-flow__controls-fitview",onClick:q,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:t.jsx(pI,{})}),l&&t.jsx($d,{className:"react-flow__controls-interactive",onClick:X,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:k?t.jsx(bI,{}):t.jsx(gI,{})}),x]})}o5.displayName="Controls";const vI=y.memo(o5);function jI({id:e,x:n,y:s,width:l,height:i,style:c,color:d,strokeColor:u,strokeWidth:h,className:f,borderRadius:x,shapeRendering:p,selected:g,onClick:b}){const{background:w,backgroundColor:k}=c||{},C=d||w||k;return t.jsx("rect",{className:rr(["react-flow__minimap-node",{selected:g},f]),x:n,y:s,rx:x,ry:x,width:l,height:i,style:{fill:C,stroke:u,strokeWidth:h},shapeRendering:p,onClick:b?E=>b(E,e):void 0})}const wI=y.memo(jI),NI=e=>e.nodes.map(n=>n.id),Ah=e=>e instanceof Function?e:()=>e;function kI({nodeStrokeColor:e,nodeColor:n,nodeClassName:s="",nodeBorderRadius:l=5,nodeStrokeWidth:i,nodeComponent:c=wI,onClick:d}){const u=rn(NI,In),h=Ah(n),f=Ah(e),x=Ah(s),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:u.map(g=>t.jsx(CI,{id:g,nodeColorFunc:h,nodeStrokeColorFunc:f,nodeClassNameFunc:x,nodeBorderRadius:l,nodeStrokeWidth:i,NodeComponent:c,onClick:d,shapeRendering:p},g))})}function SI({id:e,nodeColorFunc:n,nodeStrokeColorFunc:s,nodeClassNameFunc:l,nodeBorderRadius:i,nodeStrokeWidth:c,shapeRendering:d,NodeComponent:u,onClick:h}){const{node:f,x,y:p,width:g,height:b}=rn(w=>{const k=w.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const C=k.internals.userNode,{x:E,y:M}=k.internals.positionAbsolute,{width:N,height:A}=Na(C);return{node:C,x:E,y:M,width:N,height:A}},In);return!f||f.hidden||!cN(f)?null:t.jsx(u,{x,y:p,width:g,height:b,style:f.style,selected:!!f.selected,className:l(f),color:n(f),borderRadius:i,strokeColor:s(f),strokeWidth:c,shapeRendering:d,onClick:h,id:f.id})}const CI=y.memo(SI);var EI=y.memo(kI);const TI=200,AI=150,_I=e=>!e.hidden,MI=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?oN(bc(e.nodeLookup,{filter:_I}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},RI="react-flow__minimap-desc";function c5({style:e,className:n,nodeStrokeColor:s,nodeColor:l,nodeClassName:i="",nodeBorderRadius:c=5,nodeStrokeWidth:d,nodeComponent:u,bgColor:h,maskColor:f,maskStrokeColor:x,maskStrokeWidth:p,position:g="bottom-right",onClick:b,onNodeClick:w,pannable:k=!1,zoomable:C=!1,ariaLabel:E,inversePan:M,zoomStep:N=1,offsetScale:A=5}){const R=zn(),_=y.useRef(null),{boundingRect:Y,viewBB:q,rfId:X,panZoom:L,translateExtent:P,flowWidth:G,flowHeight:$,ariaLabelConfig:T}=rn(MI,In),z=e?.width??TI,O=e?.height??AI,V=Y.width/z,H=Y.height/O,Z=Math.max(V,H),B=Z*z,F=Z*O,K=A*Z,I=Y.x-(B-Y.width)/2-K,S=Y.y-(F-Y.height)/2-K,D=B+K*2,W=F+K*2,J=`${RI}-${X}`,te=y.useRef(0),re=y.useRef();te.current=Z,y.useEffect(()=>{if(_.current&&L)return re.current=GO({domNode:_.current,panZoom:L,getTransform:()=>R.getState().transform,getViewScale:()=>te.current}),()=>{re.current?.destroy()}},[L]),y.useEffect(()=>{re.current?.update({translateExtent:P,width:G,height:$,inversePan:M,pannable:k,zoomStep:N,zoomable:C})},[k,C,M,N,P,G,$]);const oe=b?ve=>{const[ke,Ee]=re.current?.pointer(ve)||[0,0];b(ve,{x:ke,y:Ee})}:void 0,me=w?y.useCallback((ve,ke)=>{const Ee=R.getState().nodeLookup.get(ke).internals.userNode;w(ve,Ee)},[]):void 0,Oe=E??T["minimap.ariaLabel"];return t.jsx($u,{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 x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*Z:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-width-props":typeof d=="number"?d:void 0},className:rr(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:z,height:O,viewBox:`${I} ${S} ${D} ${W}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":J,ref:_,onClick:oe,children:[Oe&&t.jsx("title",{id:J,children:Oe}),t.jsx(EI,{onClick:me,nodeColor:l,nodeStrokeColor:s,nodeBorderRadius:c,nodeClassName:i,nodeStrokeWidth:d,nodeComponent:u}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${I-K},${S-K}h${D+K*2}v${W+K*2}h${-D-K*2}z
|
|
64
|
+
M${q.x},${q.y}h${q.width}v${q.height}h${-q.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}c5.displayName="MiniMap";const OI=y.memo(c5),DI=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,LI={[Bi.Line]:"right",[Bi.Handle]:"bottom-right"};function II({nodeId:e,position:n,variant:s=Bi.Handle,className:l,style:i=void 0,children:c,color:d,minWidth:u=10,minHeight:h=10,maxWidth:f=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:b=!0,shouldResize:w,onResizeStart:k,onResize:C,onResizeEnd:E}){const M=PN(),N=typeof e=="string"?e:M,A=zn(),R=y.useRef(null),_=s===Bi.Handle,Y=rn(y.useCallback(DI(_&&b),[_,b]),In),q=y.useRef(null),X=n??LI[s];y.useEffect(()=>{if(!(!R.current||!N))return q.current||(q.current=iD({domNode:R.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:P,transform:G,snapGrid:$,snapToGrid:T,nodeOrigin:z,domNode:O}=A.getState();return{nodeLookup:P,transform:G,snapGrid:$,snapToGrid:T,nodeOrigin:z,paneDomNode:O}},onChange:(P,G)=>{const{triggerNodeChanges:$,nodeLookup:T,parentLookup:z,nodeOrigin:O}=A.getState(),V=[],H={x:P.x,y:P.y},Z=T.get(N);if(Z&&Z.expandParent&&Z.parentId){const B=Z.origin??O,F=P.width??Z.measured.width??0,K=P.height??Z.measured.height??0,I={id:Z.id,parentId:Z.parentId,rect:{width:F,height:K,...dN({x:P.x??Z.position.x,y:P.y??Z.position.y},{width:F,height:K},Z.parentId,T,B)}},S=cp([I],T,z,O);V.push(...S),H.x=P.x?Math.max(B[0]*F,P.x):void 0,H.y=P.y?Math.max(B[1]*K,P.y):void 0}if(H.x!==void 0&&H.y!==void 0){const B={id:N,type:"position",position:{...H}};V.push(B)}if(P.width!==void 0&&P.height!==void 0){const F={id:N,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:P.width,height:P.height}};V.push(F)}for(const B of G){const F={...B,type:"position"};V.push(F)}$(V)},onEnd:({width:P,height:G})=>{const $={id:N,type:"dimensions",resizing:!1,dimensions:{width:P,height:G}};A.getState().triggerNodeChanges([$])}})),q.current.update({controlPosition:X,boundaries:{minWidth:u,minHeight:h,maxWidth:f,maxHeight:x},keepAspectRatio:p,resizeDirection:g,onResizeStart:k,onResize:C,onResizeEnd:E,shouldResize:w}),()=>{q.current?.destroy()}},[X,u,h,f,x,p,k,C,E,w]);const L=X.split("-");return t.jsx("div",{className:rr(["react-flow__resize-control","nodrag",...L,s,l]),ref:R,style:{...i,scale:Y,...d&&{[_?"backgroundColor":"borderColor"]:d}},children:c})}y.memo(II);var gn=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Ms=gn((e,n)=>{var s=Object.defineProperty,l=($,T,z)=>T in $?s($,T,{enumerable:!0,configurable:!0,writable:!0,value:z}):$[T]=z,i=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports),c=($,T,z)=>l($,typeof T!="symbol"?T+"":T,z),d=i(($,T)=>{var z="\0",O="\0",V="",H=class{constructor(S){c(this,"_isDirected",!0),c(this,"_isMultigraph",!1),c(this,"_isCompound",!1),c(this,"_label"),c(this,"_defaultNodeLabelFn",()=>{}),c(this,"_defaultEdgeLabelFn",()=>{}),c(this,"_nodes",{}),c(this,"_in",{}),c(this,"_preds",{}),c(this,"_out",{}),c(this,"_sucs",{}),c(this,"_edgeObjs",{}),c(this,"_edgeLabels",{}),c(this,"_nodeCount",0),c(this,"_edgeCount",0),c(this,"_parent"),c(this,"_children"),S&&(this._isDirected=Object.hasOwn(S,"directed")?S.directed:!0,this._isMultigraph=Object.hasOwn(S,"multigraph")?S.multigraph:!1,this._isCompound=Object.hasOwn(S,"compound")?S.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[O]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(S){return this._label=S,this}graph(){return this._label}setDefaultNodeLabel(S){return this._defaultNodeLabelFn=S,typeof S!="function"&&(this._defaultNodeLabelFn=()=>S),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var S=this;return this.nodes().filter(D=>Object.keys(S._in[D]).length===0)}sinks(){var S=this;return this.nodes().filter(D=>Object.keys(S._out[D]).length===0)}setNodes(S,D){var W=arguments,J=this;return S.forEach(function(te){W.length>1?J.setNode(te,D):J.setNode(te)}),this}setNode(S,D){return Object.hasOwn(this._nodes,S)?(arguments.length>1&&(this._nodes[S]=D),this):(this._nodes[S]=arguments.length>1?D:this._defaultNodeLabelFn(S),this._isCompound&&(this._parent[S]=O,this._children[S]={},this._children[O][S]=!0),this._in[S]={},this._preds[S]={},this._out[S]={},this._sucs[S]={},++this._nodeCount,this)}node(S){return this._nodes[S]}hasNode(S){return Object.hasOwn(this._nodes,S)}removeNode(S){var D=this;if(Object.hasOwn(this._nodes,S)){var W=J=>D.removeEdge(D._edgeObjs[J]);delete this._nodes[S],this._isCompound&&(this._removeFromParentsChildList(S),delete this._parent[S],this.children(S).forEach(function(J){D.setParent(J)}),delete this._children[S]),Object.keys(this._in[S]).forEach(W),delete this._in[S],delete this._preds[S],Object.keys(this._out[S]).forEach(W),delete this._out[S],delete this._sucs[S],--this._nodeCount}return this}setParent(S,D){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(D===void 0)D=O;else{D+="";for(var W=D;W!==void 0;W=this.parent(W))if(W===S)throw new Error("Setting "+D+" as parent of "+S+" would create a cycle");this.setNode(D)}return this.setNode(S),this._removeFromParentsChildList(S),this._parent[S]=D,this._children[D][S]=!0,this}_removeFromParentsChildList(S){delete this._children[this._parent[S]][S]}parent(S){if(this._isCompound){var D=this._parent[S];if(D!==O)return D}}children(S=O){if(this._isCompound){var D=this._children[S];if(D)return Object.keys(D)}else{if(S===O)return this.nodes();if(this.hasNode(S))return[]}}predecessors(S){var D=this._preds[S];if(D)return Object.keys(D)}successors(S){var D=this._sucs[S];if(D)return Object.keys(D)}neighbors(S){var D=this.predecessors(S);if(D){let J=new Set(D);for(var W of this.successors(S))J.add(W);return Array.from(J.values())}}isLeaf(S){var D;return this.isDirected()?D=this.successors(S):D=this.neighbors(S),D.length===0}filterNodes(S){var D=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});D.setGraph(this.graph());var W=this;Object.entries(this._nodes).forEach(function([re,oe]){S(re)&&D.setNode(re,oe)}),Object.values(this._edgeObjs).forEach(function(re){D.hasNode(re.v)&&D.hasNode(re.w)&&D.setEdge(re,W.edge(re))});var J={};function te(re){var oe=W.parent(re);return oe===void 0||D.hasNode(oe)?(J[re]=oe,oe):oe in J?J[oe]:te(oe)}return this._isCompound&&D.nodes().forEach(re=>D.setParent(re,te(re))),D}setDefaultEdgeLabel(S){return this._defaultEdgeLabelFn=S,typeof S!="function"&&(this._defaultEdgeLabelFn=()=>S),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(S,D){var W=this,J=arguments;return S.reduce(function(te,re){return J.length>1?W.setEdge(te,re,D):W.setEdge(te,re),re}),this}setEdge(){var S,D,W,J,te=!1,re=arguments[0];typeof re=="object"&&re!==null&&"v"in re?(S=re.v,D=re.w,W=re.name,arguments.length===2&&(J=arguments[1],te=!0)):(S=re,D=arguments[1],W=arguments[3],arguments.length>2&&(J=arguments[2],te=!0)),S=""+S,D=""+D,W!==void 0&&(W=""+W);var oe=F(this._isDirected,S,D,W);if(Object.hasOwn(this._edgeLabels,oe))return te&&(this._edgeLabels[oe]=J),this;if(W!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(S),this.setNode(D),this._edgeLabels[oe]=te?J:this._defaultEdgeLabelFn(S,D,W);var me=K(this._isDirected,S,D,W);return S=me.v,D=me.w,Object.freeze(me),this._edgeObjs[oe]=me,Z(this._preds[D],S),Z(this._sucs[S],D),this._in[D][oe]=me,this._out[S][oe]=me,this._edgeCount++,this}edge(S,D,W){var J=arguments.length===1?I(this._isDirected,arguments[0]):F(this._isDirected,S,D,W);return this._edgeLabels[J]}edgeAsObj(){let S=this.edge(...arguments);return typeof S!="object"?{label:S}:S}hasEdge(S,D,W){var J=arguments.length===1?I(this._isDirected,arguments[0]):F(this._isDirected,S,D,W);return Object.hasOwn(this._edgeLabels,J)}removeEdge(S,D,W){var J=arguments.length===1?I(this._isDirected,arguments[0]):F(this._isDirected,S,D,W),te=this._edgeObjs[J];return te&&(S=te.v,D=te.w,delete this._edgeLabels[J],delete this._edgeObjs[J],B(this._preds[D],S),B(this._sucs[S],D),delete this._in[D][J],delete this._out[S][J],this._edgeCount--),this}inEdges(S,D){return this.isDirected()?this.filterEdges(this._in[S],S,D):this.nodeEdges(S,D)}outEdges(S,D){return this.isDirected()?this.filterEdges(this._out[S],S,D):this.nodeEdges(S,D)}nodeEdges(S,D){if(S in this._nodes)return this.filterEdges({...this._in[S],...this._out[S]},S,D)}filterEdges(S,D,W){if(S){var J=Object.values(S);return W?J.filter(function(te){return te.v===D&&te.w===W||te.v===W&&te.w===D}):J}}};function Z(S,D){S[D]?S[D]++:S[D]=1}function B(S,D){--S[D]||delete S[D]}function F(S,D,W,J){var te=""+D,re=""+W;if(!S&&te>re){var oe=te;te=re,re=oe}return te+V+re+V+(J===void 0?z:J)}function K(S,D,W,J){var te=""+D,re=""+W;if(!S&&te>re){var oe=te;te=re,re=oe}var me={v:te,w:re};return J&&(me.name=J),me}function I(S,D){return F(S,D.v,D.w,D.name)}T.exports=H}),u=i(($,T)=>{T.exports="3.0.2"}),h=i(($,T)=>{T.exports={Graph:d(),version:u()}}),f=i(($,T)=>{var z=d();T.exports={write:O,read:Z};function O(B){var F={options:{directed:B.isDirected(),multigraph:B.isMultigraph(),compound:B.isCompound()},nodes:V(B),edges:H(B)};return B.graph()!==void 0&&(F.value=structuredClone(B.graph())),F}function V(B){return B.nodes().map(function(F){var K=B.node(F),I=B.parent(F),S={v:F};return K!==void 0&&(S.value=K),I!==void 0&&(S.parent=I),S})}function H(B){return B.edges().map(function(F){var K=B.edge(F),I={v:F.v,w:F.w};return F.name!==void 0&&(I.name=F.name),K!==void 0&&(I.value=K),I})}function Z(B){var F=new z(B.options).setGraph(B.value);return B.nodes.forEach(function(K){F.setNode(K.v,K.value),K.parent&&F.setParent(K.v,K.parent)}),B.edges.forEach(function(K){F.setEdge({v:K.v,w:K.w,name:K.name},K.value)}),F}}),x=i(($,T)=>{T.exports=O;var z=()=>1;function O(H,Z,B,F){return V(H,String(Z),B||z,F||function(K){return H.outEdges(K)})}function V(H,Z,B,F){var K={},I=!0,S=0,D=H.nodes(),W=function(oe){var me=B(oe);K[oe.v].distance+me<K[oe.w].distance&&(K[oe.w]={distance:K[oe.v].distance+me,predecessor:oe.v},I=!0)},J=function(){D.forEach(function(oe){F(oe).forEach(function(me){var Oe=me.v===oe?me.v:me.w,ve=Oe===me.v?me.w:me.v;W({v:Oe,w:ve})})})};D.forEach(function(oe){var me=oe===Z?0:Number.POSITIVE_INFINITY;K[oe]={distance:me}});for(var te=D.length,re=1;re<te&&(I=!1,S++,J(),!!I);re++);if(S===te-1&&(I=!1,J(),I))throw new Error("The graph contains a negative weight cycle");return K}}),p=i(($,T)=>{T.exports=z;function z(O){var V={},H=[],Z;function B(F){Object.hasOwn(V,F)||(V[F]=!0,Z.push(F),O.successors(F).forEach(B),O.predecessors(F).forEach(B))}return O.nodes().forEach(function(F){Z=[],B(F),Z.length&&H.push(Z)}),H}}),g=i(($,T)=>{var z=class{constructor(){c(this,"_arr",[]),c(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(O){return O.key})}has(O){return Object.hasOwn(this._keyIndices,O)}priority(O){var V=this._keyIndices[O];if(V!==void 0)return this._arr[V].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(O,V){var H=this._keyIndices;if(O=String(O),!Object.hasOwn(H,O)){var Z=this._arr,B=Z.length;return H[O]=B,Z.push({key:O,priority:V}),this._decrease(B),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var O=this._arr.pop();return delete this._keyIndices[O.key],this._heapify(0),O.key}decrease(O,V){var H=this._keyIndices[O];if(V>this._arr[H].priority)throw new Error("New priority is greater than current priority. Key: "+O+" Old: "+this._arr[H].priority+" New: "+V);this._arr[H].priority=V,this._decrease(H)}_heapify(O){var V=this._arr,H=2*O,Z=H+1,B=O;H<V.length&&(B=V[H].priority<V[B].priority?H:B,Z<V.length&&(B=V[Z].priority<V[B].priority?Z:B),B!==O&&(this._swap(O,B),this._heapify(B)))}_decrease(O){for(var V=this._arr,H=V[O].priority,Z;O!==0&&(Z=O>>1,!(V[Z].priority<H));)this._swap(O,Z),O=Z}_swap(O,V){var H=this._arr,Z=this._keyIndices,B=H[O],F=H[V];H[O]=F,H[V]=B,Z[F.key]=O,Z[B.key]=V}};T.exports=z}),b=i(($,T)=>{var z=g();T.exports=V;var O=()=>1;function V(Z,B,F,K){var I=function(S){return Z.outEdges(S)};return H(Z,String(B),F||O,K||I)}function H(Z,B,F,K){var I={},S=new z,D,W,J=function(te){var re=te.v!==D?te.v:te.w,oe=I[re],me=F(te),Oe=W.distance+me;if(me<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+te+" Weight: "+me);Oe<oe.distance&&(oe.distance=Oe,oe.predecessor=D,S.decrease(re,Oe))};for(Z.nodes().forEach(function(te){var re=te===B?0:Number.POSITIVE_INFINITY;I[te]={distance:re},S.add(te,re)});S.size()>0&&(D=S.removeMin(),W=I[D],W.distance!==Number.POSITIVE_INFINITY);)K(D).forEach(J);return I}}),w=i(($,T)=>{var z=b();T.exports=O;function O(V,H,Z){return V.nodes().reduce(function(B,F){return B[F]=z(V,F,H,Z),B},{})}}),k=i(($,T)=>{T.exports=z;function z(V,H,Z){if(V[H].predecessor!==void 0)throw new Error("Invalid source vertex");if(V[Z].predecessor===void 0&&Z!==H)throw new Error("Invalid destination vertex");return{weight:V[Z].distance,path:O(V,H,Z)}}function O(V,H,Z){for(var B=[],F=Z;F!==H;)B.push(F),F=V[F].predecessor;return B.push(H),B.reverse()}}),C=i(($,T)=>{T.exports=z;function z(O){var V=0,H=[],Z={},B=[];function F(K){var I=Z[K]={onStack:!0,lowlink:V,index:V++};if(H.push(K),O.successors(K).forEach(function(W){Object.hasOwn(Z,W)?Z[W].onStack&&(I.lowlink=Math.min(I.lowlink,Z[W].index)):(F(W),I.lowlink=Math.min(I.lowlink,Z[W].lowlink))}),I.lowlink===I.index){var S=[],D;do D=H.pop(),Z[D].onStack=!1,S.push(D);while(K!==D);B.push(S)}}return O.nodes().forEach(function(K){Object.hasOwn(Z,K)||F(K)}),B}}),E=i(($,T)=>{var z=C();T.exports=O;function O(V){return z(V).filter(function(H){return H.length>1||H.length===1&&V.hasEdge(H[0],H[0])})}}),M=i(($,T)=>{T.exports=O;var z=()=>1;function O(H,Z,B){return V(H,Z||z,B||function(F){return H.outEdges(F)})}function V(H,Z,B){var F={},K=H.nodes();return K.forEach(function(I){F[I]={},F[I][I]={distance:0},K.forEach(function(S){I!==S&&(F[I][S]={distance:Number.POSITIVE_INFINITY})}),B(I).forEach(function(S){var D=S.v===I?S.w:S.v,W=Z(S);F[I][D]={distance:W,predecessor:I}})}),K.forEach(function(I){var S=F[I];K.forEach(function(D){var W=F[D];K.forEach(function(J){var te=W[I],re=S[J],oe=W[J],me=te.distance+re.distance;me<oe.distance&&(oe.distance=me,oe.predecessor=re.predecessor)})})}),F}}),N=i(($,T)=>{function z(V){var H={},Z={},B=[];function F(K){if(Object.hasOwn(Z,K))throw new O;Object.hasOwn(H,K)||(Z[K]=!0,H[K]=!0,V.predecessors(K).forEach(F),delete Z[K],B.push(K))}if(V.sinks().forEach(F),Object.keys(H).length!==V.nodeCount())throw new O;return B}var O=class extends Error{constructor(){super(...arguments)}};T.exports=z,z.CycleException=O}),A=i(($,T)=>{var z=N();T.exports=O;function O(V){try{z(V)}catch(H){if(H instanceof z.CycleException)return!1;throw H}return!0}}),R=i(($,T)=>{T.exports=z;function z(V,H,Z,B,F){Array.isArray(H)||(H=[H]);var K=(V.isDirected()?V.successors:V.neighbors).bind(V),I={};return H.forEach(function(S){if(!V.hasNode(S))throw new Error("Graph does not have node: "+S);F=O(V,S,Z==="post",I,K,B,F)}),F}function O(V,H,Z,B,F,K,I){return Object.hasOwn(B,H)||(B[H]=!0,Z||(I=K(I,H)),F(H).forEach(function(S){I=O(V,S,Z,B,F,K,I)}),Z&&(I=K(I,H))),I}}),_=i(($,T)=>{var z=R();T.exports=O;function O(V,H,Z){return z(V,H,Z,function(B,F){return B.push(F),B},[])}}),Y=i(($,T)=>{var z=_();T.exports=O;function O(V,H){return z(V,H,"post")}}),q=i(($,T)=>{var z=_();T.exports=O;function O(V,H){return z(V,H,"pre")}}),X=i(($,T)=>{var z=d(),O=g();T.exports=V;function V(H,Z){var B=new z,F={},K=new O,I;function S(W){var J=W.v===I?W.w:W.v,te=K.priority(J);if(te!==void 0){var re=Z(W);re<te&&(F[J]=I,K.decrease(J,re))}}if(H.nodeCount()===0)return B;H.nodes().forEach(function(W){K.add(W,Number.POSITIVE_INFINITY),B.setNode(W)}),K.decrease(H.nodes()[0],0);for(var D=!1;K.size()>0;){if(I=K.removeMin(),Object.hasOwn(F,I))B.setEdge(I,F[I]);else{if(D)throw new Error("Input graph is not connected: "+H);D=!0}H.nodeEdges(I).forEach(S)}return B}}),L=i(($,T)=>{var z=b(),O=x();T.exports=V;function V(Z,B,F,K){return H(Z,B,F,K||function(I){return Z.outEdges(I)})}function H(Z,B,F,K){if(F===void 0)return z(Z,B,F,K);for(var I=!1,S=Z.nodes(),D=0;D<S.length;D++){for(var W=K(S[D]),J=0;J<W.length;J++){var te=W[J],re=te.v===S[D]?te.v:te.w,oe=re===te.v?te.w:te.v;F({v:re,w:oe})<0&&(I=!0)}if(I)return O(Z,B,F,K)}return z(Z,B,F,K)}}),P=i(($,T)=>{T.exports={bellmanFord:x(),components:p(),dijkstra:b(),dijkstraAll:w(),extractPath:k(),findCycles:E(),floydWarshall:M(),isAcyclic:A(),postorder:Y(),preorder:q(),prim:X(),shortestPaths:L(),reduce:R(),tarjan:C(),topsort:N()}}),G=h();n.exports={Graph:G.Graph,json:f(),alg:P(),version:G.version}}),zI=gn((e,n)=>{var s=class{constructor(){let c={};c._next=c._prev=c,this._sentinel=c}dequeue(){let c=this._sentinel,d=c._prev;if(d!==c)return l(d),d}enqueue(c){let d=this._sentinel;c._prev&&c._next&&l(c),c._next=d._next,d._next._prev=c,d._next=c,c._prev=d}toString(){let c=[],d=this._sentinel,u=d._prev;for(;u!==d;)c.push(JSON.stringify(u,i)),u=u._prev;return"["+c.join(", ")+"]"}};function l(c){c._prev._next=c._next,c._next._prev=c._prev,delete c._next,delete c._prev}function i(c,d){if(c!=="_next"&&c!=="_prev")return d}n.exports=s}),$I=gn((e,n)=>{var s=Ms().Graph,l=zI();n.exports=c;var i=()=>1;function c(p,g){if(p.nodeCount()<=1)return[];let b=h(p,g||i);return d(b.graph,b.buckets,b.zeroIdx).flatMap(w=>p.outEdges(w.v,w.w))}function d(p,g,b){let w=[],k=g[g.length-1],C=g[0],E;for(;p.nodeCount();){for(;E=C.dequeue();)u(p,g,b,E);for(;E=k.dequeue();)u(p,g,b,E);if(p.nodeCount()){for(let M=g.length-2;M>0;--M)if(E=g[M].dequeue(),E){w=w.concat(u(p,g,b,E,!0));break}}}return w}function u(p,g,b,w,k){let C=k?[]:void 0;return p.inEdges(w.v).forEach(E=>{let M=p.edge(E),N=p.node(E.v);k&&C.push({v:E.v,w:E.w}),N.out-=M,f(g,b,N)}),p.outEdges(w.v).forEach(E=>{let M=p.edge(E),N=E.w,A=p.node(N);A.in-=M,f(g,b,A)}),p.removeNode(w.v),C}function h(p,g){let b=new s,w=0,k=0;p.nodes().forEach(M=>{b.setNode(M,{v:M,in:0,out:0})}),p.edges().forEach(M=>{let N=b.edge(M.v,M.w)||0,A=g(M),R=N+A;b.setEdge(M.v,M.w,R),k=Math.max(k,b.node(M.v).out+=A),w=Math.max(w,b.node(M.w).in+=A)});let C=x(k+w+3).map(()=>new l),E=w+1;return b.nodes().forEach(M=>{f(C,E,b.node(M))}),{graph:b,buckets:C,zeroIdx:E}}function f(p,g,b){b.out?b.in?p[b.out-b.in+g].enqueue(b):p[p.length-1].enqueue(b):p[0].enqueue(b)}function x(p){let g=[];for(let b=0;b<p;b++)g.push(b);return g}}),nr=gn((e,n)=>{var s=Ms().Graph;n.exports={addBorderNode:g,addDummyNode:l,applyWithChunking:k,asNonCompoundGraph:c,buildLayerMatrix:f,intersectRect:h,mapValues:q,maxRank:C,normalizeRanks:x,notime:N,partition:E,pick:Y,predecessorWeights:u,range:_,removeEmptyRanks:p,simplify:i,successorWeights:d,time:M,uniqueId:R,zipObject:X};function l(L,P,G,$){for(var T=$;L.hasNode(T);)T=R($);return G.dummy=P,L.setNode(T,G),T}function i(L){let P=new s().setGraph(L.graph());return L.nodes().forEach(G=>P.setNode(G,L.node(G))),L.edges().forEach(G=>{let $=P.edge(G.v,G.w)||{weight:0,minlen:1},T=L.edge(G);P.setEdge(G.v,G.w,{weight:$.weight+T.weight,minlen:Math.max($.minlen,T.minlen)})}),P}function c(L){let P=new s({multigraph:L.isMultigraph()}).setGraph(L.graph());return L.nodes().forEach(G=>{L.children(G).length||P.setNode(G,L.node(G))}),L.edges().forEach(G=>{P.setEdge(G,L.edge(G))}),P}function d(L){let P=L.nodes().map(G=>{let $={};return L.outEdges(G).forEach(T=>{$[T.w]=($[T.w]||0)+L.edge(T).weight}),$});return X(L.nodes(),P)}function u(L){let P=L.nodes().map(G=>{let $={};return L.inEdges(G).forEach(T=>{$[T.v]=($[T.v]||0)+L.edge(T).weight}),$});return X(L.nodes(),P)}function h(L,P){let G=L.x,$=L.y,T=P.x-G,z=P.y-$,O=L.width/2,V=L.height/2;if(!T&&!z)throw new Error("Not possible to find intersection inside of the rectangle");let H,Z;return Math.abs(z)*O>Math.abs(T)*V?(z<0&&(V=-V),H=V*T/z,Z=V):(T<0&&(O=-O),H=O,Z=O*z/T),{x:G+H,y:$+Z}}function f(L){let P=_(C(L)+1).map(()=>[]);return L.nodes().forEach(G=>{let $=L.node(G),T=$.rank;T!==void 0&&(P[T][$.order]=G)}),P}function x(L){let P=L.nodes().map($=>{let T=L.node($).rank;return T===void 0?Number.MAX_VALUE:T}),G=k(Math.min,P);L.nodes().forEach($=>{let T=L.node($);Object.hasOwn(T,"rank")&&(T.rank-=G)})}function p(L){let P=L.nodes().map(O=>L.node(O).rank).filter(O=>O!==void 0),G=k(Math.min,P),$=[];L.nodes().forEach(O=>{let V=L.node(O).rank-G;$[V]||($[V]=[]),$[V].push(O)});let T=0,z=L.graph().nodeRankFactor;Array.from($).forEach((O,V)=>{O===void 0&&V%z!==0?--T:O!==void 0&&T&&O.forEach(H=>L.node(H).rank+=T)})}function g(L,P,G,$){let T={width:0,height:0};return arguments.length>=4&&(T.rank=G,T.order=$),l(L,"border",T,P)}function b(L,P=w){let G=[];for(let $=0;$<L.length;$+=P){let T=L.slice($,$+P);G.push(T)}return G}var w=65535;function k(L,P){if(P.length>w){let G=b(P);return L.apply(null,G.map($=>L.apply(null,$)))}else return L.apply(null,P)}function C(L){let P=L.nodes().map(G=>{let $=L.node(G).rank;return $===void 0?Number.MIN_VALUE:$});return k(Math.max,P)}function E(L,P){let G={lhs:[],rhs:[]};return L.forEach($=>{P($)?G.lhs.push($):G.rhs.push($)}),G}function M(L,P){let G=Date.now();try{return P()}finally{console.log(L+" time: "+(Date.now()-G)+"ms")}}function N(L,P){return P()}var A=0;function R(L){var P=++A;return L+(""+P)}function _(L,P,G=1){P==null&&(P=L,L=0);let $=z=>z<P;G<0&&($=z=>P<z);let T=[];for(let z=L;$(z);z+=G)T.push(z);return T}function Y(L,P){let G={};for(let $ of P)L[$]!==void 0&&(G[$]=L[$]);return G}function q(L,P){let G=P;return typeof P=="string"&&(G=$=>$[P]),Object.entries(L).reduce(($,[T,z])=>($[T]=G(z,T),$),{})}function X(L,P){return L.reduce((G,$,T)=>(G[$]=P[T],G),{})}}),BI=gn((e,n)=>{var s=$I(),l=nr().uniqueId;n.exports={run:i,undo:d};function i(u){(u.graph().acyclicer==="greedy"?s(u,h(u)):c(u)).forEach(f=>{let x=u.edge(f);u.removeEdge(f),x.forwardName=f.name,x.reversed=!0,u.setEdge(f.w,f.v,x,l("rev"))});function h(f){return x=>f.edge(x).weight}}function c(u){let h=[],f={},x={};function p(g){Object.hasOwn(x,g)||(x[g]=!0,f[g]=!0,u.outEdges(g).forEach(b=>{Object.hasOwn(f,b.w)?h.push(b):p(b.w)}),delete f[g])}return u.nodes().forEach(p),h}function d(u){u.edges().forEach(h=>{let f=u.edge(h);if(f.reversed){u.removeEdge(h);let x=f.forwardName;delete f.reversed,delete f.forwardName,u.setEdge(h.w,h.v,f,x)}})}}),HI=gn((e,n)=>{var s=nr();n.exports={run:l,undo:c};function l(d){d.graph().dummyChains=[],d.edges().forEach(u=>i(d,u))}function i(d,u){let h=u.v,f=d.node(h).rank,x=u.w,p=d.node(x).rank,g=u.name,b=d.edge(u),w=b.labelRank;if(p===f+1)return;d.removeEdge(u);let k,C,E;for(E=0,++f;f<p;++E,++f)b.points=[],C={width:0,height:0,edgeLabel:b,edgeObj:u,rank:f},k=s.addDummyNode(d,"edge",C,"_d"),f===w&&(C.width=b.width,C.height=b.height,C.dummy="edge-label",C.labelpos=b.labelpos),d.setEdge(h,k,{weight:b.weight},g),E===0&&d.graph().dummyChains.push(k),h=k;d.setEdge(h,x,{weight:b.weight},g)}function c(d){d.graph().dummyChains.forEach(u=>{let h=d.node(u),f=h.edgeLabel,x;for(d.setEdge(h.edgeObj,f);h.dummy;)x=d.successors(u)[0],d.removeNode(u),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),u=x,h=d.node(u)})}}),bu=gn((e,n)=>{var{applyWithChunking:s}=nr();n.exports={longestPath:l,slack:i};function l(c){var d={};function u(h){var f=c.node(h);if(Object.hasOwn(d,h))return f.rank;d[h]=!0;let x=c.outEdges(h).map(g=>g==null?Number.POSITIVE_INFINITY:u(g.w)-c.edge(g).minlen);var p=s(Math.min,x);return p===Number.POSITIVE_INFINITY&&(p=0),f.rank=p}c.sources().forEach(u)}function i(c,d){return c.node(d.w).rank-c.node(d.v).rank-c.edge(d).minlen}}),d5=gn((e,n)=>{var s=Ms().Graph,l=bu().slack;n.exports=i;function i(h){var f=new s({directed:!1}),x=h.nodes()[0],p=h.nodeCount();f.setNode(x,{});for(var g,b;c(f,h)<p;)g=d(f,h),b=f.hasNode(g.v)?l(h,g):-l(h,g),u(f,h,b);return f}function c(h,f){function x(p){f.nodeEdges(p).forEach(g=>{var b=g.v,w=p===b?g.w:b;!h.hasNode(w)&&!l(f,g)&&(h.setNode(w,{}),h.setEdge(p,w,{}),x(w))})}return h.nodes().forEach(x),h.nodeCount()}function d(h,f){return f.edges().reduce((x,p)=>{let g=Number.POSITIVE_INFINITY;return h.hasNode(p.v)!==h.hasNode(p.w)&&(g=l(f,p)),g<x[0]?[g,p]:x},[Number.POSITIVE_INFINITY,null])[1]}function u(h,f,x){h.nodes().forEach(p=>f.node(p).rank+=x)}}),PI=gn((e,n)=>{var s=d5(),l=bu().slack,i=bu().longestPath,c=Ms().alg.preorder,d=Ms().alg.postorder,u=nr().simplify;n.exports=h,h.initLowLimValues=g,h.initCutValues=f,h.calcCutValue=p,h.leaveEdge=w,h.enterEdge=k,h.exchangeEdges=C;function h(A){A=u(A),i(A);var R=s(A);g(R),f(R,A);for(var _,Y;_=w(R);)Y=k(R,A,_),C(R,A,_,Y)}function f(A,R){var _=d(A,A.nodes());_=_.slice(0,_.length-1),_.forEach(Y=>x(A,R,Y))}function x(A,R,_){var Y=A.node(_),q=Y.parent;A.edge(_,q).cutvalue=p(A,R,_)}function p(A,R,_){var Y=A.node(_),q=Y.parent,X=!0,L=R.edge(_,q),P=0;return L||(X=!1,L=R.edge(q,_)),P=L.weight,R.nodeEdges(_).forEach(G=>{var $=G.v===_,T=$?G.w:G.v;if(T!==q){var z=$===X,O=R.edge(G).weight;if(P+=z?O:-O,M(A,_,T)){var V=A.edge(_,T).cutvalue;P+=z?-V:V}}}),P}function g(A,R){arguments.length<2&&(R=A.nodes()[0]),b(A,{},1,R)}function b(A,R,_,Y,q){var X=_,L=A.node(Y);return R[Y]=!0,A.neighbors(Y).forEach(P=>{Object.hasOwn(R,P)||(_=b(A,R,_,P,Y))}),L.low=X,L.lim=_++,q?L.parent=q:delete L.parent,_}function w(A){return A.edges().find(R=>A.edge(R).cutvalue<0)}function k(A,R,_){var Y=_.v,q=_.w;R.hasEdge(Y,q)||(Y=_.w,q=_.v);var X=A.node(Y),L=A.node(q),P=X,G=!1;X.lim>L.lim&&(P=L,G=!0);var $=R.edges().filter(T=>G===N(A,A.node(T.v),P)&&G!==N(A,A.node(T.w),P));return $.reduce((T,z)=>l(R,z)<l(R,T)?z:T)}function C(A,R,_,Y){var q=_.v,X=_.w;A.removeEdge(q,X),A.setEdge(Y.v,Y.w,{}),g(A),f(A,R),E(A,R)}function E(A,R){var _=A.nodes().find(q=>!R.node(q).parent),Y=c(A,_);Y=Y.slice(1),Y.forEach(q=>{var X=A.node(q).parent,L=R.edge(q,X),P=!1;L||(L=R.edge(X,q),P=!0),R.node(q).rank=R.node(X).rank+(P?L.minlen:-L.minlen)})}function M(A,R,_){return A.hasEdge(R,_)}function N(A,R,_){return _.low<=R.lim&&R.lim<=_.lim}}),UI=gn((e,n)=>{var s=bu(),l=s.longestPath,i=d5(),c=PI();n.exports=d;function d(x){var p=x.graph().ranker;if(p instanceof Function)return p(x);switch(x.graph().ranker){case"network-simplex":f(x);break;case"tight-tree":h(x);break;case"longest-path":u(x);break;case"none":break;default:f(x)}}var u=l;function h(x){l(x),i(x)}function f(x){c(x)}}),qI=gn((e,n)=>{n.exports=s;function s(c){let d=i(c);c.graph().dummyChains.forEach(u=>{let h=c.node(u),f=h.edgeObj,x=l(c,d,f.v,f.w),p=x.path,g=x.lca,b=0,w=p[b],k=!0;for(;u!==f.w;){if(h=c.node(u),k){for(;(w=p[b])!==g&&c.node(w).maxRank<h.rank;)b++;w===g&&(k=!1)}if(!k){for(;b<p.length-1&&c.node(w=p[b+1]).minRank<=h.rank;)b++;w=p[b]}c.setParent(u,w),u=c.successors(u)[0]}})}function l(c,d,u,h){let f=[],x=[],p=Math.min(d[u].low,d[h].low),g=Math.max(d[u].lim,d[h].lim),b,w;b=u;do b=c.parent(b),f.push(b);while(b&&(d[b].low>p||g>d[b].lim));for(w=b,b=h;(b=c.parent(b))!==w;)x.push(b);return{path:f.concat(x.reverse()),lca:w}}function i(c){let d={},u=0;function h(f){let x=u;c.children(f).forEach(h),d[f]={low:x,lim:u++}}return c.children().forEach(h),d}}),FI=gn((e,n)=>{var s=nr();n.exports={run:l,cleanup:u};function l(h){let f=s.addDummyNode(h,"root",{},"_root"),x=c(h),p=Object.values(x),g=s.applyWithChunking(Math.max,p)-1,b=2*g+1;h.graph().nestingRoot=f,h.edges().forEach(k=>h.edge(k).minlen*=b);let w=d(h)+1;h.children().forEach(k=>i(h,f,b,w,g,x,k)),h.graph().nodeRankFactor=b}function i(h,f,x,p,g,b,w){let k=h.children(w);if(!k.length){w!==f&&h.setEdge(f,w,{weight:0,minlen:x});return}let C=s.addBorderNode(h,"_bt"),E=s.addBorderNode(h,"_bb"),M=h.node(w);h.setParent(C,w),M.borderTop=C,h.setParent(E,w),M.borderBottom=E,k.forEach(N=>{i(h,f,x,p,g,b,N);let A=h.node(N),R=A.borderTop?A.borderTop:N,_=A.borderBottom?A.borderBottom:N,Y=A.borderTop?p:2*p,q=R!==_?1:g-b[w]+1;h.setEdge(C,R,{weight:Y,minlen:q,nestingEdge:!0}),h.setEdge(_,E,{weight:Y,minlen:q,nestingEdge:!0})}),h.parent(w)||h.setEdge(f,C,{weight:0,minlen:g+b[w]})}function c(h){var f={};function x(p,g){var b=h.children(p);b&&b.length&&b.forEach(w=>x(w,g+1)),f[p]=g}return h.children().forEach(p=>x(p,1)),f}function d(h){return h.edges().reduce((f,x)=>f+h.edge(x).weight,0)}function u(h){var f=h.graph();h.removeNode(f.nestingRoot),delete f.nestingRoot,h.edges().forEach(x=>{var p=h.edge(x);p.nestingEdge&&h.removeEdge(x)})}}),VI=gn((e,n)=>{var s=nr();n.exports=l;function l(c){function d(u){let h=c.children(u),f=c.node(u);if(h.length&&h.forEach(d),Object.hasOwn(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(let x=f.minRank,p=f.maxRank+1;x<p;++x)i(c,"borderLeft","_bl",u,f,x),i(c,"borderRight","_br",u,f,x)}}c.children().forEach(d)}function i(c,d,u,h,f,x){let p={width:0,height:0,rank:x,borderType:d},g=f[d][x-1],b=s.addDummyNode(c,"border",p,u);f[d][x]=b,c.setParent(b,h),g&&c.setEdge(g,b,{weight:1})}}),YI=gn((e,n)=>{n.exports={adjust:s,undo:l};function s(x){let p=x.graph().rankdir.toLowerCase();(p==="lr"||p==="rl")&&i(x)}function l(x){let p=x.graph().rankdir.toLowerCase();(p==="bt"||p==="rl")&&d(x),(p==="lr"||p==="rl")&&(h(x),i(x))}function i(x){x.nodes().forEach(p=>c(x.node(p))),x.edges().forEach(p=>c(x.edge(p)))}function c(x){let p=x.width;x.width=x.height,x.height=p}function d(x){x.nodes().forEach(p=>u(x.node(p))),x.edges().forEach(p=>{let g=x.edge(p);g.points.forEach(u),Object.hasOwn(g,"y")&&u(g)})}function u(x){x.y=-x.y}function h(x){x.nodes().forEach(p=>f(x.node(p))),x.edges().forEach(p=>{let g=x.edge(p);g.points.forEach(f),Object.hasOwn(g,"x")&&f(g)})}function f(x){let p=x.x;x.x=x.y,x.y=p}}),GI=gn((e,n)=>{var s=nr();n.exports=l;function l(i){let c={},d=i.nodes().filter(p=>!i.children(p).length),u=d.map(p=>i.node(p).rank),h=s.applyWithChunking(Math.max,u),f=s.range(h+1).map(()=>[]);function x(p){if(c[p])return;c[p]=!0;let g=i.node(p);f[g.rank].push(p),i.successors(p).forEach(x)}return d.sort((p,g)=>i.node(p).rank-i.node(g).rank).forEach(x),f}}),XI=gn((e,n)=>{var s=nr().zipObject;n.exports=l;function l(c,d){let u=0;for(let h=1;h<d.length;++h)u+=i(c,d[h-1],d[h]);return u}function i(c,d,u){let h=s(u,u.map((w,k)=>k)),f=d.flatMap(w=>c.outEdges(w).map(k=>({pos:h[k.w],weight:c.edge(k).weight})).sort((k,C)=>k.pos-C.pos)),x=1;for(;x<u.length;)x<<=1;let p=2*x-1;x-=1;let g=new Array(p).fill(0),b=0;return f.forEach(w=>{let k=w.pos+x;g[k]+=w.weight;let C=0;for(;k>0;)k%2&&(C+=g[k+1]),k=k-1>>1,g[k]+=w.weight;b+=w.weight*C}),b}}),KI=gn((e,n)=>{n.exports=s;function s(l,i=[]){return i.map(c=>{let d=l.inEdges(c);if(d.length){let u=d.reduce((h,f)=>{let x=l.edge(f),p=l.node(f.v);return{sum:h.sum+x.weight*p.order,weight:h.weight+x.weight}},{sum:0,weight:0});return{v:c,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:c}})}}),WI=gn((e,n)=>{var s=nr();n.exports=l;function l(d,u){let h={};d.forEach((x,p)=>{let g=h[x.v]={indegree:0,in:[],out:[],vs:[x.v],i:p};x.barycenter!==void 0&&(g.barycenter=x.barycenter,g.weight=x.weight)}),u.edges().forEach(x=>{let p=h[x.v],g=h[x.w];p!==void 0&&g!==void 0&&(g.indegree++,p.out.push(h[x.w]))});let f=Object.values(h).filter(x=>!x.indegree);return i(f)}function i(d){let u=[];function h(x){return p=>{p.merged||(p.barycenter===void 0||x.barycenter===void 0||p.barycenter>=x.barycenter)&&c(x,p)}}function f(x){return p=>{p.in.push(x),--p.indegree===0&&d.push(p)}}for(;d.length;){let x=d.pop();u.push(x),x.in.reverse().forEach(h(x)),x.out.forEach(f(x))}return u.filter(x=>!x.merged).map(x=>s.pick(x,["vs","i","barycenter","weight"]))}function c(d,u){let h=0,f=0;d.weight&&(h+=d.barycenter*d.weight,f+=d.weight),u.weight&&(h+=u.barycenter*u.weight,f+=u.weight),d.vs=u.vs.concat(d.vs),d.barycenter=h/f,d.weight=f,d.i=Math.min(u.i,d.i),u.merged=!0}}),ZI=gn((e,n)=>{var s=nr();n.exports=l;function l(d,u){let h=s.partition(d,C=>Object.hasOwn(C,"barycenter")),f=h.lhs,x=h.rhs.sort((C,E)=>E.i-C.i),p=[],g=0,b=0,w=0;f.sort(c(!!u)),w=i(p,x,w),f.forEach(C=>{w+=C.vs.length,p.push(C.vs),g+=C.barycenter*C.weight,b+=C.weight,w=i(p,x,w)});let k={vs:p.flat(!0)};return b&&(k.barycenter=g/b,k.weight=b),k}function i(d,u,h){let f;for(;u.length&&(f=u[u.length-1]).i<=h;)u.pop(),d.push(f.vs),h++;return h}function c(d){return(u,h)=>u.barycenter<h.barycenter?-1:u.barycenter>h.barycenter?1:d?h.i-u.i:u.i-h.i}}),QI=gn((e,n)=>{var s=KI(),l=WI(),i=ZI();n.exports=c;function c(h,f,x,p){let g=h.children(f),b=h.node(f),w=b?b.borderLeft:void 0,k=b?b.borderRight:void 0,C={};w&&(g=g.filter(A=>A!==w&&A!==k));let E=s(h,g);E.forEach(A=>{if(h.children(A.v).length){let R=c(h,A.v,x,p);C[A.v]=R,Object.hasOwn(R,"barycenter")&&u(A,R)}});let M=l(E,x);d(M,C);let N=i(M,p);if(w&&(N.vs=[w,N.vs,k].flat(!0),h.predecessors(w).length)){let A=h.node(h.predecessors(w)[0]),R=h.node(h.predecessors(k)[0]);Object.hasOwn(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+A.order+R.order)/(N.weight+2),N.weight+=2}return N}function d(h,f){h.forEach(x=>{x.vs=x.vs.flatMap(p=>f[p]?f[p].vs:p)})}function u(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)}}),JI=gn((e,n)=>{var s=Ms().Graph,l=nr();n.exports=i;function i(d,u,h,f){f||(f=d.nodes());let x=c(d),p=new s({compound:!0}).setGraph({root:x}).setDefaultNodeLabel(g=>d.node(g));return f.forEach(g=>{let b=d.node(g),w=d.parent(g);(b.rank===u||b.minRank<=u&&u<=b.maxRank)&&(p.setNode(g),p.setParent(g,w||x),d[h](g).forEach(k=>{let C=k.v===g?k.w:k.v,E=p.edge(C,g),M=E!==void 0?E.weight:0;p.setEdge(C,g,{weight:d.edge(k).weight+M})}),Object.hasOwn(b,"minRank")&&p.setNode(g,{borderLeft:b.borderLeft[u],borderRight:b.borderRight[u]}))}),p}function c(d){for(var u;d.hasNode(u=l.uniqueId("_root")););return u}}),ez=gn((e,n)=>{n.exports=s;function s(l,i,c){let d={},u;c.forEach(h=>{let f=l.parent(h),x,p;for(;f;){if(x=l.parent(f),x?(p=d[x],d[x]=f):(p=u,u=f),p&&p!==f){i.setEdge(p,f);return}f=x}})}}),tz=gn((e,n)=>{var s=GI(),l=XI(),i=QI(),c=JI(),d=ez(),u=Ms().Graph,h=nr();n.exports=f;function f(b,w={}){if(typeof w.customOrder=="function"){w.customOrder(b,f);return}let k=h.maxRank(b),C=x(b,h.range(1,k+1),"inEdges"),E=x(b,h.range(k-1,-1,-1),"outEdges"),M=s(b);if(g(b,M),w.disableOptimalOrderHeuristic)return;let N=Number.POSITIVE_INFINITY,A,R=w.constraints||[];for(let _=0,Y=0;Y<4;++_,++Y){p(_%2?C:E,_%4>=2,R),M=h.buildLayerMatrix(b);let q=l(b,M);q<N?(Y=0,A=Object.assign({},M),N=q):q===N&&(A=structuredClone(M))}g(b,A)}function x(b,w,k){let C=new Map,E=(M,N)=>{C.has(M)||C.set(M,[]),C.get(M).push(N)};for(let M of b.nodes()){let N=b.node(M);if(typeof N.rank=="number"&&E(N.rank,M),typeof N.minRank=="number"&&typeof N.maxRank=="number")for(let A=N.minRank;A<=N.maxRank;A++)A!==N.rank&&E(A,M)}return w.map(function(M){return c(b,M,k,C.get(M)||[])})}function p(b,w,k){let C=new u;b.forEach(function(E){k.forEach(A=>C.setEdge(A.left,A.right));let M=E.graph().root,N=i(E,M,C,w);N.vs.forEach((A,R)=>E.node(A).order=R),d(E,C,N.vs)})}function g(b,w){Object.values(w).forEach(k=>k.forEach((C,E)=>b.node(C).order=E))}}),nz=gn((e,n)=>{var s=Ms().Graph,l=nr();n.exports={positionX:k,findType1Conflicts:i,findType2Conflicts:c,addConflict:u,hasConflict:h,verticalAlignment:f,horizontalCompaction:x,alignCoordinates:b,findSmallestWidthAlignment:g,balance:w};function i(M,N){let A={};function R(_,Y){let q=0,X=0,L=_.length,P=Y[Y.length-1];return Y.forEach((G,$)=>{let T=d(M,G),z=T?M.node(T).order:L;(T||G===P)&&(Y.slice(X,$+1).forEach(O=>{M.predecessors(O).forEach(V=>{let H=M.node(V),Z=H.order;(Z<q||z<Z)&&!(H.dummy&&M.node(O).dummy)&&u(A,V,O)})}),X=$+1,q=z)}),Y}return N.length&&N.reduce(R),A}function c(M,N){let A={};function R(Y,q,X,L,P){let G;l.range(q,X).forEach($=>{G=Y[$],M.node(G).dummy&&M.predecessors(G).forEach(T=>{let z=M.node(T);z.dummy&&(z.order<L||z.order>P)&&u(A,T,G)})})}function _(Y,q){let X=-1,L,P=0;return q.forEach((G,$)=>{if(M.node(G).dummy==="border"){let T=M.predecessors(G);T.length&&(L=M.node(T[0]).order,R(q,P,$,X,L),P=$,X=L)}R(q,P,q.length,L,Y.length)}),q}return N.length&&N.reduce(_),A}function d(M,N){if(M.node(N).dummy)return M.predecessors(N).find(A=>M.node(A).dummy)}function u(M,N,A){if(N>A){let _=N;N=A,A=_}let R=M[N];R||(M[N]=R={}),R[A]=!0}function h(M,N,A){if(N>A){let R=N;N=A,A=R}return!!M[N]&&Object.hasOwn(M[N],A)}function f(M,N,A,R){let _={},Y={},q={};return N.forEach(X=>{X.forEach((L,P)=>{_[L]=L,Y[L]=L,q[L]=P})}),N.forEach(X=>{let L=-1;X.forEach(P=>{let G=R(P);if(G.length){G=G.sort((T,z)=>q[T]-q[z]);let $=(G.length-1)/2;for(let T=Math.floor($),z=Math.ceil($);T<=z;++T){let O=G[T];Y[P]===P&&L<q[O]&&!h(A,P,O)&&(Y[O]=P,Y[P]=_[P]=_[O],L=q[O])}}})}),{root:_,align:Y}}function x(M,N,A,R,_){let Y={},q=p(M,N,A,_),X=_?"borderLeft":"borderRight";function L($,T){let z=q.nodes().slice(),O={},V=z.pop();for(;V;){if(O[V])$(V);else{O[V]=!0,z.push(V);for(let H of T(V))z.push(H)}V=z.pop()}}function P($){Y[$]=q.inEdges($).reduce((T,z)=>Math.max(T,Y[z.v]+q.edge(z)),0)}function G($){let T=q.outEdges($).reduce((O,V)=>Math.min(O,Y[V.w]-q.edge(V)),Number.POSITIVE_INFINITY),z=M.node($);T!==Number.POSITIVE_INFINITY&&z.borderType!==X&&(Y[$]=Math.max(Y[$],T))}return L(P,q.predecessors.bind(q)),L(G,q.successors.bind(q)),Object.keys(R).forEach($=>Y[$]=Y[A[$]]),Y}function p(M,N,A,R){let _=new s,Y=M.graph(),q=C(Y.nodesep,Y.edgesep,R);return N.forEach(X=>{let L;X.forEach(P=>{let G=A[P];if(_.setNode(G),L){var $=A[L],T=_.edge($,G);_.setEdge($,G,Math.max(q(M,P,L),T||0))}L=P})}),_}function g(M,N){return Object.values(N).reduce((A,R)=>{let _=Number.NEGATIVE_INFINITY,Y=Number.POSITIVE_INFINITY;Object.entries(R).forEach(([X,L])=>{let P=E(M,X)/2;_=Math.max(L+P,_),Y=Math.min(L-P,Y)});let q=_-Y;return q<A[0]&&(A=[q,R]),A},[Number.POSITIVE_INFINITY,null])[1]}function b(M,N){let A=Object.values(N),R=l.applyWithChunking(Math.min,A),_=l.applyWithChunking(Math.max,A);["u","d"].forEach(Y=>{["l","r"].forEach(q=>{let X=Y+q,L=M[X];if(L===N)return;let P=Object.values(L),G=R-l.applyWithChunking(Math.min,P);q!=="l"&&(G=_-l.applyWithChunking(Math.max,P)),G&&(M[X]=l.mapValues(L,$=>$+G))})})}function w(M,N){return l.mapValues(M.ul,(A,R)=>{if(N)return M[N.toLowerCase()][R];{let _=Object.values(M).map(Y=>Y[R]).sort((Y,q)=>Y-q);return(_[1]+_[2])/2}})}function k(M){let N=l.buildLayerMatrix(M),A=Object.assign(i(M,N),c(M,N)),R={},_;["u","d"].forEach(q=>{_=q==="u"?N:Object.values(N).reverse(),["l","r"].forEach(X=>{X==="r"&&(_=_.map($=>Object.values($).reverse()));let L=(q==="u"?M.predecessors:M.successors).bind(M),P=f(M,_,A,L),G=x(M,_,P.root,P.align,X==="r");X==="r"&&(G=l.mapValues(G,$=>-$)),R[q+X]=G})});let Y=g(M,R);return b(R,Y),w(R,M.graph().align)}function C(M,N,A){return(R,_,Y)=>{let q=R.node(_),X=R.node(Y),L=0,P;if(L+=q.width/2,Object.hasOwn(q,"labelpos"))switch(q.labelpos.toLowerCase()){case"l":P=-q.width/2;break;case"r":P=q.width/2;break}if(P&&(L+=A?P:-P),P=0,L+=(q.dummy?N:M)/2,L+=(X.dummy?N:M)/2,L+=X.width/2,Object.hasOwn(X,"labelpos"))switch(X.labelpos.toLowerCase()){case"l":P=X.width/2;break;case"r":P=-X.width/2;break}return P&&(L+=A?P:-P),P=0,L}}function E(M,N){return M.node(N).width}}),rz=gn((e,n)=>{var s=nr(),l=nz().positionX;n.exports=i;function i(d){d=s.asNonCompoundGraph(d),c(d),Object.entries(l(d)).forEach(([u,h])=>d.node(u).x=h)}function c(d){let u=s.buildLayerMatrix(d),h=d.graph().ranksep,f=d.graph().rankalign,x=0;u.forEach(p=>{let g=p.reduce((b,w)=>{let k=d.node(w).height;return b>k?b:k},0);p.forEach(b=>{let w=d.node(b);f==="top"?w.y=x+w.height/2:f==="bottom"?w.y=x+g-w.height/2:w.y=x+g/2}),x+=g+h})}}),sz=gn((e,n)=>{var s=BI(),l=HI(),i=UI(),c=nr().normalizeRanks,d=qI(),u=nr().removeEmptyRanks,h=FI(),f=VI(),x=YI(),p=tz(),g=rz(),b=nr(),w=Ms().Graph;n.exports=k;function k(D,W={}){let J=W.debugTiming?b.time:b.notime;return J("layout",()=>{let te=J(" buildLayoutGraph",()=>L(D));return J(" runLayout",()=>C(te,J,W)),J(" updateInputGraph",()=>E(D,te)),te})}function C(D,W,J){W(" makeSpaceForEdgeLabels",()=>P(D)),W(" removeSelfEdges",()=>B(D)),W(" acyclic",()=>s.run(D)),W(" nestingGraph.run",()=>h.run(D)),W(" rank",()=>i(b.asNonCompoundGraph(D))),W(" injectEdgeLabelProxies",()=>G(D)),W(" removeEmptyRanks",()=>u(D)),W(" nestingGraph.cleanup",()=>h.cleanup(D)),W(" normalizeRanks",()=>c(D)),W(" assignRankMinMax",()=>$(D)),W(" removeEdgeLabelProxies",()=>T(D)),W(" normalize.run",()=>l.run(D)),W(" parentDummyChains",()=>d(D)),W(" addBorderSegments",()=>f(D)),W(" order",()=>p(D,J)),W(" insertSelfEdges",()=>F(D)),W(" adjustCoordinateSystem",()=>x.adjust(D)),W(" position",()=>g(D)),W(" positionSelfEdges",()=>K(D)),W(" removeBorderNodes",()=>Z(D)),W(" normalize.undo",()=>l.undo(D)),W(" fixupEdgeLabelCoords",()=>V(D)),W(" undoCoordinateSystem",()=>x.undo(D)),W(" translateGraph",()=>z(D)),W(" assignNodeIntersects",()=>O(D)),W(" reversePoints",()=>H(D)),W(" acyclic.undo",()=>s.undo(D))}function E(D,W){D.nodes().forEach(J=>{let te=D.node(J),re=W.node(J);te&&(te.x=re.x,te.y=re.y,te.order=re.order,te.rank=re.rank,W.children(J).length&&(te.width=re.width,te.height=re.height))}),D.edges().forEach(J=>{let te=D.edge(J),re=W.edge(J);te.points=re.points,Object.hasOwn(re,"x")&&(te.x=re.x,te.y=re.y)}),D.graph().width=W.graph().width,D.graph().height=W.graph().height}var M=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},A=["acyclicer","ranker","rankdir","align","rankalign"],R=["width","height","rank"],_={width:0,height:0},Y=["minlen","weight","width","height","labeloffset"],q={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},X=["labelpos"];function L(D){let W=new w({multigraph:!0,compound:!0}),J=S(D.graph());return W.setGraph(Object.assign({},N,I(J,M),b.pick(J,A))),D.nodes().forEach(te=>{let re=S(D.node(te)),oe=I(re,R);Object.keys(_).forEach(me=>{oe[me]===void 0&&(oe[me]=_[me])}),W.setNode(te,oe),W.setParent(te,D.parent(te))}),D.edges().forEach(te=>{let re=S(D.edge(te));W.setEdge(te,Object.assign({},q,I(re,Y),b.pick(re,X)))}),W}function P(D){let W=D.graph();W.ranksep/=2,D.edges().forEach(J=>{let te=D.edge(J);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function G(D){D.edges().forEach(W=>{let J=D.edge(W);if(J.width&&J.height){let te=D.node(W.v),re={rank:(D.node(W.w).rank-te.rank)/2+te.rank,e:W};b.addDummyNode(D,"edge-proxy",re,"_ep")}})}function $(D){let W=0;D.nodes().forEach(J=>{let te=D.node(J);te.borderTop&&(te.minRank=D.node(te.borderTop).rank,te.maxRank=D.node(te.borderBottom).rank,W=Math.max(W,te.maxRank))}),D.graph().maxRank=W}function T(D){D.nodes().forEach(W=>{let J=D.node(W);J.dummy==="edge-proxy"&&(D.edge(J.e).labelRank=J.rank,D.removeNode(W))})}function z(D){let W=Number.POSITIVE_INFINITY,J=0,te=Number.POSITIVE_INFINITY,re=0,oe=D.graph(),me=oe.marginx||0,Oe=oe.marginy||0;function ve(ke){let Ee=ke.x,Me=ke.y,dt=ke.width,pt=ke.height;W=Math.min(W,Ee-dt/2),J=Math.max(J,Ee+dt/2),te=Math.min(te,Me-pt/2),re=Math.max(re,Me+pt/2)}D.nodes().forEach(ke=>ve(D.node(ke))),D.edges().forEach(ke=>{let Ee=D.edge(ke);Object.hasOwn(Ee,"x")&&ve(Ee)}),W-=me,te-=Oe,D.nodes().forEach(ke=>{let Ee=D.node(ke);Ee.x-=W,Ee.y-=te}),D.edges().forEach(ke=>{let Ee=D.edge(ke);Ee.points.forEach(Me=>{Me.x-=W,Me.y-=te}),Object.hasOwn(Ee,"x")&&(Ee.x-=W),Object.hasOwn(Ee,"y")&&(Ee.y-=te)}),oe.width=J-W+me,oe.height=re-te+Oe}function O(D){D.edges().forEach(W=>{let J=D.edge(W),te=D.node(W.v),re=D.node(W.w),oe,me;J.points?(oe=J.points[0],me=J.points[J.points.length-1]):(J.points=[],oe=re,me=te),J.points.unshift(b.intersectRect(te,oe)),J.points.push(b.intersectRect(re,me))})}function V(D){D.edges().forEach(W=>{let J=D.edge(W);if(Object.hasOwn(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function H(D){D.edges().forEach(W=>{let J=D.edge(W);J.reversed&&J.points.reverse()})}function Z(D){D.nodes().forEach(W=>{if(D.children(W).length){let J=D.node(W),te=D.node(J.borderTop),re=D.node(J.borderBottom),oe=D.node(J.borderLeft[J.borderLeft.length-1]),me=D.node(J.borderRight[J.borderRight.length-1]);J.width=Math.abs(me.x-oe.x),J.height=Math.abs(re.y-te.y),J.x=oe.x+J.width/2,J.y=te.y+J.height/2}}),D.nodes().forEach(W=>{D.node(W).dummy==="border"&&D.removeNode(W)})}function B(D){D.edges().forEach(W=>{if(W.v===W.w){var J=D.node(W.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:W,label:D.edge(W)}),D.removeEdge(W)}})}function F(D){var W=b.buildLayerMatrix(D);W.forEach(J=>{var te=0;J.forEach((re,oe)=>{var me=D.node(re);me.order=oe+te,(me.selfEdges||[]).forEach(Oe=>{b.addDummyNode(D,"selfedge",{width:Oe.label.width,height:Oe.label.height,rank:me.rank,order:oe+ ++te,e:Oe.e,label:Oe.label},"_se")}),delete me.selfEdges})})}function K(D){D.nodes().forEach(W=>{var J=D.node(W);if(J.dummy==="selfedge"){var te=D.node(J.e.v),re=te.x+te.width/2,oe=te.y,me=J.x-re,Oe=te.height/2;D.setEdge(J.e,J.label),D.removeNode(W),J.label.points=[{x:re+2*me/3,y:oe-Oe},{x:re+5*me/6,y:oe-Oe},{x:re+me,y:oe},{x:re+5*me/6,y:oe+Oe},{x:re+2*me/3,y:oe+Oe}],J.label.x=J.x,J.label.y=J.y}})}function I(D,W){return b.mapValues(b.pick(D,W),Number)}function S(D){var W={};return D&&Object.entries(D).forEach(([J,te])=>{typeof J=="string"&&(J=J.toLowerCase()),W[J]=te}),W}}),az=gn((e,n)=>{var s=nr(),l=Ms().Graph;n.exports={debugOrdering:i};function i(c){let d=s.buildLayerMatrix(c),u=new l({compound:!0,multigraph:!0}).setGraph({});return c.nodes().forEach(h=>{u.setNode(h,{label:h}),u.setParent(h,"layer"+c.node(h).rank)}),c.edges().forEach(h=>u.setEdge(h.v,h.w,{},h.name)),d.forEach((h,f)=>{let x="layer"+f;u.setNode(x,{rank:"same"}),h.reduce((p,g)=>(u.setEdge(p,g,{style:"invis"}),g))}),u}}),lz=gn((e,n)=>{n.exports="2.0.4"}),iz=gn((e,n)=>{n.exports={graphlib:Ms(),layout:sz(),debug:az(),util:{time:nr().time,notime:nr().notime},version:lz()}});const E1=iz();const T1={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"}},oz={critical:"bg-red-500",high:"bg-amber-500",medium:"bg-amber-500",low:"bg-blue-500"};function cz({data:e}){const{task:n,agentName:s,selected:l}=e,i=T1[n.status]??T1.pending,c=n.taskType==="scheduled"&&!!n.scheduleConfig,d=c?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 ${c?`${i.bg} border-blue-500/40 ring-1 ring-blue-500/20`:`${i.bg} ${i.border}`} ${l?"ring-2 ring-brand-500 shadow-brand-500/25 shadow-lg":""}`,children:[t.jsx(al,{type:"target",position:mt.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${oz[n.priority]??"bg-gray-500"}`}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${i.text}`,children:n.status.replace("_"," ")}),c&&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"})}),d]})]}),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(al,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const A1={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"}},_1={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done",archived:"done"};function dz({data:e}){const{req:n,selected:s}=e,l=A1[n.status]??A1.pending;return t.jsxs("div",{className:`rounded-lg border-2 border-dashed px-3 py-2 min-w-[180px] max-w-[220px] shadow-lg ${l.bg} ${l.border} ${s?"ring-2 ring-brand-500 shadow-brand-500/25":""}`,children:[t.jsx(al,{type:"target",position:mt.Top,className:"!bg-border-default !w-2 !h-2"}),t.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded font-semibold bg-amber-500/15 text-amber-600",children:"REQ"}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${l.text}`,children:n.status.replace("_"," ")})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:n.title}),n.taskIds.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[n.taskIds.length," task",n.taskIds.length>1?"s":""]}),t.jsx(al,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const uz={task:cz,requirement:dz},fz=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,mz=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 hz(){return y.useSyncExternalStore(mz,fz,()=>!1)}const bx=200,yx=80;function M1(e,n,s="TB"){const l=new E1.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const i of e)l.setNode(i.id,{width:bx,height:yx});for(const i of n)l.setEdge(i.source,i.target);return E1.layout(l),e.map(i=>{const c=l.node(i.id);return{...i,position:{x:(c?.x??0)-bx/2,y:(c?.y??0)-yx/2}}})}function xz(e,n){const s=new Map,l=new Map;for(const d of e)l.set(d.id,d),s.set(d.id,new Set);for(const d of n)s.get(d.source)?.add(d.target),s.get(d.target)?.add(d.source);const i=new Set,c=[];for(const d of e){if(i.has(d.id))continue;const u=new Set,h=[d.id];for(;h.length>0;){const f=h.pop();if(!i.has(f)){i.add(f),u.add(f);for(const x of s.get(f)??[])i.has(x)||h.push(x)}}c.push({nodes:e.filter(f=>u.has(f.id)),edges:n.filter(f=>u.has(f.source)&&u.has(f.target))})}return c}function pz(e,n){if(e.length===0)return[];const s=xz(e,n);if(s.length===1)return M1(e,n);const l=s.map(p=>{const g=M1(p.nodes,p.edges);let b=1/0,w=-1/0,k=1/0,C=-1/0;for(const E of g)b=Math.min(b,E.position.x),w=Math.max(w,E.position.x+bx),k=Math.min(k,E.position.y),C=Math.max(C,E.position.y+yx);for(const E of g)E.position.x-=b,E.position.y-=k;return{nodes:g,w:w-b,h:C-k}});l.sort((p,g)=>g.h-p.h);const i=60,c=l.reduce((p,g)=>p+(g.w+i)*(g.h+i),0),d=Math.sqrt(c)*1.1,u=[];let h=0,f=0,x=0;for(const p of l){h>0&&h+p.w>d&&(h=0,f+=x+i,x=0);for(const g of p.nodes)u.push({...g,position:{x:g.position.x+h,y:g.position.y+f}});h+=p.w+i,x=Math.max(x,p.h)}return u}function gz(e,n,s){const l=new Set,i=[n];for(;i.length>0;){const c=i.pop();if(c===s)return!0;if(l.has(c))continue;l.add(c);const d=e.get(c);if(d?.blockedBy)for(const u of d.blockedBy)i.push(u)}return!1}const qo=[{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","archived"]),color:{bg:"bg-green-500/10",border:"border-green-500/30",text:"text-green-600"}}],_h=new Set(qo.map(e=>e.id)),R1=e=>e.status==="archived";function bz({tasks:e,requirements:n=[],agents:s,showArchived:l,onShowArchivedChange:i,onTaskClick:c,onReqClick:d,onDependencyChange:u,selectedTaskId:h,selectedReqId:f}){const x=hz(),[p,g]=y.useState(null),[b,w]=y.useState(null),[k,C]=y.useState(new Set(_h)),[E,M]=y.useState(l??!1),N=l??E,A=y.useCallback(ve=>{const ke=typeof ve=="function"?ve(N):ve;M(ke),i?.(ke)},[N,i]);y.useEffect(()=>{l!==void 0&&M(l)},[l]);const R=y.useMemo(()=>e.filter(ve=>R1(ve)).length,[e]),_=y.useMemo(()=>{const ve=new Set;for(const ke of qo)if(k.has(ke.id))for(const Ee of ke.statuses)ve.add(Ee);return ve},[k]),Y=y.useMemo(()=>{const ve=new Set;for(const ke of e)for(const Ee of qo)if(Ee.statuses.has(ke.status)){ve.add(Ee.id);break}for(const ke of n){const Ee=_1[ke.status];Ee&&ve.add(Ee)}return qo.filter(ke=>ve.has(ke.id))},[e,n]),q=y.useCallback(ve=>{C(ke=>{const Ee=new Set(ke);return Ee.has(ve)?Ee.delete(ve):Ee.add(ve),Ee})},[]),X=y.useCallback((ve,ke="success")=>{g({msg:ve,type:ke}),setTimeout(()=>g(null),2500)},[]),L=y.useMemo(()=>{const ve=new Map;for(const ke of s)ve.set(ke.id,ke.name);return ve},[s]),P=y.useMemo(()=>{const ve=new Map;for(const ke of e)ve.set(ke.id,ke);return ve},[e]),G=y.useMemo(()=>{const ve=new Map;for(const ke of n)ve.set(ke.id,ke);return ve},[n]),$=x?"#94a3b8":"#6b7280",T=y.useCallback((ve,ke,Ee)=>({id:`${ve}->${ke}`,source:ve,target:ke,animated:Ee==="blocked",markerEnd:{type:Li.ArrowClosed,width:14,height:14,color:Ee==="blocked"?"#ef4444":$},style:{stroke:Ee==="blocked"?"#ef4444":$,strokeWidth:1.5,cursor:"pointer"}}),[$]),{initialNodes:z,initialEdges:O}=y.useMemo(()=>{const ve=e.filter(Se=>_.has(Se.status)&&(N||!R1(Se))),ke=ve.map(Se=>({id:Se.id,type:"task",data:{task:Se,agentName:Se.assignedAgentId?L.get(Se.assignedAgentId):void 0,selected:Se.id===h},position:{x:0,y:0}})),Ee=new Set(ke.map(Se=>Se.id)),Me=new Set;for(const Se of qo)k.has(Se.id)&&Me.add(Se.id);const dt=n.filter(Se=>{const We=_1[Se.status];return We&&Me.has(We)});for(const Se of dt){const We=`req-${Se.id}`;ke.push({id:We,type:"requirement",data:{req:Se,selected:Se.id===f},position:{x:0,y:0}}),Ee.add(We)}const pt=[];for(const Se of ve)if(Se.blockedBy)for(const We of Se.blockedBy)Ee.has(We)&&pt.push(T(We,Se.id,Se.status));const et=new Set,Pt=(Se,We)=>{const kt=`${Se}->${We}`;et.has(kt)||(et.add(kt),pt.push({id:kt,source:Se,target:We,markerEnd:{type:Li.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const Se of dt){const We=`req-${Se.id}`;for(const kt of Se.taskIds)Ee.has(kt)&&Pt(We,kt)}for(const Se of ve)if(Se.requirementId){const We=`req-${Se.requirementId}`;Ee.has(We)&&Pt(We,Se.id)}return{initialNodes:pz(ke,pt),initialEdges:pt}},[e,n,L,P,T,_,k,N,h,f]),[V,H,Z]=iI(z),[B,F,K]=oI(O),I=y.useRef(null),S=y.useRef(!1),D=y.useRef({groupFilter:k,showArchived:N});y.useEffect(()=>{const ve=D.current;(ve.groupFilter!==k||ve.showArchived!==N)&&(S.current=!1,D.current={groupFilter:k,showArchived:N})},[k,N]),y.useEffect(()=>{H(z),F(O),S.current||requestAnimationFrame(()=>{I.current?.fitView({padding:.2,duration:300})})},[z,O,H,F]);const W=y.useCallback(ve=>{ve&&(S.current=!0)},[]),J=y.useCallback((ve,ke)=>{if(ke.id.startsWith("req-")){const Ee=G.get(ke.id.slice(4));Ee&&d&&d(Ee)}else{const Ee=P.get(ke.id);Ee&&c&&c(Ee)}},[P,G,c,d]),te=y.useCallback(async ve=>{const{source:ke,target:Ee}=ve;if(!ke||!Ee||ke===Ee)return;const Me=P.get(Ee);if(!Me)return;if(Me.blockedBy?.includes(ke)){X("Dependency already exists","error");return}if(gz(P,ke,Ee)){X("Cannot add: would create a cycle","error");return}const dt=[...Me.blockedBy??[],ke];try{await se.tasks.update(Ee,{blockedBy:dt}),X("Dependency added"),u?.()}catch(pt){X(`Failed: ${pt instanceof Error?pt.message:String(pt)}`,"error")}},[P,X,u]),re=y.useCallback((ve,ke)=>{w(ke)},[]),oe=y.useCallback(async()=>{if(!b)return;const ve=P.get(b.target);if(!ve){w(null);return}const ke=(ve.blockedBy??[]).filter(Ee=>Ee!==b.source);try{await se.tasks.update(b.target,{blockedBy:ke}),X("Dependency removed"),u?.()}catch(Ee){X(`Failed: ${Ee instanceof Error?Ee.message:String(Ee)}`,"error")}w(null)},[b,P,X,u]);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 me=b?P.get(b.source):null,Oe=b?P.get(b.target):null;return t.jsxs("div",{className:"flex-1 min-h-0 relative",style:{height:"100%"},children:[t.jsxs(lI,{nodes:V,edges:B,onNodesChange:Z,onEdgesChange:K,onNodeClick:J,onConnect:te,onEdgeClick:re,onMoveEnd:W,onInit:ve=>{I.current=ve},nodeTypes:uz,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(mI,{color:x?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(vI,{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(OI,{nodeColor:ve=>{const ke=ve.data?.task,Ee=ke?.status;return ke?.taskType==="scheduled"?"#06b6d4":Ee==="completed"||Ee==="accepted"?"#10b981":Ee==="in_progress"?"#f59e0b":Ee==="blocked"||Ee==="failed"?"#ef4444":x?"#94a3b8":"#6b7280"},maskColor:x?"rgba(255,255,255,0.7)":"rgba(0,0,0,0.7)",className:"!bg-surface-secondary !border-border-default"})]}),t.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-surface-secondary/90 border border-border-default rounded-lg backdrop-blur-sm z-10 flex flex-col items-center gap-1",children:[t.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-center",children:[Y.map(ve=>{const ke=k.has(ve.id);return t.jsx("button",{onClick:()=>q(ve.id),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${ke?`${ve.color.bg} ${ve.color.border} ${ve.color.text}`:"bg-surface-elevated/50 border-border-default/50 text-fg-tertiary"}`,children:ve.label},ve.id)}),R>0&&t.jsxs("button",{onClick:()=>A(ve=>!ve),className:`text-[10px] px-1.5 py-0.5 rounded border transition-colors ${N?"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]}),k.size<_h.size&&t.jsx("button",{onClick:()=>{C(new Set(_h)),A(!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"})]}),p&&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 ${p.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:p.msg}),b&&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:ve=>ve.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:Oe?.title??b.target.slice(-8)})," ","will no longer be blocked by"," ",t.jsx("span",{className:"text-fg-secondary font-medium",children:me?.title??b.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:oe,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 u5({orgId:e,onCreated:n,onClose:s}){const[l,i]=y.useState(""),[c,d]=y.useState(""),[u,h]=y.useState(""),[f,x]=y.useState("main"),[p,g]=y.useState([]),[b,w]=y.useState([]),[k,C]=y.useState(!1),[E,M]=y.useState(""),[N,A]=y.useState(!1),R=Yr();y.useEffect(()=>{se.teams.list().then(q=>w(q.teams)).catch(()=>{})},[]);const _=y.useCallback(async q=>{if(q?.preventDefault(),A(!0),!(!l.trim()||k)){C(!0),M("");try{const X=u.trim()?[{url:u.trim(),defaultBranch:f.trim()||"main"}]:[],L=await se.projects.create({name:l.trim(),description:c.trim()||void 0,repositories:X.length>0?X:void 0,teamIds:p.length>0?p:void 0,orgId:e??"default"});n(L.project)}catch(X){M(X instanceof Error?X.message:"Failed to create project")}C(!1)}},[l,c,u,f,p,e,k,n]),Y=N&&!l.trim();return vu.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:q=>q.stopPropagation(),onSubmit:_,children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:"New Project"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Project Name *"}),t.jsx("input",{value:l,onChange:q=>{i(q.target.value),M("")},onBlur:()=>A(!0),placeholder:"e.g. Mobile App, Website Redesign",className:`input ${Y?"!border-red-500 focus:!ring-red-500/25":""}`,autoFocus:!R}),Y&&t.jsx("p",{className:"text-[11px] text-red-400 mt-1",children:"Project name is required"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:"Description"}),t.jsx("textarea",{value:c,onChange:q=>d(q.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"}),b.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:b.map(q=>{const X=p.includes(q.id);return t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer hover:text-fg-primary py-0.5",children:[t.jsx("input",{type:"checkbox",checked:X,onChange:()=>g(L=>X?L.filter(P=>P!==q.id):[...L,q.id]),className:"accent-brand-500"}),t.jsx("span",{className:"truncate",children:q.name})]},q.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:u,onChange:q=>h(q.target.value),placeholder:"https://github.com/org/repo (optional)",className:"input"})]}),u.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:q=>x(q.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:!l.trim()||k,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:k?"Creating...":"Create Project"})]})]})]})}),document.body)}function Hi(e,n,s){if(!e)return null;const l=n.find(c=>c.id===e);if(l)return l.name;const i=s.find(c=>c.id===e);return i?i.name:e==="anonymous"?"Admin":null}function yz({value:e,onSave:n,className:s,placeholder:l}){const[i,c]=y.useState(!1),[d,u]=y.useState(e),h=y.useRef(null);y.useEffect(()=>{u(e)},[e]),y.useEffect(()=>{i&&h.current?.focus()},[i]);const f=async()=>{c(!1);const x=d.trim();if(x&&x!==e)try{await n(x)}catch{u(e)}else u(e)};return i?t.jsx("input",{ref:h,value:d,onChange:x=>u(x.target.value),onBlur:()=>{f()},onKeyDown:x=>{x.key==="Enter"&&f(),x.key==="Escape"&&(u(e),c(!1))},className:`bg-transparent border-b border-brand-500/50 outline-none ${s??""}`,placeholder:l}):t.jsx("span",{onClick:()=>c(!0),className:`cursor-pointer hover:border-b hover:border-gray-600 transition-colors ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:l??"Click to edit"})})}function vz({value:e,onSave:n,className:s,placeholder:l}){const[i,c]=y.useState(!1),[d,u]=y.useState(e),h=y.useRef(null);y.useEffect(()=>{u(e)},[e]),y.useEffect(()=>{i&&h.current&&(h.current.focus(),h.current.style.height="auto",h.current.style.height=h.current.scrollHeight+"px")},[i]);const f=async()=>{c(!1);const x=d.trim();if(x!==e)try{await n(x)}catch{u(e)}else u(e)};return i?t.jsx("textarea",{ref:h,value:d,onChange:x=>{u(x.target.value),x.target.style.height="auto",x.target.style.height=x.target.scrollHeight+"px"},onBlur:()=>{f()},onKeyDown:x=>{x.key==="Escape"&&(u(e),c(!1))},className:`bg-transparent border border-brand-500/30 rounded-lg p-2 outline-none resize-none w-full ${s??""}`,placeholder:l,rows:2}):t.jsx("p",{onClick:()=>c(!0),className:`cursor-pointer hover:bg-surface-elevated/50 rounded-lg transition-colors px-2 py-1 -mx-2 -my-1 ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:l??"Add a description…"})})}const jz=/^\[([^\]]+?)(?:\s+by\s+([^\]]+))?\]\s*([\s\S]*)$/;function f5(e){const n=e.match(jz);return n?{timestamp:n[1].trim(),author:n[2]?.trim()??"System",content:n[3].trim()}:{timestamp:"",author:"",content:e}}function wz(e){if(!e)return"";const n=e.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);if(!n)return e;const s=new Date,l=+n[1],i=+n[2]-1,c=+n[3],d=+n[4],u=+n[5],h=new Date(l,i,c,d,u),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`:`${l}-${String(i+1).padStart(2,"0")}-${String(c).padStart(2,"0")}`}const O1=[{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 Nz(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s)|0;return O1[Math.abs(n)%O1.length]}function kz({note:e,compact:n}){const s=f5(e),l=Nz(s.author||"System"),i=s.author?s.author.split(/[\s_-]+/).map(u=>u[0]).join("").slice(0,2).toUpperCase():"SY",c=wz(s.timestamp),d=!s.author||s.author==="System";return n?t.jsxs("div",{className:"flex gap-2.5 group",children:[t.jsx("div",{className:`w-6 h-6 rounded-full ${l.bg} flex items-center justify-center text-[9px] font-bold ${l.text} shrink-0 mt-0.5`,children:i}),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 ${d?"text-fg-tertiary":l.text}`,children:s.author||"System"}),c&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:c})]}),t.jsx("div",{className:"text-xs text-fg-secondary",children:t.jsx(Fn,{content:s.content,className:"text-xs text-fg-secondary"})})]})]}):t.jsxs("div",{className:"flex gap-3 group",children:[t.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[t.jsx("div",{className:`w-7 h-7 rounded-full ${l.bg} flex items-center justify-center text-[10px] font-bold ${l.text}`,children:i}),t.jsx("div",{className:"w-px flex-1 bg-border-default/60 mt-1.5"})]}),t.jsx("div",{className:"flex-1 min-w-0 pb-4",children:t.jsxs("div",{className:`border ${l.border} rounded-lg overflow-hidden`,children:[t.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 ${l.bg} border-b ${l.border}`,children:[t.jsx("span",{className:`text-[11px] font-medium ${d?"text-fg-secondary":l.text}`,children:s.author||"System"}),c&&t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:c})]}),t.jsx("div",{className:"px-3 py-2.5",children:t.jsx(Fn,{content:s.content,className:"text-xs text-fg-secondary"})})]})})]})}const dc=[{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","archived"],accent:"border-t-gray-500",dropStatus:"cancelled"}],m5={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"}},Fo={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"}},Sz={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},Bd={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"}},D1=["low","medium","high","urgent"],L1=["pending","in_progress","blocked","review","completed","failed","rejected","cancelled"],I1=["pending","in_progress","completed","rejected","cancelled"],z1={pending:new Set(["in_progress","blocked","rejected","cancelled"]),in_progress:new Set(["review","blocked","failed","cancelled"]),blocked:new Set(["in_progress","cancelled"]),review:new Set(["completed","in_progress","cancelled"]),completed:new Set(["archived","in_progress"]),failed:new Set(["in_progress","archived"]),rejected:new Set(["archived"]),cancelled:new Set(["archived"]),archived:new Set([])},vx={pending:new Set(["in_progress","rejected","cancelled"]),in_progress:new Set(["completed","cancelled"]),completed:new Set([]),rejected:new Set([]),cancelled:new Set([])},jx={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"},$1={idle:"text-green-500",working:"text-blue-500",error:"text-red-500",paused:"text-amber-500",offline:"text-fg-muted"};function Cz({agent:e,anchorRect:n,onClose:s}){const l=y.useRef(null);y.useEffect(()=>{const d=u=>{l.current&&!l.current.contains(u.target)&&s()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[s]);const i=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:l,className:"fixed z-50 w-56 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-3 space-y-2",style:{top:n.top+4,left:n.left},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600 shrink-0",children:e.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${i}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:c})]})]})]}),t.jsx("button",{onClick:()=>{s(),bt.navigate(ge.TEAM,{selectAgent:e.id})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:"View Profile →"})]})}function Wo({comment:e,agents:n,onReply:s}){const l=e.authorType==="agent"||e.authorType==="system",i=new Date(e.createdAt),c=i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d=i.toLocaleDateString([],{month:"short",day:"numeric"}),[u,h]=y.useState(null),[f,x]=y.useState(!1),[p,g]=y.useState([]),[b,w]=y.useState(!1),k=y.useCallback((N,A)=>{const R=n.find(_=>_.name.toLowerCase()===N.toLowerCase());if(R){const _=A.target.getBoundingClientRect();h({agent:R,top:_.bottom,left:_.left})}},[n]),C=y.useCallback(N=>{const A=n.find(R=>R.name.toLowerCase()===e.authorName.toLowerCase());if(A){const R=N.currentTarget.getBoundingClientRect();h({agent:A,top:R.bottom,left:R.left})}},[n,e.authorName]),E=y.useCallback(async()=>{if(f){x(!1);return}const N=e.activityId;if(N&&(x(!0),!(p.length>0))){w(!0);try{const{logs:A}=await se.agents.getActivityLogs(e.authorId,N),R=A.map(_=>Q1(_,N,e.authorId)).filter(_=>_!==null).map(_=>({..._,ts:new Date(_.createdAt).getTime()}));g(R)}catch{}w(!1)}},[f,p.length,e]),M=y.useMemo(()=>Jo(p.map(ec).filter(N=>N!==null)),[p]);return t.jsxs("div",{className:"flex gap-2.5 group py-1",id:`comment-${e.id}`,children:[t.jsx("div",{onClick:C,className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-[10px] mt-0.5 cursor-pointer transition-all hover:ring-1 hover:ring-brand-500/40 ${l?"bg-indigo-500/20 text-indigo-400":"bg-blue-500/20 text-blue-400"}`,children:e.authorName.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium cursor-pointer hover:underline ${l?"text-indigo-400":"text-blue-400"}`,onClick:C,children:e.authorName}),t.jsxs("span",{className:"text-fg-tertiary text-[10px]",children:[d," ",c]}),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.activityId&&l&&t.jsx("button",{onClick:E,className:"text-fg-tertiary hover:text-brand-400 text-[10px] opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:f?"Hide log":"View log"})]}),e.replyTo&&e.replyToAuthor&&t.jsxs("button",{onClick:()=>{const N=document.getElementById(`comment-${e.replyTo}`);N&&(N.scrollIntoView({behavior:"smooth",block:"center"}),N.classList.add("bg-brand-500/10"),setTimeout(()=>N.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(Fn,{content:e.content,className:"text-xs text-fg-primary",onMentionClick:k}),e.attachments?.map((N,A)=>N.type==="image"?t.jsx("img",{src:N.url,alt:N.name,className:"mt-1 max-w-[200px] rounded"},A):null),f&&t.jsx("div",{className:"mt-2 border border-border-subtle rounded-lg overflow-hidden bg-surface-secondary/30",children:b?t.jsx("div",{className:"p-3 text-xs text-fg-tertiary",children:"Loading execution log..."}):M.length===0?t.jsx("div",{className:"p-3 text-xs text-fg-tertiary",children:"No execution log available."}):t.jsx(Cu,{entries:p,isActive:!1,onCollapse:()=>x(!1),embedded:!0})})]}),u&&t.jsx(Cz,{agent:u.agent,anchorRect:{top:u.top,left:u.left},onClose:()=>h(null)})]})}function Ez({task:e,agents:n,users:s,authUser:l}){const[i,c]=y.useState([]);y.useEffect(()=>{se.tasks.getComments(e.id).then(p=>c(p.comments)).catch(()=>{})},[e.id]),y.useEffect(()=>Zt.on("task:comment",g=>{g.payload?.taskId===e.id&&g.payload.comment&&c(b=>b.some(w=>w.id===g.payload.comment.id)?b:[...b,g.payload.comment])}),[e.id]);const d=y.useMemo(()=>{const p=[];for(const g of e.notes??[]){const b=f5(g);let w;if(b.timestamp){const k=b.timestamp.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);w=k?new Date(+k[1],+k[2]-1,+k[3],+k[4],+k[5],+(k[6]??0)):new Date(0)}else w=new Date(0);p.push({type:"note",note:g,ts:w})}for(const g of i)p.push({type:"comment",comment:g,ts:new Date(g.createdAt)});return p.sort((g,b)=>g.ts.getTime()-b.ts.getTime()),p},[e.notes,i]),[u,h]=y.useState(null),f=async(p,g,b)=>{await se.tasks.addComment(e.id,p,l?.name,void 0,l?.id,g.length>0?g:void 0,b)},x=y.useCallback(p=>{h({id:p.id,authorName:p.authorName,content:p.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:[d.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:"No activity yet. Post the first comment below."}),d.map((p,g)=>p.type==="note"?t.jsx(kz,{note:p.note,compact:!0},`n-${g}`):t.jsx(Wo,{comment:p.comment,agents:n,onReply:x},`c-${p.comment.id}`))]}),t.jsx(hw,{agents:n,onSubmit:f,replyTo:u,onCancelReply:()=>h(null)})]})}function Tz({taskId:e,isRunning:n,authUser:s,agents:l}){const[i,c]=y.useState([]),[d,u]=y.useState(new Map),[h,f]=y.useState(new Set),[x,p]=y.useState([]),[g,b]=y.useState(""),[w,k]=y.useState(n),[C,E]=y.useState(!0),[M,N]=y.useState(new Set),[A,R]=y.useState(""),[_,Y]=y.useState(!1),[q,X]=y.useState([]),L=y.useRef(null),P=y.useRef(null);y.useEffect(()=>{k(n)},[n]),y.useEffect(()=>{E(!0),Promise.all([se.tasks.getLogsSummary(e).catch(()=>({rounds:[]})),se.tasks.getComments(e).catch(()=>({comments:[]}))]).then(([K,I])=>{const S=K.rounds;if(c(S),p(I.comments),S.length===0){E(!1);return}const D=S[S.length-1].round;N(new Set([D])),se.tasks.getLogs(e,D).catch(()=>({logs:[]})).then(W=>{u(new Map([[D,W.logs]])),E(!1)})})},[e]);const G=y.useCallback(K=>{d.has(K)||h.has(K)||(f(I=>new Set(I).add(K)),se.tasks.getLogs(e,K).catch(()=>({logs:[]})).then(I=>{u(S=>new Map(S).set(K,I.logs)),f(S=>{const D=new Set(S);return D.delete(K),D})}))},[e,d,h]),$=y.useCallback(K=>{N(I=>{const S=new Set(I);return S.has(K)?S.delete(K):(S.add(K),d.has(K)||G(K)),S})},[d,G]);y.useEffect(()=>{const K=Zt.on("task:log",D=>{const W=D.payload;if(W.taskId!==e)return;const J={id:W.id,taskId:W.taskId,agentId:W.agentId,seq:W.seq,type:W.logType,content:W.content,metadata:W.metadata,executionRound:W.executionRound,createdAt:W.createdAt},te=J.executionRound??1;c(re=>re.find(me=>me.round===te)?re:[...re,{round:te,logCount:0,toolCount:0,firstAt:J.createdAt,lastAt:J.createdAt,status:"running"}]),N(re=>re.has(te)?re:new Set(re).add(te)),u(re=>{const oe=re.get(te)??[];return J.id&&oe.some(me=>me.id===J.id)?re:new Map(re).set(te,[...oe,J])}),J.type==="text"&&b(""),J.type==="status"&&(J.content==="started"||J.content==="resumed"?k(!0):["completed","failed","cancelled","execution_finished"].includes(J.content)&&(k(!1),c(re=>re.map(oe=>oe.round===te?{...oe,status:J.content}:oe)))),J.type==="error"&&k(!1)}),I=Zt.on("task:log:delta",D=>{const W=D.payload;W.taskId===e&&b(J=>J+W.text)}),S=Zt.on("task:comment",D=>{const W=D.payload;if(W.taskId!==e)return;const J=W.comment;p(te=>te.some(re=>re.id===J.id)?te:[...te,J])});return()=>{K(),I(),S()}},[e]);const T=y.useMemo(()=>{const K=[];for(const[,I]of d)K.push(...I);return K.sort((I,S)=>I.seq-S.seq),K},[d]),z=y.useMemo(()=>T.map(K=>Lh(K)),[T]),O=i.length>1,V=K=>{const I=K.target.files;if(I){for(const S of Array.from(I)){if(!S.type.startsWith("image/"))continue;const D=new FileReader;D.onload=()=>{X(W=>[...W,{type:"image",url:D.result,name:S.name}])},D.readAsDataURL(S)}K.target.value=""}},H=async()=>{if(!(!A.trim()&&q.length===0)){Y(!0);try{const K=await se.tasks.addComment(e,A,s?.name,q.length>0?q:void 0,s?.id);K.comment&&p(I=>I.some(S=>S.id===K.comment.id)?I:[...I,K.comment]),R(""),X([])}catch{}Y(!1)}},Z=t.jsxs("div",{className:"border-t border-border-default px-4 py-3 sticky bottom-0 bg-surface-secondary z-10",children:[q.length>0&&t.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:q.map((K,I)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:K.url,alt:K.name,className:"w-16 h-16 object-cover rounded-lg border border-border-default"}),t.jsx("button",{onClick:()=>X(S=>S.filter((D,W)=>W!==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:A,onChange:K=>R(K.target.value),onKeyDown:K=>{K.key==="Enter"&&!K.shiftKey&&(K.preventDefault(),H())},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:L,accept:"image/*",multiple:!0,onChange:V,className:"hidden"}),t.jsx("button",{onClick:()=>L.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:()=>{H()},disabled:_||!A.trim()&&q.length===0,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 rounded-lg text-white text-xs disabled:opacity-50",children:"Send"})]})]});if(C)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-fg-tertiary",children:"Loading logs…"});if(i.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(!O){const K=z.map(D=>ec(D)).filter(D=>D!==null),I=Wy(T,Jo(K)),S=[...I.map(D=>({kind:"entry",entry:D,ts:D.timestamp?new Date(D.timestamp).getTime():0})),...x.map(D=>({kind:"comment",comment:D,ts:new Date(D.createdAt).getTime()}))];return S.sort((D,W)=>D.ts-W.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:[S.map((D,W)=>D.kind==="comment"?t.jsx(Wo,{comment:D.comment,agents:l},`c-${D.comment.id}`):t.jsx(su,{entry:D.entry,showTime:!0,isLast:W===S.length-1},`e-${W}`)),w&&g&&t.jsx(Jh,{content:g}),w&&!g&&I.length>0&&t.jsx(Qh,{})]}),Z]})}const B=(K,I)=>{const S=K.firstAt?new Date(K.firstAt).getTime():0,D=I?.firstAt?new Date(I.firstAt).getTime():1/0;return x.filter(W=>{const J=new Date(W.createdAt).getTime();return J>=S&&J<D})},F=i.length>0?x.filter(K=>new Date(K.createdAt).getTime()<new Date(i[0].firstAt).getTime()):[];return t.jsxs("div",{className:"flex flex-col flex-1",children:[t.jsx("div",{ref:P}),t.jsxs("div",{className:"px-4 py-3 flex-1 space-y-2",children:[F.length>0&&t.jsx("div",{className:"space-y-0.5",children:F.map(K=>t.jsx(Wo,{comment:K,agents:l},K.id))}),i.map((K,I)=>{const S=M.has(K.round),D=K.round===i[i.length-1].round,W=d.get(K.round),J=h.has(K.round),te=B(K,i[I+1]),re=K.status==="completed"||K.status==="execution_finished"?"✅":K.status==="failed"?"❌":K.status==="cancelled"?"⏹":"🔄",oe=K.lastAt&&K.firstAt?Math.max(0,new Date(K.lastAt).getTime()-new Date(K.firstAt).getTime()):0,me=oe>=6e4?`${Math.floor(oe/6e4)}m ${Math.floor(oe%6e4/1e3)}s`:oe>=1e3?`${Math.floor(oe/1e3)}s`:"";return t.jsxs("div",{className:"border border-border-default/50 rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>$(K.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:re}),t.jsxs("span",{className:"text-xs text-fg-secondary font-medium",children:["Round #",K.round]}),te.length>0&&t.jsxs("span",{className:"text-[10px] text-blue-400",children:["💬 ",te.length]}),D&&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:[K.toolCount," tool",K.toolCount!==1?"s":""]}),me&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:me}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${S?"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"})})]})]}),S&&t.jsxs("div",{className:"px-3 py-1.5 space-y-0.5",children:[J&&t.jsxs("div",{className:"text-xs text-fg-tertiary py-2 text-center",children:["Loading round #",K.round,"…"]}),W&&(()=>{const ve=W.map(Me=>Lh(Me)).map(Me=>ec(Me)).filter(Me=>Me!==null),Ee=[...Wy(W,Jo(ve)).map(Me=>({kind:"entry",entry:Me,ts:Me.timestamp?new Date(Me.timestamp).getTime():0})),...te.map(Me=>({kind:"comment",comment:Me,ts:new Date(Me.createdAt).getTime()}))];return Ee.sort((Me,dt)=>Me.ts-dt.ts),Ee.map((Me,dt)=>Me.kind==="comment"?t.jsx(Wo,{comment:Me.comment,agents:l},`c-${Me.comment.id}`):t.jsx(su,{entry:Me.entry,showTime:!0,isLast:dt===Ee.length-1},`e-${dt}`))})(),D&&w&&g&&t.jsx(Jh,{content:g}),D&&w&&!g&&!J&&t.jsx(Qh,{})]})]},K.round)})]}),Z]})}function Az({filePath:e,onClose:n}){const[s,l]=y.useState(null),[i,c]=y.useState(null),[d,u]=y.useState(!0);y.useEffect(()=>{u(!0),c(null),se.files.preview(e).then(f=>l(f)).catch(f=>c(String(f))).finally(()=>u(!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:[d&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"Loading..."}),i&&t.jsx("div",{className:"text-sm text-red-500 text-center py-8",children:i}),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(Fn,{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 _z({task:e,agents:n,projects:s,requirements:l,allTasks:i,users:c,onClose:d,onRefresh:u,authUser:h,scrollToComments:f,onScrollToCommentsDone:x}){const[p,g]=y.useState([]),[b,w]=y.useState(""),[k,C]=y.useState(!1),[E,M]=y.useState(!1),[N,A]=y.useState(null),[R,_]=y.useState(null),[Y,q]=y.useState(!1),[X,L]=y.useState("details"),P=y.useRef(null),[G,$]=y.useState("none"),T=y.useCallback(ye=>{L(ye),requestAnimationFrame(()=>{P.current?.scrollTo({top:0,behavior:"instant"})})},[]),z=y.useMemo(()=>[{id:"details"},{id:"logs"},{id:"deliverables"}],[]),O=va(z,X,T);y.useEffect(()=>{const ye=P.current;if(!ye)return;const Ge=()=>{const{scrollTop:Et,scrollHeight:It,clientHeight:kn}=ye;if(!(It>kn+50)){$("none");return}const Mn=Et<30,dr=Et+kn>=It-30;$(Mn?"top":dr?"bottom":"middle")};Ge(),ye.addEventListener("scroll",Ge,{passive:!0});const it=new ResizeObserver(Ge);return it.observe(ye),()=>{ye.removeEventListener("scroll",Ge),it.disconnect()}},[X]),y.useEffect(()=>{if(!f)return;L("details");const ye=setTimeout(()=>{const Ge=P.current;Ge&&Ge.scrollTo({top:Ge.scrollHeight,behavior:"smooth"}),x?.()},300);return()=>clearTimeout(ye)},[f,x]);const[V,H]=y.useState(null),[Z,B]=y.useState(null),[F,K]=y.useState(!1),[I,S]=y.useState(e.description),[D,W]=y.useState(!1),[J,te]=y.useState(""),[re,oe]=y.useState(1),[me,Oe]=y.useState(!1),ve=Yr(),ke=20,Ee=y.useCallback(async()=>{try{const ye=await se.tasks.listSubtasks(e.id);g(ye.subtasks)}catch{}},[e.id]);y.useEffect(()=>{Ee()},[Ee]);const Me=async ye=>{if(!Y){q(!0);try{await ye(),u(),await Ee()}catch(Ge){H(String(Ge).replace("Error: ",""))}finally{q(!1)}}},dt=ye=>Me(()=>se.tasks.update(e.id,{priority:ye})),pt=ye=>Me(()=>se.tasks.assign(e.id,ye||null)),et=ye=>Me(()=>se.tasks.update(e.id,{projectId:ye||null})),Pt=async()=>{if(!Y){q(!0);try{await se.tasks.pause(e.id),u()}finally{q(!1)}}},le=async()=>{if(!Y){q(!0),H(null),T("logs");try{await se.tasks.resume(e.id),u()}catch(ye){H(String(ye).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{q(!1)}}},Se=async()=>{b.trim()&&(await se.tasks.createSubtask(e.id,b.trim()),w(""),C(!1),Ee(),u())},We=async ye=>{ye.status==="completed"?await se.tasks.cancelSubtask(e.id,ye.id):await se.tasks.completeSubtask(e.id,ye.id),Ee(),u()},kt=async ye=>{await se.tasks.deleteSubtask(e.id,ye.id),A(null),Ee(),u()},Ft=async()=>{if(!Y){q(!0);try{await se.tasks.updateStatus(e.id,"in_progress"),u()}finally{q(!1)}}},xe=async()=>{if(!Y){q(!0),H(null),T("logs");try{await se.tasks.retry(e.id),u()}catch(ye){H(String(ye).replace("Error: API error: 400","Server error").replace("Error: ",""))}finally{q(!1)}}},Ce=async()=>{if(!Y){q(!0),H(null),T("logs");try{await se.tasks.runNow(e.id),u()}catch(ye){H(String(ye).replace("Error: API error: 400","Server error").replace("Error: ","")),u()}finally{q(!1)}}},Fe=y.useRef(u);Fe.current=u,y.useEffect(()=>Zt.on("task:update",Ge=>{Ge.payload.taskId===e.id&&(Ee(),Fe.current())}),[e.id,Ee]);const lt=p.filter(ye=>ye.status==="completed").length,ut=e.status==="in_progress",Lt=e.status==="blocked",bn=e.status==="completed",Ut=e.status==="failed",St=e.status==="rejected",Jt=e.status==="cancelled",yt=e.status==="archived",Xt=bn||Ut||St||Jt||yt,_t=e.taskType==="scheduled"&&!!e.scheduleConfig,$t=_t&&!!e.scheduleConfig?.paused,Hn=s.find(ye=>ye.id===e.projectId),dn=l.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:[ve&&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 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=Fo[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," ")})})()]})]}),!ve&&t.jsx("button",{onClick:d,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:()=>T("details"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors ${X==="details"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:"Details"}),t.jsxs("button",{onClick:()=>T("logs"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${X==="logs"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Execution Log",ut&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse"})]}),t.jsxs("button",{onClick:()=>T("deliverables"),className:`px-3 py-1.5 text-xs rounded-t-md transition-colors flex items-center gap-1.5 ${X==="deliverables"?"bg-surface-elevated text-fg-primary font-medium":"text-fg-tertiary hover:text-fg-secondary"}`,children:["Deliverables",(()=>{const ye=(e.deliverables??[]).filter(Ge=>Ge.type!=="branch"&&typeof Ge.reference=="string"&&Ge.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:P,className:"h-full overflow-y-auto",onTouchStart:O.onTouchStart,onTouchEnd:O.onTouchEnd,children:[X==="logs"&&t.jsxs("div",{className:"overflow-x-hidden min-w-0",children:[V&&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:"})," ",V]}),t.jsx(Tz,{taskId:e.id,isRunning:e.status==="in_progress",authUser:h,agents:n})]}),X==="details"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-6 pt-4 pb-3 border-b border-border-default",children:F?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:I,onChange:ye=>S(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:()=>{K(!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:()=>{Me(()=>se.tasks.update(e.id,{description:I})),K(!1)},disabled:Y,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:ve&&!me?"line-clamp-3":"",children:t.jsx(Fn,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"})}),ve&&e.description.length>150&&t.jsx("button",{onClick:()=>Oe(!me),className:"text-[11px] text-brand-500 mt-1 font-medium",children:me?"Collapse":"Show more"})]}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),t.jsx("button",{onClick:()=>{S(e.description),K(!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"})]})}),(Hn||dn)&&t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default flex flex-wrap items-center gap-2",children:[Hn&&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"}),Hn.name]}),dn&&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"}),dn.title.length>40?dn.title.slice(0,40)+"…":dn.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 Ge=i.find(Et=>Et.id===ye),it=Ge&&(Ge.status==="completed"||Ge.status==="cancelled");return t.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded-full ${it?"bg-green-500/10 text-green-600":"bg-amber-500/10 text-amber-600"}`,children:[t.jsx("span",{className:"text-[9px]",children:it?"✓":"⏳"}),t.jsx("span",{className:`font-mono ${it?"line-through opacity-60":""}`,children:Ge?Ge.title.slice(0,30):ye.slice(-8)}),!Xt&&t.jsx("button",{onClick:async()=>{const Et=(e.blockedBy??[]).filter(It=>It!==ye);await se.tasks.update(e.id,{blockedBy:Et}),u()},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"}),!Xt&&t.jsxs("select",{value:"",onChange:async ye=>{const Ge=ye.target.value;if(!Ge)return;const it=[...e.blockedBy??[],Ge];await se.tasks.update(e.id,{blockedBy:it}),u()},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…"}),i.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=>{et(ye.target.value)},disabled:Y,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=>Me(()=>se.tasks.update(e.id,{requirementId:ye.target.value||null})),disabled:Y,className:"w-full px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-primary focus:border-brand-500 outline-none disabled:opacity-50 cursor-pointer",children:[t.jsx("option",{value:"",children:"No Requirement"}),l.filter(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=>{pt(ye.target.value)},disabled:Y,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&&Me(()=>se.tasks.update(e.id,{reviewerAgentId:ye.target.value}))},disabled:Y,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=>{dt(ye.target.value)},disabled:Y,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:Hi(e.createdBy,n,c)??e.createdBy})]}),e.updatedBy&&t.jsxs("span",{children:["Updated by ",t.jsx("span",{className:"text-fg-secondary",children:Hi(e.updatedBy,n,c)??e.updatedBy})]}),e.createdAt&&t.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()}),e.startedAt&&t.jsxs("span",{children:["Started ",new Date(e.startedAt).toLocaleDateString()]}),e.updatedAt&&t.jsxs("span",{children:["Updated ",new Date(e.updatedAt).toLocaleDateString()]}),e.projectId&&t.jsxs("span",{className:"font-mono text-blue-600/70",children:["task/",e.id]}),(e.executionRound??1)>1&&t.jsxs("span",{className:"text-amber-600",children:["Round ",e.executionRound]})]}),t.jsxs("div",{className:"px-6 py-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:["Subtasks ",p.length>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal normal-case",children:[lt,"/",p.length," done"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[lt>0&&t.jsx("button",{onClick:()=>M(ye=>!ye),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${E?"bg-brand-500/15 text-brand-500 border-brand-500/30":"text-fg-tertiary border-border-default hover:text-fg-secondary"}`,children:E?"Hide completed":`Show completed (${lt})`}),t.jsx("button",{onClick:()=>C(!0),className:"text-xs text-brand-500 hover:text-brand-500 transition-colors",children:"+ Add subtask"})]})]}),(()=>{const ye=E?p:p.filter(Ge=>Ge.status!=="completed");return ye.length>0?t.jsx("div",{className:"space-y-1.5 mb-3",children:ye.map(Ge=>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:()=>{We(Ge)},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${Ge.status==="completed"?"bg-green-600 border-green-600 text-white":"border-gray-600 hover:border-brand-500"}`,children:Ge.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 ${Ge.status==="completed"?"line-through text-fg-tertiary":"text-fg-secondary"}`,children:Ge.title}),t.jsx("button",{onClick:()=>A(Ge),className:"shrink-0 opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-red-500 transition-all text-xs",children:"✕"})]},Ge.id))}):null})(),p.length===0&&!k&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:"No subtasks yet."}),k&&t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx("input",{autoFocus:!0,value:b,onChange:ye=>w(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&Se(),ye.key==="Escape"&&(C(!1),w(""))},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:()=>{Se()},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:()=>{C(!1),w("")},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(Et=>Et.type!=="branch"&&typeof Et.reference=="string"&&Et.reference.length>0);if(ye.length===0)return null;const Ge={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"},it=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:()=>T("deliverables"),className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View all →"})]}),t.jsx("div",{className:"space-y-1.5",children:it.map((Et,It)=>{const kn=Et.reference.split("/").pop()??Et.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 ${Ge[Et.type]??"bg-gray-500/15 text-fg-secondary"}`,children:Et.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>B(Et.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:Et.reference,children:kn}),Et.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:Et.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:Et.reference})]})]},It)})})]})})(),t.jsx(Ez,{task:e,agents:n,users:c,authUser:h})]})]}),X==="deliverables"&&t.jsx("div",{className:"px-6 py-4",children:(()=>{const ye=(e.deliverables??[]).filter(It=>It.type!=="branch"&&typeof It.reference=="string"&&It.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 Ge={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"},it=Math.ceil(ye.length/ke),Et=ye.slice((re-1)*ke,re*ke);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,")"]})]}),it>1&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary",children:[t.jsx("button",{disabled:re<=1,onClick:()=>oe(It=>It-1),className:"px-1.5 py-0.5 rounded bg-surface-elevated hover:bg-surface-overlay disabled:opacity-30",children:"‹"}),t.jsxs("span",{children:[re,"/",it]}),t.jsx("button",{disabled:re>=it,onClick:()=>oe(It=>It+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:Et.map((It,kn)=>{const _n=It.reference.split("/").pop()??It.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 ${Ge[It.type]??"bg-gray-500/15 text-fg-secondary"}`,children:It.type}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>B(It.reference),className:"text-sm text-brand-500 hover:text-brand-500 font-medium truncate block max-w-full text-left hover:underline",title:It.reference,children:_n}),It.summary&&t.jsx("p",{className:"text-[11px] text-fg-secondary mt-0.5 line-clamp-2",children:It.summary}),t.jsx("p",{className:"text-[10px] text-fg-tertiary font-mono truncate mt-0.5",children:It.reference})]})]},kn)})})]})})()})]}),G!=="none"&&G!=="top"&&t.jsx("button",{onClick:()=>P.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"})})}),G!=="none"&&G!=="bottom"&&t.jsx("button",{onClick:()=>{const ye=P.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"})})})]}),_t&&e.scheduleConfig&&t.jsxs("div",{className:`mx-6 mt-3 mb-0 px-4 py-2.5 rounded-lg border text-xs ${$t?"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:$t?"text-amber-600":"text-brand-500",children:$t?"⏸ 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"}),!$t&&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 Ge=Math.floor(ye/6e4);if(Ge<60)return`in ${Ge}m`;const it=Math.floor(Ge/60);return it<24?`in ${it}h ${Ge%60}m`:`in ${Math.floor(it/24)}d ${it%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(),Ge=Math.floor(ye/6e4);if(Ge<1)return"just now";if(Ge<60)return`${Ge}m ago`;const it=Math.floor(Ge/60);return it<24?`${it}h ${Ge%60}m ago`:`${Math.floor(it/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:()=>Me(()=>se.tasks.approve(e.id)),disabled:Y,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:()=>Me(()=>se.tasks.reject(e.id)),disabled:Y,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:()=>{Me(()=>se.tasks.accept(e.id,h?.id))},disabled:Y,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50",children:"✓ Approve"}),D?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"text",value:J,onChange:ye=>te(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&J.trim()&&(Me(()=>se.tasks.revision(e.id,J.trim(),h?.id)),W(!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:()=>{Me(()=>se.tasks.revision(e.id,J.trim()||"Revisions needed",h?.id)),W(!1),te("")},disabled:Y,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:()=>{W(!1),te("")},className:"px-1.5 py-1 text-xs text-fg-secondary hover:text-fg-primary",children:"✕"})]}):t.jsx("button",{onClick:()=>W(!0),disabled:Y,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"})]}),ut&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>{Pt()},disabled:Y,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:()=>{xe()},disabled:Y,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"]})]}),Lt&&t.jsx("button",{onClick:()=>{le()},disabled:Y,className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1",children:Y?t.jsx(t.Fragment,{children:"Resuming…"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 1.5v9l7-4.5-7-4.5z"})}),"Resume"]})}),Ut&&t.jsxs("button",{onClick:()=>{xe()},disabled:Y,className:"px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("path",{d:"M1.5 6a4.5 4.5 0 1 1 1.3 3.2",strokeLinecap:"round"}),t.jsx("path",{d:"M1 3.5V6h2.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Retry"]}),_t&&(bn||Ut)&&t.jsx("button",{onClick:()=>{Ce()},disabled:Y,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50 flex items-center gap-1.5",children:Y?t.jsx(t.Fragment,{children:"Running…"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:t.jsx("path",{d:"M3 1.5v9l7-4.5-7-4.5z"})}),"Run Now"]})}),_t&&!ut&&($t?t.jsx("button",{onClick:()=>{Me(()=>se.tasks.resumeSchedule(e.id))},disabled:Y,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:()=>{Me(()=>se.tasks.pauseSchedule(e.id))},disabled:Y,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"})),(bn||Ut||St||Jt)&&t.jsx("button",{onClick:()=>Me(()=>se.tasks.archive(e.id)),disabled:Y,className:"px-3 py-1.5 text-xs bg-gray-600 hover:bg-gray-500 rounded-lg text-white disabled:opacity-50",children:"Archive"}),(bn||Ut)&&t.jsx("button",{onClick:()=>{Ft()},disabled:Y,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"}),!Xt&&e.status!=="pending"&&t.jsx("button",{onClick:async()=>{const{count:ye}=await se.tasks.getDependentCount(e.id);ye>0?_({dependentCount:ye}):Me(()=>se.tasks.cancel(e.id))},disabled:Y,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"})]})}),N&&t.jsx(xw,{title:`Delete subtask "${N.title}"?`,message:"This subtask will be permanently deleted.",confirmLabel:"Delete",onConfirm:()=>{kt(N)},onCancel:()=>A(null)}),R&&t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>_(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:R.dependentCount})," dependent task",R.dependentCount>1?"s":""," that ",R.dependentCount>1?"are":"is"," currently blocked by it."]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{onClick:()=>{_(null),Me(()=>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:()=>{_(null),Me(()=>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 ",R.dependentCount," blocked task",R.dependentCount>1?"s":""]})]}),t.jsx("button",{onClick:()=>_(null),className:"w-full px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary",children:"Keep task running"})]})]})}),Z&&t.jsx(Az,{filePath:Z,onClose:()=>B(null)})]})}function Mz({project:e,tasks:n,requirements:s,agents:l,onDeleteProject:i,onUpdateProject:c,onRefresh:d}){const u=y.useMemo(()=>n.filter(q=>q.projectId===e.id),[n,e.id]),h=y.useMemo(()=>s.filter(q=>q.projectId===e.id),[s,e.id]),f=y.useMemo(()=>{const q={total:u.length,completed:0,inProgress:0,inReview:0,blocked:0,pending:0,failed:0,reqs:h.length,reqsDone:0};for(const X of u)X.status==="completed"||X.status==="accepted"?q.completed++:X.status==="in_progress"?q.inProgress++:X.status==="review"||X.status==="revision"?q.inReview++:X.status==="blocked"?q.blocked++:X.status==="failed"?q.failed++:q.pending++;for(const X of h)X.status==="completed"&&q.reqsDone++;return q},[u,h]),x=y.useMemo(()=>new Set(u.map(q=>q.assignedAgentId).filter(Boolean)),[u]),p=y.useMemo(()=>l.filter(q=>x.has(q.id)),[l,x]),[g,b]=y.useState(!1),[w,k]=y.useState(""),[C,E]=y.useState("main"),[M,N]=y.useState(!1),A=[{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 q=>{if(q!==e.status){N(!0);try{await c({status:q}),d()}finally{N(!1)}}},_=async()=>{const q=w.trim();if(!q)return;const X=[...e.repositories??[],{url:"",localPath:q,defaultBranch:C||"main"}];await c({repositories:X}),k(""),E("main"),b(!1),d()},Y=async q=>{const X=(e.repositories??[]).filter((L,P)=>P!==q);await c({repositories:X}),d()};return t.jsxs("div",{className:"p-5 space-y-5 max-w-3xl",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(vz,{value:e.description??"",onSave:async q=>{await c({description:q}),d()},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:A.map(q=>t.jsxs("button",{disabled:M,onClick:()=>R(q.value),className:`flex-1 px-3 py-2 rounded-lg text-xs font-medium transition-all ${e.status===q.value?q.value==="active"?"bg-green-500/15 text-green-600 ring-1 ring-green-500/30":q.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"} ${M?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[t.jsx("div",{children:q.label}),t.jsx("div",{className:"text-[10px] opacity-70 mt-0.5",children:q.desc})]},q.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(xa,{label:"Total",value:f.total,color:"text-fg-primary"}),t.jsx(xa,{label:"Completed",value:f.completed,color:"text-green-600"}),t.jsx(xa,{label:"In Progress",value:f.inProgress,color:"text-brand-500"}),t.jsx(xa,{label:"In Review",value:f.inReview,color:"text-brand-500"}),t.jsx(xa,{label:"Blocked",value:f.blocked,color:"text-amber-600"}),t.jsx(xa,{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(xa,{label:"Total",value:f.reqs,color:"text-fg-primary"}),t.jsx(xa,{label:"Completed",value:f.reqsDone,color:"text-green-600"}),t.jsx(xa,{label:"Active",value:f.reqs-f.reqsDone,color:"text-brand-500"})]})]}),p.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 (",p.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(q=>{const X=u.filter(P=>P.assignedAgentId===q.id),L=X.filter(P=>!["completed","failed","cancelled","archived"].includes(P.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 ${q.status==="working"?"bg-blue-500":q.status==="idle"?"bg-green-500":"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary",children:q.name}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[L.length," active / ",X.length," total"]})]},q.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:()=>b(!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((q,X)=>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:q.url||q.localPath}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:q.defaultBranch}),t.jsx("button",{onClick:()=>Y(X),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"})]})})]},X)),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:q=>k(q.target.value),placeholder:"Local path (e.g. /Users/me/project)",className:"w-full px-2.5 py-1.5 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:C,onChange:q=>E(q.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:_,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:i,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 xa({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 _l={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"},archived:{label:"Archived",cls:"bg-gray-600/10 text-fg-tertiary/60"}},h5={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed",archived:"closed"},x5={failed:"rejected",todo:"pending",in_progress:"in_progress",review:"in_progress",done:"completed",closed:"cancelled"},Rz={urgent:0,high:1,medium:2,low:3},B1={failed:0,todo:1,in_progress:2,review:3,done:4,closed:5},H1={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"},Oz={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"},Dz=["pending","in_progress","completed","rejected","cancelled","archived"];function Lz(e){for(const n of dc)if(n.statuses.includes(e))return n.id;return"closed"}function P1(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const l=Math.floor(s/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Hd({value:e,options:n,onSelect:s,allowedValues:l}){const[i,c]=y.useState(!1),d=y.useRef(null),u=y.useRef(null),h=n.find(f=>f.value===e);return y.useEffect(()=>{if(!i)return;const f=x=>{u.current&&!u.current.contains(x.target)&&d.current&&!d.current.contains(x.target)&&c(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i]),t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:d,onClick:()=>c(f=>!f),className:`text-[11px] px-2 py-0.5 rounded-full font-medium transition-colors cursor-pointer hover:ring-1 hover:ring-current/30 ${h?.cls??"bg-gray-500/15 text-fg-tertiary"}`,children:h?.label??e}),i&&t.jsx("div",{ref:u,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(f=>{const x=f.value===e,p=x||!l||l.has(f.value);return t.jsxs("button",{disabled:!p,onClick:()=>{!x&&p&&s(f.value),c(!1)},className:`w-full text-left px-3 py-1.5 text-[11px] flex items-center gap-2 transition-colors ${x?"bg-surface-elevated":p?"hover:bg-surface-elevated/60":"opacity-35 cursor-not-allowed"}`,children:[t.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 ${p?f.cls.split(" ")[0]:"bg-gray-600"}`}),t.jsx("span",{className:`font-medium ${x?"text-fg-primary":p?"text-fg-secondary":"text-fg-muted"}`,children:f.label}),x&&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"})})]},f.value)})})]})}function U1({row:e,idx:n,dragIdx:s,agentMap:l,projMap:i,onTaskClick:c,onReqClick:d,onRowDragStart:u,onRowDragEnd:h,handleStatusChange:f,handlePriorityChange:x,selected:p,isMobile:g}){const b=e.data.status,w=e.data.priority,k=e.kind==="task"?l.get(e.data.assignedAgentId??""):void 0,C=i.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"?c(e.data):d(e.data),className:`px-3 py-2 border-b border-border-default/40 cursor-pointer transition-colors border-l-2 ${H1[e.group]??"border-l-gray-700"} ${p?"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:M=>M.stopPropagation(),children:t.jsx(Hd,{value:b,options:e.kind==="task"?L1.map(M=>({value:M,label:Fo[M]?.label??M,cls:Fo[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})):I1.map(M=>({value:M,label:_l[M]?.label??M,cls:_l[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})),allowedValues:e.kind==="task"?z1[b]:vx[b],onSelect:M=>{f(e,M)}})}),t.jsx("div",{onClick:M=>M.stopPropagation(),children:t.jsx(Hd,{value:w,options:D1.map(M=>({value:M,label:Bd[M]?.label??M,cls:Bd[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:M=>{x(e,M)}})}),k&&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 ${jx[k.status]??"bg-gray-500"}`}),t.jsx("span",{className:`${$1[k.status]??"text-fg-secondary"}`,children:k.name})]}),C?.name&&t.jsx("span",{className:"text-[10px] text-brand-400/70 truncate max-w-[80px]",children:C.name}),t.jsx("span",{className:"text-[9px] text-fg-muted ml-auto",children:P1(e.data.updatedAt??"")})]})]}):t.jsxs("div",{draggable:!0,onDragStart:M=>u(M,n),onDragEnd:h,onClick:()=>e.kind==="task"?c(e.data):d(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 ${H1[e.group]??"border-l-gray-700"} ${s===n?"opacity-40":""} ${p?"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:M=>M.stopPropagation(),children:t.jsx(Hd,{value:b,options:e.kind==="task"?L1.map(M=>({value:M,label:Fo[M]?.label??M,cls:Fo[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})):I1.map(M=>({value:M,label:_l[M]?.label??M,cls:_l[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})),allowedValues:e.kind==="task"?z1[b]:vx[b],onSelect:M=>{f(e,M)}})}),t.jsx("div",{className:"w-[100px] shrink-0",onClick:M=>M.stopPropagation(),children:t.jsx(Hd,{value:w,options:D1.map(M=>({value:M,label:Bd[M]?.label??M,cls:Bd[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})),onSelect:M=>{x(e,M)}})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:k?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 ${jx[k.status]??"bg-gray-500"}`}),t.jsx("span",{className:`font-medium ${$1[k.status]??"text-fg-secondary"}`,children:k.name})]}):t.jsx("span",{className:"text-fg-muted",children:"—"})}),t.jsx("div",{className:"w-[120px] shrink-0 text-[11px] truncate",children:C?.name?t.jsx("span",{className:"text-brand-400/70",children:C.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:P1(e.data.updatedAt??"")})]})}function Iz({tasks:e,requirements:n,agents:s,projects:l,onTaskClick:i,onReqClick:c,onRefresh:d,selectedTaskId:u,selectedReqId:h}){const f=Yr(),[x,p]=y.useState("status"),[g,b]=y.useState(null),[w,k]=y.useState(null),C=y.useMemo(()=>{const T=[];for(const z of e){const O=Lz(z.status);T.push({kind:"task",data:z,group:O,groupOrder:B1[O]??5})}for(const z of n){const O=h5[z.status]??"todo";T.push({kind:"req",data:z,group:O,groupOrder:B1[O]??5})}if(x==="status")T.sort((z,O)=>{if(z.groupOrder!==O.groupOrder)return z.groupOrder-O.groupOrder;const V=new Date(z.data.updatedAt??0).getTime();return new Date(O.data.updatedAt??0).getTime()-V});else{const z=O=>Rz[O.data.priority]??2;T.sort((O,V)=>{const H=z(O),Z=z(V);return H!==Z?H-Z:new Date(V.data.updatedAt??0).getTime()-new Date(O.data.updatedAt??0).getTime()})}return T},[e,n,x]),E=async(T,z)=>{try{T.kind==="task"?await se.tasks.updateStatus(T.data.id,z):await se.requirements.updateStatus(T.data.id,z),d()}catch{}},M=async(T,z)=>{try{T.kind==="task"?await se.tasks.update(T.data.id,{priority:z}):await se.requirements.update(T.data.id,{priority:z}),d()}catch{}},N=(T,z)=>{b(z),T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(z)),T.currentTarget.style.opacity="0.4"},A=T=>{T.currentTarget.style.opacity="1",b(null),k(null)},R=(T,z)=>{T.preventDefault(),T.dataTransfer.dropEffect="move",w!==z&&k(z)},_=async(T,z)=>{if(T.preventDefault(),k(null),g==null)return;const O=C[g];if(!O||O.group===z)return;const V=dc.find(H=>H.id===z);if(V){try{if(O.kind==="task"){if(O.data.status==="pending")return;await se.tasks.updateStatus(O.data.id,V.dropStatus)}else{const H=x5[z];H&&await se.requirements.updateStatus(O.data.id,H)}d()}catch{}b(null)}},Y=y.useMemo(()=>new Map(s.map(T=>[T.id,T])),[s]),q=y.useMemo(()=>new Map(l.map(T=>[T.id,T])),[l]),X=["todo","in_progress","review","done"],L=y.useMemo(()=>{const T={};for(const z of C)T[z.group]=(T[z.group]??0)+1;return T},[C]),{rowsByGroup:P,rowIndexMap:G}=y.useMemo(()=>{const T=new Map,z=new Map;for(let O=0;O<C.length;O++){const V=C[O];z.set(V,O);const H=T.get(V.group)??[];H.push(V),T.set(V.group,H)}return{rowsByGroup:T,rowIndexMap:z}},[C]),$=y.useMemo(()=>{if(x!=="status")return null;const T=new Set(C.map(V=>V.group)),z=[],O=new Set;T.has("failed")&&(z.push("failed"),O.add("failed"));for(const V of X)z.push(V),O.add(V);for(const V of C)O.has(V.group)||(z.push(V.group),O.add(V.group));return z},[C,x]);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:C.length}),t.jsx("div",{className:"flex-1 min-w-[200px]",children:"Title"}),t.jsxs("button",{onClick:()=>p("status"),className:`w-[130px] shrink-0 text-left flex items-center gap-1 transition-colors ${x==="status"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Status ",x==="status"&&t.jsx("span",{className:"text-[8px]",children:"▼"})]}),t.jsxs("button",{onClick:()=>p("priority"),className:`w-[100px] shrink-0 text-left flex items-center gap-1 transition-colors ${x==="priority"?"text-brand-500":"hover:text-fg-secondary"}`,children:["Priority ",x==="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:[x==="status"&&$?$.map(T=>{const z=dc.find(V=>V.id===T),O=P.get(T)??[];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 ${Oz[T]??""} ${w===T?"ring-1 ring-brand-500/40":""}`,onDragOver:V=>R(V,T),onDragLeave:()=>k(null),onDrop:V=>{_(V,T)},children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",children:z?.label??T}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:L[T]??0})]}),O.map(V=>t.jsx(U1,{row:V,idx:G.get(V)??0,dragIdx:g,agentMap:Y,projMap:q,onTaskClick:i,onReqClick:c,onRowDragStart:N,onRowDragEnd:A,handleStatusChange:E,handlePriorityChange:M,selected:V.kind==="task"?V.data.id===u:V.data.id===h,isMobile:f},`${V.kind}-${V.data.id}`))]},T)}):C.map((T,z)=>t.jsx(U1,{row:T,idx:z,dragIdx:g,agentMap:Y,projMap:q,onTaskClick:i,onReqClick:c,onRowDragStart:N,onRowDragEnd:A,handleStatusChange:E,handlePriorityChange:M,selected:T.kind==="task"?T.data.id===u:T.data.id===h,isMobile:f},`${T.kind}-${T.data.id}`)),C.length===0&&t.jsx("div",{className:"flex items-center justify-center py-16 text-sm text-fg-tertiary",children:"No items"})]})]})})}function q1({authUser:e}){const n=Yr(),s=Tu({side:"right",defaultWidth:Math.round(window.innerWidth*2/3),minWidth:380,maxWidth:Math.round(window.innerWidth*.8),storageKey:"markus_projects_detail_v3"}),[l,i]=y.useState(!1),c=y.useRef(l);c.current=l;const[d,u]=y.useState([]),[h,f]=y.useState("all"),[x,p]=y.useState(null),[g,b]=y.useState({}),[w,k]=y.useState([]),[C,E]=y.useState([]),[M,N]=y.useState([]),[A,R]=y.useState(!0),[_,Y]=y.useState(""),[q,X]=y.useState(!1),L=y.useCallback(()=>{Mn(x??""),dn(!0)},[x]),[P,G]=y.useState(!1),[$,T]=y.useState(!1),[z,O]=y.useState(""),[V,H]=y.useState(""),[Z,B]=y.useState("medium"),[F,K]=y.useState(""),[I,S]=y.useState(""),[D,W]=y.useState(""),[J,te]=y.useState(""),[re,oe]=y.useState([]),[me,Oe]=y.useState("standard"),[ve,ke]=y.useState("4h"),[Ee,Me]=y.useState(null),[dt,pt]=y.useState(null),[et,Pt]=y.useState(new Set),[le,Se]=y.useState(new Set),We=y.useRef(new Set),kt=y.useRef(new Set),[Ft,xe]=y.useState(null),[Ce,Fe]=y.useState("backlog"),lt=y.useMemo(()=>[{id:"backlog"},{id:"kanban"},{id:"dag"}],[]),ut=va(lt,Ce,Fe),Lt=y.useRef(null),bn=y.useMemo(()=>({scrollContainerRef:Lt}),[]),Ut=va(lt,Ce,Fe,bn),[St,Jt]=y.useState(!1),[yt,Xt]=y.useState(!1),_t=y.useRef(null),$t=y.useRef(null),[Hn,dn]=y.useState(!1),[ye,Ge]=y.useState(""),[it,Et]=y.useState(""),[It,kn]=y.useState("medium"),[_n,Mn]=y.useState(""),[dr,sr]=y.useState(null),[ur,$n]=y.useState(""),ae=ne=>{Y(ne),setTimeout(()=>Y(""),3e3)},Ie=d.find(ne=>ne.id===x)??null;y.useEffect(()=>{kt.current=le},[le]);const qe=y.useCallback(async()=>{try{const{projects:ne}=await se.projects.list();u(ne)}catch{}},[]),Qe=y.useCallback(async()=>{const ne={};h==="project"&&x&&(ne.projectId=x);try{const{board:Le}=await se.tasks.board(ne);b(Le)}catch{}},[h,x]),ue=y.useCallback(async()=>{try{const{agents:ne}=await se.agents.list();k(ne)}catch{}},[]),ze=y.useCallback(async()=>{try{const{users:ne}=await se.users.list(e?.orgId);E(ne)}catch{}},[e?.orgId]),Ve=y.useCallback(async()=>{try{const{requirements:ne}=await se.requirements.list({});N(ne)}catch{}},[]),tt=y.useCallback(async()=>{await Promise.all([qe(),Qe(),ue(),ze(),Ve()]),R(!1)},[qe,Qe,ue,ze,Ve]);y.useEffect(()=>{tt()},[tt]);const ot=y.useCallback(ne=>{Me(Le=>Le?.id===ne.id?(n&&c.current&&i(!1),null):(n&&(i(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash)),ne)),pt(null)},[n]),At=y.useCallback(ne=>{pt(Le=>Le?.id===ne.id?(n&&c.current&&i(!1),null):(n&&(i(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash)),ne)),Me(null)},[n]),Sn=y.useCallback(()=>{Me(null),pt(null),n&&c.current&&i(!1)},[n]);y.useEffect(()=>{if(!n)return;const ne=()=>{c.current&&(i(!1),Me(null),pt(null))};return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[n]);const ar=y.useRef(Ee);ar.current=Ee,y.useEffect(()=>{const ne=ar.current?6e4:15e3,Le=setInterval(()=>{Qe(),ue(),Ve()},ne),Be=Zt.on("task:update",Mt=>{Qe();const He=Mt?.payload;He?.taskId&&Me(hr=>{if(!hr||hr.id!==He.taskId)return hr;const yr={};return typeof He.status=="string"&&(yr.status=He.status),Array.isArray(He.deliverables)&&(yr.deliverables=He.deliverables),Array.isArray(He.notes)&&(yr.notes=He.notes),He.result!==void 0&&(yr.result=He.result),{...hr,...yr}})}),st=Zt.on("task:create",()=>{Qe()}),un=["requirement:created","requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"].map(Mt=>Zt.on(Mt,()=>{Ve()}));return()=>{clearInterval(Le),Be(),st(),un.forEach(Mt=>Mt())}},[Qe,ue,Ve]);const mn=y.useRef(g);mn.current=g;const Wn=y.useRef(M);Wn.current=M;const Ot=y.useCallback(ne=>{if(!ne)return;const Le=kt.current;Le.size>0&&!Le.has(ne)&&Se(Be=>new Set([...Be,ne]))},[]),[pr,Tt]=y.useState(!1),hn=y.useCallback((ne,Le)=>{Me(ne),pt(null),Le?.scrollToComments&&Tt(!0),n&&(i(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash))},[n]),ln=y.useCallback((ne,Le)=>{pt(ne),Me(null),Le?.scrollToComments&&Tt(!0),n&&(i(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash))},[n]);y.useEffect(()=>{const ne=localStorage.getItem("markus_nav_openTask");if(!ne)return;const Be=Object.values(g).flat().find(st=>st.id===ne);Be&&(Ot(Be.projectId),hn(Be),localStorage.removeItem("markus_nav_openTask"))},[g,hn,Ot]),y.useEffect(()=>{const ne=window.location.hash.slice(1).split("/");if(ba(ne[0])===ge.WORK&&ne[1])Rr(ne[1]);else{const Le=localStorage.getItem("markus_nav_projectId");Le&&(localStorage.removeItem("markus_nav_projectId"),Rr(Le))}},[]);const ss=y.useRef(ba(window.location.hash.slice(1).split("/")[0]));y.useEffect(()=>{const ne=()=>{const Be=window.location.hash.slice(1).split("/"),st=ba(Be[0]),en=ss.current===ge.WORK;ss.current=st,st===ge.WORK&&(st===ge.WORK&&Be[1]?Rr(Be[1]):en&&lr())},Le=async Be=>{const st=Be.detail;if(ba(st.page)===ge.WORK){if(st.params?.openTask){const en=st.params.openTask,un=st.params.scrollToComments==="true";localStorage.removeItem("markus_nav_openTask");let Mt=Object.values(mn.current).flat().find(He=>He.id===en);if(!Mt)try{Mt=(await se.tasks.get(en)).task}catch{}Mt&&(Ot(Mt.projectId),hn(Mt,{scrollToComments:un}))}if(st.params?.openRequirement){const en=st.params.openRequirement,un=st.params.scrollToComments==="true";let Mt=Wn.current.find(He=>He.id===en);if(!Mt)try{Mt=(await se.requirements.get(en)).requirement}catch{}Mt&&(Ot(Mt.projectId),ln(Mt,{scrollToComments:un}))}st.params?.projectId&&Rr(st.params.projectId)}};return window.addEventListener("markus:navigate",Le),window.addEventListener("hashchange",ne),()=>{window.removeEventListener("markus:navigate",Le),window.removeEventListener("hashchange",ne)}},[]);const Rr=ne=>{kt.current.size>0&&(We.current=new Set(kt.current)),Se(new Set),p(ne),f("project"),X(!1),history.replaceState(null,"",Dh(ge.WORK,ne))},lr=()=>{Se(We.current),p(null),f("all"),X(!1),history.replaceState(null,"",Dh(ge.WORK))},Or=()=>{G(!1),ae("Project created"),qe()},gs=async ne=>{if(confirm("Delete this project and unlink all its tasks?"))try{await se.projects.delete(ne),x===ne&&lr(),ae("Project deleted"),qe(),Qe()}catch(Le){ae(`Error: ${Le}`)}},as=async()=>{if(!z||!F||!I)return;if(F===I){ae("Assigned agent and reviewer must be different");return}const ne=D||void 0,Le=J||void 0;try{await se.tasks.create(z,V,F,I,Z,ne,re.length>0?re:void 0,Le,me!=="standard"?me:void 0,me==="scheduled"?{every:ve}:void 0),O(""),H(""),oe([]),te(""),Oe("standard"),ke("4h"),T(!1),Qe()}catch(Be){ae(`Error creating task: ${Be}`)}},Os=()=>{Qe(),Ee&&setTimeout(()=>{const ne={};h==="project"&&x&&(ne.projectId=x),se.tasks.board(ne).then(Le=>{const st=Object.values(Le.board).flat().find(en=>en.id===Ee.id);Me(st||null)}).catch(()=>{})},150)},Ds=async()=>{if(!ye.trim()){ae("Please enter a title for this requirement");return}if(!it.trim()){ae("Please enter a description for this requirement");return}if(!_n){ae("Please select a project for this requirement");return}try{await se.requirements.create({title:ye.trim(),description:it.trim(),priority:It,projectId:_n}),ae("Requirement created"),Ge(""),Et(""),dn(!1),Ve()}catch(ne){ae(`Error: ${ne}`)}},gr=async ne=>{try{await se.requirements.approve(ne),ae("Requirement approved"),Ve(),Qe()}catch(Le){ae(`Error: ${Le}`)}},Dr=async()=>{if(dr)try{await se.requirements.reject(dr,ur),ae("Requirement rejected"),sr(null),$n(""),Ve()}catch(ne){ae(`Error: ${ne}`)}},fr=async ne=>{try{await se.requirements.cancel(ne),ae("Requirement cancelled"),Ve()}catch(Le){ae(`Error: ${Le}`)}},Vn=(ne,Le)=>{_t.current=Le,$t.current=null,ne.dataTransfer.effectAllowed="move",ne.dataTransfer.setData("text/plain",`task:${Le.id}`),ne.currentTarget.style.opacity="0.4"},bs=(ne,Le)=>{$t.current=Le,_t.current=null,ne.dataTransfer.effectAllowed="move",ne.dataTransfer.setData("text/plain",`req:${Le.id}`),ne.currentTarget.style.opacity="0.4"},de=ne=>{ne.currentTarget.style.opacity="1",_t.current=null,$t.current=null,xe(null)},Te=(ne,Le)=>{ne.preventDefault(),ne.dataTransfer.dropEffect="move",Ft!==Le&&xe(Le)},Ue=(ne,Le)=>{const Be=ne.currentTarget.getBoundingClientRect(),{clientX:st,clientY:en}=ne;(st<Be.left||st>Be.right||en<Be.top||en>Be.bottom)&&Ft===Le&&xe(null)},qt=async(ne,Le)=>{ne.preventDefault(),xe(null);const Be=_t.current,st=$t.current;if(Be){const en=dc.find(Mt=>Mt.id===Le);if(!en)return;const un=en.dropStatus;if(Be.status===un||Be.status==="pending")return;try{await se.tasks.updateStatus(Be.id,un),Qe()}catch{}}else if(st){const en=x5[Le];if(!en||st.status===en)return;try{await se.requirements.updateStatus(st.id,en),Ve()}catch{}}},Ar=ne=>{Pt(Le=>{const Be=new Set(Le);return Be.has(ne)?Be.delete(ne):Be.add(ne),Be})},Pn=ne=>{Se(Le=>{const Be=new Set(Le);return Be.has(ne)?Be.delete(ne):Be.add(ne),Be})},mr=ne=>ne.status==="archived",Ls=(ne,Le=!1)=>{let Be=ne.filter(st=>St||Le||!mr(st));return h==="project"&&x&&(Be=Be.filter(st=>st.projectId===x)),le.size>0&&(Be=Be.filter(st=>st.projectId&&le.has(st.projectId))),et.size>0&&(Be=Be.filter(st=>st.assignedAgentId&&et.has(st.assignedAgentId))),Be},ys=ne=>ne.statuses.flatMap(Le=>Ls(g[Le]??[])),br=y.useMemo(()=>{let ne=M;return St||(ne=ne.filter(Le=>!mr(Le))),h==="project"&&x&&(ne=ne.filter(Le=>Le.projectId===x)),le.size>0&&(ne=ne.filter(Le=>Le.projectId&&le.has(Le.projectId))),et.size>0&&(ne=ne.filter(Le=>et.has(Le.createdBy))),ne},[M,St,h,x,le,et]),ka=y.useCallback(ne=>br.filter(Le=>h5[Le.status]===ne.id),[br]),Hl=dc.filter(ne=>{if(ne.id==="failed"||ne.id==="closed"){const Le=ys(ne),Be=ka(ne);return Le.length+Be.length>0}return!0}),ir=Object.values(g).flat().filter(ne=>mr(ne)).length+M.filter(ne=>mr(ne)).length,Sa=y.useMemo(()=>{const ne=new Set(["completed","failed","cancelled","archived"]),Le=Object.values(g).flat(),Be=new Set;for(const st of Le)st.assignedAgentId&&!ne.has(st.status)&&(!x||st.projectId===x)&&Be.add(st.assignedAgentId);return[...w].sort((st,en)=>{const un=Be.has(st.id)?0:1,Mt=Be.has(en.id)?0:1;return un-Mt})},[w,g,x]),il=y.useMemo(()=>{const ne=new Set(["completed","failed","cancelled","archived"]),Le=Object.values(g).flat(),Be=new Set;for(const st of Le)st.projectId&&!ne.has(st.status)&&Be.add(st.projectId);return[...d].sort((st,en)=>{const un=Be.has(st.id)?0:1,Mt=Be.has(en.id)?0:1;return un-Mt})},[d,g]),ls=y.useMemo(()=>{const ne={};for(const Le of Object.values(g))for(const Be of Le){const st=Be.projectId??"__none__";ne[st]=(ne[st]??0)+1}return ne},[g]),Zs=Object.values(ls).reduce((ne,Le)=>ne+Le,0);if(A)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary",children:"Loading…"});const Ca=!!(Ee||dt);return t.jsxs("div",{className:"flex-1 overflow-hidden flex bg-surface-secondary",children:[t.jsxs("div",{className:`${n?"flex-1 min-w-0":Ca?"shrink-0":"flex-1"} overflow-hidden flex flex-col bg-surface-secondary`,style:n?l?{display:"none"}:void 0:Ca?{width:`calc(100% - ${s.width}px - 4px)`}:void 0,children:[_&&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:_}),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:[Ie?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:Ie.name}),t.jsx("button",{onClick:()=>X(!q),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors shrink-0 ${q?"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:d.length===1?d[0].name:`${d.length} Projects`}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx("button",{onClick:()=>G(!0),className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Project"}),t.jsx("button",{onClick:L,className:"px-2 py-1 text-[11px] bg-brand-600 text-white rounded-md",children:"+ Req"}),t.jsx("button",{onClick:()=>{W(x??""),T(!0)},className:"px-2 py-1 text-[11px] border border-border-default text-fg-secondary rounded-md",children:"+ Task"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 px-3 h-9 border-t border-border-default/40",children:[t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(ne=>t.jsx("button",{onClick:()=>Fe(ne),className:`px-2 py-0.5 text-[10px] font-medium transition-colors ${Ce===ne?"bg-brand-600/25 text-brand-500":"text-fg-tertiary"}`,children:ne==="backlog"?"Backlog":ne==="kanban"?"Kanban":"DAG"},ne))}),ir>0&&t.jsx("button",{onClick:()=>Jt(ne=>!ne),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${St?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary"}`,children:St?"Hide archived":`${ir} archived`}),t.jsx("div",{className:"flex-1"}),(le.size>0||et.size>0||d.length>1||w.length>0)&&t.jsxs("button",{onClick:()=>Xt(!0),className:`px-2 py-1 text-[11px] rounded-md font-medium transition-colors flex items-center gap-1 ${le.size>0||et.size>0?"bg-brand-600/20 text-brand-500 ring-1 ring-brand-500/30":"border border-border-default text-fg-secondary"}`,children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})}),"Filter",le.size+et.size>0?` (${le.size+et.size})`:""]})]})]}):t.jsxs("div",{className:"flex items-center gap-3 px-6 h-14 border-b border-border-default bg-surface-secondary/80 shrink-0",children:[Ie?t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(yz,{value:Ie.name,onSave:async ne=>{await se.projects.update(Ie.id,{name:ne}),qe()},className:"text-sm font-semibold text-fg-primary"}),t.jsx("button",{onClick:()=>X(!q),className:`w-6 h-6 flex items-center justify-center rounded-md transition-colors ${q?"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:d.length===1?d[0].name:`${d.length} Projects`}),ir>0&&t.jsx("button",{onClick:()=>Jt(ne=>!ne),className:`text-[10px] shrink-0 px-2 py-0.5 rounded-md transition-colors ${St?"bg-surface-overlay text-fg-secondary":"text-fg-tertiary hover:text-fg-secondary"}`,children:St?`Hide ${ir} archived`:`${ir} archived`}),t.jsx("div",{className:"flex items-center border border-border-default/60 rounded-md overflow-hidden shrink-0",children:["backlog","kanban","dag"].map(ne=>t.jsx("button",{onClick:()=>Fe(ne),className:`px-2.5 py-1 text-[10px] font-medium transition-colors ${Ce===ne?"bg-brand-600/25 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:ne==="backlog"?"Backlog":ne==="kanban"?"Kanban":"DAG"},ne))}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("button",{onClick:L,className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg font-medium transition-colors",children:"+ Requirement"}),t.jsx("button",{onClick:()=>{W(x??""),T(!0)},className:"px-3 py-1.5 border border-border-default hover:bg-surface-elevated text-fg-secondary text-xs rounded-lg font-medium transition-colors",children:"+ Task"})]}),t.jsx("div",{className:"flex-1"})]}),!n&&d.length>1&&!x&&!q&&(Zs>0||M.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:()=>Se(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 ${le.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),il.map(ne=>{const Le=le.has(ne.id),Be=ls[ne.id]??0;return t.jsxs("button",{onClick:()=>Pn(ne.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:ne.name[0]?.toUpperCase()}),ne.name,Be>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary ml-0.5",children:Be})]},ne.id)})]}),!n&&w.length>0&&!q&&(Zs>0||M.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:()=>Pt(new Set),className:`text-[10px] text-fg-tertiary hover:text-fg-secondary px-2 py-1 rounded-md bg-surface-elevated/60 hover:bg-surface-overlay shrink-0 transition-all ${et.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),Sa.map(ne=>{const Le=et.has(ne.id);return t.jsxs("button",{onClick:()=>Ar(ne.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:ne.name[0]?.toUpperCase()}),ne.name]},ne.id)})]}),q&&Ie?t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(Mz,{project:Ie,tasks:Object.values(g).flat(),requirements:M,agents:w,onDeleteProject:()=>gs(Ie.id),onUpdateProject:async ne=>{await se.projects.update(Ie.id,ne)},onRefresh:()=>{qe()}})}):Zs===0&&br.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:L,className:"text-xs text-brand-500 hover:text-brand-500 font-medium",children:"+ Create a requirement"})]})}):Ce==="backlog"?t.jsx("div",{className:"flex-1 min-h-0 flex flex-col",onTouchStart:n?ut.onTouchStart:void 0,onTouchEnd:n?ut.onTouchEnd:void 0,children:t.jsx(Iz,{tasks:Ls(Object.values(g).flat()),requirements:br,agents:w,projects:d,onTaskClick:ne=>ot(ne),onReqClick:ne=>At(ne),onRefresh:()=>{Qe(),Ve()},selectedTaskId:Ee?.id,selectedReqId:dt?.id})}):Ce==="dag"?t.jsxs("div",{className:"flex-1 min-h-0 flex flex-col relative",onTouchStart:n?ut.onTouchStart:void 0,onTouchEnd:n?ut.onTouchEnd:void 0,children:[t.jsx(bz,{tasks:Ls(Object.values(g).flat(),!0),requirements:br,agents:w,showArchived:St,onShowArchivedChange:Jt,onTaskClick:ne=>ot(ne),onReqClick:ne=>At(ne),onDependencyChange:Qe,selectedTaskId:Ee?.id,selectedReqId:dt?.id}),n&&t.jsx("button",{onClick:()=>Fe("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:Lt,className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden px-4 py-5",onTouchStart:n?Ut.onTouchStart:void 0,onTouchEnd:n?Ut.onTouchEnd:void 0,children:t.jsx("div",{className:"flex gap-3 h-full",children:Hl.map(ne=>{const Le=ys(ne),Be=ka(ne),st=Le.length+Be.length,en=Ft===ne.id;return t.jsxs("div",{className:`w-[280px] shrink-0 rounded-xl flex flex-col h-full transition-colors ${en?"bg-surface-elevated/60 ring-1 ring-brand-500/30":"bg-surface-secondary/50"}`,onDragOver:un=>Te(un,ne.id),onDragLeave:un=>Ue(un,ne.id),onDrop:un=>{qt(un,ne.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 ${ne.accent.replace("border-t-","bg-")}`}),t.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:ne.label})]}),t.jsx("span",{className:"text-[11px] text-fg-tertiary font-medium tabular-nums",children:st})]}),t.jsx("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto scrollbar-thin px-2 py-2",children:(()=>{const un=[...Be.map(Mt=>({kind:"req",data:Mt,time:new Date(Mt.updatedAt??Mt.createdAt).getTime()})),...Le.map(Mt=>({kind:"task",data:Mt,time:new Date(Mt.updatedAt??Mt.createdAt??0).getTime()}))];return un.sort((Mt,He)=>He.time-Mt.time),un.map(Mt=>{if(Mt.kind==="req"){const He=Mt.data,hr=_l[He.status]??{label:He.status,cls:"bg-gray-500/15 text-fg-secondary"},vr=He.source==="agent"&&He.status==="pending",Yn=h==="all"&&He.projectId?d.find(ee=>ee.id===He.projectId):null,vs=Hi(He.createdBy,w,C)??He.createdBy.slice(0,10),Lr=dt?.id===He.id;return t.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:ee=>bs(ee,He),onDragEnd:de,onClick:()=>At(He),onKeyDown:ee=>ee.key==="Enter"&&At(He),className:`group rounded-lg p-2.5 border border-transparent transition-all cursor-grab active:cursor-grabbing
|
|
65
|
+
${vr?"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"}
|
|
66
|
+
${Lr?"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 ${hr.cls}`,children:hr.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:He.title}),He.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:He.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:[Yn&&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:Yn.name,children:Yn.name}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:He.priority}),t.jsxs("span",{className:"text-[10px] text-fg-quaternary",children:["by ",vs]})]}),t.jsx("div",{className:"flex items-center gap-1",children:He.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:["📋 ",He.taskIds.length]})})]}),vr&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-amber-500/15",children:[t.jsx("button",{onClick:ee=>{ee.stopPropagation(),gr(He.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:ee=>{ee.stopPropagation(),sr(He.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-${He.id}`)}else{const He=Mt.data,hr=He.subtasks?.length??0,yr=m5[He.status],vr=He.status==="pending",Yn=He.taskType==="scheduled"&&!!He.scheduleConfig,vs=Yn?He.scheduleConfig.every?`Every ${He.scheduleConfig.every}`:He.scheduleConfig.cron?"Cron":"Scheduled":null,Lr=h==="all"&&He.projectId?d.find(Xe=>Xe.id===He.projectId)?.name:null,ee=He.requirementId?M.find(Xe=>Xe.id===He.requirementId)?.title:null,Ne=He.createdBy?Hi(He.createdBy,w,C)??He.createdBy:null,Re=Ee?.id===He.id,Ke={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":He.title,draggable:!vr,onDragStart:Xe=>!vr&&Vn(Xe,He),onDragEnd:de,onClick:()=>ot(He),onKeyDown:Xe=>Xe.key==="Enter"&&ot(He),className:`group rounded-lg p-2.5 border border-transparent transition-all ${vr?"bg-amber-500/[0.06] border-amber-500/30 ring-1 ring-amber-500/15 cursor-pointer":Yn?"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"} ${Re?"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 ${Ke[He.priority]??"bg-gray-400"}`,title:He.priority}),Yn&&t.jsx("span",{className:"text-blue-500 shrink-0",title:vs??"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"})})}),Yn&&vs&&t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-blue-500/10 text-blue-500 whitespace-nowrap",children:vs}),yr&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md ml-auto shrink-0 ${yr.cls}`,children:yr.label})]}),t.jsx("div",{className:"text-[13px] font-medium leading-snug text-fg-primary line-clamp-2 mb-1",children:He.title}),He.description&&t.jsx("div",{className:"text-[11px] text-fg-tertiary line-clamp-1 mb-1.5",children:He.description}),(Lr||ee||He.blockedBy&&He.blockedBy.length>0)&&t.jsxs("div",{className:"flex flex-wrap gap-1 mb-1.5",children:[Lr&&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:Lr,children:Lr}),ee&&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:ee,children:["# ",ee]}),He.blockedBy&&He.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:["⏳ ",He.blockedBy.length," dep",He.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:Ne&&t.jsxs("span",{className:"text-[10px] text-fg-quaternary",title:`by ${Ne}`,children:["by ",Ne]})}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[hr>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["⋮ ",hr]}),He.notes&&He.notes.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["📝 ",He.notes.length]}),He.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 ${jx[w.find(Xe=>Xe.id===He.assignedAgentId)?.status??""]??"bg-gray-500"}`}),w.find(Xe=>Xe.id===He.assignedAgentId)?.name??He.assignedAgentId.slice(0,8)]})]})]})]},He.id)}})})()}),en&&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"})})]},ne.id)})})})]}),!n&&Ca&&t.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-border-default/40 hover:bg-brand-500/30 active:bg-brand-500/50 transition-colors",onMouseDown:s.onResizeStart}),(!n||l)&&Ca&&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:Ee?t.jsx(_z,{task:Ee,agents:w,projects:d,requirements:M,allTasks:Object.values(g).flat(),users:C,onClose:Sn,onRefresh:Os,authUser:e,scrollToComments:pr,onScrollToCommentsDone:()=>Tt(!1)}):dt?t.jsx($z,{req:dt,agents:w,projects:d,allTasks:Object.values(g).flat(),users:C,onClose:Sn,onApprove:ne=>{gr(ne),Sn()},onReject:ne=>{sr(ne),Sn()},onCancel:ne=>{fr(ne),Sn()},onStatusChange:async(ne,Le)=>{try{await se.requirements.updateStatus(ne,Le),ae(`Requirement status → ${Le}`),Ve(),Qe()}catch(Be){ae(`Error: ${Be}`)}},scrollToComments:pr,onScrollToCommentsDone:()=>Tt(!1),onRefresh:Ve,authUser:e}):null}),P&&t.jsx(u5,{orgId:e?.orgId,onCreated:Or,onClose:()=>G(!1)}),$&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>T(!1),children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 space-y-4 max-h-[90dvh] overflow-y-auto ${n?"w-full":"w-[28rem]"}`,onClick:ne=>ne.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"New Task"}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Project"}),t.jsxs("select",{value:D,onChange:ne=>W(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"No Project"}),d.map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Requirement"}),t.jsxs("select",{value:J,onChange:ne=>te(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a requirement…"}),M.filter(ne=>ne.status==="in_progress"&&(!D||ne.projectId===D)).map(ne=>t.jsx("option",{value:ne.id,children:ne.title},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{autoFocus:!n,value:z,onChange:ne=>O(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&as()},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:V,onChange:ne=>H(ne.target.value),rows:2,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none resize-none"})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Priority"}),t.jsxs("select",{value:Z,onChange:ne=>B(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-fg-secondary mb-1.5",children:["Assign to ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:F,onChange:ne=>K(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select agent…"}),w.map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm text-fg-secondary mb-1.5",children:["Reviewer ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsxs("select",{value:I,onChange:ne=>S(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select reviewer…"}),w.filter(ne=>ne.id!==F).map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Task Type"}),t.jsxs("select",{value:me,onChange:ne=>Oe(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"standard",children:"Standard"}),t.jsx("option",{value:"scheduled",children:"Scheduled (recurring)"})]})]}),me==="scheduled"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Frequency"}),t.jsxs("select",{value:ve,onChange:ne=>ke(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"30m",children:"Every 30 min"}),t.jsx("option",{value:"1h",children:"Every 1 hour"}),t.jsx("option",{value:"2h",children:"Every 2 hours"}),t.jsx("option",{value:"4h",children:"Every 4 hours"}),t.jsx("option",{value:"8h",children:"Every 8 hours"}),t.jsx("option",{value:"12h",children:"Every 12 hours"}),t.jsx("option",{value:"1d",children:"Every day"}),t.jsx("option",{value:"1w",children:"Every week"})]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Blocked By (dependencies)"}),t.jsxs("select",{value:"",onChange:ne=>{const Le=ne.target.value;Le&&!re.includes(Le)&&oe([...re,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(ne=>ne.status!=="completed"&&ne.status!=="cancelled"&&!re.includes(ne.id)).map(ne=>t.jsx("option",{value:ne.id,children:ne.title},ne.id))]}),re.length>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:re.map(ne=>{const Le=Object.values(g).flat().find(Be=>Be.id===ne);return t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-2 py-1 bg-amber-500/10 text-amber-600 rounded-full",children:["⏳ ",Le?Le.title.slice(0,30):ne.slice(-8),t.jsx("button",{onClick:()=>oe(re.filter(Be=>Be!==ne)),className:"ml-0.5 text-amber-600/60 hover:text-amber-600",children:"×"})]},ne)})})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>T(!1),className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated text-fg-secondary",children:"Cancel"}),t.jsx("button",{onClick:()=>{as()},disabled:!F||!I,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Create"})]})]})}),Hn&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>{dn(!1),Ge(""),Et("")},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:ne=>ne.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"New Requirement"}),t.jsx("p",{className:"text-xs text-fg-tertiary -mt-2",children:"Describe what you need. Agents will break approved requirements into tasks."}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Project"}),t.jsxs("select",{value:_n,onChange:ne=>Mn(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"",children:"Select a project…"}),d.map(ne=>t.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Title"}),t.jsx("input",{value:ye,onChange:ne=>Ge(ne.target.value),placeholder:"e.g. Add user authentication",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",autoFocus:!n,onKeyDown:ne=>{ne.key==="Enter"&&ye.trim()&&Ds()}})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Description"}),t.jsx("textarea",{value:it,onChange:ne=>Et(ne.target.value),placeholder:"What is needed and why...",rows:3,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-none"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Priority"}),t.jsxs("select",{value:It,onChange:ne=>kn(ne.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none",children:[t.jsx("option",{value:"low",children:"Low"}),t.jsx("option",{value:"medium",children:"Medium"}),t.jsx("option",{value:"high",children:"High"}),t.jsx("option",{value:"urgent",children:"Urgent"})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1",children:[t.jsx("button",{onClick:()=>{dn(!1),Ge(""),Et("")},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:()=>{Ds()},disabled:!ye.trim()||!it.trim()||!_n,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"})]})]})}),dr&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-3",onClick:()=>sr(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:ne=>ne.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:"Reject Requirement"}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-fg-secondary mb-1.5",children:"Reason"}),t.jsx("textarea",{value:ur,onChange:ne=>$n(ne.target.value),placeholder:"Why is this being rejected...",rows:3,className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-red-500 outline-none resize-none",autoFocus:!n})]}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>sr(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:()=>{Dr()},className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 rounded-lg text-white",children:"Reject"})]})]})}),yt&&t.jsxs("div",{className:"fixed inset-0 z-[60] flex flex-col justify-end",onClick:()=>Xt(!1),children:[t.jsx("div",{className:"absolute inset-0 bg-black/50"}),t.jsxs("div",{className:"relative bg-surface-secondary rounded-t-2xl border-t border-border-default max-h-[70vh] overflow-y-auto pb-16",onClick:ne=>ne.stopPropagation(),children:[t.jsxs("div",{className:"sticky top-0 bg-surface-secondary z-10 px-4 pt-3 pb-2 flex items-center justify-between border-b border-border-default/60",children:[t.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:"Filters"}),t.jsxs("div",{className:"flex items-center gap-2",children:[(le.size>0||et.size>0)&&t.jsx("button",{onClick:()=>{Se(new Set),Pt(new Set)},className:"text-[11px] text-brand-500 font-medium",children:"Clear all"}),t.jsx("button",{onClick:()=>Xt(!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"})]})})]})]}),d.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:il.map(ne=>{const Le=le.has(ne.id),Be=ls[ne.id]??0;return t.jsxs("button",{onClick:()=>Pn(ne.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:ne.name[0]?.toUpperCase()}),ne.name,Be>0&&t.jsx("span",{className:"text-[9px] text-fg-tertiary",children:Be})]},ne.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:Sa.map(ne=>{const Le=et.has(ne.id);return t.jsxs("button",{onClick:()=>Ar(ne.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:ne.name[0]?.toUpperCase()}),ne.name]},ne.id)})})]}),t.jsx("div",{className:"h-[env(safe-area-inset-bottom,0px)]"})]})]})]})}function zz({requirementId:e,agents:n,authUser:s}){const[l,i]=y.useState([]);y.useEffect(()=>{se.requirements.getComments(e).then(f=>i(f.comments)).catch(()=>{})},[e]),y.useEffect(()=>Zt.on("requirement:comment",x=>{x.payload?.requirementId===e&&x.payload.comment&&i(p=>p.some(g=>g.id===x.payload.comment.id)?p:[...p,x.payload.comment])}),[e]);const[c,d]=y.useState(null),u=async(f,x,p)=>{await se.requirements.addComment(e,f,s?.name,s?.id,x.length>0?x:void 0,p)},h=y.useCallback(f=>{d({id:f.id,authorName:f.authorName,content:f.content.slice(0,100)})},[]);return t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 block",children:["Comments ",l.length>0&&t.jsxs("span",{className:"font-normal",children:["(",l.length,")"]})]}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[l.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary text-center py-4",children:"No comments yet."}),l.map(f=>t.jsx(Wo,{comment:f,agents:n,onReply:h},f.id))]}),t.jsx(hw,{agents:n,onSubmit:u,replyTo:c,onCancelReply:()=>d(null)})]})}function $z({req:e,agents:n,projects:s,allTasks:l,users:i,onClose:c,onApprove:d,onReject:u,onCancel:h,onStatusChange:f,onRefresh:x,authUser:p,scrollToComments:g,onScrollToCommentsDone:b}){const w=Yr(),[k,C]=y.useState(!1),[E,M]=y.useState(e.description),[N,A]=y.useState(!1),R=y.useRef(null);y.useEffect(()=>{if(!g)return;const T=setTimeout(()=>{const z=R.current;z&&z.scrollTo({top:z.scrollHeight,behavior:"smooth"}),b?.()},300);return()=>clearTimeout(T)},[g,b]);const _=_l[e.status]??{label:e.status,cls:"bg-gray-500/15 text-fg-secondary"},Y=e.source==="agent",q=Y&&e.status==="pending",X=e.status==="pending"||e.status==="in_progress",L=e.status==="completed"||e.status==="rejected"||e.status==="cancelled"||e.status==="archived",P=e.projectId?s.find(T=>T.id===e.projectId):null,G=Hi(e.createdBy,n,i)??e.createdBy.slice(0,12),$=l.filter(T=>e.taskIds.includes(T.id));return y.useEffect(()=>{M(e.description),C(!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:[w&&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-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 ${_.cls}`,children:_.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})]})]}),!w&&t.jsx("button",{onClick:c,className:"text-fg-tertiary hover:text-fg-secondary text-xl leading-none shrink-0 mt-1",children:"×"})]}),t.jsxs("div",{ref:R,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"}),k?t.jsxs("div",{className:"space-y-2",children:[t.jsx("textarea",{value:E,onChange:T=>M(T.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:()=>{C(!1),M(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()=>{A(!0);try{await se.requirements.update(e.id,{description:E}),C(!1),x?.()}catch{}finally{A(!1)}},disabled:N,className:"px-2.5 py-1 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white disabled:opacity-50",children:"Save"})]})]}):t.jsxs("div",{className:"group relative",children:[e.description?t.jsx(Fn,{content:e.description,className:"text-sm text-fg-secondary leading-relaxed"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No description"}),!L&&t.jsx("button",{onClick:()=>{M(e.description),C(!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:G}),Y&&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()})]}),P&&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:P.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:Hi(e.approvedBy,n,i)??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(T=>t.jsxs("span",{className:"text-[10px] bg-surface-elevated text-fg-secondary px-2 py-0.5 rounded-full",children:["#",T]},T))}),$.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(T=>{const z=m5[T.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 ${Sz[T.priority]?.replace("border-l-","bg-")??"bg-gray-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:T.title}),z&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${z.cls}`,children:z.label})]},T.id)})})]}),t.jsx(zz,{requirementId:e.id,agents:n,authUser:p})]}),t.jsxs("div",{className:"flex items-center gap-2 p-5 pt-3 border-t border-border-default",children:[q&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>d(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:()=>u(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"})]}),!q&&f&&!L&&t.jsx("select",{value:e.status,onChange:T=>{T.target.value!==e.status&&f(e.id,T.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:Dz.map(T=>{const z=_l[T],O=T===e.status||(vx[e.status]?.has(T)??!1);return t.jsx("option",{value:T,disabled:!O,children:z?.label??T},T)})}),L&&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"}),X&&!q&&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 Hs(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 Bz(e){return e.files&&typeof e.files=="object"&&!Array.isArray(e.files)?e.files:null}function Cl({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 vi({label:e,value:n,color:s}){if(!n)return null;const l={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:e}),t.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${l[s]??l.gray} capitalize inline-block`,children:n})]})}function Mh({files:e}){const[n,s]=y.useState(Object.keys(e)[0]??""),l=Object.keys(e);return l.length===0?null:t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Files (",l.length,")"]}),t.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[t.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:l.map(i=>t.jsx("button",{onClick:()=>s(i),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${n===i?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:i},i))}),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 Hz({artifact:e,mode:n}){const s=Bz(e),l=e.agent,i=e.team,c=e.dependencies,d=e.displayName??e.name;if(n==="agent"){const u=l?.roleName,h=l?.agentRole,f=l?.llmProvider,x=l?.llmModel,p=Hs(c?.env),g=Hs(c?.skills);return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Cl,{label:"Name",value:d}),t.jsx(Cl,{label:"Description",value:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[u&&t.jsx(vi,{label:"Base Template",value:u,color:"indigo"}),t.jsx(vi,{label:"Agent Role",value:h,color:h==="manager"?"purple":"cyan"})]}),Hs(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:Hs(e.tags).map(b=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:b},b))}),(f||x)&&t.jsxs("div",{className:"flex gap-2",children:[f&&t.jsx(vi,{label:"LLM Provider",value:f,color:"gray"}),x&&t.jsx(vi,{label:"LLM Model",value:x,color:"gray"})]}),p.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:p.map(b=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:b},b))})]}),g.length>0&&t.jsx(Cl,{label:"Skills",value:g.join(", ")}),s&&t.jsx(Mh,{files:s})]})}if(n==="team"){const h=i?.members??[];return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Cl,{label:"Name",value:d}),t.jsx(Cl,{label:"Description",value:e.description}),t.jsx("div",{className:"flex flex-wrap gap-2",children:t.jsx(vi,{label:"Category",value:e.category,color:"indigo"})}),Hs(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:Hs(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(Mh,{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,x)=>t.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${f.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:f.role==="manager"?"★":x+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)]})]}),Hs(f.skills).length>0&&t.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:Hs(f.skills).map(p=>t.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:p},p))})]},x))})]})]})}return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Cl,{label:"Name",value:d}),t.jsx(Cl,{label:"Description",value:e.description}),t.jsx("div",{className:"flex gap-2",children:t.jsx(vi,{label:"Category",value:e.category,color:"indigo"})}),s&&t.jsx(Mh,{files:s}),Hs(e.tags).length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:Hs(e.tags).map(u=>t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:u},u))})]})}const $o={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},F1={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"}},V1=["file","directory"],Ps={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 Y1(){const e=Yr(),n=Tu({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[s,l]=y.useState(!1),i=y.useRef(s);i.current=s,y.useEffect(()=>{if(!e)return;const ue=()=>{i.current&&l(!1)};return window.addEventListener("popstate",ue),()=>window.removeEventListener("popstate",ue)},[e]);const c=100,[d,u]=y.useState([]),[h,f]=y.useState(0),[x,p]=y.useState(!1),[g,b]=y.useState([]),[w,k]=y.useState([]),[C,E]=y.useState(!0),[M,N]=y.useState(""),[A,R]=y.useState(""),[_,Y]=y.useState(""),[q,X]=y.useState(""),[L,P]=y.useState(""),[G,$]=y.useState(""),[T,z]=y.useState(""),[O,V]=y.useState("date"),[H,Z]=y.useState(null),[B,F]=y.useState(null),[K,I]=y.useState(""),[S,D]=y.useState(!1),[W,J]=y.useState(!1),[te,re]=y.useState(new Set),oe=y.useMemo(()=>[{id:"date"},{id:"project"},{id:"agent"},{id:"type"}],[]),me=y.useCallback(ue=>{V(ue),re(new Set)},[]),Oe=va(oe,O,me),ve=y.useRef(null),[ke,Ee]=y.useState("file"),[Me,dt]=y.useState(""),[pt,et]=y.useState(""),[Pt,le]=y.useState(""),[Se,We]=y.useState(""),[kt,Ft]=y.useState(""),[xe,Ce]=y.useState(null),[Fe,lt]=y.useState(null),[ut,Lt]=y.useState(!1),[bn,Ut]=y.useState(!1),[St,Jt]=y.useState(!1),[yt,Xt]=y.useState(""),_t=y.useRef(void 0),$t=(ue,ze)=>{F({type:ue,text:ze}),setTimeout(()=>F(null),3e3)},Hn=async ue=>{await Fx(ue)?(Jt(!0),setTimeout(()=>Jt(!1),1500)):$t("error","Copy failed — try long-pressing to copy manually")},dn=y.useMemo(()=>new Map(w.map(ue=>[ue.id,ue])),[w]),ye=y.useMemo(()=>new Map(g.map(ue=>[ue.id,ue])),[g]);y.useEffect(()=>{se.projects.list().then(ue=>b(ue.projects)).catch(()=>{}),se.agents.list().then(ue=>k(ue.agents??[])).catch(()=>{}),se.system.storage().then(ue=>Xt(ue.dataDir+"/shared")).catch(()=>{})},[]),y.useEffect(()=>(_t.current=setTimeout(()=>R(M),300),()=>clearTimeout(_t.current)),[M]);const Ge=y.useMemo(()=>({q:A||void 0,projectId:q||void 0,agentId:L||void 0,type:_||void 0,status:G||void 0,artifactType:T||void 0}),[A,q,L,_,G,T]),it=y.useCallback(async()=>{E(!0);try{const{results:ue,total:ze}=await se.deliverables.search({...Ge,offset:0,limit:c});u(ue),f(ze)}catch{u([]),f(0)}E(!1)},[Ge]),Et=y.useCallback(async()=>{if(!(x||d.length>=h)){p(!0);try{const{results:ue,total:ze}=await se.deliverables.search({...Ge,offset:d.length,limit:c});u(Ve=>[...Ve,...ue]),f(ze)}catch{}p(!1)}},[Ge,d.length,h,x]);y.useEffect(()=>{it()},[it]),y.useEffect(()=>{const ue=Zt.on("deliverable:created",()=>it()),ze=Zt.on("deliverable:updated",()=>it()),Ve=Zt.on("deliverable:removed",()=>it());return()=>{ue(),ze(),Ve()}},[it]);const It=y.useCallback(()=>{const ue=ve.current;!ue||C||x||d.length>=h||ue.scrollHeight<=ue.clientHeight+100&&Et()},[C,x,d.length,h,Et]);y.useEffect(()=>{const ue=ve.current;if(!ue)return;const ze=()=>{ue.scrollTop+ue.clientHeight>=ue.scrollHeight-100&&Et()};return ue.addEventListener("scroll",ze,{passive:!0}),()=>ue.removeEventListener("scroll",ze)},[Et]),y.useEffect(()=>{It()},[It,te]);const kn=y.useMemo(()=>{const ue=new Map;for(const Ve of d){let tt,ot;if(O==="project")tt=Ve.projectId??"_none",ot=Ve.projectId?ye.get(Ve.projectId)?.name??Ve.projectId:"No Project";else if(O==="agent")tt=Ve.agentId??"_none",ot=Ve.agentId?dn.get(Ve.agentId)?.name??Ve.agentId:"Unknown";else if(O==="type")tt=Ve.type,ot=Ve.type.charAt(0).toUpperCase()+Ve.type.slice(1);else{const At=new Date(Ve.updatedAt);tt=`${At.getFullYear()}-${String(At.getMonth()+1).padStart(2,"0")}-${String(At.getDate()).padStart(2,"0")}`,ot=tt}ue.has(tt)||ue.set(tt,{label:ot,items:[]}),ue.get(tt).items.push(Ve)}const ze=[...ue.entries()];return O==="date"?ze.sort((Ve,tt)=>tt[0].localeCompare(Ve[0])):ze.sort((Ve,tt)=>Ve[1].label.localeCompare(tt[1].label)),ze},[d,O,ye,dn]),_n=async()=>{if(!(!Me.trim()||!pt.trim())){J(!0);try{await se.deliverables.create({type:ke,title:Me,summary:pt,reference:Pt,projectId:Se||void 0,tags:kt.split(",").map(ue=>ue.trim()).filter(Boolean)}),D(!1),$t("success","Deliverable created"),it()}catch(ue){$t("error",`Error: ${ue}`)}J(!1)}},Mn=async ue=>{I("verify");try{await se.deliverables.verify(ue.id),$t("success","Verified"),Z({...ue,status:"verified"}),it()}catch(ze){$t("error",`Error: ${ze}`)}I("")},dr=async ue=>{I("flag");try{await se.deliverables.update(ue.id,{status:"outdated"}),$t("success","Flagged as outdated"),Z({...ue,status:"outdated"}),it()}catch(ze){$t("error",`Error: ${ze}`)}I("")},sr=async ue=>{I("remove");try{await se.deliverables.remove(ue.id),$t("success","Removed"),Z(null),it()}catch(ze){$t("error",`Error: ${ze}`)}I("")},ur=()=>{bt.navigate(ge.BUILDER)},$n=async ue=>{if(ue.reference){if(ue.type==="directory"){Ut(!0);return}Lt(!0);try{const ze=await se.files.preview(ue.reference);ze.type==="image"&&ze.mimeType?lt({src:`data:${ze.mimeType};base64,${ze.content}`,name:ze.name}):Ce(ze.content)}catch{Ce(null),ue.type==="file"&&Ut(!0)}Lt(!1)}};y.useEffect(()=>{Ce(null),lt(null),Ut(!1),H&&$n(H)},[H?.id]);const ae=y.useCallback(ue=>{re(ze=>{const Ve=new Set(ze);return Ve.has(ue)?Ve.delete(ue):Ve.add(ue),Ve})},[]),Ie=y.useCallback(()=>{te.size===kn.length?re(new Set):re(new Set(kn.map(([ue])=>ue)))},[te.size,kn]),qe=()=>{dt(""),et(""),le(""),Ft(""),Ee("file"),g.length>0&&We(g[0].id),D(!0)},Qe=ue=>{Z(ue),e&&(l(!0),history.pushState({mobileDetail:ge.DELIVERABLES},"",window.location.hash))};return t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${e?"flex-1 min-w-0":"shrink-0"} border-r border-border-default flex flex-col bg-surface-primary`,style:e?s?{display:"none"}:void 0:{width:n.width},children:[t.jsxs("div",{className:"p-4 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary",children:["Deliverables",h>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",h,")"]})]}),t.jsx("button",{onClick:qe,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:M,onChange:ue=>N(ue.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"}),yt&&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:yt}),t.jsx("button",{onClick:()=>{se.system.openPath(yt)},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(tl,{label:"All types",value:"",current:_||T||"",onClick:()=>{Y(""),z("")}}),V1.map(ue=>t.jsx(tl,{label:`${$o[ue]?.icon??""} ${ue}`,value:ue,current:_,onClick:ze=>{Y(ze),z("")}},ue)),["agent","team","skill"].map(ue=>t.jsx(tl,{label:`${Ps[ue].icon} ${Ps[ue].label}`,value:ue,current:T,onClick:ze=>{z(ze),Y("")}},ue))]}),g.length>0&&t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(tl,{label:"All projects",value:"",current:q,onClick:X}),g.map(ue=>t.jsx(tl,{label:ue.name,value:ue.id,current:q,onClick:X},ue.id))]}),t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:[t.jsx(tl,{label:"Active",value:"",current:G,onClick:$}),t.jsx(tl,{label:"Verified",value:"verified",current:G,onClick:$}),t.jsx(tl,{label:"Outdated",value:"outdated",current:G,onClick:$})]}),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(ue=>t.jsx("button",{onClick:()=>{V(ue),re(new Set)},className:`px-2 py-1 rounded text-xs transition-colors ${O===ue?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:ue.charAt(0).toUpperCase()+ue.slice(1)},ue)),kn.length>1&&t.jsx("button",{onClick:Ie,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===kn.length?"Expand all":"Collapse all",children:te.size===kn.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:ve,className:"flex-1 overflow-y-auto p-2 space-y-1",onTouchStart:e?Oe.onTouchStart:void 0,onTouchEnd:e?Oe.onTouchEnd:void 0,children:[C?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(ue=>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"})]},ue))}):d.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:qe,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"+ Create first"})]}):kn.map(([ue,ze])=>{const Ve=te.has(ue);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>ae(ue),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 ${Ve?"":"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:ze.label}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:["(",ze.items.length,")"]})]}),!Ve&&ze.items.map(tt=>t.jsxs("button",{onClick:()=>Qe(tt),className:`w-full text-left p-3 rounded-lg transition-colors ${H?.id===tt.id?"bg-brand-600/20 border border-brand-500/30":"hover:bg-surface-elevated/60 border border-transparent"}`,children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:tt.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[tt.artifactType&&Ps[tt.artifactType]?t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Ps[tt.artifactType].color}`,children:[Ps[tt.artifactType].icon," ",Ps[tt.artifactType].label]}):t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium uppercase ${$o[tt.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:tt.type}),t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${F1[tt.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:tt.status}),tt.agentId&&t.jsx("span",{className:"text-[10px] text-fg-tertiary truncate",children:dn.get(tt.agentId)?.name??"Agent"})]})]},tt.id))]},ue)}),x&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(Rh,{})," ",t.jsx("span",{className:"text-[10px]",children:"Loading more..."})]}),!C&&d.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:d.length<h?`${d.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:H?.title??"Details"})]}),H?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:H.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[H.status!=="verified"&&t.jsx("button",{onClick:()=>Mn(H),disabled:!!K,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:K==="verify"?"Verifying...":"Verify"}),H.status!=="outdated"&&t.jsx("button",{onClick:()=>dr(H),disabled:!!K,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:K==="flag"?"Flagging...":"Flag Outdated"}),t.jsx("button",{onClick:()=>sr(H),disabled:!!K,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:K==="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 ${$o[H.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[$o[H.type]?.icon??""," ",H.type]}),t.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${F1[H.status]?.color??"bg-surface-elevated text-fg-tertiary"}`,children:H.status}),H.artifactType&&Ps[H.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Ps[H.artifactType].color}`,children:[Ps[H.artifactType].icon," Builder ",Ps[H.artifactType].label]})]}),H.reference&&(H.type==="file"||H.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(H.reference).catch(()=>$t("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:H.reference}),t.jsx("button",{onClick:()=>{se.files.reveal(H.reference).catch(()=>$t("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:()=>Hn(H.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${St?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:"Copy path to clipboard",children:St?"Copied!":"Copy"})]}),H.reference&&H.type!=="file"&&H.type!=="directory"&&t.jsx("div",{className:"mt-2",children:t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:H.reference})})]}),H.artifactType&&H.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(Hz,{artifact:H.artifactData,mode:H.artifactType})}),H.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:H.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:ur,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"})}),H.summary&&t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:t.jsx(Fn,{content:H.summary,className:"text-fg-secondary text-sm"})})]}):t.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:ut?t.jsxs("div",{className:"flex items-center gap-2 text-fg-tertiary text-sm",children:[t.jsx(Rh,{})," Loading preview..."]}):Fe?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Fe.src,alt:Fe.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Fe.name})]}):xe?t.jsx(Fn,{content:xe,className:"text-fg-secondary text-sm"}):bn?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-fg-secondary",children:["This ",H.type," cannot be previewed in the browser."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{se.files.reveal(H.reference).catch(()=>$t("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:H.reference}),t.jsx("button",{onClick:()=>{se.files.reveal(H.reference).catch(()=>$t("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:()=>Hn(H.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${St?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:St?"Copied!":"Copy"})]})]}):H.summary?t.jsx(Fn,{content:H.summary,className:"text-fg-secondary text-sm"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:"No content"})}),(H.diffStats||H.testResults)&&t.jsxs("div",{className:"flex gap-4 flex-wrap",children:[H.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:[H.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-600",children:["+",H.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",H.diffStats.deletions]})]})]}),H.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:[H.testResults.passed," passed"]}),t.jsxs("span",{className:"text-red-500",children:[H.testResults.failed," failed"]}),t.jsxs("span",{className:"text-fg-secondary",children:[H.testResults.skipped," skipped"]})]})]})]}),H.tags.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:H.tags.map(ue=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:ue},ue))}),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:[H.taskId&&t.jsxs("button",{onClick:()=>bt.navigate(ge.WORK,{openTask:H.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2.5 py-1 rounded",children:["Task: ",H.taskId.slice(0,12),"..."]}),H.agentId&&t.jsxs("button",{onClick:()=>bt.navigate(ge.TEAM,{selectAgent:H.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Agent: ",dn.get(H.agentId)?.name??H.agentId.slice(0,12)]}),H.projectId&&t.jsxs("button",{onClick:()=>bt.navigate(ge.WORK,{projectId:H.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2.5 py-1 rounded",children:["Project: ",ye.get(H.projectId)?.name??H.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(H.createdAt).toLocaleString()})]}),t.jsxs("span",{children:["Updated: ",t.jsx("span",{className:"text-fg-secondary",children:new Date(H.updatedAt).toLocaleString()})]}),t.jsxs("span",{children:["Accessed: ",t.jsxs("span",{className:"text-fg-secondary",children:[H.accessCount,"x"]})]})]}),t.jsxs("div",{className:"text-fg-muted select-all",children:["ID: ",H.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"})]})})]}),S&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!W&&D(!1),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[36rem] space-y-4",onClick:ue=>ue.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:ke,onChange:ue=>Ee(ue.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary",children:V1.map(ue=>t.jsxs("option",{value:ue,children:[$o[ue]?.icon??""," ",ue]},ue))})]}),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:Me,onChange:ue=>dt(ue.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:Pt,onChange:ue=>le(ue.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:pt,onChange:ue=>et(ue.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:kt,onChange:ue=>Ft(ue.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:Se,onChange:ue=>We(ue.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(ue=>t.jsx("option",{value:ue.id,children:ue.name},ue.id))]})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 pt-1 border-t border-border-default",children:[t.jsx("button",{onClick:()=>D(!1),disabled:W,className:"text-sm text-fg-tertiary hover:text-fg-secondary disabled:opacity-50 transition-colors py-2",children:"Cancel"}),t.jsxs("button",{onClick:_n,disabled:W||!Me.trim()||!pt.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:[W&&t.jsx(Rh,{}),W?"Creating...":"Create"]})]})]})})]})}function tl({label:e,value:n,current:s,onClick:l}){return t.jsx("button",{onClick:()=>l(s===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${s===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function Rh(){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 pa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function ki(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Pz(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 p5({authUser:e}){const[n,s]=y.useState("weekly"),[l,i]=y.useState(null),[c,d]=y.useState(!0),[u,h]=y.useState(""),[f,x]=y.useState(null),[p,g]=y.useState([]),[b,w]=y.useState("totalTokens"),[k,C]=y.useState(!0),[E,M]=y.useState("generate"),[N,A]=y.useState([]),[R,_]=y.useState(null),[Y,q]=y.useState([]),[X,L]=y.useState(""),[P,G]=y.useState(""),$=S=>{G(S),setTimeout(()=>G(""),3e3)},T=y.useCallback(async S=>{d(!0),h("");try{const{report:D}=await se.reports.generate({period:S,scope:"org",orgId:"default"});i(D)}catch(D){h(String(D)),i(null)}d(!1)},[]),z=y.useCallback(()=>{se.usage.summary().then(S=>x(S.usage)).catch(()=>{}),se.usage.agents().then(S=>g(S.agents)).catch(()=>{})},[]),O=y.useCallback(async()=>{try{const{reports:S}=await se.reports.list();A(S)}catch{}},[]),V=y.useCallback(async S=>{_(S);try{const{feedback:D}=await se.reports.getFeedback(S.id);q(D)}catch{q([])}},[]);y.useEffect(()=>{T(n)},[n,T]),y.useEffect(()=>{z();const S=setInterval(z,3e4);return()=>clearInterval(S)},[z]),y.useEffect(()=>{E==="history"&&O()},[E,O]);const H=y.useMemo(()=>[...p].sort((S,D)=>{const W=S[b],J=D[b];return k?J-W:W-J}),[p,b,k]),Z=p.reduce((S,D)=>S+D.estimatedCost,0),B=p.reduce((S,D)=>S+D.tokensUsedToday,0),F=Math.max(1,...p.map(S=>S.totalTokens)),K=S=>{b===S?C(!k):(w(S),C(!0))},I={daily:"Today",weekly:"This Week",monthly:"This Month"};return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl p-6 space-y-6",children:[t.jsxs("div",{className:"flex 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:()=>M("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:()=>M("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",N.length>0?` (${N.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[P&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:P}),E==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(S=>t.jsx("button",{onClick:()=>s(S),className:`px-3 py-1.5 text-xs rounded-md transition-colors capitalize ${n===S?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:S},S))})]})]}),E==="history"&&!R&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:N.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:N.map(S=>t.jsxs("button",{onClick:()=>V(S),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:[S.type," Report"]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(S.periodStart).toLocaleDateString()," — ",new Date(S.periodEnd).toLocaleDateString()]})]}),S.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${S.plan.status==="approved"?"bg-green-500/10 text-green-600":S.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:S.plan.status==="pending"?"Plan pending":`Plan ${S.plan.status}`}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(S.generatedAt).toLocaleDateString()})]},S.id))})}),E==="history"&&R&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{_(null),q([])},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(Us,{label:"Completed",value:R.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Us,{label:"In Progress",value:R.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Us,{label:"Created",value:R.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Us,{label:"Blocked",value:R.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Us,{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:ki(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((S,D)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:S.agentId}),t.jsxs("span",{className:"text-fg-tertiary tabular-nums",children:[pa(S.tokens)," tokens · ",ki(S.cost)]})]},D))})]}),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(ji,{title:`Completed (${R.taskSummary.completed.length})`,color:"emerald",items:R.taskSummary.completed.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),R.taskSummary.inProgress.length>0&&t.jsx(ji,{title:`In Progress (${R.taskSummary.inProgress.length})`,color:"indigo",items:R.taskSummary.inProgress.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),R.taskSummary.blocked.length>0&&t.jsx(ji,{title:`Blocked (${R.taskSummary.blocked.length})`,color:"amber",items:R.taskSummary.blocked.map(S=>({id:S.id,label:S.title,sub:S.reason||S.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((S,D)=>t.jsx("li",{children:S},D))})]}),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((S,D)=>t.jsx("li",{children:S},D))})]}),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:S}=await se.reports.approvePlan(R.id,{approvedBy:e?.id??"unknown"});_(S),$("Plan approved"),O()}catch(S){$(`Error: ${S}`)}},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 S=prompt("Rejection reason:");if(S)try{const{report:D}=await se.reports.rejectPlan(R.id,{rejectedBy:e?.id??"unknown",reason:S});_(D),$("Plan rejected"),O()}catch(D){$(`Error: ${D}`)}},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((S,D)=>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 ${S.priority==="high"?"bg-red-500/10 text-red-500":S.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:S.priority}),t.jsx("span",{children:S.title}),S.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:S.assignee})]},D))})]}),!R.metrics&&!R.taskSummary&&!R.costSummary&&t.jsx("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:"This report does not contain detailed metrics data."})}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:["Feedback (",Y.length,")"]}),Y.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:Y.map(S=>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:S.authorName}),t.jsx("span",{children:S.type}),t.jsx("span",{children:new Date(S.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:S.content})]},S.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:X,onChange:S=>L(S.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:S=>{S.key==="Enter"&&X.trim()&&se.reports.addFeedback(R.id,{author:e?.id??"unknown",type:"comment",content:X.trim()}).then(({feedback:D})=>{q(W=>[...W,D]),L(""),$("Feedback added")}).catch(D=>$(`Error: ${D}`))}}),t.jsx("button",{onClick:()=>{X.trim()&&se.reports.addFeedback(R.id,{author:e?.id??"unknown",type:"comment",content:X.trim()}).then(({feedback:S})=>{q(D=>[...D,S]),L(""),$("Feedback added")}).catch(S=>$(`Error: ${S}`))},disabled:!X.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(Pd,{label:"LLM Tokens (this month)",value:pa(f.llmTokens),color:"text-brand-500"}),t.jsx(Pd,{label:"Tool Calls (today)",value:pa(f.toolCalls),color:"text-blue-600"}),t.jsx(Pd,{label:"Messages (today)",value:pa(f.messages),color:"text-green-600"}),t.jsx(Pd,{label:"Storage",value:Pz(f.storageBytes),color:"text-amber-600"})]}),E==="generate"&&(c?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:"Loading…"}):u?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:u}):l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I[n]," · ",new Date(l.periodStart).toLocaleDateString()," — ",new Date(l.periodEnd).toLocaleDateString()]}),l.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Us,{label:"Completed",value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Us,{label:"In Progress",value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Us,{label:"Created",value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Us,{label:"Blocked",value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Us,{label:"Failed",value:l.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Cost Overview"}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:ki(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:pa(B)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Tokens Today"})]}),l.costSummary&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:l.costSummary.totalTokens.toLocaleString()}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Tokens (",I[n],")"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:ki(l.costSummary.totalEstimatedCost)}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Cost (",I[n],")"]})]})]})]})]}),l.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4",children:[l.taskSummary.completed.length>0&&t.jsx(ji,{title:`Completed (${l.taskSummary.completed.length})`,color:"emerald",items:l.taskSummary.completed.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),l.taskSummary.inProgress.length>0&&t.jsx(ji,{title:`In Progress (${l.taskSummary.inProgress.length})`,color:"indigo",items:l.taskSummary.inProgress.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),l.taskSummary.blocked.length>0&&t.jsx(ji,{title:`Blocked (${l.taskSummary.blocked.length})`,color:"amber",items:l.taskSummary.blocked.map(S=>({id:S.id,label:S.title,sub:S.reason||S.agent}))}),l.taskSummary.completed.length===0&&l.taskSummary.inProgress.length===0&&l.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]})]}):null),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"})}),p.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(Bo,{label:"Total Tokens",col:"totalTokens",current:b,desc:k,onSort:K}),t.jsx(Bo,{label:"Today",col:"tokensUsedToday",current:b,desc:k,onSort:K}),t.jsx(Bo,{label:"Requests",col:"requestCount",current:b,desc:k,onSort:K}),t.jsx(Bo,{label:"Tool Calls",col:"toolCalls",current:b,desc:k,onSort:K}),t.jsx(Bo,{label:"Est. Cost",col:"estimatedCost",current:b,desc:k,onSort:K,align:"right"})]})}),t.jsx("tbody",{children:H.map(S=>t.jsx(Uz,{agent:S,maxTokens:F},S.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 (",p.length," agents)"]}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:pa(p.reduce((S,D)=>S+D.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:pa(B)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:p.reduce((S,D)=>S+D.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:p.reduce((S,D)=>S+D.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:ki(Z)})]})})]})})]})]})})}function Us({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 ji({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((l,i)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${l.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:l.id?()=>bt.navigate(ge.WORK,{openTask:l.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 ${l.id?"group-hover:text-brand-500 transition-colors":""}`,children:l.label})]}),l.sub&&l.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:l.sub})]},l.id??i))})]})}function Pd({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 Bo({label:e,col:n,current:s,desc:l,onSort:i,align:c}){const d=s===n?l?"↓":"↑":"↕",u=s===n?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${c==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>i(n),children:[e,t.jsx("span",{className:`ml-1 ${u}`,children:d})]})}function Uz({agent:e,maxTokens:n}){const s=n>0?Math.min(100,e.totalTokens/n*100):0,l=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="paused"?"bg-amber-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>bt.navigate(ge.TEAM,{selectAgent:e.agentId}),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${l}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${s}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:pa(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:pa(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:ki(e.estimatedCost)})]})}function Ho({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 qz={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"};function Fz({authUser:e,onClose:n,onSaved:s}){const[l,i]=y.useState(e.name||""),[c,d]=y.useState(e.email||""),[u,h]=y.useState(!1),[f,x]=y.useState(""),[p,g]=y.useState(e.avatarUrl),b=async w=>{if(w.preventDefault(),!l.trim()){x("Name is required");return}if(c&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c.trim())){x("Invalid email");return}h(!0),x("");try{const{user:k}=await se.auth.updateProfile(l.trim(),c.trim());s({...k,avatarUrl:p??k.avatarUrl})}catch{x("Failed to save")}finally{h(!1)}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("form",{onSubmit:b,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:"Edit Profile"}),t.jsx("div",{className:"flex justify-center mb-5",children:t.jsx(Gx,{currentUrl:p,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:w=>g(w)})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:"Name"}),t.jsx("input",{value:l,onChange:w=>i(w.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"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:"Email"}),t.jsx("input",{value:c,onChange:w=>d(w.target.value),type:"email",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"})]}),f&&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:f})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[t.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:u,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:u?"Saving...":"Save"})]})]})})}function Vz({authUser:e,collapsed:n,onLogout:s,onUserUpdated:l}){const[i,c]=y.useState(!1),[d,u]=y.useState(!1),h=y.useRef(null);if(y.useEffect(()=>{if(!i)return;const p=g=>{h.current&&!h.current.contains(g.target)&&c(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]),!e)return null;const f=e.name||"User",x=e.email||e.role?.[0]?.toUpperCase()+e.role?.slice(1);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:h,className:`relative ${n?"p-2 flex flex-col items-center":"px-4 py-3"}`,children:[t.jsxs("button",{onClick:()=>c(!i),className:`${n?"hover:ring-2 hover:ring-brand-500/50 transition-all rounded-full":"w-full flex items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-surface-overlay transition-colors"}`,title:n?`${f} — ${x}`:void 0,children:[t.jsx(Ys,{name:f,avatarUrl:e.avatarUrl,size:28}),!n&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"text-xs text-fg-secondary truncate",children:f}),t.jsx("div",{className:"text-[11px] text-fg-tertiary truncate",children:x})]}),t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),i&&t.jsxs("div",{className:`absolute ${n?"left-full bottom-0 ml-2":"left-4 right-4 bottom-full mb-1"} bg-surface-secondary border border-border-default rounded-xl shadow-xl z-50 overflow-hidden`,style:n?{minWidth:200}:void 0,children:[t.jsxs("div",{className:"px-4 py-3 border-b border-border-default",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:f}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:x}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 capitalize",children:e.role})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("button",{onClick:()=>{c(!1),u(!0)},className:"w-full flex items-center gap-2.5 px-4 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",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:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Edit Profile"]}),t.jsxs("button",{onClick:()=>{c(!1),s()},className:"w-full flex items-center gap-2.5 px-4 py-2 text-sm text-red-500 hover:bg-red-500/10 transition-colors",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:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),t.jsx("polyline",{points:"16 17 21 12 16 7"}),t.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign out"]})]})]})]}),d&&t.jsx(Fz,{authUser:e,onClose:()=>u(!1),onSaved:p=>{u(!1),l?.(p)}})]})}const G1=5;function Yz({currentPage:e,onNavigate:n,authUser:s,onLogout:l,onUserUpdated:i,collapsed:c,onToggleCollapse:d}){const[u,h]=y.useState([]),[f,x]=y.useState(!1),[p,g]=y.useState(null),[b,w]=y.useState(!1),k=y.useCallback(()=>{se.projects.list().then(N=>h(N.projects)).catch(()=>{})},[]);y.useEffect(()=>{k();const N=setInterval(k,3e4);return()=>clearInterval(N)},[k]),y.useEffect(()=>{if(e!==ge.WORK){g(null);return}const A=window.location.hash.slice(1).split("/");ba(A[0])===ge.WORK&&A[1]&&g(A[1])},[e]);const C=async()=>{try{await se.auth.logout()}catch{}l?.()},E=f?u:u.slice(0,G1),M=u.length>G1;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 ${c?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:c?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(Kh,{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(Kh,{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:`${c?"p-1.5":"p-3"} flex-1 overflow-y-auto`,children:vk.map((N,A)=>t.jsx("div",{children:t.jsxs("div",{className:"mb-3",children:[!c&&t.jsx("div",{className:"px-3 py-1.5 text-[11px] font-semibold text-fg-tertiary uppercase tracking-widest",children:N.label}),c&&A>0&&t.jsx("div",{className:"my-2 mx-1"}),jk.filter(R=>R.section===N.key&&!(N.key==="workspace"&&R.id===ge.DELIVERABLES)).map(R=>{const _=e===R.id;return t.jsxs("button",{onClick:()=>n(R.id),title:c?R.label:void 0,className:`w-full flex items-center ${c?"justify-center px-2 py-2":"gap-3 px-3 py-2"} rounded-lg text-sm mb-0.5 transition-all ${_?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":"text-fg-primary hover:bg-surface-overlay"}`,children:[t.jsx(Ho,{d:wi[R.id]??""}),!c&&R.label]},R.id)}),N.key==="workspace"&&c&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{g(null),n(ge.WORK)},title:"Work",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-all ${e===ge.WORK&&!p?"bg-brand-600 text-white shadow-sm shadow-brand-900/30":e===ge.WORK?"bg-brand-600/15 text-fg-primary":"text-fg-primary hover:bg-surface-overlay"}`,children:t.jsx(Ho,{d:wi[ge.WORK]})}),t.jsx("button",{onClick:()=>n(ge.DELIVERABLES),title:"Deliverables",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===ge.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(Ho,{d:wi[ge.DELIVERABLES]})})]}),N.key==="workspace"&&!c&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center mb-0.5",children:[t.jsxs("button",{onClick:()=>{g(null),n(ge.WORK)},className:`flex-1 flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${e===ge.WORK&&!p?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(Ho,{d:wi[ge.WORK]}),"Work"]}),t.jsx("button",{onClick:()=>w(!0),className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1.5 rounded hover:bg-surface-elevated shrink-0",title:"New Project",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),u.length===0&&t.jsxs("button",{onClick:()=>w(!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"]}),E.map(R=>{const _=e===ge.WORK&&p===R.id;return t.jsxs("button",{onClick:()=>{g(R.id),e!==ge.WORK&&n(ge.WORK),window.location.hash=Dh(ge.WORK,R.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 ${_?"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 ${qz[R.status]??"bg-gray-600"}`}),t.jsx("span",{className:"truncate text-xs",children:R.name})]},R.id)}),M&&!f&&t.jsxs("button",{onClick:()=>x(!0),className:"w-full pl-9 pr-3 py-1 text-[11px] text-fg-tertiary hover:text-fg-secondary transition-colors text-left",children:["Show all ",u.length," projects..."]}),t.jsxs("button",{onClick:()=>n(ge.DELIVERABLES),className:`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===ge.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:[t.jsx(Ho,{d:wi[ge.DELIVERABLES]}),"Deliverables"]})]})]})},N.key))}),t.jsx(Vz,{authUser:s,collapsed:c,onLogout:C,onUserUpdated:i}),!c&&t.jsxs("div",{className:"px-4 pb-2 text-[10px] text-fg-muted",children:["v","0.4.22"]}),b&&t.jsx(u5,{orgId:s?.orgId,onCreated:()=>{w(!1),k()},onClose:()=>w(!1)})]})}function Gz({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:wk.map(s=>{const l=s.group.includes(e);return t.jsxs("button",{onClick:()=>n(s.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${l?"text-brand-500":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:l?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:wi[s.id]})}),t.jsx("span",{className:`text-[10px] leading-tight ${l?"font-semibold":""}`,children:s.label})]},s.id)})})}const X1=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function Xz({authUser:e}){const[n,s]=y.useState("builder"),l=va(X1,n,s);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:l.onTouchStart,onTouchEnd:l.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:X1.map(i=>t.jsx("button",{onClick:()=>s(i.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===i.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:i.label},i.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="builder"&&t.jsx(Nw,{}),n==="agents"&&t.jsx(tx,{authUser:e}),n==="teams"&&t.jsx(nx,{}),n==="skills"&&t.jsx(rx,{})]})]})}const K1=[{id:"settings",label:"Settings"},{id:"reports",label:"Reports"}];function Kz({theme:e,onThemeChange:n}){const[s,l]=y.useState("settings"),i=va(K1,s,l);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:K1.map(c=>t.jsx("button",{onClick:()=>l(c.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===c.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:c.label},c.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="settings"&&t.jsx(bw,{theme:e,onThemeChange:n}),s==="reports"&&t.jsx(p5,{})]})]})}const Ud=1,W1=3;function Wz({onComplete:e,theme:n,onThemeChange:s}){const[l,i]=y.useState(0),[c,d]=y.useState(""),[u,h]=y.useState(""),[f,x]=y.useState(""),[p,g]=y.useState(""),[b,w]=y.useState(!1),[k,C]=y.useState(""),[E,M]=y.useState(!1),[N,A]=y.useState(null),[R,_]=y.useState(!1),[Y,q]=y.useState({}),[X,L]=y.useState(!1),[P,G]=y.useState(null),[$,T]=y.useState(!1),[z,O]=y.useState(!1),[V,H]=y.useState(null),Z=y.useRef(!1),B=()=>({"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("markus_token")??""}`});y.useEffect(()=>{fetch("/api/settings/llm").then(oe=>oe.ok?oe.json():null).then(oe=>{oe?.providers&&Object.values(oe.providers).some(me=>me.configured)&&O(!0)}).catch(()=>{})},[]),y.useEffect(()=>{l===W1&&!Z.current&&!z&&(Z.current=!0,F())},[l,z]);const F=async()=>{_(!0);try{const oe=await fetch("/api/settings/env-models",{headers:B()});if(oe.ok){const me=await oe.json();if(A(me),me.detected.length>0){const Oe={};for(const ve of me.detected)Oe[ve.provider]=!0;q(Oe)}}}catch{}finally{_(!1)}},K=async()=>{if(!N)return;const oe=N.detected.filter(me=>Y[me.provider]);if(oe.length!==0){L(!0),H(null);try{const me=await fetch("/api/settings/env-models",{method:"POST",headers:B(),body:JSON.stringify({providers:oe.map(Oe=>({provider:Oe.provider,model:Oe.model,baseUrl:Oe.baseUrl,enabled:!0}))})});if(me.ok){const Oe=await me.json();H({type:"ok",text:Oe.message}),O(!0)}else H({type:"err",text:"Failed to apply"})}catch{H({type:"err",text:"Network error"})}finally{L(!1)}}},I=async()=>{T(!0);try{const me=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:B(),body:JSON.stringify({preview:!0})})).json();"error"in me||G(me)}catch{}finally{T(!1)}},S=async()=>{T(!0),H(null);try{const me=await(await fetch("/api/settings/import/openclaw",{method:"POST",headers:B(),body:JSON.stringify({preview:!1})})).json();"error"in me?H({type:"err",text:me.error}):(H({type:"ok",text:`Imported ${me.appliedModels} model configs`}),O(!0))}catch{H({type:"err",text:"Import failed"})}finally{T(!1)}},D=async()=>{if(C(""),!c.trim()){C("Please enter your name");return}if(!u.trim()){C("Please enter your email");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u.trim())){C("Please enter a valid email address");return}if(f&&f.length<6){C("Password must be at least 6 characters");return}if(f&&f!==p){C("Passwords do not match");return}w(!0);try{await se.auth.updateProfile(c.trim(),u.trim()),f&&await se.auth.changePassword("",f),M(!0)}catch{C("Failed to save profile. Please try again.")}finally{w(!1)}},W=[{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"}],J=[{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(([oe,me])=>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:oe}),t.jsx("div",{className:"text-fg-secondary text-xs mt-1",children:me})]},oe))})]})},{title:"Set Up Your Profile",subtitle:"Tell us who you are",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:"Profile saved"}),t.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[c," · ",u]})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx(Gx,{currentUrl:null,name:c,size:64,targetType:"user"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:["Your Name ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:c,onChange:oe=>d(oe.target.value),placeholder:"Enter your name",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",autoFocus:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:["Email ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"email",value:u,onChange:oe=>h(oe.target.value),placeholder:"your@email.com",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:f,onChange:oe=>x(oe.target.value),placeholder:"Set a secure password (min 6 characters)",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"})]}),f&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Confirm Password"}),t.jsx("input",{type:"password",value:p,onChange:oe=>g(oe.target.value),placeholder:"Repeat your 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"})]}),k&&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:k}),t.jsx("button",{onClick:()=>{D()},disabled:b||!c.trim()||!u.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:b?"Saving...":"Save Profile"})]})},{title:"Choose Your Theme",subtitle:"You can change this anytime in Settings",content:t.jsx("div",{className:"grid grid-cols-3 gap-3",children:W.map(oe=>t.jsxs("button",{onClick:()=>s(oe.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===oe.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:oe.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:oe.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:oe.desc})]},oe.value))})},{title:"Configure LLM",subtitle:"Agents need an LLM to think and act",content:z?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"}),R&&t.jsx("div",{className:"text-xs text-fg-tertiary animate-pulse",children:"Detecting API keys..."}),N&&N.detected.length>0&&t.jsxs("div",{className:"space-y-2",children:[N.detected.map(oe=>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:Y[oe.provider]??!1,onChange:me=>q({...Y,[oe.provider]:me.target.checked}),className:"w-4 h-4 rounded bg-surface-overlay border-gray-600 text-brand-500 focus:ring-brand-500"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-fg-primary",children:oe.displayName}),t.jsx("span",{className:"text-xs text-fg-tertiary ml-2",children:oe.model})]}),t.jsx("code",{className:"text-[10px] text-fg-tertiary",children:oe.apiKeyPreview})]},oe.provider)),t.jsx("button",{onClick:()=>{K()},disabled:X||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:X?"Applying...":`Apply ${Object.values(Y).filter(Boolean).length} Provider(s)`})]}),N&&N.detected.length===0&&!R&&t.jsxs("div",{className:"text-xs text-fg-tertiary bg-surface-elevated/30 rounded-lg p-3",children:["No API keys found. Set ",t.jsx("code",{className:"text-fg-secondary",children:"ANTHROPIC_API_KEY"}),", ",t.jsx("code",{className:"text-fg-secondary",children:"OPENAI_API_KEY"}),", etc. in your ",t.jsx("code",{className:"text-fg-secondary",children:".env"})," file and restart."]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 h-px bg-border-default"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:"or"}),t.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-secondary uppercase tracking-wider",children:"From OpenClaw"}),P?P.found?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-xs text-green-600",children:["Found: ",t.jsx("code",{className:"text-fg-secondary",children:P.summary.configPath}),P.summary.models&&t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",P.summary.models.providerCount," providers)"]})]}),t.jsx("button",{onClick:()=>{S()},disabled:$,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:$?"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:()=>{I()},disabled:$,className:"px-4 py-2 border border-border-default hover:bg-surface-elevated disabled:opacity-40 text-fg-secondary text-sm rounded-lg transition-colors w-full",children:$?"Detecting...":"Detect OpenClaw Config"})]}),V&&t.jsx("div",{className:`text-xs px-3 py-2 rounded-lg ${V.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:V.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(([oe,me])=>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:oe}),t.jsx("div",{className:"text-fg-secondary text-xs",children:me})]})]},oe))})}],te=()=>{l===Ud&&!E||(l<J.length-1?i(l+1):e())},re=J[l];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:J.map((oe,me)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${me<=l?"bg-brand-500":"bg-surface-elevated"}`},me))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:re.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:re.subtitle}),re.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[l>0?t.jsx("button",{onClick:()=>i(l-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:"Back"}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip"}),t.jsxs("div",{className:"flex items-center gap-3",children:[l===Ud&&!E&&t.jsx("button",{onClick:()=>i(l+1),className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),l===W1&&!z&&t.jsx("button",{onClick:te,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),t.jsx("button",{onClick:te,disabled:l===Ud&&!E,className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${l===Ud&&!E?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:l===J.length-1?"Get Started":"Next"})]})]})]})})})}function Zz({onLogin:e}){const[n,s]=y.useState(""),[l,i]=y.useState(""),[c,d]=y.useState(""),[u,h]=y.useState(!1),f=async x=>{if(x.preventDefault(),!(!n.trim()||!l)){d(""),h(!0);try{const{user:p}=await se.auth.login(n.trim(),l),g=n.trim().toLowerCase()==="admin@markus.local"&&l==="markus123";e(p,g)}catch{d("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:x=>s(x.target.value),autoComplete:"email",placeholder:"your@email.com",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 placeholder:text-fg-tertiary",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:"Password"}),t.jsx("input",{type:"password",value:l,onChange:x=>i(x.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),c&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:c}),t.jsx("button",{type:"submit",disabled:u||!n||!l,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:u?"Signing in…":"Sign in"}),t.jsx("p",{className:"text-center text-xs text-fg-tertiary",children:"Sign in with your email and password"})]})]})]})}function Qz({onComplete:e,isFirstTime:n}){const[s,l]=y.useState(""),[i,c]=y.useState(""),[d,u]=y.useState(""),[h,f]=y.useState(""),[x,p]=y.useState(!1),g=async b=>{if(b.preventDefault(),f(""),i.length<6){f("Password must be at least 6 characters");return}if(i!==d){f("Passwords do not match");return}p(!0);try{await se.auth.changePassword(s,i),e()}catch{f("Failed to change password. Check your current password.")}finally{p(!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:b=>l(b.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:i,onChange:b=>c(b.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:d,onChange:b=>u(b.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:x||!i||!d,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:x?"Saving…":n?"Set Password & Continue":"Change Password"})]})]})]})}const Oh={};function Jz(){const[e,n]=y.useState(kd),[s,l]=y.useState(()=>!localStorage.getItem("markus_onboarded")),[i,c]=y.useState(!0),d=Yr(),u=x_(),h=Tu({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[f,x]=y.useState(()=>new Set([kd()])),[p,g]=y.useState("loading"),[b,w]=y.useState(!1),[k,C]=y.useState(null),[E,M]=y.useState(!1),[N,A]=y.useState(null),[R,_]=y.useState(()=>{const P=localStorage.getItem("markus_update_dismissed");return P||null}),Y=y.useCallback(P=>{let G=ba(P);d&&(G=yk[G]??G);const $=kd(),T=window.location.hash.slice(1);T!==$?Oh[$]=T:delete Oh[$];const z=G!==ge.WORK?Oh[G]:void 0;z&&z!==G?(history.pushState(null,"","#"+G),history.pushState(null,"","#"+z)):history.pushState(null,"","#"+G),window.dispatchEvent(new HashChangeEvent("hashchange")),n(G),x(O=>O.has(G)?O:new Set([...O,G]))},[d]);y.useEffect(()=>{bt.setHandler(P=>Y(P))},[Y]);const q=y.useCallback(()=>{fetch("/api/settings/llm").then(P=>P.ok?P.json():null).then(P=>{if(P?.providers){const G=Object.values(P.providers).some($=>$.configured);C(G)}}).catch(()=>{})},[]);y.useEffect(()=>{se.auth.me().then(({user:$})=>{g($),q(),se.health().then(T=>{T.updateAvailable&&T.latestVersion&&A({latestVersion:T.latestVersion,currentVersion:T.version})}).catch(()=>{}),Sl(qr.builderArtifacts,()=>se.builder.artifacts.list()),Sl(qr.builderAgents,()=>se.agents.list()),Sl(qr.builderHubMyItems,()=>Bn.myItems()),Sl(qr.builderInstalled,()=>se.builder.artifacts.installed()),Sl(qr.hubAgents,()=>Bn.search({type:"agent",limit:50})),Sl(qr.hubTeams,()=>Bn.search({type:"team",limit:50})),Sl(qr.hubSkills,()=>Bn.search({type:"skill",limit:50}))}).catch(()=>g(null)),Zt.connect();const P=Zt.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),G=()=>{const $=kd();n($),x(T=>T.has($)?T:new Set([...T,$]))};return window.addEventListener("hashchange",G),()=>{P(),Zt.disconnect(),window.removeEventListener("hashchange",G)}},[]);const X=p!=="loading"&&p!==null?p:void 0,L=y.useMemo(()=>d?{[ge.HOME]:t.jsx(Yy,{authUser:X}),[ge.TEAM]:t.jsx(pv,{authUser:X}),[ge.BUILDER]:t.jsx(Xz,{authUser:X}),[ge.SETTINGS]:t.jsx(Kz,{theme:u.mode,onThemeChange:u.setMode}),[ge.WORK]:t.jsx(q1,{authUser:X}),[ge.DELIVERABLES]:t.jsx(Y1,{})}:{[ge.HOME]:t.jsx(Yy,{}),[ge.TEAM]:t.jsx(pv,{authUser:X}),[ge.SETTINGS]:t.jsx(bw,{theme:u.mode,onThemeChange:u.setMode}),[ge.STORE]:t.jsx(E_,{authUser:X}),[ge.BUILDER]:t.jsx(Nw,{}),[ge.WORK]:t.jsx(q1,{authUser:X}),[ge.DELIVERABLES]:t.jsx(Y1,{}),[ge.REPORTS]:t.jsx(p5,{authUser:X})},[X?.id,u.mode,d]);return p==="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…"})}):p===null?t.jsx(Zz,{onLogin:(P,G)=>{g(P),G&&w(!0)}}):b?t.jsx(Qz,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(Wz,{theme:u.mode,onThemeChange:u.setMode,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),l(!1),q()}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:h.width},children:t.jsx(Yz,{currentPage:e,onNavigate:P=>{Y(P),c(!1)},authUser:p,onLogout:()=>g(null),onUserUpdated:P=>g(P),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 ${d?"pb-14":""}`,children:[k===!1&&!E&&e!==ge.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:d?"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:()=>{Y(ge.SETTINGS)},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:"Go to Settings"}),t.jsx("button",{onClick:()=>M(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:"Dismiss"})]})]}),N&&R!==N.latestVersion&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[t.jsxs("span",{className:d?"text-xs":"",children:["New version available: ",t.jsxs("strong",{children:["v",N.latestVersion]})," (current: v",N.currentVersion,")",!d&&t.jsxs("span",{className:"text-fg-tertiary ml-2",children:["— run ",t.jsx("code",{className:"bg-surface-overlay px-1.5 py-0.5 rounded text-xs font-mono",children:"npm i -g @markus-global/cli"})," to upgrade"]})]}),t.jsx("button",{onClick:()=>{_(N.latestVersion),localStorage.setItem("markus_update_dismissed",N.latestVersion)},className:"text-brand-400 hover:text-brand-300 text-xs shrink-0",children:"Dismiss"})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col",children:Object.keys(L).map(P=>f.has(P)?t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:{display:P===e?"flex":"none"},children:L[P]},P):null)})]}),d&&t.jsx(Gz,{currentPage:e,onNavigate:Y})]})}pk.createRoot(document.getElementById("root")).render(t.jsx(y.StrictMode,{children:t.jsx(Jz,{})}));
|