@markus-global/cli 0.4.19 → 0.4.21
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.d.ts.map +1 -1
- package/dist/commands/start.js +163 -30
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +3685 -1398
- package/dist/paths.js +4 -4
- package/dist/paths.js.map +1 -1
- package/dist/web-ui/assets/index-BWjiUsem.js +66 -0
- package/dist/web-ui/assets/index-BgcwiZ1h.css +1 -0
- package/dist/web-ui/index.html +2 -2
- package/package.json +1 -1
- package/templates/roles/SHARED.md +7 -6
- package/templates/roles/developer/HEARTBEAT.md +4 -4
- package/templates/roles/operations/HEARTBEAT.md +4 -4
- package/templates/roles/org-manager/HEARTBEAT.md +5 -5
- package/templates/roles/product-manager/HEARTBEAT.md +4 -4
- package/templates/roles/reviewer/HEARTBEAT.md +4 -4
- package/templates/roles/secretary/HEARTBEAT.md +4 -4
- package/templates/skills/chrome-devtools/SKILL.md +33 -14
- package/templates/skills/markitdown/SKILL.md +56 -0
- package/templates/skills/markitdown/skill.json +20 -0
- package/templates/skills/self-evolution/SKILL.md +128 -150
- package/templates/skills/self-evolution/skill.json +1 -1
- package/dist/web-ui/assets/index-3aaspe8C.css +0 -1
- package/dist/web-ui/assets/index-DVrJcKF4.js +0 -64
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function s(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(l){if(l.ep)return;l.ep=!0;const c=s(l);fetch(l.href,c)}})();function vu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Bm={exports:{}},Eo={};var zb;function ik(){if(zb)return Eo;zb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(i,l,c){var d=null;if(c!==void 0&&(d=""+c),l.key!==void 0&&(d=""+l.key),"key"in l){c={};for(var u in l)u!=="key"&&(c[u]=l[u])}else c=l;return l=c.ref,{$$typeof:e,type:i,key:d,ref:l!==void 0?l:null,props:c}}return Eo.Fragment=n,Eo.jsx=s,Eo.jsxs=s,Eo}var $b;function lk(){return $b||($b=1,Bm.exports=ik()),Bm.exports}var t=lk(),Hm={exports:{}},Dt={};var Bb;function ok(){if(Bb)return Dt;Bb=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=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=l,Dt.PureComponent=N,Dt.StrictMode=i,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 Hb;function fc(){return Hb||(Hb=1,Hm.exports=ok()),Hm.exports}var y=fc();const ck=vu(y);var Pm={exports:{}},To={},Um={exports:{}},qm={};var Pb;function dk(){return Pb||(Pb=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<l(B,V))O[Z]=V,O[H]=B,H=Z;else break e}}function s(O){return O.length===0?null:O[0]}function i(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>l(I,H))S<B&&0>l(D,I)?(O[Z]=D,O[S]=H,Z=S):(O[Z]=I,O[K]=H,Z=K);else if(S<B&&0>l(D,H))O[Z]=D,O[S]=H,Z=S;else break e}}return V}function l(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)i(f);else if(V.startTime<=O)i(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)&&i(h),A(O)}else i(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}}}})(qm)),qm}var Ub;function uk(){return Ub||(Ub=1,Um.exports=dk()),Um.exports}var Fm={exports:{}},Cr={};var qb;function fk(){if(qb)return Cr;qb=1;var e=fc();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 i={d:{f:s,r:function(){throw Error(n(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(h,f,x){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,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=i,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=i.p;try{if(d.T=null,i.p=2,h)return h()}finally{d.T=f,i.p=x,i.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,i.d.C(h,f))},Cr.prefetchDNS=function(h){typeof h=="string"&&i.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"?i.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:p,integrity:g,fetchPriority:b}):x==="script"&&i.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);i.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&&i.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);i.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);i.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 i.d.m(h)},Cr.requestFormReset=function(h){i.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 Fb;function W1(){if(Fb)return Fm.exports;Fb=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(),Fm.exports=fk(),Fm.exports}var Vb;function mk(){if(Vb)return To;Vb=1;var e=uk(),n=fc(),s=W1();function i(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 l(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(i(188))}function f(r){var a=r.alternate;if(!a){if(a=c(r),a===null)throw Error(i(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(i(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(i(189))}}if(o.alternate!==m)throw Error(i(190))}if(o.tag!==3)throw Error(i(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=lb(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=lb(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 Ce=!1;function Me(r,a){if(!r||Ce)return"";Ce=!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 le=U.split(`
|
|
4
|
+
`),be=Q.split(`
|
|
5
|
+
`);for(v=m=0;m<le.length&&!le[m].includes("DetermineComponentFrameRoot");)m++;for(;v<be.length&&!be[v].includes("DetermineComponentFrameRoot");)v++;if(m===le.length||v===be.length)for(m=le.length-1,v=be.length-1;1<=m&&0<=v&&le[m]!==be[v];)v--;for(;1<=m&&0<=v;m--,v--)if(le[m]!==be[v]){if(m!==1||v!==1)do if(m--,v--,0>v||le[m]!==be[v]){var Ae=`
|
|
6
|
+
`+le[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{Ce=!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,ie=e.unstable_cancelCallback,Ee=e.unstable_shouldYield,We=e.unstable_requestPaint,kt=e.unstable_now,Ft=e.unstable_getCurrentPriorityLevel,xe=e.unstable_ImmediatePriority,Se=e.unstable_UserBlockingPriority,Fe=e.unstable_NormalPriority,it=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 Bn=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 lt(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,le=r.expirationTimes,be=r.hiddenUpdates;for(o=U&~o;0<o;){var Ae=31-yt(o),De=1<<Ae;Q[Ae]=0,le[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:_b(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 Kn(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=hb(r);r!==null;){if(o=r[ze])return o;r=hb(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(i(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 ir(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 Fn(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 Hn(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=""+Fn(a)):r.value!==""+Fn(a)&&(r.value=""+Fn(a)):U!=="submit"&&U!=="reset"||r.removeAttribute("value"),a!=null?ys(r,U,Fn(a)):o!=null?ys(r,U,Fn(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=""+Fn(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?""+Fn(o):"",a=a!=null?""+Fn(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=""+Fn(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=""+Fn(a),a!==r.value&&(r.value=a),o==null)){r.defaultValue!==a&&(r.defaultValue=a);return}r.defaultValue=o!=null?""+Fn(o):""}function Hi(r,a,o,m){if(a==null){if(m!=null){if(o!=null)throw Error(i(92));if(z(m)){if(1<m.length)throw Error(i(93));m=m[0]}o=m}o==null&&(o=""),a=o}o=Fn(a),r.defaultValue=o,m=r.textContent,m===o&&m!==""&&m!==null&&(r.value=m),Te(r)}function lr(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 li(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 is(r,a,o){if(a!=null&&typeof a!="object")throw Error(i(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&&li(r,v,m)}else for(var j in a)a.hasOwnProperty(j)&&li(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="'+Hn(""+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(i(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)&&(rd(),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(i(231,a,typeof o));return o}var Vn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vs=!1;if(Vn)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:qu,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}}),oi=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"},Uu={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 p5(r){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(r):(r=ws[r])?!!a[r]:!1}function qu(){return p5}var g5=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"?Uu[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:qu,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}}),b5=Rt(g5),y5=p({},Ir,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),up=Rt(y5),v5=p({},vt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:qu}),j5=Rt(v5),w5=p({},Ye,{propertyName:0,elapsedTime:0,pseudoElement:0}),N5=Rt(w5),k5=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}),S5=Rt(k5),C5=p({},Ye,{newState:0,oldState:0}),E5=Rt(C5),T5=[9,13,27,32],Fu=Vn&&"CompositionEvent"in window,ql=null;Vn&&"documentMode"in document&&(ql=document.documentMode);var A5=Vn&&"TextEvent"in window&&!ql,fp=Vn&&(!Fu||ql&&8<ql&&11>=ql),mp=" ",hp=!1;function xp(r,a){switch(r){case"keyup":return T5.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pp(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Pi=!1;function _5(r,a){switch(r){case"compositionend":return pp(a);case"keypress":return a.which!==32?null:(hp=!0,mp);case"textInput":return r=a.data,r===mp&&hp?null:r;default:return null}}function M5(r,a){if(Pi)return r==="compositionend"||!Fu&&xp(r,a)?(r=Ke(),Re=Ne=ee=null,Pi=!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 fp&&a.locale!=="ko"?null:a.data;default:return null}}var R5={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 gp(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a==="input"?!!R5[r.type]:a==="textarea"}function bp(r,a,o,m){un?Mt?Mt.push(m):Mt=[m]:un=m,a=dd(a,"onChange"),0<a.length&&(o=new ht("onChange","change",null,o,m),r.push({event:o,listeners:a}))}var Fl=null,Vl=null;function O5(r){eb(r,0)}function wc(r){var a=Tt(r);if(Ue(a))return r}function yp(r,a){if(r==="change")return a}var vp=!1;if(Vn){var Vu;if(Vn){var Yu="oninput"in document;if(!Yu){var jp=document.createElement("div");jp.setAttribute("oninput","return;"),Yu=typeof jp.oninput=="function"}Vu=Yu}else Vu=!1;vp=Vu&&(!document.documentMode||9<document.documentMode)}function wp(){Fl&&(Fl.detachEvent("onpropertychange",Np),Vl=Fl=null)}function Np(r){if(r.propertyName==="value"&&wc(Vl)){var a=[];bp(a,Vl,r,en(r)),yr(O5,a)}}function D5(r,a,o){r==="focusin"?(wp(),Fl=a,Vl=o,Fl.attachEvent("onpropertychange",Np)):r==="focusout"&&wp()}function L5(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return wc(Vl)}function I5(r,a){if(r==="click")return wc(a)}function z5(r,a){if(r==="input"||r==="change")return wc(a)}function $5(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var Gr=typeof Object.is=="function"?Object.is:$5;function Yl(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 kp(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Sp(r,a){var o=kp(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=kp(o)}}function Cp(r,a){return r&&a?r===a?!0:r&&r.nodeType===3?!1:a&&a.nodeType===3?Cp(r,a.parentNode):"contains"in r?r.contains(a):r.compareDocumentPosition?!!(r.compareDocumentPosition(a)&16):!1:!1}function Ep(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var a=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 Gu(r){var a=r&&r.nodeName&&r.nodeName.toLowerCase();return a&&(a==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||a==="textarea"||r.contentEditable==="true")}var B5=Vn&&"documentMode"in document&&11>=document.documentMode,Ui=null,Xu=null,Gl=null,Ku=!1;function Tp(r,a,o){var m=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Ku||Ui==null||Ui!==qt(m)||(m=Ui,"selectionStart"in m&&Gu(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}),Gl&&Yl(Gl,m)||(Gl=m,m=dd(Xu,"onSelect"),0<m.length&&(a=new ht("onSelect","select",null,a,o),r.push({event:a,listeners:m}),a.target=Ui)))}function ci(r,a){var o={};return o[r.toLowerCase()]=a.toLowerCase(),o["Webkit"+r]="webkit"+a,o["Moz"+r]="moz"+a,o}var qi={animationend:ci("Animation","AnimationEnd"),animationiteration:ci("Animation","AnimationIteration"),animationstart:ci("Animation","AnimationStart"),transitionrun:ci("Transition","TransitionRun"),transitionstart:ci("Transition","TransitionStart"),transitioncancel:ci("Transition","TransitionCancel"),transitionend:ci("Transition","TransitionEnd")},Wu={},Ap={};Vn&&(Ap=document.createElement("div").style,"AnimationEvent"in window||(delete qi.animationend.animation,delete qi.animationiteration.animation,delete qi.animationstart.animation),"TransitionEvent"in window||delete qi.transitionend.transition);function di(r){if(Wu[r])return Wu[r];if(!qi[r])return r;var a=qi[r],o;for(o in a)if(a.hasOwnProperty(o)&&o in Ap)return Wu[r]=a[o];return r}var _p=di("animationend"),Mp=di("animationiteration"),Rp=di("animationstart"),H5=di("transitionrun"),P5=di("transitionstart"),U5=di("transitioncancel"),Op=di("transitionend"),Dp=new Map,Zu="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(" ");Zu.push("scrollEnd");function Ns(r,a){Dp.set(r,a),ir(a,[r])}var Nc=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)},ls=[],Fi=0,Qu=0;function kc(){for(var r=Fi,a=Qu=Fi=0;a<r;){var o=ls[a];ls[a++]=null;var m=ls[a];ls[a++]=null;var v=ls[a];ls[a++]=null;var j=ls[a];if(ls[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&&Lp(o,v,j)}}function Sc(r,a,o,m){ls[Fi++]=r,ls[Fi++]=a,ls[Fi++]=o,ls[Fi++]=m,Qu|=m,r.lanes|=m,r=r.alternate,r!==null&&(r.lanes|=m)}function Ju(r,a,o,m){return Sc(r,a,o,m),Cc(r)}function ui(r,a){return Sc(r,null,null,a),Cc(r)}function Lp(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 Cc(r){if(50<po)throw po=0,cm=null,Error(i(185));for(var a=r.return;a!==null;)r=a,a=r.return;return r.tag===3?r.stateNode:null}var Vi={};function q5(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 q5(r,a,o,m)}function ef(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 Ip(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 Ec(r,a,o,m,v,j){var U=0;if(m=r,typeof r=="function")ef(r)&&(U=1);else if(typeof r=="string")U=X2(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 fi(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(i(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 fi(r,a,o,m){return r=Xr(7,r,m,a),r.lanes=o,r}function tf(r,a,o){return r=Xr(6,r,null,a),r.lanes=o,r}function zp(r){var a=Xr(18,null,null,0);return a.stateNode=r,a}function nf(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 $p=new WeakMap;function os(r,a){if(typeof r=="object"&&r!==null){var o=$p.get(r);return o!==void 0?o:(a={value:r,source:a,stack:pt(a)},$p.set(r,a),a)}return{value:r,source:a,stack:pt(a)}}var Yi=[],Gi=0,Tc=null,Xl=0,cs=[],ds=0,Ea=null,Is=1,zs="";function Js(r,a){Yi[Gi++]=Xl,Yi[Gi++]=Tc,Tc=r,Xl=a}function Bp(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 rf(r){r.return!==null&&(Js(r,1),Bp(r,1,0))}function sf(r){for(;r===Tc;)Tc=Yi[--Gi],Yi[Gi]=null,Xl=Yi[--Gi],Yi[Gi]=null;for(;r===Ea;)Ea=cs[--ds],cs[ds]=null,zs=cs[--ds],cs[ds]=null,Is=cs[--ds],cs[ds]=null}function Hp(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,af=Error(i(519));function Aa(r){var a=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Kl(os(a,r)),af}function Pp(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),Hi(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||sb(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 Up(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 Xi(r){if(r!==wr)return!1;if(!Qt)return Up(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")||km(r.type,r.memoizedProps)),o=!o),o&&Rn&&Aa(r),Up(r),a===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));Rn=mb(r)}else if(a===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));Rn=mb(r)}else a===27?(a=Rn,qa(r.type)?(r=Am,Am=null,Rn=r):Rn=a):Rn=wr?ms(r.stateNode.nextSibling):null;return!0}function mi(){Rn=wr=null,Qt=!1}function lf(){var r=Ta;return r!==null&&(Hr===null?Hr=r:Hr.push.apply(Hr,r),Ta=null),r}function Kl(r){Ta===null?Ta=[r]:Ta.push(r)}var of=F(null),hi=null,ea=null;function _a(r,a,o){I(of,a._currentValue),a._currentValue=o}function ta(r){r._currentValue=of.current,K(of)}function cf(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 df(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 le=0;le<a.length;le++)if(Q.context===a[le]){j.lanes|=o,Q=j.alternate,Q!==null&&(Q.lanes|=o),cf(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(i(341));U.lanes|=o,j=U.alternate,j!==null&&(j.lanes|=o),cf(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 Ki(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(i(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(i(387));U.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(r!==null?r.push(No):r=[No])}v=v.return}r!==null&&df(a,r,o,m),a.flags|=262144}function Ac(r){for(r=r.firstContext;r!==null;){if(!Gr(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function xi(r){hi=r,ea=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function Nr(r){return qp(hi,r)}function _c(r,a){return hi===null&&xi(r),qp(r,a)}function qp(r,a){var o=a._currentValue;if(a={context:a,memoizedValue:o,next:null},ea===null){if(r===null)throw Error(i(308));ea=a,r.dependencies={lanes:0,firstContext:a},r.flags|=524288}else ea=ea.next=a;return o}var F5=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()})}},V5=e.unstable_scheduleCallback,Y5=e.unstable_NormalPriority,Wn={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function uf(){return{controller:new F5,data:new Map,refCount:0}}function Wl(r){r.refCount--,r.refCount===0&&V5(Y5,function(){r.controller.abort()})}var Zl=null,ff=0,Wi=0,Zi=null;function G5(r,a){if(Zl===null){var o=Zl=[];ff=0,Wi=xm(),Zi={status:"pending",value:void 0,then:function(m){o.push(m)}}}return ff++,a.then(Fp,Fp),a}function Fp(){if(--ff===0&&Zl!==null){Zi!==null&&(Zi.status="fulfilled");var r=Zl;Zl=null,Wi=0,Zi=null;for(var a=0;a<r.length;a++)(0,r[a])()}}function X5(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 Vp=O.S;O.S=function(r,a){T0=kt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&G5(r,a),Vp!==null&&Vp(r,a)};var pi=F(null);function mf(){var r=pi.current;return r!==null?r:En.pooledCache}function Mc(r,a){a===null?I(pi,pi.current):I(pi,a.pool)}function Yp(){var r=mf();return r===null?null:{parent:Wn._currentValue,pool:r}}var Qi=Error(i(460)),hf=Error(i(474)),Rc=Error(i(542)),Oc={then:function(){}};function Gp(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Xp(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,Wp(r),r;default:if(typeof a.status=="string")a.then(Be,Be);else{if(r=En,r!==null&&100<r.shellSuspendCounter)throw Error(i(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,Wp(r),r}throw bi=a,Qi}}function gi(r){try{var a=r._init;return a(r._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(bi=o,Qi):o}}var bi=null;function Kp(){if(bi===null)throw Error(i(459));var r=bi;return bi=null,r}function Wp(r){if(r===Qi||r===Rc)throw Error(i(483))}var Ji=null,Ql=0;function Dc(r){var a=Ql;return Ql+=1,Ji===null&&(Ji=[]),Xp(Ji,r,a)}function Jl(r,a){a=a.props.ref,r.ref=a!==void 0?a:null}function Lc(r,a){throw a.$$typeof===g?Error(i(525)):(r=Object.prototype.toString.call(a),Error(i(31,r==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":r)))}function Zp(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=tf(pe,he.mode,_e),ce.return=he,ce):(ce=v(ce,pe),ce.return=he,ce)}function le(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&&gi(gt)===ce.type)?(ce=v(ce,pe.props),Jl(ce,pe),ce.return=he,ce):(ce=Ec(pe.type,pe.key,pe.props,null,he.mode,_e),Jl(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=nf(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=fi(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=tf(""+ce,he.mode,pe),ce.return=he,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case b:return pe=Ec(ce.type,ce.key,ce.props,null,he.mode,pe),Jl(pe,ce),pe.return=he,pe;case w:return ce=nf(ce,he.mode,pe),ce.return=he,ce;case q:return ce=gi(ce),De(he,ce,pe)}if(z(ce)||G(ce))return ce=fi(ce,he.mode,pe,null),ce.return=he,ce;if(typeof ce.then=="function")return De(he,Dc(ce),pe);if(ce.$$typeof===N)return De(he,_c(he,ce),pe);Lc(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?le(he,ce,pe,_e):null;case w:return pe.key===gt?be(he,ce,pe,_e):null;case q:return pe=gi(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,Dc(pe),_e);if(pe.$$typeof===N)return je(he,ce,_c(he,pe),_e);Lc(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,le(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=gi(_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,Dc(_e),gt);if(_e.$$typeof===N)return we(he,ce,pe,_c(ce,_e),gt);Lc(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(i(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(ak){return a(he,ak)}),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&&gi(gt)===ce.type){o(he,ce.sibling),_e=v(ce,pe.props),Jl(_e,pe),_e.return=he,he=_e;break e}o(he,ce);break}else a(he,ce);ce=ce.sibling}pe.type===k?(_e=fi(pe.props.children,he.mode,_e,pe.key),_e.return=he,he=_e):(_e=Ec(pe.type,pe.key,pe.props,null,he.mode,_e),Jl(_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=nf(pe,he.mode,_e),_e.return=he,he=_e}return U(he);case q:return pe=gi(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(i(150));return pe=gt.call(pe),Nt(he,ce,pe,_e)}if(typeof pe.then=="function")return Nn(he,ce,Dc(pe),_e);if(pe.$$typeof===N)return Nn(he,ce,_c(he,pe),_e);Lc(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=tf(pe,he.mode,_e),_e.return=he,he=_e),U(he)):o(he,ce)}return function(he,ce,pe,_e){try{Ql=0;var gt=Nn(he,ce,pe,_e);return Ji=null,gt}catch(ct){if(ct===Qi||ct===Rc)throw ct;var sn=Xr(29,ct,null,he.mode);return sn.lanes=_e,sn.return=he,sn}}}var yi=Zp(!0),Qp=Zp(!1),Ma=!1;function xf(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function pf(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=Cc(r),Lp(r,null,o),a}return Sc(r,m,a,o),Cc(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 gf(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 bf=!1;function to(){if(bf){var r=Zi;if(r!==null)throw r}}function no(r,a,o,m){bf=!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 le=Q,be=le.next;le.next=null,U===null?j=be:U.next=be,U=le;var Ae=r.alternate;Ae!==null&&(Ae=Ae.updateQueue,Q=Ae.lastBaseUpdate,Q!==U&&(Q===null?Ae.firstBaseUpdate=be:Q.next=be,Ae.lastBaseUpdate=le))}if(j!==null){var De=v.baseState;U=0,Ae=be=le=null,Q=j;do{var je=Q.lane&-536870913,we=je!==Q.lane;if(we?(Kt&je)===je:(m&je)===je){je!==0&&je===Wi&&(bf=!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,le=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&&(le=De),v.baseState=le,v.firstBaseUpdate=be,v.lastBaseUpdate=Ae,j===null&&(v.shared.lanes=0),$a|=U,r.lanes=U,r.memoizedState=De}}function Jp(r,a){if(typeof r!="function")throw Error(i(191,r));r.call(a)}function eg(r,a){var o=r.callbacks;if(o!==null)for(r.callbacks=null,r=0;r<o.length;r++)Jp(o[r],a)}var el=F(null),Ic=F(0);function tg(r,a){r=da,I(Ic,r),I(el,a),da=r|a.baseLanes}function yf(){I(Ic,da),I(el,el.current)}function vf(){da=Ic.current,K(el),K(Ic)}var Kr=F(null),fs=null;function Da(r){var a=r.alternate;I(Yn,Yn.current&1),I(Kr,r),fs===null&&(a===null||el.current!==null||a.memoizedState!==null)&&(fs=r)}function jf(r){I(Yn,Yn.current),I(Kr,r),fs===null&&(fs=r)}function ng(r){r.tag===22?(I(Yn,Yn.current),I(Kr,r),fs===null&&(fs=r)):La()}function La(){I(Yn,Yn.current),I(Kr,Kr.current)}function Wr(r){K(Kr),fs===r&&(fs=null),K(Yn)}var Yn=F(0);function zc(r){for(var a=r;a!==null;){if(a.tag===13){var o=a.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||Em(o)||Tm(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,Zn=null,$c=!1,tl=!1,vi=!1,Bc=0,ro=0,nl=null,K5=0;function Pn(){throw Error(i(321))}function wf(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 Nf(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?Bg:$f,vi=!1,j=o(m,v),vi=!1,tl&&(j=sg(a,o,m,v)),rg(r),j}function rg(r){O.H=io;var a=jn!==null&&jn.next!==null;if(na=0,Zn=jn=zt=null,$c=!1,ro=0,nl=null,a)throw Error(i(300));r===null||Qn||(r=r.dependencies,r!==null&&Ac(r)&&(Qn=!0))}function sg(r,a,o,m){zt=r;var v=0;do{if(tl&&(nl=null),ro=0,tl=!1,25<=v)throw Error(i(301));if(v+=1,Zn=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=Hg,j=a(o,m)}while(tl);return j}function W5(){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 kf(){var r=Bc!==0;return Bc=0,r}function Sf(r,a,o){a.updateQueue=r.updateQueue,a.flags&=-2053,r.lanes&=~o}function Cf(r){if($c){for(r=r.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}$c=!1}na=0,Zn=jn=zt=null,tl=!1,ro=Bc=0,nl=null}function _r(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Zn===null?zt.memoizedState=Zn=r:Zn=Zn.next=r,Zn}function Gn(){if(jn===null){var r=zt.alternate;r=r!==null?r.memoizedState:null}else r=jn.next;var a=Zn===null?zt.memoizedState:Zn.next;if(a!==null)Zn=a,jn=r;else{if(r===null)throw zt.alternate===null?Error(i(467)):Error(i(310));jn=r,r={memoizedState:jn.memoizedState,baseState:jn.baseState,baseQueue:jn.baseQueue,queue:jn.queue,next:null},Zn===null?zt.memoizedState=Zn=r:Zn=Zn.next=r}return Zn}function Hc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function so(r){var a=ro;return ro+=1,nl===null&&(nl=[]),r=Xp(nl,r,a),a=zt,(Zn===null?a.memoizedState:Zn.next)===null&&(a=a.alternate,O.H=a===null||a.memoizedState===null?Bg:$f),r}function Pc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return so(r);if(r.$$typeof===N)return Nr(r)}throw Error(i(438,String(r)))}function Ef(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=Hc(),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 Uc(r){var a=Gn();return Tf(a,jn,r)}function Tf(r,a,o){var m=r.queue;if(m===null)throw Error(i(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,le=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)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null}),De===Wi&&(Ae=!0);else if((na&je)===je){be=be.next,je===Wi&&(Ae=!0);continue}else De={lane:0,revertLane:be.revertLane,gesture:null,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null},le===null?(Q=le=De,U=j):le=le.next=De,zt.lanes|=je,$a|=je;De=be.action,vi&&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},le===null?(Q=le=je,U=j):le=le.next=je,zt.lanes|=De,$a|=De;be=be.next}while(be!==null&&be!==a);if(le===null?U=j:le.next=Q,!Gr(j,r.memoizedState)&&(Qn=!0,Ae&&(o=Zi,o!==null)))throw o;r.memoizedState=j,r.baseState=U,r.baseQueue=le,m.lastRenderedState=j}return v===null&&(m.lanes=0),[r.memoizedState,m.dispatch]}function Af(r){var a=Gn(),o=a.queue;if(o===null)throw Error(i(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)||(Qn=!0),a.memoizedState=j,a.baseQueue===null&&(a.baseState=j),o.lastRenderedState=j}return[j,m]}function ag(r,a,o){var m=zt,v=Gn(),j=Qt;if(j){if(o===void 0)throw Error(i(407));o=o()}else o=a();var U=!Gr((jn||v).memoizedState,o);if(U&&(v.memoizedState=o,Qn=!0),v=v.queue,Rf(og.bind(null,m,v,r),[r]),v.getSnapshot!==a||U||Zn!==null&&Zn.memoizedState.tag&1){if(m.flags|=2048,rl(9,{destroy:void 0},lg.bind(null,m,v,o,a),null),En===null)throw Error(i(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=Hc(),zt.updateQueue=a,a.stores=[r]):(o=a.stores,o===null?a.stores=[r]:o.push(r))}function lg(r,a,o,m){a.value=o,a.getSnapshot=m,cg(a)&&dg(r)}function og(r,a,o){return o(function(){cg(a)&&dg(r)})}function cg(r){var a=r.getSnapshot;r=r.value;try{var o=a();return!Gr(r,o)}catch{return!0}}function dg(r){var a=ui(r,2);a!==null&&Pr(a,r,2)}function _f(r){var a=_r();if(typeof r=="function"){var o=r;if(r=o(),vi){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 ug(r,a,o,m){return r.baseState=o,Tf(r,jn,typeof m=="function"?m:ra)}function Z5(r,a,o,m,v){if(Vc(r))throw Error(i(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,fg(a,j)):(j.next=o.next,a.pending=o.next=j)}}function fg(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),le=O.S;le!==null&&le(U,Q),mg(r,a,Q)}catch(be){Mf(r,a,be)}finally{j!==null&&U.types!==null&&(j.types=U.types),O.T=j}}else try{j=o(v,m),mg(r,a,j)}catch(be){Mf(r,a,be)}}function mg(r,a,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(m){hg(r,a,m)},function(m){return Mf(r,a,m)}):hg(r,a,o)}function hg(r,a,o){a.status="fulfilled",a.value=o,xg(a),r.state=o,a=r.pending,a!==null&&(o=a.next,o===a?r.pending=null:(o=o.next,a.next=o,fg(r,o)))}function Mf(r,a,o){var m=r.pending;if(r.pending=null,m!==null){m=m.next;do a.status="rejected",a.reason=o,xg(a),a=a.next;while(a!==m)}r.action=null}function xg(r){r=r.listeners;for(var a=0;a<r.length;a++)(0,r[a])()}function pg(r,a){return a}function gg(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:pg,lastRenderedState:a},o.queue=m,o=Ig.bind(null,zt,m),m.dispatch=o,m=_f(!1),j=zf.bind(null,zt,!1,m.queue),m=_r(),v={state:a,dispatch:null,action:r,pending:null},m.queue=v,o=Z5.bind(null,zt,v,j,o),v.dispatch=o,m.memoizedState=r,[a,o,!1]}function bg(r){var a=Gn();return yg(a,jn,r)}function yg(r,a,o){if(a=Tf(r,a,pg)[0],r=Uc(ra)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var m=so(a)}catch(U){throw U===Qi?Rc:U}else m=a;a=Gn();var v=a.queue,j=v.dispatch;return o!==a.memoizedState&&(zt.flags|=2048,rl(9,{destroy:void 0},Q5.bind(null,v,o),null)),[m,j,r]}function Q5(r,a){r.action=a}function vg(r){var a=Gn(),o=jn;if(o!==null)return yg(a,o,r);Gn(),a=a.memoizedState,o=Gn();var m=o.queue.dispatch;return o.memoizedState=r,[a,m,!1]}function rl(r,a,o,m){return r={tag:r,create:o,deps:m,inst:a,next:null},a=zt.updateQueue,a===null&&(a=Hc(),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 jg(){return Gn().memoizedState}function qc(r,a,o,m){var v=_r();zt.flags|=r,v.memoizedState=rl(1|a,{destroy:void 0},o,m===void 0?null:m)}function Fc(r,a,o,m){var v=Gn();m=m===void 0?null:m;var j=v.memoizedState.inst;jn!==null&&m!==null&&wf(m,jn.memoizedState.deps)?v.memoizedState=rl(a,j,o,m):(zt.flags|=r,v.memoizedState=rl(1|a,j,o,m))}function wg(r,a){qc(8390656,8,r,a)}function Rf(r,a){Fc(2048,8,r,a)}function J5(r){zt.flags|=4;var a=zt.updateQueue;if(a===null)a=Hc(),zt.updateQueue=a,a.events=[r];else{var o=a.events;o===null?a.events=[r]:o.push(r)}}function Ng(r){var a=Gn().memoizedState;return J5({ref:a,nextImpl:r}),function(){if((cn&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}function kg(r,a){return Fc(4,2,r,a)}function Sg(r,a){return Fc(4,4,r,a)}function Cg(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 Eg(r,a,o){o=o!=null?o.concat([r]):null,Fc(4,4,Cg.bind(null,a,r),o)}function Of(){}function Tg(r,a){var o=Gn();a=a===void 0?null:a;var m=o.memoizedState;return a!==null&&wf(a,m[1])?m[0]:(o.memoizedState=[r,a],r)}function Ag(r,a){var o=Gn();a=a===void 0?null:a;var m=o.memoizedState;if(a!==null&&wf(a,m[1]))return m[0];if(m=r(),vi){Jt(!0);try{r()}finally{Jt(!1)}}return o.memoizedState=[m,a],m}function Df(r,a,o){return o===void 0||(na&1073741824)!==0&&(Kt&261930)===0?r.memoizedState=a:(r.memoizedState=o,r=_0(),zt.lanes|=r,$a|=r,o)}function _g(r,a,o,m){return Gr(o,a)?o:el.current!==null?(r=Df(r,o,m),Gr(r,a)||(Qn=!0),r):(na&42)===0||(na&1073741824)!==0&&(Kt&261930)===0?(Qn=!0,r.memoizedState=o):(r=_0(),zt.lanes|=r,$a|=r,a)}function Mg(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,zf(r,!1,a,o);try{var le=v(),be=O.S;if(be!==null&&be(Q,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var Ae=X5(le,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 e2(){}function Lf(r,a,o,m){if(r.tag!==5)throw Error(i(476));var v=Rg(r).queue;Mg(r,v,a,H,o===null?e2:function(){return Og(r),o(m)})}function Rg(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 Og(r){var a=Rg(r);a.next===null&&(a=r.alternate.memoizedState),ao(r,a.next.queue,{},Jr())}function If(){return Nr(No)}function Dg(){return Gn().memoizedState}function Lg(){return Gn().memoizedState}function t2(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:uf()},r.payload=a;return}a=a.return}}function n2(r,a,o){var m=Jr();o={lane:m,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Vc(r)?zg(a,o):(o=Ju(r,a,o,m),o!==null&&(Pr(o,r,m),$g(o,a,m)))}function Ig(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(Vc(r))zg(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 Sc(r,a,v,0),En===null&&kc(),!1}catch{}if(o=Ju(r,a,v,m),o!==null)return Pr(o,r,m),$g(o,a,m),!0}return!1}function zf(r,a,o,m){if(m={lane:2,revertLane:xm(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Vc(r)){if(a)throw Error(i(479))}else a=Ju(r,o,m,2),a!==null&&Pr(a,r,2)}function Vc(r){var a=r.alternate;return r===zt||a!==null&&a===zt}function zg(r,a){tl=$c=!0;var o=r.pending;o===null?a.next=a:(a.next=o.next,o.next=a),r.pending=a}function $g(r,a,o){if((o&4194048)!==0){var m=a.lanes;m&=r.pendingLanes,o|=m,a.lanes=o,ur(r,o)}}var io={readContext:Nr,use:Pc,useCallback:Pn,useContext:Pn,useEffect:Pn,useImperativeHandle:Pn,useLayoutEffect:Pn,useInsertionEffect:Pn,useMemo:Pn,useReducer:Pn,useRef:Pn,useState:Pn,useDebugValue:Pn,useDeferredValue:Pn,useTransition:Pn,useSyncExternalStore:Pn,useId:Pn,useHostTransitionStatus:Pn,useFormState:Pn,useActionState:Pn,useOptimistic:Pn,useMemoCache:Pn,useCacheRefresh:Pn};io.useEffectEvent=Pn;var Bg={readContext:Nr,use:Pc,useCallback:function(r,a){return _r().memoizedState=[r,a===void 0?null:a],r},useContext:Nr,useEffect:wg,useImperativeHandle:function(r,a,o){o=o!=null?o.concat([r]):null,qc(4194308,4,Cg.bind(null,a,r),o)},useLayoutEffect:function(r,a){return qc(4194308,4,r,a)},useInsertionEffect:function(r,a){qc(4,2,r,a)},useMemo:function(r,a){var o=_r();a=a===void 0?null:a;var m=r();if(vi){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(vi){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=n2.bind(null,zt,r),[m.memoizedState,r]},useRef:function(r){var a=_r();return r={current:r},a.memoizedState=r},useState:function(r){r=_f(r);var a=r.queue,o=Ig.bind(null,zt,a);return a.dispatch=o,[r.memoizedState,o]},useDebugValue:Of,useDeferredValue:function(r,a){var o=_r();return Df(o,r,a)},useTransition:function(){var r=_f(!1);return r=Mg.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(i(407));o=o()}else{if(o=a(),En===null)throw Error(i(349));(Kt&127)!==0||ig(m,a,o)}v.memoizedState=o;var j={value:o,getSnapshot:a};return v.queue=j,wg(og.bind(null,m,j,r),[r]),m.flags|=2048,rl(9,{destroy:void 0},lg.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=Bc++,0<o&&(a+="H"+o.toString(32)),a+="_"}else o=K5++,a="_"+a+"r_"+o.toString(32)+"_";return r.memoizedState=a},useHostTransitionStatus:If,useFormState:gg,useActionState:gg,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=zf.bind(null,zt,!0,o),o.dispatch=a,[r,a]},useMemoCache:Ef,useCacheRefresh:function(){return _r().memoizedState=t2.bind(null,zt)},useEffectEvent:function(r){var a=_r(),o={impl:r};return a.memoizedState=o,function(){if((cn&2)!==0)throw Error(i(440));return o.impl.apply(void 0,arguments)}}},$f={readContext:Nr,use:Pc,useCallback:Tg,useContext:Nr,useEffect:Rf,useImperativeHandle:Eg,useInsertionEffect:kg,useLayoutEffect:Sg,useMemo:Ag,useReducer:Uc,useRef:jg,useState:function(){return Uc(ra)},useDebugValue:Of,useDeferredValue:function(r,a){var o=Gn();return _g(o,jn.memoizedState,r,a)},useTransition:function(){var r=Uc(ra)[0],a=Gn().memoizedState;return[typeof r=="boolean"?r:so(r),a]},useSyncExternalStore:ag,useId:Dg,useHostTransitionStatus:If,useFormState:bg,useActionState:bg,useOptimistic:function(r,a){var o=Gn();return ug(o,jn,r,a)},useMemoCache:Ef,useCacheRefresh:Lg};$f.useEffectEvent=Ng;var Hg={readContext:Nr,use:Pc,useCallback:Tg,useContext:Nr,useEffect:Rf,useImperativeHandle:Eg,useInsertionEffect:kg,useLayoutEffect:Sg,useMemo:Ag,useReducer:Af,useRef:jg,useState:function(){return Af(ra)},useDebugValue:Of,useDeferredValue:function(r,a){var o=Gn();return jn===null?Df(o,r,a):_g(o,jn.memoizedState,r,a)},useTransition:function(){var r=Af(ra)[0],a=Gn().memoizedState;return[typeof r=="boolean"?r:so(r),a]},useSyncExternalStore:ag,useId:Dg,useHostTransitionStatus:If,useFormState:vg,useActionState:vg,useOptimistic:function(r,a){var o=Gn();return jn!==null?ug(o,jn,r,a):(o.baseState=r,[r,o.queue.dispatch])},useMemoCache:Ef,useCacheRefresh:Lg};Hg.useEffectEvent=Ng;function Bf(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 Hf={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 Pg(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?!Yl(o,m)||!Yl(v,j):!0}function Ug(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&&Hf.enqueueReplaceState(a,a.state,null)}function ji(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 qg(r){Nc(r)}function Fg(r){console.error(r)}function Vg(r){Nc(r)}function Yc(r,a){try{var o=r.onUncaughtError;o(a.value,{componentStack:a.stack})}catch(m){setTimeout(function(){throw m})}}function Yg(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 Pf(r,a,o){return o=Ra(o),o.tag=3,o.payload={element:null},o.callback=function(){Yc(r,a)},o}function Gg(r){return r=Ra(r),r.tag=3,r}function Xg(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(){Yg(a,o,m)}}var U=o.stateNode;U!==null&&typeof U.componentDidCatch=="function"&&(r.callback=function(){Yg(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 r2(r,a,o,m,v){if(o.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(a=o.alternate,a!==null&&Ki(a,o,v,!0),o=Kr.current,o!==null){switch(o.tag){case 31:case 13:return fs===null?sd():o.alternate===null&&Un===0&&(Un=3),o.flags&=-257,o.flags|=65536,o.lanes=v,m===Oc?o.flags|=16384:(a=o.updateQueue,a===null?o.updateQueue=new Set([m]):a.add(m),fm(r,m,v)),!1;case 22:return o.flags|=65536,m===Oc?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)),fm(r,m,v)),!1}throw Error(i(435,o.tag))}return fm(r,m,v),sd(),!1}if(Qt)return a=Kr.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=v,m!==af&&(r=Error(i(422),{cause:m}),Kl(os(r,o)))):(m!==af&&(a=Error(i(423),{cause:m}),Kl(os(a,o))),r=r.current.alternate,r.flags|=65536,v&=-v,r.lanes|=v,m=os(m,o),v=Pf(r.stateNode,m,v),gf(r,v),Un!==4&&(Un=2)),!1;var j=Error(i(520),{cause:m});if(j=os(j,o),xo===null?xo=[j]:xo.push(j),Un!==4&&(Un=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=Pf(o.stateNode,m,r),gf(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=Gg(v),Xg(v,r,o,m),gf(o,v),!1}o=o.return}while(o!==null);return!1}var Uf=Error(i(461)),Qn=!1;function kr(r,a,o,m){a.child=r===null?Qp(a,null,o,m):yi(a,r.child,o,m)}function Kg(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 xi(a),m=Nf(r,a,o,U,j,v),Q=kf(),r!==null&&!Qn?(Sf(r,a,v),sa(r,a,v)):(Qt&&Q&&rf(a),a.flags|=1,kr(r,a,m,v),a.child)}function Wg(r,a,o,m,v){if(r===null){var j=o.type;return typeof j=="function"&&!ef(j)&&j.defaultProps===void 0&&o.compare===null?(a.tag=15,a.type=j,Zg(r,a,j,m,v)):(r=Ec(o.type,null,m,a,a.mode,v),r.ref=a.ref,r.return=a,a.child=r)}if(j=r.child,!Wf(r,v)){var U=j.memoizedProps;if(o=o.compare,o=o!==null?o:Yl,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 Zg(r,a,o,m,v){if(r!==null){var j=r.memoizedProps;if(Yl(j,m)&&r.ref===a.ref)if(Qn=!1,a.pendingProps=m=j,Wf(r,v))(r.flags&131072)!==0&&(Qn=!0);else return a.lanes=r.lanes,sa(r,a,v)}return qf(r,a,o,m,v)}function Qg(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 Jg(r,a,j,o,m)}if((o&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},r!==null&&Mc(a,j!==null?j.cachePool:null),j!==null?tg(a,j):yf(),ng(a);else return m=a.lanes=536870912,Jg(r,a,j!==null?j.baseLanes|o:o,o,m)}else j!==null?(Mc(a,j.cachePool),tg(a,j),La(),a.memoizedState=null):(r!==null&&Mc(a,null),yf(),La());return kr(r,a,v,o),a.child}function lo(r,a){return r!==null&&r.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Jg(r,a,o,m,v){var j=mf();return j=j===null?null:{parent:Wn._currentValue,pool:j},a.memoizedState={baseLanes:o,cachePool:j},r!==null&&Mc(a,null),yf(),ng(a),r!==null&&Ki(r,a,m,!0),a.childLanes=v,null}function Gc(r,a){return a=Kc({mode:a.mode,children:a.children},r.mode),a.ref=r.ref,r.child=a,a.return=r,a}function e0(r,a,o){return yi(a,r.child,null,o),r=Gc(a,a.pendingProps),r.flags|=2,Wr(a),a.memoizedState=null,r}function s2(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=Gc(a,m),a.lanes=536870912,lo(null,r);if(jf(a),(r=Rn)?(r=fb(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=zp(r),o.return=a,a.child=o,wr=a,Rn=null)):r=null,r===null)throw Aa(a);return a.lanes=536870912,null}return Gc(a,m)}var j=r.memoizedState;if(j!==null){var U=j.dehydrated;if(jf(a),v)if(a.flags&256)a.flags&=-257,a=e0(r,a,o);else if(a.memoizedState!==null)a.child=r.child,a.flags|=128,a=null;else throw Error(i(558));else if(Qn||Ki(r,a,o,!1),v=(o&r.childLanes)!==0,Qn||v){if(m=En,m!==null&&(U=$n(m,o),U!==0&&U!==j.retryLane))throw j.retryLane=U,ui(r,U),Pr(m,r,U),Uf;sd(),a=e0(r,a,o)}else r=j.treeContext,Rn=ms(U.nextSibling),wr=a,Qt=!0,Ta=null,us=!1,r!==null&&Hp(a,r),a=Gc(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 Xc(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(i(284));(r===null||r.ref!==o)&&(a.flags|=4194816)}}function qf(r,a,o,m,v){return xi(a),o=Nf(r,a,o,m,void 0,v),m=kf(),r!==null&&!Qn?(Sf(r,a,v),sa(r,a,v)):(Qt&&m&&rf(a),a.flags|=1,kr(r,a,o,v),a.child)}function t0(r,a,o,m,v,j){return xi(a),a.updateQueue=null,o=sg(a,m,o,v),rg(r),m=kf(),r!==null&&!Qn?(Sf(r,a,j),sa(r,a,j)):(Qt&&m&&rf(a),a.flags|=1,kr(r,a,o,j),a.child)}function n0(r,a,o,m,v){if(xi(a),a.stateNode===null){var j=Vi,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=Hf,a.stateNode=j,j._reactInternals=a,j=a.stateNode,j.props=m,j.state=a.memoizedState,j.refs={},xf(a),U=o.contextType,j.context=typeof U=="object"&&U!==null?Nr(U):Vi,j.state=a.memoizedState,U=o.getDerivedStateFromProps,typeof U=="function"&&(Bf(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&&Hf.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,le=ji(o,Q);j.props=le;var be=j.context,Ae=o.contextType;U=Vi,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)&&Ug(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"&&(Bf(a,o,De,m),be=a.memoizedState),(le=Ma||Pg(a,o,le,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=le):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),m=!1)}else{j=a.stateNode,pf(r,a),U=a.memoizedProps,Ae=ji(o,U),j.props=Ae,De=a.pendingProps,je=j.context,be=o.contextType,le=Vi,typeof be=="object"&&be!==null&&(le=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!==le)&&Ug(a,j,m,le),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&&Ac(r.dependencies)?(typeof Q=="function"&&(Bf(a,o,Q,m),we=a.memoizedState),(Ae=Ma||Pg(a,o,Ae,m,je,we,le)||r!==null&&r.dependencies!==null&&Ac(r.dependencies))?(be||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(m,we,le),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(m,we,le)),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=le,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,Xc(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=yi(a,r.child,null,v),a.child=yi(a,null,o,v)):kr(r,a,o,v),a.memoizedState=j.state,r=a.child):r=sa(r,a,v),r}function r0(r,a,o,m){return mi(),a.flags|=256,kr(r,a,o,m),a.child}var Ff={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Vf(r){return{baseLanes:r,cachePool:Yp()}}function Yf(r,a,o){return r=r!==null?r.childLanes&~o:0,a&&(r|=Qr),r}function s0(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:(Yn.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=fb(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=zp(r),o.return=a,a.child=o,wr=a,Rn=null)):r=null,r===null)throw Aa(a);return Tm(r)?a.lanes=32:a.lanes=536870912,null}var Q=m.children;return m=m.fallback,v?(La(),v=a.mode,Q=Kc({mode:"hidden",children:Q},v),m=fi(m,v,o,null),Q.return=a,m.return=a,Q.sibling=m,a.child=Q,m=a.child,m.memoizedState=Vf(o),m.childLanes=Yf(r,U,o),a.memoizedState=Ff,lo(null,m)):(Da(a),Gf(a,Q))}var le=r.memoizedState;if(le!==null&&(Q=le.dehydrated,Q!==null)){if(j)a.flags&256?(Da(a),a.flags&=-257,a=Xf(r,a,o)):a.memoizedState!==null?(La(),a.child=r.child,a.flags|=128,a=null):(La(),Q=m.fallback,v=a.mode,m=Kc({mode:"visible",children:m.children},v),Q=fi(Q,v,o,null),Q.flags|=2,m.return=a,Q.return=a,m.sibling=Q,a.child=m,yi(a,r.child,null,o),m=a.child,m.memoizedState=Vf(o),m.childLanes=Yf(r,U,o),a.memoizedState=Ff,a=lo(null,m));else if(Da(a),Tm(Q)){if(U=Q.nextSibling&&Q.nextSibling.dataset,U)var be=U.dgst;U=be,m=Error(i(419)),m.stack="",m.digest=U,Kl({value:m,source:null,stack:null}),a=Xf(r,a,o)}else if(Qn||Ki(r,a,o,!1),U=(o&r.childLanes)!==0,Qn||U){if(U=En,U!==null&&(m=$n(U,o),m!==0&&m!==le.retryLane))throw le.retryLane=m,ui(r,m),Pr(U,r,m),Uf;Em(Q)||sd(),a=Xf(r,a,o)}else Em(Q)?(a.flags|=192,a.child=r.child,a=null):(r=le.treeContext,Rn=ms(Q.nextSibling),wr=a,Qt=!0,Ta=null,us=!1,r!==null&&Hp(a,r),a=Gf(a,m.children),a.flags|=4096);return a}return v?(La(),Q=m.fallback,v=a.mode,le=r.child,be=le.sibling,m=Qs(le,{mode:"hidden",children:m.children}),m.subtreeFlags=le.subtreeFlags&65011712,be!==null?Q=Qs(be,Q):(Q=fi(Q,v,o,null),Q.flags|=2),Q.return=a,m.return=a,m.sibling=Q,a.child=m,lo(null,m),m=a.child,Q=r.child.memoizedState,Q===null?Q=Vf(o):(v=Q.cachePool,v!==null?(le=Wn._currentValue,v=v.parent!==le?{parent:le,pool:le}:v):v=Yp(),Q={baseLanes:Q.baseLanes|o,cachePool:v}),m.memoizedState=Q,m.childLanes=Yf(r,U,o),a.memoizedState=Ff,lo(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 Gf(r,a){return a=Kc({mode:"visible",children:a},r.mode),a.return=r,r.child=a}function Kc(r,a){return r=Xr(22,r,null,a),r.lanes=0,r}function Xf(r,a,o){return yi(a,r.child,null,o),r=Gf(a,a.pendingProps.children),r.flags|=2,a.memoizedState=null,r}function a0(r,a,o){r.lanes|=a;var m=r.alternate;m!==null&&(m.lanes|=a),cf(r.return,a,o)}function Kf(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=Yn.current,Q=(U&2)!==0;if(Q?(U=U&1|2,a.flags|=128):U&=1,I(Yn,U),kr(r,a,m,o),m=Qt?Xl:0,!Q&&r!==null&&(r.flags&128)!==0)e:for(r=a.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&a0(r,o,a);else if(r.tag===19)a0(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&&zc(r)===null&&(v=o),o=o.sibling;o=v,o===null?(v=a.child,a.child=null):(v=o.sibling,o.sibling=null),Kf(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&&zc(r)===null){a.child=v;break}r=v.sibling,v.sibling=o,o=v,v=r}Kf(a,!0,o,null,j,m);break;case"together":Kf(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(Ki(r,a,o,!1),(o&a.childLanes)===0)return null}else return null;if(r!==null&&a.child!==r.child)throw Error(i(153));if(a.child!==null){for(r=a.child,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 Wf(r,a){return(r.lanes&a)!==0?!0:(r=r.dependencies,!!(r!==null&&Ac(r)))}function a2(r,a,o){switch(a.tag){case 3:te(a,a.stateNode.containerInfo),_a(a,Wn,r.memoizedState.cache),mi();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,jf(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?s0(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||(Ki(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(Yn,Yn.current),m)break;return null;case 22:return a.lanes=0,Qg(r,a,o,a.pendingProps);case 24:_a(a,Wn,r.memoizedState.cache)}return sa(r,a,o)}function l0(r,a,o){if(r!==null)if(r.memoizedProps!==a.pendingProps)Qn=!0;else{if(!Wf(r,o)&&(a.flags&128)===0)return Qn=!1,a2(r,a,o);Qn=(r.flags&131072)!==0}else Qn=!1,Qt&&(a.flags&1048576)!==0&&Bp(a,Xl,a.index);switch(a.lanes=0,a.tag){case 16:e:{var m=a.pendingProps;if(r=gi(a.elementType),a.type=r,typeof r=="function")ef(r)?(m=ji(r,m),a.tag=1,a=n0(null,a,r,m,o)):(a.tag=0,a=qf(null,a,r,m,o));else{if(r!=null){var v=r.$$typeof;if(v===A){a.tag=11,a=Kg(null,a,r,m,o);break e}else if(v===Y){a.tag=14,a=Wg(null,a,r,m,o);break e}}throw a=T(r)||r,Error(i(306,a,""))}}return a;case 0:return qf(r,a,a.type,a.pendingProps,o);case 1:return m=a.type,v=ji(m,a.pendingProps),n0(r,a,m,v,o);case 3:e:{if(te(a,a.stateNode.containerInfo),r===null)throw Error(i(387));m=a.pendingProps;var j=a.memoizedState;v=j.element,pf(r,a),no(a,m,null,o);var U=a.memoizedState;if(m=U.cache,_a(a,Wn,m),m!==j.cache&&df(a,[Wn],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=r0(r,a,m,o);break e}else if(m!==v){v=os(Error(i(424)),a),Kl(v),a=r0(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=Qp(a,null,m,o),a.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(mi(),m===v){a=sa(r,a,o);break e}kr(r,a,m,o)}a=a.child}return a;case 26:return Xc(r,a),r===null?(o=bb(a.type,null,a.pendingProps,null))?a.memoizedState=o:Qt||(o=a.type,r=a.pendingProps,m=ud(W.current).createElement(o),m[ze]=a,m[Ve]=r,Sr(m,o,r),ln(m),a.stateNode=m):a.memoizedState=bb(a.type,r.memoizedProps,a.pendingProps,r.memoizedState),null;case 27:return oe(a),r===null&&Qt&&(m=a.stateNode=xb(a.type,a.pendingProps,W.current),wr=a,us=!0,v=Rn,qa(a.type)?(Am=v,Rn=ms(m.firstChild)):Rn=v),kr(r,a,a.pendingProps.children,o),Xc(r,a),r===null&&(a.flags|=4194304),a.child;case 5:return r===null&&Qt&&((v=m=Rn)&&(m=L2(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,km(v,j)?m=null:U!==null&&km(v,U)&&(a.flags|=32),a.memoizedState!==null&&(v=Nf(r,a,W5,null,null,o),No._currentValue=v),Xc(r,a),kr(r,a,m,o),a.child;case 6:return r===null&&Qt&&((r=o=Rn)&&(o=I2(o,a.pendingProps,us),o!==null?(a.stateNode=o,wr=a,Rn=null,r=!0):r=!1),r||Aa(a)),null;case 13:return s0(r,a,o);case 4:return te(a,a.stateNode.containerInfo),m=a.pendingProps,r===null?a.child=yi(a,null,m,o):kr(r,a,m,o),a.child;case 11:return Kg(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,xi(a),v=Nr(v),m=m(v),a.flags|=1,kr(r,a,m,o),a.child;case 14:return Wg(r,a,a.type,a.pendingProps,o);case 15:return Zg(r,a,a.type,a.pendingProps,o);case 19:return i0(r,a,o);case 31:return s2(r,a,o);case 22:return Qg(r,a,o,a.pendingProps);case 24:return xi(a),m=Nr(Wn),r===null?(v=mf(),v===null&&(v=En,j=uf(),v.pooledCache=j,j.refCount++,j!==null&&(v.pooledCacheLanes|=o),v=j),a.memoizedState={parent:m,cache:v},xf(a),_a(a,Wn,v)):((r.lanes&o)!==0&&(pf(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,Wn,m)):(m=j.cache,_a(a,Wn,m),m!==v.cache&&df(a,[Wn],o,!0))),kr(r,a,a.pendingProps.children,o),a.child;case 29:throw a.pendingProps}throw Error(i(156,a.tag))}function aa(r){r.flags|=4}function Zf(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(D0())r.flags|=8192;else throw bi=Oc,hf}else r.flags&=-16777217}function o0(r,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!Nb(a))if(D0())r.flags|=8192;else throw bi=Oc,hf}function Wc(r,a){a!==null&&(r.flags|=4),r.flags&16384&&(a=r.tag!==22?kn():536870912,r.lanes|=a,ll|=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(sf(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(Wn),re(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(r===null||r.child===null)&&(Xi(a)?aa(a):r===null||r.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,lf())),On(a),null;case 26:var v=a.type,j=a.memoizedState;return r===null?(aa(a),j!==null?(On(a),o0(a,j)):(On(a),Zf(a,v,null,m,o))):j?j!==r.memoizedState?(aa(a),On(a),o0(a,j)):(On(a),a.flags&=-16777217):(r=r.memoizedProps,r!==m&&aa(a),On(a),Zf(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(i(166));return On(a),null}r=S.current,Xi(a)?Pp(a):(r=xb(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(i(166));return On(a),null}if(j=S.current,Xi(a))Pp(a);else{var U=ud(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),Zf(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(i(166));if(r=W.current,Xi(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||sb(r.nodeValue,o)),r||Aa(a,!0)}else r=ud(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=Xi(a),o!==null){if(r===null){if(!m)throw Error(i(318));if(r=a.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[ze]=a}else mi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;On(a),r=!1}else o=lf(),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(i(558))}return On(a),null;case 13:if(m=a.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(v=Xi(a),m!==null&&m.dehydrated!==null){if(r===null){if(!v)throw Error(i(318));if(v=a.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(i(317));v[ze]=a}else mi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;On(a),v=!1}else v=lf(),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),Wc(a,a.updateQueue),On(a),null);case 4:return re(),r===null&&ym(a.stateNode.containerInfo),On(a),null;case 10:return ta(a.type),On(a),null;case 19:if(K(Yn),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(Un!==0||r!==null&&(r.flags&128)!==0)for(r=a.child;r!==null;){if(j=zc(r),j!==null){for(a.flags|=128,oo(m,!1),r=j.updateQueue,a.updateQueue=r,Wc(a,r),a.subtreeFlags=0,r=o,o=a.child;o!==null;)Ip(o,r),o=o.sibling;return I(Yn,Yn.current&1|2),Qt&&Js(a,m.treeForkCount),a.child}r=r.sibling}m.tail!==null&&kt()>td&&(a.flags|=128,v=!0,oo(m,!1),a.lanes=4194304)}else{if(!v)if(r=zc(j),r!==null){if(a.flags|=128,v=!0,r=r.updateQueue,a.updateQueue=r,Wc(a,r),oo(m,!0),m.tail===null&&m.tailMode==="hidden"&&!j.alternate&&!Qt)return On(a),null}else 2*kt()-m.renderingStartTime>td&&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=Yn.current,I(Yn,v?o&1|2:o&1),Qt&&Js(a,m.treeForkCount),r):(On(a),null);case 22:case 23:return Wr(a),vf(),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&&Wc(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(pi),null;case 24:return o=null,r!==null&&(o=r.memoizedState.cache),a.memoizedState.cache!==o&&(a.flags|=2048),ta(Wn),On(a),null;case 25:return null;case 30:return null}throw Error(i(156,a.tag))}function l2(r,a){switch(sf(a),a.tag){case 1:return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 3:return ta(Wn),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(i(340));mi()}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(i(340));mi()}return r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 19:return K(Yn),null;case 4:return re(),null;case 10:return ta(a.type),null;case 22:case 23:return Wr(a),vf(),r!==null&&K(pi),r=a.flags,r&65536?(a.flags=r&-65537|128,a):null;case 24:return ta(Wn),null;case 25:return null;default:return null}}function c0(r,a){switch(sf(a),a.tag){case 3:ta(Wn),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(Yn);break;case 10:ta(a.type);break;case 22:case 23:Wr(a),vf(),r!==null&&K(pi);break;case 24:ta(Wn)}}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 le=o,be=Q;try{be()}catch(Ae){pn(v,le,Ae)}}}m=m.next}while(m!==j)}}catch(Ae){pn(a,a.return,Ae)}}function d0(r){var a=r.updateQueue;if(a!==null){var o=r.stateNode;try{eg(a,o)}catch(m){pn(r,r.return,m)}}}function u0(r,a,o){o.props=ji(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 f0(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 Qf(r,a,o){try{var m=r.stateNode;A2(m,r.type,o,a),m[Ve]=a}catch(v){pn(r,r.return,v)}}function m0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&qa(r.type)||r.tag===4}function Jf(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||m0(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 em(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(em(r,a,o),r=r.sibling;r!==null;)em(r,a,o),r=r.sibling}function Zc(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(Zc(r,a,o),r=r.sibling;r!==null;)Zc(r,a,o),r=r.sibling}function h0(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 ia=!1,Jn=!1,tm=!1,x0=typeof WeakSet=="function"?WeakSet:Set,xr=null;function o2(r,a){if(r=r.containerInfo,wm=bd,r=Ep(r),Gu(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,le=-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||(le=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&&(le=U),(we=De.nextSibling)!==null)break;De=je,je=De.parentNode}De=we}o=Q===-1||le===-1?null:{start:Q,end:le}}else o=null}o=o||{start:0,end:0}}else o=null;for(Nm={focusedElem:r,selectionRange:o},bd=!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=ji(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)Cm(r);else if(o===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":Cm(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(i(163))}if(r=a.sibling,r!==null){r.return=a.return,xr=r;break}xr=a.return}}function p0(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=ji(o.type,a.memoizedProps);a=a.memoizedState;try{r.componentDidUpdate(v,a,r.__reactInternalSnapshotBeforeUpdate)}catch(U){pn(o,o.return,U)}}m&64&&d0(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{eg(r,a)}catch(U){pn(o,o.return,U)}}break;case 27:a===null&&m&4&&h0(o);case 26:case 5:oa(r,o),a===null&&m&4&&f0(o),m&512&&uo(o,o.return);break;case 12:oa(r,o);break;case 31:oa(r,o),m&4&&y0(r,o);break;case 13:oa(r,o),m&4&&v0(r,o),m&64&&(r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(o=g2.bind(null,o),z2(r,o))));break;case 22:if(m=o.memoizedState!==null||ia,!m){a=a!==null&&a.memoizedState!==null||Jn,v=ia;var j=Jn;ia=m,(Jn=a)&&!j?ca(r,o,(o.subtreeFlags&8772)!==0):oa(r,o),ia=v,Jn=j}break;case 30:break;default:oa(r,o)}}function g0(r){var a=r.alternate;a!==null&&(r.alternate=null,g0(a)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(a=r.stateNode,a!==null&&Kn(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 la(r,a,o){for(o=o.child;o!==null;)b0(r,a,o),o=o.sibling}function b0(r,a,o){if(St&&typeof St.onCommitFiberUnmount=="function")try{St.onCommitFiberUnmount(Ut,o)}catch{}switch(o.tag){case 26:Jn||$s(o,a),la(r,a,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:Jn||$s(o,a);var m=Ln,v=zr;qa(o.type)&&(Ln=o.stateNode,zr=!1),la(r,a,o),vo(o.stateNode),Ln=m,zr=v;break;case 5:Jn||$s(o,a);case 6:if(m=Ln,v=zr,Ln=null,la(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,db(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,o.stateNode),xl(r)):db(Ln,o.stateNode));break;case 4:m=Ln,v=zr,Ln=o.stateNode.containerInfo,zr=!0,la(r,a,o),Ln=m,zr=v;break;case 0:case 11:case 14:case 15:Ia(2,o,a),Jn||Ia(4,o,a),la(r,a,o);break;case 1:Jn||($s(o,a),m=o.stateNode,typeof m.componentWillUnmount=="function"&&u0(o,a,m)),la(r,a,o);break;case 21:la(r,a,o);break;case 22:Jn=(m=Jn)||o.memoizedState!==null,la(r,a,o),Jn=m;break;default:la(r,a,o)}}function y0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{xl(r)}catch(o){pn(a,a.return,o)}}}function v0(r,a){if(a.memoizedState===null&&(r=a.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{xl(r)}catch(o){pn(a,a.return,o)}}function c2(r){switch(r.tag){case 31:case 13:case 19:var a=r.stateNode;return a===null&&(a=r.stateNode=new x0),a;case 22:return r=r.stateNode,a=r._retryCache,a===null&&(a=r._retryCache=new x0),a;default:throw Error(i(435,r.tag))}}function Qc(r,a){var o=c2(r);a.forEach(function(m){if(!o.has(m)){o.add(m);var v=b2.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(i(160));b0(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;)j0(a,r),a=a.sibling}var ks=null;function j0(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&&(Jn||o===null||$s(o,o.return)),m&64&&ia&&(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&&(Jn||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=jb("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=jb("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(i(468,m))}j[ze]=r,ln(j),m=j}r.stateNode=m}else wb(v,r.type,r.stateNode);else r.stateNode=vb(v,m,r.memoizedProps);else j!==m?(j===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):j.count--,m===null?wb(v,r.type,r.stateNode):vb(v,m,r.memoizedProps)):m===null&&r.stateNode!==null&&Qf(r,r.memoizedProps,o.memoizedProps)}break;case 27:$r(a,r),Br(r),m&512&&(Jn||o===null||$s(o,o.return)),o!==null&&m&4&&Qf(r,r.memoizedProps,o.memoizedProps);break;case 5:if($r(a,r),Br(r),m&512&&(Jn||o===null||$s(o,o.return)),r.flags&32){v=r.stateNode;try{lr(v,"")}catch(rt){pn(r,r.return,rt)}}m&4&&r.stateNode!=null&&(v=r.memoizedProps,Qf(r,v,o!==null?o.memoizedProps:v)),m&1024&&(tm=!0);break;case 6:if($r(a,r),Br(r),m&4){if(r.stateNode===null)throw Error(i(162));m=r.memoizedProps,o=r.stateNode;try{o.nodeValue=m}catch(rt){pn(r,r.return,rt)}}break;case 3:if(hd=null,v=ks,ks=fd(a.containerInfo),$r(a,r),ks=v,Br(r),m&4&&o!==null&&o.memoizedState.isDehydrated)try{xl(a.containerInfo)}catch(rt){pn(r,r.return,rt)}tm&&(tm=!1,w0(r));break;case 4:m=ks,ks=fd(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,Qc(r,m)));break;case 13:$r(a,r),Br(r),r.child.flags&8192&&r.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(ed=kt()),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Qc(r,m)));break;case 22:v=r.memoizedState!==null;var le=o!==null&&o.memoizedState!==null,be=ia,Ae=Jn;if(ia=be||v,Jn=Ae||le,$r(a,r),Jn=Ae,ia=be,Br(r),m&8192)e:for(a=r.stateNode,a._visibility=v?a._visibility&-2:a._visibility|1,v&&(o===null||le||ia||Jn||wi(r)),o=null,a=r;;){if(a.tag===5||a.tag===26){if(o===null){le=o=a;try{if(j=le.stateNode,v)U=j.style,typeof U.setProperty=="function"?U.setProperty("display","none","important"):U.display="none";else{Q=le.stateNode;var De=le.memoizedProps.style,je=De!=null&&De.hasOwnProperty("display")?De.display:null;Q.style.display=je==null||typeof je=="boolean"?"":(""+je).trim()}}catch(rt){pn(le,le.return,rt)}}}else if(a.tag===6){if(o===null){le=a;try{le.stateNode.nodeValue=v?"":le.memoizedProps}catch(rt){pn(le,le.return,rt)}}}else if(a.tag===18){if(o===null){le=a;try{var we=le.stateNode;v?ub(we,!0):ub(le.stateNode,!1)}catch(rt){pn(le,le.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,Qc(r,o))));break;case 19:$r(a,r),Br(r),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Qc(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(m0(m)){o=m;break}m=m.return}if(o==null)throw Error(i(160));switch(o.tag){case 27:var v=o.stateNode,j=Jf(r);Zc(r,j,v);break;case 5:var U=o.stateNode;o.flags&32&&(lr(U,""),o.flags&=-33);var Q=Jf(r);Zc(r,Q,U);break;case 3:case 4:var le=o.stateNode.containerInfo,be=Jf(r);em(r,be,le);break;default:throw Error(i(161))}}catch(Ae){pn(r,r.return,Ae)}r.flags&=-3}a&4096&&(r.flags&=-4097)}function w0(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var a=r;w0(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;)p0(r,a.alternate,a),a=a.sibling}function wi(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),wi(a);break;case 1:$s(a,a.return);var o=a.stateNode;typeof o.componentWillUnmount=="function"&&u0(a,a.return,o),wi(a);break;case 27:vo(a.stateNode);case 26:case 5:$s(a,a.return),wi(a);break;case 22:a.memoizedState===null&&wi(a);break;case 30:wi(a);break;default:wi(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 le=v.shared.hiddenCallbacks;if(le!==null)for(v.shared.hiddenCallbacks=null,v=0;v<le.length;v++)Jp(le[v],Q)}catch(be){pn(m,m.return,be)}}o&&U&64&&d0(j),uo(j,j.return);break;case 27:h0(j);case 26:case 5:ca(v,j,o),o&&m===null&&U&4&&f0(j),uo(j,j.return);break;case 12:ca(v,j,o);break;case 31:ca(v,j,o),o&&U&4&&y0(v,j);break;case 13:ca(v,j,o),o&&U&4&&v0(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 nm(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&&Wl(o))}function rm(r,a){r=null,a.alternate!==null&&(r=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==r&&(a.refCount++,r!=null&&Wl(r))}function Ss(r,a,o,m){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)N0(r,a,o,m),a=a.sibling}function N0(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&&Wl(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(le){pn(a,a.return,le)}}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,sl(r,a,o,m,(a.subtreeFlags&10256)!==0||!1)),v&2048&&nm(U,a);break;case 24:Ss(r,a,o,m),v&2048&&rm(a.alternate,a);break;default:Ss(r,a,o,m)}}function sl(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,le=m,be=U.flags;switch(U.tag){case 0:case 11:case 15:sl(j,U,Q,le,v),co(8,U);break;case 23:break;case 22:var Ae=U.stateNode;U.memoizedState!==null?Ae._visibility&2?sl(j,U,Q,le,v):fo(j,U):(Ae._visibility|=2,sl(j,U,Q,le,v)),v&&be&2048&&nm(U.alternate,U);break;case 24:sl(j,U,Q,le,v),v&&be&2048&&rm(U.alternate,U);break;default:sl(j,U,Q,le,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&&nm(m.alternate,m);break;case 24:fo(o,m),v&2048&&rm(m.alternate,m);break;default:fo(o,m)}a=a.sibling}}var mo=8192;function al(r,a,o){if(r.subtreeFlags&mo)for(r=r.child;r!==null;)k0(r,a,o),r=r.sibling}function k0(r,a,o){switch(r.tag){case 26:al(r,a,o),r.flags&mo&&r.memoizedState!==null&&K2(o,ks,r.memoizedState,r.memoizedProps);break;case 5:al(r,a,o);break;case 3:case 4:var m=ks;ks=fd(r.stateNode.containerInfo),al(r,a,o),ks=m;break;case 22:r.memoizedState===null&&(m=r.alternate,m!==null&&m.memoizedState!==null?(m=mo,mo=16777216,al(r,a,o),mo=m):al(r,a,o));break;default:al(r,a,o)}}function S0(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,E0(m,r)}S0(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)C0(r),r=r.sibling}function C0(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,Jc(r)):ho(r);break;default:ho(r)}}function Jc(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,E0(m,r)}S0(r)}for(r=r.child;r!==null;){switch(a=r,a.tag){case 0:case 11:case 15:Ia(8,a,a.return),Jc(a);break;case 22:o=a.stateNode,o._visibility&2&&(o._visibility&=-3,Jc(a));break;default:Jc(a)}r=r.sibling}}function E0(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:Wl(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(g0(m),m===o){xr=null;break e}if(v!==null){v.return=j,xr=v;break e}xr=j}}}var d2={getCacheForType:function(r){var a=Nr(Wn),o=a.data.get(r);return o===void 0&&(o=r(),a.data.set(r,o)),o},cacheSignal:function(){return Nr(Wn).controller.signal}},u2=typeof WeakMap=="function"?WeakMap:Map,cn=0,En=null,Vt=null,Kt=0,xn=0,Zr=null,za=!1,il=!1,sm=!1,da=0,Un=0,$a=0,Ni=0,am=0,Qr=0,ll=0,xo=null,Hr=null,im=!1,ed=0,T0=0,td=1/0,nd=null,Ba=null,or=0,Ha=null,ol=null,ua=0,lm=0,om=null,A0=null,po=0,cm=null;function Jr(){return(cn&2)!==0&&Kt!==0?Kt&-Kt:O.T!==null?xm():qe()}function _0(){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)&&(cl(r,0),Pa(r,Kt,Qr,!1)),Mn(r,o),((cn&2)===0||r!==En)&&(r===En&&((cn&2)===0&&(Ni|=o),Un===4&&Pa(r,Kt,Qr,!1)),Bs(r))}function M0(r,a,o){if((cn&6)!==0)throw Error(i(327));var m=!o&&(a&127)===0&&(a&r.expiredLanes)===0||Et(r,a),v=m?h2(r,a):um(r,a,!0),j=m;do{if(v===0){il&&!m&&Pa(r,a,0,!1);break}else{if(o=r.current.alternate,j&&!f2(o)){v=um(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 le=Q.current.memoizedState.isDehydrated;if(le&&(cl(Q,U).flags|=256),U=um(Q,U,!1),U!==2){if(sm&&!le){Q.errorRecoveryDisabledLanes|=j,Ni|=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){cl(r,0),Pa(r,a,0,!0);break}e:{switch(m=r,j=v,j){case 0:case 1:throw Error(i(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(i(329))}if((a&62914560)===a&&(v=ed+300-kt(),10<v)){if(Pa(m,a,Qr,!za),lt(m,0,!0)!==0)break e;ua=a,m.timeoutHandle=ob(R0.bind(null,m,o,Hr,nd,im,a,Qr,Ni,ll,za,j,"Throttled",-0,0),v);break e}R0(m,o,Hr,nd,im,a,Qr,Ni,ll,za,j,null,-0,0)}}break}while(!0);Bs(r)}function R0(r,a,o,m,v,j,U,Q,le,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},k0(a,j,De);var rt=(j&62914560)===j?ed-kt():(j&4194048)===j?T0-kt():0;if(rt=W2(De,rt),rt!==null){ua=j,r.cancelPendingCommit=rt(H0.bind(null,r,a,j,o,m,v,U,Q,le,Ae,De,null,je,we)),Pa(r,j,U,!be);return}}H0(r,a,j,o,m,v,U,Q,le)}function f2(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&=~am,a&=~Ni,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 rd(){return(cn&6)===0?(go(0),!1):!0}function dm(){if(Vt!==null){if(xn===0)var r=Vt.return;else r=Vt,ea=hi=null,Cf(r),Ji=null,Ql=0,r=Vt;for(;r!==null;)c0(r.alternate,r),r=r.return;Vt=null}}function cl(r,a){var o=r.timeoutHandle;o!==-1&&(r.timeoutHandle=-1,R2(o)),o=r.cancelPendingCommit,o!==null&&(r.cancelPendingCommit=null,o()),ua=0,dm(),En=r,Vt=o=Qs(r.current,null),Kt=a,xn=0,Zr=null,za=!1,il=Et(r,a),sm=!1,ll=Qr=am=Ni=$a=Un=0,Hr=xo=null,im=!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,kc(),o}function O0(r,a){zt=null,O.H=io,a===Qi||a===Rc?(a=Kp(),xn=3):a===hf?(a=Kp(),xn=4):xn=a===Uf?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,Zr=a,Vt===null&&(Un=1,Yc(r,os(a,r.current)))}function D0(){var r=Kr.current;return r===null?!0:(Kt&4194048)===Kt?fs===null:(Kt&62914560)===Kt||(Kt&536870912)!==0?r===fs:!1}function L0(){var r=O.H;return O.H=io,r===null?io:r}function I0(){var r=O.A;return O.A=d2,r}function sd(){Un=4,za||(Kt&4194048)!==Kt&&Kr.current!==null||(il=!0),($a&134217727)===0&&(Ni&134217727)===0||En===null||Pa(En,Kt,Qr,!1)}function um(r,a,o){var m=cn;cn|=2;var v=L0(),j=I0();(En!==r||Kt!==a)&&(nd=null,cl(r,a)),a=!1;var U=Un;e:do try{if(xn!==0&&Vt!==null){var Q=Vt,le=Zr;switch(xn){case 8:dm(),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,dl(r,Q,le,be),o&&il){U=0;break e}break;default:be=xn,xn=0,Zr=null,dl(r,Q,le,be)}}m2(),U=Un;break}catch(Ae){O0(r,Ae)}while(!0);return a&&r.shellSuspendCounter++,ea=hi=null,cn=m,O.H=v,O.A=j,Vt===null&&(En=null,Kt=0,kc()),U}function m2(){for(;Vt!==null;)z0(Vt)}function h2(r,a){var o=cn;cn|=2;var m=L0(),v=I0();En!==r||Kt!==a?(nd=null,td=kt()+500,cl(r,a)):il=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,dl(r,a,j,1);break;case 2:case 9:if(Gp(j)){xn=0,Zr=null,$0(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:Gp(j)?(xn=0,Zr=null,$0(a)):(xn=0,Zr=null,dl(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?Nb(U):Q.stateNode.complete){xn=0,Zr=null;var le=Q.sibling;if(le!==null)Vt=le;else{var be=Q.return;be!==null?(Vt=be,ad(be)):Vt=null}break t}}xn=0,Zr=null,dl(r,a,j,5);break;case 6:xn=0,Zr=null,dl(r,a,j,6);break;case 8:dm(),Un=6;break e;default:throw Error(i(462))}}x2();break}catch(Ae){O0(r,Ae)}while(!0);return ea=hi=null,O.H=m,O.A=v,cn=o,Vt!==null?0:(En=null,Kt=0,kc(),Un)}function x2(){for(;Vt!==null&&!Ee();)z0(Vt)}function z0(r){var a=l0(r.alternate,r,da);r.memoizedProps=r.pendingProps,a===null?ad(r):Vt=a}function $0(r){var a=r,o=a.alternate;switch(a.tag){case 15:case 0:a=t0(o,a,a.pendingProps,a.type,void 0,Kt);break;case 11:a=t0(o,a,a.pendingProps,a.type.render,a.ref,Kt);break;case 5:Cf(a);default:c0(o,a),a=Vt=Ip(a,da),a=l0(o,a,da)}r.memoizedProps=r.pendingProps,a===null?ad(r):Vt=a}function dl(r,a,o,m){ea=hi=null,Cf(a),Ji=null,Ql=0;var v=a.return;try{if(r2(r,v,a,o,Kt)){Un=1,Yc(r,os(o,r.current)),Vt=null;return}}catch(j){if(v!==null)throw Vt=v,j;Un=1,Yc(r,os(o,r.current)),Vt=null;return}a.flags&32768?(Qt||m===1?r=!0:il||(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))),B0(a,r)):ad(a)}function ad(r){var a=r;do{if((a.flags&32768)!==0){B0(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);Un===0&&(Un=5)}function B0(r,a){do{var o=l2(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);Un=6,Vt=null}function H0(r,a,o,m,v,j,U,Q,le){r.cancelPendingCommit=null;do id();while(or!==0);if((cn&6)!==0)throw Error(i(327));if(a!==null){if(a===r.current)throw Error(i(177));if(j=a.lanes|a.childLanes,j|=Qu,dr(r,o,j,U,Q,le),r===En&&(Vt=En=null,Kt=0),ol=a,Ha=r,ua=o,lm=j,om=v,A0=m,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,y2(Fe,function(){return V0(),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{o2(r,a,o)}finally{cn=U,V.p=v,O.T=m}}or=1,P0(),U0(),q0()}}function P0(){if(or===1){or=0;var r=Ha,a=ol,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{j0(a,r);var j=Nm,U=Ep(r.containerInfo),Q=j.focusedElem,le=j.selectionRange;if(U!==Q&&Q&&Q.ownerDocument&&Cp(Q.ownerDocument.documentElement,Q)){if(le!==null&&Gu(Q)){var be=le.start,Ae=le.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(le.start,rt),Nn=le.end===void 0?Nt:Math.min(le.end,rt);!we.extend&&Nt>Nn&&(U=Nn,Nn=Nt,Nt=U);var he=Sp(Q,Nt),ce=Sp(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}}bd=!!wm,Nm=wm=null}finally{cn=v,V.p=m,O.T=o}}r.current=a,or=2}}function U0(){if(or===2){or=0;var r=Ha,a=ol,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{p0(r,a.alternate,a)}finally{cn=v,V.p=m,O.T=o}}or=3}}function q0(){if(or===4||or===3){or=0,We();var r=Ha,a=ol,o=ua,m=A0;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?or=5:(or=0,ol=Ha=null,F0(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&&id(),Bs(r),v=r.pendingLanes,(o&261930)!==0&&(v&42)!==0?r===cm?po++:(po=0,cm=r):po=0,go(0)}}function F0(r,a){(r.pooledCacheLanes&=a)===0&&(a=r.pooledCache,a!=null&&(r.pooledCache=null,Wl(a)))}function id(){return P0(),U0(),q0(),V0()}function V0(){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=om,om=null;var j=Ha,U=ua;if(or=0,ol=Ha=null,ua=0,(cn&6)!==0)throw Error(i(331));var Q=cn;if(cn|=4,C0(j.current),N0(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,F0(r,a)}}function Y0(r,a,o){a=os(o,a),a=Pf(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)Y0(r,r,o);else for(;a!==null;){if(a.tag===3){Y0(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=Gg(2),m=Oa(a,o,2),m!==null&&(Xg(o,m,a,r),Mn(m,2),Bs(m));break}}a=a.return}}function fm(r,a,o){var m=r.pingCache;if(m===null){m=r.pingCache=new u2;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)||(sm=!0,v.add(o),r=p2.bind(null,r,a,o),a.then(r,r))}function p2(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&&(Un===4||Un===3&&(Kt&62914560)===Kt&&300>kt()-ed?(cn&2)===0&&cl(r,0):am|=o,ll===Kt&&(ll=0)),Bs(r)}function G0(r,a){a===0&&(a=kn()),r=ui(r,a),r!==null&&(Mn(r,a),Bs(r))}function g2(r){var a=r.memoizedState,o=0;a!==null&&(o=a.retryLane),G0(r,o)}function b2(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(i(314))}m!==null&&m.delete(a),G0(r,o)}function y2(r,a){return Pt(r,a)}var ld=null,ul=null,mm=!1,od=!1,hm=!1,Ua=0;function Bs(r){r!==ul&&r.next===null&&(ul===null?ld=ul=r:ul=ul.next=r),od=!0,mm||(mm=!0,j2())}function go(r,a){if(!hm&&od){hm=!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,Z0(m,j))}else j=Kt,j=lt(m,m===En?j:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(j&3)===0||Et(m,j)||(o=!0,Z0(m,j));m=m.next}while(o);hm=!1}}function v2(){X0()}function X0(){od=mm=!1;var r=0;Ua!==0&&M2()&&(r=Ua);for(var a=kt(),o=null,m=ld;m!==null;){var v=m.next,j=K0(m,a);j===0?(m.next=null,o===null?ld=v:o.next=v,v===null&&(ul=o)):(o=m,(r!==0||(j&3)!==0)&&(od=!0)),m=v}or!==0&&or!==5||go(r),Ua!==0&&(Ua=0)}function K0(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,le=v[U];le===-1?((Q&o)===0||(Q&m)!==0)&&(v[U]=It(Q,a)):le<=a&&(r.expiredLanes|=Q),j&=~Q}if(a=En,o=Kt,o=lt(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&&ie(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&&ie(m),Ie(o)){case 2:case 8:o=Se;break;case 32:o=Fe;break;case 268435456:o=ut;break;default:o=Fe}return m=W0.bind(null,r),o=Pt(o,m),r.callbackPriority=a,r.callbackNode=o,a}return m!==null&&m!==null&&ie(m),r.callbackPriority=2,r.callbackNode=null,2}function W0(r,a){if(or!==0&&or!==5)return r.callbackNode=null,r.callbackPriority=0,null;var o=r.callbackNode;if(id()&&r.callbackNode!==o)return null;var m=Kt;return m=lt(r,r===En?m:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),m===0?null:(M0(r,m,a),K0(r,kt()),r.callbackNode!=null&&r.callbackNode===o?W0.bind(null,r):null)}function Z0(r,a){if(id())return null;M0(r,a,!0)}function j2(){O2(function(){(cn&6)!==0?Pt(xe,v2):X0()})}function xm(){if(Ua===0){var r=Wi;r===0&&(r=Bn,Bn<<=1,(Bn&261888)===0&&(Bn=256)),Ua=r}return Ua}function Q0(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Le(""+r)}function J0(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 w2(r,a,o,m,v){if(a==="submit"&&o&&o.stateNode===v){var j=Q0((v[Ve]||null).action),U=m.submitter;U&&(a=(a=U[Ve]||null)?Q0(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 le=U?J0(v,U):new FormData(v);Lf(o,{pending:!0,data:le,method:v.method,action:j},null,le)}}else typeof j=="function"&&(Q.preventDefault(),le=U?J0(v,U):new FormData(v),Lf(o,{pending:!0,data:le,method:v.method,action:j},j,le))},currentTarget:v}]})}}for(var pm=0;pm<Zu.length;pm++){var gm=Zu[pm],N2=gm.toLowerCase(),k2=gm[0].toUpperCase()+gm.slice(1);Ns(N2,"on"+k2)}Ns(_p,"onAnimationEnd"),Ns(Mp,"onAnimationIteration"),Ns(Rp,"onAnimationStart"),Ns("dblclick","onDoubleClick"),Ns("focusin","onFocus"),Ns("focusout","onBlur"),Ns(H5,"onTransitionRun"),Ns(P5,"onTransitionStart"),Ns(U5,"onTransitionCancel"),Ns(Op,"onTransitionEnd"),Or("onMouseEnter",["mouseout","mouseover"]),Or("onMouseLeave",["mouseout","mouseover"]),Or("onPointerEnter",["pointerout","pointerover"]),Or("onPointerLeave",["pointerout","pointerover"]),ir("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ir("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ir("onBeforeInput",["compositionend","keypress","textInput","paste"]),ir("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ir("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ir("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(" "),S2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bo));function eb(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],le=Q.instance,be=Q.currentTarget;if(Q=Q.listener,le!==j&&v.isPropagationStopped())break e;j=Q,v.currentTarget=be;try{j(v)}catch(Ae){Nc(Ae)}v.currentTarget=null,j=le}else for(U=0;U<m.length;U++){if(Q=m[U],le=Q.instance,be=Q.currentTarget,Q=Q.listener,le!==j&&v.isPropagationStopped())break e;j=Q,v.currentTarget=be;try{j(v)}catch(Ae){Nc(Ae)}v.currentTarget=null,j=le}}}}function Yt(r,a){var o=a[ot];o===void 0&&(o=a[ot]=new Set);var m=r+"__bubble";o.has(m)||(tb(a,r,2,!1),o.add(m))}function bm(r,a,o){var m=0;a&&(m|=4),tb(o,r,m,a)}var cd="_reactListening"+Math.random().toString(36).slice(2);function ym(r){if(!r[cd]){r[cd]=!0,ss.forEach(function(o){o!=="selectionchange"&&(S2.has(o)||bm(o,!1,r),bm(o,!0,r))});var a=r.nodeType===9?r:r.ownerDocument;a===null||a[cd]||(a[cd]=!0,bm("selectionchange",!1,a))}}function tb(r,a,o,m){switch(_b(a)){case 2:var v=J2;break;case 8:v=ek;break;default:v=Dm}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 vm(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 le=U.tag;if((le===3||le===4)&&U.stateNode.containerInfo===v)return;U=U.return}for(;Q!==null;){if(U=Ot(Q),U===null)return;if(le=U.tag,le===5||le===6||le===26||le===27){m=j=U;continue e}Q=Q.parentNode}}m=m.return}yr(function(){var be=j,Ae=en(o),De=[];e:{var je=Dp.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=b5;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=oi;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=j5;break;case _p:case Mp:case Rp:we=xt;break;case Op:we=N5;break;case"scroll":case"scrollend":we=tn;break;case"wheel":we=S5;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=up;break;case"toggle":case"beforetoggle":we=E5}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=oi,_e="onMouseLeave",he="onMouseEnter",ce="mouse",(r==="pointerout"||r==="pointerover")&&(Nt=up,_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=C2,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&&nb(De,je,we,Nt,!1),rt!==null&&Nn!==null&&nb(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=yp;else if(gp(je))if(vp)sn=z5;else{sn=L5;var ct=D5}else we=je.nodeName,!we||we.toLowerCase()!=="input"||je.type!=="checkbox"&&je.type!=="radio"?be&&Zs(be.elementType)&&(sn=yp):sn=I5;if(sn&&(sn=sn(r,be))){bp(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":(gp(ct)||ct.contentEditable==="true")&&(Ui=ct,Xu=be,Gl=null);break;case"focusout":Gl=Xu=Ui=null;break;case"mousedown":Ku=!0;break;case"contextmenu":case"mouseup":case"dragend":Ku=!1,Tp(De,o,Ae);break;case"selectionchange":if(B5)break;case"keydown":case"keyup":Tp(De,o,Ae)}var Bt;if(Fu)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 Pi?xp(r,o)&&(Wt="onCompositionEnd"):r==="keydown"&&o.keyCode===229&&(Wt="onCompositionStart");Wt&&(fp&&o.locale!=="ko"&&(Pi||Wt!=="onCompositionStart"?Wt==="onCompositionEnd"&&Pi&&(Bt=Ke()):(ee=Ae,Ne="value"in ee?ee.value:ee.textContent,Pi=!0)),ct=dd(be,Wt),0<ct.length&&(Wt=new Cn(Wt,r,null,o,Ae),De.push({event:Wt,listeners:ct}),Bt?Wt.data=Bt:(Bt=pp(o),Bt!==null&&(Wt.data=Bt)))),(Bt=A5?_5(r,o):M5(r,o))&&(Wt=dd(be,"onBeforeInput"),0<Wt.length&&(ct=new Cn("onBeforeInput","beforeinput",null,o,Ae),De.push({event:ct,listeners:Wt}),ct.data=Bt)),w2(De,r,be,o,Ae)}eb(De,a)})}function yo(r,a,o){return{instance:r,listener:a,currentTarget:o}}function dd(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 C2(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function nb(r,a,o,m,v){for(var j=a._reactName,U=[];o!==null&&o!==m;){var Q=o,le=Q.alternate,be=Q.stateNode;if(Q=Q.tag,le!==null&&le===m)break;Q!==5&&Q!==26&&Q!==27||be===null||(le=be,v?(be=vr(o,j),be!=null&&U.unshift(yo(o,be,le))):v||(be=vr(o,j),be!=null&&U.push(yo(o,be,le)))),o=o.return}U.length!==0&&r.push({event:a,listeners:U})}var E2=/\r\n?/g,T2=/\u0000|\uFFFD/g;function rb(r){return(typeof r=="string"?r:""+r).replace(E2,`
|
|
9
|
+
`).replace(T2,"")}function sb(r,a){return a=rb(a),rb(r)===a}function wn(r,a,o,m,v,j){switch(o){case"children":typeof m=="string"?a==="body"||a==="textarea"&&m===""||lr(r,m):(typeof m=="number"||typeof m=="bigint")&&a!=="body"&&lr(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":is(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(i(61));if(o=m.__html,o!=null){if(v.children!=null)throw Error(i(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 jm(r,a,o,m,v,j){switch(o){case"style":is(r,m,j);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(i(61));if(o=m.__html,o!=null){if(v.children!=null)throw Error(i(60));r.innerHTML=o}}break;case"children":typeof m=="string"?lr(r,m):(typeof m=="number"||typeof m=="bigint")&&lr(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(i(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,le=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":le=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(i(137,a));break;default:wn(r,a,m,Ae,o,null)}}Ls(r,j,Q,le,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(i(91));break;default:wn(r,a,U,Q,o,null)}Hi(r,m,v,j);return;case"option":for(le in o)o.hasOwnProperty(le)&&(m=o[le],m!=null)&&(le==="selected"?r.selected=m&&typeof m!="function"&&typeof m!="symbol":wn(r,a,le,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(i(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&&jm(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 A2(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,le=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":le=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(i(137,a));break;default:we!==De&&wn(r,a,je,we,m,De)}}mr(r,U,Q,le,be,Ae,j,v);return;case"select":we=U=Q=je=null;for(j in o)if(le=o[j],o.hasOwnProperty(j)&&le!=null)switch(j){case"value":break;case"multiple":we=le;default:m.hasOwnProperty(j)||wn(r,a,j,null,m,le)}for(v in m)if(j=m[v],le=o[v],m.hasOwnProperty(v)&&(j!=null||le!=null))switch(v){case"value":je=j;break;case"defaultValue":Q=j;break;case"multiple":U=j;default:j!==le&&wn(r,a,v,j,m,le)}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(i(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(le in m)je=m[le],we=o[le],m.hasOwnProperty(le)&&je!==we&&(je!=null||we!=null)&&(le==="selected"?r.selected=je&&typeof je!="function"&&typeof je!="symbol":wn(r,a,le,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(i(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)&&jm(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||jm(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 ab(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function _2(){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&&ab(U)){for(U=0,Q=v.responseEnd,m+=1;m<o.length;m++){var le=o[m],be=le.startTime;if(be>Q)break;var Ae=le.transferSize,De=le.initiatorType;Ae&&ab(De)&&(le=le.responseEnd,U+=Ae*(le<Q?1:(Q-be)/(le-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 wm=null,Nm=null;function ud(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 lb(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 km(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 Sm=null;function M2(){var r=window.event;return r&&r.type==="popstate"?r===Sm?!1:(Sm=r,!0):(Sm=null,!1)}var ob=typeof setTimeout=="function"?setTimeout:void 0,R2=typeof clearTimeout=="function"?clearTimeout:void 0,cb=typeof Promise=="function"?Promise:void 0,O2=typeof queueMicrotask=="function"?queueMicrotask:typeof cb<"u"?function(r){return cb.resolve(null).then(r).catch(D2)}:ob;function D2(r){setTimeout(function(){throw r})}function qa(r){return r==="head"}function db(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),xl(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);xl(a)}function ub(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 Cm(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":Cm(o),Kn(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}r.removeChild(o)}}function L2(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 I2(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 fb(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 Em(r){return r.data==="$?"||r.data==="$~"}function Tm(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function z2(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 Am=null;function mb(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 hb(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 xb(r,a,o){switch(a=ud(o),r){case"html":if(r=a.documentElement,!r)throw Error(i(452));return r;case"head":if(r=a.head,!r)throw Error(i(453));return r;case"body":if(r=a.body,!r)throw Error(i(454));return r;default:throw Error(i(451))}}function vo(r){for(var a=r.attributes;a.length;)r.removeAttributeNode(a[0]);Kn(r)}var hs=new Map,pb=new Set;function fd(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var fa=V.d;V.d={f:$2,r:B2,D:H2,C:P2,L:U2,m:q2,X:V2,S:F2,M:Y2};function $2(){var r=fa.f(),a=rd();return r||a}function B2(r){var a=pr(r);a!==null&&a.tag===5&&a.type==="form"?Og(a):fa.r(r)}var fl=typeof document>"u"?null:document;function gb(r,a,o){var m=fl;if(m&&typeof a=="string"&&a){var v=Hn(a);v='link[rel="'+r+'"][href="'+v+'"]',typeof o=="string"&&(v+='[crossorigin="'+o+'"]'),pb.has(v)||(pb.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 H2(r){fa.D(r),gb("dns-prefetch",r,null)}function P2(r,a){fa.C(r,a),gb("preconnect",r,a)}function U2(r,a,o){fa.L(r,a,o);var m=fl;if(m&&r&&a){var v='link[rel="preload"][as="'+Hn(a)+'"]';a==="image"&&o&&o.imageSrcSet?(v+='[imagesrcset="'+Hn(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(v+='[imagesizes="'+Hn(o.imageSizes)+'"]')):v+='[href="'+Hn(r)+'"]';var j=v;switch(a){case"style":j=ml(r);break;case"script":j=hl(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 q2(r,a){fa.m(r,a);var o=fl;if(o&&r){var m=a&&typeof a.as=="string"?a.as:"script",v='link[rel="modulepreload"][as="'+Hn(m)+'"][href="'+Hn(r)+'"]',j=v;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=hl(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 F2(r,a,o){fa.S(r,a,o);var m=fl;if(m&&r){var v=hn(m).hoistableStyles,j=ml(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))&&_m(r,o);var le=U=m.createElement("link");ln(le),Sr(le,"link",r),le._p=new Promise(function(be,Ae){le.onload=be,le.onerror=Ae}),le.addEventListener("load",function(){Q.loading|=1}),le.addEventListener("error",function(){Q.loading|=2}),Q.loading|=4,md(U,a,m)}U={type:"stylesheet",instance:U,count:1,state:Q},v.set(j,U)}}}function V2(r,a){fa.X(r,a);var o=fl;if(o&&r){var m=hn(o).hoistableScripts,v=hl(r),j=m.get(v);j||(j=o.querySelector(wo(v)),j||(r=p({src:r,async:!0},a),(a=hs.get(v))&&Mm(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 Y2(r,a){fa.M(r,a);var o=fl;if(o&&r){var m=hn(o).hoistableScripts,v=hl(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))&&Mm(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 bb(r,a,o,m){var v=(v=W.current)?fd(v):null;if(!v)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(a=ml(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=ml(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||G2(v,r,o,U.state))),a&&m===null)throw Error(i(528,""));return U}if(a&&m!==null)throw Error(i(529,""));return null;case"script":return a=o.async,o=o.src,typeof o=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=hl(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(i(444,r))}}function ml(r){return'href="'+Hn(r)+'"'}function jo(r){return'link[rel="stylesheet"]['+r+"]"}function yb(r){return p({},r,{"data-precedence":r.precedence,precedence:null})}function G2(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 hl(r){return'[src="'+Hn(r)+'"]'}function wo(r){return"script[async]"+r}function vb(r,a,o){if(a.count++,a.instance===null)switch(a.type){case"style":var m=r.querySelector('style[data-href~="'+Hn(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),md(m,o.precedence,r),a.instance=m;case"stylesheet":v=ml(o.href);var j=r.querySelector(jo(v));if(j)return a.state.loading|=4,a.instance=j,ln(j),j;m=yb(o),(v=hs.get(v))&&_m(m,v),j=(r.ownerDocument||r).createElement("link"),ln(j);var U=j;return U._p=new Promise(function(Q,le){U.onload=Q,U.onerror=le}),Sr(j,"link",m),a.state.loading|=4,md(j,o.precedence,r),a.instance=j;case"script":return j=hl(o.src),(v=r.querySelector(wo(j)))?(a.instance=v,ln(v),v):(m=o,(v=hs.get(j))&&(m=p({},o),Mm(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(i(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(m=a.instance,a.state.loading|=4,md(m,o.precedence,r));return a.instance}function md(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 _m(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.title==null&&(r.title=a.title)}function Mm(r,a){r.crossOrigin==null&&(r.crossOrigin=a.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=a.referrerPolicy),r.integrity==null&&(r.integrity=a.integrity)}var hd=null;function jb(r,a,o){if(hd===null){var m=new Map,v=hd=new Map;v.set(o,m)}else v=hd,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 wb(r,a,o){r=r.ownerDocument||r,r.head.insertBefore(o,a==="title"?r.querySelector("head > title"):null)}function X2(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 Nb(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function K2(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=ml(m.href),j=a.querySelector(jo(v));if(j){a=j._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(r.count++,r=xd.bind(r),a.then(r,r)),o.state.loading|=4,o.instance=j,ln(j);return}j=a.ownerDocument||a,m=yb(m),(v=hs.get(v))&&_m(m,v),j=j.createElement("link"),ln(j);var U=j;U._p=new Promise(function(Q,le){U.onload=Q,U.onerror=le}),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=xd.bind(r),a.addEventListener("load",o),a.addEventListener("error",o))}}var Rm=0;function W2(r,a){return r.stylesheets&&r.count===0&&gd(r,r.stylesheets),0<r.count||0<r.imgCount?function(o){var m=setTimeout(function(){if(r.stylesheets&&gd(r,r.stylesheets),r.unsuspend){var j=r.unsuspend;r.unsuspend=null,j()}},6e4+a);0<r.imgBytes&&Rm===0&&(Rm=62500*_2());var v=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&gd(r,r.stylesheets),r.unsuspend)){var j=r.unsuspend;r.unsuspend=null,j()}},(r.imgBytes>Rm?50:800)+a);return r.unsuspend=o,function(){r.unsuspend=null,clearTimeout(m),clearTimeout(v)}}:null}function xd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)gd(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var pd=null;function gd(r,a){r.stylesheets=null,r.unsuspend!==null&&(r.count++,pd=new Map,a.forEach(Z2,r),pd=null,xd.call(r))}function Z2(r,a){if(!(a.state.loading&4)){var o=pd.get(r);if(o)var m=o.get(null);else{o=new Map,pd.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=xd.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 Q2(r,a,o,m,v,j,U,Q,le){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=_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=le,this.incompleteTransitions=new Map}function kb(r,a,o,m,v,j,U,Q,le,be,Ae,De){return r=new Q2(r,a,o,U,le,be,Ae,De,Q),a=1,j===!0&&(a|=24),j=Xr(3,null,null,a),r.current=j,j.stateNode=r,a=uf(),a.refCount++,r.pooledCache=a,a.refCount++,j.memoizedState={element:m,isDehydrated:o,cache:a},xf(j),r}function Sb(r){return r?(r=Vi,r):Vi}function Cb(r,a,o,m,v,j){v=Sb(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 Eb(r,a){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var o=r.retryLane;r.retryLane=o!==0&&o<a?o:a}}function Om(r,a){Eb(r,a),(r=r.alternate)&&Eb(r,a)}function Tb(r){if(r.tag===13||r.tag===31){var a=ui(r,67108864);a!==null&&Pr(a,r,67108864),Om(r,67108864)}}function Ab(r){if(r.tag===13||r.tag===31){var a=Jr();a=ae(a);var o=ui(r,a);o!==null&&Pr(o,r,a),Om(r,a)}}var bd=!0;function J2(r,a,o,m){var v=O.T;O.T=null;var j=V.p;try{V.p=2,Dm(r,a,o,m)}finally{V.p=j,O.T=v}}function ek(r,a,o,m){var v=O.T;O.T=null;var j=V.p;try{V.p=8,Dm(r,a,o,m)}finally{V.p=j,O.T=v}}function Dm(r,a,o,m){if(bd){var v=Lm(m);if(v===null)vm(r,a,m,yd,o),Mb(r,m);else if(nk(v,r,a,o,m))m.stopPropagation();else if(Mb(r,m),a&4&&-1<tk.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 le=1<<31-yt(U);Q.entanglements[1]|=le,U&=~le}Bs(j),(cn&6)===0&&(td=kt()+500,go(0))}}break;case 31:case 13:Q=ui(j,2),Q!==null&&Pr(Q,j,2),rd(),Om(j,2)}if(j=Lm(m),j===null&&vm(r,a,m,yd,o),j===v)break;v=j}v!==null&&m.stopPropagation()}else vm(r,a,m,null,o)}}function Lm(r){return r=en(r),Im(r)}var yd=null;function Im(r){if(yd=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 yd=r,null}function _b(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 Se:return 8;case Fe:case it:return 32;case ut:return 268435456;default:return 32}default:return 32}}var zm=!1,Fa=null,Va=null,Ya=null,ko=new Map,So=new Map,Ga=[],tk="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 Mb(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&&Tb(a)),r):(r.eventSystemFlags|=m,a=r.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),r)}function nk(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 Rb(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(){Ab(o)});return}}else if(a===31){if(a=u(o),a!==null){r.blockedOn=a,Qe(r.priority,function(){Ab(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 vd(r){if(r.blockedOn!==null)return!1;for(var a=r.targetContainers;0<a.length;){var o=Lm(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&&Tb(a),r.blockedOn=o,!1;a.shift()}return!0}function Ob(r,a,o){vd(r)&&o.delete(a)}function rk(){zm=!1,Fa!==null&&vd(Fa)&&(Fa=null),Va!==null&&vd(Va)&&(Va=null),Ya!==null&&vd(Ya)&&(Ya=null),ko.forEach(Ob),So.forEach(Ob)}function jd(r,a){r.blockedOn===a&&(r.blockedOn=null,zm||(zm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,rk)))}var wd=null;function Db(r){wd!==r&&(wd=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){wd===r&&(wd=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(Im(m||o)===null)continue;break}var j=pr(o);j!==null&&(r.splice(a,3),a-=3,Lf(j,{pending:!0,data:v,method:o.method,action:m},m,v))}}))}function xl(r){function a(le){return jd(le,r)}Fa!==null&&jd(Fa,r),Va!==null&&jd(Va,r),Ya!==null&&jd(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);)Rb(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||Db(o);else if(U){var Q=null;if(j&&j.hasAttribute("formAction")){if(v=j,U=j[Ve]||null)Q=U.formAction;else if(Im(v)!==null)continue}else Q=U.action;typeof Q=="function"?o[m+1]=Q:(o.splice(m,3),m-=3),Db(o)}}}function Lb(){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 $m(r){this._internalRoot=r}Nd.prototype.render=$m.prototype.render=function(r){var a=this._internalRoot;if(a===null)throw Error(i(409));var o=a.current,m=Jr();Cb(o,m,r,a,null,null)},Nd.prototype.unmount=$m.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var a=r.containerInfo;Cb(r.current,2,null,r,null,null),rd(),a[tt]=null}};function Nd(r){this._internalRoot=r}Nd.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&&Rb(r)}};var Ib=n.version;if(Ib!=="19.2.4")throw Error(i(527,Ib,"19.2.4"));V.findDOMNode=function(r){var a=r._reactInternals;if(a===void 0)throw typeof r.render=="function"?Error(i(188)):(r=Object.keys(r).join(","),Error(i(268,r)));return r=f(a),r=r!==null?x(r):null,r=r===null?null:r.stateNode,r};var sk={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var kd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!kd.isDisabled&&kd.supportsFiber)try{Ut=kd.inject(sk),St=kd}catch{}}return To.createRoot=function(r,a){if(!l(r))throw Error(i(299));var o=!1,m="",v=qg,j=Fg,U=Vg;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=kb(r,1,!1,null,null,o,m,null,v,j,U,Lb),r[tt]=a.current,ym(r),new $m(a)},To.hydrateRoot=function(r,a,o){if(!l(r))throw Error(i(299));var m=!1,v="",j=qg,U=Fg,Q=Vg,le=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&&(le=o.formState)),a=kb(r,1,!0,a,o??null,m,v,le,j,U,Q,Lb),a.context=Sb(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,ym(r),new Nd(a)},To.version="19.2.4",To}var Yb;function hk(){if(Yb)return Pm.exports;Yb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Pm.exports=mk(),Pm.exports}var xk=hk();const ge={HOME:"home",TEAM:"team",WORK:"work",STORE:"store",BUILDER:"builder",DELIVERABLES:"deliverables",REPORTS:"reports",SETTINGS:"settings"},pk=new Set(Object.values(ge)),gk={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 pk.has(e)?e:gk[e]??ge.HOME}function Sd(){const e=window.location.hash.slice(1).split("/")[0];return ba(e)}function Lh(e,n){return n?`#${e}/${n}`:`#${e}`}const bk={[ge.STORE]:ge.BUILDER,[ge.REPORTS]:ge.SETTINGS},wl={[ge.HOME]:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z M9 22V12h6v10",[ge.WORK]:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",[ge.TEAM]:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",[ge.REPORTS]:"M18 20V10 M12 20V4 M6 20v-6",[ge.DELIVERABLES]:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20 M4 19.5A2.5 2.5 0 0 0 6.5 22H20V2H6.5A2.5 2.5 0 0 0 4 4.5v15z",[ge.BUILDER]:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",[ge.STORE]:"M6 2L3 7v13a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-3-5z M3 7h18 M16 11a4 4 0 0 1-8 0",[ge.SETTINGS]:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"},yk=[{key:"workspace",label:"WORKSPACE"},{key:"build",label:"BUILD"},{key:"system",label:"SYSTEM"}],vk=[{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"}],jk=[{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]}],Z1="/api";async function fe(e,n){const s=await fetch(`${Z1}${e}`,{headers:{"Content-Type":"application/json"},credentials:"include",...n,body:n?.body?typeof n.body=="string"?n.body:JSON.stringify(n.body):void 0});if(!s.ok){let i="";try{const l=await s.json();i=l.error??l.message??""}catch{}throw new Error(i||`API error: ${s.status}`)}return s.json()}const se={agents:{list:()=>fe("/agents").then(e=>({...e,agents:e.agents.filter(n=>n.name)})),get:e=>fe(`/agents/${e}`),create:(e,n,s,i)=>fe("/agents",{method:"POST",body:JSON.stringify({name:e,roleName:n,agentRole:s,teamId:i})}),start:e=>fe(`/agents/${e}/start`,{method:"POST"}),stop:e=>fe(`/agents/${e}/stop`,{method:"POST"}),remove:(e,n)=>fe(`/agents/${e}${n?.purgeFiles?"?purgeFiles=true":""}`,{method:"DELETE"}),updateConfig:(e,n)=>fe(`/agents/${e}/config`,{method:"PATCH",body:JSON.stringify(n)}),getMemory:e=>fe(`/agents/${e}/memory`),getMemorySession:(e,n)=>fe(`/agents/${e}/memory/sessions/${encodeURIComponent(n)}`),updateDailyMemory:(e,n)=>fe(`/agents/${e}/memory/daily`,{method:"PUT",body:JSON.stringify({content:n})}),updateLongTermMemory:(e,n,s)=>fe(`/agents/${e}/memory/longterm`,{method:"PUT",body:JSON.stringify({key:n,content:s})}),getFiles:e=>fe(`/agents/${e}/files`),getFilesMap:e=>fe(`/agents/${e}/files`),updateFile:(e,n,s)=>fe(`/agents/${e}/files/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify({content:s})}),updateSystemPrompt:(e,n)=>fe(`/agents/${e}/system-prompt`,{method:"PUT",body:JSON.stringify({systemPrompt:n})}),roleStatus:e=>fe(`/agents/${e}/role-status`),roleDiff:(e,n="ROLE.md")=>fe(`/agents/${e}/role-diff?file=${encodeURIComponent(n)}`),roleSync:(e,n)=>fe(`/agents/${e}/role-sync`,{method:"POST",body:JSON.stringify(n?{files:n}:{})}),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 i=s.toString();return fe(`/agents/${e}/activities${i?"?"+i:""}`)},getMindState:e=>fe(`/agents/${e}/mind`),getMailbox:(e,n)=>{const s=new URLSearchParams;n?.limit&&s.set("limit",String(n.limit)),n?.offset&&s.set("offset",String(n.offset)),n?.category&&s.set("category",n.category),n?.sourceType&&s.set("sourceType",n.sourceType),n?.status&&s.set("status",n.status);const i=s.toString();return fe(`/agents/${e}/mailbox${i?"?"+i:""}`)},getDecisions:(e,n=50)=>fe(`/agents/${e}/decisions?limit=${n}`),message:(e,n,s,i,l)=>fe(`/agents/${e}/message`,{method:"POST",body:JSON.stringify({text:n,images:s,fileNames:l,sessionId:i??void 0})}),messageStream:(e,n,s,i,l,c,d,u,h,f,x)=>new Promise(async(p,g)=>{let b="",w;try{const k=await fetch(`${Z1}/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:l});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?i?.({tool:q.toolCall.name,phase:"start"}):q.type==="agent_tool"&&q.tool&&q.phase?q.phase==="start"?i?.({tool:q.tool,phase:"start",arguments:q.arguments}):q.phase==="end"&&i?.({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?i?.({tool:q.tool,phase:"output",output:q.text}):q.type==="subagent_progress"&&q.tool&&i?.({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,i,l,c,d,u,h,f)=>fe("/tasks",{method:"POST",body:JSON.stringify({title:e,description:n,assignedAgentId:s,reviewerAgentId:i,priority:l,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,i,l,c,d)=>fe(`/tasks/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:l??"human",authorName:s??"User",authorType:"human",attachments:i,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,i,l,c)=>fe(`/requirements/${e}/comments`,{method:"POST",body:JSON.stringify({content:n,authorId:i??"human",authorName:s??"User",authorType:"human",mentions:l,replyTo:c})})},users:{list:e=>fe(`/users?orgId=${e??"default"}`),create:(e,n,s,i,l,c)=>fe("/users",{method:"POST",body:JSON.stringify({name:e,role:n,orgId:s,email:i,password:l,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,i)=>fe("/skills/import",{method:"POST",body:JSON.stringify({name:e,sourceUrl:n,description:s,category:i})}),install:e=>fe("/skills/install",{method:"POST",body:JSON.stringify(e)}),uninstall:e=>fe(`/skills/installed/${encodeURIComponent(e)}`,{method:"DELETE"}),getFilesMap:e=>fe(`/skills/${encodeURIComponent(e)}/files`)},builder:{artifacts:{list:()=>fe("/builder/artifacts"),get:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`),save:(e,n)=>fe("/builder/artifacts/save",{method:"POST",body:JSON.stringify({mode:e,artifact:n})}),import:(e,n,s,i)=>fe("/builder/artifacts/import",{method:"POST",body:JSON.stringify({type:e,name:n,files:s,source:i})}),install:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/install`,{method:"POST"}),uninstall:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}/uninstall`,{method:"POST"}),delete:(e,n)=>fe(`/builder/artifacts/${e}s/${encodeURIComponent(n)}`,{method:"DELETE"}),installed:()=>fe("/builder/artifacts/installed")}},auth:{login:(e,n)=>fe("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})}),logout:()=>fe("/auth/logout",{method:"POST"}),me:()=>fe("/auth/me"),changePassword:(e,n)=>fe("/auth/change-password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:n})}),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,i,l)=>fe(`/approvals/${e}`,{method:"POST",body:JSON.stringify({approved:n,respondedBy:s,comment:i,selectedOption:l})})},notifications:{list:(e,n,s)=>{const i=new URLSearchParams;return e&&i.set("userId",e),n&&i.set("unread","true"),s?.type&&i.set("type",s.type),s?.limit&&i.set("limit",String(s.limit)),s?.offset&&i.set("offset",String(s.offset)),fe(`/notifications?${i}`)},markRead:e=>fe(`/notifications/${e}`,{method:"POST"}),markAllRead:e=>fe("/notifications/mark-all-read",{method:"POST",body:JSON.stringify({userId:e})})},projects:{list:e=>{const n=e?`?orgId=${e}`:"";return fe(`/projects${n}`)},get:e=>fe(`/projects/${e}`),create:e=>fe("/projects",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/projects/${e}`,{method:"PUT",body:JSON.stringify(n)}),delete:e=>fe(`/projects/${e}`,{method:"DELETE"})},knowledge:{search:(e,n,s)=>{const i=new URLSearchParams;return e&&i.set("query",e),n&&i.set("scope",n),s&&i.set("category",s),fe(`/knowledge/search?${i}`)},contribute:e=>fe("/knowledge",{method:"POST",body:JSON.stringify(e)}),flagOutdated:(e,n)=>fe(`/knowledge/${e}/flag-outdated`,{method:"POST",body:JSON.stringify({reason:n})}),verify:e=>fe(`/knowledge/${e}/verify`,{method:"POST",body:JSON.stringify({verifiedBy:"human"})}),remove:e=>fe(`/knowledge/${e}`,{method:"DELETE"})},deliverables:{search:e=>{const n=new URLSearchParams;return e?.q&&n.set("q",e.q),e?.projectId&&n.set("projectId",e.projectId),e?.agentId&&n.set("agentId",e.agentId),e?.taskId&&n.set("taskId",e.taskId),e?.type&&n.set("type",e.type),e?.status&&n.set("status",e.status),e?.artifactType&&n.set("artifactType",e.artifactType),e?.offset&&n.set("offset",String(e.offset)),e?.limit&&n.set("limit",String(e.limit)),fe(`/deliverables?${n}`)},create:e=>fe("/deliverables",{method:"POST",body:JSON.stringify(e)}),update:(e,n)=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify(n)}),remove:e=>fe(`/deliverables/${e}`,{method:"DELETE"}),verify:e=>fe(`/deliverables/${e}`,{method:"PUT",body:JSON.stringify({status:"verified"})})},codeReviews:{list:(e,n=20)=>{const s=new URLSearchParams;return e&&s.set("taskId",e),s.set("limit",String(n)),fe(`/reviews?${s}`)},get:e=>fe(`/reviews/${e}`),run:e=>fe("/reviews",{method:"POST",body:JSON.stringify(e)})},reports:{list:()=>fe("/reports"),get:e=>fe(`/reports/${e}`),generate:e=>fe("/reports/generate",{method:"POST",body:JSON.stringify(e)}),approvePlan:(e,n)=>fe(`/reports/${e}/plan/approve`,{method:"POST",body:JSON.stringify(n)}),rejectPlan:(e,n)=>fe(`/reports/${e}/plan/reject`,{method:"POST",body:JSON.stringify(n)}),addFeedback:(e,n)=>fe(`/reports/${e}/feedback`,{method:"POST",body:JSON.stringify(n)}),getFeedback:e=>fe(`/reports/${e}/feedback`)},executionLogs:{get:(e,n)=>fe(`/execution-logs?sourceType=${encodeURIComponent(e)}&sourceId=${encodeURIComponent(n)}`)}};function Ih(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 wk{ws=null;handlers=new Map;reconnectTimer=null;intentionalClose=!1;connect(){if(this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))return;this.intentionalClose=!1;const s=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`,i=new WebSocket(s);this.ws=i,i.onmessage=l=>{if(this.ws===i)try{const c=JSON.parse(l.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{}},i.onclose=()=>{this.intentionalClose||(this.reconnectTimer=setTimeout(()=>this.connect(),3e3))},i.onerror=()=>{i.close()}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}on(n,s){return this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n).add(s),()=>this.handlers.get(n)?.delete(s)}}const Zt=new wk;let Zo=window.__MARKUS_HUB_URL__??"https://markus.global";fe("/settings/hub").then(e=>{e.hubUrl&&(Zo=e.hubUrl);const n=localStorage.getItem("markus_hub_token");n&&fe("/settings/hub-token",{method:"POST",body:JSON.stringify({token:n})}).catch(()=>{})}).catch(()=>{});const Nx="markus_hub_token",kx="markus_hub_user";function ni(){return localStorage.getItem(Nx)}function Nk(){try{const e=localStorage.getItem(kx);return e?JSON.parse(e):null}catch{return null}}function J1(){localStorage.removeItem(Nx),localStorage.removeItem(kx),ej(null)}function zh(e,n){localStorage.setItem(Nx,e),localStorage.setItem(kx,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(ni())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 i=`${Zo}/auth/connect?session=${encodeURIComponent(e)}`,l=460,c=580,d=Math.round(window.screenX+(window.outerWidth-l)/2),u=Math.round(window.screenY+(window.outerHeight-c)/2),h=window.open(i,"markus_hub_auth",`popup=yes,width=${l},height=${c},left=${d},top=${u}`);let f=!1;const x=()=>{clearInterval(p),clearInterval(g),Ao=null},p=setInterval(async()=>{if(!f)try{const w=await(await fetch(`${Zo}/api/auth/connect-status?session=${encodeURIComponent(e)}`)).json();w.ready&&w.token&&w.user&&(f=!0,zh(w.token,w.user),x(),h?.close(),n())}catch{}},1500),g=setInterval(()=>{f||h?.closed&&(f=!0,x(),ni()?n():s(new Error("Hub login cancelled")))},500)}),Ao}async function xs(e,n){const s=ni(),i={"Content-Type":"application/json",...n?.headers};s&&(i.Authorization=`Bearer ${s}`);const l=await fetch(`${Zo}/api${e}`,{...n,headers:i}),c=await l.json();if(l.status===401&&s&&J1(),!l.ok)throw new Error(c.error??`Hub HTTP ${l.status}`);return c}const tr={getUrl:()=>Zo,isAuthenticated:()=>!!ni(),getUser:Nk,logout:()=>{J1()},ensureAuth:Ka,login:async(e,n)=>{const s=await xs("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:n})});return zh(s.token,s.user),s},register:async(e,n,s)=>{const i=await xs("/auth/register",{method:"POST",body:JSON.stringify({username:e,email:n,password:s})});return zh(i.token,i.user),i},search:e=>{const n=new URLSearchParams;e?.type&&n.set("type",e.type),e?.q&&n.set("q",e.q),e?.category&&n.set("category",e.category),e?.sort&&n.set("sort",e.sort),e?.page&&n.set("page",String(e.page)),e?.limit&&n.set("limit",String(e.limit));const s=n.toString();return 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(!ni())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(!ni())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(!ni())return await Ka(),xs("/items",{method:"POST",body:JSON.stringify(e)});throw n}},myItems:async()=>ni()?xs("/items/mine"):{items:[]},deleteItem:async e=>(await Ka(),xs(`/items/${e}`,{method:"DELETE"}))};let Gb=null;const bt={setHandler(e){Gb=e},navigate(e,n){n&&Object.entries(n).forEach(([s,i])=>localStorage.setItem(`markus_nav_${s}`,i)),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:e,params:n}})),Gb?.(e,n)}};var ju=W1();function kk(e,n){const s={};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}const Sk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ck=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ek={};function Xb(e,n){return(Ek.jsx?Ck:Sk).test(e)}const Tk=/[ \t\n\f\r]/g;function Ak(e){return typeof e=="object"?e.type==="text"?Kb(e.value):!1:Kb(e)}function Kb(e){return e.replace(Tk,"")===""}class mc{constructor(n,s,i){this.normal=s,this.property=n,i&&(this.space=i)}}mc.prototype.normal={};mc.prototype.property={};mc.prototype.space=void 0;function tj(e,n){const s={},i={};for(const l of e)Object.assign(s,l.property),Object.assign(i,l.normal);return new mc(s,i,n)}function $h(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 _k=0;const Ht=Bi(),er=Bi(),Bh=Bi(),Pe=Bi(),An=Bi(),Tl=Bi(),es=Bi();function Bi(){return 2**++_k}const Hh=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ht,booleanish:er,commaOrSpaceSeparated:es,commaSeparated:Tl,number:Pe,overloadedBoolean:Bh,spaceSeparated:An},Symbol.toStringTag,{value:"Module"})),Vm=Object.keys(Hh);class Sx extends Vr{constructor(n,s,i,l){let c=-1;if(super(n,s),Wb(this,"space",l),typeof i=="number")for(;++c<Vm.length;){const d=Vm[c];Wb(this,Vm[c],(i&Hh[d])===Hh[d])}}}Sx.prototype.defined=!0;function Wb(e,n,s){s&&(e[n]=s)}function Pl(e){const n={},s={};for(const[i,l]of Object.entries(e.properties)){const c=new Sx(i,e.transform(e.attributes||{},i),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(c.mustUseProperty=!0),n[i]=c,s[$h(i)]=i,s[$h(c.attribute)]=i}return new mc(n,s,e.space)}const nj=Pl({properties:{ariaActiveDescendant:null,ariaAtomic:er,ariaAutoComplete:null,ariaBusy:er,ariaChecked:er,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:An,ariaCurrent:null,ariaDescribedBy:An,ariaDetails:null,ariaDisabled:er,ariaDropEffect:An,ariaErrorMessage:null,ariaExpanded:er,ariaFlowTo:An,ariaGrabbed:er,ariaHasPopup:null,ariaHidden:er,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:An,ariaLevel:Pe,ariaLive:null,ariaModal:er,ariaMultiLine:er,ariaMultiSelectable:er,ariaOrientation:null,ariaOwns:An,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:er,ariaReadOnly:er,ariaRelevant:null,ariaRequired:er,ariaRoleDescription:An,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:er,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 rj(e,n){return n in e?e[n]:n}function sj(e,n){return rj(e,n.toLowerCase())}const Mk=Pl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Tl,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:er,controls:Ht,controlsList:An,coords:Pe|Tl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ht,defer:Ht,dir:null,dirName:null,disabled:Ht,download:Bh,draggable:er,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ht,formTarget:null,headers:An,height:Pe,hidden:Bh,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:er,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:er,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:er,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:sj}),Rk=Pl({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:Tl,g2:Tl,glyphName:Tl,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:rj}),aj=Pl({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=Pl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:sj}),lj=Pl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),Ok={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Dk=/[A-Z]/g,Zb=/-[a-z]/g,Lk=/^data[-\w.:]+$/i;function Ik(e,n){const s=$h(n);let i=n,l=Vr;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&Lk.test(n)){if(n.charAt(4)==="-"){const c=n.slice(5).replace(Zb,$k);i="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=n.slice(4);if(!Zb.test(c)){let d=c.replace(Dk,zk);d.charAt(0)!=="-"&&(d="-"+d),n="data"+d}}l=Sx}return new l(i,n)}function zk(e){return"-"+e.toLowerCase()}function $k(e){return e.charAt(1).toUpperCase()}const Bk=tj([nj,Mk,aj,ij,lj],"html"),Cx=tj([nj,Rk,aj,ij,lj],"svg");function Hk(e){return e.join(" ").trim()}var pl={},Ym,Qb;function Pk(){if(Qb)return Ym;Qb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,s=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\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(i);if(z){if(P(),!q(l))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 Ym=w,Ym}var Jb;function Uk(){if(Jb)return pl;Jb=1;var e=pl&&pl.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(pl,"__esModule",{value:!0}),pl.default=s;const n=e(Pk());function s(i,l){let c=null;if(!i||typeof i!="string")return c;const d=(0,n.default)(i),u=typeof l=="function";return d.forEach(h=>{if(h.type!=="declaration")return;const{property:f,value:x}=h;u?l(f,x,h):x&&(c=c||{},c[f]=x)}),c}return pl}var _o={},ey;function qk(){if(ey)return _o;ey=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,s=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(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(l,u):f=f.replace(i,u),f.replace(n,d))};return _o.camelCase=h,_o}var Mo,ty;function Fk(){if(ty)return Mo;ty=1;var e=Mo&&Mo.__importDefault||function(l){return l&&l.__esModule?l:{default:l}},n=e(Uk()),s=qk();function i(l,c){var d={};return!l||typeof l!="string"||(0,n.default)(l,function(u,h){u&&h&&(d[(0,s.camelCase)(u,c)]=h)}),d}return i.default=i,Mo=i,Mo}var Vk=Fk();const Yk=vu(Vk),oj=cj("end"),Ex=cj("start");function cj(e){return n;function n(s){const i=s&&s.position&&s.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function Gk(e){const n=Ex(e),s=oj(e);if(n&&s)return{start:n,end:s}}function Vo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ny(e.position):"start"in e||"end"in e?ny(e):"line"in e||"column"in e?Ph(e):""}function Ph(e){return ry(e&&e.line)+":"+ry(e&&e.column)}function ny(e){return Ph(e&&e.start)+"-"+Ph(e&&e.end)}function ry(e){return e&&typeof e=="number"?e:1}class Tr extends Error{constructor(n,s,i){super(),typeof s=="string"&&(i=s,s=void 0);let l="",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"?l=n:!c.cause&&n&&(d=!0,l=n.message,c.cause=n),!c.ruleId&&!c.source&&typeof i=="string"){const h=i.indexOf(":");h===-1?c.ruleId=i:(c.source=i.slice(0,h),c.ruleId=i.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=l,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 Tx={}.hasOwnProperty,Xk=new Map,Kk=/[A-Z]/g,Wk=new Set(["table","tbody","thead","tfoot","tr"]),Zk=new Set(["td","th"]),dj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Qk(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=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");i=aS(s,n.jsx,n.jsxs)}const l={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Cx:Bk,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},c=uj(l,e,void 0);return c&&typeof c!="string"?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}function uj(e,n,s){if(n.type==="element")return Jk(e,n,s);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return eS(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return nS(e,n,s);if(n.type==="mdxjsEsm")return tS(e,n);if(n.type==="root")return rS(e,n,s);if(n.type==="text")return sS(e,n)}function Jk(e,n,s){const i=e.schema;let l=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=Cx,e.schema=l),e.ancestors.push(n);const c=mj(e,n.tagName,!1),d=lS(e,n);let u=_x(e,n);return Wk.has(n.tagName)&&(u=u.filter(function(h){return typeof h=="string"?!Ak(h):!0})),fj(e,d,c,n),Ax(d,u),e.ancestors.pop(),e.schema=i,e.create(n,c,d,s)}function eS(e,n){if(n.data&&n.data.estree&&e.evaluater){const i=n.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Qo(e,n.position)}function tS(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Qo(e,n.position)}function nS(e,n,s){const i=e.schema;let l=i;n.name==="svg"&&i.space==="html"&&(l=Cx,e.schema=l),e.ancestors.push(n);const c=n.name===null?e.Fragment:mj(e,n.name,!0),d=oS(e,n),u=_x(e,n);return fj(e,d,c,n),Ax(d,u),e.ancestors.pop(),e.schema=i,e.create(n,c,d,s)}function rS(e,n,s){const i={};return Ax(i,_x(e,n)),e.create(n,e.Fragment,i,s)}function sS(e,n){return n.value}function fj(e,n,s,i){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(n.node=i)}function Ax(e,n){if(n.length>0){const s=n.length>1?n:n[0];s&&(e.children=s)}}function aS(e,n,s){return i;function i(l,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(i,l,c,d){const u=Array.isArray(c.children),h=Ex(i);return n(l,c,d,u,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function lS(e,n){const s={};let i,l;for(l in n.properties)if(l!=="children"&&Tx.call(n.properties,l)){const c=cS(e,l,n.properties[l]);if(c){const[d,u]=c;e.tableCellAlignToStyle&&d==="align"&&typeof u=="string"&&Zk.has(n.tagName)?i=u:s[d]=u}}if(i){const c=s.style||(s.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return s}function oS(e,n){const s={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const c=i.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 Qo(e,n.position);else{const l=i.name;let c;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const u=i.value.data.estree.body[0];u.type,c=e.evaluater.evaluateExpression(u.expression)}else Qo(e,n.position);else c=i.value===null?!0:i.value;s[l]=c}return s}function _x(e,n){const s=[];let i=-1;const l=e.passKeys?new Map:Xk;for(;++i<n.children.length;){const c=n.children[i];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=l.get(h)||0;d=h+"-"+f,l.set(h,f+1)}}const u=uj(e,c,d);u!==void 0&&s.push(u)}return s}function cS(e,n,s){const i=Ik(e.schema,n);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=i.commaSeparated?kk(s):Hk(s)),i.property==="style"){let l=typeof s=="object"?s:dS(e,String(s));return e.stylePropertyNameCase==="css"&&(l=uS(l)),["style",l]}return[e.elementAttributeNameCase==="react"&&i.space?Ok[i.property]||i.property:i.attribute,s]}}function dS(e,n){try{return Yk(n,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const i=s,l=new Tr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=dj+"#cannot-parse-style-attribute",l}}function mj(e,n,s){let i;if(!s)i={type:"Literal",value:n};else if(n.includes(".")){const l=n.split(".");let c=-1,d;for(;++c<l.length;){const u=Xb(l[c])?{type:"Identifier",name:l[c]}:{type:"Literal",value:l[c]};d=d?{type:"MemberExpression",object:d,property:u,computed:!!(c&&u.type==="Literal"),optional:!1}:u}i=d}else i=Xb(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const l=i.value;return Tx.call(e.components,l)?e.components[l]:l}if(e.evaluater)return e.evaluater.evaluateExpression(i);Qo(e)}function Qo(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=dj+"#cannot-handle-mdx-estrees-without-createevaluater",s}function uS(e){const n={};let s;for(s in e)Tx.call(e,s)&&(n[fS(s)]=e[s]);return n}function fS(e){let n=e.replace(Kk,mS);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function mS(e){return"-"+e.toLowerCase()}const Gm={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"]},hS={};function Mx(e,n){const s=hS,i=typeof s.includeImageAlt=="boolean"?s.includeImageAlt:!0,l=typeof s.includeHtml=="boolean"?s.includeHtml:!0;return hj(e,i,l)}function hj(e,n,s){if(xS(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 sy(e.children,n,s)}return Array.isArray(e)?sy(e,n,s):""}function sy(e,n,s){const i=[];let l=-1;for(;++l<e.length;)i[l]=hj(e[l],n,s);return i.join("")}function xS(e){return!!(e&&typeof e=="object")}const ay=document.createElement("i");function Rx(e){const n="&"+e+";";ay.innerHTML=n;const s=ay.textContent;return s.charCodeAt(s.length-1)===59&&e!=="semi"||s===n?!1:s}function ns(e,n,s,i){const l=e.length;let c=0,d;if(n<0?n=-n>l?0:l+n:n=n>l?l:n,s=s>0?s:0,i.length<1e4)d=Array.from(i),d.unshift(n,s),e.splice(...d);else for(s&&e.splice(n,s);c<i.length;)d=i.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 xj(e){const n={};let s=-1;for(;++s<e.length;)pS(n,e[s]);return n}function pS(e,n){let s;for(s in n){const l=(iy.call(e,s)?e[s]:void 0)||(e[s]={}),c=n[s];let d;if(c)for(d in c){iy.call(l,d)||(l[d]=[]);const u=c[d];gS(l[d],Array.isArray(u)?u:u?[u]:[])}}}function gS(e,n){let s=-1;const i=[];for(;++s<n.length;)(n[s].add==="after"?e:i).push(n[s]);ns(e,0,0,i)}function pj(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=ii(/[A-Za-z]/),Er=ii(/[\dA-Za-z]/),bS=ii(/[#-'*+\--9=?A-Z^-~]/);function Jd(e){return e!==null&&(e<32||e===127)}const Uh=ii(/\d/),yS=ii(/[\dA-Fa-f]/),vS=ii(/[!-/:-@[-`{-~]/);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 wu=ii(new RegExp("\\p{P}|\\p{S}","u")),Oi=ii(/\s/);function ii(e){return n;function n(s){return s!==null&&s>-1&&e.test(String.fromCharCode(s))}}function Ul(e){const n=[];let s=-1,i=0,l=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)))l=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),l=1):d="�"}else d=String.fromCharCode(c);d&&(n.push(e.slice(i,s),encodeURIComponent(d)),i=s+l+1,d=""),l&&(s+=l,l=0)}return n.join("")+e.slice(i)}function nn(e,n,s,i){const l=i?i-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++<l?(e.consume(h),u):(e.exit(s),n(h))}}const jS={tokenize:wS};function wS(e){const n=e.attempt(this.parser.constructs.contentInitial,i,l);let s;return n;function i(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),nn(e,n,"linePrefix")}function l(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 NS={tokenize:kS},ly={tokenize:SS};function kS(e){const n=this,s=[];let i=0,l,c,d;return u;function u(N){if(i<s.length){const A=s[i];return n.containerState=A[1],e.attempt(A[0].continuation,h,f)(N)}return f(N)}function h(N){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,l&&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(i);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(i===s.length){if(!l)return g(N);if(l.currentConstruct&&l.currentConstruct.concrete)return w(N);n.interrupt=!!(l.currentConstruct&&!l._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(ly,x,p)(N)}function x(N){return l&&M(),E(i),g(N)}function p(N){return n.parser.lazy[n.now().line]=i!==s.length,d=n.now().offset,w(N)}function g(N){return n.containerState={},e.attempt(ly,b,w)(N)}function b(N){return i++,s.push([n.currentConstruct,n.containerState]),g(N)}function w(N){if(N===null){l&&M(),E(0),e.consume(N);return}return l=l||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:l,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")),i=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,l.defineSkip(N.start),l.write(R),n.parser.lazy[N.start.line]){let _=l.events.length;for(;_--;)if(l.events[_][1].start.offset<d&&(!l.events[_][1].end||l.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(i),_=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(){l.write([null]),c=void 0,l=void 0,n.containerState._closeFlow=void 0}}function SS(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 Ml(e){if(e===null||Tn(e)||Oi(e))return 1;if(wu(e))return 2}function Nu(e,n,s){const i=[];let l=-1;for(;++l<e.length;){const c=e[l].resolveAll;c&&!i.includes(c)&&(n=c(n,s),i.push(c))}return n}const qh={name:"attention",resolveAll:CS,tokenize:ES};function CS(e,n){let s=-1,i,l,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(i=s;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[s][1]).charCodeAt(0)){if((e[i][1]._close||e[s][1]._open)&&(e[s][1].end.offset-e[s][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[s][1].end.offset-e[s][1].start.offset)%3))continue;h=e[i][1].end.offset-e[i][1].start.offset>1&&e[s][1].end.offset-e[s][1].start.offset>1?2:1;const p={...e[i][1].end},g={...e[s][1].start};oy(p,-h),oy(g,h),d={type:h>1?"strongSequence":"emphasisSequence",start:p,end:{...e[i][1].end}},u={type:h>1?"strongSequence":"emphasisSequence",start:{...e[s][1].start},end:g},c={type:h>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[s][1].start}},l={type:h>1?"strong":"emphasis",start:{...d.start},end:{...u.end}},e[i][1].end={...d.start},e[s][1].start={...u.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=ps(f,[["enter",e[i][1],n],["exit",e[i][1],n]])),f=ps(f,[["enter",l,n],["enter",d,n],["exit",d,n],["enter",c,n]]),f=ps(f,Nu(n.parser.constructs.insideSpan.null,e.slice(i+1,s),n)),f=ps(f,[["exit",c,n],["enter",u,n],["exit",u,n],["exit",l,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,i-1,s-i+3,f),s=i+f.length-x-2;break}}for(s=-1;++s<e.length;)e[s][1].type==="attentionSequence"&&(e[s][1].type="data");return e}function ES(e,n){const s=this.parser.constructs.attentionMarkers.null,i=this.previous,l=Ml(i);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=Ml(h),p=!x||x===2&&l||s.includes(h),g=!l||l===2&&x||s.includes(i);return f._open=!!(c===42?p:p&&(l||!g)),f._close=!!(c===42?g:g&&(x||!p)),n(h)}}function oy(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const TS={name:"autolink",tokenize:AS};function AS(e,n,s){let i=0;return l;function l(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)?(i=1,u(b)):f(b)}function u(b){return b===58?(e.consume(b),i=0,h):(b===43||b===45||b===46||Er(b))&&i++<32?(e.consume(b),u):(i=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||Jd(b)?s(b):(e.consume(b),h)}function f(b){return b===64?(e.consume(b),x):bS(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),i=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))&&i++<63){const w=b===45?g:p;return e.consume(b),w}return s(b)}}const hc={partial:!0,tokenize:_S};function _S(e,n,s){return i;function i(c){return Gt(c)?nn(e,l,"linePrefix")(c):l(c)}function l(c){return c===null||jt(c)?n(c):s(c)}}const gj={continuation:{tokenize:RS},exit:OS,name:"blockQuote",tokenize:MS};function MS(e,n,s){const i=this;return l;function l(d){if(d===62){const u=i.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 RS(e,n,s){const i=this;return l;function l(d){return Gt(d)?nn(e,c,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):c(d)}function c(d){return e.attempt(gj,n,s)(d)}}function OS(e){e.exit("blockQuote")}const bj={name:"characterEscape",tokenize:DS};function DS(e,n,s){return i;function i(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),l}function l(c){return vS(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):s(c)}}const yj={name:"characterReference",tokenize:LS};function LS(e,n,s){const i=this;let l=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=yS,x):(e.enter("characterReferenceValue"),c=7,d=Uh,x(p))}function x(p){if(p===59&&l){const g=e.exit("characterReferenceValue");return d===Er&&!Rx(i.sliceSerialize(g))?s(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return d(p)&&l++<c?(e.consume(p),x):s(p)}}const cy={partial:!0,tokenize:zS},dy={concrete:!0,name:"codeFenced",tokenize:IS};function IS(e,n,s){const i=this,l={partial:!0,tokenize:R};let c=0,d=0,u;return h;function h(_){return f(_)}function f(_){const Y=i.events[i.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"),i.interrupt?n(_):e.check(cy,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(l,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(cy,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",i.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 zS(e,n,s){const i=this;return l;function l(d){return d===null?s(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c)}function c(d){return i.parser.lazy[i.now().line]?s(d):n(d)}}const Xm={name:"codeIndented",tokenize:BS},$S={partial:!0,tokenize:HS};function BS(e,n,s){const i=this;return l;function l(f){return e.enter("codeIndented"),nn(e,c,"linePrefix",5)(f)}function c(f){const x=i.events[i.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($S,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 HS(e,n,s){const i=this;return l;function l(d){return i.parser.lazy[i.now().line]?s(d):jt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):nn(e,c,"linePrefix",5)(d)}function c(d){const u=i.events[i.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?n(d):jt(d)?l(d):s(d)}}const PS={name:"codeText",previous:qS,resolve:US,tokenize:FS};function US(e){let n=e.length-4,s=3,i,l;if((e[s][1].type==="lineEnding"||e[s][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=s;++i<n;)if(e[i][1].type==="codeTextData"){e[s][1].type="codeTextPadding",e[n][1].type="codeTextPadding",s+=2,n-=2;break}}for(i=s-1,n++;++i<=n;)l===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(l=i):(i===n||e[i][1].type==="lineEnding")&&(e[l][1].type="codeTextData",i!==l+2&&(e[l][1].end=e[i-1][1].end,e.splice(l+2,i-l-2),n-=i-l-2,i=l+2),l=void 0);return e}function qS(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function FS(e,n,s){let i=0,l,c;return d;function d(p){return e.enter("codeText"),e.enter("codeTextSequence"),u(p)}function u(p){return p===96?(e.consume(p),i++,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"),l=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),l++,x):l===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(p)):(c.type="codeTextData",f(p))}}class VS{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,s){const i=s??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(n,i):n>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(n,s,i){const l=s||0;this.setCursor(Math.trunc(n));const c=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&Ro(this.left,i),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 vj(e){const n={};let s=-1,i,l,c,d,u,h,f;const x=new VS(e);for(;++s<x.length;){for(;s in n;)s=n[s];if(i=x.get(s),s&&i[1].type==="chunkFlow"&&x.get(s-1)[1].type==="listItemPrefix"&&(h=i[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(i[0]==="enter")i[1].contentType&&(Object.assign(n,YS(x,s)),s=n[s],f=!0);else if(i[1]._container){for(c=s,l=void 0;c--;)if(d=x.get(c),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(l&&(x.get(l)[1].type="lineEndingBlank"),d[1].type="lineEnding",l=c);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;l&&(i[1].end={...x.get(l)[1].start},u=x.slice(l,s),u.unshift(i),x.splice(l,s-l+1,u))}}return ns(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function YS(e,n){const s=e.get(n)[1],i=e.get(n)[2];let l=n-1;const c=[];let d=s._tokenizer;d||(d=i.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(++l)[1]!==b;);c.push(l),b._tokenizer||(x=i.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 GS={resolve:KS,tokenize:WS},XS={partial:!0,tokenize:ZS};function KS(e){return vj(e),e}function WS(e,n){let s;return i;function i(u){return e.enter("content"),s=e.enter("chunkContent",{contentType:"content"}),l(u)}function l(u){return u===null?c(u):jt(u)?e.check(XS,d,c)(u):(e.consume(u),l)}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,l}}function ZS(e,n,s){const i=this;return l;function l(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=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?n(d):e.interrupt(i.parser.constructs.flow,s,n)(d)}}function jj(e,n,s,i,l,c,d,u,h){const f=h||Number.POSITIVE_INFINITY;let x=0;return p;function p(E){return E===60?(e.enter(i),e.enter(l),e.enter(c),e.consume(E),e.exit(c),g):E===null||E===32||E===41||Jd(E)?s(E):(e.enter(i),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(l),e.exit(i),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(i),n(E)):x<f&&E===40?(e.consume(E),x++,k):E===41?(e.consume(E),x--,k):E===null||E===32||E===40||Jd(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 wj(e,n,s,i,l,c){const d=this;let u=0,h;return f;function f(b){return e.enter(i),e.enter(l),e.consume(b),e.exit(l),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(l),e.consume(b),e.exit(l),e.exit(i),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 Nj(e,n,s,i,l,c){let d;return u;function u(g){return g===34||g===39||g===40?(e.enter(i),e.enter(l),e.consume(g),e.exit(l),d=g===40?41:g,h):s(g)}function h(g){return g===d?(e.enter(l),e.consume(g),e.exit(l),e.exit(i),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 i;function i(l){return jt(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s=!0,i):Gt(l)?nn(e,i,s?"linePrefix":"lineSuffix")(l):n(l)}}const QS={name:"definition",tokenize:eC},JS={partial:!0,tokenize:tC};function eC(e,n,s){const i=this;let l;return c;function c(b){return e.enter("definition"),d(b)}function d(b){return wj.call(i,e,u,s,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function u(b){return l=_s(i.sliceSerialize(i.events[i.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 jj(e,x,s,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function x(b){return e.attempt(JS,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"),i.parser.defined.push(l),n(b)):s(b)}}function tC(e,n,s){return i;function i(u){return Tn(u)?Yo(e,l)(u):s(u)}function l(u){return Nj(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 nC={name:"hardBreakEscape",tokenize:rC};function rC(e,n,s){return i;function i(c){return e.enter("hardBreakEscape"),e.consume(c),l}function l(c){return jt(c)?(e.exit("hardBreakEscape"),n(c)):s(c)}}const sC={name:"headingAtx",resolve:aC,tokenize:iC};function aC(e,n){let s=e.length-2,i=3,l,c;return e[i][1].type==="whitespace"&&(i+=2),s-2>i&&e[s][1].type==="whitespace"&&(s-=2),e[s][1].type==="atxHeadingSequence"&&(i===s-1||s-4>i&&e[s-2][1].type==="whitespace")&&(s-=i+1===s?2:4),s>i&&(l={type:"atxHeadingText",start:e[i][1].start,end:e[s][1].end},c={type:"chunkText",start:e[i][1].start,end:e[s][1].end,contentType:"text"},ns(e,i,s-i+1,[["enter",l,n],["enter",c,n],["exit",c,n],["exit",l,n]])),e}function iC(e,n,s){let i=0;return l;function l(x){return e.enter("atxHeading"),c(x)}function c(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&i++<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 lC=["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"],uy=["pre","script","style","textarea"],oC={concrete:!0,name:"htmlFlow",resolveTo:uC,tokenize:fC},cC={partial:!0,tokenize:hC},dC={partial:!0,tokenize:mC};function uC(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 fC(e,n,s){const i=this;let l,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),l=3,i.interrupt?n:B):Mr(I)?(e.consume(I),d=String.fromCharCode(I),C):s(I)}function g(I){return I===45?(e.consume(I),l=2,b):I===91?(e.consume(I),l=5,u=0,w):Mr(I)?(e.consume(I),l=4,i.interrupt?n:B):s(I)}function b(I){return I===45?(e.consume(I),i.interrupt?n:B):s(I)}function w(I){const S="CDATA[";return I===S.charCodeAt(u++)?(e.consume(I),u===S.length?i.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&&uy.includes(D)?(l=1,i.interrupt?n(I):G(I)):lC.includes(d.toLowerCase())?(l=6,S?(e.consume(I),E):i.interrupt?n(I):G(I)):(l=7,i.interrupt&&!i.parser.lazy[i.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),i.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&&l===2?(e.consume(I),O):I===60&&l===1?(e.consume(I),V):I===62&&l===4?(e.consume(I),F):I===63&&l===3?(e.consume(I),B):I===93&&l===5?(e.consume(I),Z):jt(I)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check(cC,K,$)(I)):I===null||jt(I)?(e.exit("htmlFlowData"),$(I)):(e.consume(I),G)}function $(I){return e.check(dC,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 uy.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&&l===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 mC(e,n,s){const i=this;return l;function l(d){return jt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):s(d)}function c(d){return i.parser.lazy[i.now().line]?s(d):n(d)}}function hC(e,n,s){return i;function i(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(hc,n,s)}}const xC={name:"htmlText",tokenize:pC};function pC(e,n,s){const i=this;let l,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),l=B,$):jt(B)?(d=G,V(B)):Gt(B)?(e.consume(B),G):(e.consume(B),T)}function $(B){return B===l?(e.consume(B),l=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",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):Z(B)}function Z(B){return e.enter("htmlTextData"),d(B)}}const Ox={name:"labelEnd",resolveAll:vC,resolveTo:jC,tokenize:wC},gC={tokenize:NC},bC={tokenize:kC},yC={tokenize:SC};function vC(e){let n=-1;const s=[];for(;++n<e.length;){const i=e[n][1];if(s.push(e[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const l=i.type==="labelImage"?4:2;i.type="data",n+=l}}return e.length!==s.length&&ns(e,0,e.length,s),e}function jC(e,n){let s=e.length,i=0,l,c,d,u;for(;s--;)if(l=e[s][1],c){if(l.type==="link"||l.type==="labelLink"&&l._inactive)break;e[s][0]==="enter"&&l.type==="labelLink"&&(l._inactive=!0)}else if(d){if(e[s][0]==="enter"&&(l.type==="labelImage"||l.type==="labelLink")&&!l._balanced&&(c=s,l.type!=="labelLink")){i=2;break}}else l.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+i+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+i+3)),u=ps(u,[["enter",x,n]]),u=ps(u,Nu(n.parser.constructs.insideSpan.null,e.slice(c+i+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 wC(e,n,s){const i=this;let l=i.events.length,c,d;for(;l--;)if((i.events[l][1].type==="labelImage"||i.events[l][1].type==="labelLink")&&!i.events[l][1]._balanced){c=i.events[l][1];break}return u;function u(g){return c?c._inactive?p(g):(d=i.parser.defined.includes(_s(i.sliceSerialize({start:c.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),h):s(g)}function h(g){return g===40?e.attempt(gC,x,d?x:p)(g):g===91?e.attempt(bC,x,d?f:p)(g):d?x(g):p(g)}function f(g){return e.attempt(yC,x,p)(g)}function x(g){return n(g)}function p(g){return c._balanced=!0,s(g)}}function NC(e,n,s){return i;function i(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),l}function l(p){return Tn(p)?Yo(e,c)(p):c(p)}function c(p){return p===41?x(p):jj(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?Nj(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 kC(e,n,s){const i=this;return l;function l(u){return wj.call(i,e,c,d,"reference","referenceMarker","referenceString")(u)}function c(u){return i.parser.defined.includes(_s(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(u):s(u)}function d(u){return s(u)}}function SC(e,n,s){return i;function i(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),l}function l(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),n):s(c)}}const CC={name:"labelStartImage",resolveAll:Ox.resolveAll,tokenize:EC};function EC(e,n,s){const i=this;return l;function l(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 i.parser.constructs?s(u):n(u)}}const TC={name:"labelStartLink",resolveAll:Ox.resolveAll,tokenize:AC};function AC(e,n,s){const i=this;return l;function l(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 i.parser.constructs?s(d):n(d)}}const Km={name:"lineEnding",tokenize:_C};function _C(e,n){return s;function s(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),nn(e,n,"linePrefix")}}const Fd={name:"thematicBreak",tokenize:MC};function MC(e,n,s){let i=0,l;return c;function c(f){return e.enter("thematicBreak"),d(f)}function d(f){return l=f,u(f)}function u(f){return f===l?(e.enter("thematicBreakSequence"),h(f)):i>=3&&(f===null||jt(f))?(e.exit("thematicBreak"),n(f)):s(f)}function h(f){return f===l?(e.consume(f),i++,h):(e.exit("thematicBreakSequence"),Gt(f)?nn(e,u,"whitespace")(f):u(f))}}const Ur={continuation:{tokenize:LC},exit:zC,name:"list",tokenize:DC},RC={partial:!0,tokenize:$C},OC={partial:!0,tokenize:IC};function DC(e,n,s){const i=this,l=i.events[i.events.length-1];let c=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,d=0;return u;function u(b){const w=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:Uh(b)){if(i.containerState.type||(i.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Fd,s,f)(b):f(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(b)}return s(b)}function h(b){return Uh(b)&&++d<10?(e.consume(b),h):(!i.interrupt||d<2)&&(i.containerState.marker?b===i.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"),i.containerState.marker=i.containerState.marker||b,e.check(hc,i.interrupt?s:x,e.attempt(RC,g,p))}function x(b){return i.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 i.containerState.size=c+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function LC(e,n,s){const i=this;return i.containerState._closeFlow=void 0,e.check(hc,l,c);function l(u){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,nn(e,n,"listItemIndent",i.containerState.size+1)(u)}function c(u){return i.containerState.furtherBlankLines||!Gt(u)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,d(u)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(OC,n,d)(u))}function d(u){return i.containerState._closeFlow=!0,i.interrupt=void 0,nn(e,e.attempt(Ur,n,s),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function IC(e,n,s){const i=this;return nn(e,l,"listItemIndent",i.containerState.size+1);function l(c){const d=i.events[i.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===i.containerState.size?n(c):s(c)}}function zC(e){e.exit(this.containerState.type)}function $C(e,n,s){const i=this;return nn(e,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(c){const d=i.events[i.events.length-1];return!Gt(c)&&d&&d[1].type==="listItemPrefixWhitespace"?n(c):s(c)}}const fy={name:"setextUnderline",resolveTo:BC,tokenize:HC};function BC(e,n){let s=e.length,i,l,c;for(;s--;)if(e[s][0]==="enter"){if(e[s][1].type==="content"){i=s;break}e[s][1].type==="paragraph"&&(l=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[i][1].start},end:{...e[e.length-1][1].end}};return e[l][1].type="setextHeadingText",c?(e.splice(l,0,["enter",d,n]),e.splice(c+1,0,["exit",e[i][1],n]),e[i][1].end={...e[c][1].end}):e[i][1]=d,e.push(["exit",d,n]),e}function HC(e,n,s){const i=this;let l;return c;function c(f){let x=i.events.length,p;for(;x--;)if(i.events[x][1].type!=="lineEnding"&&i.events[x][1].type!=="linePrefix"&&i.events[x][1].type!=="content"){p=i.events[x][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||p)?(e.enter("setextHeadingLine"),l=f,d(f)):s(f)}function d(f){return e.enter("setextHeadingLineSequence"),u(f)}function u(f){return f===l?(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 PC={tokenize:UC};function UC(e){const n=this,s=e.attempt(hc,i,e.attempt(this.parser.constructs.flowInitial,l,nn(e,e.attempt(this.parser.constructs.flow,l,e.attempt(GS,l)),"linePrefix")));return s;function i(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),n.currentConstruct=void 0,s}function l(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),n.currentConstruct=void 0,s}}const qC={resolveAll:Sj()},FC=kj("string"),VC=kj("text");function kj(e){return{resolveAll:Sj(e==="text"?YC:void 0),tokenize:n};function n(s){const i=this,l=this.parser.constructs[e],c=s.attempt(l,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=l[x];let g=-1;if(p)for(;++g<p.length;){const b=p[g];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function Sj(e){return n;function n(s,i){let l=-1,c;for(;++l<=s.length;)c===void 0?s[l]&&s[l][1].type==="data"&&(c=l,l++):(!s[l]||s[l][1].type!=="data")&&(l!==c+2&&(s[c][1].end=s[l-1][1].end,s.splice(c+2,l-c-2),l=c+2),c=void 0);return e?e(s,i):s}}function YC(e,n){let s=0;for(;++s<=e.length;)if((s===e.length||e[s][1].type==="lineEnding")&&e[s-1][1].type==="data"){const i=e[s-1][1],l=n.sliceStream(i);let c=l.length,d=-1,u=0,h;for(;c--;){const f=l[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:i.start._bufferIndex+d,_index:i.start._index+c,line:i.end.line,column:i.end.column-u,offset:i.end.offset-u},end:{...i.end}};i.end={...f.start},i.start.offset===i.end.offset?Object.assign(i,f):(e.splice(s,0,["enter",f,n],["exit",f,n]),s+=2)}s++}return e}const GC={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:gj},XC={91:QS},KC={[-2]:Xm,[-1]:Xm,32:Xm},WC={35:sC,42:Fd,45:[fy,Fd],60:oC,61:fy,95:Fd,96:dy,126:dy},ZC={38:yj,92:bj},QC={[-5]:Km,[-4]:Km,[-3]:Km,33:CC,38:yj,42:qh,60:[TS,xC],91:TC,92:[nC,bj],93:Ox,95:qh,96:PS},JC={null:[qh,qC]},eE={null:[42,95]},tE={null:[]},nE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eE,contentInitial:XC,disable:tE,document:GC,flow:WC,flowInitial:KC,insideSpan:JC,string:ZC,text:QC},Symbol.toStringTag,{value:"Module"}));function rE(e,n,s){let i={_bufferIndex:-1,_index:0,line:s&&s.line||1,column:s&&s.column||1,offset:s&&s.offset||0};const l={},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=Nu(c,f.events,f),f.events)}function g(P,G){return aE(b(P),G)}function b(P){return sE(d,P)}function w(){const{_bufferIndex:P,_index:G,line:$,column:T,offset:z}=i;return{_bufferIndex:P,_index:G,line:$,column:T,offset:z}}function k(P){l[P.line]=P.column,L()}function C(){let P;for(;i._index<d.length;){const G=d[i._index];if(typeof G=="string")for(P=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===P&&i._bufferIndex<G.length;)E(G.charCodeAt(i._bufferIndex));else E(G)}}function E(P){x=x(P)}function M(P){jt(P)?(i.line++,i.column=1,i.offset+=P===-3?2:1,L()):P!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===d[i._index].length&&(i._bufferIndex=-1,i._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(){i=P,f.previous=G,f.currentConstruct=$,f.events.length=T,u=z,L()}}function L(){i.line in l&&i.column<2&&(i.column=l[i.line],i.offset+=l[i.line]-1)}}function sE(e,n){const s=n.start._index,i=n.start._bufferIndex,l=n.end._index,c=n.end._bufferIndex;let d;if(s===l)d=[e[s].slice(i,c)];else{if(d=e.slice(s,l),i>-1){const u=d[0];typeof u=="string"?d[0]=u.slice(i):d.shift()}c>0&&d.push(e[l].slice(0,c))}return d}function aE(e,n){let s=-1;const i=[];let l;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&&l)continue;d=" ";break}default:d=String.fromCharCode(c)}l=c===-2,i.push(d)}return i.join("")}function iE(e){const i={constructs:xj([nE,...(e||{}).extensions||[]]),content:l(jS),defined:[],document:l(NS),flow:l(PC),lazy:{},string:l(FC),text:l(VC)};return i;function l(c){return d;function d(u){return rE(i,c,u)}}}function lE(e){for(;!vj(e););return e}const my=/[\0\t\n\r]/g;function oE(){let e=1,n="",s=!0,i;return l;function l(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(my.lastIndex=p,f=my.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&&i)h.push(-3),i=void 0;else switch(i&&(h.push(-5),i=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:i=!0,e=1}p=g+1}return u&&(i&&h.push(-5),n&&h.push(n),h.push(null)),h}}const cE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function dE(e){return e.replace(cE,uE)}function uE(e,n,s){if(n)return n;if(s.charCodeAt(0)===35){const l=s.charCodeAt(1),c=l===120||l===88;return pj(s.slice(c?2:1),c?16:10)}return Rx(s)||e}const Cj={}.hasOwnProperty;function fE(e,n,s){return n&&typeof n=="object"&&(s=n,n=void 0),mE(s)(lE(iE(s).document().write(oE()(e,n,!0))))}function mE(e){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(et),autolinkProtocol:X,autolinkEmail:X,atxHeading:c(Ce),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(ie),listItemValue:g,listOrdered:c(Pt,p),listUnordered:c(Pt),paragraph:c(Ee),reference:I,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:c(Ce),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()}};Ej(n,(e||{}).mdastExtensions||[]);const s={};return i;function i(xe){let Se={type:"root",children:[]};const Fe={stack:[Se],tokenStack:[],config:n,enter:u,exit:f,buffer:d,resume:x,data:s},it=[];let ut=-1;for(;++ut<xe.length;)if(xe[ut][1].type==="listOrdered"||xe[ut][1].type==="listUnordered")if(xe[ut][0]==="enter")it.push(ut);else{const Lt=it.pop();ut=l(xe,Lt,ut)}for(ut=-1;++ut<xe.length;){const Lt=n[xe[ut][0]];Cj.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]||hy).call(Fe,void 0,Lt[0])}for(Se.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;)Se=n.transforms[ut](Se)||Se;return Se}function l(xe,Se,Fe){let it=Se-1,ut=-1,Lt=!1,bn,Ut,St,Jt;for(;++it<=Fe;){const yt=xe[it];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=it),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=it;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||it,0,["exit",bn,yt[2]]),it++,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(it,0,["enter",Xt,yt[2]]),it++,Fe++,St=void 0,Jt=!0}}}return xe[Se][1]._spread=Lt,Fe}function c(xe,Se){return Fe;function Fe(it){u.call(this,xe(it),it),Se&&Se.call(this,it)}}function d(){this.stack.push({type:"fragment",children:[]})}function u(xe,Se,Fe){this.stack[this.stack.length-1].children.push(xe),this.stack.push(xe),this.tokenStack.push([Se,Fe||void 0]),xe.position={start:Wa(Se.start),end:void 0}}function h(xe){return Se;function Se(Fe){xe&&xe.call(this,Fe),f.call(this,Fe)}}function f(xe,Se){const Fe=this.stack.pop(),it=this.tokenStack.pop();if(it)it[0].type!==xe.type&&(Se?Se.call(this,xe,it[0]):(it[1]||hy).call(this,xe,it[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 Mx(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function g(xe){if(this.data.expectingFirstListItemValue){const Se=this.stack[this.stack.length-2];Se.start=Number.parseInt(this.sliceSerialize(xe),10),this.data.expectingFirstListItemValue=void 0}}function b(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.lang=xe}function w(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.meta=xe}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=xe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=xe.replace(/(\r?\n|\r)$/g,"")}function M(xe){const Se=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Se,Fe.identifier=_s(this.sliceSerialize(xe)).toLowerCase()}function N(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.title=xe}function A(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.url=xe}function R(xe){const Se=this.stack[this.stack.length-1];if(!Se.depth){const Fe=this.sliceSerialize(xe).length;Se.depth=Fe}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function Y(xe){const Se=this.stack[this.stack.length-1];Se.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 it=Fe[Fe.length-1];(!it||it.type!=="text")&&(it=kt(),it.position={start:Wa(xe.start),end:void 0},Fe.push(it)),this.stack.push(it)}function L(xe){const Se=this.stack.pop();Se.value+=this.sliceSerialize(xe),Se.position.end=Wa(xe.end)}function P(xe){const Se=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Fe=Se.children[Se.children.length-1];Fe.position.end=Wa(xe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(Se.type)&&(X.call(this,xe),L.call(this,xe))}function G(){this.data.atHardBreak=!0}function $(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=xe}function T(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=xe}function z(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.value=xe}function O(){const xe=this.stack[this.stack.length-1];if(this.data.inReference){const Se=this.data.referenceType||"shortcut";xe.type+="Reference",xe.referenceType=Se,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 Se=this.data.referenceType||"shortcut";xe.type+="Reference",xe.referenceType=Se,delete xe.url,delete xe.title}else delete xe.identifier,delete xe.label;this.data.referenceType=void 0}function H(xe){const Se=this.sliceSerialize(xe),Fe=this.stack[this.stack.length-2];Fe.label=dE(Se),Fe.identifier=_s(Se).toLowerCase()}function Z(){const xe=this.stack[this.stack.length-1],Se=this.resume(),Fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Fe.type==="link"){const it=xe.children;Fe.children=it}else Fe.alt=Se}function B(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.url=xe}function F(){const xe=this.resume(),Se=this.stack[this.stack.length-1];Se.title=xe}function K(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function S(xe){const Se=this.resume(),Fe=this.stack[this.stack.length-1];Fe.label=Se,Fe.identifier=_s(this.sliceSerialize(xe)).toLowerCase(),this.data.referenceType="full"}function D(xe){this.data.characterReferenceType=xe.type}function W(xe){const Se=this.sliceSerialize(xe),Fe=this.data.characterReferenceType;let it;Fe?(it=pj(Se,Fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):it=Rx(Se);const ut=this.stack[this.stack.length-1];ut.value+=it}function J(xe){const Se=this.stack.pop();Se.position.end=Wa(xe.end)}function te(xe){L.call(this,xe);const Se=this.stack[this.stack.length-1];Se.url=this.sliceSerialize(xe)}function re(xe){L.call(this,xe);const Se=this.stack[this.stack.length-1];Se.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 Ce(){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 ie(xe){return{type:"listItem",spread:xe._spread,checked:null,children:[]}}function Ee(){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 Ej(e,n){let s=-1;for(;++s<n.length;){const i=n[s];Array.isArray(i)?Ej(e,i):hE(e,i)}}function hE(e,n){let s;for(s in n)if(Cj.call(n,s))switch(s){case"canContainEols":{const i=n[s];i&&e[s].push(...i);break}case"transforms":{const i=n[s];i&&e[s].push(...i);break}case"enter":case"exit":{const i=n[s];i&&Object.assign(e[s],i);break}}}function hy(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 xE(e){const n=this;n.parser=s;function s(i){return fE(i,{...n.data("settings"),...e,extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]})}}function pE(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 gE(e,n){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(n,s),[e.applyData(n,s),{type:"text",value:`
|
|
14
|
+
`}]}function bE(e,n){const s=n.value?n.value+`
|
|
15
|
+
`:"",i={},l=n.lang?n.lang.split(/\s+/):[];l.length>0&&(i.className=["language-"+l[0]]);let c={type:"element",tagName:"code",properties:i,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 yE(e,n){const s={type:"element",tagName:"del",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function vE(e,n){const s={type:"element",tagName:"em",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function jE(e,n){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),l=Ul(i.toLowerCase()),c=e.footnoteOrder.indexOf(i);let d,u=e.footnoteCounts.get(i);u===void 0?(u=0,e.footnoteOrder.push(i),d=e.footnoteOrder.length):d=c+1,u+=1,e.footnoteCounts.set(i,u);const h={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+l,id:s+"fnref-"+l+(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 wE(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 NE(e,n){if(e.options.allowDangerousHtml){const s={type:"raw",value:n.value};return e.patch(n,s),e.applyData(n,s)}}function Tj(e,n){const s=n.referenceType;let i="]";if(s==="collapsed"?i+="[]":s==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const l=e.all(n),c=l[0];c&&c.type==="text"?c.value="["+c.value:l.unshift({type:"text",value:"["});const d=l[l.length-1];return d&&d.type==="text"?d.value+=i:l.push({type:"text",value:i}),l}function kE(e,n){const s=String(n.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return Tj(e,n);const l={src:Ul(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(l.title=i.title);const c={type:"element",tagName:"img",properties:l,children:[]};return e.patch(n,c),e.applyData(n,c)}function SE(e,n){const s={src:Ul(n.url)};n.alt!==null&&n.alt!==void 0&&(s.alt=n.alt),n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(n,i),e.applyData(n,i)}function CE(e,n){const s={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};e.patch(n,s);const i={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(n,i),e.applyData(n,i)}function EE(e,n){const s=String(n.identifier).toUpperCase(),i=e.definitionById.get(s);if(!i)return Tj(e,n);const l={href:Ul(i.url||"")};i.title!==null&&i.title!==void 0&&(l.title=i.title);const c={type:"element",tagName:"a",properties:l,children:e.all(n)};return e.patch(n,c),e.applyData(n,c)}function TE(e,n){const s={href:Ul(n.url)};n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"a",properties:s,children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function AE(e,n,s){const i=e.all(n),l=s?_E(s):Aj(n),c={},d=[];if(typeof n.checked=="boolean"){const x=i[0];let p;x&&x.type==="element"&&x.tagName==="p"?p=x:(p={type:"element",tagName:"p",properties:{},children:[]},i.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<i.length;){const x=i[u];(l||u!==0||x.type!=="element"||x.tagName!=="p")&&d.push({type:"text",value:`
|
|
16
|
+
`}),x.type==="element"&&x.tagName==="p"&&!l?d.push(...x.children):d.push(x)}const h=i[i.length-1];h&&(l||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 _E(e){let n=!1;if(e.type==="list"){n=e.spread||!1;const s=e.children;let i=-1;for(;!n&&++i<s.length;)n=Aj(s[i])}return n}function Aj(e){const n=e.spread;return n??e.children.length>1}function ME(e,n){const s={},i=e.all(n);let l=-1;for(typeof n.start=="number"&&n.start!==1&&(s.start=n.start);++l<i.length;){const d=i[l];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(i,!0)};return e.patch(n,c),e.applyData(n,c)}function RE(e,n){const s={type:"element",tagName:"p",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function OE(e,n){const s={type:"root",children:e.wrap(e.all(n))};return e.patch(n,s),e.applyData(n,s)}function DE(e,n){const s={type:"element",tagName:"strong",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}function LE(e,n){const s=e.all(n),i=s.shift(),l=[];if(i){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(n.children[0],d),l.push(d)}if(s.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},u=Ex(n.children[1]),h=oj(n.children[n.children.length-1]);u&&h&&(d.position={start:u,end:h}),l.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(l,!0)};return e.patch(n,c),e.applyData(n,c)}function IE(e,n,s){const i=s?s.children:void 0,c=(i?i.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 zE(e,n){const s={type:"element",tagName:"td",properties:{},children:e.all(n)};return e.patch(n,s),e.applyData(n,s)}const xy=9,py=32;function $E(e){const n=String(e),s=/\r?\n|\r/g;let i=s.exec(n),l=0;const c=[];for(;i;)c.push(gy(n.slice(l,i.index),l>0,!0),i[0]),l=i.index+i[0].length,i=s.exec(n);return c.push(gy(n.slice(l),l>0,!1)),c.join("")}function gy(e,n,s){let i=0,l=e.length;if(n){let c=e.codePointAt(i);for(;c===xy||c===py;)i++,c=e.codePointAt(i)}if(s){let c=e.codePointAt(l-1);for(;c===xy||c===py;)l--,c=e.codePointAt(l-1)}return l>i?e.slice(i,l):""}function BE(e,n){const s={type:"text",value:$E(String(n.value))};return e.patch(n,s),e.applyData(n,s)}function HE(e,n){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(n,s),e.applyData(n,s)}const PE={blockquote:pE,break:gE,code:bE,delete:yE,emphasis:vE,footnoteReference:jE,heading:wE,html:NE,imageReference:kE,image:SE,inlineCode:CE,linkReference:EE,link:TE,listItem:AE,list:ME,paragraph:RE,root:OE,strong:DE,table:LE,tableCell:zE,tableRow:IE,text:BE,thematicBreak:HE,toml:Cd,yaml:Cd,definition:Cd,footnoteDefinition:Cd};function Cd(){}const _j=-1,ku=0,Go=1,eu=2,Dx=3,Lx=4,Ix=5,zx=6,Mj=7,Rj=8,by=typeof self=="object"?self:globalThis,UE=(e,n)=>{const s=(l,c)=>(e.set(c,l),l),i=l=>{if(e.has(l))return e.get(l);const[c,d]=n[l];switch(c){case ku:case _j:return s(d,l);case Go:{const u=s([],l);for(const h of d)u.push(i(h));return u}case eu:{const u=s({},l);for(const[h,f]of d)u[i(h)]=i(f);return u}case Dx:return s(new Date(d),l);case Lx:{const{source:u,flags:h}=d;return s(new RegExp(u,h),l)}case Ix:{const u=s(new Map,l);for(const[h,f]of d)u.set(i(h),i(f));return u}case zx:{const u=s(new Set,l);for(const h of d)u.add(i(h));return u}case Mj:{const{name:u,message:h}=d;return s(new by[u](h),l)}case Rj:return s(BigInt(d),l);case"BigInt":return s(Object(BigInt(d)),l);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 by[c](d),l)};return i},yy=e=>UE(new Map,e)(0),gl="",{toString:qE}={},{keys:FE}=Object,Oo=e=>{const n=typeof e;if(n!=="object"||!e)return[ku,n];const s=qE.call(e).slice(8,-1);switch(s){case"Array":return[Go,gl];case"Object":return[eu,gl];case"Date":return[Dx,gl];case"RegExp":return[Lx,gl];case"Map":return[Ix,gl];case"Set":return[zx,gl];case"DataView":return[Go,s]}return s.includes("Array")?[Go,s]:s.includes("Error")?[Mj,s]:[eu,s]},Ed=([e,n])=>e===ku&&(n==="function"||n==="symbol"),VE=(e,n,s,i)=>{const l=(d,u)=>{const h=i.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 ku:{let x=d;switch(h){case"bigint":u=Rj,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);x=null;break;case"undefined":return l([_j],d)}return l([u,x],d)}case Go:{if(h){let g=d;return h==="DataView"?g=new Uint8Array(d.buffer):h==="ArrayBuffer"&&(g=new Uint8Array(d)),l([h,[...g]],d)}const x=[],p=l([u,x],d);for(const g of d)x.push(c(g));return p}case eu:{if(h)switch(h){case"BigInt":return l([h,d.toString()],d);case"Boolean":case"Number":case"String":return l([h,d.valueOf()],d)}if(n&&"toJSON"in d)return c(d.toJSON());const x=[],p=l([u,x],d);for(const g of FE(d))(e||!Ed(Oo(d[g])))&&x.push([c(g),c(d[g])]);return p}case Dx:return l([u,d.toISOString()],d);case Lx:{const{source:x,flags:p}=d;return l([u,{source:x,flags:p}],d)}case Ix:{const x=[],p=l([u,x],d);for(const[g,b]of d)(e||!(Ed(Oo(g))||Ed(Oo(b))))&&x.push([c(g),c(b)]);return p}case zx:{const x=[],p=l([u,x],d);for(const g of d)(e||!Ed(Oo(g)))&&x.push(c(g));return p}}const{message:f}=d;return l([u,{name:h,message:f}],d)};return c},vy=(e,{json:n,lossy:s}={})=>{const i=[];return VE(!(n||s),!!n,new Map,i)(e),i},tu=typeof structuredClone=="function"?(e,n)=>n&&("json"in n||"lossy"in n)?yy(vy(e,n)):structuredClone(e):(e,n)=>yy(vy(e,n));function YE(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 GE(e,n){return"Back to reference "+(e+1)+(n>1?"-"+n:"")}function XE(e){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||YE,i=e.options.footnoteBackLabel||GE,l=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=Ul(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 i=="string"?i:i(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:{...tu(d),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:`
|
|
18
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
|
|
19
|
+
`}]}}const Su=(function(e){if(e==null)return QE;if(typeof e=="function")return Cu(e);if(typeof e=="object")return Array.isArray(e)?KE(e):WE(e);if(typeof e=="string")return ZE(e);throw new Error("Expected function, string, or object as test")});function KE(e){const n=[];let s=-1;for(;++s<e.length;)n[s]=Su(e[s]);return Cu(i);function i(...l){let c=-1;for(;++c<n.length;)if(n[c].apply(this,l))return!0;return!1}}function WE(e){const n=e;return Cu(s);function s(i){const l=i;let c;for(c in e)if(l[c]!==n[c])return!1;return!0}}function ZE(e){return Cu(n);function n(s){return s&&s.type===e}}function Cu(e){return n;function n(s,i,l){return!!(JE(s)&&e.call(this,s,typeof i=="number"?i:void 0,l||void 0))}}function QE(){return!0}function JE(e){return e!==null&&typeof e=="object"&&"type"in e}const Oj=[],e3=!0,Fh=!1,t3="skip";function Dj(e,n,s,i){let l;typeof n=="function"&&typeof s!="function"?(i=s,s=n):l=n;const c=Su(l),d=i?-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=Oj,w,k,C;if((!n||c(h,f,x[x.length-1]||void 0))&&(b=n3(s(h,x)),b[0]===Fh))return b;if("children"in h&&h.children){const E=h;if(E.children&&b[0]!==t3)for(k=(i?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]===Fh)return w;k=typeof w[1]=="number"?w[1]:k+d}}return b}}}function n3(e){return Array.isArray(e)?e:typeof e=="number"?[e3,e]:e==null?Oj:[e]}function $x(e,n,s,i){let l,c,d;typeof n=="function"&&typeof s!="function"?(c=void 0,d=n,l=s):(c=n,d=s,l=i),Dj(e,c,u,l);function u(h,f){const x=f[f.length-1],p=x?x.children.indexOf(h):void 0;return d(h,p,x)}}const Vh={}.hasOwnProperty,r3={};function s3(e,n){const s=n||r3,i=new Map,l=new Map,c=new Map,d={...PE,...s.handlers},u={all:f,applyData:i3,definitionById:i,footnoteById:l,footnoteCounts:c,footnoteOrder:[],handlers:d,one:h,options:s,patch:a3,wrap:o3};return $x(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const p=x.type==="definition"?i:l,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(Vh.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=tu(C);return E.children=u.all(x),E}return tu(x)}return(u.options.unknownHandler||l3)(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=jy(w.value)),!Array.isArray(w)&&w.type==="element")){const k=w.children[0];k&&k.type==="text"&&(k.value=jy(k.value))}Array.isArray(w)?p.push(...w):p.push(w)}}}return p}}function a3(e,n){e.position&&(n.position=Gk(e))}function i3(e,n){let s=n;if(e&&e.data){const i=e.data.hName,l=e.data.hChildren,c=e.data.hProperties;if(typeof i=="string")if(s.type==="element")s.tagName=i;else{const d="children"in s?s.children:[s];s={type:"element",tagName:i,properties:{},children:d}}s.type==="element"&&c&&Object.assign(s.properties,tu(c)),"children"in s&&s.children&&l!==null&&l!==void 0&&(s.children=l)}return s}function l3(e,n){const s=n.data||{},i="value"in n&&!(Vh.call(s,"hProperties")||Vh.call(s,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:e.all(n)};return e.patch(n,i),e.applyData(n,i)}function o3(e,n){const s=[];let i=-1;for(n&&s.push({type:"text",value:`
|
|
20
|
+
`});++i<e.length;)i&&s.push({type:"text",value:`
|
|
21
|
+
`}),s.push(e[i]);return n&&e.length>0&&s.push({type:"text",value:`
|
|
22
|
+
`}),s}function jy(e){let n=0,s=e.charCodeAt(n);for(;s===9||s===32;)n++,s=e.charCodeAt(n);return e.slice(n)}function wy(e,n){const s=s3(e,n),i=s.one(e,void 0),l=XE(s),c=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&c.children.push({type:"text",value:`
|
|
23
|
+
`},l),c}function c3(e,n){return e&&"run"in e?async function(s,i){const l=wy(s,{file:i,...n});await e.run(l,i)}:function(s,i){return wy(s,{file:i,...e||n})}}function Ny(e){if(e)throw e}var Wm,ky;function d3(){if(ky)return Wm;ky=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=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(i)return i(f,x).value}else return;return f[x]};return Wm=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=l(g)))?(b?(b=!1,w=p&&l(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},Wm}var u3=d3();const Zm=vu(u3);function Yh(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 f3(){const e=[],n={run:s,use:i};return n;function s(...l){let c=-1;const d=l.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);u(null,...l);function u(h,...f){const x=e[++c];let p=-1;if(h){d(h);return}for(;++p<l.length;)(f[p]===null||f[p]===void 0)&&(f[p]=l[p]);l=f,x?m3(x,u)(...f):d(null,...f)}}function i(l){if(typeof l!="function")throw new TypeError("Expected `middelware` to be a function, not "+l);return e.push(l),n}}function m3(e,n){let s;return i;function i(...d){const u=e.length>d.length;let h;u&&d.push(l);try{h=e.apply(this,d)}catch(f){const x=f;if(u&&s)throw x;return l(x)}u||(h&&h.then&&typeof h.then=="function"?h.then(c,l):h instanceof Error?l(h):c(h))}function l(d,...u){s||(s=!0,n(d,...u))}function c(d){l(null,d)}}const qs={basename:h3,dirname:x3,extname:p3,join:g3,sep:"/"};function h3(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');xc(e);let s=0,i=-1,l=e.length,c;if(n===void 0||n.length===0||n.length>e.length){for(;l--;)if(e.codePointAt(l)===47){if(c){s=l+1;break}}else i<0&&(c=!0,i=l+1);return i<0?"":e.slice(s,i)}if(n===e)return"";let d=-1,u=n.length-1;for(;l--;)if(e.codePointAt(l)===47){if(c){s=l+1;break}}else d<0&&(c=!0,d=l+1),u>-1&&(e.codePointAt(l)===n.codePointAt(u--)?u<0&&(i=l):(u=-1,i=d));return s===i?i=d:i<0&&(i=e.length),e.slice(s,i)}function x3(e){if(xc(e),e.length===0)return".";let n=-1,s=e.length,i;for(;--s;)if(e.codePointAt(s)===47){if(i){n=s;break}}else i||(i=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function p3(e){xc(e);let n=e.length,s=-1,i=0,l=-1,c=0,d;for(;n--;){const u=e.codePointAt(n);if(u===47){if(d){i=n+1;break}continue}s<0&&(d=!0,s=n+1),u===46?l<0?l=n:c!==1&&(c=1):l>-1&&(c=-1)}return l<0||s<0||c===0||c===1&&l===s-1&&l===i+1?"":e.slice(l,s)}function g3(...e){let n=-1,s;for(;++n<e.length;)xc(e[n]),e[n]&&(s=s===void 0?e[n]:s+"/"+e[n]);return s===void 0?".":b3(s)}function b3(e){xc(e);const n=e.codePointAt(0)===47;let s=y3(e,!n);return s.length===0&&!n&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),n?"/"+s:s}function y3(e,n){let s="",i=0,l=-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(!(l===d-1||c===1))if(l!==d-1&&c===2){if(s.length<2||i!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(h=s.lastIndexOf("/"),h!==s.length-1){h<0?(s="",i=0):(s=s.slice(0,h),i=s.length-1-s.lastIndexOf("/")),l=d,c=0;continue}}else if(s.length>0){s="",i=0,l=d,c=0;continue}}n&&(s=s.length>0?s+"/..":"..",i=2)}else s.length>0?s+="/"+e.slice(l+1,d):s=e.slice(l+1,d),i=d-l-1;l=d,c=0}else u===46&&c>-1?c++:c=-1}return s}function xc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const v3={cwd:j3};function j3(){return"/"}function Gh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function w3(e){if(typeof e=="string")e=new URL(e);else if(!Gh(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 N3(e)}function N3(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let s=-1;for(;++s<n.length;)if(n.codePointAt(s)===37&&n.codePointAt(s+1)===50){const i=n.codePointAt(s+2);if(i===70||i===102){const l=new TypeError("File URL path must not include encoded / characters");throw l.code="ERR_INVALID_FILE_URL_PATH",l}}return decodeURIComponent(n)}const Qm=["history","path","basename","stem","extname","dirname"];class Lj{constructor(n){let s;n?Gh(n)?s={path:n}:typeof n=="string"||k3(n)?s={value:n}:s=n:s={},this.cwd="cwd"in s?"":v3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<Qm.length;){const c=Qm[i];c in s&&s[c]!==void 0&&s[c]!==null&&(this[c]=c==="history"?[...s[c]]:s[c])}let l;for(l in s)Qm.includes(l)||(this[l]=s[l])}get basename(){return typeof this.path=="string"?qs.basename(this.path):void 0}set basename(n){eh(n,"basename"),Jm(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){Sy(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(Jm(n,"extname"),Sy(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){Gh(n)&&(n=w3(n)),eh(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){eh(n,"stem"),Jm(n,"stem"),this.path=qs.join(this.dirname||"",n+(this.extname||""))}fail(n,s,i){const l=this.message(n,s,i);throw l.fatal=!0,l}info(n,s,i){const l=this.message(n,s,i);return l.fatal=void 0,l}message(n,s,i){const l=new Tr(n,s,i);return this.path&&(l.name=this.path+":"+l.name,l.file=this.path),l.fatal=!1,this.messages.push(l),l}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function Jm(e,n){if(e&&e.includes(qs.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+qs.sep+"`")}function eh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function Sy(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function k3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const S3=(function(e){const i=this.constructor.prototype,l=i[e],c=function(){return l.apply(c,arguments)};return Object.setPrototypeOf(c,i),c}),C3={}.hasOwnProperty;class Bx extends S3{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=f3()}copy(){const n=new Bx;let s=-1;for(;++s<this.attachers.length;){const i=this.attachers[s];n.use(...i)}return n.data(Zm(!0,{},this.namespace)),n}data(n,s){return typeof n=="string"?arguments.length===2?(rh("data",this.frozen),this.namespace[n]=s,this):C3.call(this.namespace,n)&&this.namespace[n]||void 0:n?(rh("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const l=s.call(n,...i);typeof l=="function"&&this.transformers.use(l)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const s=Td(n),i=this.parser||this.Parser;return th("parse",i),i(String(s),s)}process(n,s){const i=this;return this.freeze(),th("process",this.parser||this.Parser),nh("process",this.compiler||this.Compiler),s?l(void 0,s):new Promise(l);function l(c,d){const u=Td(n),h=i.parse(u);i.run(h,u,function(x,p,g){if(x||!p||!g)return f(x);const b=p,w=i.stringify(b,g);A3(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,i;return this.freeze(),th("processSync",this.parser||this.Parser),nh("processSync",this.compiler||this.Compiler),this.process(n,l),Ey("processSync","process",s),i;function l(c,d){s=!0,Ny(c),i=d}}run(n,s,i){Cy(n),this.freeze();const l=this.transformers;return!i&&typeof s=="function"&&(i=s,s=void 0),i?c(void 0,i):new Promise(c);function c(d,u){const h=Td(s);l.run(n,h,f);function f(x,p,g){const b=p||n;x?u(x):d?d(b):i(void 0,b,g)}}}runSync(n,s){let i=!1,l;return this.run(n,s,c),Ey("runSync","run",i),l;function c(d,u){Ny(d),l=u,i=!0}}stringify(n,s){this.freeze();const i=Td(s),l=this.compiler||this.Compiler;return nh("stringify",l),Cy(n),l(n,i)}use(n,...s){const i=this.attachers,l=this.namespace;if(rh("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&&(l.settings=Zm(!0,l.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<i.length;)if(i[p][0]===f){g=p;break}if(g===-1)i.push([f,...x]);else if(x.length>0){let[b,...w]=x;const k=i[g][1];Yh(k)&&Yh(b)&&(b=Zm(!0,k,b)),i[g]=[f,b,...w]}}}}const E3=new Bx().freeze();function th(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function nh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function rh(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 Cy(e){if(!Yh(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ey(e,n,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Td(e){return T3(e)?e:new Lj(e)}function T3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function A3(e){return typeof e=="string"||_3(e)}function _3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const M3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ty=[],Ay={allowDangerousHtml:!0},R3=/^(https?|ircs?|mailto|xmpp)$/i,O3=[{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 _y(e){const n=D3(e),s=L3(e);return I3(n.runSync(n.parse(s),s),e)}function D3(e){const n=e.rehypePlugins||Ty,s=e.remarkPlugins||Ty,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ay}:Ay;return E3().use(xE).use(s).use(c3,i).use(n)}function L3(e){const n=e.children||"",s=new Lj;return typeof n=="string"&&(s.value=n),s}function I3(e,n){const s=n.allowedElements,i=n.allowElement,l=n.components,c=n.disallowedElements,d=n.skipHtml,u=n.unwrapDisallowed,h=n.urlTransform||z3;for(const x of O3)Object.hasOwn(n,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+M3+x.id,void 0);return $x(e,f),Qk(e,{Fragment:t.Fragment,components:l,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 Gm)if(Object.hasOwn(Gm,b)&&Object.hasOwn(x.properties,b)){const w=x.properties[b],k=Gm[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&&i&&typeof p=="number"&&(b=!i(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 z3(e){const n=e.indexOf(":"),s=e.indexOf("?"),i=e.indexOf("#"),l=e.indexOf("/");return n===-1||l!==-1&&n>l||s!==-1&&n>s||i!==-1&&n>i||R3.test(e.slice(0,n))?e:""}function My(e,n){const s=String(e);if(typeof n!="string")throw new TypeError("Expected character");let i=0,l=s.indexOf(n);for(;l!==-1;)i++,l=s.indexOf(n,l+n.length);return i}function $3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function B3(e,n,s){const l=Su((s||{}).ignore||[]),c=H3(n);let d=-1;for(;++d<c.length;)Dj(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(l(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 H3(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const s=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<s.length;){const l=s[i];n.push([P3(l[0]),U3(l[1])])}return n}function P3(e){return typeof e=="string"?new RegExp($3(e),"g"):e}function U3(e){return typeof e=="function"?e:function(){return e}}const sh="phrasing",ah=["autolink","link","image","label"];function q3(){return{transforms:[W3],enter:{literalAutolink:V3,literalAutolinkEmail:ih,literalAutolinkHttp:ih,literalAutolinkWww:ih},exit:{literalAutolink:K3,literalAutolinkEmail:X3,literalAutolinkHttp:Y3,literalAutolinkWww:G3}}}function F3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:sh,notInConstruct:ah},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:sh,notInConstruct:ah},{character:":",before:"[ps]",after:"\\/",inConstruct:sh,notInConstruct:ah}]}}function V3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ih(e){this.config.enter.autolinkProtocol.call(this,e)}function Y3(e){this.config.exit.autolinkProtocol.call(this,e)}function G3(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 X3(e){this.config.exit.autolinkEmail.call(this,e)}function K3(e){this.exit(e)}function W3(e){B3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Z3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Q3]],{ignore:["link","linkReference"]})}function Z3(e,n,s,i,l){let c="";if(!Ij(l)||(/^w/i.test(n)&&(s=n+s,n="",c="http://"),!J3(s)))return!1;const d=e4(s+i);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 Q3(e,n,s,i){return!Ij(i,!0)||/[-\d_]$/.test(s)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+s,children:[{type:"text",value:n+"@"+s}]}}function J3(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 e4(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let s=n[0],i=s.indexOf(")");const l=My(e,"(");let c=My(e,")");for(;i!==-1&&l>c;)e+=s.slice(0,i+1),s=s.slice(i+1),i=s.indexOf(")"),c++;return[e,s]}function Ij(e,n){const s=e.input.charCodeAt(e.index-1);return(e.index===0||Oi(s)||wu(s))&&(!n||s!==47)}zj.peek=c4;function t4(){this.buffer()}function n4(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function r4(){this.buffer()}function s4(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function a4(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 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 o4(e){this.exit(e)}function c4(){return"["}function zj(e,n,s,i){const l=s.createTracker(i);let c=l.move("[^");const d=s.enter("footnoteReference"),u=s.enter("reference");return c+=l.move(s.safe(s.associationId(e),{after:"]",before:c})),u(),d(),c+=l.move("]"),c}function d4(){return{enter:{gfmFootnoteCallString:t4,gfmFootnoteCall:n4,gfmFootnoteDefinitionLabelString:r4,gfmFootnoteDefinition:s4},exit:{gfmFootnoteCallString:a4,gfmFootnoteCall:i4,gfmFootnoteDefinitionLabelString:l4,gfmFootnoteDefinition:o4}}}function u4(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:s,footnoteReference:zj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function s(i,l,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(i),{before:h,after:"]"})),x(),h+=u.move("]:"),i.children&&i.children.length>0&&(u.shift(4),h+=u.move((n?`
|
|
24
|
+
`:" ")+c.indentLines(c.containerFlow(i,u.current()),n?$j:f4))),f(),h}}function f4(e,n,s){return n===0?e:$j(e,n,s)}function $j(e,n,s){return(s?"":" ")+e}const m4=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Bj.peek=b4;function h4(){return{canContainEols:["delete"],enter:{strikethrough:p4},exit:{strikethrough:g4}}}function x4(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:m4}],handlers:{delete:Bj}}}function p4(e){this.enter({type:"delete",children:[]},e)}function g4(e){this.exit(e)}function Bj(e,n,s,i){const l=s.createTracker(i),c=s.enter("strikethrough");let d=l.move("~~");return d+=s.containerPhrasing(e,{...l.current(),before:d,after:"~"}),d+=l.move("~~"),c(),d}function b4(){return"~"}function y4(e){return e.length}function v4(e,n){const s=n||{},i=(s.align||[]).concat(),l=s.stringLength||y4,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=j4(e[x][E]);if(s.alignDelimiters!==!1){const N=l(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 i=="object"&&"length"in i)for(;++p<f;)c[p]=Ry(i[p]);else{const k=Ry(i);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 j4(e){return e==null?"":String(e)}function Ry(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 w4(e,n,s,i){const l=s.enter("blockquote"),c=s.createTracker(i);c.move("> "),c.shift(2);const d=s.indentLines(s.containerFlow(e,c.current()),N4);return l(),d}function N4(e,n,s){return">"+(s?"":" ")+e}function k4(e,n){return Oy(e,n.inConstruct,!0)&&!Oy(e,n.notInConstruct,!1)}function Oy(e,n,s){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return s;let i=-1;for(;++i<n.length;)if(e.includes(n[i]))return!0;return!1}function Dy(e,n,s,i){let l=-1;for(;++l<s.unsafe.length;)if(s.unsafe[l].character===`
|
|
26
|
+
`&&k4(s.stack,s.unsafe[l]))return/[ \t]/.test(i.before)?"":" ";return`\\
|
|
27
|
+
`}function S4(e,n){const s=String(e);let i=s.indexOf(n),l=i,c=0,d=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===l?++c>d&&(d=c):c=1,l=i+n.length,i=s.indexOf(n,l);return d}function C4(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 E4(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 T4(e,n,s,i){const l=E4(s),c=e.value||"",d=l==="`"?"GraveAccent":"Tilde";if(C4(e,s)){const p=s.enter("codeIndented"),g=s.indentLines(c,A4);return p(),g}const u=s.createTracker(i),h=l.repeat(Math.max(S4(c,l)+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 A4(e,n,s){return(s?"":" ")+e}function Hx(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 _4(e,n,s,i){const l=Hx(s),c=l==='"'?"Quote":"Apostrophe",d=s.enter("definition");let u=s.enter("label");const h=s.createTracker(i);let f=h.move("[");return f+=h.move(s.safe(s.associationId(e),{before:f,after:"]",...h.current()})),f+=h.move("]: "),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(" "+l),f+=h.move(s.safe(e.title,{before:f,after:l,...h.current()})),f+=h.move(l),u()),d(),f}function M4(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 Jo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function nu(e,n,s){const i=Ml(e),l=Ml(n);return i===void 0?l===void 0?s==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Hj.peek=R4;function Hj(e,n,s,i){const l=M4(s),c=s.enter("emphasis"),d=s.createTracker(i),u=d.move(l);let h=d.move(s.containerPhrasing(e,{after:l,before:u,...d.current()}));const f=h.charCodeAt(0),x=nu(i.before.charCodeAt(i.before.length-1),f,l);x.inside&&(h=Jo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=nu(i.after.charCodeAt(0),p,l);g.inside&&(h=h.slice(0,-1)+Jo(p));const b=d.move(l);return c(),s.attentionEncodeSurroundingInfo={after:g.outside,before:x.outside},u+h+b}function R4(e,n,s){return s.options.emphasis||"*"}function O4(e,n){let s=!1;return $x(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return s=!0,Fh}),!!((!e.depth||e.depth<3)&&Mx(e)&&(n.options.setext||s))}function D4(e,n,s,i){const l=Math.max(Math.min(6,e.depth||1),1),c=s.createTracker(i);if(O4(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
|
+
`+(l===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
|
|
35
|
+
`))+1))}const d="#".repeat(l),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=Jo(f.charCodeAt(0))+f.slice(1)),f=f?d+" "+f:d,s.options.closeAtx&&(f+=" "+d),h(),u(),f}Pj.peek=L4;function Pj(e){return e.value||""}function L4(){return"<"}Uj.peek=I4;function Uj(e,n,s,i){const l=Hx(s),c=l==='"'?"Quote":"Apostrophe",d=s.enter("image");let u=s.enter("label");const h=s.createTracker(i);let f=h.move("![");return f+=h.move(s.safe(e.alt,{before:f,after:"]",...h.current()})),f+=h.move("]("),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(" "+l),f+=h.move(s.safe(e.title,{before:f,after:l,...h.current()})),f+=h.move(l),u()),f+=h.move(")"),d(),f}function I4(){return"!"}qj.peek=z4;function qj(e,n,s,i){const l=e.referenceType,c=s.enter("imageReference");let d=s.enter("label");const u=s.createTracker(i);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(),l==="full"||!f||f!==p?h+=u.move(p+"]"):l==="shortcut"?h=h.slice(0,-1):h+=u.move("]"),h}function z4(){return"!"}Fj.peek=$4;function Fj(e,n,s){let i=e.value||"",l="`",c=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(i);)l+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++c<s.unsafe.length;){const d=s.unsafe[c],u=s.compilePattern(d);let h;if(d.atBreak)for(;h=u.exec(i);){let f=h.index;i.charCodeAt(f)===10&&i.charCodeAt(f-1)===13&&f--,i=i.slice(0,f)+" "+i.slice(h.index+1)}}return l+i+l}function $4(){return"`"}function Vj(e,n){const s=Mx(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))}Yj.peek=B4;function Yj(e,n,s,i){const l=Hx(s),c=l==='"'?"Quote":"Apostrophe",d=s.createTracker(i);let u,h;if(Vj(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(" "+l),f+=d.move(s.safe(e.title,{before:f,after:l,...d.current()})),f+=d.move(l),h()),f+=d.move(")"),u(),f}function B4(e,n,s){return Vj(e,s)?"<":"["}Gj.peek=H4;function Gj(e,n,s,i){const l=e.referenceType,c=s.enter("linkReference");let d=s.enter("label");const u=s.createTracker(i);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(),l==="full"||!f||f!==p?h+=u.move(p+"]"):l==="shortcut"?h=h.slice(0,-1):h+=u.move("]"),h}function H4(){return"["}function Px(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function P4(e){const n=Px(e),s=e.options.bulletOther;if(!s)return n==="*"?"-":"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(s===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+s+"`) to be different");return s}function U4(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function Xj(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function q4(e,n,s,i){const l=s.enter("list"),c=s.bulletCurrent;let d=e.ordered?U4(s):Px(s);const u=e.ordered?d==="."?")":".":P4(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),Xj(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,i);return s.bulletLastUsed=d,s.bulletCurrent=c,l(),f}function F4(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 V4(e,n,s,i){const l=F4(s);let c=s.bulletCurrent||Px(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;(l==="tab"||l==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(d=Math.ceil(d/4)*4);const u=s.createTracker(i);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 Y4(e,n,s,i){const l=s.enter("paragraph"),c=s.enter("phrasing"),d=s.containerPhrasing(e,i);return c(),l(),d}const G4=Su(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function X4(e,n,s,i){return(e.children.some(function(d){return G4(d)})?s.containerPhrasing:s.containerFlow).call(s,e,i)}function K4(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}Kj.peek=W4;function Kj(e,n,s,i){const l=K4(s),c=s.enter("strong"),d=s.createTracker(i),u=d.move(l+l);let h=d.move(s.containerPhrasing(e,{after:l,before:u,...d.current()}));const f=h.charCodeAt(0),x=nu(i.before.charCodeAt(i.before.length-1),f,l);x.inside&&(h=Jo(f)+h.slice(1));const p=h.charCodeAt(h.length-1),g=nu(i.after.charCodeAt(0),p,l);g.inside&&(h=h.slice(0,-1)+Jo(p));const b=d.move(l+l);return c(),s.attentionEncodeSurroundingInfo={after:g.outside,before:x.outside},u+h+b}function W4(e,n,s){return s.options.strong||"*"}function Z4(e,n,s,i){return s.safe(e.value,i)}function Q4(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 J4(e,n,s){const i=(Xj(s)+(s.options.ruleSpaces?" ":"")).repeat(Q4(s));return s.options.ruleSpaces?i.slice(0,-1):i}const Wj={blockquote:w4,break:Dy,code:T4,definition:_4,emphasis:Hj,hardBreak:Dy,heading:D4,html:Pj,image:Uj,imageReference:qj,inlineCode:Fj,link:Yj,linkReference:Gj,list:q4,listItem:V4,paragraph:Y4,root:X4,strong:Kj,text:Z4,thematicBreak:J4};function eT(){return{enter:{table:tT,tableData:Ly,tableHeader:Ly,tableRow:rT},exit:{codeText:sT,table:nT,tableData:lh,tableHeader:lh,tableRow:lh}}}function tT(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 nT(e){this.exit(e),this.data.inTable=void 0}function rT(e){this.enter({type:"tableRow",children:[]},e)}function lh(e){this.exit(e)}function Ly(e){this.enter({type:"tableCell",children:[]},e)}function sT(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,aT));const s=this.stack[this.stack.length-1];s.type,s.value=n,this.exit(e)}function aT(e,n){return n==="|"?n:e}function iT(e){const n=e||{},s=n.tableCellPadding,i=n.tablePipeAlign,l=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 v4(b,{align:w,alignDelimiters:i,padding:s,stringLength:l})}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=Wj.inlineCode(b,w,k);return k.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function lT(){return{exit:{taskListCheckValueChecked:Iy,taskListCheckValueUnchecked:Iy,paragraph:cT}}}function oT(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dT}}}function Iy(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function cT(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const i=s.children[0];if(i&&i.type==="text"){const l=n.children;let c=-1,d;for(;++c<l.length;){const u=l[c];if(u.type==="paragraph"){d=u;break}}d===s&&(i.value=i.value.slice(1),i.value.length===0?s.children.shift():s.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,s.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function dT(e,n,s,i){const l=e.children[0],c=typeof e.checked=="boolean"&&l&&l.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",u=s.createTracker(i);c&&u.move(d);let h=Wj.listItem(e,n,s,{...i,...u.current()});return c&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),h;function f(x){return x+d}}function uT(){return[q3(),d4(),h4(),eT(),lT()]}function fT(e){return{extensions:[F3(),u4(e),x4(),iT(e),oT()]}}const mT={tokenize:yT,partial:!0},Zj={tokenize:vT,partial:!0},Qj={tokenize:jT,partial:!0},Jj={tokenize:wT,partial:!0},hT={tokenize:NT,partial:!0},ew={name:"wwwAutolink",tokenize:gT,previous:nw},tw={name:"protocolAutolink",tokenize:bT,previous:rw},wa={name:"emailAutolink",tokenize:pT,previous:sw},Ks={};function xT(){return{text:Ks}}let ki=48;for(;ki<123;)Ks[ki]=wa,ki++,ki===58?ki=65:ki===91&&(ki=97);Ks[43]=wa;Ks[45]=wa;Ks[46]=wa;Ks[95]=wa;Ks[72]=[wa,tw];Ks[104]=[wa,tw];Ks[87]=[wa,ew];Ks[119]=[wa,ew];function pT(e,n,s){const i=this;let l,c;return d;function d(p){return!Xh(p)||!sw.call(i,i.previous)||Ux(i.events)?s(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(p))}function u(p){return Xh(p)?(e.consume(p),u):p===64?(e.consume(p),h):s(p)}function h(p){return p===46?e.check(hT,x,f)(p):p===45||p===95||Er(p)?(c=!0,e.consume(p),h):x(p)}function f(p){return e.consume(p),l=!0,h}function x(p){return c&&l&&Mr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(p)):s(p)}}function gT(e,n,s){const i=this;return l;function l(d){return d!==87&&d!==119||!nw.call(i,i.previous)||Ux(i.events)?s(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mT,e.attempt(Zj,e.attempt(Qj,c),s),s)(d))}function c(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(d)}}function bT(e,n,s){const i=this;let l="",c=!1;return d;function d(p){return(p===72||p===104)&&rw.call(i,i.previous)&&!Ux(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),l+=String.fromCodePoint(p),e.consume(p),u):s(p)}function u(p){if(Mr(p)&&l.length<5)return l+=String.fromCodePoint(p),e.consume(p),u;if(p===58){const g=l.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||Jd(p)||Tn(p)||Oi(p)||wu(p)?s(p):e.attempt(Zj,e.attempt(Qj,x),s)(p)}function x(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(p)}}function yT(e,n,s){let i=0;return l;function l(d){return(d===87||d===119)&&i<3?(i++,e.consume(d),l):d===46&&i===3?(e.consume(d),c):s(d)}function c(d){return d===null?s(d):n(d)}}function vT(e,n,s){let i,l,c;return d;function d(f){return f===46||f===95?e.check(Jj,h,u)(f):f===null||Tn(f)||Oi(f)||f!==45&&wu(f)?h(f):(c=!0,e.consume(f),d)}function u(f){return f===95?i=!0:(l=i,i=void 0),e.consume(f),d}function h(f){return l||i||!c?s(f):n(f)}}function jT(e,n){let s=0,i=0;return l;function l(d){return d===40?(s++,e.consume(d),l):d===41&&i<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(Jj,n,c)(d):d===null||Tn(d)||Oi(d)?n(d):(e.consume(d),l)}function c(d){return d===41&&i++,e.consume(d),l}}function wT(e,n,s){return i;function i(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),i):u===38?(e.consume(u),c):u===93?(e.consume(u),l):u===60||u===null||Tn(u)||Oi(u)?n(u):s(u)}function l(u){return u===null||u===40||u===91||Tn(u)||Oi(u)?n(u):i(u)}function c(u){return Mr(u)?d(u):s(u)}function d(u){return u===59?(e.consume(u),i):Mr(u)?(e.consume(u),d):s(u)}}function NT(e,n,s){return i;function i(c){return e.consume(c),l}function l(c){return Er(c)?s(c):n(c)}}function nw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tn(e)}function rw(e){return!Mr(e)}function sw(e){return!(e===47||Xh(e))}function Xh(e){return e===43||e===45||e===46||e===95||Er(e)}function Ux(e){let n=e.length,s=!1;for(;n--;){const i=e[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){s=!0;break}if(i._gfmAutolinkLiteralWalkedInto){s=!1;break}}return e.length>0&&!s&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const kT={tokenize:RT,partial:!0};function ST(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:AT,continuation:{tokenize:_T},exit:MT}},text:{91:{name:"gfmFootnoteCall",tokenize:TT},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:CT,resolveTo:ET}}}}function CT(e,n,s){const i=this;let l=i.events.length;const c=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;l--;){const h=i.events[l][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(i.sliceSerialize({start:d.end,end:i.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 ET(e,n){let s=e.length;for(;s--;)if(e[s][1].type==="labelImage"&&e[s][0]==="enter"){e[s][1];break}e[s+1][1].type="data",e[s+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[s+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[s+3][1].end),end:Object.assign({},e[s+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},l.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",i,n],e[s+3],e[s+4],["enter",l,n],["exit",l,n],["enter",c,n],["enter",d,n],["exit",d,n],["exit",c,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(s,e.length-s+1,...u),e}function TT(e,n,s){const i=this,l=i.parser.gfmFootnotes||(i.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 l.includes(_s(i.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 AT(e,n,s){const i=this,l=i.parser.gfmFootnotes||(i.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(i.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"),l.includes(c)||l.push(c),nn(e,b,"gfmFootnoteDefinitionWhitespace")):s(w)}function b(w){return n(w)}}function _T(e,n,s){return e.check(hc,n,e.attempt(kT,n,s))}function MT(e){e.exit("gfmFootnoteDefinition")}function RT(e,n,s){const i=this;return nn(e,l,"gfmFootnoteDefinitionIndent",5);function l(c){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?n(c):s(c)}}function OT(e){let s=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:c,resolveAll:l};return s==null&&(s=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(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,Nu(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=Ml(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=Ml(w);return C._open=!E||E===2&&!!k,C._close=!k||k===2&&!!E,u(w)}}}class DT{constructor(){this.map=[]}add(n,s,i){LT(this,n,s,i)}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 i=[];for(;s>0;)s-=1,i.push(n.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),n.length=this.map[s][0];i.push(n.slice()),n.length=0;let l=i.pop();for(;l;){for(const c of l)n.push(c);l=i.pop()}this.map.length=0}}function LT(e,n,s,i){let l=0;if(!(s===0&&i.length===0)){for(;l<e.map.length;){if(e.map[l][0]===n){e.map[l][1]+=s,e.map[l][2].push(...i);return}l+=1}e.map.push([n,s,i])}}function IT(e,n){let s=!1;const i=[];for(;n<e.length;){const l=e[n];if(s){if(l[0]==="enter")l[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(l[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const c=i.length-1;i[c]=i[c]==="left"?"center":"right"}}else if(l[1].type==="tableDelimiterRow")break}else l[0]==="enter"&&l[1].type==="tableDelimiterRow"&&(s=!0);n+=1}return i}function zT(){return{flow:{null:{name:"table",tokenize:$T,resolveAll:BT}}}}function $T(e,n,s){const i=this;let l=0,c=0,d;return u;function u(L){let P=i.events.length-1;for(;P>-1;){const T=i.events[P][1].type;if(T==="lineEnding"||T==="linePrefix")P--;else break}const G=P>-1?i.events[P][1].type:null,$=G==="tableHead"||G==="tableRow"?_:h;return $===_&&i.parser.lazy[i.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,i.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,l+=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 i.interrupt=!1,i.parser.lazy[i.now().line]?s(L):(e.enter("tableDelimiterRow"),d=!1,Gt(L)?nn(e,w,"linePrefix",i.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||l!==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 BT(e,n){let s=-1,i=!0,l=0,c=[0,0,0,0],d=[0,0,0,0],u=!1,h=0,f,x,p;const g=new DT;for(;++s<e.length;){const b=e[s],w=b[1];b[0]==="enter"?w.type==="tableHead"?(u=!1,h!==0&&(zy(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"?(i=!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]])),l=w.type==="tableDelimiterRow"?2:x?3:1):l&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(i=!1,d[2]===0&&(c[1]!==0&&(d[0]=d[1],p=Ad(g,n,c,l,void 0,p),c=[0,0,0,0]),d[2]=s)):w.type==="tableCellDivider"&&(i?i=!1:(c[1]!==0&&(d[0]=d[1],p=Ad(g,n,c,l,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=Ad(g,n,c,l,s,p)):d[1]!==0&&(p=Ad(g,n,d,l,s,p)),l=0):l&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(d[3]=s)}for(h!==0&&zy(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=IT(n.events,s))}return e}function Ad(e,n,s,i,l,c){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",u="tableContent";s[0]!==0&&(c.end=Object.assign({},Nl(n.events,s[0])),e.add(s[0],0,[["exit",c,n]]));const h=Nl(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=Nl(n.events,s[2]),x=Nl(n.events,s[3]),p={type:u,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(s[2],0,[["enter",p,n]]),i!==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 l!==void 0&&(c.end=Object.assign({},Nl(n.events,l)),e.add(l,0,[["exit",c,n]]),c=void 0),c}function zy(e,n,s,i,l){const c=[],d=Nl(n.events,s);l&&(l.end=Object.assign({},d),c.push(["exit",l,n])),i.end=Object.assign({},d),c.push(["exit",i,n]),e.add(s+1,0,c)}function Nl(e,n){const s=e[n],i=s[0]==="enter"?"start":"end";return s[1][i]}const HT={name:"tasklistCheck",tokenize:UT};function PT(){return{text:{91:HT}}}function UT(e,n,s){const i=this;return l;function l(h){return i.previous!==null||!i._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:qT},n,s)(h):s(h)}}function qT(e,n,s){return nn(e,i,"whitespace");function i(l){return l===null?s(l):n(l)}}function FT(e){return xj([xT(),ST(),OT(e),zT(),PT()])}const VT={};function $y(e){const n=this,s=e||VT,i=n.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),c=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(FT(s)),c.push(uT()),d.push(fT(s))}const YT="modulepreload",GT=function(e){return"/"+e},By={},XT=function(n,s,i){let l=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");l=f(s.map(x=>{if(x=GT(x),x in By)return;By[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":YT,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 l.then(u=>{for(const h of u||[])h.status==="rejected"&&c(h.reason);return n().catch(c)})},KT=y.lazy(()=>XT(()=>Promise.resolve().then(()=>uA),void 0).then(e=>({default:e.MarkdownMessage})));let bl=[],Hy=60;function WT(e){const n=y.useRef(e);n.current=e;const[s]=y.useState(()=>++Hy);return y.useEffect(()=>{const i=()=>n.current();bl.push(i);const l=c=>{c.key==="Escape"&&bl[bl.length-1]===i&&(c.preventDefault(),i())};return window.addEventListener("keydown",l,!0),()=>{window.removeEventListener("keydown",l,!0),bl=bl.filter(c=>c!==i),bl.length===0&&(Hy=60)}},[]),s}const ru=new Map,su=new Set,Vd=new Map;let Yd=null;function Py(e){const n=Vd.get(e);if(n)for(const s of n)s()}function ZT(){Yd=null;const e=[...su];su.clear(),e.length!==0&&se.files.check(e).then(({results:n})=>{for(const[s,i]of Object.entries(n))ru.set(s,i),Py(s)}).catch(()=>{for(const n of e)ru.set(n,{exists:!1,isFile:!1,type:"unknown"}),Py(n)})}function QT(e){ru.has(e)||su.has(e)||(su.add(e),Yd&&clearTimeout(Yd),Yd=setTimeout(ZT,30))}function JT(e,n){let s=Vd.get(e);return s||(s=new Set,Vd.set(e,s)),s.add(n),()=>{s.delete(n),s.size===0&&Vd.delete(e)}}function eA(e){const n=y.useCallback(l=>JT(e,l),[e]),s=y.useCallback(()=>ru.get(e),[e]),i=y.useSyncExternalStore(n,s,s);return y.useEffect(()=>{QT(e)},[e]),i}const tA=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function nA(e){return e.length<2||e.length>500?!1:tA.test(e)}function rA({filePath:e,onClose:n}){const s=WT(n),[i,l]=y.useState(!0),[c,d]=y.useState(null),[u,h]=y.useState(""),[f,x]=y.useState(""),[p,g]=y.useState("");y.useEffect(()=>{l(!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(()=>{l(!1)})},[e]);const b=p||e.split(/[/\\]/).pop()||e;return ju.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:[i&&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})]}),!i&&!c&&f==="markdown"&&t.jsx(y.Suspense,{fallback:t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:t.jsx(KT,{content:u,className:"text-sm"})}),!i&&!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"})}),!i&&!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 sA({path:e}){const n=eA(e),[s,i]=y.useState(null),l=n?.exists??!1,c=n?.type==="markdown",d=y.useCallback(f=>{f.preventDefault(),f.stopPropagation(),l&&(c?i(e):se.files.reveal(e))},[l,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?l?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(rA,{filePath:s,onClose:()=>i(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 aA(e,n){const s=e.cloneNode(!0),i=n==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},l={p:`margin:0 0 10px;color:${i.text};line-height:1.7;`,h1:`font-size:1.6em;font-weight:700;color:${i.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${i.border};padding-bottom:6px;`,h2:`font-size:1.35em;font-weight:700;color:${i.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:1.15em;font-weight:600;color:${i.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:1em;font-weight:600;color:${i.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${i.strong};`,em:"font-style:italic;",a:`color:${i.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${i.text};`,blockquote:`border-left:3px solid ${i.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${i.blockquoteText};`,hr:`border:none;border-top:1px solid ${i.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${i.tableHeaderBg};`,th:`border:1px solid ${i.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${i.tableHeaderText};`,td:`border:1px solid ${i.tableBorder};padding:8px 12px;color:${i.text};`,img:"max-width:100%;height:auto;"};function c(d){d.removeAttribute("class");const u=d.tagName.toLowerCase();if(u==="pre"){d.setAttribute("style",`background:${i.preBg};color:${i.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${i.preBorder};`);const h=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:${i.codeBg};color:${i.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):l[u]&&d.setAttribute("style",l[u]),Array.from(d.children).forEach(c)}return s.removeAttribute("class"),Array.from(s.children).forEach(d=>c(d)),`<div style="background:${i.bg};color:${i.text};padding:20px 24px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif;font-size:15px;line-height:1.7;max-width:800px;">${s.innerHTML}</div>`}async function qx(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 i=aA(e,n);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([i],{type:"text/html"}),"text/plain":new Blob([s],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await qx(s),method:"text"}}}const lA=/<think>([\s\S]*?)(<\/think>|$)/g;function oA(e){const n=[];let s=e.replace(lA,(i,l)=>{const c=l.trim();return c&&n.push(c),""});return s=s.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:n,rest:s.trim()}}const Kh="#mention:";function cA(e){return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(n,s,i)=>{const l=s??i;return`[@${l}](${Kh}${encodeURIComponent(l)})`})}const oh={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 nA(s)?t.jsx(sA,{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 dA({content:e,contentRef:n}){const[s,i]=y.useState(!1),[l,c]=y.useState(null),d=y.useRef(null);y.useEffect(()=>{if(!s)return;const x=p=>{d.current&&!d.current.contains(p.target)&&i(!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 qx(e);u(x?"Copied!":"Failed"),i(!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"),i(!1)};return t.jsxs("div",{className:"absolute -top-1 -right-1 z-10",ref:d,children:[l&&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:l}),t.jsx("button",{onClick:()=>i(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 qn({content:e,className:n="",onMentionClick:s}){const{thinking:i,rest:l}=oA(e),c=y.useRef(null),d=y.useMemo(()=>s?cA(l):l,[l,s]),u=y.useMemo(()=>s?{...oh,a:({href:h,children:f})=>{if(h?.startsWith(Kh)){const x=decodeURIComponent(h.slice(Kh.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})}}:oh,[s]);return t.jsxs("div",{className:"relative group/md",children:[t.jsx(dA,{content:e,contentRef:c}),t.jsx("div",{ref:c,children:t.jsxs("div",{className:`prose prose-sm max-w-none break-words ${n}`,children:[i.length>0&&(()=>{const h=i.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(_y,{remarkPlugins:[$y],components:oh,children:h})})})]})})(),t.jsx(_y,{remarkPlugins:[$y],components:u,children:d})]})})]})}const uA=Object.freeze(Object.defineProperty({__proto__:null,MarkdownMessage:qn},Symbol.toStringTag,{value:"Module"})),Uy={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},ch={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"},fA={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 qy(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Fy(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 mA(){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 i=e.createOscillator();i.type="sine",i.frequency.setValueAtTime(880,n),i.frequency.setValueAtTime(1174.66,n+.15),i.connect(s),i.start(n),i.stop(n+.6),i.onended=()=>e.close()}catch{}}function Wh({collapsed:e,userId:n}){const[s,i]=y.useState(!1),[l,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)||i(!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&&mA(),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:()=>{i(!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&&ju.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 ${l==="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 ${l==="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:()=>i(!1),className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:"Close",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),l==="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:[l==="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:ch.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:qy(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(qn,{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))]})),l==="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=fA[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:ch[S.type]??ch.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 ${Uy[S.priority]??Uy.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(qn,{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:qy(S.createdAt)}),Fy(S)&&t.jsx("span",{className:`text-[10px] font-medium ${D}`,children:Fy(S)})]})]})]},S.id)})}))]})]}),document.body)]})}const hA="(max-width: 767px)";let dh=null;function aw(){return dh||(dh=window.matchMedia(hA)),dh}function xA(e){const n=aw();return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function pA(){return aw().matches}function gA(){return!1}function Yr(){return y.useSyncExternalStore(xA,pA,gA)}function Vy({authUser:e}={}){const n=Yr(),[s,i]=y.useState([]),[l,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=>i(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 l.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}})},[l,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(Wh,{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(_d,{label:"Active Agents",value:_,total:s.length,color:"indigo",onClick:()=>bt.navigate(ge.TEAM)}),t.jsx(_d,{label:"Tasks In Progress",value:N,color:"blue",onClick:()=>bt.navigate(ge.WORK)}),t.jsx(_d,{label:"Pending Queue",value:M,color:"amber",onClick:()=>bt.navigate(ge.WORK)}),t.jsx(_d,{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(yA,{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(l.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 ${Zh[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:Yy(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: ",Yy(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 Zh={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"},bA={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 yA({statusCounts:e,total:n}){const s=Object.entries(e).filter(([,i])=>i>0).sort(([,i],[,l])=>l-i);return t.jsxs("div",{children:[t.jsx("div",{className:"flex h-4 rounded-full overflow-hidden gap-0.5 mb-4",children:s.map(([i,l])=>t.jsx("div",{className:`${Zh[i]??"bg-gray-600"} transition-all`,style:{width:`${l/n*100}%`},title:`${i}: ${l}`},i))}),t.jsx("div",{className:"flex gap-4 flex-wrap",children:s.map(([i,l])=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-sm ${Zh[i]??"bg-gray-600"}`}),t.jsx("span",{className:"text-xs text-fg-secondary capitalize",children:i.replace(/_/g," ")}),t.jsx("span",{className:`text-xs font-semibold ${bA[i]??"text-fg-secondary"}`,children:l})]},i))})]})}function _d({label:e,value:n,total:s,color:i,onClick:l}){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[i]??c.indigo;return t.jsxs("div",{onClick:l,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:i,color:l,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[l]??"bg-gray-400",x=h[l]??"text-fg-secondary";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:e}),t.jsx("span",{className:`text-sm font-semibold ${x}`,children:c?`${i}${n}`:t.jsxs(t.Fragment,{children:[n,t.jsx("span",{className:"text-[10px] font-normal text-fg-tertiary",children:i})]})})]}),t.jsx("div",{className:"w-full h-1.5 bg-surface-elevated rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${f} transition-all`,style:{width:`${d}%`}})})]})}function Yy(e){if(e===0)return"0 B";const n=["B","KB","MB","GB"],s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n.length-1),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}const Gy={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 Di(e){const n=e.includes("__")?e.split("__").pop():e;return Gy[n]??Gy[e]??{label:n.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙"}}function Fx(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function vA(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),l=String(n.getHours()).padStart(2,"0"),c=String(n.getMinutes()).padStart(2,"0"),d=String(n.getSeconds()).padStart(2,"0");return`${s}-${i} ${l}:${c}:${d}`}function Qh(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function Xy(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function jA(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,i])=>({key:s,value:typeof i=="string"?i:JSON.stringify(i,null,2)}))}function wA(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 Ky(e,n){const s=new Map;let i=null;for(const l of e)if(l.type==="tool_start"&&(l.content==="spawn_subagent"||l.content==="spawn_subagents"))i=l.seq,s.set(l.seq,[]);else if(l.type==="tool_end"&&(l.content==="spawn_subagent"||l.content==="spawn_subagents")){if(i!==null){const c=s.get(i);c&&s.set(l.seq,c)}i=null}else if(i!==null&&l.type.startsWith("subagent_")){const c=l.type.replace("subagent_",""),d=l.metadata;s.get(i)?.push({eventType:c,content:l.content,metadata:d})}return n.map(l=>{if(l.type!=="tool")return l;const c=l.key;if(!c)return l;const d=c.replace(/^t[se]_/,""),u=parseInt(d,10);if(isNaN(u))return l;const h=s.get(u);return!h||h.length===0?l:{...l,info:{...l.info,subagentLogs:h}}})}function ec(e){const n=new Set;for(let s=0;s<e.length;s++){const i=e[s];if(i.type==="tool"&&(i.info.status==="done"||i.info.status==="error"))for(let l=s-1;l>=0;l--){const c=e[l];if(c.type==="tool"&&c.info.status==="running"&&c.info.tool===i.info.tool&&!n.has(l)){n.add(l);break}}}return e.filter((s,i)=>!n.has(i))}function tc(e){const n=vA(e.createdAt),s=e.createdAt,i=e.metadata;switch(e.type){case"text":return i?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const l=i?.action;return l&&["chat","chat_stream","task_execution","respond_in_session"].includes(l)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:i?.arguments}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:i?.success===!1?"error":"done",args:i?.arguments,result:i?.result,error:i?.error,durationMs:i?.durationMs,subagentLogs:i?.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 i=s.task;return{taskId:i.id,title:i.title,description:i.description,assignedAgentId:i.assignedAgentId,priority:i.priority}}catch{return null}}function lw(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const i=s.requirement;return i.status!=="pending"?null:{requirementId:i.id,title:i.title,description:i.description,priority:i.priority}}catch{return null}}function NA(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const i=`${s.tool}_${s.ts}`;n.push({key:i,tool:s.tool,status:"running"})}else for(let i=n.length-1;i>=0;i--)if(n[i].tool===s.tool&&n[i].status==="running"){n[i]={...n[i],status:s.success===!1?"error":"done"};break}}return n}function ow(){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 kA(){return t.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function Wy({item:e,idx:n,total:s}){const i=Di(e.tool);return t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[t.jsxs("div",{className:"flex flex-col items-center self-stretch w-3 shrink-0",children:[n>0&&t.jsx("div",{className:"w-px h-2 bg-surface-overlay"}),t.jsx("div",{className:`w-2.5 h-2.5 rounded-full border flex items-center justify-center text-[8px] shrink-0 ${e.status==="running"?"border-brand-500 bg-brand-500/15":e.status==="error"?"border-red-500 bg-red-500/15 text-red-500":"border-gray-600 bg-surface-elevated text-fg-tertiary"}`,children:e.status==="done"?"✓":e.status==="error"?"✗":""}),n<s-1&&t.jsx("div",{className:"w-px flex-1 bg-surface-overlay mt-0.5"})]}),t.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500 opacity-60":"text-fg-tertiary"}`,children:[t.jsx("span",{className:"opacity-70",children:i.icon}),t.jsxs("span",{children:[i.label,e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(ow,{})]})]})}function SA({activities:e,isActive:n,persistent:s}){const i=NA(e),[l,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]),!l)return null;const f=i.length>0,x=f&&i.every(b=>b.status!=="running"),p=n&&!f,g=n&&f&&x;if(s&&x){const b=i.filter(k=>k.status==="error").length,w=i.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:[i.slice(0,5).map(k=>t.jsx("span",{className:"text-[10px] opacity-60",title:Di(k.tool).label,children:Di(k.tool).icon},k.key)),i.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",i.length-5]})]})]}),d&&t.jsx("div",{className:"mt-2 space-y-0.5",children:i.map((k,C)=>t.jsx(Wy,{item:k,idx:C,total:i.length},k.key))})]})}return t.jsxs("div",{className:"mb-2 space-y-0.5",children:[i.map((b,w)=>t.jsx(Wy,{item:b,idx:w,total:i.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(kA,{})]}),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(ow,{}),t.jsx("span",{children:"Writing response…"})]})]})]})}function Jh({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 ex({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(qn,{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 CA({info:e,onClose:n}){const s=Di(e.tool),i=jA(e.args),l=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 ${l?"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 ${l?"bg-brand-500/15 text-brand-500":c?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:l?"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:Fx(e.durationMs)}),t.jsx("button",{onClick:n,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[i.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Arguments"}),t.jsx("div",{className:"space-y-2",children:i.map(({key:d,value: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))})]}),!l&&e.result&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Result"}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto overflow-y-auto max-h-[60vh] whitespace-pre-wrap break-all font-mono",children:Xy(e.result)})]}),!l&&e.error&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-red-500 uppercase tracking-wider mb-2",children:"Error"}),t.jsx("pre",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2 overflow-x-auto max-h-40 whitespace-pre-wrap break-all font-mono",children:Xy(String(e.error))})]}),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)})})]}),!i.length&&!l&&!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 cw={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},Zy={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",cancelled:"cancelled",archived:"archived"},Qy={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 dw({info:e}){const[n,s]=y.useState("loading");y.useEffect(()=>{let h=!1;return se.tasks.get(e.taskId).then(({task:f})=>{h||s(Zy[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(Zy[f.status]??"pending")}),[e.taskId]);const i=async()=>{s("approving");try{await se.tasks.approve(e.taskId),s("in_progress")}catch{s("pending")}},l=async()=>{s("rejecting");try{await se.tasks.reject(e.taskId),s("cancelled")}catch{s("pending")}},c=n==="pending"||n==="approving"||n==="rejecting",d=Qy[n]??Qy.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:cw[e.priority]??"text-fg-tertiary",children:e.priority}),t.jsxs("span",{className:"opacity-50",children:["ID: ",e.taskId.slice(0,8),"..."]})]})]})]}),c&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:i,disabled: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:l,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 Jy={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},ev={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:""}},EA=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function uw({info:e}){const[n,s]=y.useState("loading"),[i,l]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{let p=!1;return se.requirements.get(e.requirementId).then(({requirement:g})=>{p||s(Jy[g.status]??"pending")}).catch(()=>{p||s("pending")}),()=>{p=!0}},[e.requirementId]),y.useEffect(()=>{const p=EA.map(g=>Zt.on(g,b=>{const w=b.payload;w.id===e.requirementId&&w.status&&s(Jy[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(i.trim()){s("rejecting");try{await se.requirements.reject(e.requirementId,i.trim()),s("rejected")}catch{s("pending")}}},f=n==="pending"||n==="approving"||n==="rejecting",x=ev[n]??ev.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:cw[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:i,onChange:p=>l(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&&!i.trim(),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n==="rejecting"?"Rejecting…":"Reject"})]})]})]})}function TA({info:e,showTime:n,time:s,isLast:i}){const l=Di(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=wA(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 ${i?"":"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:l.icon}),t.jsxs("span",{children:[l.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:Fx(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:"$ "}),Qh(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(CA,{info:e,onClose:()=>d(!1)}),u&&(()=>{const b=iw(e.tool,e.result);if(b)return t.jsx(dw,{info:b});const w=lw(e.tool,e.result);return w?t.jsx(uw,{info:w}):null})()]})}function AA({content:e,time:n,showTime:s}){const[i,l]=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:()=>l(!i),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 ${i?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"font-medium shrink-0",children:"Thinking"}),!i&&t.jsx("span",{className:"text-fg-tertiary text-[11px] truncate",children:c})]}),i&&t.jsx("div",{className:"mt-2 pt-2 border-t border-purple-500/15 overflow-hidden",children:t.jsx(qn,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})]})}const au=y.memo(fw);function fw({entry:e,showTime:n,isLast:s}){if(e.type==="tool")return t.jsx(TA,{info:e.info,showTime:n,time:e.time,isLast:s},e.key);if(e.type==="thinking")return t.jsx(AA,{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(qn,{content:e.content,className:"text-sm text-fg-secondary break-words"})})]});if(e.type==="status"){const i=e.content==="completed"||e.content==="execution_finished",l=e.content==="started",c=e.content==="resumed",d=i?"text-green-600":l?"text-blue-600":c?"text-amber-600":"text-fg-tertiary",u=i?"bg-green-400":l?"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 Vx({entries:e,streamingText:n,isActive:s,onExpand:i,showRounds:l,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=l&&g.size>1;let k,C,E=null;if(s)if(n)k="✍",C="Writing response...",E=Qh(n.split(`
|
|
43
|
+
`).pop()??"",80);else if(d?.type==="tool_start"){const N=Di(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=`$ ${Qh(A,80)}`)}else if(d?.type==="tool_end"){const N=Di(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=Fx(p);return t.jsx("div",{onClick:i,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(qn,{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 _A(e){const n=new Map;for(const s of e){const i=s.executionRound??1;n.has(i)||n.set(i,[]);const l=tc(s);l&&n.get(i).push(l)}return Array.from(n.entries()).sort(([s],[i])=>s-i).map(([s,i])=>({round:s,entries:i}))}function Eu({entries:e,streamingText:n,isActive:s,onCollapse:i,showRounds:l,embedded:c}){const d=y.useRef(null),[u,h]=y.useState(new Set),f=_A(e),x=l&&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(tc).filter(w=>w!==null),b=g?ec(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:i,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=ec(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(au,{entry:M,showTime:!0,isLast:N===C.length-1},N))})]},w.round)}):b&&b.map((w,k)=>t.jsx(au,{entry:w,showTime:!0,isLast:k===b.length-1},k)),s&&n&&t.jsx(ex,{content:n}),s&&!n&&t.jsx(Jh,{})]})]})}function MA({agents:e,filter:n,anchorRef:s,onSelect:i,selectedIndex:l,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(()=>{l>=f.length&&c(Math.max(0,f.length-1))},[f.length,l,c]),y.useEffect(()=>{if(!h.current)return;h.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[l]),!d||f.length===0?null:ju.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===l,onMouseDown:g=>{g.preventDefault(),i(x)},onMouseEnter:()=>c(p),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${p===l?"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 RA(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const iu=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function OA(e){const n=[];let s;for(iu.lastIndex=0;(s=iu.exec(e))!==null;)n.push(s[1]??s[2]);return n}function tv(e,n,s){const i=[],l=new RegExp(iu.source,iu.flags);let c=0,d,u=0;for(;(d=l.exec(e))!==null;){d.index>c&&i.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());i.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&&i.push(t.jsx("span",{children:e.slice(c)},u++)),i.length>0?i:[t.jsx("span",{children:e},0)]}function mw({agents:e,onSubmit:n,placeholder:s,replyTo:i,onCancelReply:l}){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,i?.id),d(""),C([]),A.current=null,l?.()}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=RA(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(MA,{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:[i&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:i.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:i.content})]}),t.jsx("button",{onClick:l,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 hw({title:e,message:n,confirmLabel:s="Confirm",checkboxes:i,onConfirm:l,onCancel:c}){const[d,u]=y.useState(()=>{const h={};for(const f of i??[])h[f.id]=f.defaultChecked??!1;return h});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick: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}),i&&i.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:i.map(h=>t.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked: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:()=>l(i?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 Tu({children:e,onClose:n,title:s,width:i="w-[440px]"}){return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${i} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:l=>l.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 DA({onClose:e,onCreate:n}){const[s,i]=y.useState(""),[l,c]=y.useState("");return t.jsx(Tu,{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=>i(d.target.value),placeholder:"e.g. Engineering, Marketing, Support",className:"input",autoFocus:!0,onKeyDown:d=>{d.key==="Enter"&&s.trim()&&n(s.trim(),l.trim()||void 0)}})}),t.jsx(ga,{label:"Description (optional)",children:t.jsx("textarea",{value:l,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(),l.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 LA({teamId:e,teams:n,onClose:s,onAdd:i}){const[l,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(""),!l.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}i(l.trim(),d,h.trim()||void 0,x||void 0,w||void 0)};return t.jsx(Tu,{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:l,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 IA({teamId:e,ungrouped:n,onClose:s,onAdd:i}){return t.jsx(Tu,{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(l=>t.jsxs("button",{onClick:()=>i(l.id,l.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 ${l.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:l.name.charAt(0)}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-sm",children:l.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[l.role," · ",l.type==="agent"?"AI":"Human"]})]}),l.status&&t.jsx("span",{className:`w-2 h-2 rounded-full ${l.status==="idle"?"bg-green-400":l.status==="working"?"bg-blue-400":"bg-gray-600"}`})]},l.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 zA({onClose:e,onConnected:n}){const[s,i]=y.useState(""),[l,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(Tu,{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=>i(w.target.value),autoFocus:!0})}),l&&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:l}),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:i="",bgClass:l="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 ${i}`,style:{width:s,height:s},onError:u=>{u.target.style.display="none"}}):t.jsx("div",{className:`rounded-full ${l} flex items-center justify-center text-white ${d} font-bold shrink-0 ${i}`,style:{width:s,height:s},children:c})}function Yx({currentUrl:e,name:n,size:s=64,targetType:i="user",targetId:l,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,i,l);c?.(M)}catch{u(null)}finally{f(!1)}},C.readAsDataURL(k)},[i,l,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 nv=new Map;function $A({authUser:e,agents:n,teams:s,humans:i,tasks:l,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),[Ce,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})},[ie,Ee]=y.useState(null),[We,kt]=y.useState(null),Ft=y.useRef(null),xe=y.useRef(null),[Se,Fe]=y.useState(!1),[it,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(nv),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);nv=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")}},Bn=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")},lt=(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(()=>{Ee({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)&&(Se||(clearTimeout(Ft.current),Ft.current=null))},kn=async()=>{if(Ft.current&&(clearTimeout(Ft.current),Ft.current=null),xe.current=null,Se&&ie&&We){const ae=We==="_ungrouped"?void 0:We;try{if(ie.fromTeamId&&ie.fromTeamId!==ae&&await se.teams.removeMember(ie.fromTeamId,ie.agentId),ae&&ae!==ie.fromTeamId){const Ie=n.find(qe=>qe.id===ie.agentId);await se.teams.addMember(ae,ie.agentId,"agent")}w(),k(),Xt()}catch(Ie){Oe(`Move failed: ${Ie instanceof Error?Ie.message:String(Ie)}`,"error")}}Ee(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 ${Se&&ie?.agentId===ae.id?"opacity-40":""}`,onPointerDown:mn=>Et(mn,ae.id,Ie),onPointerMove:It,onPointerUp:kn,children:t.jsxs("button",{onClick:()=>{Se||p(ae.id)},onContextMenu:mn=>{if(!R)return;mn.preventDefault();const Kn=Ut(mn);K({agentId:ae.id,teamId:Ie,...Kn})},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 Kn=Ut(mn);K({agentId:ae.id,teamId:Ie,...Kn})}},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=Se&&We===ae&&ie?.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:()=>{Se&&kt(ae)},onPointerLeave:()=>{Se&&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:[it===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&&Se&&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:Ce,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"})]})})]}),i.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:()=>{Bn(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:()=>{lt(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(DA,{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(LA,{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(IA,{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(zA,{onClose:()=>H(!1),onConnected:()=>{H(!1),k(),w()}}),pt&&t.jsx(hw,{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 BA=50,HA=30;function va(e,n,s,i){const l=y.useRef(0),c=y.useRef(0),d=y.useCallback(h=>{l.current=h.touches[0].clientX,c.current=h.touches[0].clientY},[]),u=y.useCallback(h=>{const f=h.changedTouches[0].clientX-l.current,x=h.changedTouches[0].clientY-c.current,p=Math.abs(f),g=Math.abs(x);if(p<BA||Math.atan2(g,p)*(180/Math.PI)>HA)return;if(i?.scrollContainerRef?.current){const k=i.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&&i?.onSwipeOutLeft?i.onSwipeOutLeft():f<0&&w===e.length-1&&i?.onSwipeOutRight&&i.onSwipeOutRight()},[e,n,s,i]);return{onTouchStart:d,onTouchEnd:u}}const rv=[{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:"♡"}],PA={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function Gd(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function UA({agentId:e,onBack:n,inline:s,defaultTab:i,onSwipeBack:l,highlightMailboxId:c}){const d=Yr(),[u,h]=y.useState(null),[f,x]=y.useState(i??"overview"),[p,g]=y.useState(null),b=y.useMemo(()=>rv.map(N=>({id:N.key})),[]),w=y.useMemo(()=>({onSwipeOutLeft:l}),[l]),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(i??"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=PA[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:u.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||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 tr.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:rv.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(qA,{agent:u,onUpdate:E,externalInfo:p}),f==="mind"&&t.jsx(r_,{agentId:e,highlightId:c}),f==="files"&&t.jsx(YA,{agentId:e}),f==="tools"&&t.jsx(KA,{tools:u.tools??[]}),f==="skills"&&t.jsx(WA,{agent:u}),f==="memory"&&t.jsx(ZA,{agentId:e}),f==="heartbeat"&&t.jsx(QA,{agentId:e,initialData:u.heartbeat})]})]})}function qA({agent:e,onUpdate:n,externalInfo:s}){const[i,l]=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(),l(!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(Xn,{label:"Name",children:e.name}),t.jsx(Xn,{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(Xn,{label:"Role Template",children:e.role}),t.jsx(Xn,{label:"Markus Agent ID",mono:!0,children:e.id}),t.jsx(Xn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Xn,{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(Xn,{label:"External Agent ID",mono:!0,children:s.externalAgentId}),t.jsx(Xn,{label:"Registered",children:new Date(s.registeredAt).toLocaleString()}),t.jsx(Xn,{label:"Capabilities",children:s.capabilities.length>0?s.capabilities.join(", "):"none declared"}),t.jsx(Xn,{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:i?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>l(!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:()=>{l(!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(Yx,{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(Xn,{label:"Name",children:i?t.jsx("input",{className:"input-sm",value:c,onChange:S=>d(S.target.value)}):e.name}),t.jsx(Xn,{label:"Agent Role",children:i?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(Xn,{label:"Role Template",children:e.role}),t.jsx(Xn,{label:"Agent ID",mono:!0,children:e.id}),t.jsx(Xn,{label:"Organization",children:e.config?.orgId??"default"}),t.jsx(Xn,{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:Gd(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:Gd(Y.promptTokens)}),t.jsx(cr,{label:"Completion Tokens",value:Gd(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(Xn,{label:"Model Mode",children:i?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(Xn,{label:"Primary Model",children:i?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(Xn,{label:"Fallback",children:i?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(Xn,{label:"Max Tokens/Request",children:e.config?.llmConfig.maxTokensPerRequest??"default"}),t.jsx(Xn,{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(xw,{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 FA(e,n){const s=e.split(`
|
|
52
|
+
`),i=n.split(`
|
|
53
|
+
`),l=s.length,c=i.length,d=Array.from({length:l+1},()=>new Array(c+1).fill(0));for(let g=l-1;g>=0;g--)for(let b=c-1;b>=0;b--)d[g][b]=s[g]===i[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<l||f<c;)h<l&&f<c&&s[h]===i[f]?(u.push({type:"equal",content:s[h],oldLineNum:x++,lineNum:p++}),h++,f++):f<c&&(h>=l||d[h][f+1]>=d[h+1][f])?(u.push({type:"add",content:i[f],lineNum:p++}),f++):(u.push({type:"remove",content:s[h],oldLineNum:x++}),h++);return u}function sv(e){return e.match(/\S+|\s+/g)??[""]}function av({oldText:e,newText:n,mode:s}){const i=sv(e),l=sv(n),c=i.length,d=l.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]=i[p]===l[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&&i[f]===l[x]?(h.push({text:s==="remove"?i[f]:l[x],changed:!1}),f++,x++):x<d&&(f>=c||u[f][x+1]>=u[f+1][x])?(s==="add"&&h.push({text:l[x],changed:!0}),x++):(s==="remove"&&h.push({text:i[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 VA({agent:e,template:n,templateId:s}){const i=y.useMemo(()=>FA(e,n),[e,n]),[l,c]=y.useState(!0),d=3,u=y.useMemo(()=>{const g=i.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(i.length-1,g[0]+d);for(let C=1;C<g.length;C++){const E=Math.max(0,g[C]-d),M=Math.min(i.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},[i]),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(av,{oldText:g.content,newText:w[b+1].content,mode:"remove"}):g.type==="add"&&b>0&&w[b-1].type==="remove"&&(A=t.jsx(av,{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=i.filter(g=>g.type==="add").length,x=i.filter(g=>g.type==="remove").length,p=l?u.flatMap(g=>{const b=[];for(let w=g.start;w<=g.end;w++)b.push({...i[w],_idx:w});return b}):i.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:l?"Show full file":"Show changes only"})]}),t.jsxs("div",{className:"max-h-72 overflow-y-auto bg-surface-primary/50",children:[l&&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=l&&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,i)]},b)}),l&&u.length>0&&u[u.length-1].end<i.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:["··· ",i.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 YA({agentId:e}){const[n,s]=y.useState([]),[i,l]=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(()=>{l(!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(()=>l(!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(i)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(VA,{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(Sl,{text:"No configuration files found for this role"})]})]})}const GA={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 XA(e){const n=new Map,s=new Set;for(const[c,d]of Object.entries(GA)){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 i=e.filter(c=>!s.has(c.name));for(const c of i){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 l=e.filter(c=>!s.has(c.name));return l.length>0&&n.set("Other",l),[...n.entries()].map(([c,d])=>({category:c,tools:d}))}function KA({tools:e}){const n=XA(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(i=>t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-surface-elevated/30 border border-border-default/30",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium font-mono",children:i.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:i.description})]})]},i.name))})},s.category)),e.length===0&&t.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:"No tools registered"})]})}function WA({agent:e}){const n=e.proficiency??{},[s,i]=y.useState(null),[l,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){i(null),c(null);return}i(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…"}):l?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[l.category]??p.custom}`,children:l.category}),t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",l.version]}),l.author&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["by ",l.author]}),l.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))]}),l.description&&t.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:l.description}),l.tags&&l.tags.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:l.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))}),(l.toolDetails??l.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 (",(l.toolDetails??l.tools??[]).length,")"]}),t.jsx("div",{className:"space-y-1.5",children:(l.toolDetails??l.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(Sl,{text:"No skills installed"})]})}function ZA({agentId:e}){const[n,s]=y.useState(null),[i,l]=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(()=>{l(!0),se.agents.getMemory(e).then($=>{s($),x($.recentDailyLogs??""),w($.longTermMemory??"")}).catch(()=>{}).finally(()=>l(!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(i)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Loading memory..."});if(!n)return t.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:"Failed to load memory data"});const 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(Sl,{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(Sl,{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(qn,{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(qn,{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(fw,{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(Sl,{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(Sl,{text:"No long-term memory stored"})})]})}function QA({agentId:e,initialData:n}){const[s,i]=y.useState(n??null),[l,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(i).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(l)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(qn,{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 xw({taskId:e,isLive:n}){const[s,i]=y.useState([]),[l,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=>{i(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};i(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&&!l)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No execution logs yet."});const x=s.map(g=>Ih(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(Vx,{entries:x,streamingText:l,isActive:n,onExpand:()=>f("full"),showRounds:p}):t.jsx(Eu,{entries:x,streamingText:l,isActive:n,onCollapse:()=>f("compact"),showRounds:p})})}function lu({agentId:e,activityId:n,isLive:s=!1}){const[i,l]=y.useState([]),[c,d]=y.useState(!0),[u,h]=y.useState("compact");if(y.useEffect(()=>{d(!0),se.agents.getActivityLogs(e,n).then(x=>{l(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};l(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(i.length===0)return t.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:"No activity logs available."});const f=i.map(x=>Q1(x,n,e)).filter(x=>x!==null);return t.jsx("div",{className:"px-3 py-2",children:u==="compact"?t.jsx(Vx,{entries:f,isActive:s,onExpand:()=>h("full")}):t.jsx(Eu,{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 Xn({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 i=s==="green"?"text-green-600":s==="blue"?"text-blue-500":s==="indigo"?"text-brand-500":s==="red"?"text-red-500":"text-fg-secondary";return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-lg font-semibold ${i}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function Sl({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),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}const lv={0:"Critical",1:"High",2:"Normal",3:"Low",4:"Background"},ov={0:"text-red-400",1:"text-amber-400",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},JA={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"},e_={idle:"bg-green-500/20 text-green-300",focused:"bg-brand-500/20 text-brand-300",deciding:"bg-amber-500/20 text-amber-300"},uh={system_event:"⚙",human_chat:"💬",task_comment:"💬",mention:"@",session_reply:"↩",task_status_update:"📋",a2a_message:"🔗",review_request:"👀",requirement_update:"📝",requirement_comment:"💬",daily_report:"📊",heartbeat:"♡",memory_consolidation:"🧠"},t_=[{key:"all",label:"All"},{key:"interaction",label:"Interaction"},{key:"task",label:"Task"},{key:"notification",label:"Notification"},{key:"system",label:"System"}],n_={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"},cv={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 fh(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 dv(e){const n=e.payload,s=n?.summary??"",i=n?.content??"",l=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=cv[f]??{label:f},g=cv[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=fh(i);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=fh(i);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=i.slice(0,120).replace(/\n/g," ");return{title:l?`Chat from ${l}`:"Human Chat",subtitle:c+(i.length>120?"…":"")}}case"a2a_message":{const c=i.slice(0,120).replace(/\n/g," ");return{title:l?`Message from ${l}`:"Agent Message",subtitle:c+(i.length>120?"…":"")}}case"mention":{const c=s.match(/from (.+)$/),d=fh(i);return{title:c?`Mentioned by ${c[1]}`:"Mention",subtitle:d||void 0}}case"review_request":{const c=i.slice(0,120).replace(/\n/g," ");return{title:l?`Review request from ${l}`:"Review Request",subtitle:c+(i.length>120?"…":"")}}case"session_reply":{const c=i.slice(0,120).replace(/\n/g," ");return{title:l?`Reply in session (${l})`:"Session Reply",subtitle:c+(i.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 r_({agentId:e,highlightId:n}){const[s,i]=y.useState(null),[l,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})]);i(X),c(L),E((L.history?.length??0)>=M)}catch{}u(!1)},[e,h,x]),A=y.useCallback(async()=>{if(!l)return;const _=h==="all"?void 0:h,Y=x==="all"?void 0:x;try{const q=await se.agents.getMailbox(e,{limit:M,offset:l.history.length,category:_,status:Y});c(X=>X?{...X,history:[...X.history,...q.history]}:q),E((q.history?.length??0)>=M)}catch{}},[e,l,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(l?.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=l?.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,l,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 ${e_[s?.attentionState??"idle"]??"bg-gray-500/20 text-gray-300"}`,children:(s?.attentionState??"idle").toUpperCase()}),s?.currentFocus?(()=>{const _=dv({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:[uh[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:uh[_.sourceType]??"●"}),t.jsx("span",{className:`text-[10px] ${ov[_.priority]??"text-fg-tertiary"}`,children:lv[_.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:t_.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))}),(!l?.history||l.history.length===0)&&!d&&t.jsx("div",{className:"text-center text-fg-tertiary text-sm py-8",children:"No mailbox history yet"}),t.jsx("div",{className:"space-y-1",children:l?.history?.map(_=>{const Y=g===_.id,q=uh[_.sourceType]??"●",X=dv(_),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 ${n_[_.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 ${ov[_.priority]??"text-fg-tertiary"}`,children:lv[_.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:[Gd(_.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 ${JA[$.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(xw,{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&&(l?.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 s_=[{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:"⚙"}],uv={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function a_({teamId:e,onBack:n,inline:s}){const[i,l]=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&&l(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(!i)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading team..."});const F=i.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:i.name}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:[i.members.length," members"]}),t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-green-500/15 text-green-600 rounded font-medium",children:[K," online"]})]}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:i.description||"No description"})]}),t.jsxs("button",{onClick:async()=>{if(i)try{const{files:I}=await se.teams.getFilesMap(i.id),S=i.members.filter(W=>W.type==="agent"),D={type:"team",name:i.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||i.name,displayName:i.name,version:"1.0.0",description:i.description??"",author:"",category:"general",tags:[],team:{members:S.map(W=>({name:W.name,roleName:W.role,role:W.agentRole??"worker",count:1,skills:[]}))}};await tr.publishViaProxy({itemType:"team",name:i.name,description:i.description??"",category:"general",config:D,files:I}),alert(`Published "${i.name}" to Markus Hub`)}catch(I){alert(`Failed to publish: ${I}`)}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[t.jsx("span",{children:"↑"})," Hub"]}),s&&t.jsx("button",{onClick:n,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]}),t.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:s_.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??i.managerName??"None"})]}),t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[t.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team ID"}),t.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:i.id})]})]}),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:i.members.map(I=>{const S=$.find(W=>W.id===I.id),D=uv[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:[i.members.map(I=>{const S=$.find(W=>W.id===I.id),D=uv[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)}),i.members.length===0&&t.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]}),c==="announcements"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h3",{className:"text-sm font-medium text-fg-secondary",children:"Team Announcements"}),!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:i.name}),t.jsx("button",{onClick:()=>{q(i.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:i.description||"No description"}),t.jsx("button",{onClick:()=>{L(i.description??""),G(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),t.jsx(i_,{teamId:e,teamName:i.name,onDeleted:n})]})]})]})}function i_({teamId:e,teamName:n,onDeleted:s}){const[i,l]=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"}),i?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',n,'"? This removes the team record from the database.']}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked: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:()=>l(!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:()=>l(!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 Au({side:e,defaultWidth:n,minWidth:s,maxWidth:i,collapsedWidth:l=0,storageKey:c}){const[d,u]=y.useState(()=>{try{const b=localStorage.getItem(`${c}_w`);if(b)return Math.max(s,Math.min(i,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(i,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,i]),g=y.useCallback(()=>f(b=>!b),[]);return{width:h?l:d,rawWidth:d,collapsed:h,toggle:g,setCollapsed:f,onResizeStart:p}}function mh(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,i)=>s.type==="tool"?{type:"tool",key:`${s.tool}_${i}`,tool:s.tool,status:s.status,args:s.arguments,result:s.result,error:s.error,durationMs:s.durationMs,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 i=[],l=e.metadata;if(l.thinking?.length&&i.push({type:"text",content:"",thinking:l.thinking.join(`
|
|
54
|
+
|
|
55
|
+
`)}),l.toolCalls?.length)for(let c=0;c<l.toolCalls.length;c++){const d=l.toolCalls[c];i.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})}i.length>0&&(i.push({type:"text",content:e.text}),s.segments=i)}return s}function l_({name:e,agentId:n,agents:s,onViewProfile:i}){const[l,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(!l)return;const h=f=>{d.current&&!d.current.contains(f.target)&&c(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[l]),u?t.jsxs("span",{ref:d,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>c(!l),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),l&&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),i?.(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 o_({agent:e,anchorRect:n,onClose:s,onViewProfile:i}){const l=y.useRef(null);y.useEffect(()=>{const h=f=>{l.current&&!l.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;l.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(),i(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:"View Profile →"})]})}function fv(e){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let s="";const i=n.match(/\{[\s\S]*\}/);if(i)try{const l=JSON.parse(i[0]);s=l.error?.message??l.message??""}catch{}if(!s){const l=n.lastIndexOf(": ");l>=0&&(s=n.slice(l+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 mv({msg:e,onCopy:n,onRetry:s,onResume:i,onReply:l,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&&i&&t.jsxs("button",{onClick:()=>i(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"]}),l&&t.jsxs("button",{onClick:()=>l(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:"Reply",children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"9 17 4 12 9 7"}),t.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),"Reply"]})]})}function hv(e,n,s){if(!e)return[];const i=[];let l=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&&i.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:c,seq:l++,type:"text",content:N,createdAt:b,metadata:{isThinking:!0}}),p=""},k=()=>{const N=g.trim();N&&i.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:c,seq:l++,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;i.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:c,seq:l++,type:"tool_start",content:N.tool,metadata:{arguments:N.args},createdAt:A}),N.status!=="running"&&i.push({id:`cseg_${l}`,sourceType:"chat",sourceId:"",agentId:c,seq:l++,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(),i}function c_({msg:e,isStreaming:n,liveActivities:s,onViewModeChange:i}){const l=e.segments,c=e.isStopped,[d,u]=y.useState("compact"),h=y.useCallback(p=>{u(p),i?.(p)},[i]);if(l!==void 0&&l.length>0){const p=l.some(A=>A.type==="tool"),g=hv(l,e.agentId,e.rawCreatedAt),b=n?(()=>{const R=l.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=l.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?hv(E,e.agentId,e.rawCreatedAt):g,N=[];if(d==="compact")for(const A of l){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 _=lw(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(Vx,{entries:g,streamingText:b,isActive:n,onExpand:()=>h("full"),embedded:!0}):t.jsx(Eu,{entries:M,isActive:n,onCollapse:()=>h("compact"),embedded:!0})),d==="compact"&&N.map(A=>A.kind==="task"?t.jsx(dw,{info:A.info},A.key):t.jsx(uw,{info:A.info},A.key)),d==="compact"&&C&&t.jsx(qn,{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(SA,{activities:n?s:e.activities??[],isActive:n,persistent:!n&&f}),x?t.jsx(qn,{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 tx=new Set;function d_(){return window.location.hash}function u_(e){return tx.add(e),()=>{tx.delete(e)}}typeof window<"u"&&window.addEventListener("hashchange",()=>tx.forEach(e=>e()));function xv({initialAgentId:e,authUser:n}={}){const[s,i]=y.useState([]),[l,c]=y.useState([]),d=Yr(),u=y.useSyncExternalStore(u_,d_),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=Au({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([]),[Ce,Me]=y.useState(!1),[dt,pt]=y.useState(!1),[et,Pt]=y.useState([]),ie=y.useRef(null),Ee=y.useRef(null),We="__new_chat__",[kt,Ft]=y.useState([]),[xe,Se]=y.useState(null),[Fe,it]=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([]),[Bn,dn]=y.useState([]),[ye,Ge]=y.useState([]),[lt,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)&&it(!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}`},Kn=(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=>i(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(()=>Ee.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(mh);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)}},[]),ir=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||!Ce||!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(mh);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,Ce,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=Kn(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&&ir(P);const $e=bn.current.get(ee),Ze=Ut.current.get(ee);if($e&&$e.length>0&&Lt($e),it(!1),Re!==void 0)K(Re),Me(!1),Ze!==void 0&&Se(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&&ir(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;Se(yn),Lt(vt),Rr(yn,ee)}else{Se(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=Kn("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=Kn("direct",Ke,$,z);Ot(ht,vt=>[...vt,Ye])}}),[X,P,$,z,xe,Ot]),lt.find(ee=>ee.id===It),y.useEffect(()=>{kn(null)},[P]);const Os=ee=>OA(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=Kn(X,P,$,z),Ze=D;ee||(S(""),Ee.current&&(Ee.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(oi=>oi.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=fv(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,Uu=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:Uu},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&&(Se(wt.sessionId),Lt(at=>at.map(Je=>Je.id===We?{...Je,id:wt.sessionId}:Je))),ir(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&&(Se(wt),Lt(Je=>Je.map(nt=>nt.id===We?{...nt,id:wt}:nt)),ir(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=fv(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),oi=xe&&xe!==We?xe:null;Ir&&!Ir.text&&X==="direct"&&oi&&!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(oi,2)).messages.find(Ct=>Ct.role==="assistant");if(xt?.content){const Ct=mh(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),[,Fn]=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)}),Ee.current?.focus()},[n?.name]),Ar=async ee=>{Se(ee.id),it(!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)},Hn=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=()=>{Se(We);const ee=B.current;V.current.delete(ee),K([]),Me(!1),yt.current=null,it(!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,Hi=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"]),lr=y.useCallback(ee=>ee.type.startsWith("image/")||Hi.has(ee.type),[]),Sa=ee=>ee.dataUrl.startsWith("data:image/"),li=(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]??"📁"},is=y.useCallback(ee=>{const Ne=Array.from(ee).filter(lr);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)}},[lr]),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(lr);Re.length>0&&(ee.preventDefault(),is(Re))}},[is,lr]),ne=y.useCallback(ee=>{ee.preventDefault();const Ne=ee.dataTransfer?.files;Ne&&Ne.length>0&&is(Array.from(Ne).filter(lr))},[is,lr]),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=l.find(ee=>ee.id===z),yr=z===n?.id||!z,vr=_t.find(ee=>ee.channelKey===$),Vn=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($A,{authUser:n,agents:s,teams:Bn,humans:l,tasks:lt,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:Vn}),X==="direct"&&Be&&t.jsx(pv,{agent:Be,tasks:lt,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:()=>it(!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:Vn}),X==="direct"&&Be&&t.jsx(pv,{agent:Be,tasks:lt,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:()=>it(!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){Se(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(),Hn(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:()=>it(!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(UA,{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(a_,{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(qn,{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))}),tv(ee.text,s)]})}),t.jsx("div",{className:`transition-opacity ${d?"opacity-100":"opacity-0 group-hover/msg:opacity-100"}`,children:t.jsx(mv,{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(l_,{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:tv(ee.text,s)})]}):t.jsx(c_,{msg:ee,isStreaming:Ke,liveActivities:Ke?ve:[],onViewModeChange:Ze=>Fn(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(mv,{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(o_,{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:li(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:()=>ie.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:ie,type:"file",accept:"image/*,.pdf,.docx,.xlsx,.pptx,.xls,.doc,.csv,.json,.xml,.html,.epub",multiple:!0,className:"hidden",onChange:ee=>{ee.target.files&&is(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:()=>ie.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:Ee,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 pv({agent:e,tasks:n,onViewProfile:s}){const[i,l]=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(!i)return;const w=k=>{c.current&&!c.current.contains(k.target)&&l(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),y.useLayoutEffect(()=>{if(!i||!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`)},[i]);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:()=>l(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})]}),i&&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:()=>{l(!1),s?.(e.id)},className:"w-full text-center text-[10px] text-red-500 hover:text-red-500 border border-red-500/30 hover:border-red-500/50 rounded-lg py-1 transition-colors",children:"View Agent Profile →"})]}),i&&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:()=>{l(!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:()=>{l(!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 f_=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"midnight",label:"Midnight"}],pw="markus-theme";function gv(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 m_(){try{const e=localStorage.getItem(pw);if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="midnight")return e}catch{}return"system"}function h_(){const[e,n]=y.useState(m_),s=y.useCallback(i=>{n(i);try{localStorage.setItem(pw,i)}catch{}gv(i)},[]);return y.useEffect(()=>{gv(e)},[e]),{mode:e,setMode:s}}function gw({theme:e,onThemeChange:n}={}){const[s,i]=y.useState(null),[l,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,Ce]=y.useState(!1),[Me,dt]=y.useState(null),[pt,et]=y.useState(!1),[Pt,ie]=y.useState(0),[Ee,We]=y.useState(!0),[kt,Ft]=y.useState(!1),[xe,Se]=y.useState(null),[Fe,it]=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(i).catch(()=>{}),fetch("/api/settings/llm").then(de=>de.ok?de.json():Promise.reject(de.status)).then(de=>{de&&typeof de=="object"&&"providers"in de&&(c(de),u(de.defaultProvider))}).catch(()=>{})},[]),Bn=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),ie(de.remoteDebuggingPort??0),We(de.autoCloseTabs??!0))}).catch(()=>{})},[]),lt=y.useCallback(()=>{Lt(!0),se.system.storage().then(it).catch(()=>{}).finally(()=>Lt(!1)),se.system.orphans().then(Jt).catch(()=>{})},[]);y.useEffect(()=>{$t(),Bn(),dn(),ye(),Ge(),lt()},[$t,Bn,dn,ye,Ge,lt]),y.useEffect(()=>{const de=()=>lt();return window.addEventListener("markus:data-changed",de),()=>window.removeEventListener("markus:data-changed",de)},[lt]);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=l?Object.values(l.providers).some(de=>de.configured):!1;y.useEffect(()=>{l&&!It&&!re.current&&(re.current=!0,Et())},[l,It,Et]);const kn=async()=>{if(!(!d||d===l?.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,Kn]=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)}}},ir=(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=>{Kn(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{Kn(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)}},Fn=l?.providers?Object.entries(l.providers).filter(([,de])=>de.configured&&de.enabled).map(([de])=>de):[],bs=l&&!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:f_.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(hh,{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(hh,{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(hh,{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(xh,{label:"Status",value:s.status==="ok"?"Healthy":s.status,color:"green"}),t.jsx(xh,{label:"Version",value:s.version,color:"indigo"}),t.jsx(xh,{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:[l?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:Fn.length>0?Fn.map(de=>t.jsx("option",{value:de,children:l.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!==l?.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:l&&Object.entries(l.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===l.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(),ir(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}`,Hn=!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"}),Hn&&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"}),Hn&&!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()=>{Ce(!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"})}Ce(!1)},className:"px-3 py-1.5 text-xs bg-brand-500 text-white rounded-lg hover:bg-brand-600 transition-colors disabled:opacity-40",children: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),Se(null);try{const Te=await se.settings.updateBrowser({bringToFront:de});et(Te.bringToFront),Se({type:"ok",text:de?"Tabs will be brought to foreground":"Tabs will stay in background"})}catch{Se({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=!Ee;We(de),Ft(!0),Se(null);try{const Te=await se.settings.updateBrowser({autoCloseTabs:de});We(Te.autoCloseTabs),Se({type:"ok",text:"Saved"})}catch{Se({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 ${Ee?"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 ${Ee?"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=>{ie(Number(de.target.value)),Se(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),Se(null);try{const de=await se.settings.updateBrowser({remoteDebuggingPort:Pt});ie(de.remoteDebuggingPort),Se({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{Se({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:()=>lt(),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(x_,{orphanInfo:St,dataDir:Fe.dataDir,onPurged:lt})]})]})}),t.jsx("div",{className:"h-8"})]})]})}function hh({step:e,title:n,description:s,active:i,children:l}){return t.jsxs("div",{className:`rounded-xl border p-4 space-y-3 transition-colors ${i?"border-brand-500/60 bg-brand-500/10":"border-border-default bg-surface-secondary/60"}`,children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"flex-none w-6 h-6 rounded-full bg-surface-overlay flex items-center justify-center text-xs font-bold text-fg-secondary",children:e}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n}),t.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:s})]})]}),l&&t.jsx("div",{className:"pl-9",children:l})]})}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 xh({label:e,value:n,color:s}){const i=s==="green"?"bg-green-500/10 text-green-600":"bg-brand-500/10 text-brand-500";return t.jsxs("div",{className:`rounded-xl px-5 py-4 ${i}`,children:[t.jsx("div",{className:"text-2xl font-bold",children:n}),t.jsx("div",{className:"text-xs mt-1 opacity-70",children:e})]})}function 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),i=e/Math.pow(1024,s);return`${i<10?i.toFixed(1):Math.round(i)} ${n[s]}`}function x_({orphanInfo:e,dataDir:n,onPurged:s}){const i=[...e.orphanAgents.map(k=>({...k,kind:"agent"})),...e.orphanTeams.map(k=>({...k,kind:"team"}))],[l,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=l.size===i.length&&i.length>0,g=()=>c(p?new Set:new Set(i.map(k=>k.id))),b=i.filter(k=>l.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 ",i.length," director",i.length===1?"y":"ies","."]}),t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:p,onChange:g,className:"rounded"}),"Select all"]}),l.size>0&&t.jsxs("span",{className:"text-[10px] text-fg-secondary",children:[l.size," selected (",Fs(b),")"]})]}),t.jsx("div",{className:"space-y-0.5 mb-3 max-h-52 overflow-y-auto",children:i.map(k=>t.jsxs("div",{className:`flex items-center gap-2 text-xs py-1.5 px-2 rounded transition-colors ${l.has(k.id)?"bg-amber-500/10":"bg-surface-elevated/30 hover:bg-surface-elevated/50"}`,children:[t.jsx("input",{type:"checkbox",checked:l.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:[l.size>0&&t.jsx("button",{disabled:d,onClick:()=>{w([...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: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 ou=new Map;function Si(e,n){ou.has(e)||ou.set(e,n().catch(()=>{}))}function Ti(e){const n=ou.get(e);return ou.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 bw(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function p_(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let l=0;l<Math.max(s.length,i.length);l++){const c=s[l]??0,d=i[l]??0;if(c>d)return!0;if(c<d)return!1}return!1}const yw={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function nx({authUser:e}={}){const[n,s]=y.useState("all"),[i,l]=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=i?tr.search({type:"agent",q:i,limit:50}):Ti(qr.hubAgents)??tr.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;i&&A.set("q",i);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,i,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:i,onChange:A=>l(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(g_,{item:A,localInfo:k.get(bw(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:i?`No agents match "${i}"`:"No agents found"}),t.jsx("div",{className:"text-fg-tertiary text-sm",children:i?"Try different search terms.":"Agents come from the built-in registry."})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:c.map(A=>t.jsx(b_,{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 ${yw[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(y_,{template:f,onClose:()=>g(!1),onHire:N})]})}function g_({item:e,localInfo:n,onStatusChange:s}){const[i,l]=y.useState(!1),[c,d]=y.useState(""),u=n?.installed??!1,h=u&&e.version&&n?.localVersion&&p_(e.version,n.localVersion),f=async x=>{if(x.stopPropagation(),!i){l(!0),d("");try{const p=await tr.download(e.id),g=p.name||e.name,b=bw(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{l(!1)}}};return t.jsxs("div",{className:"group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5",children:[t.jsx("div",{className:"absolute inset-0 rounded-xl border border-border-default group-hover:border-brand-500/30 transition-colors duration-300"}),t.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-green-500/40 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2.5 mb-2.5",children:[t.jsx("h3",{className:"text-sm font-semibold truncate flex-1 group-hover:text-brand-400 transition-colors",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-400 rounded-md border border-brand-500/10",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-500 rounded-md border border-green-500/10",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-500",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3 pt-3 border-t border-border-default/50",children:[h?t.jsx("button",{onClick:x=>{f(x)},disabled:i,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Upgrading...":`Upgrade → v${e.version}`}):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:i,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Installing...":"Install"}),c&&t.jsx("span",{className:`text-[10px] ${c==="Failed"?"text-red-500":"text-green-600"}`,children:c})]})]})]})}function b_({template:e,isSelected:n,onSelect:s}){return t.jsxs("div",{onClick:s,className:`group relative bg-surface-secondary rounded-xl cursor-pointer transition-all duration-300 overflow-hidden ${n?"ring-1 ring-brand-500/60 shadow-lg shadow-brand-500/10":"hover:shadow-xl hover:shadow-brand-500/5 hover:-translate-y-0.5"}`,children:[t.jsx("div",{className:`absolute inset-0 rounded-xl border transition-colors duration-300 ${n?"border-brand-500/50":"border-border-default group-hover:border-brand-500/30"}`}),t.jsx("div",{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand-500/40 to-transparent transition-opacity duration-300 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}),t.jsxs("div",{className:"relative p-5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"font-semibold text-fg-primary truncate group-hover:text-brand-400 transition-colors",children:e.name}),t.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[10px] font-medium shrink-0 bg-brand-500/15 text-brand-400 border border-brand-500/10",children:["v",e.version]})]}),t.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:["by ",e.author]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-3 line-clamp-2 leading-relaxed",children:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-3",children:[e.skills.slice(0,4).map(i=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated/80 text-fg-secondary rounded-md border border-border-default/50",children:i},i)),e.skills.length>4&&t.jsxs("span",{className:"px-2 py-0.5 text-[10px] text-fg-muted",children:["+",e.skills.length-4]})]}),t.jsxs("div",{className:"mt-3 pt-3 border-t border-border-default/50 flex items-center gap-2 text-xs",children:[t.jsx("span",{className:`inline-block px-2 py-0.5 rounded-md text-[10px] font-medium capitalize ${yw[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 y_({template:e,onClose:n,onHire:s}){const[i,l]=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(i.trim()){x(!0);try{await s(e.id,i.trim(),c||void 0)}finally{x(!1)}}};return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:g=>g.stopPropagation(),children:[t.jsx("div",{className:"flex items-center gap-3 mb-5",children:t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Hire Agent"}),t.jsxs("p",{className:"text-xs text-fg-tertiary",children:['Creating agent from "',e.name,'"']})]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:"Agent Name"}),t.jsx("input",{type:"text",value:i,onChange:g=>l(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:!i.trim()||f,className:"btn-primary",children:f?"Creating...":"Create Agent"})]})]})})}function vw(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed"}function v_(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let l=0;l<Math.max(s.length,i.length);l++){const c=s[l]??0,d=i[l]??0;if(c>d)return!0;if(c<d)return!1}return!1}function rx(){const[e,n]=y.useState("all"),[s,i]=y.useState(""),[l,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?tr.search({type:"team",q:s,limit:50}):Ti(qr.hubTeams)??tr.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??"developer";try{const H=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:O,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:[l.length," team",l.length!==1?"s":""," available"]}),t.jsx("div",{className:"flex-1 min-w-[120px]",children:t.jsx("input",{type:"text",placeholder:"Search teams...",value:s,onChange:R=>i(R.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-7",children: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(j_,{item:R,localInfo:C.get(vw(R.name)),onStatusChange:M},R.id))}):l.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:l.map(R=>t.jsx(w_,{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}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary font-mono",children:R.roleName??R.templateId}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize ${R.role==="manager"?"bg-brand-500/15 text-brand-500":"bg-blue-500/15 text-blue-600"}`,children:R.role??"worker"}),(R.count??1)>1&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",R.count]})]})]})]},_))})]}),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 j_({item:e,localInfo:n,onStatusChange:s}){const[i,l]=y.useState(!1),[c,d]=y.useState(""),u=n?.installed??!1,h=u&&e.version&&n?.localVersion&&v_(e.version,n.localVersion),f=async x=>{if(x.stopPropagation(),!i){l(!0),d("");try{const p=await tr.download(e.id),g=p.name||e.name,b=vw(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{l(!1)}}};return t.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default hover:border-brand-600/50 cursor-pointer transition-all",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-sm font-semibold truncate flex-1",children:e.name}),e.version&&t.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/15 text-brand-500 rounded",children:["v",e.version]}),t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-600 rounded",children:"Hub"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary line-clamp-2 mb-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-fg-tertiary",children:[t.jsxs("span",{className:"text-amber-600",children:["★".repeat(Math.round(parseFloat(e.avgRating))),"☆".repeat(5-Math.round(parseFloat(e.avgRating)))]}),t.jsxs("span",{children:["↓"," ",e.downloadCount]}),t.jsx("span",{children:e.author?.displayName??e.author?.username})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[h?t.jsx("button",{onClick:x=>{f(x)},disabled:i,className:"px-3 py-1 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Upgrading...":`Upgrade → v${e.version}`}):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:i,className:"px-3 py-1 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:i?"Installing...":"Install"}),c&&t.jsx("span",{className:`text-[10px] ${c==="Failed"?"text-red-500":"text-green-600"}`,children:c})]})]})}function w_({template:e,isSelected:n,onSelect:s}){const i=e.members.reduce((c,d)=>c+(d.count??1),0),l=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,(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:[i," agent",i!==1?"s":""]}),l&&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 jw(e,n){const s=e.split(".").map(Number),i=n.split(".").map(Number);for(let l=0;l<Math.max(s.length,i.length);l++){const c=s[l]??0,d=i[l]??0;if(c>d)return!0;if(c<d)return!1}return!1}const ph={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",productivity:"bg-green-500/15 text-green-600",custom:"bg-gray-500/15 text-fg-secondary",browser:"bg-brand-500/15 text-brand-500",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500","AI 智能":"bg-brand-500/15 text-brand-500",开发工具:"bg-blue-500/15 text-blue-600",效率提升:"bg-green-500/15 text-green-600",数据分析:"bg-brand-500/15 text-brand-500",内容创作:"bg-brand-500/15 text-brand-500",安全合规:"bg-red-500/15 text-red-500",通讯协作:"bg-green-500/15 text-green-600"},N_=[{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 k_({item:e,installedSkills:n,onMsg:s,onRefresh:i}){const[l,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&&jw(e.version,u.version),x=async()=>{if(!l){c(!0);try{const p=await tr.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"),i(),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{s("Install failed","error")}finally{c(!1)}}};return f?t.jsx("button",{onClick:()=>{x()},disabled:l,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:l?"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:l,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l?"Installing...":"Install"})}function sx(){const e=Yr(),[n,s]=y.useState("installed"),[i,l]=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=(ie,Ee="success")=>{l({text:ie,type:Ee}),setTimeout(()=>l(null),Ee==="error"?1e4:4e3)},oe=y.useCallback(async()=>{x(!0);try{const ie=await se.skills.list();h(ie.skills)}catch{}x(!1)},[]),me=y.useCallback(async()=>{O(!0);try{const ie=await se.skills.builtin();T(ie.skills)}catch{}O(!1)},[]),Oe=y.useCallback(async ie=>{G(!0);try{const Ee=await se.skills.registrySkillhub({q:ie?.q,category:ie?.category,page:ie?.page??1,limit:24,sort:ie?.sort??Y});w(Ee.skills),C(Ee.total),Ee.categories?.length&&A(Ee.categories)}catch{}G(!1)},[Y]),ve=y.useCallback(async ie=>{K(!0);try{const Ee=await se.skills.registrySkillssh(ie);H(Ee.skills)}catch{}K(!1)},[]),ke=y.useCallback(async ie=>{W(!0);try{const We=await(ie?tr.search({type:"skill",q:ie,limit:50}):Ti(qr.hubSkills)??tr.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 Ce=async ie=>{d(Ee=>new Set(Ee).add(ie.name));try{const Ee=await se.skills.install({name:ie.name,source:"skillhub",slug:ie.slug,sourceUrl:ie.homepage,description:ie.description_zh??ie.description,category:"custom",version:ie.version});await oe(),re(`"${ie.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{re(`Download failed for "${ie.name}". You can try manually from: ${ie.homepage}`,"error")}d(Ee=>{const We=new Set(Ee);return We.delete(ie.name),We})},Me=async ie=>{d(Ee=>new Set(Ee).add(ie.name));try{const Ee=await se.skills.install({name:ie.name,source:"skillssh",sourceUrl:ie.url,githubRepo:`${ie.author}/${ie.repo}`,githubSkillPath:ie.name});await oe(),re(`"${ie.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{re(`Download failed for "${ie.name}". You can try manually from: ${ie.url}`,"error")}d(Ee=>{const We=new Set(Ee);return We.delete(ie.name),We})},dt=async ie=>{d(Ee=>new Set(Ee).add(ie.name));try{const Ee=await se.skills.install({name:ie.name,source:"builtin"});await oe(),await me(),re(`"${ie.name}" installed (${Ee.method}) → ${Ee.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Ee){re(`Install failed for "${ie.name}": ${Ee}`,"error")}d(Ee=>{const We=new Set(Ee);return We.delete(ie.name),We})},pt=async ie=>{if(confirm(`Uninstall "${ie}"? This will delete the skill files from ~/.markus/skills/.`))try{await se.skills.uninstall(ie),await oe(),re(`"${ie}" uninstalled`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(Ee){re(`Uninstall failed: ${Ee}`,"error")}},et=u.filter(ie=>{if(!p)return!0;const Ee=p.toLowerCase();return ie.name.toLowerCase().includes(Ee)||ie.description?.toLowerCase().includes(Ee)}),Pt=V.filter(ie=>{if(!Z)return!0;const Ee=Z.toLowerCase();return ie.name.toLowerCase().includes(Ee)||ie.repo.toLowerCase().includes(Ee)});return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsxs("div",{className:`${e?"px-4":"px-6"} border-b border-border-default bg-surface-secondary shrink-0`,children:[t.jsx("div",{className:"flex items-center h-14",children:t.jsx("h2",{className:"text-lg font-semibold",children:"Skill Store"})}),t.jsx("div",{className:`flex ${e?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:N_.map(ie=>t.jsx("button",{onClick:()=>s(ie.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${n===ie.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:ie.label},ie.id))})]}),i&&t.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${i.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:i.text}),n==="installed"&&t.jsxs("div",{className:`flex-1 overflow-y-auto ${e?"p-4":"p-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("input",{value:p,onChange:ie=>g(ie.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(ie=>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:ie.name}),t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] shrink-0 ${ie.type==="builtin"?"bg-blue-500/15 text-blue-600":ie.type==="filesystem"?"bg-green-500/15 text-green-600":"bg-amber-500/15 text-amber-600"}`,children:ie.type==="builtin"?"built-in":ie.type==="filesystem"?"local":"imported"})]}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[ie.author?`by ${ie.author} · `:"",ie.version?`v${ie.version}`:"",ie.sourcePath&&t.jsxs("span",{className:"ml-1 text-fg-tertiary",title:ie.sourcePath,children:["📁 ",ie.sourcePath.replace(/^.*\/\.([^/]+)\/skills\//,"~/.$1/skills/")]})]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${ph[ie.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:ie.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ie.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ie.tags?.slice(0,3).map(Ee=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Ee},Ee))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[ie.tools&&ie.tools.length>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[ie.tools.length," tool",ie.tools.length!==1?"s":""]}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"Auto-discovered by agents"})]}),ie.type!=="builtin"&&t.jsx("button",{onClick:()=>{pt(ie.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"})]})]},ie.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(ie=>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:ie.name}),ie.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:[ie.author?`by ${ie.author} · `:"","v",ie.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium ${ph[ie.category??""]??"bg-gray-500/15 text-fg-secondary"} capitalize shrink-0 ml-2`,children:ie.category??"custom"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ie.description??"No description"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:ie.tags.slice(0,4).map(Ee=>t.jsx("span",{className:"px-2 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded-full",children:Ee},Ee))}),ie.requiredPermissions.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:ie.requiredPermissions.map(Ee=>t.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-amber-500/10 text-amber-500 rounded",children:Ee},Ee))}),t.jsxs("div",{className:"mt-3 pt-2 border-t border-border-default flex items-center justify-between",children:[ie.installed&&ie.installedVersion?t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",ie.installedVersion]}):t.jsx("span",{}),ie.installed&&ie.installedVersion&&jw(ie.version,ie.installedVersion)?t.jsx("button",{onClick:()=>{dt(ie)},disabled:c.has(ie.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(ie.name)?"Upgrading...":`Upgrade → v${ie.version}`}):ie.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(ie)},disabled:c.has(ie.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(ie.name)?"Installing...":"Install"})]})]},ie.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:ie=>{_(ie.target.value),M(1),Oe({q:X||void 0,category:ie.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(ie=>t.jsx("option",{value:ie,children:ie},ie))]}),t.jsxs("select",{value:Y,onChange:ie=>{q(ie.target.value),M(1),Oe({q:X||void 0,category:R||void 0,page:1,sort:ie.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:ie=>L(ie.target.value),onKeyDown:ie=>{ie.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(ie=>{const Ee=u.some(We=>We.name===ie.name||We.name===ie.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:ie.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["v",ie.version]})]}),t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ml-2 ${ie.tags?.[0]?ph[ie.tags[0]]??"bg-brand-500/15 text-brand-500":"bg-brand-500/15 text-brand-500"}`,children:ie.tags?.[0]??"SkillHub"})]}),t.jsx("p",{className:"text-sm text-fg-secondary mt-2 line-clamp-2",children:ie.description_zh??ie.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:[ie.stars>0&&t.jsxs("span",{className:"text-[10px] text-amber-600",children:["★ ",ie.stars.toLocaleString()]}),ie.downloads>0&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[ie.downloads>=1e4?`${(ie.downloads/1e4).toFixed(1)}万`:ie.downloads.toLocaleString()," 下载"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:ie.homepage,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Ee?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{Ce(ie)},disabled:c.has(ie.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(ie.name)?"...":"Install"})]})]})]},ie.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 ie=E-1;M(ie),Oe({q:X||void 0,category:R||void 0,page:ie})},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 ie=E+1;M(ie),Oe({q:X||void 0,category:R||void 0,page:ie})},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:ie=>B(ie.target.value),onKeyDown:ie=>{ie.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(ie=>{const Ee=u.some(We=>We.name===ie.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:ie.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[ie.author," / ",ie.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:ie.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:ie.installs&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[ie.installs," installs"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:ie.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-brand-500 hover:text-brand-500",children:"View →"}),Ee?t.jsx("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:"Installed"}):t.jsx("button",{onClick:()=>{Me(ie)},disabled:c.has(ie.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(ie.name)?"...":"Install"})]})]})]},`${ie.author}-${ie.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:ie=>te(ie.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(ie=>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:ie.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:["by ",ie.author?.displayName??ie.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:ie.description}),t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["★".repeat(Math.round(parseFloat(ie.avgRating))),"☆".repeat(5-Math.round(parseFloat(ie.avgRating))),t.jsxs("span",{className:"text-fg-tertiary ml-1",children:["(",ie.ratingCount,") · ↓ ",ie.downloadCount]})]}),t.jsx("div",{className:"mt-2 pt-2 border-t border-border-default flex items-center justify-end gap-2",children:t.jsx(k_,{item:ie,installedSkills:u,onMsg:re,onRefresh:()=>{oe()}})})]},ie.id))})]})]})}const gh=[{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function S_(){const e=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_storeTab"),e==="agents"||e==="teams"||e==="skills"?e:"agents"}function C_({authUser:e}){const[n,s]=y.useState(S_),i=Yr(),l=va(gh,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)},[]),i?t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:l.onTouchStart,onTouchEnd:l.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0",children:gh.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(nx,{authUser:e}),n==="teams"&&t.jsx(rx,{}),n==="skills"&&t.jsx(sx,{})]})]}):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"})}),gh.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(nx,{authUser:e}),n==="teams"&&t.jsx(rx,{}),n==="skills"&&t.jsx(sx,{})]})]})}function E_(e){const n=e.indexOf(".markus/builder-artifacts/");return n>=0?"~/"+e.slice(n):e}const T_=[{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: "}],bv={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 yv({message:e,onConfirm:n,onCancel:s}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:i=>i.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),t.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:"Confirm Delete"}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:e})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:s,className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:"Cancel"}),t.jsx("button",{onClick:n,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:"Delete"})]})]})})}function ww(){const e=Yr(),[n,s]=y.useState([]),[i,l]=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([(Ti(qr.builderArtifacts)??se.builder.artifacts.list()).then($=>$?.artifacts??[]).catch(()=>[]),(Ti(qr.builderAgents)??se.agents.list()).then($=>$?.agents??[]).catch(()=>[]),(Ti(qr.builderHubMyItems)??tr.myItems()).then($=>$?.items??[]).catch(()=>[]),(Ti(qr.builderInstalled)??se.builder.artifacts.installed()).then($=>$?.installed??{}).catch(()=>({}))]).then(([$,T,z,O])=>{if(l($),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(T);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(T);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(T);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 tr.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($);try{await tr.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(T);try{await se.builder.artifacts.delete($.type,$.name),l(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"?i:i.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:T_.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&&i.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=bv[$.type]??bv.agent,z=$.meta.displayName||$.meta.name||$.name,O=$.meta.description||"",V=`${$.type}/${$.name}`,H=f===V,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?"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?"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=tr.getUser();if(!B||!F)return;const K=`${tr.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?"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:E_($.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(yv,{message:`Delete "${b.meta.displayName||b.meta.name||b.name}"? This cannot be undone.`,onConfirm:P,onCancel:()=>w(null)}),E&&t.jsx(yv,{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,i;s<e.length;s++)(i=rr(e[s]))!==""&&(n+=(n&&" ")+i);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}var A_={value:()=>{}};function _u(){for(var e=0,n=arguments.length,s={},i;e<n;++e){if(!(i=arguments[e]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new Xd(s)}function Xd(e){this._=e}function __(e,n){return e.trim().split(/^|\s+/).map(function(s){var i="",l=s.indexOf(".");if(l>=0&&(i=s.slice(l+1),s=s.slice(0,l)),s&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}Xd.prototype=_u.prototype={constructor:Xd,on:function(e,n){var s=this._,i=__(e+"",s),l,c=-1,d=i.length;if(arguments.length<2){for(;++c<d;)if((l=(e=i[c]).type)&&(l=M_(s[l],e.name)))return l;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++c<d;)if(l=(e=i[c]).type)s[l]=vv(s[l],e.name,n);else if(n==null)for(l in s)s[l]=vv(s[l],e.name,null);return this},copy:function(){var e={},n=this._;for(var s in n)e[s]=n[s].slice();return new Xd(e)},call:function(e,n){if((l=arguments.length-2)>0)for(var s=new Array(l),i=0,l,c;i<l;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(c=this._[e],i=0,l=c.length;i<l;++i)c[i].value.apply(n,s)},apply:function(e,n,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],l=0,c=i.length;l<c;++l)i[l].value.apply(n,s)}};function M_(e,n){for(var s=0,i=e.length,l;s<i;++s)if((l=e[s]).name===n)return l.value}function vv(e,n,s){for(var i=0,l=e.length;i<l;++i)if(e[i].name===n){e[i]=A_,e=e.slice(0,i).concat(e.slice(i+1));break}return s!=null&&e.push({name:n,value:s}),e}var ax="http://www.w3.org/1999/xhtml";const jv={svg:"http://www.w3.org/2000/svg",xhtml:ax,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Mu(e){var n=e+="",s=n.indexOf(":");return s>=0&&(n=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),jv.hasOwnProperty(n)?{space:jv[n],local:e}:e}function R_(e){return function(){var n=this.ownerDocument,s=this.namespaceURI;return s===ax&&n.documentElement.namespaceURI===ax?n.createElement(e):n.createElementNS(s,e)}}function O_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Nw(e){var n=Mu(e);return(n.local?O_:R_)(n)}function D_(){}function Gx(e){return e==null?D_:function(){return this.querySelector(e)}}function L_(e){typeof e!="function"&&(e=Gx(e));for(var n=this._groups,s=n.length,i=new Array(s),l=0;l<s;++l)for(var c=n[l],d=c.length,u=i[l]=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(i,this._parents)}function I_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function z_(){return[]}function kw(e){return e==null?z_:function(){return this.querySelectorAll(e)}}function $_(e){return function(){return I_(e.apply(this,arguments))}}function B_(e){typeof e=="function"?e=$_(e):e=kw(e);for(var n=this._groups,s=n.length,i=[],l=[],c=0;c<s;++c)for(var d=n[c],u=d.length,h,f=0;f<u;++f)(h=d[f])&&(i.push(e.call(h,h.__data__,f,d)),l.push(h));return new rs(i,l)}function Sw(e){return function(){return this.matches(e)}}function Cw(e){return function(n){return n.matches(e)}}var H_=Array.prototype.find;function P_(e){return function(){return H_.call(this.children,e)}}function U_(){return this.firstElementChild}function q_(e){return this.select(e==null?U_:P_(typeof e=="function"?e:Cw(e)))}var F_=Array.prototype.filter;function V_(){return Array.from(this.children)}function Y_(e){return function(){return F_.call(this.children,e)}}function G_(e){return this.selectAll(e==null?V_:Y_(typeof e=="function"?e:Cw(e)))}function X_(e){typeof e!="function"&&(e=Sw(e));for(var n=this._groups,s=n.length,i=new Array(s),l=0;l<s;++l)for(var c=n[l],d=c.length,u=i[l]=[],h,f=0;f<d;++f)(h=c[f])&&e.call(h,h.__data__,f,c)&&u.push(h);return new rs(i,this._parents)}function Ew(e){return new Array(e.length)}function K_(){return new rs(this._enter||this._groups.map(Ew),this._parents)}function cu(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}cu.prototype={constructor:cu,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 W_(e){return function(){return e}}function Z_(e,n,s,i,l,c){for(var d=0,u,h=n.length,f=c.length;d<f;++d)(u=n[d])?(u.__data__=c[d],i[d]=u):s[d]=new cu(e,c[d]);for(;d<h;++d)(u=n[d])&&(l[d]=u)}function Q_(e,n,s,i,l,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)?l[u]=h:f.set(b,h));for(u=0;u<p;++u)b=d.call(e,c[u],u,c)+"",(h=f.get(b))?(i[u]=h,h.__data__=c[u],f.delete(b)):s[u]=new cu(e,c[u]);for(u=0;u<x;++u)(h=n[u])&&f.get(g[u])===h&&(l[u]=h)}function J_(e){return e.__data__}function eM(e,n){if(!arguments.length)return Array.from(this,J_);var s=n?Q_:Z_,i=this._parents,l=this._groups;typeof e!="function"&&(e=W_(e));for(var c=l.length,d=new Array(c),u=new Array(c),h=new Array(c),f=0;f<c;++f){var x=i[f],p=l[f],g=p.length,b=tM(e.call(x,x&&x.__data__,f,i)),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,i),d._enter=u,d._exit=h,d}function tM(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function nM(){return new rs(this._exit||this._groups.map(Ew),this._parents)}function rM(e,n,s){var i=this.enter(),l=this,c=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),n!=null&&(l=n(l),l&&(l=l.selection())),s==null?c.remove():s(c),i&&l?i.merge(l).order():l}function sM(e){for(var n=e.selection?e.selection():e,s=this._groups,i=n._groups,l=s.length,c=i.length,d=Math.min(l,c),u=new Array(l),h=0;h<d;++h)for(var f=s[h],x=i[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<l;++h)u[h]=s[h];return new rs(u,this._parents)}function aM(){for(var e=this._groups,n=-1,s=e.length;++n<s;)for(var i=e[n],l=i.length-1,c=i[l],d;--l>=0;)(d=i[l])&&(c&&d.compareDocumentPosition(c)^4&&c.parentNode.insertBefore(d,c),c=d);return this}function iM(e){e||(e=lM);function n(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var s=this._groups,i=s.length,l=new Array(i),c=0;c<i;++c){for(var d=s[c],u=d.length,h=l[c]=new Array(u),f,x=0;x<u;++x)(f=d[x])&&(h[x]=f);h.sort(n)}return new rs(l,this._parents).order()}function lM(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function oM(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function cM(){return Array.from(this)}function dM(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var i=e[n],l=0,c=i.length;l<c;++l){var d=i[l];if(d)return d}return null}function uM(){let e=0;for(const n of this)++e;return e}function fM(){return!this.node()}function mM(e){for(var n=this._groups,s=0,i=n.length;s<i;++s)for(var l=n[s],c=0,d=l.length,u;c<d;++c)(u=l[c])&&e.call(u,u.__data__,c,l);return this}function hM(e){return function(){this.removeAttribute(e)}}function xM(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pM(e,n){return function(){this.setAttribute(e,n)}}function gM(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function bM(e,n){return function(){var s=n.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function yM(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 vM(e,n){var s=Mu(e);if(arguments.length<2){var i=this.node();return s.local?i.getAttributeNS(s.space,s.local):i.getAttribute(s)}return this.each((n==null?s.local?xM:hM:typeof n=="function"?s.local?yM:bM:s.local?gM:pM)(s,n))}function Tw(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function jM(e){return function(){this.style.removeProperty(e)}}function wM(e,n,s){return function(){this.style.setProperty(e,n,s)}}function NM(e,n,s){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,s)}}function kM(e,n,s){return arguments.length>1?this.each((n==null?jM:typeof n=="function"?NM:wM)(e,n,s??"")):Rl(this.node(),e)}function Rl(e,n){return e.style.getPropertyValue(n)||Tw(e).getComputedStyle(e,null).getPropertyValue(n)}function SM(e){return function(){delete this[e]}}function CM(e,n){return function(){this[e]=n}}function EM(e,n){return function(){var s=n.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function TM(e,n){return arguments.length>1?this.each((n==null?SM:typeof n=="function"?EM:CM)(e,n)):this.node()[e]}function Aw(e){return e.trim().split(/^|\s+/)}function Xx(e){return e.classList||new _w(e)}function _w(e){this._node=e,this._names=Aw(e.getAttribute("class")||"")}_w.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 Mw(e,n){for(var s=Xx(e),i=-1,l=n.length;++i<l;)s.add(n[i])}function Rw(e,n){for(var s=Xx(e),i=-1,l=n.length;++i<l;)s.remove(n[i])}function AM(e){return function(){Mw(this,e)}}function _M(e){return function(){Rw(this,e)}}function MM(e,n){return function(){(n.apply(this,arguments)?Mw:Rw)(this,e)}}function RM(e,n){var s=Aw(e+"");if(arguments.length<2){for(var i=Xx(this.node()),l=-1,c=s.length;++l<c;)if(!i.contains(s[l]))return!1;return!0}return this.each((typeof n=="function"?MM:n?AM:_M)(s,n))}function OM(){this.textContent=""}function DM(e){return function(){this.textContent=e}}function LM(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function IM(e){return arguments.length?this.each(e==null?OM:(typeof e=="function"?LM:DM)(e)):this.node().textContent}function zM(){this.innerHTML=""}function $M(e){return function(){this.innerHTML=e}}function BM(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function HM(e){return arguments.length?this.each(e==null?zM:(typeof e=="function"?BM:$M)(e)):this.node().innerHTML}function PM(){this.nextSibling&&this.parentNode.appendChild(this)}function UM(){return this.each(PM)}function qM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function FM(){return this.each(qM)}function VM(e){var n=typeof e=="function"?e:Nw(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function YM(){return null}function GM(e,n){var s=typeof e=="function"?e:Nw(e),i=n==null?YM:typeof n=="function"?n:Gx(n);return this.select(function(){return this.insertBefore(s.apply(this,arguments),i.apply(this,arguments)||null)})}function XM(){var e=this.parentNode;e&&e.removeChild(this)}function KM(){return this.each(XM)}function WM(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function ZM(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function QM(e){return this.select(e?ZM:WM)}function JM(e){return arguments.length?this.property("__data__",e):this.node().__data__}function e6(e){return function(n){e.call(this,n,this.__data__)}}function t6(e){return e.trim().split(/^|\s+/).map(function(n){var s="",i=n.indexOf(".");return i>=0&&(s=n.slice(i+1),n=n.slice(0,i)),{type:n,name:s}})}function n6(e){return function(){var n=this.__on;if(n){for(var s=0,i=-1,l=n.length,c;s<l;++s)c=n[s],(!e.type||c.type===e.type)&&c.name===e.name?this.removeEventListener(c.type,c.listener,c.options):n[++i]=c;++i?n.length=i:delete this.__on}}}function r6(e,n,s){return function(){var i=this.__on,l,c=e6(n);if(i){for(var d=0,u=i.length;d<u;++d)if((l=i[d]).type===e.type&&l.name===e.name){this.removeEventListener(l.type,l.listener,l.options),this.addEventListener(l.type,l.listener=c,l.options=s),l.value=n;return}}this.addEventListener(e.type,c,s),l={type:e.type,name:e.name,value:n,listener:c,options:s},i?i.push(l):this.__on=[l]}}function s6(e,n,s){var i=t6(e+""),l,c=i.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(l=0,x=u[h];l<c;++l)if((d=i[l]).type===x.type&&d.name===x.name)return x.value}return}for(u=n?r6:n6,l=0;l<c;++l)this.each(u(i[l],n,s));return this}function Ow(e,n,s){var i=Tw(e),l=i.CustomEvent;typeof l=="function"?l=new l(n,s):(l=i.document.createEvent("Event"),s?(l.initEvent(n,s.bubbles,s.cancelable),l.detail=s.detail):l.initEvent(n,!1,!1)),e.dispatchEvent(l)}function a6(e,n){return function(){return Ow(this,e,n)}}function i6(e,n){return function(){return Ow(this,e,n.apply(this,arguments))}}function l6(e,n){return this.each((typeof n=="function"?i6:a6)(e,n))}function*o6(){for(var e=this._groups,n=0,s=e.length;n<s;++n)for(var i=e[n],l=0,c=i.length,d;l<c;++l)(d=i[l])&&(yield d)}var Dw=[null];function rs(e,n){this._groups=e,this._parents=n}function pc(){return new rs([[document.documentElement]],Dw)}function c6(){return this}rs.prototype=pc.prototype={constructor:rs,select:L_,selectAll:B_,selectChild:q_,selectChildren:G_,filter:X_,data:eM,enter:K_,exit:nM,join:rM,merge:sM,selection:c6,order:aM,sort:iM,call:oM,nodes:cM,node:dM,size:uM,empty:fM,each:mM,attr:vM,style:kM,property:TM,classed:RM,text:IM,html:HM,raise:UM,lower:FM,append:VM,insert:GM,remove:KM,clone:QM,datum:JM,on:s6,dispatch:l6,[Symbol.iterator]:o6};function ts(e){return typeof e=="string"?new rs([[document.querySelector(e)]],[document.documentElement]):new rs([[e]],Dw)}function d6(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Cs(e,n){if(e=d6(e),n===void 0&&(n=e.currentTarget),n){var s=n.ownerSVGElement||n;if(s.createSVGPoint){var i=s.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}if(n.getBoundingClientRect){var l=n.getBoundingClientRect();return[e.clientX-l.left-n.clientLeft,e.clientY-l.top-n.clientTop]}}return[e.pageX,e.pageY]}const u6={passive:!1},nc={capture:!0,passive:!1};function bh(e){e.stopImmediatePropagation()}function Al(e){e.preventDefault(),e.stopImmediatePropagation()}function Lw(e){var n=e.document.documentElement,s=ts(e).on("dragstart.drag",Al,nc);"onselectstart"in n?s.on("selectstart.drag",Al,nc):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Iw(e,n){var s=e.document.documentElement,i=ts(e).on("dragstart.drag",null);n&&(i.on("click.drag",Al,nc),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in s?i.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const Md=e=>()=>e;function ix(e,{sourceEvent:n,subject:s,target:i,identifier:l,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:i,enumerable:!0,configurable:!0},identifier:{value:l,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}})}ix.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function f6(e){return!e.ctrlKey&&!e.button}function m6(){return this.parentNode}function h6(e,n){return n??{x:e.x,y:e.y}}function x6(){return navigator.maxTouchPoints||"ontouchstart"in this}function zw(){var e=f6,n=m6,s=h6,i=x6,l={},c=_u("start","drag","end"),d=0,u,h,f,x,p=0;function g(A){A.on("mousedown.drag",b).filter(i).on("touchstart.drag",C).on("touchmove.drag",E,u6).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,nc).on("mouseup.drag",k,nc),Lw(A.view),bh(A),f=!1,u=A.clientX,h=A.clientY,_("start",A))}}function w(A){if(Al(A),!f){var R=A.clientX-u,_=A.clientY-h;f=R*R+_*_>p}l.mouse("drag",A)}function k(A){ts(A.view).on("mousemove.drag mouseup.drag",null),Iw(A.view,f),Al(A),l.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]))&&(bh(A),L("start",A,_[X]))}}function E(A){var R=A.changedTouches,_=R.length,Y,q;for(Y=0;Y<_;++Y)(q=l[R[Y].identifier])&&(Al(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=l[R[Y].identifier])&&(bh(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 ix("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":l[q]=z,B=d++;break;case"end":delete l[q],--d;case"drag":P=Cs(H||V,R),B=d;break}L.call(O,A,new ix(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:Md(!!A),g):e},g.container=function(A){return arguments.length?(n=typeof A=="function"?A:Md(A),g):n},g.subject=function(A){return arguments.length?(s=typeof A=="function"?A:Md(A),g):s},g.touchable=function(A){return arguments.length?(i=typeof A=="function"?A:Md(!!A),g):i},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 Kx(e,n,s){e.prototype=n.prototype=s,s.constructor=e}function $w(e,n){var s=Object.create(e.prototype);for(var i in n)s[i]=n[i];return s}function gc(){}var rc=.7,du=1/rc,_l="\\s*([+-]?\\d+)\\s*",sc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",p6=/^#([0-9a-f]{3,8})$/,g6=new RegExp(`^rgb\\(${_l},${_l},${_l}\\)$`),b6=new RegExp(`^rgb\\(${Gs},${Gs},${Gs}\\)$`),y6=new RegExp(`^rgba\\(${_l},${_l},${_l},${sc}\\)$`),v6=new RegExp(`^rgba\\(${Gs},${Gs},${Gs},${sc}\\)$`),j6=new RegExp(`^hsl\\(${sc},${Gs},${Gs}\\)$`),w6=new RegExp(`^hsla\\(${sc},${Gs},${Gs},${sc}\\)$`),wv={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};Kx(gc,Li,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Nv,formatHex:Nv,formatHex8:N6,formatHsl:k6,formatRgb:kv,toString:kv});function Nv(){return this.rgb().formatHex()}function N6(){return this.rgb().formatHex8()}function k6(){return Bw(this).formatHsl()}function kv(){return this.rgb().formatRgb()}function Li(e){var n,s;return e=(e+"").trim().toLowerCase(),(n=p6.exec(e))?(s=n[1].length,n=parseInt(n[1],16),s===6?Sv(n):s===3?new Fr(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):s===8?Rd(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):s===4?Rd(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=g6.exec(e))?new Fr(n[1],n[2],n[3],1):(n=b6.exec(e))?new Fr(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=y6.exec(e))?Rd(n[1],n[2],n[3],n[4]):(n=v6.exec(e))?Rd(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=j6.exec(e))?Tv(n[1],n[2]/100,n[3]/100,1):(n=w6.exec(e))?Tv(n[1],n[2]/100,n[3]/100,n[4]):wv.hasOwnProperty(e)?Sv(wv[e]):e==="transparent"?new Fr(NaN,NaN,NaN,0):null}function Sv(e){return new Fr(e>>16&255,e>>8&255,e&255,1)}function Rd(e,n,s,i){return i<=0&&(e=n=s=NaN),new Fr(e,n,s,i)}function S6(e){return e instanceof gc||(e=Li(e)),e?(e=e.rgb(),new Fr(e.r,e.g,e.b,e.opacity)):new Fr}function lx(e,n,s,i){return arguments.length===1?S6(e):new Fr(e,n,s,i??1)}function Fr(e,n,s,i){this.r=+e,this.g=+n,this.b=+s,this.opacity=+i}Kx(Fr,lx,$w(gc,{brighter(e){return e=e==null?du:Math.pow(du,e),new Fr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?rc:Math.pow(rc,e),new Fr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Fr(Mi(this.r),Mi(this.g),Mi(this.b),uu(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:Cv,formatHex:Cv,formatHex8:C6,formatRgb:Ev,toString:Ev}));function Cv(){return`#${Ai(this.r)}${Ai(this.g)}${Ai(this.b)}`}function C6(){return`#${Ai(this.r)}${Ai(this.g)}${Ai(this.b)}${Ai((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ev(){const e=uu(this.opacity);return`${e===1?"rgb(":"rgba("}${Mi(this.r)}, ${Mi(this.g)}, ${Mi(this.b)}${e===1?")":`, ${e})`}`}function uu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Mi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ai(e){return e=Mi(e),(e<16?"0":"")+e.toString(16)}function Tv(e,n,s,i){return i<=0?e=n=s=NaN:s<=0||s>=1?e=n=NaN:n<=0&&(e=NaN),new Es(e,n,s,i)}function Bw(e){if(e instanceof Es)return new Es(e.h,e.s,e.l,e.opacity);if(e instanceof gc||(e=Li(e)),!e)return new Es;if(e instanceof Es)return e;e=e.rgb();var n=e.r/255,s=e.g/255,i=e.b/255,l=Math.min(n,s,i),c=Math.max(n,s,i),d=NaN,u=c-l,h=(c+l)/2;return u?(n===c?d=(s-i)/u+(s<i)*6:s===c?d=(i-n)/u+2:d=(n-s)/u+4,u/=h<.5?c+l:2-c-l,d*=60):u=h>0&&h<1?0:d,new Es(d,u,h,e.opacity)}function E6(e,n,s,i){return arguments.length===1?Bw(e):new Es(e,n,s,i??1)}function Es(e,n,s,i){this.h=+e,this.s=+n,this.l=+s,this.opacity=+i}Kx(Es,E6,$w(gc,{brighter(e){return e=e==null?du:Math.pow(du,e),new Es(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?rc:Math.pow(rc,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,i=s+(s<.5?s:1-s)*n,l=2*s-i;return new Fr(yh(e>=240?e-240:e+120,l,i),yh(e,l,i),yh(e<120?e+240:e-120,l,i),this.opacity)},clamp(){return new Es(Av(this.h),Od(this.s),Od(this.l),uu(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=uu(this.opacity);return`${e===1?"hsl(":"hsla("}${Av(this.h)}, ${Od(this.s)*100}%, ${Od(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Av(e){return e=(e||0)%360,e<0?e+360:e}function Od(e){return Math.max(0,Math.min(1,e||0))}function yh(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 Wx=e=>()=>e;function T6(e,n){return function(s){return e+s*n}}function A6(e,n,s){return e=Math.pow(e,s),n=Math.pow(n,s)-e,s=1/s,function(i){return Math.pow(e+i*n,s)}}function _6(e){return(e=+e)==1?Hw:function(n,s){return s-n?A6(n,s,e):Wx(isNaN(n)?s:n)}}function Hw(e,n){var s=n-e;return s?T6(e,s):Wx(isNaN(e)?n:e)}const fu=(function e(n){var s=_6(n);function i(l,c){var d=s((l=lx(l)).r,(c=lx(c)).r),u=s(l.g,c.g),h=s(l.b,c.b),f=Hw(l.opacity,c.opacity);return function(x){return l.r=d(x),l.g=u(x),l.b=h(x),l.opacity=f(x),l+""}}return i.gamma=e,i})(1);function M6(e,n){n||(n=[]);var s=e?Math.min(n.length,e.length):0,i=n.slice(),l;return function(c){for(l=0;l<s;++l)i[l]=e[l]*(1-c)+n[l]*c;return i}}function R6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function O6(e,n){var s=n?n.length:0,i=e?Math.min(s,e.length):0,l=new Array(i),c=new Array(s),d;for(d=0;d<i;++d)l[d]=Xo(e[d],n[d]);for(;d<s;++d)c[d]=n[d];return function(u){for(d=0;d<i;++d)c[d]=l[d](u);return c}}function D6(e,n){var s=new Date;return e=+e,n=+n,function(i){return s.setTime(e*(1-i)+n*i),s}}function Vs(e,n){return e=+e,n=+n,function(s){return e*(1-s)+n*s}}function L6(e,n){var s={},i={},l;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(l in n)l in e?s[l]=Xo(e[l],n[l]):i[l]=n[l];return function(c){for(l in s)i[l]=s[l](c);return i}}var ox=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,vh=new RegExp(ox.source,"g");function I6(e){return function(){return e}}function z6(e){return function(n){return e(n)+""}}function Pw(e,n){var s=ox.lastIndex=vh.lastIndex=0,i,l,c,d=-1,u=[],h=[];for(e=e+"",n=n+"";(i=ox.exec(e))&&(l=vh.exec(n));)(c=l.index)>s&&(c=n.slice(s,c),u[d]?u[d]+=c:u[++d]=c),(i=i[0])===(l=l[0])?u[d]?u[d]+=l:u[++d]=l:(u[++d]=null,h.push({i:d,x:Vs(i,l)})),s=vh.lastIndex;return s<n.length&&(c=n.slice(s),u[d]?u[d]+=c:u[++d]=c),u.length<2?h[0]?z6(h[0].x):I6(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,i;return n==null||s==="boolean"?Wx(n):(s==="number"?Vs:s==="string"?(i=Li(n))?(n=i,fu):Pw:n instanceof Li?fu:n instanceof Date?D6:R6(n)?M6:Array.isArray(n)?O6:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?L6:Vs)(e,n)}var _v=180/Math.PI,cx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Uw(e,n,s,i,l,c){var d,u,h;return(d=Math.sqrt(e*e+n*n))&&(e/=d,n/=d),(h=e*s+n*i)&&(s-=e*h,i-=n*h),(u=Math.sqrt(s*s+i*i))&&(s/=u,i/=u,h/=u),e*i<n*s&&(e=-e,n=-n,h=-h,d=-d),{translateX:l,translateY:c,rotate:Math.atan2(n,e)*_v,skewX:Math.atan(h)*_v,scaleX:d,scaleY:u}}var Dd;function $6(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?cx:Uw(n.a,n.b,n.c,n.d,n.e,n.f)}function B6(e){return e==null||(Dd||(Dd=document.createElementNS("http://www.w3.org/2000/svg","g")),Dd.setAttribute("transform",e),!(e=Dd.transform.baseVal.consolidate()))?cx:(e=e.matrix,Uw(e.a,e.b,e.c,e.d,e.e,e.f))}function qw(e,n,s,i){function l(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(l(p)+"rotate(",null,i)-2,x:Vs(f,x)})):x&&p.push(l(p)+"rotate("+x+i)}function u(f,x,p,g){f!==x?g.push({i:p.push(l(p)+"skewX(",null,i)-2,x:Vs(f,x)}):x&&p.push(l(p)+"skewX("+x+i)}function h(f,x,p,g,b,w){if(f!==p||x!==g){var k=b.push(l(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(l(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 H6=qw($6,"px, ","px)","deg)"),P6=qw(B6,", ",")",")"),U6=1e-12;function Mv(e){return((e=Math.exp(e))+1/e)/2}function q6(e){return((e=Math.exp(e))-1/e)/2}function F6(e){return((e=Math.exp(2*e))-1)/(e+1)}const Kd=(function e(n,s,i){function l(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<U6)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+i*k)/(2*f*s*M),A=(g*g-f*f-i*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=Mv(R),L=f/(s*M)*(X*F6(n*q+R)-q6(R));return[u+L*b,h+L*w,f*X/Mv(n*q+R)]}}return C.duration=E*1e3*n/Math.SQRT2,C}return l.rho=function(c){var d=Math.max(.001,+c),u=d*d,h=u*u;return e(d,u,h)},l})(Math.SQRT2,2,4);var Ol=0,Po=0,Io=0,Fw=1e3,mu,Uo,hu=0,Ii=0,Ru=0,ac=typeof performance=="object"&&performance.now?performance:Date,Vw=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Zx(){return Ii||(Vw(V6),Ii=ac.now()+Ru)}function V6(){Ii=0}function xu(){this._call=this._time=this._next=null}xu.prototype=Yw.prototype={constructor:xu,restart:function(e,n,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?Zx():+s)+(n==null?0:+n),!this._next&&Uo!==this&&(Uo?Uo._next=this:mu=this,Uo=this),this._call=e,this._time=s,dx()},stop:function(){this._call&&(this._call=null,this._time=1/0,dx())}};function Yw(e,n,s){var i=new xu;return i.restart(e,n,s),i}function Y6(){Zx(),++Ol;for(var e=mu,n;e;)(n=Ii-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Ol}function Rv(){Ii=(hu=ac.now())+Ru,Ol=Po=0;try{Y6()}finally{Ol=0,X6(),Ii=0}}function G6(){var e=ac.now(),n=e-hu;n>Fw&&(Ru-=n,hu=e)}function X6(){for(var e,n=mu,s,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(s=n._next,n._next=null,n=e?e._next=s:mu=s);Uo=e,dx(i)}function dx(e){if(!Ol){Po&&(Po=clearTimeout(Po));var n=e-Ii;n>24?(e<1/0&&(Po=setTimeout(Rv,e-ac.now()-Ru)),Io&&(Io=clearInterval(Io))):(Io||(hu=ac.now(),Io=setInterval(G6,Fw)),Ol=1,Vw(Rv))}}function Ov(e,n,s){var i=new xu;return n=n==null?0:+n,i.restart(l=>{i.stop(),e(l+n)},n,s),i}var K6=_u("start","end","cancel","interrupt"),W6=[],Gw=0,Dv=1,ux=2,Wd=3,Lv=4,fx=5,Zd=6;function Ou(e,n,s,i,l,c){var d=e.__transition;if(!d)e.__transition={};else if(s in d)return;Z6(e,s,{name:n,index:i,group:l,on:K6,tween:W6,time:c.time,delay:c.delay,duration:c.duration,ease:c.ease,timer:null,state:Gw})}function Qx(e,n){var s=Rs(e,n);if(s.state>Gw)throw new Error("too late; already scheduled");return s}function Ws(e,n){var s=Rs(e,n);if(s.state>Wd)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 Z6(e,n,s){var i=e.__transition,l;i[n]=s,s.timer=Yw(c,0,s.time);function c(f){s.state=Dv,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!==Dv)return h();for(x in i)if(b=i[x],b.name===s.name){if(b.state===Wd)return Ov(d);b.state===Lv?(b.state=Zd,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete i[x]):+x<n&&(b.state=Zd,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete i[x])}if(Ov(function(){s.state===Wd&&(s.state=Lv,s.timer.restart(u,s.delay,s.time),u(f))}),s.state=ux,s.on.call("start",e,e.__data__,s.index,s.group),s.state===ux){for(s.state=Wd,l=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))&&(l[++p]=b);l.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=fx,1),p=-1,g=l.length;++p<g;)l[p].call(e,x);s.state===fx&&(s.on.call("end",e,e.__data__,s.index,s.group),h())}function h(){s.state=Zd,s.timer.stop(),delete i[n];for(var f in i)return;delete e.__transition}}function Qd(e,n){var s=e.__transition,i,l,c=!0,d;if(s){n=n==null?null:n+"";for(d in s){if((i=s[d]).name!==n){c=!1;continue}l=i.state>ux&&i.state<fx,i.state=Zd,i.timer.stop(),i.on.call(l?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete s[d]}c&&delete e.__transition}}function Q6(e){return this.each(function(){Qd(this,e)})}function J6(e,n){var s,i;return function(){var l=Ws(this,e),c=l.tween;if(c!==s){i=s=c;for(var d=0,u=i.length;d<u;++d)if(i[d].name===n){i=i.slice(),i.splice(d,1);break}}l.tween=i}}function eR(e,n,s){var i,l;if(typeof s!="function")throw new Error;return function(){var c=Ws(this,e),d=c.tween;if(d!==i){l=(i=d).slice();for(var u={name:n,value:s},h=0,f=l.length;h<f;++h)if(l[h].name===n){l[h]=u;break}h===f&&l.push(u)}c.tween=l}}function tR(e,n){var s=this._id;if(e+="",arguments.length<2){for(var i=Rs(this.node(),s).tween,l=0,c=i.length,d;l<c;++l)if((d=i[l]).name===e)return d.value;return null}return this.each((n==null?J6:eR)(s,e,n))}function Jx(e,n,s){var i=e._id;return e.each(function(){var l=Ws(this,i);(l.value||(l.value={}))[n]=s.apply(this,arguments)}),function(l){return Rs(l,i).value[n]}}function Xw(e,n){var s;return(typeof n=="number"?Vs:n instanceof Li?fu:(s=Li(n))?(n=s,fu):Pw)(e,n)}function nR(e){return function(){this.removeAttribute(e)}}function rR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sR(e,n,s){var i,l=s+"",c;return function(){var d=this.getAttribute(e);return d===l?null:d===i?c:c=n(i=d,s)}}function aR(e,n,s){var i,l=s+"",c;return function(){var d=this.getAttributeNS(e.space,e.local);return d===l?null:d===i?c:c=n(i=d,s)}}function iR(e,n,s){var i,l,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===i&&h===l?c:(l=h,c=n(i=d,u)))}}function lR(e,n,s){var i,l,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===i&&h===l?c:(l=h,c=n(i=d,u)))}}function oR(e,n){var s=Mu(e),i=s==="transform"?P6:Xw;return this.attrTween(e,typeof n=="function"?(s.local?lR:iR)(s,i,Jx(this,"attr."+e,n)):n==null?(s.local?rR:nR)(s):(s.local?aR:sR)(s,i,n))}function cR(e,n){return function(s){this.setAttribute(e,n.call(this,s))}}function dR(e,n){return function(s){this.setAttributeNS(e.space,e.local,n.call(this,s))}}function uR(e,n){var s,i;function l(){var c=n.apply(this,arguments);return c!==i&&(s=(i=c)&&dR(e,c)),s}return l._value=n,l}function fR(e,n){var s,i;function l(){var c=n.apply(this,arguments);return c!==i&&(s=(i=c)&&cR(e,c)),s}return l._value=n,l}function mR(e,n){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;var i=Mu(e);return this.tween(s,(i.local?uR:fR)(i,n))}function hR(e,n){return function(){Qx(this,e).delay=+n.apply(this,arguments)}}function xR(e,n){return n=+n,function(){Qx(this,e).delay=n}}function pR(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?hR:xR)(n,e)):Rs(this.node(),n).delay}function gR(e,n){return function(){Ws(this,e).duration=+n.apply(this,arguments)}}function bR(e,n){return n=+n,function(){Ws(this,e).duration=n}}function yR(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?gR:bR)(n,e)):Rs(this.node(),n).duration}function vR(e,n){if(typeof n!="function")throw new Error;return function(){Ws(this,e).ease=n}}function jR(e){var n=this._id;return arguments.length?this.each(vR(n,e)):Rs(this.node(),n).ease}function wR(e,n){return function(){var s=n.apply(this,arguments);if(typeof s!="function")throw new Error;Ws(this,e).ease=s}}function NR(e){if(typeof e!="function")throw new Error;return this.each(wR(this._id,e))}function kR(e){typeof e!="function"&&(e=Sw(e));for(var n=this._groups,s=n.length,i=new Array(s),l=0;l<s;++l)for(var c=n[l],d=c.length,u=i[l]=[],h,f=0;f<d;++f)(h=c[f])&&e.call(h,h.__data__,f,c)&&u.push(h);return new ja(i,this._parents,this._name,this._id)}function SR(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,s=e._groups,i=n.length,l=s.length,c=Math.min(i,l),d=new Array(i),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<i;++u)d[u]=n[u];return new ja(d,this._parents,this._name,this._id)}function CR(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 ER(e,n,s){var i,l,c=CR(n)?Qx:Ws;return function(){var d=c(this,e),u=d.on;u!==i&&(l=(i=u).copy()).on(n,s),d.on=l}}function TR(e,n){var s=this._id;return arguments.length<2?Rs(this.node(),s).on.on(e):this.each(ER(s,e,n))}function AR(e){return function(){var n=this.parentNode;for(var s in this.__transition)if(+s!==e)return;n&&n.removeChild(this)}}function _R(){return this.on("end.remove",AR(this._id))}function MR(e){var n=this._name,s=this._id;typeof e!="function"&&(e=Gx(e));for(var i=this._groups,l=i.length,c=new Array(l),d=0;d<l;++d)for(var u=i[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,Ou(f[g],n,s,g,f,Rs(x,s)));return new ja(c,this._parents,n,s)}function RR(e){var n=this._name,s=this._id;typeof e!="function"&&(e=kw(e));for(var i=this._groups,l=i.length,c=[],d=[],u=0;u<l;++u)for(var h=i[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])&&Ou(b,n,s,k,g,w);c.push(g),d.push(x)}return new ja(c,d,n,s)}var OR=pc.prototype.constructor;function DR(){return new OR(this._groups,this._parents)}function LR(e,n){var s,i,l;return function(){var c=Rl(this,e),d=(this.style.removeProperty(e),Rl(this,e));return c===d?null:c===s&&d===i?l:l=n(s=c,i=d)}}function Kw(e){return function(){this.style.removeProperty(e)}}function IR(e,n,s){var i,l=s+"",c;return function(){var d=Rl(this,e);return d===l?null:d===i?c:c=n(i=d,s)}}function zR(e,n,s){var i,l,c;return function(){var d=Rl(this,e),u=s(this),h=u+"";return u==null&&(h=u=(this.style.removeProperty(e),Rl(this,e))),d===h?null:d===i&&h===l?c:(l=h,c=n(i=d,u))}}function $R(e,n){var s,i,l,c="style."+n,d="end."+c,u;return function(){var h=Ws(this,e),f=h.on,x=h.value[c]==null?u||(u=Kw(n)):void 0;(f!==s||l!==x)&&(i=(s=f).copy()).on(d,l=x),h.on=i}}function BR(e,n,s){var i=(e+="")=="transform"?H6:Xw;return n==null?this.styleTween(e,LR(e,i)).on("end.style."+e,Kw(e)):typeof n=="function"?this.styleTween(e,zR(e,i,Jx(this,"style."+e,n))).each($R(this._id,e)):this.styleTween(e,IR(e,i,n),s).on("end.style."+e,null)}function HR(e,n,s){return function(i){this.style.setProperty(e,n.call(this,i),s)}}function PR(e,n,s){var i,l;function c(){var d=n.apply(this,arguments);return d!==l&&(i=(l=d)&&HR(e,d,s)),i}return c._value=n,c}function UR(e,n,s){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;return this.tween(i,PR(e,n,s??""))}function qR(e){return function(){this.textContent=e}}function FR(e){return function(){var n=e(this);this.textContent=n??""}}function VR(e){return this.tween("text",typeof e=="function"?FR(Jx(this,"text",e)):qR(e==null?"":e+""))}function YR(e){return function(n){this.textContent=e.call(this,n)}}function GR(e){var n,s;function i(){var l=e.apply(this,arguments);return l!==s&&(n=(s=l)&&YR(l)),n}return i._value=e,i}function XR(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,GR(e))}function KR(){for(var e=this._name,n=this._id,s=Ww(),i=this._groups,l=i.length,c=0;c<l;++c)for(var d=i[c],u=d.length,h,f=0;f<u;++f)if(h=d[f]){var x=Rs(h,n);Ou(h,e,s,f,d,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new ja(i,this._parents,e,s)}function WR(){var e,n,s=this,i=s._id,l=s.size();return new Promise(function(c,d){var u={value:d},h={value:function(){--l===0&&c()}};s.each(function(){var f=Ws(this,i),x=f.on;x!==e&&(n=(e=x).copy(),n._.cancel.push(u),n._.interrupt.push(u),n._.end.push(h)),f.on=n}),l===0&&c()})}var ZR=0;function ja(e,n,s,i){this._groups=e,this._parents=n,this._name=s,this._id=i}function Ww(){return++ZR}var ha=pc.prototype;ja.prototype={constructor:ja,select:MR,selectAll:RR,selectChild:ha.selectChild,selectChildren:ha.selectChildren,filter:kR,merge:SR,selection:DR,transition:KR,call:ha.call,nodes:ha.nodes,node:ha.node,size:ha.size,empty:ha.empty,each:ha.each,on:TR,attr:oR,attrTween:mR,style:BR,styleTween:UR,text:VR,textTween:XR,remove:_R,tween:tR,delay:pR,duration:yR,ease:jR,easeVarying:NR,end:WR,[Symbol.iterator]:ha[Symbol.iterator]};function QR(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var JR={time:null,delay:0,duration:250,ease:QR};function eO(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 tO(e){var n,s;e instanceof ja?(n=e._id,e=e._name):(n=Ww(),(s=JR).time=Zx(),e=e==null?null:e+"");for(var i=this._groups,l=i.length,c=0;c<l;++c)for(var d=i[c],u=d.length,h,f=0;f<u;++f)(h=d[f])&&Ou(h,e,n,f,d,s||eO(h,n));return new ja(i,this._parents,e,n)}pc.prototype.interrupt=Q6;pc.prototype.transition=tO;const Ld=e=>()=>e;function nO(e,{sourceEvent:n,target:s,transform:i,dispatch:l}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:l}})}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 Du=new ya(1,0,0);Zw.prototype=ya.prototype;function Zw(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Du;return e.__zoom}function jh(e){e.stopImmediatePropagation()}function zo(e){e.preventDefault(),e.stopImmediatePropagation()}function rO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sO(){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 Iv(){return this.__zoom||Du}function aO(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 lO(e,n,s){var i=e.invertX(n[0][0])-s[0][0],l=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(l>i?(i+l)/2:Math.min(0,i)||Math.max(0,l),d>c?(c+d)/2:Math.min(0,c)||Math.max(0,d))}function Qw(){var e=rO,n=sO,s=lO,i=aO,l=iO,c=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],u=250,h=Kd,f=_u("start","zoom","end"),x,p,g,b=500,w=150,k=0,C=10;function E(T){T.property("__zoom",Iv).on("wheel.zoom",q,{passive:!1}).on("mousedown.zoom",X).on("dblclick.zoom",L).filter(l).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",Iv),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(Du.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 nO(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,i.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)],Qd(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;Lw(T.view),jh(T),V.mouse=[Z,this.__zoom.invert(Z)],Qd(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),Iw(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(jh(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)),Qd(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(jh(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?(i=typeof T=="function"?T:Ld(+T),E):i},E.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Ld(!!T),E):e},E.touchable=function(T){return arguments.length?(l=typeof T=="function"?T:Ld(!!T),E):l},E.extent=function(T){return arguments.length?(n=typeof T=="function"?T:Ld([[+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:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:i}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ic=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Jw=["Enter"," ","Escape"],eN={"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 Dl;(function(e){e.Strict="strict",e.Loose="loose"})(Dl||(Dl={}));var Ri;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ri||(Ri={}));var lc;(function(e){e.Partial="partial",e.Full="full"})(lc||(lc={}));const tN={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ri;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ri||(ri={}));var Ll;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ll||(Ll={}));var mt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(mt||(mt={}));const zv={[mt.Left]:mt.Right,[mt.Right]:mt.Left,[mt.Top]:mt.Bottom,[mt.Bottom]:mt.Top};function nN(e){return e===null?null:e?"valid":"invalid"}const rN=e=>"id"in e&&"source"in e&&"target"in e,oO=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ep=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),bc=(e,n=[0,0])=>{const{width:s,height:i}=Na(e),l=e.origin??n,c=s*l[0],d=i*l[1];return{x:e.position.x-c,y:e.position.y-d}},cO=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((i,l)=>{const c=typeof l=="string";let d=!n.nodeLookup&&!c?l:void 0;n.nodeLookup&&(d=c?n.nodeLookup.get(l):ep(l)?l:n.nodeLookup.get(l.id));const u=d?pu(d,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Lu(i,u)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Iu(s)},yc=(e,n={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(l=>{(n.filter===void 0||n.filter(l))&&(s=Lu(s,pu(l)),i=!0)}),i?Iu(s):{x:0,y:0,width:0,height:0}},tp=(e,n,[s,i,l]=[0,0,1],c=!1,d=!1)=>{const u={...jc(n,[s,i,l]),width:n.width/l,height:n.height/l},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=oc(u,zl(f)),C=(b??0)*(w??0),E=c&&k>0;(!f.internals.handleBounds||E||k>=C||f.dragging)&&h.push(f)}return h},dO=(e,n)=>{const s=new Set;return e.forEach(i=>{s.add(i.id)}),n.filter(i=>s.has(i.source)||s.has(i.target))};function uO(e,n){const s=new Map,i=n?.nodes?new Set(n.nodes.map(l=>l.id)):null;return e.forEach(l=>{l.measured.width&&l.measured.height&&(n?.includeHiddenNodes||!l.hidden)&&(!i||i.has(l.id))&&s.set(l.id,l)}),s}async function fO({nodes:e,width:n,height:s,panZoom:i,minZoom:l,maxZoom:c},d){if(e.size===0)return Promise.resolve(!0);const u=uO(e,d),h=yc(u),f=np(h,n,s,d?.minZoom??l,d?.maxZoom??c,d?.padding??.1);return await i.setViewport(f,{duration:d?.duration,ease:d?.ease,interpolate:d?.interpolate}),Promise.resolve(!0)}function sN({nodeId:e,nextPosition:n,nodeLookup:s,nodeOrigin:i=[0,0],nodeExtent:l,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??i;let p=d.extent||l;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&&$l(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=$l(p)?zi(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 mO({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:i,onBeforeDelete:l}){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=i.filter(g=>g.deletable!==!1),x=dO(d,h);for(const g of h)u.has(g.id)&&!x.find(w=>w.id===g.id)&&x.push(g);if(!l)return{edges:x,nodes:d};const p=await l({nodes:d,edges:x});return typeof p=="boolean"?p?{edges:x,nodes:d}:{edges:[],nodes:[]}:p}const Il=(e,n=0,s=1)=>Math.min(Math.max(e,n),s),zi=(e={x:0,y:0},n,s)=>({x:Il(e.x,n[0][0],n[1][0]-(s?.width??0)),y:Il(e.y,n[0][1],n[1][1]-(s?.height??0))});function aN(e,n,s){const{width:i,height:l}=Na(s),{x:c,y:d}=s.internals.positionAbsolute;return zi(e,[[c,d],[c+i,d+l]],n)}const $v=(e,n,s)=>e<n?Il(Math.abs(e-n),1,n)/n:e>s?-Il(Math.abs(e-s),1,n)/n:0,iN=(e,n,s=15,i=40)=>{const l=$v(e.x,i,n.width-i)*s,c=$v(e.y,i,n.height-i)*s;return[l,c]},Lu=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),mx=({x:e,y:n,width:s,height:i})=>({x:e,y:n,x2:e+s,y2:n+i}),Iu=({x:e,y:n,x2:s,y2:i})=>({x:e,y:n,width:s-e,height:i-n}),zl=(e,n=[0,0])=>{const{x:s,y:i}=ep(e)?e.internals.positionAbsolute:bc(e,n);return{x:s,y:i,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},pu=(e,n=[0,0])=>{const{x:s,y:i}=ep(e)?e.internals.positionAbsolute:bc(e,n);return{x:s,y:i,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:i+(e.measured?.height??e.height??e.initialHeight??0)}},lN=(e,n)=>Iu(Lu(mx(e),mx(n))),oc=(e,n)=>{const s=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),i=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(s*i)},Bv=e=>Ts(e.width)&&Ts(e.height)&&Ts(e.x)&&Ts(e.y),Ts=e=>!isNaN(e)&&isFinite(e),hO=(e,n)=>{},vc=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),jc=({x:e,y:n},[s,i,l],c=!1,d=[1,1])=>{const u={x:(e-s)/l,y:(n-i)/l};return c?vc(u,d):u},gu=({x:e,y:n},[s,i,l])=>({x:e*l+s,y:n*l+i});function yl(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 xO(e,n,s){if(typeof e=="string"||typeof e=="number"){const i=yl(e,s),l=yl(e,n);return{top:i,right:l,bottom:i,left:l,x:l*2,y:i*2}}if(typeof e=="object"){const i=yl(e.top??e.y??0,s),l=yl(e.bottom??e.y??0,s),c=yl(e.left??e.x??0,n),d=yl(e.right??e.x??0,n);return{top:i,right:d,bottom:l,left:c,x:c+d,y:i+l}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function pO(e,n,s,i,l,c){const{x:d,y:u}=gu(e,[n,s,i]),{x:h,y:f}=gu({x:e.x+e.width,y:e.y+e.height},[n,s,i]),x=l-h,p=c-f;return{left:Math.floor(d),top:Math.floor(u),right:Math.floor(x),bottom:Math.floor(p)}}const np=(e,n,s,i,l,c)=>{const d=xO(c,n,s),u=(n-d.x)/e.width,h=(s-d.y)/e.height,f=Math.min(u,h),x=Il(f,i,l),p=e.x+e.width/2,g=e.y+e.height/2,b=n/2-p*x,w=s/2-g*x,k=pO(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}},cc=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function $l(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 oN(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function cN(e,n={width:0,height:0},s,i,l){const c={...e},d=i.get(s);if(d){const u=d.origin||l;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 Hv(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function gO(){let e,n;return{promise:new Promise((i,l)=>{e=i,n=l}),resolve:e,reject:n}}function bO(e){return{...eN,...e||{}}}function Ko(e,{snapGrid:n=[0,0],snapToGrid:s=!1,transform:i,containerBounds:l}){const{x:c,y:d}=As(e),u=jc({x:c-(l?.left??0),y:d-(l?.top??0)},i),{x:h,y:f}=s?vc(u,n):u;return{xSnapped:h,ySnapped:f,...u}}const rp=e=>({width:e.offsetWidth,height:e.offsetHeight}),dN=e=>e?.getRootNode?.()||window?.document,yO=["INPUT","SELECT","TEXTAREA"];function uN(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:yO.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const fN=e=>"clientX"in e,As=(e,n)=>{const s=fN(e),i=s?e.clientX:e.touches?.[0].clientX,l=s?e.clientY:e.touches?.[0].clientY;return{x:i-(n?.left??0),y:l-(n?.top??0)}},Pv=(e,n,s,i,l)=>{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:l,position:d.getAttribute("data-handlepos"),x:(u.left-s.left)/i,y:(u.top-s.top)/i,...rp(d)}})};function mN({sourceX:e,sourceY:n,targetX:s,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:u}){const h=e*.125+l*.375+d*.375+s*.125,f=n*.125+c*.375+u*.375+i*.125,x=Math.abs(h-e),p=Math.abs(f-n);return[h,f,x,p]}function Id(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Uv({pos:e,x1:n,y1:s,x2:i,y2:l,c}){switch(e){case mt.Left:return[n-Id(n-i,c),s];case mt.Right:return[n+Id(i-n,c),s];case mt.Top:return[n,s-Id(s-l,c)];case mt.Bottom:return[n,s+Id(l-s,c)]}}function hN({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:i,targetY:l,targetPosition:c=mt.Top,curvature:d=.25}){const[u,h]=Uv({pos:s,x1:e,y1:n,x2:i,y2:l,c:d}),[f,x]=Uv({pos:c,x1:i,y1:l,x2:e,y2:n,c:d}),[p,g,b,w]=mN({sourceX:e,sourceY:n,targetX:i,targetY:l,sourceControlX:u,sourceControlY:h,targetControlX:f,targetControlY:x});return[`M${e},${n} C${u},${h} ${f},${x} ${i},${l}`,p,g,b,w]}function xN({sourceX:e,sourceY:n,targetX:s,targetY:i}){const l=Math.abs(s-e)/2,c=s<e?s+l:s-l,d=Math.abs(i-n)/2,u=i<n?i+d:i-d;return[c,u,l,d]}function vO({sourceNode:e,targetNode:n,selected:s=!1,zIndex:i=0,elevateOnSelect:l=!1,zIndexMode:c="basic"}){if(c==="manual")return i;const d=l&&s?i+1e3:i,u=Math.max(e.parentId||l&&e.selected?e.internals.z:0,n.parentId||l&&n.selected?n.internals.z:0);return d+u}function jO({sourceNode:e,targetNode:n,width:s,height:i,transform:l}){const c=Lu(pu(e),pu(n));c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d={x:-l[0]/l[2],y:-l[1]/l[2],width:s/l[2],height:i/l[2]};return oc(d,Iu(c))>0}const wO=({source:e,sourceHandle:n,target:s,targetHandle:i})=>`xy-edge__${e}${n||""}-${s}${i||""}`,NO=(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)),kO=(e,n,s={})=>{if(!e.source||!e.target)return n;const i=s.getEdgeId||wO;let l;return rN(e)?l={...e}:l={...e,id:i(e)},NO(l,n)?n:(l.sourceHandle===null&&delete l.sourceHandle,l.targetHandle===null&&delete l.targetHandle,n.concat(l))};function pN({sourceX:e,sourceY:n,targetX:s,targetY:i}){const[l,c,d,u]=xN({sourceX:e,sourceY:n,targetX:s,targetY:i});return[`M ${e},${n}L ${s},${i}`,l,c,d,u]}const qv={[mt.Left]:{x:-1,y:0},[mt.Right]:{x:1,y:0},[mt.Top]:{x:0,y:-1},[mt.Bottom]:{x:0,y:1}},SO=({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},Fv=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function CO({source:e,sourcePosition:n=mt.Bottom,target:s,targetPosition:i=mt.Top,center:l,offset:c,stepPosition:d}){const u=qv[n],h=qv[i],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=SO({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]=xN({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(u[g]*h[g]===-1){g==="x"?(k=l.x??f.x+(x.x-f.x)*d,C=l.y??(f.y+x.y)/2):(k=l.x??(f.x+x.x)/2,C=l.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===i){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!==i){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 EO(e,n,s,i){const l=Math.min(Fv(e,n)/2,Fv(n,s)/2,i),{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+l*f},${d}Q ${c},${d} ${c},${d+l*x}`}const u=e.x<s.x?1:-1,h=e.y<s.y?-1:1;return`L ${c},${d+l*h}Q ${c},${d} ${c+l*u},${d}`}function hx({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:i,targetY:l,targetPosition:c=mt.Top,borderRadius:d=5,centerX:u,centerY:h,offset:f=20,stepPosition:x=.5}){const[p,g,b,w,k]=CO({source:{x:e,y:n},sourcePosition:s,target:{x:i,y:l},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=EO(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 Vv(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function TO(e){const{sourceNode:n,targetNode:s}=e;if(!Vv(n)||!Vv(s))return null;const i=n.internals.handleBounds||Yv(n.handles),l=s.internals.handleBounds||Yv(s.handles),c=Gv(i?.source??[],e.sourceHandle),d=Gv(e.connectionMode===Dl.Strict?l?.target??[]:(l?.target??[]).concat(l?.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=$i(n,c,u),x=$i(s,d,h);return{sourceX:f.x,sourceY:f.y,targetX:x.x,targetY:x.y,sourcePosition:u,targetPosition:h}}function Yv(e){if(!e)return null;const n=[],s=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?n.push(i):i.type==="target"&&s.push(i);return{source:n,target:s}}function $i(e,n,s=mt.Left,i=!1){const l=(n?.x??0)+e.internals.positionAbsolute.x,c=(n?.y??0)+e.internals.positionAbsolute.y,{width:d,height:u}=n??Na(e);if(i)return{x:l+d/2,y:c+u/2};switch(n?.position??s){case mt.Top:return{x:l+d/2,y:c};case mt.Right:return{x:l+d,y:c+u/2};case mt.Bottom:return{x:l+d/2,y:c+u};case mt.Left:return{x:l,y:c+u/2}}}function Gv(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function xx(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function AO(e,{id:n,defaultColor:s,defaultMarkerStart:i,defaultMarkerEnd:l}){const c=new Set;return e.reduce((d,u)=>([u.markerStart||i,u.markerEnd||l].forEach(h=>{if(h&&typeof h=="object"){const f=xx(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 gN=1e3,_O=10,sp={nodeOrigin:[0,0],nodeExtent:ic,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},MO={...sp,checkEquality:!0};function ap(e,n){const s={...e};for(const i in n)n[i]!==void 0&&(s[i]=n[i]);return s}function RO(e,n,s){const i=ap(sp,s);for(const l of e.values())if(l.parentId)lp(l,e,n,i);else{const c=bc(l,i.nodeOrigin),d=$l(l.extent)?l.extent:i.nodeExtent,u=zi(c,d,Na(l));l.internals.positionAbsolute=u}}function OO(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const s=[],i=[];for(const l of e.handles){const c={id:l.id,width:l.width??1,height:l.height??1,nodeId:e.id,x:l.x,y:l.y,position:l.position,type:l.type};l.type==="source"?s.push(c):l.type==="target"&&i.push(c)}return{source:s,target:i}}function ip(e){return e==="manual"}function px(e,n,s,i={}){const l=ap(MO,i),c={i:0},d=new Map(n),u=l?.elevateNodesOnSelect&&!ip(l.zIndexMode)?gN:0;let h=e.length>0;n.clear(),s.clear();for(const f of e){let x=d.get(f.id);if(l.checkEquality&&f===x?.internals.userNode)n.set(f.id,x);else{const p=bc(f,l.nodeOrigin),g=$l(f.extent)?f.extent:l.nodeExtent,b=zi(p,g,Na(f));x={...l.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:b,handleBounds:OO(f,x),z:bN(f,u,l.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&&lp(x,n,s,i,c)}return h}function DO(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 lp(e,n,s,i,l){const{elevateNodesOnSelect:c,nodeOrigin:d,nodeExtent:u,zIndexMode:h}=ap(sp,i),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}DO(e,s),l&&!x.parentId&&x.internals.rootParentIndex===void 0&&h==="auto"&&(x.internals.rootParentIndex=++l.i,x.internals.z=x.internals.z+l.i*_O),l&&x.internals.rootParentIndex!==void 0&&(l.i=x.internals.rootParentIndex);const p=c&&!ip(h)?gN:0,{x:g,y:b,z:w}=LO(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 bN(e,n,s){const i=Ts(e.zIndex)?e.zIndex:0;return ip(s)?i:i+(e.selected?n:0)}function LO(e,n,s,i,l,c){const{x:d,y:u}=n.internals.positionAbsolute,h=Na(e),f=bc(e,s),x=$l(e.extent)?zi(f,e.extent,h):f;let p=zi({x:d+x.x,y:u+x.y},i,h);e.extent==="parent"&&(p=aN(p,h,n));const g=bN(e,l,c),b=n.internals.z??0;return{x:p.x,y:p.y,z:b>=g?b+1:g}}function op(e,n,s,i=[0,0]){const l=[],c=new Map;for(const d of e){const u=n.get(d.parentId);if(!u)continue;const h=c.get(d.parentId)?.expandedRect??zl(u),f=lN(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??i,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)&&(l.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)||l.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)&&l.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?p[0]*g-C:0),height:k+(b?p[1]*b-E:0)}})}),l}function IO(e,n,s,i,l,c,d){const u=i?.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=rp(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=$l(w.extent)?w.extent:c;let{positionAbsolute:A}=w.internals;w.parentId&&w.extent==="parent"?A=aN(A,k,n.get(w.parentId)):N&&(A=zi(A,N,k));const R={...w,measured:k,internals:{...w.internals,positionAbsolute:A,handleBounds:{source:Pv("source",b.nodeElement,M,p,w.id),target:Pv("target",b.nodeElement,M,p,w.id)}}};n.set(w.id,R),w.parentId&&lp(R,n,s,{nodeOrigin:l,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:zl(R,l)}))}}if(g.length>0){const b=op(g,n,s,l);f.push(...b)}return{changes:f,updatedInternals:h}}async function zO({delta:e,panZoom:n,transform:s,translateExtent:i,width:l,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],[l,c]],i),u=!!d&&(d.x!==s[0]||d.y!==s[1]||d.k!==s[2]);return Promise.resolve(u)}function Xv(e,n,s,i,l,c){let d=l;const u=i.get(d)||new Map;i.set(d,u.set(s,n)),d=`${l}-${e}`;const h=i.get(d)||new Map;if(i.set(d,h.set(s,n)),c){d=`${l}-${e}-${c}`;const f=i.get(d)||new Map;i.set(d,f.set(s,n))}}function yN(e,n,s){e.clear(),n.clear();for(const i of s){const{source:l,target:c,sourceHandle:d=null,targetHandle:u=null}=i,h={edgeId:i.id,source:l,target:c,sourceHandle:d,targetHandle:u},f=`${l}-${d}--${c}-${u}`,x=`${c}-${u}--${l}-${d}`;Xv("source",h,x,e,l,d),Xv("target",h,f,e,c,u),n.set(i.id,i)}}function vN(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:vN(s,n):!1}function Kv(e,n,s){let i=e;do{if(i?.matches?.(n))return!0;if(i===s)return!1;i=i?.parentElement}while(i);return!1}function $O(e,n,s,i){const l=new Map;for(const[c,d]of e)if((d.selected||d.id===i)&&(!d.parentId||!vN(d,e))&&(d.draggable||n&&typeof d.draggable>"u")){const u=e.get(c);u&&l.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 l}function wh({nodeId:e,dragItems:n,nodeLookup:s,dragging:i=!0}){const l=[];for(const[d,u]of n){const h=s.get(d)?.internals.userNode;h&&l.push({...h,position:u.position,dragging:i})}if(!e)return[l[0],l];const c=s.get(e)?.internals.userNode;return[c?{...c,position:n.get(e)?.position||c.position,dragging:i}:l[0],l]}function BO({dragItems:e,snapGrid:n,x:s,y:i}){const l=e.values().next().value;if(!l)return null;const c={x:s-l.distance.x,y:i-l.distance.y},d=vc(c,n);return{x:d.x-c.x,y:d.y-c.y}}function HO({onNodeMouseDown:e,getStoreItems:n,onDragStart:s,onDrag:i,onDragStop:l}){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?mx(yc(u)):null,W=S&&V?BO({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)}:vc(re,O));let oe=null;if(S&&z&&!te.extent&&D){const{positionAbsolute:ve}=te.internals,ke=ve.x-D.x+z[0][0],Ce=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],[Ce,dt]]}const{position:me,positionAbsolute:Oe}=sN({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&&(i||Z||!_&&B))){const[J,te]=wh({nodeId:_,dragItems:u,nodeLookup:T});i?.(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=$O($,z,I,_),u.size>0&&(s||B||!_&&F)){const[S,D]=wh({nodeId:_,dragItems:u,nodeLookup:$});s?.(G.sourceEvent,u,S,D),B?.(G.sourceEvent,S,D),_||F?.(G.sourceEvent,D)}}const P=zw().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),l||z||!_&&O){const[V,H]=wh({nodeId:_,dragItems:u,nodeLookup:$,dragging:!1});l?.(G.sourceEvent,u,V,H),z?.(G.sourceEvent,V,H),_||O?.(G.sourceEvent,H)}}}).filter(G=>{const $=G.target;return!G.button&&(!M||!Kv($,`.${M}`,A))&&(!N||Kv($,N,A))});g.call(P)}function E(){g?.on(".drag",null)}return{update:C,destroy:E}}function PO(e,n,s){const i=[],l={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const c of n.values())oc(l,zl(c))>0&&i.push(c);return i}const UO=250;function qO(e,n,s,i){let l=[],c=1/0;const d=PO(e,s,n+UO);for(const u of d){const h=[...u.internals.handleBounds?.source??[],...u.internals.handleBounds?.target??[]];for(const f of h){if(i.nodeId===f.nodeId&&i.type===f.type&&i.id===f.id)continue;const{x,y:p}=$i(u,f,f.position,!0),g=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(p-e.y,2));g>n||(g<c?(l=[{...f,x,y:p}],c=g):g===c&&l.push({...f,x,y:p}))}}if(!l.length)return null;if(l.length>1){const u=i.type==="source"?"target":"source";return l.find(h=>h.type===u)??l[0]}return l[0]}function jN(e,n,s,i,l,c=!1){const d=i.get(e);if(!d)return null;const u=l==="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,...$i(d,h,h.position,!0)}:h}function wN(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function FO(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const NN=()=>!0;function VO(e,{connectionMode:n,connectionRadius:s,handleId:i,nodeId:l,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=NN,onReconnectEnd:M,updateConnection:N,getTransform:A,getFromHandle:R,autoPanSpeed:_,dragThreshold:Y=1,handleDomNode:q}){const X=dN(e.target);let L=0,P;const{x:G,y:$}=As(e),T=wN(c,q),z=u?.getBoundingClientRect();let O=!1;if(!z||!T)return;const V=jN(l,T,i,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:l,type:T,position:V.position},D=h.get(l);let J={inProgress:!0,isValid:null,from:$i(D,S,mt.Left,!0),fromHandle:S,fromPosition:S.position,fromNode:D,to:H,toHandle:null,toPosition:zv[S.position],toNode:null,pointer:H};function te(){O=!0,N(J),w?.(e,{nodeId:l,handleId:i,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=qO(jc(H,Oe,!1,[1,1]),s,h,S),Z||(I(),Z=!0);const ve=kN(me,{handle:P,connectionMode:n,fromNodeId:l,fromHandleId:i,fromType:d?"target":"source",isValidConnection:E,doc:X,lib:f,flowId:p,nodeLookup:h});K=ve.handleDomNode,B=ve.connection,F=FO(!!P,ve.isValid);const ke=h.get(l),Ce=ke?$i(ke,S,mt.Left,!0):J.from,Me={...J,from:Ce,isValid:F,to:ve.toHandle&&F?gu({x:ve.toHandle.x,y:ve.toHandle.y},Oe):H,toHandle:ve.toHandle,toPosition:F&&ve.toHandle?ve.toHandle.position:zv[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 kN(e,{handle:n,connectionMode:s,fromNodeId:i,fromHandleId:l,fromType:c,doc:d,lib:u,flowId:h,isValidConnection:f=NN,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=wN(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:i,sourceHandle:p?A:l,target:p?i:N,targetHandle:p?l:A};E.connection=Y;const X=R&&_&&(s===Dl.Strict?p&&M==="source"||!p&&M==="target":N!==i||A!==l);E.isValid=X&&f(Y),E.toHandle=jN(N,M,A,x,s,!0)}return E}const gx={onPointerDown:VO,isValid:kN};function YO({domNode:e,panZoom:n,getTransform:s,getViewScale:i}){const l=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&&cc()?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=i()*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=Qw().on("start",C).on("zoom",p?E:null).on("zoom.wheel",g?w:null);l.call(M,{})}function d(){l.on("zoom",null)}return{update:c,destroy:d,pointer:Cs}}const zu=e=>({x:e.x,y:e.y,zoom:e.k}),Nh=({x:e,y:n,zoom:s})=>Du.translate(e,n).scale(s),Cl=(e,n)=>e.target.closest(`.${n}`),SN=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),GO=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kh=(e,n=0,s=GO,i=()=>{})=>{const l=typeof n=="number"&&n>0;return l||i(),l?e.transition().duration(n).ease(s).on("end",i):e},CN=e=>{const n=e.ctrlKey&&cc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function XO({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:i,panOnScrollMode:l,panOnScrollSpeed:c,zoomOnPinch:d,onPanZoomStart:u,onPanZoom:h,onPanZoomEnd:f}){return x=>{if(Cl(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=CN(x),M=p*Math.pow(2,E);i.scaleTo(s,M,C,x);return}const g=x.deltaMode===1?20:1;let b=l===Ri.Vertical?0:x.deltaX*g,w=l===Ri.Horizontal?0:x.deltaY*g;!cc()&&x.shiftKey&&l!==Ri.Vertical&&(b=x.deltaY*g,w=0),i.translateBy(s,-(b/p)*c,-(w/p)*c,{internal:!0});const k=zu(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 KO({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:s}){return function(i,l){const c=i.type==="wheel",d=!n&&c&&!i.ctrlKey,u=Cl(i,e);if(i.ctrlKey&&c&&u&&i.preventDefault(),d||u)return null;i.preventDefault(),s.call(this,i,l)}}function WO({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return i=>{if(i.sourceEvent?.internal)return;const l=zu(i.transform);e.mouseButton=i.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=l,i.sourceEvent?.type==="mousedown"&&n(!0),s&&s?.(i.sourceEvent,l)}}function ZO({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:i,onPanZoom:l}){return c=>{e.usedRightMouseButton=!!(s&&SN(n,e.mouseButton??0)),c.sourceEvent?.sync||i([c.transform.x,c.transform.y,c.transform.k]),l&&!c.sourceEvent?.internal&&l?.(c.sourceEvent,zu(c.transform))}}function QO({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:i,onPanZoomEnd:l,onPaneContextMenu:c}){return d=>{if(!d.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,c&&SN(n,e.mouseButton??0)&&!e.usedRightMouseButton&&d.sourceEvent&&c(d.sourceEvent),e.usedRightMouseButton=!1,i(!1),l)){const u=zu(d.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{l?.(d.sourceEvent,u)},s?150:0)}}}function JO({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:i,panOnScroll:l,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"&&(Cl(p,`${f}-flow__node`)||Cl(p,`${f}-flow__edge`)))return!0;if(!i&&!g&&!l&&!c&&!s||d||x&&!w||Cl(p,u)&&w||Cl(p,h)&&(!w||l&&w&&!e)||!s&&p.ctrlKey&&w)return!1;if(!s&&p.type==="touchstart"&&p.touches?.length>1)return p.preventDefault(),!1;if(!g&&!l&&!b&&w||!i&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(i)&&!i.includes(p.button)&&p.type==="mousedown")return!1;const k=Array.isArray(i)&&i.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&k}}function eD({domNode:e,minZoom:n,maxZoom:s,translateExtent:i,viewport:l,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=Qw().scaleExtent([n,s]).translateExtent(i),g=ts(e).call(p);M({x:l.x,y:l.y,zoom:Il(l.zoom,n,s)},[[0,0],[x.width,x.height]],i);const b=g.on("wheel.zoom"),w=g.on("dblclick.zoom");p.wheelDelta(CN);function k(P,G){return g?new Promise($=>{p?.interpolate(G?.interpolate==="linear"?Xo:Kd).transform(kh(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?XO({zoomPanValues:f,noWheelClassName:P,d3Selection:g,d3Zoom:p,panOnScrollMode:V,panOnScrollSpeed:H,zoomOnPinch:B,onPanZoomStart:d,onPanZoom:c,onPanZoomEnd:u}):KO({noWheelClassName:P,preventScrolling:Z,d3ZoomHandler:b});if(g.on("wheel.zoom",oe,{passive:!1}),!T){const Oe=WO({zoomPanValues:f,onDraggingChange:h,onPanZoomStart:d});p.on("start",Oe);const ve=ZO({zoomPanValues:f,panOnDrag:O,onPaneContextMenu:!!$,onPanZoom:c,onTransformChange:D});p.on("zoom",ve);const ke=QO({zoomPanValues:f,panOnDrag:O,panOnScroll:z,onPaneContextMenu:$,onPanZoomEnd:u,onDraggingChange:h});p.on("end",ke)}const me=JO({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=Nh(P),z=p?.constrain()(T,G,$);return z&&await k(z),new Promise(O=>O(z))}async function N(P,G){const $=Nh(P);return await k($,G),new Promise(T=>T($))}function A(P){if(g){const G=Nh(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?Zw(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:Kd).scaleTo(kh(g,G?.duration,G?.ease,()=>$(!0)),P)}):Promise.resolve(!1)}function Y(P,G){return g?new Promise($=>{p?.interpolate(G?.interpolate==="linear"?Xo:Kd).scaleBy(kh(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 Bl;(function(e){e.Line="line",e.Handle="handle"})(Bl||(Bl={}));function tD({width:e,prevWidth:n,height:s,prevHeight:i,affectsX:l,affectsY:c}){const d=e-n,u=s-i,h=[d>0?1:d<0?-1:0,u>0?1:u<0?-1:0];return d&&l&&(h[0]=h[0]*-1),u&&c&&(h[1]=h[1]*-1),h}function Wv(e){const n=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),i=e.includes("left"),l=e.includes("top");return{isHorizontal:n,isVertical:s,affectsX:i,affectsY:l}}function Ja(e,n){return Math.max(0,n-e)}function ei(e,n){return Math.max(0,e-n)}function zd(e,n,s){return Math.max(0,n-e,e-s)}function Zv(e,n){return e?!n:n}function nD(e,n,s,i,l,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}=i,{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=zd(L,k,C),z=zd(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=ei(N+L+G,d[1][0])),f&&X<0?Z=Ja(A+X+$,d[0][1]):!f&&X>0&&(Z=ei(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=ei(N+q,u[0][0]):!h&&q<0&&(H=Ja(N+L,u[1][0])),f&&X>0?Z=ei(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(l){if(x){const H=zd(L/Y,E,M)*Y;if(T=Math.max(T,H),d){let Z=0;!h&&!f||h&&!f&&g?Z=ei(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=ei(A+(h?q:-q)/Y,u[0][1])*Y,T=Math.max(T,Z)}}if(p){const H=zd(P*Y,k,C)/Y;if(z=Math.max(z,H),d){let Z=0;!h&&!f||f&&!h&&g?Z=ei(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=ei(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),l&&(g?L>P*Y?X=(Zv(h,f)?-q:q)/Y:q=(Zv(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 EN={width:0,height:0,x:0,y:0},rD={...EN,pointerX:0,pointerY:0,aspectRatio:1};function sD(e){return[[0,0],[e.measured.width,e.measured.height]]}function aD(e,n,s){const i=n.position.x+e.position.x,l=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[[i-u,l-h],[i+c-u,l+d-h]]}function iD({domNode:e,nodeId:n,getStoreItems:s,onChange:i,onEnd:l}){const c=ts(e);let d={controlDirection:Wv("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={...EN},M={...rD};d={boundaries:x,resizeDirection:g,keepAspectRatio:p,controlDirection:Wv(f)};let N,A=null,R=[],_,Y,q,X=!1;const L=zw().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"?sD(_):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=aD(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}=nD(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 Ce=W-H,Me=J-Z;for(const dt of R)dt.position={x:dt.position.x-Ce+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 Ce=I[0]*(K.width??0);K.x&&K.x<Ce&&(E.x=Ce,M.x=M.x-(K.x-Ce));const Me=I[1]*(K.height??0);K.y&&K.y<Me&&(E.y=Me,M.y=M.y-(K.y-Me))}const Oe=tD({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),i(K,V))}).on("end",P=>{X&&(k?.(P,{...E}),l?.({...E}),X=!1)});c.call(L)}function h(){c.on(".drag",null)}return{update:u,destroy:h}}var Sh={exports:{}},Ch={},Eh={exports:{}},Th={};var Qv;function lD(){if(Qv)return Th;Qv=1;var e=fc();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,i=e.useState,l=e.useEffect,c=e.useLayoutEffect,d=e.useDebugValue;function u(p,g){var b=g(),w=i({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]),l(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 Th.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,Th}var Jv;function oD(){return Jv||(Jv=1,Eh.exports=lD()),Eh.exports}var e1;function cD(){if(e1)return Ch;e1=1;var e=fc(),n=oD();function s(f,x){return f===x&&(f!==0||1/f===1/x)||f!==f&&x!==x}var i=typeof Object.is=="function"?Object.is:s,l=n.useSyncExternalStore,c=e.useRef,d=e.useEffect,u=e.useMemo,h=e.useDebugValue;return Ch.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,i(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=l(f,w[0],w[1]);return d(function(){k.hasValue=!0,k.value=C},[C]),h(C),C},Ch}var t1;function dD(){return t1||(t1=1,Sh.exports=cD()),Sh.exports}var uD=dD();const fD=vu(uD),mD={},n1=e=>{let n;const s=new Set,i=(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))}},l=()=>n,h={setState:i,getState:l,getInitialState:()=>f,subscribe:x=>(s.add(x),()=>s.delete(x)),destroy:()=>{(mD?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),s.clear()}},f=n=e(i,l,h);return h},hD=e=>e?n1(e):n1,{useDebugValue:xD}=ck,{useSyncExternalStoreWithSelector:pD}=fD,gD=e=>e;function TN(e,n=gD,s){const i=pD(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return xD(i),i}const r1=(e,n)=>{const s=hD(e),i=(l,c=n)=>TN(s,l,c);return Object.assign(i,s),i},bD=(e,n)=>e?r1(e,n):r1;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[i,l]of e)if(!Object.is(l,n.get(i)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(n).length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(n,i)||!Object.is(e[i],n[i]))return!1;return!0}const $u=y.createContext(null),yD=$u.Provider,AN=Xs.error001();function rn(e,n){const s=y.useContext($u);if(s===null)throw new Error(AN);return TN(s,e,n)}function zn(){const e=y.useContext($u);if(e===null)throw new Error(AN);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const s1={display:"none"},vD={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},_N="react-flow__node-desc",MN="react-flow__edge-desc",jD="react-flow__aria-live",wD=e=>e.ariaLiveMessage,ND=e=>e.ariaLabelConfig;function kD({rfId:e}){const n=rn(wD);return t.jsx("div",{id:`${jD}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:vD,children:n})}function SD({rfId:e,disableKeyboardA11y:n}){const s=rn(ND);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${_N}-${e}`,style:s1,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${MN}-${e}`,style:s1,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(kD,{rfId:e})]})}const Bu=y.forwardRef(({position:e="top-left",children:n,className:s,style:i,...l},c)=>{const d=`${e}`.split("-");return t.jsx("div",{className:rr(["react-flow__panel",s,...d]),style:i,ref:c,...l,children:n})});Bu.displayName="Panel";function CD({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(Bu,{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 ED=e=>{const n=[],s=[];for(const[,i]of e.nodeLookup)i.selected&&n.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&s.push(i);return{selectedNodes:n,selectedEdges:s}},$d=e=>e.id;function TD(e,n){return In(e.selectedNodes.map($d),n.selectedNodes.map($d))&&In(e.selectedEdges.map($d),n.selectedEdges.map($d))}function AD({onSelectionChange:e}){const n=zn(),{selectedNodes:s,selectedEdges:i}=rn(ED,TD);return y.useEffect(()=>{const l={nodes:s,edges:i};e?.(l),n.getState().onSelectionChangeHandlers.forEach(c=>c(l))},[s,i,e]),null}const _D=e=>!!e.onSelectionChangeHandlers;function MD({onSelectionChange:e}){const n=rn(_D);return e||n?t.jsx(AD,{onSelectionChange:e}):null}const RN=[0,0],RD={x:0,y:0,zoom:1},OD=["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"],a1=[...OD,"rfId"],DD=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:ic,nodeOrigin:RN,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function LD(e){const{setNodes:n,setEdges:s,setMinZoom:i,setMaxZoom:l,setTranslateExtent:c,setNodeExtent:d,reset:u,setDefaultNodesAndEdges:h}=rn(DD,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 a1){const g=e[p],b=x.current[p];g!==b&&(typeof e[p]>"u"||(p==="nodes"?n(g):p==="edges"?s(g):p==="minZoom"?i(g):p==="maxZoom"?l(g):p==="translateExtent"?c(g):p==="nodeExtent"?d(g):p==="ariaLabelConfig"?f.setState({ariaLabelConfig:bO(g)}):p==="fitView"?f.setState({fitViewQueued:g}):p==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[p]:g})))}x.current=e},a1.map(p=>e[p])),null}function l1(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ID(e){const[n,s]=y.useState(e==="system"?null:e);return y.useEffect(()=>{if(e!=="system"){s(e);return}const i=l1(),l=()=>s(i?.matches?"dark":"light");return l(),i?.addEventListener("change",l),()=>{i?.removeEventListener("change",l)}},[e]),n!==null?n:l1()?.matches?"dark":"light"}const o1=typeof document<"u"?document:null;function dc(e=null,n={target:o1,actInsideInputWithModifier:!0}){const[s,i]=y.useState(!1),l=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??o1,f=n?.actInsideInputWithModifier??!0;if(e!==null){const x=b=>{if(l.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!l.current||l.current&&!f)&&uN(b))return!1;const k=d1(b.code,u);if(c.current.add(b[k]),c1(d,c.current,!1)){const C=b.composedPath?.()?.[0]||b.target,E=C?.nodeName==="BUTTON"||C?.nodeName==="A";n.preventDefault!==!1&&(l.current||!E)&&b.preventDefault(),i(!0)}},p=b=>{const w=d1(b.code,u);c1(d,c.current,!0)?(i(!1),c.current.clear()):c.current.delete(b[w]),b.key==="Meta"&&c.current.clear(),l.current=!1},g=()=>{c.current.clear(),i(!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,i]),s}function c1(e,n,s){return e.filter(i=>s||i.length===n.size).some(i=>i.every(l=>n.has(l)))}function d1(e,n){return n.includes(e)?"code":"key"}const zD=()=>{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:i}=e.getState();return i?i.scaleTo(n,{duration:s?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,s)=>{const{transform:[i,l,c],panZoom:d}=e.getState();return d?(await d.setViewport({x:n.x??i,y:n.y??l,zoom:n.zoom??c},s),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,s,i]=e.getState().transform;return{x:n,y:s,zoom:i}},setCenter:async(n,s,i)=>e.getState().setCenter(n,s,i),fitBounds:async(n,s)=>{const{width:i,height:l,minZoom:c,maxZoom:d,panZoom:u}=e.getState(),h=np(n,i,l,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:i,snapGrid:l,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??l,p=s.snapToGrid??c;return jc(f,i,p,x)},flowToScreenPosition:n=>{const{transform:s,domNode:i}=e.getState();if(!i)return n;const{x:l,y:c}=i.getBoundingClientRect(),d=gu(n,s);return{x:d.x+l,y:d.y+c}}}),[])};function ON(e,n){const s=[],i=new Map,l=[];for(const c of e)if(c.type==="add"){l.push(c);continue}else if(c.type==="remove"||c.type==="replace")i.set(c.id,[c]);else{const d=i.get(c.id);d?d.push(c):i.set(c.id,[c])}for(const c of n){const d=i.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)$D(h,u);s.push(u)}return l.length&&l.forEach(c=>{c.index!==void 0?s.splice(c.index,0,{...c.item}):s.push({...c.item})}),s}function $D(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 DN(e,n){return ON(e,n)}function LN(e,n){return ON(e,n)}function Ei(e,n){return{id:e,type:"select",selected:n}}function El(e,n=new Set,s=!1){const i=[];for(const[l,c]of e){const d=n.has(l);!(c.selected===void 0&&!d)&&c.selected!==d&&(s&&(c.selected=d),i.push(Ei(c.id,d)))}return i}function u1({items:e=[],lookup:n}){const s=[],i=new Map(e.map(l=>[l.id,l]));for(const[l,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:l})}for(const[l]of n)i.get(l)===void 0&&s.push({id:l,type:"remove"});return s}function f1(e){return{id:e.id,type:"remove"}}const m1=e=>oO(e),BD=e=>rN(e);function IN(e){return y.forwardRef(e)}const HD=typeof window<"u"?y.useLayoutEffect:y.useEffect;function h1(e){const[n,s]=y.useState(BigInt(0)),[i]=y.useState(()=>PD(()=>s(l=>l+BigInt(1))));return HD(()=>{const l=i.get();l.length&&(e(l),i.reset())},[n]),i}function PD(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:s=>{n.push(s),e()}}}const zN=y.createContext(null);function UD({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=u1({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)})},[]),i=h1(s),l=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(u1({items:b,lookup:g}))},[]),c=h1(l),d=y.useMemo(()=>({nodeQueue:i,edgeQueue:c}),[]);return t.jsx(zN.Provider,{value:d,children:e})}function qD(){const e=y.useContext(zN);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const FD=e=>!!e.panZoom;function cp(){const e=zD(),n=zn(),s=qD(),i=rn(FD),l=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=m1(p)?p:g.get(p.id),k=w.parentId?cN(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 zl(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&&m1(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&&BD(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 mO({nodesToRemove:p,edgesToRemove:g,nodes:b,edges:w,onBeforeDelete:A}),Y=_.length>0,q=R.length>0;if(Y){const X=_.map(f1);C?.(_),M(X)}if(q){const X=R.map(f1);k?.(R),E(X)}return(q||Y)&&N?.({nodes:R,edges:_}),{deletedNodes:R,deletedEdges:_}},getIntersectingNodes:(p,g=!0,b)=>{const w=Bv(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=zl(C?E:M),A=oc(N,k);return g&&A>0||A>=N.width*N.height||A>=k.width*k.height}):[]},isNodeIntersecting:(p,g,b=!0)=>{const k=Bv(p)?p:h(p);if(!k)return!1;const C=oc(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 cO(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??gO();return n.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:g}),s.nodeQueue.push(b=>[...b]),g.promise}}},[]);return y.useMemo(()=>({...l,...e,viewportInitialized:i}),[i])}const x1=e=>e.selected,VD=typeof window<"u"?window:void 0;function YD({deleteKeyCode:e,multiSelectionKeyCode:n}){const s=zn(),{deleteElements:i}=cp(),l=dc(e,{actInsideInputWithModifier:!1}),c=dc(n,{target:VD});y.useEffect(()=>{if(l){const{edges:d,nodes:u}=s.getState();i({nodes:u.filter(x1),edges:d.filter(x1)}),s.setState({nodesSelectionActive:!1})}},[l]),y.useEffect(()=>{s.setState({multiSelectionActive:c})},[c])}function GD(e){const n=zn();y.useEffect(()=>{const s=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const i=rp(e.current);(i.height===0||i.width===0)&&n.getState().onError?.("004",Xs.error004()),n.setState({width:i.width||500,height:i.height||500})};if(e.current){s(),window.addEventListener("resize",s);const i=new ResizeObserver(()=>s());return i.observe(e.current),()=>{window.removeEventListener("resize",s),i&&e.current&&i.unobserve(e.current)}}},[])}const Hu={position:"absolute",width:"100%",height:"100%",top:0,left:0},XD=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function KD({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=Ri.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(XD,In),L=dc(g),P=y.useRef();GD(_);const G=y.useCallback($=>{E?.({x:$[0],y:$[1],zoom:$[2]}),M||R.setState({transform:$})},[E,M]);return y.useEffect(()=>{if(_.current){P.current=eD({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:i,panOnScrollSpeed:l,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,i,l,c,d,u,L,b,C,Y,k,q,G,X,A,N]),t.jsx("div",{className:"react-flow__renderer",ref:_,style:Hu,children:w})}const WD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ZD(){const{userSelectionActive:e,userSelectionRect:n}=rn(WD,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 Ah=(e,n)=>s=>{s.target===n.current&&e?.(s)},QD=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function JD({isSelecting:e,selectionKeyPressed:n,selectionMode:s=lc.Full,panOnDrag:i,paneClickDistance:l,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(QD,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(i)&&i?.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:l;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(tp(F,Oe,B,s===lc.Partial,!0).map(Me=>Me.id)),q.current=new Set;const Ce=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??Ce)&&q.current.add(pt)}}if(!Hv(ve,Y.current)){const Me=El(F,Y.current,!0);S(Me)}if(!Hv(ke,q.current)){const Me=El(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=i===!0||Array.isArray(i)&&i.includes(0);return t.jsxs("div",{className:rr(["react-flow__pane",{draggable:V,dragging:M,selection:e}]),onClick:A?void 0:Ah(L,R),onContextMenu:Ah(P,R),onWheel:Ah(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:Hu,children:[w,t.jsx(ZD,{})]})}function bx({id:e,store:n,unselect:s=!1,nodeRef:i}){const{addSelectedNodes:l,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(()=>i?.current?.blur())):l([e])}function $N({nodeRef:e,disabled:n=!1,noDragClassName:s,handleSelector:i,nodeId:l,isSelectable:c,nodeClickDistance:d}){const u=zn(),[h,f]=y.useState(!1),x=y.useRef();return y.useEffect(()=>{x.current=HO({getStoreItems:()=>u.getState(),onNodeMouseDown:p=>{bx({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:i,domNode:e.current,isSelectable:c,nodeId:l,nodeClickDistance:d}),()=>{x.current?.destroy()}},[s,i,n,c,e,l,d]),h}const eL=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function BN(){const e=zn();return y.useCallback(s=>{const{nodeExtent:i,snapToGrid:l,snapGrid:c,nodesDraggable:d,onError:u,updateNodePositions:h,nodeLookup:f,nodeOrigin:x}=e.getState(),p=new Map,g=eL(d),b=l?c[0]:5,w=l?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};l&&(M=vc(M,c));const{position:N,positionAbsolute:A}=sN({nodeId:E.id,nextPosition:M,nodeLookup:f,nodeExtent:i,nodeOrigin:x,onError:u});E.position=N,E.internals.positionAbsolute=A,p.set(E.id,E)}h(p)},[])}const dp=y.createContext(null),tL=dp.Provider;dp.Consumer;const HN=()=>y.useContext(dp),nL=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),rL=(e,n,s)=>i=>{const{connectionClickStartHandle:l,connectionMode:c,connection:d}=i,{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:l?.nodeId===e&&l?.id===n&&l?.type===s,isPossibleEndHandle:c===Dl.Strict?u?.type!==s:e!==u?.nodeId||n!==u?.id,connectionInProcess:!!u,clickConnectionInProcess:!!l,valid:x&&f}};function sL({type:e="source",position:n=mt.Top,isValidConnection:s,isConnectable:i=!0,isConnectableStart:l=!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=HN(),{connectOnClick:M,noPanClassName:N,rfId:A}=rn(nL,In),{connectingFrom:R,connectingTo:_,clickConnecting:Y,isPossibleEndHandle:q,connectionInProcess:X,clickConnectionInProcess:L,valid:P}=rn(rL(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(kO(Z,B))}V?.(Z),u?.(Z)},$=z=>{if(!E)return;const O=fN(z.nativeEvent);if(l&&(O&&z.button===0||!O)){const V=C.getState();gx.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&&!l)return;if(!H){O?.(z.nativeEvent,{nodeId:E,handleId:w,handleType:e}),C.setState({connectionClickStartHandle:{nodeId:E,type:e,id:w}});return}const D=dN(z.target),W=s||B,{connection:J,isValid:te}=gx.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:i,connectablestart:l,connectableend:c,clickconnecting:Y,connectingfrom:R,connectingto:_,valid:P,connectionindicator:i&&(!X||q)&&(X||L?c:l)}]),onMouseDown:$,onTouchStart:$,onClick:M?T:void 0,ref:b,...g,children:h})}const ai=y.memo(IN(sL));function aL({data:e,isConnectable:n,sourcePosition:s=mt.Bottom}){return t.jsxs(t.Fragment,{children:[e?.label,t.jsx(ai,{type:"source",position:s,isConnectable:n})]})}function iL({data:e,isConnectable:n,targetPosition:s=mt.Top,sourcePosition:i=mt.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(ai,{type:"target",position:s,isConnectable:n}),e?.label,t.jsx(ai,{type:"source",position:i,isConnectable:n})]})}function lL(){return null}function oL({data:e,isConnectable:n,targetPosition:s=mt.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(ai,{type:"target",position:s,isConnectable:n}),e?.label]})}const bu={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},p1={input:aL,default:iL,output:oL,group:lL};function cL(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 dL=e=>{const{width:n,height:s,x:i,y:l}=yc(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(${i}px,${l}px)`}};function uL({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:s}){const i=zn(),{width:l,height:c,transformString:d,userSelectionActive:u}=rn(dL,In),h=BN(),f=y.useRef(null);y.useEffect(()=>{s||f.current?.focus({preventScroll:!0})},[s]);const x=!u&&l!==null&&c!==null;if($N({nodeRef:f,disabled:!x}),!x)return null;const p=e?b=>{const w=i.getState().nodes.filter(k=>k.selected);e(b,w)}:void 0,g=b=>{Object.prototype.hasOwnProperty.call(bu,b.key)&&(b.preventDefault(),h({direction:bu[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:l,height:c}})})}const g1=typeof window<"u"?window:void 0,fL=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function PN({children:e,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:l,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(fL,In),K=dc(f,{target:g1}),I=dc(k,{target:g1}),S=I||q,D=I||A,W=x&&S!==!0,J=K||F||W;return YD({deleteKeyCode:h,multiSelectionKeyCode:w}),t.jsx(KD,{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(JD,{onSelectionStart:g,onSelectionEnd:b,onPaneClick:n,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:l,onPaneContextMenu:c,onPaneScroll:d,panOnDrag:S,isSelecting:!!J,selectionMode:p,selectionKeyPressed:K,paneClickDistance:u,selectionOnDrag:W,children:[e,B&&t.jsx(uL,{onSelectionContextMenu:T,noPanClassName:O,disableKeyboardA11y:V})]})})}PN.displayName="FlowRenderer";const mL=y.memo(PN),hL=e=>n=>e?tp(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 xL(e){return rn(y.useCallback(hL(e),[e]),In)}const pL=e=>e.updateNodeInternals;function gL(){const e=rn(pL),[n]=y.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const i=new Map;s.forEach(l=>{const c=l.target.getAttribute("data-id");i.set(c,{id:c,nodeElement:l.target,force:!0})}),e(i)}));return y.useEffect(()=>()=>{n?.disconnect()},[n]),n}function bL({node:e,nodeType:n,hasDimensions:s,resizeObserver:i}){const l=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&&i?.unobserve(d.current),i?.observe(c.current),d.current=c.current)},[x,e.hidden]),y.useEffect(()=>()=>{d.current&&(i?.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,l.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:c.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),c}function yL({id:e,onClick:n,onMouseEnter:s,onMouseMove:i,onMouseLeave:l,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?.[_]||p1[_];Y===void 0&&(M?.("003",Xs.error003(_)),_="default",Y=C?.default||p1.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(),$=oN(N),T=bL({node:N,nodeType:_,hasDimensions:$,resizeObserver:p}),z=$N({nodeRef:T,disabled:N.hidden||!q,noDragClassName:g,handleSelector:N.dragHandle,nodeId:e,isSelectable:X,nodeClickDistance:E}),O=BN();if(N.hidden)return null;const V=Na(N),H=cL(N),Z=X||q||n||s||i||l,B=s?te=>s(te,{...A.userNode}):void 0,F=i?te=>i(te,{...A.userNode}):void 0,K=l?te=>l(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)&&bx({id:e,store:G,nodeRef:T}),n&&n(te,{...A.userNode})},W=te=>{if(!(uN(te.nativeEvent)||w)){if(Jw.includes(te.key)&&X){const re=te.key==="Escape";bx({id:e,store:G,unselect:re,nodeRef:T})}else if(q&&N.selected&&Object.prototype.hasOwnProperty.call(bu,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:bu[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;tp(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:`${_N}-${k}`,"aria-label":N.ariaLabel,...N.domAttributes,children:t.jsx(tL,{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 vL=y.memo(yL);const jL=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function UN(e){const{nodesDraggable:n,nodesConnectable:s,nodesFocusable:i,elementsSelectable:l,onError:c}=rn(jL,In),d=xL(e.onlyRenderVisibleElements),u=gL();return t.jsx("div",{className:"react-flow__nodes",style:Hu,children:d.map(h=>t.jsx(vL,{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:i,elementsSelectable:l,nodeClickDistance:e.nodeClickDistance,onError:c},h))})}UN.displayName="NodeRenderer";const wL=y.memo(UN);function NL(e){return rn(y.useCallback(s=>{if(!e)return s.edges.map(l=>l.id);const i=[];if(s.width&&s.height)for(const l of s.edges){const c=s.nodeLookup.get(l.source),d=s.nodeLookup.get(l.target);c&&d&&jO({sourceNode:c,targetNode:d,width:s.width,height:s.height,transform:s.transform})&&i.push(l.id)}return i},[e]),In)}const kL=({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"})},SL=({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"})},b1={[Ll.Arrow]:kL,[Ll.ArrowClosed]:SL};function CL(e){const n=zn();return y.useMemo(()=>Object.prototype.hasOwnProperty.call(b1,e)?b1[e]:(n.getState().onError?.("009",Xs.error009(e)),null),[e])}const EL=({id:e,type:n,color:s,width:i=12.5,height:l=12.5,markerUnits:c="strokeWidth",strokeWidth:d,orient:u="auto-start-reverse"})=>{const h=CL(n);return h?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${l}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:u,refX:"0",refY:"0",children:t.jsx(h,{color:s,strokeWidth:d})}):null},qN=({defaultColor:e,rfId:n})=>{const s=rn(c=>c.edges),i=rn(c=>c.defaultEdgeOptions),l=y.useMemo(()=>AO(s,{id:n,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd}),[s,i,n,e]);return l.length?t.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:t.jsx("defs",{children:l.map(c=>t.jsx(EL,{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};qN.displayName="MarkerDefinitions";var TL=y.memo(qN);function FN({x:e,y:n,label:s,labelStyle:i,labelShowBg:l=!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:[l&&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:i,children:s}),h]}):null}FN.displayName="EdgeText";const AL=y.memo(FN);function Pu({path:e,labelX:n,labelY:s,label:i,labelStyle:l,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,i&&Ts(n)&&Ts(s)?t.jsx(AL,{x:n,y:s,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h}):null]})}function y1({pos:e,x1:n,y1:s,x2:i,y2:l}){return e===mt.Left||e===mt.Right?[.5*(n+i),s]:[n,.5*(s+l)]}function VN({sourceX:e,sourceY:n,sourcePosition:s=mt.Bottom,targetX:i,targetY:l,targetPosition:c=mt.Top}){const[d,u]=y1({pos:s,x1:e,y1:n,x2:i,y2:l}),[h,f]=y1({pos:c,x1:i,y1:l,x2:e,y2:n}),[x,p,g,b]=mN({sourceX:e,sourceY:n,targetX:i,targetY:l,sourceControlX:d,sourceControlY:u,targetControlX:h,targetControlY:f});return[`M${e},${n} C${d},${u} ${h},${f} ${i},${l}`,x,p,g,b]}function YN(e){return y.memo(({id:n,sourceX:s,sourceY:i,targetX:l,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]=VN({sourceX:s,sourceY:i,sourcePosition:d,targetX:l,targetY:c,targetPosition:u}),R=e.isInternal?void 0:n;return t.jsx(Pu,{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 _L=YN({isInternal:!1}),GN=YN({isInternal:!0});_L.displayName="SimpleBezierEdge";GN.displayName="SimpleBezierEdgeInternal";function XN(e){return y.memo(({id:n,sourceX:s,sourceY:i,targetX:l,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]=hx({sourceX:s,sourceY:i,sourcePosition:b,targetX:l,targetY:c,targetPosition:w,borderRadius:E?.borderRadius,offset:E?.offset,stepPosition:E?.stepPosition}),_=e.isInternal?void 0:n;return t.jsx(Pu,{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 KN=XN({isInternal:!1}),WN=XN({isInternal:!0});KN.displayName="SmoothStepEdge";WN.displayName="SmoothStepEdgeInternal";function ZN(e){return y.memo(({id:n,...s})=>{const i=e.isInternal?void 0:n;return t.jsx(KN,{...s,id:i,pathOptions:y.useMemo(()=>({borderRadius:0,offset:s.pathOptions?.offset}),[s.pathOptions?.offset])})})}const ML=ZN({isInternal:!1}),QN=ZN({isInternal:!0});ML.displayName="StepEdge";QN.displayName="StepEdgeInternal";function JN(e){return y.memo(({id:n,sourceX:s,sourceY:i,targetX:l,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]=pN({sourceX:s,sourceY:i,targetX:l,targetY:c}),N=e.isInternal?void 0:n;return t.jsx(Pu,{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 RL=JN({isInternal:!1}),e5=JN({isInternal:!0});RL.displayName="StraightEdge";e5.displayName="StraightEdgeInternal";function t5(e){return y.memo(({id:n,sourceX:s,sourceY:i,targetX:l,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]=hN({sourceX:s,sourceY:i,sourcePosition:d,targetX:l,targetY:c,targetPosition:u,curvature:E?.curvature}),_=e.isInternal?void 0:n;return t.jsx(Pu,{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 OL=t5({isInternal:!1}),n5=t5({isInternal:!0});OL.displayName="BezierEdge";n5.displayName="BezierEdgeInternal";const v1={default:n5,straight:e5,step:QN,smoothstep:WN,simplebezier:GN},j1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},DL=(e,n,s)=>s===mt.Left?e-n:s===mt.Right?e+n:e,LL=(e,n,s)=>s===mt.Top?e-n:s===mt.Bottom?e+n:e,w1="react-flow__edgeupdater";function N1({position:e,centerX:n,centerY:s,radius:i=10,onMouseDown:l,onMouseEnter:c,onMouseOut:d,type:u}){return t.jsx("circle",{onMouseDown:l,onMouseEnter:c,onMouseOut:d,className:rr([w1,`${w1}-${u}`]),cx:DL(n,i,e),cy:LL(s,i,e),r:i,stroke:"transparent",fill:"transparent"})}function IL({isReconnectable:e,reconnectRadius:n,edge:s,sourceX:i,sourceY:l,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)};gx.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(N1,{position:u,centerX:i,centerY:l,radius:n,onMouseDown:C,onMouseEnter:M,onMouseOut:N,type:"source"}),(e===!0||e==="target")&&t.jsx(N1,{position:h,centerX:c,centerY:d,radius:n,onMouseDown:E,onMouseEnter:M,onMouseOut:N,type:"target"})]})}function zL({id:e,edgesFocusable:n,edgesReconnectable:s,elementsSelectable:i,onClick:l,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]||v1[R];_===void 0&&(E?.("011",Xs.error011(R)),R="default",_=k?.default||v1.default);const Y=!!(N.focusable||n&&typeof N.focusable>"u"),q=typeof p<"u"&&(N.reconnectable||s&&typeof N.reconnectable>"u"),X=!!(N.selectable||i&&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,...j1};const Ce=TO({id:e,sourceNode:ve,targetNode:ke,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:Oe.connectionMode,onError:E});return{zIndex:vO({selected:N.selected,zIndex:N.zIndex,sourceNode:ve,targetNode:ke,elevateOnSelect:Oe.elevateEdgesOnSelect,zIndexMode:Oe.zIndexMode}),...Ce||j1}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex]),In),I=y.useMemo(()=>N.markerStart?`url('#${xx(N.markerStart,w)}')`:void 0,[N.markerStart,w]),S=y.useMemo(()=>N.markerEnd?`url('#${xx(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:Ce}=z.getState();X&&(z.setState({nodesSelectionActive:!1}),N.selected&&Ce?(ke({nodes:[],edges:[N]}),L.current?.blur()):ve([e])),l&&l(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&&Jw.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&&!l,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?`${MN}-${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(IL,{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 $L=y.memo(zL);const BL=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function r5({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:s,edgeTypes:i,noPanClassName:l,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(BL,In),A=NL(n);return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(TL,{defaultColor:e,rfId:s}),A.map(R=>t.jsx($L,{id:R,edgesFocusable:C,edgesReconnectable:E,elementsSelectable:M,noPanClassName:l,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:i,disableKeyboardA11y:k},R))]})}r5.displayName="EdgeRenderer";const HL=y.memo(r5),PL=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function UL({children:e}){const n=rn(PL);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function qL(e){const n=cp(),s=y.useRef(!1);y.useEffect(()=>{!s.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),s.current=!0)},[e,n.viewportInitialized])}const FL=e=>e.panZoom?.syncViewport;function VL(e){const n=rn(FL),s=zn();return y.useEffect(()=>{e&&(n?.(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function YL(e){return e.connection.inProgress?{...e.connection,to:jc(e.connection.to,e.transform)}:{...e.connection}}function GL(e){return YL}function XL(e){const n=GL();return rn(n,In)}const KL=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function WL({containerStyle:e,style:n,type:s,component:i}){const{nodesConnectable:l,width:c,height:d,isValid:u,inProgress:h}=rn(KL,In);return!(c&&l&&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",nN(u)]),children:t.jsx(s5,{style:n,type:s,CustomComponent:i,isValid:u})})})}const s5=({style:e,type:n=ri.Bezier,CustomComponent:s,isValid:i})=>{const{inProgress:l,from:c,fromNode:d,fromHandle:u,fromPosition:h,to:f,toNode:x,toHandle:p,toPosition:g,pointer:b}=XL();if(!l)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:nN(i),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 ri.Bezier:[w]=hN(k);break;case ri.SimpleBezier:[w]=VN(k);break;case ri.Step:[w]=hx({...k,borderRadius:0});break;case ri.SmoothStep:[w]=hx(k);break;default:[w]=pN(k)}return t.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};s5.displayName="ConnectionLine";const ZL={};function k1(e=ZL){y.useRef(e),zn(),y.useEffect(()=>{},[e])}function QL(){zn(),y.useRef(!1),y.useEffect(()=>{},[])}function a5({nodeTypes:e,edgeTypes:n,onInit:s,onNodeClick:i,onEdgeClick:l,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:Ce,reconnectRadius:Me,onReconnect:dt,onReconnectStart:pt,onReconnectEnd:et,noDragClassName:Pt,noWheelClassName:ie,noPanClassName:Ee,disableKeyboardA11y:We,nodeExtent:kt,rfId:Ft,viewport:xe,onViewportChange:Se}){return k1(e),k1(n),QL(),qL(s),VL(xe),t.jsx(mL,{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:ie,noPanClassName:Ee,disableKeyboardA11y:We,onViewportChange:Se,isControlledViewport:!!xe,children:t.jsxs(UL,{children:[t.jsx(HL,{edgeTypes:n,onEdgeClick:l,onEdgeDoubleClick:d,onReconnect:dt,onReconnectStart:pt,onReconnectEnd:et,onlyRenderVisibleElements:X,onEdgeContextMenu:Oe,onEdgeMouseEnter:ve,onEdgeMouseMove:ke,onEdgeMouseLeave:Ce,reconnectRadius:Me,defaultMarkerColor:O,noPanClassName:Ee,disableKeyboardA11y:We,rfId:Ft}),t.jsx(WL,{style:k,type:w,component:C,containerStyle:E}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(wL,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:x,nodeClickDistance:me,onlyRenderVisibleElements:X,noPanClassName:Ee,noDragClassName:Pt,disableKeyboardA11y:We,nodeExtent:kt,rfId:Ft}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}a5.displayName="GraphView";const JL=y.memo(a5),S1=({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:l,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=i??n??[],M=s??e??[],N=x??[0,0],A=p??ic;yN(k,C,E);const R=px(M,b,w,{nodeOrigin:N,nodeExtent:A,zIndexMode:g});let _=[0,0,1];if(d&&l&&c){const Y=yc(b,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:q,y:X,zoom:L}=np(Y,l,c,h,f,u?.padding??.1);_=[q,X,L]}return{rfId:"1",width:l??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:i!==void 0,panZoom:null,minZoom:h,maxZoom:f,translateExtent:ic,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Dl.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:{...tN},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:hO,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:eN,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},eI=({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:l,height:c,fitView:d,fitViewOptions:u,minZoom:h,maxZoom:f,nodeOrigin:x,nodeExtent:p,zIndexMode:g})=>bD((b,w)=>{async function k(){const{nodeLookup:C,panZoom:E,fitViewOptions:M,fitViewResolver:N,width:A,height:R,minZoom:_,maxZoom:Y}=w();E&&(await fO({nodes:C,width:A,height:R,panZoom:E,minZoom:_,maxZoom:Y},M),N?.resolve(!0),b({fitViewResolver:null}))}return{...S1({nodes:e,edges:n,width:l,height:c,fitView:d,fitViewOptions:u,minZoom:h,maxZoom:f,nodeOrigin:x,nodeExtent:p,defaultNodes:s,defaultEdges:i,zIndexMode:g}),setNodes:C=>{const{nodeLookup:E,parentLookup:M,nodeOrigin:N,elevateNodesOnSelect:A,fitViewQueued:R,zIndexMode:_}=w(),Y=px(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();yN(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}=IO(C,M,N,A,R,_,X);P&&(RO(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=$i(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=op(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 _=DN(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 _=LN(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=>Ei(Y,!0));A(_);return}A(El(N,new Set([...C]),!0)),R(El(M))},addSelectedEdges:C=>{const{multiSelectionActive:E,edgeLookup:M,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:R}=w();if(E){const _=C.map(Y=>Ei(Y,!0));R(_);return}R(El(M,new Set([...C]))),A(El(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(Ei(P.id,!1))}const L=[];for(const P of q)P.selected&&L.push(Ei(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,Ei(q.id,!1)]:Y,[]),_=C.reduce((Y,q)=>q.selected?[...Y,Ei(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]||(px(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 zO({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:{...tN}})},updateConnection:C=>{b({connection:C})},reset:()=>b({...S1()})}},Object.is);function tI({initialNodes:e,initialEdges:n,defaultNodes:s,defaultEdges:i,initialWidth:l,initialHeight:c,initialMinZoom:d,initialMaxZoom:u,initialFitViewOptions:h,fitView:f,nodeOrigin:x,nodeExtent:p,zIndexMode:g,children:b}){const[w]=y.useState(()=>eI({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,width:l,height:c,fitView:f,minZoom:d,maxZoom:u,fitViewOptions:h,nodeOrigin:x,nodeExtent:p,zIndexMode:g}));return t.jsx(yD,{value:w,children:t.jsx(UD,{children:b})})}function nI({children:e,nodes:n,edges:s,defaultNodes:i,defaultEdges:l,width:c,height:d,fitView:u,fitViewOptions:h,minZoom:f,maxZoom:x,nodeOrigin:p,nodeExtent:g,zIndexMode:b}){return y.useContext($u)?t.jsx(t.Fragment,{children:e}):t.jsx(tI,{initialNodes:n,initialEdges:s,defaultNodes:i,defaultEdges:l,initialWidth:c,initialHeight:d,fitView:u,initialFitViewOptions:h,initialMinZoom:f,initialMaxZoom:x,nodeOrigin:p,nodeExtent:g,zIndexMode:b,children:e})}const rI={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function sI({nodes:e,edges:n,defaultNodes:s,defaultEdges:i,className:l,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=ri.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=cc()?"Meta":"Control",zoomActivationKeyCode:Oe=cc()?"Meta":"Control",snapToGrid:ve,snapGrid:ke,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:Me,nodesDraggable:dt,autoPanOnNodeFocus:pt,nodesConnectable:et,nodesFocusable:Pt,nodeOrigin:ie=RN,edgesFocusable:Ee,edgesReconnectable:We,elementsSelectable:kt=!0,defaultViewport:Ft=RD,minZoom:xe=.5,maxZoom:Se=2,translateExtent:Fe=ic,preventScrolling:it=!0,nodeExtent:ut,defaultMarkerColor:Lt="#b1b1b7",zoomOnScroll:bn=!0,zoomOnPinch:Ut=!0,panOnScroll:St=!1,panOnScrollSpeed:Jt=.5,panOnScrollMode:yt=Ri.Free,zoomOnDoubleClick:Xt=!0,panOnDrag:_t=!0,onPaneClick:$t,onPaneMouseEnter:Bn,onPaneMouseMove:dn,onPaneMouseLeave:ye,onPaneScroll:Ge,onPaneContextMenu:lt,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:Kn,elevateNodesOnSelect:Ot=!0,elevateEdgesOnSelect:pr=!1,disableKeyboardA11y:Tt=!1,autoPanOnConnect:hn,autoPanOnNodeDrag:ln,autoPanSpeed:ss,connectionRadius:Rr,isValidConnection:ir,onError:Or,style:gs,id:as,nodeDragThreshold:Os,connectionDragThreshold:Ds,viewport:gr,onViewportChange:Dr,width:fr,height:Fn,colorMode:bs="light",debug:de,onScroll:Te,ariaLabelConfig:Ue,zIndexMode:qt="basic",...Ar},Hn){const mr=as||"1",Ls=ID(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,...rI},ref:Hn,className:rr(["react-flow",l,Ls]),id:as,role:"application",children:t.jsxs(nI,{nodes:e,edges:n,width:fr,height:Fn,fitView:ot,fitViewOptions:At,minZoom:xe,maxZoom:Se,nodeOrigin:ie,nodeExtent:ut,zIndexMode:qt,children:[t.jsx(JL,{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:Ce,defaultViewport:Ft,translateExtent:Fe,minZoom:xe,maxZoom:Se,preventScrolling:it,zoomOnScroll:bn,zoomOnPinch:Ut,zoomOnDoubleClick:Xt,panOnScroll:St,panOnScrollSpeed:Jt,panOnScrollMode:yt,panOnDrag:_t,onPaneClick:$t,onPaneMouseEnter:Bn,onPaneMouseMove:dn,onPaneMouseLeave:ye,onPaneScroll:Ge,onPaneContextMenu:lt,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(LD,{nodes:e,edges:n,defaultNodes:s,defaultEdges:i,onConnect:b,onConnectStart:w,onConnectEnd:k,onClickConnectStart:C,onClickConnectEnd:E,nodesDraggable:dt,autoPanOnNodeFocus:pt,nodesConnectable:et,nodesFocusable:Pt,edgesFocusable:Ee,edgesReconnectable:We,elementsSelectable:kt,elevateNodesOnSelect:Ot,elevateEdgesOnSelect:pr,minZoom:xe,maxZoom:Se,nodeExtent:ut,onNodesChange:Qe,onEdgesChange:ue,snapToGrid:ve,snapGrid:ke,connectionMode:F,translateExtent:Fe,connectOnClick:Sn,defaultEdgeOptions:Kn,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:ie,rfId:mr,autoPanOnConnect:hn,autoPanOnNodeDrag:ln,autoPanSpeed:ss,onError:Or,connectionRadius:Rr,isValidConnection:ir,selectNodesOnDrag:Me,nodeDragThreshold:Os,connectionDragThreshold:Ds,onBeforeDelete:B,debug:de,ariaLabelConfig:Ue,zIndexMode:qt}),t.jsx(MD,{onSelectionChange:$}),kn,t.jsx(CD,{proOptions:mn,position:ar}),t.jsx(SD,{rfId:mr,disableKeyboardA11y:Tt})]})})}var aI=IN(sI);function iI(e){const[n,s]=y.useState(e),i=y.useCallback(l=>s(c=>DN(l,c)),[]);return[n,s,i]}function lI(e){const[n,s]=y.useState(e),i=y.useCallback(l=>s(c=>LN(l,c)),[]);return[n,s,i]}function oI({dimensions:e,lineWidth:n,variant:s,className:i}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:rr(["react-flow__background-pattern",s,i])})}function cI({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:rr(["react-flow__background-pattern","dots",n])})}var si;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(si||(si={}));const dI={[si.Dots]:1,[si.Lines]:1,[si.Cross]:6},uI=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function i5({id:e,variant:n=si.Dots,gap:s=20,size:i,lineWidth:l=1,offset:c=0,color:d,bgColor:u,style:h,className:f,patternClassName:x}){const p=y.useRef(null),{transform:g,patternId:b}=rn(uI,In),w=i||dI[n],k=n===si.Dots,C=n===si.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,...Hu,"--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(cI,{radius:N/2,className:x}):t.jsx(oI,{dimensions:R,lineWidth:l,variant:n,className:x})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${Y})`})]})}i5.displayName="Background";const fI=y.memo(i5);function mI(){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 hI(){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 xI(){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 pI(){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 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 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 Bd({children:e,className:n,...s}){return t.jsx("button",{type:"button",className:rr(["react-flow__controls-button",n]),...s,children:e})}const bI=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function l5({style:e,showZoom:n=!0,showFitView:s=!0,showInteractive:i=!0,fitViewOptions:l,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(bI,In),{zoomIn:N,zoomOut:A,fitView:R}=cp(),_=()=>{N(),c?.()},Y=()=>{A(),d?.()},q=()=>{R(l),u?.()},X=()=>{w.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),h?.(!k)},L=g==="horizontal"?"horizontal":"vertical";return t.jsxs(Bu,{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(Bd,{onClick:_,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:E,children:t.jsx(mI,{})}),t.jsx(Bd,{onClick:Y,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:C,children:t.jsx(hI,{})})]}),s&&t.jsx(Bd,{className:"react-flow__controls-fitview",onClick:q,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:t.jsx(xI,{})}),i&&t.jsx(Bd,{className:"react-flow__controls-interactive",onClick:X,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:k?t.jsx(gI,{}):t.jsx(pI,{})}),x]})}l5.displayName="Controls";const yI=y.memo(l5);function vI({id:e,x:n,y:s,width:i,height:l,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:i,height:l,style:{fill:C,stroke:u,strokeWidth:h},shapeRendering:p,onClick:b?E=>b(E,e):void 0})}const jI=y.memo(vI),wI=e=>e.nodes.map(n=>n.id),_h=e=>e instanceof Function?e:()=>e;function NI({nodeStrokeColor:e,nodeColor:n,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:l,nodeComponent:c=jI,onClick:d}){const u=rn(wI,In),h=_h(n),f=_h(e),x=_h(s),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:u.map(g=>t.jsx(SI,{id:g,nodeColorFunc:h,nodeStrokeColorFunc:f,nodeClassNameFunc:x,nodeBorderRadius:i,nodeStrokeWidth:l,NodeComponent:c,onClick:d,shapeRendering:p},g))})}function kI({id:e,nodeColorFunc:n,nodeStrokeColorFunc:s,nodeClassNameFunc:i,nodeBorderRadius:l,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||!oN(f)?null:t.jsx(u,{x,y:p,width:g,height:b,style:f.style,selected:!!f.selected,className:i(f),color:n(f),borderRadius:l,strokeColor:s(f),strokeWidth:c,shapeRendering:d,onClick:h,id:f.id})}const SI=y.memo(kI);var CI=y.memo(NI);const EI=200,TI=150,AI=e=>!e.hidden,_I=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?lN(yc(e.nodeLookup,{filter:AI}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},MI="react-flow__minimap-desc";function o5({style:e,className:n,nodeStrokeColor:s,nodeColor:i,nodeClassName:l="",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(_I,In),z=e?.width??EI,O=e?.height??TI,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=`${MI}-${X}`,te=y.useRef(0),re=y.useRef();te.current=Z,y.useEffect(()=>{if(_.current&&L)return re.current=YO({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,Ce]=re.current?.pointer(ve)||[0,0];b(ve,{x:ke,y:Ce})}:void 0,me=w?y.useCallback((ve,ke)=>{const Ce=R.getState().nodeLookup.get(ke).internals.userNode;w(ve,Ce)},[]):void 0,Oe=E??T["minimap.ariaLabel"];return t.jsx(Bu,{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 i=="string"?i: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(CI,{onClick:me,nodeColor:i,nodeStrokeColor:s,nodeBorderRadius:c,nodeClassName:l,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"})]})})}o5.displayName="MiniMap";const RI=y.memo(o5),OI=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,DI={[Bl.Line]:"right",[Bl.Handle]:"bottom-right"};function LI({nodeId:e,position:n,variant:s=Bl.Handle,className:i,style:l=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=HN(),N=typeof e=="string"?e:M,A=zn(),R=y.useRef(null),_=s===Bl.Handle,Y=rn(y.useCallback(OI(_&&b),[_,b]),In),q=y.useRef(null),X=n??DI[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,...cN({x:P.x??Z.position.x,y:P.y??Z.position.y},{width:F,height:K},Z.parentId,T,B)}},S=op([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,i]),ref:R,style:{...l,scale:Y,...d&&{[_?"backgroundColor":"borderColor"]:d}},children:c})}y.memo(LI);var gn=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Ms=gn((e,n)=>{var s=Object.defineProperty,i=($,T,z)=>T in $?s($,T,{enumerable:!0,configurable:!0,writable:!0,value:z}):$[T]=z,l=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports),c=($,T,z)=>i($,typeof T!="symbol"?T+"":T,z),d=l(($,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=l(($,T)=>{T.exports="3.0.2"}),h=l(($,T)=>{T.exports={Graph:d(),version:u()}}),f=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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=l(($,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}}),_=l(($,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=l(($,T)=>{var z=_();T.exports=O;function O(V,H){return z(V,H,"post")}}),q=l(($,T)=>{var z=_();T.exports=O;function O(V,H){return z(V,H,"pre")}}),X=l(($,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=l(($,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=l(($,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}}),II=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 i(d),d}enqueue(c){let d=this._sentinel;c._prev&&c._next&&i(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,l)),u=u._prev;return"["+c.join(", ")+"]"}};function i(c){c._prev._next=c._next,c._next._prev=c._prev,delete c._next,delete c._prev}function l(c,d){if(c!=="_next"&&c!=="_prev")return d}n.exports=s}),zI=gn((e,n)=>{var s=Ms().Graph,i=II();n.exports=c;var l=()=>1;function c(p,g){if(p.nodeCount()<=1)return[];let b=h(p,g||l);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 i),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:i,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:l,successorWeights:d,time:M,uniqueId:R,zipObject:X};function i(L,P,G,$){for(var T=$;L.hasNode(T);)T=R($);return G.dummy=P,L.setNode(T,G),T}function l(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=$),i(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),{})}}),$I=gn((e,n)=>{var s=zI(),i=nr().uniqueId;n.exports={run:l,undo:d};function l(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,i("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)}})}}),BI=gn((e,n)=>{var s=nr();n.exports={run:i,undo:c};function i(d){d.graph().dummyChains=[],d.edges().forEach(u=>l(d,u))}function l(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)})}}),yu=gn((e,n)=>{var{applyWithChunking:s}=nr();n.exports={longestPath:i,slack:l};function i(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 l(c,d){return c.node(d.w).rank-c.node(d.v).rank-c.edge(d).minlen}}),c5=gn((e,n)=>{var s=Ms().Graph,i=yu().slack;n.exports=l;function l(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)?i(h,g):-i(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)&&!i(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=i(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)}}),HI=gn((e,n)=>{var s=c5(),i=yu().slack,l=yu().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),l(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)=>i(R,z)<i(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}}),PI=gn((e,n)=>{var s=yu(),i=s.longestPath,l=c5(),c=HI();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=i;function h(x){i(x),l(x)}function f(x){c(x)}}),UI=gn((e,n)=>{n.exports=s;function s(c){let d=l(c);c.graph().dummyChains.forEach(u=>{let h=c.node(u),f=h.edgeObj,x=i(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 i(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 l(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}}),qI=gn((e,n)=>{var s=nr();n.exports={run:i,cleanup:u};function i(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=>l(h,f,b,w,g,x,k)),h.graph().nodeRankFactor=b}function l(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=>{l(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)})}}),FI=gn((e,n)=>{var s=nr();n.exports=i;function i(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)l(c,"borderLeft","_bl",u,f,x),l(c,"borderRight","_br",u,f,x)}}c.children().forEach(d)}function l(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})}}),VI=gn((e,n)=>{n.exports={adjust:s,undo:i};function s(x){let p=x.graph().rankdir.toLowerCase();(p==="lr"||p==="rl")&&l(x)}function i(x){let p=x.graph().rankdir.toLowerCase();(p==="bt"||p==="rl")&&d(x),(p==="lr"||p==="rl")&&(h(x),l(x))}function l(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}}),YI=gn((e,n)=>{var s=nr();n.exports=i;function i(l){let c={},d=l.nodes().filter(p=>!l.children(p).length),u=d.map(p=>l.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=l.node(p);f[g.rank].push(p),l.successors(p).forEach(x)}return d.sort((p,g)=>l.node(p).rank-l.node(g).rank).forEach(x),f}}),GI=gn((e,n)=>{var s=nr().zipObject;n.exports=i;function i(c,d){let u=0;for(let h=1;h<d.length;++h)u+=l(c,d[h-1],d[h]);return u}function l(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}}),XI=gn((e,n)=>{n.exports=s;function s(i,l=[]){return l.map(c=>{let d=i.inEdges(c);if(d.length){let u=d.reduce((h,f)=>{let x=i.edge(f),p=i.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}})}}),KI=gn((e,n)=>{var s=nr();n.exports=i;function i(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 l(f)}function l(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}}),WI=gn((e,n)=>{var s=nr();n.exports=i;function i(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=l(p,x,w),f.forEach(C=>{w+=C.vs.length,p.push(C.vs),g+=C.barycenter*C.weight,b+=C.weight,w=l(p,x,w)});let k={vs:p.flat(!0)};return b&&(k.barycenter=g/b,k.weight=b),k}function l(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}}),ZI=gn((e,n)=>{var s=XI(),i=KI(),l=WI();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=i(E,x);d(M,C);let N=l(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)}}),QI=gn((e,n)=>{var s=Ms().Graph,i=nr();n.exports=l;function l(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=i.uniqueId("_root")););return u}}),JI=gn((e,n)=>{n.exports=s;function s(i,l,c){let d={},u;c.forEach(h=>{let f=i.parent(h),x,p;for(;f;){if(x=i.parent(f),x?(p=d[x],d[x]=f):(p=u,u=f),p&&p!==f){l.setEdge(p,f);return}f=x}})}}),ez=gn((e,n)=>{var s=YI(),i=GI(),l=ZI(),c=QI(),d=JI(),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=i(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=l(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))}}),tz=gn((e,n)=>{var s=Ms().Graph,i=nr();n.exports={positionX:k,findType1Conflicts:l,findType2Conflicts:c,addConflict:u,hasConflict:h,verticalAlignment:f,horizontalCompaction:x,alignCoordinates:b,findSmallestWidthAlignment:g,balance:w};function l(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;i.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=i.applyWithChunking(Math.min,A),_=i.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-i.applyWithChunking(Math.min,P);q!=="l"&&(G=_-i.applyWithChunking(Math.max,P)),G&&(M[X]=i.mapValues(L,$=>$+G))})})}function w(M,N){return i.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=i.buildLayerMatrix(M),A=Object.assign(l(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=i.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}}),nz=gn((e,n)=>{var s=nr(),i=tz().positionX;n.exports=l;function l(d){d=s.asNonCompoundGraph(d),c(d),Object.entries(i(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})}}),rz=gn((e,n)=>{var s=$I(),i=BI(),l=PI(),c=nr().normalizeRanks,d=UI(),u=nr().removeEmptyRanks,h=qI(),f=FI(),x=VI(),p=ez(),g=nz(),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",()=>l(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",()=>i.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",()=>i.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 Ce=ke.x,Me=ke.y,dt=ke.width,pt=ke.height;W=Math.min(W,Ce-dt/2),J=Math.max(J,Ce+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 Ce=D.edge(ke);Object.hasOwn(Ce,"x")&&ve(Ce)}),W-=me,te-=Oe,D.nodes().forEach(ke=>{let Ce=D.node(ke);Ce.x-=W,Ce.y-=te}),D.edges().forEach(ke=>{let Ce=D.edge(ke);Ce.points.forEach(Me=>{Me.x-=W,Me.y-=te}),Object.hasOwn(Ce,"x")&&(Ce.x-=W),Object.hasOwn(Ce,"y")&&(Ce.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}}),sz=gn((e,n)=>{var s=nr(),i=Ms().Graph;n.exports={debugOrdering:l};function l(c){let d=s.buildLayerMatrix(c),u=new i({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}}),az=gn((e,n)=>{n.exports="2.0.4"}),iz=gn((e,n)=>{n.exports={graphlib:Ms(),layout:rz(),debug:sz(),util:{time:nr().time,notime:nr().notime},version:az()}});const C1=iz();const E1={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"}},lz={critical:"bg-red-500",high:"bg-amber-500",medium:"bg-amber-500",low:"bg-blue-500"};function oz({data:e}){const{task:n,agentName:s,selected:i}=e,l=E1[n.status]??E1.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?`${l.bg} border-blue-500/40 ring-1 ring-blue-500/20`:`${l.bg} ${l.border}`} ${i?"ring-2 ring-brand-500 shadow-brand-500/25 shadow-lg":""}`,children:[t.jsx(ai,{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 ${lz[n.priority]??"bg-gray-500"}`}),t.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider ${l.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(ai,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const T1={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"}},A1={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"done",cancelled:"done",archived:"done"};function cz({data:e}){const{req:n,selected:s}=e,i=T1[n.status]??T1.pending;return t.jsxs("div",{className:`rounded-lg border-2 border-dashed px-3 py-2 min-w-[180px] max-w-[220px] shadow-lg ${i.bg} ${i.border} ${s?"ring-2 ring-brand-500 shadow-brand-500/25":""}`,children:[t.jsx(ai,{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 ${i.text}`,children:n.status.replace("_"," ")})]}),t.jsx("div",{className:"text-xs font-medium text-fg-primary leading-snug line-clamp-2 mb-1",children:n.title}),n.taskIds.length>0&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[n.taskIds.length," task",n.taskIds.length>1?"s":""]}),t.jsx(ai,{type:"source",position:mt.Bottom,className:"!bg-border-default !w-2 !h-2"})]})}const dz={task:oz,requirement:cz},uz=()=>document.documentElement.classList.contains("light")||!document.documentElement.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches,fz=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 mz(){return y.useSyncExternalStore(fz,uz,()=>!1)}const yx=200,vx=80;function _1(e,n,s="TB"){const i=new C1.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:s,nodesep:40,ranksep:60});for(const l of e)i.setNode(l.id,{width:yx,height:vx});for(const l of n)i.setEdge(l.source,l.target);return C1.layout(i),e.map(l=>{const c=i.node(l.id);return{...l,position:{x:(c?.x??0)-yx/2,y:(c?.y??0)-vx/2}}})}function hz(e,n){const s=new Map,i=new Map;for(const d of e)i.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 l=new Set,c=[];for(const d of e){if(l.has(d.id))continue;const u=new Set,h=[d.id];for(;h.length>0;){const f=h.pop();if(!l.has(f)){l.add(f),u.add(f);for(const x of s.get(f)??[])l.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 xz(e,n){if(e.length===0)return[];const s=hz(e,n);if(s.length===1)return _1(e,n);const i=s.map(p=>{const g=_1(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+yx),k=Math.min(k,E.position.y),C=Math.max(C,E.position.y+vx);for(const E of g)E.position.x-=b,E.position.y-=k;return{nodes:g,w:w-b,h:C-k}});i.sort((p,g)=>g.h-p.h);const l=60,c=i.reduce((p,g)=>p+(g.w+l)*(g.h+l),0),d=Math.sqrt(c)*1.1,u=[];let h=0,f=0,x=0;for(const p of i){h>0&&h+p.w>d&&(h=0,f+=x+l,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+l,x=Math.max(x,p.h)}return u}function pz(e,n,s){const i=new Set,l=[n];for(;l.length>0;){const c=l.pop();if(c===s)return!0;if(i.has(c))continue;i.add(c);const d=e.get(c);if(d?.blockedBy)for(const u of d.blockedBy)l.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"}}],Mh=new Set(qo.map(e=>e.id)),M1=e=>e.status==="archived";function gz({tasks:e,requirements:n=[],agents:s,showArchived:i,onShowArchivedChange:l,onTaskClick:c,onReqClick:d,onDependencyChange:u,selectedTaskId:h,selectedReqId:f}){const x=mz(),[p,g]=y.useState(null),[b,w]=y.useState(null),[k,C]=y.useState(new Set(Mh)),[E,M]=y.useState(i??!1),N=i??E,A=y.useCallback(ve=>{const ke=typeof ve=="function"?ve(N):ve;M(ke),l?.(ke)},[N,l]);y.useEffect(()=>{i!==void 0&&M(i)},[i]);const R=y.useMemo(()=>e.filter(ve=>M1(ve)).length,[e]),_=y.useMemo(()=>{const ve=new Set;for(const ke of qo)if(k.has(ke.id))for(const Ce of ke.statuses)ve.add(Ce);return ve},[k]),Y=y.useMemo(()=>{const ve=new Set;for(const ke of e)for(const Ce of qo)if(Ce.statuses.has(ke.status)){ve.add(Ce.id);break}for(const ke of n){const Ce=A1[ke.status];Ce&&ve.add(Ce)}return qo.filter(ke=>ve.has(ke.id))},[e,n]),q=y.useCallback(ve=>{C(ke=>{const Ce=new Set(ke);return Ce.has(ve)?Ce.delete(ve):Ce.add(ve),Ce})},[]),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,Ce)=>({id:`${ve}->${ke}`,source:ve,target:ke,animated:Ce==="blocked",markerEnd:{type:Ll.ArrowClosed,width:14,height:14,color:Ce==="blocked"?"#ef4444":$},style:{stroke:Ce==="blocked"?"#ef4444":$,strokeWidth:1.5,cursor:"pointer"}}),[$]),{initialNodes:z,initialEdges:O}=y.useMemo(()=>{const ve=e.filter(Ee=>_.has(Ee.status)&&(N||!M1(Ee))),ke=ve.map(Ee=>({id:Ee.id,type:"task",data:{task:Ee,agentName:Ee.assignedAgentId?L.get(Ee.assignedAgentId):void 0,selected:Ee.id===h},position:{x:0,y:0}})),Ce=new Set(ke.map(Ee=>Ee.id)),Me=new Set;for(const Ee of qo)k.has(Ee.id)&&Me.add(Ee.id);const dt=n.filter(Ee=>{const We=A1[Ee.status];return We&&Me.has(We)});for(const Ee of dt){const We=`req-${Ee.id}`;ke.push({id:We,type:"requirement",data:{req:Ee,selected:Ee.id===f},position:{x:0,y:0}}),Ce.add(We)}const pt=[];for(const Ee of ve)if(Ee.blockedBy)for(const We of Ee.blockedBy)Ce.has(We)&&pt.push(T(We,Ee.id,Ee.status));const et=new Set,Pt=(Ee,We)=>{const kt=`${Ee}->${We}`;et.has(kt)||(et.add(kt),pt.push({id:kt,source:Ee,target:We,markerEnd:{type:Ll.ArrowClosed,width:14,height:14,color:"#8b5cf6"},style:{stroke:"#8b5cf6",strokeWidth:1.5,strokeDasharray:"4 2"}}))};for(const Ee of dt){const We=`req-${Ee.id}`;for(const kt of Ee.taskIds)Ce.has(kt)&&Pt(We,kt)}for(const Ee of ve)if(Ee.requirementId){const We=`req-${Ee.requirementId}`;Ce.has(We)&&Pt(We,Ee.id)}return{initialNodes:xz(ke,pt),initialEdges:pt}},[e,n,L,P,T,_,k,N,h,f]),[V,H,Z]=iI(z),[B,F,K]=lI(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 Ce=G.get(ke.id.slice(4));Ce&&d&&d(Ce)}else{const Ce=P.get(ke.id);Ce&&c&&c(Ce)}},[P,G,c,d]),te=y.useCallback(async ve=>{const{source:ke,target:Ce}=ve;if(!ke||!Ce||ke===Ce)return;const Me=P.get(Ce);if(!Me)return;if(Me.blockedBy?.includes(ke)){X("Dependency already exists","error");return}if(pz(P,ke,Ce)){X("Cannot add: would create a cycle","error");return}const dt=[...Me.blockedBy??[],ke];try{await se.tasks.update(Ce,{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(Ce=>Ce!==b.source);try{await se.tasks.update(b.target,{blockedBy:ke}),X("Dependency removed"),u?.()}catch(Ce){X(`Failed: ${Ce instanceof Error?Ce.message:String(Ce)}`,"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(aI,{nodes:V,edges:B,onNodesChange:Z,onEdgesChange:K,onNodeClick:J,onConnect:te,onEdgeClick:re,onMoveEnd:W,onInit:ve=>{I.current=ve},nodeTypes:dz,fitView:!0,minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},connectionLineStyle:{stroke:"#818cf8",strokeWidth:2,strokeDasharray:"6 3"},children:[t.jsx(fI,{color:x?"#cbd5e1":"#374151",gap:20,size:1}),t.jsx(yI,{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(RI,{nodeColor:ve=>{const ke=ve.data?.task,Ce=ke?.status;return ke?.taskType==="scheduled"?"#06b6d4":Ce==="completed"||Ce==="accepted"?"#10b981":Ce==="in_progress"?"#f59e0b":Ce==="blocked"||Ce==="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<Mh.size&&t.jsx("button",{onClick:()=>{C(new Set(Mh)),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 d5({orgId:e,onCreated:n,onClose:s}){const[i,l]=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),!(!i.trim()||k)){C(!0),M("");try{const X=u.trim()?[{url:u.trim(),defaultBranch:f.trim()||"main"}]:[],L=await se.projects.create({name:i.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)}},[i,c,u,f,p,e,k,n]),Y=N&&!i.trim();return ju.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:i,onChange:q=>{l(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:!i.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 Hl(e,n,s){if(!e)return null;const i=n.find(c=>c.id===e);if(i)return i.name;const l=s.find(c=>c.id===e);return l?l.name:e==="anonymous"?"Admin":null}function bz({value:e,onSave:n,className:s,placeholder:i}){const[l,c]=y.useState(!1),[d,u]=y.useState(e),h=y.useRef(null);y.useEffect(()=>{u(e)},[e]),y.useEffect(()=>{l&&h.current?.focus()},[l]);const f=async()=>{c(!1);const x=d.trim();if(x&&x!==e)try{await n(x)}catch{u(e)}else u(e)};return l?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:i}):t.jsx("span",{onClick:()=>c(!0),className:`cursor-pointer hover:border-b hover:border-gray-600 transition-colors ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:i??"Click to edit"})})}function yz({value:e,onSave:n,className:s,placeholder:i}){const[l,c]=y.useState(!1),[d,u]=y.useState(e),h=y.useRef(null);y.useEffect(()=>{u(e)},[e]),y.useEffect(()=>{l&&h.current&&(h.current.focus(),h.current.style.height="auto",h.current.style.height=h.current.scrollHeight+"px")},[l]);const f=async()=>{c(!1);const x=d.trim();if(x!==e)try{await n(x)}catch{u(e)}else u(e)};return l?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:i,rows:2}):t.jsx("p",{onClick:()=>c(!0),className:`cursor-pointer hover:bg-surface-elevated/50 rounded-lg transition-colors px-2 py-1 -mx-2 -my-1 ${s??""}`,title:"Click to edit",children:e||t.jsx("span",{className:"text-fg-tertiary italic",children:i??"Add a description…"})})}const vz=/^\[([^\]]+?)(?:\s+by\s+([^\]]+))?\]\s*([\s\S]*)$/;function u5(e){const n=e.match(vz);return n?{timestamp:n[1].trim(),author:n[2]?.trim()??"System",content:n[3].trim()}:{timestamp:"",author:"",content:e}}function jz(e){if(!e)return"";const n=e.match(/^(\d{4})[/-](\d{2})[/-](\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?/);if(!n)return e;const s=new Date,i=+n[1],l=+n[2]-1,c=+n[3],d=+n[4],u=+n[5],h=new Date(i,l,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`:`${i}-${String(l+1).padStart(2,"0")}-${String(c).padStart(2,"0")}`}const R1=[{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 wz(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s)|0;return R1[Math.abs(n)%R1.length]}function Nz({note:e,compact:n}){const s=u5(e),i=wz(s.author||"System"),l=s.author?s.author.split(/[\s_-]+/).map(u=>u[0]).join("").slice(0,2).toUpperCase():"SY",c=jz(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 ${i.bg} flex items-center justify-center text-[9px] font-bold ${i.text} shrink-0 mt-0.5`,children:l}),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":i.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(qn,{content:s.content,className:"text-xs text-fg-secondary"})})]})]}):t.jsxs("div",{className:"flex gap-3 group",children:[t.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[t.jsx("div",{className:`w-7 h-7 rounded-full ${i.bg} flex items-center justify-center text-[10px] font-bold ${i.text}`,children:l}),t.jsx("div",{className:"w-px flex-1 bg-border-default/60 mt-1.5"})]}),t.jsx("div",{className:"flex-1 min-w-0 pb-4",children:t.jsxs("div",{className:`border ${i.border} rounded-lg overflow-hidden`,children:[t.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 ${i.bg} border-b ${i.border}`,children:[t.jsx("span",{className:`text-[11px] font-medium ${d?"text-fg-secondary":i.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(qn,{content:s.content,className:"text-xs text-fg-secondary"})})]})})]})}const uc=[{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"}],f5={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"}},kz={urgent:"border-l-red-500",high:"border-l-amber-500",medium:"border-l-blue-500",low:"border-l-gray-500"},Hd={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"}},O1=["low","medium","high","urgent"],D1=["pending","in_progress","blocked","review","completed","failed","rejected","cancelled"],L1=["pending","in_progress","completed","rejected","cancelled"],I1={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([])},jx={pending:new Set(["in_progress","rejected","cancelled"]),in_progress:new Set(["completed","cancelled"]),completed:new Set([]),rejected:new Set([]),cancelled:new Set([])},wx={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"},z1={idle:"text-green-500",working:"text-blue-500",error:"text-red-500",paused:"text-amber-500",offline:"text-fg-muted"};function Sz({agent:e,anchorRect:n,onClose:s}){const i=y.useRef(null);y.useEffect(()=>{const d=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[s]);const l=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:i,className:"fixed z-50 w-56 bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-3 space-y-2",style:{top:n.top+4,left:n.left},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-7 h-7 rounded-full bg-brand-500/15 flex items-center justify-center text-[10px] font-bold text-brand-600 shrink-0",children:e.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[10px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l}`}),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 i=e.authorType==="agent"||e.authorType==="system",l=new Date(e.createdAt),c=l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d=l.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(()=>ec(p.map(tc).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 ${i?"bg-indigo-500/20 text-indigo-400":"bg-blue-500/20 text-blue-400"}`,children:e.authorName.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[t.jsx("span",{className:`text-[11px] font-medium cursor-pointer hover:underline ${i?"text-indigo-400":"text-blue-400"}`,onClick: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&&i&&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(qn,{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(Eu,{entries:p,isActive:!1,onCollapse:()=>x(!1),embedded:!0})})]}),u&&t.jsx(Sz,{agent:u.agent,anchorRect:{top:u.top,left:u.left},onClose:()=>h(null)})]})}function Cz({task:e,agents:n,users:s,authUser:i}){const[l,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=u5(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 l)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,l]),[u,h]=y.useState(null),f=async(p,g,b)=>{await se.tasks.addComment(e.id,p,i?.name,void 0,i?.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(Nz,{note:p.note,compact:!0},`n-${g}`):t.jsx(Wo,{comment:p.comment,agents:n,onReply:x},`c-${p.comment.id}`))]}),t.jsx(mw,{agents:n,onSubmit:f,replyTo:u,onCancelReply:()=>h(null)})]})}function Ez({taskId:e,isRunning:n,authUser:s,agents:i}){const[l,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=>Ih(K)),[T]),O=l.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(l.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=>tc(D)).filter(D=>D!==null),I=Ky(T,ec(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:i},`c-${D.comment.id}`):t.jsx(au,{entry:D.entry,showTime:!0,isLast:W===S.length-1},`e-${W}`)),w&&g&&t.jsx(ex,{content:g}),w&&!g&&I.length>0&&t.jsx(Jh,{})]}),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=l.length>0?x.filter(K=>new Date(K.createdAt).getTime()<new Date(l[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:i},K.id))}),l.map((K,I)=>{const S=M.has(K.round),D=K.round===l[l.length-1].round,W=d.get(K.round),J=h.has(K.round),te=B(K,l[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=>Ih(Me)).map(Me=>tc(Me)).filter(Me=>Me!==null),Ce=[...Ky(W,ec(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 Ce.sort((Me,dt)=>Me.ts-dt.ts),Ce.map((Me,dt)=>Me.kind==="comment"?t.jsx(Wo,{comment:Me.comment,agents:i},`c-${Me.comment.id}`):t.jsx(au,{entry:Me.entry,showTime:!0,isLast:dt===Ce.length-1},`e-${dt}`))})(),D&&w&&g&&t.jsx(ex,{content:g}),D&&w&&!g&&!J&&t.jsx(Jh,{})]})]},K.round)})]}),Z]})}function Tz({filePath:e,onClose:n}){const[s,i]=y.useState(null),[l,c]=y.useState(null),[d,u]=y.useState(!0);y.useEffect(()=>{u(!0),c(null),se.files.preview(e).then(f=>i(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..."}),l&&t.jsx("div",{className:"text-sm text-red-500 text-center py-8",children:l}),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(qn,{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 Az({task:e,agents:n,projects:s,requirements:i,allTasks:l,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 lt=new ResizeObserver(Ge);return lt.observe(ye),()=>{ye.removeEventListener("scroll",Ge),lt.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,Ce=y.useCallback(async()=>{try{const ye=await se.tasks.listSubtasks(e.id);g(ye.subtasks)}catch{}},[e.id]);y.useEffect(()=>{Ce()},[Ce]);const Me=async ye=>{if(!Y){q(!0);try{await ye(),u(),await Ce()}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)}}},ie=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)}}},Ee=async()=>{b.trim()&&(await se.tasks.createSubtask(e.id,b.trim()),w(""),C(!1),Ce(),u())},We=async ye=>{ye.status==="completed"?await se.tasks.cancelSubtask(e.id,ye.id):await se.tasks.completeSubtask(e.id,ye.id),Ce(),u()},kt=async ye=>{await se.tasks.deleteSubtask(e.id,ye.id),A(null),Ce(),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)}}},Se=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&&(Ce(),Fe.current())}),[e.id,Ce]);const it=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,Bn=s.find(ye=>ye.id===e.projectId),dn=i.find(ye=>ye.id===e.requirementId);return n.find(ye=>ye.id===e.assignedAgentId),t.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-surface-secondary",children:[t.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3 border-b border-border-default shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 pr-4",children:[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(Ez,{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(qn,{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"})]})}),(Bn||dn)&&t.jsxs("div",{className:"px-6 py-2.5 border-b border-border-default flex flex-wrap items-center gap-2",children:[Bn&&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"}),Bn.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=l.find(Et=>Et.id===ye),lt=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 ${lt?"bg-green-500/10 text-green-600":"bg-amber-500/10 text-amber-600"}`,children:[t.jsx("span",{className:"text-[9px]",children:lt?"✓":"⏳"}),t.jsx("span",{className:`font-mono ${lt?"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 lt=[...e.blockedBy??[],Ge];await se.tasks.update(e.id,{blockedBy:lt}),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…"}),l.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"}),i.filter(ye=>!e.projectId||ye.projectId===e.projectId).map(ye=>t.jsx("option",{value:ye.id,children:ye.title},ye.id))]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:"Assignee"}),t.jsxs("select",{value:e.assignedAgentId??"",onChange:ye=>{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:Hl(e.createdBy,n,c)??e.createdBy})]}),e.updatedBy&&t.jsxs("span",{children:["Updated by ",t.jsx("span",{className:"text-fg-secondary",children:Hl(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:[it,"/",p.length," done"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[it>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 (${it})`}),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"&&Ee(),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:()=>{Ee()},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg",children:"Add"}),t.jsx("button",{onClick:()=>{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"},lt=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:lt.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(Cz,{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"},lt=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,")"]})]}),lt>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,"/",lt]}),t.jsx("button",{disabled:re>=lt,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 lt=Math.floor(Ge/60);return lt<24?`in ${lt}h ${Ge%60}m`:`in ${Math.floor(lt/24)}d ${lt%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 lt=Math.floor(Ge/60);return lt<24?`${lt}h ${Ge%60}m ago`:`${Math.floor(lt/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:()=>{ie()},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:()=>{Se()},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(hw,{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(Tz,{filePath:Z,onClose:()=>B(null)})]})}function _z({project:e,tasks:n,requirements:s,agents:i,onDeleteProject:l,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(()=>i.filter(q=>x.has(q.id)),[i,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(yz,{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:l,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 _i={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"}},m5={pending:"todo",in_progress:"in_progress",completed:"done",rejected:"closed",cancelled:"closed",archived:"closed"},h5={failed:"rejected",todo:"pending",in_progress:"in_progress",review:"in_progress",done:"completed",closed:"cancelled"},Mz={urgent:0,high:1,medium:2,low:3},$1={failed:0,todo:1,in_progress:2,review:3,done:4,closed:5},B1={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"},Rz={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"},Oz=["pending","in_progress","completed","rejected","cancelled","archived"];function Dz(e){for(const n of uc)if(n.statuses.includes(e))return n.id;return"closed"}function H1(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Pd({value:e,options:n,onSelect:s,allowedValues:i}){const[l,c]=y.useState(!1),d=y.useRef(null),u=y.useRef(null),h=n.find(f=>f.value===e);return y.useEffect(()=>{if(!l)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)},[l]),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}),l&&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||!i||i.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 P1({row:e,idx:n,dragIdx:s,agentMap:i,projMap:l,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"?i.get(e.data.assignedAgentId??""):void 0,C=l.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 ${B1[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(Pd,{value:b,options:e.kind==="task"?D1.map(M=>({value:M,label:Fo[M]?.label??M,cls:Fo[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})):L1.map(M=>({value:M,label:_i[M]?.label??M,cls:_i[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})),allowedValues:e.kind==="task"?I1[b]:jx[b],onSelect:M=>{f(e,M)}})}),t.jsx("div",{onClick:M=>M.stopPropagation(),children:t.jsx(Pd,{value:w,options:O1.map(M=>({value:M,label:Hd[M]?.label??M,cls:Hd[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 ${wx[k.status]??"bg-gray-500"}`}),t.jsx("span",{className:`${z1[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:H1(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 ${B1[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(Pd,{value:b,options:e.kind==="task"?D1.map(M=>({value:M,label:Fo[M]?.label??M,cls:Fo[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})):L1.map(M=>({value:M,label:_i[M]?.label??M,cls:_i[M]?.cls??"bg-gray-500/15 text-fg-tertiary"})),allowedValues:e.kind==="task"?I1[b]:jx[b],onSelect:M=>{f(e,M)}})}),t.jsx("div",{className:"w-[100px] shrink-0",onClick:M=>M.stopPropagation(),children:t.jsx(Pd,{value:w,options:O1.map(M=>({value:M,label:Hd[M]?.label??M,cls:Hd[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 ${wx[k.status]??"bg-gray-500"}`}),t.jsx("span",{className:`font-medium ${z1[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:H1(e.data.updatedAt??"")})]})}function Lz({tasks:e,requirements:n,agents:s,projects:i,onTaskClick:l,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=Dz(z.status);T.push({kind:"task",data:z,group:O,groupOrder:$1[O]??5})}for(const z of n){const O=m5[z.status]??"todo";T.push({kind:"req",data:z,group:O,groupOrder:$1[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=>Mz[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=uc.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=h5[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(i.map(T=>[T.id,T])),[i]),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=uc.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 ${Rz[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(P1,{row:V,idx:G.get(V)??0,dragIdx:g,agentMap:Y,projMap:q,onTaskClick:l,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(P1,{row:T,idx:z,dragIdx:g,agentMap:Y,projMap:q,onTaskClick:l,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 U1({authUser:e}){const n=Yr(),s=Au({side:"right",defaultWidth:Math.round(window.innerWidth*2/3),minWidth:380,maxWidth:Math.round(window.innerWidth*.8),storageKey:"markus_projects_detail_v3"}),[i,l]=y.useState(!1),c=y.useRef(i);c.current=i;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"),[Ce,Me]=y.useState(null),[dt,pt]=y.useState(null),[et,Pt]=y.useState(new Set),[ie,Ee]=y.useState(new Set),We=y.useRef(new Set),kt=y.useRef(new Set),[Ft,xe]=y.useState(null),[Se,Fe]=y.useState("backlog"),it=y.useMemo(()=>[{id:"backlog"},{id:"kanban"},{id:"dag"}],[]),ut=va(it,Se,Fe),Lt=y.useRef(null),bn=y.useMemo(()=>({scrollContainerRef:Lt}),[]),Ut=va(it,Se,Fe,bn),[St,Jt]=y.useState(!1),[yt,Xt]=y.useState(!1),_t=y.useRef(null),$t=y.useRef(null),[Bn,dn]=y.useState(!1),[ye,Ge]=y.useState(""),[lt,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=ie},[ie]);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&&l(!1),null):(n&&(l(!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&&l(!1),null):(n&&(l(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash)),ne)),Me(null)},[n]),Sn=y.useCallback(()=>{Me(null),pt(null),n&&c.current&&l(!1)},[n]);y.useEffect(()=>{if(!n)return;const ne=()=>{c.current&&(l(!1),Me(null),pt(null))};return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[n]);const ar=y.useRef(Ce);ar.current=Ce,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 Kn=y.useRef(M);Kn.current=M;const Ot=y.useCallback(ne=>{if(!ne)return;const Le=kt.current;Le.size>0&&!Le.has(ne)&&Ee(Be=>new Set([...Be,ne]))},[]),[pr,Tt]=y.useState(!1),hn=y.useCallback((ne,Le)=>{Me(ne),pt(null),Le?.scrollToComments&&Tt(!0),n&&(l(!0),history.pushState({mobileDetail:ge.WORK},"",window.location.hash))},[n]),ln=y.useCallback((ne,Le)=>{pt(ne),Me(null),Le?.scrollToComments&&Tt(!0),n&&(l(!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&&ir())},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=Kn.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)),Ee(new Set),p(ne),f("project"),X(!1),history.replaceState(null,"",Lh(ge.WORK,ne))},ir=()=>{Ee(We.current),p(null),f("all"),X(!1),history.replaceState(null,"",Lh(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&&ir(),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(),Ce&&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===Ce.id);Me(st||null)}).catch(()=>{})},150)},Ds=async()=>{if(!ye.trim()){ae("Please enter a title for this requirement");return}if(!lt.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:lt.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}`)}},Fn=(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=uc.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=h5[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})},Hn=ne=>{Ee(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)),ie.size>0&&(Be=Be.filter(st=>st.projectId&&ie.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)),ie.size>0&&(ne=ne.filter(Le=>Le.projectId&&ie.has(Le.projectId))),et.size>0&&(ne=ne.filter(Le=>et.has(Le.createdBy))),ne},[M,St,h,x,ie,et]),ka=y.useCallback(ne=>br.filter(Le=>m5[Le.status]===ne.id),[br]),Hi=uc.filter(ne=>{if(ne.id==="failed"||ne.id==="closed"){const Le=ys(ne),Be=ka(ne);return Le.length+Be.length>0}return!0}),lr=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]),li=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]),is=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(is).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=!!(Ce||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?i?{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 ${Se===ne?"bg-brand-600/25 text-brand-500":"text-fg-tertiary"}`,children:ne==="backlog"?"Backlog":ne==="kanban"?"Kanban":"DAG"},ne))}),lr>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":`${lr} archived`}),t.jsx("div",{className:"flex-1"}),(ie.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 ${ie.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",ie.size+et.size>0?` (${ie.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(bz,{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`}),lr>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 ${lr} archived`:`${lr} 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 ${Se===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:()=>Ee(new Set),className:`text-[10px] text-fg-tertiary hover:text-fg-secondary px-2 py-1 rounded-md bg-surface-elevated/60 hover:bg-surface-overlay shrink-0 transition-all ${ie.size>0?"visible opacity-100":"invisible opacity-0"}`,children:"Clear"}),li.map(ne=>{const Le=ie.has(ne.id),Be=is[ne.id]??0;return t.jsxs("button",{onClick:()=>Hn(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(_z,{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"})]})}):Se==="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(Lz,{tasks:Ls(Object.values(g).flat()),requirements:br,agents:w,projects:d,onTaskClick:ne=>ot(ne),onReqClick:ne=>At(ne),onRefresh:()=>{Qe(),Ve()},selectedTaskId:Ce?.id,selectedReqId:dt?.id})}):Se==="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(gz,{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:Ce?.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:Hi.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=_i[He.status]??{label:He.status,cls:"bg-gray-500/15 text-fg-secondary"},vr=He.source==="agent"&&He.status==="pending",Vn=h==="all"&&He.projectId?d.find(ee=>ee.id===He.projectId):null,vs=Hl(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:[Vn&&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:Vn.name,children:Vn.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=f5[He.status],vr=He.status==="pending",Vn=He.taskType==="scheduled"&&!!He.scheduleConfig,vs=Vn?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?Hl(He.createdBy,w,C)??He.createdBy:null,Re=Ce?.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&&Fn(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":Vn?"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}),Vn&&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"})})}),Vn&&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 ${wx[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||i)&&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:Ce?t.jsx(Az,{task:Ce,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(zz,{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(d5,{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"})]})]})}),Bn&&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:lt,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()||!lt.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:[(ie.size>0||et.size>0)&&t.jsx("button",{onClick:()=>{Ee(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:li.map(ne=>{const Le=ie.has(ne.id),Be=is[ne.id]??0;return t.jsxs("button",{onClick:()=>Hn(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 Iz({requirementId:e,agents:n,authUser:s}){const[i,l]=y.useState([]);y.useEffect(()=>{se.requirements.getComments(e).then(f=>l(f.comments)).catch(()=>{})},[e]),y.useEffect(()=>Zt.on("requirement:comment",x=>{x.payload?.requirementId===e&&x.payload.comment&&l(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 ",i.length>0&&t.jsxs("span",{className:"font-normal",children:["(",i.length,")"]})]}),t.jsxs("div",{className:"space-y-0.5 mb-3",children:[i.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary text-center py-4",children:"No comments yet."}),i.map(f=>t.jsx(Wo,{comment:f,agents:n,onReply:h},f.id))]}),t.jsx(mw,{agents:n,onSubmit:u,replyTo:c,onCancelReply:()=>d(null)})]})}function zz({req:e,agents:n,projects:s,allTasks:i,users:l,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 _=_i[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=Hl(e.createdBy,n,l)??e.createdBy.slice(0,12),$=i.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(qn,{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:Hl(e.approvedBy,n,l)??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=f5[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 ${kz[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(Iz,{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:Oz.map(T=>{const z=_i[T],O=T===e.status||(jx[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 $z(e){return e.files&&typeof e.files=="object"&&!Array.isArray(e.files)?e.files:null}function Ci({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 vl({label:e,value:n,color:s}){if(!n)return null;const i={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return t.jsxs("div",{children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:e}),t.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${i[s]??i.gray} capitalize inline-block`,children:n})]})}function Rh({files:e}){const[n,s]=y.useState(Object.keys(e)[0]??""),i=Object.keys(e);return i.length===0?null:t.jsxs("div",{children:[t.jsxs("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:["Files (",i.length,")"]}),t.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[t.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:i.map(l=>t.jsx("button",{onClick:()=>s(l),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${n===l?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:l},l))}),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 Bz({artifact:e,mode:n}){const s=$z(e),i=e.agent,l=e.team,c=e.dependencies,d=e.displayName??e.name;if(n==="agent"){const u=i?.roleName,h=i?.agentRole,f=i?.llmProvider,x=i?.llmModel,p=Hs(c?.env),g=Hs(c?.skills);return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Ci,{label:"Name",value:d}),t.jsx(Ci,{label:"Description",value:e.description}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(vl,{label:"Role Template",value:u,color:"indigo"}),t.jsx(vl,{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(vl,{label:"LLM Provider",value:f,color:"gray"}),x&&t.jsx(vl,{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(Ci,{label:"Skills",value:g.join(", ")}),s&&t.jsx(Rh,{files:s})]})}if(n==="team"){const h=l?.members??[];return t.jsxs("div",{className:"space-y-3 text-sm",children:[t.jsx(Ci,{label:"Name",value:d}),t.jsx(Ci,{label:"Description",value:e.description}),t.jsx("div",{className:"flex flex-wrap gap-2",children:t.jsx(vl,{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(Rh,{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(Ci,{label:"Name",value:d}),t.jsx(Ci,{label:"Description",value:e.description}),t.jsx("div",{className:"flex gap-2",children:t.jsx(vl,{label:"Category",value:e.category,color:"indigo"})}),s&&t.jsx(Rh,{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"}},q1={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"}},F1=["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 V1(){const e=Yr(),n=Au({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[s,i]=y.useState(!1),l=y.useRef(s);l.current=s,y.useEffect(()=>{if(!e)return;const ue=()=>{l.current&&i(!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,Ce]=y.useState("file"),[Me,dt]=y.useState(""),[pt,et]=y.useState(""),[Pt,ie]=y.useState(""),[Ee,We]=y.useState(""),[kt,Ft]=y.useState(""),[xe,Se]=y.useState(null),[Fe,it]=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)},Bn=async ue=>{await qx(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]),lt=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(()=>{lt()},[lt]),y.useEffect(()=>{const ue=Zt.on("deliverable:created",()=>lt()),ze=Zt.on("deliverable:updated",()=>lt()),Ve=Zt.on("deliverable:removed",()=>lt());return()=>{ue(),ze(),Ve()}},[lt]);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:Ee||void 0,tags:kt.split(",").map(ue=>ue.trim()).filter(Boolean)}),D(!1),$t("success","Deliverable created"),lt()}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"}),lt()}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"}),lt()}catch(ze){$t("error",`Error: ${ze}`)}I("")},sr=async ue=>{I("remove");try{await se.deliverables.remove(ue.id),$t("success","Removed"),Z(null),lt()}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?it({src:`data:${ze.mimeType};base64,${ze.content}`,name:ze.name}):Se(ze.content)}catch{Se(null),ue.type==="file"&&Ut(!0)}Lt(!1)}};y.useEffect(()=>{Se(null),it(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(""),ie(""),Ft(""),Ce("file"),g.length>0&&We(g[0].id),D(!0)},Qe=ue=>{Z(ue),e&&(i(!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(ti,{label:"All types",value:"",current:_||T||"",onClick:()=>{Y(""),z("")}}),F1.map(ue=>t.jsx(ti,{label:`${$o[ue]?.icon??""} ${ue}`,value:ue,current:_,onClick:ze=>{Y(ze),z("")}},ue)),["agent","team","skill"].map(ue=>t.jsx(ti,{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(ti,{label:"All projects",value:"",current:q,onClick:X}),g.map(ue=>t.jsx(ti,{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(ti,{label:"Active",value:"",current:G,onClick:$}),t.jsx(ti,{label:"Verified",value:"verified",current:G,onClick:$}),t.jsx(ti,{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 ${q1[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(Oh,{})," ",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 ${q1[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:()=>Bn(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(Bz,{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(qn,{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(Oh,{})," 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(qn,{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:()=>Bn(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(qn,{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=>Ce(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:F1.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=>ie(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:Ee,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(Oh,{}),W?"Creating...":"Create"]})]})]})})]})}function ti({label:e,value:n,current:s,onClick:i}){return t.jsx("button",{onClick:()=>i(s===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${s===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function Oh(){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 kl(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Hz(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 x5({authUser:e}){const[n,s]=y.useState("weekly"),[i,l]=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"});l(D)}catch(D){h(String(D)),l(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:kl(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 · ",kl(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(jl,{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(jl,{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(jl,{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(Ud,{label:"LLM Tokens (this month)",value:pa(f.llmTokens),color:"text-brand-500"}),t.jsx(Ud,{label:"Tool Calls (today)",value:pa(f.toolCalls),color:"text-blue-600"}),t.jsx(Ud,{label:"Messages (today)",value:pa(f.messages),color:"text-green-600"}),t.jsx(Ud,{label:"Storage",value:Hz(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}):i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[I[n]," · ",new Date(i.periodStart).toLocaleDateString()," — ",new Date(i.periodEnd).toLocaleDateString()]}),i.metrics&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Metrics"}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Us,{label:"Completed",value:i.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Us,{label:"In Progress",value:i.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Us,{label:"Created",value:i.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Us,{label:"Blocked",value:i.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Us,{label:"Failed",value:i.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Cost Overview"}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:kl(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"})]}),i.costSummary&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:i.costSummary.totalTokens.toLocaleString()}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Tokens (",I[n],")"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:kl(i.costSummary.totalEstimatedCost)}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:["Cost (",I[n],")"]})]})]})]})]}),i.taskSummary&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:"Task Summary"}),t.jsxs("div",{className:"space-y-4",children:[i.taskSummary.completed.length>0&&t.jsx(jl,{title:`Completed (${i.taskSummary.completed.length})`,color:"emerald",items:i.taskSummary.completed.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),i.taskSummary.inProgress.length>0&&t.jsx(jl,{title:`In Progress (${i.taskSummary.inProgress.length})`,color:"indigo",items:i.taskSummary.inProgress.map(S=>({id:S.id,label:S.title,sub:S.agent}))}),i.taskSummary.blocked.length>0&&t.jsx(jl,{title:`Blocked (${i.taskSummary.blocked.length})`,color:"amber",items:i.taskSummary.blocked.map(S=>({id:S.id,label:S.title,sub:S.reason||S.agent}))}),i.taskSummary.completed.length===0&&i.taskSummary.inProgress.length===0&&i.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:"No tasks in this period."})]})]})]}):null),E==="generate"&&t.jsxs("section",{className:"bg-surface-secondary border border-border-default rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:"Per-Agent Usage"})}),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(Pz,{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:kl(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 jl({title:e,color:n,items:s}){return t.jsxs("div",{className:"min-w-0 overflow-hidden",children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1.5",children:s.map((i,l)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${i.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:i.id?()=>bt.navigate(ge.WORK,{openTask:i.id}):void 0,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate min-w-0 ${i.id?"group-hover:text-brand-500 transition-colors":""}`,children:i.label})]}),i.sub&&i.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:i.sub})]},i.id??l))})]})}function Ud({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:i,onSort:l,align:c}){const d=s===n?i?"↓":"↑":"↕",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:()=>l(n),children:[e,t.jsx("span",{className:`ml-1 ${u}`,children:d})]})}function Pz({agent:e,maxTokens:n}){const s=n>0?Math.min(100,e.totalTokens/n*100):0,i=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="paused"?"bg-amber-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>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 ${i}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${s}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children: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:kl(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 Uz={active:"bg-green-500",paused:"bg-amber-500",completed:"bg-gray-500",archived:"bg-gray-600"};function qz({authUser:e,onClose:n,onSaved:s}){const[i,l]=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(),!i.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(i.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(Yx,{currentUrl:p,name:i,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:i,onChange:w=>l(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 Fz({authUser:e,collapsed:n,onLogout:s,onUserUpdated:i}){const[l,c]=y.useState(!1),[d,u]=y.useState(!1),h=y.useRef(null);if(y.useEffect(()=>{if(!l)return;const p=g=>{h.current&&!h.current.contains(g.target)&&c(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),!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(!l),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"})})]})]}),l&&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(qz,{authUser:e,onClose:()=>u(!1),onSaved:p=>{u(!1),i?.(p)}})]})}const Y1=5;function Vz({currentPage:e,onNavigate:n,authUser:s,onLogout:i,onUserUpdated:l,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{}i?.()},E=f?u:u.slice(0,Y1),M=u.length>Y1;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(Wh,{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(Wh,{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:yk.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"}),vk.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:wl[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:wl[ge.WORK]})}),t.jsx("button",{onClick:()=>n(ge.DELIVERABLES),title:"Deliverables",className:`w-full flex items-center justify-center px-2 py-2 rounded-lg text-sm mb-0.5 transition-colors ${e===ge.DELIVERABLES?"bg-brand-600 text-white":"text-fg-primary hover:bg-surface-elevated"}`,children:t.jsx(Ho,{d:wl[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:wl[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=Lh(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 ${Uz[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:wl[ge.DELIVERABLES]}),"Deliverables"]})]})]})},N.key))}),t.jsx(Fz,{authUser:s,collapsed:c,onLogout:C,onUserUpdated:l}),!c&&t.jsxs("div",{className:"px-4 pb-2 text-[10px] text-fg-muted",children:["v","0.4.21"]}),b&&t.jsx(d5,{orgId:s?.orgId,onCreated:()=>{w(!1),k()},onClose:()=>w(!1)})]})}function Yz({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:jk.map(s=>{const i=s.group.includes(e);return t.jsxs("button",{onClick:()=>n(s.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${i?"text-brand-500":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:i?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:wl[s.id]})}),t.jsx("span",{className:`text-[10px] leading-tight ${i?"font-semibold":""}`,children:s.label})]},s.id)})})}const G1=[{id:"builder",label:"Builder"},{id:"agents",label:"Agents"},{id:"teams",label:"Teams"},{id:"skills",label:"Skills"}];function Gz({authUser:e}){const[n,s]=y.useState("builder"),i=va(G1,n,s);return t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:i.onTouchStart,onTouchEnd:i.onTouchEnd,children:[t.jsx("div",{className:"flex border-b border-border-default bg-surface-secondary shrink-0 overflow-x-auto scrollbar-hide",children:G1.map(l=>t.jsx("button",{onClick:()=>s(l.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===l.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:l.label},l.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[n==="builder"&&t.jsx(ww,{}),n==="agents"&&t.jsx(nx,{authUser:e}),n==="teams"&&t.jsx(rx,{}),n==="skills"&&t.jsx(sx,{})]})]})}const X1=[{id:"settings",label:"Settings"},{id:"reports",label:"Reports"}];function Xz({theme:e,onThemeChange:n}){const[s,i]=y.useState("settings"),l=va(X1,s,i);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(c=>t.jsx("button",{onClick:()=>i(c.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===c.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:c.label},c.id))}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="settings"&&t.jsx(gw,{theme:e,onThemeChange:n}),s==="reports"&&t.jsx(x5,{})]})]})}const qd=1,K1=3;function Kz({onComplete:e,theme:n,onThemeChange:s}){const[i,l]=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(()=>{i===K1&&!Z.current&&!z&&(Z.current=!0,F())},[i,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(Yx,{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=()=>{i===qd&&!E||(i<J.length-1?l(i+1):e())},re=J[i];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:J.map((oe,me)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${me<=i?"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:[i>0?t.jsx("button",{onClick:()=>l(i-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:"Back"}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip"}),t.jsxs("div",{className:"flex items-center gap-3",children:[i===qd&&!E&&t.jsx("button",{onClick:()=>l(i+1),className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:"Skip for now"}),i===K1&&!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:i===qd&&!E,className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${i===qd&&!E?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:i===J.length-1?"Get Started":"Next"})]})]})]})})})}function Wz({onLogin:e}){const[n,s]=y.useState(""),[i,l]=y.useState(""),[c,d]=y.useState(""),[u,h]=y.useState(!1),f=async x=>{if(x.preventDefault(),!(!n.trim()||!i)){d(""),h(!0);try{const{user:p}=await se.auth.login(n.trim(),i),g=n.trim().toLowerCase()==="admin@markus.local"&&i==="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:i,onChange:x=>l(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||!i,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children: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 Zz({onComplete:e,isFirstTime:n}){const[s,i]=y.useState(""),[l,c]=y.useState(""),[d,u]=y.useState(""),[h,f]=y.useState(""),[x,p]=y.useState(!1),g=async b=>{if(b.preventDefault(),f(""),l.length<6){f("Password must be at least 6 characters");return}if(l!==d){f("Passwords do not match");return}p(!0);try{await se.auth.changePassword(s,l),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=>i(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:l,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||!l||!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 Dh={};function Qz(){const[e,n]=y.useState(Sd),[s,i]=y.useState(()=>!localStorage.getItem("markus_onboarded")),[l,c]=y.useState(!0),d=Yr(),u=h_(),h=Au({side:"left",defaultWidth:240,minWidth:180,maxWidth:400,collapsedWidth:48,storageKey:"markus_sidebar"}),[f,x]=y.useState(()=>new Set([Sd()])),[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=bk[G]??G);const $=Sd(),T=window.location.hash.slice(1);T!==$?Dh[$]=T:delete Dh[$];const z=G!==ge.WORK?Dh[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(()=>{}),Si(qr.builderArtifacts,()=>se.builder.artifacts.list()),Si(qr.builderAgents,()=>se.agents.list()),Si(qr.builderHubMyItems,()=>tr.myItems()),Si(qr.builderInstalled,()=>se.builder.artifacts.installed()),Si(qr.hubAgents,()=>tr.search({type:"agent",limit:50})),Si(qr.hubTeams,()=>tr.search({type:"team",limit:50})),Si(qr.hubSkills,()=>tr.search({type:"skill",limit:50}))}).catch(()=>g(null)),Zt.connect();const P=Zt.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),G=()=>{const $=Sd();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(Vy,{authUser:X}),[ge.TEAM]:t.jsx(xv,{authUser:X}),[ge.BUILDER]:t.jsx(Gz,{authUser:X}),[ge.SETTINGS]:t.jsx(Xz,{theme:u.mode,onThemeChange:u.setMode}),[ge.WORK]:t.jsx(U1,{authUser:X}),[ge.DELIVERABLES]:t.jsx(V1,{})}:{[ge.HOME]:t.jsx(Vy,{}),[ge.TEAM]:t.jsx(xv,{authUser:X}),[ge.SETTINGS]:t.jsx(gw,{theme:u.mode,onThemeChange:u.setMode}),[ge.STORE]:t.jsx(C_,{authUser:X}),[ge.BUILDER]:t.jsx(ww,{}),[ge.WORK]:t.jsx(U1,{authUser:X}),[ge.DELIVERABLES]:t.jsx(V1,{}),[ge.REPORTS]:t.jsx(x5,{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(Wz,{onLogin:(P,G)=>{g(P),G&&w(!0)}}):b?t.jsx(Zz,{onComplete:()=>w(!1),isFirstTime:!0}):s?t.jsx(Kz,{theme:u.mode,onThemeChange:u.setMode,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),i(!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(Vz,{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(Yz,{currentPage:e,onNavigate:Y})]})}xk.createRoot(document.getElementById("root")).render(t.jsx(y.StrictMode,{children:t.jsx(Qz,{})}));
|