tycono 0.3.14-beta.2 → 0.3.14-beta.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.
@@ -0,0 +1,138 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Czp8wshq.js","assets/index-BOuHc64o.css"])))=>i.map(i=>d[i]);
2
+ var T4=Object.defineProperty;var _4=(e,t,n)=>t in e?T4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var fb=(e,t,n)=>_4(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function zf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wm={exports:{}},xc={};/**
3
+ * @license React
4
+ * react-jsx-runtime.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var hb;function M4(){if(hb)return xc;hb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(i,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var d in a)d!=="key"&&(o[d]=a[d])}else o=a;return a=o.ref,{$$typeof:e,type:i,key:c,ref:a!==void 0?a:null,props:o}}return xc.Fragment=t,xc.jsx=n,xc.jsxs=n,xc}var mb;function F4(){return mb||(mb=1,Wm.exports=M4()),Wm.exports}var l=F4(),Gm={exports:{}},St={};/**
11
+ * @license React
12
+ * react.production.js
13
+ *
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var pb;function R4(){if(pb)return St;pb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),y=Symbol.iterator;function g(U){return U===null||typeof U!="object"?null:(U=y&&U[y]||U["@@iterator"],typeof U=="function"?U:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function C(U,P,O){this.props=U,this.context=P,this.refs=j,this.updater=O||w}C.prototype.isReactComponent={},C.prototype.setState=function(U,P){if(typeof U!="object"&&typeof U!="function"&&U!=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,U,P,"setState")},C.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function N(){}N.prototype=C.prototype;function E(U,P,O){this.props=U,this.context=P,this.refs=j,this.updater=O||w}var A=E.prototype=new N;A.constructor=E,k(A,C.prototype),A.isPureReactComponent=!0;var z=Array.isArray;function D(){}var F={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function V(U,P,O){var Z=O.ref;return{$$typeof:e,type:U,key:P,ref:Z!==void 0?Z:null,props:O}}function L(U,P){return V(U.type,P,U.props)}function _(U){return typeof U=="object"&&U!==null&&U.$$typeof===e}function B(U){var P={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(O){return P[O]})}var X=/\/+/g;function R(U,P){return typeof U=="object"&&U!==null&&U.key!=null?B(""+U.key):P.toString(36)}function H(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(D,D):(U.status="pending",U.then(function(P){U.status==="pending"&&(U.status="fulfilled",U.value=P)},function(P){U.status==="pending"&&(U.status="rejected",U.reason=P)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function $(U,P,O,Z,ee){var J=typeof U;(J==="undefined"||J==="boolean")&&(U=null);var se=!1;if(U===null)se=!0;else switch(J){case"bigint":case"string":case"number":se=!0;break;case"object":switch(U.$$typeof){case e:case t:se=!0;break;case x:return se=U._init,$(se(U._payload),P,O,Z,ee)}}if(se)return ee=ee(U),se=Z===""?"."+R(U,0):Z,z(ee)?(O="",se!=null&&(O=se.replace(X,"$&/")+"/"),$(ee,P,O,"",function(De){return De})):ee!=null&&(_(ee)&&(ee=L(ee,O+(ee.key==null||U&&U.key===ee.key?"":(""+ee.key).replace(X,"$&/")+"/")+se)),P.push(ee)),1;se=0;var le=Z===""?".":Z+":";if(z(U))for(var ye=0;ye<U.length;ye++)Z=U[ye],J=le+R(Z,ye),se+=$(Z,P,O,J,ee);else if(ye=g(U),typeof ye=="function")for(U=ye.call(U),ye=0;!(Z=U.next()).done;)Z=Z.value,J=le+R(Z,ye++),se+=$(Z,P,O,J,ee);else if(J==="object"){if(typeof U.then=="function")return $(H(U),P,O,Z,ee);throw P=String(U),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.")}return se}function G(U,P,O){if(U==null)return U;var Z=[],ee=0;return $(U,Z,"","",function(J){return P.call(O,J,ee++)}),Z}function Q(U){if(U._status===-1){var P=U._result;P=P(),P.then(function(O){(U._status===0||U._status===-1)&&(U._status=1,U._result=O)},function(O){(U._status===0||U._status===-1)&&(U._status=2,U._result=O)}),U._status===-1&&(U._status=0,U._result=P)}if(U._status===1)return U._result.default;throw U._result}var K=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var P=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(P))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},M={map:G,forEach:function(U,P,O){G(U,function(){P.apply(this,arguments)},O)},count:function(U){var P=0;return G(U,function(){P++}),P},toArray:function(U){return G(U,function(P){return P})||[]},only:function(U){if(!_(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return St.Activity=p,St.Children=M,St.Component=C,St.Fragment=n,St.Profiler=a,St.PureComponent=E,St.StrictMode=i,St.Suspense=m,St.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=F,St.__COMPILER_RUNTIME={__proto__:null,c:function(U){return F.H.useMemoCache(U)}},St.cache=function(U){return function(){return U.apply(null,arguments)}},St.cacheSignal=function(){return null},St.cloneElement=function(U,P,O){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var Z=k({},U.props),ee=U.key;if(P!=null)for(J in P.key!==void 0&&(ee=""+P.key),P)!q.call(P,J)||J==="key"||J==="__self"||J==="__source"||J==="ref"&&P.ref===void 0||(Z[J]=P[J]);var J=arguments.length-2;if(J===1)Z.children=O;else if(1<J){for(var se=Array(J),le=0;le<J;le++)se[le]=arguments[le+2];Z.children=se}return V(U.type,ee,Z)},St.createContext=function(U){return U={$$typeof:c,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:o,_context:U},U},St.createElement=function(U,P,O){var Z,ee={},J=null;if(P!=null)for(Z in P.key!==void 0&&(J=""+P.key),P)q.call(P,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(ee[Z]=P[Z]);var se=arguments.length-2;if(se===1)ee.children=O;else if(1<se){for(var le=Array(se),ye=0;ye<se;ye++)le[ye]=arguments[ye+2];ee.children=le}if(U&&U.defaultProps)for(Z in se=U.defaultProps,se)ee[Z]===void 0&&(ee[Z]=se[Z]);return V(U,J,ee)},St.createRef=function(){return{current:null}},St.forwardRef=function(U){return{$$typeof:d,render:U}},St.isValidElement=_,St.lazy=function(U){return{$$typeof:x,_payload:{_status:-1,_result:U},_init:Q}},St.memo=function(U,P){return{$$typeof:f,type:U,compare:P===void 0?null:P}},St.startTransition=function(U){var P=F.T,O={};F.T=O;try{var Z=U(),ee=F.S;ee!==null&&ee(O,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(D,K)}catch(J){K(J)}finally{P!==null&&O.types!==null&&(P.types=O.types),F.T=P}},St.unstable_useCacheRefresh=function(){return F.H.useCacheRefresh()},St.use=function(U){return F.H.use(U)},St.useActionState=function(U,P,O){return F.H.useActionState(U,P,O)},St.useCallback=function(U,P){return F.H.useCallback(U,P)},St.useContext=function(U){return F.H.useContext(U)},St.useDebugValue=function(){},St.useDeferredValue=function(U,P){return F.H.useDeferredValue(U,P)},St.useEffect=function(U,P){return F.H.useEffect(U,P)},St.useEffectEvent=function(U){return F.H.useEffectEvent(U)},St.useId=function(){return F.H.useId()},St.useImperativeHandle=function(U,P,O){return F.H.useImperativeHandle(U,P,O)},St.useInsertionEffect=function(U,P){return F.H.useInsertionEffect(U,P)},St.useLayoutEffect=function(U,P){return F.H.useLayoutEffect(U,P)},St.useMemo=function(U,P){return F.H.useMemo(U,P)},St.useOptimistic=function(U,P){return F.H.useOptimistic(U,P)},St.useReducer=function(U,P,O){return F.H.useReducer(U,P,O)},St.useRef=function(U){return F.H.useRef(U)},St.useState=function(U){return F.H.useState(U)},St.useSyncExternalStore=function(U,P,O){return F.H.useSyncExternalStore(U,P,O)},St.useTransition=function(){return F.H.useTransition()},St.version="19.2.4",St}var xb;function Qc(){return xb||(xb=1,Gm.exports=R4()),Gm.exports}var S=Qc();const z4=zf(S);var Km={exports:{}},gc={},Qm={exports:{}},Zm={};/**
19
+ * @license React
20
+ * scheduler.production.js
21
+ *
22
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ */var gb;function B4(){return gb||(gb=1,(function(e){function t($,G){var Q=$.length;$.push(G);e:for(;0<Q;){var K=Q-1>>>1,M=$[K];if(0<a(M,G))$[K]=G,$[Q]=M,Q=K;else break e}}function n($){return $.length===0?null:$[0]}function i($){if($.length===0)return null;var G=$[0],Q=$.pop();if(Q!==G){$[0]=Q;e:for(var K=0,M=$.length,U=M>>>1;K<U;){var P=2*(K+1)-1,O=$[P],Z=P+1,ee=$[Z];if(0>a(O,Q))Z<M&&0>a(ee,O)?($[K]=ee,$[Z]=Q,K=Z):($[K]=O,$[P]=Q,K=P);else if(Z<M&&0>a(ee,Q))$[K]=ee,$[Z]=Q,K=Z;else break e}}return G}function a($,G){var Q=$.sortIndex-G.sortIndex;return Q!==0?Q:$.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],f=[],x=1,p=null,y=3,g=!1,w=!1,k=!1,j=!1,C=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function A($){for(var G=n(f);G!==null;){if(G.callback===null)i(f);else if(G.startTime<=$)i(f),G.sortIndex=G.expirationTime,t(m,G);else break;G=n(f)}}function z($){if(k=!1,A($),!w)if(n(m)!==null)w=!0,D||(D=!0,B());else{var G=n(f);G!==null&&H(z,G.startTime-$)}}var D=!1,F=-1,q=5,V=-1;function L(){return j?!0:!(e.unstable_now()-V<q)}function _(){if(j=!1,D){var $=e.unstable_now();V=$;var G=!0;try{e:{w=!1,k&&(k=!1,N(F),F=-1),g=!0;var Q=y;try{t:{for(A($),p=n(m);p!==null&&!(p.expirationTime>$&&L());){var K=p.callback;if(typeof K=="function"){p.callback=null,y=p.priorityLevel;var M=K(p.expirationTime<=$);if($=e.unstable_now(),typeof M=="function"){p.callback=M,A($),G=!0;break t}p===n(m)&&i(m),A($)}else i(m);p=n(m)}if(p!==null)G=!0;else{var U=n(f);U!==null&&H(z,U.startTime-$),G=!1}}break e}finally{p=null,y=Q,g=!1}G=void 0}}finally{G?B():D=!1}}}var B;if(typeof E=="function")B=function(){E(_)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,R=X.port2;X.port1.onmessage=_,B=function(){R.postMessage(null)}}else B=function(){C(_,0)};function H($,G){F=C(function(){$(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_next=function($){switch(y){case 1:case 2:case 3:var G=3;break;default:G=y}var Q=y;y=G;try{return $()}finally{y=Q}},e.unstable_requestPaint=function(){j=!0},e.unstable_runWithPriority=function($,G){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var Q=y;y=$;try{return G()}finally{y=Q}},e.unstable_scheduleCallback=function($,G,Q){var K=e.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?K+Q:K):Q=K,$){case 1:var M=-1;break;case 2:M=250;break;case 5:M=1073741823;break;case 4:M=1e4;break;default:M=5e3}return M=Q+M,$={id:x++,callback:G,priorityLevel:$,startTime:Q,expirationTime:M,sortIndex:-1},Q>K?($.sortIndex=Q,t(f,$),n(m)===null&&$===n(f)&&(k?(N(F),F=-1):k=!0,H(z,Q-K))):($.sortIndex=M,t(m,$),w||g||(w=!0,D||(D=!0,B()))),$},e.unstable_shouldYield=L,e.unstable_wrapCallback=function($){var G=y;return function(){var Q=y;y=G;try{return $.apply(this,arguments)}finally{y=Q}}}})(Zm)),Zm}var yb;function $4(){return yb||(yb=1,Qm.exports=B4()),Qm.exports}var Jm={exports:{}},hr={};/**
27
+ * @license React
28
+ * react-dom.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var bb;function O4(){if(bb)return hr;bb=1;var e=Qc();function t(m){var f="https://react.dev/errors/"+m;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 #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var i={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function o(m,f,x){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:p==null?null:""+p,children:m,containerInfo:f,implementation:x}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return hr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,hr.createPortal=function(m,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(t(299));return o(m,f,null,x)},hr.flushSync=function(m){var f=c.T,x=i.p;try{if(c.T=null,i.p=2,m)return m()}finally{c.T=f,i.p=x,i.d.f()}},hr.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,i.d.C(m,f))},hr.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},hr.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var x=f.as,p=d(x,f.crossOrigin),y=typeof f.integrity=="string"?f.integrity:void 0,g=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;x==="style"?i.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:p,integrity:y,fetchPriority:g}):x==="script"&&i.d.X(m,{crossOrigin:p,integrity:y,fetchPriority:g,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},hr.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var x=d(f.as,f.crossOrigin);i.d.M(m,{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(m)},hr.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var x=f.as,p=d(x,f.crossOrigin);i.d.L(m,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})}},hr.preloadModule=function(m,f){if(typeof m=="string")if(f){var x=d(f.as,f.crossOrigin);i.d.m(m,{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(m)},hr.requestFormReset=function(m){i.d.r(m)},hr.unstable_batchedUpdates=function(m,f){return m(f)},hr.useFormState=function(m,f,x){return c.H.useFormState(m,f,x)},hr.useFormStatus=function(){return c.H.useHostTransitionStatus()},hr.version="19.2.4",hr}var vb;function g2(){if(vb)return Jm.exports;vb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Jm.exports=O4(),Jm.exports}/**
35
+ * @license React
36
+ * react-dom-client.production.js
37
+ *
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var wb;function L4(){if(wb)return gc;wb=1;var e=$4(),t=Qc(),n=g2();function i(r){var s="https://react.dev/errors/"+r;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)s+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+r+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function o(r){var s=r,u=r;if(r.alternate)for(;s.return;)s=s.return;else{r=s;do s=r,(s.flags&4098)!==0&&(u=s.return),r=s.return;while(r)}return s.tag===3?u:null}function c(r){if(r.tag===13){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function d(r){if(r.tag===31){var s=r.memoizedState;if(s===null&&(r=r.alternate,r!==null&&(s=r.memoizedState)),s!==null)return s.dehydrated}return null}function m(r){if(o(r)!==r)throw Error(i(188))}function f(r){var s=r.alternate;if(!s){if(s=o(r),s===null)throw Error(i(188));return s!==r?null:r}for(var u=r,h=s;;){var b=u.return;if(b===null)break;var v=b.alternate;if(v===null){if(h=b.return,h!==null){u=h;continue}break}if(b.child===v.child){for(v=b.child;v;){if(v===u)return m(b),r;if(v===h)return m(b),s;v=v.sibling}throw Error(i(188))}if(u.return!==h.return)u=b,h=v;else{for(var T=!1,Y=b.child;Y;){if(Y===u){T=!0,u=b,h=v;break}if(Y===h){T=!0,h=b,u=v;break}Y=Y.sibling}if(!T){for(Y=v.child;Y;){if(Y===u){T=!0,u=v,h=b;break}if(Y===h){T=!0,h=v,u=b;break}Y=Y.sibling}if(!T)throw Error(i(189))}}if(u.alternate!==h)throw Error(i(190))}if(u.tag!==3)throw Error(i(188));return u.stateNode.current===u?r:s}function x(r){var s=r.tag;if(s===5||s===26||s===27||s===6)return r;for(r=r.child;r!==null;){if(s=x(r),s!==null)return s;r=r.sibling}return null}var p=Object.assign,y=Symbol.for("react.element"),g=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),E=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),L=Symbol.for("react.memo_cache_sentinel"),_=Symbol.iterator;function B(r){return r===null||typeof r!="object"?null:(r=_&&r[_]||r["@@iterator"],typeof r=="function"?r:null)}var X=Symbol.for("react.client.reference");function R(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===X?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case k:return"Fragment";case C:return"Profiler";case j:return"StrictMode";case z:return"Suspense";case D:return"SuspenseList";case V:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case E:return r.displayName||"Context";case N:return(r._context.displayName||"Context")+".Consumer";case A:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case F:return s=r.displayName||null,s!==null?s:R(r.type)||"Memo";case q:s=r._payload,r=r._init;try{return R(r(s))}catch{}}return null}var H=Array.isArray,$=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},K=[],M=-1;function U(r){return{current:r}}function P(r){0>M||(r.current=K[M],K[M]=null,M--)}function O(r,s){M++,K[M]=r.current,r.current=s}var Z=U(null),ee=U(null),J=U(null),se=U(null);function le(r,s){switch(O(J,s),O(ee,r),O(Z,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?zy(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=zy(s),r=By(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}P(Z),O(Z,r)}function ye(){P(Z),P(ee),P(J)}function De(r){r.memoizedState!==null&&O(se,r);var s=Z.current,u=By(s,r.type);s!==u&&(O(ee,r),O(Z,u))}function Ee(r){ee.current===r&&(P(Z),P(ee)),se.current===r&&(P(se),fc._currentValue=Q)}var Re,me;function Fe(r){if(Re===void 0)try{throw Error()}catch(u){var s=u.stack.trim().match(/\n( *(at )?)/);Re=s&&s[1]||"",me=-1<u.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+Re+r+me}var Je=!1;function Pe(r,s){if(!r||Je)return"";Je=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var h={DetermineComponentFrameRoot:function(){try{if(s){var _e=function(){throw Error()};if(Object.defineProperty(_e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_e,[])}catch(ge){var xe=ge}Reflect.construct(r,[],_e)}else{try{_e.call()}catch(ge){xe=ge}r.call(_e.prototype)}}else{try{throw Error()}catch(ge){xe=ge}(_e=r())&&typeof _e.catch=="function"&&_e.catch(function(){})}}catch(ge){if(ge&&xe&&typeof ge.stack=="string")return[ge.stack,xe.stack]}return[null,null]}};h.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(h.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(h.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=h.DetermineComponentFrameRoot(),T=v[0],Y=v[1];if(T&&Y){var ne=T.split(`
45
+ `),he=Y.split(`
46
+ `);for(b=h=0;h<ne.length&&!ne[h].includes("DetermineComponentFrameRoot");)h++;for(;b<he.length&&!he[b].includes("DetermineComponentFrameRoot");)b++;if(h===ne.length||b===he.length)for(h=ne.length-1,b=he.length-1;1<=h&&0<=b&&ne[h]!==he[b];)b--;for(;1<=h&&0<=b;h--,b--)if(ne[h]!==he[b]){if(h!==1||b!==1)do if(h--,b--,0>b||ne[h]!==he[b]){var je=`
47
+ `+ne[h].replace(" at new "," at ");return r.displayName&&je.includes("<anonymous>")&&(je=je.replace("<anonymous>",r.displayName)),je}while(1<=h&&0<=b);break}}}finally{Je=!1,Error.prepareStackTrace=u}return(u=r?r.displayName||r.name:"")?Fe(u):""}function it(r,s){switch(r.tag){case 26:case 27:case 5:return Fe(r.type);case 16:return Fe("Lazy");case 13:return r.child!==s&&s!==null?Fe("Suspense Fallback"):Fe("Suspense");case 19:return Fe("SuspenseList");case 0:case 15:return Pe(r.type,!1);case 11:return Pe(r.type.render,!1);case 1:return Pe(r.type,!0);case 31:return Fe("Activity");default:return""}}function ht(r){try{var s="",u=null;do s+=it(r,u),u=r,r=r.return;while(r);return s}catch(h){return`
48
+ Error generating stack: `+h.message+`
49
+ `+h.stack}}var Ye=Object.prototype.hasOwnProperty,nt=e.unstable_scheduleCallback,ut=e.unstable_cancelCallback,kt=e.unstable_shouldYield,mt=e.unstable_requestPaint,ve=e.unstable_now,be=e.unstable_getCurrentPriorityLevel,te=e.unstable_ImmediatePriority,oe=e.unstable_UserBlockingPriority,Ce=e.unstable_NormalPriority,pe=e.unstable_LowPriority,Se=e.unstable_IdlePriority,Me=e.log,Ge=e.unstable_setDisableYieldValue,Ie=null,qe=null;function Xe(r){if(typeof Me=="function"&&Ge(r),qe&&typeof qe.setStrictMode=="function")try{qe.setStrictMode(Ie,r)}catch{}}var et=Math.clz32?Math.clz32:_t,ze=Math.log,Be=Math.LN2;function _t(r){return r>>>=0,r===0?32:31-(ze(r)/Be|0)|0}var en=256,Tt=262144,Pt=4194304;function hn(r){var s=r&42;if(s!==0)return s;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 Zt(r,s,u){var h=r.pendingLanes;if(h===0)return 0;var b=0,v=r.suspendedLanes,T=r.pingedLanes;r=r.warmLanes;var Y=h&134217727;return Y!==0?(h=Y&~v,h!==0?b=hn(h):(T&=Y,T!==0?b=hn(T):u||(u=Y&~r,u!==0&&(b=hn(u))))):(Y=h&~v,Y!==0?b=hn(Y):T!==0?b=hn(T):u||(u=h&~r,u!==0&&(b=hn(u)))),b===0?0:s!==0&&s!==b&&(s&v)===0&&(v=b&-b,u=s&-s,v>=u||v===32&&(u&4194048)!==0)?s:b}function ae(r,s){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&s)===0}function Ve(r,s){switch(r){case 1:case 2:case 4:case 8:case 64:return s+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 s+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 We(){var r=Pt;return Pt<<=1,(Pt&62914560)===0&&(Pt=4194304),r}function tn(r){for(var s=[],u=0;31>u;u++)s.push(r);return s}function Ne(r,s){r.pendingLanes|=s,s!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Ct(r,s,u,h,b,v){var T=r.pendingLanes;r.pendingLanes=u,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=u,r.entangledLanes&=u,r.errorRecoveryDisabledLanes&=u,r.shellSuspendCounter=0;var Y=r.entanglements,ne=r.expirationTimes,he=r.hiddenUpdates;for(u=T&~u;0<u;){var je=31-et(u),_e=1<<je;Y[je]=0,ne[je]=-1;var xe=he[je];if(xe!==null)for(he[je]=null,je=0;je<xe.length;je++){var ge=xe[je];ge!==null&&(ge.lane&=-536870913)}u&=~_e}h!==0&&ln(r,h,0),v!==0&&b===0&&r.tag!==0&&(r.suspendedLanes|=v&~(T&~s))}function ln(r,s,u){r.pendingLanes|=s,r.suspendedLanes&=~s;var h=31-et(s);r.entangledLanes|=s,r.entanglements[h]=r.entanglements[h]|1073741824|u&261930}function nn(r,s){var u=r.entangledLanes|=s;for(r=r.entanglements;u;){var h=31-et(u),b=1<<h;b&s|r[h]&s&&(r[h]|=s),u&=~b}}function Kr(r,s){var u=s&-s;return u=(u&42)!==0?1:gr(u),(u&(r.suspendedLanes|s))!==0?0:u}function gr(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 vn(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function ce(){var r=G.p;return r!==0?r:(r=window.event,r===void 0?32:sb(r.type))}function Ue(r,s){var u=G.p;try{return G.p=r,s()}finally{G.p=u}}var $e=Math.random().toString(36).slice(2),dt="__reactFiber$"+$e,wt="__reactProps$"+$e,yr="__reactContainer$"+$e,Pn="__reactEvents$"+$e,Qr="__reactListeners$"+$e,fi="__reactHandles$"+$e,Ls="__reactResources$"+$e,Zr="__reactMarker$"+$e;function Ma(r){delete r[dt],delete r[wt],delete r[Pn],delete r[Qr],delete r[fi]}function jr(r){var s=r[dt];if(s)return s;for(var u=r.parentNode;u;){if(s=u[yr]||u[dt]){if(u=s.alternate,s.child!==null||u!==null&&u.child!==null)for(r=qy(r);r!==null;){if(u=r[dt])return u;r=qy(r)}return s}r=u,u=r.parentNode}return null}function dr(r){if(r=r[dt]||r[yr]){var s=r.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return r}return null}function Ai(r){var s=r.tag;if(s===5||s===26||s===27||s===6)return r.stateNode;throw Error(i(33))}function Di(r){var s=r[Ls];return s||(s=r[Ls]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function Sn(r){r[Zr]=!0}var Fa=new Set,Is={};function $n(r,s){Ti(r,s),Ti(r+"Capture",s)}function Ti(r,s){for(Is[r]=s,r=0;r<s.length;r++)Fa.add(s[r])}var _i=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]*$"),is={},hi={};function Mi(r){return Ye.call(hi,r)?!0:Ye.call(is,r)?!1:_i.test(r)?hi[r]=!0:(is[r]=!0,!1)}function Fr(r,s,u){if(Mi(s))if(u===null)r.removeAttribute(s);else{switch(typeof u){case"undefined":case"function":case"symbol":r.removeAttribute(s);return;case"boolean":var h=s.toLowerCase().slice(0,5);if(h!=="data-"&&h!=="aria-"){r.removeAttribute(s);return}}r.setAttribute(s,""+u)}}function ss(r,s,u){if(u===null)r.removeAttribute(s);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(s);return}r.setAttribute(s,""+u)}}function Zn(r,s,u,h){if(h===null)r.removeAttribute(u);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(u);return}r.setAttributeNS(s,u,""+h)}}function nr(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Ra(r){var s=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function za(r,s,u){var h=Object.getOwnPropertyDescriptor(r.constructor.prototype,s);if(!r.hasOwnProperty(s)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var b=h.get,v=h.set;return Object.defineProperty(r,s,{configurable:!0,get:function(){return b.call(this)},set:function(T){u=""+T,v.call(this,T)}}),Object.defineProperty(r,s,{enumerable:h.enumerable}),{getValue:function(){return u},setValue:function(T){u=""+T},stopTracking:function(){r._valueTracker=null,delete r[s]}}}}function mi(r){if(!r._valueTracker){var s=Ra(r)?"checked":"value";r._valueTracker=za(r,s,""+r[s])}}function Ba(r){if(!r)return!1;var s=r._valueTracker;if(!s)return!0;var u=s.getValue(),h="";return r&&(h=Ra(r)?r.checked?"true":"false":r.value),r=h,r!==u?(s.setValue(r),!0):!1}function as(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 pi=/[\n"\\]/g;function jn(r){return r.replace(pi,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function Jn(r,s,u,h,b,v,T,Y){r.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?r.type=T:r.removeAttribute("type"),s!=null?T==="number"?(s===0&&r.value===""||r.value!=s)&&(r.value=""+nr(s)):r.value!==""+nr(s)&&(r.value=""+nr(s)):T!=="submit"&&T!=="reset"||r.removeAttribute("value"),s!=null?br(r,T,nr(s)):u!=null?br(r,T,nr(u)):h!=null&&r.removeAttribute("value"),b==null&&v!=null&&(r.defaultChecked=!!v),b!=null&&(r.checked=b&&typeof b!="function"&&typeof b!="symbol"),Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?r.name=""+nr(Y):r.removeAttribute("name")}function Rr(r,s,u,h,b,v,T,Y){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(r.type=v),s!=null||u!=null){if(!(v!=="submit"&&v!=="reset"||s!=null)){mi(r);return}u=u!=null?""+nr(u):"",s=s!=null?""+nr(s):u,Y||s===r.value||(r.value=s),r.defaultValue=s}h=h??b,h=typeof h!="function"&&typeof h!="symbol"&&!!h,r.checked=Y?r.checked:!!h,r.defaultChecked=!!h,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(r.name=T),mi(r)}function br(r,s,u){s==="number"&&as(r.ownerDocument)===r||r.defaultValue===""+u||(r.defaultValue=""+u)}function mn(r,s,u,h){if(r=r.options,s){s={};for(var b=0;b<u.length;b++)s["$"+u[b]]=!0;for(u=0;u<r.length;u++)b=s.hasOwnProperty("$"+r[u].value),r[u].selected!==b&&(r[u].selected=b),b&&h&&(r[u].defaultSelected=!0)}else{for(u=""+nr(u),s=null,b=0;b<r.length;b++){if(r[b].value===u){r[b].selected=!0,h&&(r[b].defaultSelected=!0);return}s!==null||r[b].disabled||(s=r[b])}s!==null&&(s.selected=!0)}}function Eo(r,s,u){if(s!=null&&(s=""+nr(s),s!==r.value&&(r.value=s),u==null)){r.defaultValue!==s&&(r.defaultValue=s);return}r.defaultValue=u!=null?""+nr(u):""}function uu(r,s,u,h){if(s==null){if(h!=null){if(u!=null)throw Error(i(92));if(H(h)){if(1<h.length)throw Error(i(93));h=h[0]}u=h}u==null&&(u=""),s=u}u=nr(s),r.defaultValue=u,h=r.textContent,h===u&&h!==""&&h!==null&&(r.value=h),mi(r)}function Fi(r,s){if(s){var u=r.firstChild;if(u&&u===r.lastChild&&u.nodeType===3){u.nodeValue=s;return}}r.textContent=s}var Jr=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 ls(r,s,u){var h=s.indexOf("--")===0;u==null||typeof u=="boolean"||u===""?h?r.setProperty(s,""):s==="float"?r.cssFloat="":r[s]="":h?r.setProperty(s,u):typeof u!="number"||u===0||Jr.has(s)?s==="float"?r.cssFloat=u:r[s]=(""+u).trim():r[s]=u+"px"}function Ri(r,s,u){if(s!=null&&typeof s!="object")throw Error(i(62));if(r=r.style,u!=null){for(var h in u)!u.hasOwnProperty(h)||s!=null&&s.hasOwnProperty(h)||(h.indexOf("--")===0?r.setProperty(h,""):h==="float"?r.cssFloat="":r[h]="");for(var b in s)h=s[b],s.hasOwnProperty(b)&&u[b]!==h&&ls(r,b,h)}else for(var v in s)s.hasOwnProperty(v)&&ls(r,v,s[v])}function Ao(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 rr=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"]]),yn=/^[\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 zr(r){return yn.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Cn(){}var ei=null;function xi(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Hs=null,os=null;function cs(r){var s=dr(r);if(s&&(r=s.stateNode)){var u=r[wt]||null;e:switch(r=s.stateNode,s.type){case"input":if(Jn(r,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name),s=u.name,u.type==="radio"&&s!=null){for(u=r;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll('input[name="'+jn(""+s)+'"][type="radio"]'),s=0;s<u.length;s++){var h=u[s];if(h!==r&&h.form===r.form){var b=h[wt]||null;if(!b)throw Error(i(90));Jn(h,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name)}}for(s=0;s<u.length;s++)h=u[s],h.form===r.form&&Ba(h)}break e;case"textarea":Eo(r,u.value,u.defaultValue);break e;case"select":s=u.value,s!=null&&mn(r,!!u.multiple,s,!1)}}}var gi=!1;function Do(r,s,u){if(gi)return r(s,u);gi=!0;try{var h=r(s);return h}finally{if(gi=!1,(Hs!==null||os!==null)&&(od(),Hs&&(s=Hs,r=os,os=Hs=null,cs(s),r)))for(s=0;s<r.length;s++)cs(r[s])}}function Us(r,s){var u=r.stateNode;if(u===null)return null;var h=u[wt]||null;if(h===null)return null;u=h[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(h=!h.disabled)||(r=r.type,h=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!h;break e;default:r=!1}if(r)return null;if(u&&typeof u!="function")throw Error(i(231,s,typeof u));return u}var Tn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),us=!1;if(Tn)try{var zi={};Object.defineProperty(zi,"passive",{get:function(){us=!0}}),window.addEventListener("test",zi,zi),window.removeEventListener("test",zi,zi)}catch{us=!1}var Bi=null,To=null,Mt=null;function du(){if(Mt)return Mt;var r,s=To,u=s.length,h,b="value"in Bi?Bi.value:Bi.textContent,v=b.length;for(r=0;r<u&&s[r]===b[r];r++);var T=u-r;for(h=1;h<=T&&s[u-h]===b[v-h];h++);return Mt=b.slice(r,1<h?1-h:void 0)}function on(r){var s=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&s===13&&(r=13)):r=s,r===10&&(r=13),32<=r||r===13?r:0}function qs(){return!0}function Ys(){return!1}function fr(r){function s(u,h,b,v,T){this._reactName=u,this._targetInst=b,this.type=h,this.nativeEvent=v,this.target=T,this.currentTarget=null;for(var Y in r)r.hasOwnProperty(Y)&&(u=r[Y],this[Y]=u?u(v):v[Y]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?qs:Ys,this.isPropagationStopped=Ys,this}return p(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=qs)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=qs)},persist:function(){},isPersistent:qs}),s}var ir={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vl=fr(ir),ds=p({},ir,{view:0,detail:0}),fs=fr(ds),$a,_o,Oa,Ps=p({},ds,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Jt,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!==Oa&&(Oa&&r.type==="mousemove"?($a=r.screenX-Oa.screenX,_o=r.screenY-Oa.screenY):_o=$a=0,Oa=r),$a)},movementY:function(r){return"movementY"in r?r.movementY:_o}}),fu=fr(Ps),hu=p({},Ps,{dataTransfer:0}),mu=fr(hu),Jf=p({},ds,{relatedTarget:0}),wl=fr(Jf),pu=p({},ir,{animationName:0,elapsedTime:0,pseudoElement:0}),xu=fr(pu),$i=p({},ir,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),hs=fr($i),Mo=p({},ir,{data:0}),gu=fr(Mo),yu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},bu={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"},eh={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vu(r){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(r):(r=eh[r])?!!s[r]:!1}function Jt(){return vu}var kl=p({},ds,{key:function(r){if(r.key){var s=yu[r.key]||r.key;if(s!=="Unidentified")return s}return r.type==="keypress"?(r=on(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?bu[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Jt,charCode:function(r){return r.type==="keypress"?on(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?on(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),wu=fr(kl),ku=p({},Ps,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Fo=fr(ku),Su=p({},ds,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Jt}),ju=fr(Su),Cu=p({},ir,{propertyName:0,elapsedTime:0,pseudoElement:0}),Nu=fr(Cu),I=p({},Ps,{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}),re=fr(I),de=p({},ir,{newState:0,oldState:0}),we=fr(de),Te=[9,13,27,32],Ke=Tn&&"CompositionEvent"in window,$t=null;Tn&&"documentMode"in document&&($t=document.documentMode);var yt=Tn&&"TextEvent"in window&&!$t,ct=Tn&&(!Ke||$t&&8<$t&&11>=$t),ot=" ",vt=!1;function Yt(r,s){switch(r){case"keyup":return Te.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xs(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Xn=!1;function jt(r,s){switch(r){case"compositionend":return Xs(s);case"keypress":return s.which!==32?null:(vt=!0,ot);case"textInput":return r=s.data,r===ot&&vt?null:r;default:return null}}function Xt(r,s){if(Xn)return r==="compositionend"||!Ke&&Yt(r,s)?(r=du(),Mt=To=Bi=null,Xn=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return ct&&s.locale!=="ko"?null:s.data;default:return null}}var Mn={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 pn(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s==="input"?!!Mn[r.type]:s==="textarea"}function V0(r,s,u,h){Hs?os?os.push(h):os=[h]:Hs=h,s=pd(s,"onChange"),0<s.length&&(u=new vl("onChange","change",null,u,h),r.push({event:u,listeners:s}))}var Ro=null,zo=null;function rS(r){Dy(r,0)}function Eu(r){var s=Ai(r);if(Ba(s))return r}function W0(r,s){if(r==="change")return s}var G0=!1;if(Tn){var th;if(Tn){var nh="oninput"in document;if(!nh){var K0=document.createElement("div");K0.setAttribute("oninput","return;"),nh=typeof K0.oninput=="function"}th=nh}else th=!1;G0=th&&(!document.documentMode||9<document.documentMode)}function Q0(){Ro&&(Ro.detachEvent("onpropertychange",Z0),zo=Ro=null)}function Z0(r){if(r.propertyName==="value"&&Eu(zo)){var s=[];V0(s,zo,r,xi(r)),Do(rS,s)}}function iS(r,s,u){r==="focusin"?(Q0(),Ro=s,zo=u,Ro.attachEvent("onpropertychange",Z0)):r==="focusout"&&Q0()}function sS(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Eu(zo)}function aS(r,s){if(r==="click")return Eu(s)}function lS(r,s){if(r==="input"||r==="change")return Eu(s)}function oS(r,s){return r===s&&(r!==0||1/r===1/s)||r!==r&&s!==s}var Br=typeof Object.is=="function"?Object.is:oS;function Bo(r,s){if(Br(r,s))return!0;if(typeof r!="object"||r===null||typeof s!="object"||s===null)return!1;var u=Object.keys(r),h=Object.keys(s);if(u.length!==h.length)return!1;for(h=0;h<u.length;h++){var b=u[h];if(!Ye.call(s,b)||!Br(r[b],s[b]))return!1}return!0}function J0(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function eg(r,s){var u=J0(r);r=0;for(var h;u;){if(u.nodeType===3){if(h=r+u.textContent.length,r<=s&&h>=s)return{node:u,offset:s-r};r=h}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=J0(u)}}function tg(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?tg(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function ng(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var s=as(r.document);s instanceof r.HTMLIFrameElement;){try{var u=typeof s.contentWindow.location.href=="string"}catch{u=!1}if(u)r=s.contentWindow;else break;s=as(r.document)}return s}function rh(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}var cS=Tn&&"documentMode"in document&&11>=document.documentMode,Sl=null,ih=null,$o=null,sh=!1;function rg(r,s,u){var h=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;sh||Sl==null||Sl!==as(h)||(h=Sl,"selectionStart"in h&&rh(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),$o&&Bo($o,h)||($o=h,h=pd(ih,"onSelect"),0<h.length&&(s=new vl("onSelect","select",null,s,u),r.push({event:s,listeners:h}),s.target=Sl)))}function La(r,s){var u={};return u[r.toLowerCase()]=s.toLowerCase(),u["Webkit"+r]="webkit"+s,u["Moz"+r]="moz"+s,u}var jl={animationend:La("Animation","AnimationEnd"),animationiteration:La("Animation","AnimationIteration"),animationstart:La("Animation","AnimationStart"),transitionrun:La("Transition","TransitionRun"),transitionstart:La("Transition","TransitionStart"),transitioncancel:La("Transition","TransitionCancel"),transitionend:La("Transition","TransitionEnd")},ah={},ig={};Tn&&(ig=document.createElement("div").style,"AnimationEvent"in window||(delete jl.animationend.animation,delete jl.animationiteration.animation,delete jl.animationstart.animation),"TransitionEvent"in window||delete jl.transitionend.transition);function Ia(r){if(ah[r])return ah[r];if(!jl[r])return r;var s=jl[r],u;for(u in s)if(s.hasOwnProperty(u)&&u in ig)return ah[r]=s[u];return r}var sg=Ia("animationend"),ag=Ia("animationiteration"),lg=Ia("animationstart"),uS=Ia("transitionrun"),dS=Ia("transitionstart"),fS=Ia("transitioncancel"),og=Ia("transitionend"),cg=new Map,lh="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(" ");lh.push("scrollEnd");function yi(r,s){cg.set(r,s),$n(s,[r])}var Au=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=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(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},ti=[],Cl=0,oh=0;function Du(){for(var r=Cl,s=oh=Cl=0;s<r;){var u=ti[s];ti[s++]=null;var h=ti[s];ti[s++]=null;var b=ti[s];ti[s++]=null;var v=ti[s];if(ti[s++]=null,h!==null&&b!==null){var T=h.pending;T===null?b.next=b:(b.next=T.next,T.next=b),h.pending=b}v!==0&&ug(u,b,v)}}function Tu(r,s,u,h){ti[Cl++]=r,ti[Cl++]=s,ti[Cl++]=u,ti[Cl++]=h,oh|=h,r.lanes|=h,r=r.alternate,r!==null&&(r.lanes|=h)}function ch(r,s,u,h){return Tu(r,s,u,h),_u(r)}function Ha(r,s){return Tu(r,null,null,s),_u(r)}function ug(r,s,u){r.lanes|=u;var h=r.alternate;h!==null&&(h.lanes|=u);for(var b=!1,v=r.return;v!==null;)v.childLanes|=u,h=v.alternate,h!==null&&(h.childLanes|=u),v.tag===22&&(r=v.stateNode,r===null||r._visibility&1||(b=!0)),r=v,v=v.return;return r.tag===3?(v=r.stateNode,b&&s!==null&&(b=31-et(u),r=v.hiddenUpdates,h=r[b],h===null?r[b]=[s]:h.push(s),s.lane=u|536870912),v):null}function _u(r){if(50<sc)throw sc=0,ym=null,Error(i(185));for(var s=r.return;s!==null;)r=s,s=r.return;return r.tag===3?r.stateNode:null}var Nl={};function hS(r,s,u,h){this.tag=r,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=h,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $r(r,s,u,h){return new hS(r,s,u,h)}function uh(r){return r=r.prototype,!(!r||!r.isReactComponent)}function ms(r,s){var u=r.alternate;return u===null?(u=$r(r.tag,s,r.key,r.mode),u.elementType=r.elementType,u.type=r.type,u.stateNode=r.stateNode,u.alternate=r,r.alternate=u):(u.pendingProps=s,u.type=r.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=r.flags&65011712,u.childLanes=r.childLanes,u.lanes=r.lanes,u.child=r.child,u.memoizedProps=r.memoizedProps,u.memoizedState=r.memoizedState,u.updateQueue=r.updateQueue,s=r.dependencies,u.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},u.sibling=r.sibling,u.index=r.index,u.ref=r.ref,u.refCleanup=r.refCleanup,u}function dg(r,s){r.flags&=65011714;var u=r.alternate;return u===null?(r.childLanes=0,r.lanes=s,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=u.childLanes,r.lanes=u.lanes,r.child=u.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=u.memoizedProps,r.memoizedState=u.memoizedState,r.updateQueue=u.updateQueue,r.type=u.type,s=u.dependencies,r.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),r}function Mu(r,s,u,h,b,v){var T=0;if(h=r,typeof r=="function")uh(r)&&(T=1);else if(typeof r=="string")T=y4(r,u,Z.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case V:return r=$r(31,u,s,b),r.elementType=V,r.lanes=v,r;case k:return Ua(u.children,b,v,s);case j:T=8,b|=24;break;case C:return r=$r(12,u,s,b|2),r.elementType=C,r.lanes=v,r;case z:return r=$r(13,u,s,b),r.elementType=z,r.lanes=v,r;case D:return r=$r(19,u,s,b),r.elementType=D,r.lanes=v,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case E:T=10;break e;case N:T=9;break e;case A:T=11;break e;case F:T=14;break e;case q:T=16,h=null;break e}T=29,u=Error(i(130,r===null?"null":typeof r,"")),h=null}return s=$r(T,u,s,b),s.elementType=r,s.type=h,s.lanes=v,s}function Ua(r,s,u,h){return r=$r(7,r,h,s),r.lanes=u,r}function dh(r,s,u){return r=$r(6,r,null,s),r.lanes=u,r}function fg(r){var s=$r(18,null,null,0);return s.stateNode=r,s}function fh(r,s,u){return s=$r(4,r.children!==null?r.children:[],r.key,s),s.lanes=u,s.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},s}var hg=new WeakMap;function ni(r,s){if(typeof r=="object"&&r!==null){var u=hg.get(r);return u!==void 0?u:(s={value:r,source:s,stack:ht(s)},hg.set(r,s),s)}return{value:r,source:s,stack:ht(s)}}var El=[],Al=0,Fu=null,Oo=0,ri=[],ii=0,Vs=null,Oi=1,Li="";function ps(r,s){El[Al++]=Oo,El[Al++]=Fu,Fu=r,Oo=s}function mg(r,s,u){ri[ii++]=Oi,ri[ii++]=Li,ri[ii++]=Vs,Vs=r;var h=Oi;r=Li;var b=32-et(h)-1;h&=~(1<<b),u+=1;var v=32-et(s)+b;if(30<v){var T=b-b%5;v=(h&(1<<T)-1).toString(32),h>>=T,b-=T,Oi=1<<32-et(s)+b|u<<b|h,Li=v+r}else Oi=1<<v|u<<b|h,Li=r}function hh(r){r.return!==null&&(ps(r,1),mg(r,1,0))}function mh(r){for(;r===Fu;)Fu=El[--Al],El[Al]=null,Oo=El[--Al],El[Al]=null;for(;r===Vs;)Vs=ri[--ii],ri[ii]=null,Li=ri[--ii],ri[ii]=null,Oi=ri[--ii],ri[ii]=null}function pg(r,s){ri[ii++]=Oi,ri[ii++]=Li,ri[ii++]=Vs,Oi=s.id,Li=s.overflow,Vs=r}var sr=null,wn=null,Ht=!1,Ws=null,si=!1,ph=Error(i(519));function Gs(r){var s=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Lo(ni(s,r)),ph}function xg(r){var s=r.stateNode,u=r.type,h=r.memoizedProps;switch(s[dt]=r,s[wt]=h,u){case"dialog":Rt("cancel",s),Rt("close",s);break;case"iframe":case"object":case"embed":Rt("load",s);break;case"video":case"audio":for(u=0;u<lc.length;u++)Rt(lc[u],s);break;case"source":Rt("error",s);break;case"img":case"image":case"link":Rt("error",s),Rt("load",s);break;case"details":Rt("toggle",s);break;case"input":Rt("invalid",s),Rr(s,h.value,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name,!0);break;case"select":Rt("invalid",s);break;case"textarea":Rt("invalid",s),uu(s,h.value,h.defaultValue,h.children)}u=h.children,typeof u!="string"&&typeof u!="number"&&typeof u!="bigint"||s.textContent===""+u||h.suppressHydrationWarning===!0||Fy(s.textContent,u)?(h.popover!=null&&(Rt("beforetoggle",s),Rt("toggle",s)),h.onScroll!=null&&Rt("scroll",s),h.onScrollEnd!=null&&Rt("scrollend",s),h.onClick!=null&&(s.onclick=Cn),s=!0):s=!1,s||Gs(r,!0)}function gg(r){for(sr=r.return;sr;)switch(sr.tag){case 5:case 31:case 13:si=!1;return;case 27:case 3:si=!0;return;default:sr=sr.return}}function Dl(r){if(r!==sr)return!1;if(!Ht)return gg(r),Ht=!0,!1;var s=r.tag,u;if((u=s!==3&&s!==27)&&((u=s===5)&&(u=r.type,u=!(u!=="form"&&u!=="button")||Fm(r.type,r.memoizedProps)),u=!u),u&&wn&&Gs(r),gg(r),s===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));wn=Uy(r)}else if(s===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(317));wn=Uy(r)}else s===27?(s=wn,ca(r.type)?(r=Om,Om=null,wn=r):wn=s):wn=sr?li(r.stateNode.nextSibling):null;return!0}function qa(){wn=sr=null,Ht=!1}function xh(){var r=Ws;return r!==null&&(Ar===null?Ar=r:Ar.push.apply(Ar,r),Ws=null),r}function Lo(r){Ws===null?Ws=[r]:Ws.push(r)}var gh=U(null),Ya=null,xs=null;function Ks(r,s,u){O(gh,s._currentValue),s._currentValue=u}function gs(r){r._currentValue=gh.current,P(gh)}function yh(r,s,u){for(;r!==null;){var h=r.alternate;if((r.childLanes&s)!==s?(r.childLanes|=s,h!==null&&(h.childLanes|=s)):h!==null&&(h.childLanes&s)!==s&&(h.childLanes|=s),r===u)break;r=r.return}}function bh(r,s,u,h){var b=r.child;for(b!==null&&(b.return=r);b!==null;){var v=b.dependencies;if(v!==null){var T=b.child;v=v.firstContext;e:for(;v!==null;){var Y=v;v=b;for(var ne=0;ne<s.length;ne++)if(Y.context===s[ne]){v.lanes|=u,Y=v.alternate,Y!==null&&(Y.lanes|=u),yh(v.return,u,r),h||(T=null);break e}v=Y.next}}else if(b.tag===18){if(T=b.return,T===null)throw Error(i(341));T.lanes|=u,v=T.alternate,v!==null&&(v.lanes|=u),yh(T,u,r),T=null}else T=b.child;if(T!==null)T.return=b;else for(T=b;T!==null;){if(T===r){T=null;break}if(b=T.sibling,b!==null){b.return=T.return,T=b;break}T=T.return}b=T}}function Tl(r,s,u,h){r=null;for(var b=s,v=!1;b!==null;){if(!v){if((b.flags&524288)!==0)v=!0;else if((b.flags&262144)!==0)break}if(b.tag===10){var T=b.alternate;if(T===null)throw Error(i(387));if(T=T.memoizedProps,T!==null){var Y=b.type;Br(b.pendingProps.value,T.value)||(r!==null?r.push(Y):r=[Y])}}else if(b===se.current){if(T=b.alternate,T===null)throw Error(i(387));T.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(r!==null?r.push(fc):r=[fc])}b=b.return}r!==null&&bh(s,r,u,h),s.flags|=262144}function Ru(r){for(r=r.firstContext;r!==null;){if(!Br(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Pa(r){Ya=r,xs=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function ar(r){return yg(Ya,r)}function zu(r,s){return Ya===null&&Pa(r),yg(r,s)}function yg(r,s){var u=s._currentValue;if(s={context:s,memoizedValue:u,next:null},xs===null){if(r===null)throw Error(i(308));xs=s,r.dependencies={lanes:0,firstContext:s},r.flags|=524288}else xs=xs.next=s;return u}var mS=typeof AbortController<"u"?AbortController:function(){var r=[],s=this.signal={aborted:!1,addEventListener:function(u,h){r.push(h)}};this.abort=function(){s.aborted=!0,r.forEach(function(u){return u()})}},pS=e.unstable_scheduleCallback,xS=e.unstable_NormalPriority,On={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function vh(){return{controller:new mS,data:new Map,refCount:0}}function Io(r){r.refCount--,r.refCount===0&&pS(xS,function(){r.controller.abort()})}var Ho=null,wh=0,_l=0,Ml=null;function gS(r,s){if(Ho===null){var u=Ho=[];wh=0,_l=jm(),Ml={status:"pending",value:void 0,then:function(h){u.push(h)}}}return wh++,s.then(bg,bg),s}function bg(){if(--wh===0&&Ho!==null){Ml!==null&&(Ml.status="fulfilled");var r=Ho;Ho=null,_l=0,Ml=null;for(var s=0;s<r.length;s++)(0,r[s])()}}function yS(r,s){var u=[],h={status:"pending",value:null,reason:null,then:function(b){u.push(b)}};return r.then(function(){h.status="fulfilled",h.value=s;for(var b=0;b<u.length;b++)(0,u[b])(s)},function(b){for(h.status="rejected",h.reason=b,b=0;b<u.length;b++)(0,u[b])(void 0)}),h}var vg=$.S;$.S=function(r,s){ry=ve(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&gS(r,s),vg!==null&&vg(r,s)};var Xa=U(null);function kh(){var r=Xa.current;return r!==null?r:xn.pooledCache}function Bu(r,s){s===null?O(Xa,Xa.current):O(Xa,s.pool)}function wg(){var r=kh();return r===null?null:{parent:On._currentValue,pool:r}}var Fl=Error(i(460)),Sh=Error(i(474)),$u=Error(i(542)),Ou={then:function(){}};function kg(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Sg(r,s,u){switch(u=r[u],u===void 0?r.push(s):u!==s&&(s.then(Cn,Cn),s=u),s.status){case"fulfilled":return s.value;case"rejected":throw r=s.reason,Cg(r),r;default:if(typeof s.status=="string")s.then(Cn,Cn);else{if(r=xn,r!==null&&100<r.shellSuspendCounter)throw Error(i(482));r=s,r.status="pending",r.then(function(h){if(s.status==="pending"){var b=s;b.status="fulfilled",b.value=h}},function(h){if(s.status==="pending"){var b=s;b.status="rejected",b.reason=h}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw r=s.reason,Cg(r),r}throw Wa=s,Fl}}function Va(r){try{var s=r._init;return s(r._payload)}catch(u){throw u!==null&&typeof u=="object"&&typeof u.then=="function"?(Wa=u,Fl):u}}var Wa=null;function jg(){if(Wa===null)throw Error(i(459));var r=Wa;return Wa=null,r}function Cg(r){if(r===Fl||r===$u)throw Error(i(483))}var Rl=null,Uo=0;function Lu(r){var s=Uo;return Uo+=1,Rl===null&&(Rl=[]),Sg(Rl,r,s)}function qo(r,s){s=s.props.ref,r.ref=s!==void 0?s:null}function Iu(r,s){throw s.$$typeof===y?Error(i(525)):(r=Object.prototype.toString.call(s),Error(i(31,r==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":r)))}function Ng(r){function s(ue,ie){if(r){var fe=ue.deletions;fe===null?(ue.deletions=[ie],ue.flags|=16):fe.push(ie)}}function u(ue,ie){if(!r)return null;for(;ie!==null;)s(ue,ie),ie=ie.sibling;return null}function h(ue){for(var ie=new Map;ue!==null;)ue.key!==null?ie.set(ue.key,ue):ie.set(ue.index,ue),ue=ue.sibling;return ie}function b(ue,ie){return ue=ms(ue,ie),ue.index=0,ue.sibling=null,ue}function v(ue,ie,fe){return ue.index=fe,r?(fe=ue.alternate,fe!==null?(fe=fe.index,fe<ie?(ue.flags|=67108866,ie):fe):(ue.flags|=67108866,ie)):(ue.flags|=1048576,ie)}function T(ue){return r&&ue.alternate===null&&(ue.flags|=67108866),ue}function Y(ue,ie,fe,Ae){return ie===null||ie.tag!==6?(ie=dh(fe,ue.mode,Ae),ie.return=ue,ie):(ie=b(ie,fe),ie.return=ue,ie)}function ne(ue,ie,fe,Ae){var lt=fe.type;return lt===k?je(ue,ie,fe.props.children,Ae,fe.key):ie!==null&&(ie.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===q&&Va(lt)===ie.type)?(ie=b(ie,fe.props),qo(ie,fe),ie.return=ue,ie):(ie=Mu(fe.type,fe.key,fe.props,null,ue.mode,Ae),qo(ie,fe),ie.return=ue,ie)}function he(ue,ie,fe,Ae){return ie===null||ie.tag!==4||ie.stateNode.containerInfo!==fe.containerInfo||ie.stateNode.implementation!==fe.implementation?(ie=fh(fe,ue.mode,Ae),ie.return=ue,ie):(ie=b(ie,fe.children||[]),ie.return=ue,ie)}function je(ue,ie,fe,Ae,lt){return ie===null||ie.tag!==7?(ie=Ua(fe,ue.mode,Ae,lt),ie.return=ue,ie):(ie=b(ie,fe),ie.return=ue,ie)}function _e(ue,ie,fe){if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return ie=dh(""+ie,ue.mode,fe),ie.return=ue,ie;if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case g:return fe=Mu(ie.type,ie.key,ie.props,null,ue.mode,fe),qo(fe,ie),fe.return=ue,fe;case w:return ie=fh(ie,ue.mode,fe),ie.return=ue,ie;case q:return ie=Va(ie),_e(ue,ie,fe)}if(H(ie)||B(ie))return ie=Ua(ie,ue.mode,fe,null),ie.return=ue,ie;if(typeof ie.then=="function")return _e(ue,Lu(ie),fe);if(ie.$$typeof===E)return _e(ue,zu(ue,ie),fe);Iu(ue,ie)}return null}function xe(ue,ie,fe,Ae){var lt=ie!==null?ie.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return lt!==null?null:Y(ue,ie,""+fe,Ae);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case g:return fe.key===lt?ne(ue,ie,fe,Ae):null;case w:return fe.key===lt?he(ue,ie,fe,Ae):null;case q:return fe=Va(fe),xe(ue,ie,fe,Ae)}if(H(fe)||B(fe))return lt!==null?null:je(ue,ie,fe,Ae,null);if(typeof fe.then=="function")return xe(ue,ie,Lu(fe),Ae);if(fe.$$typeof===E)return xe(ue,ie,zu(ue,fe),Ae);Iu(ue,fe)}return null}function ge(ue,ie,fe,Ae,lt){if(typeof Ae=="string"&&Ae!==""||typeof Ae=="number"||typeof Ae=="bigint")return ue=ue.get(fe)||null,Y(ie,ue,""+Ae,lt);if(typeof Ae=="object"&&Ae!==null){switch(Ae.$$typeof){case g:return ue=ue.get(Ae.key===null?fe:Ae.key)||null,ne(ie,ue,Ae,lt);case w:return ue=ue.get(Ae.key===null?fe:Ae.key)||null,he(ie,ue,Ae,lt);case q:return Ae=Va(Ae),ge(ue,ie,fe,Ae,lt)}if(H(Ae)||B(Ae))return ue=ue.get(fe)||null,je(ie,ue,Ae,lt,null);if(typeof Ae.then=="function")return ge(ue,ie,fe,Lu(Ae),lt);if(Ae.$$typeof===E)return ge(ue,ie,fe,zu(ie,Ae),lt);Iu(ie,Ae)}return null}function Qe(ue,ie,fe,Ae){for(var lt=null,Vt=null,tt=ie,Et=ie=0,Lt=null;tt!==null&&Et<fe.length;Et++){tt.index>Et?(Lt=tt,tt=null):Lt=tt.sibling;var Wt=xe(ue,tt,fe[Et],Ae);if(Wt===null){tt===null&&(tt=Lt);break}r&&tt&&Wt.alternate===null&&s(ue,tt),ie=v(Wt,ie,Et),Vt===null?lt=Wt:Vt.sibling=Wt,Vt=Wt,tt=Lt}if(Et===fe.length)return u(ue,tt),Ht&&ps(ue,Et),lt;if(tt===null){for(;Et<fe.length;Et++)tt=_e(ue,fe[Et],Ae),tt!==null&&(ie=v(tt,ie,Et),Vt===null?lt=tt:Vt.sibling=tt,Vt=tt);return Ht&&ps(ue,Et),lt}for(tt=h(tt);Et<fe.length;Et++)Lt=ge(tt,ue,Et,fe[Et],Ae),Lt!==null&&(r&&Lt.alternate!==null&&tt.delete(Lt.key===null?Et:Lt.key),ie=v(Lt,ie,Et),Vt===null?lt=Lt:Vt.sibling=Lt,Vt=Lt);return r&&tt.forEach(function(ma){return s(ue,ma)}),Ht&&ps(ue,Et),lt}function pt(ue,ie,fe,Ae){if(fe==null)throw Error(i(151));for(var lt=null,Vt=null,tt=ie,Et=ie=0,Lt=null,Wt=fe.next();tt!==null&&!Wt.done;Et++,Wt=fe.next()){tt.index>Et?(Lt=tt,tt=null):Lt=tt.sibling;var ma=xe(ue,tt,Wt.value,Ae);if(ma===null){tt===null&&(tt=Lt);break}r&&tt&&ma.alternate===null&&s(ue,tt),ie=v(ma,ie,Et),Vt===null?lt=ma:Vt.sibling=ma,Vt=ma,tt=Lt}if(Wt.done)return u(ue,tt),Ht&&ps(ue,Et),lt;if(tt===null){for(;!Wt.done;Et++,Wt=fe.next())Wt=_e(ue,Wt.value,Ae),Wt!==null&&(ie=v(Wt,ie,Et),Vt===null?lt=Wt:Vt.sibling=Wt,Vt=Wt);return Ht&&ps(ue,Et),lt}for(tt=h(tt);!Wt.done;Et++,Wt=fe.next())Wt=ge(tt,ue,Et,Wt.value,Ae),Wt!==null&&(r&&Wt.alternate!==null&&tt.delete(Wt.key===null?Et:Wt.key),ie=v(Wt,ie,Et),Vt===null?lt=Wt:Vt.sibling=Wt,Vt=Wt);return r&&tt.forEach(function(D4){return s(ue,D4)}),Ht&&ps(ue,Et),lt}function dn(ue,ie,fe,Ae){if(typeof fe=="object"&&fe!==null&&fe.type===k&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case g:e:{for(var lt=fe.key;ie!==null;){if(ie.key===lt){if(lt=fe.type,lt===k){if(ie.tag===7){u(ue,ie.sibling),Ae=b(ie,fe.props.children),Ae.return=ue,ue=Ae;break e}}else if(ie.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===q&&Va(lt)===ie.type){u(ue,ie.sibling),Ae=b(ie,fe.props),qo(Ae,fe),Ae.return=ue,ue=Ae;break e}u(ue,ie);break}else s(ue,ie);ie=ie.sibling}fe.type===k?(Ae=Ua(fe.props.children,ue.mode,Ae,fe.key),Ae.return=ue,ue=Ae):(Ae=Mu(fe.type,fe.key,fe.props,null,ue.mode,Ae),qo(Ae,fe),Ae.return=ue,ue=Ae)}return T(ue);case w:e:{for(lt=fe.key;ie!==null;){if(ie.key===lt)if(ie.tag===4&&ie.stateNode.containerInfo===fe.containerInfo&&ie.stateNode.implementation===fe.implementation){u(ue,ie.sibling),Ae=b(ie,fe.children||[]),Ae.return=ue,ue=Ae;break e}else{u(ue,ie);break}else s(ue,ie);ie=ie.sibling}Ae=fh(fe,ue.mode,Ae),Ae.return=ue,ue=Ae}return T(ue);case q:return fe=Va(fe),dn(ue,ie,fe,Ae)}if(H(fe))return Qe(ue,ie,fe,Ae);if(B(fe)){if(lt=B(fe),typeof lt!="function")throw Error(i(150));return fe=lt.call(fe),pt(ue,ie,fe,Ae)}if(typeof fe.then=="function")return dn(ue,ie,Lu(fe),Ae);if(fe.$$typeof===E)return dn(ue,ie,zu(ue,fe),Ae);Iu(ue,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint"?(fe=""+fe,ie!==null&&ie.tag===6?(u(ue,ie.sibling),Ae=b(ie,fe),Ae.return=ue,ue=Ae):(u(ue,ie),Ae=dh(fe,ue.mode,Ae),Ae.return=ue,ue=Ae),T(ue)):u(ue,ie)}return function(ue,ie,fe,Ae){try{Uo=0;var lt=dn(ue,ie,fe,Ae);return Rl=null,lt}catch(tt){if(tt===Fl||tt===$u)throw tt;var Vt=$r(29,tt,null,ue.mode);return Vt.lanes=Ae,Vt.return=ue,Vt}finally{}}}var Ga=Ng(!0),Eg=Ng(!1),Qs=!1;function jh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ch(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Zs(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function Js(r,s,u){var h=r.updateQueue;if(h===null)return null;if(h=h.shared,(Kt&2)!==0){var b=h.pending;return b===null?s.next=s:(s.next=b.next,b.next=s),h.pending=s,s=_u(r),ug(r,null,u),s}return Tu(r,h,s,u),_u(r)}function Yo(r,s,u){if(s=s.updateQueue,s!==null&&(s=s.shared,(u&4194048)!==0)){var h=s.lanes;h&=r.pendingLanes,u|=h,s.lanes=u,nn(r,u)}}function Nh(r,s){var u=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,u===h)){var b=null,v=null;if(u=u.firstBaseUpdate,u!==null){do{var T={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};v===null?b=v=T:v=v.next=T,u=u.next}while(u!==null);v===null?b=v=s:v=v.next=s}else b=v=s;u={baseState:h.baseState,firstBaseUpdate:b,lastBaseUpdate:v,shared:h.shared,callbacks:h.callbacks},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=s:r.next=s,u.lastBaseUpdate=s}var Eh=!1;function Po(){if(Eh){var r=Ml;if(r!==null)throw r}}function Xo(r,s,u,h){Eh=!1;var b=r.updateQueue;Qs=!1;var v=b.firstBaseUpdate,T=b.lastBaseUpdate,Y=b.shared.pending;if(Y!==null){b.shared.pending=null;var ne=Y,he=ne.next;ne.next=null,T===null?v=he:T.next=he,T=ne;var je=r.alternate;je!==null&&(je=je.updateQueue,Y=je.lastBaseUpdate,Y!==T&&(Y===null?je.firstBaseUpdate=he:Y.next=he,je.lastBaseUpdate=ne))}if(v!==null){var _e=b.baseState;T=0,je=he=ne=null,Y=v;do{var xe=Y.lane&-536870913,ge=xe!==Y.lane;if(ge?(Ot&xe)===xe:(h&xe)===xe){xe!==0&&xe===_l&&(Eh=!0),je!==null&&(je=je.next={lane:0,tag:Y.tag,payload:Y.payload,callback:null,next:null});e:{var Qe=r,pt=Y;xe=s;var dn=u;switch(pt.tag){case 1:if(Qe=pt.payload,typeof Qe=="function"){_e=Qe.call(dn,_e,xe);break e}_e=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=pt.payload,xe=typeof Qe=="function"?Qe.call(dn,_e,xe):Qe,xe==null)break e;_e=p({},_e,xe);break e;case 2:Qs=!0}}xe=Y.callback,xe!==null&&(r.flags|=64,ge&&(r.flags|=8192),ge=b.callbacks,ge===null?b.callbacks=[xe]:ge.push(xe))}else ge={lane:xe,tag:Y.tag,payload:Y.payload,callback:Y.callback,next:null},je===null?(he=je=ge,ne=_e):je=je.next=ge,T|=xe;if(Y=Y.next,Y===null){if(Y=b.shared.pending,Y===null)break;ge=Y,Y=ge.next,ge.next=null,b.lastBaseUpdate=ge,b.shared.pending=null}}while(!0);je===null&&(ne=_e),b.baseState=ne,b.firstBaseUpdate=he,b.lastBaseUpdate=je,v===null&&(b.shared.lanes=0),ia|=T,r.lanes=T,r.memoizedState=_e}}function Ag(r,s){if(typeof r!="function")throw Error(i(191,r));r.call(s)}function Dg(r,s){var u=r.callbacks;if(u!==null)for(r.callbacks=null,r=0;r<u.length;r++)Ag(u[r],s)}var zl=U(null),Hu=U(0);function Tg(r,s){r=Ns,O(Hu,r),O(zl,s),Ns=r|s.baseLanes}function Ah(){O(Hu,Ns),O(zl,zl.current)}function Dh(){Ns=Hu.current,P(zl),P(Hu)}var Or=U(null),ai=null;function ea(r){var s=r.alternate;O(zn,zn.current&1),O(Or,r),ai===null&&(s===null||zl.current!==null||s.memoizedState!==null)&&(ai=r)}function Th(r){O(zn,zn.current),O(Or,r),ai===null&&(ai=r)}function _g(r){r.tag===22?(O(zn,zn.current),O(Or,r),ai===null&&(ai=r)):ta()}function ta(){O(zn,zn.current),O(Or,Or.current)}function Lr(r){P(Or),ai===r&&(ai=null),P(zn)}var zn=U(0);function Uu(r){for(var s=r;s!==null;){if(s.tag===13){var u=s.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||Bm(u)||$m(u)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break;for(;s.sibling===null;){if(s.return===null||s.return===r)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var ys=0,Nt=null,cn=null,Ln=null,qu=!1,Bl=!1,Ka=!1,Yu=0,Vo=0,$l=null,bS=0;function Fn(){throw Error(i(321))}function _h(r,s){if(s===null)return!1;for(var u=0;u<s.length&&u<r.length;u++)if(!Br(r[u],s[u]))return!1;return!0}function Mh(r,s,u,h,b,v){return ys=v,Nt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,$.H=r===null||r.memoizedState===null?m1:Vh,Ka=!1,v=u(h,b),Ka=!1,Bl&&(v=Fg(s,u,h,b)),Mg(r),v}function Mg(r){$.H=Ko;var s=cn!==null&&cn.next!==null;if(ys=0,Ln=cn=Nt=null,qu=!1,Vo=0,$l=null,s)throw Error(i(300));r===null||In||(r=r.dependencies,r!==null&&Ru(r)&&(In=!0))}function Fg(r,s,u,h){Nt=r;var b=0;do{if(Bl&&($l=null),Vo=0,Bl=!1,25<=b)throw Error(i(301));if(b+=1,Ln=cn=null,r.updateQueue!=null){var v=r.updateQueue;v.lastEffect=null,v.events=null,v.stores=null,v.memoCache!=null&&(v.memoCache.index=0)}$.H=p1,v=s(u,h)}while(Bl);return v}function vS(){var r=$.H,s=r.useState()[0];return s=typeof s.then=="function"?Wo(s):s,r=r.useState()[0],(cn!==null?cn.memoizedState:null)!==r&&(Nt.flags|=1024),s}function Fh(){var r=Yu!==0;return Yu=0,r}function Rh(r,s,u){s.updateQueue=r.updateQueue,s.flags&=-2053,r.lanes&=~u}function zh(r){if(qu){for(r=r.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}qu=!1}ys=0,Ln=cn=Nt=null,Bl=!1,Vo=Yu=0,$l=null}function vr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ln===null?Nt.memoizedState=Ln=r:Ln=Ln.next=r,Ln}function Bn(){if(cn===null){var r=Nt.alternate;r=r!==null?r.memoizedState:null}else r=cn.next;var s=Ln===null?Nt.memoizedState:Ln.next;if(s!==null)Ln=s,cn=r;else{if(r===null)throw Nt.alternate===null?Error(i(467)):Error(i(310));cn=r,r={memoizedState:cn.memoizedState,baseState:cn.baseState,baseQueue:cn.baseQueue,queue:cn.queue,next:null},Ln===null?Nt.memoizedState=Ln=r:Ln=Ln.next=r}return Ln}function Pu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Wo(r){var s=Vo;return Vo+=1,$l===null&&($l=[]),r=Sg($l,r,s),s=Nt,(Ln===null?s.memoizedState:Ln.next)===null&&(s=s.alternate,$.H=s===null||s.memoizedState===null?m1:Vh),r}function Xu(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Wo(r);if(r.$$typeof===E)return ar(r)}throw Error(i(438,String(r)))}function Bh(r){var s=null,u=Nt.updateQueue;if(u!==null&&(s=u.memoCache),s==null){var h=Nt.alternate;h!==null&&(h=h.updateQueue,h!==null&&(h=h.memoCache,h!=null&&(s={data:h.data.map(function(b){return b.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),u===null&&(u=Pu(),Nt.updateQueue=u),u.memoCache=s,u=s.data[s.index],u===void 0)for(u=s.data[s.index]=Array(r),h=0;h<r;h++)u[h]=L;return s.index++,u}function bs(r,s){return typeof s=="function"?s(r):s}function Vu(r){var s=Bn();return $h(s,cn,r)}function $h(r,s,u){var h=r.queue;if(h===null)throw Error(i(311));h.lastRenderedReducer=u;var b=r.baseQueue,v=h.pending;if(v!==null){if(b!==null){var T=b.next;b.next=v.next,v.next=T}s.baseQueue=b=v,h.pending=null}if(v=r.baseState,b===null)r.memoizedState=v;else{s=b.next;var Y=T=null,ne=null,he=s,je=!1;do{var _e=he.lane&-536870913;if(_e!==he.lane?(Ot&_e)===_e:(ys&_e)===_e){var xe=he.revertLane;if(xe===0)ne!==null&&(ne=ne.next={lane:0,revertLane:0,gesture:null,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),_e===_l&&(je=!0);else if((ys&xe)===xe){he=he.next,xe===_l&&(je=!0);continue}else _e={lane:0,revertLane:he.revertLane,gesture:null,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null},ne===null?(Y=ne=_e,T=v):ne=ne.next=_e,Nt.lanes|=xe,ia|=xe;_e=he.action,Ka&&u(v,_e),v=he.hasEagerState?he.eagerState:u(v,_e)}else xe={lane:_e,revertLane:he.revertLane,gesture:he.gesture,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null},ne===null?(Y=ne=xe,T=v):ne=ne.next=xe,Nt.lanes|=_e,ia|=_e;he=he.next}while(he!==null&&he!==s);if(ne===null?T=v:ne.next=Y,!Br(v,r.memoizedState)&&(In=!0,je&&(u=Ml,u!==null)))throw u;r.memoizedState=v,r.baseState=T,r.baseQueue=ne,h.lastRenderedState=v}return b===null&&(h.lanes=0),[r.memoizedState,h.dispatch]}function Oh(r){var s=Bn(),u=s.queue;if(u===null)throw Error(i(311));u.lastRenderedReducer=r;var h=u.dispatch,b=u.pending,v=s.memoizedState;if(b!==null){u.pending=null;var T=b=b.next;do v=r(v,T.action),T=T.next;while(T!==b);Br(v,s.memoizedState)||(In=!0),s.memoizedState=v,s.baseQueue===null&&(s.baseState=v),u.lastRenderedState=v}return[v,h]}function Rg(r,s,u){var h=Nt,b=Bn(),v=Ht;if(v){if(u===void 0)throw Error(i(407));u=u()}else u=s();var T=!Br((cn||b).memoizedState,u);if(T&&(b.memoizedState=u,In=!0),b=b.queue,Hh($g.bind(null,h,b,r),[r]),b.getSnapshot!==s||T||Ln!==null&&Ln.memoizedState.tag&1){if(h.flags|=2048,Ol(9,{destroy:void 0},Bg.bind(null,h,b,u,s),null),xn===null)throw Error(i(349));v||(ys&127)!==0||zg(h,s,u)}return u}function zg(r,s,u){r.flags|=16384,r={getSnapshot:s,value:u},s=Nt.updateQueue,s===null?(s=Pu(),Nt.updateQueue=s,s.stores=[r]):(u=s.stores,u===null?s.stores=[r]:u.push(r))}function Bg(r,s,u,h){s.value=u,s.getSnapshot=h,Og(s)&&Lg(r)}function $g(r,s,u){return u(function(){Og(s)&&Lg(r)})}function Og(r){var s=r.getSnapshot;r=r.value;try{var u=s();return!Br(r,u)}catch{return!0}}function Lg(r){var s=Ha(r,2);s!==null&&Dr(s,r,2)}function Lh(r){var s=vr();if(typeof r=="function"){var u=r;if(r=u(),Ka){Xe(!0);try{u()}finally{Xe(!1)}}}return s.memoizedState=s.baseState=r,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bs,lastRenderedState:r},s}function Ig(r,s,u,h){return r.baseState=u,$h(r,cn,typeof h=="function"?h:bs)}function wS(r,s,u,h,b){if(Ku(r))throw Error(i(485));if(r=s.action,r!==null){var v={payload:b,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(T){v.listeners.push(T)}};$.T!==null?u(!0):v.isTransition=!1,h(v),u=s.pending,u===null?(v.next=s.pending=v,Hg(s,v)):(v.next=u.next,s.pending=u.next=v)}}function Hg(r,s){var u=s.action,h=s.payload,b=r.state;if(s.isTransition){var v=$.T,T={};$.T=T;try{var Y=u(b,h),ne=$.S;ne!==null&&ne(T,Y),Ug(r,s,Y)}catch(he){Ih(r,s,he)}finally{v!==null&&T.types!==null&&(v.types=T.types),$.T=v}}else try{v=u(b,h),Ug(r,s,v)}catch(he){Ih(r,s,he)}}function Ug(r,s,u){u!==null&&typeof u=="object"&&typeof u.then=="function"?u.then(function(h){qg(r,s,h)},function(h){return Ih(r,s,h)}):qg(r,s,u)}function qg(r,s,u){s.status="fulfilled",s.value=u,Yg(s),r.state=u,s=r.pending,s!==null&&(u=s.next,u===s?r.pending=null:(u=u.next,s.next=u,Hg(r,u)))}function Ih(r,s,u){var h=r.pending;if(r.pending=null,h!==null){h=h.next;do s.status="rejected",s.reason=u,Yg(s),s=s.next;while(s!==h)}r.action=null}function Yg(r){r=r.listeners;for(var s=0;s<r.length;s++)(0,r[s])()}function Pg(r,s){return s}function Xg(r,s){if(Ht){var u=xn.formState;if(u!==null){e:{var h=Nt;if(Ht){if(wn){t:{for(var b=wn,v=si;b.nodeType!==8;){if(!v){b=null;break t}if(b=li(b.nextSibling),b===null){b=null;break t}}v=b.data,b=v==="F!"||v==="F"?b:null}if(b){wn=li(b.nextSibling),h=b.data==="F!";break e}}Gs(h)}h=!1}h&&(s=u[0])}}return u=vr(),u.memoizedState=u.baseState=s,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Pg,lastRenderedState:s},u.queue=h,u=d1.bind(null,Nt,h),h.dispatch=u,h=Lh(!1),v=Xh.bind(null,Nt,!1,h.queue),h=vr(),b={state:s,dispatch:null,action:r,pending:null},h.queue=b,u=wS.bind(null,Nt,b,v,u),b.dispatch=u,h.memoizedState=r,[s,u,!1]}function Vg(r){var s=Bn();return Wg(s,cn,r)}function Wg(r,s,u){if(s=$h(r,s,Pg)[0],r=Vu(bs)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var h=Wo(s)}catch(T){throw T===Fl?$u:T}else h=s;s=Bn();var b=s.queue,v=b.dispatch;return u!==s.memoizedState&&(Nt.flags|=2048,Ol(9,{destroy:void 0},kS.bind(null,b,u),null)),[h,v,r]}function kS(r,s){r.action=s}function Gg(r){var s=Bn(),u=cn;if(u!==null)return Wg(s,u,r);Bn(),s=s.memoizedState,u=Bn();var h=u.queue.dispatch;return u.memoizedState=r,[s,h,!1]}function Ol(r,s,u,h){return r={tag:r,create:u,deps:h,inst:s,next:null},s=Nt.updateQueue,s===null&&(s=Pu(),Nt.updateQueue=s),u=s.lastEffect,u===null?s.lastEffect=r.next=r:(h=u.next,u.next=r,r.next=h,s.lastEffect=r),r}function Kg(){return Bn().memoizedState}function Wu(r,s,u,h){var b=vr();Nt.flags|=r,b.memoizedState=Ol(1|s,{destroy:void 0},u,h===void 0?null:h)}function Gu(r,s,u,h){var b=Bn();h=h===void 0?null:h;var v=b.memoizedState.inst;cn!==null&&h!==null&&_h(h,cn.memoizedState.deps)?b.memoizedState=Ol(s,v,u,h):(Nt.flags|=r,b.memoizedState=Ol(1|s,v,u,h))}function Qg(r,s){Wu(8390656,8,r,s)}function Hh(r,s){Gu(2048,8,r,s)}function SS(r){Nt.flags|=4;var s=Nt.updateQueue;if(s===null)s=Pu(),Nt.updateQueue=s,s.events=[r];else{var u=s.events;u===null?s.events=[r]:u.push(r)}}function Zg(r){var s=Bn().memoizedState;return SS({ref:s,nextImpl:r}),function(){if((Kt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}function Jg(r,s){return Gu(4,2,r,s)}function e1(r,s){return Gu(4,4,r,s)}function t1(r,s){if(typeof s=="function"){r=r();var u=s(r);return function(){typeof u=="function"?u():s(null)}}if(s!=null)return r=r(),s.current=r,function(){s.current=null}}function n1(r,s,u){u=u!=null?u.concat([r]):null,Gu(4,4,t1.bind(null,s,r),u)}function Uh(){}function r1(r,s){var u=Bn();s=s===void 0?null:s;var h=u.memoizedState;return s!==null&&_h(s,h[1])?h[0]:(u.memoizedState=[r,s],r)}function i1(r,s){var u=Bn();s=s===void 0?null:s;var h=u.memoizedState;if(s!==null&&_h(s,h[1]))return h[0];if(h=r(),Ka){Xe(!0);try{r()}finally{Xe(!1)}}return u.memoizedState=[h,s],h}function qh(r,s,u){return u===void 0||(ys&1073741824)!==0&&(Ot&261930)===0?r.memoizedState=s:(r.memoizedState=u,r=sy(),Nt.lanes|=r,ia|=r,u)}function s1(r,s,u,h){return Br(u,s)?u:zl.current!==null?(r=qh(r,u,h),Br(r,s)||(In=!0),r):(ys&42)===0||(ys&1073741824)!==0&&(Ot&261930)===0?(In=!0,r.memoizedState=u):(r=sy(),Nt.lanes|=r,ia|=r,s)}function a1(r,s,u,h,b){var v=G.p;G.p=v!==0&&8>v?v:8;var T=$.T,Y={};$.T=Y,Xh(r,!1,s,u);try{var ne=b(),he=$.S;if(he!==null&&he(Y,ne),ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var je=yS(ne,h);Go(r,s,je,Ur(r))}else Go(r,s,h,Ur(r))}catch(_e){Go(r,s,{then:function(){},status:"rejected",reason:_e},Ur())}finally{G.p=v,T!==null&&Y.types!==null&&(T.types=Y.types),$.T=T}}function jS(){}function Yh(r,s,u,h){if(r.tag!==5)throw Error(i(476));var b=l1(r).queue;a1(r,b,s,Q,u===null?jS:function(){return o1(r),u(h)})}function l1(r){var s=r.memoizedState;if(s!==null)return s;s={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bs,lastRenderedState:Q},next:null};var u={};return s.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bs,lastRenderedState:u},next:null},r.memoizedState=s,r=r.alternate,r!==null&&(r.memoizedState=s),s}function o1(r){var s=l1(r);s.next===null&&(s=r.alternate.memoizedState),Go(r,s.next.queue,{},Ur())}function Ph(){return ar(fc)}function c1(){return Bn().memoizedState}function u1(){return Bn().memoizedState}function CS(r){for(var s=r.return;s!==null;){switch(s.tag){case 24:case 3:var u=Ur();r=Zs(u);var h=Js(s,r,u);h!==null&&(Dr(h,s,u),Yo(h,s,u)),s={cache:vh()},r.payload=s;return}s=s.return}}function NS(r,s,u){var h=Ur();u={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Ku(r)?f1(s,u):(u=ch(r,s,u,h),u!==null&&(Dr(u,r,h),h1(u,s,h)))}function d1(r,s,u){var h=Ur();Go(r,s,u,h)}function Go(r,s,u,h){var b={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Ku(r))f1(s,b);else{var v=r.alternate;if(r.lanes===0&&(v===null||v.lanes===0)&&(v=s.lastRenderedReducer,v!==null))try{var T=s.lastRenderedState,Y=v(T,u);if(b.hasEagerState=!0,b.eagerState=Y,Br(Y,T))return Tu(r,s,b,0),xn===null&&Du(),!1}catch{}finally{}if(u=ch(r,s,b,h),u!==null)return Dr(u,r,h),h1(u,s,h),!0}return!1}function Xh(r,s,u,h){if(h={lane:2,revertLane:jm(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Ku(r)){if(s)throw Error(i(479))}else s=ch(r,u,h,2),s!==null&&Dr(s,r,2)}function Ku(r){var s=r.alternate;return r===Nt||s!==null&&s===Nt}function f1(r,s){Bl=qu=!0;var u=r.pending;u===null?s.next=s:(s.next=u.next,u.next=s),r.pending=s}function h1(r,s,u){if((u&4194048)!==0){var h=s.lanes;h&=r.pendingLanes,u|=h,s.lanes=u,nn(r,u)}}var Ko={readContext:ar,use:Xu,useCallback:Fn,useContext:Fn,useEffect:Fn,useImperativeHandle:Fn,useLayoutEffect:Fn,useInsertionEffect:Fn,useMemo:Fn,useReducer:Fn,useRef:Fn,useState:Fn,useDebugValue:Fn,useDeferredValue:Fn,useTransition:Fn,useSyncExternalStore:Fn,useId:Fn,useHostTransitionStatus:Fn,useFormState:Fn,useActionState:Fn,useOptimistic:Fn,useMemoCache:Fn,useCacheRefresh:Fn};Ko.useEffectEvent=Fn;var m1={readContext:ar,use:Xu,useCallback:function(r,s){return vr().memoizedState=[r,s===void 0?null:s],r},useContext:ar,useEffect:Qg,useImperativeHandle:function(r,s,u){u=u!=null?u.concat([r]):null,Wu(4194308,4,t1.bind(null,s,r),u)},useLayoutEffect:function(r,s){return Wu(4194308,4,r,s)},useInsertionEffect:function(r,s){Wu(4,2,r,s)},useMemo:function(r,s){var u=vr();s=s===void 0?null:s;var h=r();if(Ka){Xe(!0);try{r()}finally{Xe(!1)}}return u.memoizedState=[h,s],h},useReducer:function(r,s,u){var h=vr();if(u!==void 0){var b=u(s);if(Ka){Xe(!0);try{u(s)}finally{Xe(!1)}}}else b=s;return h.memoizedState=h.baseState=b,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:b},h.queue=r,r=r.dispatch=NS.bind(null,Nt,r),[h.memoizedState,r]},useRef:function(r){var s=vr();return r={current:r},s.memoizedState=r},useState:function(r){r=Lh(r);var s=r.queue,u=d1.bind(null,Nt,s);return s.dispatch=u,[r.memoizedState,u]},useDebugValue:Uh,useDeferredValue:function(r,s){var u=vr();return qh(u,r,s)},useTransition:function(){var r=Lh(!1);return r=a1.bind(null,Nt,r.queue,!0,!1),vr().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,s,u){var h=Nt,b=vr();if(Ht){if(u===void 0)throw Error(i(407));u=u()}else{if(u=s(),xn===null)throw Error(i(349));(Ot&127)!==0||zg(h,s,u)}b.memoizedState=u;var v={value:u,getSnapshot:s};return b.queue=v,Qg($g.bind(null,h,v,r),[r]),h.flags|=2048,Ol(9,{destroy:void 0},Bg.bind(null,h,v,u,s),null),u},useId:function(){var r=vr(),s=xn.identifierPrefix;if(Ht){var u=Li,h=Oi;u=(h&~(1<<32-et(h)-1)).toString(32)+u,s="_"+s+"R_"+u,u=Yu++,0<u&&(s+="H"+u.toString(32)),s+="_"}else u=bS++,s="_"+s+"r_"+u.toString(32)+"_";return r.memoizedState=s},useHostTransitionStatus:Ph,useFormState:Xg,useActionState:Xg,useOptimistic:function(r){var s=vr();s.memoizedState=s.baseState=r;var u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=u,s=Xh.bind(null,Nt,!0,u),u.dispatch=s,[r,s]},useMemoCache:Bh,useCacheRefresh:function(){return vr().memoizedState=CS.bind(null,Nt)},useEffectEvent:function(r){var s=vr(),u={impl:r};return s.memoizedState=u,function(){if((Kt&2)!==0)throw Error(i(440));return u.impl.apply(void 0,arguments)}}},Vh={readContext:ar,use:Xu,useCallback:r1,useContext:ar,useEffect:Hh,useImperativeHandle:n1,useInsertionEffect:Jg,useLayoutEffect:e1,useMemo:i1,useReducer:Vu,useRef:Kg,useState:function(){return Vu(bs)},useDebugValue:Uh,useDeferredValue:function(r,s){var u=Bn();return s1(u,cn.memoizedState,r,s)},useTransition:function(){var r=Vu(bs)[0],s=Bn().memoizedState;return[typeof r=="boolean"?r:Wo(r),s]},useSyncExternalStore:Rg,useId:c1,useHostTransitionStatus:Ph,useFormState:Vg,useActionState:Vg,useOptimistic:function(r,s){var u=Bn();return Ig(u,cn,r,s)},useMemoCache:Bh,useCacheRefresh:u1};Vh.useEffectEvent=Zg;var p1={readContext:ar,use:Xu,useCallback:r1,useContext:ar,useEffect:Hh,useImperativeHandle:n1,useInsertionEffect:Jg,useLayoutEffect:e1,useMemo:i1,useReducer:Oh,useRef:Kg,useState:function(){return Oh(bs)},useDebugValue:Uh,useDeferredValue:function(r,s){var u=Bn();return cn===null?qh(u,r,s):s1(u,cn.memoizedState,r,s)},useTransition:function(){var r=Oh(bs)[0],s=Bn().memoizedState;return[typeof r=="boolean"?r:Wo(r),s]},useSyncExternalStore:Rg,useId:c1,useHostTransitionStatus:Ph,useFormState:Gg,useActionState:Gg,useOptimistic:function(r,s){var u=Bn();return cn!==null?Ig(u,cn,r,s):(u.baseState=r,[r,u.queue.dispatch])},useMemoCache:Bh,useCacheRefresh:u1};p1.useEffectEvent=Zg;function Wh(r,s,u,h){s=r.memoizedState,u=u(h,s),u=u==null?s:p({},s,u),r.memoizedState=u,r.lanes===0&&(r.updateQueue.baseState=u)}var Gh={enqueueSetState:function(r,s,u){r=r._reactInternals;var h=Ur(),b=Zs(h);b.payload=s,u!=null&&(b.callback=u),s=Js(r,b,h),s!==null&&(Dr(s,r,h),Yo(s,r,h))},enqueueReplaceState:function(r,s,u){r=r._reactInternals;var h=Ur(),b=Zs(h);b.tag=1,b.payload=s,u!=null&&(b.callback=u),s=Js(r,b,h),s!==null&&(Dr(s,r,h),Yo(s,r,h))},enqueueForceUpdate:function(r,s){r=r._reactInternals;var u=Ur(),h=Zs(u);h.tag=2,s!=null&&(h.callback=s),s=Js(r,h,u),s!==null&&(Dr(s,r,u),Yo(s,r,u))}};function x1(r,s,u,h,b,v,T){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(h,v,T):s.prototype&&s.prototype.isPureReactComponent?!Bo(u,h)||!Bo(b,v):!0}function g1(r,s,u,h){r=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(u,h),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(u,h),s.state!==r&&Gh.enqueueReplaceState(s,s.state,null)}function Qa(r,s){var u=s;if("ref"in s){u={};for(var h in s)h!=="ref"&&(u[h]=s[h])}if(r=r.defaultProps){u===s&&(u=p({},u));for(var b in r)u[b]===void 0&&(u[b]=r[b])}return u}function y1(r){Au(r)}function b1(r){console.error(r)}function v1(r){Au(r)}function Qu(r,s){try{var u=r.onUncaughtError;u(s.value,{componentStack:s.stack})}catch(h){setTimeout(function(){throw h})}}function w1(r,s,u){try{var h=r.onCaughtError;h(u.value,{componentStack:u.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function Kh(r,s,u){return u=Zs(u),u.tag=3,u.payload={element:null},u.callback=function(){Qu(r,s)},u}function k1(r){return r=Zs(r),r.tag=3,r}function S1(r,s,u,h){var b=u.type.getDerivedStateFromError;if(typeof b=="function"){var v=h.value;r.payload=function(){return b(v)},r.callback=function(){w1(s,u,h)}}var T=u.stateNode;T!==null&&typeof T.componentDidCatch=="function"&&(r.callback=function(){w1(s,u,h),typeof b!="function"&&(sa===null?sa=new Set([this]):sa.add(this));var Y=h.stack;this.componentDidCatch(h.value,{componentStack:Y!==null?Y:""})})}function ES(r,s,u,h,b){if(u.flags|=32768,h!==null&&typeof h=="object"&&typeof h.then=="function"){if(s=u.alternate,s!==null&&Tl(s,u,b,!0),u=Or.current,u!==null){switch(u.tag){case 31:case 13:return ai===null?cd():u.alternate===null&&Rn===0&&(Rn=3),u.flags&=-257,u.flags|=65536,u.lanes=b,h===Ou?u.flags|=16384:(s=u.updateQueue,s===null?u.updateQueue=new Set([h]):s.add(h),wm(r,h,b)),!1;case 22:return u.flags|=65536,h===Ou?u.flags|=16384:(s=u.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([h])},u.updateQueue=s):(u=s.retryQueue,u===null?s.retryQueue=new Set([h]):u.add(h)),wm(r,h,b)),!1}throw Error(i(435,u.tag))}return wm(r,h,b),cd(),!1}if(Ht)return s=Or.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=b,h!==ph&&(r=Error(i(422),{cause:h}),Lo(ni(r,u)))):(h!==ph&&(s=Error(i(423),{cause:h}),Lo(ni(s,u))),r=r.current.alternate,r.flags|=65536,b&=-b,r.lanes|=b,h=ni(h,u),b=Kh(r.stateNode,h,b),Nh(r,b),Rn!==4&&(Rn=2)),!1;var v=Error(i(520),{cause:h});if(v=ni(v,u),ic===null?ic=[v]:ic.push(v),Rn!==4&&(Rn=2),s===null)return!0;h=ni(h,u),u=s;do{switch(u.tag){case 3:return u.flags|=65536,r=b&-b,u.lanes|=r,r=Kh(u.stateNode,h,r),Nh(u,r),!1;case 1:if(s=u.type,v=u.stateNode,(u.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(sa===null||!sa.has(v))))return u.flags|=65536,b&=-b,u.lanes|=b,b=k1(b),S1(b,r,u,h),Nh(u,b),!1}u=u.return}while(u!==null);return!1}var Qh=Error(i(461)),In=!1;function lr(r,s,u,h){s.child=r===null?Eg(s,null,u,h):Ga(s,r.child,u,h)}function j1(r,s,u,h,b){u=u.render;var v=s.ref;if("ref"in h){var T={};for(var Y in h)Y!=="ref"&&(T[Y]=h[Y])}else T=h;return Pa(s),h=Mh(r,s,u,T,v,b),Y=Fh(),r!==null&&!In?(Rh(r,s,b),vs(r,s,b)):(Ht&&Y&&hh(s),s.flags|=1,lr(r,s,h,b),s.child)}function C1(r,s,u,h,b){if(r===null){var v=u.type;return typeof v=="function"&&!uh(v)&&v.defaultProps===void 0&&u.compare===null?(s.tag=15,s.type=v,N1(r,s,v,h,b)):(r=Mu(u.type,null,h,s,s.mode,b),r.ref=s.ref,r.return=s,s.child=r)}if(v=r.child,!sm(r,b)){var T=v.memoizedProps;if(u=u.compare,u=u!==null?u:Bo,u(T,h)&&r.ref===s.ref)return vs(r,s,b)}return s.flags|=1,r=ms(v,h),r.ref=s.ref,r.return=s,s.child=r}function N1(r,s,u,h,b){if(r!==null){var v=r.memoizedProps;if(Bo(v,h)&&r.ref===s.ref)if(In=!1,s.pendingProps=h=v,sm(r,b))(r.flags&131072)!==0&&(In=!0);else return s.lanes=r.lanes,vs(r,s,b)}return Zh(r,s,u,h,b)}function E1(r,s,u,h){var b=h.children,v=r!==null?r.memoizedState:null;if(r===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),h.mode==="hidden"){if((s.flags&128)!==0){if(v=v!==null?v.baseLanes|u:u,r!==null){for(h=s.child=r.child,b=0;h!==null;)b=b|h.lanes|h.childLanes,h=h.sibling;h=b&~v}else h=0,s.child=null;return A1(r,s,v,u,h)}if((u&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},r!==null&&Bu(s,v!==null?v.cachePool:null),v!==null?Tg(s,v):Ah(),_g(s);else return h=s.lanes=536870912,A1(r,s,v!==null?v.baseLanes|u:u,u,h)}else v!==null?(Bu(s,v.cachePool),Tg(s,v),ta(),s.memoizedState=null):(r!==null&&Bu(s,null),Ah(),ta());return lr(r,s,b,u),s.child}function Qo(r,s){return r!==null&&r.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function A1(r,s,u,h,b){var v=kh();return v=v===null?null:{parent:On._currentValue,pool:v},s.memoizedState={baseLanes:u,cachePool:v},r!==null&&Bu(s,null),Ah(),_g(s),r!==null&&Tl(r,s,h,!0),s.childLanes=b,null}function Zu(r,s){return s=ed({mode:s.mode,children:s.children},r.mode),s.ref=r.ref,r.child=s,s.return=r,s}function D1(r,s,u){return Ga(s,r.child,null,u),r=Zu(s,s.pendingProps),r.flags|=2,Lr(s),s.memoizedState=null,r}function AS(r,s,u){var h=s.pendingProps,b=(s.flags&128)!==0;if(s.flags&=-129,r===null){if(Ht){if(h.mode==="hidden")return r=Zu(s,h),s.lanes=536870912,Qo(null,r);if(Th(s),(r=wn)?(r=Hy(r,si),r=r!==null&&r.data==="&"?r:null,r!==null&&(s.memoizedState={dehydrated:r,treeContext:Vs!==null?{id:Oi,overflow:Li}:null,retryLane:536870912,hydrationErrors:null},u=fg(r),u.return=s,s.child=u,sr=s,wn=null)):r=null,r===null)throw Gs(s);return s.lanes=536870912,null}return Zu(s,h)}var v=r.memoizedState;if(v!==null){var T=v.dehydrated;if(Th(s),b)if(s.flags&256)s.flags&=-257,s=D1(r,s,u);else if(s.memoizedState!==null)s.child=r.child,s.flags|=128,s=null;else throw Error(i(558));else if(In||Tl(r,s,u,!1),b=(u&r.childLanes)!==0,In||b){if(h=xn,h!==null&&(T=Kr(h,u),T!==0&&T!==v.retryLane))throw v.retryLane=T,Ha(r,T),Dr(h,r,T),Qh;cd(),s=D1(r,s,u)}else r=v.treeContext,wn=li(T.nextSibling),sr=s,Ht=!0,Ws=null,si=!1,r!==null&&pg(s,r),s=Zu(s,h),s.flags|=4096;return s}return r=ms(r.child,{mode:h.mode,children:h.children}),r.ref=s.ref,s.child=r,r.return=s,r}function Ju(r,s){var u=s.ref;if(u===null)r!==null&&r.ref!==null&&(s.flags|=4194816);else{if(typeof u!="function"&&typeof u!="object")throw Error(i(284));(r===null||r.ref!==u)&&(s.flags|=4194816)}}function Zh(r,s,u,h,b){return Pa(s),u=Mh(r,s,u,h,void 0,b),h=Fh(),r!==null&&!In?(Rh(r,s,b),vs(r,s,b)):(Ht&&h&&hh(s),s.flags|=1,lr(r,s,u,b),s.child)}function T1(r,s,u,h,b,v){return Pa(s),s.updateQueue=null,u=Fg(s,h,u,b),Mg(r),h=Fh(),r!==null&&!In?(Rh(r,s,v),vs(r,s,v)):(Ht&&h&&hh(s),s.flags|=1,lr(r,s,u,v),s.child)}function _1(r,s,u,h,b){if(Pa(s),s.stateNode===null){var v=Nl,T=u.contextType;typeof T=="object"&&T!==null&&(v=ar(T)),v=new u(h,v),s.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=Gh,s.stateNode=v,v._reactInternals=s,v=s.stateNode,v.props=h,v.state=s.memoizedState,v.refs={},jh(s),T=u.contextType,v.context=typeof T=="object"&&T!==null?ar(T):Nl,v.state=s.memoizedState,T=u.getDerivedStateFromProps,typeof T=="function"&&(Wh(s,u,T,h),v.state=s.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(T=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),T!==v.state&&Gh.enqueueReplaceState(v,v.state,null),Xo(s,h,v,b),Po(),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308),h=!0}else if(r===null){v=s.stateNode;var Y=s.memoizedProps,ne=Qa(u,Y);v.props=ne;var he=v.context,je=u.contextType;T=Nl,typeof je=="object"&&je!==null&&(T=ar(je));var _e=u.getDerivedStateFromProps;je=typeof _e=="function"||typeof v.getSnapshotBeforeUpdate=="function",Y=s.pendingProps!==Y,je||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(Y||he!==T)&&g1(s,v,h,T),Qs=!1;var xe=s.memoizedState;v.state=xe,Xo(s,h,v,b),Po(),he=s.memoizedState,Y||xe!==he||Qs?(typeof _e=="function"&&(Wh(s,u,_e,h),he=s.memoizedState),(ne=Qs||x1(s,u,ne,h,xe,he,T))?(je||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount()),typeof v.componentDidMount=="function"&&(s.flags|=4194308)):(typeof v.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=h,s.memoizedState=he),v.props=h,v.state=he,v.context=T,h=ne):(typeof v.componentDidMount=="function"&&(s.flags|=4194308),h=!1)}else{v=s.stateNode,Ch(r,s),T=s.memoizedProps,je=Qa(u,T),v.props=je,_e=s.pendingProps,xe=v.context,he=u.contextType,ne=Nl,typeof he=="object"&&he!==null&&(ne=ar(he)),Y=u.getDerivedStateFromProps,(he=typeof Y=="function"||typeof v.getSnapshotBeforeUpdate=="function")||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(T!==_e||xe!==ne)&&g1(s,v,h,ne),Qs=!1,xe=s.memoizedState,v.state=xe,Xo(s,h,v,b),Po();var ge=s.memoizedState;T!==_e||xe!==ge||Qs||r!==null&&r.dependencies!==null&&Ru(r.dependencies)?(typeof Y=="function"&&(Wh(s,u,Y,h),ge=s.memoizedState),(je=Qs||x1(s,u,je,h,xe,ge,ne)||r!==null&&r.dependencies!==null&&Ru(r.dependencies))?(he||typeof v.UNSAFE_componentWillUpdate!="function"&&typeof v.componentWillUpdate!="function"||(typeof v.componentWillUpdate=="function"&&v.componentWillUpdate(h,ge,ne),typeof v.UNSAFE_componentWillUpdate=="function"&&v.UNSAFE_componentWillUpdate(h,ge,ne)),typeof v.componentDidUpdate=="function"&&(s.flags|=4),typeof v.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof v.componentDidUpdate!="function"||T===r.memoizedProps&&xe===r.memoizedState||(s.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&xe===r.memoizedState||(s.flags|=1024),s.memoizedProps=h,s.memoizedState=ge),v.props=h,v.state=ge,v.context=ne,h=je):(typeof v.componentDidUpdate!="function"||T===r.memoizedProps&&xe===r.memoizedState||(s.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&xe===r.memoizedState||(s.flags|=1024),h=!1)}return v=h,Ju(r,s),h=(s.flags&128)!==0,v||h?(v=s.stateNode,u=h&&typeof u.getDerivedStateFromError!="function"?null:v.render(),s.flags|=1,r!==null&&h?(s.child=Ga(s,r.child,null,b),s.child=Ga(s,null,u,b)):lr(r,s,u,b),s.memoizedState=v.state,r=s.child):r=vs(r,s,b),r}function M1(r,s,u,h){return qa(),s.flags|=256,lr(r,s,u,h),s.child}var Jh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function em(r){return{baseLanes:r,cachePool:wg()}}function tm(r,s,u){return r=r!==null?r.childLanes&~u:0,s&&(r|=Hr),r}function F1(r,s,u){var h=s.pendingProps,b=!1,v=(s.flags&128)!==0,T;if((T=v)||(T=r!==null&&r.memoizedState===null?!1:(zn.current&2)!==0),T&&(b=!0,s.flags&=-129),T=(s.flags&32)!==0,s.flags&=-33,r===null){if(Ht){if(b?ea(s):ta(),(r=wn)?(r=Hy(r,si),r=r!==null&&r.data!=="&"?r:null,r!==null&&(s.memoizedState={dehydrated:r,treeContext:Vs!==null?{id:Oi,overflow:Li}:null,retryLane:536870912,hydrationErrors:null},u=fg(r),u.return=s,s.child=u,sr=s,wn=null)):r=null,r===null)throw Gs(s);return $m(r)?s.lanes=32:s.lanes=536870912,null}var Y=h.children;return h=h.fallback,b?(ta(),b=s.mode,Y=ed({mode:"hidden",children:Y},b),h=Ua(h,b,u,null),Y.return=s,h.return=s,Y.sibling=h,s.child=Y,h=s.child,h.memoizedState=em(u),h.childLanes=tm(r,T,u),s.memoizedState=Jh,Qo(null,h)):(ea(s),nm(s,Y))}var ne=r.memoizedState;if(ne!==null&&(Y=ne.dehydrated,Y!==null)){if(v)s.flags&256?(ea(s),s.flags&=-257,s=rm(r,s,u)):s.memoizedState!==null?(ta(),s.child=r.child,s.flags|=128,s=null):(ta(),Y=h.fallback,b=s.mode,h=ed({mode:"visible",children:h.children},b),Y=Ua(Y,b,u,null),Y.flags|=2,h.return=s,Y.return=s,h.sibling=Y,s.child=h,Ga(s,r.child,null,u),h=s.child,h.memoizedState=em(u),h.childLanes=tm(r,T,u),s.memoizedState=Jh,s=Qo(null,h));else if(ea(s),$m(Y)){if(T=Y.nextSibling&&Y.nextSibling.dataset,T)var he=T.dgst;T=he,h=Error(i(419)),h.stack="",h.digest=T,Lo({value:h,source:null,stack:null}),s=rm(r,s,u)}else if(In||Tl(r,s,u,!1),T=(u&r.childLanes)!==0,In||T){if(T=xn,T!==null&&(h=Kr(T,u),h!==0&&h!==ne.retryLane))throw ne.retryLane=h,Ha(r,h),Dr(T,r,h),Qh;Bm(Y)||cd(),s=rm(r,s,u)}else Bm(Y)?(s.flags|=192,s.child=r.child,s=null):(r=ne.treeContext,wn=li(Y.nextSibling),sr=s,Ht=!0,Ws=null,si=!1,r!==null&&pg(s,r),s=nm(s,h.children),s.flags|=4096);return s}return b?(ta(),Y=h.fallback,b=s.mode,ne=r.child,he=ne.sibling,h=ms(ne,{mode:"hidden",children:h.children}),h.subtreeFlags=ne.subtreeFlags&65011712,he!==null?Y=ms(he,Y):(Y=Ua(Y,b,u,null),Y.flags|=2),Y.return=s,h.return=s,h.sibling=Y,s.child=h,Qo(null,h),h=s.child,Y=r.child.memoizedState,Y===null?Y=em(u):(b=Y.cachePool,b!==null?(ne=On._currentValue,b=b.parent!==ne?{parent:ne,pool:ne}:b):b=wg(),Y={baseLanes:Y.baseLanes|u,cachePool:b}),h.memoizedState=Y,h.childLanes=tm(r,T,u),s.memoizedState=Jh,Qo(r.child,h)):(ea(s),u=r.child,r=u.sibling,u=ms(u,{mode:"visible",children:h.children}),u.return=s,u.sibling=null,r!==null&&(T=s.deletions,T===null?(s.deletions=[r],s.flags|=16):T.push(r)),s.child=u,s.memoizedState=null,u)}function nm(r,s){return s=ed({mode:"visible",children:s},r.mode),s.return=r,r.child=s}function ed(r,s){return r=$r(22,r,null,s),r.lanes=0,r}function rm(r,s,u){return Ga(s,r.child,null,u),r=nm(s,s.pendingProps.children),r.flags|=2,s.memoizedState=null,r}function R1(r,s,u){r.lanes|=s;var h=r.alternate;h!==null&&(h.lanes|=s),yh(r.return,s,u)}function im(r,s,u,h,b,v){var T=r.memoizedState;T===null?r.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:h,tail:u,tailMode:b,treeForkCount:v}:(T.isBackwards=s,T.rendering=null,T.renderingStartTime=0,T.last=h,T.tail=u,T.tailMode=b,T.treeForkCount=v)}function z1(r,s,u){var h=s.pendingProps,b=h.revealOrder,v=h.tail;h=h.children;var T=zn.current,Y=(T&2)!==0;if(Y?(T=T&1|2,s.flags|=128):T&=1,O(zn,T),lr(r,s,h,u),h=Ht?Oo:0,!Y&&r!==null&&(r.flags&128)!==0)e:for(r=s.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&R1(r,u,s);else if(r.tag===19)R1(r,u,s);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(b){case"forwards":for(u=s.child,b=null;u!==null;)r=u.alternate,r!==null&&Uu(r)===null&&(b=u),u=u.sibling;u=b,u===null?(b=s.child,s.child=null):(b=u.sibling,u.sibling=null),im(s,!1,b,u,v,h);break;case"backwards":case"unstable_legacy-backwards":for(u=null,b=s.child,s.child=null;b!==null;){if(r=b.alternate,r!==null&&Uu(r)===null){s.child=b;break}r=b.sibling,b.sibling=u,u=b,b=r}im(s,!0,u,null,v,h);break;case"together":im(s,!1,null,null,void 0,h);break;default:s.memoizedState=null}return s.child}function vs(r,s,u){if(r!==null&&(s.dependencies=r.dependencies),ia|=s.lanes,(u&s.childLanes)===0)if(r!==null){if(Tl(r,s,u,!1),(u&s.childLanes)===0)return null}else return null;if(r!==null&&s.child!==r.child)throw Error(i(153));if(s.child!==null){for(r=s.child,u=ms(r,r.pendingProps),s.child=u,u.return=s;r.sibling!==null;)r=r.sibling,u=u.sibling=ms(r,r.pendingProps),u.return=s;u.sibling=null}return s.child}function sm(r,s){return(r.lanes&s)!==0?!0:(r=r.dependencies,!!(r!==null&&Ru(r)))}function DS(r,s,u){switch(s.tag){case 3:le(s,s.stateNode.containerInfo),Ks(s,On,r.memoizedState.cache),qa();break;case 27:case 5:De(s);break;case 4:le(s,s.stateNode.containerInfo);break;case 10:Ks(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Th(s),null;break;case 13:var h=s.memoizedState;if(h!==null)return h.dehydrated!==null?(ea(s),s.flags|=128,null):(u&s.child.childLanes)!==0?F1(r,s,u):(ea(s),r=vs(r,s,u),r!==null?r.sibling:null);ea(s);break;case 19:var b=(r.flags&128)!==0;if(h=(u&s.childLanes)!==0,h||(Tl(r,s,u,!1),h=(u&s.childLanes)!==0),b){if(h)return z1(r,s,u);s.flags|=128}if(b=s.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),O(zn,zn.current),h)break;return null;case 22:return s.lanes=0,E1(r,s,u,s.pendingProps);case 24:Ks(s,On,r.memoizedState.cache)}return vs(r,s,u)}function B1(r,s,u){if(r!==null)if(r.memoizedProps!==s.pendingProps)In=!0;else{if(!sm(r,u)&&(s.flags&128)===0)return In=!1,DS(r,s,u);In=(r.flags&131072)!==0}else In=!1,Ht&&(s.flags&1048576)!==0&&mg(s,Oo,s.index);switch(s.lanes=0,s.tag){case 16:e:{var h=s.pendingProps;if(r=Va(s.elementType),s.type=r,typeof r=="function")uh(r)?(h=Qa(r,h),s.tag=1,s=_1(null,s,r,h,u)):(s.tag=0,s=Zh(null,s,r,h,u));else{if(r!=null){var b=r.$$typeof;if(b===A){s.tag=11,s=j1(null,s,r,h,u);break e}else if(b===F){s.tag=14,s=C1(null,s,r,h,u);break e}}throw s=R(r)||r,Error(i(306,s,""))}}return s;case 0:return Zh(r,s,s.type,s.pendingProps,u);case 1:return h=s.type,b=Qa(h,s.pendingProps),_1(r,s,h,b,u);case 3:e:{if(le(s,s.stateNode.containerInfo),r===null)throw Error(i(387));h=s.pendingProps;var v=s.memoizedState;b=v.element,Ch(r,s),Xo(s,h,null,u);var T=s.memoizedState;if(h=T.cache,Ks(s,On,h),h!==v.cache&&bh(s,[On],u,!0),Po(),h=T.element,v.isDehydrated)if(v={element:h,isDehydrated:!1,cache:T.cache},s.updateQueue.baseState=v,s.memoizedState=v,s.flags&256){s=M1(r,s,h,u);break e}else if(h!==b){b=ni(Error(i(424)),s),Lo(b),s=M1(r,s,h,u);break e}else{switch(r=s.stateNode.containerInfo,r.nodeType){case 9:r=r.body;break;default:r=r.nodeName==="HTML"?r.ownerDocument.body:r}for(wn=li(r.firstChild),sr=s,Ht=!0,Ws=null,si=!0,u=Eg(s,null,h,u),s.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling}else{if(qa(),h===b){s=vs(r,s,u);break e}lr(r,s,h,u)}s=s.child}return s;case 26:return Ju(r,s),r===null?(u=Vy(s.type,null,s.pendingProps,null))?s.memoizedState=u:Ht||(u=s.type,r=s.pendingProps,h=xd(J.current).createElement(u),h[dt]=s,h[wt]=r,or(h,u,r),Sn(h),s.stateNode=h):s.memoizedState=Vy(s.type,r.memoizedProps,s.pendingProps,r.memoizedState),null;case 27:return De(s),r===null&&Ht&&(h=s.stateNode=Yy(s.type,s.pendingProps,J.current),sr=s,si=!0,b=wn,ca(s.type)?(Om=b,wn=li(h.firstChild)):wn=b),lr(r,s,s.pendingProps.children,u),Ju(r,s),r===null&&(s.flags|=4194304),s.child;case 5:return r===null&&Ht&&((b=h=wn)&&(h=s4(h,s.type,s.pendingProps,si),h!==null?(s.stateNode=h,sr=s,wn=li(h.firstChild),si=!1,b=!0):b=!1),b||Gs(s)),De(s),b=s.type,v=s.pendingProps,T=r!==null?r.memoizedProps:null,h=v.children,Fm(b,v)?h=null:T!==null&&Fm(b,T)&&(s.flags|=32),s.memoizedState!==null&&(b=Mh(r,s,vS,null,null,u),fc._currentValue=b),Ju(r,s),lr(r,s,h,u),s.child;case 6:return r===null&&Ht&&((r=u=wn)&&(u=a4(u,s.pendingProps,si),u!==null?(s.stateNode=u,sr=s,wn=null,r=!0):r=!1),r||Gs(s)),null;case 13:return F1(r,s,u);case 4:return le(s,s.stateNode.containerInfo),h=s.pendingProps,r===null?s.child=Ga(s,null,h,u):lr(r,s,h,u),s.child;case 11:return j1(r,s,s.type,s.pendingProps,u);case 7:return lr(r,s,s.pendingProps,u),s.child;case 8:return lr(r,s,s.pendingProps.children,u),s.child;case 12:return lr(r,s,s.pendingProps.children,u),s.child;case 10:return h=s.pendingProps,Ks(s,s.type,h.value),lr(r,s,h.children,u),s.child;case 9:return b=s.type._context,h=s.pendingProps.children,Pa(s),b=ar(b),h=h(b),s.flags|=1,lr(r,s,h,u),s.child;case 14:return C1(r,s,s.type,s.pendingProps,u);case 15:return N1(r,s,s.type,s.pendingProps,u);case 19:return z1(r,s,u);case 31:return AS(r,s,u);case 22:return E1(r,s,u,s.pendingProps);case 24:return Pa(s),h=ar(On),r===null?(b=kh(),b===null&&(b=xn,v=vh(),b.pooledCache=v,v.refCount++,v!==null&&(b.pooledCacheLanes|=u),b=v),s.memoizedState={parent:h,cache:b},jh(s),Ks(s,On,b)):((r.lanes&u)!==0&&(Ch(r,s),Xo(s,null,null,u),Po()),b=r.memoizedState,v=s.memoizedState,b.parent!==h?(b={parent:h,cache:h},s.memoizedState=b,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=b),Ks(s,On,h)):(h=v.cache,Ks(s,On,h),h!==b.cache&&bh(s,[On],u,!0))),lr(r,s,s.pendingProps.children,u),s.child;case 29:throw s.pendingProps}throw Error(i(156,s.tag))}function ws(r){r.flags|=4}function am(r,s,u,h,b){if((s=(r.mode&32)!==0)&&(s=!1),s){if(r.flags|=16777216,(b&335544128)===b)if(r.stateNode.complete)r.flags|=8192;else if(cy())r.flags|=8192;else throw Wa=Ou,Sh}else r.flags&=-16777217}function $1(r,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!Zy(s))if(cy())r.flags|=8192;else throw Wa=Ou,Sh}function td(r,s){s!==null&&(r.flags|=4),r.flags&16384&&(s=r.tag!==22?We():536870912,r.lanes|=s,Ul|=s)}function Zo(r,s){if(!Ht)switch(r.tailMode){case"hidden":s=r.tail;for(var u=null;s!==null;)s.alternate!==null&&(u=s),s=s.sibling;u===null?r.tail=null:u.sibling=null;break;case"collapsed":u=r.tail;for(var h=null;u!==null;)u.alternate!==null&&(h=u),u=u.sibling;h===null?s||r.tail===null?r.tail=null:r.tail.sibling=null:h.sibling=null}}function kn(r){var s=r.alternate!==null&&r.alternate.child===r.child,u=0,h=0;if(s)for(var b=r.child;b!==null;)u|=b.lanes|b.childLanes,h|=b.subtreeFlags&65011712,h|=b.flags&65011712,b.return=r,b=b.sibling;else for(b=r.child;b!==null;)u|=b.lanes|b.childLanes,h|=b.subtreeFlags,h|=b.flags,b.return=r,b=b.sibling;return r.subtreeFlags|=h,r.childLanes=u,s}function TS(r,s,u){var h=s.pendingProps;switch(mh(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return kn(s),null;case 1:return kn(s),null;case 3:return u=s.stateNode,h=null,r!==null&&(h=r.memoizedState.cache),s.memoizedState.cache!==h&&(s.flags|=2048),gs(On),ye(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(r===null||r.child===null)&&(Dl(s)?ws(s):r===null||r.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,xh())),kn(s),null;case 26:var b=s.type,v=s.memoizedState;return r===null?(ws(s),v!==null?(kn(s),$1(s,v)):(kn(s),am(s,b,null,h,u))):v?v!==r.memoizedState?(ws(s),kn(s),$1(s,v)):(kn(s),s.flags&=-16777217):(r=r.memoizedProps,r!==h&&ws(s),kn(s),am(s,b,r,h,u)),null;case 27:if(Ee(s),u=J.current,b=s.type,r!==null&&s.stateNode!=null)r.memoizedProps!==h&&ws(s);else{if(!h){if(s.stateNode===null)throw Error(i(166));return kn(s),null}r=Z.current,Dl(s)?xg(s):(r=Yy(b,h,u),s.stateNode=r,ws(s))}return kn(s),null;case 5:if(Ee(s),b=s.type,r!==null&&s.stateNode!=null)r.memoizedProps!==h&&ws(s);else{if(!h){if(s.stateNode===null)throw Error(i(166));return kn(s),null}if(v=Z.current,Dl(s))xg(s);else{var T=xd(J.current);switch(v){case 1:v=T.createElementNS("http://www.w3.org/2000/svg",b);break;case 2:v=T.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;default:switch(b){case"svg":v=T.createElementNS("http://www.w3.org/2000/svg",b);break;case"math":v=T.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;case"script":v=T.createElement("div"),v.innerHTML="<script><\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof h.is=="string"?T.createElement("select",{is:h.is}):T.createElement("select"),h.multiple?v.multiple=!0:h.size&&(v.size=h.size);break;default:v=typeof h.is=="string"?T.createElement(b,{is:h.is}):T.createElement(b)}}v[dt]=s,v[wt]=h;e:for(T=s.child;T!==null;){if(T.tag===5||T.tag===6)v.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===s)break e;for(;T.sibling===null;){if(T.return===null||T.return===s)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}s.stateNode=v;e:switch(or(v,b,h),b){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&ws(s)}}return kn(s),am(s,s.type,r===null?null:r.memoizedProps,s.pendingProps,u),null;case 6:if(r&&s.stateNode!=null)r.memoizedProps!==h&&ws(s);else{if(typeof h!="string"&&s.stateNode===null)throw Error(i(166));if(r=J.current,Dl(s)){if(r=s.stateNode,u=s.memoizedProps,h=null,b=sr,b!==null)switch(b.tag){case 27:case 5:h=b.memoizedProps}r[dt]=s,r=!!(r.nodeValue===u||h!==null&&h.suppressHydrationWarning===!0||Fy(r.nodeValue,u)),r||Gs(s,!0)}else r=xd(r).createTextNode(h),r[dt]=s,s.stateNode=r}return kn(s),null;case 31:if(u=s.memoizedState,r===null||r.memoizedState!==null){if(h=Dl(s),u!==null){if(r===null){if(!h)throw Error(i(318));if(r=s.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[dt]=s}else qa(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;kn(s),r=!1}else u=xh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=u),r=!0;if(!r)return s.flags&256?(Lr(s),s):(Lr(s),null);if((s.flags&128)!==0)throw Error(i(558))}return kn(s),null;case 13:if(h=s.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(b=Dl(s),h!==null&&h.dehydrated!==null){if(r===null){if(!b)throw Error(i(318));if(b=s.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(i(317));b[dt]=s}else qa(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;kn(s),b=!1}else b=xh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=b),b=!0;if(!b)return s.flags&256?(Lr(s),s):(Lr(s),null)}return Lr(s),(s.flags&128)!==0?(s.lanes=u,s):(u=h!==null,r=r!==null&&r.memoizedState!==null,u&&(h=s.child,b=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(b=h.alternate.memoizedState.cachePool.pool),v=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(v=h.memoizedState.cachePool.pool),v!==b&&(h.flags|=2048)),u!==r&&u&&(s.child.flags|=8192),td(s,s.updateQueue),kn(s),null);case 4:return ye(),r===null&&Am(s.stateNode.containerInfo),kn(s),null;case 10:return gs(s.type),kn(s),null;case 19:if(P(zn),h=s.memoizedState,h===null)return kn(s),null;if(b=(s.flags&128)!==0,v=h.rendering,v===null)if(b)Zo(h,!1);else{if(Rn!==0||r!==null&&(r.flags&128)!==0)for(r=s.child;r!==null;){if(v=Uu(r),v!==null){for(s.flags|=128,Zo(h,!1),r=v.updateQueue,s.updateQueue=r,td(s,r),s.subtreeFlags=0,r=u,u=s.child;u!==null;)dg(u,r),u=u.sibling;return O(zn,zn.current&1|2),Ht&&ps(s,h.treeForkCount),s.child}r=r.sibling}h.tail!==null&&ve()>ad&&(s.flags|=128,b=!0,Zo(h,!1),s.lanes=4194304)}else{if(!b)if(r=Uu(v),r!==null){if(s.flags|=128,b=!0,r=r.updateQueue,s.updateQueue=r,td(s,r),Zo(h,!0),h.tail===null&&h.tailMode==="hidden"&&!v.alternate&&!Ht)return kn(s),null}else 2*ve()-h.renderingStartTime>ad&&u!==536870912&&(s.flags|=128,b=!0,Zo(h,!1),s.lanes=4194304);h.isBackwards?(v.sibling=s.child,s.child=v):(r=h.last,r!==null?r.sibling=v:s.child=v,h.last=v)}return h.tail!==null?(r=h.tail,h.rendering=r,h.tail=r.sibling,h.renderingStartTime=ve(),r.sibling=null,u=zn.current,O(zn,b?u&1|2:u&1),Ht&&ps(s,h.treeForkCount),r):(kn(s),null);case 22:case 23:return Lr(s),Dh(),h=s.memoizedState!==null,r!==null?r.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(u&536870912)!==0&&(s.flags&128)===0&&(kn(s),s.subtreeFlags&6&&(s.flags|=8192)):kn(s),u=s.updateQueue,u!==null&&td(s,u.retryQueue),u=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==u&&(s.flags|=2048),r!==null&&P(Xa),null;case 24:return u=null,r!==null&&(u=r.memoizedState.cache),s.memoizedState.cache!==u&&(s.flags|=2048),gs(On),kn(s),null;case 25:return null;case 30:return null}throw Error(i(156,s.tag))}function _S(r,s){switch(mh(s),s.tag){case 1:return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return gs(On),ye(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 26:case 27:case 5:return Ee(s),null;case 31:if(s.memoizedState!==null){if(Lr(s),s.alternate===null)throw Error(i(340));qa()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 13:if(Lr(s),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(i(340));qa()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return P(zn),null;case 4:return ye(),null;case 10:return gs(s.type),null;case 22:case 23:return Lr(s),Dh(),r!==null&&P(Xa),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 24:return gs(On),null;case 25:return null;default:return null}}function O1(r,s){switch(mh(s),s.tag){case 3:gs(On),ye();break;case 26:case 27:case 5:Ee(s);break;case 4:ye();break;case 31:s.memoizedState!==null&&Lr(s);break;case 13:Lr(s);break;case 19:P(zn);break;case 10:gs(s.type);break;case 22:case 23:Lr(s),Dh(),r!==null&&P(Xa);break;case 24:gs(On)}}function Jo(r,s){try{var u=s.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var b=h.next;u=b;do{if((u.tag&r)===r){h=void 0;var v=u.create,T=u.inst;h=v(),T.destroy=h}u=u.next}while(u!==b)}}catch(Y){sn(s,s.return,Y)}}function na(r,s,u){try{var h=s.updateQueue,b=h!==null?h.lastEffect:null;if(b!==null){var v=b.next;h=v;do{if((h.tag&r)===r){var T=h.inst,Y=T.destroy;if(Y!==void 0){T.destroy=void 0,b=s;var ne=u,he=Y;try{he()}catch(je){sn(b,ne,je)}}}h=h.next}while(h!==v)}}catch(je){sn(s,s.return,je)}}function L1(r){var s=r.updateQueue;if(s!==null){var u=r.stateNode;try{Dg(s,u)}catch(h){sn(r,r.return,h)}}}function I1(r,s,u){u.props=Qa(r.type,r.memoizedProps),u.state=r.memoizedState;try{u.componentWillUnmount()}catch(h){sn(r,s,h)}}function ec(r,s){try{var u=r.ref;if(u!==null){switch(r.tag){case 26:case 27:case 5:var h=r.stateNode;break;case 30:h=r.stateNode;break;default:h=r.stateNode}typeof u=="function"?r.refCleanup=u(h):u.current=h}}catch(b){sn(r,s,b)}}function Ii(r,s){var u=r.ref,h=r.refCleanup;if(u!==null)if(typeof h=="function")try{h()}catch(b){sn(r,s,b)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(b){sn(r,s,b)}else u.current=null}function H1(r){var s=r.type,u=r.memoizedProps,h=r.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":u.autoFocus&&h.focus();break e;case"img":u.src?h.src=u.src:u.srcSet&&(h.srcset=u.srcSet)}}catch(b){sn(r,r.return,b)}}function lm(r,s,u){try{var h=r.stateNode;JS(h,r.type,u,s),h[wt]=s}catch(b){sn(r,r.return,b)}}function U1(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&ca(r.type)||r.tag===4}function om(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||U1(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&&ca(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 cm(r,s,u){var h=r.tag;if(h===5||h===6)r=r.stateNode,s?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(r,s):(s=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,s.appendChild(r),u=u._reactRootContainer,u!=null||s.onclick!==null||(s.onclick=Cn));else if(h!==4&&(h===27&&ca(r.type)&&(u=r.stateNode,s=null),r=r.child,r!==null))for(cm(r,s,u),r=r.sibling;r!==null;)cm(r,s,u),r=r.sibling}function nd(r,s,u){var h=r.tag;if(h===5||h===6)r=r.stateNode,s?u.insertBefore(r,s):u.appendChild(r);else if(h!==4&&(h===27&&ca(r.type)&&(u=r.stateNode),r=r.child,r!==null))for(nd(r,s,u),r=r.sibling;r!==null;)nd(r,s,u),r=r.sibling}function q1(r){var s=r.stateNode,u=r.memoizedProps;try{for(var h=r.type,b=s.attributes;b.length;)s.removeAttributeNode(b[0]);or(s,h,u),s[dt]=r,s[wt]=u}catch(v){sn(r,r.return,v)}}var ks=!1,Hn=!1,um=!1,Y1=typeof WeakSet=="function"?WeakSet:Set,er=null;function MS(r,s){if(r=r.containerInfo,_m=Sd,r=ng(r),rh(r)){if("selectionStart"in r)var u={start:r.selectionStart,end:r.selectionEnd};else e:{u=(u=r.ownerDocument)&&u.defaultView||window;var h=u.getSelection&&u.getSelection();if(h&&h.rangeCount!==0){u=h.anchorNode;var b=h.anchorOffset,v=h.focusNode;h=h.focusOffset;try{u.nodeType,v.nodeType}catch{u=null;break e}var T=0,Y=-1,ne=-1,he=0,je=0,_e=r,xe=null;t:for(;;){for(var ge;_e!==u||b!==0&&_e.nodeType!==3||(Y=T+b),_e!==v||h!==0&&_e.nodeType!==3||(ne=T+h),_e.nodeType===3&&(T+=_e.nodeValue.length),(ge=_e.firstChild)!==null;)xe=_e,_e=ge;for(;;){if(_e===r)break t;if(xe===u&&++he===b&&(Y=T),xe===v&&++je===h&&(ne=T),(ge=_e.nextSibling)!==null)break;_e=xe,xe=_e.parentNode}_e=ge}u=Y===-1||ne===-1?null:{start:Y,end:ne}}else u=null}u=u||{start:0,end:0}}else u=null;for(Mm={focusedElem:r,selectionRange:u},Sd=!1,er=s;er!==null;)if(s=er,r=s.child,(s.subtreeFlags&1028)!==0&&r!==null)r.return=s,er=r;else for(;er!==null;){switch(s=er,v=s.alternate,r=s.flags,s.tag){case 0:if((r&4)!==0&&(r=s.updateQueue,r=r!==null?r.events:null,r!==null))for(u=0;u<r.length;u++)b=r[u],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&v!==null){r=void 0,u=s,b=v.memoizedProps,v=v.memoizedState,h=u.stateNode;try{var Qe=Qa(u.type,b);r=h.getSnapshotBeforeUpdate(Qe,v),h.__reactInternalSnapshotBeforeUpdate=r}catch(pt){sn(u,u.return,pt)}}break;case 3:if((r&1024)!==0){if(r=s.stateNode.containerInfo,u=r.nodeType,u===9)zm(r);else if(u===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":zm(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=s.sibling,r!==null){r.return=s.return,er=r;break}er=s.return}}function P1(r,s,u){var h=u.flags;switch(u.tag){case 0:case 11:case 15:js(r,u),h&4&&Jo(5,u);break;case 1:if(js(r,u),h&4)if(r=u.stateNode,s===null)try{r.componentDidMount()}catch(T){sn(u,u.return,T)}else{var b=Qa(u.type,s.memoizedProps);s=s.memoizedState;try{r.componentDidUpdate(b,s,r.__reactInternalSnapshotBeforeUpdate)}catch(T){sn(u,u.return,T)}}h&64&&L1(u),h&512&&ec(u,u.return);break;case 3:if(js(r,u),h&64&&(r=u.updateQueue,r!==null)){if(s=null,u.child!==null)switch(u.child.tag){case 27:case 5:s=u.child.stateNode;break;case 1:s=u.child.stateNode}try{Dg(r,s)}catch(T){sn(u,u.return,T)}}break;case 27:s===null&&h&4&&q1(u);case 26:case 5:js(r,u),s===null&&h&4&&H1(u),h&512&&ec(u,u.return);break;case 12:js(r,u);break;case 31:js(r,u),h&4&&W1(r,u);break;case 13:js(r,u),h&4&&G1(r,u),h&64&&(r=u.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(u=HS.bind(null,u),l4(r,u))));break;case 22:if(h=u.memoizedState!==null||ks,!h){s=s!==null&&s.memoizedState!==null||Hn,b=ks;var v=Hn;ks=h,(Hn=s)&&!v?Cs(r,u,(u.subtreeFlags&8772)!==0):js(r,u),ks=b,Hn=v}break;case 30:break;default:js(r,u)}}function X1(r){var s=r.alternate;s!==null&&(r.alternate=null,X1(s)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(s=r.stateNode,s!==null&&Ma(s)),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 Nn=null,Cr=!1;function Ss(r,s,u){for(u=u.child;u!==null;)V1(r,s,u),u=u.sibling}function V1(r,s,u){if(qe&&typeof qe.onCommitFiberUnmount=="function")try{qe.onCommitFiberUnmount(Ie,u)}catch{}switch(u.tag){case 26:Hn||Ii(u,s),Ss(r,s,u),u.memoizedState?u.memoizedState.count--:u.stateNode&&(u=u.stateNode,u.parentNode.removeChild(u));break;case 27:Hn||Ii(u,s);var h=Nn,b=Cr;ca(u.type)&&(Nn=u.stateNode,Cr=!1),Ss(r,s,u),cc(u.stateNode),Nn=h,Cr=b;break;case 5:Hn||Ii(u,s);case 6:if(h=Nn,b=Cr,Nn=null,Ss(r,s,u),Nn=h,Cr=b,Nn!==null)if(Cr)try{(Nn.nodeType===9?Nn.body:Nn.nodeName==="HTML"?Nn.ownerDocument.body:Nn).removeChild(u.stateNode)}catch(v){sn(u,s,v)}else try{Nn.removeChild(u.stateNode)}catch(v){sn(u,s,v)}break;case 18:Nn!==null&&(Cr?(r=Nn,Ly(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,u.stateNode),Kl(r)):Ly(Nn,u.stateNode));break;case 4:h=Nn,b=Cr,Nn=u.stateNode.containerInfo,Cr=!0,Ss(r,s,u),Nn=h,Cr=b;break;case 0:case 11:case 14:case 15:na(2,u,s),Hn||na(4,u,s),Ss(r,s,u);break;case 1:Hn||(Ii(u,s),h=u.stateNode,typeof h.componentWillUnmount=="function"&&I1(u,s,h)),Ss(r,s,u);break;case 21:Ss(r,s,u);break;case 22:Hn=(h=Hn)||u.memoizedState!==null,Ss(r,s,u),Hn=h;break;default:Ss(r,s,u)}}function W1(r,s){if(s.memoizedState===null&&(r=s.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{Kl(r)}catch(u){sn(s,s.return,u)}}}function G1(r,s){if(s.memoizedState===null&&(r=s.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{Kl(r)}catch(u){sn(s,s.return,u)}}function FS(r){switch(r.tag){case 31:case 13:case 19:var s=r.stateNode;return s===null&&(s=r.stateNode=new Y1),s;case 22:return r=r.stateNode,s=r._retryCache,s===null&&(s=r._retryCache=new Y1),s;default:throw Error(i(435,r.tag))}}function rd(r,s){var u=FS(r);s.forEach(function(h){if(!u.has(h)){u.add(h);var b=US.bind(null,r,h);h.then(b,b)}})}function Nr(r,s){var u=s.deletions;if(u!==null)for(var h=0;h<u.length;h++){var b=u[h],v=r,T=s,Y=T;e:for(;Y!==null;){switch(Y.tag){case 27:if(ca(Y.type)){Nn=Y.stateNode,Cr=!1;break e}break;case 5:Nn=Y.stateNode,Cr=!1;break e;case 3:case 4:Nn=Y.stateNode.containerInfo,Cr=!0;break e}Y=Y.return}if(Nn===null)throw Error(i(160));V1(v,T,b),Nn=null,Cr=!1,v=b.alternate,v!==null&&(v.return=null),b.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)K1(s,r),s=s.sibling}var bi=null;function K1(r,s){var u=r.alternate,h=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Nr(s,r),Er(r),h&4&&(na(3,r,r.return),Jo(3,r),na(5,r,r.return));break;case 1:Nr(s,r),Er(r),h&512&&(Hn||u===null||Ii(u,u.return)),h&64&&ks&&(r=r.updateQueue,r!==null&&(h=r.callbacks,h!==null&&(u=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=u===null?h:u.concat(h))));break;case 26:var b=bi;if(Nr(s,r),Er(r),h&512&&(Hn||u===null||Ii(u,u.return)),h&4){var v=u!==null?u.memoizedState:null;if(h=r.memoizedState,u===null)if(h===null)if(r.stateNode===null){e:{h=r.type,u=r.memoizedProps,b=b.ownerDocument||b;t:switch(h){case"title":v=b.getElementsByTagName("title")[0],(!v||v[Zr]||v[dt]||v.namespaceURI==="http://www.w3.org/2000/svg"||v.hasAttribute("itemprop"))&&(v=b.createElement(h),b.head.insertBefore(v,b.querySelector("head > title"))),or(v,h,u),v[dt]=r,Sn(v),h=v;break e;case"link":var T=Ky("link","href",b).get(h+(u.href||""));if(T){for(var Y=0;Y<T.length;Y++)if(v=T[Y],v.getAttribute("href")===(u.href==null||u.href===""?null:u.href)&&v.getAttribute("rel")===(u.rel==null?null:u.rel)&&v.getAttribute("title")===(u.title==null?null:u.title)&&v.getAttribute("crossorigin")===(u.crossOrigin==null?null:u.crossOrigin)){T.splice(Y,1);break t}}v=b.createElement(h),or(v,h,u),b.head.appendChild(v);break;case"meta":if(T=Ky("meta","content",b).get(h+(u.content||""))){for(Y=0;Y<T.length;Y++)if(v=T[Y],v.getAttribute("content")===(u.content==null?null:""+u.content)&&v.getAttribute("name")===(u.name==null?null:u.name)&&v.getAttribute("property")===(u.property==null?null:u.property)&&v.getAttribute("http-equiv")===(u.httpEquiv==null?null:u.httpEquiv)&&v.getAttribute("charset")===(u.charSet==null?null:u.charSet)){T.splice(Y,1);break t}}v=b.createElement(h),or(v,h,u),b.head.appendChild(v);break;default:throw Error(i(468,h))}v[dt]=r,Sn(v),h=v}r.stateNode=h}else Qy(b,r.type,r.stateNode);else r.stateNode=Gy(b,h,r.memoizedProps);else v!==h?(v===null?u.stateNode!==null&&(u=u.stateNode,u.parentNode.removeChild(u)):v.count--,h===null?Qy(b,r.type,r.stateNode):Gy(b,h,r.memoizedProps)):h===null&&r.stateNode!==null&&lm(r,r.memoizedProps,u.memoizedProps)}break;case 27:Nr(s,r),Er(r),h&512&&(Hn||u===null||Ii(u,u.return)),u!==null&&h&4&&lm(r,r.memoizedProps,u.memoizedProps);break;case 5:if(Nr(s,r),Er(r),h&512&&(Hn||u===null||Ii(u,u.return)),r.flags&32){b=r.stateNode;try{Fi(b,"")}catch(Qe){sn(r,r.return,Qe)}}h&4&&r.stateNode!=null&&(b=r.memoizedProps,lm(r,b,u!==null?u.memoizedProps:b)),h&1024&&(um=!0);break;case 6:if(Nr(s,r),Er(r),h&4){if(r.stateNode===null)throw Error(i(162));h=r.memoizedProps,u=r.stateNode;try{u.nodeValue=h}catch(Qe){sn(r,r.return,Qe)}}break;case 3:if(bd=null,b=bi,bi=gd(s.containerInfo),Nr(s,r),bi=b,Er(r),h&4&&u!==null&&u.memoizedState.isDehydrated)try{Kl(s.containerInfo)}catch(Qe){sn(r,r.return,Qe)}um&&(um=!1,Q1(r));break;case 4:h=bi,bi=gd(r.stateNode.containerInfo),Nr(s,r),Er(r),bi=h;break;case 12:Nr(s,r),Er(r);break;case 31:Nr(s,r),Er(r),h&4&&(h=r.updateQueue,h!==null&&(r.updateQueue=null,rd(r,h)));break;case 13:Nr(s,r),Er(r),r.child.flags&8192&&r.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(sd=ve()),h&4&&(h=r.updateQueue,h!==null&&(r.updateQueue=null,rd(r,h)));break;case 22:b=r.memoizedState!==null;var ne=u!==null&&u.memoizedState!==null,he=ks,je=Hn;if(ks=he||b,Hn=je||ne,Nr(s,r),Hn=je,ks=he,Er(r),h&8192)e:for(s=r.stateNode,s._visibility=b?s._visibility&-2:s._visibility|1,b&&(u===null||ne||ks||Hn||Za(r)),u=null,s=r;;){if(s.tag===5||s.tag===26){if(u===null){ne=u=s;try{if(v=ne.stateNode,b)T=v.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none";else{Y=ne.stateNode;var _e=ne.memoizedProps.style,xe=_e!=null&&_e.hasOwnProperty("display")?_e.display:null;Y.style.display=xe==null||typeof xe=="boolean"?"":(""+xe).trim()}}catch(Qe){sn(ne,ne.return,Qe)}}}else if(s.tag===6){if(u===null){ne=s;try{ne.stateNode.nodeValue=b?"":ne.memoizedProps}catch(Qe){sn(ne,ne.return,Qe)}}}else if(s.tag===18){if(u===null){ne=s;try{var ge=ne.stateNode;b?Iy(ge,!0):Iy(ne.stateNode,!1)}catch(Qe){sn(ne,ne.return,Qe)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===r)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break e;for(;s.sibling===null;){if(s.return===null||s.return===r)break e;u===s&&(u=null),s=s.return}u===s&&(u=null),s.sibling.return=s.return,s=s.sibling}h&4&&(h=r.updateQueue,h!==null&&(u=h.retryQueue,u!==null&&(h.retryQueue=null,rd(r,u))));break;case 19:Nr(s,r),Er(r),h&4&&(h=r.updateQueue,h!==null&&(r.updateQueue=null,rd(r,h)));break;case 30:break;case 21:break;default:Nr(s,r),Er(r)}}function Er(r){var s=r.flags;if(s&2){try{for(var u,h=r.return;h!==null;){if(U1(h)){u=h;break}h=h.return}if(u==null)throw Error(i(160));switch(u.tag){case 27:var b=u.stateNode,v=om(r);nd(r,v,b);break;case 5:var T=u.stateNode;u.flags&32&&(Fi(T,""),u.flags&=-33);var Y=om(r);nd(r,Y,T);break;case 3:case 4:var ne=u.stateNode.containerInfo,he=om(r);cm(r,he,ne);break;default:throw Error(i(161))}}catch(je){sn(r,r.return,je)}r.flags&=-3}s&4096&&(r.flags&=-4097)}function Q1(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var s=r;Q1(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),r=r.sibling}}function js(r,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)P1(r,s.alternate,s),s=s.sibling}function Za(r){for(r=r.child;r!==null;){var s=r;switch(s.tag){case 0:case 11:case 14:case 15:na(4,s,s.return),Za(s);break;case 1:Ii(s,s.return);var u=s.stateNode;typeof u.componentWillUnmount=="function"&&I1(s,s.return,u),Za(s);break;case 27:cc(s.stateNode);case 26:case 5:Ii(s,s.return),Za(s);break;case 22:s.memoizedState===null&&Za(s);break;case 30:Za(s);break;default:Za(s)}r=r.sibling}}function Cs(r,s,u){for(u=u&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var h=s.alternate,b=r,v=s,T=v.flags;switch(v.tag){case 0:case 11:case 15:Cs(b,v,u),Jo(4,v);break;case 1:if(Cs(b,v,u),h=v,b=h.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(he){sn(h,h.return,he)}if(h=v,b=h.updateQueue,b!==null){var Y=h.stateNode;try{var ne=b.shared.hiddenCallbacks;if(ne!==null)for(b.shared.hiddenCallbacks=null,b=0;b<ne.length;b++)Ag(ne[b],Y)}catch(he){sn(h,h.return,he)}}u&&T&64&&L1(v),ec(v,v.return);break;case 27:q1(v);case 26:case 5:Cs(b,v,u),u&&h===null&&T&4&&H1(v),ec(v,v.return);break;case 12:Cs(b,v,u);break;case 31:Cs(b,v,u),u&&T&4&&W1(b,v);break;case 13:Cs(b,v,u),u&&T&4&&G1(b,v);break;case 22:v.memoizedState===null&&Cs(b,v,u),ec(v,v.return);break;case 30:break;default:Cs(b,v,u)}s=s.sibling}}function dm(r,s){var u=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),r=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(r=s.memoizedState.cachePool.pool),r!==u&&(r!=null&&r.refCount++,u!=null&&Io(u))}function fm(r,s){r=null,s.alternate!==null&&(r=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==r&&(s.refCount++,r!=null&&Io(r))}function vi(r,s,u,h){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Z1(r,s,u,h),s=s.sibling}function Z1(r,s,u,h){var b=s.flags;switch(s.tag){case 0:case 11:case 15:vi(r,s,u,h),b&2048&&Jo(9,s);break;case 1:vi(r,s,u,h);break;case 3:vi(r,s,u,h),b&2048&&(r=null,s.alternate!==null&&(r=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==r&&(s.refCount++,r!=null&&Io(r)));break;case 12:if(b&2048){vi(r,s,u,h),r=s.stateNode;try{var v=s.memoizedProps,T=v.id,Y=v.onPostCommit;typeof Y=="function"&&Y(T,s.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(ne){sn(s,s.return,ne)}}else vi(r,s,u,h);break;case 31:vi(r,s,u,h);break;case 13:vi(r,s,u,h);break;case 23:break;case 22:v=s.stateNode,T=s.alternate,s.memoizedState!==null?v._visibility&2?vi(r,s,u,h):tc(r,s):v._visibility&2?vi(r,s,u,h):(v._visibility|=2,Ll(r,s,u,h,(s.subtreeFlags&10256)!==0||!1)),b&2048&&dm(T,s);break;case 24:vi(r,s,u,h),b&2048&&fm(s.alternate,s);break;default:vi(r,s,u,h)}}function Ll(r,s,u,h,b){for(b=b&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var v=r,T=s,Y=u,ne=h,he=T.flags;switch(T.tag){case 0:case 11:case 15:Ll(v,T,Y,ne,b),Jo(8,T);break;case 23:break;case 22:var je=T.stateNode;T.memoizedState!==null?je._visibility&2?Ll(v,T,Y,ne,b):tc(v,T):(je._visibility|=2,Ll(v,T,Y,ne,b)),b&&he&2048&&dm(T.alternate,T);break;case 24:Ll(v,T,Y,ne,b),b&&he&2048&&fm(T.alternate,T);break;default:Ll(v,T,Y,ne,b)}s=s.sibling}}function tc(r,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var u=r,h=s,b=h.flags;switch(h.tag){case 22:tc(u,h),b&2048&&dm(h.alternate,h);break;case 24:tc(u,h),b&2048&&fm(h.alternate,h);break;default:tc(u,h)}s=s.sibling}}var nc=8192;function Il(r,s,u){if(r.subtreeFlags&nc)for(r=r.child;r!==null;)J1(r,s,u),r=r.sibling}function J1(r,s,u){switch(r.tag){case 26:Il(r,s,u),r.flags&nc&&r.memoizedState!==null&&b4(u,bi,r.memoizedState,r.memoizedProps);break;case 5:Il(r,s,u);break;case 3:case 4:var h=bi;bi=gd(r.stateNode.containerInfo),Il(r,s,u),bi=h;break;case 22:r.memoizedState===null&&(h=r.alternate,h!==null&&h.memoizedState!==null?(h=nc,nc=16777216,Il(r,s,u),nc=h):Il(r,s,u));break;default:Il(r,s,u)}}function ey(r){var s=r.alternate;if(s!==null&&(r=s.child,r!==null)){s.child=null;do s=r.sibling,r.sibling=null,r=s;while(r!==null)}}function rc(r){var s=r.deletions;if((r.flags&16)!==0){if(s!==null)for(var u=0;u<s.length;u++){var h=s[u];er=h,ny(h,r)}ey(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)ty(r),r=r.sibling}function ty(r){switch(r.tag){case 0:case 11:case 15:rc(r),r.flags&2048&&na(9,r,r.return);break;case 3:rc(r);break;case 12:rc(r);break;case 22:var s=r.stateNode;r.memoizedState!==null&&s._visibility&2&&(r.return===null||r.return.tag!==13)?(s._visibility&=-3,id(r)):rc(r);break;default:rc(r)}}function id(r){var s=r.deletions;if((r.flags&16)!==0){if(s!==null)for(var u=0;u<s.length;u++){var h=s[u];er=h,ny(h,r)}ey(r)}for(r=r.child;r!==null;){switch(s=r,s.tag){case 0:case 11:case 15:na(8,s,s.return),id(s);break;case 22:u=s.stateNode,u._visibility&2&&(u._visibility&=-3,id(s));break;default:id(s)}r=r.sibling}}function ny(r,s){for(;er!==null;){var u=er;switch(u.tag){case 0:case 11:case 15:na(8,u,s);break;case 23:case 22:if(u.memoizedState!==null&&u.memoizedState.cachePool!==null){var h=u.memoizedState.cachePool.pool;h!=null&&h.refCount++}break;case 24:Io(u.memoizedState.cache)}if(h=u.child,h!==null)h.return=u,er=h;else e:for(u=r;er!==null;){h=er;var b=h.sibling,v=h.return;if(X1(h),h===u){er=null;break e}if(b!==null){b.return=v,er=b;break e}er=v}}}var RS={getCacheForType:function(r){var s=ar(On),u=s.data.get(r);return u===void 0&&(u=r(),s.data.set(r,u)),u},cacheSignal:function(){return ar(On).controller.signal}},zS=typeof WeakMap=="function"?WeakMap:Map,Kt=0,xn=null,Ft=null,Ot=0,rn=0,Ir=null,ra=!1,Hl=!1,hm=!1,Ns=0,Rn=0,ia=0,Ja=0,mm=0,Hr=0,Ul=0,ic=null,Ar=null,pm=!1,sd=0,ry=0,ad=1/0,ld=null,sa=null,Vn=0,aa=null,ql=null,Es=0,xm=0,gm=null,iy=null,sc=0,ym=null;function Ur(){return(Kt&2)!==0&&Ot!==0?Ot&-Ot:$.T!==null?jm():ce()}function sy(){if(Hr===0)if((Ot&536870912)===0||Ht){var r=Tt;Tt<<=1,(Tt&3932160)===0&&(Tt=262144),Hr=r}else Hr=536870912;return r=Or.current,r!==null&&(r.flags|=32),Hr}function Dr(r,s,u){(r===xn&&(rn===2||rn===9)||r.cancelPendingCommit!==null)&&(Yl(r,0),la(r,Ot,Hr,!1)),Ne(r,u),((Kt&2)===0||r!==xn)&&(r===xn&&((Kt&2)===0&&(Ja|=u),Rn===4&&la(r,Ot,Hr,!1)),Hi(r))}function ay(r,s,u){if((Kt&6)!==0)throw Error(i(327));var h=!u&&(s&127)===0&&(s&r.expiredLanes)===0||ae(r,s),b=h?OS(r,s):vm(r,s,!0),v=h;do{if(b===0){Hl&&!h&&la(r,s,0,!1);break}else{if(u=r.current.alternate,v&&!BS(u)){b=vm(r,s,!1),v=!1;continue}if(b===2){if(v=s,r.errorRecoveryDisabledLanes&v)var T=0;else T=r.pendingLanes&-536870913,T=T!==0?T:T&536870912?536870912:0;if(T!==0){s=T;e:{var Y=r;b=ic;var ne=Y.current.memoizedState.isDehydrated;if(ne&&(Yl(Y,T).flags|=256),T=vm(Y,T,!1),T!==2){if(hm&&!ne){Y.errorRecoveryDisabledLanes|=v,Ja|=v,b=4;break e}v=Ar,Ar=b,v!==null&&(Ar===null?Ar=v:Ar.push.apply(Ar,v))}b=T}if(v=!1,b!==2)continue}}if(b===1){Yl(r,0),la(r,s,0,!0);break}e:{switch(h=r,v=b,v){case 0:case 1:throw Error(i(345));case 4:if((s&4194048)!==s)break;case 6:la(h,s,Hr,!ra);break e;case 2:Ar=null;break;case 3:case 5:break;default:throw Error(i(329))}if((s&62914560)===s&&(b=sd+300-ve(),10<b)){if(la(h,s,Hr,!ra),Zt(h,0,!0)!==0)break e;Es=s,h.timeoutHandle=$y(ly.bind(null,h,u,Ar,ld,pm,s,Hr,Ja,Ul,ra,v,"Throttled",-0,0),b);break e}ly(h,u,Ar,ld,pm,s,Hr,Ja,Ul,ra,v,null,-0,0)}}break}while(!0);Hi(r)}function ly(r,s,u,h,b,v,T,Y,ne,he,je,_e,xe,ge){if(r.timeoutHandle=-1,_e=s.subtreeFlags,_e&8192||(_e&16785408)===16785408){_e={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Cn},J1(s,v,_e);var Qe=(v&62914560)===v?sd-ve():(v&4194048)===v?ry-ve():0;if(Qe=v4(_e,Qe),Qe!==null){Es=v,r.cancelPendingCommit=Qe(py.bind(null,r,s,v,u,h,b,T,Y,ne,je,_e,null,xe,ge)),la(r,v,T,!he);return}}py(r,s,v,u,h,b,T,Y,ne)}function BS(r){for(var s=r;;){var u=s.tag;if((u===0||u===11||u===15)&&s.flags&16384&&(u=s.updateQueue,u!==null&&(u=u.stores,u!==null)))for(var h=0;h<u.length;h++){var b=u[h],v=b.getSnapshot;b=b.value;try{if(!Br(v(),b))return!1}catch{return!1}}if(u=s.child,s.subtreeFlags&16384&&u!==null)u.return=s,s=u;else{if(s===r)break;for(;s.sibling===null;){if(s.return===null||s.return===r)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function la(r,s,u,h){s&=~mm,s&=~Ja,r.suspendedLanes|=s,r.pingedLanes&=~s,h&&(r.warmLanes|=s),h=r.expirationTimes;for(var b=s;0<b;){var v=31-et(b),T=1<<v;h[v]=-1,b&=~T}u!==0&&ln(r,u,s)}function od(){return(Kt&6)===0?(ac(0),!1):!0}function bm(){if(Ft!==null){if(rn===0)var r=Ft.return;else r=Ft,xs=Ya=null,zh(r),Rl=null,Uo=0,r=Ft;for(;r!==null;)O1(r.alternate,r),r=r.return;Ft=null}}function Yl(r,s){var u=r.timeoutHandle;u!==-1&&(r.timeoutHandle=-1,n4(u)),u=r.cancelPendingCommit,u!==null&&(r.cancelPendingCommit=null,u()),Es=0,bm(),xn=r,Ft=u=ms(r.current,null),Ot=s,rn=0,Ir=null,ra=!1,Hl=ae(r,s),hm=!1,Ul=Hr=mm=Ja=ia=Rn=0,Ar=ic=null,pm=!1,(s&8)!==0&&(s|=s&32);var h=r.entangledLanes;if(h!==0)for(r=r.entanglements,h&=s;0<h;){var b=31-et(h),v=1<<b;s|=r[b],h&=~v}return Ns=s,Du(),u}function oy(r,s){Nt=null,$.H=Ko,s===Fl||s===$u?(s=jg(),rn=3):s===Sh?(s=jg(),rn=4):rn=s===Qh?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Ir=s,Ft===null&&(Rn=1,Qu(r,ni(s,r.current)))}function cy(){var r=Or.current;return r===null?!0:(Ot&4194048)===Ot?ai===null:(Ot&62914560)===Ot||(Ot&536870912)!==0?r===ai:!1}function uy(){var r=$.H;return $.H=Ko,r===null?Ko:r}function dy(){var r=$.A;return $.A=RS,r}function cd(){Rn=4,ra||(Ot&4194048)!==Ot&&Or.current!==null||(Hl=!0),(ia&134217727)===0&&(Ja&134217727)===0||xn===null||la(xn,Ot,Hr,!1)}function vm(r,s,u){var h=Kt;Kt|=2;var b=uy(),v=dy();(xn!==r||Ot!==s)&&(ld=null,Yl(r,s)),s=!1;var T=Rn;e:do try{if(rn!==0&&Ft!==null){var Y=Ft,ne=Ir;switch(rn){case 8:bm(),T=6;break e;case 3:case 2:case 9:case 6:Or.current===null&&(s=!0);var he=rn;if(rn=0,Ir=null,Pl(r,Y,ne,he),u&&Hl){T=0;break e}break;default:he=rn,rn=0,Ir=null,Pl(r,Y,ne,he)}}$S(),T=Rn;break}catch(je){oy(r,je)}while(!0);return s&&r.shellSuspendCounter++,xs=Ya=null,Kt=h,$.H=b,$.A=v,Ft===null&&(xn=null,Ot=0,Du()),T}function $S(){for(;Ft!==null;)fy(Ft)}function OS(r,s){var u=Kt;Kt|=2;var h=uy(),b=dy();xn!==r||Ot!==s?(ld=null,ad=ve()+500,Yl(r,s)):Hl=ae(r,s);e:do try{if(rn!==0&&Ft!==null){s=Ft;var v=Ir;t:switch(rn){case 1:rn=0,Ir=null,Pl(r,s,v,1);break;case 2:case 9:if(kg(v)){rn=0,Ir=null,hy(s);break}s=function(){rn!==2&&rn!==9||xn!==r||(rn=7),Hi(r)},v.then(s,s);break e;case 3:rn=7;break e;case 4:rn=5;break e;case 7:kg(v)?(rn=0,Ir=null,hy(s)):(rn=0,Ir=null,Pl(r,s,v,7));break;case 5:var T=null;switch(Ft.tag){case 26:T=Ft.memoizedState;case 5:case 27:var Y=Ft;if(T?Zy(T):Y.stateNode.complete){rn=0,Ir=null;var ne=Y.sibling;if(ne!==null)Ft=ne;else{var he=Y.return;he!==null?(Ft=he,ud(he)):Ft=null}break t}}rn=0,Ir=null,Pl(r,s,v,5);break;case 6:rn=0,Ir=null,Pl(r,s,v,6);break;case 8:bm(),Rn=6;break e;default:throw Error(i(462))}}LS();break}catch(je){oy(r,je)}while(!0);return xs=Ya=null,$.H=h,$.A=b,Kt=u,Ft!==null?0:(xn=null,Ot=0,Du(),Rn)}function LS(){for(;Ft!==null&&!kt();)fy(Ft)}function fy(r){var s=B1(r.alternate,r,Ns);r.memoizedProps=r.pendingProps,s===null?ud(r):Ft=s}function hy(r){var s=r,u=s.alternate;switch(s.tag){case 15:case 0:s=T1(u,s,s.pendingProps,s.type,void 0,Ot);break;case 11:s=T1(u,s,s.pendingProps,s.type.render,s.ref,Ot);break;case 5:zh(s);default:O1(u,s),s=Ft=dg(s,Ns),s=B1(u,s,Ns)}r.memoizedProps=r.pendingProps,s===null?ud(r):Ft=s}function Pl(r,s,u,h){xs=Ya=null,zh(s),Rl=null,Uo=0;var b=s.return;try{if(ES(r,b,s,u,Ot)){Rn=1,Qu(r,ni(u,r.current)),Ft=null;return}}catch(v){if(b!==null)throw Ft=b,v;Rn=1,Qu(r,ni(u,r.current)),Ft=null;return}s.flags&32768?(Ht||h===1?r=!0:Hl||(Ot&536870912)!==0?r=!1:(ra=r=!0,(h===2||h===9||h===3||h===6)&&(h=Or.current,h!==null&&h.tag===13&&(h.flags|=16384))),my(s,r)):ud(s)}function ud(r){var s=r;do{if((s.flags&32768)!==0){my(s,ra);return}r=s.return;var u=TS(s.alternate,s,Ns);if(u!==null){Ft=u;return}if(s=s.sibling,s!==null){Ft=s;return}Ft=s=r}while(s!==null);Rn===0&&(Rn=5)}function my(r,s){do{var u=_S(r.alternate,r);if(u!==null){u.flags&=32767,Ft=u;return}if(u=r.return,u!==null&&(u.flags|=32768,u.subtreeFlags=0,u.deletions=null),!s&&(r=r.sibling,r!==null)){Ft=r;return}Ft=r=u}while(r!==null);Rn=6,Ft=null}function py(r,s,u,h,b,v,T,Y,ne){r.cancelPendingCommit=null;do dd();while(Vn!==0);if((Kt&6)!==0)throw Error(i(327));if(s!==null){if(s===r.current)throw Error(i(177));if(v=s.lanes|s.childLanes,v|=oh,Ct(r,u,v,T,Y,ne),r===xn&&(Ft=xn=null,Ot=0),ql=s,aa=r,Es=u,xm=v,gm=b,iy=h,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,qS(Ce,function(){return vy(),null})):(r.callbackNode=null,r.callbackPriority=0),h=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||h){h=$.T,$.T=null,b=G.p,G.p=2,T=Kt,Kt|=4;try{MS(r,s,u)}finally{Kt=T,G.p=b,$.T=h}}Vn=1,xy(),gy(),yy()}}function xy(){if(Vn===1){Vn=0;var r=aa,s=ql,u=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||u){u=$.T,$.T=null;var h=G.p;G.p=2;var b=Kt;Kt|=4;try{K1(s,r);var v=Mm,T=ng(r.containerInfo),Y=v.focusedElem,ne=v.selectionRange;if(T!==Y&&Y&&Y.ownerDocument&&tg(Y.ownerDocument.documentElement,Y)){if(ne!==null&&rh(Y)){var he=ne.start,je=ne.end;if(je===void 0&&(je=he),"selectionStart"in Y)Y.selectionStart=he,Y.selectionEnd=Math.min(je,Y.value.length);else{var _e=Y.ownerDocument||document,xe=_e&&_e.defaultView||window;if(xe.getSelection){var ge=xe.getSelection(),Qe=Y.textContent.length,pt=Math.min(ne.start,Qe),dn=ne.end===void 0?pt:Math.min(ne.end,Qe);!ge.extend&&pt>dn&&(T=dn,dn=pt,pt=T);var ue=eg(Y,pt),ie=eg(Y,dn);if(ue&&ie&&(ge.rangeCount!==1||ge.anchorNode!==ue.node||ge.anchorOffset!==ue.offset||ge.focusNode!==ie.node||ge.focusOffset!==ie.offset)){var fe=_e.createRange();fe.setStart(ue.node,ue.offset),ge.removeAllRanges(),pt>dn?(ge.addRange(fe),ge.extend(ie.node,ie.offset)):(fe.setEnd(ie.node,ie.offset),ge.addRange(fe))}}}}for(_e=[],ge=Y;ge=ge.parentNode;)ge.nodeType===1&&_e.push({element:ge,left:ge.scrollLeft,top:ge.scrollTop});for(typeof Y.focus=="function"&&Y.focus(),Y=0;Y<_e.length;Y++){var Ae=_e[Y];Ae.element.scrollLeft=Ae.left,Ae.element.scrollTop=Ae.top}}Sd=!!_m,Mm=_m=null}finally{Kt=b,G.p=h,$.T=u}}r.current=s,Vn=2}}function gy(){if(Vn===2){Vn=0;var r=aa,s=ql,u=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||u){u=$.T,$.T=null;var h=G.p;G.p=2;var b=Kt;Kt|=4;try{P1(r,s.alternate,s)}finally{Kt=b,G.p=h,$.T=u}}Vn=3}}function yy(){if(Vn===4||Vn===3){Vn=0,mt();var r=aa,s=ql,u=Es,h=iy;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Vn=5:(Vn=0,ql=aa=null,by(r,r.pendingLanes));var b=r.pendingLanes;if(b===0&&(sa=null),vn(u),s=s.stateNode,qe&&typeof qe.onCommitFiberRoot=="function")try{qe.onCommitFiberRoot(Ie,s,void 0,(s.current.flags&128)===128)}catch{}if(h!==null){s=$.T,b=G.p,G.p=2,$.T=null;try{for(var v=r.onRecoverableError,T=0;T<h.length;T++){var Y=h[T];v(Y.value,{componentStack:Y.stack})}}finally{$.T=s,G.p=b}}(Es&3)!==0&&dd(),Hi(r),b=r.pendingLanes,(u&261930)!==0&&(b&42)!==0?r===ym?sc++:(sc=0,ym=r):sc=0,ac(0)}}function by(r,s){(r.pooledCacheLanes&=s)===0&&(s=r.pooledCache,s!=null&&(r.pooledCache=null,Io(s)))}function dd(){return xy(),gy(),yy(),vy()}function vy(){if(Vn!==5)return!1;var r=aa,s=xm;xm=0;var u=vn(Es),h=$.T,b=G.p;try{G.p=32>u?32:u,$.T=null,u=gm,gm=null;var v=aa,T=Es;if(Vn=0,ql=aa=null,Es=0,(Kt&6)!==0)throw Error(i(331));var Y=Kt;if(Kt|=4,ty(v.current),Z1(v,v.current,T,u),Kt=Y,ac(0,!1),qe&&typeof qe.onPostCommitFiberRoot=="function")try{qe.onPostCommitFiberRoot(Ie,v)}catch{}return!0}finally{G.p=b,$.T=h,by(r,s)}}function wy(r,s,u){s=ni(u,s),s=Kh(r.stateNode,s,2),r=Js(r,s,2),r!==null&&(Ne(r,2),Hi(r))}function sn(r,s,u){if(r.tag===3)wy(r,r,u);else for(;s!==null;){if(s.tag===3){wy(s,r,u);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(sa===null||!sa.has(h))){r=ni(u,r),u=k1(2),h=Js(s,u,2),h!==null&&(S1(u,h,s,r),Ne(h,2),Hi(h));break}}s=s.return}}function wm(r,s,u){var h=r.pingCache;if(h===null){h=r.pingCache=new zS;var b=new Set;h.set(s,b)}else b=h.get(s),b===void 0&&(b=new Set,h.set(s,b));b.has(u)||(hm=!0,b.add(u),r=IS.bind(null,r,s,u),s.then(r,r))}function IS(r,s,u){var h=r.pingCache;h!==null&&h.delete(s),r.pingedLanes|=r.suspendedLanes&u,r.warmLanes&=~u,xn===r&&(Ot&u)===u&&(Rn===4||Rn===3&&(Ot&62914560)===Ot&&300>ve()-sd?(Kt&2)===0&&Yl(r,0):mm|=u,Ul===Ot&&(Ul=0)),Hi(r)}function ky(r,s){s===0&&(s=We()),r=Ha(r,s),r!==null&&(Ne(r,s),Hi(r))}function HS(r){var s=r.memoizedState,u=0;s!==null&&(u=s.retryLane),ky(r,u)}function US(r,s){var u=0;switch(r.tag){case 31:case 13:var h=r.stateNode,b=r.memoizedState;b!==null&&(u=b.retryLane);break;case 19:h=r.stateNode;break;case 22:h=r.stateNode._retryCache;break;default:throw Error(i(314))}h!==null&&h.delete(s),ky(r,u)}function qS(r,s){return nt(r,s)}var fd=null,Xl=null,km=!1,hd=!1,Sm=!1,oa=0;function Hi(r){r!==Xl&&r.next===null&&(Xl===null?fd=Xl=r:Xl=Xl.next=r),hd=!0,km||(km=!0,PS())}function ac(r,s){if(!Sm&&hd){Sm=!0;do for(var u=!1,h=fd;h!==null;){if(r!==0){var b=h.pendingLanes;if(b===0)var v=0;else{var T=h.suspendedLanes,Y=h.pingedLanes;v=(1<<31-et(42|r)+1)-1,v&=b&~(T&~Y),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(u=!0,Ny(h,v))}else v=Ot,v=Zt(h,h===xn?v:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(v&3)===0||ae(h,v)||(u=!0,Ny(h,v));h=h.next}while(u);Sm=!1}}function YS(){Sy()}function Sy(){hd=km=!1;var r=0;oa!==0&&t4()&&(r=oa);for(var s=ve(),u=null,h=fd;h!==null;){var b=h.next,v=jy(h,s);v===0?(h.next=null,u===null?fd=b:u.next=b,b===null&&(Xl=u)):(u=h,(r!==0||(v&3)!==0)&&(hd=!0)),h=b}Vn!==0&&Vn!==5||ac(r),oa!==0&&(oa=0)}function jy(r,s){for(var u=r.suspendedLanes,h=r.pingedLanes,b=r.expirationTimes,v=r.pendingLanes&-62914561;0<v;){var T=31-et(v),Y=1<<T,ne=b[T];ne===-1?((Y&u)===0||(Y&h)!==0)&&(b[T]=Ve(Y,s)):ne<=s&&(r.expiredLanes|=Y),v&=~Y}if(s=xn,u=Ot,u=Zt(r,r===s?u:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),h=r.callbackNode,u===0||r===s&&(rn===2||rn===9)||r.cancelPendingCommit!==null)return h!==null&&h!==null&&ut(h),r.callbackNode=null,r.callbackPriority=0;if((u&3)===0||ae(r,u)){if(s=u&-u,s===r.callbackPriority)return s;switch(h!==null&&ut(h),vn(u)){case 2:case 8:u=oe;break;case 32:u=Ce;break;case 268435456:u=Se;break;default:u=Ce}return h=Cy.bind(null,r),u=nt(u,h),r.callbackPriority=s,r.callbackNode=u,s}return h!==null&&h!==null&&ut(h),r.callbackPriority=2,r.callbackNode=null,2}function Cy(r,s){if(Vn!==0&&Vn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var u=r.callbackNode;if(dd()&&r.callbackNode!==u)return null;var h=Ot;return h=Zt(r,r===xn?h:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),h===0?null:(ay(r,h,s),jy(r,ve()),r.callbackNode!=null&&r.callbackNode===u?Cy.bind(null,r):null)}function Ny(r,s){if(dd())return null;ay(r,s,!0)}function PS(){r4(function(){(Kt&6)!==0?nt(te,YS):Sy()})}function jm(){if(oa===0){var r=_l;r===0&&(r=en,en<<=1,(en&261888)===0&&(en=256)),oa=r}return oa}function Ey(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:zr(""+r)}function Ay(r,s){var u=s.ownerDocument.createElement("input");return u.name=s.name,u.value=s.value,r.id&&u.setAttribute("form",r.id),s.parentNode.insertBefore(u,s),r=new FormData(r),u.parentNode.removeChild(u),r}function XS(r,s,u,h,b){if(s==="submit"&&u&&u.stateNode===b){var v=Ey((b[wt]||null).action),T=h.submitter;T&&(s=(s=T[wt]||null)?Ey(s.formAction):T.getAttribute("formAction"),s!==null&&(v=s,T=null));var Y=new vl("action","action",null,h,b);r.push({event:Y,listeners:[{instance:null,listener:function(){if(h.defaultPrevented){if(oa!==0){var ne=T?Ay(b,T):new FormData(b);Yh(u,{pending:!0,data:ne,method:b.method,action:v},null,ne)}}else typeof v=="function"&&(Y.preventDefault(),ne=T?Ay(b,T):new FormData(b),Yh(u,{pending:!0,data:ne,method:b.method,action:v},v,ne))},currentTarget:b}]})}}for(var Cm=0;Cm<lh.length;Cm++){var Nm=lh[Cm],VS=Nm.toLowerCase(),WS=Nm[0].toUpperCase()+Nm.slice(1);yi(VS,"on"+WS)}yi(sg,"onAnimationEnd"),yi(ag,"onAnimationIteration"),yi(lg,"onAnimationStart"),yi("dblclick","onDoubleClick"),yi("focusin","onFocus"),yi("focusout","onBlur"),yi(uS,"onTransitionRun"),yi(dS,"onTransitionStart"),yi(fS,"onTransitionCancel"),yi(og,"onTransitionEnd"),Ti("onMouseEnter",["mouseout","mouseover"]),Ti("onMouseLeave",["mouseout","mouseover"]),Ti("onPointerEnter",["pointerout","pointerover"]),Ti("onPointerLeave",["pointerout","pointerover"]),$n("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),$n("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),$n("onBeforeInput",["compositionend","keypress","textInput","paste"]),$n("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),$n("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),$n("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var lc="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(" "),GS=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(lc));function Dy(r,s){s=(s&4)!==0;for(var u=0;u<r.length;u++){var h=r[u],b=h.event;h=h.listeners;e:{var v=void 0;if(s)for(var T=h.length-1;0<=T;T--){var Y=h[T],ne=Y.instance,he=Y.currentTarget;if(Y=Y.listener,ne!==v&&b.isPropagationStopped())break e;v=Y,b.currentTarget=he;try{v(b)}catch(je){Au(je)}b.currentTarget=null,v=ne}else for(T=0;T<h.length;T++){if(Y=h[T],ne=Y.instance,he=Y.currentTarget,Y=Y.listener,ne!==v&&b.isPropagationStopped())break e;v=Y,b.currentTarget=he;try{v(b)}catch(je){Au(je)}b.currentTarget=null,v=ne}}}}function Rt(r,s){var u=s[Pn];u===void 0&&(u=s[Pn]=new Set);var h=r+"__bubble";u.has(h)||(Ty(s,r,2,!1),u.add(h))}function Em(r,s,u){var h=0;s&&(h|=4),Ty(u,r,h,s)}var md="_reactListening"+Math.random().toString(36).slice(2);function Am(r){if(!r[md]){r[md]=!0,Fa.forEach(function(u){u!=="selectionchange"&&(GS.has(u)||Em(u,!1,r),Em(u,!0,r))});var s=r.nodeType===9?r:r.ownerDocument;s===null||s[md]||(s[md]=!0,Em("selectionchange",!1,s))}}function Ty(r,s,u,h){switch(sb(s)){case 2:var b=S4;break;case 8:b=j4;break;default:b=qm}u=b.bind(null,s,u,r),b=void 0,!us||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(b=!0),h?b!==void 0?r.addEventListener(s,u,{capture:!0,passive:b}):r.addEventListener(s,u,!0):b!==void 0?r.addEventListener(s,u,{passive:b}):r.addEventListener(s,u,!1)}function Dm(r,s,u,h,b){var v=h;if((s&1)===0&&(s&2)===0&&h!==null)e:for(;;){if(h===null)return;var T=h.tag;if(T===3||T===4){var Y=h.stateNode.containerInfo;if(Y===b)break;if(T===4)for(T=h.return;T!==null;){var ne=T.tag;if((ne===3||ne===4)&&T.stateNode.containerInfo===b)return;T=T.return}for(;Y!==null;){if(T=jr(Y),T===null)return;if(ne=T.tag,ne===5||ne===6||ne===26||ne===27){h=v=T;continue e}Y=Y.parentNode}}h=h.return}Do(function(){var he=v,je=xi(u),_e=[];e:{var xe=cg.get(r);if(xe!==void 0){var ge=vl,Qe=r;switch(r){case"keypress":if(on(u)===0)break e;case"keydown":case"keyup":ge=wu;break;case"focusin":Qe="focus",ge=wl;break;case"focusout":Qe="blur",ge=wl;break;case"beforeblur":case"afterblur":ge=wl;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ge=fu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ge=mu;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ge=ju;break;case sg:case ag:case lg:ge=xu;break;case og:ge=Nu;break;case"scroll":case"scrollend":ge=fs;break;case"wheel":ge=re;break;case"copy":case"cut":case"paste":ge=hs;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ge=Fo;break;case"toggle":case"beforetoggle":ge=we}var pt=(s&4)!==0,dn=!pt&&(r==="scroll"||r==="scrollend"),ue=pt?xe!==null?xe+"Capture":null:xe;pt=[];for(var ie=he,fe;ie!==null;){var Ae=ie;if(fe=Ae.stateNode,Ae=Ae.tag,Ae!==5&&Ae!==26&&Ae!==27||fe===null||ue===null||(Ae=Us(ie,ue),Ae!=null&&pt.push(oc(ie,Ae,fe))),dn)break;ie=ie.return}0<pt.length&&(xe=new ge(xe,Qe,null,u,je),_e.push({event:xe,listeners:pt}))}}if((s&7)===0){e:{if(xe=r==="mouseover"||r==="pointerover",ge=r==="mouseout"||r==="pointerout",xe&&u!==ei&&(Qe=u.relatedTarget||u.fromElement)&&(jr(Qe)||Qe[yr]))break e;if((ge||xe)&&(xe=je.window===je?je:(xe=je.ownerDocument)?xe.defaultView||xe.parentWindow:window,ge?(Qe=u.relatedTarget||u.toElement,ge=he,Qe=Qe?jr(Qe):null,Qe!==null&&(dn=o(Qe),pt=Qe.tag,Qe!==dn||pt!==5&&pt!==27&&pt!==6)&&(Qe=null)):(ge=null,Qe=he),ge!==Qe)){if(pt=fu,Ae="onMouseLeave",ue="onMouseEnter",ie="mouse",(r==="pointerout"||r==="pointerover")&&(pt=Fo,Ae="onPointerLeave",ue="onPointerEnter",ie="pointer"),dn=ge==null?xe:Ai(ge),fe=Qe==null?xe:Ai(Qe),xe=new pt(Ae,ie+"leave",ge,u,je),xe.target=dn,xe.relatedTarget=fe,Ae=null,jr(je)===he&&(pt=new pt(ue,ie+"enter",Qe,u,je),pt.target=fe,pt.relatedTarget=dn,Ae=pt),dn=Ae,ge&&Qe)t:{for(pt=KS,ue=ge,ie=Qe,fe=0,Ae=ue;Ae;Ae=pt(Ae))fe++;Ae=0;for(var lt=ie;lt;lt=pt(lt))Ae++;for(;0<fe-Ae;)ue=pt(ue),fe--;for(;0<Ae-fe;)ie=pt(ie),Ae--;for(;fe--;){if(ue===ie||ie!==null&&ue===ie.alternate){pt=ue;break t}ue=pt(ue),ie=pt(ie)}pt=null}else pt=null;ge!==null&&_y(_e,xe,ge,pt,!1),Qe!==null&&dn!==null&&_y(_e,dn,Qe,pt,!0)}}e:{if(xe=he?Ai(he):window,ge=xe.nodeName&&xe.nodeName.toLowerCase(),ge==="select"||ge==="input"&&xe.type==="file")var Vt=W0;else if(pn(xe))if(G0)Vt=lS;else{Vt=sS;var tt=iS}else ge=xe.nodeName,!ge||ge.toLowerCase()!=="input"||xe.type!=="checkbox"&&xe.type!=="radio"?he&&Ao(he.elementType)&&(Vt=W0):Vt=aS;if(Vt&&(Vt=Vt(r,he))){V0(_e,Vt,u,je);break e}tt&&tt(r,xe,he),r==="focusout"&&he&&xe.type==="number"&&he.memoizedProps.value!=null&&br(xe,"number",xe.value)}switch(tt=he?Ai(he):window,r){case"focusin":(pn(tt)||tt.contentEditable==="true")&&(Sl=tt,ih=he,$o=null);break;case"focusout":$o=ih=Sl=null;break;case"mousedown":sh=!0;break;case"contextmenu":case"mouseup":case"dragend":sh=!1,rg(_e,u,je);break;case"selectionchange":if(cS)break;case"keydown":case"keyup":rg(_e,u,je)}var Et;if(Ke)e:{switch(r){case"compositionstart":var Lt="onCompositionStart";break e;case"compositionend":Lt="onCompositionEnd";break e;case"compositionupdate":Lt="onCompositionUpdate";break e}Lt=void 0}else Xn?Yt(r,u)&&(Lt="onCompositionEnd"):r==="keydown"&&u.keyCode===229&&(Lt="onCompositionStart");Lt&&(ct&&u.locale!=="ko"&&(Xn||Lt!=="onCompositionStart"?Lt==="onCompositionEnd"&&Xn&&(Et=du()):(Bi=je,To="value"in Bi?Bi.value:Bi.textContent,Xn=!0)),tt=pd(he,Lt),0<tt.length&&(Lt=new gu(Lt,r,null,u,je),_e.push({event:Lt,listeners:tt}),Et?Lt.data=Et:(Et=Xs(u),Et!==null&&(Lt.data=Et)))),(Et=yt?jt(r,u):Xt(r,u))&&(Lt=pd(he,"onBeforeInput"),0<Lt.length&&(tt=new gu("onBeforeInput","beforeinput",null,u,je),_e.push({event:tt,listeners:Lt}),tt.data=Et)),XS(_e,r,he,u,je)}Dy(_e,s)})}function oc(r,s,u){return{instance:r,listener:s,currentTarget:u}}function pd(r,s){for(var u=s+"Capture",h=[];r!==null;){var b=r,v=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||v===null||(b=Us(r,u),b!=null&&h.unshift(oc(r,b,v)),b=Us(r,s),b!=null&&h.push(oc(r,b,v))),r.tag===3)return h;r=r.return}return[]}function KS(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function _y(r,s,u,h,b){for(var v=s._reactName,T=[];u!==null&&u!==h;){var Y=u,ne=Y.alternate,he=Y.stateNode;if(Y=Y.tag,ne!==null&&ne===h)break;Y!==5&&Y!==26&&Y!==27||he===null||(ne=he,b?(he=Us(u,v),he!=null&&T.unshift(oc(u,he,ne))):b||(he=Us(u,v),he!=null&&T.push(oc(u,he,ne)))),u=u.return}T.length!==0&&r.push({event:s,listeners:T})}var QS=/\r\n?/g,ZS=/\u0000|\uFFFD/g;function My(r){return(typeof r=="string"?r:""+r).replace(QS,`
50
+ `).replace(ZS,"")}function Fy(r,s){return s=My(s),My(r)===s}function un(r,s,u,h,b,v){switch(u){case"children":typeof h=="string"?s==="body"||s==="textarea"&&h===""||Fi(r,h):(typeof h=="number"||typeof h=="bigint")&&s!=="body"&&Fi(r,""+h);break;case"className":ss(r,"class",h);break;case"tabIndex":ss(r,"tabindex",h);break;case"dir":case"role":case"viewBox":case"width":case"height":ss(r,u,h);break;case"style":Ri(r,h,v);break;case"data":if(s!=="object"){ss(r,"data",h);break}case"src":case"href":if(h===""&&(s!=="a"||u!=="href")){r.removeAttribute(u);break}if(h==null||typeof h=="function"||typeof h=="symbol"||typeof h=="boolean"){r.removeAttribute(u);break}h=zr(""+h),r.setAttribute(u,h);break;case"action":case"formAction":if(typeof h=="function"){r.setAttribute(u,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof v=="function"&&(u==="formAction"?(s!=="input"&&un(r,s,"name",b.name,b,null),un(r,s,"formEncType",b.formEncType,b,null),un(r,s,"formMethod",b.formMethod,b,null),un(r,s,"formTarget",b.formTarget,b,null)):(un(r,s,"encType",b.encType,b,null),un(r,s,"method",b.method,b,null),un(r,s,"target",b.target,b,null)));if(h==null||typeof h=="symbol"||typeof h=="boolean"){r.removeAttribute(u);break}h=zr(""+h),r.setAttribute(u,h);break;case"onClick":h!=null&&(r.onclick=Cn);break;case"onScroll":h!=null&&Rt("scroll",r);break;case"onScrollEnd":h!=null&&Rt("scrollend",r);break;case"dangerouslySetInnerHTML":if(h!=null){if(typeof h!="object"||!("__html"in h))throw Error(i(61));if(u=h.__html,u!=null){if(b.children!=null)throw Error(i(60));r.innerHTML=u}}break;case"multiple":r.multiple=h&&typeof h!="function"&&typeof h!="symbol";break;case"muted":r.muted=h&&typeof h!="function"&&typeof h!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(h==null||typeof h=="function"||typeof h=="boolean"||typeof h=="symbol"){r.removeAttribute("xlink:href");break}u=zr(""+h),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":h!=null&&typeof h!="function"&&typeof h!="symbol"?r.setAttribute(u,""+h):r.removeAttribute(u);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":h&&typeof h!="function"&&typeof h!="symbol"?r.setAttribute(u,""):r.removeAttribute(u);break;case"capture":case"download":h===!0?r.setAttribute(u,""):h!==!1&&h!=null&&typeof h!="function"&&typeof h!="symbol"?r.setAttribute(u,h):r.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":h!=null&&typeof h!="function"&&typeof h!="symbol"&&!isNaN(h)&&1<=h?r.setAttribute(u,h):r.removeAttribute(u);break;case"rowSpan":case"start":h==null||typeof h=="function"||typeof h=="symbol"||isNaN(h)?r.removeAttribute(u):r.setAttribute(u,h);break;case"popover":Rt("beforetoggle",r),Rt("toggle",r),Fr(r,"popover",h);break;case"xlinkActuate":Zn(r,"http://www.w3.org/1999/xlink","xlink:actuate",h);break;case"xlinkArcrole":Zn(r,"http://www.w3.org/1999/xlink","xlink:arcrole",h);break;case"xlinkRole":Zn(r,"http://www.w3.org/1999/xlink","xlink:role",h);break;case"xlinkShow":Zn(r,"http://www.w3.org/1999/xlink","xlink:show",h);break;case"xlinkTitle":Zn(r,"http://www.w3.org/1999/xlink","xlink:title",h);break;case"xlinkType":Zn(r,"http://www.w3.org/1999/xlink","xlink:type",h);break;case"xmlBase":Zn(r,"http://www.w3.org/XML/1998/namespace","xml:base",h);break;case"xmlLang":Zn(r,"http://www.w3.org/XML/1998/namespace","xml:lang",h);break;case"xmlSpace":Zn(r,"http://www.w3.org/XML/1998/namespace","xml:space",h);break;case"is":Fr(r,"is",h);break;case"innerText":case"textContent":break;default:(!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(u=rr.get(u)||u,Fr(r,u,h))}}function Tm(r,s,u,h,b,v){switch(u){case"style":Ri(r,h,v);break;case"dangerouslySetInnerHTML":if(h!=null){if(typeof h!="object"||!("__html"in h))throw Error(i(61));if(u=h.__html,u!=null){if(b.children!=null)throw Error(i(60));r.innerHTML=u}}break;case"children":typeof h=="string"?Fi(r,h):(typeof h=="number"||typeof h=="bigint")&&Fi(r,""+h);break;case"onScroll":h!=null&&Rt("scroll",r);break;case"onScrollEnd":h!=null&&Rt("scrollend",r);break;case"onClick":h!=null&&(r.onclick=Cn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Is.hasOwnProperty(u))e:{if(u[0]==="o"&&u[1]==="n"&&(b=u.endsWith("Capture"),s=u.slice(2,b?u.length-7:void 0),v=r[wt]||null,v=v!=null?v[u]:null,typeof v=="function"&&r.removeEventListener(s,v,b),typeof h=="function")){typeof v!="function"&&v!==null&&(u in r?r[u]=null:r.hasAttribute(u)&&r.removeAttribute(u)),r.addEventListener(s,h,b);break e}u in r?r[u]=h:h===!0?r.setAttribute(u,""):Fr(r,u,h)}}}function or(r,s,u){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Rt("error",r),Rt("load",r);var h=!1,b=!1,v;for(v in u)if(u.hasOwnProperty(v)){var T=u[v];if(T!=null)switch(v){case"src":h=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,s));default:un(r,s,v,T,u,null)}}b&&un(r,s,"srcSet",u.srcSet,u,null),h&&un(r,s,"src",u.src,u,null);return;case"input":Rt("invalid",r);var Y=v=T=b=null,ne=null,he=null;for(h in u)if(u.hasOwnProperty(h)){var je=u[h];if(je!=null)switch(h){case"name":b=je;break;case"type":T=je;break;case"checked":ne=je;break;case"defaultChecked":he=je;break;case"value":v=je;break;case"defaultValue":Y=je;break;case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(i(137,s));break;default:un(r,s,h,je,u,null)}}Rr(r,v,Y,ne,he,T,b,!1);return;case"select":Rt("invalid",r),h=T=v=null;for(b in u)if(u.hasOwnProperty(b)&&(Y=u[b],Y!=null))switch(b){case"value":v=Y;break;case"defaultValue":T=Y;break;case"multiple":h=Y;default:un(r,s,b,Y,u,null)}s=v,u=T,r.multiple=!!h,s!=null?mn(r,!!h,s,!1):u!=null&&mn(r,!!h,u,!0);return;case"textarea":Rt("invalid",r),v=b=h=null;for(T in u)if(u.hasOwnProperty(T)&&(Y=u[T],Y!=null))switch(T){case"value":h=Y;break;case"defaultValue":b=Y;break;case"children":v=Y;break;case"dangerouslySetInnerHTML":if(Y!=null)throw Error(i(91));break;default:un(r,s,T,Y,u,null)}uu(r,h,b,v);return;case"option":for(ne in u)if(u.hasOwnProperty(ne)&&(h=u[ne],h!=null))switch(ne){case"selected":r.selected=h&&typeof h!="function"&&typeof h!="symbol";break;default:un(r,s,ne,h,u,null)}return;case"dialog":Rt("beforetoggle",r),Rt("toggle",r),Rt("cancel",r),Rt("close",r);break;case"iframe":case"object":Rt("load",r);break;case"video":case"audio":for(h=0;h<lc.length;h++)Rt(lc[h],r);break;case"image":Rt("error",r),Rt("load",r);break;case"details":Rt("toggle",r);break;case"embed":case"source":case"link":Rt("error",r),Rt("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(he in u)if(u.hasOwnProperty(he)&&(h=u[he],h!=null))switch(he){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,s));default:un(r,s,he,h,u,null)}return;default:if(Ao(s)){for(je in u)u.hasOwnProperty(je)&&(h=u[je],h!==void 0&&Tm(r,s,je,h,u,void 0));return}}for(Y in u)u.hasOwnProperty(Y)&&(h=u[Y],h!=null&&un(r,s,Y,h,u,null))}function JS(r,s,u,h){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var b=null,v=null,T=null,Y=null,ne=null,he=null,je=null;for(ge in u){var _e=u[ge];if(u.hasOwnProperty(ge)&&_e!=null)switch(ge){case"checked":break;case"value":break;case"defaultValue":ne=_e;default:h.hasOwnProperty(ge)||un(r,s,ge,null,h,_e)}}for(var xe in h){var ge=h[xe];if(_e=u[xe],h.hasOwnProperty(xe)&&(ge!=null||_e!=null))switch(xe){case"type":v=ge;break;case"name":b=ge;break;case"checked":he=ge;break;case"defaultChecked":je=ge;break;case"value":T=ge;break;case"defaultValue":Y=ge;break;case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(i(137,s));break;default:ge!==_e&&un(r,s,xe,ge,h,_e)}}Jn(r,T,Y,ne,he,je,v,b);return;case"select":ge=T=Y=xe=null;for(v in u)if(ne=u[v],u.hasOwnProperty(v)&&ne!=null)switch(v){case"value":break;case"multiple":ge=ne;default:h.hasOwnProperty(v)||un(r,s,v,null,h,ne)}for(b in h)if(v=h[b],ne=u[b],h.hasOwnProperty(b)&&(v!=null||ne!=null))switch(b){case"value":xe=v;break;case"defaultValue":Y=v;break;case"multiple":T=v;default:v!==ne&&un(r,s,b,v,h,ne)}s=Y,u=T,h=ge,xe!=null?mn(r,!!u,xe,!1):!!h!=!!u&&(s!=null?mn(r,!!u,s,!0):mn(r,!!u,u?[]:"",!1));return;case"textarea":ge=xe=null;for(Y in u)if(b=u[Y],u.hasOwnProperty(Y)&&b!=null&&!h.hasOwnProperty(Y))switch(Y){case"value":break;case"children":break;default:un(r,s,Y,null,h,b)}for(T in h)if(b=h[T],v=u[T],h.hasOwnProperty(T)&&(b!=null||v!=null))switch(T){case"value":xe=b;break;case"defaultValue":ge=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(i(91));break;default:b!==v&&un(r,s,T,b,h,v)}Eo(r,xe,ge);return;case"option":for(var Qe in u)if(xe=u[Qe],u.hasOwnProperty(Qe)&&xe!=null&&!h.hasOwnProperty(Qe))switch(Qe){case"selected":r.selected=!1;break;default:un(r,s,Qe,null,h,xe)}for(ne in h)if(xe=h[ne],ge=u[ne],h.hasOwnProperty(ne)&&xe!==ge&&(xe!=null||ge!=null))switch(ne){case"selected":r.selected=xe&&typeof xe!="function"&&typeof xe!="symbol";break;default:un(r,s,ne,xe,h,ge)}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 pt in u)xe=u[pt],u.hasOwnProperty(pt)&&xe!=null&&!h.hasOwnProperty(pt)&&un(r,s,pt,null,h,xe);for(he in h)if(xe=h[he],ge=u[he],h.hasOwnProperty(he)&&xe!==ge&&(xe!=null||ge!=null))switch(he){case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(i(137,s));break;default:un(r,s,he,xe,h,ge)}return;default:if(Ao(s)){for(var dn in u)xe=u[dn],u.hasOwnProperty(dn)&&xe!==void 0&&!h.hasOwnProperty(dn)&&Tm(r,s,dn,void 0,h,xe);for(je in h)xe=h[je],ge=u[je],!h.hasOwnProperty(je)||xe===ge||xe===void 0&&ge===void 0||Tm(r,s,je,xe,h,ge);return}}for(var ue in u)xe=u[ue],u.hasOwnProperty(ue)&&xe!=null&&!h.hasOwnProperty(ue)&&un(r,s,ue,null,h,xe);for(_e in h)xe=h[_e],ge=u[_e],!h.hasOwnProperty(_e)||xe===ge||xe==null&&ge==null||un(r,s,_e,xe,h,ge)}function Ry(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function e4(){if(typeof performance.getEntriesByType=="function"){for(var r=0,s=0,u=performance.getEntriesByType("resource"),h=0;h<u.length;h++){var b=u[h],v=b.transferSize,T=b.initiatorType,Y=b.duration;if(v&&Y&&Ry(T)){for(T=0,Y=b.responseEnd,h+=1;h<u.length;h++){var ne=u[h],he=ne.startTime;if(he>Y)break;var je=ne.transferSize,_e=ne.initiatorType;je&&Ry(_e)&&(ne=ne.responseEnd,T+=je*(ne<Y?1:(Y-he)/(ne-he)))}if(--h,s+=8*(v+T)/(b.duration/1e3),r++,10<r)break}}if(0<r)return s/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var _m=null,Mm=null;function xd(r){return r.nodeType===9?r:r.ownerDocument}function zy(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 By(r,s){if(r===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&s==="foreignObject"?0:r}function Fm(r,s){return r==="textarea"||r==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Rm=null;function t4(){var r=window.event;return r&&r.type==="popstate"?r===Rm?!1:(Rm=r,!0):(Rm=null,!1)}var $y=typeof setTimeout=="function"?setTimeout:void 0,n4=typeof clearTimeout=="function"?clearTimeout:void 0,Oy=typeof Promise=="function"?Promise:void 0,r4=typeof queueMicrotask=="function"?queueMicrotask:typeof Oy<"u"?function(r){return Oy.resolve(null).then(r).catch(i4)}:$y;function i4(r){setTimeout(function(){throw r})}function ca(r){return r==="head"}function Ly(r,s){var u=s,h=0;do{var b=u.nextSibling;if(r.removeChild(u),b&&b.nodeType===8)if(u=b.data,u==="/$"||u==="/&"){if(h===0){r.removeChild(b),Kl(s);return}h--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")h++;else if(u==="html")cc(r.ownerDocument.documentElement);else if(u==="head"){u=r.ownerDocument.head,cc(u);for(var v=u.firstChild;v;){var T=v.nextSibling,Y=v.nodeName;v[Zr]||Y==="SCRIPT"||Y==="STYLE"||Y==="LINK"&&v.rel.toLowerCase()==="stylesheet"||u.removeChild(v),v=T}}else u==="body"&&cc(r.ownerDocument.body);u=b}while(u);Kl(s)}function Iy(r,s){var u=r;r=0;do{var h=u.nextSibling;if(u.nodeType===1?s?(u._stashedDisplay=u.style.display,u.style.display="none"):(u.style.display=u._stashedDisplay||"",u.getAttribute("style")===""&&u.removeAttribute("style")):u.nodeType===3&&(s?(u._stashedText=u.nodeValue,u.nodeValue=""):u.nodeValue=u._stashedText||""),h&&h.nodeType===8)if(u=h.data,u==="/$"){if(r===0)break;r--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||r++;u=h}while(u)}function zm(r){var s=r.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var u=s;switch(s=s.nextSibling,u.nodeName){case"HTML":case"HEAD":case"BODY":zm(u),Ma(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}r.removeChild(u)}}function s4(r,s,u,h){for(;r.nodeType===1;){var b=u;if(r.nodeName.toLowerCase()!==s.toLowerCase()){if(!h&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(h){if(!r[Zr])switch(s){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(v=r.getAttribute("rel"),v==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(v!==b.rel||r.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||r.getAttribute("title")!==(b.title==null?null:b.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(v=r.getAttribute("src"),(v!==(b.src==null?null:b.src)||r.getAttribute("type")!==(b.type==null?null:b.type)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&v&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(s==="input"&&r.type==="hidden"){var v=b.name==null?null:""+b.name;if(b.type==="hidden"&&r.getAttribute("name")===v)return r}else return r;if(r=li(r.nextSibling),r===null)break}return null}function a4(r,s,u){if(s==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!u||(r=li(r.nextSibling),r===null))return null;return r}function Hy(r,s){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!s||(r=li(r.nextSibling),r===null))return null;return r}function Bm(r){return r.data==="$?"||r.data==="$~"}function $m(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function l4(r,s){var u=r.ownerDocument;if(r.data==="$~")r._reactRetry=s;else if(r.data!=="$?"||u.readyState!=="loading")s();else{var h=function(){s(),u.removeEventListener("DOMContentLoaded",h)};u.addEventListener("DOMContentLoaded",h),r._reactRetry=h}}function li(r){for(;r!=null;r=r.nextSibling){var s=r.nodeType;if(s===1||s===3)break;if(s===8){if(s=r.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return r}var Om=null;function Uy(r){r=r.nextSibling;for(var s=0;r;){if(r.nodeType===8){var u=r.data;if(u==="/$"||u==="/&"){if(s===0)return li(r.nextSibling);s--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||s++}r=r.nextSibling}return null}function qy(r){r=r.previousSibling;for(var s=0;r;){if(r.nodeType===8){var u=r.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(s===0)return r;s--}else u!=="/$"&&u!=="/&"||s++}r=r.previousSibling}return null}function Yy(r,s,u){switch(s=xd(u),r){case"html":if(r=s.documentElement,!r)throw Error(i(452));return r;case"head":if(r=s.head,!r)throw Error(i(453));return r;case"body":if(r=s.body,!r)throw Error(i(454));return r;default:throw Error(i(451))}}function cc(r){for(var s=r.attributes;s.length;)r.removeAttributeNode(s[0]);Ma(r)}var oi=new Map,Py=new Set;function gd(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var As=G.d;G.d={f:o4,r:c4,D:u4,C:d4,L:f4,m:h4,X:p4,S:m4,M:x4};function o4(){var r=As.f(),s=od();return r||s}function c4(r){var s=dr(r);s!==null&&s.tag===5&&s.type==="form"?o1(s):As.r(r)}var Vl=typeof document>"u"?null:document;function Xy(r,s,u){var h=Vl;if(h&&typeof s=="string"&&s){var b=jn(s);b='link[rel="'+r+'"][href="'+b+'"]',typeof u=="string"&&(b+='[crossorigin="'+u+'"]'),Py.has(b)||(Py.add(b),r={rel:r,crossOrigin:u,href:s},h.querySelector(b)===null&&(s=h.createElement("link"),or(s,"link",r),Sn(s),h.head.appendChild(s)))}}function u4(r){As.D(r),Xy("dns-prefetch",r,null)}function d4(r,s){As.C(r,s),Xy("preconnect",r,s)}function f4(r,s,u){As.L(r,s,u);var h=Vl;if(h&&r&&s){var b='link[rel="preload"][as="'+jn(s)+'"]';s==="image"&&u&&u.imageSrcSet?(b+='[imagesrcset="'+jn(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(b+='[imagesizes="'+jn(u.imageSizes)+'"]')):b+='[href="'+jn(r)+'"]';var v=b;switch(s){case"style":v=Wl(r);break;case"script":v=Gl(r)}oi.has(v)||(r=p({rel:"preload",href:s==="image"&&u&&u.imageSrcSet?void 0:r,as:s},u),oi.set(v,r),h.querySelector(b)!==null||s==="style"&&h.querySelector(uc(v))||s==="script"&&h.querySelector(dc(v))||(s=h.createElement("link"),or(s,"link",r),Sn(s),h.head.appendChild(s)))}}function h4(r,s){As.m(r,s);var u=Vl;if(u&&r){var h=s&&typeof s.as=="string"?s.as:"script",b='link[rel="modulepreload"][as="'+jn(h)+'"][href="'+jn(r)+'"]',v=b;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Gl(r)}if(!oi.has(v)&&(r=p({rel:"modulepreload",href:r},s),oi.set(v,r),u.querySelector(b)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(dc(v)))return}h=u.createElement("link"),or(h,"link",r),Sn(h),u.head.appendChild(h)}}}function m4(r,s,u){As.S(r,s,u);var h=Vl;if(h&&r){var b=Di(h).hoistableStyles,v=Wl(r);s=s||"default";var T=b.get(v);if(!T){var Y={loading:0,preload:null};if(T=h.querySelector(uc(v)))Y.loading=5;else{r=p({rel:"stylesheet",href:r,"data-precedence":s},u),(u=oi.get(v))&&Lm(r,u);var ne=T=h.createElement("link");Sn(ne),or(ne,"link",r),ne._p=new Promise(function(he,je){ne.onload=he,ne.onerror=je}),ne.addEventListener("load",function(){Y.loading|=1}),ne.addEventListener("error",function(){Y.loading|=2}),Y.loading|=4,yd(T,s,h)}T={type:"stylesheet",instance:T,count:1,state:Y},b.set(v,T)}}}function p4(r,s){As.X(r,s);var u=Vl;if(u&&r){var h=Di(u).hoistableScripts,b=Gl(r),v=h.get(b);v||(v=u.querySelector(dc(b)),v||(r=p({src:r,async:!0},s),(s=oi.get(b))&&Im(r,s),v=u.createElement("script"),Sn(v),or(v,"link",r),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},h.set(b,v))}}function x4(r,s){As.M(r,s);var u=Vl;if(u&&r){var h=Di(u).hoistableScripts,b=Gl(r),v=h.get(b);v||(v=u.querySelector(dc(b)),v||(r=p({src:r,async:!0,type:"module"},s),(s=oi.get(b))&&Im(r,s),v=u.createElement("script"),Sn(v),or(v,"link",r),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},h.set(b,v))}}function Vy(r,s,u,h){var b=(b=J.current)?gd(b):null;if(!b)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(s=Wl(u.href),u=Di(b).hoistableStyles,h=u.get(s),h||(h={type:"style",instance:null,count:0,state:null},u.set(s,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){r=Wl(u.href);var v=Di(b).hoistableStyles,T=v.get(r);if(T||(b=b.ownerDocument||b,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(r,T),(v=b.querySelector(uc(r)))&&!v._p&&(T.instance=v,T.state.loading=5),oi.has(r)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},oi.set(r,u),v||g4(b,r,u,T.state))),s&&h===null)throw Error(i(528,""));return T}if(s&&h!==null)throw Error(i(529,""));return null;case"script":return s=u.async,u=u.src,typeof u=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Gl(u),u=Di(b).hoistableScripts,h=u.get(s),h||(h={type:"script",instance:null,count:0,state:null},u.set(s,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function Wl(r){return'href="'+jn(r)+'"'}function uc(r){return'link[rel="stylesheet"]['+r+"]"}function Wy(r){return p({},r,{"data-precedence":r.precedence,precedence:null})}function g4(r,s,u,h){r.querySelector('link[rel="preload"][as="style"]['+s+"]")?h.loading=1:(s=r.createElement("link"),h.preload=s,s.addEventListener("load",function(){return h.loading|=1}),s.addEventListener("error",function(){return h.loading|=2}),or(s,"link",u),Sn(s),r.head.appendChild(s))}function Gl(r){return'[src="'+jn(r)+'"]'}function dc(r){return"script[async]"+r}function Gy(r,s,u){if(s.count++,s.instance===null)switch(s.type){case"style":var h=r.querySelector('style[data-href~="'+jn(u.href)+'"]');if(h)return s.instance=h,Sn(h),h;var b=p({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return h=(r.ownerDocument||r).createElement("style"),Sn(h),or(h,"style",b),yd(h,u.precedence,r),s.instance=h;case"stylesheet":b=Wl(u.href);var v=r.querySelector(uc(b));if(v)return s.state.loading|=4,s.instance=v,Sn(v),v;h=Wy(u),(b=oi.get(b))&&Lm(h,b),v=(r.ownerDocument||r).createElement("link"),Sn(v);var T=v;return T._p=new Promise(function(Y,ne){T.onload=Y,T.onerror=ne}),or(v,"link",h),s.state.loading|=4,yd(v,u.precedence,r),s.instance=v;case"script":return v=Gl(u.src),(b=r.querySelector(dc(v)))?(s.instance=b,Sn(b),b):(h=u,(b=oi.get(v))&&(h=p({},u),Im(h,b)),r=r.ownerDocument||r,b=r.createElement("script"),Sn(b),or(b,"link",h),r.head.appendChild(b),s.instance=b);case"void":return null;default:throw Error(i(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(h=s.instance,s.state.loading|=4,yd(h,u.precedence,r));return s.instance}function yd(r,s,u){for(var h=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=h.length?h[h.length-1]:null,v=b,T=0;T<h.length;T++){var Y=h[T];if(Y.dataset.precedence===s)v=Y;else if(v!==b)break}v?v.parentNode.insertBefore(r,v.nextSibling):(s=u.nodeType===9?u.head:u,s.insertBefore(r,s.firstChild))}function Lm(r,s){r.crossOrigin==null&&(r.crossOrigin=s.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=s.referrerPolicy),r.title==null&&(r.title=s.title)}function Im(r,s){r.crossOrigin==null&&(r.crossOrigin=s.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=s.referrerPolicy),r.integrity==null&&(r.integrity=s.integrity)}var bd=null;function Ky(r,s,u){if(bd===null){var h=new Map,b=bd=new Map;b.set(u,h)}else b=bd,h=b.get(u),h||(h=new Map,b.set(u,h));if(h.has(r))return h;for(h.set(r,null),u=u.getElementsByTagName(r),b=0;b<u.length;b++){var v=u[b];if(!(v[Zr]||v[dt]||r==="link"&&v.getAttribute("rel")==="stylesheet")&&v.namespaceURI!=="http://www.w3.org/2000/svg"){var T=v.getAttribute(s)||"";T=r+T;var Y=h.get(T);Y?Y.push(v):h.set(T,[v])}}return h}function Qy(r,s,u){r=r.ownerDocument||r,r.head.insertBefore(u,s==="title"?r.querySelector("head > title"):null)}function y4(r,s,u){if(u===1||s.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return r=s.disabled,typeof s.precedence=="string"&&r==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function Zy(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function b4(r,s,u,h){if(u.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var b=Wl(h.href),v=s.querySelector(uc(b));if(v){s=v._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(r.count++,r=vd.bind(r),s.then(r,r)),u.state.loading|=4,u.instance=v,Sn(v);return}v=s.ownerDocument||s,h=Wy(h),(b=oi.get(b))&&Lm(h,b),v=v.createElement("link"),Sn(v);var T=v;T._p=new Promise(function(Y,ne){T.onload=Y,T.onerror=ne}),or(v,"link",h),u.instance=v}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(u,s),(s=u.state.preload)&&(u.state.loading&3)===0&&(r.count++,u=vd.bind(r),s.addEventListener("load",u),s.addEventListener("error",u))}}var Hm=0;function v4(r,s){return r.stylesheets&&r.count===0&&kd(r,r.stylesheets),0<r.count||0<r.imgCount?function(u){var h=setTimeout(function(){if(r.stylesheets&&kd(r,r.stylesheets),r.unsuspend){var v=r.unsuspend;r.unsuspend=null,v()}},6e4+s);0<r.imgBytes&&Hm===0&&(Hm=62500*e4());var b=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&kd(r,r.stylesheets),r.unsuspend)){var v=r.unsuspend;r.unsuspend=null,v()}},(r.imgBytes>Hm?50:800)+s);return r.unsuspend=u,function(){r.unsuspend=null,clearTimeout(h),clearTimeout(b)}}:null}function vd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)kd(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var wd=null;function kd(r,s){r.stylesheets=null,r.unsuspend!==null&&(r.count++,wd=new Map,s.forEach(w4,r),wd=null,vd.call(r))}function w4(r,s){if(!(s.state.loading&4)){var u=wd.get(r);if(u)var h=u.get(null);else{u=new Map,wd.set(r,u);for(var b=r.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v<b.length;v++){var T=b[v];(T.nodeName==="LINK"||T.getAttribute("media")!=="not all")&&(u.set(T.dataset.precedence,T),h=T)}h&&u.set(null,h)}b=s.instance,T=b.getAttribute("data-precedence"),v=u.get(T)||h,v===h&&u.set(null,b),u.set(T,b),this.count++,h=vd.bind(this),b.addEventListener("load",h),b.addEventListener("error",h),v?v.parentNode.insertBefore(b,v.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(b,r.firstChild)),s.state.loading|=4}}var fc={$$typeof:E,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function k4(r,s,u,h,b,v,T,Y,ne){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=tn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tn(0),this.hiddenUpdates=tn(null),this.identifierPrefix=h,this.onUncaughtError=b,this.onCaughtError=v,this.onRecoverableError=T,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ne,this.incompleteTransitions=new Map}function Jy(r,s,u,h,b,v,T,Y,ne,he,je,_e){return r=new k4(r,s,u,T,ne,he,je,_e,Y),s=1,v===!0&&(s|=24),v=$r(3,null,null,s),r.current=v,v.stateNode=r,s=vh(),s.refCount++,r.pooledCache=s,s.refCount++,v.memoizedState={element:h,isDehydrated:u,cache:s},jh(v),r}function eb(r){return r?(r=Nl,r):Nl}function tb(r,s,u,h,b,v){b=eb(b),h.context===null?h.context=b:h.pendingContext=b,h=Zs(s),h.payload={element:u},v=v===void 0?null:v,v!==null&&(h.callback=v),u=Js(r,h,s),u!==null&&(Dr(u,r,s),Yo(u,r,s))}function nb(r,s){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var u=r.retryLane;r.retryLane=u!==0&&u<s?u:s}}function Um(r,s){nb(r,s),(r=r.alternate)&&nb(r,s)}function rb(r){if(r.tag===13||r.tag===31){var s=Ha(r,67108864);s!==null&&Dr(s,r,67108864),Um(r,67108864)}}function ib(r){if(r.tag===13||r.tag===31){var s=Ur();s=gr(s);var u=Ha(r,s);u!==null&&Dr(u,r,s),Um(r,s)}}var Sd=!0;function S4(r,s,u,h){var b=$.T;$.T=null;var v=G.p;try{G.p=2,qm(r,s,u,h)}finally{G.p=v,$.T=b}}function j4(r,s,u,h){var b=$.T;$.T=null;var v=G.p;try{G.p=8,qm(r,s,u,h)}finally{G.p=v,$.T=b}}function qm(r,s,u,h){if(Sd){var b=Ym(h);if(b===null)Dm(r,s,h,jd,u),ab(r,h);else if(N4(b,r,s,u,h))h.stopPropagation();else if(ab(r,h),s&4&&-1<C4.indexOf(r)){for(;b!==null;){var v=dr(b);if(v!==null)switch(v.tag){case 3:if(v=v.stateNode,v.current.memoizedState.isDehydrated){var T=hn(v.pendingLanes);if(T!==0){var Y=v;for(Y.pendingLanes|=2,Y.entangledLanes|=2;T;){var ne=1<<31-et(T);Y.entanglements[1]|=ne,T&=~ne}Hi(v),(Kt&6)===0&&(ad=ve()+500,ac(0))}}break;case 31:case 13:Y=Ha(v,2),Y!==null&&Dr(Y,v,2),od(),Um(v,2)}if(v=Ym(h),v===null&&Dm(r,s,h,jd,u),v===b)break;b=v}b!==null&&h.stopPropagation()}else Dm(r,s,h,null,u)}}function Ym(r){return r=xi(r),Pm(r)}var jd=null;function Pm(r){if(jd=null,r=jr(r),r!==null){var s=o(r);if(s===null)r=null;else{var u=s.tag;if(u===13){if(r=c(s),r!==null)return r;r=null}else if(u===31){if(r=d(s),r!==null)return r;r=null}else if(u===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;r=null}else s!==r&&(r=null)}}return jd=r,null}function sb(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(be()){case te:return 2;case oe:return 8;case Ce:case pe:return 32;case Se:return 268435456;default:return 32}default:return 32}}var Xm=!1,ua=null,da=null,fa=null,hc=new Map,mc=new Map,ha=[],C4="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 ab(r,s){switch(r){case"focusin":case"focusout":ua=null;break;case"dragenter":case"dragleave":da=null;break;case"mouseover":case"mouseout":fa=null;break;case"pointerover":case"pointerout":hc.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":mc.delete(s.pointerId)}}function pc(r,s,u,h,b,v){return r===null||r.nativeEvent!==v?(r={blockedOn:s,domEventName:u,eventSystemFlags:h,nativeEvent:v,targetContainers:[b]},s!==null&&(s=dr(s),s!==null&&rb(s)),r):(r.eventSystemFlags|=h,s=r.targetContainers,b!==null&&s.indexOf(b)===-1&&s.push(b),r)}function N4(r,s,u,h,b){switch(s){case"focusin":return ua=pc(ua,r,s,u,h,b),!0;case"dragenter":return da=pc(da,r,s,u,h,b),!0;case"mouseover":return fa=pc(fa,r,s,u,h,b),!0;case"pointerover":var v=b.pointerId;return hc.set(v,pc(hc.get(v)||null,r,s,u,h,b)),!0;case"gotpointercapture":return v=b.pointerId,mc.set(v,pc(mc.get(v)||null,r,s,u,h,b)),!0}return!1}function lb(r){var s=jr(r.target);if(s!==null){var u=o(s);if(u!==null){if(s=u.tag,s===13){if(s=c(u),s!==null){r.blockedOn=s,Ue(r.priority,function(){ib(u)});return}}else if(s===31){if(s=d(u),s!==null){r.blockedOn=s,Ue(r.priority,function(){ib(u)});return}}else if(s===3&&u.stateNode.current.memoizedState.isDehydrated){r.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Cd(r){if(r.blockedOn!==null)return!1;for(var s=r.targetContainers;0<s.length;){var u=Ym(r.nativeEvent);if(u===null){u=r.nativeEvent;var h=new u.constructor(u.type,u);ei=h,u.target.dispatchEvent(h),ei=null}else return s=dr(u),s!==null&&rb(s),r.blockedOn=u,!1;s.shift()}return!0}function ob(r,s,u){Cd(r)&&u.delete(s)}function E4(){Xm=!1,ua!==null&&Cd(ua)&&(ua=null),da!==null&&Cd(da)&&(da=null),fa!==null&&Cd(fa)&&(fa=null),hc.forEach(ob),mc.forEach(ob)}function Nd(r,s){r.blockedOn===s&&(r.blockedOn=null,Xm||(Xm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,E4)))}var Ed=null;function cb(r){Ed!==r&&(Ed=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Ed===r&&(Ed=null);for(var s=0;s<r.length;s+=3){var u=r[s],h=r[s+1],b=r[s+2];if(typeof h!="function"){if(Pm(h||u)===null)continue;break}var v=dr(u);v!==null&&(r.splice(s,3),s-=3,Yh(v,{pending:!0,data:b,method:u.method,action:h},h,b))}}))}function Kl(r){function s(ne){return Nd(ne,r)}ua!==null&&Nd(ua,r),da!==null&&Nd(da,r),fa!==null&&Nd(fa,r),hc.forEach(s),mc.forEach(s);for(var u=0;u<ha.length;u++){var h=ha[u];h.blockedOn===r&&(h.blockedOn=null)}for(;0<ha.length&&(u=ha[0],u.blockedOn===null);)lb(u),u.blockedOn===null&&ha.shift();if(u=(r.ownerDocument||r).$$reactFormReplay,u!=null)for(h=0;h<u.length;h+=3){var b=u[h],v=u[h+1],T=b[wt]||null;if(typeof v=="function")T||cb(u);else if(T){var Y=null;if(v&&v.hasAttribute("formAction")){if(b=v,T=v[wt]||null)Y=T.formAction;else if(Pm(b)!==null)continue}else Y=T.action;typeof Y=="function"?u[h+1]=Y:(u.splice(h,3),h-=3),cb(u)}}}function ub(){function r(v){v.canIntercept&&v.info==="react-transition"&&v.intercept({handler:function(){return new Promise(function(T){return b=T})},focusReset:"manual",scroll:"manual"})}function s(){b!==null&&(b(),b=null),h||setTimeout(u,20)}function u(){if(!h&&!navigation.transition){var v=navigation.currentEntry;v&&v.url!=null&&navigation.navigate(v.url,{state:v.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var h=!1,b=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(u,100),function(){h=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),b!==null&&(b(),b=null)}}}function Vm(r){this._internalRoot=r}Ad.prototype.render=Vm.prototype.render=function(r){var s=this._internalRoot;if(s===null)throw Error(i(409));var u=s.current,h=Ur();tb(u,h,r,s,null,null)},Ad.prototype.unmount=Vm.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var s=r.containerInfo;tb(r.current,2,null,r,null,null),od(),s[yr]=null}};function Ad(r){this._internalRoot=r}Ad.prototype.unstable_scheduleHydration=function(r){if(r){var s=ce();r={blockedOn:null,target:r,priority:s};for(var u=0;u<ha.length&&s!==0&&s<ha[u].priority;u++);ha.splice(u,0,r),u===0&&lb(r)}};var db=t.version;if(db!=="19.2.4")throw Error(i(527,db,"19.2.4"));G.findDOMNode=function(r){var s=r._reactInternals;if(s===void 0)throw typeof r.render=="function"?Error(i(188)):(r=Object.keys(r).join(","),Error(i(268,r)));return r=f(s),r=r!==null?x(r):null,r=r===null?null:r.stateNode,r};var A4={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Dd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Dd.isDisabled&&Dd.supportsFiber)try{Ie=Dd.inject(A4),qe=Dd}catch{}}return gc.createRoot=function(r,s){if(!a(r))throw Error(i(299));var u=!1,h="",b=y1,v=b1,T=v1;return s!=null&&(s.unstable_strictMode===!0&&(u=!0),s.identifierPrefix!==void 0&&(h=s.identifierPrefix),s.onUncaughtError!==void 0&&(b=s.onUncaughtError),s.onCaughtError!==void 0&&(v=s.onCaughtError),s.onRecoverableError!==void 0&&(T=s.onRecoverableError)),s=Jy(r,1,!1,null,null,u,h,null,b,v,T,ub),r[yr]=s.current,Am(r),new Vm(s)},gc.hydrateRoot=function(r,s,u){if(!a(r))throw Error(i(299));var h=!1,b="",v=y1,T=b1,Y=v1,ne=null;return u!=null&&(u.unstable_strictMode===!0&&(h=!0),u.identifierPrefix!==void 0&&(b=u.identifierPrefix),u.onUncaughtError!==void 0&&(v=u.onUncaughtError),u.onCaughtError!==void 0&&(T=u.onCaughtError),u.onRecoverableError!==void 0&&(Y=u.onRecoverableError),u.formState!==void 0&&(ne=u.formState)),s=Jy(r,1,!0,s,u??null,h,b,ne,v,T,Y,ub),s.context=eb(null),u=s.current,h=Ur(),h=gr(h),b=Zs(h),b.callback=null,Js(u,b,h),u=h,s.current.lanes=u,Ne(s,u),Hi(s),r[yr]=s.current,Am(r),new Ad(s)},gc.version="19.2.4",gc}var kb;function I4(){if(kb)return Km.exports;kb=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(t){console.error(t)}}return e(),Km.exports=L4(),Km.exports}var H4=I4();const U4="modulepreload",q4=function(e){return"/"+e},Sb={},Px=function(t,n,i){let a=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(x=>Promise.resolve(x).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=c(n.map(f=>{if(f=q4(f),f in Sb)return;Sb[f]=!0;const x=f.endsWith(".css"),p=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const y=document.createElement("link");if(y.rel=x?"stylesheet":U4,x||(y.as="script"),y.crossOrigin="",y.href=f,m&&y.setAttribute("nonce",m),document.head.appendChild(y),x)return new Promise((g,w)=>{y.addEventListener("load",g),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return a.then(c=>{for(const d of c||[])d.status==="rejected"&&o(d.reason);return t().catch(o)})};class Y4 extends S.Component{constructor(){super(...arguments);fb(this,"state",{hasError:!1,error:null})}static getDerivedStateFromError(n){return{hasError:!0,error:n}}render(){var n;return this.state.hasError?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",children:[l.jsx("div",{className:"text-4xl mb-3",children:"🚨"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2",children:"Something went wrong"}),l.jsx("div",{className:"text-gray-500 text-sm mb-4",children:((n=this.state.error)==null?void 0:n.message)??"An unexpected error occurred."}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white rounded-lg text-sm hover:bg-gray-700",children:"Reload"})]})}):this.props.children}}const Gi="/api";async function zt(e){const t=await fetch(`${Gi}${e}`);if(!t.ok)throw new Error(`API error: ${t.status}`);return t.json()}async function an(e,t){const n=await fetch(`${Gi}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function Td(e,t){const n=await fetch(`${Gi}${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function P4(e,t){const n=await fetch(`${Gi}${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}async function Ui(e,t){const n={method:"DELETE"};t!==void 0&&(n.headers={"Content-Type":"application/json"},n.body=JSON.stringify(t));const i=await fetch(`${Gi}${e}`,n);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const ke={getCompany:()=>zt("/company"),getRoles:()=>zt("/roles"),getRole:e=>zt(`/roles/${e}`),getProjects:()=>zt("/projects"),getProject:e=>zt(`/projects/${e}`),getStandups:()=>zt("/operations/standups"),getWaves:()=>zt("/operations/waves"),getActiveWaves:()=>zt("/waves/active"),getWaveDetail:e=>zt(`/operations/waves/${e}`),patchWave:(e,t)=>Td(`/operations/waves/${e}`,t),getDecisions:()=>zt("/operations/decisions"),updateDecision:(e,t)=>P4(`/operations/decisions/${e}`,{content:t}),deleteDecision:e=>Ui(`/operations/decisions/${e}`),getOrgTree:()=>zt("/engine/org"),getSkills:()=>zt("/skills"),exportSkills:e=>zt(`/skills/export/${e}`),getSkillRegistry:()=>zt("/skills/registry"),installRegistrySkill:(e,t)=>an("/skills/registry/install",{skillId:e,url:t}),getPresets:()=>zt("/presets"),getPreset:e=>zt(`/presets/${e}`),installPreset:(e,t,n,i)=>an("/presets/install",{id:e,preset:t,knowledge:n,roleDefinitions:i}),removePreset:e=>Ui(`/presets/${e}`),createRole:e=>an("/engine/roles",e),updateRole:(e,t)=>Td(`/engine/roles/${e}`,t),deleteRole:e=>Ui(`/engine/roles/${e}`),getSessions:()=>zt("/sessions"),getSession:e=>zt(`/sessions/${e}`),createSession:(e,t="talk")=>an("/sessions",{roleId:e,mode:t}),deleteSession:e=>Ui(`/sessions/${e}`),deleteSessions:e=>Ui("/sessions",{ids:e}),deleteEmptySessions:()=>Ui("/sessions?empty=true"),updateSession:(e,t)=>Td(`/sessions/${e}`,t),abortSession:e=>an(`/sessions/${e}/abort`,{}),abortExec:e=>an(`/jobs/${e}/abort`,{}),replyToSession:(e,t,n)=>an(`/sessions/${e}/reply`,{message:t,...n&&{attachments:n}}),execute:e=>an("/jobs",e),saveWave:e=>an("/waves/save",e),getStatus:()=>zt("/status"),detectEngine:()=>an("/setup/detect-engine",{}),validatePath:e=>an("/setup/validate-path",{path:e}),scaffold:e=>an("/setup/scaffold",e),getTeams:()=>zt("/setup/teams"),browse:e=>an("/setup/browse",{path:e}),mkdir:(e,t)=>an("/setup/mkdir",{path:e,name:t}),connectAkb:e=>an("/setup/connect-akb",{path:e}),getRequiredTools:e=>an("/setup/required-tools",{team:e}),installTools:(e,t)=>fetch(`${Gi}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(n=>{var d;const i=(d=n.body)==null?void 0:d.getReader();if(!i)return;const a=new TextDecoder;let o="";const c=()=>i.read().then(({done:m,value:f})=>{if(m)return;o+=a.decode(f,{stream:!0});const x=o.split(`
51
+ `);o=x.pop()||"";let p="";for(const y of x)if(y.startsWith("event: "))p=y.slice(7);else if(y.startsWith("data: ")&&p){try{t(p,JSON.parse(y.slice(6)))}catch{}p=""}return c()});return c()}),getKnowledge:()=>zt("/knowledge"),getKnowledgeDoc:e=>{const t=e.split("/").map(encodeURIComponent).join("/");return zt(`/knowledge/${t}`)},createKnowledgeDoc:e=>an("/knowledge",e),updateKnowledgeDoc:(e,t)=>{const n=e.split("/").map(encodeURIComponent).join("/");return fetch(`${Gi}/knowledge/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})}).then(i=>{if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()})},deleteKnowledgeDoc:e=>{const t=e.split("/").map(encodeURIComponent).join("/");return Ui(`/knowledge/${t}`)},getKnowledgeHealth:()=>zt("/knowledge/health"),getPreferences:()=>zt("/preferences"),updatePreferences:e=>Td("/preferences",e),chatInChannel:e=>an("/speech/chat",e),getSaveStatus:(e="akb")=>zt(`/save/status?repo=${e}`),save:(e,t="akb")=>an(`/save?repo=${t}`,{message:e}),getSaveHistory:(e=20,t="akb")=>zt(`/save/history?limit=${e}&repo=${t}`),restoreSave:(e,t,n="akb")=>an(`/save/restore?repo=${n}`,{sha:e,paths:t}),initGit:(e="akb")=>an(`/save/init?repo=${e}`,{}),getSyncStatus:(e="akb")=>zt(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${Gi}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>zt(`/save/github-status?repo=${e}`),githubCreateRepo:(e,t="private",n="akb")=>an(`/save/github-create-repo?repo=${n}`,{name:e,visibility:t}),addRemote:(e,t="akb")=>an(`/save/remote?repo=${t}`,{url:e}),setCodeRoot:async e=>{const t=await fetch(`${Gi}/setup/code-root`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({codeRoot:e})}),n=await t.json();if(!t.ok)throw new Error(n.error||`API error: ${t.status}`);return n},getCodeRoot:()=>zt("/setup/code-root"),getCostSummary:()=>zt("/cost/summary"),getSyncRoles:()=>zt("/sync/roles"),applySyncUpdate:e=>an("/sync/apply",e),getCompanyStats:()=>zt("/sync/stats"),getCoins:()=>zt("/coins"),earnCoins:(e,t,n)=>an("/coins/earn",{amount:e,reason:t,ref:n}),spendCoins:(e,t,n)=>an("/coins/spend",{amount:e,reason:t,ref:n}),migrateCoins:e=>an("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>zt("/quests/progress"),saveQuestProgress:e=>fetch(`${Gi}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>t.json()),getActiveSessions:()=>zt("/active-sessions"),getActiveSession:e=>zt(`/active-sessions/${e}`),registerActiveSession:e=>an("/active-sessions/register",e),deleteActiveSession:e=>Ui(`/active-sessions/${e}`),cleanupActiveSessions:()=>an("/active-sessions/cleanup",{}),getGitStatus:(e="akb")=>zt(`/git/status?repo=${e}`),deleteWorktree:(e,t="akb")=>Ui(`/git/worktrees/${encodeURIComponent(e)}?repo=${t}`),deleteBranch:(e,t="akb")=>Ui(`/git/branches/${encodeURIComponent(e)}?repo=${t}`)},X4=Object.freeze(Object.defineProperty({__proto__:null,api:ke},Symbol.toStringTag,{value:"Module"}));function tr(e){return e==="working"||e==="awaiting_input"}function y2(e){return e==="streaming"||e==="awaiting_input"}function Na(e){return e==="streaming"||e==="awaiting_input"}function b2(e){const[t,n]=S.useState([]),[i,a]=S.useState("idle"),[o,c]=S.useState(""),[d,m]=S.useState([]),f=S.useRef(-1),x=S.useRef(null),p=S.useRef(0),y=S.useCallback(()=>{var C;if(!e)return;(C=x.current)==null||C.abort();const w=new AbortController;x.current=w,a("connecting");const k=f.current+1,j=`/api/sessions/${e}/stream?from=${k}`;fetch(j,{signal:w.signal}).then(async N=>{if(!N.ok||!N.body){a("error");return}a("streaming");const E=N.body.getReader(),A=new TextDecoder;let z="";for(;;){const{done:D,value:F}=await E.read();if(D)break;z+=A.decode(F,{stream:!0});const q=z.split(`
52
+ `);z=q.pop()??"";let V="";for(const L of q)if(L.startsWith("event: "))V=L.slice(7).trim();else if(L.startsWith("data: ")){try{const _=JSON.parse(L.slice(6));if(V==="activity"){const B=_;B.seq>f.current&&(f.current=B.seq),n(X=>X.some(R=>R.seq===B.seq)?X:[...X,B]),B.type==="text"&&c(X=>X+(B.data.text??"")),B.type==="dispatch:start"&&B.data.childSessionId&&m(X=>[...X,B.data.childSessionId]),B.type==="msg:done"?a("done"):B.type==="msg:error"&&a("error")}else if(V==="stream:end"){const B=_.reason;a(B==="done"?"done":B==="error"?"error":"done")}}catch{}V=""}}i==="streaming"&&a("done")}).catch(N=>{N.name!=="AbortError"&&(a("error"),p.current<3&&(p.current++,setTimeout(y,1e3*p.current)))})},[e]),g=S.useCallback(()=>{p.current=0,y()},[y]);return S.useEffect(()=>{if(!e){n([]),a("idle"),c(""),m([]),f.current=-1;return}return n([]),c(""),m([]),f.current=-1,p.current=0,y(),()=>{var w;(w=x.current)==null||w.abort()}},[e,y]),{events:t,status:i,textOutput:o,childSessionIds:d,reconnect:g}}function V4(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const W4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,G4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,K4={};function jb(e,t){return(K4.jsx?G4:W4).test(e)}const Q4=/[ \t\n\f\r]/g;function Z4(e){return typeof e=="object"?e.type==="text"?Cb(e.value):!1:Cb(e)}function Cb(e){return e.replace(Q4,"")===""}class Zc{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}}Zc.prototype.normal={};Zc.prototype.property={};Zc.prototype.space=void 0;function v2(e,t){const n={},i={};for(const a of e)Object.assign(n,a.property),Object.assign(i,a.normal);return new Zc(n,i,t)}function ex(e){return e.toLowerCase()}class Mr{constructor(t,n){this.attribute=n,this.property=t}}Mr.prototype.attribute="";Mr.prototype.booleanish=!1;Mr.prototype.boolean=!1;Mr.prototype.commaOrSpaceSeparated=!1;Mr.prototype.commaSeparated=!1;Mr.prototype.defined=!1;Mr.prototype.mustUseProperty=!1;Mr.prototype.number=!1;Mr.prototype.overloadedBoolean=!1;Mr.prototype.property="";Mr.prototype.spaceSeparated=!1;Mr.prototype.space=void 0;let J4=0;const At=bl(),Un=bl(),tx=bl(),He=bl(),bn=bl(),so=bl(),qr=bl();function bl(){return 2**++J4}const nx=Object.freeze(Object.defineProperty({__proto__:null,boolean:At,booleanish:Un,commaOrSpaceSeparated:qr,commaSeparated:so,number:He,overloadedBoolean:tx,spaceSeparated:bn},Symbol.toStringTag,{value:"Module"})),ep=Object.keys(nx);class Xx extends Mr{constructor(t,n,i,a){let o=-1;if(super(t,n),Nb(this,"space",a),typeof i=="number")for(;++o<ep.length;){const c=ep[o];Nb(this,ep[o],(i&nx[c])===nx[c])}}}Xx.prototype.defined=!0;function Nb(e,t,n){n&&(e[t]=n)}function ko(e){const t={},n={};for(const[i,a]of Object.entries(e.properties)){const o=new Xx(i,e.transform(e.attributes||{},i),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),t[i]=o,n[ex(i)]=i,n[ex(o.attribute)]=i}return new Zc(t,n,e.space)}const w2=ko({properties:{ariaActiveDescendant:null,ariaAtomic:Un,ariaAutoComplete:null,ariaBusy:Un,ariaChecked:Un,ariaColCount:He,ariaColIndex:He,ariaColSpan:He,ariaControls:bn,ariaCurrent:null,ariaDescribedBy:bn,ariaDetails:null,ariaDisabled:Un,ariaDropEffect:bn,ariaErrorMessage:null,ariaExpanded:Un,ariaFlowTo:bn,ariaGrabbed:Un,ariaHasPopup:null,ariaHidden:Un,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:bn,ariaLevel:He,ariaLive:null,ariaModal:Un,ariaMultiLine:Un,ariaMultiSelectable:Un,ariaOrientation:null,ariaOwns:bn,ariaPlaceholder:null,ariaPosInSet:He,ariaPressed:Un,ariaReadOnly:Un,ariaRelevant:null,ariaRequired:Un,ariaRoleDescription:bn,ariaRowCount:He,ariaRowIndex:He,ariaRowSpan:He,ariaSelected:Un,ariaSetSize:He,ariaSort:null,ariaValueMax:He,ariaValueMin:He,ariaValueNow:He,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function k2(e,t){return t in e?e[t]:t}function S2(e,t){return k2(e,t.toLowerCase())}const ej=ko({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:so,acceptCharset:bn,accessKey:bn,action:null,allow:null,allowFullScreen:At,allowPaymentRequest:At,allowUserMedia:At,alt:null,as:null,async:At,autoCapitalize:null,autoComplete:bn,autoFocus:At,autoPlay:At,blocking:bn,capture:null,charSet:null,checked:At,cite:null,className:bn,cols:He,colSpan:null,content:null,contentEditable:Un,controls:At,controlsList:bn,coords:He|so,crossOrigin:null,data:null,dateTime:null,decoding:null,default:At,defer:At,dir:null,dirName:null,disabled:At,download:tx,draggable:Un,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:At,formTarget:null,headers:bn,height:He,hidden:tx,high:He,href:null,hrefLang:null,htmlFor:bn,httpEquiv:bn,id:null,imageSizes:null,imageSrcSet:null,inert:At,inputMode:null,integrity:null,is:null,isMap:At,itemId:null,itemProp:bn,itemRef:bn,itemScope:At,itemType:bn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:At,low:He,manifest:null,max:null,maxLength:He,media:null,method:null,min:null,minLength:He,multiple:At,muted:At,name:null,nonce:null,noModule:At,noValidate:At,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:At,optimum:He,pattern:null,ping:bn,placeholder:null,playsInline:At,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:At,referrerPolicy:null,rel:bn,required:At,reversed:At,rows:He,rowSpan:He,sandbox:bn,scope:null,scoped:At,seamless:At,selected:At,shadowRootClonable:At,shadowRootDelegatesFocus:At,shadowRootMode:null,shape:null,size:He,sizes:null,slot:null,span:He,spellCheck:Un,src:null,srcDoc:null,srcLang:null,srcSet:null,start:He,step:null,style:null,tabIndex:He,target:null,title:null,translate:null,type:null,typeMustMatch:At,useMap:null,value:Un,width:He,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:bn,axis:null,background:null,bgColor:null,border:He,borderColor:null,bottomMargin:He,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:At,declare:At,event:null,face:null,frame:null,frameBorder:null,hSpace:He,leftMargin:He,link:null,longDesc:null,lowSrc:null,marginHeight:He,marginWidth:He,noResize:At,noHref:At,noShade:At,noWrap:At,object:null,profile:null,prompt:null,rev:null,rightMargin:He,rules:null,scheme:null,scrolling:Un,standby:null,summary:null,text:null,topMargin:He,valueType:null,version:null,vAlign:null,vLink:null,vSpace:He,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:At,disableRemotePlayback:At,prefix:null,property:null,results:He,security:null,unselectable:null},space:"html",transform:S2}),tj=ko({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:qr,accentHeight:He,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:He,amplitude:He,arabicForm:null,ascent:He,attributeName:null,attributeType:null,azimuth:He,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:He,by:null,calcMode:null,capHeight:He,className:bn,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:He,diffuseConstant:He,direction:null,display:null,dur:null,divisor:He,dominantBaseline:null,download:At,dx:null,dy:null,edgeMode:null,editable:null,elevation:He,enableBackground:null,end:null,event:null,exponent:He,externalResourcesRequired:null,fill:null,fillOpacity:He,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:so,g2:so,glyphName:so,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:He,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:He,horizOriginX:He,horizOriginY:He,id:null,ideographic:He,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:He,k:He,k1:He,k2:He,k3:He,k4:He,kernelMatrix:qr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:He,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:He,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:He,overlineThickness:He,paintOrder:null,panose1:null,path:null,pathLength:He,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:bn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:He,pointsAtY:He,pointsAtZ:He,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:qr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:qr,rev:qr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:qr,requiredFeatures:qr,requiredFonts:qr,requiredFormats:qr,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:He,specularExponent:He,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:He,strikethroughThickness:He,string:null,stroke:null,strokeDashArray:qr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:He,strokeOpacity:He,strokeWidth:null,style:null,surfaceScale:He,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:qr,tabIndex:He,tableValues:null,target:null,targetX:He,targetY:He,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:qr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:He,underlineThickness:He,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:He,values:null,vAlphabetic:He,vMathematical:He,vectorEffect:null,vHanging:He,vIdeographic:He,version:null,vertAdvY:He,vertOriginX:He,vertOriginY:He,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:He,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:k2}),j2=ko({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),C2=ko({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:S2}),N2=ko({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nj={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"},rj=/[A-Z]/g,Eb=/-[a-z]/g,ij=/^data[-\w.:]+$/i;function sj(e,t){const n=ex(t);let i=t,a=Mr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ij.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Eb,lj);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Eb.test(o)){let c=o.replace(rj,aj);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Xx}return new a(i,t)}function aj(e){return"-"+e.toLowerCase()}function lj(e){return e.charAt(1).toUpperCase()}const oj=v2([w2,ej,j2,C2,N2],"html"),Vx=v2([w2,tj,j2,C2,N2],"svg");function cj(e){return e.join(" ").trim()}var Ql={},tp,Ab;function uj(){if(Ab)return tp;Ab=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,m=`
53
+ `,f="/",x="*",p="",y="comment",g="declaration";function w(j,C){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];C=C||{};var N=1,E=1;function A(R){var H=R.match(t);H&&(N+=H.length);var $=R.lastIndexOf(m);E=~$?R.length-$:E+R.length}function z(){var R={line:N,column:E};return function(H){return H.position=new D(R),V(),H}}function D(R){this.start=R,this.end={line:N,column:E},this.source=C.source}D.prototype.content=j;function F(R){var H=new Error(C.source+":"+N+":"+E+": "+R);if(H.reason=R,H.filename=C.source,H.line=N,H.column=E,H.source=j,!C.silent)throw H}function q(R){var H=R.exec(j);if(H){var $=H[0];return A($),j=j.slice($.length),H}}function V(){q(n)}function L(R){var H;for(R=R||[];H=_();)H!==!1&&R.push(H);return R}function _(){var R=z();if(!(f!=j.charAt(0)||x!=j.charAt(1))){for(var H=2;p!=j.charAt(H)&&(x!=j.charAt(H)||f!=j.charAt(H+1));)++H;if(H+=2,p===j.charAt(H-1))return F("End of comment missing");var $=j.slice(2,H-2);return E+=2,A($),j=j.slice(H),E+=2,R({type:y,comment:$})}}function B(){var R=z(),H=q(i);if(H){if(_(),!q(a))return F("property missing ':'");var $=q(o),G=R({type:g,property:k(H[0].replace(e,p)),value:$?k($[0].replace(e,p)):p});return q(c),G}}function X(){var R=[];L(R);for(var H;H=B();)H!==!1&&(R.push(H),L(R));return R}return V(),X()}function k(j){return j?j.replace(d,p):p}return tp=w,tp}var Db;function dj(){if(Db)return Ql;Db=1;var e=Ql&&Ql.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ql,"__esModule",{value:!0}),Ql.default=n;const t=e(uj());function n(i,a){let o=null;if(!i||typeof i!="string")return o;const c=(0,t.default)(i),d=typeof a=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:f,value:x}=m;d?a(f,x,m):x&&(o=o||{},o[f]=x)}),o}return Ql}var yc={},Tb;function fj(){if(Tb)return yc;Tb=1,Object.defineProperty(yc,"__esModule",{value:!0}),yc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(f){return!f||n.test(f)||e.test(f)},c=function(f,x){return x.toUpperCase()},d=function(f,x){return"".concat(x,"-")},m=function(f,x){return x===void 0&&(x={}),o(f)?f:(f=f.toLowerCase(),x.reactCompat?f=f.replace(a,d):f=f.replace(i,d),f.replace(t,c))};return yc.camelCase=m,yc}var bc,_b;function hj(){if(_b)return bc;_b=1;var e=bc&&bc.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(dj()),n=fj();function i(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(d,m){d&&m&&(c[(0,n.camelCase)(d,o)]=m)}),c}return i.default=i,bc=i,bc}var mj=hj();const pj=zf(mj),E2=A2("end"),Wx=A2("start");function A2(e){return t;function t(n){const i=n&&n.position&&n.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 xj(e){const t=Wx(e),n=E2(e);if(t&&n)return{start:t,end:n}}function Mc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Mb(e.position):"start"in e||"end"in e?Mb(e):"line"in e||"column"in e?rx(e):""}function rx(e){return Fb(e&&e.line)+":"+Fb(e&&e.column)}function Mb(e){return rx(e&&e.start)+"-"+rx(e&&e.end)}function Fb(e){return e&&typeof e=="number"?e:1}class xr extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let a="",o={},c=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof i=="string"){const m=i.indexOf(":");m===-1?o.ruleId=i:(o.source=i.slice(0,m),o.ruleId=i.slice(m+1))}if(!o.place&&o.ancestors&&o.ancestors){const m=o.ancestors[o.ancestors.length-1];m&&(o.place=m.position)}const d=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=d?d.line:void 0,this.name=Mc(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}xr.prototype.file="";xr.prototype.name="";xr.prototype.reason="";xr.prototype.message="";xr.prototype.stack="";xr.prototype.column=void 0;xr.prototype.line=void 0;xr.prototype.ancestors=void 0;xr.prototype.cause=void 0;xr.prototype.fatal=void 0;xr.prototype.place=void 0;xr.prototype.ruleId=void 0;xr.prototype.source=void 0;const Gx={}.hasOwnProperty,gj=new Map,yj=/[A-Z]/g,bj=new Set(["table","tbody","thead","tfoot","tr"]),vj=new Set(["td","th"]),D2="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wj(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=Dj(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=Aj(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Vx:oj,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=T2(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function T2(e,t,n){if(t.type==="element")return kj(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Sj(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Cj(e,t,n);if(t.type==="mdxjsEsm")return jj(e,t);if(t.type==="root")return Nj(e,t,n);if(t.type==="text")return Ej(e,t)}function kj(e,t,n){const i=e.schema;let a=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(a=Vx,e.schema=a),e.ancestors.push(t);const o=M2(e,t.tagName,!1),c=Tj(e,t);let d=Qx(e,t);return bj.has(t.tagName)&&(d=d.filter(function(m){return typeof m=="string"?!Z4(m):!0})),_2(e,c,o,t),Kx(c,d),e.ancestors.pop(),e.schema=i,e.create(t,o,c,n)}function Sj(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Oc(e,t.position)}function jj(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Oc(e,t.position)}function Cj(e,t,n){const i=e.schema;let a=i;t.name==="svg"&&i.space==="html"&&(a=Vx,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:M2(e,t.name,!0),c=_j(e,t),d=Qx(e,t);return _2(e,c,o,t),Kx(c,d),e.ancestors.pop(),e.schema=i,e.create(t,o,c,n)}function Nj(e,t,n){const i={};return Kx(i,Qx(e,t)),e.create(t,e.Fragment,i,n)}function Ej(e,t){return t.value}function _2(e,t,n,i){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=i)}function Kx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Aj(e,t,n){return i;function i(a,o,c,d){const f=Array.isArray(c.children)?n:t;return d?f(o,c,d):f(o,c)}}function Dj(e,t){return n;function n(i,a,o,c){const d=Array.isArray(o.children),m=Wx(i);return t(a,o,c,d,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function Tj(e,t){const n={};let i,a;for(a in t.properties)if(a!=="children"&&Gx.call(t.properties,a)){const o=Mj(e,a,t.properties[a]);if(o){const[c,d]=o;e.tableCellAlignToStyle&&c==="align"&&typeof d=="string"&&vj.has(t.tagName)?i=d:n[c]=d}}if(i){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function _j(e,t){const n={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const o=i.data.estree.body[0];o.type;const c=o.expression;c.type;const d=c.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else Oc(e,t.position);else{const a=i.name;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const d=i.value.data.estree.body[0];d.type,o=e.evaluater.evaluateExpression(d.expression)}else Oc(e,t.position);else o=i.value===null?!0:i.value;n[a]=o}return n}function Qx(e,t){const n=[];let i=-1;const a=e.passKeys?new Map:gj;for(;++i<t.children.length;){const o=t.children[i];let c;if(e.passKeys){const m=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(m){const f=a.get(m)||0;c=m+"-"+f,a.set(m,f+1)}}const d=T2(e,o,c);d!==void 0&&n.push(d)}return n}function Mj(e,t,n){const i=sj(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?V4(n):cj(n)),i.property==="style"){let a=typeof n=="object"?n:Fj(e,String(n));return e.stylePropertyNameCase==="css"&&(a=Rj(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&i.space?nj[i.property]||i.property:i.attribute,n]}}function Fj(e,t){try{return pj(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const i=n,a=new xr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=D2+"#cannot-parse-style-attribute",a}}function M2(e,t,n){let i;if(!n)i={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,c;for(;++o<a.length;){const d=jb(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};c=c?{type:"MemberExpression",object:c,property:d,computed:!!(o&&d.type==="Literal"),optional:!1}:d}i=c}else i=jb(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(i.type==="Literal"){const a=i.value;return Gx.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(i);Oc(e)}function Oc(e,t){const n=new xr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=D2+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Rj(e){const t={};let n;for(n in e)Gx.call(e,n)&&(t[zj(n)]=e[n]);return t}function zj(e){let t=e.replace(yj,Bj);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Bj(e){return"-"+e.toLowerCase()}const np={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"]},$j={};function Zx(e,t){const n=$j,i=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return F2(e,i,a)}function F2(e,t,n){if(Oj(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Rb(e.children,t,n)}return Array.isArray(e)?Rb(e,t,n):""}function Rb(e,t,n){const i=[];let a=-1;for(;++a<e.length;)i[a]=F2(e[a],t,n);return i.join("")}function Oj(e){return!!(e&&typeof e=="object")}const zb=document.createElement("i");function Jx(e){const t="&"+e+";";zb.innerHTML=t;const n=zb.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Wr(e,t,n,i){const a=e.length;let o=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,i.length<1e4)c=Array.from(i),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);o<i.length;)c=i.slice(o,o+1e4),c.unshift(t,0),e.splice(...c),o+=1e4,t+=1e4}function ci(e,t){return e.length>0?(Wr(e,e.length,0,t),e):t}const Bb={}.hasOwnProperty;function R2(e){const t={};let n=-1;for(;++n<e.length;)Lj(t,e[n]);return t}function Lj(e,t){let n;for(n in t){const a=(Bb.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let c;if(o)for(c in o){Bb.call(a,c)||(a[c]=[]);const d=o[c];Ij(a[c],Array.isArray(d)?d:d?[d]:[])}}}function Ij(e,t){let n=-1;const i=[];for(;++n<t.length;)(t[n].add==="after"?e:i).push(t[n]);Wr(e,0,0,i)}function z2(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ni(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const wr=Da(/[A-Za-z]/),pr=Da(/[\dA-Za-z]/),Hj=Da(/[#-'*+\--9=?A-Z^-~]/);function mf(e){return e!==null&&(e<32||e===127)}const ix=Da(/\d/),Uj=Da(/[\dA-Fa-f]/),qj=Da(/[!-/:-@[-`{-~]/);function ft(e){return e!==null&&e<-2}function gn(e){return e!==null&&(e<0||e===32)}function Bt(e){return e===-2||e===-1||e===32}const Bf=Da(new RegExp("\\p{P}|\\p{S}","u")),ml=Da(/\s/);function Da(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function So(e){const t=[];let n=-1,i=0,a=0;for(;++n<e.length;){const o=e.charCodeAt(n);let c="";if(o===37&&pr(e.charCodeAt(n+1))&&pr(e.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(c=String.fromCharCode(o));else if(o>55295&&o<57344){const d=e.charCodeAt(n+1);o<56320&&d>56319&&d<57344?(c=String.fromCharCode(o,d),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(i,n),encodeURIComponent(c)),i=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(i)}function Ut(e,t,n,i){const a=i?i-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(m){return Bt(m)?(e.enter(n),d(m)):t(m)}function d(m){return Bt(m)&&o++<a?(e.consume(m),d):(e.exit(n),t(m))}}const Yj={tokenize:Pj};function Pj(e){const t=e.attempt(this.parser.constructs.contentInitial,i,a);let n;return t;function i(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Ut(e,t,"linePrefix")}function a(d){return e.enter("paragraph"),o(d)}function o(d){const m=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=m),n=m,c(d)}function c(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return ft(d)?(e.consume(d),e.exit("chunkText"),o):(e.consume(d),c)}}const Xj={tokenize:Vj},$b={tokenize:Wj};function Vj(e){const t=this,n=[];let i=0,a,o,c;return d;function d(E){if(i<n.length){const A=n[i];return t.containerState=A[1],e.attempt(A[0].continuation,m,f)(E)}return f(E)}function m(E){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&N();const A=t.events.length;let z=A,D;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){D=t.events[z][1].end;break}C(i);let F=A;for(;F<t.events.length;)t.events[F][1].end={...D},F++;return Wr(t.events,z+1,0,t.events.slice(A)),t.events.length=F,f(E)}return d(E)}function f(E){if(i===n.length){if(!a)return y(E);if(a.currentConstruct&&a.currentConstruct.concrete)return w(E);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check($b,x,p)(E)}function x(E){return a&&N(),C(i),y(E)}function p(E){return t.parser.lazy[t.now().line]=i!==n.length,c=t.now().offset,w(E)}function y(E){return t.containerState={},e.attempt($b,g,w)(E)}function g(E){return i++,n.push([t.currentConstruct,t.containerState]),y(E)}function w(E){if(E===null){a&&N(),C(0),e.consume(E);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),k(E)}function k(E){if(E===null){j(e.exit("chunkFlow"),!0),C(0),e.consume(E);return}return ft(E)?(e.consume(E),j(e.exit("chunkFlow")),i=0,t.interrupt=void 0,d):(e.consume(E),k)}function j(E,A){const z=t.sliceStream(E);if(A&&z.push(null),E.previous=o,o&&(o.next=E),o=E,a.defineSkip(E.start),a.write(z),t.parser.lazy[E.start.line]){let D=a.events.length;for(;D--;)if(a.events[D][1].start.offset<c&&(!a.events[D][1].end||a.events[D][1].end.offset>c))return;const F=t.events.length;let q=F,V,L;for(;q--;)if(t.events[q][0]==="exit"&&t.events[q][1].type==="chunkFlow"){if(V){L=t.events[q][1].end;break}V=!0}for(C(i),D=F;D<t.events.length;)t.events[D][1].end={...L},D++;Wr(t.events,q+1,0,t.events.slice(F)),t.events.length=D}}function C(E){let A=n.length;for(;A-- >E;){const z=n[A];t.containerState=z[1],z[0].exit.call(t,e)}n.length=E}function N(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function Wj(e,t,n){return Ut(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function co(e){if(e===null||gn(e)||ml(e))return 1;if(Bf(e))return 2}function $f(e,t,n){const i=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!i.includes(o)&&(t=o(t,n),i.push(o))}return t}const sx={name:"attention",resolveAll:Gj,tokenize:Kj};function Gj(e,t){let n=-1,i,a,o,c,d,m,f,x;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(i=n;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[i][1].end},y={...e[n][1].start};Ob(p,-m),Ob(y,m),c={type:m>1?"strongSequence":"emphasisSequence",start:p,end:{...e[i][1].end}},d={type:m>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},o={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},a={type:m>1?"strong":"emphasis",start:{...c.start},end:{...d.end}},e[i][1].end={...c.start},e[n][1].start={...d.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=ci(f,[["enter",e[i][1],t],["exit",e[i][1],t]])),f=ci(f,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),f=ci(f,$f(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),f=ci(f,[["exit",o,t],["enter",d,t],["exit",d,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(x=2,f=ci(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):x=0,Wr(e,i-1,n-i+3,f),n=i+f.length-x-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Kj(e,t){const n=this.parser.constructs.attentionMarkers.null,i=this.previous,a=co(i);let o;return c;function c(m){return o=m,e.enter("attentionSequence"),d(m)}function d(m){if(m===o)return e.consume(m),d;const f=e.exit("attentionSequence"),x=co(m),p=!x||x===2&&a||n.includes(m),y=!a||a===2&&x||n.includes(i);return f._open=!!(o===42?p:p&&(a||!y)),f._close=!!(o===42?y:y&&(x||!p)),t(m)}}function Ob(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Qj={name:"autolink",tokenize:Zj};function Zj(e,t,n){let i=0;return a;function a(g){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(g){return wr(g)?(e.consume(g),c):g===64?n(g):f(g)}function c(g){return g===43||g===45||g===46||pr(g)?(i=1,d(g)):f(g)}function d(g){return g===58?(e.consume(g),i=0,m):(g===43||g===45||g===46||pr(g))&&i++<32?(e.consume(g),d):(i=0,f(g))}function m(g){return g===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):g===null||g===32||g===60||mf(g)?n(g):(e.consume(g),m)}function f(g){return g===64?(e.consume(g),x):Hj(g)?(e.consume(g),f):n(g)}function x(g){return pr(g)?p(g):n(g)}function p(g){return g===46?(e.consume(g),i=0,x):g===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):y(g)}function y(g){if((g===45||pr(g))&&i++<63){const w=g===45?y:p;return e.consume(g),w}return n(g)}}const Jc={partial:!0,tokenize:Jj};function Jj(e,t,n){return i;function i(o){return Bt(o)?Ut(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||ft(o)?t(o):n(o)}}const B2={continuation:{tokenize:tC},exit:nC,name:"blockQuote",tokenize:eC};function eC(e,t,n){const i=this;return a;function a(c){if(c===62){const d=i.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),o}return n(c)}function o(c){return Bt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function tC(e,t,n){const i=this;return a;function a(c){return Bt(c)?Ut(e,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(B2,t,n)(c)}}function nC(e){e.exit("blockQuote")}const $2={name:"characterEscape",tokenize:rC};function rC(e,t,n){return i;function i(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return qj(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const O2={name:"characterReference",tokenize:iC};function iC(e,t,n){const i=this;let a=0,o,c;return d;function d(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),m}function m(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),o=31,c=pr,x(p))}function f(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=Uj,x):(e.enter("characterReferenceValue"),o=7,c=ix,x(p))}function x(p){if(p===59&&a){const y=e.exit("characterReferenceValue");return c===pr&&!Jx(i.sliceSerialize(y))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(p)&&a++<o?(e.consume(p),x):n(p)}}const Lb={partial:!0,tokenize:aC},Ib={concrete:!0,name:"codeFenced",tokenize:sC};function sC(e,t,n){const i=this,a={partial:!0,tokenize:z};let o=0,c=0,d;return m;function m(D){return f(D)}function f(D){const F=i.events[i.events.length-1];return o=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,d=D,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(D)}function x(D){return D===d?(c++,e.consume(D),x):c<3?n(D):(e.exit("codeFencedFenceSequence"),Bt(D)?Ut(e,p,"whitespace")(D):p(D))}function p(D){return D===null||ft(D)?(e.exit("codeFencedFence"),i.interrupt?t(D):e.check(Lb,k,A)(D)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(D))}function y(D){return D===null||ft(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(D)):Bt(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ut(e,g,"whitespace")(D)):D===96&&D===d?n(D):(e.consume(D),y)}function g(D){return D===null||ft(D)?p(D):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(D))}function w(D){return D===null||ft(D)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(D)):D===96&&D===d?n(D):(e.consume(D),w)}function k(D){return e.attempt(a,A,j)(D)}function j(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),C}function C(D){return o>0&&Bt(D)?Ut(e,N,"linePrefix",o+1)(D):N(D)}function N(D){return D===null||ft(D)?e.check(Lb,k,A)(D):(e.enter("codeFlowValue"),E(D))}function E(D){return D===null||ft(D)?(e.exit("codeFlowValue"),N(D)):(e.consume(D),E)}function A(D){return e.exit("codeFenced"),t(D)}function z(D,F,q){let V=0;return L;function L(H){return D.enter("lineEnding"),D.consume(H),D.exit("lineEnding"),_}function _(H){return D.enter("codeFencedFence"),Bt(H)?Ut(D,B,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):B(H)}function B(H){return H===d?(D.enter("codeFencedFenceSequence"),X(H)):q(H)}function X(H){return H===d?(V++,D.consume(H),X):V>=c?(D.exit("codeFencedFenceSequence"),Bt(H)?Ut(D,R,"whitespace")(H):R(H)):q(H)}function R(H){return H===null||ft(H)?(D.exit("codeFencedFence"),F(H)):q(H)}}}function aC(e,t,n){const i=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return i.parser.lazy[i.now().line]?n(c):t(c)}}const rp={name:"codeIndented",tokenize:oC},lC={partial:!0,tokenize:cC};function oC(e,t,n){const i=this;return a;function a(f){return e.enter("codeIndented"),Ut(e,o,"linePrefix",5)(f)}function o(f){const x=i.events[i.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?c(f):n(f)}function c(f){return f===null?m(f):ft(f)?e.attempt(lC,c,m)(f):(e.enter("codeFlowValue"),d(f))}function d(f){return f===null||ft(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),d)}function m(f){return e.exit("codeIndented"),t(f)}}function cC(e,t,n){const i=this;return a;function a(c){return i.parser.lazy[i.now().line]?n(c):ft(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ut(e,o,"linePrefix",5)(c)}function o(c){const d=i.events[i.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):ft(c)?a(c):n(c)}}const uC={name:"codeText",previous:fC,resolve:dC,tokenize:hC};function dC(e){let t=e.length-4,n=3,i,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=n;++i<t;)if(e[i][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(i=n-1,t++;++i<=t;)a===void 0?i!==t&&e[i][1].type!=="lineEnding"&&(a=i):(i===t||e[i][1].type==="lineEnding")&&(e[a][1].type="codeTextData",i!==a+2&&(e[a][1].end=e[i-1][1].end,e.splice(a+2,i-a-2),t-=i-a-2,i=a+2),a=void 0);return e}function fC(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hC(e,t,n){let i=0,a,o;return c;function c(p){return e.enter("codeText"),e.enter("codeTextSequence"),d(p)}function d(p){return p===96?(e.consume(p),i++,d):(e.exit("codeTextSequence"),m(p))}function m(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),m):p===96?(o=e.enter("codeTextSequence"),a=0,x(p)):ft(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),m):(e.enter("codeTextData"),f(p))}function f(p){return p===null||p===32||p===96||ft(p)?(e.exit("codeTextData"),m(p)):(e.consume(p),f)}function x(p){return p===96?(e.consume(p),a++,x):a===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",f(p))}}class mC{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const i=n??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(t,i):t>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,n,i){const a=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return i&&vc(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),vc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),vc(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);vc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);vc(this.left,n.reverse())}}}function vc(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function L2(e){const t={};let n=-1,i,a,o,c,d,m,f;const x=new mC(e);for(;++n<x.length;){for(;n in t;)n=t[n];if(i=x.get(n),n&&i[1].type==="chunkFlow"&&x.get(n-1)[1].type==="listItemPrefix"&&(m=i[1]._tokenizer.events,o=0,o<m.length&&m[o][1].type==="lineEndingBlank"&&(o+=2),o<m.length&&m[o][1].type==="content"))for(;++o<m.length&&m[o][1].type!=="content";)m[o][1].type==="chunkText"&&(m[o][1]._isInFirstContentOfListItem=!0,o++);if(i[0]==="enter")i[1].contentType&&(Object.assign(t,pC(x,n)),n=t[n],f=!0);else if(i[1]._container){for(o=n,a=void 0;o--;)if(c=x.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(x.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=o);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(i[1].end={...x.get(a)[1].start},d=x.slice(a,n),d.unshift(i),x.splice(a,n-a+1,d))}}return Wr(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function pC(e,t){const n=e.get(t)[1],i=e.get(t)[2];let a=t-1;const o=[];let c=n._tokenizer;c||(c=i.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const d=c.events,m=[],f={};let x,p,y=-1,g=n,w=0,k=0;const j=[k];for(;g;){for(;e.get(++a)[1]!==g;);o.push(a),g._tokenizer||(x=i.sliceStream(g),g.next||x.push(null),p&&c.defineSkip(g.start),g._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(x),g._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),p=g,g=g.next}for(g=n;++y<d.length;)d[y][0]==="exit"&&d[y-1][0]==="enter"&&d[y][1].type===d[y-1][1].type&&d[y][1].start.line!==d[y][1].end.line&&(k=y+1,j.push(k),g._tokenizer=void 0,g.previous=void 0,g=g.next);for(c.events=[],g?(g._tokenizer=void 0,g.previous=void 0):j.pop(),y=j.length;y--;){const C=d.slice(j[y],j[y+1]),N=o.pop();m.push([N,N+C.length-1]),e.splice(N,2,C)}for(m.reverse(),y=-1;++y<m.length;)f[w+m[y][0]]=w+m[y][1],w+=m[y][1]-m[y][0]-1;return f}const xC={resolve:yC,tokenize:bC},gC={partial:!0,tokenize:vC};function yC(e){return L2(e),e}function bC(e,t){let n;return i;function i(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(d)}function a(d){return d===null?o(d):ft(d)?e.check(gC,c,o)(d):(e.consume(d),a)}function o(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function c(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function vC(e,t,n){const i=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ut(e,o,"linePrefix")}function o(c){if(c===null||ft(c))return n(c);const d=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):e.interrupt(i.parser.constructs.flow,n,t)(c)}}function I2(e,t,n,i,a,o,c,d,m){const f=m||Number.POSITIVE_INFINITY;let x=0;return p;function p(C){return C===60?(e.enter(i),e.enter(a),e.enter(o),e.consume(C),e.exit(o),y):C===null||C===32||C===41||mf(C)?n(C):(e.enter(i),e.enter(c),e.enter(d),e.enter("chunkString",{contentType:"string"}),k(C))}function y(C){return C===62?(e.enter(o),e.consume(C),e.exit(o),e.exit(a),e.exit(i),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),g(C))}function g(C){return C===62?(e.exit("chunkString"),e.exit(d),y(C)):C===null||C===60||ft(C)?n(C):(e.consume(C),C===92?w:g)}function w(C){return C===60||C===62||C===92?(e.consume(C),g):g(C)}function k(C){return!x&&(C===null||C===41||gn(C))?(e.exit("chunkString"),e.exit(d),e.exit(c),e.exit(i),t(C)):x<f&&C===40?(e.consume(C),x++,k):C===41?(e.consume(C),x--,k):C===null||C===32||C===40||mf(C)?n(C):(e.consume(C),C===92?j:k)}function j(C){return C===40||C===41||C===92?(e.consume(C),k):k(C)}}function H2(e,t,n,i,a,o){const c=this;let d=0,m;return f;function f(g){return e.enter(i),e.enter(a),e.consume(g),e.exit(a),e.enter(o),x}function x(g){return d>999||g===null||g===91||g===93&&!m||g===94&&!d&&"_hiddenFootnoteSupport"in c.parser.constructs?n(g):g===93?(e.exit(o),e.enter(a),e.consume(g),e.exit(a),e.exit(i),t):ft(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===null||g===91||g===93||ft(g)||d++>999?(e.exit("chunkString"),x(g)):(e.consume(g),m||(m=!Bt(g)),g===92?y:p)}function y(g){return g===91||g===92||g===93?(e.consume(g),d++,p):p(g)}}function U2(e,t,n,i,a,o){let c;return d;function d(y){return y===34||y===39||y===40?(e.enter(i),e.enter(a),e.consume(y),e.exit(a),c=y===40?41:y,m):n(y)}function m(y){return y===c?(e.enter(a),e.consume(y),e.exit(a),e.exit(i),t):(e.enter(o),f(y))}function f(y){return y===c?(e.exit(o),m(c)):y===null?n(y):ft(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Ut(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(y))}function x(y){return y===c||y===null||ft(y)?(e.exit("chunkString"),f(y)):(e.consume(y),y===92?p:x)}function p(y){return y===c||y===92?(e.consume(y),x):x(y)}}function Fc(e,t){let n;return i;function i(a){return ft(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,i):Bt(a)?Ut(e,i,n?"linePrefix":"lineSuffix")(a):t(a)}}const wC={name:"definition",tokenize:SC},kC={partial:!0,tokenize:jC};function SC(e,t,n){const i=this;let a;return o;function o(g){return e.enter("definition"),c(g)}function c(g){return H2.call(i,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function d(g){return a=Ni(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),m):n(g)}function m(g){return gn(g)?Fc(e,f)(g):f(g)}function f(g){return I2(e,x,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function x(g){return e.attempt(kC,p,p)(g)}function p(g){return Bt(g)?Ut(e,y,"whitespace")(g):y(g)}function y(g){return g===null||ft(g)?(e.exit("definition"),i.parser.defined.push(a),t(g)):n(g)}}function jC(e,t,n){return i;function i(d){return gn(d)?Fc(e,a)(d):n(d)}function a(d){return U2(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function o(d){return Bt(d)?Ut(e,c,"whitespace")(d):c(d)}function c(d){return d===null||ft(d)?t(d):n(d)}}const CC={name:"hardBreakEscape",tokenize:NC};function NC(e,t,n){return i;function i(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ft(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const EC={name:"headingAtx",resolve:AC,tokenize:DC};function AC(e,t){let n=e.length-2,i=3,a,o;return e[i][1].type==="whitespace"&&(i+=2),n-2>i&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&e[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(a={type:"atxHeadingText",start:e[i][1].start,end:e[n][1].end},o={type:"chunkText",start:e[i][1].start,end:e[n][1].end,contentType:"text"},Wr(e,i,n-i+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function DC(e,t,n){let i=0;return a;function a(x){return e.enter("atxHeading"),o(x)}function o(x){return e.enter("atxHeadingSequence"),c(x)}function c(x){return x===35&&i++<6?(e.consume(x),c):x===null||gn(x)?(e.exit("atxHeadingSequence"),d(x)):n(x)}function d(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||ft(x)?(e.exit("atxHeading"),t(x)):Bt(x)?Ut(e,d,"whitespace")(x):(e.enter("atxHeadingText"),f(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),d(x))}function f(x){return x===null||x===35||gn(x)?(e.exit("atxHeadingText"),d(x)):(e.consume(x),f)}}const TC=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Hb=["pre","script","style","textarea"],_C={concrete:!0,name:"htmlFlow",resolveTo:RC,tokenize:zC},MC={partial:!0,tokenize:$C},FC={partial:!0,tokenize:BC};function RC(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function zC(e,t,n){const i=this;let a,o,c,d,m;return f;function f(O){return x(O)}function x(O){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(O),p}function p(O){return O===33?(e.consume(O),y):O===47?(e.consume(O),o=!0,k):O===63?(e.consume(O),a=3,i.interrupt?t:M):wr(O)?(e.consume(O),c=String.fromCharCode(O),j):n(O)}function y(O){return O===45?(e.consume(O),a=2,g):O===91?(e.consume(O),a=5,d=0,w):wr(O)?(e.consume(O),a=4,i.interrupt?t:M):n(O)}function g(O){return O===45?(e.consume(O),i.interrupt?t:M):n(O)}function w(O){const Z="CDATA[";return O===Z.charCodeAt(d++)?(e.consume(O),d===Z.length?i.interrupt?t:B:w):n(O)}function k(O){return wr(O)?(e.consume(O),c=String.fromCharCode(O),j):n(O)}function j(O){if(O===null||O===47||O===62||gn(O)){const Z=O===47,ee=c.toLowerCase();return!Z&&!o&&Hb.includes(ee)?(a=1,i.interrupt?t(O):B(O)):TC.includes(c.toLowerCase())?(a=6,Z?(e.consume(O),C):i.interrupt?t(O):B(O)):(a=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(O):o?N(O):E(O))}return O===45||pr(O)?(e.consume(O),c+=String.fromCharCode(O),j):n(O)}function C(O){return O===62?(e.consume(O),i.interrupt?t:B):n(O)}function N(O){return Bt(O)?(e.consume(O),N):L(O)}function E(O){return O===47?(e.consume(O),L):O===58||O===95||wr(O)?(e.consume(O),A):Bt(O)?(e.consume(O),E):L(O)}function A(O){return O===45||O===46||O===58||O===95||pr(O)?(e.consume(O),A):z(O)}function z(O){return O===61?(e.consume(O),D):Bt(O)?(e.consume(O),z):E(O)}function D(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),m=O,F):Bt(O)?(e.consume(O),D):q(O)}function F(O){return O===m?(e.consume(O),m=null,V):O===null||ft(O)?n(O):(e.consume(O),F)}function q(O){return O===null||O===34||O===39||O===47||O===60||O===61||O===62||O===96||gn(O)?z(O):(e.consume(O),q)}function V(O){return O===47||O===62||Bt(O)?E(O):n(O)}function L(O){return O===62?(e.consume(O),_):n(O)}function _(O){return O===null||ft(O)?B(O):Bt(O)?(e.consume(O),_):n(O)}function B(O){return O===45&&a===2?(e.consume(O),$):O===60&&a===1?(e.consume(O),G):O===62&&a===4?(e.consume(O),U):O===63&&a===3?(e.consume(O),M):O===93&&a===5?(e.consume(O),K):ft(O)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(MC,P,X)(O)):O===null||ft(O)?(e.exit("htmlFlowData"),X(O)):(e.consume(O),B)}function X(O){return e.check(FC,R,P)(O)}function R(O){return e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),H}function H(O){return O===null||ft(O)?X(O):(e.enter("htmlFlowData"),B(O))}function $(O){return O===45?(e.consume(O),M):B(O)}function G(O){return O===47?(e.consume(O),c="",Q):B(O)}function Q(O){if(O===62){const Z=c.toLowerCase();return Hb.includes(Z)?(e.consume(O),U):B(O)}return wr(O)&&c.length<8?(e.consume(O),c+=String.fromCharCode(O),Q):B(O)}function K(O){return O===93?(e.consume(O),M):B(O)}function M(O){return O===62?(e.consume(O),U):O===45&&a===2?(e.consume(O),M):B(O)}function U(O){return O===null||ft(O)?(e.exit("htmlFlowData"),P(O)):(e.consume(O),U)}function P(O){return e.exit("htmlFlow"),t(O)}}function BC(e,t,n){const i=this;return a;function a(c){return ft(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):n(c)}function o(c){return i.parser.lazy[i.now().line]?n(c):t(c)}}function $C(e,t,n){return i;function i(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Jc,t,n)}}const OC={name:"htmlText",tokenize:LC};function LC(e,t,n){const i=this;let a,o,c;return d;function d(M){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(M),m}function m(M){return M===33?(e.consume(M),f):M===47?(e.consume(M),z):M===63?(e.consume(M),E):wr(M)?(e.consume(M),q):n(M)}function f(M){return M===45?(e.consume(M),x):M===91?(e.consume(M),o=0,w):wr(M)?(e.consume(M),N):n(M)}function x(M){return M===45?(e.consume(M),g):n(M)}function p(M){return M===null?n(M):M===45?(e.consume(M),y):ft(M)?(c=p,G(M)):(e.consume(M),p)}function y(M){return M===45?(e.consume(M),g):p(M)}function g(M){return M===62?$(M):M===45?y(M):p(M)}function w(M){const U="CDATA[";return M===U.charCodeAt(o++)?(e.consume(M),o===U.length?k:w):n(M)}function k(M){return M===null?n(M):M===93?(e.consume(M),j):ft(M)?(c=k,G(M)):(e.consume(M),k)}function j(M){return M===93?(e.consume(M),C):k(M)}function C(M){return M===62?$(M):M===93?(e.consume(M),C):k(M)}function N(M){return M===null||M===62?$(M):ft(M)?(c=N,G(M)):(e.consume(M),N)}function E(M){return M===null?n(M):M===63?(e.consume(M),A):ft(M)?(c=E,G(M)):(e.consume(M),E)}function A(M){return M===62?$(M):E(M)}function z(M){return wr(M)?(e.consume(M),D):n(M)}function D(M){return M===45||pr(M)?(e.consume(M),D):F(M)}function F(M){return ft(M)?(c=F,G(M)):Bt(M)?(e.consume(M),F):$(M)}function q(M){return M===45||pr(M)?(e.consume(M),q):M===47||M===62||gn(M)?V(M):n(M)}function V(M){return M===47?(e.consume(M),$):M===58||M===95||wr(M)?(e.consume(M),L):ft(M)?(c=V,G(M)):Bt(M)?(e.consume(M),V):$(M)}function L(M){return M===45||M===46||M===58||M===95||pr(M)?(e.consume(M),L):_(M)}function _(M){return M===61?(e.consume(M),B):ft(M)?(c=_,G(M)):Bt(M)?(e.consume(M),_):V(M)}function B(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),a=M,X):ft(M)?(c=B,G(M)):Bt(M)?(e.consume(M),B):(e.consume(M),R)}function X(M){return M===a?(e.consume(M),a=void 0,H):M===null?n(M):ft(M)?(c=X,G(M)):(e.consume(M),X)}function R(M){return M===null||M===34||M===39||M===60||M===61||M===96?n(M):M===47||M===62||gn(M)?V(M):(e.consume(M),R)}function H(M){return M===47||M===62||gn(M)?V(M):n(M)}function $(M){return M===62?(e.consume(M),e.exit("htmlTextData"),e.exit("htmlText"),t):n(M)}function G(M){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),Q}function Q(M){return Bt(M)?Ut(e,K,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):K(M)}function K(M){return e.enter("htmlTextData"),c(M)}}const e0={name:"labelEnd",resolveAll:qC,resolveTo:YC,tokenize:PC},IC={tokenize:XC},HC={tokenize:VC},UC={tokenize:WC};function qC(e){let t=-1;const n=[];for(;++t<e.length;){const i=e[t][1];if(n.push(e[t]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const a=i.type==="labelImage"?4:2;i.type="data",t+=a}}return e.length!==n.length&&Wr(e,0,e.length,n),e}function YC(e,t){let n=e.length,i=0,a,o,c,d;for(;n--;)if(a=e[n][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=n,a.type!=="labelLink")){i=2;break}}else a.type==="labelEnd"&&(c=n);const m={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[o][1].start},end:{...e[c][1].end}},x={type:"labelText",start:{...e[o+i+2][1].end},end:{...e[c-2][1].start}};return d=[["enter",m,t],["enter",f,t]],d=ci(d,e.slice(o+1,o+i+3)),d=ci(d,[["enter",x,t]]),d=ci(d,$f(t.parser.constructs.insideSpan.null,e.slice(o+i+4,c-3),t)),d=ci(d,[["exit",x,t],e[c-2],e[c-1],["exit",f,t]]),d=ci(d,e.slice(c+1)),d=ci(d,[["exit",m,t]]),Wr(e,o,e.length,d),e}function PC(e,t,n){const i=this;let a=i.events.length,o,c;for(;a--;)if((i.events[a][1].type==="labelImage"||i.events[a][1].type==="labelLink")&&!i.events[a][1]._balanced){o=i.events[a][1];break}return d;function d(y){return o?o._inactive?p(y):(c=i.parser.defined.includes(Ni(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),m):n(y)}function m(y){return y===40?e.attempt(IC,x,c?x:p)(y):y===91?e.attempt(HC,x,c?f:p)(y):c?x(y):p(y)}function f(y){return e.attempt(UC,x,p)(y)}function x(y){return t(y)}function p(y){return o._balanced=!0,n(y)}}function XC(e,t,n){return i;function i(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),a}function a(p){return gn(p)?Fc(e,o)(p):o(p)}function o(p){return p===41?x(p):I2(e,c,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function c(p){return gn(p)?Fc(e,m)(p):x(p)}function d(p){return n(p)}function m(p){return p===34||p===39||p===40?U2(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):x(p)}function f(p){return gn(p)?Fc(e,x)(p):x(p)}function x(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function VC(e,t,n){const i=this;return a;function a(d){return H2.call(i,e,o,c,"reference","referenceMarker","referenceString")(d)}function o(d){return i.parser.defined.includes(Ni(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function c(d){return n(d)}}function WC(e,t,n){return i;function i(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),a}function a(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const GC={name:"labelStartImage",resolveAll:e0.resolveAll,tokenize:KC};function KC(e,t,n){const i=this;return a;function a(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),o}function o(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),c):n(d)}function c(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(d):t(d)}}const QC={name:"labelStartLink",resolveAll:e0.resolveAll,tokenize:ZC};function ZC(e,t,n){const i=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),o}function o(c){return c===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(c):t(c)}}const ip={name:"lineEnding",tokenize:JC};function JC(e,t){return n;function n(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Ut(e,t,"linePrefix")}}const sf={name:"thematicBreak",tokenize:eN};function eN(e,t,n){let i=0,a;return o;function o(f){return e.enter("thematicBreak"),c(f)}function c(f){return a=f,d(f)}function d(f){return f===a?(e.enter("thematicBreakSequence"),m(f)):i>=3&&(f===null||ft(f))?(e.exit("thematicBreak"),t(f)):n(f)}function m(f){return f===a?(e.consume(f),i++,m):(e.exit("thematicBreakSequence"),Bt(f)?Ut(e,d,"whitespace")(f):d(f))}}const Tr={continuation:{tokenize:iN},exit:aN,name:"list",tokenize:rN},tN={partial:!0,tokenize:lN},nN={partial:!0,tokenize:sN};function rN(e,t,n){const i=this,a=i.events[i.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return d;function d(g){const w=i.containerState.type||(g===42||g===43||g===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||g===i.containerState.marker:ix(g)){if(i.containerState.type||(i.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),g===42||g===45?e.check(sf,n,f)(g):f(g);if(!i.interrupt||g===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(g)}return n(g)}function m(g){return ix(g)&&++c<10?(e.consume(g),m):(!i.interrupt||c<2)&&(i.containerState.marker?g===i.containerState.marker:g===41||g===46)?(e.exit("listItemValue"),f(g)):n(g)}function f(g){return e.enter("listItemMarker"),e.consume(g),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||g,e.check(Jc,i.interrupt?n:x,e.attempt(tN,y,p))}function x(g){return i.containerState.initialBlankLine=!0,o++,y(g)}function p(g){return Bt(g)?(e.enter("listItemPrefixWhitespace"),e.consume(g),e.exit("listItemPrefixWhitespace"),y):n(g)}function y(g){return i.containerState.size=o+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(g)}}function iN(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check(Jc,a,o);function a(d){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Ut(e,t,"listItemIndent",i.containerState.size+1)(d)}function o(d){return i.containerState.furtherBlankLines||!Bt(d)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,c(d)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(nN,t,c)(d))}function c(d){return i.containerState._closeFlow=!0,i.interrupt=void 0,Ut(e,e.attempt(Tr,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function sN(e,t,n){const i=this;return Ut(e,a,"listItemIndent",i.containerState.size+1);function a(o){const c=i.events[i.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===i.containerState.size?t(o):n(o)}}function aN(e){e.exit(this.containerState.type)}function lN(e,t,n){const i=this;return Ut(e,a,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=i.events[i.events.length-1];return!Bt(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Ub={name:"setextUnderline",resolveTo:oN,tokenize:cN};function oN(e,t){let n=e.length,i,a,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){i=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const c={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[i][1],t]),e[i][1].end={...e[o][1].end}):e[i][1]=c,e.push(["exit",c,t]),e}function cN(e,t,n){const i=this;let a;return o;function o(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"),a=f,c(f)):n(f)}function c(f){return e.enter("setextHeadingLineSequence"),d(f)}function d(f){return f===a?(e.consume(f),d):(e.exit("setextHeadingLineSequence"),Bt(f)?Ut(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||ft(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const uN={tokenize:dN};function dN(e){const t=this,n=e.attempt(Jc,i,e.attempt(this.parser.constructs.flowInitial,a,Ut(e,e.attempt(this.parser.constructs.flow,a,e.attempt(xC,a)),"linePrefix")));return n;function i(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const fN={resolveAll:Y2()},hN=q2("string"),mN=q2("text");function q2(e){return{resolveAll:Y2(e==="text"?pN:void 0),tokenize:t};function t(n){const i=this,a=this.parser.constructs[e],o=n.attempt(a,c,d);return c;function c(x){return f(x)?o(x):d(x)}function d(x){if(x===null){n.consume(x);return}return n.enter("data"),n.consume(x),m}function m(x){return f(x)?(n.exit("data"),o(x)):(n.consume(x),m)}function f(x){if(x===null)return!0;const p=a[x];let y=-1;if(p)for(;++y<p.length;){const g=p[y];if(!g.previous||g.previous.call(i,i.previous))return!0}return!1}}}function Y2(e){return t;function t(n,i){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(n,i):n}}function pN(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const i=e[n-1][1],a=t.sliceStream(i);let o=a.length,c=-1,d=0,m;for(;o--;){const f=a[o];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)d++,c--;if(c)break;c=-1}else if(f===-2)m=!0,d++;else if(f!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const f={type:n===e.length||m||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:i.start._bufferIndex+c,_index:i.start._index+o,line:i.end.line,column:i.end.column-d,offset:i.end.offset-d},end:{...i.end}};i.end={...f.start},i.start.offset===i.end.offset?Object.assign(i,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const xN={42:Tr,43:Tr,45:Tr,48:Tr,49:Tr,50:Tr,51:Tr,52:Tr,53:Tr,54:Tr,55:Tr,56:Tr,57:Tr,62:B2},gN={91:wC},yN={[-2]:rp,[-1]:rp,32:rp},bN={35:EC,42:sf,45:[Ub,sf],60:_C,61:Ub,95:sf,96:Ib,126:Ib},vN={38:O2,92:$2},wN={[-5]:ip,[-4]:ip,[-3]:ip,33:GC,38:O2,42:sx,60:[Qj,OC],91:QC,92:[CC,$2],93:e0,95:sx,96:uC},kN={null:[sx,fN]},SN={null:[42,95]},jN={null:[]},CN=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:SN,contentInitial:gN,disable:jN,document:xN,flow:bN,flowInitial:yN,insideSpan:kN,string:vN,text:wN},Symbol.toStringTag,{value:"Module"}));function NN(e,t,n){let i={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let c=[],d=[];const m={attempt:F(z),check:F(D),consume:N,enter:E,exit:A,interrupt:F(D,{interrupt:!0})},f={code:null,containerState:{},defineSkip:k,events:[],now:w,parser:e,previous:null,sliceSerialize:y,sliceStream:g,write:p};let x=t.tokenize.call(f,m);return t.resolveAll&&o.push(t),f;function p(_){return c=ci(c,_),j(),c[c.length-1]!==null?[]:(q(t,0),f.events=$f(o,f.events,f),f.events)}function y(_,B){return AN(g(_),B)}function g(_){return EN(c,_)}function w(){const{_bufferIndex:_,_index:B,line:X,column:R,offset:H}=i;return{_bufferIndex:_,_index:B,line:X,column:R,offset:H}}function k(_){a[_.line]=_.column,L()}function j(){let _;for(;i._index<c.length;){const B=c[i._index];if(typeof B=="string")for(_=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===_&&i._bufferIndex<B.length;)C(B.charCodeAt(i._bufferIndex));else C(B)}}function C(_){x=x(_)}function N(_){ft(_)?(i.line++,i.column=1,i.offset+=_===-3?2:1,L()):_!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===c[i._index].length&&(i._bufferIndex=-1,i._index++)),f.previous=_}function E(_,B){const X=B||{};return X.type=_,X.start=w(),f.events.push(["enter",X,f]),d.push(X),X}function A(_){const B=d.pop();return B.end=w(),f.events.push(["exit",B,f]),B}function z(_,B){q(_,B.from)}function D(_,B){B.restore()}function F(_,B){return X;function X(R,H,$){let G,Q,K,M;return Array.isArray(R)?P(R):"tokenize"in R?P([R]):U(R);function U(J){return se;function se(le){const ye=le!==null&&J[le],De=le!==null&&J.null,Ee=[...Array.isArray(ye)?ye:ye?[ye]:[],...Array.isArray(De)?De:De?[De]:[]];return P(Ee)(le)}}function P(J){return G=J,Q=0,J.length===0?$:O(J[Q])}function O(J){return se;function se(le){return M=V(),K=J,J.partial||(f.currentConstruct=J),J.name&&f.parser.constructs.disable.null.includes(J.name)?ee():J.tokenize.call(B?Object.assign(Object.create(f),B):f,m,Z,ee)(le)}}function Z(J){return _(K,M),H}function ee(J){return M.restore(),++Q<G.length?O(G[Q]):$}}}function q(_,B){_.resolveAll&&!o.includes(_)&&o.push(_),_.resolve&&Wr(f.events,B,f.events.length-B,_.resolve(f.events.slice(B),f)),_.resolveTo&&(f.events=_.resolveTo(f.events,f))}function V(){const _=w(),B=f.previous,X=f.currentConstruct,R=f.events.length,H=Array.from(d);return{from:R,restore:$};function $(){i=_,f.previous=B,f.currentConstruct=X,f.events.length=R,d=H,L()}}function L(){i.line in a&&i.column<2&&(i.column=a[i.line],i.offset+=a[i.line]-1)}}function EN(e,t){const n=t.start._index,i=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let c;if(n===a)c=[e[n].slice(i,o)];else{if(c=e.slice(n,a),i>-1){const d=c[0];typeof d=="string"?c[0]=d.slice(i):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function AN(e,t){let n=-1;const i=[];let a;for(;++n<e.length;){const o=e[n];let c;if(typeof o=="string")c=o;else switch(o){case-5:{c="\r";break}case-4:{c=`
54
+ `;break}case-3:{c=`\r
55
+ `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(o)}a=o===-2,i.push(c)}return i.join("")}function DN(e){const i={constructs:R2([CN,...(e||{}).extensions||[]]),content:a(Yj),defined:[],document:a(Xj),flow:a(uN),lazy:{},string:a(hN),text:a(mN)};return i;function a(o){return c;function c(d){return NN(i,o,d)}}}function TN(e){for(;!L2(e););return e}const qb=/[\0\t\n\r]/g;function _N(){let e=1,t="",n=!0,i;return a;function a(o,c,d){const m=[];let f,x,p,y,g;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(qb.lastIndex=p,f=qb.exec(o),y=f&&f.index!==void 0?f.index:o.length,g=o.charCodeAt(y),!f){t=o.slice(p);break}if(g===10&&p===y&&i)m.push(-3),i=void 0;else switch(i&&(m.push(-5),i=void 0),p<y&&(m.push(o.slice(p,y)),e+=y-p),g){case 0:{m.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,m.push(-2);e++<x;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:i=!0,e=1}p=y+1}return d&&(i&&m.push(-5),t&&m.push(t),m.push(null)),m}}const MN=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FN(e){return e.replace(MN,RN)}function RN(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),o=a===120||a===88;return z2(n.slice(o?2:1),o?16:10)}return Jx(n)||e}const P2={}.hasOwnProperty;function zN(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),BN(n)(TN(DN(n).document().write(_N()(e,t,!0))))}function BN(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ye),autolinkProtocol:V,autolinkEmail:V,atxHeading:o(Je),blockQuote:o(De),characterEscape:V,characterReference:V,codeFenced:o(Ee),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(Ee,c),codeText:o(Re,c),codeTextData:V,data:V,codeFlowValue:V,definition:o(me),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(Fe),hardBreakEscape:o(Pe),hardBreakTrailing:o(Pe),htmlFlow:o(it,c),htmlFlowData:V,htmlText:o(it,c),htmlTextData:V,image:o(ht),label:c,link:o(Ye),listItem:o(ut),listItemValue:y,listOrdered:o(nt,p),listUnordered:o(nt),paragraph:o(kt),reference:O,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(Je),strong:o(mt),thematicBreak:o(be)},exit:{atxHeading:m(),atxHeadingSequence:z,autolink:m(),autolinkEmail:ye,autolinkProtocol:le,blockQuote:m(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:J,characterReference:se,codeFenced:m(j),codeFencedFence:k,codeFencedFenceInfo:g,codeFencedFenceMeta:w,codeFlowValue:L,codeIndented:m(C),codeText:m(H),codeTextData:L,data:L,definition:m(),definitionDestinationString:A,definitionLabelString:N,definitionTitleString:E,emphasis:m(),hardBreakEscape:m(B),hardBreakTrailing:m(B),htmlFlow:m(X),htmlFlowData:L,htmlText:m(R),htmlTextData:L,image:m(G),label:K,labelText:Q,lineEnding:_,link:m($),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Z,resourceDestinationString:M,resourceTitleString:U,resource:P,setextHeading:m(q),setextHeadingLineSequence:F,setextHeadingText:D,strong:m(),thematicBreak:m()}};X2(t,(e||{}).mdastExtensions||[]);const n={};return i;function i(te){let oe={type:"root",children:[]};const Ce={stack:[oe],tokenStack:[],config:t,enter:d,exit:f,buffer:c,resume:x,data:n},pe=[];let Se=-1;for(;++Se<te.length;)if(te[Se][1].type==="listOrdered"||te[Se][1].type==="listUnordered")if(te[Se][0]==="enter")pe.push(Se);else{const Me=pe.pop();Se=a(te,Me,Se)}for(Se=-1;++Se<te.length;){const Me=t[te[Se][0]];P2.call(Me,te[Se][1].type)&&Me[te[Se][1].type].call(Object.assign({sliceSerialize:te[Se][2].sliceSerialize},Ce),te[Se][1])}if(Ce.tokenStack.length>0){const Me=Ce.tokenStack[Ce.tokenStack.length-1];(Me[1]||Yb).call(Ce,void 0,Me[0])}for(oe.position={start:pa(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:pa(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},Se=-1;++Se<t.transforms.length;)oe=t.transforms[Se](oe)||oe;return oe}function a(te,oe,Ce){let pe=oe-1,Se=-1,Me=!1,Ge,Ie,qe,Xe;for(;++pe<=Ce;){const et=te[pe];switch(et[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{et[0]==="enter"?Se++:Se--,Xe=void 0;break}case"lineEndingBlank":{et[0]==="enter"&&(Ge&&!Xe&&!Se&&!qe&&(qe=pe),Xe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Xe=void 0}if(!Se&&et[0]==="enter"&&et[1].type==="listItemPrefix"||Se===-1&&et[0]==="exit"&&(et[1].type==="listUnordered"||et[1].type==="listOrdered")){if(Ge){let ze=pe;for(Ie=void 0;ze--;){const Be=te[ze];if(Be[1].type==="lineEnding"||Be[1].type==="lineEndingBlank"){if(Be[0]==="exit")continue;Ie&&(te[Ie][1].type="lineEndingBlank",Me=!0),Be[1].type="lineEnding",Ie=ze}else if(!(Be[1].type==="linePrefix"||Be[1].type==="blockQuotePrefix"||Be[1].type==="blockQuotePrefixWhitespace"||Be[1].type==="blockQuoteMarker"||Be[1].type==="listItemIndent"))break}qe&&(!Ie||qe<Ie)&&(Ge._spread=!0),Ge.end=Object.assign({},Ie?te[Ie][1].start:et[1].end),te.splice(Ie||pe,0,["exit",Ge,et[2]]),pe++,Ce++}if(et[1].type==="listItemPrefix"){const ze={type:"listItem",_spread:!1,start:Object.assign({},et[1].start),end:void 0};Ge=ze,te.splice(pe,0,["enter",ze,et[2]]),pe++,Ce++,qe=void 0,Xe=!0}}}return te[oe][1]._spread=Me,Ce}function o(te,oe){return Ce;function Ce(pe){d.call(this,te(pe),pe),oe&&oe.call(this,pe)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(te,oe,Ce){this.stack[this.stack.length-1].children.push(te),this.stack.push(te),this.tokenStack.push([oe,Ce||void 0]),te.position={start:pa(oe.start),end:void 0}}function m(te){return oe;function oe(Ce){te&&te.call(this,Ce),f.call(this,Ce)}}function f(te,oe){const Ce=this.stack.pop(),pe=this.tokenStack.pop();if(pe)pe[0].type!==te.type&&(oe?oe.call(this,te,pe[0]):(pe[1]||Yb).call(this,te,pe[0]));else throw new Error("Cannot close `"+te.type+"` ("+Mc({start:te.start,end:te.end})+"): it’s not open");Ce.position.end=pa(te.end)}function x(){return Zx(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function y(te){if(this.data.expectingFirstListItemValue){const oe=this.stack[this.stack.length-2];oe.start=Number.parseInt(this.sliceSerialize(te),10),this.data.expectingFirstListItemValue=void 0}}function g(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.lang=te}function w(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.meta=te}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function j(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.value=te.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.value=te.replace(/(\r?\n|\r)$/g,"")}function N(te){const oe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.label=oe,Ce.identifier=Ni(this.sliceSerialize(te)).toLowerCase()}function E(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.title=te}function A(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.url=te}function z(te){const oe=this.stack[this.stack.length-1];if(!oe.depth){const Ce=this.sliceSerialize(te).length;oe.depth=Ce}}function D(){this.data.setextHeadingSlurpLineEnding=!0}function F(te){const oe=this.stack[this.stack.length-1];oe.depth=this.sliceSerialize(te).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function V(te){const Ce=this.stack[this.stack.length-1].children;let pe=Ce[Ce.length-1];(!pe||pe.type!=="text")&&(pe=ve(),pe.position={start:pa(te.start),end:void 0},Ce.push(pe)),this.stack.push(pe)}function L(te){const oe=this.stack.pop();oe.value+=this.sliceSerialize(te),oe.position.end=pa(te.end)}function _(te){const oe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ce=oe.children[oe.children.length-1];Ce.position.end=pa(te.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(oe.type)&&(V.call(this,te),L.call(this,te))}function B(){this.data.atHardBreak=!0}function X(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.value=te}function R(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.value=te}function H(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.value=te}function $(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=oe,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function G(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const oe=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=oe,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function Q(te){const oe=this.sliceSerialize(te),Ce=this.stack[this.stack.length-2];Ce.label=FN(oe),Ce.identifier=Ni(oe).toLowerCase()}function K(){const te=this.stack[this.stack.length-1],oe=this.resume(),Ce=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ce.type==="link"){const pe=te.children;Ce.children=pe}else Ce.alt=oe}function M(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.url=te}function U(){const te=this.resume(),oe=this.stack[this.stack.length-1];oe.title=te}function P(){this.data.inReference=void 0}function O(){this.data.referenceType="collapsed"}function Z(te){const oe=this.resume(),Ce=this.stack[this.stack.length-1];Ce.label=oe,Ce.identifier=Ni(this.sliceSerialize(te)).toLowerCase(),this.data.referenceType="full"}function ee(te){this.data.characterReferenceType=te.type}function J(te){const oe=this.sliceSerialize(te),Ce=this.data.characterReferenceType;let pe;Ce?(pe=z2(oe,Ce==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):pe=Jx(oe);const Se=this.stack[this.stack.length-1];Se.value+=pe}function se(te){const oe=this.stack.pop();oe.position.end=pa(te.end)}function le(te){L.call(this,te);const oe=this.stack[this.stack.length-1];oe.url=this.sliceSerialize(te)}function ye(te){L.call(this,te);const oe=this.stack[this.stack.length-1];oe.url="mailto:"+this.sliceSerialize(te)}function De(){return{type:"blockquote",children:[]}}function Ee(){return{type:"code",lang:null,meta:null,value:""}}function Re(){return{type:"inlineCode",value:""}}function me(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Fe(){return{type:"emphasis",children:[]}}function Je(){return{type:"heading",depth:0,children:[]}}function Pe(){return{type:"break"}}function it(){return{type:"html",value:""}}function ht(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function nt(te){return{type:"list",ordered:te.type==="listOrdered",start:null,spread:te._spread,children:[]}}function ut(te){return{type:"listItem",spread:te._spread,checked:null,children:[]}}function kt(){return{type:"paragraph",children:[]}}function mt(){return{type:"strong",children:[]}}function ve(){return{type:"text",value:""}}function be(){return{type:"thematicBreak"}}}function pa(e){return{line:e.line,column:e.column,offset:e.offset}}function X2(e,t){let n=-1;for(;++n<t.length;){const i=t[n];Array.isArray(i)?X2(e,i):$N(e,i)}}function $N(e,t){let n;for(n in t)if(P2.call(t,n))switch(n){case"canContainEols":{const i=t[n];i&&e[n].push(...i);break}case"transforms":{const i=t[n];i&&e[n].push(...i);break}case"enter":case"exit":{const i=t[n];i&&Object.assign(e[n],i);break}}}function Yb(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Mc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Mc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Mc({start:t.start,end:t.end})+") is still open")}function ON(e){const t=this;t.parser=n;function n(i){return zN(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function LN(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function IN(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
56
+ `}]}function HN(e,t){const n=t.value?t.value+`
57
+ `:"",i={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(i.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function UN(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qN(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function YN(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),a=So(i.toLowerCase()),o=e.footnoteOrder.indexOf(i);let c,d=e.footnoteCounts.get(i);d===void 0?(d=0,e.footnoteOrder.push(i),c=e.footnoteOrder.length):c=o+1,d+=1,e.footnoteCounts.set(i,d);const m={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,m);const f={type:"element",tagName:"sup",properties:{},children:[m]};return e.patch(t,f),e.applyData(t,f)}function PN(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XN(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function V2(e,t){const n=t.referenceType;let i="]";if(n==="collapsed"?i+="[]":n==="full"&&(i+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+i}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=i:a.push({type:"text",value:i}),a}function VN(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return V2(e,t);const a={src:So(i.url||""),alt:t.alt};i.title!==null&&i.title!==void 0&&(a.title=i.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function WN(e,t){const n={src:So(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,i),e.applyData(t,i)}function GN(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const i={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,i),e.applyData(t,i)}function KN(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return V2(e,t);const a={href:So(i.url||"")};i.title!==null&&i.title!==void 0&&(a.title=i.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function QN(e,t){const n={href:So(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function ZN(e,t,n){const i=e.all(t),a=n?JN(n):W2(t),o={},c=[];if(typeof t.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:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let d=-1;for(;++d<i.length;){const x=i[d];(a||d!==0||x.type!=="element"||x.tagName!=="p")&&c.push({type:"text",value:`
58
+ `}),x.type==="element"&&x.tagName==="p"&&!a?c.push(...x.children):c.push(x)}const m=i[i.length-1];m&&(a||m.type!=="element"||m.tagName!=="p")&&c.push({type:"text",value:`
59
+ `});const f={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,f),e.applyData(t,f)}function JN(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let i=-1;for(;!t&&++i<n.length;)t=W2(n[i])}return t}function W2(e){const t=e.spread;return t??e.children.length>1}function eE(e,t){const n={},i=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<i.length;){const c=i[a];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function tE(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nE(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function rE(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iE(e,t){const n=e.all(t),i=n.shift(),a=[];if(i){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(t.children[0],c),a.push(c)}if(n.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},d=Wx(t.children[1]),m=E2(t.children[t.children.length-1]);d&&m&&(c.position={start:d,end:m}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function sE(e,t,n){const i=n?n.children:void 0,o=(i?i.indexOf(t):1)===0?"th":"td",c=n&&n.type==="table"?n.align:void 0,d=c?c.length:t.children.length;let m=-1;const f=[];for(;++m<d;){const p=t.children[m],y={},g=c?c[m]:void 0;g&&(y.align=g);let w={type:"element",tagName:o,properties:y,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(t,x),e.applyData(t,x)}function aE(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Pb=9,Xb=32;function lE(e){const t=String(e),n=/\r?\n|\r/g;let i=n.exec(t),a=0;const o=[];for(;i;)o.push(Vb(t.slice(a,i.index),a>0,!0),i[0]),a=i.index+i[0].length,i=n.exec(t);return o.push(Vb(t.slice(a),a>0,!1)),o.join("")}function Vb(e,t,n){let i=0,a=e.length;if(t){let o=e.codePointAt(i);for(;o===Pb||o===Xb;)i++,o=e.codePointAt(i)}if(n){let o=e.codePointAt(a-1);for(;o===Pb||o===Xb;)a--,o=e.codePointAt(a-1)}return a>i?e.slice(i,a):""}function oE(e,t){const n={type:"text",value:lE(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function cE(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const uE={blockquote:LN,break:IN,code:HN,delete:UN,emphasis:qN,footnoteReference:YN,heading:PN,html:XN,imageReference:VN,image:WN,inlineCode:GN,linkReference:KN,link:QN,listItem:ZN,list:eE,paragraph:tE,root:nE,strong:rE,table:iE,tableCell:aE,tableRow:sE,text:oE,thematicBreak:cE,toml:_d,yaml:_d,definition:_d,footnoteDefinition:_d};function _d(){}const G2=-1,Of=0,Rc=1,pf=2,t0=3,n0=4,r0=5,i0=6,K2=7,Q2=8,Wb=typeof self=="object"?self:globalThis,dE=(e,t)=>{const n=(a,o)=>(e.set(o,a),a),i=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Of:case G2:return n(c,a);case Rc:{const d=n([],a);for(const m of c)d.push(i(m));return d}case pf:{const d=n({},a);for(const[m,f]of c)d[i(m)]=i(f);return d}case t0:return n(new Date(c),a);case n0:{const{source:d,flags:m}=c;return n(new RegExp(d,m),a)}case r0:{const d=n(new Map,a);for(const[m,f]of c)d.set(i(m),i(f));return d}case i0:{const d=n(new Set,a);for(const m of c)d.add(i(m));return d}case K2:{const{name:d,message:m}=c;return n(new Wb[d](m),a)}case Q2:return n(BigInt(c),a);case"BigInt":return n(Object(BigInt(c)),a);case"ArrayBuffer":return n(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:d}=new Uint8Array(c);return n(new DataView(d),c)}}return n(new Wb[o](c),a)};return i},Gb=e=>dE(new Map,e)(0),Zl="",{toString:fE}={},{keys:hE}=Object,wc=e=>{const t=typeof e;if(t!=="object"||!e)return[Of,t];const n=fE.call(e).slice(8,-1);switch(n){case"Array":return[Rc,Zl];case"Object":return[pf,Zl];case"Date":return[t0,Zl];case"RegExp":return[n0,Zl];case"Map":return[r0,Zl];case"Set":return[i0,Zl];case"DataView":return[Rc,n]}return n.includes("Array")?[Rc,n]:n.includes("Error")?[K2,n]:[pf,n]},Md=([e,t])=>e===Of&&(t==="function"||t==="symbol"),mE=(e,t,n,i)=>{const a=(c,d)=>{const m=i.push(c)-1;return n.set(d,m),m},o=c=>{if(n.has(c))return n.get(c);let[d,m]=wc(c);switch(d){case Of:{let x=c;switch(m){case"bigint":d=Q2,x=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return a([G2],c)}return a([d,x],c)}case Rc:{if(m){let y=c;return m==="DataView"?y=new Uint8Array(c.buffer):m==="ArrayBuffer"&&(y=new Uint8Array(c)),a([m,[...y]],c)}const x=[],p=a([d,x],c);for(const y of c)x.push(o(y));return p}case pf:{if(m)switch(m){case"BigInt":return a([m,c.toString()],c);case"Boolean":case"Number":case"String":return a([m,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const x=[],p=a([d,x],c);for(const y of hE(c))(e||!Md(wc(c[y])))&&x.push([o(y),o(c[y])]);return p}case t0:return a([d,c.toISOString()],c);case n0:{const{source:x,flags:p}=c;return a([d,{source:x,flags:p}],c)}case r0:{const x=[],p=a([d,x],c);for(const[y,g]of c)(e||!(Md(wc(y))||Md(wc(g))))&&x.push([o(y),o(g)]);return p}case i0:{const x=[],p=a([d,x],c);for(const y of c)(e||!Md(wc(y)))&&x.push(o(y));return p}}const{message:f}=c;return a([d,{name:m,message:f}],c)};return o},Kb=(e,{json:t,lossy:n}={})=>{const i=[];return mE(!(t||n),!!t,new Map,i)(e),i},xf=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Gb(Kb(e,t)):structuredClone(e):(e,t)=>Gb(Kb(e,t));function pE(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function xE(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function gE(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||pE,i=e.options.footnoteBackLabel||xE,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let m=-1;for(;++m<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[m]);if(!f)continue;const x=e.all(f),p=String(f.identifier).toUpperCase(),y=So(p.toLowerCase());let g=0;const w=[],k=e.footnoteCounts.get(p);for(;k!==void 0&&++g<=k;){w.length>0&&w.push({type:"text",value:" "});let N=typeof n=="string"?n:n(m,g);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+y+(g>1?"-"+g:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(m,g),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const j=x[x.length-1];if(j&&j.type==="element"&&j.tagName==="p"){const N=j.children[j.children.length-1];N&&N.type==="text"?N.value+=" ":j.children.push({type:"text",value:" "}),j.children.push(...w)}else x.push(...w);const C={type:"element",tagName:"li",properties:{id:t+"fn-"+y},children:e.wrap(x,!0)};e.patch(f,C),d.push(C)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...xf(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
60
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(d,!0)},{type:"text",value:`
61
+ `}]}}const Lf=(function(e){if(e==null)return wE;if(typeof e=="function")return If(e);if(typeof e=="object")return Array.isArray(e)?yE(e):bE(e);if(typeof e=="string")return vE(e);throw new Error("Expected function, string, or object as test")});function yE(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Lf(e[n]);return If(i);function i(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function bE(e){const t=e;return If(n);function n(i){const a=i;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function vE(e){return If(t);function t(n){return n&&n.type===e}}function If(e){return t;function t(n,i,a){return!!(kE(n)&&e.call(this,n,typeof i=="number"?i:void 0,a||void 0))}}function wE(){return!0}function kE(e){return e!==null&&typeof e=="object"&&"type"in e}const Z2=[],SE=!0,ax=!1,jE="skip";function J2(e,t,n,i){let a;typeof t=="function"&&typeof n!="function"?(i=n,n=t):a=t;const o=Lf(a),c=i?-1:1;d(e,void 0,[])();function d(m,f,x){const p=m&&typeof m=="object"?m:{};if(typeof p.type=="string"){const g=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(y,"name",{value:"node ("+(m.type+(g?"<"+g+">":""))+")"})}return y;function y(){let g=Z2,w,k,j;if((!t||o(m,f,x[x.length-1]||void 0))&&(g=CE(n(m,x)),g[0]===ax))return g;if("children"in m&&m.children){const C=m;if(C.children&&g[0]!==jE)for(k=(i?C.children.length:-1)+c,j=x.concat(C);k>-1&&k<C.children.length;){const N=C.children[k];if(w=d(N,k,j)(),w[0]===ax)return w;k=typeof w[1]=="number"?w[1]:k+c}}return g}}}function CE(e){return Array.isArray(e)?e:typeof e=="number"?[SE,e]:e==null?Z2:[e]}function s0(e,t,n,i){let a,o,c;typeof t=="function"&&typeof n!="function"?(o=void 0,c=t,a=n):(o=t,c=n,a=i),J2(e,o,d,a);function d(m,f){const x=f[f.length-1],p=x?x.children.indexOf(m):void 0;return c(m,p,x)}}const lx={}.hasOwnProperty,NE={};function EE(e,t){const n=t||NE,i=new Map,a=new Map,o=new Map,c={...uE,...n.handlers},d={all:f,applyData:DE,definitionById:i,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:m,options:n,patch:AE,wrap:_E};return s0(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const p=x.type==="definition"?i:a,y=String(x.identifier).toUpperCase();p.has(y)||p.set(y,x)}}),d;function m(x,p){const y=x.type,g=d.handlers[y];if(lx.call(d.handlers,y)&&g)return g(d,x,p);if(d.options.passThrough&&d.options.passThrough.includes(y)){if("children"in x){const{children:k,...j}=x,C=xf(j);return C.children=d.all(x),C}return xf(x)}return(d.options.unknownHandler||TE)(d,x,p)}function f(x){const p=[];if("children"in x){const y=x.children;let g=-1;for(;++g<y.length;){const w=d.one(y[g],x);if(w){if(g&&y[g-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Qb(w.value)),!Array.isArray(w)&&w.type==="element")){const k=w.children[0];k&&k.type==="text"&&(k.value=Qb(k.value))}Array.isArray(w)?p.push(...w):p.push(w)}}}return p}}function AE(e,t){e.position&&(t.position=xj(e))}function DE(e,t){let n=t;if(e&&e.data){const i=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof i=="string")if(n.type==="element")n.tagName=i;else{const c="children"in n?n.children:[n];n={type:"element",tagName:i,properties:{},children:c}}n.type==="element"&&o&&Object.assign(n.properties,xf(o)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function TE(e,t){const n=t.data||{},i="value"in t&&!(lx.call(n,"hProperties")||lx.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function _E(e,t){const n=[];let i=-1;for(t&&n.push({type:"text",value:`
62
+ `});++i<e.length;)i&&n.push({type:"text",value:`
63
+ `}),n.push(e[i]);return t&&e.length>0&&n.push({type:"text",value:`
64
+ `}),n}function Qb(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Zb(e,t){const n=EE(e,t),i=n.one(e,void 0),a=gE(n),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
65
+ `},a),o}function ME(e,t){return e&&"run"in e?async function(n,i){const a=Zb(n,{file:i,...t});await e.run(a,i)}:function(n,i){return Zb(n,{file:i,...e||t})}}function Jb(e){if(e)throw e}var sp,ev;function FE(){if(ev)return sp;ev=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},o=function(f){if(!f||t.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 y;for(y in f);return typeof y>"u"||e.call(f,y)},c=function(f,x){n&&x.name==="__proto__"?n(f,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):f[x.name]=x.newValue},d=function(f,x){if(x==="__proto__")if(e.call(f,x)){if(i)return i(f,x).value}else return;return f[x]};return sp=function m(){var f,x,p,y,g,w,k=arguments[0],j=1,C=arguments.length,N=!1;for(typeof k=="boolean"&&(N=k,k=arguments[1]||{},j=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});j<C;++j)if(f=arguments[j],f!=null)for(x in f)p=d(k,x),y=d(f,x),k!==y&&(N&&y&&(o(y)||(g=a(y)))?(g?(g=!1,w=p&&a(p)?p:[]):w=p&&o(p)?p:{},c(k,{name:x,newValue:m(N,w,y)})):typeof y<"u"&&c(k,{name:x,newValue:y}));return k},sp}var RE=FE();const ap=zf(RE);function ox(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function zE(){const e=[],t={run:n,use:i};return t;function n(...a){let o=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);d(null,...a);function d(m,...f){const x=e[++o];let p=-1;if(m){c(m);return}for(;++p<a.length;)(f[p]===null||f[p]===void 0)&&(f[p]=a[p]);a=f,x?BE(x,d)(...f):c(null,...f)}}function i(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function BE(e,t){let n;return i;function i(...c){const d=e.length>c.length;let m;d&&c.push(a);try{m=e.apply(this,c)}catch(f){const x=f;if(d&&n)throw x;return a(x)}d||(m&&m.then&&typeof m.then=="function"?m.then(o,a):m instanceof Error?a(m):o(m))}function a(c,...d){n||(n=!0,t(c,...d))}function o(c){a(null,c)}}const Vi={basename:$E,dirname:OE,extname:LE,join:IE,sep:"/"};function $E(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');eu(e);let n=0,i=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else i<0&&(o=!0,i=a+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let c=-1,d=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else c<0&&(o=!0,c=a+1),d>-1&&(e.codePointAt(a)===t.codePointAt(d--)?d<0&&(i=a):(d=-1,i=c));return n===i?i=c:i<0&&(i=e.length),e.slice(n,i)}function OE(e){if(eu(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function LE(e){eu(e);let t=e.length,n=-1,i=0,a=-1,o=0,c;for(;t--;){const d=e.codePointAt(t);if(d===47){if(c){i=t+1;break}continue}n<0&&(c=!0,n=t+1),d===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===i+1?"":e.slice(a,n)}function IE(...e){let t=-1,n;for(;++t<e.length;)eu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":HE(n)}function HE(e){eu(e);const t=e.codePointAt(0)===47;let n=UE(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function UE(e,t){let n="",i=0,a=-1,o=0,c=-1,d,m;for(;++c<=e.length;){if(c<e.length)d=e.codePointAt(c);else{if(d===47)break;d=47}if(d===47){if(!(a===c-1||o===1))if(a!==c-1&&o===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(m=n.lastIndexOf("/"),m!==n.length-1){m<0?(n="",i=0):(n=n.slice(0,m),i=n.length-1-n.lastIndexOf("/")),a=c,o=0;continue}}else if(n.length>0){n="",i=0,a=c,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),i=c-a-1;a=c,o=0}else d===46&&o>-1?o++:o=-1}return n}function eu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const qE={cwd:YE};function YE(){return"/"}function cx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function PE(e){if(typeof e=="string")e=new URL(e);else if(!cx(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return XE(e)}function XE(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 t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const i=t.codePointAt(n+2);if(i===70||i===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const lp=["history","path","basename","stem","extname","dirname"];class e5{constructor(t){let n;t?cx(t)?n={path:t}:typeof t=="string"||VE(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":qE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<lp.length;){const o=lp[i];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let a;for(a in n)lp.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Vi.basename(this.path):void 0}set basename(t){cp(t,"basename"),op(t,"basename"),this.path=Vi.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Vi.dirname(this.path):void 0}set dirname(t){tv(this.basename,"dirname"),this.path=Vi.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Vi.extname(this.path):void 0}set extname(t){if(op(t,"extname"),tv(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Vi.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){cx(t)&&(t=PE(t)),cp(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Vi.basename(this.path,this.extname):void 0}set stem(t){cp(t,"stem"),op(t,"stem"),this.path=Vi.join(this.dirname||"",t+(this.extname||""))}fail(t,n,i){const a=this.message(t,n,i);throw a.fatal=!0,a}info(t,n,i){const a=this.message(t,n,i);return a.fatal=void 0,a}message(t,n,i){const a=new xr(t,n,i);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function op(e,t){if(e&&e.includes(Vi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Vi.sep+"`")}function cp(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function tv(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function VE(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const WE=(function(e){const i=this.constructor.prototype,a=i[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,i),o}),GE={}.hasOwnProperty;class a0 extends WE{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=zE()}copy(){const t=new a0;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(ap(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(fp("data",this.frozen),this.namespace[t]=n,this):GE.call(this.namespace,t)&&this.namespace[t]||void 0:t?(fp("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const a=n.call(t,...i);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Fd(t),i=this.parser||this.Parser;return up("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),up("process",this.parser||this.Parser),dp("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,c){const d=Fd(t),m=i.parse(d);i.run(m,d,function(x,p,y){if(x||!p||!y)return f(x);const g=p,w=i.stringify(g,y);ZE(w)?y.value=w:y.result=w,f(x,y)});function f(x,p){x||!p?c(x):o?o(p):n(void 0,p)}}}processSync(t){let n=!1,i;return this.freeze(),up("processSync",this.parser||this.Parser),dp("processSync",this.compiler||this.Compiler),this.process(t,a),rv("processSync","process",n),i;function a(o,c){n=!0,Jb(o),i=c}}run(t,n,i){nv(t),this.freeze();const a=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?o(void 0,i):new Promise(o);function o(c,d){const m=Fd(n);a.run(t,m,f);function f(x,p,y){const g=p||t;x?d(x):c?c(g):i(void 0,g,y)}}}runSync(t,n){let i=!1,a;return this.run(t,n,o),rv("runSync","run",i),a;function o(c,d){Jb(c),a=d,i=!0}}stringify(t,n){this.freeze();const i=Fd(n),a=this.compiler||this.Compiler;return dp("stringify",a),nv(t),a(t,i)}use(t,...n){const i=this.attachers,a=this.namespace;if(fp("use",this.frozen),t!=null)if(typeof t=="function")m(t,n);else if(typeof t=="object")Array.isArray(t)?d(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(f){if(typeof f=="function")m(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[x,...p]=f;m(x,p)}else c(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function c(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(f.plugins),f.settings&&(a.settings=ap(!0,a.settings,f.settings))}function d(f){let x=-1;if(f!=null)if(Array.isArray(f))for(;++x<f.length;){const p=f[x];o(p)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function m(f,x){let p=-1,y=-1;for(;++p<i.length;)if(i[p][0]===f){y=p;break}if(y===-1)i.push([f,...x]);else if(x.length>0){let[g,...w]=x;const k=i[y][1];ox(k)&&ox(g)&&(g=ap(!0,k,g)),i[y]=[f,g,...w]}}}}const KE=new a0().freeze();function up(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function dp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function fp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function nv(e){if(!ox(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function rv(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Fd(e){return QE(e)?e:new e5(e)}function QE(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function ZE(e){return typeof e=="string"||JE(e)}function JE(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const eA="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",iv=[],sv={allowDangerousHtml:!0},tA=/^(https?|ircs?|mailto|xmpp)$/i,nA=[{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 l0(e){const t=rA(e),n=iA(e);return sA(t.runSync(t.parse(n),n),e)}function rA(e){const t=e.rehypePlugins||iv,n=e.remarkPlugins||iv,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sv}:sv;return KE().use(ON).use(n).use(ME,i).use(t)}function iA(e){const t=e.children||"",n=new e5;return typeof t=="string"&&(n.value=t),n}function sA(e,t){const n=t.allowedElements,i=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,d=t.unwrapDisallowed,m=t.urlTransform||aA;for(const x of nA)Object.hasOwn(t,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+eA+x.id,void 0);return s0(e,f),wj(e,{Fragment:l.Fragment,components:a,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function f(x,p,y){if(x.type==="raw"&&y&&typeof p=="number")return c?y.children.splice(p,1):y.children[p]={type:"text",value:x.value},p;if(x.type==="element"){let g;for(g in np)if(Object.hasOwn(np,g)&&Object.hasOwn(x.properties,g)){const w=x.properties[g],k=np[g];(k===null||k.includes(x.tagName))&&(x.properties[g]=m(String(w||""),g,x))}}if(x.type==="element"){let g=n?!n.includes(x.tagName):o?o.includes(x.tagName):!1;if(!g&&i&&typeof p=="number"&&(g=!i(x,p,y)),g&&y&&typeof p=="number")return d&&x.children?y.children.splice(p,1,...x.children):y.children.splice(p,1),p}}}function aA(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||i!==-1&&t>i||tA.test(e.slice(0,t))?e:""}function av(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let i=0,a=n.indexOf(t);for(;a!==-1;)i++,a=n.indexOf(t,a+t.length);return i}function lA(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function oA(e,t,n){const a=Lf((n||{}).ignore||[]),o=cA(t);let c=-1;for(;++c<o.length;)J2(e,"text",d);function d(f,x){let p=-1,y;for(;++p<x.length;){const g=x[p],w=y?y.children:void 0;if(a(g,w?w.indexOf(g):void 0,y))return;y=g}if(y)return m(f,x)}function m(f,x){const p=x[x.length-1],y=o[c][0],g=o[c][1];let w=0;const j=p.children.indexOf(f);let C=!1,N=[];y.lastIndex=0;let E=y.exec(f.value);for(;E;){const A=E.index,z={index:E.index,input:E.input,stack:[...x,f]};let D=g(...E,z);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?y.lastIndex=A+1:(w!==A&&N.push({type:"text",value:f.value.slice(w,A)}),Array.isArray(D)?N.push(...D):D&&N.push(D),w=A+E[0].length,C=!0),!y.global)break;E=y.exec(f.value)}return C?(w<f.value.length&&N.push({type:"text",value:f.value.slice(w)}),p.children.splice(j,1,...N)):N=[f],j+N.length}}function cA(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<n.length;){const a=n[i];t.push([uA(a[0]),dA(a[1])])}return t}function uA(e){return typeof e=="string"?new RegExp(lA(e),"g"):e}function dA(e){return typeof e=="function"?e:function(){return e}}const hp="phrasing",mp=["autolink","link","image","label"];function fA(){return{transforms:[bA],enter:{literalAutolink:mA,literalAutolinkEmail:pp,literalAutolinkHttp:pp,literalAutolinkWww:pp},exit:{literalAutolink:yA,literalAutolinkEmail:gA,literalAutolinkHttp:pA,literalAutolinkWww:xA}}}function hA(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:hp,notInConstruct:mp},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:hp,notInConstruct:mp},{character:":",before:"[ps]",after:"\\/",inConstruct:hp,notInConstruct:mp}]}}function mA(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function pp(e){this.config.enter.autolinkProtocol.call(this,e)}function pA(e){this.config.exit.autolinkProtocol.call(this,e)}function xA(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function gA(e){this.config.exit.autolinkEmail.call(this,e)}function yA(e){this.exit(e)}function bA(e){oA(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,vA],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),wA]],{ignore:["link","linkReference"]})}function vA(e,t,n,i,a){let o="";if(!t5(a)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!kA(n)))return!1;const c=SA(n+i);if(!c[0])return!1;const d={type:"link",title:null,url:o+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[d,{type:"text",value:c[1]}]:d}function wA(e,t,n,i){return!t5(i,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function kA(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function SA(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],i=n.indexOf(")");const a=av(e,"(");let o=av(e,")");for(;i!==-1&&a>o;)e+=n.slice(0,i+1),n=n.slice(i+1),i=n.indexOf(")"),o++;return[e,n]}function t5(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||ml(n)||Bf(n))&&(!t||n!==47)}n5.peek=MA;function jA(){this.buffer()}function CA(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function NA(){this.buffer()}function EA(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function AA(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ni(this.sliceSerialize(e)).toLowerCase(),n.label=t}function DA(e){this.exit(e)}function TA(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ni(this.sliceSerialize(e)).toLowerCase(),n.label=t}function _A(e){this.exit(e)}function MA(){return"["}function n5(e,t,n,i){const a=n.createTracker(i);let o=a.move("[^");const c=n.enter("footnoteReference"),d=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),d(),c(),o+=a.move("]"),o}function FA(){return{enter:{gfmFootnoteCallString:jA,gfmFootnoteCall:CA,gfmFootnoteDefinitionLabelString:NA,gfmFootnoteDefinition:EA},exit:{gfmFootnoteCallString:AA,gfmFootnoteCall:DA,gfmFootnoteDefinitionLabelString:TA,gfmFootnoteDefinition:_A}}}function RA(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:n5},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(i,a,o,c){const d=o.createTracker(c);let m=d.move("[^");const f=o.enter("footnoteDefinition"),x=o.enter("label");return m+=d.move(o.safe(o.associationId(i),{before:m,after:"]"})),x(),m+=d.move("]:"),i.children&&i.children.length>0&&(d.shift(4),m+=d.move((t?`
66
+ `:" ")+o.indentLines(o.containerFlow(i,d.current()),t?r5:zA))),f(),m}}function zA(e,t,n){return t===0?e:r5(e,t,n)}function r5(e,t,n){return(n?"":" ")+e}const BA=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];i5.peek=HA;function $A(){return{canContainEols:["delete"],enter:{strikethrough:LA},exit:{strikethrough:IA}}}function OA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:BA}],handlers:{delete:i5}}}function LA(e){this.enter({type:"delete",children:[]},e)}function IA(e){this.exit(e)}function i5(e,t,n,i){const a=n.createTracker(i),o=n.enter("strikethrough");let c=a.move("~~");return c+=n.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function HA(){return"~"}function UA(e){return e.length}function qA(e,t){const n=t||{},i=(n.align||[]).concat(),a=n.stringLength||UA,o=[],c=[],d=[],m=[];let f=0,x=-1;for(;++x<e.length;){const k=[],j=[];let C=-1;for(e[x].length>f&&(f=e[x].length);++C<e[x].length;){const N=YA(e[x][C]);if(n.alignDelimiters!==!1){const E=a(N);j[C]=E,(m[C]===void 0||E>m[C])&&(m[C]=E)}k.push(N)}c[x]=k,d[x]=j}let p=-1;if(typeof i=="object"&&"length"in i)for(;++p<f;)o[p]=lv(i[p]);else{const k=lv(i);for(;++p<f;)o[p]=k}p=-1;const y=[],g=[];for(;++p<f;){const k=o[p];let j="",C="";k===99?(j=":",C=":"):k===108?j=":":k===114&&(C=":");let N=n.alignDelimiters===!1?1:Math.max(1,m[p]-j.length-C.length);const E=j+"-".repeat(N)+C;n.alignDelimiters!==!1&&(N=j.length+N+C.length,N>m[p]&&(m[p]=N),g[p]=N),y[p]=E}c.splice(1,0,y),d.splice(1,0,g),x=-1;const w=[];for(;++x<c.length;){const k=c[x],j=d[x];p=-1;const C=[];for(;++p<f;){const N=k[p]||"";let E="",A="";if(n.alignDelimiters!==!1){const z=m[p]-(j[p]||0),D=o[p];D===114?E=" ".repeat(z):D===99?z%2?(E=" ".repeat(z/2+.5),A=" ".repeat(z/2-.5)):(E=" ".repeat(z/2),A=E):A=" ".repeat(z)}n.delimiterStart!==!1&&!p&&C.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&N==="")&&(n.delimiterStart!==!1||p)&&C.push(" "),n.alignDelimiters!==!1&&C.push(E),C.push(N),n.alignDelimiters!==!1&&C.push(A),n.padding!==!1&&C.push(" "),(n.delimiterEnd!==!1||p!==f-1)&&C.push("|")}w.push(n.delimiterEnd===!1?C.join("").replace(/ +$/,""):C.join(""))}return w.join(`
67
+ `)}function YA(e){return e==null?"":String(e)}function lv(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function PA(e,t,n,i){const a=n.enter("blockquote"),o=n.createTracker(i);o.move("> "),o.shift(2);const c=n.indentLines(n.containerFlow(e,o.current()),XA);return a(),c}function XA(e,t,n){return">"+(n?"":" ")+e}function VA(e,t){return ov(e,t.inConstruct,!0)&&!ov(e,t.notInConstruct,!1)}function ov(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let i=-1;for(;++i<t.length;)if(e.includes(t[i]))return!0;return!1}function cv(e,t,n,i){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
68
+ `&&VA(n.stack,n.unsafe[a]))return/[ \t]/.test(i.before)?"":" ";return`\\
69
+ `}function WA(e,t){const n=String(e);let i=n.indexOf(t),a=i,o=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===a?++o>c&&(c=o):o=1,a=i+t.length,i=n.indexOf(t,a);return c}function GA(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function KA(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function QA(e,t,n,i){const a=KA(n),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(GA(e,n)){const p=n.enter("codeIndented"),y=n.indentLines(o,ZA);return p(),y}const d=n.createTracker(i),m=a.repeat(Math.max(WA(o,a)+1,3)),f=n.enter("codeFenced");let x=d.move(m);if(e.lang){const p=n.enter(`codeFencedLang${c}`);x+=d.move(n.safe(e.lang,{before:x,after:" ",encode:["`"],...d.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${c}`);x+=d.move(" "),x+=d.move(n.safe(e.meta,{before:x,after:`
70
+ `,encode:["`"],...d.current()})),p()}return x+=d.move(`
71
+ `),o&&(x+=d.move(o+`
72
+ `)),x+=d.move(m),f(),x}function ZA(e,t,n){return(n?"":" ")+e}function o0(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function JA(e,t,n,i){const a=o0(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("definition");let d=n.enter("label");const m=n.createTracker(i);let f=m.move("[");return f+=m.move(n.safe(n.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(n.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(d=n.enter("destinationRaw"),f+=m.move(n.safe(e.url,{before:f,after:e.title?" ":`
73
+ `,...m.current()}))),d(),e.title&&(d=n.enter(`title${o}`),f+=m.move(" "+a),f+=m.move(n.safe(e.title,{before:f,after:a,...m.current()})),f+=m.move(a),d()),c(),f}function e6(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Lc(e){return"&#x"+e.toString(16).toUpperCase()+";"}function gf(e,t,n){const i=co(e),a=co(t);return i===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}s5.peek=t6;function s5(e,t,n,i){const a=e6(n),o=n.enter("emphasis"),c=n.createTracker(i),d=c.move(a);let m=c.move(n.containerPhrasing(e,{after:a,before:d,...c.current()}));const f=m.charCodeAt(0),x=gf(i.before.charCodeAt(i.before.length-1),f,a);x.inside&&(m=Lc(f)+m.slice(1));const p=m.charCodeAt(m.length-1),y=gf(i.after.charCodeAt(0),p,a);y.inside&&(m=m.slice(0,-1)+Lc(p));const g=c.move(a);return o(),n.attentionEncodeSurroundingInfo={after:y.outside,before:x.outside},d+m+g}function t6(e,t,n){return n.options.emphasis||"*"}function n6(e,t){let n=!1;return s0(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return n=!0,ax}),!!((!e.depth||e.depth<3)&&Zx(e)&&(t.options.setext||n))}function r6(e,t,n,i){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(i);if(n6(e,n)){const x=n.enter("headingSetext"),p=n.enter("phrasing"),y=n.containerPhrasing(e,{...o.current(),before:`
74
+ `,after:`
75
+ `});return p(),x(),y+`
76
+ `+(a===1?"=":"-").repeat(y.length-(Math.max(y.lastIndexOf("\r"),y.lastIndexOf(`
77
+ `))+1))}const c="#".repeat(a),d=n.enter("headingAtx"),m=n.enter("phrasing");o.move(c+" ");let f=n.containerPhrasing(e,{before:"# ",after:`
78
+ `,...o.current()});return/^[\t ]/.test(f)&&(f=Lc(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,n.options.closeAtx&&(f+=" "+c),m(),d(),f}a5.peek=i6;function a5(e){return e.value||""}function i6(){return"<"}l5.peek=s6;function l5(e,t,n,i){const a=o0(n),o=a==='"'?"Quote":"Apostrophe",c=n.enter("image");let d=n.enter("label");const m=n.createTracker(i);let f=m.move("![");return f+=m.move(n.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(n.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(d=n.enter("destinationRaw"),f+=m.move(n.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),d(),e.title&&(d=n.enter(`title${o}`),f+=m.move(" "+a),f+=m.move(n.safe(e.title,{before:f,after:a,...m.current()})),f+=m.move(a),d()),f+=m.move(")"),c(),f}function s6(){return"!"}o5.peek=a6;function o5(e,t,n,i){const a=e.referenceType,o=n.enter("imageReference");let c=n.enter("label");const d=n.createTracker(i);let m=d.move("![");const f=n.safe(e.alt,{before:m,after:"]",...d.current()});m+=d.move(f+"]["),c();const x=n.stack;n.stack=[],c=n.enter("reference");const p=n.safe(n.associationId(e),{before:m,after:"]",...d.current()});return c(),n.stack=x,o(),a==="full"||!f||f!==p?m+=d.move(p+"]"):a==="shortcut"?m=m.slice(0,-1):m+=d.move("]"),m}function a6(){return"!"}c5.peek=l6;function c5(e,t,n){let i=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(i);)a+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o<n.unsafe.length;){const c=n.unsafe[o],d=n.compilePattern(c);let m;if(c.atBreak)for(;m=d.exec(i);){let f=m.index;i.charCodeAt(f)===10&&i.charCodeAt(f-1)===13&&f--,i=i.slice(0,f)+" "+i.slice(m.index+1)}}return a+i+a}function l6(){return"`"}function u5(e,t){const n=Zx(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}d5.peek=o6;function d5(e,t,n,i){const a=o0(n),o=a==='"'?"Quote":"Apostrophe",c=n.createTracker(i);let d,m;if(u5(e,n)){const x=n.stack;n.stack=[],d=n.enter("autolink");let p=c.move("<");return p+=c.move(n.containerPhrasing(e,{before:p,after:">",...c.current()})),p+=c.move(">"),d(),n.stack=x,p}d=n.enter("link"),m=n.enter("label");let f=c.move("[");return f+=c.move(n.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=n.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(n.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(m=n.enter("destinationRaw"),f+=c.move(n.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),m(),e.title&&(m=n.enter(`title${o}`),f+=c.move(" "+a),f+=c.move(n.safe(e.title,{before:f,after:a,...c.current()})),f+=c.move(a),m()),f+=c.move(")"),d(),f}function o6(e,t,n){return u5(e,n)?"<":"["}f5.peek=c6;function f5(e,t,n,i){const a=e.referenceType,o=n.enter("linkReference");let c=n.enter("label");const d=n.createTracker(i);let m=d.move("[");const f=n.containerPhrasing(e,{before:m,after:"]",...d.current()});m+=d.move(f+"]["),c();const x=n.stack;n.stack=[],c=n.enter("reference");const p=n.safe(n.associationId(e),{before:m,after:"]",...d.current()});return c(),n.stack=x,o(),a==="full"||!f||f!==p?m+=d.move(p+"]"):a==="shortcut"?m=m.slice(0,-1):m+=d.move("]"),m}function c6(){return"["}function c0(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function u6(e){const t=c0(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function d6(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function h5(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function f6(e,t,n,i){const a=n.enter("list"),o=n.bulletCurrent;let c=e.ordered?d6(n):c0(n);const d=e.ordered?c==="."?")":".":u6(n);let m=t&&n.bulletLastUsed?c===n.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&x&&(!x.children||!x.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(m=!0),h5(n)===c&&x){let p=-1;for(;++p<e.children.length;){const y=e.children[p];if(y&&y.type==="listItem"&&y.children&&y.children[0]&&y.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=d),n.bulletCurrent=c;const f=n.containerFlow(e,i);return n.bulletLastUsed=c,n.bulletCurrent=o,a(),f}function h6(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function m6(e,t,n,i){const a=h6(n);let o=n.bulletCurrent||c0(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const d=n.createTracker(i);d.move(o+" ".repeat(c-o.length)),d.shift(c);const m=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,d.current()),x);return m(),f;function x(p,y,g){return y?(g?"":" ".repeat(c))+p:(g?o:o+" ".repeat(c-o.length))+p}}function p6(e,t,n,i){const a=n.enter("paragraph"),o=n.enter("phrasing"),c=n.containerPhrasing(e,i);return o(),a(),c}const x6=Lf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function g6(e,t,n,i){return(e.children.some(function(c){return x6(c)})?n.containerPhrasing:n.containerFlow).call(n,e,i)}function y6(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}m5.peek=b6;function m5(e,t,n,i){const a=y6(n),o=n.enter("strong"),c=n.createTracker(i),d=c.move(a+a);let m=c.move(n.containerPhrasing(e,{after:a,before:d,...c.current()}));const f=m.charCodeAt(0),x=gf(i.before.charCodeAt(i.before.length-1),f,a);x.inside&&(m=Lc(f)+m.slice(1));const p=m.charCodeAt(m.length-1),y=gf(i.after.charCodeAt(0),p,a);y.inside&&(m=m.slice(0,-1)+Lc(p));const g=c.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:y.outside,before:x.outside},d+m+g}function b6(e,t,n){return n.options.strong||"*"}function v6(e,t,n,i){return n.safe(e.value,i)}function w6(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function k6(e,t,n){const i=(h5(n)+(n.options.ruleSpaces?" ":"")).repeat(w6(n));return n.options.ruleSpaces?i.slice(0,-1):i}const p5={blockquote:PA,break:cv,code:QA,definition:JA,emphasis:s5,hardBreak:cv,heading:r6,html:a5,image:l5,imageReference:o5,inlineCode:c5,link:d5,linkReference:f5,list:f6,listItem:m6,paragraph:p6,root:g6,strong:m5,text:v6,thematicBreak:k6};function S6(){return{enter:{table:j6,tableData:uv,tableHeader:uv,tableRow:N6},exit:{codeText:E6,table:C6,tableData:xp,tableHeader:xp,tableRow:xp}}}function j6(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function C6(e){this.exit(e),this.data.inTable=void 0}function N6(e){this.enter({type:"tableRow",children:[]},e)}function xp(e){this.exit(e)}function uv(e){this.enter({type:"tableCell",children:[]},e)}function E6(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,A6));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function A6(e,t){return t==="|"?t:e}function D6(e){const t=e||{},n=t.tableCellPadding,i=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
79
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:y,table:c,tableCell:m,tableRow:d}};function c(g,w,k,j){return f(x(g,k,j),g.align)}function d(g,w,k,j){const C=p(g,k,j),N=f([C]);return N.slice(0,N.indexOf(`
80
+ `))}function m(g,w,k,j){const C=k.enter("tableCell"),N=k.enter("phrasing"),E=k.containerPhrasing(g,{...j,before:o,after:o});return N(),C(),E}function f(g,w){return qA(g,{align:w,alignDelimiters:i,padding:n,stringLength:a})}function x(g,w,k){const j=g.children;let C=-1;const N=[],E=w.enter("table");for(;++C<j.length;)N[C]=p(j[C],w,k);return E(),N}function p(g,w,k){const j=g.children;let C=-1;const N=[],E=w.enter("tableRow");for(;++C<j.length;)N[C]=m(j[C],g,w,k);return E(),N}function y(g,w,k){let j=p5.inlineCode(g,w,k);return k.stack.includes("tableCell")&&(j=j.replace(/\|/g,"\\$&")),j}}function T6(){return{exit:{taskListCheckValueChecked:dv,taskListCheckValueUnchecked:dv,paragraph:M6}}}function _6(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:F6}}}function dv(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function M6(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const i=n.children[0];if(i&&i.type==="text"){const a=t.children;let o=-1,c;for(;++o<a.length;){const d=a[o];if(d.type==="paragraph"){c=d;break}}c===n&&(i.value=i.value.slice(1),i.value.length===0?n.children.shift():n.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,n.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function F6(e,t,n,i){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",d=n.createTracker(i);o&&d.move(c);let m=p5.listItem(e,t,n,{...i,...d.current()});return o&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),m;function f(x){return x+c}}function R6(){return[fA(),FA(),$A(),S6(),T6()]}function z6(e){return{extensions:[hA(),RA(e),OA(),D6(e),_6()]}}const B6={tokenize:U6,partial:!0},x5={tokenize:q6,partial:!0},g5={tokenize:Y6,partial:!0},y5={tokenize:P6,partial:!0},$6={tokenize:X6,partial:!0},b5={name:"wwwAutolink",tokenize:I6,previous:w5},v5={name:"protocolAutolink",tokenize:H6,previous:k5},$s={name:"emailAutolink",tokenize:L6,previous:S5},ts={};function O6(){return{text:ts}}let el=48;for(;el<123;)ts[el]=$s,el++,el===58?el=65:el===91&&(el=97);ts[43]=$s;ts[45]=$s;ts[46]=$s;ts[95]=$s;ts[72]=[$s,v5];ts[104]=[$s,v5];ts[87]=[$s,b5];ts[119]=[$s,b5];function L6(e,t,n){const i=this;let a,o;return c;function c(p){return!ux(p)||!S5.call(i,i.previous)||u0(i.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(p))}function d(p){return ux(p)?(e.consume(p),d):p===64?(e.consume(p),m):n(p)}function m(p){return p===46?e.check($6,x,f)(p):p===45||p===95||pr(p)?(o=!0,e.consume(p),m):x(p)}function f(p){return e.consume(p),a=!0,m}function x(p){return o&&a&&wr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function I6(e,t,n){const i=this;return a;function a(c){return c!==87&&c!==119||!w5.call(i,i.previous)||u0(i.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(B6,e.attempt(x5,e.attempt(g5,o),n),n)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function H6(e,t,n){const i=this;let a="",o=!1;return c;function c(p){return(p===72||p===104)&&k5.call(i,i.previous)&&!u0(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(p),e.consume(p),d):n(p)}function d(p){if(wr(p)&&a.length<5)return a+=String.fromCodePoint(p),e.consume(p),d;if(p===58){const y=a.toLowerCase();if(y==="http"||y==="https")return e.consume(p),m}return n(p)}function m(p){return p===47?(e.consume(p),o?f:(o=!0,m)):n(p)}function f(p){return p===null||mf(p)||gn(p)||ml(p)||Bf(p)?n(p):e.attempt(x5,e.attempt(g5,x),n)(p)}function x(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function U6(e,t,n){let i=0;return a;function a(c){return(c===87||c===119)&&i<3?(i++,e.consume(c),a):c===46&&i===3?(e.consume(c),o):n(c)}function o(c){return c===null?n(c):t(c)}}function q6(e,t,n){let i,a,o;return c;function c(f){return f===46||f===95?e.check(y5,m,d)(f):f===null||gn(f)||ml(f)||f!==45&&Bf(f)?m(f):(o=!0,e.consume(f),c)}function d(f){return f===95?i=!0:(a=i,i=void 0),e.consume(f),c}function m(f){return a||i||!o?n(f):t(f)}}function Y6(e,t){let n=0,i=0;return a;function a(c){return c===40?(n++,e.consume(c),a):c===41&&i<n?o(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(y5,t,o)(c):c===null||gn(c)||ml(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&i++,e.consume(c),a}}function P6(e,t,n){return i;function i(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),i):d===38?(e.consume(d),o):d===93?(e.consume(d),a):d===60||d===null||gn(d)||ml(d)?t(d):n(d)}function a(d){return d===null||d===40||d===91||gn(d)||ml(d)?t(d):i(d)}function o(d){return wr(d)?c(d):n(d)}function c(d){return d===59?(e.consume(d),i):wr(d)?(e.consume(d),c):n(d)}}function X6(e,t,n){return i;function i(o){return e.consume(o),a}function a(o){return pr(o)?n(o):t(o)}}function w5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||gn(e)}function k5(e){return!wr(e)}function S5(e){return!(e===47||ux(e))}function ux(e){return e===43||e===45||e===46||e===95||pr(e)}function u0(e){let t=e.length,n=!1;for(;t--;){const i=e[t][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){n=!0;break}if(i._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const V6={tokenize:t8,partial:!0};function W6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Z6,continuation:{tokenize:J6},exit:e8}},text:{91:{name:"gfmFootnoteCall",tokenize:Q6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:G6,resolveTo:K6}}}}function G6(e,t,n){const i=this;let a=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;a--;){const m=i.events[a][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return d;function d(m){if(!c||!c._balanced)return n(m);const f=Ni(i.sliceSerialize({start:c.end,end:i.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?n(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),t(m))}}function K6(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},d=[e[n+1],e[n+2],["enter",i,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",i,t]];return e.splice(n,e.length-n+1,...d),e}function Q6(e,t,n){const i=this,a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,c;return d;function d(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),m}function m(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(o>999||p===93&&!c||p===null||p===91||gn(p))return n(p);if(p===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return a.includes(Ni(i.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return gn(p)||(c=!0),o++,e.consume(p),p===92?x:f}function x(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function Z6(e,t,n){const i=this,a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,c=0,d;return m;function m(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):n(w)}function x(w){if(c>999||w===93&&!d||w===null||w===91||gn(w))return n(w);if(w===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Ni(i.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return gn(w)||(d=!0),c++,e.consume(w),w===92?p:x}function p(w){return w===91||w===92||w===93?(e.consume(w),c++,x):x(w)}function y(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ut(e,g,"gfmFootnoteDefinitionWhitespace")):n(w)}function g(w){return t(w)}}function J6(e,t,n){return e.check(Jc,t,e.attempt(V6,t,n))}function e8(e){e.exit("gfmFootnoteDefinition")}function t8(e,t,n){const i=this;return Ut(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):n(o)}}function n8(e){let n=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function a(c,d){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let f=m;for(;f--;)if(c[f][0]==="exit"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[f][1].end.offset-c[f][1].start.offset){c[m][1].type="strikethroughSequence",c[f][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},c[f][1].start),end:Object.assign({},c[m][1].end)},p={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[m][1].start)},y=[["enter",x,d],["enter",c[f][1],d],["exit",c[f][1],d],["enter",p,d]],g=d.parser.constructs.insideSpan.null;g&&Wr(y,y.length,0,$f(g,c.slice(f+1,m),d)),Wr(y,y.length,0,[["exit",p,d],["enter",c[m][1],d],["exit",c[m][1],d],["exit",x,d]]),Wr(c,f-1,m-f+3,y),m=f+y.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function o(c,d,m){const f=this.previous,x=this.events;let p=0;return y;function y(w){return f===126&&x[x.length-1][1].type!=="characterEscape"?m(w):(c.enter("strikethroughSequenceTemporary"),g(w))}function g(w){const k=co(f);if(w===126)return p>1?m(w):(c.consume(w),p++,g);if(p<2&&!n)return m(w);const j=c.exit("strikethroughSequenceTemporary"),C=co(w);return j._open=!C||C===2&&!!k,j._close=!k||k===2&&!!C,d(w)}}}class r8{constructor(){this.map=[]}add(t,n,i){i8(this,t,n,i)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let n=this.map.length;const i=[];for(;n>0;)n-=1,i.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];i.push(t.slice()),t.length=0;let a=i.pop();for(;a;){for(const o of a)t.push(o);a=i.pop()}this.map.length=0}}function i8(e,t,n,i){let a=0;if(!(n===0&&i.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...i);return}a+=1}e.map.push([t,n,i])}}function s8(e,t){let n=!1;const i=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&i.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=i.length-1;i[o]=i[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return i}function a8(){return{flow:{null:{name:"table",tokenize:l8,resolveAll:o8}}}}function l8(e,t,n){const i=this;let a=0,o=0,c;return d;function d(L){let _=i.events.length-1;for(;_>-1;){const R=i.events[_][1].type;if(R==="lineEnding"||R==="linePrefix")_--;else break}const B=_>-1?i.events[_][1].type:null,X=B==="tableHead"||B==="tableRow"?D:m;return X===D&&i.parser.lazy[i.now().line]?n(L):X(L)}function m(L){return e.enter("tableHead"),e.enter("tableRow"),f(L)}function f(L){return L===124||(c=!0,o+=1),x(L)}function x(L){return L===null?n(L):ft(L)?o>1?(o=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),g):n(L):Bt(L)?Ut(e,x,"whitespace")(L):(o+=1,c&&(c=!1,a+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),c=!0,x):(e.enter("data"),p(L)))}function p(L){return L===null||L===124||gn(L)?(e.exit("data"),x(L)):(e.consume(L),L===92?y:p)}function y(L){return L===92||L===124?(e.consume(L),p):p(L)}function g(L){return i.interrupt=!1,i.parser.lazy[i.now().line]?n(L):(e.enter("tableDelimiterRow"),c=!1,Bt(L)?Ut(e,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):w(L))}function w(L){return L===45||L===58?j(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),k):z(L)}function k(L){return Bt(L)?Ut(e,j,"whitespace")(L):j(L)}function j(L){return L===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),C):L===45?(o+=1,C(L)):L===null||ft(L)?A(L):z(L)}function C(L){return L===45?(e.enter("tableDelimiterFiller"),N(L)):z(L)}function N(L){return L===45?(e.consume(L),N):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(L))}function E(L){return Bt(L)?Ut(e,A,"whitespace")(L):A(L)}function A(L){return L===124?w(L):L===null||ft(L)?!c||a!==o?z(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):z(L)}function z(L){return n(L)}function D(L){return e.enter("tableRow"),F(L)}function F(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),F):L===null||ft(L)?(e.exit("tableRow"),t(L)):Bt(L)?Ut(e,F,"whitespace")(L):(e.enter("data"),q(L))}function q(L){return L===null||L===124||gn(L)?(e.exit("data"),F(L)):(e.consume(L),L===92?V:q)}function V(L){return L===92||L===124?(e.consume(L),q):q(L)}}function o8(e,t){let n=-1,i=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],d=!1,m=0,f,x,p;const y=new r8;for(;++n<e.length;){const g=e[n],w=g[1];g[0]==="enter"?w.type==="tableHead"?(d=!1,m!==0&&(fv(y,t,m,f,x),x=void 0,m=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},y.add(n,0,[["enter",f,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(i=!0,p=void 0,o=[0,0,0,0],c=[0,n+1,0,0],d&&(d=!1,x={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},y.add(n,0,[["enter",x,t]])),a=w.type==="tableDelimiterRow"?2:x?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],p=Rd(y,t,o,a,void 0,p),o=[0,0,0,0]),c[2]=n)):w.type==="tableCellDivider"&&(i?i=!1:(o[1]!==0&&(c[0]=c[1],p=Rd(y,t,o,a,void 0,p)),o=c,c=[o[1],n,0,0])):w.type==="tableHead"?(d=!0,m=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(m=n,o[1]!==0?(c[0]=c[1],p=Rd(y,t,o,a,n,p)):c[1]!==0&&(p=Rd(y,t,c,a,n,p)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=n)}for(m!==0&&fv(y,t,m,f,x),y.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=s8(t.events,n))}return e}function Rd(e,t,n,i,a,o){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",d="tableContent";n[0]!==0&&(o.end=Object.assign({},eo(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const m=eo(t.events,n[1]);if(o={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const f=eo(t.events,n[2]),x=eo(t.events,n[3]),p={type:d,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(n[2],0,[["enter",p,t]]),i!==2){const y=t.events[n[2]],g=t.events[n[3]];if(y[1].end=Object.assign({},g[1].end),y[1].type="chunkText",y[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,k=n[3]-n[2]-1;e.add(w,k,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},eo(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function fv(e,t,n,i,a){const o=[],c=eo(t.events,n);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),i.end=Object.assign({},c),o.push(["exit",i,t]),e.add(n+1,0,o)}function eo(e,t){const n=e[t],i=n[0]==="enter"?"start":"end";return n[1][i]}const c8={name:"tasklistCheck",tokenize:d8};function u8(){return{text:{91:c8}}}function d8(e,t,n){const i=this;return a;function a(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?n(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),o)}function o(m){return gn(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):n(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):n(m)}function d(m){return ft(m)?t(m):Bt(m)?e.check({tokenize:f8},t,n)(m):n(m)}}function f8(e,t,n){return Ut(e,i,"whitespace");function i(a){return a===null?n(a):t(a)}}function h8(e){return R2([O6(),W6(),n8(e),a8(),u8()])}const m8={};function d0(e){const t=this,n=e||m8,i=t.data(),a=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);a.push(h8(n)),o.push(R6()),c.push(z6(n))}function jo({content:e,className:t=""}){return l.jsx("div",{className:`office-markdown ${t}`,children:l.jsx(l0,{remarkPlugins:[d0],components:{code:p8,table:({children:n})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:n})})},children:e})})}function p8({className:e,children:t,...n}){const i=/language-(\w+)/.exec(e??"");return i||typeof t=="string"&&t.includes(`
81
+ `)?l.jsx(x8,{language:i==null?void 0:i[1],children:t}):l.jsx("code",{className:"px-1 py-0.5 rounded text-[0.9em] font-mono",style:{background:"rgba(148,163,184,0.15)",color:"var(--terminal-text)"},...n,children:t})}function x8({children:e,language:t}){const[n,i]=S.useState(!1),a=String(e).replace(/\n$/,""),o=()=>{navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"office-code-block group relative my-2",children:[t&&l.jsx("div",{className:"text-[10px] text-gray-400 px-3 pt-1.5",children:t}),l.jsx("button",{onClick:o,className:"absolute top-1.5 right-2 text-[10px] text-gray-400 hover:text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:n?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:a})})]})}var hv={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},g8=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function y8(e,t){const n=parseInt(e.replace("#",""),16),i=Math.max(0,(n>>16&255)-t),a=Math.max(0,(n>>8&255)-t),o=Math.max(0,(n&255)-t);return`#${(i<<16|a<<8|o).toString(16).padStart(6,"0")}`}function b8(e,t){const n=parseInt(e.replace("#",""),16),i=Math.min(255,(n>>16&255)+t),a=Math.min(255,(n>>8&255)+t),o=Math.min(255,(n&255)+t);return`#${(i<<16|a<<8|o).toString(16).padStart(6,"0")}`}function f0(e,t){const n=hv[e];if(n&&t)return t[n];const i=g8.exec(e);if(i){const[,a,o,c]=i,d=hv[o],m=d&&t?t[d]:o,f=parseInt(c,10);return a==="darken"?y8(m,f):b8(m,f)}return e}function dx(e,t=12){return e.map(n=>({...n,x:t-n.x-n.w}))}function v8(e,t){return t==="down"?e.down:t==="up"&&e.up?e.up:t==="left"&&e.left?e.left:t==="right"&&e.right?e.right:t==="right"&&e.left?{name:e.left.name,pixels:dx(e.left.pixels)}:t==="left"&&e.right?{name:e.right.name,pixels:dx(e.right.pixels)}:e.down}function w8(e,t){return fx(e,"hair",t,1)}function fx(e,t,n,i){const a=e.layers.findIndex(c=>c.name===t),o=[...e.layers];if(a>=0)o[a]={...n,name:t};else{const c=i??o.length;o.splice(c,0,{...n,name:t})}return{...e,layers:o}}var j5=new Map,k8=new Map;function C5(e,t){j5.set(e,t)}function Hf(e,t){k8.set(e,t)}function hx(e){return j5.get(e)}function S8(e,t,n,i,a=2){e.clearRect(0,0,t.width*a,t.height*a);for(const o of t.layers)j8(e,o.pixels,a,n,i)}function Sa(e,t,n,i,a){for(const o of t){const c=f0(o.c,a);o.a!==void 0&&o.a!==1&&(e.globalAlpha=o.a),e.fillStyle=c,e.fillRect(n+o.x,i+o.y,o.w,o.h),o.a!==void 0&&o.a!==1&&(e.globalAlpha=1)}}function j8(e,t,n,i,a){for(const o of t){const c=f0(o.c,a);o.a!==void 0&&o.a!==1&&(e.globalAlpha=o.a),e.fillStyle=c,e.fillRect(o.x*n,(o.y+i)*n,o.w*n,o.h*n),o.a!==void 0&&o.a!==1&&(e.globalAlpha=1)}}var yf=new Map;function Ta(e,t,n){if("down"in n&&!("pixels"in n)){const a=n;yf.set(e,{id:e,name:t,layer:{...a.down,name:"hair"},directions:{down:{...a.down,name:"hair"},up:a.up?{...a.up,name:"hair"}:void 0,left:a.left?{...a.left,name:"hair"}:void 0,right:a.right?{...a.right,name:"hair"}:void 0}})}else{const a=n;yf.set(e,{id:e,name:t,layer:{...a,name:"hair"}})}}function mx(e){return yf.get(e)}function h0(){return Array.from(yf.values())}Ta("short","Short",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Ta("messy","Messy",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:0,w:2,h:4,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:7,y:-1,w:2,h:2,c:"lighten($hair, 20)"},{x:2,y:0,w:4,h:1,c:"lighten($hair, 30)",a:.3}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:4,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:0,w:2,h:4,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:7,y:-1,w:2,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:3,y:-1,w:3,h:2,c:"$hair"},{x:2,y:0,w:4,h:1,c:"lighten($hair, 30)",a:.3}]}});Ta("bun","Bun",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:4,y:-2,w:4,h:3,c:"$hair"},{x:5,y:-2,w:2,h:1,c:"lighten($hair, 30)",a:.4}]}});Ta("long","Long",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:11,y:1,w:2,h:7,c:"$hair"},{x:-1,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:11,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:11,y:1,w:2,h:7,c:"$hair"},{x:1,y:2,w:10,h:6,c:"$hair"},{x:2,y:6,w:8,h:2,c:"darken($hair, 10)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:3,c:"$hair"},{x:-1,y:1,w:2,h:7,c:"$hair"},{x:-1,y:6,w:2,h:3,c:"darken($hair, 15)",a:.5},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Ta("mohawk","Mohawk",{down:{name:"hair",pixels:[{x:4,y:-2,w:4,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"},{x:8,y:1,w:3,h:2,c:"$hair"}]},up:{name:"hair",pixels:[{x:4,y:-2,w:4,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"},{x:8,y:1,w:3,h:2,c:"$hair"}]},left:{name:"hair",pixels:[{x:4,y:-2,w:3,h:4,c:"$hair"},{x:5,y:-3,w:2,h:2,c:"lighten($hair, 20)"},{x:1,y:1,w:3,h:2,c:"$hair"}]}});Ta("slicked","Slicked Back",{down:{name:"hair",pixels:[{x:1,y:0,w:10,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 15)",a:.4},{x:3,y:1,w:6,h:1,c:"lighten($hair, 10)",a:.2}]},up:{name:"hair",pixels:[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:10,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 15)",a:.4}]},left:{name:"hair",pixels:[{x:1,y:0,w:9,h:2,c:"$hair"},{x:0,y:1,w:2,h:2,c:"$hair"},{x:2,y:0,w:6,h:1,c:"lighten($hair, 15)",a:.4}]}});Ta("bob","Bob Cut",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:-1,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:11,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:1,y:2,w:10,h:4,c:"$hair"},{x:2,y:5,w:8,h:1,c:"darken($hair, 10)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:3,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:-1,y:5,w:2,h:1,c:"darken($hair, 15)",a:.4},{x:2,y:0,w:6,h:1,c:"lighten($hair, 25)",a:.3}]}});Ta("curly","Curly",{down:{name:"hair",pixels:[{x:0,y:0,w:12,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:2,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:6,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:4,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3},{x:8,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3}]},up:{name:"hair",pixels:[{x:0,y:0,w:12,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:11,y:1,w:2,h:5,c:"$hair"},{x:1,y:2,w:10,h:4,c:"$hair"},{x:3,y:1,w:2,h:1,c:"lighten($hair, 15)",a:.3},{x:7,y:1,w:2,h:1,c:"lighten($hair, 15)",a:.3}]},left:{name:"hair",pixels:[{x:0,y:0,w:10,h:4,c:"$hair"},{x:-1,y:1,w:2,h:5,c:"$hair"},{x:2,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:5,y:0,w:2,h:1,c:"lighten($hair, 25)",a:.4},{x:3,y:2,w:2,h:1,c:"lighten($hair, 15)",a:.3}]}});var C8={short:1,messy:1,bun:2,long:2,mohawk:3,slicked:3,bob:4,curly:4},N8={short:0,messy:0,bun:500,long:500,mohawk:2e3,slicked:2e3,bob:5e3,curly:5e3};function N5(e){return C8[e]??1}function E5(e,t){return t>=N5(e)}function E8(e){return N8[e]??0}var bf=new Map;function ns(e,t,n){if("down"in n&&!("pixels"in n)){const a=n;bf.set(e,{id:e,name:t,layer:{...a.down,name:"torso"},directions:{down:{...a.down,name:"torso"},up:a.up?{...a.up,name:"torso"}:void 0,left:a.left?{...a.left,name:"torso"}:void 0,right:a.right?{...a.right,name:"torso"}:void 0}})}else{const a=n;bf.set(e,{id:e,name:t,layer:{...a,name:"torso"}})}}function px(e){return bf.get(e)}function m0(){return Array.from(bf.values())}ns("tshirt","T-Shirt",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:5,y:10,w:2,h:3,c:"darken($shirt, 10)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:2,y:10,w:7,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});ns("suit","Suit",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 12)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:10,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:2,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:7,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:5,y:10,w:2,h:5,c:"#E8E8E8",a:.5},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:11,w:2,h:1,c:"darken($shirt, 20)",a:.2},{x:11,y:11,w:2,h:1,c:"darken($shirt, 20)",a:.2},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:10,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:5,y:12,w:2,h:4,c:"darken($shirt, 10)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 30)",a:.3},{x:2,y:10,w:3,h:3,c:"darken($shirt, 20)",a:.3},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:11,w:3,h:1,c:"darken($shirt, 20)",a:.2},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});ns("hoodie","Hoodie",{down:{name:"torso",pixels:[{x:0,y:10,w:12,h:6,c:"$shirt"},{x:1,y:10,w:10,h:1,c:"lighten($shirt, 15)",a:.25},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:8,w:8,h:2,c:"$shirt",a:.4},{x:3,y:13,w:6,h:2,c:"darken($shirt, 15)",a:.2},{x:5,y:10,w:1,h:2,c:"#DDD",a:.3},{x:6,y:10,w:1,h:2,c:"#DDD",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:6,c:"$shirt"},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:7,w:8,h:3,c:"$shirt",a:.5},{x:3,y:7,w:6,h:1,c:"darken($shirt, 10)",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:0,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:8,h:1,c:"lighten($shirt, 15)",a:.25},{x:0,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.3},{x:2,y:8,w:6,h:2,c:"$shirt",a:.4},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});ns("vest","Vest",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:5,y:10,w:2,h:2,c:"$skin",a:.6},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:-1,y:11,w:3,h:5,c:"$skin"},{x:-1,y:15,w:3,h:1,c:"darken($skin, 10)"}]}});ns("tank","Tank Top",{down:{name:"torso",pixels:[{x:2,y:10,w:8,h:6,c:"$shirt"},{x:3,y:10,w:6,h:1,c:"lighten($shirt, 18)",a:.3},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:9,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:10,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},up:{name:"torso",pixels:[{x:2,y:10,w:8,h:6,c:"$shirt"},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:9,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:10,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:2,h:5,c:"$skin"},{x:11,y:11,w:2,h:5,c:"$skin"},{x:-1,y:15,w:2,h:1,c:"darken($skin, 10)"},{x:11,y:15,w:2,h:1,c:"darken($skin, 10)"}]},left:{name:"torso",pixels:[{x:2,y:10,w:7,h:6,c:"$shirt"},{x:2,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:0,y:10,w:2,h:2,c:"$skin"},{x:-1,y:11,w:3,h:5,c:"$skin"},{x:-1,y:15,w:3,h:1,c:"darken($skin, 10)"}]}});ns("polo","Polo",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:6,h:2,c:"lighten($shirt, 25)",a:.5},{x:5,y:9,w:2,h:1,c:"$skin",a:.4},{x:5,y:10,w:2,h:3,c:"darken($shirt, 15)",a:.15},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:6,h:1,c:"lighten($shirt, 25)",a:.5},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:9,w:4,h:2,c:"lighten($shirt, 25)",a:.5},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});ns("labcoat","Lab Coat",{down:{name:"torso",pixels:[{x:4,y:10,w:4,h:5,c:"$shirt"},{x:0,y:10,w:4,h:7,c:"#F0F0F0"},{x:8,y:10,w:4,h:7,c:"#F0F0F0"},{x:1,y:10,w:10,h:1,c:"#FAFAFA"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:11,y:10,w:1,h:7,c:"#DDD",a:.5},{x:1,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:9,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:-1,y:11,w:2,h:5,c:"#F0F0F0"},{x:11,y:11,w:2,h:5,c:"#F0F0F0"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"#F0F0F0"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:11,y:10,w:1,h:7,c:"#DDD",a:.5},{x:5,y:11,w:2,h:5,c:"#E8E8E8",a:.3},{x:-1,y:11,w:2,h:5,c:"#F0F0F0"},{x:11,y:11,w:2,h:5,c:"#F0F0F0"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:3,y:10,w:3,h:5,c:"$shirt"},{x:0,y:10,w:3,h:7,c:"#F0F0F0"},{x:6,y:10,w:4,h:7,c:"#F0F0F0"},{x:1,y:10,w:8,h:1,c:"#FAFAFA"},{x:0,y:10,w:1,h:7,c:"#DDD",a:.5},{x:1,y:13,w:2,h:2,c:"#E0E0E0",a:.4},{x:-1,y:11,w:3,h:5,c:"#F0F0F0"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});ns("overalls","Overalls",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:3,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:3,y:11,w:6,h:5,c:"#3D6B99"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:7,y:10,w:2,h:1,c:"#3D6B99"},{x:3,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:8,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:1,y:13,w:2,h:3,c:"#3D6B99"},{x:9,y:13,w:2,h:3,c:"#3D6B99"},{x:5,y:13,w:2,h:2,c:"#345E87",a:.4},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:3,c:"$shirt"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:7,y:10,w:2,h:1,c:"#3D6B99"},{x:1,y:13,w:10,h:3,c:"#3D6B99"},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:3,c:"$shirt"},{x:3,y:11,w:5,h:5,c:"#3D6B99"},{x:3,y:10,w:2,h:1,c:"#3D6B99"},{x:3,y:11,w:1,h:1,c:"#FFD700",a:.6},{x:1,y:13,w:2,h:3,c:"#3D6B99"},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});ns("turtleneck","Turtleneck",{down:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:6,h:2,c:"$shirt"},{x:4,y:8,w:4,h:1,c:"lighten($shirt, 12)",a:.3},{x:3,y:9,w:1,h:1,c:"darken($shirt, 15)",a:.2},{x:8,y:9,w:1,h:1,c:"darken($shirt, 15)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:6,h:2,c:"$shirt"},{x:4,y:8,w:4,h:1,c:"lighten($shirt, 12)",a:.3},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:1,y:10,w:9,h:6,c:"$shirt"},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:3,y:8,w:4,h:2,c:"$shirt"},{x:3,y:8,w:3,h:1,c:"lighten($shirt, 12)",a:.3},{x:-1,y:11,w:3,h:5,c:"$shirt"},{x:-1,y:15,w:3,h:1,c:"$skin"}]}});ns("robe","Robe",{down:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:3,y:10,w:3,h:4,c:"lighten($shirt, 15)",a:.25},{x:6,y:10,w:3,h:4,c:"darken($shirt, 10)",a:.2},{x:1,y:14,w:10,h:1,c:"darken($shirt, 35)"},{x:2,y:14,w:8,h:1,c:"darken($shirt, 25)",a:.4},{x:-2,y:11,w:3,h:5,c:"$shirt"},{x:11,y:11,w:3,h:5,c:"$shirt"},{x:-2,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:11,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},up:{name:"torso",pixels:[{x:0,y:10,w:12,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:11,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:1,y:14,w:10,h:1,c:"darken($shirt, 35)"},{x:-2,y:11,w:3,h:5,c:"$shirt"},{x:11,y:11,w:3,h:5,c:"$shirt"},{x:-2,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:11,y:15,w:3,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}]},left:{name:"torso",pixels:[{x:0,y:10,w:10,h:7,c:"$shirt"},{x:0,y:10,w:1,h:6,c:"darken($shirt, 25)",a:.3},{x:1,y:14,w:8,h:1,c:"darken($shirt, 35)"},{x:-2,y:11,w:4,h:5,c:"$shirt"},{x:-2,y:15,w:4,h:1,c:"darken($shirt, 15)",a:.3},{x:-1,y:15,w:2,h:1,c:"$skin"}]}});var A8={tshirt:1,polo:1,hoodie:2,vest:2,suit:3,tank:3,overalls:4,turtleneck:4,labcoat:5,robe:5},D8={tshirt:0,polo:0,hoodie:500,vest:500,suit:3e3,tank:1e3,overalls:5e3,turtleneck:5e3,labcoat:1e4,robe:1e4};function A5(e){return A8[e]??1}function D5(e,t){return t>=A5(e)}function T8(e){return D8[e]??0}var Ic=new Map;function Qt(e,t,n){if("down"in n&&!("pixels"in n)){const a=n;Ic.set(e,{id:e,name:t,layer:{...a.down,name:"accessory"},directions:{down:{...a.down,name:"accessory"},up:a.up?{...a.up,name:"accessory"}:void 0,left:a.left?{...a.left,name:"accessory"}:void 0,right:a.right?{...a.right,name:"accessory"}:void 0}})}else{const a=n;Ic.set(e,{id:e,name:t,layer:{...a,name:"accessory"}})}}function T5(e){return Ic.get(e)}function _8(e,t){const n=Ic.get(e);if(!n)return;if(n.directions)return v8(n.directions,t);if(t==="down")return n.layer;const i=n.layer.pixels.filter(o=>o.y<2);if(i.length===0)return;const a=t==="right"?1:t==="left"?-1:0;return{name:n.layer.name,pixels:a?i.map(o=>({...o,x:o.x+a})):i}}function p0(){return Array.from(Ic.values())}Qt("none","None",{name:"accessory",pixels:[]});Qt("glasses","Glasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:7,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:2,h:1,c:"#2A3A50",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#2A3A50",a:.4},{x:10,y:3,w:2,h:1,c:"#2A3A50",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#2A3A50",a:.5},{x:5,y:4,w:6,h:1,c:"#2A3A50",a:.3}]}});Qt("round-glasses","Round Glasses",{down:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:7,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:8,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:2,h:1,c:"#8B7355",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#8B7355",a:.3},{x:10,y:3,w:2,h:1,c:"#8B7355",a:.3}]},left:{name:"accessory",pixels:[{x:2,y:3,w:3,h:3,c:"#8B7355",a:.4},{x:3,y:4,w:1,h:1,c:"#B0E0FF",a:.15},{x:5,y:4,w:6,h:1,c:"#8B7355",a:.25}]}});Qt("sunglasses","Sunglasses",{down:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:7,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:5,y:4,w:2,h:1,c:"#1A1A2E",a:.4},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:8,y:4,w:1,h:1,c:"#334",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#1A1A2E",a:.4},{x:10,y:3,w:2,h:1,c:"#1A1A2E",a:.4}]},left:{name:"accessory",pixels:[{x:2,y:4,w:3,h:2,c:"#1A1A2E",a:.7},{x:3,y:4,w:1,h:1,c:"#334",a:.3},{x:5,y:4,w:6,h:1,c:"#1A1A2E",a:.35}]}});Qt("headphones","Headphones",{down:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:0,w:12,h:1,c:"#333",a:.7},{x:-1,y:1,w:2,h:5,c:"#444"},{x:11,y:1,w:2,h:5,c:"#444"},{x:-1,y:2,w:2,h:3,c:"#555",a:.3},{x:11,y:2,w:2,h:3,c:"#555",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:10,h:1,c:"#333",a:.7},{x:-1,y:1,w:3,h:5,c:"#444"},{x:-1,y:2,w:3,h:3,c:"#555",a:.3}]}});Qt("beret","Beret",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:1,y:0,w:2,h:1,c:"#E91E63",a:.6},{x:4,y:-1,w:4,h:1,c:"#F06292",a:.3}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#E91E63"},{x:9,y:0,w:2,h:1,c:"#E91E63",a:.6}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:8,h:2,c:"#E91E63"},{x:2,y:-1,w:4,h:1,c:"#F06292",a:.3}]}});Qt("cap","Cap",{down:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:0,y:1,w:12,h:1,c:"#0D47A1"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:10,h:2,c:"#1565C0"},{x:3,y:-1,w:6,h:1,c:"#1E88E5",a:.3},{x:5,y:1,w:2,h:1,c:"#0D47A1",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:-1,w:9,h:2,c:"#1565C0"},{x:-2,y:1,w:6,h:1,c:"#0D47A1"},{x:2,y:-1,w:5,h:1,c:"#1E88E5",a:.3}]}});Qt("badge","Badge",{down:{name:"accessory",pixels:[{x:5,y:8,w:2,h:3,c:"#2196F3",a:.4},{x:4,y:11,w:4,h:3,c:"#FFF",a:.5},{x:5,y:12,w:2,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:8,w:1,h:3,c:"#2196F3",a:.4},{x:2,y:11,w:3,h:3,c:"#FFF",a:.5}]}});Qt("lapels","Lapels",{down:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4},{x:8,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:1,y:10,w:3,h:2,c:"#1A1A2E",a:.4}]}});Qt("blush","Blush",{down:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3},{x:9,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:2,y:6,w:1,h:1,c:"#FFCDD2",a:.3}]}});Qt("scarf","Scarf",{down:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3},{x:3,y:11,w:2,h:3,c:"#E53935",a:.5}]},up:{name:"accessory",pixels:[{x:2,y:9,w:8,h:2,c:"#E53935",a:.6},{x:3,y:9,w:6,h:1,c:"#EF5350",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:9,w:8,h:2,c:"#E53935",a:.6},{x:2,y:9,w:5,h:1,c:"#EF5350",a:.3},{x:1,y:11,w:2,h:3,c:"#E53935",a:.5}]}});Qt("tie","Tie",{down:{name:"accessory",pixels:[{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:5,y:10,w:2,h:4,c:"#D32F2F"},{x:5,y:10,w:1,h:4,c:"#E53935",a:.3},{x:5,y:14,w:2,h:1,c:"#B71C1C",a:.8}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:4,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:10,w:2,h:4,c:"#D32F2F"},{x:4,y:14,w:2,h:1,c:"#B71C1C",a:.8}]}});Qt("bowtie","Bowtie",{down:{name:"accessory",pixels:[{x:3,y:9,w:2,h:1,c:"#D32F2F"},{x:7,y:9,w:2,h:1,c:"#D32F2F"},{x:5,y:9,w:2,h:1,c:"#B71C1C"},{x:4,y:9,w:1,h:1,c:"#E53935",a:.3},{x:7,y:9,w:1,h:1,c:"#E53935",a:.3}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:3,y:9,w:3,h:1,c:"#D32F2F"},{x:4,y:9,w:1,h:1,c:"#B71C1C"}]}});Qt("cat-ears","Cat Ears",{down:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:1,y:-2,w:1,h:1,c:"#FFB0C0",a:.6},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"},{x:10,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#555"},{x:0,y:-2,w:3,h:1,c:"#555"},{x:0,y:-1,w:3,h:1,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:1,c:"#555"},{x:9,y:-1,w:3,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:2,y:-3,w:2,h:1,c:"#555"},{x:1,y:-2,w:3,h:1,c:"#555"},{x:1,y:-1,w:3,h:1,c:"#555"},{x:2,y:-2,w:1,h:1,c:"#FFB0C0",a:.6}]}});Qt("bear-ears","Bear Ears",{down:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:1,y:-1,w:1,h:1,c:"#C4A24A",a:.5},{x:9,y:-2,w:3,h:2,c:"#8B6914"},{x:10,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]},up:{name:"accessory",pixels:[{x:0,y:-2,w:3,h:2,c:"#8B6914"},{x:9,y:-2,w:3,h:2,c:"#8B6914"}]},left:{name:"accessory",pixels:[{x:1,y:-2,w:3,h:2,c:"#8B6914"},{x:2,y:-1,w:1,h:1,c:"#C4A24A",a:.5}]}});Qt("bunny-ears","Bunny Ears",{down:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:2,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},up:{name:"accessory",pixels:[{x:2,y:-5,w:2,h:4,c:"#F5F5F5"},{x:8,y:-5,w:2,h:4,c:"#F5F5F5"},{x:9,y:-6,w:2,h:1,c:"#F5F5F5"}]},left:{name:"accessory",pixels:[{x:3,y:-5,w:2,h:4,c:"#F5F5F5"},{x:3,y:-4,w:1,h:2,c:"#FFB0C0",a:.5},{x:4,y:-6,w:2,h:1,c:"#F5F5F5"}]}});Qt("dog-nose","Dog Nose",{down:{name:"accessory",pixels:[{x:4,y:5,w:4,h:3,c:"#D2B48C",a:.5},{x:5,y:5,w:2,h:1,c:"#222"},{x:6,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]},up:{name:"accessory",pixels:[]},left:{name:"accessory",pixels:[{x:0,y:5,w:4,h:2,c:"#D2B48C",a:.5},{x:0,y:5,w:2,h:1,c:"#222"},{x:1,y:7,w:1,h:1,c:"#FF6B8A",a:.7}]}});Qt("fox-mask","Fox Mask",{down:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"},{x:0,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:11,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:9,y:5,w:2,h:2,c:"#FFF",a:.25},{x:5,y:6,w:2,h:1,c:"#222",a:.6}]},up:{name:"accessory",pixels:[{x:0,y:-3,w:2,h:1,c:"#E65100"},{x:-1,y:-2,w:3,h:1,c:"#E65100"},{x:0,y:-1,w:3,h:1,c:"#E65100"},{x:10,y:-3,w:2,h:1,c:"#E65100"},{x:10,y:-2,w:3,h:1,c:"#E65100"},{x:9,y:-1,w:3,h:1,c:"#E65100"}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:2,h:1,c:"#E65100"},{x:0,y:-2,w:3,h:1,c:"#E65100"},{x:1,y:-1,w:3,h:1,c:"#E65100"},{x:1,y:-2,w:1,h:1,c:"#FFF",a:.4},{x:1,y:5,w:2,h:2,c:"#FFF",a:.25},{x:1,y:6,w:2,h:1,c:"#222",a:.6}]}});Qt("crown","Crown",{down:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:4,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:6,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:8,y:-2,w:1,h:1,c:"#66BB6A",a:.8},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-1,w:8,h:2,c:"#FFD700"},{x:3,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:7,y:-3,w:2,h:2,c:"#FFD700"},{x:3,y:-1,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-1,w:7,h:2,c:"#FFD700"},{x:2,y:-3,w:2,h:2,c:"#FFD700"},{x:5,y:-2,w:2,h:1,c:"#FFD700"},{x:3,y:-2,w:1,h:1,c:"#E53935",a:.8},{x:5,y:-1,w:1,h:1,c:"#42A5F5",a:.8},{x:2,y:-1,w:5,h:1,c:"#FFF",a:.15}]}});Qt("halo","Halo",{down:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},up:{name:"accessory",pixels:[{x:2,y:-3,w:8,h:1,c:"#FFE082",a:.7},{x:1,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:10,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:3,y:-4,w:6,h:1,c:"#FFF9C4",a:.4},{x:3,y:-3,w:6,h:1,c:"#FFF",a:.15}]},left:{name:"accessory",pixels:[{x:1,y:-3,w:7,h:1,c:"#FFE082",a:.7},{x:0,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:8,y:-2,w:1,h:1,c:"#FFE082",a:.5},{x:2,y:-4,w:5,h:1,c:"#FFF9C4",a:.4},{x:2,y:-3,w:5,h:1,c:"#FFF",a:.15}]}});Qt("horns","Horns",{down:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},up:{name:"accessory",pixels:[{x:1,y:-1,w:2,h:2,c:"#8B0000"},{x:0,y:-3,w:2,h:2,c:"#A00"},{x:0,y:-4,w:1,h:1,c:"#C62828"},{x:9,y:-1,w:2,h:2,c:"#8B0000"},{x:10,y:-3,w:2,h:2,c:"#A00"},{x:11,y:-4,w:1,h:1,c:"#C62828"}]},left:{name:"accessory",pixels:[{x:2,y:-1,w:2,h:2,c:"#8B0000"},{x:1,y:-3,w:2,h:2,c:"#A00"},{x:1,y:-4,w:1,h:1,c:"#C62828"}]}});Qt("mask","Mask",{down:{name:"accessory",pixels:[{x:1,y:3,w:10,h:3,c:"#1A1A2E",a:.75},{x:3,y:4,w:2,h:1,c:"#000",a:0},{x:7,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:10,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:10,h:1,c:"#FFD700",a:.2}]},up:{name:"accessory",pixels:[{x:0,y:4,w:12,h:1,c:"#1A1A2E",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:6,h:3,c:"#1A1A2E",a:.75},{x:2,y:4,w:2,h:1,c:"#000",a:0},{x:1,y:3,w:6,h:1,c:"#FFD700",a:.3},{x:1,y:5,w:6,h:1,c:"#FFD700",a:.2}]}});Qt("bandana","Bandana",{down:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:1,w:12,h:2,c:"#E53935"},{x:1,y:1,w:10,h:1,c:"#EF5350",a:.3},{x:11,y:2,w:2,h:2,c:"#E53935",a:.7},{x:12,y:3,w:1,h:1,c:"#C62828",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:1,w:10,h:2,c:"#E53935"},{x:1,y:1,w:8,h:1,c:"#EF5350",a:.3}]}});Qt("eyepatch","Eye Patch",{down:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5},{x:2,y:3,w:3,h:3,c:"#1A1A1A"},{x:3,y:4,w:1,h:1,c:"#333",a:.3}]},up:{name:"accessory",pixels:[{x:0,y:3,w:12,h:1,c:"#222",a:.5}]},left:{name:"accessory",pixels:[{x:0,y:3,w:10,h:1,c:"#222",a:.5},{x:1,y:3,w:3,h:3,c:"#1A1A1A"},{x:2,y:4,w:1,h:1,c:"#333",a:.3}]}});Qt("cat-face","Cat Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:1,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:10,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:7,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:8,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:4,y:6,w:1,h:1,c:"#444",a:.6},{x:7,y:6,w:1,h:1,c:"#444",a:.6},{x:0,y:5,w:2,h:1,c:"#888",a:.4},{x:10,y:5,w:2,h:1,c:"#888",a:.4},{x:0,y:6,w:2,h:1,c:"#888",a:.3},{x:10,y:6,w:2,h:1,c:"#888",a:.3}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#555"},{x:2,y:0,w:8,h:1,c:"#555"},{x:0,y:-2,w:3,h:2,c:"#555"},{x:1,y:-3,w:2,h:1,c:"#555"},{x:9,y:-2,w:3,h:2,c:"#555"},{x:9,y:-3,w:2,h:1,c:"#555"},{x:5,y:1,w:2,h:5,c:"#4A4A4A",a:.3},{x:9,y:8,w:2,h:2,c:"#555"},{x:10,y:7,w:1,h:1,c:"#555"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#555"},{x:2,y:0,w:7,h:1,c:"#555"},{x:2,y:-2,w:3,h:2,c:"#555"},{x:3,y:-3,w:2,h:1,c:"#555"},{x:3,y:-1,w:1,h:1,c:"#FFB0C0",a:.7},{x:2,y:3,w:3,h:3,c:"#222"},{x:3,y:3,w:1,h:2,c:"#4FC3F7",a:.8},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#555"},{x:0,y:5,w:2,h:1,c:"#FFB0C0"},{x:-1,y:5,w:2,h:1,c:"#888",a:.4},{x:-1,y:6,w:2,h:1,c:"#888",a:.3}]}});Qt("bear-face","Bear Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:3,y:5,w:6,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:7,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:7,y:3,w:1,h:1,c:"#FFF",a:.3},{x:5,y:5,w:2,h:1,c:"#222"},{x:5,y:7,w:2,h:1,c:"#6B4F10",a:.5}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#8B6914"},{x:2,y:-1,w:8,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:9,y:-1,w:3,h:3,c:"#8B6914"},{x:1,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:10,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:5,y:1,w:2,h:5,c:"#7A5B10",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#8B6914"},{x:2,y:-1,w:7,h:1,c:"#8B6914"},{x:0,y:-1,w:3,h:3,c:"#8B6914"},{x:0,y:0,w:1,h:1,c:"#C4A24A",a:.6},{x:0,y:4,w:3,h:4,c:"#C4A24A",a:.7},{x:3,y:3,w:2,h:2,c:"#111"},{x:3,y:3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:5,w:2,h:1,c:"#222"}]}});Qt("panda-face","Panda Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:7,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:8,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:8,y:4,w:1,h:1,c:"#111"},{x:5,y:6,w:2,h:1,c:"#222"},{x:5,y:7,w:1,h:1,c:"#CCC",a:.4},{x:6,y:7,w:1,h:1,c:"#CCC",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#F5F5F5"},{x:2,y:-1,w:8,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:9,y:-2,w:3,h:3,c:"#222"},{x:5,y:1,w:2,h:5,c:"#EEE",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#F5F5F5"},{x:2,y:-1,w:7,h:1,c:"#F5F5F5"},{x:0,y:-2,w:3,h:3,c:"#222"},{x:2,y:2,w:3,h:4,c:"#222"},{x:3,y:3,w:1,h:2,c:"#FFF"},{x:3,y:4,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:2,c:"#F5F5F5"},{x:1,y:6,w:1,h:1,c:"#222"}]}});Qt("frog-face","Frog Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:3,c:"#4CAF50"},{x:7,y:-2,w:4,h:3,c:"#4CAF50"},{x:2,y:-1,w:2,h:2,c:"#FFF"},{x:8,y:-1,w:2,h:2,c:"#FFF"},{x:3,y:0,w:1,h:1,c:"#111"},{x:9,y:0,w:1,h:1,c:"#111"},{x:3,y:5,w:6,h:3,c:"#81C784",a:.5},{x:2,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:4,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:7,y:4,w:1,h:1,c:"#388E3C",a:.5},{x:1,y:5,w:2,h:1,c:"#FF8A80",a:.25},{x:9,y:5,w:2,h:1,c:"#FF8A80",a:.25}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#4CAF50"},{x:2,y:0,w:8,h:1,c:"#4CAF50"},{x:1,y:-2,w:4,h:2,c:"#4CAF50"},{x:7,y:-2,w:4,h:2,c:"#4CAF50"},{x:5,y:2,w:2,h:4,c:"#388E3C",a:.2}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#4CAF50"},{x:2,y:0,w:7,h:1,c:"#4CAF50"},{x:0,y:-2,w:4,h:3,c:"#4CAF50"},{x:1,y:-1,w:2,h:2,c:"#FFF"},{x:2,y:0,w:1,h:1,c:"#111"},{x:0,y:5,w:3,h:3,c:"#81C784",a:.5},{x:0,y:7,w:8,h:1,c:"#388E3C",a:.6},{x:1,y:5,w:1,h:1,c:"#FF8A80",a:.25}]}});Qt("rabbit-face","Rabbit Face",{down:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:7,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:8,y:3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:1,c:"#FFB0C0"},{x:5,y:6,w:1,h:1,c:"#DDD",a:.4},{x:6,y:6,w:1,h:1,c:"#DDD",a:.4},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6},{x:10,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]},up:{name:"accessory",pixels:[{x:1,y:1,w:10,h:8,c:"#F5F5F5"},{x:2,y:0,w:8,h:1,c:"#F5F5F5"},{x:2,y:-6,w:3,h:6,c:"#F5F5F5"},{x:7,y:-6,w:3,h:6,c:"#F5F5F5"},{x:3,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:8,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:5,y:8,w:3,h:2,c:"#FFF"}]},left:{name:"accessory",pixels:[{x:1,y:1,w:9,h:8,c:"#F5F5F5"},{x:2,y:0,w:7,h:1,c:"#F5F5F5"},{x:3,y:-6,w:3,h:6,c:"#F5F5F5"},{x:4,y:-5,w:1,h:4,c:"#FFB0C0",a:.6},{x:2,y:3,w:3,h:3,c:"#E57373",a:.7},{x:3,y:3,w:1,h:1,c:"#FFF",a:.4},{x:0,y:4,w:3,h:3,c:"#F5F5F5"},{x:1,y:5,w:1,h:1,c:"#FFB0C0"},{x:0,y:4,w:2,h:3,c:"#F5F5F5",a:.6}]}});Qt("dog-face","Dog Face",{down:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:3,y:5,w:6,h:4,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:7,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:7,y:2,w:1,h:1,c:"#FFF",a:.4},{x:5,y:5,w:2,h:2,c:"#222"},{x:5,y:7,w:2,h:2,c:"#FF6B8A",a:.8},{x:5,y:7,w:1,h:1,c:"#FF8A9E",a:.4}]},up:{name:"accessory",pixels:[{x:1,y:0,w:10,h:9,c:"#D2A25C"},{x:2,y:-1,w:8,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:10,y:1,w:3,h:6,c:"#A67B3D"},{x:5,y:0,w:2,h:6,c:"#B8883C",a:.3},{x:2,y:8,w:8,h:1,c:"#A67B3D",a:.5}]},left:{name:"accessory",pixels:[{x:1,y:0,w:9,h:9,c:"#D2A25C"},{x:2,y:-1,w:7,h:1,c:"#D2A25C"},{x:-1,y:1,w:3,h:6,c:"#A67B3D"},{x:-1,y:4,w:3,h:4,c:"#D2A25C"},{x:-1,y:5,w:2,h:3,c:"#F5E6D0",a:.8},{x:3,y:2,w:2,h:3,c:"#3E2723"},{x:3,y:2,w:1,h:1,c:"#FFF",a:.4},{x:0,y:5,w:2,h:1,c:"#222"},{x:0,y:7,w:2,h:1,c:"#FF6B8A",a:.7}]}});var M8={none:1,glasses:1,beret:1,cap:1,badge:1,blush:1,lapels:1,"round-glasses":2,headphones:2,scarf:3,tie:3,bowtie:3,sunglasses:4,bandana:4,eyepatch:4,crown:5,halo:5,horns:5,mask:5,"cat-ears":6,"bear-ears":6,"bunny-ears":6,"dog-nose":6,"fox-mask":6,"cat-face":7,"bear-face":7,"panda-face":7,"frog-face":8,"rabbit-face":8,"dog-face":8,"star-glasses":9};function _5(e){return M8[e]??1}function M5(e,t){return t>=_5(e)}var F8={none:0,glasses:0,beret:0,cap:0,badge:0,blush:0,lapels:0,"round-glasses":500,headphones:800,scarf:1500,tie:1500,bowtie:1500,sunglasses:3e3,bandana:3e3,eyepatch:3e3,crown:8e3,halo:8e3,horns:5e3,mask:5e3,"cat-ears":8e3,"bear-ears":8e3,"bunny-ears":8e3,"dog-nose":5e3,"fox-mask":8e3,"cat-face":15e3,"bear-face":15e3,"panda-face":15e3,"frog-face":25e3,"rabbit-face":25e3,"dog-face":25e3,"star-glasses":5e4};function R8(e){return F8[e]??0}Qt("star-glasses","Star Glasses",{down:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:7,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:8,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:8,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:2,h:1,c:"#FF4081",a:.4}]},up:{name:"accessory",pixels:[{x:0,y:3,w:2,h:1,c:"#FF4081",a:.3},{x:10,y:3,w:2,h:1,c:"#FF4081",a:.3}]},left:{name:"accessory",pixels:[{x:1,y:3,w:4,h:3,c:"#FF4081",a:.6},{x:2,y:2,w:2,h:1,c:"#FF4081",a:.6},{x:2,y:6,w:2,h:1,c:"#FF4081",a:.6},{x:5,y:4,w:6,h:1,c:"#FF4081",a:.3}]}});function kc({r:e,g:t,b:n}){return`#${(e<<16|t<<8|n).toString(16).padStart(6,"0")}`}function af(e,t){const n=e.r-t.r,i=e.g-t.g,a=e.b-t.b;return n*n+i*i+a*a}function z8(e,t){const n=[];n.push(e[Math.floor(Math.random()*e.length)]);for(let i=1;i<t;i++){const a=e.map(d=>{let m=1/0;for(const f of n)m=Math.min(m,af(d,f));return m}),o=a.reduce((d,m)=>d+m,0);let c=Math.random()*o;for(let d=0;d<e.length;d++)if(c-=a[d],c<=0){n.push(e[d]);break}n.length<=i&&n.push(e[Math.floor(Math.random()*e.length)])}return n}function B8(e,t,n=20){if(e.length===0)return[];const i=z8(e,t);for(let o=0;o<n;o++){const c=Array.from({length:t},()=>[]);for(const m of e){let f=1/0,x=0;for(let p=0;p<t;p++){const y=af(m,i[p]);y<f&&(f=y,x=p)}c[x].push(m)}let d=!0;for(let m=0;m<t;m++){if(c[m].length===0)continue;const f={r:0,g:0,b:0};for(const y of c[m])f.r+=y.r,f.g+=y.g,f.b+=y.b;const x=c[m].length,p={r:Math.round(f.r/x),g:Math.round(f.g/x),b:Math.round(f.b/x)};af(p,i[m])>1&&(d=!1),i[m]=p}if(d)break}const a=new Array(t).fill(0);for(const o of e){let c=1/0,d=0;for(let m=0;m<t;m++){const f=af(o,i[m]);f<c&&(c=f,d=m)}a[d]++}return i.map((o,c)=>({c:o,count:a[c]})).sort((o,c)=>c.count-o.count).map(o=>o.c)}function $8(e,t=1e4){const n=document.createElement("canvas"),i=e instanceof HTMLImageElement?e.naturalWidth:e.width,a=e instanceof HTMLImageElement?e.naturalHeight:e.height;n.width=i,n.height=a;const o=n.getContext("2d");o.drawImage(e,0,0);const c=o.getImageData(0,0,i,a).data,d=i*a,m=Math.max(1,Math.floor(d/t)),f=[];for(let x=0;x<d;x+=m){const p=x*4;c[p+3]<128||f.push({r:c[p],g:c[p+1],b:c[p+2]})}return f}function mv(e){return .299*e.r+.587*e.g+.114*e.b}function pv(e){const t=Math.max(e.r,e.g,e.b),n=Math.min(e.r,e.g,e.b);return t===0?0:(t-n)/t*255}function O8(e,t=8){const n=$8(e),i=B8(n,t);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const a=[...i].sort((p,y)=>mv(y)-mv(p)),o=[...i].sort((p,y)=>pv(y)-pv(p)),c=a[0],d=a[a.length-1],m=o[0],f=a[a.length-2],x=a[a.length-1];return{skinColor:kc(c),hairColor:kc(d),shirtColor:kc(m),pantsColor:kc(f),shoeColor:kc(x)}}var L8=[{x:1,y:19,w:10,h:2,c:"#100A06",a:.15},{x:2,y:15,w:3,h:4,c:"$pants"},{x:7,y:15,w:3,h:4,c:"$pants"},{x:2,y:19,w:3,h:2,c:"$shoes"},{x:7,y:19,w:3,h:2,c:"$shoes"},{x:2,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4},{x:7,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4}],I8=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}];function Sc(e,t,n,i,a,o){for(const c of t){const d=f0(c.c,o);c.a!==void 0&&c.a!==1&&(e.globalAlpha=c.a),e.fillStyle=d,e.fillRect((c.x+i)*n,(c.y+a)*n,c.w*n,c.h*n),c.a!==void 0&&c.a!==1&&(e.globalAlpha=1)}}function H8(e){var n;const t=mx(e);return t?(n=t.directions)!=null&&n.down?t.directions.down.pixels:t.layer.pixels:mx("short").layer.pixels}function U8(e){var n;const t=px(e);return t?(n=t.directions)!=null&&n.down?t.directions.down.pixels:t.layer.pixels:px("tshirt").layer.pixels}function q8(e){var n;const t=T5(e);return t?(n=t.directions)!=null&&n.down?t.directions.down.pixels:t.layer.pixels:[]}function DL(e,t){const n=(t==null?void 0:t.scale)??3,i=(t==null?void 0:t.padX)??2,a=(t==null?void 0:t.padY)??4,o=1,c=12+i*2,d=22+a+o,m=document.createElement("canvas");m.width=c*n,m.height=d*n,m.style.imageRendering="pixelated";const f=m.getContext("2d"),x=i,p=a;Sc(f,L8,n,x,p,e);const y=e.outfitStyle||"tshirt";Sc(f,U8(y),n,x,p,e),Sc(f,I8,n,x,p,e);const g=e.hairStyle||"short";Sc(f,H8(g),n,x,p,e);const w=e.accessory||"none";return Sc(f,q8(w),n,x,p,e),m}var TL=h0().map(e=>e.id),Y8=m0().map(e=>e.id),_L=Y8,ML=p0().map(e=>e.id);const P8=[{x:1,y:19,w:10,h:2,c:"#100A06",a:.15},{x:2,y:15,w:3,h:4,c:"$pants"},{x:7,y:15,w:3,h:4,c:"$pants"},{x:2,y:19,w:3,h:2,c:"$shoes"},{x:7,y:19,w:3,h:2,c:"$shoes"},{x:2,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4},{x:7,y:19,w:3,h:1,c:"lighten($shoes, 20)",a:.4}],X8=[{x:1,y:10,w:10,h:6,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:5,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"},{x:-1,y:15,w:2,h:1,c:"$skin"},{x:11,y:15,w:2,h:1,c:"$skin"}],V8=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}],W8=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function G8(){return{width:12,height:22,layers:[{name:"lower",pixels:P8},{name:"torso",pixels:X8},{name:"head",pixels:V8},{name:"hair",pixels:W8},{name:"accessory",pixels:[]}]}}const K8=["cto","cbo","pm","engineer","designer","qa","data-analyst","default"];for(const e of K8)C5(`mini:${e}`,G8());const Q8=[{x:1,y:10,w:10,h:8,c:"$shirt"},{x:2,y:10,w:8,h:1,c:"lighten($shirt, 18)",a:.3},{x:1,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:10,y:10,w:1,h:7,c:"darken($shirt, 25)",a:.25},{x:4,y:10,w:4,h:2,c:"darken($shirt, 25)",a:.2},{x:-1,y:11,w:2,h:5,c:"$shirt"},{x:11,y:11,w:2,h:5,c:"$shirt"}],Z8=[{x:4,y:8,w:4,h:3,c:"$skin"},{x:1,y:1,w:10,h:8,c:"$skin"},{x:3,y:4,w:2,h:2,c:"#1A1A2E"},{x:7,y:4,w:2,h:2,c:"#1A1A2E"},{x:3,y:4,w:1,h:1,c:"#FFF",a:.35},{x:7,y:4,w:1,h:1,c:"#FFF",a:.35},{x:5,y:7,w:2,h:1,c:"darken($skin, 25)",a:.4},{x:0,y:4,w:1,h:1,c:"$skin"},{x:11,y:4,w:1,h:1,c:"$skin"}],J8=[{x:1,y:0,w:10,h:3,c:"$hair"},{x:0,y:1,w:2,h:3,c:"$hair"},{x:10,y:1,w:2,h:3,c:"$hair"},{x:2,y:0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:2,y:2,w:8,h:1,c:"darken($hair, 20)",a:.2}];function eD(){return{width:12,height:22,layers:[{name:"torso",pixels:Q8},{name:"head",pixels:Z8},{name:"hair",pixels:J8},{name:"accessory",pixels:[]}]}}C5("mini-seated:default",eD());const tD={canvasWidth:160,canvasHeight:80,scale:2,pixels:[{x:0,y:0,w:80,h:40,c:"#1e2030"},{x:10,y:2,w:10,h:6,c:"#78889c"},{x:10,y:2,w:10,h:1,c:"#8899ad"},{x:24,y:0,w:10,h:6,c:"#78889c"},{x:24,y:0,w:10,h:1,c:"#8899ad"},{x:38,y:2,w:10,h:6,c:"#78889c"},{x:38,y:2,w:10,h:1,c:"#8899ad"},{x:54,y:2,w:10,h:6,c:"#78889c"},{x:54,y:2,w:10,h:1,c:"#8899ad"},{x:11,y:7,w:2,h:2,c:"#2a2a2a"},{x:17,y:7,w:2,h:2,c:"#2a2a2a"},{x:25,y:5,w:2,h:2,c:"#2a2a2a"},{x:31,y:5,w:2,h:2,c:"#2a2a2a"},{x:39,y:7,w:2,h:2,c:"#2a2a2a"},{x:45,y:7,w:2,h:2,c:"#2a2a2a"},{x:55,y:7,w:2,h:2,c:"#2a2a2a"},{x:61,y:7,w:2,h:2,c:"#2a2a2a"},{x:8,y:8,w:64,h:24,c:"#6b5b4b"},{x:4,y:10,w:72,h:20,c:"#7d6d5d"},{x:2,y:12,w:76,h:16,c:"#7d6d5d"},{x:2,y:12,w:76,h:2,c:"#8b7b6b"},{x:2,y:26,w:76,h:2,c:"#4b3b2b"},{x:2,y:28,w:76,h:3,c:"#4b3b2b"},{x:4,y:28,w:72,h:1,c:"#5b4b3b"},{x:6,y:30,w:3,h:2,c:"#3a2a1a"},{x:71,y:30,w:3,h:2,c:"#3a2a1a"},{x:18,y:14,w:44,h:12,c:"#6b5b4b",a:.5},{x:28,y:14,w:14,h:8,c:"#1a1a2e"},{x:29,y:15,w:12,h:6,c:"#1565C0",a:.5},{x:30,y:16,w:8,h:1,c:"#60A5FA",a:.45},{x:30,y:18,w:5,h:1,c:"#60A5FA",a:.3},{x:58,y:16,w:5,h:5,c:"#795548"},{x:59,y:17,w:3,h:3,c:"#A67C52"},{x:63,y:18,w:2,h:2,c:"#795548"},{x:10,y:16,w:10,h:8,c:"#FFEE58",a:.7},{x:11,y:17,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:19,w:8,h:1,c:"#9E9E9E",a:.5},{x:11,y:21,w:6,h:1,c:"#9E9E9E",a:.5},{x:10,y:32,w:10,h:6,c:"#78889c"},{x:10,y:32,w:10,h:1,c:"#8899ad"},{x:24,y:34,w:10,h:6,c:"#78889c"},{x:24,y:34,w:10,h:1,c:"#8899ad"},{x:38,y:32,w:10,h:6,c:"#78889c"},{x:38,y:32,w:10,h:1,c:"#8899ad"},{x:54,y:32,w:10,h:6,c:"#78889c"},{x:54,y:32,w:10,h:1,c:"#8899ad"},{x:11,y:37,w:2,h:2,c:"#2a2a2a"},{x:17,y:37,w:2,h:2,c:"#2a2a2a"},{x:25,y:39,w:2,h:2,c:"#2a2a2a"},{x:31,y:39,w:2,h:2,c:"#2a2a2a"},{x:39,y:37,w:2,h:2,c:"#2a2a2a"},{x:45,y:37,w:2,h:2,c:"#2a2a2a"},{x:55,y:37,w:2,h:2,c:"#2a2a2a"},{x:61,y:37,w:2,h:2,c:"#2a2a2a"}]},nD={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:0,y:0,w:64,h:48,c:"#4b3b2b"},{x:3,y:3,w:58,h:42,c:"#8B7355"},{x:4,y:4,w:10,h:10,c:"#A0845C",a:.5},{x:20,y:8,w:8,h:8,c:"#A0845C",a:.4},{x:40,y:6,w:12,h:6,c:"#A0845C",a:.3},{x:8,y:30,w:14,h:10,c:"#A0845C",a:.25},{x:44,y:32,w:10,h:8,c:"#A0845C",a:.3},{x:6,y:8,w:18,h:12,c:"#FFEE58"},{x:5,y:7,w:3,h:3,c:"#EF5350"},{x:6,y:7,w:2,h:2,c:"#C62828"},{x:8,y:10,w:14,h:1,c:"#9E9E9E"},{x:8,y:12,w:12,h:1,c:"#9E9E9E"},{x:8,y:14,w:10,h:1,c:"#9E9E9E"},{x:28,y:6,w:16,h:14,c:"#B3E5FC"},{x:35,y:5,w:3,h:3,c:"#42A5F5"},{x:36,y:5,w:2,h:2,c:"#1565C0"},{x:30,y:9,w:12,h:1,c:"#9E9E9E"},{x:30,y:11,w:10,h:1,c:"#9E9E9E"},{x:30,y:13,w:11,h:1,c:"#9E9E9E"},{x:8,y:24,w:16,h:14,c:"#C8E6C9"},{x:15,y:23,w:3,h:3,c:"#66BB6A"},{x:16,y:23,w:2,h:2,c:"#388E3C"},{x:10,y:27,w:12,h:1,c:"#9E9E9E"},{x:10,y:29,w:8,h:1,c:"#9E9E9E"},{x:10,y:31,w:10,h:1,c:"#9E9E9E"},{x:28,y:24,w:28,h:16,c:"#FFCDD2"},{x:43,y:23,w:3,h:3,c:"#EF5350"},{x:44,y:23,w:2,h:2,c:"#B71C1C"},{x:32,y:27,w:24,h:1,c:"#9E9E9E"},{x:32,y:29,w:20,h:1,c:"#9E9E9E"},{x:32,y:31,w:22,h:1,c:"#9E9E9E"},{x:32,y:33,w:15,h:1,c:"#9E9E9E"},{x:0,y:0,w:64,h:3,c:"#5a4a3a"},{x:0,y:45,w:64,h:3,c:"#3a2a1a"}]},rD={canvasWidth:128,canvasHeight:96,scale:2,pixels:[{x:2,y:0,w:60,h:48,c:"#3b1f0a"},{x:4,y:2,w:56,h:44,c:"#5a3310"},{x:4,y:13,w:56,h:2,c:"#2d1508"},{x:4,y:27,w:56,h:2,c:"#2d1508"},{x:4,y:41,w:56,h:2,c:"#2d1508"},{x:5,y:3,w:4,h:10,c:"#2563EB"},{x:5,y:3,w:4,h:2,c:"#1D4ED8"},{x:10,y:4,w:3,h:9,c:"#DC2626"},{x:10,y:4,w:3,h:2,c:"#B91C1C"},{x:14,y:3,w:5,h:10,c:"#16A34A"},{x:14,y:3,w:5,h:2,c:"#15803D"},{x:20,y:4,w:3,h:9,c:"#9333EA"},{x:20,y:4,w:3,h:2,c:"#7E22CE"},{x:24,y:3,w:4,h:10,c:"#D97706"},{x:24,y:3,w:4,h:2,c:"#B45309"},{x:29,y:4,w:3,h:9,c:"#0891B2"},{x:29,y:4,w:3,h:2,c:"#0E7490"},{x:33,y:3,w:5,h:10,c:"#BE123C"},{x:33,y:3,w:5,h:2,c:"#9F1239"},{x:39,y:4,w:4,h:9,c:"#4F46E5"},{x:39,y:4,w:4,h:2,c:"#3730A3"},{x:44,y:3,w:3,h:10,c:"#065F46"},{x:44,y:3,w:3,h:2,c:"#064E3B"},{x:48,y:4,w:4,h:9,c:"#92400E"},{x:48,y:4,w:4,h:2,c:"#78350F"},{x:53,y:3,w:5,h:10,c:"#1E3A5F"},{x:53,y:3,w:5,h:2,c:"#1e3060"},{x:6,y:6,w:2,h:1,c:"#BFDBFE",a:.7},{x:11,y:7,w:1,h:1,c:"#FCA5A5",a:.7},{x:16,y:6,w:3,h:1,c:"#BBF7D0",a:.7},{x:21,y:7,w:1,h:1,c:"#D8B4FE",a:.7},{x:25,y:6,w:2,h:1,c:"#FDE68A",a:.7},{x:5,y:16,w:5,h:11,c:"#0F766E"},{x:5,y:16,w:5,h:2,c:"#0D6056"},{x:11,y:17,w:3,h:10,c:"#C2410C"},{x:11,y:17,w:3,h:2,c:"#9A3412"},{x:15,y:16,w:4,h:11,c:"#7C3AED"},{x:15,y:16,w:4,h:2,c:"#6D28D9"},{x:20,y:17,w:3,h:10,c:"#1D4ED8"},{x:20,y:17,w:3,h:2,c:"#1E40AF"},{x:24,y:16,w:5,h:11,c:"#166534"},{x:24,y:16,w:5,h:2,c:"#14532D"},{x:30,y:17,w:4,h:10,c:"#991B1B"},{x:30,y:17,w:4,h:2,c:"#7F1D1D"},{x:35,y:16,w:3,h:11,c:"#854D0E"},{x:35,y:16,w:3,h:2,c:"#713F12"},{x:39,y:17,w:4,h:10,c:"#1E40AF"},{x:39,y:17,w:4,h:2,c:"#1E3A8A"},{x:44,y:16,w:5,h:11,c:"#065F46"},{x:44,y:16,w:5,h:2,c:"#064E3B"},{x:50,y:17,w:3,h:10,c:"#831843"},{x:50,y:17,w:3,h:2,c:"#6B21A8"},{x:54,y:16,w:5,h:11,c:"#374151"},{x:54,y:16,w:5,h:2,c:"#1F2937"},{x:5,y:30,w:4,h:11,c:"#0E7490"},{x:5,y:30,w:4,h:2,c:"#0C6B7E"},{x:10,y:31,w:3,h:10,c:"#B45309"},{x:10,y:31,w:3,h:2,c:"#92400E"},{x:14,y:30,w:5,h:11,c:"#6D28D9"},{x:14,y:30,w:5,h:2,c:"#5B21B6"},{x:20,y:30,w:7,h:8,c:"#1e293b"},{x:22,y:32,w:3,h:3,c:"#3b82f6",a:.9},{x:22,y:32,w:1,h:3,c:"#60a5fa",a:.6},{x:28,y:31,w:4,h:10,c:"#DC2626"},{x:28,y:31,w:4,h:2,c:"#B91C1C"},{x:33,y:30,w:3,h:11,c:"#065F46"},{x:33,y:30,w:3,h:2,c:"#064E3B"},{x:37,y:31,w:4,h:10,c:"#1D4ED8"},{x:37,y:31,w:4,h:2,c:"#1E40AF"},{x:42,y:35,w:6,h:6,c:"#92400E"},{x:43,y:30,w:4,h:6,c:"#16a34a",a:.8},{x:43,y:29,w:2,h:3,c:"#15803d",a:.7},{x:45,y:28,w:2,h:4,c:"#16a34a",a:.6},{x:49,y:30,w:3,h:11,c:"#7C3AED"},{x:49,y:30,w:3,h:2,c:"#6D28D9"},{x:53,y:31,w:5,h:10,c:"#B45309"},{x:53,y:31,w:5,h:2,c:"#92400E"},{x:2,y:46,w:60,h:2,c:"#1a0a03"},{x:2,y:0,w:60,h:2,c:"#4a2510"},{x:2,y:0,w:2,h:48,c:"#2d1508"},{x:60,y:0,w:2,h:48,c:"#2d1508"}]},iD={canvasWidth:96,canvasHeight:120,scale:2,pixels:[{x:2,y:0,w:44,h:60,c:"#546E7A"},{x:2,y:0,w:44,h:3,c:"#78909C"},{x:2,y:57,w:44,h:3,c:"#37474F"},{x:2,y:0,w:2,h:60,c:"#455A64"},{x:44,y:0,w:2,h:60,c:"#37474F"},{x:5,y:4,w:38,h:3,c:"#FFD54F",a:.5},{x:6,y:1,w:2,h:4,c:"#FFFDE7"},{x:10,y:0,w:2,h:5,c:"#FFF9C4"},{x:14,y:1,w:2,h:3,c:"#FFFDE7"},{x:18,y:0,w:2,h:4,c:"#FFF8E1"},{x:5,y:5,w:38,h:16,c:"#607D8B"},{x:5,y:5,w:38,h:2,c:"#78909C"},{x:15,y:12,w:18,h:4,c:"#37474F"},{x:22,y:11,w:4,h:6,c:"#455A64"},{x:23,y:13,w:2,h:2,c:"#B0BEC5"},{x:7,y:14,w:8,h:5,c:"#B0BEC5"},{x:8,y:15,w:6,h:1,c:"#607D8B"},{x:8,y:17,w:5,h:1,c:"#607D8B"},{x:5,y:23,w:38,h:16,c:"#607D8B"},{x:5,y:23,w:38,h:2,c:"#78909C"},{x:15,y:30,w:18,h:4,c:"#37474F"},{x:22,y:29,w:4,h:6,c:"#455A64"},{x:23,y:31,w:2,h:2,c:"#B0BEC5"},{x:7,y:32,w:8,h:5,c:"#B0BEC5"},{x:8,y:33,w:6,h:1,c:"#607D8B"},{x:8,y:35,w:4,h:1,c:"#607D8B"},{x:5,y:41,w:38,h:16,c:"#607D8B"},{x:5,y:41,w:38,h:2,c:"#78909C"},{x:15,y:48,w:18,h:4,c:"#37474F"},{x:22,y:47,w:4,h:6,c:"#455A64"},{x:23,y:49,w:2,h:2,c:"#B0BEC5"},{x:7,y:50,w:8,h:5,c:"#B0BEC5"},{x:8,y:51,w:6,h:1,c:"#607D8B"},{x:8,y:53,w:3,h:1,c:"#607D8B"}]};Hf("meeting",tD);Hf("bulletin",nD);Hf("decision",iD);Hf("knowledge",rD);const gp=16,yp=24,sD=60,aD={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function F5(e,t){if(!e)return e;let n=e;if(t!=null&&t.hairStyle){const i=mx(t.hairStyle);i&&(n=w8(n,i.layer))}if(t!=null&&t.outfitStyle){const i=px(t.outfitStyle);i&&(n=fx(n,"torso",i.layer,1))}if(t!=null&&t.accessory&&t.accessory!=="none"){const i=T5(t.accessory);i&&(n=fx(n,"accessory",i.layer))}return n}function Aa({roleId:e,className:t,appearance:n,scale:i}){const a=S.useRef(null),o=S.useRef(0),c=S.useRef(0),d=S.useRef(n);d.current=n;const m=i??4,f=gp*m,x=yp*m,p=S.useMemo(()=>{const y=hx(`mini:${e}`)??hx("mini:default");return F5(y,n)},[e,n==null?void 0:n.hairStyle,n==null?void 0:n.outfitStyle,n==null?void 0:n.accessory]);return S.useEffect(()=>{const y=a.current;if(!y)return;const g=y.getContext("2d");if(!g)return;const w=aD[e]??0,k=()=>{c.current++;const j=d.current;if(!j||!p){o.current=requestAnimationFrame(k);return}const N=(c.current+w)%sD<30?1:0;g.clearRect(0,0,gp,yp),g.save(),g.translate(2,1),S8(g,p,N,j,1),g.restore(),o.current=requestAnimationFrame(k)};return o.current=requestAnimationFrame(k),()=>cancelAnimationFrame(o.current)},[e,p]),l.jsx("canvas",{ref:a,width:gp,height:yp,className:t,style:{imageRendering:"pixelated",display:"block",width:f,height:x}})}const lD="https://api.tycono.ai",x0=lD;async function tl(e){const t=await fetch(`${x0}${e}`);if(!t.ok)throw new Error(`Cloud API error: ${t.status}`);return t.json()}async function qi(e,t){const n=await fetch(`${x0}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Cloud API error: ${n.status}`);return n.json()}const ur={health:()=>tl("/api/health"),getMyName:e=>tl(`/api/auth/my-name?instance_id=${encodeURIComponent(e)}`),getCharacters:e=>{const t=new URLSearchParams;e!=null&&e.sort&&t.set("sort",e.sort),e!=null&&e.instanceId&&t.set("instance_id",e.instanceId);const n=t.toString();return tl(`/api/store/characters${n?`?${n}`:""}`)},getCharacter:e=>tl(`/api/store/characters/${e}`),getCharacterVersion:e=>tl(`/api/store/characters/${e}/version`),voteCharacter:(e,t,n)=>qi(`/api/store/characters/${e}/vote`,{instanceId:t,vote:n}),trackInstall:e=>qi(`/api/store/characters/${e}/install`,{}),syncCheck:e=>qi("/api/sync/check",{roles:e}),syncPull:e=>qi("/api/sync/pull",{sourceId:e}),publishCharacter:e=>qi("/api/store/publish",e),deleteCharacter:(e,t)=>{const n=t?`?publisher_id=${encodeURIComponent(t)}`:"";return fetch(`${x0}/api/store/characters/${e}${n}`,{method:"DELETE"}).then(i=>i.json())},getCloudPresets:e=>{const t=new URLSearchParams;e!=null&&e.sort&&t.set("sort",e.sort),e!=null&&e.instanceId&&t.set("instance_id",e.instanceId);const n=t.toString();return tl(`/api/presets${n?`?${n}`:""}`)},getCloudPreset:e=>tl(`/api/presets/${e}`),votePreset:(e,t,n)=>qi(`/api/presets/${e}/vote`,{instanceId:t,vote:n}),trackPresetInstall:e=>qi(`/api/presets/${e}/install`,{}),publishPreset:e=>qi("/api/presets/publish",e),uploadTelemetry:e=>qi("/api/telemetry",e),syncStats:e=>qi("/api/stats/sync",e)},oD={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},bp={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},cD={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},uD=500,xv=360,gv=700,dD=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function yv({role:e,allRoles:t,recentActivity:n,onClose:i,onFireRole:a,terminalWidth:o=0,activeSessionId:c,activeTask:d,isWorking:m,startedAt:f,onAbortSession:x,sessions:p,streamingSessionId:y,onCreateSessionSilent:g,onSendMessage:w,onFocusTerminal:k,onCustomize:j,onUpdateRole:C,appearance:N,relationships:E,roleLevel:A,onMaximize:z}){var Xe,et;const[D,F]=S.useState(uD),[q,V]=S.useState(!1),L=S.useRef(0),_=S.useRef(0),[B,X]=S.useState(!1),[R,H]=S.useState(!1),[$,G]=S.useState(!1),[Q,K]=S.useState(!1),[M,U]=S.useState("talk"),[P,O]=S.useState(!1),[Z,ee]=S.useState(""),[J,se]=S.useState(!1),le=S.useRef(null),[ye,De]=S.useState(!1),[Ee,Re]=S.useState(""),[me,Fe]=S.useState(!1),{events:Je,status:Pe}=b2(c??null),[it,ht]=S.useState(0);S.useEffect(()=>{if(!m||!f){ht(0);return}const ze=new Date(f).getTime(),Be=()=>ht(Math.floor((Date.now()-ze)/1e3));Be();const _t=setInterval(Be,1e3);return()=>clearInterval(_t)},[m,f]);const Ye=o>0,nt=Ye?o:0,ut=Ye?Math.max(xv,window.innerWidth-o-100):gv,kt=Math.min(D,ut),mt=S.useCallback(ze=>{ze.preventDefault(),L.current=ze.clientX,_.current=kt,V(!0);const Be=z,_t=()=>{V(!1),document.removeEventListener("mousemove",en),document.removeEventListener("mouseup",_t)},en=Tt=>{const Pt=L.current-Tt.clientX,hn=_.current+Pt;if(hn>=window.innerWidth*.6&&Be){_t(),Be();return}const Zt=Math.min(gv,Math.max(xv,hn));F(Zt)};document.addEventListener("mousemove",en),document.addEventListener("mouseup",_t)},[kt,z]),ve=S.useRef(null),be=e?p.find(ze=>ze.roleId===e.id):null,te=ze=>{if(!e)return;const Be=m?"talk":M;be?(w(be.id,ze,Be),k(e.id)):(ve.current={content:ze,mode:Be},g(e.id))};S.useEffect(()=>{if(be&&ve.current){const{content:ze,mode:Be}=ve.current;ve.current=null,w(be.id,ze,Be),e&&k(e.id)}},[be==null?void 0:be.id]);const oe=(()=>{if(!Je.length)return null;const ze=[];let Be=0,_t=0,en=0;for(const Tt of Je)if(Tt.type==="thinking")Be++;else if(Tt.type==="text")_t++;else if(Tt.type==="tool:start"){const Pt=String(Tt.data.name??"");ze.includes(Pt)||ze.push(Pt)}else Tt.type==="dispatch:start"&&en++;return{tools:ze,thinkCount:Be,textCount:_t,dispatchCount:en,total:Je.length}})(),Ce=d||(()=>{if(!be)return null;const ze=be.messages;for(let Be=ze.length-1;Be>=0;Be--)if(ze[Be].from==="ceo")return ze[Be].content;return null})(),pe=(()=>{if(!be)return null;const ze=be.messages;for(let Be=ze.length-1;Be>=0;Be--)if(ze[Be].from==="role"&&ze[Be].content)return ze[Be].content;return null})();if(!e)return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:nt},onClick:i}),l.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px]",style:{right:nt,width:kt,background:"var(--terminal-bg)",borderLeftColor:"var(--pixel-border)"},children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading role..."})})]});const Se=bp[e.id]??"#666",Me=oD[e.id]??"👤",Ge=t.filter(ze=>ze.reportsTo===e.id),Ie=be&&y===be.id,qe=e.name||cD[e.id]||e.id;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:nt},onClick:i}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${q?"resizing":""}`,style:{borderLeftColor:Se,right:nt,width:kt,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${q?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:mt}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Se}ee, ${Se}99)`},children:[l.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:"repeating-linear-gradient(45deg, transparent, transparent 8px, white 8px, white 9px)"}}),l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1.5 z-10",children:[j&&l.jsx("button",{onClick:()=>j(e.id),className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-sm hover:bg-black/30 cursor-pointer backdrop-blur-sm",title:"Customize",children:"🎨"}),z&&l.jsx("button",{onClick:z,className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-sm hover:bg-black/30 cursor-pointer backdrop-blur-sm",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-black/20 text-white flex items-center justify-center text-lg hover:bg-black/30 cursor-pointer backdrop-blur-sm",children:"×"})]}),l.jsxs("div",{className:"relative flex items-end gap-4 px-4 pt-4 pb-3",children:[l.jsx("div",{className:"shrink-0 relative",style:{marginBottom:-2},children:l.jsx("div",{className:"rounded-lg p-1",style:{background:"rgba(0,0,0,0.2)"},children:l.jsx(Aa,{roleId:e.id,appearance:N,scale:8})})}),l.jsxs("div",{className:"flex-1 min-w-0 text-white pb-1",children:[l.jsxs("div",{className:"text-lg font-bold flex items-center gap-2",style:{fontFamily:"var(--pixel-font)"},children:[Me," ",e.id.toUpperCase(),m&&l.jsx("span",{className:"text-[9px] font-semibold px-2 py-0.5 rounded-full animate-pulse",style:{background:"rgba(251,191,36,0.25)",color:"#fde68a"},children:"WORKING"})]}),P?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async ze=>{ze.preventDefault();const Be=Z.trim();if(!Be||Be===qe||!C){O(!1);return}se(!0);try{await C(e.id,{name:Be})}catch{}se(!1),O(!1)},children:[l.jsx("input",{ref:le,value:Z,onChange:ze=>ee(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&O(!1)},disabled:J,autoFocus:!0,className:"bg-white/20 text-white text-xs rounded px-1.5 py-0.5 outline-none focus:bg-white/30 w-full",style:{fontFamily:"inherit"}}),l.jsx("button",{type:"submit",disabled:J,className:"text-white/80 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✓"}),l.jsx("button",{type:"button",onClick:()=>O(!1),className:"text-white/60 hover:text-white text-[10px] cursor-pointer shrink-0",children:"✕"})]}):l.jsxs("div",{className:"text-xs opacity-75 mt-0.5 group/name flex items-center gap-1 cursor-pointer hover:opacity-100 transition-opacity",onClick:()=>{C&&(ee(qe),O(!0))},title:C?"Click to edit name":void 0,children:[qe,C&&l.jsx("span",{className:"opacity-0 group-hover/name:opacity-60 text-[10px]",children:"✎"})]})]})]}),l.jsxs("div",{className:"relative flex items-center gap-3 px-4 py-2 text-[10px] font-bold text-white/80",style:{background:"rgba(0,0,0,0.2)",fontFamily:"var(--pixel-font)"},children:[l.jsxs("span",{children:["Lv.",A??1]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:m?"var(--idle-amber)":"var(--active-green)"}}),m?"Working":"Idle"]}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsx("span",{children:e.level}),e.reportsTo&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"|"}),l.jsxs("span",{className:"opacity-60",children:["→"," ",e.reportsTo]})]})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[m&&l.jsxs("div",{className:"px-4 py-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--idle-amber)"}}),l.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--idle-amber)"},children:["Working",it>0?` · ${dD(it)}`:""]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"}),c&&x&&l.jsx("button",{onClick:()=>x(c),className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold transition-colors",style:{background:"rgba(239,68,68,0.15)",color:"#ef4444"},children:"Stop"})]})]}),Ce&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:Ce})]}),m&&c&&oe&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Activity"}),l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"View details ↗"})]}),l.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[oe.thinkCount>0&&l.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(168,85,247,0.15)",color:"#c084fc"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:"#a855f7"}}),"thinking ×",oe.thinkCount]}),oe.tools.map(ze=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(59,130,246,0.15)",color:"#60a5fa"},children:ze},ze)),oe.dispatchCount>0&&l.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(249,115,22,0.15)",color:"#fb923c"},children:["dispatch ×",oe.dispatchCount]}),oe.textCount>0&&l.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{background:"rgba(34,197,94,0.15)",color:"#4ade80"},children:["output ×",oe.textCount]}),(Pe==="streaming"||Pe==="connecting")&&l.jsx("span",{className:"inline-block w-1.5 h-3 animate-pulse rounded-sm",style:{background:"var(--active-green)"}})]}),l.jsxs("div",{className:"text-[10px] mt-1",style:{color:"var(--terminal-text-muted)"},children:[oe.total," events"]})]}),m&&pe&&l.jsxs("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)"},children:"Last Message"}),l.jsx("button",{onClick:()=>k(e.id),className:"text-[10px] cursor-pointer hover:underline",style:{color:"var(--terminal-text-muted)"},children:"Open chat ↗"})]}),l.jsxs("div",{className:"rounded-lg p-2.5 text-xs leading-relaxed line-clamp-3 overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[pe.slice(0,200),pe.length>200&&"..."]})]}),m&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(bv,{onSend:te,disabled:!!Ie,placeholder:"Ask something...",color:Se})}),!m&&l.jsxs("div",{className:"px-4 pt-4 pb-2",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-secondary)"},children:"Latest"}),l.jsx(hD,{icon:Me,roleId:e.id,roleName:qe,color:Se,text:n})]}),!m&&l.jsx("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[pe&&l.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>k(e.id),children:[l.jsxs("div",{className:"flex items-center justify-between mb-1",children:[l.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"Last response"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:"View ↗"})]}),l.jsxs("div",{className:"text-xs leading-relaxed line-clamp-2 overflow-hidden",style:{color:"var(--terminal-text-secondary)"},children:[pe.slice(0,150),pe.length>150&&"..."]})]}),l.jsx("div",{className:"p-2",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex rounded-lg overflow-hidden shrink-0",style:{border:"1px solid var(--pixel-border)"},children:[l.jsx("button",{onClick:()=>U("talk"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:M==="talk"?"var(--accent)":"transparent",color:M==="talk"?"#fff":"var(--terminal-text-secondary)"},children:"Talk"}),l.jsx("button",{onClick:()=>U("do"),className:"px-2 py-1 text-[10px] font-semibold cursor-pointer transition-colors",style:{background:M==="do"?"var(--idle-amber)":"transparent",color:M==="do"?"#fff":"var(--terminal-text-secondary)"},children:"Do"})]}),l.jsx(bv,{onSend:te,disabled:!!Ie,placeholder:M==="talk"?"Ask something...":"Give a directive...",color:Se})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(zd,{title:`Profile${e.persona?"":" (empty)"}`,open:B,onToggle:()=>X(ze=>!ze),children:[ye?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:Ee,onChange:ze=>Re(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&De(!1)},disabled:me,autoFocus:!0,rows:5,placeholder:"Describe this role's personality and communication style. How do they talk? Are they sarcastic? Cheerful? Blunt?",className:"w-full text-xs leading-relaxed rounded-lg p-3 outline-none resize-y",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--active-green)",color:"var(--terminal-text)",fontFamily:"inherit",minHeight:"80px"}}),l.jsxs("div",{className:"flex gap-1.5 justify-end",children:[l.jsx("button",{onClick:()=>De(!1),disabled:me,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Cancel"}),l.jsx("button",{onClick:async()=>{if(C){Fe(!0);try{await C(e.id,{persona:Ee.trim()})}catch{}Fe(!1),De(!1)}},disabled:me,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:me?"Saving...":"Save"})]})]}):l.jsxs("div",{className:"text-xs leading-relaxed rounded-lg p-3 group/persona cursor-pointer hover:opacity-90 transition-opacity",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},onClick:()=>{C&&(Re(e.persona||""),De(!0))},title:C?"Click to edit persona":void 0,children:[e.persona||l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:"No persona set. Click to add one."}),C&&l.jsx("span",{className:"opacity-0 group-hover/persona:opacity-60 text-[10px] ml-1",children:"✎"})]}),l.jsxs("div",{className:"space-y-0 mt-2",children:[l.jsx(vp,{label:"Level",value:e.level}),l.jsx(vp,{label:"Reports to",value:e.reportsTo}),l.jsx(vp,{label:"Status",value:e.status})]}),Ge.length>0&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"text-[11px] font-semibold mb-1",style:{color:"var(--terminal-text-muted)"},children:"Direct Reports"}),l.jsx("div",{className:"space-y-1",children:Ge.map(ze=>l.jsxs("div",{className:"flex items-center gap-2 p-1.5 rounded-lg",style:{background:"var(--hud-bg-alt)"},children:[l.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center text-white text-[10px] font-bold",style:{background:bp[ze.id]??"#666"},children:ze.id.slice(0,2).toUpperCase()}),l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text)"},children:ze.name})]},ze.id))})]})]}),e.authority&&l.jsxs(zd,{title:"Authority",open:R,onToggle:()=>H(ze=>!ze),children:[((Xe=e.authority.autonomous)==null?void 0:Xe.length)>0&&l.jsxs("div",{className:"mb-2",children:[l.jsx("div",{className:"text-xs font-semibold mb-1",style:{color:"var(--active-green)"},children:"Autonomous"}),e.authority.autonomous.map((ze,Be)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",ze]},Be))]}),((et=e.authority.needsApproval)==null?void 0:et.length)>0&&l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-semibold mb-1",style:{color:"var(--idle-amber)"},children:"Needs Approval"}),e.authority.needsApproval.map((ze,Be)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",ze]},Be))]})]}),e&&E&&(()=>{const ze=E.filter(Be=>Be.roleA===e.id||Be.roleB===e.id).filter(Be=>Be.familiarity>0).sort((Be,_t)=>_t.familiarity-Be.familiarity);return ze.length===0?null:l.jsx(zd,{title:`Relationships (${ze.length})`,open:$,onToggle:()=>G(Be=>!Be),children:l.jsx("div",{className:"space-y-1.5",children:ze.map((Be,_t)=>{const en=Be.roleA===e.id?Be.roleB:Be.roleA,Tt=t.find(Zt=>Zt.id===en),Pt=Be.familiarity>=80?"Best Partner":Be.familiarity>=50?"Friend":Be.familiarity>=20?"Colleague":"Acquaintance",hn=Be.familiarity>=80?"#4CAF50":Be.familiarity>=50?"#2196F3":Be.familiarity>=20?"#FF9800":"#9E9E9E";return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs w-20 truncate",style:{color:bp[en]??"var(--terminal-text-secondary)"},children:(Tt==null?void 0:Tt.name)??en}),l.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-white/10",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Be.familiarity}%`,background:hn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:Pt})]},_t)})})})})(),e.journal&&l.jsx(zd,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:Q,onToggle:()=>K(ze=>!ze),children:l.jsxs("div",{className:"text-xs leading-relaxed rounded-lg p-3 max-h-[300px] overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:[l.jsx(jo,{content:e.journal.slice(0,3e3)}),e.journal.length>3e3&&l.jsx("div",{className:"italic mt-2",style:{color:"var(--terminal-text-muted)"},children:"... (truncated)"})]})})]}),l.jsx(fD,{role:e,appearance:N}),a&&l.jsx("div",{className:"px-4 pb-4 mt-auto shrink-0",children:l.jsx("button",{onClick:()=>{a(e.id,e.name),i()},className:"w-full p-2 text-center text-xs font-medium border-2 border-dashed rounded-lg cursor-pointer transition-colors",style:{borderColor:"rgba(239,68,68,0.3)",color:"rgba(239,68,68,0.5)"},children:"Fire Role"})})]})]})]})}function fD({role:e,appearance:t}){const[n,i]=S.useState("idle"),[a,o]=S.useState(""),[c,d]=S.useState(!1),[m,f]=S.useState(null),[x,p]=S.useState(!1),[y,g]=S.useState(!1),[w,k]=S.useState(null);S.useEffect(()=>{ur.getCharacterVersion(e.id).then(N=>f((N==null?void 0:N.version)??null)).catch(()=>f(null)),ke.getPreferences().then(N=>k(N.instanceId??null)).catch(()=>{})},[e.id]);const j=async()=>{var N,E;if(!c){d(!0);return}i("publishing");try{let A=null;try{A=await ke.exportSkills(e.id)}catch{}const z={roleId:e.id,persona:e.persona??"",authority:e.authority??{autonomous:[],needsApproval:[]},level:e.level,tagline:((N=(e.persona??"").split(/[.\n]/)[0])==null?void 0:N.trim().slice(0,80))||e.name,chatStyle:"Professional and focused",skills:A??[],resume:{summary:((E=e.persona)==null?void 0:E.split(`
82
+ `)[0])??"",strengths:[],specialties:[],experience:""},author:{id:"tycono",name:"Tycono"},tags:[e.level,e.id],price:"free",installs:0,rating:0,featured:!1,randomActive:!0,randomPersonality:""};t&&(z.appearance=t);let D="1.0.0";try{const F=await ur.getCharacterVersion(e.id);if(F!=null&&F.version){const q=F.version.split(".").map(Number);q[2]=(q[2]??0)+1,D=q.join(".")}}catch{}await ur.publishCharacter({id:e.id,name:e.name||e.id,version:D,data:z,publisherId:w??void 0}),i("done"),o(`Published v${D}`),f(D),d(!1)}catch(A){i("error"),o(A instanceof Error?A.message:"Failed"),d(!1)}},C=async()=>{g(!0);try{await ur.deleteCharacter(e.id,w??void 0),f(null),i("idle"),o(""),p(!1)}catch{o("Delete failed")}g(!1)};return l.jsx("div",{className:"px-4 pb-2 shrink-0",children:l.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:l.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between gap-2",style:{background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("a",{href:"https://tycono.ai/store.html",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-bold uppercase tracking-wider shrink-0 hover:underline cursor-pointer",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)",textDecoration:"none"},onClick:N=>N.stopPropagation(),children:"Job Board ↗"}),m&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded shrink-0",style:{background:"rgba(34,197,94,0.1)",color:"rgba(34,197,94,0.6)",border:"1px solid rgba(34,197,94,0.2)"},children:["v",m]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n==="done"?l.jsx(l.Fragment,{children:l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--active-green)"},children:a})}):n==="error"?l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#ef4444"},children:a}):l.jsx("button",{onClick:j,disabled:n==="publishing",className:"text-[10px] px-2.5 py-1 rounded font-semibold cursor-pointer transition-colors disabled:opacity-50",style:{background:c?"rgba(59,130,246,0.3)":"rgba(59,130,246,0.15)",color:"#60a5fa",border:c?"1px solid rgba(59,130,246,0.5)":"1px solid transparent"},children:n==="publishing"?"Publishing...":c?"Confirm?":m?"Update":"Publish"}),m&&!x&&l.jsx("button",{onClick:()=>p(!0),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer transition-colors",style:{color:"rgba(239,68,68,0.4)"},title:"Remove from store",children:"✕"}),x&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:C,disabled:y,className:"text-[10px] px-2 py-1 rounded font-semibold cursor-pointer disabled:opacity-50",style:{background:"rgba(239,68,68,0.2)",color:"#ef4444",border:"1px solid rgba(239,68,68,0.3)"},children:y?"...":"Delete"}),l.jsx("button",{onClick:()=>p(!1),className:"text-[10px] px-1.5 py-1 rounded cursor-pointer",style:{color:"var(--terminal-text-muted)"},children:"No"})]})]})]})})})}function hD({icon:e,roleId:t,roleName:n,color:i,text:a}){const o=!!a;return l.jsx("div",{className:"relative",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:"shrink-0",children:[l.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center text-xl shadow-sm",style:{background:`${i}18`,border:`2px solid ${i}44`},children:e}),l.jsx("div",{className:"text-[9px] font-bold text-center mt-0.5 uppercase tracking-wide",style:{color:i},children:t})]}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"absolute top-3 -left-2 w-0 h-0",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:`8px solid ${i}12`}}),l.jsxs("div",{className:"rounded-xl rounded-tl-sm p-4 border",style:{background:`${i}08`,borderColor:`${i}22`},children:[l.jsx("div",{className:"text-[10px] font-semibold mb-1.5 uppercase tracking-wider",style:{color:i},children:n}),o?l.jsx("div",{className:"text-sm leading-relaxed",style:{color:"var(--terminal-text)"},children:l.jsx(jo,{content:a})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function zd({title:e,open:t,onToggle:n,children:i}){return l.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsxs("button",{onClick:n,className:"w-full px-3 py-2.5 flex items-center justify-between cursor-pointer transition-colors group",style:{background:"var(--hud-bg-alt)"},children:[l.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:e}),l.jsx("span",{className:"text-[10px] transition-transform",style:{color:"var(--terminal-text-muted)",transform:t?"rotate(0deg)":"rotate(-90deg)"},children:"▼"})]}),t&&l.jsx("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:i})]})}function bv({onSend:e,disabled:t,placeholder:n,color:i}){const[a,o]=S.useState(""),c=S.useRef(!1),d=()=>{const m=a.trim();!m||t||(e(m),o(""))};return l.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[l.jsx("input",{type:"text",value:a,onChange:m=>o(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!c.current&&(m.preventDefault(),d())},onCompositionStart:()=>{c.current=!0},onCompositionEnd:()=>{c.current=!1},placeholder:t?"Waiting...":n,disabled:t,className:"flex-1 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none disabled:opacity-40",style:{background:"var(--hud-bg)",border:"1px solid var(--pixel-border)",color:"var(--terminal-text)"}}),l.jsx("button",{onClick:d,disabled:t||!a.trim(),className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 cursor-pointer text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",style:{background:t||!a.trim()?"#666":i},children:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M22 2L11 13"}),l.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})}function vp({label:e,value:t}){return l.jsxs("div",{className:"flex justify-between py-1.5 text-xs",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:e}),l.jsx("span",{className:"font-semibold",style:{color:"var(--terminal-text)"},children:t})]})}function mD(e,t){var n,i=1;e==null&&(e=0),t==null&&(t=0);function a(){var o,c=n.length,d,m=0,f=0;for(o=0;o<c;++o)d=n[o],m+=d.x,f+=d.y;for(m=(m/c-e)*i,f=(f/c-t)*i,o=0;o<c;++o)d=n[o],d.x-=m,d.y-=f}return a.initialize=function(o){n=o},a.x=function(o){return arguments.length?(e=+o,a):e},a.y=function(o){return arguments.length?(t=+o,a):t},a.strength=function(o){return arguments.length?(i=+o,a):i},a}function pD(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return R5(this.cover(t,n),t,n,e)}function R5(e,t,n,i){if(isNaN(t)||isNaN(n))return e;var a,o=e._root,c={data:i},d=e._x0,m=e._y0,f=e._x1,x=e._y1,p,y,g,w,k,j,C,N;if(!o)return e._root=c,e;for(;o.length;)if((k=t>=(p=(d+f)/2))?d=p:f=p,(j=n>=(y=(m+x)/2))?m=y:x=y,a=o,!(o=o[C=j<<1|k]))return a[C]=c,e;if(g=+e._x.call(null,o.data),w=+e._y.call(null,o.data),t===g&&n===w)return c.next=o,a?a[C]=c:e._root=c,e;do a=a?a[C]=new Array(4):e._root=new Array(4),(k=t>=(p=(d+f)/2))?d=p:f=p,(j=n>=(y=(m+x)/2))?m=y:x=y;while((C=j<<1|k)===(N=(w>=y)<<1|g>=p));return a[N]=o,a[C]=c,e}function xD(e){var t,n,i=e.length,a,o,c=new Array(i),d=new Array(i),m=1/0,f=1/0,x=-1/0,p=-1/0;for(n=0;n<i;++n)isNaN(a=+this._x.call(null,t=e[n]))||isNaN(o=+this._y.call(null,t))||(c[n]=a,d[n]=o,a<m&&(m=a),a>x&&(x=a),o<f&&(f=o),o>p&&(p=o));if(m>x||f>p)return this;for(this.cover(m,f).cover(x,p),n=0;n<i;++n)R5(this,c[n],d[n],e[n]);return this}function gD(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,i=this._y0,a=this._x1,o=this._y1;if(isNaN(n))a=(n=Math.floor(e))+1,o=(i=Math.floor(t))+1;else{for(var c=a-n||1,d=this._root,m,f;n>e||e>=a||i>t||t>=o;)switch(f=(t<i)<<1|e<n,m=new Array(4),m[f]=d,d=m,c*=2,f){case 0:a=n+c,o=i+c;break;case 1:n=a-c,o=i+c;break;case 2:a=n+c,i=o-c;break;case 3:n=a-c,i=o-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=i,this._x1=a,this._y1=o,this}function yD(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function bD(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function kr(e,t,n,i,a){this.node=e,this.x0=t,this.y0=n,this.x1=i,this.y1=a}function vD(e,t,n){var i,a=this._x0,o=this._y0,c,d,m,f,x=this._x1,p=this._y1,y=[],g=this._root,w,k;for(g&&y.push(new kr(g,a,o,x,p)),n==null?n=1/0:(a=e-n,o=t-n,x=e+n,p=t+n,n*=n);w=y.pop();)if(!(!(g=w.node)||(c=w.x0)>x||(d=w.y0)>p||(m=w.x1)<a||(f=w.y1)<o))if(g.length){var j=(c+m)/2,C=(d+f)/2;y.push(new kr(g[3],j,C,m,f),new kr(g[2],c,C,j,f),new kr(g[1],j,d,m,C),new kr(g[0],c,d,j,C)),(k=(t>=C)<<1|e>=j)&&(w=y[y.length-1],y[y.length-1]=y[y.length-1-k],y[y.length-1-k]=w)}else{var N=e-+this._x.call(null,g.data),E=t-+this._y.call(null,g.data),A=N*N+E*E;if(A<n){var z=Math.sqrt(n=A);a=e-z,o=t-z,x=e+z,p=t+z,i=g.data}}return i}function wD(e){if(isNaN(x=+this._x.call(null,e))||isNaN(p=+this._y.call(null,e)))return this;var t,n=this._root,i,a,o,c=this._x0,d=this._y0,m=this._x1,f=this._y1,x,p,y,g,w,k,j,C;if(!n)return this;if(n.length)for(;;){if((w=x>=(y=(c+m)/2))?c=y:m=y,(k=p>=(g=(d+f)/2))?d=g:f=g,t=n,!(n=n[j=k<<1|w]))return this;if(!n.length)break;(t[j+1&3]||t[j+2&3]||t[j+3&3])&&(i=t,C=j)}for(;n.data!==e;)if(a=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,a?(o?a.next=o:delete a.next,this):t?(o?t[j]=o:delete t[j],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(i?i[C]=n:this._root=n),this):(this._root=o,this)}function kD(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function SD(){return this._root}function jD(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function CD(e){var t=[],n,i=this._root,a,o,c,d,m;for(i&&t.push(new kr(i,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(i=n.node,o=n.x0,c=n.y0,d=n.x1,m=n.y1)&&i.length){var f=(o+d)/2,x=(c+m)/2;(a=i[3])&&t.push(new kr(a,f,x,d,m)),(a=i[2])&&t.push(new kr(a,o,x,f,m)),(a=i[1])&&t.push(new kr(a,f,c,d,x)),(a=i[0])&&t.push(new kr(a,o,c,f,x))}return this}function ND(e){var t=[],n=[],i;for(this._root&&t.push(new kr(this._root,this._x0,this._y0,this._x1,this._y1));i=t.pop();){var a=i.node;if(a.length){var o,c=i.x0,d=i.y0,m=i.x1,f=i.y1,x=(c+m)/2,p=(d+f)/2;(o=a[0])&&t.push(new kr(o,c,d,x,p)),(o=a[1])&&t.push(new kr(o,x,d,m,p)),(o=a[2])&&t.push(new kr(o,c,p,x,f)),(o=a[3])&&t.push(new kr(o,x,p,m,f))}n.push(i)}for(;i=n.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function ED(e){return e[0]}function AD(e){return arguments.length?(this._x=e,this):this._x}function DD(e){return e[1]}function TD(e){return arguments.length?(this._y=e,this):this._y}function g0(e,t,n){var i=new y0(t??ED,n??DD,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function y0(e,t,n,i,a,o){this._x=e,this._y=t,this._x0=n,this._y0=i,this._x1=a,this._y1=o,this._root=void 0}function vv(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Sr=g0.prototype=y0.prototype;Sr.copy=function(){var e=new y0(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,i;if(!t)return e;if(!t.length)return e._root=vv(t),e;for(n=[{source:t,target:e._root=new Array(4)}];t=n.pop();)for(var a=0;a<4;++a)(i=t.source[a])&&(i.length?n.push({source:i,target:t.target[a]=new Array(4)}):t.target[a]=vv(i));return e};Sr.add=pD;Sr.addAll=xD;Sr.cover=gD;Sr.data=yD;Sr.extent=bD;Sr.find=vD;Sr.remove=wD;Sr.removeAll=kD;Sr.root=SD;Sr.size=jD;Sr.visit=CD;Sr.visitAfter=ND;Sr.x=AD;Sr.y=TD;function cl(e){return function(){return e}}function Ca(e){return(e()-.5)*1e-6}function _D(e){return e.x+e.vx}function MD(e){return e.y+e.vy}function FD(e){var t,n,i,a=1,o=1;typeof e!="function"&&(e=cl(e==null?1:+e));function c(){for(var f,x=t.length,p,y,g,w,k,j,C=0;C<o;++C)for(p=g0(t,_D,MD).visitAfter(d),f=0;f<x;++f)y=t[f],k=n[y.index],j=k*k,g=y.x+y.vx,w=y.y+y.vy,p.visit(N);function N(E,A,z,D,F){var q=E.data,V=E.r,L=k+V;if(q){if(q.index>y.index){var _=g-q.x-q.vx,B=w-q.y-q.vy,X=_*_+B*B;X<L*L&&(_===0&&(_=Ca(i),X+=_*_),B===0&&(B=Ca(i),X+=B*B),X=(L-(X=Math.sqrt(X)))/X*a,y.vx+=(_*=X)*(L=(V*=V)/(j+V)),y.vy+=(B*=X)*L,q.vx-=_*(L=1-L),q.vy-=B*L)}return}return A>g+L||D<g-L||z>w+L||F<w-L}}function d(f){if(f.data)return f.r=n[f.data.index];for(var x=f.r=0;x<4;++x)f[x]&&f[x].r>f.r&&(f.r=f[x].r)}function m(){if(t){var f,x=t.length,p;for(n=new Array(x),f=0;f<x;++f)p=t[f],n[p.index]=+e(p,f,t)}}return c.initialize=function(f,x){t=f,i=x,m()},c.iterations=function(f){return arguments.length?(o=+f,c):o},c.strength=function(f){return arguments.length?(a=+f,c):a},c.radius=function(f){return arguments.length?(e=typeof f=="function"?f:cl(+f),m(),c):e},c}function RD(e){return e.index}function wv(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function zD(e){var t=RD,n=p,i,a=cl(30),o,c,d,m,f,x=1;e==null&&(e=[]);function p(j){return 1/Math.min(d[j.source.index],d[j.target.index])}function y(j){for(var C=0,N=e.length;C<x;++C)for(var E=0,A,z,D,F,q,V,L;E<N;++E)A=e[E],z=A.source,D=A.target,F=D.x+D.vx-z.x-z.vx||Ca(f),q=D.y+D.vy-z.y-z.vy||Ca(f),V=Math.sqrt(F*F+q*q),V=(V-o[E])/V*j*i[E],F*=V,q*=V,D.vx-=F*(L=m[E]),D.vy-=q*L,z.vx+=F*(L=1-L),z.vy+=q*L}function g(){if(c){var j,C=c.length,N=e.length,E=new Map(c.map((z,D)=>[t(z,D,c),z])),A;for(j=0,d=new Array(C);j<N;++j)A=e[j],A.index=j,typeof A.source!="object"&&(A.source=wv(E,A.source)),typeof A.target!="object"&&(A.target=wv(E,A.target)),d[A.source.index]=(d[A.source.index]||0)+1,d[A.target.index]=(d[A.target.index]||0)+1;for(j=0,m=new Array(N);j<N;++j)A=e[j],m[j]=d[A.source.index]/(d[A.source.index]+d[A.target.index]);i=new Array(N),w(),o=new Array(N),k()}}function w(){if(c)for(var j=0,C=e.length;j<C;++j)i[j]=+n(e[j],j,e)}function k(){if(c)for(var j=0,C=e.length;j<C;++j)o[j]=+a(e[j],j,e)}return y.initialize=function(j,C){c=j,f=C,g()},y.links=function(j){return arguments.length?(e=j,g(),y):e},y.id=function(j){return arguments.length?(t=j,y):t},y.iterations=function(j){return arguments.length?(x=+j,y):x},y.strength=function(j){return arguments.length?(n=typeof j=="function"?j:cl(+j),w(),y):n},y.distance=function(j){return arguments.length?(a=typeof j=="function"?j:cl(+j),k(),y):a},y}var BD={value:()=>{}};function tu(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new lf(n)}function lf(e){this._=e}function $D(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",a=n.indexOf(".");if(a>=0&&(i=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}lf.prototype=tu.prototype={constructor:lf,on:function(e,t){var n=this._,i=$D(e+"",n),a,o=-1,c=i.length;if(arguments.length<2){for(;++o<c;)if((a=(e=i[o]).type)&&(a=OD(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<c;)if(a=(e=i[o]).type)n[a]=kv(n[a],e.name,t);else if(t==null)for(a in n)n[a]=kv(n[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new lf(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),i=0,a,o;i<a;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],i=0,a=o.length;i<a;++i)o[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],a=0,o=i.length;a<o;++a)i[a].value.apply(t,n)}};function OD(e,t){for(var n=0,i=e.length,a;n<i;++n)if((a=e[n]).name===t)return a.value}function kv(e,t,n){for(var i=0,a=e.length;i<a;++i)if(e[i].name===t){e[i]=BD,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var uo=0,Dc=0,jc=0,z5=1e3,vf,Tc,wf=0,pl=0,Uf=0,Hc=typeof performance=="object"&&performance.now?performance:Date,B5=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function b0(){return pl||(B5(LD),pl=Hc.now()+Uf)}function LD(){pl=0}function kf(){this._call=this._time=this._next=null}kf.prototype=v0.prototype={constructor:kf,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?b0():+n)+(t==null?0:+t),!this._next&&Tc!==this&&(Tc?Tc._next=this:vf=this,Tc=this),this._call=e,this._time=n,xx()},stop:function(){this._call&&(this._call=null,this._time=1/0,xx())}};function v0(e,t,n){var i=new kf;return i.restart(e,t,n),i}function ID(){b0(),++uo;for(var e=vf,t;e;)(t=pl-e._time)>=0&&e._call.call(void 0,t),e=e._next;--uo}function Sv(){pl=(wf=Hc.now())+Uf,uo=Dc=0;try{ID()}finally{uo=0,UD(),pl=0}}function HD(){var e=Hc.now(),t=e-wf;t>z5&&(Uf-=t,wf=e)}function UD(){for(var e,t=vf,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:vf=n);Tc=e,xx(i)}function xx(e){if(!uo){Dc&&(Dc=clearTimeout(Dc));var t=e-pl;t>24?(e<1/0&&(Dc=setTimeout(Sv,e-Hc.now()-Uf)),jc&&(jc=clearInterval(jc))):(jc||(wf=Hc.now(),jc=setInterval(HD,z5)),uo=1,B5(Sv))}}function jv(e,t,n){var i=new kf;return t=t==null?0:+t,i.restart(a=>{i.stop(),e(a+t)},t,n),i}const qD=1664525,YD=1013904223,Cv=4294967296;function PD(){let e=1;return()=>(e=(qD*e+YD)%Cv)/Cv}function XD(e){return e.x}function VD(e){return e.y}var WD=10,GD=Math.PI*(3-Math.sqrt(5));function KD(e){var t,n=1,i=.001,a=1-Math.pow(i,1/300),o=0,c=.6,d=new Map,m=v0(p),f=tu("tick","end"),x=PD();e==null&&(e=[]);function p(){y(),f.call("tick",t),n<i&&(m.stop(),f.call("end",t))}function y(k){var j,C=e.length,N;k===void 0&&(k=1);for(var E=0;E<k;++E)for(n+=(o-n)*a,d.forEach(function(A){A(n)}),j=0;j<C;++j)N=e[j],N.fx==null?N.x+=N.vx*=c:(N.x=N.fx,N.vx=0),N.fy==null?N.y+=N.vy*=c:(N.y=N.fy,N.vy=0);return t}function g(){for(var k=0,j=e.length,C;k<j;++k){if(C=e[k],C.index=k,C.fx!=null&&(C.x=C.fx),C.fy!=null&&(C.y=C.fy),isNaN(C.x)||isNaN(C.y)){var N=WD*Math.sqrt(.5+k),E=k*GD;C.x=N*Math.cos(E),C.y=N*Math.sin(E)}(isNaN(C.vx)||isNaN(C.vy))&&(C.vx=C.vy=0)}}function w(k){return k.initialize&&k.initialize(e,x),k}return g(),t={tick:y,restart:function(){return m.restart(p),t},stop:function(){return m.stop(),t},nodes:function(k){return arguments.length?(e=k,g(),d.forEach(w),t):e},alpha:function(k){return arguments.length?(n=+k,t):n},alphaMin:function(k){return arguments.length?(i=+k,t):i},alphaDecay:function(k){return arguments.length?(a=+k,t):+a},alphaTarget:function(k){return arguments.length?(o=+k,t):o},velocityDecay:function(k){return arguments.length?(c=1-k,t):1-c},randomSource:function(k){return arguments.length?(x=k,d.forEach(w),t):x},force:function(k,j){return arguments.length>1?(j==null?d.delete(k):d.set(k,w(j)),t):d.get(k)},find:function(k,j,C){var N=0,E=e.length,A,z,D,F,q;for(C==null?C=1/0:C*=C,N=0;N<E;++N)F=e[N],A=k-F.x,z=j-F.y,D=A*A+z*z,D<C&&(q=F,C=D);return q},on:function(k,j){return arguments.length>1?(f.on(k,j),t):f.on(k)}}}function QD(){var e,t,n,i,a=cl(-30),o,c=1,d=1/0,m=.81;function f(g){var w,k=e.length,j=g0(e,XD,VD).visitAfter(p);for(i=g,w=0;w<k;++w)t=e[w],j.visit(y)}function x(){if(e){var g,w=e.length,k;for(o=new Array(w),g=0;g<w;++g)k=e[g],o[k.index]=+a(k,g,e)}}function p(g){var w=0,k,j,C=0,N,E,A;if(g.length){for(N=E=A=0;A<4;++A)(k=g[A])&&(j=Math.abs(k.value))&&(w+=k.value,C+=j,N+=j*k.x,E+=j*k.y);g.x=N/C,g.y=E/C}else{k=g,k.x=k.data.x,k.y=k.data.y;do w+=o[k.data.index];while(k=k.next)}g.value=w}function y(g,w,k,j){if(!g.value)return!0;var C=g.x-t.x,N=g.y-t.y,E=j-w,A=C*C+N*N;if(E*E/m<A)return A<d&&(C===0&&(C=Ca(n),A+=C*C),N===0&&(N=Ca(n),A+=N*N),A<c&&(A=Math.sqrt(c*A)),t.vx+=C*g.value*i/A,t.vy+=N*g.value*i/A),!0;if(g.length||A>=d)return;(g.data!==t||g.next)&&(C===0&&(C=Ca(n),A+=C*C),N===0&&(N=Ca(n),A+=N*N),A<c&&(A=Math.sqrt(c*A)));do g.data!==t&&(E=o[g.data.index]*i/A,t.vx+=C*E,t.vy+=N*E);while(g=g.next)}return f.initialize=function(g,w){e=g,n=w,x()},f.strength=function(g){return arguments.length?(a=typeof g=="function"?g:cl(+g),x(),f):a},f.distanceMin=function(g){return arguments.length?(c=g*g,f):Math.sqrt(c)},f.distanceMax=function(g){return arguments.length?(d=g*g,f):Math.sqrt(d)},f.theta=function(g){return arguments.length?(m=g*g,f):Math.sqrt(m)},f}function Rs(e){return Array.isArray?Array.isArray(e):L5(e)==="[object Array]"}function ZD(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function JD(e){return e==null?"":ZD(e)}function Ki(e){return typeof e=="string"}function $5(e){return typeof e=="number"}function eT(e){return e===!0||e===!1||tT(e)&&L5(e)=="[object Boolean]"}function O5(e){return typeof e=="object"}function tT(e){return O5(e)&&e!==null}function Pr(e){return e!=null}function wp(e){return!e.trim().length}function L5(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const nT="Incorrect 'index' type",rT=e=>`Invalid value for key ${e}`,iT=e=>`Pattern length exceeds max of ${e}.`,sT=e=>`Missing ${e} property in key`,aT=e=>`Property 'weight' in key '${e}' must be a positive integer`,Nv=Object.prototype.hasOwnProperty;class lT{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(i=>{let a=I5(i);this._keys.push(a),this._keyMap[a.id]=a,n+=a.weight}),this._keys.forEach(i=>{i.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function I5(e){let t=null,n=null,i=null,a=1,o=null;if(Ki(e)||Rs(e))i=e,t=Ev(e),n=gx(e);else{if(!Nv.call(e,"name"))throw new Error(sT("name"));const c=e.name;if(i=c,Nv.call(e,"weight")&&(a=e.weight,a<=0))throw new Error(aT(c));t=Ev(c),n=gx(c),o=e.getFn}return{path:t,id:n,weight:a,src:i,getFn:o}}function Ev(e){return Rs(e)?e:e.split(".")}function gx(e){return Rs(e)?e.join("."):e}function oT(e,t){let n=[],i=!1;const a=(o,c,d)=>{if(Pr(o))if(!c[d])n.push(o);else{let m=c[d];const f=o[m];if(!Pr(f))return;if(d===c.length-1&&(Ki(f)||$5(f)||eT(f)))n.push(JD(f));else if(Rs(f)){i=!0;for(let x=0,p=f.length;x<p;x+=1)a(f[x],c,d+1)}else c.length&&a(f,c,d+1)}};return a(e,Ki(t)?t.split("."):t,0),i?n:n[0]}const cT={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},uT={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},dT={location:0,threshold:.6,distance:100},fT={useExtendedSearch:!1,getFn:oT,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var bt={...uT,...cT,...dT,...fT};const hT=/[^ ]+/g;function mT(e=1,t=3){const n=new Map,i=Math.pow(10,t);return{get(a){const o=a.match(hT).length;if(n.has(o))return n.get(o);const c=1/Math.pow(o,.5*e),d=parseFloat(Math.round(c*i)/i);return n.set(o,d),d},clear(){n.clear()}}}class w0{constructor({getFn:t=bt.getFn,fieldNormWeight:n=bt.fieldNormWeight}={}){this.norm=mT(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,i)=>{this._keysMap[n.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Ki(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();Ki(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,i=this.size();n<i;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Pr(t)||wp(t))return;let i={v:t,i:n,n:this.norm.get(t)};this.records.push(i)}_addObject(t,n){let i={i:n,$:{}};this.keys.forEach((a,o)=>{let c=a.getFn?a.getFn(t):this.getFn(t,a.path);if(Pr(c)){if(Rs(c)){let d=[];const m=[{nestedArrIndex:-1,value:c}];for(;m.length;){const{nestedArrIndex:f,value:x}=m.pop();if(Pr(x))if(Ki(x)&&!wp(x)){let p={v:x,i:f,n:this.norm.get(x)};d.push(p)}else Rs(x)&&x.forEach((p,y)=>{m.push({nestedArrIndex:y,value:p})})}i.$[o]=d}else if(Ki(c)&&!wp(c)){let d={v:c,n:this.norm.get(c)};i.$[o]=d}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function H5(e,t,{getFn:n=bt.getFn,fieldNormWeight:i=bt.fieldNormWeight}={}){const a=new w0({getFn:n,fieldNormWeight:i});return a.setKeys(e.map(I5)),a.setSources(t),a.create(),a}function pT(e,{getFn:t=bt.getFn,fieldNormWeight:n=bt.fieldNormWeight}={}){const{keys:i,records:a}=e,o=new w0({getFn:t,fieldNormWeight:n});return o.setKeys(i),o.setIndexRecords(a),o}function Bd(e,{errors:t=0,currentLocation:n=0,expectedLocation:i=0,distance:a=bt.distance,ignoreLocation:o=bt.ignoreLocation}={}){const c=t/e.length;if(o)return c;const d=Math.abs(i-n);return a?c+d/a:d?1:c}function xT(e=[],t=bt.minMatchCharLength){let n=[],i=-1,a=-1,o=0;for(let c=e.length;o<c;o+=1){let d=e[o];d&&i===-1?i=o:!d&&i!==-1&&(a=o-1,a-i+1>=t&&n.push([i,a]),i=-1)}return e[o-1]&&o-i>=t&&n.push([i,o-1]),n}const ll=32;function gT(e,t,n,{location:i=bt.location,distance:a=bt.distance,threshold:o=bt.threshold,findAllMatches:c=bt.findAllMatches,minMatchCharLength:d=bt.minMatchCharLength,includeMatches:m=bt.includeMatches,ignoreLocation:f=bt.ignoreLocation}={}){if(t.length>ll)throw new Error(iT(ll));const x=t.length,p=e.length,y=Math.max(0,Math.min(i,p));let g=o,w=y;const k=d>1||m,j=k?Array(p):[];let C;for(;(C=e.indexOf(t,w))>-1;){let F=Bd(t,{currentLocation:C,expectedLocation:y,distance:a,ignoreLocation:f});if(g=Math.min(F,g),w=C+x,k){let q=0;for(;q<x;)j[C+q]=1,q+=1}}w=-1;let N=[],E=1,A=x+p;const z=1<<x-1;for(let F=0;F<x;F+=1){let q=0,V=A;for(;q<V;)Bd(t,{errors:F,currentLocation:y+V,expectedLocation:y,distance:a,ignoreLocation:f})<=g?q=V:A=V,V=Math.floor((A-q)/2+q);A=V;let L=Math.max(1,y-V+1),_=c?p:Math.min(y+V,p)+x,B=Array(_+2);B[_+1]=(1<<F)-1;for(let R=_;R>=L;R-=1){let H=R-1,$=n[e.charAt(H)];if(k&&(j[H]=+!!$),B[R]=(B[R+1]<<1|1)&$,F&&(B[R]|=(N[R+1]|N[R])<<1|1|N[R+1]),B[R]&z&&(E=Bd(t,{errors:F,currentLocation:H,expectedLocation:y,distance:a,ignoreLocation:f}),E<=g)){if(g=E,w=H,w<=y)break;L=Math.max(1,2*y-w)}}if(Bd(t,{errors:F+1,currentLocation:y,expectedLocation:y,distance:a,ignoreLocation:f})>g)break;N=B}const D={isMatch:w>=0,score:Math.max(.001,E)};if(k){const F=xT(j,d);F.length?m&&(D.indices=F):D.isMatch=!1}return D}function yT(e){let t={};for(let n=0,i=e.length;n<i;n+=1){const a=e.charAt(n);t[a]=(t[a]||0)|1<<i-n-1}return t}const Sf=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class U5{constructor(t,{location:n=bt.location,threshold:i=bt.threshold,distance:a=bt.distance,includeMatches:o=bt.includeMatches,findAllMatches:c=bt.findAllMatches,minMatchCharLength:d=bt.minMatchCharLength,isCaseSensitive:m=bt.isCaseSensitive,ignoreDiacritics:f=bt.ignoreDiacritics,ignoreLocation:x=bt.ignoreLocation}={}){if(this.options={location:n,threshold:i,distance:a,includeMatches:o,findAllMatches:c,minMatchCharLength:d,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x},t=m?t:t.toLowerCase(),t=f?Sf(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const p=(g,w)=>{this.chunks.push({pattern:g,alphabet:yT(g),startIndex:w})},y=this.pattern.length;if(y>ll){let g=0;const w=y%ll,k=y-w;for(;g<k;)p(this.pattern.substr(g,ll),g),g+=ll;if(w){const j=y-ll;p(this.pattern.substr(j),j)}}else p(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:i,includeMatches:a}=this.options;if(t=n?t:t.toLowerCase(),t=i?Sf(t):t,this.pattern===t){let k={isMatch:!0,score:0};return a&&(k.indices=[[0,t.length-1]]),k}const{location:o,distance:c,threshold:d,findAllMatches:m,minMatchCharLength:f,ignoreLocation:x}=this.options;let p=[],y=0,g=!1;this.chunks.forEach(({pattern:k,alphabet:j,startIndex:C})=>{const{isMatch:N,score:E,indices:A}=gT(t,k,j,{location:o+C,distance:c,threshold:d,findAllMatches:m,minMatchCharLength:f,includeMatches:a,ignoreLocation:x});N&&(g=!0),y+=E,N&&A&&(p=[...p,...A])});let w={isMatch:g,score:g?y/this.chunks.length:1};return g&&a&&(w.indices=p),w}}class _a{constructor(t){this.pattern=t}static isMultiMatch(t){return Av(t,this.multiRegex)}static isSingleMatch(t){return Av(t,this.singleRegex)}search(){}}function Av(e,t){const n=e.match(t);return n?n[1]:null}class bT extends _a{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class vT extends _a{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class wT extends _a{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class kT extends _a{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ST extends _a{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class jT extends _a{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class q5 extends _a{constructor(t,{location:n=bt.location,threshold:i=bt.threshold,distance:a=bt.distance,includeMatches:o=bt.includeMatches,findAllMatches:c=bt.findAllMatches,minMatchCharLength:d=bt.minMatchCharLength,isCaseSensitive:m=bt.isCaseSensitive,ignoreDiacritics:f=bt.ignoreDiacritics,ignoreLocation:x=bt.ignoreLocation}={}){super(t),this._bitapSearch=new U5(t,{location:n,threshold:i,distance:a,includeMatches:o,findAllMatches:c,minMatchCharLength:d,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Y5 extends _a{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,i;const a=[],o=this.pattern.length;for(;(i=t.indexOf(this.pattern,n))>-1;)n=i+o,a.push([i,n-1]);const c=!!a.length;return{isMatch:c,score:c?0:1,indices:a}}}const yx=[bT,Y5,wT,kT,jT,ST,vT,q5],Dv=yx.length,CT=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,NT="|";function ET(e,t={}){return e.split(NT).map(n=>{let i=n.trim().split(CT).filter(o=>o&&!!o.trim()),a=[];for(let o=0,c=i.length;o<c;o+=1){const d=i[o];let m=!1,f=-1;for(;!m&&++f<Dv;){const x=yx[f];let p=x.isMultiMatch(d);p&&(a.push(new x(p,t)),m=!0)}if(!m)for(f=-1;++f<Dv;){const x=yx[f];let p=x.isSingleMatch(d);if(p){a.push(new x(p,t));break}}}return a})}const AT=new Set([q5.type,Y5.type]);class DT{constructor(t,{isCaseSensitive:n=bt.isCaseSensitive,ignoreDiacritics:i=bt.ignoreDiacritics,includeMatches:a=bt.includeMatches,minMatchCharLength:o=bt.minMatchCharLength,ignoreLocation:c=bt.ignoreLocation,findAllMatches:d=bt.findAllMatches,location:m=bt.location,threshold:f=bt.threshold,distance:x=bt.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:i,includeMatches:a,minMatchCharLength:o,findAllMatches:d,ignoreLocation:c,location:m,threshold:f,distance:x},t=n?t:t.toLowerCase(),t=i?Sf(t):t,this.pattern=t,this.query=ET(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:a,ignoreDiacritics:o}=this.options;t=a?t:t.toLowerCase(),t=o?Sf(t):t;let c=0,d=[],m=0;for(let f=0,x=n.length;f<x;f+=1){const p=n[f];d.length=0,c=0;for(let y=0,g=p.length;y<g;y+=1){const w=p[y],{isMatch:k,indices:j,score:C}=w.search(t);if(k){if(c+=1,m+=C,i){const N=w.constructor.type;AT.has(N)?d=[...d,...j]:d.push(j)}}else{m=0,c=0,d.length=0;break}}if(c){let y={isMatch:!0,score:m/c};return i&&(y.indices=d),y}}return{isMatch:!1,score:1}}}const bx=[];function TT(...e){bx.push(...e)}function vx(e,t){for(let n=0,i=bx.length;n<i;n+=1){let a=bx[n];if(a.condition(e,t))return new a(e,t)}return new U5(e,t)}const jf={AND:"$and",OR:"$or"},wx={PATH:"$path",PATTERN:"$val"},kx=e=>!!(e[jf.AND]||e[jf.OR]),_T=e=>!!e[wx.PATH],MT=e=>!Rs(e)&&O5(e)&&!kx(e),Tv=e=>({[jf.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function P5(e,t,{auto:n=!0}={}){const i=a=>{let o=Object.keys(a);const c=_T(a);if(!c&&o.length>1&&!kx(a))return i(Tv(a));if(MT(a)){const m=c?a[wx.PATH]:o[0],f=c?a[wx.PATTERN]:a[m];if(!Ki(f))throw new Error(rT(m));const x={keyId:gx(m),pattern:f};return n&&(x.searcher=vx(f,t)),x}let d={children:[],operator:o[0]};return o.forEach(m=>{const f=a[m];Rs(f)&&f.forEach(x=>{d.children.push(i(x))})}),d};return kx(e)||(e=Tv(e)),i(e)}function FT(e,{ignoreFieldNorm:t=bt.ignoreFieldNorm}){e.forEach(n=>{let i=1;n.matches.forEach(({key:a,norm:o,score:c})=>{const d=a?a.weight:null;i*=Math.pow(c===0&&d?Number.EPSILON:c,(d||1)*(t?1:o))}),n.score=i})}function RT(e,t){const n=e.matches;t.matches=[],Pr(n)&&n.forEach(i=>{if(!Pr(i.indices)||!i.indices.length)return;const{indices:a,value:o}=i;let c={indices:a,value:o};i.key&&(c.key=i.key.src),i.idx>-1&&(c.refIndex=i.idx),t.matches.push(c)})}function zT(e,t){t.score=e.score}function BT(e,t,{includeMatches:n=bt.includeMatches,includeScore:i=bt.includeScore}={}){const a=[];return n&&a.push(RT),i&&a.push(zT),e.map(o=>{const{idx:c}=o,d={item:t[c],refIndex:c};return a.length&&a.forEach(m=>{m(o,d)}),d})}class Co{constructor(t,n={},i){this.options={...bt,...n},this.options.useExtendedSearch,this._keyStore=new lT(this.options.keys),this.setCollection(t,i)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof w0))throw new Error(nT);this._myIndex=n||H5(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Pr(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let i=0,a=this._docs.length;i<a;i+=1){const o=this._docs[i];t(o,i)&&(this.removeAt(i),i-=1,a-=1,n.push(o))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:i,includeScore:a,shouldSort:o,sortFn:c,ignoreFieldNorm:d}=this.options;let m=Ki(t)?Ki(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return FT(m,{ignoreFieldNorm:d}),o&&m.sort(c),$5(n)&&n>-1&&(m=m.slice(0,n)),BT(m,this._docs,{includeMatches:i,includeScore:a})}_searchStringList(t){const n=vx(t,this.options),{records:i}=this._myIndex,a=[];return i.forEach(({v:o,i:c,n:d})=>{if(!Pr(o))return;const{isMatch:m,score:f,indices:x}=n.searchIn(o);m&&a.push({item:o,idx:c,matches:[{score:f,value:o,norm:d,indices:x}]})}),a}_searchLogical(t){const n=P5(t,this.options),i=(d,m,f)=>{if(!d.children){const{keyId:p,searcher:y}=d,g=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(m,p),searcher:y});return g&&g.length?[{idx:f,item:m,matches:g}]:[]}const x=[];for(let p=0,y=d.children.length;p<y;p+=1){const g=d.children[p],w=i(g,m,f);if(w.length)x.push(...w);else if(d.operator===jf.AND)return[]}return x},a=this._myIndex.records,o={},c=[];return a.forEach(({$:d,i:m})=>{if(Pr(d)){let f=i(n,d,m);f.length&&(o[m]||(o[m]={idx:m,item:d,matches:[]},c.push(o[m])),f.forEach(({matches:x})=>{o[m].matches.push(...x)}))}}),c}_searchObjectList(t){const n=vx(t,this.options),{keys:i,records:a}=this._myIndex,o=[];return a.forEach(({$:c,i:d})=>{if(!Pr(c))return;let m=[];i.forEach((f,x)=>{m.push(...this._findMatches({key:f,value:c[x],searcher:n}))}),m.length&&o.push({idx:d,item:c,matches:m})}),o}_findMatches({key:t,value:n,searcher:i}){if(!Pr(n))return[];let a=[];if(Rs(n))n.forEach(({v:o,i:c,n:d})=>{if(!Pr(o))return;const{isMatch:m,score:f,indices:x}=i.searchIn(o);m&&a.push({score:f,key:t,value:o,idx:c,norm:d,indices:x})});else{const{v:o,n:c}=n,{isMatch:d,score:m,indices:f}=i.searchIn(o);d&&a.push({score:m,key:t,value:o,norm:c,indices:f})}return a}}Co.version="7.1.0";Co.createIndex=H5;Co.parseIndex=pT;Co.config=bt;Co.parseQuery=P5;TT(DT);const _s={architecture:{bg:"rgba(59,130,246,0.15)",border:"#3b82f6",text:"#60a5fa"},knowledge:{bg:"rgba(245,158,11,0.15)",border:"#f59e0b",text:"#fbbf24"},roles:{bg:"rgba(139,92,246,0.15)",border:"#8b5cf6",text:"#a78bfa"},projects:{bg:"rgba(34,197,94,0.15)",border:"#22c55e",text:"#4ade80"},operations:{bg:"rgba(236,72,153,0.15)",border:"#ec4899",text:"#f472b6"},company:{bg:"rgba(239,68,68,0.15)",border:"#ef4444",text:"#f87171"},methodologies:{bg:"rgba(14,165,233,0.15)",border:"#0ea5e9",text:"#38bdf8"},src:{bg:"rgba(251,146,60,0.15)",border:"#fb923c",text:"#fdba74"},general:{bg:"rgba(148,163,184,0.12)",border:"#64748b",text:"#94a3b8"}};function Sx(e){return _s[e]??_s.general}function $T(e){return e>1600?"macro":e<800?"micro":"standard"}function OT(e){const t=new Map;for(const i of e){const a=i.category||"general";t.has(a)||t.set(a,[]),t.get(a).push(i)}const n=[];for(const[i,a]of t){let o=0,c=0;for(const m of a)o+=m.x??0,c+=m.y??0;const d=a.length;n.push({domain:i,count:d,centerX:o/d,centerY:c/d,nodes:a})}return n}function LT(e,t=60){if(!e)return"";const n=e.match(/^[^.!?]+[.!?]/),i=n?n[0]:e;return i.length>t?i.slice(0,t-2)+"..":i}function IT(e,t,n){const i=[...new Set(n.map(m=>m.category||"general"))],a=new Map,o=e/2,c=t/2,d=Math.min(e,t)*.3;return i.forEach((m,f)=>{const x=2*Math.PI*f/i.length-Math.PI/2;a.set(m,{x:o+d*Math.cos(x),y:c+d*Math.sin(x)})}),a}function HT(e,t=.12){let n;function i(a){for(const o of n){const c=e.get(o.category)||e.get("general");c&&o.x!==void 0&&o.y!==void 0&&(o.vx=(o.vx||0)+(c.x-o.x)*a*t,o.vy=(o.vy||0)+(c.y-o.y)*a*t)}}return i.initialize=function(a){n=a},i}function UT(e){return e.map(t=>{let n=0;for(const a of t.nodes){const o=(a.x??0)-t.centerX,c=(a.y??0)-t.centerY,d=Math.sqrt(o*o+c*c);d>n&&(n=d)}const i=Math.max(40,t.count*8);return{...t,radius:n+i}})}function qT(e,t,n,i){if(!e)return n;const a=new Set([e]),o=new Set;let c=new Set([e]);for(let d=0;d<i;d++){const m=new Set;for(const f of c)if(!o.has(f)){o.add(f);for(const x of t){const p=typeof x.source=="string"?x.source:x.source.id,y=typeof x.target=="string"?x.target:x.target.id;p===f&&!a.has(y)&&(a.add(y),m.add(y)),y===f&&!a.has(p)&&(a.add(p),m.add(p))}}c=m}return a}function YT({docs:e,onNodeClick:t,selectedDocId:n,matchedIds:i,localGraphMode:a,onLocalModeChange:o,onClusterClick:c}){var O;const d=S.useRef(null),m=S.useRef(null),[f,x]=S.useState({width:600,height:400}),[p,y]=S.useState({nodes:[],links:[]}),[g,w]=S.useState(null),[k,j]=S.useState(null),[C,N]=S.useState(new Set),[E,A]=S.useState(null),[z,D]=S.useState({x:0,y:0}),[F,q]=S.useState({x:0,y:0,w:600,h:400}),V=S.useRef(!1),L=S.useRef({x:0,y:0,vx:0,vy:0}),_=S.useRef(null),B=S.useRef(null),X=S.useMemo(()=>$T(F.w),[F.w]),R=S.useMemo(()=>OT(p.nodes),[p.nodes]),H=S.useMemo(()=>UT(R),[R]),$=S.useMemo(()=>{if(a==="global"||!n)return null;const Z=new Set(p.nodes.map(J=>J.id)),ee=a==="1-hop"?1:2;return qT(n,p.links,Z,ee)},[a,n,p.nodes,p.links]);S.useEffect(()=>{const Z=d.current;if(!Z)return;const ee=new ResizeObserver(J=>{const{width:se,height:le}=J[0].contentRect;se>0&&le>0&&(x({width:se,height:le}),q(ye=>({...ye,w:se,h:le})))});return ee.observe(Z),()=>ee.disconnect()},[]),S.useEffect(()=>{if(e.length===0)return;const Z=new Set(e.map(Ye=>Ye.id)),ee=e.map(Ye=>({id:Ye.id,title:Ye.title,category:Ye.category,akb_type:Ye.akb_type,tldr:Ye.tldr,tags:Ye.tags})),J=(Ye,nt)=>{if(!nt.startsWith(".")&&!nt.startsWith("/"))return nt;const ut=Ye.split("/");ut.pop();const kt=nt.split("/");for(const mt of kt)mt===".."?ut.pop():mt!=="."&&mt!==""&&ut.push(mt);return ut.join("/")},se=[];for(const Ye of e)for(const nt of Ye.links){const ut=J(Ye.id,nt.href);Z.has(ut)&&ut!==Ye.id&&(se.some(kt=>kt.source===Ye.id&&kt.target===ut||kt.source===ut&&kt.target===Ye.id)||se.push({source:Ye.id,target:ut,label:nt.text}))}const{width:le,height:ye}=f,De=ee.length,Ee=De>100?-600:De>50?-500:-400,Re=De>100?180:De>50?160:140,me=De>100?60:50,Fe=Math.max(le,De*12),Je=Math.max(ye,De*10),Pe=IT(Fe,Je,ee),it=KD(ee).force("link",zD(se).id(Ye=>Ye.id).distance(Re)).force("charge",QD().strength(Ee)).force("center",mD(Fe/2,Je/2)).force("collide",FD(me)).force("cluster",HT(Pe,.15));B.current=it,it.on("tick",()=>{y({nodes:[...ee],links:[...se]})}),it.alpha(1).restart();const ht=De>100?300:150;for(let Ye=0;Ye<ht;Ye++)it.tick();if(it.stop(),y({nodes:[...ee],links:[...se]}),ee.length>0){let Ye=1/0,nt=1/0,ut=-1/0,kt=-1/0;for(const ve of ee){const be=ve.x??0,te=ve.y??0;be<Ye&&(Ye=be),te<nt&&(nt=te),be>ut&&(ut=be),te>kt&&(kt=te)}const mt=100;q({x:Ye-mt,y:nt-mt,w:Math.max(le,ut-Ye+mt*2),h:Math.max(ye,kt-nt+mt*2)})}return()=>{it.stop()}},[e,f]);const G=Z=>{if(typeof Z=="string"){const ee=p.nodes.find(J=>J.id===Z);return{x:(ee==null?void 0:ee.x)??0,y:(ee==null?void 0:ee.y)??0}}return{x:Z.x??0,y:Z.y??0}},Q=S.useCallback(Z=>{Z.preventDefault();const ee=Z.deltaY>0?1.1:.9;q(J=>{const se=Math.max(200,Math.min(f.width*3,J.w*ee)),le=Math.max(150,Math.min(f.height*3,J.h*ee)),ye=(se-J.w)/2,De=(le-J.h)/2;return{x:J.x-ye,y:J.y-De,w:se,h:le}})},[f]),K=S.useCallback(Z=>{Z.button===0&&(V.current=!0,L.current={x:Z.clientX,y:Z.clientY,vx:F.x,vy:F.y})},[F]),M=S.useCallback(Z=>{var ee;if(_.current){const J=m.current;if(!J)return;const se=J.getBoundingClientRect(),le=F.w/se.width,ye=F.h/se.height,De=F.x+(Z.clientX-se.left)*le,Ee=F.y+(Z.clientY-se.top)*ye;_.current.fx=De,_.current.fy=Ee,(ee=B.current)==null||ee.alpha(.3).restart();return}if(V.current){const J=(Z.clientX-L.current.x)*(F.w/f.width),se=(Z.clientY-L.current.y)*(F.h/f.height);q(le=>({...le,x:L.current.vx-J,y:L.current.vy-se}))}},[F,f]),U=S.useCallback(()=>{V.current=!1,_.current&&(_.current.fx=null,_.current.fy=null,_.current=null)},[]),P=S.useCallback((Z,ee)=>{var J;Z.stopPropagation(),_.current=ee,(J=B.current)==null||J.alpha(.3).restart()},[]);return l.jsxs("div",{ref:d,className:"relative flex-1 overflow-hidden",style:{background:"#1e1e2e"},children:[l.jsxs("svg",{ref:m,width:f.width,height:f.height,viewBox:`${F.x} ${F.y} ${F.w} ${F.h}`,style:{display:"block",cursor:V.current?"grabbing":"grab"},onWheel:Q,onMouseDown:K,onMouseMove:M,onMouseUp:U,onMouseLeave:U,children:[l.jsx("defs",{children:l.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:l.jsx("circle",{cx:"0",cy:"0",r:"0.5",fill:"rgba(255,255,255,0.06)"})})}),l.jsx("rect",{x:F.x-100,y:F.y-100,width:F.w+200,height:F.h+200,fill:"url(#grid)",pointerEvents:"none"}),X==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:R.map(Z=>{const ee=_s[Z.domain]??_s.general,J=Math.max(40,Math.sqrt(Z.count)*25),le=i===null||Z.nodes.some(ye=>i.has(ye.id))?1:.4;return l.jsxs("g",{transform:`translate(${Z.centerX}, ${Z.centerY})`,style:{cursor:"pointer",opacity:le,transition:"opacity 0.3s ease"},onMouseEnter:ye=>{var Ee;const De=(Ee=d.current)==null?void 0:Ee.getBoundingClientRect();De&&D({x:ye.clientX-De.left,y:ye.clientY-De.top}),w({id:`cluster-${Z.domain}`,title:`${Z.domain} (${Z.count})`,category:Z.domain,akb_type:"hub"})},onMouseLeave:()=>w(null),children:[l.jsx("circle",{r:J,fill:ee.bg,stroke:ee.border,strokeWidth:3,opacity:.8}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:ee.text,fontSize:16,fontFamily:"monospace",fontWeight:"bold",style:{pointerEvents:"none"},children:Z.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:ee.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",Z.count,")"]})]},Z.domain)})}),X!=="macro"&&l.jsxs(l.Fragment,{children:[X==="standard"&&H.map(Z=>{const ee=_s[Z.domain]??_s.general;if(Z.count<2)return null;const J=i===null||Z.nodes.some(le=>i.has(le.id)),se=J?.08:.04;return l.jsxs("g",{children:[l.jsx("circle",{cx:Z.centerX,cy:Z.centerY,r:Z.radius,fill:ee.bg,stroke:ee.border,strokeWidth:1,opacity:se,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:Z.centerX,y:Z.centerY-Z.radius-8,textAnchor:"middle",fill:ee.text,fontSize:12,fontFamily:"monospace",fontWeight:"600",opacity:J?.85:.5,onClick:()=>c(Z.domain),style:{cursor:"pointer",pointerEvents:"auto",transition:"opacity 0.3s ease"},children:[Z.domain," (",Z.count,")"]})]},`cluster-bg-${Z.domain}`)}),p.links.map((Z,ee)=>{const J=G(Z.source),se=G(Z.target),le=k===ee,ye=(J.x+se.x)/2,De=(J.y+se.y)/2,Ee=typeof Z.source=="string"?Z.source:Z.source.id,Re=typeof Z.target=="string"?Z.target:Z.target.id,me=$===null||$.has(Ee)&&$.has(Re),Pe=le||E!==null&&(Ee===E||Re===E)||n&&(Ee===n||Re===n),it=me?1:.3,ht=Pe?it:it*.15;return l.jsxs("g",{style:{opacity:ht,transition:"opacity 0.25s ease"},children:[l.jsx("line",{x1:J.x,y1:J.y,x2:se.x,y2:se.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>{j(ee),N(new Set([Ee,Re]))},onMouseLeave:()=>{j(null),N(new Set)}}),l.jsx("line",{x1:J.x,y1:J.y,x2:se.x,y2:se.y,stroke:Pe?"rgba(148,163,184,0.8)":"rgba(148,163,184,0.4)",strokeWidth:Pe?1.5:.5,pointerEvents:"none"}),le&&Z.label&&l.jsx("text",{x:ye,y:De-6,textAnchor:"middle",fill:"#e2e8f0",fontSize:9,fontFamily:"monospace",style:{pointerEvents:"none"},children:l.jsx("tspan",{style:{filter:"drop-shadow(0 0 2px rgba(0,0,0,0.8))"},children:Z.label.length>30?Z.label.slice(0,28)+"..":Z.label})})]},ee)}),p.nodes.map(Z=>{const ee=_s[Z.category]??_s.general,J=Z.akb_type==="hub",se=J?24:16,le=X==="micro"?se*1.5:se,ye=(g==null?void 0:g.id)===Z.id,De=n===Z.id,Ee=C.has(Z.id),Re=ye?1.1:De?1.05:1,me=i===null||i.has(Z.id),Fe=$===null||$.has(Z.id),Je=me&&Fe?1:.35,Pe=X==="micro"?LT(Z.tldr,60):"",it=X==="micro"&&Z.tags?Z.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${Z.x??0}, ${Z.y??0}) scale(${Re})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:Je},onClick:ht=>{ht.stopPropagation();const Ye=e.find(nt=>nt.id===Z.id);Ye&&t(Ye)},onMouseDown:ht=>P(ht,Z),onMouseEnter:ht=>{var nt;w(Z),A(Z.id);const Ye=(nt=d.current)==null?void 0:nt.getBoundingClientRect();Ye&&D({x:ht.clientX-Ye.left,y:ht.clientY-Ye.top})},onMouseLeave:()=>{w(null),A(null)},children:[De&&l.jsx("rect",{x:-le/2-4,y:-le/2-4,width:le+8,height:le+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:J?5:2,opacity:.6}),!De&&Ee&&l.jsx("rect",{x:-le/2-3,y:-le/2-3,width:le+6,height:le+6,fill:"none",stroke:"#60a5fa",strokeWidth:1.5,rx:J?5:2,opacity:.7}),l.jsx("rect",{x:-le/2,y:-le/2,width:le,height:le,fill:ee.border,rx:J?4:2,opacity:ye?1:.9}),l.jsx("rect",{x:-le/2+3,y:-le/2+3,width:Math.max(0,le-6),height:Math.max(0,le-6),fill:ee.bg,rx:J?3:1}),l.jsx("text",{y:le/2+14,textAnchor:"middle",fill:De?"#e2e8f0":"#cbd5e1",fontSize:X==="micro"?13:12,fontFamily:"monospace",fontWeight:De?"bold":"normal",style:{pointerEvents:"none"},children:Z.title.length>36?Z.title.slice(0,34)+"..":Z.title}),X==="micro"&&Pe&&l.jsx("text",{y:le/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:10,fontFamily:"system-ui, sans-serif",opacity:.85,style:{pointerEvents:"none"},children:Pe}),X==="micro"&&it.length>0&&l.jsx("g",{transform:`translate(0, ${le/2+(Pe?42:28)})`,children:it.map((ht,Ye)=>{const nt=ht.length*5+8;let kt=-it.reduce((mt,ve)=>mt+ve.length*5+10,0)/2;for(let mt=0;mt<Ye;mt++)kt+=it[mt].length*5+10;return l.jsxs("g",{transform:`translate(${kt+nt/2}, 0)`,children:[l.jsx("rect",{x:-nt/2,y:-6,width:nt,height:12,fill:ee.bg,stroke:ee.border,strokeWidth:.5,rx:3}),l.jsx("text",{textAnchor:"middle",dominantBaseline:"middle",fill:ee.text,fontSize:9,fontFamily:"monospace",style:{pointerEvents:"none"},children:ht})]},ht)})})]},Z.id)})]})]}),g&&!_.current&&l.jsxs("div",{className:"absolute z-10 pointer-events-none p-2.5 rounded text-xs max-w-[240px]",style:{left:Math.min(z.x+16,f.width-250),top:Math.max(z.y-30,8),background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[l.jsx("div",{className:"font-bold mb-1",children:g.title}),l.jsxs("div",{className:"text-[10px] opacity-60 mb-1",children:[g.akb_type.toUpperCase()," / ",g.category]}),g.id.startsWith("cluster-")?l.jsx("div",{className:"text-[10px] text-green-400",children:"Zoom in to see documents"}):l.jsxs(l.Fragment,{children:[((O=e.find(Z=>Z.id===g.id))==null?void 0:O.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(Z=>Z.id===g.id).tldr}),l.jsx("div",{className:"text-[10px] text-green-400",children:"Click to open | Drag to move"})]})]}),l.jsxs("div",{className:"absolute bottom-3 left-3 px-2 py-1 rounded text-[10px] font-mono",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:X==="macro"?"#f59e0b":X==="micro"?"#22c55e":"#94a3b8",transition:"color 0.3s ease"},children:[X==="macro"&&"📍 Overview",X==="standard"&&"📍 Standard",X==="micro"&&"📍 Detail"]}),l.jsx("div",{className:"absolute bottom-3 right-3 flex gap-1 rounded overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:["global","1-hop","2-hop"].map(Z=>{const ee=a===Z,J=Z!=="global"&&!n,se=Z==="global"?"🌐 All":Z==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!J&&o(Z),disabled:J,className:"px-2 py-1 text-[10px] font-medium cursor-pointer transition-all",style:{background:ee?"rgba(22,163,106,0.3)":"transparent",color:J?"var(--terminal-text-muted)":ee?"#4ade80":"var(--terminal-text-secondary)",opacity:J?.4:1,cursor:J?"not-allowed":"pointer"},title:J?"Select a node first":`Show ${Z==="global"?"all nodes":`nodes within ${Z}`}`,children:se},Z)})}),e.length===0&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-xs",style:{color:"var(--terminal-text-muted)"},children:"No knowledge documents found"})]})}function PT(e){const t=[],n=new Map;return[...e].sort((a,o)=>a.id.localeCompare(o.id)).forEach(a=>{const o=a.id.split("/");let c=t,d="";for(let m=0;m<o.length-1;m++)if(d=d?`${d}/${o[m]}`:o[m],n.has(d))c=n.get(d).children;else{const f={type:"folder",name:o[m],path:d,children:[]};n.set(d,f),c.push(f),c=f.children}c.push({type:"file",name:o[o.length-1],path:a.id,doc:a})}),t}function XT({docs:e,onDocumentClick:t,selectedDocId:n,matchedIds:i}){const[a,o]=S.useState(new Set(["knowledge","projects","architecture","operations","company"])),[c,d]=S.useState(null),[m,f]=S.useState([]),[x,p]=S.useState(-1),y=S.useMemo(()=>PT(e),[e]),g=z=>{o(D=>{const F=new Set(D);return F.has(z)?F.delete(z):F.add(z),F})},w=z=>{d(z),t(z);const D=m.slice(0,x+1);D.push(z),D.length>10&&D.shift(),f(D),p(D.length-1)},k=()=>{d(null),t(null)},j=()=>{if(x>0){const z=x-1;p(z),d(m[z]),t(m[z])}},C=()=>{if(x<m.length-1){const z=x+1;p(z),d(m[z]),t(m[z])}},N=z=>{const D=m.indexOf(z);D!==-1&&(p(D),d(z),t(z))},E=z=>{z==="hub"&&k()},A=c?e.find(z=>z.id===c):null;return l.jsxs("div",{className:"flex-1 overflow-hidden flex animate-fadeIn",children:[l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:220,background:"var(--hud-bg-alt)",borderRight:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-2",style:{color:"var(--terminal-text-muted)"},children:"📂 Explorer"}),y.map(z=>l.jsx(X5,{node:z,level:0,expandedFolders:a,selectedDocId:n,viewingDocId:c,onToggleFolder:g,onFileClick:w,matchedIds:i},z.path))]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:A?l.jsx(V5,{doc:A,onClose:k,onBreadcrumbClick:E,history:m,historyIndex:x,onHistoryBack:j,onHistoryForward:C,onHistoryJump:N,onNavigateDoc:w,allDocs:e}):l.jsx("div",{className:"flex items-center justify-center h-full text-xs",style:{color:"var(--terminal-text-muted)"},children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-2xl mb-2",children:"📄"}),l.jsx("div",{children:"Select a document to view"})]})})})]})}function X5({node:e,level:t,expandedFolders:n,selectedDocId:i,viewingDocId:a,onToggleFolder:o,onFileClick:c,matchedIds:d}){var g,w,k;const m=n.has(e.path),f=e.type==="file"&&e.path===i,x=e.type==="file"&&e.path===a,p=((g=e.doc)==null?void 0:g.akb_type)==="hub",y=e.type==="folder"||d===null||d.has(e.path);if(e.type==="folder"){const j=d===null||(((w=e.children)==null?void 0:w.some(C=>{if(C.type==="file")return d.has(C.path);const N=E=>{var A;return E.type==="file"?d.has(E.path):((A=E.children)==null?void 0:A.some(N))??!1};return N(C)}))??!1);return l.jsxs("div",{style:{opacity:j?1:.5,transition:"opacity 0.2s ease"},children:[l.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded cursor-pointer hover:bg-white/5",style:{paddingLeft:t*12+4},onClick:()=>o(e.path),children:[l.jsx("span",{className:"text-[10px]",children:m?"📂":"📁"}),l.jsx("span",{className:"text-[11px]",style:{color:"var(--terminal-text)"},children:e.name})]}),m&&((k=e.children)==null?void 0:k.map(C=>l.jsx(X5,{node:C,level:t+1,expandedFolders:n,selectedDocId:i,viewingDocId:a,onToggleFolder:o,onFileClick:c,matchedIds:d},C.path)))]})}return l.jsxs("div",{className:`flex items-center gap-1 py-0.5 px-1 rounded cursor-pointer transition-colors ${x?"bg-green-500/20":f?"bg-white/10":"hover:bg-white/5"}`,style:{paddingLeft:t*12+4,opacity:y?1:.45,transition:"opacity 0.2s ease"},onClick:()=>c(e.path),children:[l.jsx("span",{className:"text-[10px]",children:p?"📘":"📄"}),l.jsx("span",{className:`text-[11px] truncate ${p?"font-semibold":""}`,style:{color:p?"#16a34a":"var(--terminal-text)"},children:e.name})]})}function VT(e){const t=e.split(`
83
+ `),n=[],i=new Map;for(const a of t){const o=a.match(/^(#{2,3})\s+(.+)$/);if(!o)continue;const c=o[1].length,d=o[2].trim();let m=d.toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);const f=i.get(m)||0;i.set(m,f+1);const x=f>0?`${m}-${f}`:m;n.push({id:x,text:d,level:c})}return n}function V5({doc:e,onClose:t,onBreadcrumbClick:n,history:i,historyIndex:a,onHistoryBack:o,onHistoryForward:c,onHistoryJump:d,onNavigateDoc:m,allDocs:f}){const[x,p]=S.useState(null),[y,g]=S.useState(!1),[w,k]=S.useState(null),j=S.useRef(null),[C,N]=S.useState(null);S.useEffect(()=>{if("content"in e&&e.content){p(e);return}g(!0),k(null),ke.getKnowledgeDoc(e.id).then(p).catch(X=>k(X instanceof Error?X.message:"Failed to load")).finally(()=>g(!1))},[e]);const E=S.useMemo(()=>!x||e.format==="html"?[]:VT(x.content),[x,e.format]),A=X=>{if(!j.current)return;const R=j.current.querySelectorAll("h2, h3");for(const H of R){const G=(H.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(X.startsWith(G)){H.scrollIntoView({behavior:"smooth",block:"start"}),N(X);break}}},z=Sx(e.category),D=e.akb_type==="hub",F=E.length>0&&!y&&!w,q=S.useMemo(()=>new Set(f.map(X=>X.id)),[f]),V=S.useCallback(X=>{const H=X.target.closest("a");if(!H)return;const $=H.getAttribute("href");if(!$||$.startsWith("http://")||$.startsWith("https://")||$.startsWith("#"))return;const G=$.split("#")[0];if(!G.endsWith(".md"))return;X.preventDefault();const Q=e.id.substring(0,e.id.lastIndexOf("/"));let K=G;if(G.startsWith("./")||G.startsWith("../")){const M=Q.split("/"),U=G.split("/");for(const P of U)P===".."?M.pop():P!=="."&&M.push(P);K=M.join("/")}if(q.has(K))m(K);else{const M=K.split("/").pop()||"",U=f.find(P=>P.id.endsWith("/"+M)||P.id===M);U&&m(U.id)}},[e.id,f,q,m]),L=i.slice(0,a).reverse().filter(X=>X!==e.id).slice(0,3).map(X=>f.find(R=>R.id===X)).filter(X=>X!==void 0),_=a>0,B=a<i.length-1;return l.jsxs("div",{className:"h-full flex flex-col",children:[l.jsxs("div",{className:"shrink-0 p-4",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("button",{onClick:o,disabled:!_,className:"text-xs font-semibold cursor-pointer hover:opacity-70 disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--active-green)"},title:"Back",children:"←"}),l.jsx("button",{onClick:c,disabled:!B,className:"text-xs font-semibold cursor-pointer hover:opacity-70 disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--active-green)"},title:"Forward",children:"→"}),l.jsx("div",{className:"flex-1 flex items-center gap-1 overflow-x-auto",children:L.map(X=>l.jsxs("button",{onClick:()=>d(X.id),className:"px-2 py-0.5 rounded text-[9px] hover:opacity-70 cursor-pointer whitespace-nowrap",style:{background:"var(--hud-bg)",color:"var(--terminal-text-secondary)"},title:X.title,children:["📄 ",X.title.length>15?X.title.slice(0,15)+"...":X.title]},X.id))})]}),l.jsxs("div",{className:"flex items-center gap-1 mb-2 text-[10px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("button",{onClick:()=>n("hub"),className:"hover:underline cursor-pointer",style:{color:"var(--active-green)"},children:"Knowledge Hub"}),l.jsx("span",{children:"›"}),l.jsx("span",{style:{color:z.text},children:e.category}),l.jsx("span",{children:"›"}),l.jsx("span",{style:{color:"var(--terminal-text)"},children:e.title})]}),l.jsx("div",{className:"flex items-center gap-2 mb-2",children:l.jsxs("button",{onClick:t,className:"text-xs font-semibold cursor-pointer hover:opacity-70",style:{color:"var(--active-green)"},children:["←"," Back"]})}),l.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[l.jsx("span",{className:"text-lg",children:D?"📘":e.format==="html"?"🌐":"📄"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-bold mb-1",style:{color:"var(--terminal-text)"},children:e.title}),l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:e.status==="active"?"#16a34a":e.status==="draft"?"#f59e0b":"#94a3b8"},title:e.status}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:e.id})]}),e.tags.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:e.tags.map(X=>l.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium",style:{background:z.bg,color:z.text,border:`1px solid ${z.border}`},children:X},X))})]})]}),e.tldr&&l.jsx("div",{className:"text-[11px] italic leading-relaxed p-2 rounded",style:{background:"var(--hud-bg)",color:"var(--terminal-text-secondary)"},children:e.tldr})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[l.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto p-4",onClick:V,children:[y&&l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"Loading..."}),w&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:w}),x&&l.jsx(jo,{content:x.content})]}),F&&l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:180,background:"var(--hud-bg-alt)",borderLeft:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-2",style:{color:"var(--terminal-text-muted)"},children:"Contents"}),l.jsx("div",{className:"space-y-1",children:E.map(X=>l.jsx("button",{onClick:()=>A(X.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(X.level-2)*8+8,color:C===X.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:C===X.id?"bold":"normal"},children:X.text.length>30?X.text.slice(0,28)+"..":X.text},X.id))})]})]})]})}const WT=500,_v=360,GT=700;function nu(e,t,n){const i=t??WT,[a,o]=S.useState(i),[c,d]=S.useState(!1),m=S.useRef(0),f=S.useRef(0),x=S.useRef(n);x.current=n;const p=e>0,y=p?e:0,g=Math.max(GT,i),w=p?Math.max(_v,window.innerWidth-e-100):g,k=Math.min(a,w),j=S.useCallback(C=>{C.preventDefault(),m.current=C.clientX,f.current=k,d(!0);const N=()=>{d(!1),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",N)},E=A=>{const z=m.current-A.clientX,D=f.current+z;if(D>=window.innerWidth*.6&&x.current){N(),x.current();return}const F=Math.min(g,Math.max(_v,D));o(F)};document.addEventListener("mousemove",E),document.addEventListener("mouseup",N)},[k]);return{panelRight:y,panelWidth:k,isResizing:c,handleResizeStart:j}}function Mv({docs:e,onClose:t,onRefresh:n,terminalWidth:i=0,initialDocId:a,onMaximize:o,hideHeader:c}){const[d,m]=S.useState(()=>{const ee=localStorage.getItem("kb-view-mode");return ee==="graph"||ee==="tree"||ee==="list"||ee==="health"?ee:"graph"}),[f,x]=S.useState(null),[p,y]=S.useState(null),[g,w]=S.useState([]),[k,j]=S.useState(-1),[C,N]=S.useState("global"),[E,A]=S.useState(""),z=S.useMemo(()=>{const ee=new Set(e.map(se=>se.category)),J=Object.keys(_s);return[...ee].sort((se,le)=>{const ye=J.includes(se)?0:1,De=J.includes(le)?0:1;return ye-De||se.localeCompare(le)})},[e]),[D,F]=S.useState(()=>new Set);S.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const q=S.useMemo(()=>new Co(e,{keys:["title","tldr","tags","id"],threshold:.3,includeScore:!0}),[e]),V=S.useMemo(()=>{let ee=new Set(e.map(J=>J.id));if(E.trim()){const J=q.search(E);ee=new Set(J.map(se=>se.item.id))}return D.size>0&&(ee=new Set(Array.from(ee).filter(J=>{const se=e.find(le=>le.id===J);return se&&D.has(se.category)}))),ee.size===e.length?null:ee},[e,E,q,D]),L=S.useMemo(()=>V===null?e:e.filter(ee=>V.has(ee.id)),[e,V]),_=ee=>{F(J=>{if(J.size===0)return new Set(z.filter(ye=>ye!==ee));const se=new Set(J);if(se.has(ee)){if(se.delete(ee),se.size===0)return new Set}else if(se.add(ee),se.size===z.length)return new Set;return se})},{panelRight:B,panelWidth:X,isResizing:R,handleResizeStart:H}=nu(i,void 0,o),$=ee=>{x(ee.id),G(ee.id)},G=ee=>{y(ee);const J=g.slice(0,k+1);J.push(ee),J.length>10&&J.shift(),w(J),j(J.length-1)},Q=()=>{y(null)},K=()=>{if(k>0){const ee=k-1;j(ee),y(g[ee]),x(g[ee])}},M=()=>{if(k<g.length-1){const ee=k+1;j(ee),y(g[ee]),x(g[ee])}},U=ee=>{const J=g.indexOf(ee);J!==-1&&(j(J),y(ee),x(ee))},P=ee=>{ee==="hub"&&Q()},O=ee=>{F(J=>J.size===1&&J.has(ee)?new Set:new Set([ee]))},Z=f?e.find(ee=>ee.id===f):null;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:B},onClick:t}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${R?"resizing":""}`,style:{right:B,width:X,background:"var(--terminal-bg)",borderLeftColor:"#16a34a"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${R?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:H}),!c&&l.jsxs("div",{className:"px-4 py-2.5 text-white relative flex items-center gap-3",style:{background:"#16a34a"},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm font-bold",children:["📚"," Knowledge Base"]}),l.jsxs("div",{className:"text-[10px] opacity-80",children:[e.length," documents"]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{className:"w-6 h-6 rounded-full bg-white/20 text-white flex items-center justify-center text-xs hover:bg-white/30 cursor-help",title:`Keyboard Shortcuts:
84
+ • Esc — Close panel
85
+ • Mouse Wheel — Zoom in/out
86
+ • Mouse Drag — Pan view
87
+ • Click Cluster Label — Filter to domain
88
+ • Hover Edge — Highlight connected nodes`,children:"?"}),o&&l.jsx("button",{onClick:o,className:"w-6 h-6 rounded-full bg-white/20 text-white flex items-center justify-center text-xs hover:bg-white/30 cursor-pointer",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:t,className:"w-6 h-6 rounded-full bg-white/20 text-white flex items-center justify-center text-sm hover:bg-white/30 cursor-pointer",children:"×"})]})]}),l.jsxs("div",{className:"flex gap-1 p-2",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx($d,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>m("graph")}),l.jsx($d,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{m("tree"),x(null)}}),l.jsx($d,{icon:"📋",label:"List",active:d==="list",onClick:()=>{m("list"),x(null)}}),l.jsx($d,{icon:"🏥",label:"Health",active:d==="health",onClick:()=>{m("health"),x(null)}})]}),l.jsxs("div",{className:"p-3 space-y-2",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-sm",children:"🔍"}),l.jsx("input",{type:"text",value:E,onChange:ee=>A(ee.target.value),placeholder:"Search docs...",className:"w-full pl-8 pr-3 py-1.5 text-xs rounded focus:outline-none transition-colors",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)"}}),E&&l.jsx("button",{onClick:()=>A(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs hover:opacity-70",style:{color:"var(--terminal-text-muted)"},children:"✕"})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:z.map(ee=>{const J=Sx(ee),se=D.size===0||D.has(ee);return l.jsx("button",{onClick:()=>_(ee),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:se?J.bg:"transparent",color:se?J.text:"var(--terminal-text-muted)",border:`1px solid ${se?J.border:"var(--terminal-border)"}`,opacity:se?1:.5},children:ee},ee)})}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:L.length===e.length?`${e.length} documents`:`${L.length} of ${e.length} documents`})]}),d==="graph"&&l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col animate-fadeIn",children:[p&&(()=>{const ee=e.find(J=>J.id===p);return ee?l.jsx("div",{className:"flex-1 overflow-y-auto",children:l.jsx(V5,{doc:ee,onClose:Q,onBreadcrumbClick:P,history:g,historyIndex:k,onHistoryBack:K,onHistoryForward:M,onHistoryJump:U,onNavigateDoc:G,allDocs:e})}):null})(),!p&&l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx(YT,{docs:e,onNodeClick:$,selectedDocId:f,matchedIds:V,localGraphMode:C,onLocalModeChange:N,onClusterClick:O}),Z&&!p&&l.jsxs("div",{className:"shrink-0 overflow-y-auto p-3",style:{width:200,background:"var(--hud-bg-alt)",borderLeft:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase mb-1",style:{color:"var(--terminal-text-muted)"},children:"Selected"}),l.jsx("div",{className:"text-xs font-bold mb-1",style:{color:"var(--terminal-text)"},children:Z.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:Z.status==="active"?"#16a34a":Z.status==="draft"?"#f59e0b":"#94a3b8"}}),Z.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:Z.tldr}),Z.links.length>0&&l.jsxs("div",{className:"mb-2",children:[l.jsx("div",{className:"text-[9px] font-bold mb-1",style:{color:"var(--terminal-text-muted)"},children:"Links"}),Z.links.slice(0,5).map((ee,J)=>l.jsxs("div",{className:"text-[9px] mb-0.5 truncate",style:{color:"var(--terminal-text-secondary)"},children:["🔗"," ",ee.text]},J))]})]})]}),!p&&l.jsx("div",{className:"shrink-0 p-2",style:{borderTop:"1px solid var(--terminal-border)"},children:l.jsx("div",{className:"flex flex-wrap gap-2",children:z.map(ee=>{const J=Sx(ee);return l.jsxs("div",{className:"flex items-center gap-1 text-[9px]",children:[l.jsx("div",{className:"w-2 h-2",style:{background:J.border}}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:ee})]},ee)})})})]}),d==="tree"&&l.jsx(XT,{docs:e,onDocumentClick:ee=>x(ee),selectedDocId:f,matchedIds:V}),d==="list"&&l.jsx(KT,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"}),d==="health"&&l.jsx(QT,{onNavigateDoc:ee=>x(ee)})]})]})}function $d({icon:e,label:t,active:n,onClick:i}){return l.jsxs("button",{onClick:i,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-xs font-medium rounded cursor-pointer transition-all",style:{background:n?"rgba(22,163,106,0.2)":"transparent",color:n?"#4ade80":"var(--terminal-text-muted)",border:n?"1px solid rgba(22,163,106,0.4)":"1px solid transparent"},children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{children:t})]})}function KT({icon:e,title:t,message:n,description:i}){return l.jsx("div",{className:"flex-1 flex items-center justify-center p-8 animate-fadeIn",children:l.jsxs("div",{className:"text-center max-w-md",children:[l.jsx("div",{className:"text-6xl mb-4",children:e}),l.jsx("div",{className:"text-lg font-bold mb-2",style:{color:"var(--terminal-text)"},children:t}),l.jsx("div",{className:"text-sm mb-3",style:{color:"#4ade80"},children:n}),l.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:i})]})})}function QT({onNavigateDoc:e}){const[t,n]=S.useState(null),[i,a]=S.useState(!0),[o,c]=S.useState(null);if(S.useEffect(()=>{ke.getKnowledgeHealth().then(k=>{n(k),a(!1)}).catch(k=>{c(k.message||"Failed to fetch health data"),a(!1)})},[]),i)return l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading health data..."})});if(o)return l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-sm",style:{color:"#ef4444"},children:["Error: ",o]})});if(!t)return null;const{health:d,orphanDocs:m,staleDocs:f,brokenLinks:x,suggestions:p,totalDocs:y,linkedDocs:g}=t;let w="#4ade80";return d<70&&(w="#f59e0b"),d<50&&(w="#ef4444"),l.jsx("div",{className:"flex-1 overflow-y-auto p-6 animate-fadeIn",children:l.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[l.jsxs("div",{className:"p-6 rounded-lg",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-lg font-bold mb-1",style:{color:"var(--terminal-text)"},children:"Knowledge Health"}),l.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[y," total documents, ",g," linked"]})]}),l.jsx("div",{className:"text-4xl font-bold px-6 py-3 rounded-lg",style:{color:w,background:`${w}15`,border:`2px solid ${w}40`},children:d})]}),l.jsx("div",{className:"w-full h-2 rounded-full overflow-hidden",style:{background:"var(--hud-bg)"},children:l.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${d}%`,background:w}})})]}),p.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(59,130,246,0.1)",border:"1px solid rgba(59,130,246,0.3)"},children:[l.jsx("div",{className:"text-sm font-bold mb-2",style:{color:"#60a5fa"},children:"💡 Suggestions"}),l.jsx("ul",{className:"space-y-1",children:p.map((k,j)=>l.jsxs("li",{className:"text-xs",style:{color:"var(--terminal-text)"},children:["• ",k]},j))})]}),m.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(245,158,11,0.1)",border:"1px solid rgba(245,158,11,0.3)"},children:[l.jsxs("div",{className:"text-sm font-bold mb-2",style:{color:"#fbbf24"},children:["📦 Orphan Documents (",m.length,")"]}),l.jsx("div",{className:"text-xs mb-2",style:{color:"var(--terminal-text-muted)"},children:"Documents not registered in any Hub"}),l.jsx("ul",{className:"space-y-1",children:m.map((k,j)=>l.jsx("li",{children:l.jsx("button",{onClick:()=>e(k),className:"text-xs hover:underline",style:{color:"#fbbf24"},children:k})},j))})]}),f.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(236,72,153,0.1)",border:"1px solid rgba(236,72,153,0.3)"},children:[l.jsxs("div",{className:"text-sm font-bold mb-2",style:{color:"#f472b6"},children:["📅 Stale Documents (",f.length,")"]}),l.jsx("div",{className:"text-xs mb-2",style:{color:"var(--terminal-text-muted)"},children:"Documents marked as deprecated or stale"}),l.jsx("ul",{className:"space-y-1",children:f.map((k,j)=>l.jsx("li",{children:l.jsx("button",{onClick:()=>e(k),className:"text-xs hover:underline",style:{color:"#f472b6"},children:k})},j))})]}),x.length>0&&l.jsxs("div",{className:"p-4 rounded-lg",style:{background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)"},children:[l.jsxs("div",{className:"text-sm font-bold mb-2",style:{color:"#f87171"},children:["🔗 Broken Links (",x.length,")"]}),l.jsx("div",{className:"text-xs mb-2",style:{color:"var(--terminal-text-muted)"},children:"Links pointing to non-existent documents"}),l.jsx("ul",{className:"space-y-2",children:x.map((k,j)=>l.jsxs("li",{className:"space-y-0.5",children:[l.jsx("button",{onClick:()=>e(k.file),className:"text-xs hover:underline block",style:{color:"#f87171"},children:k.file}),l.jsxs("div",{className:"text-xs pl-4",style:{color:"var(--terminal-text-muted)"},children:["→ ",k.link]})]},j))})]}),m.length===0&&f.length===0&&x.length===0&&l.jsxs("div",{className:"p-8 rounded-lg text-center",style:{background:"rgba(34,197,94,0.1)",border:"1px solid rgba(34,197,94,0.3)"},children:[l.jsx("div",{className:"text-4xl mb-3",children:"🎉"}),l.jsx("div",{className:"text-lg font-bold mb-2",style:{color:"#4ade80"},children:"All documents are healthy!"}),l.jsx("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:"No orphan documents, stale content, or broken links detected."})]})]})})}function Fv({waves:e,decisions:t,mode:n,onClose:i,onOpenWaveCenter:a,onUpdateDecision:o,onDeleteDecision:c,terminalWidth:d=0,onMaximize:m}){const[f,x]=S.useState("decisions"),{panelRight:p,panelWidth:y,isResizing:g,handleResizeStart:w}=nu(d,void 0,m);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:p},onClick:i}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${g?"resizing":""}`,style:{right:p,width:y,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${g?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:w}),l.jsxs("div",{className:"p-5 bg-[var(--desk-wood)] text-white relative",children:[l.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1",children:[m&&l.jsx("button",{onClick:m,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-sm hover:bg-white/30 cursor-pointer",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:i,className:"w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"})]}),l.jsxs("div",{className:"text-lg font-bold",children:["📋"," Decisions"]})]}),l.jsxs("div",{className:"flex",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx(kp,{label:`Decisions (${t.length})`,active:f==="decisions",onClick:()=>x("decisions")}),a?l.jsx(kp,{label:"Waves →",active:!1,onClick:a}):l.jsx(kp,{label:`Waves (${e.length})`,active:f==="waves",onClick:()=>x("waves")})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[f==="decisions"&&(t.length>0?t.map(k=>l.jsx(ZT,{decision:k,onSave:o,onDelete:c},k.id)):l.jsx("div",{className:"text-center py-10 text-sm",style:{color:"var(--terminal-text-muted)"},children:"No decisions yet"})),f==="waves"&&e.map((k,j)=>l.jsx(JT,{title:`Wave ${k.id}`,subtitle:k.startedAt,content:k.directive},j))]})]})]})}function ZT({decision:e,onSave:t,onDelete:n}){const[i,a]=S.useState(!1),[o,c]=S.useState(!1),[d,m]=S.useState(e.content),[f,x]=S.useState(!1),p=W5(e.content).slice(0,160),y=e.content.length>100,g=S.useCallback(async()=>{if(!t||d===e.content){c(!1);return}x(!0);try{await t(e.id,d),c(!1)}finally{x(!1)}},[t,d,e.id,e.content]),w=S.useCallback(async()=>{if(n){x(!0);try{await n(e.id)}finally{x(!1)}}},[n,e.id]);return l.jsxs("div",{className:"mb-3 rounded-lg overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer hover:bg-white/5",onClick:()=>{o||a(!i)},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"font-medium text-sm",style:{color:"var(--terminal-text)"},children:["#",e.id," ",e.title]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[i&&!o&&t&&l.jsx("button",{onClick:k=>{k.stopPropagation(),m(e.content),c(!0)},className:"text-[10px] px-2 py-0.5 rounded hover:bg-white/10 transition-colors",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Edit"}),l.jsx("span",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:i?"▲":"▼"})]})]}),e.date&&l.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:e.date})]}),i&&o?l.jsxs("div",{className:"px-3 pb-3 pt-2",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("textarea",{value:d,onChange:k=>m(k.target.value),className:"w-full rounded-lg p-3 text-xs leading-relaxed resize-none font-mono terminal-scrollbar focus:outline-none",style:{background:"var(--terminal-inline-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",minHeight:200},rows:12}),l.jsxs("div",{className:"flex items-center justify-between mt-2",children:[l.jsx("div",{children:n&&l.jsx("button",{onClick:w,disabled:f,className:"text-[10px] px-2 py-1 rounded hover:bg-red-900/30 transition-colors disabled:opacity-40",style:{color:"#EF4444",border:"1px solid #EF444440"},children:"Delete"})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>c(!1),disabled:f,className:"text-[10px] px-3 py-1 rounded hover:bg-white/5 transition-colors disabled:opacity-40",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Cancel"}),l.jsx("button",{onClick:g,disabled:f||d===e.content,className:"text-[10px] px-3 py-1 rounded font-semibold transition-colors disabled:opacity-40",style:{background:"var(--desk-wood)",color:"#fff"},children:f?"Saving...":"Save"})]})]})]}):i?l.jsx("div",{className:"px-3 pb-3 text-xs leading-relaxed pt-2",style:{borderTop:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(jo,{content:e.content})}):null,!i&&y&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:p})]})}function kp({label:e,active:t,onClick:n}){return l.jsx("button",{onClick:n,className:"px-4 py-2.5 text-sm font-medium cursor-pointer",style:{color:t?"var(--accent)":"var(--terminal-text-muted)",borderBottom:t?"2px solid var(--accent)":"2px solid transparent"},children:e})}function W5(e){return e.replace(/^#{1,6}\s+/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/```[\s\S]*?```/g,"").replace(/^\s*[-*+]\s+/gm,"• ").replace(/^\s*\d+\.\s+/gm,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^>\s+/gm,"").replace(/^---+$/gm,"").replace(/\|[^|]*\|/g,"").replace(/\n{2,}/g," · ").replace(/\n/g," ").trim()}function JT({title:e,subtitle:t,content:n}){const[i,a]=S.useState(!1),o=n.length>100,c=W5(n).slice(0,160);return l.jsxs("div",{className:"mb-3 rounded-lg overflow-hidden",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer hover:bg-white/5",onClick:()=>a(!i),children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"font-medium text-sm",style:{color:"var(--terminal-text)"},children:e}),l.jsx("span",{className:"text-xs shrink-0 ml-2",style:{color:"var(--terminal-text-muted)"},children:i?"▲":"▼"})]}),t&&l.jsx("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:t})]}),i&&l.jsx("div",{className:"px-3 pb-3 text-xs leading-relaxed pt-2",style:{borderTop:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(jo,{content:n})}),!i&&o&&l.jsx("div",{className:"px-3 pb-2 text-xs line-clamp-2 leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:c})]})}const fo=[{id:"ch1-q1",chapter:1,title:"Hire your first employee",description:'Every company starts with its first hire. Click the HIRE button to open the recruitment panel. Choose a role name (e.g. "PM"), set a level, and bring them on board. Each role becomes an AI agent that works for your company.',type:"main",trigger:{type:"role_hired"},rewards:{coins:1e3},hint:{target:"hire-btn",message:"Click HIRE to recruit your first team member"}},{id:"ch1-q2",chapter:1,title:"Open the Terminal",description:"The Terminal is your command center — where you talk to your team. Click TERMINAL in the bottom bar to open it. You'll see a chat-like interface where you can select any role and give them instructions.",type:"main",trigger:{type:"terminal_opened"},rewards:{coins:500},hint:{target:"terminal-btn",message:"Click TERMINAL to open your command center"}},{id:"ch1-q3",chapter:1,title:"Talk to your team",description:`Use "Talk" mode to have a conversation with your team. Talk mode is for quick questions, brainstorming, and discussions — the AI role will respond with advice but won't modify any files. Select a role tab and type your message.`,type:"main",trigger:{type:"talk_mode_used"},rewards:{coins:1e3},hint:{target:"terminal-btn",message:"Open the terminal, select Talk mode, and chat"}},{id:"ch2-q1",chapter:2,title:"Create a project",description:"Projects organize your company's work. Click the Meeting Room in the office view to create one. Give it a name, description, and the system will scaffold a project folder with PRD, tasks, and design docs that your AI team will use.",type:"main",trigger:{type:"project_created"},rewards:{coins:1500},hint:{target:"meeting-room",message:"Click the Meeting Room to create a project"}},{id:"ch2-q2",chapter:2,title:"Give your first order",description:'Use "Do" mode to assign real work. Unlike Talk mode, Do mode lets roles execute tasks — they can read/write files, create documents, and run commands. Switch to Do mode in the terminal and give your team member a task.',type:"main",trigger:{type:"do_mode_used"},rewards:{badge:"first-launch",coins:2e3},hint:{target:"terminal-btn",message:"Open the terminal, switch to Do mode, and assign a task"}},{id:"ch3-q1",chapter:3,title:"Create a chat channel",description:'Chat channels let multiple roles discuss topics together — like Slack for your AI team. Click the "+" button next to channel tabs in the terminal to create a new channel. Add members and set a topic for focused collaboration.',type:"main",trigger:{type:"chat_channel_created"},rewards:{coins:1500},hint:{target:"terminal-btn",message:'Open the terminal and click "+" to create a chat channel'}},{id:"ch3-q2",chapter:3,title:"Dispatch a CEO Wave",description:"CEO Wave broadcasts a directive to your entire C-Level team at once. It's like an all-hands announcement — each C-Level role receives the wave and can delegate to their reports. Use it for company-wide initiatives, pivots, or big decisions.",type:"main",trigger:{type:"wave_dispatched"},rewards:{badge:"team-builder",coins:3e3},hint:{target:"wave-btn",message:"Click CEO WAVE to broadcast to your team"}},{id:"ch4-q1",chapter:4,title:"Hire a CTO",description:"C-Level roles are special — they can delegate work to their reports and make autonomous decisions. A CTO manages your technical team (Engineers, QA). Hire one with the C-Level tier to unlock the org hierarchy.",type:"main",trigger:{type:"role_hired",condition:{roleId:"cto"}},rewards:{coins:2e3},hint:{target:"hire-btn",message:"Hire a CTO to lead your tech team"}},{id:"ch4-q2",chapter:4,title:"Hire an Engineer",description:'Engineers are the builders. They read architecture docs, write code, and ship features. Set their "Reports To" to CTO so the org hierarchy works — when you wave, the CTO can delegate tasks down to engineers automatically.',type:"main",trigger:{type:"role_hired",condition:{roleId:"engineer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire an Engineer to start building"}},{id:"ch4-q3",chapter:4,title:"Define a persona",description:"Each role has a persona — their personality, expertise, and communication style. Click a role in the office to open their panel, then edit their persona. A well-defined persona makes the AI role more consistent and specialized.",type:"main",trigger:{type:"persona_updated"},rewards:{coins:2e3},hint:{target:"terminal-btn",message:"Click a role in the office, then edit their persona"}},{id:"ch5-q1",chapter:5,title:"Explore the Knowledge Base",description:"The Knowledge Hub stores your company's documents — architecture decisions, domain knowledge, meeting notes. Your AI team reads these docs for context when working. Click the Knowledge bookshelf in the office to browse.",type:"main",trigger:{type:"knowledge_visited"},rewards:{coins:2e3},hint:{target:"knowledge-hub",message:"Click the Knowledge Hub to explore your docs"}},{id:"ch5-q2",chapter:5,title:"Check the Bulletin Board",description:"The Bulletin Board shows your company's daily standups and wave execution logs. Every time a role completes work, they post a standup. Waves show the full chain of delegation. It's your company's activity feed.",type:"main",trigger:{type:"bulletin_visited"},rewards:{badge:"scholar",coins:2e3},hint:{target:"bulletin-board",message:"Click the Bulletin Board for company updates"}},{id:"ch6-q1",chapter:6,title:"Visit the Character Store",description:"The Store has community-created characters with unique pixel art designs. Browse characters shared by other Tycono users, preview their look, and import them into your team. Open HIRE and switch to the Store tab.",type:"main",trigger:{type:"store_visited"},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Open HIRE and check out the Store tab"}},{id:"ch6-q2",chapter:6,title:"Customize a character",description:"Every role has a pixel art character you can customize — change hair, skin, outfit, and accessories. Click a role in the office view to open their panel, then click the character sprite to enter the customization editor.",type:"main",trigger:{type:"accessory_changed"},rewards:{badge:"explorer",coins:5e3},hint:{target:"hire-btn",message:"Click a team member to customize their look"}},{id:"ch6-q3",chapter:6,title:"Change the office theme",description:"Your office supports multiple visual themes — each changes the color palette, mood, and atmosphere. Click the theme icon in the bottom bar to browse available themes and pick the one that matches your company's vibe.",type:"main",trigger:{type:"theme_changed"},rewards:{badge:"stylist",coins:2e3},hint:{target:"theme-btn",message:"Click the Theme button to change your office look"}},{id:"ch7-q1",chapter:7,title:"Decorate your office",description:"Enter Edit mode to rearrange your office layout. You can drag furniture, place decorations, and create different room zones. Click the EDIT button, then drag items to place them. Click DONE when finished.",type:"main",trigger:{type:"furniture_placed"},rewards:{coins:2e3},hint:{target:"edit-btn",message:"Click EDIT to enter furniture layout mode"}},{id:"ch7-q2",chapter:7,title:"Buy premium furniture",description:"Spend coins earned from quests and achievements to buy premium furniture. Enter Edit mode and browse the furniture shop — each item has a coin price. Premium items add unique visual flair to your office.",type:"main",trigger:{type:"furniture_purchased"},rewards:{badge:"interior-designer",coins:3e3},hint:{target:"edit-btn",message:"Enter EDIT mode and buy furniture with coins"}},{id:"ch8-q1",chapter:8,title:"Review company stats",description:"The Stats panel shows your company's performance metrics — token usage per role, activity levels, role leaderboard, and growth over time. Click the Stats facility in the office to see how your team is performing.",type:"main",trigger:{type:"stats_visited"},rewards:{coins:2e3},hint:{target:"stats-btn",message:"Click Stats to see your company metrics"}},{id:"ch8-q2",chapter:8,title:"Save your progress",description:"Tycono uses git to track all changes your AI team makes. Press Cmd+S (or click the save indicator) to commit your company's current state. Each save creates a git commit — you can view history and even restore previous states.",type:"main",trigger:{type:"save_committed"},rewards:{coins:2e3},hint:{target:"save-btn",message:"Press Cmd+S or click Save to commit changes"}},{id:"ch8-q3",chapter:8,title:"Open Settings",description:"The Settings panel lets you configure your company — adjust API keys, execution engine preferences, and other system options. Click the gear icon in the bottom bar to access it.",type:"main",trigger:{type:"settings_visited"},rewards:{coins:2e3},hint:{target:"settings-btn",message:"Click the Settings gear to configure your company"}},{id:"ch9-q1",chapter:9,title:"Hire a Designer",description:"A Designer handles UI/UX work — wireframes, mockups, and visual design decisions. They complement your Engineer by focusing on the user experience side. Hire one to round out your product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"designer"}},rewards:{coins:2500},hint:{target:"hire-btn",message:"Hire a Designer for your creative team"}},{id:"ch9-q2",chapter:9,title:"Hire a QA Engineer",description:"QA Engineers test your product, find bugs, and ensure quality. They review code changes, write test plans, and validate that features work as expected. Essential for any serious product team.",type:"main",trigger:{type:"role_hired",condition:{roleId:"qa"}},rewards:{coins:3e3},hint:{target:"hire-btn",message:"Hire a QA Engineer for quality assurance"}},{id:"ch9-q3",chapter:9,title:"Build a 5-person team",description:"Growing your team unlocks the full potential of delegation. With 5+ members, your C-Level roles can distribute work across specialized team members, creating a real organizational hierarchy.",type:"main",trigger:{type:"role_hired",condition:{minRoles:5}},rewards:{badge:"growing-company",coins:5e3},hint:{target:"hire-btn",message:"Keep hiring until you have 5+ team members"}},{id:"ch10-q1",chapter:10,title:"Build a 7-person team",description:"A full-size team with diverse roles means your company can handle any challenge. CEO at the top, C-Levels managing domains, and specialists executing. You've built a real AI-powered organization.",type:"main",trigger:{type:"role_hired",condition:{minRoles:7}},rewards:{badge:"tycoon-master",coins:1e4},hint:{target:"hire-btn",message:"Keep hiring until you have 7+ team members"}}],jx=[{num:1,title:"Getting Started",questIds:["ch1-q1","ch1-q2","ch1-q3"]},{num:2,title:"First Project",questIds:["ch2-q1","ch2-q2"]},{num:3,title:"Team Communication",questIds:["ch3-q1","ch3-q2"]},{num:4,title:"Building the Team",questIds:["ch4-q1","ch4-q2","ch4-q3"]},{num:5,title:"Knowledge & Docs",questIds:["ch5-q1","ch5-q2"]},{num:6,title:"Customization",questIds:["ch6-q1","ch6-q2","ch6-q3"]},{num:7,title:"Office Design",questIds:["ch7-q1","ch7-q2"]},{num:8,title:"Operations",questIds:["ch8-q1","ch8-q2","ch8-q3"]},{num:9,title:"Scaling Up",questIds:["ch9-q1","ch9-q2","ch9-q3"]},{num:10,title:"Tycoon Master",questIds:["ch10-q1"]}],e_={completedQuests:[],activeChapter:1,sideQuestsCompleted:[]};function Rv(){return{...e_}}function Cx(e,t){return t.completedQuests.includes(e.id)?"completed":"active"}function G5(e){return fo.filter(t=>Cx(t,e)==="active")}function t_(e){const t=G5(e);return t.find(i=>i.chapter===e.activeChapter)??t[0]??null}function n_(e,t){const n=fo.find(a=>a.id===t);return n?e.completedQuests.includes(t)?{progress:e,quest:null}:{progress:{...e,completedQuests:[...e.completedQuests,t],firstCompletedAt:e.firstCompletedAt??new Date().toISOString()},quest:n}:{progress:e,quest:null}}function zv(e){let t=1;for(const n of jx)if(n.questIds.every(i=>e.completedQuests.includes(i))){const i=jx.find(a=>a.num===n.num+1);i&&(t=i.num)}return t!==e.activeChapter?{...e,activeChapter:t}:e}function r_(e){const t=fo.filter(i=>i.type==="main").length;return{completed:e.completedQuests.filter(i=>{var a;return((a=fo.find(o=>o.id===i))==null?void 0:a.type)==="main"}).length,total:t}}function i_(e,t){if(e.trigger.type!==t.type)return!1;if(e.trigger.condition&&t.condition){for(const[n,i]of Object.entries(e.trigger.condition))if(n==="minRoles"){if(t.condition.roleCount<i)return!1}else if(t.condition[n]!==i)return!1}return!0}function s_({progress:e,onQuestAction:t,onClose:n,terminalWidth:i=0}){const{completed:a,total:o}=r_(e),c=o>0?Math.round(a/o*100):0,{panelRight:d,panelWidth:m,isResizing:f,handleResizeStart:x}=nu(i);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:d},onClick:n}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${f?"resizing":""}`,style:{right:d,width:m,background:"var(--terminal-bg)",borderLeftColor:"var(--desk-wood)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${f?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:x}),l.jsxs("div",{className:"p-5 text-white relative",style:{background:"linear-gradient(135deg, #8B5E3C, #6B4226)"},children:[l.jsx("button",{onClick:n,className:"absolute top-3 right-3 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xl",children:"🐾"}),l.jsxs("div",{children:[l.jsx("div",{className:"text-lg font-bold",children:"Pupu's Quest Board"}),l.jsxs("div",{className:"text-xs opacity-70 mt-0.5",children:[a,"/",o," quests completed · ",c,"%"]})]})]}),l.jsx("div",{className:"mt-3",children:l.jsx("div",{className:"h-2 rounded-full overflow-hidden bg-white/15",children:l.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${c}%`,background:"#F4D03F"}})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-5 flex flex-col gap-3",children:jx.map(p=>{const y=fo.filter(k=>p.questIds.includes(k.id)),g=y.every(k=>e.completedQuests.includes(k.id)),w=y.some(k=>Cx(k,e)==="active");return l.jsxs("div",{className:"rounded-lg",style:{background:w?"var(--hud-bg-alt)":"transparent",border:w?"1px solid var(--accent)":"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[l.jsx("span",{className:"text-sm",children:g?"✅":"🟡"}),l.jsxs("span",{className:"text-sm font-medium",style:{color:w?"var(--accent)":"var(--terminal-text)"},children:["Chapter ",p.num,": ",p.title]})]}),l.jsx("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:y.map(k=>{const j=Cx(k,e);return l.jsxs("div",{className:"flex items-start gap-2 pl-2",children:[l.jsx("span",{className:"text-xs mt-0.5 shrink-0",children:j==="completed"?"☑":"☐"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs",style:{color:j==="completed"?"var(--terminal-text-muted)":"var(--terminal-text)",textDecoration:j==="completed"?"line-through":"none"},children:k.title}),j==="active"&&k.hint&&t&&l.jsx("button",{onClick:()=>t(k.id),className:"shrink-0 text-[10px] px-2 py-0.5 rounded cursor-pointer hover:brightness-125 transition-all",style:{background:"var(--accent)",color:"#000",fontWeight:600},children:"GO →"})]}),j==="active"&&l.jsx("div",{className:"text-[10px] mt-1 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:k.description}),j==="active"&&k.hint&&l.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--accent)"},children:["💡 ",k.hint.message]})]})]},k.id)})})]},p.num)})})]})]})}function a_({projectId:e,onClose:t,terminalWidth:n=0}){const[i,a]=S.useState(null),{panelRight:o,panelWidth:c,isResizing:d,handleResizeStart:m}=nu(n);if(S.useEffect(()=>{ke.getProject(e).then(a).catch(console.error)},[e]),!i)return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:o},onClick:t}),l.jsx("div",{className:"side-panel open fixed top-0 h-full z-50 flex items-center justify-center border-l-[3px] border-[var(--meeting-blue)]",style:{right:o,width:c,background:"var(--terminal-bg)"},children:l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-muted)"},children:"Loading project..."})})]});const f=i.tasks.filter(y=>y.status==="done").length,x=i.tasks.length,p=x>0?Math.round(f/x*100):0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:o},onClick:t}),l.jsxs("div",{className:`side-panel open fixed top-0 h-full z-50 flex flex-col border-l-[3px] border-[var(--meeting-blue)] shadow-[-4px_0_20px_rgba(0,0,0,0.4)] ${d?"resizing":""}`,style:{right:o,width:c,background:"var(--terminal-bg)"},children:[l.jsx("div",{className:`absolute top-0 -left-[5px] w-[10px] h-full cursor-col-resize z-[60] transition-colors ${d?"bg-white/10":"hover:bg-white/5"}`,onMouseDown:m}),l.jsxs("div",{className:"p-5 bg-[var(--meeting-blue)] text-white relative",children:[l.jsx("div",{className:"text-sm opacity-70",children:"Meeting Room"}),l.jsx("button",{onClick:t,className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full bg-white/20 text-white flex items-center justify-center text-lg hover:bg-white/30 cursor-pointer",children:"×"}),l.jsx("div",{className:"text-xl font-bold mt-1",children:i.name}),l.jsxs("div",{className:"flex items-center gap-3 mt-3 text-sm",children:[l.jsxs("span",{children:["Tasks: ",x]}),l.jsxs("span",{children:["Done: ",f]}),l.jsxs("span",{children:["Progress: ",p,"%"]})]}),l.jsx("div",{className:"mt-2 h-1.5 bg-white/20 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-white rounded-full transition-all",style:{width:`${p}%`}})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[i.prd&&l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"PRD"}),l.jsx("div",{className:"rounded-lg p-4 text-xs leading-relaxed max-h-60 overflow-y-auto",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-secondary)"},children:l.jsx(jo,{content:i.prd})})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:["Tasks (",x,")"]}),l.jsx("div",{className:"space-y-2",children:i.tasks.map(y=>l.jsxs("div",{className:"rounded-lg p-3",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm font-medium",style:{color:"var(--terminal-text)"},children:y.title}),l.jsx(l_,{status:y.status})]}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-muted)"},children:y.role}),y.description&&l.jsx("div",{className:"text-xs mt-1.5 line-clamp-2",style:{color:"var(--terminal-text-secondary)"},children:y.description})]},y.id))})]})]})]})]})}function l_({status:e}){const t={done:{bg:"rgba(34,197,94,0.15)",color:"#4ade80"},"in-progress":{bg:"rgba(59,130,246,0.15)",color:"#60a5fa"},todo:{bg:"rgba(148,163,184,0.15)",color:"var(--terminal-text-muted)"}},n=t[e]??t.todo;return l.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:n.bg,color:n.color},children:e})}const o_={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function c_({roleId:e,roleName:t,mode:n="assign",onClose:i,onExecutionStart:a}){const[o,c]=S.useState(""),d=S.useRef(null);S.useEffect(()=>{var p;(p=d.current)==null||p.focus()},[]);const m=()=>{o.trim()&&(a(e,o.trim()),i())},f=p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&m(),p.key==="Escape"&&i()},x=o_[e]??"#666";return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:`linear-gradient(135deg, ${x}, ${x}cc)`},children:[l.jsx("div",{className:"text-lg font-bold",children:n==="ask"?"Ask":"Assign Task"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:n==="ask"?`to ${t}`:`to ${t} (${e})`})]}),l.jsxs("div",{className:"p-5",children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Task Description"}),l.jsx("textarea",{ref:d,value:o,onChange:p=>c(p.target.value),onKeyDown:f,placeholder:n==="ask"?"What would you like to ask?":"Describe the task...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-white/30 mt-1",children:"Cmd+Enter to submit"})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:m,disabled:!o.trim(),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:x},children:n==="ask"?"Ask":"Assign"})]})]})]})}const Bv={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function k0({event:e,isThinkingCollapsed:t,onToggleThinking:n,onNavigateToSession:i,onOpenKnowledgeDoc:a,compact:o}){var d;const c=Bv[e.roleId]??"#888";switch(e.type){case"text":{const m=e.data.text??"",f=o?m.slice(0,300):m;return/[#*|`\[\]_~>-]/.test(f)?l.jsx("div",{className:"text-green-300/90 leading-relaxed event-markdown",children:l.jsx(l0,{remarkPlugins:[d0],children:f})}):l.jsx("div",{className:"text-green-300/90 whitespace-pre-wrap leading-relaxed",children:f})}case"thinking":{const m=e.data.text??"";return l.jsxs("div",{className:"group",children:[l.jsxs("button",{onClick:n,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-[10px] cursor-pointer flex items-center gap-1 select-text",children:[l.jsx("span",{children:t?"▶":"▼"}),l.jsx("span",{className:"italic",children:"thinking..."})]}),!t&&l.jsxs("div",{className:`ml-3 text-[var(--terminal-text-muted)] italic whitespace-pre-wrap opacity-60 text-[11px] overflow-hidden ${o?"max-h-[60px]":"max-h-[120px]"}`,children:[m.slice(0,o?200:500),m.length>(o?200:500)?"...":""]})]})}case"tool:start":{const m=String(e.data.name??""),f=e.data.input,x=typeof(f==null?void 0:f.command)=="string"?f.command.slice(0,80):"",p=typeof(f==null?void 0:f.file_path)=="string"?String(f.file_path):typeof(f==null?void 0:f.path)=="string"?String(f.path):"",y=p?p.split("/").pop()??"":"",g=/^(write_file|Write|edit_file|Edit)$/i.test(m),w=(d=p.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:d[1],k=g&&w&&a;return l.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[l.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${k?"text-green-400/80 bg-green-400/10":"text-blue-400/80 bg-blue-400/10"}`,children:k?g&&m.toLowerCase().includes("edit")?"Edit":"Write":m}),k?l.jsx("button",{onClick:()=>a(w),className:"text-[10px] text-green-400 hover:text-green-300 underline underline-offset-2 cursor-pointer truncate",style:{maxWidth:o?200:400},children:y}):l.jsxs(l.Fragment,{children:[x&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${o?"max-w-[200px]":"max-w-[400px]"}`,children:x}),y&&l.jsx("span",{className:`text-[var(--terminal-text-muted)] text-[10px] truncate ${o?"max-w-[200px]":"max-w-[400px]"}`,children:y})]})]})}case"dispatch:start":{const m=e.data.targetRoleId??e.data.roleId??"",f=e.data.task??"",x=e.data.childSessionId,p=Bv[m]??"#888";return l.jsx("div",{className:"my-1 p-2 rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",style:{borderColor:`${p}44`,background:`${p}11`},onClick:()=>x&&(i==null?void 0:i(x)),children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{style:{color:p},className:"font-bold text-[11px]",children:["→"," ",m.toUpperCase()]}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] text-[10px] truncate flex-1",children:f.slice(0,o?60:100)}),x&&i&&l.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-[var(--terminal-text-muted)]",children:["View ","→"]})]})})}case"dispatch:done":return l.jsx("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pl-3 border-l-2 border-[var(--terminal-border)] my-0.5",children:"Dispatch completed"});case"msg:turn-complete":return l.jsx("div",{className:"border-t border-[var(--terminal-border)] my-2 relative",children:l.jsxs("span",{className:"absolute -top-2 left-2 bg-[var(--terminal-bg)] px-2 text-[9px] text-[var(--terminal-text-muted)]",children:["Turn ",e.data.turn]})});case"stderr":return l.jsxs("div",{className:"text-red-400/80 text-[11px]",children:["⚠"," ",e.data.message]});case"msg:start":return l.jsxs("div",{className:"text-[var(--terminal-text-muted)] text-[10px] pb-1",children:[l.jsx("span",{style:{color:c},className:"font-bold",children:e.roleId.toUpperCase()})," ","started: ",(e.data.task??"").slice(0,o?50:80)]});case"msg:done":{const m=e.data.turns??0,f=e.data.toolCalls??0;return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-green-900/20 border border-green-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),l.jsx("span",{className:"text-green-300 font-bold text-[11px]",children:"Complete"}),l.jsxs("span",{className:"text-[var(--terminal-text-muted)] text-[10px]",children:[m," turns · ",f," tools"]})]})})}case"msg:error":return l.jsx("div",{className:"mt-2 p-2 rounded-lg bg-red-900/20 border border-red-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400"}),l.jsx("span",{className:"text-red-300 font-bold text-[11px]",children:"Error"}),l.jsx("span",{className:"text-red-200/70 text-[10px]",children:e.data.message})]})});case"msg:awaiting_input":{const m=e.data.question??"";return l.jsxs("div",{className:"mt-2 p-2 rounded-lg border",style:{background:"#F59E0B11",borderColor:"#F59E0B33"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsx("span",{className:"font-bold text-[11px]",style:{color:"#F59E0B"},children:"Awaiting Reply"})]}),m&&l.jsx("div",{className:"mt-1 text-[11px] text-[var(--terminal-text)] whitespace-pre-wrap",children:m})]})}case"msg:reply":return l.jsx("div",{className:"mt-1 p-2 rounded-lg bg-blue-900/20 border border-blue-800/30",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-blue-300 font-bold text-[11px]",children:"CEO replied:"}),l.jsx("span",{className:"text-blue-200/80 text-[11px]",children:e.data.response??""})]})});case"import:scan":case"import:process":case"import:created":return l.jsxs("div",{className:"text-cyan-300/70 text-[11px]",children:["[",e.type,"] ",JSON.stringify(e.data)]});default:return null}}function u_({sessionId:e,title:t,color:n,variant:i,style:a,onClose:o,onMinimize:c,onDone:d,onNavigateToSession:m,onOpenKnowledgeDoc:f}){const{events:x,status:p,textOutput:y,childSessionIds:g}=b2(e),[w,k]=S.useState(0),[j,C]=S.useState(new Set),N=S.useRef(null),E=S.useRef(Date.now()),A=S.useRef(!1);S.useEffect(()=>{const _=setInterval(()=>{k(Math.floor((Date.now()-E.current)/1e3))},1e3);return()=>clearInterval(_)},[]),S.useEffect(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)},[x]),S.useEffect(()=>{(p==="done"||p==="error")&&!A.current&&(A.current=!0,d==null||d())},[p,d]);const z=_=>{C(B=>{const X=new Set(B);return X.has(_)?X.delete(_):X.add(_),X})},D={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[p],F={idle:"#888",connecting:"#888",streaming:n,done:"#2E7D32",error:"#C62828"}[p],q=_=>`${Math.floor(_/60)}:${String(_%60).padStart(2,"0")}`,V=p==="done"||p==="error",L=l.jsxs("div",{className:i==="modal"?"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col":"bg-[var(--terminal-bg)] rounded-xl border border-[var(--terminal-border)] overflow-hidden flex flex-col max-h-[400px]",style:a,children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full animate-pulse",style:{background:F}}),l.jsx("div",{children:l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:t})})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:q(w)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${F}22`,color:F},children:D}),c&&i==="modal"&&l.jsx("button",{onClick:c,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),V&&l.jsx("button",{onClick:o,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",children:"×"})]})]}),l.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto p-4 space-y-1 text-xs font-mono",children:[x.length===0&&p==="connecting"&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:"Connecting to activity stream..."}),x.map(_=>l.jsx(k0,{event:_,isThinkingCollapsed:j.has(_.seq),onToggleThinking:()=>z(_.seq),onNavigateToSession:m,onOpenKnowledgeDoc:f},_.seq)),p==="streaming"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),l.jsxs("div",{className:"px-5 py-3 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[l.jsxs("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[x.length>0&&`${x.length} events`,y.length>0&&` · ${y.length} chars`,g.length>0&&` · ${g.length} dispatches`]}),V&&l.jsx("button",{onClick:o,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer",style:{background:n},children:"Close"})]})]});return i==="modal"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:V?o:void 0}),L]}):L}const d_={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function f_({orgNodes:e,rootId:t,activeRoles:n,onToggleRole:i}){const a=e[t];if(!a)return null;const o=!!n&&!!i,d=a.children.map(g=>e[g]).filter(Boolean),m=new Map,f=[];for(const g of d){const w=[];for(const k of g.children){const j=e[k];j&&(w.push(j),f.push(j))}m.set(g.id,w)}const x=g=>!n||n.has(g),p=o?d.filter(g=>n.has(g.id)).length+f.filter(g=>n.has(g.id)).length:d.length+f.length,y=d.length+f.length;return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider",children:o?"Select Target Roles":"Propagation Preview"}),o&&l.jsxs("span",{className:"text-[10px] text-white/50",children:[p,"/",y," selected"]})]}),l.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[l.jsx("div",{className:"flex justify-center mb-2",children:l.jsx("span",{className:"px-3 py-1 text-[10px] font-bold rounded border-2 border-white/20 bg-white/5 text-white/30 uppercase",children:"CEO"})}),d.length>0&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-3 bg-white/15"})}),d.length>1&&l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"h-px bg-white/15",style:{width:`${Math.min(d.length*80,320)}px`}})}),l.jsx("div",{className:"flex justify-center gap-3 mb-2 flex-wrap",children:d.map(g=>{const w=x(g.id),k=d_[g.id]??"#888";return l.jsx(h_,{node:g,active:w,color:k,interactive:o,onToggle:i,subRoles:m.get(g.id)??[],activeRoles:n},g.id)})}),f.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex justify-center mb-1",children:l.jsx("div",{className:"w-px h-2 bg-white/10"})}),l.jsx("div",{className:"flex justify-center gap-2 flex-wrap",children:f.map(g=>{var N;const w=x(g.id),k=(N=d.find(E=>E.children.includes(g.id)))==null?void 0:N.id,j=k?x(k):!0,C=o&&j;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${C?"cursor-pointer select-none":o?"cursor-not-allowed":""} ${w&&j?"border-white/15 text-white/40":"border-white/5 text-white/15 opacity-50"}`,onClick:C?()=>i(g.id,!w):void 0,title:o?j?w?"Click to exclude":"Click to include":`Enable ${k==null?void 0:k.toUpperCase()} first`:void 0,children:g.id},g.id)})}),l.jsx("div",{className:"text-center text-[8px] text-white/30 mt-1",children:"via re-dispatch"})]})]}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1.5",children:o?`${p} role${p!==1?"s":""} will receive this wave`:`${y} role${y!==1?"s":""} will receive this wave`})]})}function h_({node:e,active:t,color:n,interactive:i,onToggle:a,subRoles:o,activeRoles:c}){const d=S.useCallback(m=>{if(!(!i||!a)){if(t){a(e.id,!1);for(const f of o)c!=null&&c.has(f.id)&&a(f.id,!1)}else if(a(e.id,!0),m.shiftKey)for(const f of o)c!=null&&c.has(f.id)||a(f.id,!0)}},[i,a,t,e.id,o,c]);return l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx("span",{className:`px-2.5 py-1 text-[10px] font-bold rounded border-2 uppercase transition-all ${i?"cursor-pointer select-none hover:scale-105":""}`,style:{borderColor:t?n:`${n}44`,color:t?n:`${n}44`,background:t?`${n}22`:"transparent",opacity:t?1:.4},onClick:d,title:i?t?"Click to exclude (disables subordinates)":"Click to include / Shift+click to include with all subordinates":void 0,children:e.id}),l.jsx("span",{className:"text-[8px] text-white/30 mt-0.5",children:i?t?"active":"off":"direct"})]})}function m_({cLevelRoles:e,orgNodes:t,rootId:n,onClose:i,onDispatch:a}){const[o,c]=S.useState(""),d=S.useRef(null),[m,f]=S.useState(()=>{const k=new Set,j=t[n];if(j)for(const C of j.children){k.add(C);const N=t[C];if(N)for(const E of N.children)k.add(E)}return k});S.useEffect(()=>{var k;(k=d.current)==null||k.focus()},[]);const x=S.useCallback((k,j)=>{f(C=>{const N=new Set(C);return j?N.add(k):N.delete(k),N})},[]),p=e.filter(k=>m.has(k.id)).length,y=()=>{if(!o.trim()||p===0)return;const k=t[n];let j=0;if(k)for(const E of k.children){j++;const A=t[E];A&&(j+=A.children.length)}const N=m.size>=j?void 0:Array.from(m);a(o.trim(),N),i()},g=k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&y(),k.key==="Escape"&&i()},w=n&&Object.keys(t).length>0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:i}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsx("div",{className:"text-lg font-bold",children:"CEO Wave"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:w?"Select target roles and broadcast a directive":"Broadcast a directive to all C-Level reports"})]}),l.jsxs("div",{className:"p-5 space-y-4",children:[w&&l.jsx(f_,{orgNodes:t,rootId:n,activeRoles:m,onToggleRole:x}),!w&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Dispatching to"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:e.length>0?e.map(k=>l.jsxs("span",{className:"px-3 py-1.5 text-xs font-semibold rounded-lg border-2 border-red-200 bg-red-50 text-red-800",children:[k.id.toUpperCase()," · ",k.name]},k.id)):l.jsx("span",{className:"text-xs text-gray-400 italic",children:"No C-Level roles found"})}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Each C-Level receives the directive and delegates to their reports"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Directive"}),l.jsx("textarea",{ref:d,value:o,onChange:k=>c(k.target.value),onKeyDown:g,placeholder:"e.g. Report current status across all departments",className:"w-full h-28 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Cmd+Enter to dispatch"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:i,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),l.jsxs("button",{onClick:y,disabled:!o.trim()||p===0,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:["Dispatch to ",p," Role",p!==1?"s":""]})]})]})]})}function p_(){const e=S.useRef(null),t=S.useRef(0),n=S.useCallback((a,o,c)=>{e.current&&e.current.abort();const d=new AbortController;e.current=d,t.current=0;const f=`/api/waves/${a}/stream?from=0`;fetch(f,{signal:d.signal}).then(async x=>{if(!x.ok||!x.body){console.error(`[WaveStream] Failed to connect: ${x.status}`);return}console.log(`[WaveStream] Connected to wave=${a}`);const p=x.body.getReader(),y=new TextDecoder;let g="",w="",k=Date.now();const j=6e4,C=setInterval(()=>{Date.now()-k>j&&(console.warn("[WaveStream] Stale connection — no data for 60s"),d.abort(),clearInterval(C))},1e4);try{for(;;){const{done:N,value:E}=await p.read();if(N)break;k=Date.now(),g+=y.decode(E,{stream:!0});const A=g.split(`
89
+ `);g=A.pop()??"";for(const z of A)if(z.startsWith("event: "))w=z.slice(7).trim();else if(z.startsWith("data: ")){try{const D=JSON.parse(z.slice(6));x_(w,D,o,c)}catch{}w=""}}}finally{clearInterval(C)}}).catch(x=>{x.name!=="AbortError"&&console.error("[WaveStream] Connection error:",x)})},[]),i=S.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{connectWaveStream:n,disconnectWaveStream:i}}function x_(e,t,n,i){switch(e){case"wave:event":g_(t,n);break;case"wave:role-attached":y_(t,n,i);break;case"wave:role-detached":b_(t,n);break;case"wave:done":v_(n);break}}function g_(e,t){const{event:n,sessionId:i}=e,{roleId:a}=n;t(o=>{const c=new Map(o),d=c.get(a);if(!d||d.events.some(f=>f.seq===n.seq&&f.roleId===n.roleId))return o;const m={...d,sessionId:i||d.sessionId,events:[...d.events,n]};return n.type==="msg:start"?(m.status="streaming",m.streamStatus="streaming"):n.type==="msg:done"?(m.status="done",m.streamStatus="done"):n.type==="msg:error"?(m.status="error",m.streamStatus="error"):n.type==="msg:awaiting_input"?(m.status="awaiting_input",m.streamStatus="done"):n.type==="msg:reply"&&(m.status="streaming",m.streamStatus="streaming"),c.set(a,m),c})}function y_(e,t,n){const{sessionId:i,roleId:a}=e;t(o=>{const c=new Map(o),d=c.get(a);if(d)if(i!==d.sessionId&&!!d.sessionId)c.set(a,{...d,sessionId:i,status:"streaming",streamStatus:"streaming",events:[]});else{const f=d.status==="awaiting_input"||d.status==="done"||d.status==="error";c.set(a,{...d,sessionId:i,status:f?d.status:"streaming",streamStatus:f?d.streamStatus:"streaming"})}else{const m=n[a];c.set(a,{sessionId:i,roleId:a,roleName:(m==null?void 0:m.name)??a,children:(m==null?void 0:m.children)??[],status:"streaming",events:[],streamStatus:"streaming"})}return c})}function b_(e,t){const{roleId:n,reason:i}=e,a=i==="error"?"error":"done";t(o=>{const c=new Map(o),d=c.get(n);return!d||d.status==="done"||d.status==="error"?o:(c.set(n,{...d,status:a,streamStatus:a==="error"?"error":"done"}),c)})}function v_(e){e(t=>{const n=new Map(t);let i=!1;for(const[a,o]of n)o.status==="waiting"&&(n.set(a,{...o,status:"not-dispatched"}),i=!0);return i?n:t})}function K5(e,t,n,i){const[a,o]=S.useState(new Map),[c,d]=S.useState(null),[m,f]=S.useState(new Set),x=S.useRef(new Map),p=S.useRef(a);p.current=a;const y=S.useRef(!1),{connectWaveStream:g,disconnectWaveStream:w}=p_(),k=S.useCallback(()=>{if(!n||Object.keys(t).length===0)return null;const _=new Map,B=new Set,X=H=>{const $=t[H];$&&(B.add(H),_.set(H,{sessionId:"",roleId:H,roleName:$.name,children:$.children,status:"waiting",events:[],streamStatus:"idle"}),$.children.forEach(X))},R=t[n];return R&&(_.set(n,{sessionId:"",roleId:n,roleName:"CEO",children:R.children,status:"not-dispatched",events:[],streamStatus:"idle"}),R.children.forEach(X)),{initial:_,allRoles:B}},[t,n]),j=S.useRef(!1);S.useEffect(()=>{if(y.current)if(e.length>0)y.current=!1;else return;if(e.length===0&&j.current&&p.current.size>0)return;j.current=e.length>0;const _=k();if(!_)return;const{initial:B,allRoles:X}=_;for(const R of e){const H=B.get(R.roleId);H&&(H.sessionId=R.sessionId,H.status="streaming",H.streamStatus="connecting")}o(B),f(R=>{if(R.size===0){const H=new Set(X);return H.delete(n),H}return R}),e.length>0&&d(R=>R??e[0].roleId)},[e,t,n,k]);const C=S.useCallback(_=>{f(B=>{const X=new Set(B);return X.has(_)?X.delete(_):X.add(_),X})},[]),N=S.useCallback(_=>{for(const[,B]of x.current)B.controller.abort();x.current.clear(),y.current=!0,o(_);for(const[B,X]of _)if(B!==n&&X.events.length>0){d(B);break}},[n]),E=S.useCallback((_,B)=>{const X=x.current.get(_);if(X&&!X.controller.signal.aborted){console.log(`[WaveTree] connectStream SKIP (already connected) → role=${B} session=${_}`);return}X&&X.controller.abort(),console.log(`[WaveTree] connectStream → role=${B} session=${_}`),o(G=>{const Q=new Map(G),K=Q.get(B);return K&&Q.set(B,{...K,sessionId:_,status:"streaming",streamStatus:"connecting",events:[]}),Q});const R=new AbortController,H={controller:R,lastSeq:-1};x.current.set(_,H);const $=`/api/sessions/${_}/stream?from=0`;fetch($,{signal:R.signal}).then(async G=>{if(!G.ok||!G.body){o(P=>{const O=new Map(P),Z=O.get(B);return Z&&O.set(B,{...Z,streamStatus:"error"}),O});return}console.log(`[WaveTree SSE] connected → role=${B} status=${G.status}`),o(P=>{const O=new Map(P),Z=O.get(B);return Z&&O.set(B,{...Z,streamStatus:"streaming",status:"streaming"}),O});const Q=G.body.getReader(),K=new TextDecoder;let M="",U="";for(;;){const{done:P,value:O}=await Q.read();if(P){R.abort();break}M+=K.decode(O,{stream:!0});const Z=M.split(`
90
+ `);M=Z.pop()??"";for(const ee of Z)if(ee.startsWith("event: "))U=ee.slice(7).trim();else if(ee.startsWith("data: ")){try{const J=JSON.parse(ee.slice(6));if(console.log(`[WaveTree SSE] role=${B} event=${U} type=${(J==null?void 0:J.type)??"?"} seq=${(J==null?void 0:J.seq)??"?"}`),U==="activity"){const se=J;se.seq>H.lastSeq&&(H.lastSeq=se.seq),o(le=>{const ye=new Map(le),De=ye.get(B);if(!De||De.events.some(Re=>Re.seq===se.seq))return le;const Ee={...De,events:[...De.events,se]};if(se.type==="dispatch:start"&&se.data.childSessionId){const Re=se.data.targetRoleId??se.data.roleId,me=se.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${Re} childSession=${me??"none"} from=${B}`),Re&&me){const Fe=ye.get(Re);Fe&&(ye.set(Re,{...Fe,sessionId:me,status:"streaming",streamStatus:"connecting"}),setTimeout(()=>E(me,Re),0))}}return se.type==="msg:done"?(Ee.status="done",Ee.streamStatus="done"):se.type==="msg:error"?(Ee.status="error",Ee.streamStatus="error"):se.type==="msg:awaiting_input"?(Ee.status="awaiting_input",Ee.streamStatus="done"):se.type==="msg:reply"&&(Ee.status="streaming",Ee.streamStatus="streaming"),ye.set(B,Ee),ye})}else if(U==="stream:end"){const se=J.reason;se!=="replied"&&o(le=>{const ye=new Map(le),De=ye.get(B);if(!De)return le;const Ee=se==="error"?"error":se==="awaiting_input"?"awaiting_input":"done";return ye.set(B,{...De,status:De.status==="streaming"?Ee:De.status,streamStatus:Ee==="error"?"error":"done"}),ye})}}catch{}U=""}}}).catch(G=>{G.name!=="AbortError"&&o(Q=>{const K=new Map(Q),M=K.get(B);return M&&K.set(B,{...M,streamStatus:"error"}),K})})},[]),A=S.useRef(new Set),z=S.useRef(!1),D=S.useRef(t);D.current=t;const F=S.useRef(e);F.current=e,S.useEffect(()=>{if(!(!i||F.current.length===0))return z.current=!0,g(i,o,D.current),()=>{w(),z.current=!1}},[i,g,w]),S.useEffect(()=>{if(i||e.length===0)return;z.current=!1;const _=new Set;for(const B of e)_.add(B.sessionId),E(B.sessionId,B.roleId);return A.current=_,()=>{for(const B of A.current){const X=x.current.get(B);X&&(X.controller.abort(),x.current.delete(B))}A.current.clear()}},[e,E,i]);const q=(()=>{let _=0,B=0,X=0,R=0;for(const[H,$]of a)H!==n&&(R++,$.status==="done"?_++:$.status==="streaming"?B++:$.status==="awaiting_input"&&X++);return{done:_,total:R,running:B,awaitingInput:X}})(),V=q.total>0&&q.done>0&&q.running===0&&q.awaitingInput===0&&Array.from(a.values()).every(_=>!Na(_.status)&&_.streamStatus!=="streaming"&&_.streamStatus!=="connecting");S.useEffect(()=>{V&&o(_=>{const B=new Map(_);let X=!1;for(const[R,H]of B)H.status==="waiting"&&(B.set(R,{...H,status:"not-dispatched"}),X=!0);return X?B:_})},[V]);const L=S.useCallback(()=>{for(const[,B]of x.current)B.controller.abort();x.current.clear(),y.current=!1;const _=k();if(_){o(_.initial);const B=new Set(_.allRoles);B.delete(n),f(B)}d(n)},[k,n]);return{nodes:a,selectedRoleId:c,selectNode:d,checkedRoles:m,toggleCheck:C,setCheckedRoles:f,progress:q,allDone:V,connectStream:E,injectStaticNodes:N,reset:L}}function Yn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=Yn(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Nx="http://www.w3.org/1999/xhtml";const $v={svg:"http://www.w3.org/2000/svg",xhtml:Nx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function qf(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),$v.hasOwnProperty(t)?{space:$v[t],local:e}:e}function w_(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Nx&&t.documentElement.namespaceURI===Nx?t.createElement(e):t.createElementNS(n,e)}}function k_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Q5(e){var t=qf(e);return(t.local?k_:w_)(t)}function S_(){}function S0(e){return e==null?S_:function(){return this.querySelector(e)}}function j_(e){typeof e!="function"&&(e=S0(e));for(var t=this._groups,n=t.length,i=new Array(n),a=0;a<n;++a)for(var o=t[a],c=o.length,d=i[a]=new Array(c),m,f,x=0;x<c;++x)(m=o[x])&&(f=e.call(m,m.__data__,x,o))&&("__data__"in m&&(f.__data__=m.__data__),d[x]=f);return new Gr(i,this._parents)}function C_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function N_(){return[]}function Z5(e){return e==null?N_:function(){return this.querySelectorAll(e)}}function E_(e){return function(){return C_(e.apply(this,arguments))}}function A_(e){typeof e=="function"?e=E_(e):e=Z5(e);for(var t=this._groups,n=t.length,i=[],a=[],o=0;o<n;++o)for(var c=t[o],d=c.length,m,f=0;f<d;++f)(m=c[f])&&(i.push(e.call(m,m.__data__,f,c)),a.push(m));return new Gr(i,a)}function J5(e){return function(){return this.matches(e)}}function ek(e){return function(t){return t.matches(e)}}var D_=Array.prototype.find;function T_(e){return function(){return D_.call(this.children,e)}}function __(){return this.firstElementChild}function M_(e){return this.select(e==null?__:T_(typeof e=="function"?e:ek(e)))}var F_=Array.prototype.filter;function R_(){return Array.from(this.children)}function z_(e){return function(){return F_.call(this.children,e)}}function B_(e){return this.selectAll(e==null?R_:z_(typeof e=="function"?e:ek(e)))}function $_(e){typeof e!="function"&&(e=J5(e));for(var t=this._groups,n=t.length,i=new Array(n),a=0;a<n;++a)for(var o=t[a],c=o.length,d=i[a]=[],m,f=0;f<c;++f)(m=o[f])&&e.call(m,m.__data__,f,o)&&d.push(m);return new Gr(i,this._parents)}function tk(e){return new Array(e.length)}function O_(){return new Gr(this._enter||this._groups.map(tk),this._parents)}function Cf(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Cf.prototype={constructor:Cf,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function L_(e){return function(){return e}}function I_(e,t,n,i,a,o){for(var c=0,d,m=t.length,f=o.length;c<f;++c)(d=t[c])?(d.__data__=o[c],i[c]=d):n[c]=new Cf(e,o[c]);for(;c<m;++c)(d=t[c])&&(a[c]=d)}function H_(e,t,n,i,a,o,c){var d,m,f=new Map,x=t.length,p=o.length,y=new Array(x),g;for(d=0;d<x;++d)(m=t[d])&&(y[d]=g=c.call(m,m.__data__,d,t)+"",f.has(g)?a[d]=m:f.set(g,m));for(d=0;d<p;++d)g=c.call(e,o[d],d,o)+"",(m=f.get(g))?(i[d]=m,m.__data__=o[d],f.delete(g)):n[d]=new Cf(e,o[d]);for(d=0;d<x;++d)(m=t[d])&&f.get(y[d])===m&&(a[d]=m)}function U_(e){return e.__data__}function q_(e,t){if(!arguments.length)return Array.from(this,U_);var n=t?H_:I_,i=this._parents,a=this._groups;typeof e!="function"&&(e=L_(e));for(var o=a.length,c=new Array(o),d=new Array(o),m=new Array(o),f=0;f<o;++f){var x=i[f],p=a[f],y=p.length,g=Y_(e.call(x,x&&x.__data__,f,i)),w=g.length,k=d[f]=new Array(w),j=c[f]=new Array(w),C=m[f]=new Array(y);n(x,p,k,j,C,g,t);for(var N=0,E=0,A,z;N<w;++N)if(A=k[N]){for(N>=E&&(E=N+1);!(z=j[E])&&++E<w;);A._next=z||null}}return c=new Gr(c,i),c._enter=d,c._exit=m,c}function Y_(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function P_(){return new Gr(this._exit||this._groups.map(tk),this._parents)}function X_(e,t,n){var i=this.enter(),a=this,o=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),n==null?o.remove():n(o),i&&a?i.merge(a).order():a}function V_(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,a=n.length,o=i.length,c=Math.min(a,o),d=new Array(a),m=0;m<c;++m)for(var f=n[m],x=i[m],p=f.length,y=d[m]=new Array(p),g,w=0;w<p;++w)(g=f[w]||x[w])&&(y[w]=g);for(;m<a;++m)d[m]=n[m];return new Gr(d,this._parents)}function W_(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],a=i.length-1,o=i[a],c;--a>=0;)(c=i[a])&&(o&&c.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(c,o),o=c);return this}function G_(e){e||(e=K_);function t(p,y){return p&&y?e(p.__data__,y.__data__):!p-!y}for(var n=this._groups,i=n.length,a=new Array(i),o=0;o<i;++o){for(var c=n[o],d=c.length,m=a[o]=new Array(d),f,x=0;x<d;++x)(f=c[x])&&(m[x]=f);m.sort(t)}return new Gr(a,this._parents).order()}function K_(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Q_(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Z_(){return Array.from(this)}function J_(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],a=0,o=i.length;a<o;++a){var c=i[a];if(c)return c}return null}function eM(){let e=0;for(const t of this)++e;return e}function tM(){return!this.node()}function nM(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var a=t[n],o=0,c=a.length,d;o<c;++o)(d=a[o])&&e.call(d,d.__data__,o,a);return this}function rM(e){return function(){this.removeAttribute(e)}}function iM(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sM(e,t){return function(){this.setAttribute(e,t)}}function aM(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lM(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function oM(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function cM(e,t){var n=qf(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?iM:rM:typeof t=="function"?n.local?oM:lM:n.local?aM:sM)(n,t))}function nk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function uM(e){return function(){this.style.removeProperty(e)}}function dM(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fM(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function hM(e,t,n){return arguments.length>1?this.each((t==null?uM:typeof t=="function"?fM:dM)(e,t,n??"")):ho(this.node(),e)}function ho(e,t){return e.style.getPropertyValue(t)||nk(e).getComputedStyle(e,null).getPropertyValue(t)}function mM(e){return function(){delete this[e]}}function pM(e,t){return function(){this[e]=t}}function xM(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function gM(e,t){return arguments.length>1?this.each((t==null?mM:typeof t=="function"?xM:pM)(e,t)):this.node()[e]}function rk(e){return e.trim().split(/^|\s+/)}function j0(e){return e.classList||new ik(e)}function ik(e){this._node=e,this._names=rk(e.getAttribute("class")||"")}ik.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function sk(e,t){for(var n=j0(e),i=-1,a=t.length;++i<a;)n.add(t[i])}function ak(e,t){for(var n=j0(e),i=-1,a=t.length;++i<a;)n.remove(t[i])}function yM(e){return function(){sk(this,e)}}function bM(e){return function(){ak(this,e)}}function vM(e,t){return function(){(t.apply(this,arguments)?sk:ak)(this,e)}}function wM(e,t){var n=rk(e+"");if(arguments.length<2){for(var i=j0(this.node()),a=-1,o=n.length;++a<o;)if(!i.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?vM:t?yM:bM)(n,t))}function kM(){this.textContent=""}function SM(e){return function(){this.textContent=e}}function jM(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function CM(e){return arguments.length?this.each(e==null?kM:(typeof e=="function"?jM:SM)(e)):this.node().textContent}function NM(){this.innerHTML=""}function EM(e){return function(){this.innerHTML=e}}function AM(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function DM(e){return arguments.length?this.each(e==null?NM:(typeof e=="function"?AM:EM)(e)):this.node().innerHTML}function TM(){this.nextSibling&&this.parentNode.appendChild(this)}function _M(){return this.each(TM)}function MM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function FM(){return this.each(MM)}function RM(e){var t=typeof e=="function"?e:Q5(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function zM(){return null}function BM(e,t){var n=typeof e=="function"?e:Q5(e),i=t==null?zM:typeof t=="function"?t:S0(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function $M(){var e=this.parentNode;e&&e.removeChild(this)}function OM(){return this.each($M)}function LM(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function IM(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function HM(e){return this.select(e?IM:LM)}function UM(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qM(e){return function(t){e.call(this,t,this.__data__)}}function YM(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function PM(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,a=t.length,o;n<a;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++i]=o;++i?t.length=i:delete this.__on}}}function XM(e,t,n){return function(){var i=this.__on,a,o=qM(t);if(i){for(var c=0,d=i.length;c<d;++c)if((a=i[c]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=o,a.options=n),a.value=t;return}}this.addEventListener(e.type,o,n),a={type:e.type,name:e.name,value:t,listener:o,options:n},i?i.push(a):this.__on=[a]}}function VM(e,t,n){var i=YM(e+""),a,o=i.length,c;if(arguments.length<2){var d=this.node().__on;if(d){for(var m=0,f=d.length,x;m<f;++m)for(a=0,x=d[m];a<o;++a)if((c=i[a]).type===x.type&&c.name===x.name)return x.value}return}for(d=t?XM:PM,a=0;a<o;++a)this.each(d(i[a],t,n));return this}function lk(e,t,n){var i=nk(e),a=i.CustomEvent;typeof a=="function"?a=new a(t,n):(a=i.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function WM(e,t){return function(){return lk(this,e,t)}}function GM(e,t){return function(){return lk(this,e,t.apply(this,arguments))}}function KM(e,t){return this.each((typeof t=="function"?GM:WM)(e,t))}function*QM(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],a=0,o=i.length,c;a<o;++a)(c=i[a])&&(yield c)}var ok=[null];function Gr(e,t){this._groups=e,this._parents=t}function ru(){return new Gr([[document.documentElement]],ok)}function ZM(){return this}Gr.prototype=ru.prototype={constructor:Gr,select:j_,selectAll:A_,selectChild:M_,selectChildren:B_,filter:$_,data:q_,enter:O_,exit:P_,join:X_,merge:V_,selection:ZM,order:W_,sort:G_,call:Q_,nodes:Z_,node:J_,size:eM,empty:tM,each:nM,attr:cM,style:hM,property:gM,classed:wM,text:CM,html:DM,raise:_M,lower:FM,append:RM,insert:BM,remove:OM,clone:HM,datum:UM,on:VM,dispatch:KM,[Symbol.iterator]:QM};function Vr(e){return typeof e=="string"?new Gr([[document.querySelector(e)]],[document.documentElement]):new Gr([[e]],ok)}function JM(e){let t;for(;t=e.sourceEvent;)e=t;return e}function wi(e,t){if(e=JM(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const eF={passive:!1},Uc={capture:!0,passive:!1};function Sp(e){e.stopImmediatePropagation()}function ao(e){e.preventDefault(),e.stopImmediatePropagation()}function ck(e){var t=e.document.documentElement,n=Vr(e).on("dragstart.drag",ao,Uc);"onselectstart"in t?n.on("selectstart.drag",ao,Uc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function uk(e,t){var n=e.document.documentElement,i=Vr(e).on("dragstart.drag",null);t&&(i.on("click.drag",ao,Uc),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Od=e=>()=>e;function Ex(e,{sourceEvent:t,subject:n,target:i,identifier:a,active:o,x:c,y:d,dx:m,dy:f,dispatch:x}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:d,enumerable:!0,configurable:!0},dx:{value:m,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:x}})}Ex.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tF(e){return!e.ctrlKey&&!e.button}function nF(){return this.parentNode}function rF(e,t){return t??{x:e.x,y:e.y}}function iF(){return navigator.maxTouchPoints||"ontouchstart"in this}function dk(){var e=tF,t=nF,n=rF,i=iF,a={},o=tu("start","drag","end"),c=0,d,m,f,x,p=0;function y(A){A.on("mousedown.drag",g).filter(i).on("touchstart.drag",j).on("touchmove.drag",C,eF).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(A,z){if(!(x||!e.call(this,A,z))){var D=E(this,t.call(this,A,z),A,z,"mouse");D&&(Vr(A.view).on("mousemove.drag",w,Uc).on("mouseup.drag",k,Uc),ck(A.view),Sp(A),f=!1,d=A.clientX,m=A.clientY,D("start",A))}}function w(A){if(ao(A),!f){var z=A.clientX-d,D=A.clientY-m;f=z*z+D*D>p}a.mouse("drag",A)}function k(A){Vr(A.view).on("mousemove.drag mouseup.drag",null),uk(A.view,f),ao(A),a.mouse("end",A)}function j(A,z){if(e.call(this,A,z)){var D=A.changedTouches,F=t.call(this,A,z),q=D.length,V,L;for(V=0;V<q;++V)(L=E(this,F,A,z,D[V].identifier,D[V]))&&(Sp(A),L("start",A,D[V]))}}function C(A){var z=A.changedTouches,D=z.length,F,q;for(F=0;F<D;++F)(q=a[z[F].identifier])&&(ao(A),q("drag",A,z[F]))}function N(A){var z=A.changedTouches,D=z.length,F,q;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),F=0;F<D;++F)(q=a[z[F].identifier])&&(Sp(A),q("end",A,z[F]))}function E(A,z,D,F,q,V){var L=o.copy(),_=wi(V||D,z),B,X,R;if((R=n.call(A,new Ex("beforestart",{sourceEvent:D,target:y,identifier:q,active:c,x:_[0],y:_[1],dx:0,dy:0,dispatch:L}),F))!=null)return B=R.x-_[0]||0,X=R.y-_[1]||0,function H($,G,Q){var K=_,M;switch($){case"start":a[q]=H,M=c++;break;case"end":delete a[q],--c;case"drag":_=wi(Q||G,z),M=c;break}L.call($,A,new Ex($,{sourceEvent:G,subject:R,target:y,identifier:q,active:M,x:_[0]+B,y:_[1]+X,dx:_[0]-K[0],dy:_[1]-K[1],dispatch:L}),F)}}return y.filter=function(A){return arguments.length?(e=typeof A=="function"?A:Od(!!A),y):e},y.container=function(A){return arguments.length?(t=typeof A=="function"?A:Od(A),y):t},y.subject=function(A){return arguments.length?(n=typeof A=="function"?A:Od(A),y):n},y.touchable=function(A){return arguments.length?(i=typeof A=="function"?A:Od(!!A),y):i},y.on=function(){var A=o.on.apply(o,arguments);return A===o?y:A},y.clickDistance=function(A){return arguments.length?(p=(A=+A)*A,y):Math.sqrt(p)},y}function C0(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function fk(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function iu(){}var qc=.7,Nf=1/qc,lo="\\s*([+-]?\\d+)\\s*",Yc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Zi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sF=/^#([0-9a-f]{3,8})$/,aF=new RegExp(`^rgb\\(${lo},${lo},${lo}\\)$`),lF=new RegExp(`^rgb\\(${Zi},${Zi},${Zi}\\)$`),oF=new RegExp(`^rgba\\(${lo},${lo},${lo},${Yc}\\)$`),cF=new RegExp(`^rgba\\(${Zi},${Zi},${Zi},${Yc}\\)$`),uF=new RegExp(`^hsl\\(${Yc},${Zi},${Zi}\\)$`),dF=new RegExp(`^hsla\\(${Yc},${Zi},${Zi},${Yc}\\)$`),Ov={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};C0(iu,xl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Lv,formatHex:Lv,formatHex8:fF,formatHsl:hF,formatRgb:Iv,toString:Iv});function Lv(){return this.rgb().formatHex()}function fF(){return this.rgb().formatHex8()}function hF(){return hk(this).formatHsl()}function Iv(){return this.rgb().formatRgb()}function xl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=sF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hv(t):n===3?new _r(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ld(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ld(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=aF.exec(e))?new _r(t[1],t[2],t[3],1):(t=lF.exec(e))?new _r(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oF.exec(e))?Ld(t[1],t[2],t[3],t[4]):(t=cF.exec(e))?Ld(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uF.exec(e))?Yv(t[1],t[2]/100,t[3]/100,1):(t=dF.exec(e))?Yv(t[1],t[2]/100,t[3]/100,t[4]):Ov.hasOwnProperty(e)?Hv(Ov[e]):e==="transparent"?new _r(NaN,NaN,NaN,0):null}function Hv(e){return new _r(e>>16&255,e>>8&255,e&255,1)}function Ld(e,t,n,i){return i<=0&&(e=t=n=NaN),new _r(e,t,n,i)}function mF(e){return e instanceof iu||(e=xl(e)),e?(e=e.rgb(),new _r(e.r,e.g,e.b,e.opacity)):new _r}function Ax(e,t,n,i){return arguments.length===1?mF(e):new _r(e,t,n,i??1)}function _r(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}C0(_r,Ax,fk(iu,{brighter(e){return e=e==null?Nf:Math.pow(Nf,e),new _r(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qc:Math.pow(qc,e),new _r(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new _r(ul(this.r),ul(this.g),ul(this.b),Ef(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:Uv,formatHex:Uv,formatHex8:pF,formatRgb:qv,toString:qv}));function Uv(){return`#${ol(this.r)}${ol(this.g)}${ol(this.b)}`}function pF(){return`#${ol(this.r)}${ol(this.g)}${ol(this.b)}${ol((isNaN(this.opacity)?1:this.opacity)*255)}`}function qv(){const e=Ef(this.opacity);return`${e===1?"rgb(":"rgba("}${ul(this.r)}, ${ul(this.g)}, ${ul(this.b)}${e===1?")":`, ${e})`}`}function Ef(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ul(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ol(e){return e=ul(e),(e<16?"0":"")+e.toString(16)}function Yv(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Si(e,t,n,i)}function hk(e){if(e instanceof Si)return new Si(e.h,e.s,e.l,e.opacity);if(e instanceof iu||(e=xl(e)),!e)return new Si;if(e instanceof Si)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,a=Math.min(t,n,i),o=Math.max(t,n,i),c=NaN,d=o-a,m=(o+a)/2;return d?(t===o?c=(n-i)/d+(n<i)*6:n===o?c=(i-t)/d+2:c=(t-n)/d+4,d/=m<.5?o+a:2-o-a,c*=60):d=m>0&&m<1?0:c,new Si(c,d,m,e.opacity)}function xF(e,t,n,i){return arguments.length===1?hk(e):new Si(e,t,n,i??1)}function Si(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}C0(Si,xF,fk(iu,{brighter(e){return e=e==null?Nf:Math.pow(Nf,e),new Si(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qc:Math.pow(qc,e),new Si(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,a=2*n-i;return new _r(jp(e>=240?e-240:e+120,a,i),jp(e,a,i),jp(e<120?e+240:e-120,a,i),this.opacity)},clamp(){return new Si(Pv(this.h),Id(this.s),Id(this.l),Ef(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=Ef(this.opacity);return`${e===1?"hsl(":"hsla("}${Pv(this.h)}, ${Id(this.s)*100}%, ${Id(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Pv(e){return e=(e||0)%360,e<0?e+360:e}function Id(e){return Math.max(0,Math.min(1,e||0))}function jp(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const N0=e=>()=>e;function gF(e,t){return function(n){return e+n*t}}function yF(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function bF(e){return(e=+e)==1?mk:function(t,n){return n-t?yF(t,n,e):N0(isNaN(t)?n:t)}}function mk(e,t){var n=t-e;return n?gF(e,n):N0(isNaN(e)?t:e)}const Af=(function e(t){var n=bF(t);function i(a,o){var c=n((a=Ax(a)).r,(o=Ax(o)).r),d=n(a.g,o.g),m=n(a.b,o.b),f=mk(a.opacity,o.opacity);return function(x){return a.r=c(x),a.g=d(x),a.b=m(x),a.opacity=f(x),a+""}}return i.gamma=e,i})(1);function vF(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),a;return function(o){for(a=0;a<n;++a)i[a]=e[a]*(1-o)+t[a]*o;return i}}function wF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function kF(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,a=new Array(i),o=new Array(n),c;for(c=0;c<i;++c)a[c]=zc(e[c],t[c]);for(;c<n;++c)o[c]=t[c];return function(d){for(c=0;c<i;++c)o[c]=a[c](d);return o}}function SF(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function Wi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function jF(e,t){var n={},i={},a;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(a in t)a in e?n[a]=zc(e[a],t[a]):i[a]=t[a];return function(o){for(a in n)i[a]=n[a](o);return i}}var Dx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Cp=new RegExp(Dx.source,"g");function CF(e){return function(){return e}}function NF(e){return function(t){return e(t)+""}}function pk(e,t){var n=Dx.lastIndex=Cp.lastIndex=0,i,a,o,c=-1,d=[],m=[];for(e=e+"",t=t+"";(i=Dx.exec(e))&&(a=Cp.exec(t));)(o=a.index)>n&&(o=t.slice(n,o),d[c]?d[c]+=o:d[++c]=o),(i=i[0])===(a=a[0])?d[c]?d[c]+=a:d[++c]=a:(d[++c]=null,m.push({i:c,x:Wi(i,a)})),n=Cp.lastIndex;return n<t.length&&(o=t.slice(n),d[c]?d[c]+=o:d[++c]=o),d.length<2?m[0]?NF(m[0].x):CF(t):(t=m.length,function(f){for(var x=0,p;x<t;++x)d[(p=m[x]).i]=p.x(f);return d.join("")})}function zc(e,t){var n=typeof t,i;return t==null||n==="boolean"?N0(t):(n==="number"?Wi:n==="string"?(i=xl(t))?(t=i,Af):pk:t instanceof xl?Af:t instanceof Date?SF:wF(t)?vF:Array.isArray(t)?kF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?jF:Wi)(e,t)}var Xv=180/Math.PI,Tx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xk(e,t,n,i,a,o){var c,d,m;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(m=e*n+t*i)&&(n-=e*m,i-=t*m),(d=Math.sqrt(n*n+i*i))&&(n/=d,i/=d,m/=d),e*i<t*n&&(e=-e,t=-t,m=-m,c=-c),{translateX:a,translateY:o,rotate:Math.atan2(t,e)*Xv,skewX:Math.atan(m)*Xv,scaleX:c,scaleY:d}}var Hd;function EF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Tx:xk(t.a,t.b,t.c,t.d,t.e,t.f)}function AF(e){return e==null||(Hd||(Hd=document.createElementNS("http://www.w3.org/2000/svg","g")),Hd.setAttribute("transform",e),!(e=Hd.transform.baseVal.consolidate()))?Tx:(e=e.matrix,xk(e.a,e.b,e.c,e.d,e.e,e.f))}function gk(e,t,n,i){function a(f){return f.length?f.pop()+" ":""}function o(f,x,p,y,g,w){if(f!==p||x!==y){var k=g.push("translate(",null,t,null,n);w.push({i:k-4,x:Wi(f,p)},{i:k-2,x:Wi(x,y)})}else(p||y)&&g.push("translate("+p+t+y+n)}function c(f,x,p,y){f!==x?(f-x>180?x+=360:x-f>180&&(f+=360),y.push({i:p.push(a(p)+"rotate(",null,i)-2,x:Wi(f,x)})):x&&p.push(a(p)+"rotate("+x+i)}function d(f,x,p,y){f!==x?y.push({i:p.push(a(p)+"skewX(",null,i)-2,x:Wi(f,x)}):x&&p.push(a(p)+"skewX("+x+i)}function m(f,x,p,y,g,w){if(f!==p||x!==y){var k=g.push(a(g)+"scale(",null,",",null,")");w.push({i:k-4,x:Wi(f,p)},{i:k-2,x:Wi(x,y)})}else(p!==1||y!==1)&&g.push(a(g)+"scale("+p+","+y+")")}return function(f,x){var p=[],y=[];return f=e(f),x=e(x),o(f.translateX,f.translateY,x.translateX,x.translateY,p,y),c(f.rotate,x.rotate,p,y),d(f.skewX,x.skewX,p,y),m(f.scaleX,f.scaleY,x.scaleX,x.scaleY,p,y),f=x=null,function(g){for(var w=-1,k=y.length,j;++w<k;)p[(j=y[w]).i]=j.x(g);return p.join("")}}}var DF=gk(EF,"px, ","px)","deg)"),TF=gk(AF,", ",")",")"),_F=1e-12;function Vv(e){return((e=Math.exp(e))+1/e)/2}function MF(e){return((e=Math.exp(e))-1/e)/2}function FF(e){return((e=Math.exp(2*e))-1)/(e+1)}const of=(function e(t,n,i){function a(o,c){var d=o[0],m=o[1],f=o[2],x=c[0],p=c[1],y=c[2],g=x-d,w=p-m,k=g*g+w*w,j,C;if(k<_F)C=Math.log(y/f)/t,j=function(F){return[d+F*g,m+F*w,f*Math.exp(t*F*C)]};else{var N=Math.sqrt(k),E=(y*y-f*f+i*k)/(2*f*n*N),A=(y*y-f*f-i*k)/(2*y*n*N),z=Math.log(Math.sqrt(E*E+1)-E),D=Math.log(Math.sqrt(A*A+1)-A);C=(D-z)/t,j=function(F){var q=F*C,V=Vv(z),L=f/(n*N)*(V*FF(t*q+z)-MF(z));return[d+L*g,m+L*w,f*V/Vv(t*q+z)]}}return j.duration=C*1e3*t/Math.SQRT2,j}return a.rho=function(o){var c=Math.max(.001,+o),d=c*c,m=d*d;return e(c,d,m)},a})(Math.SQRT2,2,4);var RF=tu("start","end","cancel","interrupt"),zF=[],yk=0,Wv=1,_x=2,cf=3,Gv=4,Mx=5,uf=6;function Yf(e,t,n,i,a,o){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;BF(e,n,{name:t,index:i,group:a,on:RF,tween:zF,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:yk})}function E0(e,t){var n=Ei(e,t);if(n.state>yk)throw new Error("too late; already scheduled");return n}function rs(e,t){var n=Ei(e,t);if(n.state>cf)throw new Error("too late; already running");return n}function Ei(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function BF(e,t,n){var i=e.__transition,a;i[t]=n,n.timer=v0(o,0,n.time);function o(f){n.state=Wv,n.timer.restart(c,n.delay,n.time),n.delay<=f&&c(f-n.delay)}function c(f){var x,p,y,g;if(n.state!==Wv)return m();for(x in i)if(g=i[x],g.name===n.name){if(g.state===cf)return jv(c);g.state===Gv?(g.state=uf,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete i[x]):+x<t&&(g.state=uf,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete i[x])}if(jv(function(){n.state===cf&&(n.state=Gv,n.timer.restart(d,n.delay,n.time),d(f))}),n.state=_x,n.on.call("start",e,e.__data__,n.index,n.group),n.state===_x){for(n.state=cf,a=new Array(y=n.tween.length),x=0,p=-1;x<y;++x)(g=n.tween[x].value.call(e,e.__data__,n.index,n.group))&&(a[++p]=g);a.length=p+1}}function d(f){for(var x=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(m),n.state=Mx,1),p=-1,y=a.length;++p<y;)a[p].call(e,x);n.state===Mx&&(n.on.call("end",e,e.__data__,n.index,n.group),m())}function m(){n.state=uf,n.timer.stop(),delete i[t];for(var f in i)return;delete e.__transition}}function df(e,t){var n=e.__transition,i,a,o=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((i=n[c]).name!==t){o=!1;continue}a=i.state>_x&&i.state<Mx,i.state=uf,i.timer.stop(),i.on.call(a?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[c]}o&&delete e.__transition}}function $F(e){return this.each(function(){df(this,e)})}function OF(e,t){var n,i;return function(){var a=rs(this,e),o=a.tween;if(o!==n){i=n=o;for(var c=0,d=i.length;c<d;++c)if(i[c].name===t){i=i.slice(),i.splice(c,1);break}}a.tween=i}}function LF(e,t,n){var i,a;if(typeof n!="function")throw new Error;return function(){var o=rs(this,e),c=o.tween;if(c!==i){a=(i=c).slice();for(var d={name:t,value:n},m=0,f=a.length;m<f;++m)if(a[m].name===t){a[m]=d;break}m===f&&a.push(d)}o.tween=a}}function IF(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Ei(this.node(),n).tween,a=0,o=i.length,c;a<o;++a)if((c=i[a]).name===e)return c.value;return null}return this.each((t==null?OF:LF)(n,e,t))}function A0(e,t,n){var i=e._id;return e.each(function(){var a=rs(this,i);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Ei(a,i).value[t]}}function bk(e,t){var n;return(typeof t=="number"?Wi:t instanceof xl?Af:(n=xl(t))?(t=n,Af):pk)(e,t)}function HF(e){return function(){this.removeAttribute(e)}}function UF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qF(e,t,n){var i,a=n+"",o;return function(){var c=this.getAttribute(e);return c===a?null:c===i?o:o=t(i=c,n)}}function YF(e,t,n){var i,a=n+"",o;return function(){var c=this.getAttributeNS(e.space,e.local);return c===a?null:c===i?o:o=t(i=c,n)}}function PF(e,t,n){var i,a,o;return function(){var c,d=n(this),m;return d==null?void this.removeAttribute(e):(c=this.getAttribute(e),m=d+"",c===m?null:c===i&&m===a?o:(a=m,o=t(i=c,d)))}}function XF(e,t,n){var i,a,o;return function(){var c,d=n(this),m;return d==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),m=d+"",c===m?null:c===i&&m===a?o:(a=m,o=t(i=c,d)))}}function VF(e,t){var n=qf(e),i=n==="transform"?TF:bk;return this.attrTween(e,typeof t=="function"?(n.local?XF:PF)(n,i,A0(this,"attr."+e,t)):t==null?(n.local?UF:HF)(n):(n.local?YF:qF)(n,i,t))}function WF(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function GF(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function KF(e,t){var n,i;function a(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&GF(e,o)),n}return a._value=t,a}function QF(e,t){var n,i;function a(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&WF(e,o)),n}return a._value=t,a}function ZF(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=qf(e);return this.tween(n,(i.local?KF:QF)(i,t))}function JF(e,t){return function(){E0(this,e).delay=+t.apply(this,arguments)}}function eR(e,t){return t=+t,function(){E0(this,e).delay=t}}function tR(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?JF:eR)(t,e)):Ei(this.node(),t).delay}function nR(e,t){return function(){rs(this,e).duration=+t.apply(this,arguments)}}function rR(e,t){return t=+t,function(){rs(this,e).duration=t}}function iR(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?nR:rR)(t,e)):Ei(this.node(),t).duration}function sR(e,t){if(typeof t!="function")throw new Error;return function(){rs(this,e).ease=t}}function aR(e){var t=this._id;return arguments.length?this.each(sR(t,e)):Ei(this.node(),t).ease}function lR(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;rs(this,e).ease=n}}function oR(e){if(typeof e!="function")throw new Error;return this.each(lR(this._id,e))}function cR(e){typeof e!="function"&&(e=J5(e));for(var t=this._groups,n=t.length,i=new Array(n),a=0;a<n;++a)for(var o=t[a],c=o.length,d=i[a]=[],m,f=0;f<c;++f)(m=o[f])&&e.call(m,m.__data__,f,o)&&d.push(m);return new zs(i,this._parents,this._name,this._id)}function uR(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,a=n.length,o=Math.min(i,a),c=new Array(i),d=0;d<o;++d)for(var m=t[d],f=n[d],x=m.length,p=c[d]=new Array(x),y,g=0;g<x;++g)(y=m[g]||f[g])&&(p[g]=y);for(;d<i;++d)c[d]=t[d];return new zs(c,this._parents,this._name,this._id)}function dR(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function fR(e,t,n){var i,a,o=dR(t)?E0:rs;return function(){var c=o(this,e),d=c.on;d!==i&&(a=(i=d).copy()).on(t,n),c.on=a}}function hR(e,t){var n=this._id;return arguments.length<2?Ei(this.node(),n).on.on(e):this.each(fR(n,e,t))}function mR(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function pR(){return this.on("end.remove",mR(this._id))}function xR(e){var t=this._name,n=this._id;typeof e!="function"&&(e=S0(e));for(var i=this._groups,a=i.length,o=new Array(a),c=0;c<a;++c)for(var d=i[c],m=d.length,f=o[c]=new Array(m),x,p,y=0;y<m;++y)(x=d[y])&&(p=e.call(x,x.__data__,y,d))&&("__data__"in x&&(p.__data__=x.__data__),f[y]=p,Yf(f[y],t,n,y,f,Ei(x,n)));return new zs(o,this._parents,t,n)}function gR(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Z5(e));for(var i=this._groups,a=i.length,o=[],c=[],d=0;d<a;++d)for(var m=i[d],f=m.length,x,p=0;p<f;++p)if(x=m[p]){for(var y=e.call(x,x.__data__,p,m),g,w=Ei(x,n),k=0,j=y.length;k<j;++k)(g=y[k])&&Yf(g,t,n,k,y,w);o.push(y),c.push(x)}return new zs(o,c,t,n)}var yR=ru.prototype.constructor;function bR(){return new yR(this._groups,this._parents)}function vR(e,t){var n,i,a;return function(){var o=ho(this,e),c=(this.style.removeProperty(e),ho(this,e));return o===c?null:o===n&&c===i?a:a=t(n=o,i=c)}}function vk(e){return function(){this.style.removeProperty(e)}}function wR(e,t,n){var i,a=n+"",o;return function(){var c=ho(this,e);return c===a?null:c===i?o:o=t(i=c,n)}}function kR(e,t,n){var i,a,o;return function(){var c=ho(this,e),d=n(this),m=d+"";return d==null&&(m=d=(this.style.removeProperty(e),ho(this,e))),c===m?null:c===i&&m===a?o:(a=m,o=t(i=c,d))}}function SR(e,t){var n,i,a,o="style."+t,c="end."+o,d;return function(){var m=rs(this,e),f=m.on,x=m.value[o]==null?d||(d=vk(t)):void 0;(f!==n||a!==x)&&(i=(n=f).copy()).on(c,a=x),m.on=i}}function jR(e,t,n){var i=(e+="")=="transform"?DF:bk;return t==null?this.styleTween(e,vR(e,i)).on("end.style."+e,vk(e)):typeof t=="function"?this.styleTween(e,kR(e,i,A0(this,"style."+e,t))).each(SR(this._id,e)):this.styleTween(e,wR(e,i,t),n).on("end.style."+e,null)}function CR(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function NR(e,t,n){var i,a;function o(){var c=t.apply(this,arguments);return c!==a&&(i=(a=c)&&CR(e,c,n)),i}return o._value=t,o}function ER(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,NR(e,t,n??""))}function AR(e){return function(){this.textContent=e}}function DR(e){return function(){var t=e(this);this.textContent=t??""}}function TR(e){return this.tween("text",typeof e=="function"?DR(A0(this,"text",e)):AR(e==null?"":e+""))}function _R(e){return function(t){this.textContent=e.call(this,t)}}function MR(e){var t,n;function i(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&_R(a)),t}return i._value=e,i}function FR(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,MR(e))}function RR(){for(var e=this._name,t=this._id,n=wk(),i=this._groups,a=i.length,o=0;o<a;++o)for(var c=i[o],d=c.length,m,f=0;f<d;++f)if(m=c[f]){var x=Ei(m,t);Yf(m,e,n,f,c,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new zs(i,this._parents,e,n)}function zR(){var e,t,n=this,i=n._id,a=n.size();return new Promise(function(o,c){var d={value:c},m={value:function(){--a===0&&o()}};n.each(function(){var f=rs(this,i),x=f.on;x!==e&&(t=(e=x).copy(),t._.cancel.push(d),t._.interrupt.push(d),t._.end.push(m)),f.on=t}),a===0&&o()})}var BR=0;function zs(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function wk(){return++BR}var Ds=ru.prototype;zs.prototype={constructor:zs,select:xR,selectAll:gR,selectChild:Ds.selectChild,selectChildren:Ds.selectChildren,filter:cR,merge:uR,selection:bR,transition:RR,call:Ds.call,nodes:Ds.nodes,node:Ds.node,size:Ds.size,empty:Ds.empty,each:Ds.each,on:hR,attr:VF,attrTween:ZF,style:jR,styleTween:ER,text:TR,textTween:FR,remove:pR,tween:IF,delay:tR,duration:iR,ease:aR,easeVarying:oR,end:zR,[Symbol.iterator]:Ds[Symbol.iterator]};function $R(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var OR={time:null,delay:0,duration:250,ease:$R};function LR(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function IR(e){var t,n;e instanceof zs?(t=e._id,e=e._name):(t=wk(),(n=OR).time=b0(),e=e==null?null:e+"");for(var i=this._groups,a=i.length,o=0;o<a;++o)for(var c=i[o],d=c.length,m,f=0;f<d;++f)(m=c[f])&&Yf(m,e,t,f,c,n||LR(m,t));return new zs(i,this._parents,e,t)}ru.prototype.interrupt=$F;ru.prototype.transition=IR;const Ud=e=>()=>e;function HR(e,{sourceEvent:t,target:n,transform:i,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function Ms(e,t,n){this.k=e,this.x=t,this.y=n}Ms.prototype={constructor:Ms,scale:function(e){return e===1?this:new Ms(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ms(this.k,this.x+this.k*e,this.y+this.k*t)},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 Pf=new Ms(1,0,0);kk.prototype=Ms.prototype;function kk(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Pf;return e.__zoom}function Np(e){e.stopImmediatePropagation()}function Cc(e){e.preventDefault(),e.stopImmediatePropagation()}function UR(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function qR(){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 Kv(){return this.__zoom||Pf}function YR(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function PR(){return navigator.maxTouchPoints||"ontouchstart"in this}function XR(e,t,n){var i=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a),c>o?(o+c)/2:Math.min(0,o)||Math.max(0,c))}function Sk(){var e=UR,t=qR,n=XR,i=YR,a=PR,o=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,m=of,f=tu("start","zoom","end"),x,p,y,g=500,w=150,k=0,j=10;function C(R){R.property("__zoom",Kv).on("wheel.zoom",q,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",L).filter(a).on("touchstart.zoom",_).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}C.transform=function(R,H,$,G){var Q=R.selection?R.selection():R;Q.property("__zoom",Kv),R!==Q?z(R,H,$,G):Q.interrupt().each(function(){D(this,arguments).event(G).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},C.scaleBy=function(R,H,$,G){C.scaleTo(R,function(){var Q=this.__zoom.k,K=typeof H=="function"?H.apply(this,arguments):H;return Q*K},$,G)},C.scaleTo=function(R,H,$,G){C.transform(R,function(){var Q=t.apply(this,arguments),K=this.__zoom,M=$==null?A(Q):typeof $=="function"?$.apply(this,arguments):$,U=K.invert(M),P=typeof H=="function"?H.apply(this,arguments):H;return n(E(N(K,P),M,U),Q,c)},$,G)},C.translateBy=function(R,H,$,G){C.transform(R,function(){return n(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof $=="function"?$.apply(this,arguments):$),t.apply(this,arguments),c)},null,G)},C.translateTo=function(R,H,$,G,Q){C.transform(R,function(){var K=t.apply(this,arguments),M=this.__zoom,U=G==null?A(K):typeof G=="function"?G.apply(this,arguments):G;return n(Pf.translate(U[0],U[1]).scale(M.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof $=="function"?-$.apply(this,arguments):-$),K,c)},G,Q)};function N(R,H){return H=Math.max(o[0],Math.min(o[1],H)),H===R.k?R:new Ms(H,R.x,R.y)}function E(R,H,$){var G=H[0]-$[0]*R.k,Q=H[1]-$[1]*R.k;return G===R.x&&Q===R.y?R:new Ms(R.k,G,Q)}function A(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function z(R,H,$,G){R.on("start.zoom",function(){D(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,M=D(Q,K).event(G),U=t.apply(Q,K),P=$==null?A(U):typeof $=="function"?$.apply(Q,K):$,O=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),Z=Q.__zoom,ee=typeof H=="function"?H.apply(Q,K):H,J=m(Z.invert(P).concat(O/Z.k),ee.invert(P).concat(O/ee.k));return function(se){if(se===1)se=ee;else{var le=J(se),ye=O/le[2];se=new Ms(ye,P[0]-le[0]*ye,P[1]-le[1]*ye)}M.zoom(null,se)}})}function D(R,H,$){return!$&&R.__zooming||new F(R,H)}function F(R,H){this.that=R,this.args=H,this.active=0,this.sourceEvent=null,this.extent=t.apply(R,H),this.taps=0}F.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,H){return this.mouse&&R!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var H=Vr(this.that).datum();f.call(R,this.that,new HR(R,{sourceEvent:this.sourceEvent,target:C,transform:this.that.__zoom,dispatch:f}),H)}};function q(R,...H){if(!e.apply(this,arguments))return;var $=D(this,H).event(R),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,i.apply(this,arguments)))),K=wi(R);if($.wheel)($.mouse[0][0]!==K[0]||$.mouse[0][1]!==K[1])&&($.mouse[1]=G.invert($.mouse[0]=K)),clearTimeout($.wheel);else{if(G.k===Q)return;$.mouse=[K,G.invert(K)],df(this),$.start()}Cc(R),$.wheel=setTimeout(M,w),$.zoom("mouse",n(E(N(G,Q),$.mouse[0],$.mouse[1]),$.extent,c));function M(){$.wheel=null,$.end()}}function V(R,...H){if(y||!e.apply(this,arguments))return;var $=R.currentTarget,G=D(this,H,!0).event(R),Q=Vr(R.view).on("mousemove.zoom",P,!0).on("mouseup.zoom",O,!0),K=wi(R,$),M=R.clientX,U=R.clientY;ck(R.view),Np(R),G.mouse=[K,this.__zoom.invert(K)],df(this),G.start();function P(Z){if(Cc(Z),!G.moved){var ee=Z.clientX-M,J=Z.clientY-U;G.moved=ee*ee+J*J>k}G.event(Z).zoom("mouse",n(E(G.that.__zoom,G.mouse[0]=wi(Z,$),G.mouse[1]),G.extent,c))}function O(Z){Q.on("mousemove.zoom mouseup.zoom",null),uk(Z.view,G.moved),Cc(Z),G.event(Z).end()}}function L(R,...H){if(e.apply(this,arguments)){var $=this.__zoom,G=wi(R.changedTouches?R.changedTouches[0]:R,this),Q=$.invert(G),K=$.k*(R.shiftKey?.5:2),M=n(E(N($,K),G,Q),t.apply(this,H),c);Cc(R),d>0?Vr(this).transition().duration(d).call(z,M,G,R):Vr(this).call(C.transform,M,G,R)}}function _(R,...H){if(e.apply(this,arguments)){var $=R.touches,G=$.length,Q=D(this,H,R.changedTouches.length===G).event(R),K,M,U,P;for(Np(R),M=0;M<G;++M)U=$[M],P=wi(U,this),P=[P,this.__zoom.invert(P),U.identifier],Q.touch0?!Q.touch1&&Q.touch0[2]!==P[2]&&(Q.touch1=P,Q.taps=0):(Q.touch0=P,K=!0,Q.taps=1+!!x);x&&(x=clearTimeout(x)),K&&(Q.taps<2&&(p=P[0],x=setTimeout(function(){x=null},g)),df(this),Q.start())}}function B(R,...H){if(this.__zooming){var $=D(this,H).event(R),G=R.changedTouches,Q=G.length,K,M,U,P;for(Cc(R),K=0;K<Q;++K)M=G[K],U=wi(M,this),$.touch0&&$.touch0[2]===M.identifier?$.touch0[0]=U:$.touch1&&$.touch1[2]===M.identifier&&($.touch1[0]=U);if(M=$.that.__zoom,$.touch1){var O=$.touch0[0],Z=$.touch0[1],ee=$.touch1[0],J=$.touch1[1],se=(se=ee[0]-O[0])*se+(se=ee[1]-O[1])*se,le=(le=J[0]-Z[0])*le+(le=J[1]-Z[1])*le;M=N(M,Math.sqrt(se/le)),U=[(O[0]+ee[0])/2,(O[1]+ee[1])/2],P=[(Z[0]+J[0])/2,(Z[1]+J[1])/2]}else if($.touch0)U=$.touch0[0],P=$.touch0[1];else return;$.zoom("touch",n(E(M,U,P),$.extent,c))}}function X(R,...H){if(this.__zooming){var $=D(this,H).event(R),G=R.changedTouches,Q=G.length,K,M;for(Np(R),y&&clearTimeout(y),y=setTimeout(function(){y=null},g),K=0;K<Q;++K)M=G[K],$.touch0&&$.touch0[2]===M.identifier?delete $.touch0:$.touch1&&$.touch1[2]===M.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(M=wi(M,this),Math.hypot(p[0]-M[0],p[1]-M[1])<j)){var U=Vr(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return C.wheelDelta=function(R){return arguments.length?(i=typeof R=="function"?R:Ud(+R),C):i},C.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Ud(!!R),C):e},C.touchable=function(R){return arguments.length?(a=typeof R=="function"?R:Ud(!!R),C):a},C.extent=function(R){return arguments.length?(t=typeof R=="function"?R:Ud([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),C):t},C.scaleExtent=function(R){return arguments.length?(o[0]=+R[0],o[1]=+R[1],C):[o[0],o[1]]},C.translateExtent=function(R){return arguments.length?(c[0][0]=+R[0][0],c[1][0]=+R[1][0],c[0][1]=+R[0][1],c[1][1]=+R[1][1],C):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},C.constrain=function(R){return arguments.length?(n=R,C):n},C.duration=function(R){return arguments.length?(d=+R,C):d},C.interpolate=function(R){return arguments.length?(m=R,C):m},C.on=function(){var R=f.on.apply(f,arguments);return R===f?C:R},C.clickDistance=function(R){return arguments.length?(k=(R=+R)*R,C):Math.sqrt(k)},C.tapDistance=function(R){return arguments.length?(j=+R,C):j},C}const Ji={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:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,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."},Pc=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],jk=["Enter"," ","Escape"],Ck={"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:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"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 mo;(function(e){e.Strict="strict",e.Loose="loose"})(mo||(mo={}));var dl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(dl||(dl={}));var Xc;(function(e){e.Partial="partial",e.Full="full"})(Xc||(Xc={}));const Nk={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ja;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ja||(ja={}));var Df;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Df||(Df={}));var at;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(at||(at={}));const Qv={[at.Left]:at.Right,[at.Right]:at.Left,[at.Top]:at.Bottom,[at.Bottom]:at.Top};function Ek(e){return e===null?null:e?"valid":"invalid"}const Ak=e=>"id"in e&&"source"in e&&"target"in e,VR=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),D0=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),su=(e,t=[0,0])=>{const{width:n,height:i}=Os(e),a=e.origin??t,o=n*a[0],c=i*a[1];return{x:e.position.x-o,y:e.position.y-c}},WR=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,a)=>{const o=typeof a=="string";let c=!t.nodeLookup&&!o?a:void 0;t.nodeLookup&&(c=o?t.nodeLookup.get(a):D0(a)?a:t.nodeLookup.get(a.id));const d=c?Tf(c,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Xf(i,d)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Vf(n)},au=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(n=Xf(n,Tf(a)),i=!0)}),i?Vf(n):{x:0,y:0,width:0,height:0}},T0=(e,t,[n,i,a]=[0,0,1],o=!1,c=!1)=>{const d={...ou(t,[n,i,a]),width:t.width/a,height:t.height/a},m=[];for(const f of e.values()){const{measured:x,selectable:p=!0,hidden:y=!1}=f;if(c&&!p||y)continue;const g=x.width??f.width??f.initialWidth??null,w=x.height??f.height??f.initialHeight??null,k=Vc(d,xo(f)),j=(g??0)*(w??0),C=o&&k>0;(!f.internals.handleBounds||C||k>=j||f.dragging)&&m.push(f)}return m},GR=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function KR(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!a.hidden)&&(!i||i.has(a.id))&&n.set(a.id,a)}),n}async function QR({nodes:e,width:t,height:n,panZoom:i,minZoom:a,maxZoom:o},c){if(e.size===0)return Promise.resolve(!0);const d=KR(e,c),m=au(d),f=_0(m,t,n,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??o,(c==null?void 0:c.padding)??.1);return await i.setViewport(f,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),Promise.resolve(!0)}function Dk({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:a,onError:o}){const c=n.get(e),d=c.parentId?n.get(c.parentId):void 0,{x:m,y:f}=d?d.internals.positionAbsolute:{x:0,y:0},x=c.origin??i;let p=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!d)o==null||o("005",Ji.error005());else{const g=d.measured.width,w=d.measured.height;g&&w&&(p=[[m,f],[m+g,f+w]])}else d&&go(c.extent)&&(p=[[c.extent[0][0]+m,c.extent[0][1]+f],[c.extent[1][0]+m,c.extent[1][1]+f]]);const y=go(p)?gl(t,p,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(o==null||o("015",Ji.error015())),{position:{x:y.x-m+(c.measured.width??0)*x[0],y:y.y-f+(c.measured.height??0)*x[1]},positionAbsolute:y}}async function ZR({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:a}){const o=new Set(e.map(y=>y.id)),c=[];for(const y of n){if(y.deletable===!1)continue;const g=o.has(y.id),w=!g&&y.parentId&&c.find(k=>k.id===y.parentId);(g||w)&&c.push(y)}const d=new Set(t.map(y=>y.id)),m=i.filter(y=>y.deletable!==!1),x=GR(c,m);for(const y of m)d.has(y.id)&&!x.find(w=>w.id===y.id)&&x.push(y);if(!a)return{edges:x,nodes:c};const p=await a({nodes:c,edges:x});return typeof p=="boolean"?p?{edges:x,nodes:c}:{edges:[],nodes:[]}:p}const po=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),gl=(e={x:0,y:0},t,n)=>({x:po(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:po(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Tk(e,t,n){const{width:i,height:a}=Os(n),{x:o,y:c}=n.internals.positionAbsolute;return gl(e,[[o,c],[o+i,c+a]],t)}const Zv=(e,t,n)=>e<t?po(Math.abs(e-t),1,t)/t:e>n?-po(Math.abs(e-n),1,t)/t:0,_k=(e,t,n=15,i=40)=>{const a=Zv(e.x,i,t.width-i)*n,o=Zv(e.y,i,t.height-i)*n;return[a,o]},Xf=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Fx=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Vf=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),xo=(e,t=[0,0])=>{var a,o;const{x:n,y:i}=D0(e)?e.internals.positionAbsolute:su(e,t);return{x:n,y:i,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Tf=(e,t=[0,0])=>{var a,o;const{x:n,y:i}=D0(e)?e.internals.positionAbsolute:su(e,t);return{x:n,y:i,x2:n+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},Mk=(e,t)=>Vf(Xf(Fx(e),Fx(t))),Vc=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},Jv=e=>ji(e.width)&&ji(e.height)&&ji(e.x)&&ji(e.y),ji=e=>!isNaN(e)&&isFinite(e),JR=(e,t)=>{},lu=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ou=({x:e,y:t},[n,i,a],o=!1,c=[1,1])=>{const d={x:(e-n)/a,y:(t-i)/a};return o?lu(d,c):d},_f=({x:e,y:t},[n,i,a])=>({x:e*a+n,y:t*a+i});function Jl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.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 ez(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=Jl(e,n),a=Jl(e,t);return{top:i,right:a,bottom:i,left:a,x:a*2,y:i*2}}if(typeof e=="object"){const i=Jl(e.top??e.y??0,n),a=Jl(e.bottom??e.y??0,n),o=Jl(e.left??e.x??0,t),c=Jl(e.right??e.x??0,t);return{top:i,right:c,bottom:a,left:o,x:o+c,y:i+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function tz(e,t,n,i,a,o){const{x:c,y:d}=_f(e,[t,n,i]),{x:m,y:f}=_f({x:e.x+e.width,y:e.y+e.height},[t,n,i]),x=a-m,p=o-f;return{left:Math.floor(c),top:Math.floor(d),right:Math.floor(x),bottom:Math.floor(p)}}const _0=(e,t,n,i,a,o)=>{const c=ez(o,t,n),d=(t-c.x)/e.width,m=(n-c.y)/e.height,f=Math.min(d,m),x=po(f,i,a),p=e.x+e.width/2,y=e.y+e.height/2,g=t/2-p*x,w=n/2-y*x,k=tz(e,g,w,x,t,n),j={left:Math.min(k.left-c.left,0),top:Math.min(k.top-c.top,0),right:Math.min(k.right-c.right,0),bottom:Math.min(k.bottom-c.bottom,0)};return{x:g-j.left+j.right,y:w-j.top+j.bottom,zoom:x}},Wc=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function go(e){return e!=null&&e!=="parent"}function Os(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Fk(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Rk(e,t={width:0,height:0},n,i,a){const o={...e},c=i.get(n);if(c){const d=c.origin||a;o.x+=c.internals.positionAbsolute.x-(t.width??0)*d[0],o.y+=c.internals.positionAbsolute.y-(t.height??0)*d[1]}return o}function ew(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function nz(){let e,t;return{promise:new Promise((i,a)=>{e=i,t=a}),resolve:e,reject:t}}function rz(e){return{...Ck,...e||{}}}function Bc(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:a}){const{x:o,y:c}=Ci(e),d=ou({x:o-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},i),{x:m,y:f}=n?lu(d,t):d;return{xSnapped:m,ySnapped:f,...d}}const M0=e=>({width:e.offsetWidth,height:e.offsetHeight}),zk=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},iz=["INPUT","SELECT","TEXTAREA"];function Bk(e){var i,a;const t=((a=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:iz.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const $k=e=>"clientX"in e,Ci=(e,t)=>{var o,c;const n=$k(e),i=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},tw=(e,t,n,i,a)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(c=>{const d=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:a,position:c.getAttribute("data-handlepos"),x:(d.left-n.left)/i,y:(d.top-n.top)/i,...M0(c)}})};function Ok({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:a,sourceControlY:o,targetControlX:c,targetControlY:d}){const m=e*.125+a*.375+c*.375+n*.125,f=t*.125+o*.375+d*.375+i*.125,x=Math.abs(m-e),p=Math.abs(f-t);return[m,f,x,p]}function qd(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function nw({pos:e,x1:t,y1:n,x2:i,y2:a,c:o}){switch(e){case at.Left:return[t-qd(t-i,o),n];case at.Right:return[t+qd(i-t,o),n];case at.Top:return[t,n-qd(n-a,o)];case at.Bottom:return[t,n+qd(a-n,o)]}}function Lk({sourceX:e,sourceY:t,sourcePosition:n=at.Bottom,targetX:i,targetY:a,targetPosition:o=at.Top,curvature:c=.25}){const[d,m]=nw({pos:n,x1:e,y1:t,x2:i,y2:a,c}),[f,x]=nw({pos:o,x1:i,y1:a,x2:e,y2:t,c}),[p,y,g,w]=Ok({sourceX:e,sourceY:t,targetX:i,targetY:a,sourceControlX:d,sourceControlY:m,targetControlX:f,targetControlY:x});return[`M${e},${t} C${d},${m} ${f},${x} ${i},${a}`,p,y,g,w]}function Ik({sourceX:e,sourceY:t,targetX:n,targetY:i}){const a=Math.abs(n-e)/2,o=n<e?n+a:n-a,c=Math.abs(i-t)/2,d=i<t?i+c:i-c;return[o,d,a,c]}function sz({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:a=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const c=a&&n?i+1e3:i,d=Math.max(e.parentId||a&&e.selected?e.internals.z:0,t.parentId||a&&t.selected?t.internals.z:0);return c+d}function az({sourceNode:e,targetNode:t,width:n,height:i,transform:a}){const o=Xf(Tf(e),Tf(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const c={x:-a[0]/a[2],y:-a[1]/a[2],width:n/a[2],height:i/a[2]};return Vc(c,Vf(o))>0}const lz=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,oz=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),cz=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||lz;let a;return Ak(e)?a={...e}:a={...e,id:i(e)},oz(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function Hk({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[a,o,c,d]=Ik({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,a,o,c,d]}const rw={[at.Left]:{x:-1,y:0},[at.Right]:{x:1,y:0},[at.Top]:{x:0,y:-1},[at.Bottom]:{x:0,y:1}},uz=({source:e,sourcePosition:t=at.Bottom,target:n})=>t===at.Left||t===at.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},iw=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function dz({source:e,sourcePosition:t=at.Bottom,target:n,targetPosition:i=at.Top,center:a,offset:o,stepPosition:c}){const d=rw[t],m=rw[i],f={x:e.x+d.x*o,y:e.y+d.y*o},x={x:n.x+m.x*o,y:n.y+m.y*o},p=uz({source:f,sourcePosition:t,target:x}),y=p.x!==0?"x":"y",g=p[y];let w=[],k,j;const C={x:0,y:0},N={x:0,y:0},[,,E,A]=Ik({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(d[y]*m[y]===-1){y==="x"?(k=a.x??f.x+(x.x-f.x)*c,j=a.y??(f.y+x.y)/2):(k=a.x??(f.x+x.x)/2,j=a.y??f.y+(x.y-f.y)*c);const D=[{x:k,y:f.y},{x:k,y:x.y}],F=[{x:f.x,y:j},{x:x.x,y:j}];d[y]===g?w=y==="x"?D:F:w=y==="x"?F:D}else{const D=[{x:f.x,y:x.y}],F=[{x:x.x,y:f.y}];if(y==="x"?w=d.x===g?F:D:w=d.y===g?D:F,t===i){const B=Math.abs(e[y]-n[y]);if(B<=o){const X=Math.min(o-1,o-B);d[y]===g?C[y]=(f[y]>e[y]?-1:1)*X:N[y]=(x[y]>n[y]?-1:1)*X}}if(t!==i){const B=y==="x"?"y":"x",X=d[y]===m[B],R=f[B]>x[B],H=f[B]<x[B];(d[y]===1&&(!X&&R||X&&H)||d[y]!==1&&(!X&&H||X&&R))&&(w=y==="x"?D:F)}const q={x:f.x+C.x,y:f.y+C.y},V={x:x.x+N.x,y:x.y+N.y},L=Math.max(Math.abs(q.x-w[0].x),Math.abs(V.x-w[0].x)),_=Math.max(Math.abs(q.y-w[0].y),Math.abs(V.y-w[0].y));L>=_?(k=(q.x+V.x)/2,j=w[0].y):(k=w[0].x,j=(q.y+V.y)/2)}return[[e,{x:f.x+C.x,y:f.y+C.y},...w,{x:x.x+N.x,y:x.y+N.y},n],k,j,E,A]}function fz(e,t,n,i){const a=Math.min(iw(e,t)/2,iw(t,n)/2,i),{x:o,y:c}=t;if(e.x===o&&o===n.x||e.y===c&&c===n.y)return`L${o} ${c}`;if(e.y===c){const f=e.x<n.x?-1:1,x=e.y<n.y?1:-1;return`L ${o+a*f},${c}Q ${o},${c} ${o},${c+a*x}`}const d=e.x<n.x?1:-1,m=e.y<n.y?-1:1;return`L ${o},${c+a*m}Q ${o},${c} ${o+a*d},${c}`}function Mf({sourceX:e,sourceY:t,sourcePosition:n=at.Bottom,targetX:i,targetY:a,targetPosition:o=at.Top,borderRadius:c=5,centerX:d,centerY:m,offset:f=20,stepPosition:x=.5}){const[p,y,g,w,k]=dz({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:a},targetPosition:o,center:{x:d,y:m},offset:f,stepPosition:x});return[p.reduce((C,N,E)=>{let A="";return E>0&&E<p.length-1?A=fz(p[E-1],N,p[E+1],c):A=`${E===0?"M":"L"}${N.x} ${N.y}`,C+=A,C},""),y,g,w,k]}function sw(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function hz(e){var p;const{sourceNode:t,targetNode:n}=e;if(!sw(t)||!sw(n))return null;const i=t.internals.handleBounds||aw(t.handles),a=n.internals.handleBounds||aw(n.handles),o=lw((i==null?void 0:i.source)??[],e.sourceHandle),c=lw(e.connectionMode===mo.Strict?(a==null?void 0:a.target)??[]:((a==null?void 0:a.target)??[]).concat((a==null?void 0:a.source)??[]),e.targetHandle);if(!o||!c)return(p=e.onError)==null||p.call(e,"008",Ji.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const d=(o==null?void 0:o.position)||at.Bottom,m=(c==null?void 0:c.position)||at.Top,f=yl(t,o,d),x=yl(n,c,m);return{sourceX:f.x,sourceY:f.y,targetX:x.x,targetY:x.y,sourcePosition:d,targetPosition:m}}function aw(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function yl(e,t,n=at.Left,i=!1){const a=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:c,height:d}=t??Os(e);if(i)return{x:a+c/2,y:o+d/2};switch((t==null?void 0:t.position)??n){case at.Top:return{x:a+c/2,y:o};case at.Right:return{x:a+c,y:o+d/2};case at.Bottom:return{x:a+c/2,y:o+d};case at.Left:return{x:a,y:o+d/2}}}function lw(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Rx(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function mz(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:a}){const o=new Set;return e.reduce((c,d)=>([d.markerStart||i,d.markerEnd||a].forEach(m=>{if(m&&typeof m=="object"){const f=Rx(m,t);o.has(f)||(c.push({id:f,color:m.color||n,...m}),o.add(f))}}),c),[]).sort((c,d)=>c.id.localeCompare(d.id))}const Uk=1e3,pz=10,F0={nodeOrigin:[0,0],nodeExtent:Pc,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},xz={...F0,checkEquality:!0};function R0(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function gz(e,t,n){const i=R0(F0,n);for(const a of e.values())if(a.parentId)B0(a,e,t,i);else{const o=su(a,i.nodeOrigin),c=go(a.extent)?a.extent:i.nodeExtent,d=gl(o,c,Os(a));a.internals.positionAbsolute=d}}function yz(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const a of e.handles){const o={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?n.push(o):a.type==="target"&&i.push(o)}return{source:n,target:i}}function z0(e){return e==="manual"}function zx(e,t,n,i={}){var f,x;const a=R0(xz,i),o={i:0},c=new Map(t),d=a!=null&&a.elevateNodesOnSelect&&!z0(a.zIndexMode)?Uk:0;let m=e.length>0;t.clear(),n.clear();for(const p of e){let y=c.get(p.id);if(a.checkEquality&&p===(y==null?void 0:y.internals.userNode))t.set(p.id,y);else{const g=su(p,a.nodeOrigin),w=go(p.extent)?p.extent:a.nodeExtent,k=gl(g,w,Os(p));y={...a.defaults,...p,measured:{width:(f=p.measured)==null?void 0:f.width,height:(x=p.measured)==null?void 0:x.height},internals:{positionAbsolute:k,handleBounds:yz(p,y),z:qk(p,d,a.zIndexMode),userNode:p}},t.set(p.id,y)}(y.measured===void 0||y.measured.width===void 0||y.measured.height===void 0)&&!y.hidden&&(m=!1),p.parentId&&B0(y,t,n,i,o)}return m}function bz(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function B0(e,t,n,i,a){const{elevateNodesOnSelect:o,nodeOrigin:c,nodeExtent:d,zIndexMode:m}=R0(F0,i),f=e.parentId,x=t.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}bz(e,n),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&m==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*pz),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const p=o&&!z0(m)?Uk:0,{x:y,y:g,z:w}=vz(e,x,c,d,p,m),{positionAbsolute:k}=e.internals,j=y!==k.x||g!==k.y;(j||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:j?{x:y,y:g}:k,z:w}})}function qk(e,t,n){const i=ji(e.zIndex)?e.zIndex:0;return z0(n)?i:i+(e.selected?t:0)}function vz(e,t,n,i,a,o){const{x:c,y:d}=t.internals.positionAbsolute,m=Os(e),f=su(e,n),x=go(e.extent)?gl(f,e.extent,m):f;let p=gl({x:c+x.x,y:d+x.y},i,m);e.extent==="parent"&&(p=Tk(p,m,t));const y=qk(e,a,o),g=t.internals.z??0;return{x:p.x,y:p.y,z:g>=y?g+1:y}}function $0(e,t,n,i=[0,0]){var c;const a=[],o=new Map;for(const d of e){const m=t.get(d.parentId);if(!m)continue;const f=((c=o.get(d.parentId))==null?void 0:c.expandedRect)??xo(m),x=Mk(f,d.rect);o.set(d.parentId,{expandedRect:x,parent:m})}return o.size>0&&o.forEach(({expandedRect:d,parent:m},f)=>{var E;const x=m.internals.positionAbsolute,p=Os(m),y=m.origin??i,g=d.x<x.x?Math.round(Math.abs(x.x-d.x)):0,w=d.y<x.y?Math.round(Math.abs(x.y-d.y)):0,k=Math.max(p.width,Math.round(d.width)),j=Math.max(p.height,Math.round(d.height)),C=(k-p.width)*y[0],N=(j-p.height)*y[1];(g>0||w>0||C||N)&&(a.push({id:f,type:"position",position:{x:m.position.x-g+C,y:m.position.y-w+N}}),(E=n.get(f))==null||E.forEach(A=>{e.some(z=>z.id===A.id)||a.push({id:A.id,type:"position",position:{x:A.position.x+g,y:A.position.y+w}})})),(p.width<d.width||p.height<d.height||g||w)&&a.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:k+(g?y[0]*g-C:0),height:j+(w?y[1]*w-N:0)}})}),a}function wz(e,t,n,i,a,o,c){const d=i==null?void 0:i.querySelector(".xyflow__viewport");let m=!1;if(!d)return{changes:[],updatedInternals:m};const f=[],x=window.getComputedStyle(d),{m22:p}=new window.DOMMatrixReadOnly(x.transform),y=[];for(const g of e.values()){const w=t.get(g.id);if(!w)continue;if(w.hidden){t.set(w.id,{...w,internals:{...w.internals,handleBounds:void 0}}),m=!0;continue}const k=M0(g.nodeElement),j=w.measured.width!==k.width||w.measured.height!==k.height;if(!!(k.width&&k.height&&(j||!w.internals.handleBounds||g.force))){const N=g.nodeElement.getBoundingClientRect(),E=go(w.extent)?w.extent:o;let{positionAbsolute:A}=w.internals;w.parentId&&w.extent==="parent"?A=Tk(A,k,t.get(w.parentId)):E&&(A=gl(A,E,k));const z={...w,measured:k,internals:{...w.internals,positionAbsolute:A,handleBounds:{source:tw("source",g.nodeElement,N,p,w.id),target:tw("target",g.nodeElement,N,p,w.id)}}};t.set(w.id,z),w.parentId&&B0(z,t,n,{nodeOrigin:a,zIndexMode:c}),m=!0,j&&(f.push({id:w.id,type:"dimensions",dimensions:k}),w.expandParent&&w.parentId&&y.push({id:w.id,parentId:w.parentId,rect:xo(z,a)}))}}if(y.length>0){const g=$0(y,t,n,a);f.push(...g)}return{changes:f,updatedInternals:m}}async function kz({delta:e,panZoom:t,transform:n,translateExtent:i,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const c=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[a,o]],i),d=!!c&&(c.x!==n[0]||c.y!==n[1]||c.k!==n[2]);return Promise.resolve(d)}function ow(e,t,n,i,a,o){let c=a;const d=i.get(c)||new Map;i.set(c,d.set(n,t)),c=`${a}-${e}`;const m=i.get(c)||new Map;if(i.set(c,m.set(n,t)),o){c=`${a}-${e}-${o}`;const f=i.get(c)||new Map;i.set(c,f.set(n,t))}}function Yk(e,t,n){e.clear(),t.clear();for(const i of n){const{source:a,target:o,sourceHandle:c=null,targetHandle:d=null}=i,m={edgeId:i.id,source:a,target:o,sourceHandle:c,targetHandle:d},f=`${a}-${c}--${o}-${d}`,x=`${o}-${d}--${a}-${c}`;ow("source",m,x,e,a,c),ow("target",m,f,e,o,d),t.set(i.id,i)}}function Pk(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Pk(n,t):!1}function cw(e,t,n){var a;let i=e;do{if((a=i==null?void 0:i.matches)!=null&&a.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Sz(e,t,n,i){const a=new Map;for(const[o,c]of e)if((c.selected||c.id===i)&&(!c.parentId||!Pk(c,e))&&(c.draggable||t&&typeof c.draggable>"u")){const d=e.get(o);d&&a.set(o,{id:o,position:d.position||{x:0,y:0},distance:{x:n.x-d.internals.positionAbsolute.x,y:n.y-d.internals.positionAbsolute.y},extent:d.extent,parentId:d.parentId,origin:d.origin,expandParent:d.expandParent,internals:{positionAbsolute:d.internals.positionAbsolute||{x:0,y:0}},measured:{width:d.measured.width??0,height:d.measured.height??0}})}return a}function Ep({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var c,d,m;const a=[];for(const[f,x]of t){const p=(c=n.get(f))==null?void 0:c.internals.userNode;p&&a.push({...p,position:x.position,dragging:i})}if(!e)return[a[0],a];const o=(d=n.get(e))==null?void 0:d.internals.userNode;return[o?{...o,position:((m=t.get(e))==null?void 0:m.position)||o.position,dragging:i}:a[0],a]}function jz({dragItems:e,snapGrid:t,x:n,y:i}){const a=e.values().next().value;if(!a)return null;const o={x:n-a.distance.x,y:i-a.distance.y},c=lu(o,t);return{x:c.x-o.x,y:c.y-o.y}}function Cz({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:a}){let o={x:null,y:null},c=0,d=new Map,m=!1,f={x:0,y:0},x=null,p=!1,y=null,g=!1,w=!1,k=null;function j({noDragClassName:N,handleSelector:E,domNode:A,isSelectable:z,nodeId:D,nodeClickDistance:F=0}){y=Vr(A);function q({x:B,y:X}){const{nodeLookup:R,nodeExtent:H,snapGrid:$,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:M,onError:U,updateNodePositions:P}=t();o={x:B,y:X};let O=!1;const Z=d.size>1,ee=Z&&H?Fx(au(d)):null,J=Z&&G?jz({dragItems:d,snapGrid:$,x:B,y:X}):null;for(const[se,le]of d){if(!R.has(se))continue;let ye={x:B-le.distance.x,y:X-le.distance.y};G&&(ye=J?{x:Math.round(ye.x+J.x),y:Math.round(ye.y+J.y)}:lu(ye,$));let De=null;if(Z&&H&&!le.extent&&ee){const{positionAbsolute:me}=le.internals,Fe=me.x-ee.x+H[0][0],Je=me.x+le.measured.width-ee.x2+H[1][0],Pe=me.y-ee.y+H[0][1],it=me.y+le.measured.height-ee.y2+H[1][1];De=[[Fe,Pe],[Je,it]]}const{position:Ee,positionAbsolute:Re}=Dk({nodeId:se,nextPosition:ye,nodeLookup:R,nodeExtent:De||H,nodeOrigin:Q,onError:U});O=O||le.position.x!==Ee.x||le.position.y!==Ee.y,le.position=Ee,le.internals.positionAbsolute=Re}if(w=w||O,!!O&&(P(d,!0),k&&(i||K||!D&&M))){const[se,le]=Ep({nodeId:D,dragItems:d,nodeLookup:R});i==null||i(k,d,se,le),K==null||K(k,se,le),D||M==null||M(k,le)}}async function V(){if(!x)return;const{transform:B,panBy:X,autoPanSpeed:R,autoPanOnNodeDrag:H}=t();if(!H){m=!1,cancelAnimationFrame(c);return}const[$,G]=_k(f,x,R);($!==0||G!==0)&&(o.x=(o.x??0)-$/B[2],o.y=(o.y??0)-G/B[2],await X({x:$,y:G})&&q(o)),c=requestAnimationFrame(V)}function L(B){var Z;const{nodeLookup:X,multiSelectionActive:R,nodesDraggable:H,transform:$,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:M,onSelectionDragStart:U,unselectNodesAndEdges:P}=t();p=!0,(!K||!z)&&!R&&D&&((Z=X.get(D))!=null&&Z.selected||P()),z&&K&&D&&(e==null||e(D));const O=Bc(B.sourceEvent,{transform:$,snapGrid:G,snapToGrid:Q,containerBounds:x});if(o=O,d=Sz(X,H,O,D),d.size>0&&(n||M||!D&&U)){const[ee,J]=Ep({nodeId:D,dragItems:d,nodeLookup:X});n==null||n(B.sourceEvent,d,ee,J),M==null||M(B.sourceEvent,ee,J),D||U==null||U(B.sourceEvent,J)}}const _=dk().clickDistance(F).on("start",B=>{const{domNode:X,nodeDragThreshold:R,transform:H,snapGrid:$,snapToGrid:G}=t();x=(X==null?void 0:X.getBoundingClientRect())||null,g=!1,w=!1,k=B.sourceEvent,R===0&&L(B),o=Bc(B.sourceEvent,{transform:H,snapGrid:$,snapToGrid:G,containerBounds:x}),f=Ci(B.sourceEvent,x)}).on("drag",B=>{const{autoPanOnNodeDrag:X,transform:R,snapGrid:H,snapToGrid:$,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Bc(B.sourceEvent,{transform:R,snapGrid:H,snapToGrid:$,containerBounds:x});if(k=B.sourceEvent,(B.sourceEvent.type==="touchmove"&&B.sourceEvent.touches.length>1||D&&!Q.has(D))&&(g=!0),!g){if(!m&&X&&p&&(m=!0,V()),!p){const M=Ci(B.sourceEvent,x),U=M.x-f.x,P=M.y-f.y;Math.sqrt(U*U+P*P)>G&&L(B)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&d&&p&&(f=Ci(B.sourceEvent,x),q(K))}}).on("end",B=>{if(!(!p||g)&&(m=!1,p=!1,cancelAnimationFrame(c),d.size>0)){const{nodeLookup:X,updateNodePositions:R,onNodeDragStop:H,onSelectionDragStop:$}=t();if(w&&(R(d,!1),w=!1),a||H||!D&&$){const[G,Q]=Ep({nodeId:D,dragItems:d,nodeLookup:X,dragging:!1});a==null||a(B.sourceEvent,d,G,Q),H==null||H(B.sourceEvent,G,Q),D||$==null||$(B.sourceEvent,Q)}}}).filter(B=>{const X=B.target;return!B.button&&(!N||!cw(X,`.${N}`,A))&&(!E||cw(X,E,A))});y.call(_)}function C(){y==null||y.on(".drag",null)}return{update:j,destroy:C}}function Nz(e,t,n){const i=[],a={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())Vc(a,xo(o))>0&&i.push(o);return i}const Ez=250;function Az(e,t,n,i){var d,m;let a=[],o=1/0;const c=Nz(e,n,t+Ez);for(const f of c){const x=[...((d=f.internals.handleBounds)==null?void 0:d.source)??[],...((m=f.internals.handleBounds)==null?void 0:m.target)??[]];for(const p of x){if(i.nodeId===p.nodeId&&i.type===p.type&&i.id===p.id)continue;const{x:y,y:g}=yl(f,p,p.position,!0),w=Math.sqrt(Math.pow(y-e.x,2)+Math.pow(g-e.y,2));w>t||(w<o?(a=[{...p,x:y,y:g}],o=w):w===o&&a.push({...p,x:y,y:g}))}}if(!a.length)return null;if(a.length>1){const f=i.type==="source"?"target":"source";return a.find(x=>x.type===f)??a[0]}return a[0]}function Xk(e,t,n,i,a,o=!1){var f,x,p;const c=i.get(e);if(!c)return null;const d=a==="strict"?(f=c.internals.handleBounds)==null?void 0:f[t]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((p=c.internals.handleBounds)==null?void 0:p.target)??[]],m=(n?d==null?void 0:d.find(y=>y.id===n):d==null?void 0:d[0])??null;return m&&o?{...m,...yl(c,m,m.position,!0)}:m}function Vk(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Dz(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Wk=()=>!0;function Tz(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:a,edgeUpdaterType:o,isTarget:c,domNode:d,nodeLookup:m,lib:f,autoPanOnConnect:x,flowId:p,panBy:y,cancelConnection:g,onConnectStart:w,onConnect:k,onConnectEnd:j,isValidConnection:C=Wk,onReconnectEnd:N,updateConnection:E,getTransform:A,getFromHandle:z,autoPanSpeed:D,dragThreshold:F=1,handleDomNode:q}){const V=zk(e.target);let L=0,_;const{x:B,y:X}=Ci(e),R=Vk(o,q),H=d==null?void 0:d.getBoundingClientRect();let $=!1;if(!H||!R)return;const G=Xk(a,R,i,m,t);if(!G)return;let Q=Ci(e,H),K=!1,M=null,U=!1,P=null;function O(){if(!x||!H)return;const[Ee,Re]=_k(Q,H,D);y({x:Ee,y:Re}),L=requestAnimationFrame(O)}const Z={...G,nodeId:a,type:R,position:G.position},ee=m.get(a);let se={inProgress:!0,isValid:null,from:yl(ee,Z,at.Left,!0),fromHandle:Z,fromPosition:Z.position,fromNode:ee,to:Q,toHandle:null,toPosition:Qv[Z.position],toNode:null,pointer:Q};function le(){$=!0,E(se),w==null||w(e,{nodeId:a,handleId:i,handleType:R})}F===0&&le();function ye(Ee){if(!$){const{x:it,y:ht}=Ci(Ee),Ye=it-B,nt=ht-X;if(!(Ye*Ye+nt*nt>F*F))return;le()}if(!z()||!Z){De(Ee);return}const Re=A();Q=Ci(Ee,H),_=Az(ou(Q,Re,!1,[1,1]),n,m,Z),K||(O(),K=!0);const me=Gk(Ee,{handle:_,connectionMode:t,fromNodeId:a,fromHandleId:i,fromType:c?"target":"source",isValidConnection:C,doc:V,lib:f,flowId:p,nodeLookup:m});P=me.handleDomNode,M=me.connection,U=Dz(!!_,me.isValid);const Fe=m.get(a),Je=Fe?yl(Fe,Z,at.Left,!0):se.from,Pe={...se,from:Je,isValid:U,to:me.toHandle&&U?_f({x:me.toHandle.x,y:me.toHandle.y},Re):Q,toHandle:me.toHandle,toPosition:U&&me.toHandle?me.toHandle.position:Qv[Z.position],toNode:me.toHandle?m.get(me.toHandle.nodeId):null,pointer:Q};E(Pe),se=Pe}function De(Ee){if(!("touches"in Ee&&Ee.touches.length>0)){if($){(_||P)&&M&&U&&(k==null||k(M));const{inProgress:Re,...me}=se,Fe={...me,toPosition:se.toHandle?se.toPosition:null};j==null||j(Ee,Fe),o&&(N==null||N(Ee,Fe))}g(),cancelAnimationFrame(L),K=!1,U=!1,M=null,P=null,V.removeEventListener("mousemove",ye),V.removeEventListener("mouseup",De),V.removeEventListener("touchmove",ye),V.removeEventListener("touchend",De)}}V.addEventListener("mousemove",ye),V.addEventListener("mouseup",De),V.addEventListener("touchmove",ye),V.addEventListener("touchend",De)}function Gk(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:a,fromType:o,doc:c,lib:d,flowId:m,isValidConnection:f=Wk,nodeLookup:x}){const p=o==="target",y=t?c.querySelector(`.${d}-flow__handle[data-id="${m}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:g,y:w}=Ci(e),k=c.elementFromPoint(g,w),j=k!=null&&k.classList.contains(`${d}-flow__handle`)?k:y,C={handleDomNode:j,isValid:!1,connection:null,toHandle:null};if(j){const N=Vk(void 0,j),E=j.getAttribute("data-nodeid"),A=j.getAttribute("data-handleid"),z=j.classList.contains("connectable"),D=j.classList.contains("connectableend");if(!E||!N)return C;const F={source:p?E:i,sourceHandle:p?A:a,target:p?i:E,targetHandle:p?a:A};C.connection=F;const V=z&&D&&(n===mo.Strict?p&&N==="source"||!p&&N==="target":E!==i||A!==a);C.isValid=V&&f(F),C.toHandle=Xk(E,N,A,x,n,!0)}return C}const Bx={onPointerDown:Tz,isValid:Gk};function _z({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const a=Vr(e);function o({translateExtent:d,width:m,height:f,zoomStep:x=1,pannable:p=!0,zoomable:y=!0,inversePan:g=!1}){const w=E=>{if(E.sourceEvent.type!=="wheel"||!t)return;const A=n(),z=E.sourceEvent.ctrlKey&&Wc()?10:1,D=-E.sourceEvent.deltaY*(E.sourceEvent.deltaMode===1?.05:E.sourceEvent.deltaMode?1:.002)*x,F=A[2]*Math.pow(2,D*z);t.scaleTo(F)};let k=[0,0];const j=E=>{(E.sourceEvent.type==="mousedown"||E.sourceEvent.type==="touchstart")&&(k=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY])},C=E=>{const A=n();if(E.sourceEvent.type!=="mousemove"&&E.sourceEvent.type!=="touchmove"||!t)return;const z=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY],D=[z[0]-k[0],z[1]-k[1]];k=z;const F=i()*Math.max(A[2],Math.log(A[2]))*(g?-1:1),q={x:A[0]-D[0]*F,y:A[1]-D[1]*F},V=[[0,0],[m,f]];t.setViewportConstrained({x:q.x,y:q.y,zoom:A[2]},V,d)},N=Sk().on("start",j).on("zoom",p?C:null).on("zoom.wheel",y?w:null);a.call(N,{})}function c(){a.on("zoom",null)}return{update:o,destroy:c,pointer:wi}}const Wf=e=>({x:e.x,y:e.y,zoom:e.k}),Ap=({x:e,y:t,zoom:n})=>Pf.translate(e,t).scale(n),no=(e,t)=>e.target.closest(`.${t}`),Kk=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Mz=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Dp=(e,t=0,n=Mz,i=()=>{})=>{const a=typeof t=="number"&&t>0;return a||i(),a?e.transition().duration(t).ease(n).on("end",i):e},Qk=e=>{const t=e.ctrlKey&&Wc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fz({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:c,onPanZoomStart:d,onPanZoom:m,onPanZoomEnd:f}){return x=>{if(no(x,t))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(x.ctrlKey&&c){const j=wi(x),C=Qk(x),N=p*Math.pow(2,C);i.scaleTo(n,N,j,x);return}const y=x.deltaMode===1?20:1;let g=a===dl.Vertical?0:x.deltaX*y,w=a===dl.Horizontal?0:x.deltaY*y;!Wc()&&x.shiftKey&&a!==dl.Vertical&&(g=x.deltaY*y,w=0),i.translateBy(n,-(g/p)*o,-(w/p)*o,{internal:!0});const k=Wf(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(m==null||m(x,k),e.panScrollTimeout=setTimeout(()=>{f==null||f(x,k),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,d==null||d(x,k))}}function Rz({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,a){const o=i.type==="wheel",c=!t&&o&&!i.ctrlKey,d=no(i,e);if(i.ctrlKey&&o&&d&&i.preventDefault(),c||d)return null;i.preventDefault(),n.call(this,i,a)}}function zz({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var o,c,d;if((o=i.sourceEvent)!=null&&o.internal)return;const a=Wf(i.transform);e.mouseButton=((c=i.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((d=i.sourceEvent)==null?void 0:d.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,a))}}function Bz({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:a}){return o=>{var c,d;e.usedRightMouseButton=!!(n&&Kk(t,e.mouseButton??0)),(c=o.sourceEvent)!=null&&c.sync||i([o.transform.x,o.transform.y,o.transform.k]),a&&!((d=o.sourceEvent)!=null&&d.internal)&&(a==null||a(o.sourceEvent,Wf(o.transform)))}}function $z({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:a,onPaneContextMenu:o}){return c=>{var d;if(!((d=c.sourceEvent)!=null&&d.internal)&&(e.isZoomingOrPanning=!1,o&&Kk(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&o(c.sourceEvent),e.usedRightMouseButton=!1,i(!1),a)){const m=Wf(c.transform);e.prevViewport=m,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,m)},n?150:0)}}}function Oz({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:c,noWheelClassName:d,noPanClassName:m,lib:f,connectionInProgress:x}){return p=>{var j;const y=e||t,g=n&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(no(p,`${f}-flow__node`)||no(p,`${f}-flow__edge`)))return!0;if(!i&&!y&&!a&&!o&&!n||c||x&&!w||no(p,d)&&w||no(p,m)&&(!w||a&&w&&!e)||!n&&p.ctrlKey&&w)return!1;if(!n&&p.type==="touchstart"&&((j=p.touches)==null?void 0:j.length)>1)return p.preventDefault(),!1;if(!y&&!a&&!g&&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 Lz({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:a,onPanZoom:o,onPanZoomStart:c,onPanZoomEnd:d,onDraggingChange:m}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=e.getBoundingClientRect(),p=Sk().scaleExtent([t,n]).translateExtent(i),y=Vr(e).call(p);N({x:a.x,y:a.y,zoom:po(a.zoom,t,n)},[[0,0],[x.width,x.height]],i);const g=y.on("wheel.zoom"),w=y.on("dblclick.zoom");p.wheelDelta(Qk);function k(_,B){return y?new Promise(X=>{p==null||p.interpolate((B==null?void 0:B.interpolate)==="linear"?zc:of).transform(Dp(y,B==null?void 0:B.duration,B==null?void 0:B.ease,()=>X(!0)),_)}):Promise.resolve(!1)}function j({noWheelClassName:_,noPanClassName:B,onPaneContextMenu:X,userSelectionActive:R,panOnScroll:H,panOnDrag:$,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:M,zoomOnScroll:U,zoomOnDoubleClick:P,zoomActivationKeyPressed:O,lib:Z,onTransformChange:ee,connectionInProgress:J,paneClickDistance:se,selectionOnDrag:le}){R&&!f.isZoomingOrPanning&&C();const ye=H&&!O&&!R;p.clickDistance(le?1/0:!ji(se)||se<0?0:se);const De=ye?Fz({zoomPanValues:f,noWheelClassName:_,d3Selection:y,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:M,onPanZoomStart:c,onPanZoom:o,onPanZoomEnd:d}):Rz({noWheelClassName:_,preventScrolling:K,d3ZoomHandler:g});if(y.on("wheel.zoom",De,{passive:!1}),!R){const Re=zz({zoomPanValues:f,onDraggingChange:m,onPanZoomStart:c});p.on("start",Re);const me=Bz({zoomPanValues:f,panOnDrag:$,onPaneContextMenu:!!X,onPanZoom:o,onTransformChange:ee});p.on("zoom",me);const Fe=$z({zoomPanValues:f,panOnDrag:$,panOnScroll:H,onPaneContextMenu:X,onPanZoomEnd:d,onDraggingChange:m});p.on("end",Fe)}const Ee=Oz({zoomActivationKeyPressed:O,panOnDrag:$,zoomOnScroll:U,panOnScroll:H,zoomOnDoubleClick:P,zoomOnPinch:M,userSelectionActive:R,noPanClassName:B,noWheelClassName:_,lib:Z,connectionInProgress:J});p.filter(Ee),P?y.on("dblclick.zoom",w):y.on("dblclick.zoom",null)}function C(){p.on("zoom",null)}async function N(_,B,X){const R=Ap(_),H=p==null?void 0:p.constrain()(R,B,X);return H&&await k(H),new Promise($=>$(H))}async function E(_,B){const X=Ap(_);return await k(X,B),new Promise(R=>R(X))}function A(_){if(y){const B=Ap(_),X=y.property("__zoom");(X.k!==_.zoom||X.x!==_.x||X.y!==_.y)&&(p==null||p.transform(y,B,null,{sync:!0}))}}function z(){const _=y?kk(y.node()):{x:0,y:0,k:1};return{x:_.x,y:_.y,zoom:_.k}}function D(_,B){return y?new Promise(X=>{p==null||p.interpolate((B==null?void 0:B.interpolate)==="linear"?zc:of).scaleTo(Dp(y,B==null?void 0:B.duration,B==null?void 0:B.ease,()=>X(!0)),_)}):Promise.resolve(!1)}function F(_,B){return y?new Promise(X=>{p==null||p.interpolate((B==null?void 0:B.interpolate)==="linear"?zc:of).scaleBy(Dp(y,B==null?void 0:B.duration,B==null?void 0:B.ease,()=>X(!0)),_)}):Promise.resolve(!1)}function q(_){p==null||p.scaleExtent(_)}function V(_){p==null||p.translateExtent(_)}function L(_){const B=!ji(_)||_<0?0:_;p==null||p.clickDistance(B)}return{update:j,destroy:C,setViewport:E,setViewportConstrained:N,getViewport:z,scaleTo:D,scaleBy:F,setScaleExtent:q,setTranslateExtent:V,syncViewport:A,setClickDistance:L}}var yo;(function(e){e.Line="line",e.Handle="handle"})(yo||(yo={}));function Iz({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:a,affectsY:o}){const c=e-t,d=n-i,m=[c>0?1:c<0?-1:0,d>0?1:d<0?-1:0];return c&&a&&(m[0]=m[0]*-1),d&&o&&(m[1]=m[1]*-1),m}function uw(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:a}}function xa(e,t){return Math.max(0,t-e)}function ga(e,t){return Math.max(0,e-t)}function Yd(e,t,n){return Math.max(0,t-e,e-n)}function dw(e,t){return e?!t:t}function Hz(e,t,n,i,a,o,c,d){let{affectsX:m,affectsY:f}=t;const{isHorizontal:x,isVertical:p}=t,y=x&&p,{xSnapped:g,ySnapped:w}=n,{minWidth:k,maxWidth:j,minHeight:C,maxHeight:N}=i,{x:E,y:A,width:z,height:D,aspectRatio:F}=e;let q=Math.floor(x?g-e.pointerX:0),V=Math.floor(p?w-e.pointerY:0);const L=z+(m?-q:q),_=D+(f?-V:V),B=-o[0]*z,X=-o[1]*D;let R=Yd(L,k,j),H=Yd(_,C,N);if(c){let Q=0,K=0;m&&q<0?Q=xa(E+q+B,c[0][0]):!m&&q>0&&(Q=ga(E+L+B,c[1][0])),f&&V<0?K=xa(A+V+X,c[0][1]):!f&&V>0&&(K=ga(A+_+X,c[1][1])),R=Math.max(R,Q),H=Math.max(H,K)}if(d){let Q=0,K=0;m&&q>0?Q=ga(E+q,d[0][0]):!m&&q<0&&(Q=xa(E+L,d[1][0])),f&&V>0?K=ga(A+V,d[0][1]):!f&&V<0&&(K=xa(A+_,d[1][1])),R=Math.max(R,Q),H=Math.max(H,K)}if(a){if(x){const Q=Yd(L/F,C,N)*F;if(R=Math.max(R,Q),c){let K=0;!m&&!f||m&&!f&&y?K=ga(A+X+L/F,c[1][1])*F:K=xa(A+X+(m?q:-q)/F,c[0][1])*F,R=Math.max(R,K)}if(d){let K=0;!m&&!f||m&&!f&&y?K=xa(A+L/F,d[1][1])*F:K=ga(A+(m?q:-q)/F,d[0][1])*F,R=Math.max(R,K)}}if(p){const Q=Yd(_*F,k,j)/F;if(H=Math.max(H,Q),c){let K=0;!m&&!f||f&&!m&&y?K=ga(E+_*F+B,c[1][0])/F:K=xa(E+(f?V:-V)*F+B,c[0][0])/F,H=Math.max(H,K)}if(d){let K=0;!m&&!f||f&&!m&&y?K=xa(E+_*F,d[1][0])/F:K=ga(E+(f?V:-V)*F,d[0][0])/F,H=Math.max(H,K)}}}V=V+(V<0?H:-H),q=q+(q<0?R:-R),a&&(y?L>_*F?V=(dw(m,f)?-q:q)/F:q=(dw(m,f)?-V:V)*F:x?(V=q/F,f=m):(q=V*F,m=f));const $=m?E+q:E,G=f?A+V:A;return{width:z+(m?-q:q),height:D+(f?-V:V),x:o[0]*q*(m?-1:1)+$,y:o[1]*V*(f?-1:1)+G}}const Zk={width:0,height:0,x:0,y:0},Uz={...Zk,pointerX:0,pointerY:0,aspectRatio:1};function qz(e){return[[0,0],[e.measured.width,e.measured.height]]}function Yz(e,t,n){const i=t.position.x+e.position.x,a=t.position.y+e.position.y,o=e.measured.width??0,c=e.measured.height??0,d=n[0]*o,m=n[1]*c;return[[i-d,a-m],[i+o-d,a+c-m]]}function Pz({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:a}){const o=Vr(e);let c={controlDirection:uw("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function d({controlPosition:f,boundaries:x,keepAspectRatio:p,resizeDirection:y,onResizeStart:g,onResize:w,onResizeEnd:k,shouldResize:j}){let C={...Zk},N={...Uz};c={boundaries:x,resizeDirection:y,keepAspectRatio:p,controlDirection:uw(f)};let E,A=null,z=[],D,F,q,V=!1;const L=dk().on("start",_=>{const{nodeLookup:B,transform:X,snapGrid:R,snapToGrid:H,nodeOrigin:$,paneDomNode:G}=n();if(E=B.get(t),!E)return;A=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Bc(_.sourceEvent,{transform:X,snapGrid:R,snapToGrid:H,containerBounds:A});C={width:E.measured.width??0,height:E.measured.height??0,x:E.position.x??0,y:E.position.y??0},N={...C,pointerX:Q,pointerY:K,aspectRatio:C.width/C.height},D=void 0,E.parentId&&(E.extent==="parent"||E.expandParent)&&(D=B.get(E.parentId),F=D&&E.extent==="parent"?qz(D):void 0),z=[],q=void 0;for(const[M,U]of B)if(U.parentId===t&&(z.push({id:M,position:{...U.position},extent:U.extent}),U.extent==="parent"||U.expandParent)){const P=Yz(U,E,U.origin??$);q?q=[[Math.min(P[0][0],q[0][0]),Math.min(P[0][1],q[0][1])],[Math.max(P[1][0],q[1][0]),Math.max(P[1][1],q[1][1])]]:q=P}g==null||g(_,{...C})}).on("drag",_=>{const{transform:B,snapGrid:X,snapToGrid:R,nodeOrigin:H}=n(),$=Bc(_.sourceEvent,{transform:B,snapGrid:X,snapToGrid:R,containerBounds:A}),G=[];if(!E)return;const{x:Q,y:K,width:M,height:U}=C,P={},O=E.origin??H,{width:Z,height:ee,x:J,y:se}=Hz(N,c.controlDirection,$,c.boundaries,c.keepAspectRatio,O,F,q),le=Z!==M,ye=ee!==U,De=J!==Q&&le,Ee=se!==K&&ye;if(!De&&!Ee&&!le&&!ye)return;if((De||Ee||O[0]===1||O[1]===1)&&(P.x=De?J:C.x,P.y=Ee?se:C.y,C.x=P.x,C.y=P.y,z.length>0)){const Je=J-Q,Pe=se-K;for(const it of z)it.position={x:it.position.x-Je+O[0]*(Z-M),y:it.position.y-Pe+O[1]*(ee-U)},G.push(it)}if((le||ye)&&(P.width=le&&(!c.resizeDirection||c.resizeDirection==="horizontal")?Z:C.width,P.height=ye&&(!c.resizeDirection||c.resizeDirection==="vertical")?ee:C.height,C.width=P.width,C.height=P.height),D&&E.expandParent){const Je=O[0]*(P.width??0);P.x&&P.x<Je&&(C.x=Je,N.x=N.x-(P.x-Je));const Pe=O[1]*(P.height??0);P.y&&P.y<Pe&&(C.y=Pe,N.y=N.y-(P.y-Pe))}const Re=Iz({width:C.width,prevWidth:M,height:C.height,prevHeight:U,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),me={...C,direction:Re};(j==null?void 0:j(_,me))!==!1&&(V=!0,w==null||w(_,me),i(P,G))}).on("end",_=>{V&&(k==null||k(_,{...C}),a==null||a({...C}),V=!1)});o.call(L)}function m(){o.on(".drag",null)}return{update:d,destroy:m}}var Tp={exports:{}},_p={},Mp={exports:{}},Fp={};/**
91
+ * @license React
92
+ * use-sync-external-store-shim.production.js
93
+ *
94
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
95
+ *
96
+ * This source code is licensed under the MIT license found in the
97
+ * LICENSE file in the root directory of this source tree.
98
+ */var fw;function Xz(){if(fw)return Fp;fw=1;var e=Qc();function t(p,y){return p===y&&(p!==0||1/p===1/y)||p!==p&&y!==y}var n=typeof Object.is=="function"?Object.is:t,i=e.useState,a=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function d(p,y){var g=y(),w=i({inst:{value:g,getSnapshot:y}}),k=w[0].inst,j=w[1];return o(function(){k.value=g,k.getSnapshot=y,m(k)&&j({inst:k})},[p,g,y]),a(function(){return m(k)&&j({inst:k}),p(function(){m(k)&&j({inst:k})})},[p]),c(g),g}function m(p){var y=p.getSnapshot;p=p.value;try{var g=y();return!n(p,g)}catch{return!0}}function f(p,y){return y()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:d;return Fp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,Fp}var hw;function Vz(){return hw||(hw=1,Mp.exports=Xz()),Mp.exports}/**
99
+ * @license React
100
+ * use-sync-external-store-shim/with-selector.production.js
101
+ *
102
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
103
+ *
104
+ * This source code is licensed under the MIT license found in the
105
+ * LICENSE file in the root directory of this source tree.
106
+ */var mw;function Wz(){if(mw)return _p;mw=1;var e=Qc(),t=Vz();function n(f,x){return f===x&&(f!==0||1/f===1/x)||f!==f&&x!==x}var i=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,d=e.useMemo,m=e.useDebugValue;return _p.useSyncExternalStoreWithSelector=function(f,x,p,y,g){var w=o(null);if(w.current===null){var k={hasValue:!1,value:null};w.current=k}else k=w.current;w=d(function(){function C(D){if(!N){if(N=!0,E=D,D=y(D),g!==void 0&&k.hasValue){var F=k.value;if(g(F,D))return A=F}return A=D}if(F=A,i(E,D))return F;var q=y(D);return g!==void 0&&g(F,q)?(E=D,F):(E=D,A=q)}var N=!1,E,A,z=p===void 0?null:p;return[function(){return C(x())},z===null?void 0:function(){return C(z())}]},[x,p,y,g]);var j=a(f,w[0],w[1]);return c(function(){k.hasValue=!0,k.value=j},[j]),m(j),j},_p}var pw;function Gz(){return pw||(pw=1,Tp.exports=Wz()),Tp.exports}var Kz=Gz();const Qz=zf(Kz),Zz={},xw=e=>{let t;const n=new Set,i=(x,p)=>{const y=typeof x=="function"?x(t):x;if(!Object.is(y,t)){const g=t;t=p??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(w=>w(t,g))}},a=()=>t,m={setState:i,getState:a,getInitialState:()=>f,subscribe:x=>(n.add(x),()=>n.delete(x)),destroy:()=>{(Zz?"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."),n.clear()}},f=t=e(i,a,m);return m},Jz=e=>e?xw(e):xw,{useDebugValue:e9}=z4,{useSyncExternalStoreWithSelector:t9}=Qz,n9=e=>e;function Jk(e,t=n9,n){const i=t9(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return e9(i),i}const gw=(e,t)=>{const n=Jz(e),i=(a,o=t)=>Jk(n,a,o);return Object.assign(i,n),i},r9=(e,t)=>e?gw(e,t):gw;function An(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[i,a]of e)if(!Object.is(a,t.get(i)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||!Object.is(e[i],t[i]))return!1;return!0}g2();const Gf=S.createContext(null),i9=Gf.Provider,e3=Ji.error001();function qt(e,t){const n=S.useContext(Gf);if(n===null)throw new Error(e3);return Jk(n,e,t)}function Dn(){const e=S.useContext(Gf);if(e===null)throw new Error(e3);return S.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const yw={display:"none"},s9={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},t3="react-flow__node-desc",n3="react-flow__edge-desc",a9="react-flow__aria-live",l9=e=>e.ariaLiveMessage,o9=e=>e.ariaLabelConfig;function c9({rfId:e}){const t=qt(l9);return l.jsx("div",{id:`${a9}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:s9,children:t})}function u9({rfId:e,disableKeyboardA11y:t}){const n=qt(o9);return l.jsxs(l.Fragment,{children:[l.jsx("div",{id:`${t3}-${e}`,style:yw,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),l.jsx("div",{id:`${n3}-${e}`,style:yw,children:n["edge.a11yDescription.default"]}),!t&&l.jsx(c9,{rfId:e})]})}const Kf=S.forwardRef(({position:e="top-left",children:t,className:n,style:i,...a},o)=>{const c=`${e}`.split("-");return l.jsx("div",{className:Yn(["react-flow__panel",n,...c]),style:i,ref:o,...a,children:t})});Kf.displayName="Panel";function d9({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:l.jsx(Kf,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:l.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const f9=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Pd=e=>e.id;function h9(e,t){return An(e.selectedNodes.map(Pd),t.selectedNodes.map(Pd))&&An(e.selectedEdges.map(Pd),t.selectedEdges.map(Pd))}function m9({onSelectionChange:e}){const t=Dn(),{selectedNodes:n,selectedEdges:i}=qt(f9,h9);return S.useEffect(()=>{const a={nodes:n,edges:i};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[n,i,e]),null}const p9=e=>!!e.onSelectionChangeHandlers;function x9({onSelectionChange:e}){const t=qt(p9);return e||t?l.jsx(m9,{onSelectionChange:e}):null}const r3=[0,0],g9={x:0,y:0,zoom:1},y9=["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"],bw=[...y9,"rfId"],b9=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}),vw={translateExtent:Pc,nodeOrigin:r3,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function v9(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:c,reset:d,setDefaultNodesAndEdges:m}=qt(b9,An),f=Dn();S.useEffect(()=>(m(e.defaultNodes,e.defaultEdges),()=>{x.current=vw,d()}),[]);const x=S.useRef(vw);return S.useEffect(()=>{for(const p of bw){const y=e[p],g=x.current[p];y!==g&&(typeof e[p]>"u"||(p==="nodes"?t(y):p==="edges"?n(y):p==="minZoom"?i(y):p==="maxZoom"?a(y):p==="translateExtent"?o(y):p==="nodeExtent"?c(y):p==="ariaLabelConfig"?f.setState({ariaLabelConfig:rz(y)}):p==="fitView"?f.setState({fitViewQueued:y}):p==="fitViewOptions"?f.setState({fitViewOptions:y}):f.setState({[p]:y})))}x.current=e},bw.map(p=>e[p])),null}function ww(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function w9(e){var i;const[t,n]=S.useState(e==="system"?null:e);return S.useEffect(()=>{if(e!=="system"){n(e);return}const a=ww(),o=()=>n(a!=null&&a.matches?"dark":"light");return o(),a==null||a.addEventListener("change",o),()=>{a==null||a.removeEventListener("change",o)}},[e]),t!==null?t:(i=ww())!=null&&i.matches?"dark":"light"}const kw=typeof document<"u"?document:null;function Gc(e=null,t={target:kw,actInsideInputWithModifier:!0}){const[n,i]=S.useState(!1),a=S.useRef(!1),o=S.useRef(new Set([])),[c,d]=S.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
107
+ `).replace(`
108
+
109
+ `,`
110
+ +`).split(`
111
+ `)),x=f.reduce((p,y)=>p.concat(...y),[]);return[f,x]}return[[],[]]},[e]);return S.useEffect(()=>{const m=(t==null?void 0:t.target)??kw,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const x=g=>{var j,C;if(a.current=g.ctrlKey||g.metaKey||g.shiftKey||g.altKey,(!a.current||a.current&&!f)&&Bk(g))return!1;const k=jw(g.code,d);if(o.current.add(g[k]),Sw(c,o.current,!1)){const N=((C=(j=g.composedPath)==null?void 0:j.call(g))==null?void 0:C[0])||g.target,E=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(a.current||!E)&&g.preventDefault(),i(!0)}},p=g=>{const w=jw(g.code,d);Sw(c,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(g[w]),g.key==="Meta"&&o.current.clear(),a.current=!1},y=()=>{o.current.clear(),i(!1)};return m==null||m.addEventListener("keydown",x),m==null||m.addEventListener("keyup",p),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{m==null||m.removeEventListener("keydown",x),m==null||m.removeEventListener("keyup",p),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[e,i]),n}function Sw(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(a=>t.has(a)))}function jw(e,t){return t.includes(e)?"code":"key"}const k9=()=>{const e=Dn();return S.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,a,o],panZoom:c}=e.getState();return c?(await c.setViewport({x:t.x??i,y:t.y??a,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:a,minZoom:o,maxZoom:c,panZoom:d}=e.getState(),m=_0(t,i,a,o,c,(n==null?void 0:n.padding)??.1);return d?(await d.setViewport(m,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:a,snapToGrid:o,domNode:c}=e.getState();if(!c)return t;const{x:d,y:m}=c.getBoundingClientRect(),f={x:t.x-d,y:t.y-m},x=n.snapGrid??a,p=n.snapToGrid??o;return ou(f,i,p,x)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:a,y:o}=i.getBoundingClientRect(),c=_f(t,n);return{x:c.x+a,y:c.y+o}}}),[])};function i3(e,t){const n=[],i=new Map,a=[];for(const o of e)if(o.type==="add"){a.push(o);continue}else if(o.type==="remove"||o.type==="replace")i.set(o.id,[o]);else{const c=i.get(o.id);c?c.push(o):i.set(o.id,[o])}for(const o of t){const c=i.get(o.id);if(!c){n.push(o);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){n.push({...c[0].item});continue}const d={...o};for(const m of c)S9(m,d);n.push(d)}return a.length&&a.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function S9(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function j9(e,t){return i3(e,t)}function C9(e,t){return i3(e,t)}function rl(e,t){return{id:e,type:"select",selected:t}}function ro(e,t=new Set,n=!1){const i=[];for(const[a,o]of e){const c=t.has(a);!(o.selected===void 0&&!c)&&o.selected!==c&&(n&&(o.selected=c),i.push(rl(o.id,c)))}return i}function Cw({items:e=[],lookup:t}){var a;const n=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,c]of e.entries()){const d=t.get(c.id),m=((a=d==null?void 0:d.internals)==null?void 0:a.userNode)??d;m!==void 0&&m!==c&&n.push({id:c.id,item:c,type:"replace"}),m===void 0&&n.push({item:c,type:"add",index:o})}for(const[o]of t)i.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function Nw(e){return{id:e.id,type:"remove"}}const Ew=e=>VR(e),N9=e=>Ak(e);function s3(e){return S.forwardRef(e)}const E9=typeof window<"u"?S.useLayoutEffect:S.useEffect;function Aw(e){const[t,n]=S.useState(BigInt(0)),[i]=S.useState(()=>A9(()=>n(a=>a+BigInt(1))));return E9(()=>{const a=i.get();a.length&&(e(a),i.reset())},[t]),i}function A9(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const a3=S.createContext(null);function D9({children:e}){const t=Dn(),n=S.useCallback(d=>{const{nodes:m=[],setNodes:f,hasDefaultNodes:x,onNodesChange:p,nodeLookup:y,fitViewQueued:g,onNodesChangeMiddlewareMap:w}=t.getState();let k=m;for(const C of d)k=typeof C=="function"?C(k):C;let j=Cw({items:k,lookup:y});for(const C of w.values())j=C(j);x&&f(k),j.length>0?p==null||p(j):g&&window.requestAnimationFrame(()=>{const{fitViewQueued:C,nodes:N,setNodes:E}=t.getState();C&&E(N)})},[]),i=Aw(n),a=S.useCallback(d=>{const{edges:m=[],setEdges:f,hasDefaultEdges:x,onEdgesChange:p,edgeLookup:y}=t.getState();let g=m;for(const w of d)g=typeof w=="function"?w(g):w;x?f(g):p&&p(Cw({items:g,lookup:y}))},[]),o=Aw(a),c=S.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return l.jsx(a3.Provider,{value:c,children:e})}function T9(){const e=S.useContext(a3);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const _9=e=>!!e.panZoom;function O0(){const e=k9(),t=Dn(),n=T9(),i=qt(_9),a=S.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),c=p=>{n.nodeQueue.push(p)},d=p=>{n.edgeQueue.push(p)},m=p=>{var C,N;const{nodeLookup:y,nodeOrigin:g}=t.getState(),w=Ew(p)?p:y.get(p.id),k=w.parentId?Rk(w.position,w.measured,w.parentId,y,g):w.position,j={...w,position:k,width:((C=w.measured)==null?void 0:C.width)??w.width,height:((N=w.measured)==null?void 0:N.height)??w.height};return xo(j)},f=(p,y,g={replace:!1})=>{c(w=>w.map(k=>{if(k.id===p){const j=typeof y=="function"?y(k):y;return g.replace&&Ew(j)?j:{...k,...j}}return k}))},x=(p,y,g={replace:!1})=>{d(w=>w.map(k=>{if(k.id===p){const j=typeof y=="function"?y(k):y;return g.replace&&N9(j)?j:{...k,...j}}return k}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var y;return(y=o(p))==null?void 0:y.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(y=>({...y}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:c,setEdges:d,addNodes:p=>{const y=Array.isArray(p)?p:[p];n.nodeQueue.push(g=>[...g,...y])},addEdges:p=>{const y=Array.isArray(p)?p:[p];n.edgeQueue.push(g=>[...g,...y])},toObject:()=>{const{nodes:p=[],edges:y=[],transform:g}=t.getState(),[w,k,j]=g;return{nodes:p.map(C=>({...C})),edges:y.map(C=>({...C})),viewport:{x:w,y:k,zoom:j}}},deleteElements:async({nodes:p=[],edges:y=[]})=>{const{nodes:g,edges:w,onNodesDelete:k,onEdgesDelete:j,triggerNodeChanges:C,triggerEdgeChanges:N,onDelete:E,onBeforeDelete:A}=t.getState(),{nodes:z,edges:D}=await ZR({nodesToRemove:p,edgesToRemove:y,nodes:g,edges:w,onBeforeDelete:A}),F=D.length>0,q=z.length>0;if(F){const V=D.map(Nw);j==null||j(D),N(V)}if(q){const V=z.map(Nw);k==null||k(z),C(V)}return(q||F)&&(E==null||E({nodes:z,edges:D})),{deletedNodes:z,deletedEdges:D}},getIntersectingNodes:(p,y=!0,g)=>{const w=Jv(p),k=w?p:m(p),j=g!==void 0;return k?(g||t.getState().nodes).filter(C=>{const N=t.getState().nodeLookup.get(C.id);if(N&&!w&&(C.id===p.id||!N.internals.positionAbsolute))return!1;const E=xo(j?C:N),A=Vc(E,k);return y&&A>0||A>=E.width*E.height||A>=k.width*k.height}):[]},isNodeIntersecting:(p,y,g=!0)=>{const k=Jv(p)?p:m(p);if(!k)return!1;const j=Vc(k,y);return g&&j>0||j>=y.width*y.height||j>=k.width*k.height},updateNode:f,updateNodeData:(p,y,g={replace:!1})=>{f(p,w=>{const k=typeof y=="function"?y(w):y;return g.replace?{...w,data:k}:{...w,data:{...w.data,...k}}},g)},updateEdge:x,updateEdgeData:(p,y,g={replace:!1})=>{x(p,w=>{const k=typeof y=="function"?y(w):y;return g.replace?{...w,data:k}:{...w,data:{...w.data,...k}}},g)},getNodesBounds:p=>{const{nodeLookup:y,nodeOrigin:g}=t.getState();return WR(p,{nodeLookup:y,nodeOrigin:g})},getHandleConnections:({type:p,id:y,nodeId:g})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${g}-${p}${y?`-${y}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:y,nodeId:g})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${g}${p?y?`-${p}-${y}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const y=t.getState().fitViewResolver??nz();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:y}),n.nodeQueue.push(g=>[...g]),y.promise}}},[]);return S.useMemo(()=>({...a,...e,viewportInitialized:i}),[i])}const Dw=e=>e.selected,M9=typeof window<"u"?window:void 0;function F9({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Dn(),{deleteElements:i}=O0(),a=Gc(e,{actInsideInputWithModifier:!1}),o=Gc(t,{target:M9});S.useEffect(()=>{if(a){const{edges:c,nodes:d}=n.getState();i({nodes:d.filter(Dw),edges:c.filter(Dw)}),n.setState({nodesSelectionActive:!1})}},[a]),S.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function R9(e){const t=Dn();S.useEffect(()=>{const n=()=>{var a,o,c,d;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const i=M0(e.current);(i.height===0||i.width===0)&&((d=(c=t.getState()).onError)==null||d.call(c,"004",Ji.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const Qf={position:"absolute",width:"100%",height:"100%",top:0,left:0},z9=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function B9({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=dl.Free,zoomOnDoubleClick:c=!0,panOnDrag:d=!0,defaultViewport:m,translateExtent:f,minZoom:x,maxZoom:p,zoomActivationKeyCode:y,preventScrolling:g=!0,children:w,noWheelClassName:k,noPanClassName:j,onViewportChange:C,isControlledViewport:N,paneClickDistance:E,selectionOnDrag:A}){const z=Dn(),D=S.useRef(null),{userSelectionActive:F,lib:q,connectionInProgress:V}=qt(z9,An),L=Gc(y),_=S.useRef();R9(D);const B=S.useCallback(X=>{C==null||C({x:X[0],y:X[1],zoom:X[2]}),N||z.setState({transform:X})},[C,N]);return S.useEffect(()=>{if(D.current){_.current=Lz({domNode:D.current,minZoom:x,maxZoom:p,translateExtent:f,viewport:m,onDraggingChange:$=>z.setState(G=>G.paneDragging===$?G:{paneDragging:$}),onPanZoomStart:($,G)=>{const{onViewportChangeStart:Q,onMoveStart:K}=z.getState();K==null||K($,G),Q==null||Q(G)},onPanZoom:($,G)=>{const{onViewportChange:Q,onMove:K}=z.getState();K==null||K($,G),Q==null||Q(G)},onPanZoomEnd:($,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:K}=z.getState();K==null||K($,G),Q==null||Q(G)}});const{x:X,y:R,zoom:H}=_.current.getViewport();return z.setState({panZoom:_.current,transform:[X,R,H],domNode:D.current.closest(".react-flow")}),()=>{var $;($=_.current)==null||$.destroy()}}},[]),S.useEffect(()=>{var X;(X=_.current)==null||X.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:c,panOnDrag:d,zoomActivationKeyPressed:L,preventScrolling:g,noPanClassName:j,userSelectionActive:F,noWheelClassName:k,lib:q,onTransformChange:B,connectionInProgress:V,selectionOnDrag:A,paneClickDistance:E})},[e,t,n,i,a,o,c,d,L,g,j,F,k,q,B,V,A,E]),l.jsx("div",{className:"react-flow__renderer",ref:D,style:Qf,children:w})}const $9=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function O9(){const{userSelectionActive:e,userSelectionRect:t}=qt($9,An);return e&&t?l.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Rp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},L9=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function I9({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Xc.Full,panOnDrag:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:c,onSelectionEnd:d,onPaneClick:m,onPaneContextMenu:f,onPaneScroll:x,onPaneMouseEnter:p,onPaneMouseMove:y,onPaneMouseLeave:g,children:w}){const k=Dn(),{userSelectionActive:j,elementsSelectable:C,dragging:N,connectionInProgress:E}=qt(L9,An),A=C&&(e||j),z=S.useRef(null),D=S.useRef(),F=S.useRef(new Set),q=S.useRef(new Set),V=S.useRef(!1),L=Q=>{if(V.current||E){V.current=!1;return}m==null||m(Q),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},_=Q=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){Q.preventDefault();return}f==null||f(Q)},B=x?Q=>x(Q):void 0,X=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},R=Q=>{var ee,J;const{domNode:K}=k.getState();if(D.current=K==null?void 0:K.getBoundingClientRect(),!D.current)return;const M=Q.target===z.current;if(!M&&!!Q.target.closest(".nokey")||!e||!(o&&M||t)||Q.button!==0||!Q.isPrimary)return;(J=(ee=Q.target)==null?void 0:ee.setPointerCapture)==null||J.call(ee,Q.pointerId),V.current=!1;const{x:O,y:Z}=Ci(Q.nativeEvent,D.current);k.setState({userSelectionRect:{width:0,height:0,startX:O,startY:Z,x:O,y:Z}}),M||(Q.stopPropagation(),Q.preventDefault())},H=Q=>{const{userSelectionRect:K,transform:M,nodeLookup:U,edgeLookup:P,connectionLookup:O,triggerNodeChanges:Z,triggerEdgeChanges:ee,defaultEdgeOptions:J,resetSelectedElements:se}=k.getState();if(!D.current||!K)return;const{x:le,y:ye}=Ci(Q.nativeEvent,D.current),{startX:De,startY:Ee}=K;if(!V.current){const Pe=t?0:a;if(Math.hypot(le-De,ye-Ee)<=Pe)return;se(),c==null||c(Q)}V.current=!0;const Re={startX:De,startY:Ee,x:le<De?le:De,y:ye<Ee?ye:Ee,width:Math.abs(le-De),height:Math.abs(ye-Ee)},me=F.current,Fe=q.current;F.current=new Set(T0(U,Re,M,n===Xc.Partial,!0).map(Pe=>Pe.id)),q.current=new Set;const Je=(J==null?void 0:J.selectable)??!0;for(const Pe of F.current){const it=O.get(Pe);if(it)for(const{edgeId:ht}of it.values()){const Ye=P.get(ht);Ye&&(Ye.selectable??Je)&&q.current.add(ht)}}if(!ew(me,F.current)){const Pe=ro(U,F.current,!0);Z(Pe)}if(!ew(Fe,q.current)){const Pe=ro(P,q.current);ee(Pe)}k.setState({userSelectionRect:Re,userSelectionActive:!0,nodesSelectionActive:!1})},$=Q=>{var K,M;Q.button===0&&((M=(K=Q.target)==null?void 0:K.releasePointerCapture)==null||M.call(K,Q.pointerId),!j&&Q.target===z.current&&k.getState().userSelectionRect&&(L==null||L(Q)),k.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(d==null||d(Q),k.setState({nodesSelectionActive:F.current.size>0})))},G=i===!0||Array.isArray(i)&&i.includes(0);return l.jsxs("div",{className:Yn(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:A?void 0:Rp(L,z),onContextMenu:Rp(_,z),onWheel:Rp(B,z),onPointerEnter:A?void 0:p,onPointerMove:A?H:y,onPointerUp:A?$:void 0,onPointerDownCapture:A?R:void 0,onClickCapture:A?X:void 0,onPointerLeave:g,ref:z,style:Qf,children:[w,l.jsx(O9,{})]})}function $x({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:c,nodeLookup:d,onError:m}=t.getState(),f=d.get(e);if(!f){m==null||m("012",Ji.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&c)&&(o({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var x;return(x=i==null?void 0:i.current)==null?void 0:x.blur()})):a([e])}function l3({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:a,isSelectable:o,nodeClickDistance:c}){const d=Dn(),[m,f]=S.useState(!1),x=S.useRef();return S.useEffect(()=>{x.current=Cz({getStoreItems:()=>d.getState(),onNodeMouseDown:p=>{$x({id:p,store:d,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),S.useEffect(()=>{if(!(t||!e.current||!x.current))return x.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:c}),()=>{var p;(p=x.current)==null||p.destroy()}},[n,i,t,o,e,a,c]),m}const H9=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function o3(){const e=Dn();return S.useCallback(n=>{const{nodeExtent:i,snapToGrid:a,snapGrid:o,nodesDraggable:c,onError:d,updateNodePositions:m,nodeLookup:f,nodeOrigin:x}=e.getState(),p=new Map,y=H9(c),g=a?o[0]:5,w=a?o[1]:5,k=n.direction.x*g*n.factor,j=n.direction.y*w*n.factor;for(const[,C]of f){if(!y(C))continue;let N={x:C.internals.positionAbsolute.x+k,y:C.internals.positionAbsolute.y+j};a&&(N=lu(N,o));const{position:E,positionAbsolute:A}=Dk({nodeId:C.id,nextPosition:N,nodeLookup:f,nodeExtent:i,nodeOrigin:x,onError:d});C.position=E,C.internals.positionAbsolute=A,p.set(C.id,C)}m(p)},[])}const L0=S.createContext(null),U9=L0.Provider;L0.Consumer;const c3=()=>S.useContext(L0),q9=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Y9=(e,t,n)=>i=>{const{connectionClickStartHandle:a,connectionMode:o,connection:c}=i,{fromHandle:d,toHandle:m,isValid:f}=c,x=(m==null?void 0:m.nodeId)===e&&(m==null?void 0:m.id)===t&&(m==null?void 0:m.type)===n;return{connectingFrom:(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===n,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,isPossibleEndHandle:o===mo.Strict?(d==null?void 0:d.type)!==n:e!==(d==null?void 0:d.nodeId)||t!==(d==null?void 0:d.id),connectionInProcess:!!d,clickConnectionInProcess:!!a,valid:x&&f}};function P9({type:e="source",position:t=at.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:c,onConnect:d,children:m,className:f,onMouseDown:x,onTouchStart:p,...y},g){var H,$;const w=c||null,k=e==="target",j=Dn(),C=c3(),{connectOnClick:N,noPanClassName:E,rfId:A}=qt(q9,An),{connectingFrom:z,connectingTo:D,clickConnecting:F,isPossibleEndHandle:q,connectionInProcess:V,clickConnectionInProcess:L,valid:_}=qt(Y9(C,w,e),An);C||($=(H=j.getState()).onError)==null||$.call(H,"010",Ji.error010());const B=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:M}=j.getState(),U={...Q,...G};if(M){const{edges:P,setEdges:O}=j.getState();O(cz(U,P))}K==null||K(U),d==null||d(U)},X=G=>{if(!C)return;const Q=$k(G.nativeEvent);if(a&&(Q&&G.button===0||!Q)){const K=j.getState();Bx.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:k,handleId:w,nodeId:C,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...M)=>{var U,P;return(P=(U=j.getState()).onConnectEnd)==null?void 0:P.call(U,...M)},updateConnection:K.updateConnection,onConnect:B,isValidConnection:n||((...M)=>{var U,P;return((P=(U=j.getState()).isValidConnection)==null?void 0:P.call(U,...M))??!0}),getTransform:()=>j.getState().transform,getFromHandle:()=>j.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Q?x==null||x(G):p==null||p(G)},R=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:M,connectionMode:U,isValidConnection:P,lib:O,rfId:Z,nodeLookup:ee,connection:J}=j.getState();if(!C||!M&&!a)return;if(!M){Q==null||Q(G.nativeEvent,{nodeId:C,handleId:w,handleType:e}),j.setState({connectionClickStartHandle:{nodeId:C,type:e,id:w}});return}const se=zk(G.target),le=n||P,{connection:ye,isValid:De}=Bx.isValid(G.nativeEvent,{handle:{nodeId:C,id:w,type:e},connectionMode:U,fromNodeId:M.nodeId,fromHandleId:M.id||null,fromType:M.type,isValidConnection:le,flowId:Z,doc:se,lib:O,nodeLookup:ee});De&&ye&&B(ye);const Ee=structuredClone(J);delete Ee.inProgress,Ee.toPosition=Ee.toHandle?Ee.toHandle.position:null,K==null||K(G,Ee),j.setState({connectionClickStartHandle:null})};return l.jsx("div",{"data-handleid":w,"data-nodeid":C,"data-handlepos":t,"data-id":`${A}-${C}-${w}-${e}`,className:Yn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",E,f,{source:!k,target:k,connectable:i,connectablestart:a,connectableend:o,clickconnecting:F,connectingfrom:z,connectingto:D,valid:_,connectionindicator:i&&(!V||q)&&(V||L?o:a)}]),onMouseDown:X,onTouchStart:X,onClick:N?R:void 0,ref:g,...y,children:m})}const bo=S.memo(s3(P9));function X9({data:e,isConnectable:t,sourcePosition:n=at.Bottom}){return l.jsxs(l.Fragment,{children:[e==null?void 0:e.label,l.jsx(bo,{type:"source",position:n,isConnectable:t})]})}function V9({data:e,isConnectable:t,targetPosition:n=at.Top,sourcePosition:i=at.Bottom}){return l.jsxs(l.Fragment,{children:[l.jsx(bo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,l.jsx(bo,{type:"source",position:i,isConnectable:t})]})}function W9(){return null}function G9({data:e,isConnectable:t,targetPosition:n=at.Top}){return l.jsxs(l.Fragment,{children:[l.jsx(bo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Ff={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Tw={input:X9,default:V9,output:G9,group:W9};function K9(e){var t,n,i,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const Q9=e=>{const{width:t,height:n,x:i,y:a}=au(e.nodeLookup,{filter:o=>!!o.selected});return{width:ji(t)?t:null,height:ji(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${a}px)`}};function Z9({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=Dn(),{width:a,height:o,transformString:c,userSelectionActive:d}=qt(Q9,An),m=o3(),f=S.useRef(null);S.useEffect(()=>{var g;n||(g=f.current)==null||g.focus({preventScroll:!0})},[n]);const x=!d&&a!==null&&o!==null;if(l3({nodeRef:f,disabled:!x}),!x)return null;const p=e?g=>{const w=i.getState().nodes.filter(k=>k.selected);e(g,w)}:void 0,y=g=>{Object.prototype.hasOwnProperty.call(Ff,g.key)&&(g.preventDefault(),m({direction:Ff[g.key],factor:g.shiftKey?4:1}))};return l.jsx("div",{className:Yn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:l.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:y,style:{width:a,height:o}})})}const _w=typeof window<"u"?window:void 0,J9=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function u3({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:c,paneClickDistance:d,deleteKeyCode:m,selectionKeyCode:f,selectionOnDrag:x,selectionMode:p,onSelectionStart:y,onSelectionEnd:g,multiSelectionKeyCode:w,panActivationKeyCode:k,zoomActivationKeyCode:j,elementsSelectable:C,zoomOnScroll:N,zoomOnPinch:E,panOnScroll:A,panOnScrollSpeed:z,panOnScrollMode:D,zoomOnDoubleClick:F,panOnDrag:q,defaultViewport:V,translateExtent:L,minZoom:_,maxZoom:B,preventScrolling:X,onSelectionContextMenu:R,noWheelClassName:H,noPanClassName:$,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:M,userSelectionActive:U}=qt(J9,An),P=Gc(f,{target:_w}),O=Gc(k,{target:_w}),Z=O||q,ee=O||A,J=x&&Z!==!0,se=P||U||J;return F9({deleteKeyCode:m,multiSelectionKeyCode:w}),l.jsx(B9,{onPaneContextMenu:o,elementsSelectable:C,zoomOnScroll:N,zoomOnPinch:E,panOnScroll:ee,panOnScrollSpeed:z,panOnScrollMode:D,zoomOnDoubleClick:F,panOnDrag:!P&&Z,defaultViewport:V,translateExtent:L,minZoom:_,maxZoom:B,zoomActivationKeyCode:j,preventScrolling:X,noWheelClassName:H,noPanClassName:$,onViewportChange:Q,isControlledViewport:K,paneClickDistance:d,selectionOnDrag:J,children:l.jsxs(I9,{onSelectionStart:y,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:c,panOnDrag:Z,isSelecting:!!se,selectionMode:p,selectionKeyPressed:P,paneClickDistance:d,selectionOnDrag:J,children:[e,M&&l.jsx(Z9,{onSelectionContextMenu:R,noPanClassName:$,disableKeyboardA11y:G})]})})}u3.displayName="FlowRenderer";const e7=S.memo(u3),t7=e=>t=>e?T0(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function n7(e){return qt(S.useCallback(t7(e),[e]),An)}const r7=e=>e.updateNodeInternals;function i7(){const e=qt(r7),[t]=S.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(a=>{const o=a.target.getAttribute("data-id");i.set(o,{id:o,nodeElement:a.target,force:!0})}),e(i)}));return S.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function s7({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const a=Dn(),o=S.useRef(null),c=S.useRef(null),d=S.useRef(e.sourcePosition),m=S.useRef(e.targetPosition),f=S.useRef(t),x=n&&!!e.internals.handleBounds;return S.useEffect(()=>{o.current&&!e.hidden&&(!x||c.current!==o.current)&&(c.current&&(i==null||i.unobserve(c.current)),i==null||i.observe(o.current),c.current=o.current)},[x,e.hidden]),S.useEffect(()=>()=>{c.current&&(i==null||i.unobserve(c.current),c.current=null)},[]),S.useEffect(()=>{if(o.current){const p=f.current!==t,y=d.current!==e.sourcePosition,g=m.current!==e.targetPosition;(p||y||g)&&(f.current=t,d.current=e.sourcePosition,m.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function a7({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:a,onContextMenu:o,onDoubleClick:c,nodesDraggable:d,elementsSelectable:m,nodesConnectable:f,nodesFocusable:x,resizeObserver:p,noDragClassName:y,noPanClassName:g,disableKeyboardA11y:w,rfId:k,nodeTypes:j,nodeClickDistance:C,onError:N}){const{node:E,internals:A,isParent:z}=qt(le=>{const ye=le.nodeLookup.get(e),De=le.parentLookup.has(e);return{node:ye,internals:ye.internals,isParent:De}},An);let D=E.type||"default",F=(j==null?void 0:j[D])||Tw[D];F===void 0&&(N==null||N("003",Ji.error003(D)),D="default",F=(j==null?void 0:j.default)||Tw.default);const q=!!(E.draggable||d&&typeof E.draggable>"u"),V=!!(E.selectable||m&&typeof E.selectable>"u"),L=!!(E.connectable||f&&typeof E.connectable>"u"),_=!!(E.focusable||x&&typeof E.focusable>"u"),B=Dn(),X=Fk(E),R=s7({node:E,nodeType:D,hasDimensions:X,resizeObserver:p}),H=l3({nodeRef:R,disabled:E.hidden||!q,noDragClassName:y,handleSelector:E.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:C}),$=o3();if(E.hidden)return null;const G=Os(E),Q=K9(E),K=V||q||t||n||i||a,M=n?le=>n(le,{...A.userNode}):void 0,U=i?le=>i(le,{...A.userNode}):void 0,P=a?le=>a(le,{...A.userNode}):void 0,O=o?le=>o(le,{...A.userNode}):void 0,Z=c?le=>c(le,{...A.userNode}):void 0,ee=le=>{const{selectNodesOnDrag:ye,nodeDragThreshold:De}=B.getState();V&&(!ye||!q||De>0)&&$x({id:e,store:B,nodeRef:R}),t&&t(le,{...A.userNode})},J=le=>{if(!(Bk(le.nativeEvent)||w)){if(jk.includes(le.key)&&V){const ye=le.key==="Escape";$x({id:e,store:B,unselect:ye,nodeRef:R})}else if(q&&E.selected&&Object.prototype.hasOwnProperty.call(Ff,le.key)){le.preventDefault();const{ariaLabelConfig:ye}=B.getState();B.setState({ariaLiveMessage:ye["node.a11yDescription.ariaLiveMessage"]({direction:le.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),$({direction:Ff[le.key],factor:le.shiftKey?4:1})}}},se=()=>{var Fe;if(w||!((Fe=R.current)!=null&&Fe.matches(":focus-visible")))return;const{transform:le,width:ye,height:De,autoPanOnNodeFocus:Ee,setCenter:Re}=B.getState();if(!Ee)return;T0(new Map([[e,E]]),{x:0,y:0,width:ye,height:De},le,!0).length>0||Re(E.position.x+G.width/2,E.position.y+G.height/2,{zoom:le[2]})};return l.jsx("div",{className:Yn(["react-flow__node",`react-flow__node-${D}`,{[g]:q},E.className,{selected:E.selected,selectable:V,parent:z,draggable:q,dragging:H}]),ref:R,style:{zIndex:A.z,transform:`translate(${A.positionAbsolute.x}px,${A.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:X?"visible":"hidden",...E.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:M,onMouseMove:U,onMouseLeave:P,onContextMenu:O,onClick:ee,onDoubleClick:Z,onKeyDown:_?J:void 0,tabIndex:_?0:void 0,onFocus:_?se:void 0,role:E.ariaRole??(_?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${t3}-${k}`,"aria-label":E.ariaLabel,...E.domAttributes,children:l.jsx(U9,{value:e,children:l.jsx(F,{id:e,data:E.data,type:D,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.positionAbsolute.y,selected:E.selected??!1,selectable:V,draggable:q,deletable:E.deletable??!0,isConnectable:L,sourcePosition:E.sourcePosition,targetPosition:E.targetPosition,dragging:H,dragHandle:E.dragHandle,zIndex:A.z,parentId:E.parentId,...G})})})}var l7=S.memo(a7);const o7=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function d3(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:a,onError:o}=qt(o7,An),c=n7(e.onlyRenderVisibleElements),d=i7();return l.jsx("div",{className:"react-flow__nodes",style:Qf,children:c.map(m=>l.jsx(l7,{id:m,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:d,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},m))})}d3.displayName="NodeRenderer";const c7=S.memo(d3);function u7(e){return qt(S.useCallback(n=>{if(!e)return n.edges.map(a=>a.id);const i=[];if(n.width&&n.height)for(const a of n.edges){const o=n.nodeLookup.get(a.source),c=n.nodeLookup.get(a.target);o&&c&&az({sourceNode:o,targetNode:c,width:n.width,height:n.height,transform:n.transform})&&i.push(a.id)}return i},[e]),An)}const d7=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return l.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},f7=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return l.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Mw={[Df.Arrow]:d7,[Df.ArrowClosed]:f7};function h7(e){const t=Dn();return S.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(Mw,e)?Mw[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",Ji.error009(e)),null)},[e])}const m7=({id:e,type:t,color:n,width:i=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:c,orient:d="auto-start-reverse"})=>{const m=h7(t);return m?l.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:d,refX:"0",refY:"0",children:l.jsx(m,{color:n,strokeWidth:c})}):null},f3=({defaultColor:e,rfId:t})=>{const n=qt(o=>o.edges),i=qt(o=>o.defaultEdgeOptions),a=S.useMemo(()=>mz(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return a.length?l.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:l.jsx("defs",{children:a.map(o=>l.jsx(m7,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};f3.displayName="MarkerDefinitions";var p7=S.memo(f3);function h3({x:e,y:t,label:n,labelStyle:i,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:c=[2,4],labelBgBorderRadius:d=2,children:m,className:f,...x}){const[p,y]=S.useState({x:1,y:0,width:0,height:0}),g=Yn(["react-flow__edge-textwrapper",f]),w=S.useRef(null);return S.useEffect(()=>{if(w.current){const k=w.current.getBBox();y({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),n?l.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:g,visibility:p.width?"visible":"hidden",...x,children:[a&&l.jsx("rect",{width:p.width+2*c[0],x:-c[0],y:-c[1],height:p.height+2*c[1],className:"react-flow__edge-textbg",style:o,rx:d,ry:d}),l.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:i,children:n}),m]}):null}h3.displayName="EdgeText";const x7=S.memo(h3);function cu({path:e,labelX:t,labelY:n,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:m,interactionWidth:f=20,...x}){return l.jsxs(l.Fragment,{children:[l.jsx("path",{...x,d:e,fill:"none",className:Yn(["react-flow__edge-path",x.className])}),f?l.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,i&&ji(t)&&ji(n)?l.jsx(x7,{x:t,y:n,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:m}):null]})}function Fw({pos:e,x1:t,y1:n,x2:i,y2:a}){return e===at.Left||e===at.Right?[.5*(t+i),n]:[t,.5*(n+a)]}function m3({sourceX:e,sourceY:t,sourcePosition:n=at.Bottom,targetX:i,targetY:a,targetPosition:o=at.Top}){const[c,d]=Fw({pos:n,x1:e,y1:t,x2:i,y2:a}),[m,f]=Fw({pos:o,x1:i,y1:a,x2:e,y2:t}),[x,p,y,g]=Ok({sourceX:e,sourceY:t,targetX:i,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:m,targetControlY:f});return[`M${e},${t} C${c},${d} ${m},${f} ${i},${a}`,x,p,y,g]}function p3(e){return S.memo(({id:t,sourceX:n,sourceY:i,targetX:a,targetY:o,sourcePosition:c,targetPosition:d,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:g,style:w,markerEnd:k,markerStart:j,interactionWidth:C})=>{const[N,E,A]=m3({sourceX:n,sourceY:i,sourcePosition:c,targetX:a,targetY:o,targetPosition:d}),z=e.isInternal?void 0:t;return l.jsx(cu,{id:z,path:N,labelX:E,labelY:A,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:g,style:w,markerEnd:k,markerStart:j,interactionWidth:C})})}const g7=p3({isInternal:!1}),x3=p3({isInternal:!0});g7.displayName="SimpleBezierEdge";x3.displayName="SimpleBezierEdgeInternal";function g3(e){return S.memo(({id:t,sourceX:n,sourceY:i,targetX:a,targetY:o,label:c,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:y,sourcePosition:g=at.Bottom,targetPosition:w=at.Top,markerEnd:k,markerStart:j,pathOptions:C,interactionWidth:N})=>{const[E,A,z]=Mf({sourceX:n,sourceY:i,sourcePosition:g,targetX:a,targetY:o,targetPosition:w,borderRadius:C==null?void 0:C.borderRadius,offset:C==null?void 0:C.offset,stepPosition:C==null?void 0:C.stepPosition}),D=e.isInternal?void 0:t;return l.jsx(cu,{id:D,path:E,labelX:A,labelY:z,label:c,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:y,markerEnd:k,markerStart:j,interactionWidth:N})})}const y3=g3({isInternal:!1}),b3=g3({isInternal:!0});y3.displayName="SmoothStepEdge";b3.displayName="SmoothStepEdgeInternal";function v3(e){return S.memo(({id:t,...n})=>{var a;const i=e.isInternal?void 0:t;return l.jsx(y3,{...n,id:i,pathOptions:S.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(a=n.pathOptions)==null?void 0:a.offset])})})}const y7=v3({isInternal:!1}),w3=v3({isInternal:!0});y7.displayName="StepEdge";w3.displayName="StepEdgeInternal";function k3(e){return S.memo(({id:t,sourceX:n,sourceY:i,targetX:a,targetY:o,label:c,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:y,markerEnd:g,markerStart:w,interactionWidth:k})=>{const[j,C,N]=Hk({sourceX:n,sourceY:i,targetX:a,targetY:o}),E=e.isInternal?void 0:t;return l.jsx(cu,{id:E,path:j,labelX:C,labelY:N,label:c,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:y,markerEnd:g,markerStart:w,interactionWidth:k})})}const b7=k3({isInternal:!1}),S3=k3({isInternal:!0});b7.displayName="StraightEdge";S3.displayName="StraightEdgeInternal";function j3(e){return S.memo(({id:t,sourceX:n,sourceY:i,targetX:a,targetY:o,sourcePosition:c=at.Bottom,targetPosition:d=at.Top,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:g,style:w,markerEnd:k,markerStart:j,pathOptions:C,interactionWidth:N})=>{const[E,A,z]=Lk({sourceX:n,sourceY:i,sourcePosition:c,targetX:a,targetY:o,targetPosition:d,curvature:C==null?void 0:C.curvature}),D=e.isInternal?void 0:t;return l.jsx(cu,{id:D,path:E,labelX:A,labelY:z,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:g,style:w,markerEnd:k,markerStart:j,interactionWidth:N})})}const v7=j3({isInternal:!1}),C3=j3({isInternal:!0});v7.displayName="BezierEdge";C3.displayName="BezierEdgeInternal";const Rw={default:C3,straight:S3,step:w3,smoothstep:b3,simplebezier:x3},zw={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},w7=(e,t,n)=>n===at.Left?e-t:n===at.Right?e+t:e,k7=(e,t,n)=>n===at.Top?e-t:n===at.Bottom?e+t:e,Bw="react-flow__edgeupdater";function $w({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:a,onMouseEnter:o,onMouseOut:c,type:d}){return l.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:c,className:Yn([Bw,`${Bw}-${d}`]),cx:w7(t,i,e),cy:k7(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function S7({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:a,targetX:o,targetY:c,sourcePosition:d,targetPosition:m,onReconnect:f,onReconnectStart:x,onReconnectEnd:p,setReconnecting:y,setUpdateHover:g}){const w=Dn(),k=(A,z)=>{if(A.button!==0)return;const{autoPanOnConnect:D,domNode:F,connectionMode:q,connectionRadius:V,lib:L,onConnectStart:_,cancelConnection:B,nodeLookup:X,rfId:R,panBy:H,updateConnection:$}=w.getState(),G=z.type==="target",Q=(U,P)=>{y(!1),p==null||p(U,n,z.type,P)},K=U=>f==null?void 0:f(n,U),M=(U,P)=>{y(!0),x==null||x(A,n,z.type),_==null||_(U,P)};Bx.onPointerDown(A.nativeEvent,{autoPanOnConnect:D,connectionMode:q,connectionRadius:V,domNode:F,handleId:z.id,nodeId:z.nodeId,nodeLookup:X,isTarget:G,edgeUpdaterType:z.type,lib:L,flowId:R,cancelConnection:B,panBy:H,isValidConnection:(...U)=>{var P,O;return((O=(P=w.getState()).isValidConnection)==null?void 0:O.call(P,...U))??!0},onConnect:K,onConnectStart:M,onConnectEnd:(...U)=>{var P,O;return(O=(P=w.getState()).onConnectEnd)==null?void 0:O.call(P,...U)},onReconnectEnd:Q,updateConnection:$,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},j=A=>k(A,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),C=A=>k(A,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>g(!0),E=()=>g(!1);return l.jsxs(l.Fragment,{children:[(e===!0||e==="source")&&l.jsx($w,{position:d,centerX:i,centerY:a,radius:t,onMouseDown:j,onMouseEnter:N,onMouseOut:E,type:"source"}),(e===!0||e==="target")&&l.jsx($w,{position:m,centerX:o,centerY:c,radius:t,onMouseDown:C,onMouseEnter:N,onMouseOut:E,type:"target"})]})}function j7({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:a,onDoubleClick:o,onContextMenu:c,onMouseEnter:d,onMouseMove:m,onMouseLeave:f,reconnectRadius:x,onReconnect:p,onReconnectStart:y,onReconnectEnd:g,rfId:w,edgeTypes:k,noPanClassName:j,onError:C,disableKeyboardA11y:N}){let E=qt(Re=>Re.edgeLookup.get(e));const A=qt(Re=>Re.defaultEdgeOptions);E=A?{...A,...E}:E;let z=E.type||"default",D=(k==null?void 0:k[z])||Rw[z];D===void 0&&(C==null||C("011",Ji.error011(z)),z="default",D=(k==null?void 0:k.default)||Rw.default);const F=!!(E.focusable||t&&typeof E.focusable>"u"),q=typeof p<"u"&&(E.reconnectable||n&&typeof E.reconnectable>"u"),V=!!(E.selectable||i&&typeof E.selectable>"u"),L=S.useRef(null),[_,B]=S.useState(!1),[X,R]=S.useState(!1),H=Dn(),{zIndex:$,sourceX:G,sourceY:Q,targetX:K,targetY:M,sourcePosition:U,targetPosition:P}=qt(S.useCallback(Re=>{const me=Re.nodeLookup.get(E.source),Fe=Re.nodeLookup.get(E.target);if(!me||!Fe)return{zIndex:E.zIndex,...zw};const Je=hz({id:e,sourceNode:me,targetNode:Fe,sourceHandle:E.sourceHandle||null,targetHandle:E.targetHandle||null,connectionMode:Re.connectionMode,onError:C});return{zIndex:sz({selected:E.selected,zIndex:E.zIndex,sourceNode:me,targetNode:Fe,elevateOnSelect:Re.elevateEdgesOnSelect,zIndexMode:Re.zIndexMode}),...Je||zw}},[E.source,E.target,E.sourceHandle,E.targetHandle,E.selected,E.zIndex]),An),O=S.useMemo(()=>E.markerStart?`url('#${Rx(E.markerStart,w)}')`:void 0,[E.markerStart,w]),Z=S.useMemo(()=>E.markerEnd?`url('#${Rx(E.markerEnd,w)}')`:void 0,[E.markerEnd,w]);if(E.hidden||G===null||Q===null||K===null||M===null)return null;const ee=Re=>{var Pe;const{addSelectedEdges:me,unselectNodesAndEdges:Fe,multiSelectionActive:Je}=H.getState();V&&(H.setState({nodesSelectionActive:!1}),E.selected&&Je?(Fe({nodes:[],edges:[E]}),(Pe=L.current)==null||Pe.blur()):me([e])),a&&a(Re,E)},J=o?Re=>{o(Re,{...E})}:void 0,se=c?Re=>{c(Re,{...E})}:void 0,le=d?Re=>{d(Re,{...E})}:void 0,ye=m?Re=>{m(Re,{...E})}:void 0,De=f?Re=>{f(Re,{...E})}:void 0,Ee=Re=>{var me;if(!N&&jk.includes(Re.key)&&V){const{unselectNodesAndEdges:Fe,addSelectedEdges:Je}=H.getState();Re.key==="Escape"?((me=L.current)==null||me.blur(),Fe({edges:[E]})):Je([e])}};return l.jsx("svg",{style:{zIndex:$},children:l.jsxs("g",{className:Yn(["react-flow__edge",`react-flow__edge-${z}`,E.className,j,{selected:E.selected,animated:E.animated,inactive:!V&&!a,updating:_,selectable:V}]),onClick:ee,onDoubleClick:J,onContextMenu:se,onMouseEnter:le,onMouseMove:ye,onMouseLeave:De,onKeyDown:F?Ee:void 0,tabIndex:F?0:void 0,role:E.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":E.ariaLabel===null?void 0:E.ariaLabel||`Edge from ${E.source} to ${E.target}`,"aria-describedby":F?`${n3}-${w}`:void 0,ref:L,...E.domAttributes,children:[!X&&l.jsx(D,{id:e,source:E.source,target:E.target,type:E.type,selected:E.selected,animated:E.animated,selectable:V,deletable:E.deletable??!0,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:K,targetY:M,sourcePosition:U,targetPosition:P,data:E.data,style:E.style,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerStart:O,markerEnd:Z,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth}),q&&l.jsx(S7,{edge:E,isReconnectable:q,reconnectRadius:x,onReconnect:p,onReconnectStart:y,onReconnectEnd:g,sourceX:G,sourceY:Q,targetX:K,targetY:M,sourcePosition:U,targetPosition:P,setUpdateHover:B,setReconnecting:R})]})})}var C7=S.memo(j7);const N7=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function N3({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:a,onReconnect:o,onEdgeContextMenu:c,onEdgeMouseEnter:d,onEdgeMouseMove:m,onEdgeMouseLeave:f,onEdgeClick:x,reconnectRadius:p,onEdgeDoubleClick:y,onReconnectStart:g,onReconnectEnd:w,disableKeyboardA11y:k}){const{edgesFocusable:j,edgesReconnectable:C,elementsSelectable:N,onError:E}=qt(N7,An),A=u7(t);return l.jsxs("div",{className:"react-flow__edges",children:[l.jsx(p7,{defaultColor:e,rfId:n}),A.map(z=>l.jsx(C7,{id:z,edgesFocusable:j,edgesReconnectable:C,elementsSelectable:N,noPanClassName:a,onReconnect:o,onContextMenu:c,onMouseEnter:d,onMouseMove:m,onMouseLeave:f,onClick:x,reconnectRadius:p,onDoubleClick:y,onReconnectStart:g,onReconnectEnd:w,rfId:n,onError:E,edgeTypes:i,disableKeyboardA11y:k},z))]})}N3.displayName="EdgeRenderer";const E7=S.memo(N3),A7=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function D7({children:e}){const t=qt(A7);return l.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function T7(e){const t=O0(),n=S.useRef(!1);S.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const _7=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function M7(e){const t=qt(_7),n=Dn();return S.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function F7(e){return e.connection.inProgress?{...e.connection,to:ou(e.connection.to,e.transform)}:{...e.connection}}function R7(e){return F7}function z7(e){const t=R7();return qt(t,An)}const B7=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function $7({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:a,width:o,height:c,isValid:d,inProgress:m}=qt(B7,An);return!(o&&a&&m)?null:l.jsx("svg",{style:e,width:o,height:c,className:"react-flow__connectionline react-flow__container",children:l.jsx("g",{className:Yn(["react-flow__connection",Ek(d)]),children:l.jsx(E3,{style:t,type:n,CustomComponent:i,isValid:d})})})}const E3=({style:e,type:t=ja.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:a,from:o,fromNode:c,fromHandle:d,fromPosition:m,to:f,toNode:x,toHandle:p,toPosition:y,pointer:g}=z7();if(!a)return;if(n)return l.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:c,fromHandle:d,fromX:o.x,fromY:o.y,toX:f.x,toY:f.y,fromPosition:m,toPosition:y,connectionStatus:Ek(i),toNode:x,toHandle:p,pointer:g});let w="";const k={sourceX:o.x,sourceY:o.y,sourcePosition:m,targetX:f.x,targetY:f.y,targetPosition:y};switch(t){case ja.Bezier:[w]=Lk(k);break;case ja.SimpleBezier:[w]=m3(k);break;case ja.Step:[w]=Mf({...k,borderRadius:0});break;case ja.SmoothStep:[w]=Mf(k);break;default:[w]=Hk(k)}return l.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};E3.displayName="ConnectionLine";const O7={};function Ow(e=O7){S.useRef(e),Dn(),S.useEffect(()=>{},[e])}function L7(){Dn(),S.useRef(!1),S.useEffect(()=>{},[])}function A3({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:x,onSelectionContextMenu:p,onSelectionStart:y,onSelectionEnd:g,connectionLineType:w,connectionLineStyle:k,connectionLineComponent:j,connectionLineContainerStyle:C,selectionKeyCode:N,selectionOnDrag:E,selectionMode:A,multiSelectionKeyCode:z,panActivationKeyCode:D,zoomActivationKeyCode:F,deleteKeyCode:q,onlyRenderVisibleElements:V,elementsSelectable:L,defaultViewport:_,translateExtent:B,minZoom:X,maxZoom:R,preventScrolling:H,defaultMarkerColor:$,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:M,panOnScrollMode:U,zoomOnDoubleClick:P,panOnDrag:O,onPaneClick:Z,onPaneMouseEnter:ee,onPaneMouseMove:J,onPaneMouseLeave:se,onPaneScroll:le,onPaneContextMenu:ye,paneClickDistance:De,nodeClickDistance:Ee,onEdgeContextMenu:Re,onEdgeMouseEnter:me,onEdgeMouseMove:Fe,onEdgeMouseLeave:Je,reconnectRadius:Pe,onReconnect:it,onReconnectStart:ht,onReconnectEnd:Ye,noDragClassName:nt,noWheelClassName:ut,noPanClassName:kt,disableKeyboardA11y:mt,nodeExtent:ve,rfId:be,viewport:te,onViewportChange:oe}){return Ow(e),Ow(t),L7(),T7(n),M7(te),l.jsx(e7,{onPaneClick:Z,onPaneMouseEnter:ee,onPaneMouseMove:J,onPaneMouseLeave:se,onPaneContextMenu:ye,onPaneScroll:le,paneClickDistance:De,deleteKeyCode:q,selectionKeyCode:N,selectionOnDrag:E,selectionMode:A,onSelectionStart:y,onSelectionEnd:g,multiSelectionKeyCode:z,panActivationKeyCode:D,zoomActivationKeyCode:F,elementsSelectable:L,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:P,panOnScroll:K,panOnScrollSpeed:M,panOnScrollMode:U,panOnDrag:O,defaultViewport:_,translateExtent:B,minZoom:X,maxZoom:R,onSelectionContextMenu:p,preventScrolling:H,noDragClassName:nt,noWheelClassName:ut,noPanClassName:kt,disableKeyboardA11y:mt,onViewportChange:oe,isControlledViewport:!!te,children:l.jsxs(D7,{children:[l.jsx(E7,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:it,onReconnectStart:ht,onReconnectEnd:Ye,onlyRenderVisibleElements:V,onEdgeContextMenu:Re,onEdgeMouseEnter:me,onEdgeMouseMove:Fe,onEdgeMouseLeave:Je,reconnectRadius:Pe,defaultMarkerColor:$,noPanClassName:kt,disableKeyboardA11y:mt,rfId:be}),l.jsx($7,{style:k,type:w,component:j,containerStyle:C}),l.jsx("div",{className:"react-flow__edgelabel-renderer"}),l.jsx(c7,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:d,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:x,nodeClickDistance:Ee,onlyRenderVisibleElements:V,noPanClassName:kt,noDragClassName:nt,disableKeyboardA11y:mt,nodeExtent:ve,rfId:be}),l.jsx("div",{className:"react-flow__viewport-portal"})]})})}A3.displayName="GraphView";const I7=S.memo(A3),Lw=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:a,height:o,fitView:c,fitViewOptions:d,minZoom:m=.5,maxZoom:f=2,nodeOrigin:x,nodeExtent:p,zIndexMode:y="basic"}={})=>{const g=new Map,w=new Map,k=new Map,j=new Map,C=i??t??[],N=n??e??[],E=x??[0,0],A=p??Pc;Yk(k,j,C);const z=zx(N,g,w,{nodeOrigin:E,nodeExtent:A,zIndexMode:y});let D=[0,0,1];if(c&&a&&o){const F=au(g,{filter:_=>!!((_.width||_.initialWidth)&&(_.height||_.initialHeight))}),{x:q,y:V,zoom:L}=_0(F,a,o,m,f,(d==null?void 0:d.padding)??.1);D=[q,V,L]}return{rfId:"1",width:a??0,height:o??0,transform:D,nodes:N,nodesInitialized:z,nodeLookup:g,parentLookup:w,edges:C,edgeLookup:j,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:m,maxZoom:f,translateExtent:Pc,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:mo.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:E,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:d,fitViewResolver:null,connection:{...Nk},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:JR,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ck,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},H7=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:a,height:o,fitView:c,fitViewOptions:d,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:p,zIndexMode:y})=>r9((g,w)=>{async function k(){const{nodeLookup:j,panZoom:C,fitViewOptions:N,fitViewResolver:E,width:A,height:z,minZoom:D,maxZoom:F}=w();C&&(await QR({nodes:j,width:A,height:z,panZoom:C,minZoom:D,maxZoom:F},N),E==null||E.resolve(!0),g({fitViewResolver:null}))}return{...Lw({nodes:e,edges:t,width:a,height:o,fitView:c,fitViewOptions:d,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:p,defaultNodes:n,defaultEdges:i,zIndexMode:y}),setNodes:j=>{const{nodeLookup:C,parentLookup:N,nodeOrigin:E,elevateNodesOnSelect:A,fitViewQueued:z,zIndexMode:D}=w(),F=zx(j,C,N,{nodeOrigin:E,nodeExtent:p,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:D});z&&F?(k(),g({nodes:j,nodesInitialized:F,fitViewQueued:!1,fitViewOptions:void 0})):g({nodes:j,nodesInitialized:F})},setEdges:j=>{const{connectionLookup:C,edgeLookup:N}=w();Yk(C,N,j),g({edges:j})},setDefaultNodesAndEdges:(j,C)=>{if(j){const{setNodes:N}=w();N(j),g({hasDefaultNodes:!0})}if(C){const{setEdges:N}=w();N(C),g({hasDefaultEdges:!0})}},updateNodeInternals:j=>{const{triggerNodeChanges:C,nodeLookup:N,parentLookup:E,domNode:A,nodeOrigin:z,nodeExtent:D,debug:F,fitViewQueued:q,zIndexMode:V}=w(),{changes:L,updatedInternals:_}=wz(j,N,E,A,z,D,V);_&&(gz(N,E,{nodeOrigin:z,nodeExtent:D,zIndexMode:V}),q?(k(),g({fitViewQueued:!1,fitViewOptions:void 0})):g({}),(L==null?void 0:L.length)>0&&(F&&console.log("React Flow: trigger node changes",L),C==null||C(L)))},updateNodePositions:(j,C=!1)=>{const N=[];let E=[];const{nodeLookup:A,triggerNodeChanges:z,connection:D,updateConnection:F,onNodesChangeMiddlewareMap:q}=w();for(const[V,L]of j){const _=A.get(V),B=!!(_!=null&&_.expandParent&&(_!=null&&_.parentId)&&(L!=null&&L.position)),X={id:V,type:"position",position:B?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:C};if(_&&D.inProgress&&D.fromNode.id===_.id){const R=yl(_,D.fromHandle,at.Left,!0);F({...D,from:R})}B&&_.parentId&&N.push({id:V,parentId:_.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),E.push(X)}if(N.length>0){const{parentLookup:V,nodeOrigin:L}=w(),_=$0(N,A,V,L);E.push(..._)}for(const V of q.values())E=V(E);z(E)},triggerNodeChanges:j=>{const{onNodesChange:C,setNodes:N,nodes:E,hasDefaultNodes:A,debug:z}=w();if(j!=null&&j.length){if(A){const D=j9(j,E);N(D)}z&&console.log("React Flow: trigger node changes",j),C==null||C(j)}},triggerEdgeChanges:j=>{const{onEdgesChange:C,setEdges:N,edges:E,hasDefaultEdges:A,debug:z}=w();if(j!=null&&j.length){if(A){const D=C9(j,E);N(D)}z&&console.log("React Flow: trigger edge changes",j),C==null||C(j)}},addSelectedNodes:j=>{const{multiSelectionActive:C,edgeLookup:N,nodeLookup:E,triggerNodeChanges:A,triggerEdgeChanges:z}=w();if(C){const D=j.map(F=>rl(F,!0));A(D);return}A(ro(E,new Set([...j]),!0)),z(ro(N))},addSelectedEdges:j=>{const{multiSelectionActive:C,edgeLookup:N,nodeLookup:E,triggerNodeChanges:A,triggerEdgeChanges:z}=w();if(C){const D=j.map(F=>rl(F,!0));z(D);return}z(ro(N,new Set([...j]))),A(ro(E,new Set,!0))},unselectNodesAndEdges:({nodes:j,edges:C}={})=>{const{edges:N,nodes:E,nodeLookup:A,triggerNodeChanges:z,triggerEdgeChanges:D}=w(),F=j||E,q=C||N,V=[];for(const _ of F){if(!_.selected)continue;const B=A.get(_.id);B&&(B.selected=!1),V.push(rl(_.id,!1))}const L=[];for(const _ of q)_.selected&&L.push(rl(_.id,!1));z(V),D(L)},setMinZoom:j=>{const{panZoom:C,maxZoom:N}=w();C==null||C.setScaleExtent([j,N]),g({minZoom:j})},setMaxZoom:j=>{const{panZoom:C,minZoom:N}=w();C==null||C.setScaleExtent([N,j]),g({maxZoom:j})},setTranslateExtent:j=>{var C;(C=w().panZoom)==null||C.setTranslateExtent(j),g({translateExtent:j})},resetSelectedElements:()=>{const{edges:j,nodes:C,triggerNodeChanges:N,triggerEdgeChanges:E,elementsSelectable:A}=w();if(!A)return;const z=C.reduce((F,q)=>q.selected?[...F,rl(q.id,!1)]:F,[]),D=j.reduce((F,q)=>q.selected?[...F,rl(q.id,!1)]:F,[]);N(z),E(D)},setNodeExtent:j=>{const{nodes:C,nodeLookup:N,parentLookup:E,nodeOrigin:A,elevateNodesOnSelect:z,nodeExtent:D,zIndexMode:F}=w();j[0][0]===D[0][0]&&j[0][1]===D[0][1]&&j[1][0]===D[1][0]&&j[1][1]===D[1][1]||(zx(C,N,E,{nodeOrigin:A,nodeExtent:j,elevateNodesOnSelect:z,checkEquality:!1,zIndexMode:F}),g({nodeExtent:j}))},panBy:j=>{const{transform:C,width:N,height:E,panZoom:A,translateExtent:z}=w();return kz({delta:j,panZoom:A,transform:C,translateExtent:z,width:N,height:E})},setCenter:async(j,C,N)=>{const{width:E,height:A,maxZoom:z,panZoom:D}=w();if(!D)return Promise.resolve(!1);const F=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:z;return await D.setViewport({x:E/2-j*F,y:A/2-C*F,zoom:F},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{g({connection:{...Nk}})},updateConnection:j=>{g({connection:j})},reset:()=>g({...Lw()})}},Object.is);function U7({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:a,initialHeight:o,initialMinZoom:c,initialMaxZoom:d,initialFitViewOptions:m,fitView:f,nodeOrigin:x,nodeExtent:p,zIndexMode:y,children:g}){const[w]=S.useState(()=>H7({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:a,height:o,fitView:f,minZoom:c,maxZoom:d,fitViewOptions:m,nodeOrigin:x,nodeExtent:p,zIndexMode:y}));return l.jsx(i9,{value:w,children:l.jsx(D9,{children:g})})}function q7({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:a,width:o,height:c,fitView:d,fitViewOptions:m,minZoom:f,maxZoom:x,nodeOrigin:p,nodeExtent:y,zIndexMode:g}){return S.useContext(Gf)?l.jsx(l.Fragment,{children:e}):l.jsx(U7,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:a,initialWidth:o,initialHeight:c,fitView:d,initialFitViewOptions:m,initialMinZoom:f,initialMaxZoom:x,nodeOrigin:p,nodeExtent:y,zIndexMode:g,children:e})}const Y7={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function P7({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:a,nodeTypes:o,edgeTypes:c,onNodeClick:d,onEdgeClick:m,onInit:f,onMove:x,onMoveStart:p,onMoveEnd:y,onConnect:g,onConnectStart:w,onConnectEnd:k,onClickConnectStart:j,onClickConnectEnd:C,onNodeMouseEnter:N,onNodeMouseMove:E,onNodeMouseLeave:A,onNodeContextMenu:z,onNodeDoubleClick:D,onNodeDragStart:F,onNodeDrag:q,onNodeDragStop:V,onNodesDelete:L,onEdgesDelete:_,onDelete:B,onSelectionChange:X,onSelectionDragStart:R,onSelectionDrag:H,onSelectionDragStop:$,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:M,connectionMode:U,connectionLineType:P=ja.Bezier,connectionLineStyle:O,connectionLineComponent:Z,connectionLineContainerStyle:ee,deleteKeyCode:J="Backspace",selectionKeyCode:se="Shift",selectionOnDrag:le=!1,selectionMode:ye=Xc.Full,panActivationKeyCode:De="Space",multiSelectionKeyCode:Ee=Wc()?"Meta":"Control",zoomActivationKeyCode:Re=Wc()?"Meta":"Control",snapToGrid:me,snapGrid:Fe,onlyRenderVisibleElements:Je=!1,selectNodesOnDrag:Pe,nodesDraggable:it,autoPanOnNodeFocus:ht,nodesConnectable:Ye,nodesFocusable:nt,nodeOrigin:ut=r3,edgesFocusable:kt,edgesReconnectable:mt,elementsSelectable:ve=!0,defaultViewport:be=g9,minZoom:te=.5,maxZoom:oe=2,translateExtent:Ce=Pc,preventScrolling:pe=!0,nodeExtent:Se,defaultMarkerColor:Me="#b1b1b7",zoomOnScroll:Ge=!0,zoomOnPinch:Ie=!0,panOnScroll:qe=!1,panOnScrollSpeed:Xe=.5,panOnScrollMode:et=dl.Free,zoomOnDoubleClick:ze=!0,panOnDrag:Be=!0,onPaneClick:_t,onPaneMouseEnter:en,onPaneMouseMove:Tt,onPaneMouseLeave:Pt,onPaneScroll:hn,onPaneContextMenu:Zt,paneClickDistance:ae=1,nodeClickDistance:Ve=0,children:We,onReconnect:tn,onReconnectStart:Ne,onReconnectEnd:Ct,onEdgeContextMenu:ln,onEdgeDoubleClick:nn,onEdgeMouseEnter:Kr,onEdgeMouseMove:gr,onEdgeMouseLeave:vn,reconnectRadius:ce=10,onNodesChange:Ue,onEdgesChange:$e,noDragClassName:dt="nodrag",noWheelClassName:wt="nowheel",noPanClassName:yr="nopan",fitView:Pn,fitViewOptions:Qr,connectOnClick:fi,attributionPosition:Ls,proOptions:Zr,defaultEdgeOptions:Ma,elevateNodesOnSelect:jr=!0,elevateEdgesOnSelect:dr=!1,disableKeyboardA11y:Ai=!1,autoPanOnConnect:Di,autoPanOnNodeDrag:Sn,autoPanSpeed:Fa,connectionRadius:Is,isValidConnection:$n,onError:Ti,style:_i,id:is,nodeDragThreshold:hi,connectionDragThreshold:Mi,viewport:Fr,onViewportChange:ss,width:Zn,height:nr,colorMode:Ra="light",debug:za,onScroll:mi,ariaLabelConfig:Ba,zIndexMode:as="basic",...pi},jn){const Jn=is||"1",Rr=w9(Ra),br=S.useCallback(mn=>{mn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),mi==null||mi(mn)},[mi]);return l.jsx("div",{"data-testid":"rf__wrapper",...pi,onScroll:br,style:{..._i,...Y7},ref:jn,className:Yn(["react-flow",a,Rr]),id:is,role:"application",children:l.jsxs(q7,{nodes:e,edges:t,width:Zn,height:nr,fitView:Pn,fitViewOptions:Qr,minZoom:te,maxZoom:oe,nodeOrigin:ut,nodeExtent:Se,zIndexMode:as,children:[l.jsx(I7,{onInit:f,onNodeClick:d,onEdgeClick:m,onNodeMouseEnter:N,onNodeMouseMove:E,onNodeMouseLeave:A,onNodeContextMenu:z,onNodeDoubleClick:D,nodeTypes:o,edgeTypes:c,connectionLineType:P,connectionLineStyle:O,connectionLineComponent:Z,connectionLineContainerStyle:ee,selectionKeyCode:se,selectionOnDrag:le,selectionMode:ye,deleteKeyCode:J,multiSelectionKeyCode:Ee,panActivationKeyCode:De,zoomActivationKeyCode:Re,onlyRenderVisibleElements:Je,defaultViewport:be,translateExtent:Ce,minZoom:te,maxZoom:oe,preventScrolling:pe,zoomOnScroll:Ge,zoomOnPinch:Ie,zoomOnDoubleClick:ze,panOnScroll:qe,panOnScrollSpeed:Xe,panOnScrollMode:et,panOnDrag:Be,onPaneClick:_t,onPaneMouseEnter:en,onPaneMouseMove:Tt,onPaneMouseLeave:Pt,onPaneScroll:hn,onPaneContextMenu:Zt,paneClickDistance:ae,nodeClickDistance:Ve,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:tn,onReconnectStart:Ne,onReconnectEnd:Ct,onEdgeContextMenu:ln,onEdgeDoubleClick:nn,onEdgeMouseEnter:Kr,onEdgeMouseMove:gr,onEdgeMouseLeave:vn,reconnectRadius:ce,defaultMarkerColor:Me,noDragClassName:dt,noWheelClassName:wt,noPanClassName:yr,rfId:Jn,disableKeyboardA11y:Ai,nodeExtent:Se,viewport:Fr,onViewportChange:ss}),l.jsx(v9,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:g,onConnectStart:w,onConnectEnd:k,onClickConnectStart:j,onClickConnectEnd:C,nodesDraggable:it,autoPanOnNodeFocus:ht,nodesConnectable:Ye,nodesFocusable:nt,edgesFocusable:kt,edgesReconnectable:mt,elementsSelectable:ve,elevateNodesOnSelect:jr,elevateEdgesOnSelect:dr,minZoom:te,maxZoom:oe,nodeExtent:Se,onNodesChange:Ue,onEdgesChange:$e,snapToGrid:me,snapGrid:Fe,connectionMode:U,translateExtent:Ce,connectOnClick:fi,defaultEdgeOptions:Ma,fitView:Pn,fitViewOptions:Qr,onNodesDelete:L,onEdgesDelete:_,onDelete:B,onNodeDragStart:F,onNodeDrag:q,onNodeDragStop:V,onSelectionDrag:H,onSelectionDragStart:R,onSelectionDragStop:$,onMove:x,onMoveStart:p,onMoveEnd:y,noPanClassName:yr,nodeOrigin:ut,rfId:Jn,autoPanOnConnect:Di,autoPanOnNodeDrag:Sn,autoPanSpeed:Fa,onError:Ti,connectionRadius:Is,isValidConnection:$n,selectNodesOnDrag:Pe,nodeDragThreshold:hi,connectionDragThreshold:Mi,onBeforeDelete:M,debug:za,ariaLabelConfig:Ba,zIndexMode:as}),l.jsx(x9,{onSelectionChange:X}),We,l.jsx(d9,{proOptions:Zr,position:Ls}),l.jsx(u9,{rfId:Jn,disableKeyboardA11y:Ai})]})})}var X7=s3(P7);function V7({dimensions:e,lineWidth:t,variant:n,className:i}){return l.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Yn(["react-flow__background-pattern",n,i])})}function W7({radius:e,className:t}){return l.jsx("circle",{cx:e,cy:e,r:e,className:Yn(["react-flow__background-pattern","dots",t])})}var Ea;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ea||(Ea={}));const G7={[Ea.Dots]:1,[Ea.Lines]:1,[Ea.Cross]:6},K7=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function D3({id:e,variant:t=Ea.Dots,gap:n=20,size:i,lineWidth:a=1,offset:o=0,color:c,bgColor:d,style:m,className:f,patternClassName:x}){const p=S.useRef(null),{transform:y,patternId:g}=qt(K7,An),w=i||G7[t],k=t===Ea.Dots,j=t===Ea.Cross,C=Array.isArray(n)?n:[n,n],N=[C[0]*y[2]||1,C[1]*y[2]||1],E=w*y[2],A=Array.isArray(o)?o:[o,o],z=j?[E,E]:N,D=[A[0]*y[2]||1+z[0]/2,A[1]*y[2]||1+z[1]/2],F=`${g}${e||""}`;return l.jsxs("svg",{className:Yn(["react-flow__background",f]),style:{...m,...Qf,"--xy-background-color-props":d,"--xy-background-pattern-color-props":c},ref:p,"data-testid":"rf__background",children:[l.jsx("pattern",{id:F,x:y[0]%N[0],y:y[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:k?l.jsx(W7,{radius:E/2,className:x}):l.jsx(V7,{dimensions:z,lineWidth:a,variant:t,className:x})}),l.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}D3.displayName="Background";S.memo(D3);function Q7(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:l.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Z7(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:l.jsx("path",{d:"M0 0h32v4.2H0z"})})}function J7(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:l.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 eB(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.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 tB(){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l.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 Xd({children:e,className:t,...n}){return l.jsx("button",{type:"button",className:Yn(["react-flow__controls-button",t]),...n,children:e})}const nB=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function T3({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:c,onFitView:d,onInteractiveChange:m,className:f,children:x,position:p="bottom-left",orientation:y="vertical","aria-label":g}){const w=Dn(),{isInteractive:k,minZoomReached:j,maxZoomReached:C,ariaLabelConfig:N}=qt(nB,An),{zoomIn:E,zoomOut:A,fitView:z}=O0(),D=()=>{E(),o==null||o()},F=()=>{A(),c==null||c()},q=()=>{z(a),d==null||d()},V=()=>{w.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),m==null||m(!k)},L=y==="horizontal"?"horizontal":"vertical";return l.jsxs(Kf,{className:Yn(["react-flow__controls",L,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":g??N["controls.ariaLabel"],children:[t&&l.jsxs(l.Fragment,{children:[l.jsx(Xd,{onClick:D,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:C,children:l.jsx(Q7,{})}),l.jsx(Xd,{onClick:F,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:j,children:l.jsx(Z7,{})})]}),n&&l.jsx(Xd,{className:"react-flow__controls-fitview",onClick:q,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:l.jsx(J7,{})}),i&&l.jsx(Xd,{className:"react-flow__controls-interactive",onClick:V,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:k?l.jsx(tB,{}):l.jsx(eB,{})}),x]})}T3.displayName="Controls";S.memo(T3);function rB({id:e,x:t,y:n,width:i,height:a,style:o,color:c,strokeColor:d,strokeWidth:m,className:f,borderRadius:x,shapeRendering:p,selected:y,onClick:g}){const{background:w,backgroundColor:k}=o||{},j=c||w||k;return l.jsx("rect",{className:Yn(["react-flow__minimap-node",{selected:y},f]),x:t,y:n,rx:x,ry:x,width:i,height:a,style:{fill:j,stroke:d,strokeWidth:m},shapeRendering:p,onClick:g?C=>g(C,e):void 0})}const iB=S.memo(rB),sB=e=>e.nodes.map(t=>t.id),zp=e=>e instanceof Function?e:()=>e;function aB({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:o=iB,onClick:c}){const d=qt(sB,An),m=zp(t),f=zp(e),x=zp(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return l.jsx(l.Fragment,{children:d.map(y=>l.jsx(oB,{id:y,nodeColorFunc:m,nodeStrokeColorFunc:f,nodeClassNameFunc:x,nodeBorderRadius:i,nodeStrokeWidth:a,NodeComponent:o,onClick:c,shapeRendering:p},y))})}function lB({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:c,NodeComponent:d,onClick:m}){const{node:f,x,y:p,width:y,height:g}=qt(w=>{const k=w.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const j=k.internals.userNode,{x:C,y:N}=k.internals.positionAbsolute,{width:E,height:A}=Os(j);return{node:j,x:C,y:N,width:E,height:A}},An);return!f||f.hidden||!Fk(f)?null:l.jsx(d,{x,y:p,width:y,height:g,style:f.style,selected:!!f.selected,className:i(f),color:t(f),borderRadius:a,strokeColor:n(f),strokeWidth:o,shapeRendering:c,onClick:m,id:f.id})}const oB=S.memo(lB);var cB=S.memo(aB);const uB=200,dB=150,fB=e=>!e.hidden,hB=e=>{const t={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:t,boundingRect:e.nodeLookup.size>0?Mk(au(e.nodeLookup,{filter:fB}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},mB="react-flow__minimap-desc";function _3({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:c,nodeComponent:d,bgColor:m,maskColor:f,maskStrokeColor:x,maskStrokeWidth:p,position:y="bottom-right",onClick:g,onNodeClick:w,pannable:k=!1,zoomable:j=!1,ariaLabel:C,inversePan:N,zoomStep:E=1,offsetScale:A=5}){const z=Dn(),D=S.useRef(null),{boundingRect:F,viewBB:q,rfId:V,panZoom:L,translateExtent:_,flowWidth:B,flowHeight:X,ariaLabelConfig:R}=qt(hB,An),H=(e==null?void 0:e.width)??uB,$=(e==null?void 0:e.height)??dB,G=F.width/H,Q=F.height/$,K=Math.max(G,Q),M=K*H,U=K*$,P=A*K,O=F.x-(M-F.width)/2-P,Z=F.y-(U-F.height)/2-P,ee=M+P*2,J=U+P*2,se=`${mB}-${V}`,le=S.useRef(0),ye=S.useRef();le.current=K,S.useEffect(()=>{if(D.current&&L)return ye.current=_z({domNode:D.current,panZoom:L,getTransform:()=>z.getState().transform,getViewScale:()=>le.current}),()=>{var me;(me=ye.current)==null||me.destroy()}},[L]),S.useEffect(()=>{var me;(me=ye.current)==null||me.update({translateExtent:_,width:B,height:X,inversePan:N,pannable:k,zoomStep:E,zoomable:j})},[k,j,N,E,_,B,X]);const De=g?me=>{var Pe;const[Fe,Je]=((Pe=ye.current)==null?void 0:Pe.pointer(me))||[0,0];g(me,{x:Fe,y:Je})}:void 0,Ee=w?S.useCallback((me,Fe)=>{const Je=z.getState().nodeLookup.get(Fe).internals.userNode;w(me,Je)},[]):void 0,Re=C??R["minimap.ariaLabel"];return l.jsx(Kf,{position:y,style:{...e,"--xy-minimap-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:Yn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:l.jsxs("svg",{width:H,height:$,viewBox:`${O} ${Z} ${ee} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":se,ref:D,onClick:De,children:[Re&&l.jsx("title",{id:se,children:Re}),l.jsx(cB,{onClick:Ee,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:d}),l.jsx("path",{className:"react-flow__minimap-mask",d:`M${O-P},${Z-P}h${ee+P*2}v${J+P*2}h${-ee-P*2}z
112
+ M${q.x},${q.y}h${q.width}v${q.height}h${-q.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}_3.displayName="MiniMap";S.memo(_3);const pB=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,xB={[yo.Line]:"right",[yo.Handle]:"bottom-right"};function gB({nodeId:e,position:t,variant:n=yo.Handle,className:i,style:a=void 0,children:o,color:c,minWidth:d=10,minHeight:m=10,maxWidth:f=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:y,autoScale:g=!0,shouldResize:w,onResizeStart:k,onResize:j,onResizeEnd:C}){const N=c3(),E=typeof e=="string"?e:N,A=Dn(),z=S.useRef(null),D=n===yo.Handle,F=qt(S.useCallback(pB(D&&g),[D,g]),An),q=S.useRef(null),V=t??xB[n];S.useEffect(()=>{if(!(!z.current||!E))return q.current||(q.current=Pz({domNode:z.current,nodeId:E,getStoreItems:()=>{const{nodeLookup:_,transform:B,snapGrid:X,snapToGrid:R,nodeOrigin:H,domNode:$}=A.getState();return{nodeLookup:_,transform:B,snapGrid:X,snapToGrid:R,nodeOrigin:H,paneDomNode:$}},onChange:(_,B)=>{const{triggerNodeChanges:X,nodeLookup:R,parentLookup:H,nodeOrigin:$}=A.getState(),G=[],Q={x:_.x,y:_.y},K=R.get(E);if(K&&K.expandParent&&K.parentId){const M=K.origin??$,U=_.width??K.measured.width??0,P=_.height??K.measured.height??0,O={id:K.id,parentId:K.parentId,rect:{width:U,height:P,...Rk({x:_.x??K.position.x,y:_.y??K.position.y},{width:U,height:P},K.parentId,R,M)}},Z=$0([O],R,H,$);G.push(...Z),Q.x=_.x?Math.max(M[0]*U,_.x):void 0,Q.y=_.y?Math.max(M[1]*P,_.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const M={id:E,type:"position",position:{...Q}};G.push(M)}if(_.width!==void 0&&_.height!==void 0){const U={id:E,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:_.width,height:_.height}};G.push(U)}for(const M of B){const U={...M,type:"position"};G.push(U)}X(G)},onEnd:({width:_,height:B})=>{const X={id:E,type:"dimensions",resizing:!1,dimensions:{width:_,height:B}};A.getState().triggerNodeChanges([X])}})),q.current.update({controlPosition:V,boundaries:{minWidth:d,minHeight:m,maxWidth:f,maxHeight:x},keepAspectRatio:p,resizeDirection:y,onResizeStart:k,onResize:j,onResizeEnd:C,shouldResize:w}),()=>{var _;(_=q.current)==null||_.destroy()}},[V,d,m,f,x,p,k,j,C,w]);const L=V.split("-");return l.jsx("div",{className:Yn(["react-flow__resize-control","nodrag",...L,n,i]),ref:z,style:{...a,scale:F,...c&&{[D?"backgroundColor":"borderColor"]:c}},children:o})}S.memo(gB);const yB={ceo:"#B71C1C",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#7C4DFF",designer:"#E91E63",qa:"#00897B","data-analyst":"#0288D1","designer-seek":"#E91E63",test:"#78909C"},bB={ceo:"👑",cto:"⚙️",cbo:"📊",pm:"📋",engineer:"🏗️",designer:"🎨",qa:"🔍","data-analyst":"📈","designer-seek":"🎨",test:"🧪"};function vB(e){switch(e.status){case"streaming":return"#60A5FA";case"awaiting_input":return"#FBBF24";case"done":return"#4ADE80";case"error":return"#F87171";case"not-dispatched":return"#4B5563";default:return"#6B7280"}}function wB(e,t){switch(e.status){case"streaming":return"● Working...";case"awaiting_input":return"◉ Awaiting Reply";case"done":return t?"◎ Supervising":"✓ Complete";case"error":return"✗ Error";case"waiting":return"○ Waiting";default:return""}}const io={ceo:{w:120,h:48},"c-level":{w:170,h:64},member:{w:156,h:56}};function kB({data:e,id:t}){const n=e,{node:i,roleLevel:a,isSelected:o,isChecked:c,showCheckbox:d,isEligible:m,hasActiveChildren:f}=n,x=yB[i.roleId]??"#6B7280",p=vB(i),y=Na(i.status),g=a==="ceo",w=io[a],k=bB[i.roleId]??"👤",j=i.status==="not-dispatched",C=g?o?.9:.65:j&&!c?.4:1;return l.jsxs("div",{className:"org-rf-node",style:{width:w.w,height:w.h,borderRadius:g?24:12,background:g?"linear-gradient(135deg, #1a1a2e 0%, #16213e 100%)":`linear-gradient(180deg, ${x}10 0%, var(--terminal-bg-deeper, #181825) 40%)`,border:o?`2px solid ${x}`:c?"2px solid #EF5350":`1px solid ${j?"#333":x+"30"}`,borderStyle:j&&!c?"dashed":"solid",cursor:"pointer",opacity:C,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",boxShadow:y?`0 0 20px ${x}30, 0 4px 12px rgba(0,0,0,0.3)`:o?`0 0 12px ${x}20, 0 2px 8px rgba(0,0,0,0.2)`:"0 2px 6px rgba(0,0,0,0.15)"},children:[l.jsx(bo,{type:"target",position:at.Top,style:{opacity:0,width:1,height:1}}),l.jsx(bo,{type:"source",position:at.Bottom,style:{opacity:0,width:1,height:1}}),y&&l.jsx("div",{style:{position:"absolute",inset:-2,borderRadius:g?26:14,border:`2px solid ${p}`,animation:"org-rf-glow 2s ease-in-out infinite",pointerEvents:"none"}}),g?l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",gap:8,padding:"0 16px"},children:[l.jsx("span",{style:{fontSize:18,lineHeight:1},children:"👑"}),l.jsx("span",{style:{fontSize:13,fontWeight:900,color:"#fff",fontFamily:"var(--pixel-font)",letterSpacing:2},children:"CEO"})]}):l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:a==="c-level"?"10px 12px":"8px 10px",flex:1},children:[l.jsx("div",{style:{width:a==="c-level"?32:28,height:a==="c-level"?32:28,borderRadius:8,background:`${x}18`,border:`1px solid ${x}30`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:a==="c-level"?16:14,flexShrink:0},children:k}),l.jsxs("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[l.jsx("div",{style:{fontSize:a==="c-level"?12:11,fontWeight:800,color:x,fontFamily:"var(--pixel-font)",letterSpacing:.5,lineHeight:1.2},children:i.roleId.toUpperCase()}),i.roleName&&i.roleName!==i.roleId&&l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-secondary, #aaa)",fontFamily:"var(--pixel-font)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:1},children:i.roleName}),l.jsx("div",{style:{fontSize:9,color:p,fontFamily:"var(--pixel-font)",fontWeight:600,marginTop:2},children:wB(i,f)})]}),d&&!g?l.jsx("div",{onClick:N=>{N.stopPropagation(),m&&window.dispatchEvent(new CustomEvent("org-toggle-check",{detail:{roleId:t}}))},style:{cursor:m?"pointer":"default",opacity:m?1:.2,flexShrink:0},children:l.jsx("div",{style:{width:16,height:16,borderRadius:4,background:c?"#EF5350":"transparent",border:`2px solid ${c?"#EF5350":"#555"}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"#fff",transition:"all 0.15s"},children:c&&"✓"})}):!d&&i.status==="done"?l.jsx("span",{style:{fontSize:14,color:"#4ADE80",flexShrink:0,fontWeight:700},children:"✓"}):!d&&i.status==="error"?l.jsx("span",{style:{fontSize:14,color:"#F87171",flexShrink:0,fontWeight:700},children:"✗"}):null]})]})}const SB=S.memo(kB),jB={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#7C4DFF",designer:"#E91E63",qa:"#00897B","data-analyst":"#0288D1","designer-seek":"#E91E63",test:"#78909C"};function CB(e){const{sourceX:t,sourceY:n,targetX:i,targetY:a,data:o}=e,c=o??{},[d]=Mf({sourceX:t,sourceY:n,targetX:i,targetY:a,borderRadius:16});let m="rgba(180,200,240,0.08)",f="6 6",x=!1,p=1.5;return c.childStatus==="done"||c.parentStatus==="done"?(m="#4ADE8040",f="",p=2):c.childStatus==="awaiting_input"?(m="#FBBF2466",f="8 5",x=!0,p=2):c.childStatus==="streaming"&&(m=(jB[c.childRoleId??""]??"#60A5FA")+"55",f="8 5",x=!0,p=2.2),l.jsx(cu,{path:d,style:{stroke:m,strokeWidth:p,strokeDasharray:f},className:x?"wave-edge-flow":void 0})}const NB=S.memo(CB),Bp=24,EB=56,AB={orgRole:SB},DB={orgEdge:NB};function TB(e,t,n){var i,a;return e===t?"ceo":((i=n==null?void 0:n[e])==null?void 0:i.level)==="c-level"||((a=n==null?void 0:n[e])==null?void 0:a.reportsTo)===t?"c-level":"member"}function _B(e,t,n){if(!e.get(t))return[];const a=[],o=[],c=[{id:t,depth:0,parentId:null}],d=new Set;for(;c.length>0;){const{id:f,depth:x,parentId:p}=c.shift();if(d.has(f))continue;for(d.add(f);o.length<=x;)o.push([]);o[x].push(f);const y=TB(f,t,n);a.push({roleId:f,x:0,y:0,parentId:p,level:y});const g=e.get(f);if(g)for(const w of g.children)e.has(w)&&!d.has(w)&&c.push({id:w,depth:x+1,parentId:f})}let m=0;for(let f=0;f<o.length;f++){const x=o[f],p=Math.max(...x.map(w=>{const k=a.find(j=>j.roleId===w);return k?io[k.level].h:44}));let g=-x.reduce((w,k)=>{const j=a.find(C=>C.roleId===k);return w+(j?io[j.level].w:130)+Bp},-Bp)/2;for(const w of x){const k=a.find(C=>C.roleId===w);if(!k)continue;const j=io[k.level];k.x=g+j.w/2,k.y=m+(p-j.h)/2,g+=j.w+Bp}m+=p+EB}for(const f of a){const x=io[f.level];f.x-=x.w/2}return a}function M3({nodes:e,rootId:t,selectedRoleId:n,onSelectNode:i,checkedRoles:a,onToggleCheck:o,eligibleRoles:c,orgNodes:d}){const m=!!o,{rfNodes:f,rfEdges:x}=S.useMemo(()=>{const y=_B(e,t,d),g=y.map(k=>{const j=e.get(k.roleId);if(!j)return null;const C=j.children.some(A=>{const z=e.get(A);return z&&Na(z.status)}),N={node:j,roleLevel:k.level,isSelected:n===k.roleId,isChecked:(a==null?void 0:a.has(k.roleId))??!1,showCheckbox:m,isEligible:!c||c.has(k.roleId),hasActiveChildren:C},E=io[k.level];return{id:k.roleId,type:"orgRole",position:{x:k.x,y:k.y},data:N,draggable:!1,selectable:!1,width:E.w,height:E.h}}).filter(Boolean),w=y.filter(k=>k.parentId).map(k=>{const j=e.get(k.roleId),C=e.get(k.parentId);return{id:`${k.parentId}-${k.roleId}`,source:k.parentId,target:k.roleId,type:"orgEdge",data:{childStatus:j==null?void 0:j.status,parentStatus:C==null?void 0:C.status,childRoleId:k.roleId},selectable:!1}});return{rfNodes:g,rfEdges:w}},[e,t,n,a,c,m,d]),p=S.useCallback((y,g)=>{i(g.id)},[i]);return S.useEffect(()=>{if(!o)return;const y=g=>{var k;const w=(k=g.detail)==null?void 0:k.roleId;w&&o(w)};return window.addEventListener("org-toggle-check",y),()=>window.removeEventListener("org-toggle-check",y)},[o]),l.jsx("div",{className:"org-rf-container",style:{width:"100%",height:"100%",minHeight:220},children:l.jsx(X7,{nodes:f,edges:x,nodeTypes:AB,edgeTypes:DB,onNodeClick:p,fitView:!0,fitViewOptions:{padding:.12,minZoom:.5,maxZoom:1},zoomOnScroll:!1,zoomOnPinch:!1,panOnDrag:!1,panOnScroll:!1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},minZoom:.3,maxZoom:2})})}const MB={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function FB({directive:e,rootDispatches:t,orgNodes:n,rootRoleId:i,waveId:a,onClose:o,onMinimize:c,onDone:d,onOpenKnowledgeDoc:m,onSave:f}){const{nodes:x,selectedRoleId:p,selectNode:y,progress:g,allDone:w,connectStream:k}=K5(t,n,i,a),[j,C]=S.useState(0),[N,E]=S.useState(new Set),[A,z]=S.useState(""),[D,F]=S.useState(!1),[q,V]=S.useState(!1),L=S.useRef(null),_=S.useRef(Date.now()),B=S.useRef(!1),X=S.useCallback(async()=>{if(f){V(!0);try{const P=t.map(O=>O.sessionId).filter(Boolean);await f(P)}catch(P){console.error("Save failed:",P)}finally{V(!1),o()}}},[f,t,o]),R=S.useCallback(async()=>{if(!p||!A.trim())return;const P=x.get(p);if(!(!(P!=null&&P.sessionId)||P.status!=="awaiting_input"&&P.status!=="done")){F(!0);try{await ke.replyToSession(P.sessionId,A.trim()),z(""),k(P.sessionId,p)}catch(O){console.error("Reply failed:",O)}finally{F(!1)}}},[p,A,x,k]),H=S.useCallback(async P=>{const O=x.get(P);if(O!=null&&O.sessionId)try{await ke.abortSession(O.sessionId)}catch{}},[x]),$=S.useCallback(async()=>{for(const[,P]of x)if(Na(P.status))try{P.sessionId&&await ke.abortSession(P.sessionId)}catch{}},[x]);S.useEffect(()=>{const P=setInterval(()=>{C(Math.floor((Date.now()-_.current)/1e3))},1e3);return()=>clearInterval(P)},[]);const G=S.useRef(!1);S.useEffect(()=>{const P=L.current;if(!P)return;const O=()=>{const Z=P.scrollHeight-P.scrollTop-P.clientHeight<60;G.current=!Z};return P.addEventListener("scroll",O),()=>P.removeEventListener("scroll",O)},[]),S.useEffect(()=>{G.current=!1,L.current&&(L.current.scrollTop=L.current.scrollHeight)},[p]),S.useEffect(()=>{L.current&&!G.current&&(L.current.scrollTop=L.current.scrollHeight)},[x]),S.useEffect(()=>{w&&!B.current&&(B.current=!0,d==null||d()),!w&&B.current&&(B.current=!1)},[w,d]);const Q=P=>`${Math.floor(P/60)}:${String(P%60).padStart(2,"0")}`,K=p?x.get(p):null,M=p?MB[p]??"#888":"#888",U=P=>{E(O=>{const Z=new Set(O);return Z.has(P)?Z.delete(P):Z.add(P),Z})};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm pointer-events-none"}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[960px] max-w-[95vw] h-[85vh] z-[61] bg-[var(--terminal-bg)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:w?"#2E7D32":"#B71C1C",animation:w?void 0:"wave-pulse 2s ease-in-out infinite"}}),l.jsx("div",{children:l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-sm",children:w?"WAVE COMPLETE":"WAVE COMMAND CENTER"})})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono",children:Q(j)}),g.awaitingInput>0&&l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:"#F59E0B22",color:"#F59E0B"},children:[g.awaitingInput," awaiting reply"]}),l.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:w?"#2E7D3222":"#B71C1C22",color:w?"#2E7D32":"#B71C1C"},children:[g.done,"/",g.total," done"]}),!w&&(g.running>0||g.awaitingInput>0)&&l.jsx("button",{onClick:$,className:"text-xs px-2 py-0.5 rounded font-semibold cursor-pointer",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Stop all running jobs",children:"Stop All"}),l.jsx("button",{onClick:c,title:"Minimize",className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-sm cursor-pointer px-1",children:"–"}),l.jsx("button",{onClick:o,className:"text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text)] text-lg cursor-pointer",title:w?"Dismiss wave":"Close (jobs keep running)",children:"×"})]})]}),l.jsx("div",{className:"px-5 py-2 border-b border-[var(--terminal-border)] shrink-0",children:l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic",children:["“",e,"”"]})}),l.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[l.jsxs("div",{className:"shrink-0 border-b border-[var(--terminal-border)] flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",children:[l.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:"Org Propagation"}),l.jsx("div",{className:"flex gap-x-3 ml-auto",children:[{label:"streaming",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(P=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:P.color,animation:P.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:P.label})]},P.label))})]}),l.jsx("div",{className:"px-3 pb-2",style:{height:"35vh"},children:l.jsx(M3,{nodes:x,rootId:i,selectedRoleId:p,onSelectNode:y,orgNodes:n})})]}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[K&&l.jsxs("div",{className:"px-4 py-2 border-b border-[var(--terminal-border)] shrink-0 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:M}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:K.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:K.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:K.status==="awaiting_input"?"#F59E0B22":`${M}22`,color:K.status==="awaiting_input"?"#F59E0B":M},children:K.status==="streaming"?"Working":K.status==="done"?"Complete":K.status==="error"?"Error":K.status==="waiting"?"Waiting":K.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),Na(K.status)&&K.sessionId&&l.jsx("button",{onClick:()=>H(K.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},title:"Force stop this execution",children:"Stop"})]}),l.jsxs("div",{ref:L,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text",children:[K&&K.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:K.status==="waiting"?"Waiting for dispatch...":K.status==="streaming"?"Connecting to activity stream...":K.status==="not-dispatched"?"This role was not dispatched in this wave.":""}),K==null?void 0:K.events.map(P=>l.jsx(k0,{event:P,isThinkingCollapsed:N.has(P.seq),onToggleThinking:()=>U(P.seq),onNavigateToSession:O=>{const Z=K==null?void 0:K.events.find(J=>J.type==="dispatch:start"&&J.data.childSessionId===O),ee=Z==null?void 0:Z.data.targetRoleId;ee&&x.has(ee)&&y(ee)},onOpenKnowledgeDoc:m},P.seq)),(K==null?void 0:K.status)==="streaming"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"})]}),(K==null?void 0:K.status)==="awaiting_input"&&l.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#F59E0B0A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#F59E0B"},children:[K.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:A,onChange:P=>z(P.target.value),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),R())},placeholder:"Type your response...",disabled:D,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#F59E0B]",autoFocus:!0}),l.jsx("button",{onClick:R,disabled:D||!A.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#F59E0B",color:"#000"},children:D?"...":"Reply"})]})]}),(K==null?void 0:K.status)==="done"&&K.sessionId&&l.jsxs("div",{className:"px-4 py-3 border-t border-[var(--terminal-border)] shrink-0",style:{background:"#1565C00A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#64B5F6"},children:["Follow-up to ",K.roleName]}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"Send a follow-up directive"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:A,onChange:P=>z(P.target.value),onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),R())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:D,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#64B5F6]"}),l.jsx("button",{onClick:R,disabled:D||!A.trim(),className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#1565C0",color:"#fff"},children:D?"...":"Send"})]})]}),!K&&l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-xs",children:"Click a node in the org tree to view activity"}),l.jsxs("div",{className:"px-4 py-2 border-t border-[var(--terminal-border)] flex items-center justify-between shrink-0",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:K&&K.events.length>0&&`${K.events.length} events`}),w&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:o,className:"px-4 py-1.5 text-xs rounded-lg font-semibold cursor-pointer",style:{background:"rgba(255,255,255,0.08)",color:"var(--terminal-text-muted)"},children:"Dismiss"}),f&&l.jsx("button",{onClick:X,disabled:q,className:"px-4 py-1.5 text-xs text-white rounded-lg font-semibold cursor-pointer disabled:opacity-50",style:{background:"#2E7D32"},children:q?"Saving...":"Save Wave"})]})]})]})]})]})]})}const RB={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function Iw({orgNodes:e,rootRoleId:t,cLevelRoles:n,pastWaves:i,activeWaves:a,onDispatch:o,onClose:c,onDone:d,onSave:m,onOpenKnowledgeDoc:f,onRefreshWaves:x,terminalWidth:p=0,onMaximize:y,inline:g=!1,onOpenSaveModal:w}){const[k,j]=S.useState(""),[C,N]=S.useState(!1),[E,A]=S.useState(null),[z,D]=S.useState(!1),[F,q]=S.useState(a.length>0?0:-1),[,V]=S.useState(!1),L=S.useRef(null),_=F>=0?a[F]??null:null,B=S.useMemo(()=>[],[]),X=(_==null?void 0:_.rootDispatches)??B,R=K5(X,e,t,(_==null?void 0:_.id)??null);S.useEffect(()=>{if(E){const ce=zB(e,t,E.roles);R.injectStaticNodes(ce);for(const Ue of E.roles??[])if(y2(Ue.status)&&Ue.sessionId){const $e=ce.get(Ue.roleId);$e!=null&&$e.sessionId&&setTimeout(()=>R.connectStream($e.sessionId,Ue.roleId),100)}}},[E,e,t]),S.useEffect(()=>{!R.selectedRoleId&&t&&R.selectNode(t)},[t]);const H=S.useRef(a.length);S.useEffect(()=>{const ce=a.length>H.current;H.current=a.length,ce&&(q(0),A(null),V(!1))},[a.length]);const[$,G]=S.useState(null),Q=S.useMemo(()=>{if(!$)return null;const ce=$.modified.length+$.untracked.length;return{branch:$.branch,dirty:ce>0,count:ce}},[$]),K=S.useCallback(()=>{ke.getSaveStatus("code").then(ce=>{G({dirty:ce.modified.length+ce.untracked.length>0,modified:ce.modified,untracked:ce.untracked,lastCommit:ce.lastCommit,branch:ce.branch})}).catch(()=>{})},[]);S.useEffect(()=>{K()},[K]);const[M,U]=S.useState(0);S.useEffect(()=>{if(!_)return;const ce=setInterval(()=>{U(Math.floor((Date.now()-_.startedAt)/1e3))},1e3);return()=>clearInterval(ce)},[_]);const[P,O]=S.useState(""),[Z,ee]=S.useState(!1),[J,se]=S.useState([]),[le,ye]=S.useState(!1),[De,Ee]=S.useState(null),Re=S.useRef(null);S.useEffect(()=>{if(De){const ce=setTimeout(()=>Ee(null),3e3);return()=>clearTimeout(ce)}},[De]);const me=S.useCallback(async ce=>["image/png","image/jpeg","image/gif","image/webp"].includes(ce.type)?ce.size>5*1024*1024?(Ee(`Too large: ${(ce.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise($e=>{const dt=new FileReader;dt.onload=()=>{const wt=dt.result.split(",")[1];$e({type:"image",data:wt,name:ce.name,mediaType:ce.type})},dt.onerror=()=>{Ee("Failed to read file"),$e(null)},dt.readAsDataURL(ce)}):(Ee(`Unsupported: ${ce.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),Fe=S.useCallback(async ce=>{const Ue=[];for(const $e of Array.from(ce)){const dt=await me($e);dt&&Ue.push(dt)}Ue.length>0&&se($e=>[...$e,...Ue])},[me]),Je=S.useCallback(ce=>{ce.preventDefault(),ce.stopPropagation(),ye(!0)},[]),Pe=S.useCallback(ce=>{ce.preventDefault(),ce.stopPropagation(),ye(!1)},[]),it=S.useCallback(ce=>{ce.preventDefault(),ce.stopPropagation(),ye(!1),ce.dataTransfer.files.length>0&&Fe(ce.dataTransfer.files)},[Fe]),ht=S.useCallback(ce=>{const Ue=[];for(let $e=0;$e<ce.clipboardData.items.length;$e++){const dt=ce.clipboardData.items[$e];if(dt.type.startsWith("image/")){const wt=dt.getAsFile();wt&&Ue.push(wt)}}Ue.length>0&&(ce.preventDefault(),Fe(Ue))},[Fe]),[Ye,nt]=S.useState(320),ut=S.useRef(!1),kt=S.useRef(0),mt=S.useRef(0),ve=S.useCallback(ce=>{ce.preventDefault(),ut.current=!0,kt.current=ce.clientX,mt.current=Ye;const Ue=dt=>{if(!ut.current)return;const wt=kt.current-dt.clientX;nt(Math.max(200,Math.min(500,mt.current+wt)))},$e=()=>{ut.current=!1,window.removeEventListener("mousemove",Ue),window.removeEventListener("mouseup",$e)};window.addEventListener("mousemove",Ue),window.addEventListener("mouseup",$e)},[Ye]),[be,te]=S.useState(new Set),oe=S.useRef(null),Ce=S.useRef(!1);S.useEffect(()=>{const ce=oe.current;if(!ce)return;const Ue=()=>{const $e=ce.scrollHeight-ce.scrollTop-ce.clientHeight<60;Ce.current=!$e};return ce.addEventListener("scroll",Ue),()=>ce.removeEventListener("scroll",Ue)},[]),S.useEffect(()=>{!Ce.current&&oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)},[R.nodes,R.selectedRoleId]);const pe=R.selectedRoleId?R.nodes.get(R.selectedRoleId)??null:null,Se=pe?RB[pe.roleId]??"#888":"#888",Me=R.progress.running>0||R.progress.awaitingInput>0,Ge=R.selectedRoleId===t,Ie=!!E&&!_,qe=(_==null?void 0:_.directive)??(E==null?void 0:E.directive)??"",Xe=S.useCallback(ce=>{const Ue=new Set,$e=[ce];for(;$e.length>0;){const dt=$e.shift();if(Ue.has(dt))continue;Ue.add(dt);const wt=e[dt];wt&&$e.push(...wt.children)}return Ue},[e]),et=S.useMemo(()=>{if(!R.selectedRoleId)return new Set;const ce=Xe(R.selectedRoleId);return ce.delete(t),ce},[R.selectedRoleId,Xe,t]),ze=S.useRef(null);S.useEffect(()=>{if(R.selectedRoleId===ze.current||(ze.current=R.selectedRoleId,!R.selectedRoleId))return;const ce=Xe(R.selectedRoleId);ce.delete(t),R.setCheckedRoles(ce)},[R.selectedRoleId,Xe,t]);const Be=R.checkedRoles.size,_t=()=>{if(!k.trim()&&J.length===0||Be===0)return;const Ue=Array.from(R.nodes.keys()).filter(dt=>dt!==t).every(dt=>R.checkedRoles.has(dt)),$e=J.length>0?J:void 0;o(k.trim(),Ue?void 0:Array.from(R.checkedRoles),$e,C||void 0),j(""),se([])},en=ce=>{ce.key==="Enter"&&(ce.metaKey||ce.ctrlKey)&&(ce.preventDefault(),_t()),ce.key==="Escape"&&c()},Tt=S.useCallback(async()=>{if(!R.selectedRoleId||!P.trim()&&J.length===0)return;const ce=R.nodes.get(R.selectedRoleId);if(!ce)return;const Ue=J.length>0?J:void 0;ee(!0);try{if(ce.status==="awaiting_input"&&ce.sessionId){const $e=await ke.replyToSession(ce.sessionId,P.trim(),Ue);O(""),se([]),!!(_!=null&&_.id)||R.connectStream($e.sessionId||ce.sessionId,R.selectedRoleId)}else{const $e=(_==null?void 0:_.id)??(E==null?void 0:E.waveId)??(E==null?void 0:E.id),dt=await ke.execute({type:"assign",roleId:R.selectedRoleId,task:P.trim(),...$e&&{waveId:$e},...Ue&&{attachments:Ue}});O(""),se([]),dt.sessionId&&(_!=null&&_.id||R.connectStream(dt.sessionId,R.selectedRoleId))}}catch($e){console.error("Reply failed:",$e)}finally{ee(!1)}},[R,P,J,_,E]),Pt=S.useCallback(async ce=>{const Ue=R.nodes.get(ce);if(Ue!=null&&Ue.sessionId)try{await ke.abortSession(Ue.sessionId)}catch{}},[R.nodes]),hn=S.useCallback(async()=>{for(const[,ce]of R.nodes)if(Na(ce.status))try{ce.sessionId&&await ke.abortSession(ce.sessionId)}catch{}},[R.nodes]),Zt=S.useCallback(async ce=>{D(!0),A(null),q(-1);try{const Ue=await ke.getWaveDetail(ce);Ue.replay&&A(Ue.replay)}catch(Ue){console.error("Failed to load wave:",Ue)}finally{D(!1)}},[]),ae=S.useRef(!1);S.useEffect(()=>{ae.current||a.length===0&&i.length>0&&!E&&!z&&(ae.current=!0,Zt(i[0].id))},[a.length,i,E,z,Zt]);const Ve=S.useRef(!1),We=S.useRef(null);S.useEffect(()=>{if(!(E||z)&&((_==null?void 0:_.id)!==We.current&&(Ve.current=!1,We.current=(_==null?void 0:_.id)??null),R.allDone&&!Ve.current&&_&&(Ve.current=!0,K(),d==null||d(),m))){const ce=_.rootDispatches.map(Ue=>Ue.sessionId).filter(Boolean);m(_.directive,ce,{waveId:_.id,sessionIds:_.sessionIds}).catch(()=>{})}},[R.allDone,_,d,m,K,E,z]);const tn=S.useCallback(async()=>{if(!m||!_)return;const ce=_.rootDispatches.map(Ue=>Ue.sessionId).filter(Boolean);await m(_.directive,ce,{waveId:_.id,sessionIds:_.sessionIds})},[m,_]),Ne=ce=>{te(Ue=>{const $e=new Set(Ue);return $e.has(ce)?$e.delete(ce):$e.add(ce),$e})},Ct=ce=>{const Ue=Math.floor(ce/60),$e=ce%60;return`${Ue}:${$e.toString().padStart(2,"0")}`},{panelRight:ln,panelWidth:nn,isResizing:Kr,handleResizeStart:gr}=nu(p,700,y),vn=l.jsxs(l.Fragment,{children:[!g&&l.jsxs("div",{className:"shrink-0 px-4 py-3",style:{background:"linear-gradient(180deg, #B71C1C 0%, #7f1d1d 100%)"},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-white font-bold text-lg tracking-wide",style:{fontFamily:"var(--pixel-font)"},children:"Wave Center"}),Me&&l.jsxs("span",{className:"text-white/60 text-xs",children:[R.progress.running+R.progress.awaitingInput," active",R.progress.awaitingInput>0&&` (${R.progress.awaitingInput} awaiting)`]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[y&&l.jsx("button",{onClick:y,className:"text-white/50 hover:text-white text-xs cursor-pointer",children:"Maximize"}),l.jsx("button",{onClick:c,className:"text-white/50 hover:text-white text-xl leading-none cursor-pointer px-2",children:"✕"})]})]}),l.jsx("div",{className:"text-white/60 text-xs mt-0.5",children:_?`${a.length} active wave${a.length!==1?"s":""}`:Ie?"Reviewing past wave":"Broadcast directives to your organization"})]}),l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[(_||Ie)&&l.jsxs("div",{className:"px-4 py-2 border-b flex items-center gap-3 shrink-0",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{background:Me?"#FBBF24":R.allDone||Ie?"#2E7D32":"#B71C1C",animation:Me?"wave-pulse 2s ease-in-out infinite":void 0}}),l.jsxs("span",{className:"text-[var(--terminal-text-secondary)] text-xs italic flex-1 min-w-0 truncate",children:["“",qe,"”"]}),_&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:Ct(M)}),Ie&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:Me?"#FBBF2422":"#2E7D3222",color:Me?"#FBBF24":"#2E7D32"},children:Me?"LIVE":"REPLAY"}),Ie&&(E==null?void 0:E.startedAt)&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:new Date(E.startedAt).toLocaleString()}),R.progress.awaitingInput>0&&l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:"#F59E0B22",color:"#F59E0B"},children:[R.progress.awaitingInput," awaiting"]}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:R.allDone||Ie&&!Me?"#2E7D3222":"#B71C1C22",color:R.allDone||Ie&&!Me?"#2E7D32":"#B71C1C"},children:[R.progress.done,"/",R.progress.total]}),Me&&l.jsx("button",{onClick:hn,className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer shrink-0",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},children:"Stop All"})]}),l.jsxs("div",{className:"shrink-0 border-b flex flex-col",style:{borderColor:"var(--terminal-border)"},children:[l.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",children:[l.jsx("span",{className:"text-[10px] font-bold text-[var(--terminal-text-secondary)] uppercase tracking-wider",children:_||Ie?"Org Propagation":"Select Target Roles"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[R.checkedRoles.size,"/",R.progress.total," selected"]}),(_||Ie)&&l.jsx("div",{className:"flex gap-x-3",children:[{label:"streaming",color:"#FBBF24",dot:!0},{label:"awaiting",color:"#F59E0B",dot:!0},{label:"done",color:"#2E7D32",dot:!1},{label:"waiting",color:"#888",dot:!1},{label:"error",color:"#C62828",dot:!1}].map(ce=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:ce.color,animation:ce.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:ce.label})]},ce.label))})]}),l.jsx("div",{className:"px-3 pb-2",style:{height:"38vh"},children:l.jsx(M3,{nodes:R.nodes,rootId:t,selectedRoleId:R.selectedRoleId,onSelectNode:R.selectNode,checkedRoles:R.checkedRoles,onToggleCheck:R.toggleCheck,eligibleRoles:et,orgNodes:e})})]}),z?l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"Loading wave data..."}):Ge?l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[l.jsxs("div",{className:"px-4 py-2 border-b shrink-0 flex items-center gap-2",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:"#B71C1C"}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:"CEO"}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:"Directive Control"}),l.jsxs("span",{className:"ml-auto text-[10px] text-[var(--terminal-text-muted)]",children:[Be," target role",Be!==1?"s":""," selected"]})]}),l.jsxs("div",{ref:oe,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-2 text-xs font-mono select-text",children:[qe&&l.jsxs("div",{className:"flex items-start gap-2 pb-3 border-b",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded shrink-0",style:{background:"#B71C1C33",color:"#EF5350"},children:"CEO"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--terminal-text-secondary)] whitespace-pre-wrap",children:qe}),_&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:["dispatched ",Ct(M)," ago to ",_.rootDispatches.length," role",_.rootDispatches.length!==1?"s":""]})]})]}),!qe&&!_&&l.jsx("div",{className:"text-[var(--terminal-text-muted)] text-center py-8",children:"Select target roles using checkboxes, then dispatch a directive below."})]}),l.jsxs("div",{className:"px-4 py-3 border-t shrink-0",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[J.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:J.map((ce,Ue)=>l.jsxs("div",{className:"relative group w-14 h-14 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${ce.mediaType};base64,${ce.data}`,alt:ce.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>se($e=>$e.filter((dt,wt)=>wt!==Ue)),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-[9px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[7px] text-white truncate px-1",children:ce.name})]},Ue))}),De&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:De}),l.jsxs("div",{className:"flex gap-2 items-end",children:[l.jsx("button",{onClick:()=>{var ce;return(ce=Re.current)==null?void 0:ce.click()},className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] transition-colors",title:"Attach image",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("textarea",{ref:L,value:k,onChange:ce=>j(ce.target.value),onKeyDown:en,onPaste:ht,placeholder:"e.g. Report current status across all departments",rows:2,className:"flex-1 px-3 py-2 text-sm rounded-lg border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none resize-none",style:{borderColor:"var(--terminal-border)"}}),l.jsxs("button",{onClick:_t,disabled:!k.trim()&&J.length===0||Be===0,className:"px-4 py-2 text-xs font-bold rounded-lg cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed shrink-0",style:{background:k.trim()&&Be>0?"#B71C1C":"#333",color:"#fff",minWidth:140},children:["Dispatch to ",Be," Role",Be!==1?"s":""]})]}),l.jsxs("div",{className:"flex items-center justify-between mt-1",children:[l.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[l.jsx("input",{type:"checkbox",checked:C,onChange:ce=>N(ce.target.checked),className:"accent-[#B71C1C] w-3 h-3 cursor-pointer"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"Continuous"})]}),l.jsx("div",{className:"text-[9px] text-[var(--terminal-text-muted)]",children:"Cmd+Enter to dispatch"})]})]})]}):l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[pe&&l.jsxs("div",{className:"px-4 py-2 border-b shrink-0 flex items-center gap-2",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:Se}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:pe.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:pe.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:pe.status==="awaiting_input"?"#F59E0B22":pe.status==="streaming"?"#FBBF2422":`${Se}22`,color:pe.status==="awaiting_input"?"#F59E0B":pe.status==="streaming"?"#FBBF24":Se},children:pe.status==="streaming"?"Working...":pe.status==="done"?pe.children.some(ce=>{const Ue=R.nodes.get(ce);return Ue&&Na(Ue.status)})?"Supervising...":"Complete":pe.status==="error"?"Error":pe.status==="waiting"?"Waiting":pe.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),l.jsxs("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[pe.events.length," events"]}),Na(pe.status)&&pe.sessionId&&l.jsx("button",{onClick:()=>Pt(pe.roleId),className:"text-[10px] px-2 py-0.5 rounded font-semibold cursor-pointer ml-1",style:{background:"#C6282822",color:"#C62828",border:"1px solid #C6282844"},children:"Stop"})]}),pe&&l.jsxs("div",{className:"px-4 py-2 border-b shrink-0",style:{borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] font-mono",children:[pe.sessionId&&l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)]",children:"Session "}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)]",children:pe.sessionId.slice(0,8)})]}),l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)]",children:"Events "}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)]",children:pe.events.length})]}),l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)]",children:"Stream "}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)]",children:pe.streamStatus})]}),(()=>{const ce=pe.events[pe.events.length-1];if(!(ce!=null&&ce.ts))return null;const Ue=Math.floor((Date.now()-new Date(ce.ts).getTime())/1e3);if(isNaN(Ue)||Ue<0)return null;const $e=Ue<60?`${Ue}s ago`:Ue<3600?`${Math.floor(Ue/60)}m ago`:`${Math.floor(Ue/3600)}h ago`;return l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--terminal-text-muted)]",children:"Last activity "}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)]",children:$e})]})})()]}),(()=>{var wt,yr;const ce=pe.events.filter(Pn=>Pn.type==="text"||Pn.type==="tool:result"),Ue=ce[ce.length-1];if(!Ue)return null;const $e=typeof((wt=Ue.data)==null?void 0:wt.text)=="string"?Ue.data.text:typeof((yr=Ue.data)==null?void 0:yr.content)=="string"?Ue.data.content:null;if(!$e)return null;const dt=$e.length>120?$e.slice(0,120)+"...":$e;return l.jsx("div",{className:"mt-1.5 text-[10px] text-[var(--terminal-text-muted)] italic truncate",title:$e,children:dt})})()]}),l.jsx("input",{ref:Re,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:ce=>{var Ue;(Ue=ce.target.files)!=null&&Ue.length&&Fe(ce.target.files),ce.target.value=""},className:"hidden"}),l.jsxs("div",{ref:oe,className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text transition-colors ${le?"bg-amber-500/5 ring-1 ring-inset ring-amber-500/30":""}`,onDragOver:Je,onDragLeave:Pe,onDrop:it,children:[pe&&qe&&pe.status!=="waiting"&&pe.status!=="not-dispatched"&&l.jsxs("div",{className:"flex items-start gap-2 mb-3 pb-2 border-b",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded shrink-0",style:{background:"#B71C1C33",color:"#EF5350"},children:"CEO"}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] whitespace-pre-wrap",children:qe})]}),pe&&pe.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:pe.status==="waiting"?"Waiting for dispatch...":pe.status==="streaming"?"Connecting to activity stream...":pe.status==="not-dispatched"?"This role was not dispatched. Send a follow-up to activate.":""}),pe==null?void 0:pe.events.map((ce,Ue)=>{const $e=pe.events,dt=ce.type==="msg:start"&&Ue>0,wt=$e[Ue+1];if((ce.type==="msg:done"||ce.type==="msg:error"||ce.type==="msg:awaiting_input")&&(wt==null?void 0:wt.type)==="msg:start")return null;if(dt){const Pn=ce.data.task??"",Qr=Pn.match(/\[CEO Follow-up\]\n([\s\S]+)$/),fi=Qr?Qr[1].trim():Pn;return l.jsx(S.Fragment,{children:l.jsxs("div",{className:"flex items-start gap-2 my-3 pt-2 pb-2 border-t border-b",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded shrink-0",style:{background:"#B71C1C33",color:"#EF5350"},children:"CEO"}),l.jsx("span",{className:"text-[var(--terminal-text-secondary)] whitespace-pre-wrap",children:fi})]})},`followup-${ce.seq}`)}return l.jsx(k0,{event:ce,isThinkingCollapsed:be.has(ce.seq),onToggleThinking:()=>Ne(ce.seq),onNavigateToSession:Pn=>{for(const[,Qr]of R.nodes)if(Qr.events.some(fi=>fi.data.childSessionId===Pn)){R.selectNode(Qr.roleId);return}},onOpenKnowledgeDoc:f},ce.seq)}),(pe==null?void 0:pe.status)==="streaming"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"}),!pe&&l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-xs h-full",children:"Click a node in the org tree to view activity"})]}),((pe==null?void 0:pe.status)==="awaiting_input"||(pe==null?void 0:pe.status)==="done"||(pe==null?void 0:pe.status)==="not-dispatched")&&(J.length>0||De||le)&&l.jsxs("div",{className:"px-4 pt-2 border-t shrink-0",style:{borderColor:"var(--terminal-border)"},children:[De&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:De}),le&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-1",children:"Drop image here"}),J.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-1",children:J.map((ce,Ue)=>l.jsxs("div",{className:"relative group w-14 h-14 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${ce.mediaType};base64,${ce.data}`,alt:ce.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>se($e=>$e.filter((dt,wt)=>wt!==Ue)),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-[9px] flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[7px] text-white truncate px-1",children:ce.name})]},Ue))})]}),(pe==null?void 0:pe.status)==="awaiting_input"&&l.jsxs("div",{className:"px-4 py-3 border-t shrink-0",style:{borderColor:"var(--terminal-border)",background:"#F59E0B0A"},children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:"#F59E0B",animation:"wave-pulse 1.5s ease-in-out infinite"}}),l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#F59E0B"},children:[pe.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ce;return(ce=Re.current)==null?void 0:ce.click()},disabled:Z,className:"w-7 h-7 rounded bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 transition-colors",title:"Attach image",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{type:"text",value:P,onChange:ce=>O(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&!ce.shiftKey&&(ce.preventDefault(),Tt())},onPaste:ht,placeholder:"Type your response...",disabled:Z,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none",style:{borderColor:"var(--terminal-border)"},autoFocus:!0}),l.jsx("button",{onClick:Tt,disabled:Z||!P.trim()&&J.length===0,className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#F59E0B",color:"#000"},children:Z?"...":"Reply"})]})]}),pe&&(pe.status==="done"||pe.status==="not-dispatched")&&l.jsxs("div",{className:"px-4 py-3 border-t shrink-0",style:{borderColor:"var(--terminal-border)",background:"#1565C00A"},children:[l.jsx("div",{className:"flex items-center gap-2 mb-2",children:l.jsxs("span",{className:"text-[11px] font-semibold",style:{color:"#64B5F6"},children:["Follow-up to ",pe.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ce;return(ce=Re.current)==null?void 0:ce.click()},disabled:Z,className:"w-7 h-7 rounded bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 transition-colors",title:"Attach image",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{type:"text",value:P,onChange:ce=>O(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&!ce.shiftKey&&(ce.preventDefault(),Tt())},onPaste:ht,placeholder:"Send a follow-up directive...",disabled:Z,className:"flex-1 px-3 py-1.5 text-xs rounded border bg-[var(--terminal-bg)] text-[var(--terminal-text)] outline-none",style:{borderColor:"var(--terminal-border)"}}),l.jsx("button",{onClick:Tt,disabled:Z||!P.trim()&&J.length===0,className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#1565C0",color:"#fff"},children:Z?"...":"Send"})]})]}),R.allDone&&_&&m&&l.jsx("div",{className:"px-4 py-2 border-t shrink-0 flex justify-end",style:{borderColor:"var(--terminal-border)"},children:l.jsx("button",{onClick:tn,className:"px-4 py-1.5 text-xs rounded font-semibold cursor-pointer",style:{background:"#1565C022",color:"#64B5F6",border:"1px solid #1565C044"},children:"Save Wave"})})]})]}),l.jsxs("div",{className:"shrink-0 border-l flex flex-col relative",style:{width:Ye,borderColor:"var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsx("div",{className:"absolute top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-[var(--accent)] z-10",style:{left:-2},onMouseDown:ve}),l.jsx("div",{className:"p-3 pb-0",children:l.jsx("button",{onClick:()=>{A(null),q(-1),V(!0),R.reset()},className:"w-full px-3 py-1.5 text-[11px] font-bold rounded-lg cursor-pointer transition-colors",style:{background:!E&&F<0?"#B71C1C":"var(--terminal-inline-bg)",color:!E&&F<0?"#fff":"var(--terminal-text-secondary)",border:"1px solid",borderColor:!E&&F<0?"#B71C1C":"var(--terminal-border)"},children:"+ New Wave"})}),a.length>0&&l.jsxs("div",{className:"p-3",children:[l.jsx("div",{className:"text-[10px] font-bold text-[var(--terminal-text-muted)] uppercase tracking-wider mb-2",children:"Active"}),l.jsx("div",{className:"flex flex-col gap-1.5",children:a.map((ce,Ue)=>l.jsxs("button",{onClick:()=>{q(Ue),A(null),V(!1),R.reset()},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:F===Ue&&!E?"var(--terminal-bg)":"transparent",border:F===Ue&&!E?"1px solid var(--accent)":"1px solid transparent"},children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 shrink-0 animate-pulse"}),l.jsxs("span",{className:"text-[11px] text-[var(--terminal-text)] truncate font-medium",children:[ce.directive.slice(0,40),ce.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[ce.rootDispatches.length," role",ce.rootDispatches.length!==1?"s":""]})]},ce.id))})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-3",children:[l.jsxs("div",{className:"text-[10px] font-bold text-[var(--terminal-text-muted)] uppercase tracking-wider mb-2",children:["Past Waves (",i.length,")"]}),i.length===0&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] italic",children:"No past waves yet"}),l.jsx("div",{className:"flex flex-col gap-1.5",children:i.map(ce=>l.jsx(BB,{wave:ce,active:(E==null?void 0:E.id)===ce.id,onLoad:()=>Zt(ce.id)},ce.id))})]}),Q&&l.jsxs("button",{onClick:w,disabled:!w,className:"px-3 py-2.5 border-t shrink-0 flex items-center gap-1.5 w-full text-left hover:bg-white/5 transition-colors cursor-pointer disabled:cursor-default",style:{borderColor:"var(--terminal-border)"},children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:Q.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:Q.branch}),Q.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[Q.count," unsaved"]}),!Q.dirty&&l.jsx("span",{className:"text-[9px] text-green-400 ml-auto shrink-0",children:"clean"})]})]})]})]});return g?l.jsx("div",{className:"flex flex-col h-full w-full",style:{background:"var(--terminal-bg)"},children:vn}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dimmer fixed top-0 left-0 bottom-0 bg-black/30 z-40 open",style:{right:ln},onClick:c}),l.jsxs("div",{className:"fixed top-0 bottom-0 z-50 flex flex-col",style:{right:ln,width:nn,background:"var(--terminal-bg)",borderLeft:"1px solid var(--terminal-border)",transition:Kr?"none":"width 0.2s ease"},children:[l.jsx("div",{className:"absolute top-0 bottom-0 w-1 cursor-col-resize hover:bg-[var(--accent)] z-50",style:{left:0},onMouseDown:gr}),vn]})]})}function zB(e,t,n){const i=new Map,a=c=>{const d=e[c];!d||i.has(c)||(i.set(c,{sessionId:"",roleId:c,roleName:d.name,children:d.children,status:"not-dispatched",events:[],streamStatus:"idle"}),d.children.forEach(a))},o=e[t];o&&(i.set(t,{sessionId:"",roleId:t,roleName:"CEO",children:o.children,status:"not-dispatched",events:[],streamStatus:"idle"}),o.children.forEach(a));for(const c of n){const d=i.get(c.roleId);if(d){const f=y2(c.status);i.set(c.roleId,{...d,sessionId:c.sessionId??"",status:c.status||"done",events:c.events,streamStatus:f?"connecting":"done"})}const m=c.childSessions??[];for(const f of m){const x=i.get(f.roleId);x&&i.set(f.roleId,{...x,sessionId:f.sessionId??"",status:f.status||"done",events:f.events,streamStatus:"done"})}}return i}function BB({wave:e,active:t,onLoad:n}){const i=e.id.match(/^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})/),a=i?`${i[1]}-${i[2]}-${i[3]} ${i[4]}:${i[5]}`:e.id;return l.jsx("div",{className:"rounded-lg cursor-pointer transition-colors hover:bg-[var(--terminal-bg)]",style:{border:t?"1px solid var(--accent)":"1px solid var(--terminal-border)",background:t?"var(--terminal-bg)":void 0},onClick:n,children:l.jsxs("div",{className:"p-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[e.hasRunning?l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:"#4CAF50"}}):l.jsx("span",{className:"text-[10px]",children:"▶"}),l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:a}),e.hasRunning?l.jsx("span",{className:"text-[9px] ml-auto animate-pulse",style:{color:"#4CAF50"},children:"running"}):e.commit?l.jsx("span",{className:"text-[9px] text-green-400 ml-auto font-mono",title:`Committed: ${e.commit.sha}`,children:e.commit.sha.slice(0,7)}):e.rolesCount?l.jsx("span",{className:"text-[9px] ml-auto",style:{color:"var(--idle-amber)"},title:"No commit recorded",children:"uncommitted"}):null]}),l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-secondary)] mt-0.5 line-clamp-2 leading-relaxed",children:e.directive.slice(0,80)}),e.rolesCount?l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5",children:[e.rolesCount," role",e.rolesCount!==1?"s":""]}):null]})})}const $B={cto:{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"glasses"},cbo:{skinColor:"#FDEBD0",hairColor:"#1A0A00",shirtColor:"#E65100",pantsColor:"#37474F",shoeColor:"#1A1A1A",hairStyle:"slicked",outfitStyle:"suit",accessory:"lapels"},pm:{skinColor:"#FDEBD0",hairColor:"#6D4C41",shirtColor:"#2E7D32",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bun",outfitStyle:"tshirt",accessory:"blush"},engineer:{skinColor:"#F5CBA7",hairColor:"#1A1A1A",shirtColor:"#4A148C",pantsColor:"#37474F",shoeColor:"#7B1FA2",hairStyle:"messy",outfitStyle:"hoodie",accessory:"headphones"},designer:{skinColor:"#FDEBD0",hairColor:"#AD1457",shirtColor:"#AD1457",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"bob",outfitStyle:"tshirt",accessory:"beret"},qa:{skinColor:"#F5CBA7",hairColor:"#4E342E",shirtColor:"#00695C",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"short",outfitStyle:"tshirt",accessory:"badge"},"data-analyst":{skinColor:"#F5CBA7",hairColor:"#3E2723",shirtColor:"#0277BD",pantsColor:"#37474F",shoeColor:"#212121",hairStyle:"curly",outfitStyle:"vest",accessory:"none"}};function I0(e){return $B[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const F3=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],R3=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],z3=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],B3=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],$3=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],Bs={default:{name:"MIDNIGHT",icon:"🌃",vars:{"--floor-light":"#0d1117","--floor-dark":"#0a0e14","--hud-bg":"#0d1117","--hud-bg-alt":"#161b22","--pixel-border":"#30363d","--terminal-bg":"#0d1117","--terminal-border":"#21262d","--terminal-border-hover":"#388bfd","--terminal-text":"#e6edf3","--terminal-text-secondary":"#8b949e","--terminal-text-muted":"#484f58","--accent":"#388bfd","--active-green":"#3fb950","--idle-amber":"#d29922"}},light:{name:"DAYLIGHT",icon:"☀️",vars:{"--floor-light":"#f6f8fa","--floor-dark":"#eaeef2","--hud-bg":"#f0f3f6","--hud-bg-alt":"#e4e8ec","--pixel-border":"#c0c8d0","--terminal-bg":"#ffffff","--terminal-border":"#d0d7de","--terminal-border-hover":"#0969da","--terminal-text":"#1f2328","--terminal-text-secondary":"#484f58","--terminal-text-muted":"#6e7781","--accent":"#0969da","--active-green":"#1a7f37","--idle-amber":"#9a6700","--bar-bg":"#24292f","--bar-text":"#e6edf3","--bar-border":"#444c56","--terminal-bg-deeper":"#e8ecf0"}},retro:{name:"RETRO",icon:"🎮",vars:{"--floor-light":"#1a1410","--floor-dark":"#140f0a","--hud-bg":"#1a1410","--hud-bg-alt":"#2a2018","--pixel-border":"#5c4a32","--terminal-bg":"#1a1410","--terminal-border":"#3a2e20","--terminal-border-hover":"#d4a44e","--terminal-text":"#e8d5b0","--terminal-text-secondary":"#a08860","--terminal-text-muted":"#6b5840","--accent":"#d4a44e","--active-green":"#8bba4a","--idle-amber":"#e8a030"}},cyberpunk:{name:"NEON",icon:"🌌",vars:{"--floor-light":"#0a0014","--floor-dark":"#06000e","--hud-bg":"#0a0014","--hud-bg-alt":"#14002a","--pixel-border":"#4a1a80","--terminal-bg":"#0a0014","--terminal-border":"#2a0a50","--terminal-border-hover":"#e040fb","--terminal-text":"#e0d0ff","--terminal-text-secondary":"#9070c0","--terminal-text-muted":"#5a3a80","--accent":"#e040fb","--active-green":"#00ff88","--idle-amber":"#ffab00"}},forest:{name:"FOREST",icon:"🌲",vars:{"--floor-light":"#0a1410","--floor-dark":"#060e0a","--hud-bg":"#0a1410","--hud-bg-alt":"#142a1e","--pixel-border":"#2a5a3a","--terminal-bg":"#0a1410","--terminal-border":"#1a3a26","--terminal-border-hover":"#4ade80","--terminal-text":"#d0f0d8","--terminal-text-secondary":"#70a880","--terminal-text-muted":"#3a6848","--accent":"#4ade80","--active-green":"#86efac","--idle-amber":"#fcd34d"}},ocean:{name:"OCEAN",icon:"🌊",vars:{"--floor-light":"#0a1420","--floor-dark":"#060e18","--hud-bg":"#0a1420","--hud-bg-alt":"#142a40","--pixel-border":"#1e4a6a","--terminal-bg":"#0a1420","--terminal-border":"#163050","--terminal-border-hover":"#38bdf8","--terminal-text":"#d0e8f8","--terminal-text-secondary":"#6090b0","--terminal-text-muted":"#305070","--accent":"#38bdf8","--active-green":"#34d399","--idle-amber":"#fbbf24"}}};function OB({color:e,selected:t,onClick:n}){return l.jsx("button",{onClick:n,className:"customize-swatch",style:{background:e,outline:t?"2px solid #fff":"2px solid transparent",boxShadow:t?`0 0 0 1px ${e}, 0 0 6px ${e}88`:"none"}})}function Nc({label:e,presets:t,value:n,onChange:i}){return l.jsxs("div",{className:"customize-row",children:[l.jsxs("div",{className:"customize-row-header",children:[l.jsx("span",{className:"customize-row-label",children:e}),l.jsx("div",{className:"customize-row-current",style:{background:n}})]}),l.jsx("div",{className:"customize-swatches",children:t.map(a=>l.jsx(OB,{color:a,selected:a===n,onClick:()=>i(a)},a))})]})}function $p({label:e,items:t,value:n,onChange:i,lockInfo:a}){return l.jsxs("div",{className:"customize-row",children:[l.jsx("div",{className:"customize-row-header",children:l.jsx("span",{className:"customize-row-label",children:e})}),l.jsx("div",{className:"customize-swatches",style:{gap:4},children:t.map(o=>{const c=a?a.getLockLevel(o.id):1,d=a!=null&&a.getCost?a.getCost(o.id):0,m=o.id===n,f=a?c>a.roleLevel&&!m:!1,x=d>0&&(a==null?void 0:a.purchased)&&!a.purchased.has(o.id)&&!m,p=(a==null?void 0:a.coinBalance)!==void 0?a.coinBalance>=d:!0,y=f||!1,g=a?m&&c>a.roleLevel:!1;return l.jsxs("button",{onClick:()=>{if(!y){if(x&&!f){p&&(a!=null&&a.onPurchase)&&a.onPurchase(o.id,d);return}i(o.id===n?void 0:o.id)}},className:"customize-swatch",style:{width:"auto",height:"auto",padding:y||x?"2px 6px 12px 6px":"2px 6px",fontSize:9,fontFamily:"var(--font-pixel, monospace)",background:m?"rgba(255,255,255,0.15)":y?"rgba(255,255,255,0.02)":x?"rgba(255,200,0,0.04)":"rgba(255,255,255,0.04)",outline:m?g?"2px solid #F59E0B":"2px solid #fff":x&&!y?"2px solid rgba(255,200,0,0.3)":"2px solid transparent",color:y?"rgba(255,255,255,0.25)":x?"rgba(255,255,255,0.45)":m?"#fff":"rgba(255,255,255,0.5)",borderRadius:4,cursor:y?"not-allowed":x?p?"pointer":"not-allowed":"pointer",opacity:y?.35:1,position:"relative"},children:[o.name,y&&l.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:"rgba(255,255,255,0.5)",whiteSpace:"nowrap"},children:["🔒"," Lv.",c]}),!y&&x&&l.jsxs("span",{style:{position:"absolute",bottom:1,left:"50%",transform:"translateX(-50%)",fontSize:8,color:p?"#FFD700":"#F87171",whiteSpace:"nowrap"},children:["🪙"," ",d]}),g&&l.jsxs("span",{style:{position:"absolute",bottom:-8,left:"50%",transform:"translateX(-50%)",fontSize:7,color:"#F59E0B",whiteSpace:"nowrap"},children:["⚠"," Lv.",c]})]},o.id)})})]})}function Op({label:e,active:t,onClick:n}){return l.jsx("button",{onClick:n,style:{flex:1,padding:"6px 0",fontSize:10,fontFamily:"var(--font-pixel, monospace)",fontWeight:"bold",letterSpacing:1,background:t?"rgba(255,255,255,0.08)":"transparent",color:t?"#fff":"rgba(255,255,255,0.35)",border:"none",borderBottom:t?"2px solid #3B82F6":"2px solid transparent",cursor:"pointer",transition:"all 0.15s"},children:e})}function ya(e){return e[Math.floor(Math.random()*e.length)]}function to(e){var a,o,c;const t=h0().filter(d=>!e||E5(d.id,e)),n=m0().filter(d=>!e||D5(d.id,e)),i=p0().filter(d=>!e||M5(d.id,e));return{skinColor:ya(F3),hairColor:ya(R3),shirtColor:ya(z3),pantsColor:ya(B3),shoeColor:ya($3),hairStyle:(a=ya(t))==null?void 0:a.id,outfitStyle:(o=ya(n))==null?void 0:o.id,accessory:(c=ya(i))==null?void 0:c.id}}function O3({roleId:e,appearance:t,onChange:n,onRandomize:i,onReset:a,label:o,roleLevel:c,coinBalance:d,purchased:m,onPurchase:f}){const[x,p]=S.useState("look"),y=S.useCallback((D,F)=>{n({...t,[D]:F})},[t,n]),g=S.useRef(null),w=S.useCallback(D=>{var V;const F=(V=D.target.files)==null?void 0:V[0];if(!F)return;const q=new Image;q.onload=()=>{const L=O8(q);n({...L,hairStyle:t.hairStyle,outfitStyle:t.outfitStyle,accessory:t.accessory}),URL.revokeObjectURL(q.src)},q.src=URL.createObjectURL(F),D.target.value=""},[t.hairStyle,t.outfitStyle,t.accessory,n]),k=h0(),j=m0(),C=p0(),N=c!==void 0?k.filter(D=>E5(D.id,c)).length:k.length,E=c!==void 0?j.filter(D=>D5(D.id,c)).length:j.length,A=c!==void 0?C.filter(D=>M5(D.id,c)).length:C.length,z=(D,F)=>c!==void 0?{roleLevel:c,getLockLevel:D,getCost:F,purchased:m,onPurchase:f,coinBalance:d}:void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"customize-preview",children:[l.jsx("div",{className:"customize-preview-bg",children:l.jsx(Aa,{roleId:e,appearance:t,scale:12})}),o&&l.jsx("div",{className:"customize-preview-name",children:o}),l.jsxs("div",{className:"customize-preview-actions",children:[l.jsx("button",{className:"customize-btn customize-btn--random",onClick:i,children:"RANDOM"}),l.jsx("button",{className:"customize-btn customize-btn--reset",onClick:a,children:"RESET"}),l.jsx("button",{className:"customize-btn",onClick:()=>{var D;return(D=g.current)==null?void 0:D.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:g,type:"file",accept:"image/*",onChange:w,style:{display:"none"}})]})]}),l.jsxs("div",{className:"customize-colors",children:[l.jsxs("div",{style:{display:"flex",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:[l.jsx(Op,{label:"LOOK",active:x==="look",onClick:()=>p("look")}),l.jsx(Op,{label:"OUTFIT",active:x==="outfit",onClick:()=>p("outfit")}),l.jsx(Op,{label:"ACCESSORY",active:x==="accessory",onClick:()=>p("accessory")})]}),x==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(Nc,{label:"SKIN",presets:F3,value:t.skinColor,onChange:D=>y("skinColor",D)}),l.jsx(Nc,{label:"HAIR COLOR",presets:R3,value:t.hairColor,onChange:D=>y("hairColor",D)}),c!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",c]}),l.jsxs("span",{children:[N,"/",k.length," unlocked"]})]}),l.jsx($p,{label:"HAIR STYLE",items:k,value:t.hairStyle,onChange:D=>y("hairStyle",D),lockInfo:z(N5,E8)})]}),x==="outfit"&&l.jsxs(l.Fragment,{children:[c!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",c]}),l.jsxs("span",{children:[E,"/",j.length," unlocked"]})]}),l.jsx($p,{label:"STYLE",items:j,value:t.outfitStyle,onChange:D=>y("outfitStyle",D),lockInfo:z(A5,T8)}),l.jsx(Nc,{label:"TOP",presets:z3,value:t.shirtColor,onChange:D=>y("shirtColor",D)}),l.jsx(Nc,{label:"PANTS",presets:B3,value:t.pantsColor,onChange:D=>y("pantsColor",D)}),l.jsx(Nc,{label:"SHOES",presets:$3,value:t.shoeColor,onChange:D=>y("shoeColor",D)})]}),x==="accessory"&&l.jsxs(l.Fragment,{children:[c!==void 0&&l.jsxs("div",{style:{padding:"4px 8px",marginBottom:4,background:"rgba(255,255,255,0.04)",borderRadius:4,fontSize:9,fontFamily:"var(--font-pixel, monospace)",color:"rgba(255,255,255,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("span",{children:["Lv.",c]}),l.jsxs("span",{children:[A,"/",C.length," unlocked"]})]}),l.jsx($p,{label:"ACCESSORY",items:C,value:t.accessory,onChange:D=>y("accessory",D),lockInfo:z(_5,R8)}),l.jsx("div",{style:{marginTop:12,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,border:"1px dashed rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.25)",fontSize:9,fontFamily:"var(--font-pixel, monospace)",textAlign:"center"},children:c!==void 0&&c<10?"Level up to unlock more accessories":"More accessories coming soon"})]})]})]})}const LB=[{value:"c-level",label:"C-Level"},{value:"member",label:"Member"}];function Ox(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function Lp(e){switch(e){case"c-level":return{authority:{autonomous:["Strategic decisions within domain","Task delegation to reports"],needsApproval:["Budget over $5K","External commitments"]},knowledge:{reads:["company/","operations/","projects/"],writes:["operations/","knowledge/"]},reports:{daily:"standup",weekly:"summary"}};default:return{authority:{autonomous:["Implementation within assigned tasks"],needsApproval:["Design changes","New dependencies"]},knowledge:{reads:["projects/"],writes:[]},reports:{daily:"standup",weekly:""}}}}const IB={cto:{name:"CTO",id:"cto",level:"c-level"},cbo:{name:"CBO",id:"cbo",level:"c-level"},pm:{name:"PM",id:"pm",level:"member"},engineer:{name:"Engineer",id:"engineer",level:"member"},designer:{name:"Designer",id:"designer",level:"member"},qa:{name:"QA Engineer",id:"qa",level:"member"}};let wa=null;async function HB(){if(wa)return wa;try{const n=await ke.getPreferences();if(n.instanceId)return wa=n.instanceId,localStorage.setItem("tycono_instance_id",wa),wa}catch{}const e="tycono_instance_id";let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),wa=t,t}const Ec=4;function UB(e,t,n){const i=e.trim();if(!i||i.startsWith("#"))return null;const a=i.split(",").map(p=>p.trim()),o=a[0];if(!o)return null;const c=Ox(o),m=(a[1]||"member").toLowerCase()==="c-level"?"c-level":"member",f=a[2]||"ceo";let x;return t.has(c)?x="ID already exists":n.has(c)&&(x="Duplicate ID in batch"),n.add(c),{name:o,id:c,level:m,reportsTo:f,error:x}}function qB({existingRoles:e,onClose:t,onHire:n,onStoreVisit:i,questHint:a}){const[o,c]=S.useState("single"),[d,m]=S.useState([]),[f,x]=S.useState(!1),[p,y]=S.useState("popular"),[g,w]=S.useState(""),[k,j]=S.useState(null),[C,N]=S.useState(!1),[E,A]=S.useState(""),[z,D]=S.useState("browse"),[F,q]=S.useState(""),[V,L]=S.useState(""),[_,B]=S.useState("ceo"),[X,R]=S.useState(null),[H,$]=S.useState(1),[G,Q]=S.useState(""),[K,M]=S.useState(""),[U,P]=S.useState(!1),[O,Z]=S.useState("member"),[ee,J]=S.useState(()=>{const ae=e.find(Ve=>Ve.level==="c-level");return(ae==null?void 0:ae.id)??"ceo"}),[se,le]=S.useState(""),[ye,De]=S.useState(to),[Ee,Re]=S.useState(!1),[me,Fe]=S.useState(""),[Je,Pe]=S.useState([]),[it,ht]=S.useState(new Set),[Ye,nt]=S.useState(""),[ut,kt]=S.useState("input"),[mt,ve]=S.useState({done:0,total:0}),be=S.useRef(null),te=S.useRef(null),oe=S.useRef(null);S.useEffect(()=>{ke.getSkills().then(ae=>Pe(ae.filter(Ve=>Ve.installed))).catch(()=>{}),HB().then(ae=>R(ae)).catch(()=>{})},[]),S.useEffect(()=>{var ae,Ve,We;o==="single"?(H===1&&((ae=be.current)==null||ae.focus()),H===2&&((Ve=te.current)==null||Ve.focus())):o==="bulk"&&ut==="input"&&((We=oe.current)==null||We.focus())},[H,o,ut]),S.useEffect(()=>{o==="store"&&z==="browse"&&d.length===0&&Ce()},[o,z]);const Ce=async()=>{x(!0);try{const ae=await ur.getCharacters({sort:p,instanceId:X??void 0});m(ae.characters)}catch{A("Failed to load job board")}x(!1)};S.useEffect(()=>{o==="store"&&z==="browse"&&Ce()},[p,X]);const pe=S.useMemo(()=>{if(!g.trim())return d;const ae=g.toLowerCase();return d.filter(Ve=>Ve.name.toLowerCase().includes(ae)||Ve.id.toLowerCase().includes(ae)||(Ve.tagline??"").toLowerCase().includes(ae))},[d,g]),Se=S.useMemo(()=>new Set(e.map(ae=>ae.id)),[e]),Me=S.useMemo(()=>{const ae=Ye.split(`
113
+ `),Ve=new Set;return ae.map(We=>UB(We,Se,Ve)).filter(We=>We!==null)},[Ye,Se]),Ge=Me.length>0&&Me.every(ae=>!ae.error),Ie=ae=>{Q(ae),U||M(Ox(ae))},qe=G.trim().length>0&&K.trim().length>0&&!e.some(ae=>ae.id===K),Xe=se.trim().length>0,et=async()=>{Re(!0),Fe("");const ae=Lp(O);try{await n({id:K,name:G.trim(),level:O,reportsTo:ee,persona:se.trim(),...ae,skills:it.size>0?[...it]:void 0},ye),t()}catch(Ve){Fe(Ve instanceof Error?Ve.message:"Failed to create role"),Re(!1)}},ze=ae=>ae===1?qe:ae===2?Xe:!0,Be=async()=>{Re(!0),Fe(""),ve({done:0,total:Me.length});try{for(let ae=0;ae<Me.length;ae++){const Ve=Me[ae],We=Lp(Ve.level),tn=to(),Ne=`${Ve.name}. A ${Ve.level} role reporting to ${Ve.reportsTo}.`;await n({id:Ve.id,name:Ve.name,level:Ve.level,reportsTo:Ve.reportsTo,persona:Ne,...We},tn),ve({done:ae+1,total:Me.length})}t()}catch(ae){Fe(ae instanceof Error?ae.message:"Failed to create roles"),Re(!1)}},_t=async ae=>{N(!0),A("");try{const Ve=await ur.getCharacter(ae);j(Ve),q(Ve.name||""),L(Ox(Ve.name||ae)),D("review")}catch{A("Failed to load character details")}finally{N(!1)}},en=async(ae,Ve)=>{if(!X)return;const We=d.find(Ne=>Ne.id===ae);if(!We)return;const tn=We.my_vote===Ve?0:Ve;try{const Ne=await ur.voteCharacter(ae,X,tn);m(Ct=>Ct.map(ln=>ln.id===ae?{...ln,upvotes:Ne.upvotes,downvotes:Ne.downvotes,vote_score:Ne.upvotes-Ne.downvotes,my_vote:tn===0?null:tn}:ln))}catch{}},Tt=async()=>{if(!k)return;Re(!0),Fe("");const ae=k,Ve=ae.level==="c-level"?"c-level":"member",We=Lp(Ve),tn=ae.skills!=null&&typeof ae.skills=="object"&&!Array.isArray(ae.skills)&&"primary"in ae.skills;try{await n({id:V,name:F.trim(),level:Ve,reportsTo:_,persona:ae.persona||`${F}. Imported from Job Board.`,authority:ae.authority||We.authority,knowledge:We.knowledge,reports:We.reports,source:{id:`tycono/${ae.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:tn?ae.skills:void 0},ae.appearance?ae.appearance:to()),ur.trackInstall(ae.id).catch(()=>{}),t()}catch(Ne){Fe(Ne instanceof Error?Ne.message:"Failed to hire"),Re(!1)}},Pt=async ae=>{if(X)try{await ur.deleteCharacter(ae,X),m(Ve=>Ve.filter(We=>We.id!==ae))}catch{}},hn=ae=>{ae.key==="Escape"&&t(),ae.key==="Enter"&&(ae.metaKey||ae.ctrlKey)&&(o==="single"?H<Ec&&ze(H)?$(H+1):H===Ec&&et():o==="bulk"?ut==="input"&&Ge?kt("review"):ut==="review"&&Be():o==="store"&&z==="review"&&Tt())},Zt=e.some(ae=>ae.id===K)&&K.length>0;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:t}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] max-h-[90vh] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",onKeyDown:hn,children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #2E7D32, #43A047)"},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"text-lg font-bold",children:"Hire New Role"}),l.jsxs("div",{className:"flex bg-black/20 rounded-lg p-0.5",children:[l.jsx("button",{onClick:()=>{c("single"),Fe("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${o==="single"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Single"}),l.jsx("button",{onClick:()=>{c("bulk"),Fe("")},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${o==="bulk"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Bulk"}),l.jsx("button",{onClick:()=>{c("store"),Fe(""),i==null||i()},className:`px-3 py-1 text-xs font-semibold rounded-md cursor-pointer transition-colors ${o==="store"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Job Board"})]})]}),a&&l.jsxs("div",{className:"mt-2 px-3 py-1.5 rounded-lg text-xs flex items-center gap-2",style:{background:"rgba(0,0,0,0.2)"},children:[l.jsx("span",{children:"🐾"}),l.jsx("span",{className:"opacity-90",children:a.message}),a.roleId&&o==="single"&&H===1&&!G&&l.jsx("button",{className:"ml-auto px-2 py-0.5 rounded text-[10px] font-semibold cursor-pointer hover:brightness-125",style:{background:"rgba(255,255,255,0.15)",color:"#fff"},onClick:()=>{const ae=IB[a.roleId];ae&&(Q(ae.name),M(ae.id),P(!0),Z(ae.level))},children:"Auto-fill →"})]}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5 flex items-center gap-2",children:[l.jsx("span",{children:o==="single"?`Step ${H} of ${Ec}`:o==="bulk"?ut==="input"?"Enter roles, one per line":`Review ${Me.length} roles`:z==="browse"?`${d.length} roles available`:"Review & customize"}),o==="store"&&z==="browse"&&l.jsx("a",{href:"https://tycono.ai/jobs",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] opacity-60 hover:opacity-100 transition-opacity",onClick:ae=>ae.stopPropagation(),children:"Open in browser ↗"})]})]}),o==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:Ec},(ae,Ve)=>Ve+1).map(ae=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:ae<=H?"#2E7D32":"rgba(255,255,255,0.1)"}},ae))}),l.jsx("div",{className:"p-5 min-h-[240px] overflow-y-auto flex-1",children:o==="store"?l.jsxs(l.Fragment,{children:[z==="browse"&&l.jsxs("div",{className:"space-y-3",children:[X?l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 rounded-lg bg-green-900/10 border border-green-800/20 text-[10px]",children:[l.jsxs("span",{className:"text-green-400/70",children:["Signed in · ",l.jsxs("span",{className:"font-mono text-white/40",children:[X.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{wa=null,localStorage.removeItem("tycono_instance_id"),R(null)},className:"text-white/30 hover:text-white/60 cursor-pointer",children:"Sign out"})]}):l.jsx(YB,{onLogin:ae=>{wa=ae,localStorage.setItem("tycono_instance_id",ae),R(ae)}}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{placeholder:"Paste ID (tycono:engineer)",className:"flex-1 p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-accent/40 transition-colors font-mono",onKeyDown:ae=>{if(ae.key==="Enter"){const We=ae.target.value.trim().replace(/^tycono:/,"");We&&(_t(We),ae.target.value="")}}}),l.jsx("button",{onClick:()=>{const ae=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(ae){const We=ae.value.trim().replace(/^tycono:/,"");We&&(_t(We),ae.value="")}},disabled:C,className:"px-3 py-2 rounded-lg bg-accent/10 border border-accent/25 text-accent text-xs font-medium hover:bg-accent/20 transition-colors shrink-0 cursor-pointer disabled:opacity-50",children:C?"Loading...":"Fetch"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 h-px bg-white/10"}),l.jsx("span",{className:"text-[10px] text-white/30",children:"or browse"}),l.jsx("div",{className:"flex-1 h-px bg-white/10"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:g,onChange:ae=>w(ae.target.value),placeholder:"Search roles...",className:"flex-1 p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors",autoFocus:!0}),l.jsxs("select",{value:p,onChange:ae=>y(ae.target.value),className:"px-2 py-2 rounded-lg border border-white/10 bg-white/5 text-xs text-white/70 focus:outline-none cursor-pointer",children:[l.jsx("option",{value:"popular",className:"bg-[var(--wall)]",children:"Popular"}),l.jsx("option",{value:"installs",className:"bg-[var(--wall)]",children:"Most Hired"}),l.jsx("option",{value:"newest",className:"bg-[var(--wall)]",children:"Newest"}),l.jsx("option",{value:"name",className:"bg-[var(--wall)]",children:"A-Z"})]})]}),f?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:"Loading store..."}):E?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:E}),l.jsx("button",{onClick:Ce,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):pe.length===0?l.jsx("div",{className:"text-center py-8 text-sm text-white/40",children:g?"No matches found":"No characters in store yet"}):l.jsx("div",{className:"space-y-2 max-h-[380px] overflow-y-auto pr-1",children:pe.map(ae=>l.jsx(PB,{char:ae,isHired:Se.has(ae.id),onSelect:()=>_t(ae.id),onVote:Ve=>en(ae.id,Ve),onDelete:()=>Pt(ae.id),fetching:C,token:X},ae.id))})]}),z==="review"&&k&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"bg-white/5 rounded-xl p-4 border border-white/10",children:[l.jsxs("div",{className:"flex gap-4",children:[k.appearance&&l.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:l.jsx(Aa,{roleId:"store-preview",appearance:k.appearance,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Name"}),l.jsx("input",{value:F,onChange:ae=>q(ae.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Role ID"}),l.jsx("input",{value:V,onChange:ae=>L(ae.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 font-mono focus:outline-none focus:border-white/25 transition-colors"}),e.some(ae=>ae.id===V)&&V.length>0&&l.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Level"}),l.jsx("div",{className:"text-sm text-white/70 p-2 rounded-lg bg-white/5 border border-white/10",children:k.level==="c-level"?"C-Level":"Member"})]}),l.jsxs("div",{className:"flex-1",children:[l.jsx("label",{className:"block text-[10px] text-white/30 uppercase tracking-wider mb-0.5",children:"Reports To"}),l.jsxs("select",{value:_,onChange:ae=>B(ae.target.value),className:"w-full p-2 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:[l.jsx("option",{value:"ceo",className:"bg-[var(--wall)] text-white",children:"CEO"}),e.map(ae=>l.jsxs("option",{value:ae.id,className:"bg-[var(--wall)] text-white",children:[ae.name," (",ae.id,")"]},ae.id))]})]})]})]})]}),k.persona&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed line-clamp-3",children:k.persona})]}),k.skills&&l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Skills"}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{var tn,Ne;const ae=k.skills;if(ae&&typeof ae=="object"&&!Array.isArray(ae)&&"primary"in ae){const Ct=[];return(Ne=(tn=ae.primary)==null?void 0:tn.frontmatter)!=null&&Ne.name&&Ct.push(ae.primary.frontmatter.name),ae.shared&&ae.shared.forEach(ln=>{var nn;return Ct.push(((nn=ln.frontmatter)==null?void 0:nn.name)||ln.id)}),Ct.map(ln=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:ln},ln))}return(Array.isArray(ae)?ae:[]).map((Ct,ln)=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-green-900/20 border border-green-800/30 text-green-400",children:typeof Ct=="string"?Ct:Ct.name},ln))})()})]})]}),me&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:me})]})]}):o==="single"?l.jsxs(l.Fragment,{children:[H===1&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role Name"}),l.jsx("input",{ref:be,value:G,onChange:ae=>Ie(ae.target.value),placeholder:"e.g. Data Analyst",className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 focus:outline-none focus:border-white/25 transition-colors"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Role ID (slug)"}),l.jsx("input",{value:K,onChange:ae=>{M(ae.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),P(!0)},className:`w-full p-2.5 rounded-lg border bg-white/5 text-sm text-white/90 font-mono focus:outline-none transition-colors ${Zt?"border-red-400":"border-white/10 focus:border-white/25"}`}),Zt&&l.jsx("div",{className:"text-xs text-red-500 mt-1",children:"ID already exists"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Level"}),l.jsx("div",{className:"flex gap-2",children:LB.map(ae=>l.jsx("button",{onClick:()=>{if(Z(ae.value),ae.value==="c-level")J("ceo");else{const Ve=e.find(We=>We.level==="c-level");J((Ve==null?void 0:Ve.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${O===ae.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:ae.label},ae.value))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-1",children:"Reports To"}),O==="c-level"?l.jsx("div",{className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/40",children:"CEO (automatic)"}):l.jsx("select",{value:ee,onChange:ae=>J(ae.target.value),className:"w-full p-2.5 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 focus:outline-none focus:border-white/25 transition-colors",children:e.filter(ae=>ae.level==="c-level").map(ae=>l.jsxs("option",{value:ae.id,className:"bg-[var(--wall)] text-white",children:[ae.name," (",ae.id,")"]},ae.id))})]})]}),H===2&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Persona"}),l.jsx("textarea",{ref:te,value:se,onChange:ae=>le(ae.target.value),placeholder:"Describe this role's personality, expertise, and working style...",className:"w-full h-32 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"This defines how the AI agent will behave in this role"})]}),Je.length>0&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Skills"}),l.jsx("div",{className:"space-y-1.5 max-h-[120px] overflow-y-auto",children:Je.map(ae=>l.jsxs("label",{className:"flex items-center gap-2 p-2 rounded-lg border border-white/10 bg-white/5 cursor-pointer hover:border-white/20 transition-colors",children:[l.jsx("input",{type:"checkbox",checked:it.has(ae.id),onChange:()=>ht(Ve=>{const We=new Set(Ve);return We.has(ae.id)?We.delete(ae.id):We.add(ae.id),We}),className:"accent-green-600"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-xs font-semibold text-white/80",children:ae.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:ae.description})]})]},ae.id))})]})]}),H===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx(O3,{roleId:"default",appearance:ye,onChange:De,onRandomize:()=>De(to()),onReset:()=>De(to()),label:l.jsxs("span",{children:[K||"new-role"," — ",G||"New Role"]})})}),H===4&&l.jsxs("div",{className:"space-y-3",children:[l.jsx("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Review"}),l.jsxs("div",{className:"bg-white/5 rounded-xl p-4 border border-white/10",children:[l.jsxs("div",{className:"flex gap-4",children:[l.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:l.jsx(Aa,{roleId:"default",appearance:ye,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(Ac,{label:"Name",value:G}),l.jsx(Ac,{label:"ID",value:K,mono:!0}),l.jsx(Ac,{label:"Level",value:O}),l.jsx(Ac,{label:"Reports To",value:ee}),it.size>0&&l.jsx(Ac,{label:"Skills",value:[...it].join(", ")})]})]}),l.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10",children:[l.jsx("div",{className:"text-[10px] text-white/30 uppercase tracking-wider mb-1",children:"Persona"}),l.jsx("div",{className:"text-xs text-white/60 leading-relaxed",children:se})]})]}),me&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:me})]})]}):l.jsxs(l.Fragment,{children:[ut==="input"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:"Roles (one per line)"}),l.jsx("textarea",{ref:oe,value:Ye,onChange:ae=>nt(ae.target.value),placeholder:`Name, Level, ReportsTo
114
+ e.g.
115
+ Data Analyst
116
+ DevOps Engineer, member, cto
117
+ VP Marketing, c-level, ceo`,className:"w-full h-40 p-3 rounded-lg border border-white/10 bg-white/5 text-sm text-white/90 placeholder-white/25 resize-none focus:outline-none focus:border-white/25 transition-colors font-mono"}),l.jsx("div",{className:"text-[10px] text-gray-400 mt-1",children:"Format: Name, Level (member/c-level), ReportsTo. Level and ReportsTo are optional."})]}),Me.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:["Preview (",Me.length," role",Me.length!==1?"s":"",")"]}),l.jsx("div",{className:"bg-white/5 rounded-lg border border-white/10 overflow-hidden",children:l.jsxs("table",{className:"w-full text-xs",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-white/10",children:[l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Name"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"ID"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Level"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Reports To"})]})}),l.jsx("tbody",{children:Me.map((ae,Ve)=>l.jsxs("tr",{className:`border-b border-white/5 ${ae.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:ae.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:ae.id}),l.jsx("td",{className:"p-2 text-white/60",children:ae.level}),l.jsx("td",{className:"p-2 text-white/60",children:ae.reportsTo}),ae.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:ae.error})]},Ve))})]})})]})]}),ut==="review"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"text-[11px] font-bold text-[var(--desk-dark)] uppercase tracking-wider mb-2",children:["Confirm Bulk Hire — ",Me.length," roles"]}),l.jsx("div",{className:"bg-white/5 rounded-lg border border-white/10 overflow-hidden max-h-[300px] overflow-y-auto",children:l.jsxs("table",{className:"w-full text-xs",children:[l.jsx("thead",{className:"sticky top-0 bg-[var(--wall)]",children:l.jsxs("tr",{className:"border-b border-white/10",children:[l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"#"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Name"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"ID"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Level"}),l.jsx("th",{className:"text-left p-2 text-white/40 font-semibold",children:"Reports To"})]})}),l.jsx("tbody",{children:Me.map((ae,Ve)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:Ve+1}),l.jsx("td",{className:"p-2 text-white/80",children:ae.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:ae.id}),l.jsx("td",{className:"p-2 text-white/60",children:ae.level}),l.jsx("td",{className:"p-2 text-white/60",children:ae.reportsTo})]},Ve))})]})}),Ee&&mt.total>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-[10px] text-white/40 mb-1",children:[l.jsx("span",{children:"Hiring..."}),l.jsxs("span",{children:[mt.done,"/",mt.total]})]}),l.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${mt.done/mt.total*100}%`,background:"#2E7D32"}})})]}),l.jsx("div",{className:"text-[10px] text-white/30",children:"Each role will get a random appearance and auto-generated persona. You can customize them later."}),me&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:me})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[o==="single"&&H>1&&l.jsx("button",{onClick:()=>$(H-1),className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Back"}),o==="bulk"&&ut==="review"&&l.jsx("button",{onClick:()=>kt("input"),disabled:Ee,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer disabled:opacity-40",children:"Back"}),o==="store"&&z==="review"&&l.jsx("button",{onClick:()=>{D("browse"),j(null),Fe("")},disabled:Ee,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer disabled:opacity-40",children:"Back"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded-lg border border-white/15 text-white/60 hover:bg-white/5 cursor-pointer",children:"Cancel"}),o==="single"?H<Ec?l.jsx("button",{onClick:()=>$(H+1),disabled:!ze(H),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:"Next"}):l.jsx("button",{onClick:et,disabled:Ee,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Ee?"Hiring...":"HIRE"}):o==="bulk"?ut==="input"?l.jsxs("button",{onClick:()=>kt("review"),disabled:!Ge,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:["Review (",Me.length,")"]}):l.jsx("button",{onClick:Be,disabled:Ee,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Ee?`Hiring ${mt.done}/${mt.total}...`:`HIRE ALL (${Me.length})`}):z==="review"?l.jsx("button",{onClick:Tt,disabled:Ee||!F.trim()||!V.trim()||e.some(ae=>ae.id===V),className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#2E7D32"},children:Ee?"Hiring...":"HIRE"}):null]})]})]})]})}function YB({onLogin:e}){const[t,n]=S.useState(""),[i,a]=S.useState(!1),[o,c]=S.useState(""),d=()=>{const m=t.trim();if(m){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(m)){c("Invalid token format");return}e(m)}};return l.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] p-3 space-y-2",children:[l.jsx("div",{className:"text-[11px] text-white/50",children:"Sign in to vote, publish, and manage your characters."}),i?l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:t,onChange:m=>{n(m.target.value),c("")},onKeyDown:m=>{m.key==="Enter"&&d()},placeholder:"Paste your token here...",className:"flex-1 px-2 py-1.5 rounded-lg border border-white/10 bg-white/5 text-xs text-white/90 font-mono placeholder-white/20 focus:outline-none focus:border-amber-800/40",autoFocus:!0}),l.jsx("button",{onClick:d,disabled:!t.trim(),className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer text-green-400 bg-green-900/20 border border-green-800/30 hover:bg-green-900/40 disabled:opacity-30 transition-colors",children:"Sign in"})]}),o&&l.jsx("div",{className:"text-[10px] text-red-400",children:o}),l.jsx("button",{onClick:a.bind(null,!1),className:"text-[10px] text-white/30 hover:text-white/50 cursor-pointer",children:"Cancel"})]}):l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:a.bind(null,!0),className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer text-amber-400 bg-amber-900/20 border border-amber-800/30 hover:bg-amber-900/40 transition-colors",children:"Paste Token"}),l.jsx("span",{className:"text-[10px] text-white/20 self-center",children:"from Settings → Token"})]})]})}function PB({char:e,isHired:t,onSelect:n,onVote:i,onDelete:a,fetching:o,token:c}){const[d,m]=S.useState(!1),f=c&&e.publisher_id===c,x=!!c;return l.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border border-white/10 bg-white/[0.03] hover:bg-white/[0.06] transition-colors group",children:[l.jsxs("div",{className:"flex flex-col items-center gap-0.5 shrink-0 w-8",children:[l.jsx("button",{onClick:p=>{p.stopPropagation(),i(1)},disabled:!x,className:`text-[14px] leading-none transition-colors ${x?"cursor-pointer":"cursor-not-allowed opacity-30"} ${e.my_vote===1?"text-green-400":"text-white/20 hover:text-green-400/60"}`,title:x?"Upvote":"Sign in to vote",children:"▲"}),l.jsx("span",{className:`text-[11px] font-bold tabular-nums ${(e.vote_score??0)>0?"text-green-400/80":(e.vote_score??0)<0?"text-red-400/80":"text-white/30"}`,children:e.vote_score??0}),l.jsx("button",{onClick:p=>{p.stopPropagation(),i(-1)},disabled:!x,className:`text-[14px] leading-none transition-colors ${x?"cursor-pointer":"cursor-not-allowed opacity-30"} ${e.my_vote===-1?"text-red-400":"text-white/20 hover:text-red-400/60"}`,title:x?"Downvote":"Sign in to vote",children:"▼"})]}),l.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:n,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-white/90 truncate",children:e.name}),l.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded font-semibold uppercase ${e.level==="c-level"?"bg-amber-900/30 text-amber-400 border border-amber-800/30":"bg-white/5 text-white/40 border border-white/10"}`,children:e.level}),t&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-green-900/20 text-green-400/60 border border-green-800/20",children:"Hired"})]}),e.tagline&&l.jsx("div",{className:"text-[11px] text-white/40 truncate mt-0.5",children:e.tagline}),l.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[l.jsxs("span",{className:"text-[10px] text-white/25",children:[e.installs??0," installs"]}),l.jsxs("span",{className:"text-[10px] text-white/25",children:["v",e.version]}),l.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:e.id})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[l.jsx("button",{onClick:n,disabled:o,className:"px-3 py-1.5 text-[11px] font-semibold rounded-lg cursor-pointer transition-colors disabled:opacity-40 text-green-400 bg-green-900/20 border border-green-800/30 hover:bg-green-900/40",children:"Hire"}),f&&(d?l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:p=>{p.stopPropagation(),a(),m(!1)},className:"px-2 py-1.5 text-[10px] font-semibold rounded cursor-pointer text-red-400 bg-red-900/30 border border-red-800/40 hover:bg-red-900/50",children:"Confirm"}),l.jsx("button",{onClick:p=>{p.stopPropagation(),m(!1)},className:"px-2 py-1.5 text-[10px] rounded cursor-pointer text-white/40 hover:text-white/60",children:"No"})]}):l.jsx("button",{onClick:p=>{p.stopPropagation(),m(!0)},className:"w-7 h-7 rounded-lg flex items-center justify-center cursor-pointer text-white/15 hover:text-red-400/60 hover:bg-red-900/10 transition-colors opacity-0 group-hover:opacity-100",title:"Delete from store",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2"})})}))]})]})}function Ac({label:e,value:t,mono:n}){return l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-white/40",children:e}),l.jsx("span",{className:`font-semibold text-white/80 ${n?"font-mono":""}`,children:t})]})}function XB({onClose:e}){const[t,n]=S.useState("installed"),[i,a]=S.useState([]),[o,c]=S.useState([]),[d,m]=S.useState(!0),[f,x]=S.useState(""),[p,y]=S.useState("list"),[g,w]=S.useState(null),[k,j]=S.useState(null),[C,N]=S.useState(null),[E,A]=S.useState(!1),z=S.useCallback(async()=>{try{m(!0);const B=await ke.getPresets();a(B),x("")}catch{x("Failed to load presets")}finally{m(!1)}},[]),D=S.useCallback(async()=>{try{m(!0);const{presets:B}=await ur.getCloudPresets({sort:"popular"});c(B),A(!0),x("")}catch{x("Marketplace unavailable — check your connection"),c([])}finally{m(!1)}},[]);S.useEffect(()=>{z()},[z]),S.useEffect(()=>{t==="browse"&&!E&&D()},[t,E,D]);const F=async(B,X)=>{try{if(X==="local"){const R=await ke.getPreset(B);w(R)}else{const R=await ur.getCloudPreset(B);w(R)}y("detail")}catch{x(`Failed to load preset: ${B}`)}},q=async B=>{if(confirm(`Remove preset "${B}"?`))try{j(B),await ke.removePreset(B),await z(),p==="detail"&&(g==null?void 0:g.id)===B&&(y("list"),w(null))}catch(X){x(`Failed to remove: ${X instanceof Error?X.message:"unknown"}`)}finally{j(null)}},V=async B=>{try{N(B.id),await ke.installPreset(B.id,{spec:"preset/v1",id:B.id,name:B.name,version:B.version,description:B.description,tagline:B.tagline,author:B.author,category:B.category,roles:B.roles,tags:B.tags,pricing:B.pricing,wave_scoped:B.wave_scoped});try{await ur.trackPresetInstall(B.id)}catch{}await z(),x(""),n("installed")}catch(X){x(`Install failed: ${X instanceof Error?X.message:"unknown"}`)}finally{N(null)}},L=new Set(i.map(B=>B.id)),_=B=>{B.key==="Escape"&&(p==="detail"?(y("list"),w(null)):e())};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:e}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[560px] max-h-[85vh] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden flex flex-col",onKeyDown:_,tabIndex:-1,children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #1565C0, #1E88E5)"},children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-lg font-bold",children:p==="detail"?(g==null?void 0:g.name)??"Preset":"Team Presets"}),l.jsx("div",{className:"text-xs text-white/60",children:p==="detail"?(g==null?void 0:g.tagline)??"":"Manage team packages for your waves"})]}),l.jsxs("div",{className:"flex gap-2",children:[p==="detail"&&l.jsx("button",{onClick:()=>{y("list"),w(null)},className:"w-8 h-8 rounded-lg bg-white/20 text-white hover:bg-white/30 cursor-pointer flex items-center justify-center",children:"←"}),l.jsx("button",{onClick:e,className:"w-8 h-8 rounded-lg bg-white/20 text-white hover:bg-white/30 cursor-pointer flex items-center justify-center",children:"✕"})]})]}),p==="list"&&l.jsxs("div",{className:"flex mt-3 bg-black/20 rounded-lg p-0.5",children:[l.jsxs("button",{onClick:()=>n("installed"),className:`flex-1 px-3 py-1.5 text-xs font-semibold rounded-md cursor-pointer transition-colors ${t==="installed"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:["Installed (",i.length,")"]}),l.jsx("button",{onClick:()=>n("browse"),className:`flex-1 px-3 py-1.5 text-xs font-semibold rounded-md cursor-pointer transition-colors ${t==="browse"?"bg-white/20 text-white":"text-white/50 hover:text-white/70"}`,children:"Browse Marketplace"})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:[f&&l.jsx("div",{className:"text-red-400 text-sm mb-3 p-2 bg-red-500/10 rounded-lg",children:f}),d?l.jsx("div",{className:"text-center text-[var(--text-secondary)] py-8",children:"Loading..."}):p==="detail"&&g?l.jsx(GB,{preset:g,isInstalled:L.has(g.id),onRemove:q,removing:k}):t==="installed"?l.jsx(VB,{presets:i,removing:k,onView:B=>F(B,"local"),onRemove:q}):l.jsx(WB,{presets:o,installedIds:L,installing:C,onView:B=>F(B,"cloud"),onInstall:V})]})]})]})}function VB({presets:e,removing:t,onView:n,onRemove:i}){return e.length===0?l.jsxs("div",{className:"text-center text-[var(--text-secondary)] py-8",children:[l.jsx("div",{className:"text-2xl mb-2",children:"📦"}),l.jsx("div",{children:"No presets installed yet."}),l.jsx("div",{className:"text-xs mt-1",children:"Browse the marketplace to find team packages."})]}):l.jsx("div",{className:"space-y-2",children:e.map(a=>l.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-black/10 hover:bg-black/20 cursor-pointer transition-colors",onClick:()=>n(a.id),children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center text-lg shrink-0",children:a.isDefault?"🏠":"📦"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-semibold text-[var(--text-primary)] text-sm",children:a.name}),a.isDefault&&l.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded-full",children:"default"})]}),l.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:a.description||`${a.rolesCount} roles: ${a.roles.join(", ")}`})]}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[l.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:[a.rolesCount," roles"]}),!a.isDefault&&l.jsx("button",{onClick:o=>{o.stopPropagation(),i(a.id)},disabled:t===a.id,className:"w-7 h-7 rounded-lg text-red-400 hover:bg-red-500/20 cursor-pointer flex items-center justify-center text-xs disabled:opacity-50",children:t===a.id?"...":"🗑"})]})]},a.id))})}function WB({presets:e,installedIds:t,installing:n,onView:i,onInstall:a}){return e.length===0?l.jsxs("div",{className:"text-center text-[var(--text-secondary)] py-8",children:[l.jsx("div",{className:"text-2xl mb-2",children:"🌐"}),l.jsx("div",{children:"No presets available yet."}),l.jsx("div",{className:"text-xs mt-1",children:"Check back later or publish your own!"})]}):l.jsx("div",{className:"space-y-2",children:e.map(o=>{var d,m;const c=t.has(o.id);return l.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-black/10 hover:bg-black/20 cursor-pointer transition-colors",onClick:()=>i(o.id),children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/20 flex items-center justify-center text-lg shrink-0",children:"🌐"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-semibold text-[var(--text-primary)] text-sm",children:o.name}),((d=o.author)==null?void 0:d.verified)&&l.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded-full",children:"official"}),c&&l.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded-full",children:"installed"})]}),l.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:o.description||o.tagline||`${((m=o.roles)==null?void 0:m.length)??0} roles`}),l.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-[var(--text-secondary)]",children:[l.jsxs("span",{children:["▲ ",o.vote_score]}),l.jsxs("span",{children:[o.installs??0," installs"]}),o.roles&&l.jsxs("span",{children:[o.roles.length," roles"]})]})]}),l.jsx("div",{className:"shrink-0",children:c?l.jsx("span",{className:"text-xs text-green-400",children:"✓"}):l.jsx("button",{onClick:f=>{f.stopPropagation(),a(o)},disabled:n===o.id,className:"px-3 py-1.5 text-xs rounded-lg bg-blue-500/20 text-blue-300 hover:bg-blue-500/30 cursor-pointer disabled:opacity-50",children:n===o.id?"...":"Install"})})]},o.id)})})}function GB({preset:e,isInstalled:t,onRemove:n,removing:i}){var o;const a=e.id==="default";return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"p-4 rounded-xl bg-black/10",children:[e.description&&l.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3 whitespace-pre-line",children:e.description}),l.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--text-secondary)]",children:"Version: "}),l.jsx("span",{className:"text-[var(--text-primary)]",children:e.version})]}),e.category&&l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--text-secondary)]",children:"Category: "}),l.jsx("span",{className:"text-[var(--text-primary)]",children:e.category})]}),e.author&&l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--text-secondary)]",children:"Author: "}),l.jsxs("span",{className:"text-[var(--text-primary)]",children:[e.author.name,e.author.verified&&" ✓"]})]}),e.pricing&&l.jsxs("div",{children:[l.jsx("span",{className:"text-[var(--text-secondary)]",children:"Price: "}),l.jsx("span",{className:"text-[var(--text-primary)]",children:e.pricing.price===0?"Free":`$${e.pricing.price}`})]})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider mb-2",children:["Roles (",e.roles.length,")"]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.roles.map(c=>l.jsx("span",{className:"px-2.5 py-1 text-xs rounded-lg bg-blue-500/15 text-blue-300",children:c},c))})]}),((o=e.wave_scoped)==null?void 0:o.recommended_tasks)&&e.wave_scoped.recommended_tasks.length>0&&l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-semibold text-[var(--text-secondary)] uppercase tracking-wider mb-2",children:"Recommended Tasks"}),l.jsx("div",{className:"space-y-1",children:e.wave_scoped.recommended_tasks.map((c,d)=>l.jsxs("div",{className:"text-xs text-[var(--text-primary)] flex gap-2",children:[l.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),c]},d))})]}),e.tags&&e.tags.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(c=>l.jsxs("span",{className:"px-2 py-0.5 text-[10px] rounded-full bg-white/5 text-[var(--text-secondary)]",children:["#",c]},c))}),!a&&t&&l.jsx("div",{className:"pt-2 border-t border-white/5",children:l.jsx("button",{onClick:()=>n(e.id),disabled:i===e.id,className:"px-4 py-2 text-sm rounded-lg bg-red-500/20 text-red-400 hover:bg-red-500/30 cursor-pointer disabled:opacity-50",children:i===e.id?"Removing...":"Remove Preset"})})]})}function KB({roleId:e,roleName:t,onClose:n,onConfirm:i}){const[a,o]=S.useState(!1),c=async()=>{o(!0);try{await i(e)}finally{o(!1)}};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:n}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] z-[61] bg-[var(--wall)] rounded-2xl shadow-2xl overflow-hidden",children:[l.jsxs("div",{className:"p-5 text-white",style:{background:"linear-gradient(135deg, #B71C1C, #D32F2F)"},children:[l.jsx("div",{className:"text-lg font-bold",children:"Fire Role"}),l.jsxs("div",{className:"text-sm opacity-80 mt-0.5",children:["Remove ",t," (",e,")"]})]}),l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"p-4 rounded-lg border-2 border-red-300 bg-red-50 mb-4",children:[l.jsx("div",{className:"text-sm font-bold text-red-800 mb-1",children:"Warning"}),l.jsxs("div",{className:"text-xs text-red-700 leading-relaxed",children:["This will permanently delete the role directory including",l.jsx("strong",{children:" role.yaml"}),", ",l.jsx("strong",{children:"profile.md"}),", ",l.jsx("strong",{children:"SKILL.md"}),", and all journal entries. This action cannot be undone."]})]}),l.jsxs("div",{className:"text-sm text-gray-600",children:["Are you sure you want to fire ",l.jsx("strong",{children:t}),"?"]})]}),l.jsxs("div",{className:"flex justify-end gap-3 px-5 pb-5",children:[l.jsx("button",{onClick:n,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:c,disabled:a,className:"px-5 py-2 text-sm text-white rounded-lg font-semibold cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#B71C1C"},children:a?"Removing...":"Confirm Fire"})]})]})]})}const QB={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function ZB({roleId:e,title:t,roleColor:n,active:i,isWave:a,isWaveStreaming:o,onClick:c,onClose:d,"data-session-id":m}){const f=a?"#F59E0B":n;return l.jsxs("button",{onClick:c,"data-session-id":m,className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors max-w-[180px] group ${i?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] hover:bg-[var(--terminal-surface)]"}`,style:i?{borderTop:`2px solid ${f}`}:void 0,children:[a&&o&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse shrink-0"}),l.jsx("span",{className:"text-xs",children:QB[e]??"👤"}),l.jsx("span",{className:`truncate ${a?"text-amber-400/90":""}`,children:t}),l.jsx("span",{onClick:d,className:"ml-auto text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none",children:"×"})]})}function JB({content:e,streaming:t}){let n=e;return t&&(e.match(/```/g)??[]).length%2!==0&&(n+="\n```"),l.jsx("div",{className:"terminal-markdown",children:l.jsx(l0,{remarkPlugins:[d0],components:{code:e$,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:n})})}function e$({className:e,children:t,...n}){const i=/language-(\w+)/.exec(e??"");return i||typeof t=="string"&&t.includes(`
118
+ `)?l.jsx(t$,{language:i==null?void 0:i[1],children:t}):l.jsx("code",{className:"terminal-inline-code",...n,children:t})}function t$({children:e,language:t}){const[n,i]=S.useState(!1),a=String(e).replace(/\n$/,""),o=()=>{navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),1500)};return l.jsxs("div",{className:"terminal-code-block group relative my-2",children:[t&&l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] px-3 pt-1.5",children:t}),l.jsx("button",{onClick:o,className:"absolute top-1.5 right-2 text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:n?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:a})})]})}const n$={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function r$({attachments:e}){const[t,n]=S.useState(null);return e.length===0?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:e.map((i,a)=>l.jsxs("button",{onClick:()=>n(a),className:"relative w-20 h-20 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)] cursor-pointer hover:border-[var(--terminal-border-hover)] transition-colors",children:[l.jsx("img",{src:`data:${i.mediaType};base64,${i.data}`,alt:i.name,className:"w-full h-full object-cover"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[8px] text-white truncate px-1 py-0.5",children:i.name})]},a))}),t!==null&&l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/80 flex items-center justify-center",onClick:()=>n(null),children:l.jsxs("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[l.jsx("img",{src:`data:${e[t].mediaType};base64,${e[t].data}`,alt:e[t].name,className:"max-w-full max-h-[90vh] object-contain rounded-lg"}),l.jsx("button",{onClick:()=>n(null),className:"absolute top-2 right-2 w-8 h-8 rounded-full bg-black/70 text-white flex items-center justify-center cursor-pointer hover:bg-black/90",children:"x"}),l.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 bg-black/70 text-white text-sm px-3 py-1 rounded",children:e[t].name})]})})]})}function Ip(e,t){return t?t.file_path?String(t.file_path).replace(/^.*\/(?=[^/]+\/)/,""):t.path?String(t.path).replace(/^.*\/(?=[^/]+\/)/,""):t.pattern?String(t.pattern):t.command?String(t.command).slice(0,60):t.query?String(t.query).slice(0,60):t.url?String(t.url).slice(0,60):"":""}function i$(e){const t=[];let n="";for(const i of e)if(i.type==="thinking")i.text&&(n=i.text),t.length===0||t[t.length-1].type!=="thinking"?t.push({type:"thinking",text:i.text}):t[t.length-1].text=i.text;else if(i.type==="tool")t.push({type:"tool",toolName:i.toolName,toolSummary:Ip(i.toolName??"",i.toolInput),toolInput:i.toolInput});else if(i.type==="dispatch")t.push({type:"dispatch",roleId:i.roleId,task:i.task});else if(i.type==="dispatch:progress"){const a=t.length>0?t[t.length-1]:null;(a==null?void 0:a.type)==="dispatch:progress"&&a.roleId===i.roleId?i.progressType==="tool"?(a.toolName=i.toolName,a.toolSummary=Ip(i.toolName??"",i.toolInput),a.progressType="tool"):i.progressType==="thinking"?(a.text=i.text,a.progressType="thinking"):i.progressType==="text"?(a.text=i.text,a.progressType="text"):(i.progressType==="done"||i.progressType==="error")&&(a.progressType=i.progressType):t.push({type:"dispatch:progress",roleId:i.roleId,progressType:i.progressType,text:i.text,toolName:i.toolName,toolSummary:i.toolName?Ip(i.toolName,i.toolInput):void 0})}if(n){const i=t.filter(a=>a.type==="thinking");i.length>0&&(i[i.length-1].text=n)}return t}function s$({event:e,isStreaming:t}){var a,o,c;const[n,i]=S.useState(!1);switch(e.type){case"thinking":return l.jsxs("div",{className:"stream-event-thinking",children:[l.jsxs("div",{className:"stream-event-thinking-header",onClick:()=>i(!n),children:[l.jsx("span",{className:"stream-event-thinking-icon"}),l.jsxs("span",{className:"stream-event-thinking-label",children:["thinking",t?"...":""]}),e.text&&!t&&l.jsx("span",{className:"stream-event-thinking-toggle",children:n?"▾":"▸"})]}),(t||n)&&e.text&&l.jsx("div",{className:"stream-event-thinking-content",children:e.text.slice(-500)})]});case"tool":return l.jsxs("div",{className:"stream-event-tool",children:[l.jsx("span",{className:"stream-event-tool-badge",children:e.toolName}),e.toolSummary&&l.jsx("span",{className:"stream-event-tool-path",children:e.toolSummary}),e.toolInput&&l.jsx("span",{className:"stream-event-tool-toggle",onClick:()=>i(!n),children:n?"▾":"▸"}),n&&e.toolInput&&l.jsx("div",{className:"stream-event-tool-detail",children:JSON.stringify(e.toolInput,null,1).slice(0,300)})]});case"dispatch":return l.jsxs("div",{className:"stream-event-dispatch",children:[l.jsxs("span",{className:"stream-event-dispatch-badge",children:["→"," ",(a=e.roleId)==null?void 0:a.toUpperCase()]}),l.jsx("span",{className:"stream-event-dispatch-task",children:(o=e.task)==null?void 0:o.slice(0,80)})]});case"dispatch:progress":return l.jsxs("div",{className:"stream-event-dispatch-progress",children:[l.jsx("span",{className:"stream-event-dispatch-progress-role",children:(c=e.roleId)==null?void 0:c.toUpperCase()}),e.progressType==="thinking"&&l.jsxs("span",{className:"stream-event-dispatch-progress-status",children:["thinking",t?"...":""]}),e.progressType==="tool"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"stream-event-tool-badge",children:e.toolName}),e.toolSummary&&l.jsx("span",{className:"stream-event-tool-path",children:e.toolSummary})]}),e.progressType==="text"&&e.text&&l.jsx("span",{className:"stream-event-dispatch-progress-status",children:"responding..."}),e.progressType==="done"&&l.jsx("span",{className:"stream-event-dispatch-progress-done",children:"done"}),e.progressType==="error"&&l.jsx("span",{className:"stream-event-dispatch-progress-error",children:"error"})]});default:return null}}function a$({events:e,isStreaming:t}){const[n,i]=S.useState(!1);if(e.length===0)return null;const a=i$(e);if(a.length===0)return null;const o=e.filter(y=>y.type==="thinking").length,c=e.filter(y=>y.type==="tool"),d=e.filter(y=>y.type==="dispatch"||y.type==="dispatch:progress"),m=e.filter(y=>y.type==="turn").reduce((y,g)=>Math.max(y,g.turn??0),0),f=[];if(o>0&&f.push("thinking"),c.length>0){const y=[...new Set(c.map(g=>g.toolName))];y.length<=3?f.push(y.join(", ")):f.push(`${c.length} tool calls`)}d.length>0&&f.push(`${d.length} dispatch`),m>1&&f.push(`${m} turns`);const x=f.join(" · "),p=!n;return l.jsxs("div",{className:"stream-activity-log",children:[l.jsxs("div",{className:"stream-activity-header",onClick:()=>i(!n),children:[t&&l.jsx("span",{className:"stream-activity-pulse"}),l.jsxs("span",{className:"stream-activity-summary",children:[n?"▸":"▾"," ",x,t?"...":""]})]}),p&&l.jsx("div",{className:"stream-activity-events",children:a.map((y,g)=>l.jsx(s$,{event:y,isStreaming:t&&g===a.length-1},g))})]})}function l$(e){return e.map(t=>({type:t.type==="tool:start"?"tool":t.type==="dispatch:start"?"dispatch":t.type,timestamp:new Date(t.ts).getTime(),text:t.data.text,toolName:t.data.name,toolInput:t.data.input,roleId:t.data.roleId,task:t.data.task}))}function o$({message:e,roleId:t,roleColor:n}){const i=e.from==="ceo",a=e.type==="system",o=e.status==="streaming";if(a)return l.jsx("div",{className:"flex justify-center my-2",children:l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] bg-[var(--terminal-inline-bg)] px-3 py-1 rounded-full",children:e.content})});if(i)return l.jsx("div",{className:"flex justify-end mb-3",children:l.jsxs("div",{className:"max-w-[85%]",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] text-right mb-1",children:"CEO"}),e.attachments&&e.attachments.length>0&&l.jsx("div",{className:"flex justify-end mb-1",children:l.jsx(r$,{attachments:e.attachments})}),l.jsxs("div",{className:"bg-[var(--terminal-surface-light)] rounded-xl rounded-tr-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",children:[e.type==="directive"&&l.jsx("span",{className:"text-amber-400 text-[10px] font-bold mr-1.5",children:"DO"}),e.content]})]})});const c=e.streamEvents??(e.events?l$(e.events):void 0),d=((c==null?void 0:c.length)??0)>0,m=!!e.thinking,f=m&&!e.content&&o&&!d;return l.jsxs("div",{className:"flex gap-2.5 mb-3",children:[l.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-sm shrink-0 mt-5",style:{background:`${n}33`},children:n$[t]??"👤"}),l.jsxs("div",{className:"max-w-[85%] min-w-0",children:[l.jsx("div",{className:"text-[10px] text-[var(--terminal-text-muted)] mb-1",children:t.toUpperCase()}),d&&l.jsx(a$,{events:c,isStreaming:o}),m&&!d&&l.jsxs("details",{open:f,className:"mb-1",children:[l.jsxs("summary",{className:"text-[10px] text-purple-400/70 cursor-pointer select-none flex items-center gap-1",children:[f&&l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-purple-400 animate-pulse"}),"thinking",f?"...":` (${e.thinking.length} chars)`]}),l.jsx("div",{className:"text-[11px] text-[var(--terminal-text-muted)] leading-relaxed mt-1 pl-2 border-l border-purple-400/20 max-h-32 overflow-y-auto",children:e.thinking.slice(-500)})]}),l.jsxs("div",{className:"rounded-xl rounded-tl-sm px-4 py-2.5 text-sm text-[var(--terminal-text)] leading-relaxed",style:{borderLeft:`3px solid ${n}`,background:"var(--terminal-surface)"},children:[e.content?l.jsx(JB,{content:e.content,streaming:o}):o&&!m?l.jsxs("span",{className:"typing-dots",children:[l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"})]}):o&&m?l.jsxs("span",{className:"typing-dots",children:[l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"}),l.jsx("span",{className:"typing-dot"})]}):null,o&&e.content&&l.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-[var(--terminal-text-secondary)] animate-pulse ml-0.5 align-middle"})]}),e.status==="error"&&l.jsx("div",{className:"text-[10px] text-red-400 mt-1",children:"Error occurred"}),e.status==="done"&&(e.turns||e.tokens)&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1 flex gap-2",children:[e.turns&&l.jsxs("span",{children:[e.turns," turns"]}),e.tokens&&l.jsxs("span",{children:[(e.tokens.input+e.tokens.output).toLocaleString()," tokens"]}),e.readOnly&&l.jsx("span",{className:"text-blue-400/60",children:"read-only"})]}),e.knowledgeDebt&&e.knowledgeDebt.length>0&&l.jsxs("div",{className:"mt-1.5 px-3 py-2 rounded-lg text-[10px]",style:{background:"#FFA72615",border:"1px solid #FFA72630"},children:[l.jsxs("div",{className:"font-bold mb-1",style:{color:"#FFA726"},children:["Knowledge Debt (",e.knowledgeDebt.length,")"]}),e.knowledgeDebt.map((x,p)=>l.jsxs("div",{className:"flex gap-1.5 mb-0.5",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("span",{style:{color:"#FFA726"},children:x.type==="orphan"?"⚠":x.type==="no-hub"?"📁":"🔗"}),l.jsxs("span",{children:[x.message,x.file?` (${x.file})`:""]})]},p))]})]})]})}function L3({messages:e,roleId:t,roleColor:n}){var a;const i=S.useRef(null);return S.useEffect(()=>{var o;(o=i.current)==null||o.scrollIntoView({behavior:"smooth"})},[e,(a=e[e.length-1])==null?void 0:a.content]),e.length===0?l.jsxs("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:["Start a conversation with ",t.toUpperCase()]}):l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 terminal-scrollbar",children:[e.map(o=>l.jsx(o$,{message:o,roleId:t,roleColor:n},o.id)),l.jsx("div",{ref:i})]})}const c$=5*1024*1024,u$=["image/png","image/jpeg","image/gif","image/webp"];function H0({mode:e,onModeChange:t,onSend:n,disabled:i,disabledReason:a,onStop:o}){const[c,d]=S.useState(""),[m,f]=S.useState([]),[x,p]=S.useState(!1),[y,g]=S.useState(null),w=S.useRef(null),k=S.useRef(null),j=S.useRef(!1);S.useEffect(()=>{const _=w.current;_&&(_.style.height="0",_.style.height=Math.min(_.scrollHeight,120)+"px")},[c]),S.useEffect(()=>{if(y){const _=setTimeout(()=>g(null),3e3);return()=>clearTimeout(_)}},[y]);const C=S.useCallback(async _=>u$.includes(_.type)?_.size>c$?(g(`File too large: ${(_.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(B=>{const X=new FileReader;X.onload=()=>{const H=X.result.split(",")[1];B({type:"image",data:H,name:_.name,mediaType:_.type})},X.onerror=()=>{g("Failed to read file"),B(null)},X.readAsDataURL(_)}):(g(`Unsupported format: ${_.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),N=S.useCallback(async _=>{const B=Array.from(_),X=[];for(const R of B){const H=await C(R);H&&X.push(H)}X.length>0&&f(R=>[...R,...X])},[C]),E=S.useCallback(_=>{_.preventDefault(),_.stopPropagation(),p(!0)},[]),A=S.useCallback(_=>{_.preventDefault(),_.stopPropagation(),p(!1)},[]),z=S.useCallback(_=>{_.preventDefault(),_.stopPropagation(),p(!1);const B=_.dataTransfer.files;B.length>0&&N(B)},[N]),D=S.useCallback(_=>{const B=_.clipboardData.items,X=[];for(let R=0;R<B.length;R++){const H=B[R];if(H.type.startsWith("image/")){const $=H.getAsFile();$&&X.push($)}}X.length>0&&(_.preventDefault(),N(X))},[N]),F=S.useCallback(_=>{const B=_.target.files;B&&B.length>0&&N(B),_.target.value=""},[N]),q=S.useCallback(_=>{f(B=>B.filter((X,R)=>R!==_))},[]),V=()=>{const _=c.trim();!_&&m.length===0||i||(n(_,m.length>0?m:void 0),d(""),f([]))},L=_=>{if(_.key==="Enter"&&!_.shiftKey){if(j.current)return;_.preventDefault(),V()}};return l.jsxs("div",{className:`border-t border-[var(--terminal-border)] p-3 shrink-0 transition-colors ${x?"bg-[var(--terminal-surface-light)] border-amber-500/50":""}`,onDragOver:E,onDragLeave:A,onDrop:z,children:[y&&l.jsx("div",{className:"text-[10px] text-red-400 mb-2 text-center",children:y}),a&&l.jsx("div",{className:"text-[10px] text-amber-400/70 mb-2 text-center",children:a}),m.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:m.map((_,B)=>l.jsxs("div",{className:"relative group w-16 h-16 rounded-lg overflow-hidden border border-[var(--terminal-border)] bg-[var(--terminal-inline-bg)]",children:[l.jsx("img",{src:`data:${_.mediaType};base64,${_.data}`,alt:_.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>q(B),className:"absolute top-0.5 right-0.5 w-4 h-4 rounded-full bg-black/70 text-white text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:"x"}),l.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-[8px] text-white truncate px-1 py-0.5",children:_.name})]},B))}),x&&l.jsx("div",{className:"text-[11px] text-amber-400 text-center mb-2",children:"Drop image here"}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"flex rounded-lg overflow-hidden border border-[var(--terminal-border)] shrink-0",children:[l.jsx("button",{onClick:()=>t("talk"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${e==="talk"?"bg-[var(--desk-wood)] text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Talk"}),l.jsx("button",{onClick:()=>t("do"),className:`px-2.5 py-1.5 text-[11px] font-semibold cursor-pointer transition-colors ${e==="do"?"bg-amber-700 text-white":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)]"}`,children:"Do"})]}),l.jsx("button",{onClick:()=>{var _;return(_=k.current)==null?void 0:_.click()},disabled:i,className:"w-8 h-8 rounded-lg bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] text-[var(--terminal-text-muted)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--terminal-surface-light)] hover:text-[var(--terminal-text-secondary)] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Attach image (PNG, JPG, GIF, WebP)",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),l.jsx("input",{ref:k,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:F,className:"hidden"}),l.jsx("textarea",{ref:w,value:c,onChange:_=>d(_.target.value),onKeyDown:L,onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1},onPaste:D,placeholder:i?"Waiting...":e==="talk"?"Ask something...":"Give a directive...",disabled:i,rows:1,className:"flex-1 bg-[var(--terminal-inline-bg)] border border-[var(--terminal-border)] rounded-lg px-3 py-2 text-sm text-[var(--terminal-text)] placeholder:text-[var(--terminal-text-muted)] resize-none focus:outline-none focus:border-[var(--terminal-border-hover)] disabled:opacity-40 terminal-scrollbar"}),i&&o&&l.jsx("button",{onClick:o,className:"w-8 h-8 rounded-lg bg-red-900/40 text-red-400 flex items-center justify-center shrink-0 cursor-pointer hover:bg-red-900/60 hover:text-red-300 transition-colors",title:"Stop",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),l.jsx("button",{onClick:V,disabled:i||!c.trim()&&m.length===0,className:"w-8 h-8 rounded-lg bg-[var(--terminal-surface-light)] text-[var(--terminal-text-secondary)] flex items-center justify-center shrink-0 cursor-pointer hover:bg-[var(--desk-wood)] hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M22 2L11 13"}),l.jsx("path",{d:"M22 2L15 22L11 13L2 9L22 2Z"})]})})]})]})}const d$={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},I3={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Hw(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function f$({msg:e}){const t=d$[e.roleId]??"#888",n=I3[e.roleId]??e.roleId;if(e.type==="dispatch"){const i=e.text.includes("WAVE"),a=e.text.includes("completed")||e.text.includes("완료"),o=i?"📡":a?"✓":"→",c=a?"text-green-400/70":"text-[var(--terminal-text-muted)]";return l.jsxs("div",{className:"flex items-start gap-2 px-3 py-1 hover:bg-white/[0.02]",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:Hw(e.ts)}),l.jsx("span",{className:"text-[10px] shrink-0 mt-0.5",children:o}),l.jsx("span",{className:`text-[11px] ${c}`,children:e.text})]})}return l.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-white/[0.02]",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)] shrink-0 w-10 text-right mt-0.5",children:Hw(e.ts)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-[11px] font-semibold mr-1.5",style:{color:t},children:n}),l.jsx("span",{className:"text-xs text-[var(--terminal-text-secondary)]",children:e.text})]})]})}function h$({channel:e,allRoles:t,onUpdateMembers:n,onUpdateTopic:i,onSendMessage:a}){const o=S.useRef(null),c=S.useRef(null),[d,m]=S.useState("");S.useEffect(()=>{var E;const C=c.current;if(!C)return;C.scrollHeight-C.scrollTop-C.clientHeight<80&&((E=o.current)==null||E.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[f,x]=S.useState(!1),[p,y]=S.useState(!1),[g,w]=S.useState(""),k=a&&e.id!=="general",j=()=>{!d.trim()||!a||(a(e.id,d.trim()),m(""),setTimeout(()=>{var C;return(C=o.current)==null?void 0:C.scrollIntoView({behavior:"smooth"})},50))};return l.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[l.jsxs("div",{ref:c,className:"flex-1 overflow-y-auto terminal-scrollbar py-2 min-h-0",children:[l.jsxs("div",{className:"px-3 py-2 mb-2 border-b border-[var(--terminal-border)] flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-semibold text-[var(--terminal-text)]",children:e.name}),e.members.length>0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.members.map(C=>I3[C]??C).join(", ")}),e.members.length===0&&l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:e.isDefault?"system logs":"no members"}),!e.isDefault&&t&&n&&l.jsx("button",{className:"ml-auto text-[10px] px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 text-[var(--terminal-text-muted)]",onClick:()=>x(!f),children:f?"Done":"Invite"})]}),!e.isDefault&&i&&l.jsx("div",{className:"px-3 pb-2 mb-1",children:p?l.jsx("input",{autoFocus:!0,value:g,onChange:C=>w(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(i(e.id,g.trim()),y(!1)),C.key==="Escape"&&y(!1)},onBlur:()=>{i(e.id,g.trim()),y(!1)},placeholder:"Set a topic for this channel...",className:"w-full bg-transparent text-[10px] text-[var(--terminal-text-muted)] outline-none border-b border-[var(--terminal-border)] pb-0.5"}):l.jsx("button",{onClick:()=>{w(e.topic??""),y(!0)},className:"text-[10px] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] cursor-pointer italic",children:e.topic||"Click to set channel topic..."})}),f&&!e.isDefault&&t&&n&&l.jsx("div",{className:"px-3 pb-2 mb-2 border-b border-[var(--terminal-border)]",children:l.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(C=>{const N=e.members.includes(C.id);return l.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${N?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const E=N?e.members.filter(A=>A!==C.id):[...e.members,C.id];n(e.id,E)},children:[N?"✓ ":"",C.name]},C.id)})})}),e.messages.length===0&&l.jsx("div",{className:"flex-1 flex flex-col items-center justify-center text-[var(--terminal-text-muted)] text-xs gap-1 py-8",children:l.jsx("span",{children:e.isDefault?"No dispatch events yet":"No messages yet — invite roles to start chatting"})}),e.messages.map(C=>l.jsx(f$,{msg:C},C.id)),l.jsx("div",{ref:o})]}),k&&l.jsx("div",{className:"shrink-0 px-3 py-2 border-t border-[var(--terminal-border)]",children:l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("span",{className:"text-[10px] font-semibold shrink-0",style:{color:"#FFB300"},children:"CEO"}),l.jsx("input",{type:"text",value:d,onChange:C=>m(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),j())},placeholder:"Say something...",className:"flex-1 px-2 py-1 text-xs rounded border bg-transparent text-[var(--terminal-text)] border-[var(--terminal-border)] outline-none focus:border-[#FFB300]/50"})]})})]})}const Hp={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},m$=400,p$=800;function Uw({sessions:e,activeSessionId:t,roles:n,streamingSessionId:i,width:a,onWidthChange:o,onSwitchSession:c,onCloseSession:d,onCreateSession:m,onClearEmpty:f,onCloseAll:x,onSendMessage:p,onModeChange:y,onStopSession:g,onCloseTerminal:w,onMaximize:k,chatChannels:j,activeChatChannelId:C,onSwitchChatChannel:N,onCreateChatChannel:E,onDeleteChatChannel:A,onUpdateChatMembers:z,onUpdateChatTopic:D,onSendChatMessage:F,unreadChannels:q}){const[V,L]=S.useState(!1),[_,B]=S.useState(!1),[X,R]=S.useState(!1),[H,$]=S.useState(""),G=C!=null,Q=j==null?void 0:j.find(me=>me.id===C),[K,M]=S.useState(!1),[U,P]=S.useState(!1),[O,Z]=S.useState(!1),ee=S.useRef(0),J=S.useRef(0),se=S.useRef(null),le=e.find(me=>me.id===t),ye=i===t,De=e.filter(me=>me.messages.length===0).length,Ee=S.useCallback(()=>{const me=se.current;me&&(P(me.scrollLeft>0),Z(me.scrollLeft+me.clientWidth<me.scrollWidth-1))},[]);S.useEffect(()=>{if(!t||!se.current)return;const me=se.current.querySelector(`[data-session-id="${t}"]`);me&&me.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),Ee()},[t,e.length,Ee]),S.useEffect(()=>{const me=se.current;if(!me)return;Ee(),me.addEventListener("scroll",Ee);const Fe=new ResizeObserver(Ee);return Fe.observe(me),()=>{me.removeEventListener("scroll",Ee),Fe.disconnect()}},[Ee]);const Re=S.useCallback(me=>{me.preventDefault(),ee.current=me.clientX,J.current=a,M(!0);const Fe=k,Je=()=>{M(!1),document.removeEventListener("mousemove",Pe),document.removeEventListener("mouseup",Je)},Pe=it=>{const ht=ee.current-it.clientX,Ye=J.current+ht;if(Ye>=window.innerWidth*.6&&Fe){Je(),Fe();return}const nt=Math.min(p$,Math.max(m$,Ye));o==null||o(nt)};document.addEventListener("mousemove",Pe),document.addEventListener("mouseup",Je)},[a,o,k]);return l.jsxs("div",{className:"shrink-0 bg-[var(--terminal-bg)] border-l border-[var(--terminal-border)] flex flex-col h-full relative",style:{width:a},children:[o&&l.jsx("div",{className:`terminal-resize-handle absolute top-0 left-0 w-1 h-full cursor-col-resize z-10 transition-colors ${K?"bg-[var(--terminal-border-hover)]":"bg-transparent"}`,onMouseDown:Re}),l.jsxs("div",{className:"flex items-center bg-[var(--terminal-bg-deeper)] border-b border-[var(--terminal-border)] shrink-0",children:[l.jsxs("div",{className:"relative flex-1 min-w-0",children:[U&&l.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-6 bg-gradient-to-r from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"}),l.jsxs("div",{ref:se,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[j==null?void 0:j.map(me=>l.jsxs("button",{onClick:()=>{N==null||N(me.id)},className:`flex items-center gap-1 px-2.5 py-1.5 text-[11px] rounded-t-lg shrink-0 cursor-pointer transition-colors group ${C===me.id?"bg-[var(--terminal-bg)] text-[var(--terminal-text)]":"bg-[var(--terminal-inline-bg)] text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface)]"}`,style:C===me.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:me.name}),(q==null?void 0:q.has(me.id))&&C!==me.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!me.isDefault&&l.jsx("span",{onClick:Fe=>{Fe.stopPropagation(),A==null||A(me.id)},className:"ml-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm leading-none opacity-0 group-hover:opacity-100",children:"×"})]},me.id)),j&&j.length>0&&e.length>0&&l.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),e.map(me=>l.jsx(ZB,{roleId:me.roleId,title:me.title,roleColor:Hp[me.roleId]??"#666",active:!G&&me.id===t,isWave:me.source==="wave",isWaveStreaming:me.source==="wave"&&me.status==="active",onClick:()=>{N==null||N(null),c(me.id)},onClose:Fe=>{Fe.stopPropagation(),d(me.id)},"data-session-id":me.id},me.id))]}),O&&l.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-6 bg-gradient-to-l from-[var(--terminal-bg-deeper)] to-transparent z-10 pointer-events-none"})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{L(!V),B(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-lg cursor-pointer",children:"+"}),V&&l.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[E&&l.jsxs(l.Fragment,{children:[X?l.jsxs("div",{className:"px-3 py-2 flex items-center gap-1",children:[l.jsx("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:"#"}),l.jsx("input",{autoFocus:!0,value:H,onChange:me=>$(me.target.value),onKeyDown:me=>{me.key==="Enter"&&H.trim()&&(E(H.trim(),[]),$(""),R(!1),L(!1)),me.key==="Escape"&&(R(!1),$(""))},placeholder:"channel name",className:"flex-1 bg-transparent text-xs text-[var(--terminal-text)] outline-none border-b border-[var(--terminal-border)]"})]}):l.jsxs("button",{onClick:()=>R(!0),className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer flex items-center gap-2",children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),"New Channel"]}),l.jsx("div",{className:"border-b border-[var(--terminal-border)] my-1"})]}),n.map(me=>l.jsxs("button",{onClick:()=>{m(me.id),N==null||N(null),L(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:Hp[me.id]??"#666"}}),me.id.toUpperCase()," — ",me.name]},me.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{B(!_),L(!1)},className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-xs cursor-pointer tracking-tight",title:"Manage sessions",children:"···"}),_&&l.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-[var(--terminal-surface)] border border-[var(--terminal-border)] rounded-lg shadow-xl z-50 py-1 min-w-[200px]",children:[l.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-[var(--terminal-text-muted)] border-b border-[var(--terminal-border)]",children:[e.length," session",e.length!==1?"s":""]}),De>0&&f&&l.jsxs("button",{onClick:()=>{f(),B(!1)},className:"w-full text-left px-3 py-2 text-xs text-[var(--terminal-text-secondary)] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:["Clear empty sessions (",De,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),B(!1)},className:"w-full text-left px-3 py-2 text-xs text-[#E57373] hover:bg-[var(--terminal-surface-light)] cursor-pointer",children:"Close all sessions"}),e.length===0&&l.jsx("div",{className:"px-3 py-2 text-xs text-[var(--terminal-text-muted)]",children:"No sessions"})]})]}),k&&l.jsx("button",{onClick:k,className:"w-7 h-7 flex items-center justify-center text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",title:"Maximize (Pro View)",children:"⤢"}),l.jsx("button",{onClick:w,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"×"})]}),G&&Q?l.jsx(h$,{channel:Q,allRoles:n,onUpdateMembers:z,onUpdateTopic:D,onSendMessage:F}):le?l.jsxs(l.Fragment,{children:[l.jsx(L3,{messages:le.messages,roleId:le.roleId,roleColor:Hp[le.roleId]??"#666"}),l.jsx(H0,{mode:le.mode,onModeChange:me=>y(le.id,me),onSend:(me,Fe)=>p(le.id,me,le.mode,Fe),disabled:ye,disabledReason:ye?`${le.roleId.toUpperCase()} is responding...`:void 0,onStop:ye&&g?()=>g(le.id):void 0})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center text-[var(--terminal-text-muted)] text-sm",children:"No active session. Click [+] to start."})]})}function x$(){const e=S.useRef(null),t=S.useCallback(()=>{var i;(i=e.current)==null||i.abort(),e.current=null},[]);return{sendMessage:S.useCallback((i,a,o,c,d)=>{t();const m=new AbortController;return e.current=m,fetch(`/api/sessions/${i}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a,mode:o,attachments:d}),signal:m.signal}).then(async f=>{var j,C,N,E,A;if(!f.ok||!f.body){c.onError("Failed to connect");return}const x=f.body.getReader(),p=new TextDecoder;let y="",g=Date.now();const w=6e4,k=setInterval(()=>{Date.now()-g>w&&(clearInterval(k),m.abort(),c.onError("Connection stale — no data received for 60s"))},1e4);try{for(;;){const{done:z,value:D}=await x.read();if(z)break;g=Date.now(),y+=p.decode(D,{stream:!0});const F=y.split(`
119
+ `);y=F.pop()??"";let q="";for(let V=0;V<F.length;V++){const L=F[V];if(L.startsWith("event: ")){q=L.slice(7).trim();continue}if(L.startsWith("data: ")){let _;try{_=JSON.parse(L.slice(6))}catch{q="";continue}switch(q){case"thinking":_.text&&((j=c.onThinking)==null||j.call(c,_.text));break;case"output":_.text&&c.onText(_.text);break;case"tool":(C=c.onToolUse)==null||C.call(c,_.name,_.input);break;case"dispatch":(N=c.onDispatch)==null||N.call(c,_.roleId,_.task);break;case"dispatch:progress":(E=c.onDispatchProgress)==null||E.call(c,_.roleId,_.type,_);break;case"turn":(A=c.onTurn)==null||A.call(c,_.turn);break;case"done":c.onDone(_);break;case"error":c.onError(_.message??"Unknown error");break;default:_.text&&c.onText(_.text);break}q=""}}}}finally{clearInterval(k)}}).catch(f=>{f.name!=="AbortError"&&c.onError(f.message)}),{abort:t}},[t]),abort:t}}const H3="tycono-appearances",Lx="tycono-theme";function qw(){try{const e=localStorage.getItem(H3);return e?JSON.parse(e):{}}catch{return{}}}function Up(e){localStorage.setItem(H3,JSON.stringify(e))}function Yw(){try{const e=localStorage.getItem(Lx);if(e&&e in Bs)return e}catch{}return"default"}const U3=new Set;for(const e of Object.values(Bs))for(const t of Object.keys(e.vars))U3.add(t);function g$(e){var i;const t=(i=Bs[e])==null?void 0:i.vars;if(!t)return;const n=document.documentElement;for(const a of U3)a in t||n.style.removeProperty(a);for(const[a,o]of Object.entries(t))n.style.setProperty(a,o)}const qp={mode:"auto",intervalSec:18,dailyBudgetUsd:1},Ix="tycono-speech-settings",Yp="tycono-language";function y$(){try{const e=localStorage.getItem(Ix);return e?{...qp,...JSON.parse(e)}:qp}catch{return qp}}function b$(){const[e,t]=S.useState(qw),[n,i]=S.useState(Yw),[a,o]=S.useState(y$),[c,d]=S.useState(()=>{try{return localStorage.getItem(Yp)??"auto"}catch{return"auto"}}),[m,f]=S.useState(new Set),x=S.useRef(!1);S.useEffect(()=>{x.current||(x.current=!0,ke.getPreferences().then(N=>{const E=Object.keys(N.appearances??{}).length>0||N.theme!=="default";if(N.speech&&(o(A=>({...A,...N.speech})),localStorage.setItem(Ix,JSON.stringify(N.speech))),N.language&&(d(N.language),localStorage.setItem(Yp,N.language)),N.purchasedItems&&f(new Set(N.purchasedItems)),E){const A=N.appearances;t(A),Up(A),N.theme&&N.theme in Bs&&(i(N.theme),localStorage.setItem(Lx,N.theme))}else{const A=qw(),z=Yw();(Object.keys(A).length>0||z!=="default")&&ke.updatePreferences({appearances:A,theme:z}).catch(()=>{})}}).catch(()=>{}))},[]),S.useEffect(()=>{g$(n)},[n]);const p=S.useCallback(N=>e[N]??I0(N),[e]),y=S.useCallback((N,E)=>{t(A=>{const z={...A,[N]:E};return Up(z),ke.updatePreferences({appearances:z}).catch(()=>{}),z})},[]),g=S.useCallback(N=>{t(E=>{const A={...E};return delete A[N],Up(A),ke.updatePreferences({appearances:A}).catch(()=>{}),A})},[]),w=S.useCallback(N=>{i(N),localStorage.setItem(Lx,N),ke.updatePreferences({theme:N}).catch(()=>{})},[]),k=S.useCallback(N=>{o(E=>{const A={...E,...N};return localStorage.setItem(Ix,JSON.stringify(A)),ke.updatePreferences({speech:A}).catch(()=>{}),A})},[]),j=S.useCallback(N=>{d(N),localStorage.setItem(Yp,N),ke.updatePreferences({language:N}).catch(()=>{})},[]),C=S.useCallback(N=>{f(E=>{const A=new Set(E);return A.add(N),ke.updatePreferences({purchasedItems:Array.from(A)}).catch(()=>{}),A})},[]);return{appearances:e,getAppearance:p,setAppearance:y,resetAppearance:g,theme:n,setTheme:w,speechSettings:a,setSpeechSettings:k,language:c,setLanguage:j,purchasedItems:m,addPurchasedItem:C}}const v$=3e4,w$=3e5;function k$(){var _;const[e,t]=S.useState("akb"),[n,i]=S.useState(null),[a,o]=S.useState("synced"),[c,d]=S.useState([]),[m,f]=S.useState(null),[x,p]=S.useState(!1),y=S.useRef(null),g=S.useRef(null),w=S.useRef(e);w.current=e;const k=S.useCallback(async()=>{try{const B=await ke.getSaveStatus(w.current);i(B),B.noGit?o("no-git"):o(X=>X==="saving"?X:B.dirty?"dirty":"synced")}catch{o("error")}},[]),j=S.useCallback(async()=>{try{const B=await ke.getSyncStatus(w.current);f({ahead:B.ahead,behind:B.behind,branch:B.branch,hasRemote:B.hasRemote})}catch{}},[]),C=S.useCallback(()=>{y.current&&clearInterval(y.current),k(),y.current=setInterval(k,v$),g.current&&clearInterval(g.current),j(),g.current=setInterval(j,w$)},[k,j]);S.useEffect(()=>()=>{y.current&&clearInterval(y.current),g.current&&clearInterval(g.current)},[]);const N=S.useCallback(B=>{t(B),w.current=B,i(null),f(null),d([]),setTimeout(()=>{k(),j()},0)},[k,j]),E=S.useCallback(async B=>{o("saving");try{const X=await ke.save(B,w.current);return await k(),X}catch(X){throw o("error"),X}},[k]),A=S.useCallback(async()=>{try{const B=await ke.getSaveHistory(20,w.current);d(B)}catch{}},[]),z=S.useCallback(async B=>{o("saving");try{await ke.restoreSave(B,void 0,w.current),await k()}catch(X){throw o("error"),X}},[k]),D=S.useCallback(async()=>{p(!0);try{const B=await ke.pull(w.current);return await k(),await j(),B}catch(B){throw B}finally{p(!1)}},[k,j]),F=S.useCallback(async()=>{try{await ke.initGit(w.current),await k()}catch{o("error")}},[k]),q=n?n.modified.length+n.untracked.length:0,V=((_=n==null?void 0:n.lastCommit)==null?void 0:_.date)??null,L=S.useCallback(async()=>{C()},[C]);return{state:a,dirtyCount:q,lastSaved:V,status:n,save:E,history:c,loadHistory:A,restore:z,refresh:L,initGit:F,repo:e,setRepo:N,syncInfo:m,fetchSyncStatus:j,pull:D,pulling:x}}const Pw={cto:["Need to reduce this architecture tech debt...","Don't over-engineer. Keep it minimal.","Performance profiling results are a bit concerning.","Should do a system design review.","If I just strip one abstraction layer, it should work.","Let me check the monitoring dashboard.","Need to go through the code review queue.","It's about time to clean up these module dependencies."],cbo:["Heard the competitor launched a new feature... need to analyze.","Should compile this month's revenue metrics.","It's time to update the market trend report.","Maybe I should benchmark the pricing strategy.","Need to recalculate the ROI.","Let me check the competitor's GitHub star trends.","Thinking about launch timing...","Should re-examine the positioning strategy."],pm:["Is this feature really what users want?","Need to clean up the backlog...","MVP scope keeps expanding.","Analyzing user feedback...","Might need to re-prioritize.","Watch out for scope creep.","Will the roadmap timeline hold...","Should double-check the task dependencies."],engineer:["I want to refactor this code...","Test coverage seems a bit low.","Working code first, perfect code later.","Waiting for PR review...","What could be causing this bug...","Is the build broken?","Need to fix that one type error.","Maybe I should run npm audit."],designer:["This UI flow feels a bit awkward...","Usability first, pretty later.","Need to organize the design system components.","Let me make two quick options and compare.","Should run through the accessibility checklist.","Maybe I should prototype this interaction.","Let me revisit the color palette...","The spacing feels a bit cramped."],qa:['"Works" and "correct" are two different things.',"Organizing edge case scenarios...","Should run the regression test suite.","This part could be converted to automated tests.","Need to go through the pre-release checklist.","Reproducible bug reports are key.","Should run cross-browser tests.","Need to check for performance regressions."],"data-analyst":["Checking the data pipeline status...","Interesting outlier detection pattern.","Need to update the dashboard metrics.","Correlation isn't causation though...","Seems like there is room for SQL query optimization.","It's time for a data quality check."]},Xw={cto:["Should I assign more work to the team...","It's time to clean up the architecture debt.","Need to re-examine the tech roadmap.","It's quiet... am I missing something?"],cbo:["It's time to update the market analysis...","Should be preparing the revenue report, but no directives.","Let me check on competitor movements.","It's quiet on the business side..."],pm:["Backlog is pretty quiet... nothing to plan?","It's been a while since we scheduled a sprint.","User feedback must be piling up...","No PRD to write... that's unusual."],engineer:["Nothing to do today... maybe some code reviews.","Task queue is empty. Guess I'll refactor.","Am I missing something?","Should clean up the commit log."],designer:["No design requests coming in. Should I improve something on my own?","Maybe run a UI audit...","Should organize my portfolio.","Let me tidy up the component library."],qa:["No builds to test. Let me improve the automation scripts.","It's quiet... no bugs, or just haven't found them?","Let me review the existing test scenarios.","Should update the test coverage report."],"data-analyst":["No analysis requests coming in...","Maybe I should clean up the data warehouse.","Should verify the past reports."]},S$=[{id:"sup-check-1",relation:"superior-subordinate",minFamiliarity:0,topic:"progress",turns:[{speaker:"A",text:"How's the progress?"},{speaker:"B",text:"Going well. Should be done soon."},{speaker:"A",text:"Good, let me know when it's done."}]},{id:"sup-check-2",relation:"superior-subordinate",minFamiliarity:20,topic:"progress",turns:[{speaker:"A",text:"What are you working on today?"},{speaker:"B",text:"Finishing up what I was doing yesterday."}]},{id:"sub-report-1",relation:"superior-subordinate",minFamiliarity:10,topic:"report",turns:[{speaker:"B",text:"Done with that task from earlier."},{speaker:"A",text:"Nice work. Can you share the results?"},{speaker:"B",text:"Sure, I've updated the docs."}]},{id:"peer-tech-1",relation:"peer",minFamiliarity:20,topic:"tech",turns:[{speaker:"A",text:"What do you think about this design?"},{speaker:"B",text:"I think we could go simpler."},{speaker:"A",text:"Really? Want to look at it together?"}]},{id:"peer-tech-2",relation:"peer",minFamiliarity:30,topic:"tech",turns:[{speaker:"A",text:"Have you used this library before?"},{speaker:"B",text:"Yeah, used it in the last project. It was decent."}]},{id:"close-feedback-1",relation:"peer",minFamiliarity:60,topic:"feedback",turns:[{speaker:"A",text:"Can I be honest with you?"},{speaker:"B",text:"Of course, go ahead."},{speaker:"A",text:"This one feels a bit off. Let's revisit."},{speaker:"B",text:"...Alright. Thanks for the feedback."}]},{id:"clevel-sync-1",relation:"c-level",minFamiliarity:10,topic:"strategy",turns:[{speaker:"A",text:"We need to sync the roadmap with the business timeline."},{speaker:"B",text:"Agreed. I'll have it organized and shared by tomorrow."}]},{id:"clevel-sync-2",relation:"c-level",minFamiliarity:30,topic:"strategy",turns:[{speaker:"A",text:"I have some competitor intel to share."},{speaker:"B",text:"Great, I have a tech update too."},{speaker:"A",text:"Let's sync up when you're free."}]},{id:"casual-coffee",relation:"any",minFamiliarity:30,topic:"casual",turns:[{speaker:"A",text:"Want to grab a coffee?"},{speaker:"B",text:"Sure. Feels like it's going to be a long day."}]},{id:"casual-overtime",relation:"any",minFamiliarity:25,topic:"casual",turns:[{speaker:"A",text:"Working late again..."},{speaker:"B",text:"We're in this together. Hang in there."}]},{id:"casual-lunch",relation:"any",minFamiliarity:35,topic:"casual",turns:[{speaker:"A",text:"What should we get for lunch?"},{speaker:"B",text:"Anything. Feel like we eat the same thing every day."}]},{id:"casual-weekend",relation:"any",minFamiliarity:40,topic:"casual",turns:[{speaker:"A",text:"What did you do this weekend?"},{speaker:"B",text:"Just rested. Was too tired."}]},{id:"bestie-1",relation:"any",minFamiliarity:80,topic:"trust",turns:[{speaker:"A",text:"I'm a bit unsure about this direction..."},{speaker:"B",text:"What's bothering you? Be honest."},{speaker:"A",text:"Thanks. It's nice having someone I can talk to."}]}],j$=18e3,Vw=6e3,C$=2500,N$=30*6e4,q3="tycono:relationships";function E$(){try{const e=localStorage.getItem(q3);return e?JSON.parse(e):[]}catch{return[]}}function A$(e){localStorage.setItem(q3,JSON.stringify(e))}function Vd(e,t,n){const[i,a]=t<n?[t,n]:[n,t];let o=e.find(c=>c.roleA===i&&c.roleB===a);return o||(o={roleA:i,roleB:a,dispatches:0,wavesTogether:0,conversations:0,familiarity:0,lastInteraction:new Date().toISOString()},e.push(o)),o}function Wd(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function Gd(e){return e[Math.floor(Math.random()*e.length)]}function D$(e,t,n){const i=n.find(d=>d.id===e),a=n.find(d=>d.id===t);if(!i||!a)return null;const o=i.level==="c-level",c=a.level==="c-level";return o&&c?"c-level":i.reportsTo===t||a.reportsTo===e?"superior-subordinate":(i.reportsTo===a.reportsTo,"peer")}function T$(e,t){return e.relation==="any"?!0:e.relation===t}function _$({roles:e,roleStatuses:t,activeExecs:n,getStandupSpeech:i}){const[a,o]=S.useState(new Map),[c,d]=S.useState(E$),m=S.useRef({}),f=S.useRef(null),x=S.useRef(e),p=S.useRef(t),y=S.useRef(n),g=S.useRef(i),w=S.useRef(c);x.current=e,p.current=t,y.current=n,g.current=i,w.current=c,S.useEffect(()=>{const A=Date.now();for(const[z,D]of Object.entries(t))tr(D)&&(m.current[z]=A)},[t]),S.useEffect(()=>{A$(c)},[c]);const k=S.useCallback(A=>{const z=p.current[A],D=y.current.find(_=>_.roleId===A);if(tr(z)&&(D!=null&&D.task))return null;const F=g.current(A);if(F&&Math.random()<.3)return{text:F,type:"work",ts:Date.now()};const q=Date.now(),V=m.current[A]??0;if(q-V>N$&&Math.random()<.5){const _=Xw[A]??Xw.engineer;return{text:Gd(_),type:"guilt",ts:q}}const L=Pw[A]??Pw.engineer;return{text:Gd(L),type:"personality",ts:q}},[]),j=S.useCallback(A=>{if(f.current)return!1;const z=A.filter(G=>!tr(p.current[G.id]));if(z.length<2)return!1;const D=[...z].sort(()=>Math.random()-.5),F=D[0],q=D[1],V=D$(F.id,q.id,A);if(!V)return!1;const L=Vd(w.current,F.id,q.id),_=Wd(L),B=S$.filter(G=>T$(G,V)&&_>=G.minFamiliarity);if(B.length===0)return!1;const X=Gd(B);let R=F.id,H=q.id;X.relation==="superior-subordinate"&&(q.reportsTo===F.id||F.level==="c-level"?(R=F.id,H=q.id):(R=q.id,H=F.id)),f.current={templateId:X.id,roleA:R,roleB:H,turnIdx:0,timer:null};const $=G=>{if(!f.current||G>=X.turns.length){f.current=null,d(U=>{const P=[...U],O=Vd(P,R,H);return O.conversations++,O.familiarity=Wd(O),O.lastInteraction=new Date().toISOString(),P}),setTimeout(()=>{o(U=>{const P=new Map(U);return P.delete(R),P.delete(H),P})},Vw);return}const Q=X.turns[G],K=Q.speaker==="A"?R:H,M=Q.speaker==="A"?H:R;o(U=>{const P=new Map(U);if(P.set(K,{text:Q.text,type:"social",partnerId:M,ts:Date.now()}),G>0){const O=X.turns[G-1].speaker==="A"?R:H;O!==K&&P.delete(O)}return P}),f.current.turnIdx=G,f.current.timer=setTimeout(()=>$(G+1),C$)};return $(0),!0},[]);S.useEffect(()=>{const A=setInterval(()=>{const z=x.current;if(z.length===0||f.current||Math.random()<.35&&j(z))return;const D=z.filter(V=>!tr(p.current[V.id]));if(D.length===0)return;const F=Gd(D),q=k(F.id);q&&(o(V=>{const L=new Map(V);return L.set(F.id,q),L}),setTimeout(()=>{o(V=>{const L=new Map(V),_=L.get(F.id);return _&&_.ts===q.ts&&L.delete(F.id),L})},Vw))},j$);return()=>{var z;clearInterval(A),(z=f.current)!=null&&z.timer&&clearTimeout(f.current.timer)}},[k,j]);const C=S.useCallback(A=>{const z=a.get(A);return(z==null?void 0:z.text)??""},[a]),N=S.useCallback((A,z)=>{d(D=>{const F=[...D],q=Vd(F,A,z);return q.dispatches++,q.familiarity=Wd(q),q.lastInteraction=new Date().toISOString(),F})},[]),E=S.useCallback(A=>{A.length<2||d(z=>{const D=[...z];for(let F=0;F<A.length;F++)for(let q=F+1;q<A.length;q++){const V=Vd(D,A[F],A[q]);V.wavesTogether++,V.familiarity=Wd(V),V.lastInteraction=new Date().toISOString()}return D})},[]);return{speeches:a,getSpeech:C,relationships:c,notifyDispatch:N,notifyWave:E}}const Y3="tycono:office-chat";let M$=0;function F$(){return`chat-${Date.now()}-${++M$}`}function Pp(){return[{id:"general",name:"#general",members:[],isDefault:!0,messages:[],topic:"Company-wide announcements and general discussion"},{id:"watercooler",name:"#watercooler",members:[],isDefault:!0,messages:[],topic:"No managers allowed. Vent, gossip, joke around. Talk freely about work frustrations, complain about directives you disagree with, share hot takes."}]}function R$(){try{const e=localStorage.getItem(Y3);if(e){const t=JSON.parse(e);if(t.find(i=>i.id==="office")&&!t.find(i=>i.id==="general")){const i=t.filter(a=>a.id!=="office");return[...Pp(),...i]}const n=Pp();for(const i of n)t.find(a=>a.id===i.id)||t.unshift(i);return t}}catch{}return Pp()}function z$(e){const t=e.map(n=>({...n,messages:n.messages.slice(-200)}));localStorage.setItem(Y3,JSON.stringify(t))}function B$(){const[e,t]=S.useState(R$),[n,i]=S.useState(null),[a,o]=S.useState(new Set);S.useEffect(()=>{z$(e)},[e]);const c=S.useCallback(g=>{i(g),g&&o(w=>{const k=new Set(w);return k.delete(g),k})},[]),d=S.useCallback(g=>{const w={...g,id:F$()};t(k=>{const j=k.map(C=>C.id==="general"?g.type==="dispatch"?{...C,messages:[...C.messages,w].slice(-200)}:C:g.channelId?C.id===g.channelId?{...C,messages:[...C.messages,w].slice(-200)}:C:C.members.length>0&&C.members.includes(g.roleId)?{...C,messages:[...C.messages,w].slice(-200)}:C);return o(C=>{const N=new Set(C);for(const E of j){const A=k.find(z=>z.id===E.id);A&&E.messages.length>A.messages.length&&N.add(E.id)}return N}),j})},[]),m=S.useCallback((g,w,k)=>{const j=`ch-${Date.now()}`,C={id:j,name:g.startsWith("#")?g:`#${g}`,members:w,isDefault:!1,messages:[],topic:k};t(N=>[...N,C]),i(j)},[]),f=S.useCallback(g=>{t(w=>w.filter(k=>k.id!==g||k.isDefault)),i(w=>w===g?"general":w)},[]),x=S.useCallback((g,w)=>{t(k=>k.map(j=>j.id===g&&!j.isDefault?{...j,members:w}:j))},[]),p=S.useCallback((g,w)=>{t(k=>k.map(j=>j.id===g&&!j.isDefault?{...j,topic:w||void 0}:j))},[]),y=S.useCallback(g=>{t(w=>w.map(k=>{if(k.id==="watercooler"){const j=g.filter(C=>C.level!=="c-level").map(C=>C.id);if(k.members.length!==j.length||!j.every(C=>k.members.includes(C)))return{...k,members:j}}return k}))},[]);return{channels:e,activeChannelId:n,setActiveChannelId:c,pushMessage:d,createChannel:m,deleteChannel:f,updateMembers:x,updateTopic:p,unreadChannels:a,syncDefaultMembers:y}}const $$=45e3,Ww=5e3,O$=4,L$=20;function I$({roles:e,roleStatuses:t,activeExecs:n,channels:i,relationships:a,pushMessage:o,speechSettings:c,engineType:d,hasApiKey:m}){const x=((c==null?void 0:c.mode)==="auto"?d==="claude-cli"||d==="local"?"llm":"template":(c==null?void 0:c.mode)??"template")==="llm"&&(m!==!1||d==="claude-cli"),p=((c==null?void 0:c.intervalSec)??$$/1e3)*1e3,y=S.useRef(e),g=S.useRef(t),w=S.useRef(n),k=S.useRef(i),j=S.useRef(a),C=S.useRef(o),N=S.useRef(0),E=S.useRef(!1);y.current=e,g.current=t,w.current=n,k.current=i,j.current=a,C.current=o;const A=S.useCallback(async(F,q)=>{if(E.current)return!1;E.current=!0;try{if(!y.current.find($=>$.id===F))return!1;const L=q.messages.slice(-L$).map($=>({roleId:$.roleId,text:$.text,ts:$.ts})),_=y.current.filter($=>q.members.includes($.id)),B=j.current.filter($=>$.roleA===F||$.roleB===F).map($=>({partnerId:$.roleA===F?$.roleB:$.roleA,familiarity:$.familiarity})),X=w.current.find($=>$.roleId===F),R=X?{currentTask:X.task,taskProgress:null}:{currentTask:null,taskProgress:null},H=await ke.chatInChannel({channelId:q.name.replace("#",""),channelTopic:q.topic,roleId:F,history:L,members:_.map($=>({id:$.id,name:$.name,level:$.level})),relationships:B,workContext:R});return H.message?(C.current({ts:Date.now(),roleId:F,text:H.message,type:"chat",channelId:q.id}),!0):!1}catch{return!1}finally{E.current=!1}},[]),z=S.useCallback(async(F,q)=>{if(N.current>=O$){N.current=0;return}const V=F.members.filter(X=>X!==q&&!tr(g.current[X]));if(V.length===0){N.current=0;return}const L=V[Math.floor(Math.random()*V.length)];if(Math.random()>.7){N.current=0;return}const _=N.current*2e3,B=Math.random()*5e3;setTimeout(async()=>{N.current++;const X=k.current.find(H=>H.id===F.id);if(!X)return;if(await A(L,X)){const H=.6-N.current*.1;Math.random()<H?z(X,L):N.current=0}else N.current=0},Ww+_+B)},[A]);return S.useEffect(()=>{if(!x)return;const F=setInterval(async()=>{const q=y.current;if(q.length===0||E.current)return;const V=q.filter(R=>!tr(g.current[R.id]));if(V.length===0)return;const L=V[Math.floor(Math.random()*V.length)],_=k.current.filter(R=>R.members.length===0?!0:R.members.includes(L.id));if(_.length===0)return;const B=_[Math.floor(Math.random()*_.length)];N.current=0,await A(L.id,B)&&z(B,L.id)},p);return()=>clearInterval(F)},[x,p,A,z]),{triggerCeoReaction:S.useCallback(F=>{if(!x)return;const q=k.current.find(V=>V.id===F);q&&(N.current=0,setTimeout(()=>{z(q,"ceo")},Ww))},[x,z])}}const P3=[[1,8],[3,5],[8,1],[5,3]],H$=[[1,4],[2,3],[4,1],[3,2]];function Kd(e){const t=e===1||e===3?-1:0,n=P3[e],i=e<2?[0,1]:[1,0],a=t;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:n[0],y:13,w:3,h:4,c:"$pants"},{x:n[1],y:13,w:3,h:4,c:"$pants"},{x:n[0]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:n[1]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:n[0],y:16,w:3,h:2,c:"$shoes"},{x:n[1],y:16,w:3,h:2,c:"$shoes"},{x:n[0],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:n[1],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:1,y:a+8,w:10,h:6,c:"$shirt"},{x:2,y:a+8,w:8,h:1,c:"lighten($shirt, 20)",a:.35},{x:1,y:a+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:10,y:a+8,w:1,h:5,c:"darken($shirt, 30)",a:.2},{x:-1,y:a+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:a+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:-1,y:a+12,w:2,h:1,c:"$skin"},{x:11,y:a+12,w:2,h:1,c:"$skin"},{x:4,y:a+6,w:4,h:3,c:"$skin"},{x:1,y:a+0,w:10,h:7,c:"$skin"},{x:3,y:a+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:a+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:a+3,w:1,h:1,c:"#FFF",a:.4},{x:7,y:a+3,w:1,h:1,c:"#FFF",a:.4},{x:5,y:a+6,w:2,h:1,c:"darken($skin, 25)",a:.35},{x:0,y:a+3,w:1,h:1,c:"$skin"},{x:11,y:a+3,w:1,h:1,c:"$skin"},{x:1,y:a+0,w:10,h:3,c:"$hair"},{x:0,y:a+1,w:2,h:3,c:"$hair"},{x:10,y:a+1,w:2,h:3,c:"$hair"},{x:2,y:a+0,w:8,h:1,c:"lighten($hair, 25)",a:.3}]}function Qd(e){const t=e===1||e===3?-1:0,n=P3[e],i=e<2?[0,1]:[1,0],a=t;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:n[0],y:13,w:3,h:4,c:"$pants"},{x:n[1],y:13,w:3,h:4,c:"$pants"},{x:n[0],y:16,w:3,h:2,c:"$shoes"},{x:n[1],y:16,w:3,h:2,c:"$shoes"},{x:1,y:a+8,w:10,h:6,c:"$shirt"},{x:2,y:a+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:5,y:a+10,w:2,h:3,c:"darken($shirt, 30)",a:.12},{x:-1,y:a+9+i[0],w:3,h:4-i[0],c:"$shirt"},{x:10,y:a+9+i[1],w:3,h:4-i[1],c:"$shirt"},{x:4,y:a+6,w:4,h:3,c:"$skin"},{x:1,y:a+0,w:10,h:7,c:"$skin"},{x:1,y:a+0,w:10,h:6,c:"$hair"},{x:0,y:a+1,w:2,h:5,c:"$hair"},{x:10,y:a+1,w:2,h:5,c:"$hair"},{x:2,y:a+0,w:8,h:1,c:"lighten($hair, 25)",a:.3},{x:0,y:a+4,w:1,h:1,c:"$skin",a:.6},{x:11,y:a+4,w:1,h:1,c:"$skin",a:.6}]}function ba(e,t){const n=e===1||e===3?-1:0,i=H$[e],a=n,o=e%2===0?1:0;return t?[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:a+8,w:8,h:6,c:"$shirt"},{x:2,y:a+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:8,y:a+9+o,w:3,h:4-o,c:"$shirt"},{x:9,y:a+12,w:2,h:1,c:"$skin"},{x:4,y:a+6,w:4,h:3,c:"$skin"},{x:2,y:a+0,w:8,h:7,c:"$skin"},{x:7,y:a+3,w:2,h:2,c:"#1A1A2E"},{x:7,y:a+3,w:1,h:1,c:"#FFF",a:.3},{x:9,y:a+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:a+0,w:8,h:3,c:"$hair"},{x:1,y:a+1,w:2,h:4,c:"$hair"},{x:9,y:a+1,w:2,h:3,c:"$hair"},{x:3,y:a+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]:[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:i[0],y:13,w:3,h:4,c:"$pants"},{x:i[1],y:13,w:3,h:4,c:"$pants"},{x:i[0],y:16,w:3,h:2,c:"$shoes"},{x:i[1],y:16,w:3,h:2,c:"$shoes"},{x:2,y:a+8,w:8,h:6,c:"$shirt"},{x:2,y:a+8,w:8,h:1,c:"lighten($shirt, 20)",a:.2},{x:0,y:a+9+o,w:3,h:4-o,c:"$shirt"},{x:-1,y:a+12,w:2,h:1,c:"$skin"},{x:4,y:a+6,w:4,h:3,c:"$skin"},{x:2,y:a+0,w:8,h:7,c:"$skin"},{x:3,y:a+3,w:2,h:2,c:"#1A1A2E"},{x:3,y:a+3,w:1,h:1,c:"#FFF",a:.3},{x:1,y:a+4,w:1,h:1,c:"darken($skin, 25)",a:.3},{x:2,y:a+0,w:8,h:3,c:"$hair"},{x:1,y:a+1,w:2,h:3,c:"$hair"},{x:9,y:a+1,w:2,h:4,c:"$hair"},{x:3,y:a+0,w:6,h:1,c:"lighten($hair, 25)",a:.25}]}const Gw={down:[Kd(0),Kd(1),Kd(2),Kd(3)],up:[Qd(0),Qd(1),Qd(2),Qd(3)],right:[ba(0,!0),ba(1,!0),ba(2,!0),ba(3,!0)],left:[ba(0,!1),ba(1,!1),ba(2,!1),ba(3,!1)]},Le="#FAFAF7",Qn="#FFFFFF",Oe="#EDE8E2",st="#DDD6CC",Kc="#1A1A2E",Zf="#2A2A2A",U0="#FFB0B0",Kw=[{x:2,y:0,w:1,h:1,c:Oe},{x:3,y:0,w:1,h:1,c:Le},{x:4,y:0,w:1,h:1,c:Qn},{x:5,y:0,w:1,h:1,c:Le},{x:6,y:0,w:1,h:1,c:Oe},{x:1,y:1,w:1,h:1,c:st},{x:2,y:1,w:1,h:1,c:Le},{x:3,y:1,w:1,h:1,c:Qn},{x:4,y:1,w:1,h:1,c:Le},{x:5,y:1,w:1,h:1,c:Qn},{x:6,y:1,w:1,h:1,c:Le},{x:7,y:1,w:1,h:1,c:st},{x:0,y:2,w:1,h:1,c:st},{x:1,y:2,w:1,h:1,c:Oe},{x:2,y:2,w:1,h:1,c:Le},{x:3,y:2,w:1,h:1,c:Le},{x:4,y:2,w:1,h:1,c:Qn},{x:5,y:2,w:1,h:1,c:Le},{x:6,y:2,w:1,h:1,c:Le},{x:7,y:2,w:1,h:1,c:Oe},{x:8,y:2,w:1,h:1,c:st},{x:1,y:3,w:1,h:1,c:Oe},{x:2,y:3,w:1,h:1,c:Le},{x:3,y:3,w:1,h:1,c:Kc},{x:4,y:3,w:1,h:1,c:Le},{x:5,y:3,w:1,h:1,c:Kc},{x:6,y:3,w:1,h:1,c:Le},{x:7,y:3,w:1,h:1,c:Oe},{x:2,y:4,w:1,h:1,c:Oe},{x:3,y:4,w:1,h:1,c:Le},{x:4,y:4,w:1,h:1,c:Zf},{x:5,y:4,w:1,h:1,c:Le},{x:6,y:4,w:1,h:1,c:Oe},{x:3,y:5,w:1,h:1,c:st},{x:4,y:5,w:1,h:1,c:Oe},{x:5,y:5,w:1,h:1,c:st},{x:2,y:6,w:1,h:1,c:Oe},{x:3,y:6,w:1,h:1,c:Le},{x:4,y:6,w:1,h:1,c:Qn},{x:5,y:6,w:1,h:1,c:Le},{x:6,y:6,w:1,h:1,c:Oe},{x:2,y:7,w:1,h:1,c:st},{x:3,y:7,w:1,h:1,c:Oe},{x:4,y:7,w:1,h:1,c:Le},{x:5,y:7,w:1,h:1,c:Oe},{x:6,y:7,w:1,h:1,c:st}],U$=[{x:3,y:8,w:1,h:1,c:Oe},{x:5,y:8,w:1,h:1,c:Oe},{x:3,y:9,w:1,h:1,c:st},{x:5,y:9,w:1,h:1,c:st}],q$=[{x:2,y:8,w:1,h:1,c:Oe},{x:6,y:8,w:1,h:1,c:Oe},{x:2,y:9,w:1,h:1,c:st},{x:6,y:9,w:1,h:1,c:st}],Qw=[{x:2,y:0,w:1,h:1,c:Oe},{x:3,y:0,w:1,h:1,c:Le},{x:4,y:0,w:1,h:1,c:Qn},{x:5,y:0,w:1,h:1,c:Le},{x:6,y:0,w:1,h:1,c:Oe},{x:1,y:1,w:1,h:1,c:st},{x:2,y:1,w:1,h:1,c:Oe},{x:3,y:1,w:1,h:1,c:Le},{x:4,y:1,w:1,h:1,c:Qn},{x:5,y:1,w:1,h:1,c:Le},{x:6,y:1,w:1,h:1,c:Oe},{x:7,y:1,w:1,h:1,c:st},{x:0,y:2,w:1,h:1,c:st},{x:1,y:2,w:1,h:1,c:Oe},{x:2,y:2,w:1,h:1,c:Le},{x:3,y:2,w:1,h:1,c:Le},{x:4,y:2,w:1,h:1,c:Le},{x:5,y:2,w:1,h:1,c:Le},{x:6,y:2,w:1,h:1,c:Le},{x:7,y:2,w:1,h:1,c:Oe},{x:8,y:2,w:1,h:1,c:st},{x:1,y:3,w:1,h:1,c:st},{x:2,y:3,w:1,h:1,c:Oe},{x:3,y:3,w:1,h:1,c:Le},{x:4,y:3,w:1,h:1,c:Le},{x:5,y:3,w:1,h:1,c:Le},{x:6,y:3,w:1,h:1,c:Oe},{x:7,y:3,w:1,h:1,c:st},{x:2,y:4,w:1,h:1,c:st},{x:3,y:4,w:1,h:1,c:Oe},{x:4,y:4,w:1,h:1,c:Le},{x:5,y:4,w:1,h:1,c:Oe},{x:6,y:4,w:1,h:1,c:st},{x:3,y:5,w:1,h:1,c:st},{x:4,y:5,w:1,h:1,c:Oe},{x:5,y:5,w:1,h:1,c:st},{x:2,y:6,w:1,h:1,c:Oe},{x:3,y:6,w:1,h:1,c:Le},{x:4,y:6,w:1,h:1,c:Le},{x:5,y:6,w:1,h:1,c:Le},{x:6,y:6,w:1,h:1,c:Oe},{x:2,y:7,w:1,h:1,c:st},{x:3,y:7,w:1,h:1,c:Oe},{x:4,y:7,w:1,h:1,c:Le},{x:5,y:7,w:1,h:1,c:Oe},{x:6,y:7,w:1,h:1,c:st},{x:4,y:5,w:1,h:1,c:Le},{x:4,y:4,w:1,h:1,c:Qn}],Y$=[{x:3,y:8,w:1,h:1,c:Oe},{x:5,y:8,w:1,h:1,c:Oe},{x:3,y:9,w:1,h:1,c:st},{x:5,y:9,w:1,h:1,c:st}],P$=[{x:2,y:8,w:1,h:1,c:Oe},{x:6,y:8,w:1,h:1,c:Oe},{x:2,y:9,w:1,h:1,c:st},{x:6,y:9,w:1,h:1,c:st}],Hx=[{x:8,y:0,w:1,h:1,c:Oe},{x:9,y:0,w:1,h:1,c:Le},{x:10,y:0,w:1,h:1,c:Qn},{x:11,y:0,w:1,h:1,c:Le},{x:7,y:1,w:1,h:1,c:st},{x:8,y:1,w:1,h:1,c:Le},{x:9,y:1,w:1,h:1,c:Qn},{x:10,y:1,w:1,h:1,c:Le},{x:11,y:1,w:1,h:1,c:Le},{x:12,y:1,w:1,h:1,c:Oe},{x:0,y:2,w:1,h:1,c:Qn},{x:1,y:2,w:1,h:1,c:Le},{x:3,y:2,w:1,h:1,c:Oe},{x:4,y:2,w:1,h:1,c:Le},{x:5,y:2,w:1,h:1,c:Le},{x:6,y:2,w:1,h:1,c:Le},{x:7,y:2,w:1,h:1,c:Oe},{x:8,y:2,w:1,h:1,c:Le},{x:9,y:2,w:1,h:1,c:Le},{x:10,y:2,w:1,h:1,c:Le},{x:11,y:2,w:1,h:1,c:Le},{x:12,y:2,w:1,h:1,c:Oe},{x:0,y:3,w:1,h:1,c:Oe},{x:1,y:3,w:1,h:1,c:st},{x:3,y:3,w:1,h:1,c:st},{x:4,y:3,w:1,h:1,c:Oe},{x:5,y:3,w:1,h:1,c:Le},{x:6,y:3,w:1,h:1,c:Oe},{x:7,y:3,w:1,h:1,c:st},{x:8,y:3,w:1,h:1,c:Le},{x:9,y:3,w:1,h:1,c:Kc},{x:10,y:3,w:1,h:1,c:Le},{x:11,y:3,w:1,h:1,c:Oe},{x:3,y:4,w:1,h:1,c:st},{x:4,y:4,w:1,h:1,c:Oe},{x:5,y:4,w:1,h:1,c:Le},{x:6,y:4,w:1,h:1,c:Oe},{x:8,y:4,w:1,h:1,c:Oe},{x:9,y:4,w:1,h:1,c:Le},{x:10,y:4,w:1,h:1,c:Zf}],X3=[{x:4,y:5,w:1,h:1,c:Oe},{x:6,y:5,w:1,h:1,c:Oe},{x:8,y:5,w:1,h:1,c:Oe},{x:10,y:5,w:1,h:1,c:Oe},{x:4,y:6,w:1,h:1,c:st},{x:6,y:6,w:1,h:1,c:st},{x:8,y:6,w:1,h:1,c:st},{x:10,y:6,w:1,h:1,c:st}],V3=[{x:3,y:5,w:1,h:1,c:Oe},{x:5,y:5,w:1,h:1,c:Oe},{x:9,y:5,w:1,h:1,c:Oe},{x:11,y:5,w:1,h:1,c:Oe},{x:3,y:6,w:1,h:1,c:st},{x:5,y:6,w:1,h:1,c:st},{x:9,y:6,w:1,h:1,c:st},{x:11,y:6,w:1,h:1,c:st}];function q0(e,t=13){return e.map(n=>({...n,x:t-1-n.x}))}const Zw=q0(Hx),X$=q0(X3),V$=q0(V3),W$={down:[[...Kw,...U$],[...Kw,...q$]],up:[[...Qw,...Y$],[...Qw,...P$]],right:[[...Hx,...X3],[...Hx,...V3]],left:[[...Zw,...X$],[...Zw,...V$]]},G$=[{x:4,y:5,w:1,h:1,c:U0}],qn="#FFD4D4",ui="#FFCCD5",K$=[{x:2,y:0,w:1,h:1,c:st},{x:3,y:0,w:1,h:1,c:Oe},{x:4,y:0,w:1,h:1,c:Le},{x:5,y:0,w:1,h:1,c:Qn},{x:6,y:0,w:1,h:1,c:Oe},{x:7,y:0,w:1,h:1,c:st},{x:1,y:1,w:1,h:1,c:st},{x:2,y:1,w:1,h:1,c:Oe},{x:3,y:1,w:1,h:1,c:Le},{x:4,y:1,w:1,h:1,c:Qn},{x:5,y:1,w:1,h:1,c:Le},{x:6,y:1,w:1,h:1,c:Qn},{x:7,y:1,w:1,h:1,c:Oe},{x:8,y:1,w:1,h:1,c:st},{x:1,y:2,w:1,h:1,c:Oe},{x:2,y:2,w:1,h:1,c:Le},{x:3,y:2,w:1,h:1,c:Kc},{x:4,y:2,w:1,h:1,c:Le},{x:5,y:2,w:1,h:1,c:Le},{x:6,y:2,w:1,h:1,c:Kc},{x:7,y:2,w:1,h:1,c:Le},{x:8,y:2,w:1,h:1,c:Oe},{x:2,y:3,w:1,h:1,c:Oe},{x:3,y:3,w:1,h:1,c:Le},{x:4,y:3,w:1,h:1,c:Zf},{x:5,y:3,w:1,h:1,c:U0},{x:6,y:3,w:1,h:1,c:Le},{x:7,y:3,w:1,h:1,c:Oe},{x:2,y:4,w:1,h:1,c:st},{x:3,y:4,w:1,h:1,c:Oe},{x:4,y:4,w:1,h:1,c:Le},{x:5,y:4,w:1,h:1,c:Le},{x:6,y:4,w:1,h:1,c:Oe},{x:7,y:4,w:1,h:1,c:st},{x:0,y:5,w:1,h:1,c:Oe},{x:1,y:5,w:1,h:1,c:ui},{x:2,y:5,w:1,h:1,c:Le},{x:3,y:5,w:1,h:1,c:qn},{x:4,y:5,w:1,h:1,c:qn},{x:5,y:5,w:1,h:1,c:qn},{x:6,y:5,w:1,h:1,c:qn},{x:7,y:5,w:1,h:1,c:Le},{x:8,y:5,w:1,h:1,c:ui},{x:9,y:5,w:1,h:1,c:Oe},{x:1,y:6,w:1,h:1,c:Oe},{x:2,y:6,w:1,h:1,c:Le},{x:3,y:6,w:1,h:1,c:qn},{x:4,y:6,w:1,h:1,c:ui},{x:5,y:6,w:1,h:1,c:ui},{x:6,y:6,w:1,h:1,c:qn},{x:7,y:6,w:1,h:1,c:Le},{x:8,y:6,w:1,h:1,c:Oe},{x:2,y:7,w:1,h:1,c:Le},{x:3,y:7,w:1,h:1,c:qn},{x:4,y:7,w:1,h:1,c:qn},{x:5,y:7,w:1,h:1,c:qn},{x:6,y:7,w:1,h:1,c:qn},{x:7,y:7,w:1,h:1,c:Le},{x:0,y:8,w:1,h:1,c:Oe},{x:1,y:8,w:1,h:1,c:ui},{x:2,y:8,w:1,h:1,c:st},{x:3,y:8,w:1,h:1,c:Oe},{x:4,y:8,w:1,h:1,c:Le},{x:5,y:8,w:1,h:1,c:Le},{x:6,y:8,w:1,h:1,c:Oe},{x:7,y:8,w:1,h:1,c:st},{x:8,y:8,w:1,h:1,c:ui},{x:9,y:8,w:1,h:1,c:Oe},{x:4,y:9,w:1,h:1,c:Le},{x:5,y:9,w:1,h:1,c:Qn}],Q$=[{x:2,y:0,w:1,h:1,c:st},{x:3,y:0,w:1,h:1,c:Oe},{x:4,y:0,w:1,h:1,c:Le},{x:5,y:0,w:1,h:1,c:Qn},{x:6,y:0,w:1,h:1,c:Oe},{x:7,y:0,w:1,h:1,c:st},{x:1,y:1,w:1,h:1,c:st},{x:2,y:1,w:1,h:1,c:Oe},{x:3,y:1,w:1,h:1,c:Le},{x:4,y:1,w:1,h:1,c:Qn},{x:5,y:1,w:1,h:1,c:Le},{x:6,y:1,w:1,h:1,c:Qn},{x:7,y:1,w:1,h:1,c:Oe},{x:8,y:1,w:1,h:1,c:st},{x:1,y:2,w:1,h:1,c:Oe},{x:2,y:2,w:1,h:1,c:Le},{x:3,y:2,w:1,h:1,c:Oe},{x:4,y:2,w:1,h:1,c:Le},{x:5,y:2,w:1,h:1,c:Le},{x:6,y:2,w:1,h:1,c:Oe},{x:7,y:2,w:1,h:1,c:Le},{x:8,y:2,w:1,h:1,c:Oe},{x:2,y:3,w:1,h:1,c:Oe},{x:3,y:3,w:1,h:1,c:Le},{x:4,y:3,w:1,h:1,c:Zf},{x:5,y:3,w:1,h:1,c:U0},{x:6,y:3,w:1,h:1,c:Le},{x:7,y:3,w:1,h:1,c:Oe},{x:2,y:4,w:1,h:1,c:st},{x:3,y:4,w:1,h:1,c:Oe},{x:4,y:4,w:1,h:1,c:Le},{x:5,y:4,w:1,h:1,c:Le},{x:6,y:4,w:1,h:1,c:Oe},{x:7,y:4,w:1,h:1,c:st},{x:0,y:5,w:1,h:1,c:Oe},{x:1,y:5,w:1,h:1,c:ui},{x:2,y:5,w:1,h:1,c:Le},{x:3,y:5,w:1,h:1,c:qn},{x:4,y:5,w:1,h:1,c:qn},{x:5,y:5,w:1,h:1,c:qn},{x:6,y:5,w:1,h:1,c:qn},{x:7,y:5,w:1,h:1,c:Le},{x:8,y:5,w:1,h:1,c:ui},{x:9,y:5,w:1,h:1,c:Oe},{x:1,y:6,w:1,h:1,c:Oe},{x:2,y:6,w:1,h:1,c:Le},{x:3,y:6,w:1,h:1,c:qn},{x:4,y:6,w:1,h:1,c:ui},{x:5,y:6,w:1,h:1,c:ui},{x:6,y:6,w:1,h:1,c:qn},{x:7,y:6,w:1,h:1,c:Le},{x:8,y:6,w:1,h:1,c:Oe},{x:2,y:7,w:1,h:1,c:Le},{x:3,y:7,w:1,h:1,c:qn},{x:4,y:7,w:1,h:1,c:qn},{x:5,y:7,w:1,h:1,c:qn},{x:6,y:7,w:1,h:1,c:qn},{x:7,y:7,w:1,h:1,c:Le},{x:0,y:8,w:1,h:1,c:Oe},{x:1,y:8,w:1,h:1,c:ui},{x:2,y:8,w:1,h:1,c:st},{x:3,y:8,w:1,h:1,c:Oe},{x:4,y:8,w:1,h:1,c:Le},{x:5,y:8,w:1,h:1,c:Le},{x:6,y:8,w:1,h:1,c:Oe},{x:7,y:8,w:1,h:1,c:st},{x:8,y:8,w:1,h:1,c:ui},{x:9,y:8,w:1,h:1,c:Oe},{x:5,y:9,w:1,h:1,c:Le},{x:6,y:9,w:1,h:1,c:Qn}],Z$=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],J$=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],eO=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],gt=4,fn=28,Kn=2,It=4,Dt=4,Fs=[{wallColor:"#C8B898",baseboardColor:"#6A5840",floorType:"wood"},{wallColor:"#A8B8C8",baseboardColor:"#586878",floorType:"dark"},{wallColor:"#A8C8B0",baseboardColor:"#4A6A50",floorType:"carpet"},{wallColor:"#C8C0A8",baseboardColor:"#7A6A50",floorType:"tile"}];function Y0(e,t,n){const o=e.fy+Math.max(10,Math.floor(e.fh*.18)),c=Math.min(t,n),d=Math.ceil(t/c),m=[],f=c*28,x=e.fx+Math.max(8,Math.floor((e.fw-f)/2));for(let p=0;p<d&&m.length<t;p++){const y=Math.min(c,t-p*c);for(let g=0;g<y;g++)m.push({dx:x+g*28,dy:o+p*28,room:e.id})}return m}function tO(e){const i=Fs[0],a={id:"main",wx:gt+Dt,wy:gt,ww:160-2*(gt+Dt),wh:fn,fx:gt+Dt,fy:gt+fn+Kn,fw:160-2*(gt+Dt),fh:120-gt-fn-Kn-gt,...i},o=Y0(a,Math.min(e,6),3),c=[{id:"s-window-l",type:"window",room:"main",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"s-window-r",type:"window",room:"main",zone:"wall",anchorX:"right",offsetX:-26,offsetY:6,windowW:16,windowH:14},{id:"s-clock",type:"clock",room:"main",zone:"wall",offsetX:Math.floor((160-2*(gt+Dt))/2),offsetY:10}],d=[{id:"s-plant-l",type:"plant",room:"main",zone:"floor",offsetX:4,offsetY:4},{id:"s-plant-r",type:"plant",room:"main",zone:"floor",anchorX:"right",offsetX:-8,offsetY:4}];return{preset:"S",canvasW:160,canvasH:120,rooms:{main:a},desks:o,doors:{},adjacency:{main:[]},corridorY:{main:a.fy+a.fh-12},waypoints:{main:[{x:a.fx+10,y:a.fy+a.fh-14},{x:a.fx+a.fw/2,y:a.fy+a.fh-14},{x:a.fx+a.fw-10,y:a.fy+a.fh-14}]},wallDecorations:c,furniture:d}}function nO(e){const a={id:"exec",wx:gt+Dt,wy:gt,ww:144-gt-Dt-It/2,wh:fn,fx:gt+Dt,fy:gt+fn+Kn,fw:144-gt-Dt-It/2,fh:66,...Fs[0]},o={id:"work",wx:144+It/2+Dt,wy:gt,ww:144-It/2-Dt-gt,wh:fn,fx:144+It/2+Dt,fy:gt+fn+Kn,fw:144-It/2-Dt-gt,fh:66,...Fs[1]},c={id:"meet",wx:gt+Dt,wy:gt+fn+Kn+66+It,ww:144-gt-Dt-It/2,wh:fn,fx:gt+Dt,fy:gt+fn+Kn+66+It+fn+Kn,fw:144-gt-Dt-It/2,fh:70,...Fs[2]},d={id:"comm",wx:144+It/2+Dt,wy:gt+fn+Kn+66+It,ww:144-It/2-Dt-gt,wh:fn,fx:144+It/2+Dt,fy:gt+fn+Kn+66+It+fn+Kn,fw:144-It/2-Dt-gt,fh:70,...Fs[3]},m={exec:a,work:o,meet:c,comm:d},f=[];let x=e;const p=[[a,Math.min(3,x)],[o,0]];p[1][1]=Math.min(3,x-p[0][1]);const y=[[c,0],[d,0]];let g=x-p[0][1]-p[1][1];g>0&&(y[0][1]=Math.min(2,g),g-=y[0][1]),g>0&&(y[1][1]=Math.min(2,g));for(const[D,F]of[...p,...y])F>0&&f.push(...Y0(D,F,3));const w=gt+fn+Kn+66,k=144-It/2,j={exec_work:{id:"exec_work",type:"v",doorY:gt+fn+Kn+20+12,xA:k-2,xB:o.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:gt+fn+Kn+66+It+fn+Kn+20+12,xA:k-2,xB:d.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:gt+Dt+40+14,yA:w-2,yB:c.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+It/2+Dt+40+14,yA:w-2,yB:d.fy+2}},C={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},N={exec:a.fy+52,work:o.fy+48,meet:c.fy+56,comm:d.fy+54},E={exec:[{x:a.fx+6,y:a.fy+52},{x:a.fx+60,y:a.fy+54},{x:a.fx+112,y:a.fy+50},{x:a.fx+50,y:a.fy+52}],work:[{x:o.fx+14,y:o.fy+48},{x:o.fx+44,y:o.fy+48},{x:o.fx+70,y:o.fy+48},{x:o.fx+100,y:o.fy+48}],meet:[{x:c.fx+60,y:c.fy+56},{x:c.fx+30,y:c.fy+54},{x:c.fx+110,y:c.fy+50},{x:c.fx+80,y:c.fy+56}],comm:[{x:d.fx+96,y:d.fy+8},{x:d.fx+60,y:d.fy+54},{x:d.fx+40,y:d.fy+54},{x:d.fx+20,y:d.fy+54}]},A=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0",facility:{id:"theme",label:"THEME",icon:"🎨",color:"#42A5F5",hitW:12,hitH:10}},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10,facility:{id:"settings",label:"SETTINGS",icon:"⚙",color:"#78909C",hitW:10,hitH:10}},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:14,facility:{id:"stats",label:"STATS",icon:"📊",color:"#7E57C2",hitW:16,hitH:8}},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],z=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(a.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:42,facility:{id:"meeting",label:"MEETING",icon:"🏢",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"📚",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"M",canvasW:288,canvasH:208,rooms:m,desks:f,doors:j,adjacency:C,corridorY:N,waypoints:E,wallDecorations:A,furniture:z}}function rO(e){const c={id:"exec",wx:gt+Dt,wy:gt,ww:180-gt-Dt-It/2,wh:fn,fx:gt+Dt,fy:gt+fn+Kn,fw:180-gt-Dt-It/2,fh:82,...Fs[0]},d={id:"work",wx:180+It/2+Dt,wy:gt,ww:180-It/2-Dt-gt,wh:fn,fx:180+It/2+Dt,fy:gt+fn+Kn,fw:180-It/2-Dt-gt,fh:82,...Fs[1]},m=gt+fn+Kn+82,f={id:"meet",wx:gt+Dt,wy:m+It,ww:180-gt-Dt-It/2,wh:fn,fx:gt+Dt,fy:m+It+fn+Kn,fw:180-gt-Dt-It/2,fh:86,...Fs[2]},x={id:"comm",wx:180+It/2+Dt,wy:m+It,ww:180-It/2-Dt-gt,wh:fn,fx:180+It/2+Dt,fy:m+It+fn+Kn,fw:180-It/2-Dt-gt,fh:86,...Fs[3]},p={exec:c,work:d,meet:f,comm:x},y=[];let g=e;const w=[[c,Math.min(5,g)],[d,0]];w[1][1]=Math.min(5,g-w[0][1]);const k=[[f,0],[x,0]];let j=g-w[0][1]-w[1][1];j>0&&(k[0][1]=Math.min(3,j),j-=k[0][1]),j>0&&(k[1][1]=Math.min(3,j));for(const[q,V]of[...w,...k])V>0&&y.push(...Y0(q,V,4));const C=180-It/2,N={exec_work:{id:"exec_work",type:"v",doorY:c.fy+82/2,xA:C-2,xB:d.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:f.fy+86/2,xA:C-2,xB:x.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:c.fx+54,yA:m-2,yB:f.fy+2},work_comm:{id:"work_comm",type:"h",doorX:d.fx+54,yA:m-2,yB:x.fy+2}},E={exec:[{room:"work",door:"exec_work",side:"A"},{room:"meet",door:"exec_meet",side:"A"}],work:[{room:"exec",door:"exec_work",side:"B"},{room:"comm",door:"work_comm",side:"A"}],meet:[{room:"exec",door:"exec_meet",side:"B"},{room:"comm",door:"meet_comm",side:"A"}],comm:[{room:"work",door:"work_comm",side:"B"},{room:"meet",door:"meet_comm",side:"B"}]},A={exec:c.fy+82-12,work:d.fy+82-12,meet:f.fy+86-12,comm:x.fy+86-12},z={exec:[{x:c.fx+10,y:A.exec},{x:c.fx+c.fw/2,y:A.exec},{x:c.fx+c.fw-10,y:A.exec}],work:[{x:d.fx+10,y:A.work},{x:d.fx+d.fw/2,y:A.work},{x:d.fx+d.fw-10,y:A.work}],meet:[{x:f.fx+10,y:A.meet},{x:f.fx+f.fw/2,y:A.meet},{x:f.fx+f.fw-10,y:A.meet}],comm:[{x:x.fx+10,y:A.comm},{x:x.fx+x.fw/2,y:A.comm},{x:x.fx+x.fw-10,y:A.comm}]},D=[{id:"exec-window-1",type:"window",room:"exec",zone:"wall",offsetX:10,offsetY:6,windowW:16,windowH:14},{id:"exec-picture-1",type:"picture",room:"exec",zone:"wall",offsetX:34,offsetY:8,pictureColor:"#1565C0",facility:{id:"theme",label:"THEME",icon:"🎨",color:"#42A5F5",hitW:12,hitH:10}},{id:"exec-picture-2",type:"picture",room:"exec",zone:"wall",offsetX:48,offsetY:8,pictureColor:"#E65100"},{id:"exec-clock",type:"clock",room:"exec",zone:"wall",offsetX:64,offsetY:10,facility:{id:"settings",label:"SETTINGS",icon:"⚙",color:"#78909C",hitW:10,hitH:10}},{id:"exec-shelf",type:"shelf",room:"exec",zone:"wall",offsetX:78,offsetY:14,facility:{id:"stats",label:"STATS",icon:"📊",color:"#7E57C2",hitW:16,hitH:8}},{id:"exec-window-2",type:"window",room:"exec",zone:"wall",offsetX:104,offsetY:6,windowW:16,windowH:14},{id:"work-whiteboard",type:"whiteboard",room:"work",zone:"wall",offsetX:6,offsetY:4},{id:"work-window-1",type:"window",room:"work",zone:"wall",offsetX:50,offsetY:6,windowW:16,windowH:14},{id:"work-window-2",type:"window",room:"work",zone:"wall",offsetX:92,offsetY:6,windowW:16,windowH:14},{id:"meet-bulletin",type:"bulletin-board",room:"meet",zone:"wall",offsetX:6,offsetY:4,facility:{id:"bulletin",label:"BULLETIN",icon:"📋",color:"#F59E0B",hitW:22,hitH:16}},{id:"meet-picture",type:"picture",room:"meet",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#10B981"},{id:"meet-window",type:"window",room:"meet",zone:"wall",offsetX:80,offsetY:6,windowW:16,windowH:14},{id:"meet-shelf",type:"shelf",room:"meet",zone:"wall",offsetX:102,offsetY:18},{id:"comm-screen",type:"screen",room:"comm",zone:"wall",offsetX:6,offsetY:6,facility:{id:"decisions",label:"DECISIONS",icon:"📜",color:"#EF4444",hitW:16,hitH:12}},{id:"comm-picture",type:"picture",room:"comm",zone:"wall",offsetX:28,offsetY:8,pictureColor:"#d4956a"},{id:"comm-window",type:"window",room:"comm",zone:"wall",offsetX:76,offsetY:6,windowW:16,windowH:14},{id:"comm-clock",type:"clock",room:"comm",zone:"wall",offsetX:98,offsetY:10},{id:"comm-shelf",type:"shelf",room:"comm",zone:"wall",offsetX:108,offsetY:18}],F=[{id:"exec-bookshelf",type:"bookshelf",room:"exec",zone:"floor",offsetX:2,offsetY:4},{id:"exec-plant-r",type:"plant",room:"exec",zone:"floor",anchorX:"right",offsetX:-10,offsetY:4},{id:"exec-plant-c",type:"plant",room:"exec",zone:"floor",offsetX:Math.floor(c.fw/2),offsetY:4},{id:"work-plant-1",type:"plant",room:"work",zone:"floor",offsetX:36,offsetY:4},{id:"work-plant-2",type:"plant",room:"work",zone:"floor",offsetX:80,offsetY:4},{id:"meet-plant",type:"plant",room:"meet",zone:"floor",anchorX:"right",offsetX:-12,offsetY:4},{id:"meet-table",type:"meeting-table",room:"meet",zone:"floor",offsetX:10,offsetY:42,facility:{id:"meeting",label:"MEETING",icon:"🏢",color:"#3B82F6",hitW:44,hitH:40}},{id:"comm-coffee-machine",type:"coffee-machine",room:"comm",zone:"floor",anchorX:"right",offsetX:-30,offsetY:4,condition:"no-desks"},{id:"comm-plant-1",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:4,condition:"no-desks"},{id:"comm-bookshelf",type:"bookshelf",room:"comm",zone:"floor",anchorX:"right",offsetX:-26,offsetY:16,accent:"#10B981",condition:"no-desks",facility:{id:"knowledge",label:"KNOWLEDGE",icon:"📚",color:"#10B981",hitW:26,hitH:24}},{id:"comm-sofa",type:"sofa",room:"comm",zone:"floor",offsetX:44,offsetY:30,condition:"no-desks"},{id:"comm-coffee-table",type:"coffee-table",room:"comm",zone:"floor",offsetX:50,offsetY:50,condition:"no-desks"},{id:"comm-plant-2",type:"plant",room:"comm",zone:"floor",offsetX:38,offsetY:50,condition:"no-desks"}];return{preset:"L",canvasW:360,canvasH:260,rooms:p,desks:y,doors:N,adjacency:E,corridorY:A,waypoints:z,wallDecorations:D,furniture:F}}const iO=2;function W3(e,t,n){return n||(t?t==="L"&&e<=12-iO?"M":t==="M"&&e>12?"L":t:e<=12?"M":"L")}function G3(e,t){switch(t??W3(e)){case"S":return tO(e);case"M":return nO(e);case"L":return rO(e)}}function sO(e,t){if(!t||Object.keys(t).length===0)return e;const n=i=>i.map(a=>{const o=t[a.id];return o?{...a,offsetX:o.offsetX,offsetY:o.offsetY}:a});return{...e,wallDecorations:n(e.wallDecorations),furniture:n(e.furniture)}}function aO(e,t){if(t)for(const[n,i]of Object.entries(t))e[n]&&(e[n]={...e[n],dx:i.dx,dy:i.dy})}function Jw(e,t){if(!t||t.length===0)return e;const n=new Set(t);return{...e,wallDecorations:e.wallDecorations.filter(i=>!n.has(i.id)),furniture:e.furniture.filter(i=>!n.has(i.id))}}function lO(e,t){if(!t||t.length===0)return e;const n=[],i=[];for(const a of t)a.zone==="wall"?n.push(a):i.push(a);return{...e,wallDecorations:[...e.wallDecorations,...n],furniture:[...e.furniture,...i]}}let _c;function oO(e){_c=e}function W(e,t,n,i,a,o){e=Math.round(e),t=Math.round(t),!(o!==void 0&&o<.01)&&(o!==void 0&&o!==1&&(_c.globalAlpha=o),_c.fillStyle=a,_c.fillRect(e,t,n,i),o!==void 0&&o!==1&&(_c.globalAlpha=1))}function xt(e,t,n,i){W(e,t,1,1,n,i)}let ff=1;function No(e){ff=e}function Qi(){return ff=ff*16807%2147483647,(ff&65535)/65535}function K3(e){const t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255,a=Math.max(t,n,i),o=Math.min(t,n,i);let c=0,d=0;const m=(a+o)/2;if(a!==o){const f=a-o;d=m>.5?f/(2-a-o):f/(a+o),a===t?c=((n-i)/f+(n<i?6:0))/6:a===n?c=((i-t)/f+2)/6:c=((t-n)/f+4)/6}return[c*360,d*100,m*100]}function Q3(e,t,n){e=(e%360+360)%360,t=Math.max(0,Math.min(100,t))/100,n=Math.max(0,Math.min(100,n))/100;const i=t*Math.min(n,1-n),a=c=>{const d=(c+e/30)%12;return n-i*Math.max(-1,Math.min(d-3,9-d,1))},o=c=>Math.round(c*255).toString(16).padStart(2,"0");return"#"+o(a(0))+o(a(8))+o(a(4))}function es(e,t=1){const[n,i,a]=K3(e);return Q3(n+15*t,Math.min(100,i+8),a-12*t)}function En(e,t=1){const[n,i,a]=K3(e);return Q3(n-10*t,i-3,a+10*t)}const Gn={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},Xr={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},Yi={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},di="#100A06";function cO(e,t,n=14,i=12){W(e,t,n,i,"#4A3828"),W(e+1,t+1,n-2,i-2,"#5A4838"),W(e+2,t+2,n-4,i-4,"#4A7098"),W(e+2,t+2,n-4,Math.floor((i-4)/2),"#6A90B8",.35);const a=Math.floor(n/2);W(e+a,t+1,1,i-2,"#4A3828"),W(e+1,t+Math.floor(i/2),n-2,1,"#4A3828",.5),xt(e+3,t+3,"#8AB8E8",.35),xt(e+a+2,t+3,"#8AB8E8",.25),W(e-1,t+i,n+2,2,"#5A4838"),W(e-1,t+i,n+2,1,En("#5A4838",.5),.35)}function uO(e,t,n){W(e,t,10,8,"#3A2818"),W(e+1,t+1,8,6,n),W(e+2,t+2,4,3,En(n,1.2),.3),xt(e+3,t+2,En(n,2),.25)}function dO(e,t){W(e,t,7,7,"#3A2818"),W(e+1,t+1,5,5,"#F0EDE5"),xt(e+3,t+1,"#AAA"),xt(e+3,t+5,"#AAA"),xt(e+1,t+3,"#AAA"),xt(e+5,t+3,"#AAA"),xt(e+3,t+3,"#222"),W(e+3,t+1,1,2,"#333"),xt(e+4,t+3,"#D32F2F")}function fO(e,t){W(e,t,26,16,"#586878"),W(e+1,t+1,24,13,"#ECEFF1"),W(e+1,t+1,24,1,"#F5F5F5",.4),W(e+3,t+3,14,1,"#1565C0",.6),W(e+3,t+5,18,1,"#333",.2),W(e+3,t+7,12,1,"#D32F2F",.35),W(e+3,t+9,16,1,"#333",.15),W(e+1,t+14,24,2,"#708898"),W(e+3,t+14,3,1,"#D32F2F"),W(e+7,t+14,3,1,"#1565C0"),W(e+11,t+14,3,1,"#2E7D32")}function hO(e,t){W(e,t,22,16,"#6A5030"),W(e+1,t+1,20,14,"#C4A66A"),No(88);for(let n=0;n<14;n++)for(let i=0;i<20;i++)Qi()>.5&&xt(e+1+i,t+1+n,Qi()>.5?"#B89858":"#D4B87A",.18);W(e+2,t+2,5,4,"#FFF176"),W(e+8,t+2,5,4,"#90CAF9"),W(e+14,t+3,5,4,"#CE93D8"),W(e+3,t+8,7,4,"#C8E6C9"),W(e+11,t+8,8,4,"#F8BBD0"),xt(e+4,t+2,"#E53935"),xt(e+10,t+2,"#1E88E5"),xt(e+16,t+3,"#FF9800")}function mO(e,t){W(e,t,20,3,"#5A4030"),W(e,t,20,1,En("#5A4030",.5),.35),W(e,t+2,20,1,es("#5A4030",.5),.3),W(e+2,t-4,3,4,"#E53935"),W(e+2,t-4,3,1,En("#E53935",1),.3),W(e+6,t-3,2,3,"#1E88E5"),W(e+9,t-5,4,5,"#43A047"),W(e+14,t-3,3,3,"#FFD54F"),xt(e+15,t-3,"#FFF176",.4)}function pO(e,t){W(e,t,16,12,"#1E1E28"),W(e+1,t+1,14,9,"#0C1420"),W(e+2,t+2,12,1,"#EF4444",.6),xt(e+2,t+4,"#4CAF50"),W(e+4,t+4,7,1,"#8b949e",.4),xt(e+2,t+6,"#FF9800"),W(e+4,t+6,5,1,"#8b949e",.3),xt(e+2,t+8,"#42A5F5"),W(e+4,t+8,8,1,"#8b949e",.25),W(e+7,t+10,2,2,"#1E1E28"),W(e+5,t+11,6,1,"#586878")}function xO(e,t,n){W(e+2,t+20,22,2,di,.15),W(e,t,22,20,Xr.deep),W(e+1,t+1,20,18,Xr.base),W(e,t,22,1,Xr.hi,.35),W(e,t,1,20,Xr.hi,.2);for(const o of[6,12])W(e+1,t+o,20,2,Xr.sh),W(e+1,t+o,20,1,Xr.hi,.2);const i=["#E53935","#1E88E5","#43A047","#8E24AA","#FB8C00","#00897B","#5C6BC0"];let a=e+2;for(let o=0;o<5;o++){const c=2+o%2;W(a,t+1,c,5,i[o]),W(a,t+1,c,1,En(i[o],1),.35),a+=c+1}a=e+2;for(let o=0;o<4;o++)W(a,t+7,4,5,i[o+3]),W(a,t+7,4,1,En(i[o+3],1),.25),a+=5;W(e+2,t+14,4,4,"#FFD54F"),W(e+8,t+14,7,4,"#90CAF9"),n&&W(e,t-1,22,1,n,.7)}function gO(e,t){W(e+2,t+11,6,2,di,.1),W(e+2,t+8,6,4,"#8B5E3C"),W(e+1,t+7,8,2,es("#A06E48",.3)),W(e+2,t+7,6,1,En("#A06E48",.5),.4),W(e+1,t+3,3,4,"#2E7D32"),W(e+5,t+2,3,4,"#2E7D32"),W(e+2,t+1,4,4,"#43A047"),W(e+3,t+0,3,3,"#66BB6A"),xt(e+4,t,"#81C784"),xt(e+3,t+1,"#A5D6A7",.4)}function yO(e,t){il(e+4,t-4,"down"),il(e+16,t-4,"down"),il(e+28,t-4,"down"),W(e+3,t+24,34,3,di,.15),W(e,t+2,36,18,Gn.deep),W(e+1,t+3,34,16,Gn.base),W(e+1,t+3,34,1,Gn.hi,.35);for(let n=0;n<14;n+=3)W(e+1,t+4+n,34,1,es(Gn.base,.2),.08);W(e,t+20,36,4,Gn.deep),W(e+1,t+21,34,2,Gn.sh),W(e+6,t+7,10,6,"#1A1A24"),W(e+7,t+8,8,4,"#0C1420"),W(e+8,t+9,4,1,"#2A6898",.4),W(e+20,t+8,6,4,"#F0F0F0"),W(e+15,t+7,3,3,"#ECEFF1"),xt(e+16,t+8,"#795548"),il(e+4,t+24,"up"),il(e+16,t+24,"up"),il(e+28,t+24,"up")}function bO(e,t){W(e+2,t+16,36,3,di,.15),W(e,t,36,5,"#5D4037"),W(e+1,t+1,34,3,"#6D4C41"),W(e+1,t+1,34,1,En("#6D4C41",.5),.3),W(e,t+5,36,8,"#5D4037"),W(e+2,t+6,15,6,"#6D4C41"),W(e+3,t+6,13,1,En("#6D4C41",.5),.35),W(e+19,t+6,15,6,"#6D4C41"),W(e+20,t+6,13,1,En("#6D4C41",.5),.35),W(e+17,t+6,2,6,"#5D4037"),W(e,t+13,36,3,es("#5D4037",1)),W(e-2,t+2,3,12,"#5D4037"),W(e+35,t+2,3,12,"#5D4037"),W(e+4,t+7,6,4,"#FF8A65"),W(e+5,t+7,4,1,En("#FF8A65",1),.35)}function vO(e,t){W(e+2,t+10,22,2,di,.12),W(e,t,22,8,Xr.deep),W(e+1,t+1,20,6,Xr.base),W(e+1,t+1,20,1,Xr.hi,.3),W(e,t+8,22,2,Xr.sh),W(e+3,t+2,6,4,"#F0F0F0"),W(e+13,t+3,3,3,"#ECEFF1"),xt(e+14,t+4,"#795548")}function wO(e,t){W(e+1,t+14,10,2,di,.12),W(e,t,10,14,"#546E7A"),W(e,t,10,1,En("#546E7A",1),.35),W(e+1,t+1,8,3,"#78909C"),W(e+1,t+5,8,4,"#37474F"),xt(e+2,t+6,"#EF5350"),xt(e+4,t+6,"#66BB6A"),W(e+2,t+11,4,2,"#ECEFF1")}function kO(e,t){W(e+2,t+18,28,3,di,.12),W(e,t,28,18,"#37474F"),W(e+1,t+1,26,15,"#0D47A1"),W(e+2,t+2,24,13,"#1565C0"),W(e+2,t+2,24,4,"#1976D2",.4),W(e+2,t+12,24,3,"#F9A825",.35),W(e+4,t+8,2,5,"#2E7D32"),W(e+6,t+9,2,4,"#43A047"),W(e+20,t+7,2,6,"#2E7D32"),W(e+22,t+8,2,5,"#388E3C"),W(e+9,t+5,4,2,"#FF8A65"),xt(e+12,t+5,"#FF5722"),W(e+16,t+8,3,2,"#FFD54F"),xt(e+15,t+8,"#FFC107"),xt(e+13,t+3,"#90CAF9",.5),xt(e+14,t+4,"#BBDEFB",.35),xt(e+8,t+3,"#BBDEFB",.3),W(e,t+16,28,2,"#455A64"),W(e+1,t+16,26,1,En("#455A64",.5),.3)}function SO(e,t){W(e,t,24,10,"#1A1A2E"),W(e+2,t+1,20,8,"#E040FB",.15),W(e+3,t+2,4,6,"#E040FB",.7),W(e+4,t+3,2,4,"#1A1A2E"),W(e+8,t+2,1,6,"#00E5FF",.7),W(e+8,t+2,4,1,"#00E5FF",.7),W(e+8,t+4,4,1,"#00E5FF",.7),W(e+11,t+2,1,3,"#00E5FF",.7),W(e+13,t+2,1,6,"#E040FB",.7),W(e+13,t+2,4,1,"#E040FB",.7),W(e+13,t+4,3,1,"#E040FB",.7),W(e+13,t+7,4,1,"#E040FB",.7),W(e+18,t+2,1,6,"#00E5FF",.7),W(e+21,t+2,1,6,"#00E5FF",.7),W(e+19,t+3,1,2,"#00E5FF",.5),W(e+20,t+5,1,2,"#00E5FF",.5)}function jO(e,t){W(e+2,t+28,16,3,di,.15),W(e,t,16,28,"#1A237E"),W(e+1,t+1,14,3,"#283593"),W(e+2,t+4,12,10,"#0D1117"),W(e+3,t+5,10,8,"#1B5E20"),W(e+5,t+6,2,2,"#4CAF50"),W(e+9,t+8,2,2,"#FF5722"),W(e+7,t+10,3,1,"#FFD54F"),xt(e+6,t+7,"#81C784"),W(e+1,t+14,14,6,"#1A237E"),W(e+2,t+15,4,4,"#212121"),xt(e+4,t+16,"#F44336"),xt(e+9,t+16,"#F44336"),xt(e+11,t+16,"#2196F3"),xt(e+10,t+18,"#FFEB3B"),W(e,t+20,16,8,"#0D47A1"),W(e+1,t+21,14,6,"#1565C0"),W(e,t+4,1,14,"#FF4081",.4),W(e+15,t+4,1,14,"#FF4081",.4)}function CO(e,t){W(e+2,t+24,20,3,di,.15),W(e,t,20,24,"#4E342E"),W(e+1,t+1,18,22,"#5D4037"),W(e+2,t+1,16,4,"#FF6F00"),W(e+3,t+2,14,2,"#FF8F00",.6),W(e+2,t+5,16,10,"#1A1A2E"),W(e+3,t+6,14,8,"#212121"),W(e+4,t+7,4,4,"#333"),W(e+5,t+8,2,2,"#E53935"),W(e+10,t+7,4,4,"#333"),W(e+11,t+8,2,2,"#1E88E5"),W(e+3,t+16,14,6,"#3E2723");for(let n=0;n<7;n++)W(e+4+n*2,t+17,1,4,"#5D4037",.5);W(e+1,t+5,18,1,"#FFD54F",.5),W(e+1,t+15,18,1,"#FFD54F",.5)}function NO(e,t){W(e+2,t+22,22,2,di,.12),W(e,t,22,22,Xr.deep),W(e+1,t+1,20,20,"#37474F"),W(e+2,t+2,18,18,"#546E7A",.3),W(e+1,t+10,20,1,Xr.base),W(e+1,t+10,20,1,Xr.hi,.2),W(e+4,t+3,4,5,"#FFD54F"),W(e+5,t+4,2,3,"#FFC107"),W(e+4,t+7,4,1,"#FFA000"),xt(e+5,t+3,"#FFF176",.5),W(e+13,t+4,4,4,"#B0BEC5"),W(e+14,t+3,2,1,"#CFD8DC"),xt(e+14,t+5,"#ECEFF1",.6),W(e+5,t+12,3,3,"#A1887F"),W(e+6,t+11,1,1,"#D7CCC8"),W(e+12,t+12,6,4,"#5D4037"),W(e+13,t+13,4,2,"#FFD54F",.6),W(e+2,t+2,2,18,"#fff",.08)}function EO(e,t){W(e+2,t+16,26,3,di,.18),W(e,t,26,10,Gn.deep),W(e+1,t+1,24,8,Gn.base),W(e+1,t+2,24,1,Gn.hi,.2),W(e+1,t+4,24,1,es(Gn.base,.2),.1),W(e+1,t+6,24,1,Gn.hi,.15),W(e+1,t+1,24,1,Gn.hi,.4),W(e+1,t+1,1,8,Gn.hi,.2),W(e,t+10,26,5,Gn.deep),W(e+1,t+11,24,3,Gn.sh),W(e+1,t+10,24,1,es(Gn.base,1.5),.4),W(e+1,t+14,24,1,Gn.base,.15),W(e+2,t+12,10,1,Gn.deep,.4),W(e+14,t+12,10,1,Gn.deep,.4),xt(e+7,t+11,"#C8D0D8",.6),xt(e+19,t+11,"#C8D0D8",.6),W(e+6,t-5,14,7,"#1E1E28"),W(e+7,t-4,12,5,"#0C1420"),W(e+8,t-3,5,1,"#2A6898",.6),W(e+8,t-2,8,1,"#1A3858",.4),W(e+8,t-1,3,1,"#2A6898",.35),xt(e+7,t-4,"#4A98D8",.25),xt(e+12,t+1,"#4CAF50",.4),W(e+12,t+2,2,3,"#586878"),W(e+10,t+4,6,1,"#8898A8"),W(e+6,t+4,12,4,"#222228"),W(e+6,t+4,12,1,"#333338",.4);for(let n=0;n<5;n++)xt(e+7+n*2,t+5,"#444",.6),xt(e+7+n*2,t+6,"#3A3A3E",.4);W(e+20,t+5,3,4,"#333338"),W(e+20,t+5,3,1,"#444448"),W(e+1,t+3,4,4,"#F0EDE8"),W(e+1,t+3,4,1,"#F8F6F2"),xt(e+2,t+5,"#6D4C41")}function il(e,t,n){W(e+1,t+9,10,2,di,.1),xt(e+5,t+9,"#1E1E22"),xt(e+1,t+10,"#1A1A1E"),xt(e+9,t+10,"#1A1A1E"),xt(e+3,t+11,"#1A1A1E"),xt(e+7,t+11,"#1A1A1E"),W(e+1,t+2,8,6,Yi.base),W(e+2,t+3,6,4,Yi.hi,.35),W(e+2,t+3,6,1,En(Yi.hi,.5),.25),W(e+1,t+7,8,1,Yi.deep),n==="up"?(W(e,t+7,10,3,Yi.deep),W(e+1,t+8,8,1,Yi.sh)):(W(e,t-1,10,3,Yi.deep),W(e+1,t,8,1,Yi.sh)),W(e,t+3,1,4,Yi.sh),W(e+9,t+3,1,4,Yi.sh)}const Z3={bookshelf:(e,t,n)=>xO(e,t,n.accent),plant:(e,t)=>gO(e,t),"meeting-table":(e,t)=>yO(e,t),sofa:(e,t)=>bO(e,t),"coffee-table":(e,t)=>vO(e,t),"coffee-machine":(e,t)=>wO(e,t),window:(e,t,n)=>cO(e,t,n.windowW??16,n.windowH??14),picture:(e,t,n)=>uO(e,t,n.pictureColor??"#1565C0"),clock:(e,t)=>dO(e,t),whiteboard:(e,t)=>fO(e,t),"bulletin-board":(e,t)=>hO(e,t),shelf:(e,t)=>mO(e,t),screen:(e,t)=>pO(e,t),aquarium:(e,t)=>kO(e,t),"neon-sign":(e,t)=>SO(e,t),arcade:(e,t)=>jO(e,t),jukebox:(e,t)=>CO(e,t),"trophy-case":(e,t)=>NO(e,t)};function vo(e,t){const n=e.zone==="wall"?t.wx:t.fx,i=e.zone==="wall"?t.wy:t.fy;return{x:e.anchorX==="right"?(e.zone==="wall"?t.wx+t.ww:t.fx+t.fw)+e.offsetX:n+e.offsetX,y:i+e.offsetY}}function AO(e){for(const t of e.wallDecorations){const n=e.rooms[t.room];if(!n)continue;const{x:i,y:a}=vo(t,n),o=Z3[t.type];o&&o(i,a,t)}}function DO(e,t,n){for(const i of e.furniture){const a=e.rooms[i.room];if(!a||i.condition==="no-desks"&&n.has(i.room))continue;const{x:o,y:c}=vo(i,a),d=Z3[i.type];d&&t.push({y:c,draw:()=>d(o,c,i)})}}function sl(e){const t=[],n=[...e.wallDecorations,...e.furniture];for(const i of n){if(!i.facility)continue;const a=e.rooms[i.room];if(!a)continue;const{x:o,y:c}=vo(i,a);t.push({id:i.facility.id,label:i.facility.label,icon:i.facility.icon,color:i.facility.color,dx:o,dy:c,pw:i.facility.hitW,ph:i.facility.hitH})}return t}const TO={bookshelf:{w:22,h:20},plant:{w:10,h:12},"meeting-table":{w:36,h:28},sofa:{w:38,h:16},"coffee-table":{w:22,h:10},"coffee-machine":{w:10,h:14},window:{w:16,h:14},picture:{w:10,h:8},clock:{w:7,h:7},whiteboard:{w:26,h:16},"bulletin-board":{w:22,h:16},shelf:{w:20,h:8},screen:{w:16,h:12},aquarium:{w:28,h:18},"neon-sign":{w:24,h:10},arcade:{w:16,h:28},jukebox:{w:20,h:24},"trophy-case":{w:22,h:22}};function Ux(e){return TO[e]??{w:16,h:16}}function Xp(e,t,n,i){for(let a=e.furniture.length-1;a>=0;a--){const o=e.furniture[a],c=e.rooms[o.room];if(!c||o.condition==="no-desks"&&i.has(o.room))continue;const{x:d,y:m}=vo(o,c),f=Ux(o.type);if(t>=d&&t<=d+f.w&&n>=m&&n<=m+f.h)return o.id}for(let a=e.wallDecorations.length-1;a>=0;a--){const o=e.wallDecorations[a],c=e.rooms[o.room];if(!c)continue;const{x:d,y:m}=vo(o,c),f=Ux(o.type);if(t>=d&&t<=d+f.w&&n>=m&&n<=m+f.h)return o.id}return null}function e2(e,t,n,i,a){const c=[...t.wallDecorations,...t.furniture].find(p=>p.id===n);if(!c||c.condition==="no-desks"&&a.has(c.room))return;const d=t.rooms[c.room];if(!d)return;const{x:m,y:f}=vo(c,d),x=Ux(c.type);e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(m-1,f-1,x.w+2,x.h+2),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(m-.5,f-.5,x.w+1,x.h+1),e.restore()}function t2(e,t,n,i){e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(t-1,n-1,28,42),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t-.5,n-.5,27,41),e.restore()}function n2(e,t,n){for(const[i,a]of Object.entries(e))if(t>=a.dx&&t<=a.dx+26&&n>=a.dy&&n<=a.dy+40)return i;return null}const r2=[{type:"plant",zone:"floor",label:"Plant",icon:"🪴",price:0},{type:"clock",zone:"wall",label:"Clock",icon:"🕐",price:0},{type:"bookshelf",zone:"floor",label:"Bookshelf",icon:"📚",price:500},{type:"picture",zone:"wall",label:"Picture",icon:"🖼️",price:500},{type:"shelf",zone:"wall",label:"Shelf",icon:"📦",price:800},{type:"window",zone:"wall",label:"Window",icon:"🪟",price:1e3},{type:"sofa",zone:"floor",label:"Sofa",icon:"🛋️",price:1500},{type:"coffee-table",zone:"floor",label:"Coffee Table",icon:"☕",price:1500},{type:"coffee-machine",zone:"floor",label:"Coffee Machine",icon:"☕",price:2e3},{type:"meeting-table",zone:"floor",label:"Meeting Table",icon:"🪑",price:3e3},{type:"whiteboard",zone:"wall",label:"Whiteboard",icon:"📋",price:3e3},{type:"screen",zone:"wall",label:"Screen",icon:"🖥️",price:5e3},{type:"aquarium",zone:"floor",label:"Aquarium",icon:"🐠",price:5e3},{type:"neon-sign",zone:"wall",label:"Neon Sign",icon:"💡",price:3e3},{type:"arcade",zone:"floor",label:"Arcade",icon:"🕹️",price:8e3},{type:"jukebox",zone:"floor",label:"Jukebox",icon:"🎵",price:6e3},{type:"trophy-case",zone:"floor",label:"Trophy Case",icon:"🏆",price:7e3}],Zd=16,_O=4,nl=4,hf=2,Gt=4,ka=4;let rt=G3(7);const Rf={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},i2={ceo:{en:["Boss?","What's up?","Time for a meeting?","Got any ideas?","How's everyone doing?"],ko:["대표님?","무슨 일이신가요?","회의 시간이신가요?","좋은 아이디어 있으시면 말씀해주세요.","다들 잘하고 있나요?"],ja:["社長?","何かありますか?","会議の時間ですか?","良いアイデアがあれば教えてください。","みんな元気ですか?"]},cto:{en:["Need anything?","Tech question?","Reviewing architecture.","Deploy in a moment.","Want me to look at the code?"],ko:["뭐 필요하신 거 있으세요?","기술 관련 질문이신가요?","아키텍처 리뷰 중이에요.","배포는 조금만 기다려주세요.","코드 봐드릴까요?"],ja:["何かお手伝いしましょうか?","技術的な質問ですか?","アーキテクチャレビュー中です。","デプロイはもう少しお待ちください。","コード見ましょうか?"]},cbo:{en:["Business question?","Reviewing revenue model.","Want to see market research?","Analyzing competitors.","Can I help?"],ko:["비즈니스 관련 얘기신가요?","수익 모델 검토 중이에요.","시장 조사 결과 보실래요?","경쟁사 분석 중입니다.","뭔가 도와드릴까요?"],ja:["ビジネスの話ですか?","収益モデルを検討中です。","市場調査の結果を見ますか?","競合分析中です。","何かお手伝いしましょうか?"]},pm:{en:["Curious about progress?","Updating the roadmap.","Assigning tasks.","Need to re-prioritize?","Preparing sprint review."],ko:["프로젝트 진행 상황 궁금하신가요?","로드맵 업데이트 중이에요.","태스크 할당 중입니다.","우선순위 조정이 필요할까요?","스프린트 리뷰 준비 중이에요."],ja:["進捗が気になりますか?","ロードマップを更新中です。","タスクを割り当て中です。","優先順位の調整が必要ですか?","スプリントレビューの準備中です。"]},engineer:{en:["Working on it!","Fixing a bug.","Need a code review?","Writing tests.","Pushing a PR."],ko:["일하고 있어요!","버그 수정 중입니다.","코드 리뷰 필요하신가요?","테스트 작성 중이에요.","PR 올리고 있어요."],ja:["作業中です!","バグ修正中です。","コードレビュー必要ですか?","テスト書いてます。","PR出してます。"]},designer:{en:["Got design feedback?","Working on mockups.","Thinking about UI improvements.","Picking colors...","Want to see the prototype?"],ko:["디자인 피드백 있으신가요?","목업 작업 중이에요.","UI 개선안 생각 중입니다.","컬러 팔레트 고민 중이에요.","프로토타입 보여드릴까요?"],ja:["デザインのフィードバックありますか?","モックアップ作業中です。","UI改善案を考えています。","カラーパレットを検討中です。","プロトタイプ見せましょうか?"]},qa:{en:["Testing in progress.","Found a bug!","Writing test cases.","Running regression tests.","Quality check in progress."],ko:["테스트 중이에요.","버그 발견했어요!","테스트 케이스 작성 중입니다.","회귀 테스트 진행 중이에요.","품질 체크 중입니다."],ja:["テスト中です。","バグ見つけました!","テストケース作成中です。","回帰テスト実行中です。","品質チェック中です。"]},"data-analyst":{en:["Analyzing data.","Preparing a report.","Want to check the dashboard?","Tracking metrics.","Found an insight!"],ko:["데이터 분석 중이에요.","리포트 준비 중입니다.","대시보드 확인해보실래요?","지표 추적 중이에요.","인사이트 발견했어요!"],ja:["データ分析中です。","レポート準備中です。","ダッシュボード確認しますか?","指標追跡中です。","インサイト発見しました!"]},default:{en:["Hello!","How can I help?","Working hard.","Have a great day!"],ko:["안녕하세요!","무엇을 도와드릴까요?","열심히 일하고 있어요.","좋은 하루 되세요!"],ja:["こんにちは!","何かお手伝いしましょうか?","頑張って仕事してます。","良い一日を!"]}};function MO(e,t){const n=i2[e]||i2.default;return n[t]||n.en||n.default||[]}let Xi=sl(rt);function J3(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function eS(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let _n={};function FO(e){const t={};for(let n=0;n<e.length&&n<rt.desks.length;n++)t[e[n]]=rt.desks[n];return t}let Ze,cr=null,al=null,Ts=!1,ki=null,Yr=null,tS=0,mr=null,Wn=null,va=null,Pi=null,Vp=900;function RO(e,t){const{wx:n,wy:i,ww:a,wh:o,wallColor:c,baseboardColor:d}=e,m=es(c,.5),f=En(c,.5),x=[];if(t){const p=t.x-n,y=t.w;p>0&&x.push({sx:n,sw:p}),p+y<a&&x.push({sx:t.x+y,sw:a-p-y})}else x.push({sx:n,sw:a});for(const p of x){W(p.sx,i,p.sw,o,c);for(let y=0;y<o;y+=4)W(p.sx,i+y,p.sw,1,f,.08),W(p.sx,i+y+2,p.sw,1,m,.05);No(Math.round(p.sx*7+i*13));for(let y=0;y<p.sw;y+=3)Qi()>.4&&W(p.sx+y,i,1,o,f,.04);W(p.sx,i,p.sw,2,f,.3),W(p.sx,i,p.sw,1,En(c,1),.2),W(p.sx,i+o-2,p.sw,2,m,.3),W(p.sx,i+o,p.sw,hf,d),W(p.sx,i+o,p.sw,1,En(d,.5),.4)}t&&(W(t.x-1,i,1,o+hf,"#4A3828"),W(t.x+t.w,i,1,o+hf,"#4A3828"),W(t.x,i,t.w,1,"#0A0808",.12)),W(e.fx,e.fy,e.fw,3,"#0A0808",.12),W(e.fx,e.fy+3,e.fw,2,"#0A0808",.06)}function zO(e){const t="#504038",n=es(t,.5),i=En(t,.5),a=e.wx-ka,o=e.wy,c=e.wh+hf+e.fh;W(a,o,ka,c,t),W(a,o,1,c,i,.3),W(a+ka-1,o,1,c,n,.4);for(let m=0;m<c;m+=6)W(a+1,o+m,ka-2,1,i,.06);const d=e.wx+e.ww;W(d,o,ka,c,t),W(d,o,1,c,i,.2),W(d+ka-1,o,1,c,n,.3)}function Wp(e){const{fx:t,fy:n,fw:i,fh:a}=e,o="#B08040",c="#C89848",d="#8A6030",m="#6A4820";W(t,n,i,a,o),No(42);for(let f=0;f<a;f+=5){const x=Math.floor(f/5)%2*10;for(let p=-10;p<i+10;p+=20){const y=t+p+x,g=Math.max(t,y),w=Math.min(y+19,t+i)-g;if(w<=0)continue;const k=Qi()>.5?c:o;W(g,n+f,w,4,k,.25),W(g,n+f,w,1,c,.3),W(g,n+f+4,w,1,m,.35),y>=t&&y<t+i&&W(y,n+f,1,4,m,.2),W(g,n+f+2,w,1,d,.1)}}W(t,n,i,2,"#0A0808",.08),W(t,n,2,a,"#0A0808",.06)}function s2(e){const{fx:t,fy:n,fw:i,fh:a}=e,o="#1C2A38",c="#101820";No(99),W(t,n,i,a,o);for(let d=0;d<a;d+=Zd)for(let m=0;m<i;m+=Zd){const f=Math.min(Zd,i-m),x=Math.min(Zd,a-d);Qi()>.5&&W(t+m,n+d,f,x,En(o,.2),.15),W(t+m+2,n+d+2,f-4,x-4,En(o,.3),.08),W(t+m,n+d,f,1,c,.5),W(t+m,n+d,1,x,c,.5),W(t+m+1,n+d+1,1,x-1,En(o,.4),.1),Qi()>.85&&xt(t+m+4+Math.floor(Qi()*8),n+d+4+Math.floor(Qi()*8),"#3A6A9A",.08)}}function BO(e){const{fx:t,fy:n,fw:i,fh:a}=e,o="#387848",c="#4A9058",d="#285E38";W(t,n,i,a,o),No(77);for(let f=0;f<a;f+=2)for(let x=0;x<i;x+=2)Qi()>.5&&xt(t+x,n+f,c,.1),Qi()>.8&&xt(t+x+1,n+f+1,d,.12);const m=5;W(t+m,n+m,i-m*2,1,c,.45),W(t+m,n+a-m-1,i-m*2,1,d,.45),W(t+m,n+m,1,a-m*2,c,.35),W(t+i-m-1,n+m,1,a-m*2,d,.35)}function $O(e){const{fx:t,fy:n,fw:i,fh:a}=e,o="#D8C490",c="#B09060",d="#907848";No(55);for(let m=0;m<a;m+=8)for(let f=0;f<i;f+=8){const x=Math.min(8,i-f),p=Math.min(8,a-m),y=(f/8+m/8)%2===0?c:o;W(t+f,n+m,x,p,y),W(t+f+1,n+m+1,x-2,1,En(y,.4),.2),W(t+f+1,n+m+1,1,p-2,En(y,.4),.15),W(t+f+x-2,n+m+2,1,p-3,es(y,.4),.15),W(t+f+2,n+m+p-2,x-3,1,es(y,.4),.15),W(t+f,n+m,x,1,d,.3),W(t+f,n+m,1,p,d,.3)}}function OO(){const{canvasW:e,canvasH:t,rooms:n,doors:i}=rt,a="#2A1E14",o="#3A2E24";if(W(0,0,e,nl,a),W(0,t-nl,e,nl,a),W(0,0,nl,t,a),W(e-nl,0,nl,t,a),W(0,0,e,1,o,.3),W(0,0,1,t,o,.2),!n.exec||!n.work||!n.meet||!n.comm)return;const c=n.exec,d=n.meet,m=e/2,f=m-Gt/2,x=c.fy+c.fh,p=i.exec_work,y=i.meet_comm,g=i.exec_meet,w=i.work_comm,k=24,j=28,C=((p==null?void 0:p.doorY)??c.fy+20)-k/2,N=((g==null?void 0:g.doorX)??nl+ka+54)-j/2,E=((w==null?void 0:w.doorX)??m+Gt/2+ka+54)-j/2,A=((y==null?void 0:y.doorY)??d.fy+20)-k/2;W(0,x,N,Gt,a),W(N+j,x,f-N-j,Gt,a),W(f+Gt,x,E-f-Gt,Gt,a),W(E+j,x,e-E-j,Gt,a),W(0,x,N,1,o,.3),W(N+j,x,f-N-j,1,o,.3),W(f+Gt,x,E-f-Gt,1,o,.3),W(E+j,x,e-E-j,1,o,.3),W(f,0,Gt,C,a),W(f,C+k,Gt,x-C-k,a),W(f,x+Gt,Gt,A-x-Gt,a),W(f,A+k,Gt,t-A-k,a),W(f,0,1,C,o,.2),W(f,C+k,1,x-C-k,o,.2),W(f,x+Gt,1,A-x-Gt,o,.2),W(f,A+k,1,t-A-k,o,.2),W(f,C,Gt,k,"#C4A070"),W(f+Gt/2,C,Gt/2,k,"#3A4858"),W(f,A,Gt,k,"#7AA880"),W(f+Gt/2,A,Gt/2,k,"#C8B890");const z="#4A3828";W(f,C-1,Gt,1,z),W(f,C+k,Gt,1,z),W(N-1,x,1,Gt,z),W(N+j,x,1,Gt,z),W(E-1,x,1,Gt,z),W(E+j,x,1,Gt,z),W(f,A-1,Gt,1,z),W(f,A+k,Gt,1,z)}const a2=new Map;function LO(e,t="right"){const n=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${t}`;let i=a2.get(n);if(!i){const a=hx("mini-seated:default"),o=F5(a,e);let c=o?o.layers.flatMap(d=>d.pixels):[];t==="left"&&c.length>0&&(c=dx(c,12)),i=c,a2.set(n,i)}return i}function IO(e,t,n,i="right"){Sa(Ze,LO(n,i),e,t,n)}function HO(e,t,n,i,a,o="right"){il(e+8,t+20,"up"),a||IO(e+8,t+0+i,n,o),EO(e,t+14)}function UO(e,t,n,i,a){const o=i in Gw?i:"down",c=a%4,d=Gw[o][c];Sa(Ze,d,e,t,n);const m=c===1||c===3?-1:0;if(n.accessory&&n.accessory!=="none"){const f=_8(n.accessory,o);f&&f.pixels.length>0&&Sa(Ze,f.pixels,e,t+m,n)}Ze.globalAlpha=1}let $c=[],fl=!1,wo=0;function qO(){const e=Object.keys(rt.rooms),t=e[Math.floor(Math.random()*e.length)],n=rt.rooms[t];return{x:n.fx+n.fw/2,y:n.fy+n.fh/2,dir:"down",walkFrame:0,walkTimer:0,path:[],room:t,state:"walking",stateTimer:0,tongueTimer:0,idleTime:0}}function YO(e){if(e.stateTimer--,fl){wo++,e.dir="down",e.walkFrame=0,e.tongueTimer++,e.idleTime=0;return}else wo=0;if(e.state==="idle"){if(e.tongueTimer++,e.idleTime++,e.stateTimer<=0){e.state="walking",e.tongueTimer=0;const t=Object.keys(rt.rooms);if(Math.random()<.35&&t.length>1){const n=t.filter(c=>c!==e.room),i=n[Math.floor(Math.random()*n.length)],a=P0(e,i),o=rt.waypoints[i];if(o&&o.length>0){const c=o[Math.floor(Math.random()*o.length)],d=a[a.length-1]??{x:e.x,y:e.y},m=hl(d.x,d.y,c.x,c.y,i);e.path=[...a,...m]}else e.path=a}else{const n=rt.waypoints[e.room];if(n&&n.length>0){const i=n[Math.floor(Math.random()*n.length)];e.path=hl(e.x,e.y,i.x,i.y,e.room)}}e.walkTimer=0}}else if(e.state==="walking"){if(e.idleTime=0,e.path.length===0){e.state="idle",e.dir="down",e.stateTimer=120+Math.floor(Math.random()*240);return}const t=e.path[0],n=t.x-e.x,i=t.y-e.y,a=Math.sqrt(n*n+i*i);if(a<1.5){e.x=t.x,e.y=t.y,e.path.shift();for(const[o,c]of Object.entries(rt.rooms))if(e.x>=c.fx&&e.x<=c.fx+c.fw&&e.y>=c.fy&&e.y<=c.fy+c.fh){e.room=o;break}}else e.x+=n/a*.15,e.y+=i/a*.15,Math.abs(n)>Math.abs(i)?e.dir=n>0?"right":"left":e.dir=i>0?"down":"up",e.walkTimer++,e.walkFrame=Math.floor(e.walkTimer/15)%2}}function PO(e){const t=Math.round(e.x),n=Math.round(e.y);if(fl&&wo>90){const c=Math.floor(wo/12)%2===0?K$:Q$;Sa(Ze,eO,t,n),Sa(Ze,c,t,n);return}const i=e.state==="walking"?e.walkFrame:0,a=W$[e.dir][i],o=e.dir==="left"||e.dir==="right";Sa(Ze,o?J$:Z$,t,n),Sa(Ze,a,t,n),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&Sa(Ze,G$,t,n)}function XO(e){const t={};let n=0;for(const i of e){const a=_n[i];a&&(t[i]={state:"sitting",homeX:a.dx+8,homeY:a.dy+34,homeRoom:a.room,x:a.dx+8,y:a.dy+34,path:[],room:a.room,dir:"down",walkFrame:0,walkTimer:0,bobY:0,bobOff:n*17,stateTimer:1200+Math.floor(Math.random()*1800),sittingTime:0,lookDir:"right",isStretching:!1,stretchTimer:0},n++)}return t}function hl(e,t,n,i,a){const o=rt.corridorY[a]??t,c=[];return t<o-4&&c.push({x:e,y:o}),Math.abs(e-n)>4&&c.push({x:n,y:o}),c.push({x:n,y:i}),c}function Gp(e,t,n,i){const a=rt.adjacency[n];if(!a)return[];const o=a.find(x=>x.room===i);if(!o)return[];const c=rt.doors[o.door];if(!c)return[];const d=[],m=rt.corridorY[n]??t,f=rt.corridorY[i]??t;if(Math.abs(t-m)>4&&d.push({x:e,y:m}),c.type==="v"){const x=o.side==="A"?c.xA:c.xB,p=o.side==="A"?c.xB:c.xA;d.push({x,y:m}),d.push({x,y:c.doorY}),d.push({x:p,y:c.doorY}),d.push({x:p,y:f})}else{const x=o.side==="A"?c.yA:c.yB,p=o.side==="A"?c.yB:c.yA;d.push({x:c.doorX,y:m}),d.push({x:c.doorX,y:x}),d.push({x:c.doorX,y:p}),d.push({x:c.doorX,y:f})}return d}function P0(e,t){const n=rt.adjacency[e.room];if(!n)return[];if(!n.find(a=>a.room===t)){for(const a of n){const o=rt.adjacency[a.room];if(o!=null&&o.find(c=>c.room===t)){const c=Gp(e.x,e.y,e.room,a.room),d=c[c.length-1],m=Gp((d==null?void 0:d.x)??e.x,(d==null?void 0:d.y)??e.y,a.room,t);return[...c,...m]}}return[]}return Gp(e.x,e.y,e.room,t)}function VO(e){if(e.room!==e.homeRoom){const t=P0({...e},e.homeRoom),n=t[t.length-1],i=hl((n==null?void 0:n.x)??e.x,(n==null?void 0:n.y)??e.y,e.homeX,e.homeY,e.homeRoom);return[...t,...i]}return hl(e.x,e.y,e.homeX,e.homeY,e.room)}function WO(e,t){if(Vp--,Vp<=0){const n=Object.entries(e).filter(([,i])=>i.state==="sitting"&&!i.isStretching);if(n.length>0){const[,i]=n[Math.floor(Math.random()*n.length)];i.isStretching=!0,i.stretchTimer=120}Vp=900}for(const[n,i]of Object.entries(e))if(i.stateTimer--,i.isStretching&&i.stretchTimer>0&&(i.stretchTimer--,i.stretchTimer<=0&&(i.isStretching=!1)),i.state==="sitting"){if(i.sittingTime++,cr===n){i.sittingTime=0,i.bobY=-3;const o=_n[n];if(o){const c=o.dx+13;i.lookDir=tS<c?"left":"right"}}else i.bobY=(t+i.bobOff)%60<30?1:0,i.lookDir="right";if(i.stateTimer<=0){i.state="walking",i.x=i.homeX,i.y=i.homeY,i.room=i.homeRoom;const o=Object.keys(rt.rooms);if(Math.random()<.15&&o.length>1){const c=o.filter(x=>x!==i.room),d=c[Math.floor(Math.random()*c.length)],m=P0(i,d),f=rt.waypoints[d];if(f&&f.length>0){const x=f[Math.floor(Math.random()*f.length)],p=m[m.length-1]??{x:i.x,y:i.y},y=hl(p.x,p.y,x.x,x.y,d);i.path=[...m,...y]}else i.path=m;i.walkTimer=0}else{const c=rt.waypoints[i.room];if(c&&c.length>0){const d=c[Math.floor(Math.random()*c.length)];i.path=hl(i.x,i.y,d.x,d.y,i.room)}i.walkTimer=0}}}else if(i.state==="walking"||i.state==="returning"){if(i.sittingTime=0,cr===n){i.dir="down",i.walkFrame=0;continue}if(i.path.length===0){i.state==="returning"?(i.state="sitting",i.room=i.homeRoom,i.stateTimer=1200+Math.floor(Math.random()*1800)):(i.state="idle",i.dir="down",i.stateTimer=180+Math.floor(Math.random()*360));continue}const o=i.path[0],c=o.x-i.x,d=o.y-i.y,m=Math.sqrt(c*c+d*d);if(m<1.5){i.x=o.x,i.y=o.y,i.path.shift();for(const[f,x]of Object.entries(rt.rooms))if(i.x>=x.fx&&i.x<=x.fx+x.fw&&i.y>=x.fy&&i.y<=x.fy+x.fh){i.room=f;break}}else i.x+=c/m*.2,i.y+=d/m*.2,Math.abs(c)>Math.abs(d)?i.dir=c>0?"right":"left":i.dir=d>0?"down":"up",i.walkTimer++,i.walkFrame=Math.floor(i.walkTimer/12)%4}else if(i.state==="idle"){if(cr===n){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const a=rt.waypoints[i.room];if(a&&a.length>0){const o=a[Math.floor(Math.random()*a.length)];i.path=hl(i.x,i.y,o.x,o.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=VO(i),i.walkTimer=0}}function GO(e,t,n,i){const{canvasW:a,canvasH:o,rooms:c}=rt;Ze.clearRect(0,0,a,o),W(0,0,a,o,"#2A1E14");const d={wood:Wp,dark:s2,carpet:BO,tile:$O};for(const g of Object.values(c))(d[g.floorType]??Wp)(g);const m=Object.keys(c);if(m.length>=4){const g=c.exec,w=c.meet,{doors:k}=rt;if(g&&w&&k.exec_meet&&k.work_comm){const C=(k.exec_meet.doorX??0)-14,N=(k.work_comm.doorX??0)-28/2,E=g.fy+g.fh,A=w.fy;Wp({fx:C,fy:E,fw:28,fh:A-E}),s2({fx:N,fy:E,fw:28,fh:A-E})}}const f={};if(m.length>=4){const{doors:g}=rt,w=28,k=g.exec_meet,j=g.work_comm;k!=null&&k.doorX&&(f.meet={x:k.doorX-w/2,w}),j!=null&&j.doorX&&(f.comm={x:j.doorX-w/2,w})}for(const g of Object.values(c))RO(g,f[g.id]),zO(g);OO(),AO(rt);const x=[],p=new Set(Object.values(_n).map(g=>g.room));DO(rt,x,p);for(const[g,w]of Object.entries(_n)){const k=e[g];if(!k)continue;const j=k.state==="sitting",C=t(g),N=tr(n[g]),E=k.isStretching&&k.stretchTimer>0?Math.sin(k.stretchTimer*.15)*1:0;x.push({y:w.dy+14,draw:()=>{const A=j?k.bobY+E:0;if(HO(w.dx,w.dy,C,A,!j,k.lookDir),j&&N){const z=Rf[g]??"#388bfd";W(w.dx+7,w.dy+14-4,12,5,z,.15),xt(w.dx+12,w.dy+14+1,"#4CAF50",.8)}}})}for(const[g,w]of Object.entries(e))if(w.state!=="sitting"){const k=t(g);x.push({y:w.y+14,draw:()=>UO(Math.round(w.x),Math.round(w.y),k,w.dir,w.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>PO(i)}),x.sort((g,w)=>g.y-w.y);for(const g of x)g.draw();for(const g of Xi){const w=al===g.id,k=eS(g);if(Ze.save(),Ze.globalAlpha=w?.9:.5,Ze.fillStyle=g.color,Ze.fillRect(k.cx-1,k.botY-2,3,3),w){const j=J3(g);Ze.globalAlpha=.3,Ze.strokeStyle=g.color,Ze.lineWidth=1,Ze.strokeRect(j.x-1,j.y-1,j.w+2,j.h+2)}Ze.restore()}if(Ts){const g=new Set(Object.values(_n).map(w=>w.room));if(ki&&ki!==Yr)if(ki.startsWith("desk:")){const w=ki.slice(5),k=_n[w];k&&t2(Ze,k.dx,k.dy,"#FBBF24")}else e2(Ze,rt,ki,"#FBBF24",g);if(Yr)if(Yr.startsWith("desk:")){const w=Yr.slice(5),k=_n[w];k&&t2(Ze,k.dx,k.dy,"#3B82F6")}else e2(Ze,rt,Yr,"#3B82F6",g)}if(cr){const g=_n[cr],w=e[cr];if(g&&w){Ze.save(),Ze.globalAlpha=.25,Ze.fillStyle=Rf[cr]??"#fff",w.state==="sitting"?Ze.fillRect(g.dx-1,g.dy+6,28,30):Ze.fillRect(Math.round(w.x)-1,Math.round(w.y)-1,14,24),Ze.globalAlpha=.95,Ze.fillStyle="#FBBF24",Ze.font="bold 8px monospace",Ze.textAlign="center";const k=w.state==="sitting"?g.dx+13:Math.round(w.x)+6,j=w.state==="sitting"?g.dy-1:Math.round(w.y)-5;Ze.fillText("!",k,j),Ze.restore()}}const y=3600;for(const[,g]of Object.entries(e))if(g.state==="sitting"&&g.sittingTime>y&&!g.isStretching){const w=Object.values(_n).find(A=>A.dx+8===g.homeX&&A.dy+34===g.homeY);if(!w)continue;const k=w.dx+13,j=w.dy,C=Math.floor(g.sittingTime/40)%3;Ze.save(),Ze.font="5px monospace",Ze.textAlign="center";const N=[.7,.5,.3],E=[{x:3,y:-2-C},{x:6,y:-5-(C+1)%3},{x:4,y:-8-(C+2)%3}];for(let A=0;A<3;A++)Ze.globalAlpha=N[A],Ze.fillStyle="#93C5FD",Ze.font=`${4+A}px monospace`,Ze.fillText("z",k+E[A].x,j+E[A].y);Ze.restore()}$c=$c.filter(g=>g.life>0);for(const g of $c)g.x+=g.vx,g.y+=g.vy,g.life--,Ze.save(),Ze.globalAlpha=Math.min(1,g.life/(g.maxLife*.3)),Ze.fillStyle=g.color??"#FF6B8A",Ze.font="8px serif",Ze.fillText(g.char,Math.round(g.x),Math.round(g.y)),Ze.restore();if(fl&&i&&wo<=90){const g=Math.round(i.x),w=Math.round(i.y);Ze.save(),Ze.globalAlpha=.9,Ze.fillStyle="#FBBF24",Ze.font="bold 5px monospace",Ze.textAlign="center",Ze.fillText("!",g+4,w-2),Ze.restore()}if(i&&!fl&&i.state==="idle"&&i.idleTime>600){const g=Math.round(i.x),w=Math.round(i.y),k=Math.floor(i.idleTime/40)%3;Ze.save();const j=[{x:3,y:-2-k},{x:5,y:-5-(k+1)%3},{x:4,y:-8-(k+2)%3}];for(let C=0;C<3;C++)Ze.globalAlpha=[.7,.5,.3][C],Ze.fillStyle="#93C5FD",Ze.font=`${3+C}px monospace`,Ze.textAlign="center",Ze.fillText("z",g+j[C].x,w+j[C].y);Ze.restore()}if(fl&&i&&wo<=90){const g=Math.round(i.x),w=Math.round(i.y),k=Math.floor(Date.now()/150)%2===0?-1:1;i.dir==="down"&&(Ze.fillStyle="#FAFAF7",Ze.fillRect(g+4+k,w-1,2,2))}}function KO(e,t){for(let n=0;n<4;n++)$c.push({x:e+(Math.random()-.5)*8,y:t,vx:(Math.random()-.5)*.3,vy:-.3-Math.random()*.2,life:60+Math.floor(Math.random()*30),maxLife:80,char:n%2===0?"♥":"♡",color:"#FF6B8A"})}function QO(e,t){for(let n=0;n<3;n++)$c.push({x:e+(Math.random()-.5)*8,y:t,vx:(Math.random()-.5)*.3,vy:-.3-Math.random()*.2,life:60+Math.floor(Math.random()*30),maxLife:80,char:"💧",color:"#64B5F6"})}function ZO({roles:e,projects:t,roleStatuses:n,activeExecs:i,onRoleClick:a,onProjectClick:o,onBulletinClick:c,onDecisionsClick:d,onKnowledgeClick:m,onSettingsClick:f,onThemeClick:x,onStatsClick:p,getRoleSpeech:y,getAppearance:g,onHireClick:w,onPresetsClick:k,onMascotClick:j,roleLevels:C,coinBalance:N=0,onCoinsSpent:E,onFurniturePlaced:A,purchasedPreset:z,language:D="en"}){const F=S.useRef(null),q=S.useRef(null),V=S.useRef(null),L=S.useRef({}),_=S.useRef(null),B=S.useRef(0),X=S.useRef(_O),[R,H]=S.useState(!1),[$,G]=S.useState(null),[Q,K]=S.useState(null),M=S.useRef({}),U=S.useRef({}),P=S.useRef([]),O=S.useRef([]);S.useEffect(()=>{Ts=R},[R]),S.useEffect(()=>{va=$,Pi=Q},[$,Q]);const[Z,ee]=S.useState(!1);S.useEffect(()=>{ke.getPreferences().then(ve=>{const be=ve.furnitureOverrides;be&&Object.keys(be).length>0&&(M.current=be);const te=ve.deskOverrides;te&&Object.keys(te).length>0&&(U.current=te);const oe=ve.removedFurniture;oe&&oe.length>0&&(P.current=oe);const Ce=ve.addedFurniture;Ce&&Ce.length>0&&(O.current=Ce),ee(!0)}).catch(()=>{ee(!0)})},[]);const J=S.useRef({roleStatuses:n,activeExecs:i,getRoleSpeech:y,getAppearance:g});J.current={roleStatuses:n,activeExecs:i,getRoleSpeech:y,getAppearance:g};const se=S.useRef({}),le=S.useMemo(()=>e.map(ve=>ve.id),[e]),ye=S.useRef(rt);S.useEffect(()=>{if(!Z)return;const ve=le.length,be=W3(ve,ye.current.preset,z),te=ye.current.preset!==be;let oe=G3(ve,be);P.current.length>0&&(oe=Jw(oe,P.current)),O.current.length>0&&(oe=lO(oe,O.current)),Object.keys(M.current).length>0&&(oe=sO(oe,M.current)),rt=oe,ye.current=oe,_n=FO(le),Object.keys(U.current).length>0&&aO(_n,U.current),Xi=sl(oe),L.current=XO(le),_.current=qO();const Ce=F.current;Ce&&(Ce.width=oe.canvasW,Ce.height=oe.canvasH,te&&(Ce.style.opacity="0",Ce.style.transition="opacity 0.3s",setTimeout(()=>{Ce.style.opacity="1"},50))),Ee()},[le,z,Z]);const De=S.useCallback(ve=>{var be,te;return((te=(be=J.current).getAppearance)==null?void 0:te.call(be,ve))??I0(ve)},[]),Ee=S.useCallback(()=>{const ve=q.current,be=F.current;if(!ve||!be)return;const te=ve.parentElement;if(!te)return;const oe=te.clientWidth,Ce=te.clientHeight;if(oe===0||Ce===0)return;const{canvasW:pe,canvasH:Se}=rt;let Me=Math.min(oe/pe,Ce/Se);Me=Math.round(Me*2)/2,Me=Math.max(2,Math.min(Me,5)),X.current=Me,be.style.width=pe*Me+"px",be.style.height=Se*Me+"px",ve.style.width=pe*Me+"px",ve.style.height=Se*Me+"px"},[]);S.useEffect(()=>{var Se;const ve=F.current;if(!ve)return;const be=ve.getContext("2d");if(!be)return;Ze=be,oO(be),Ee();const te=new ResizeObserver(()=>Ee()),oe=(Se=q.current)==null?void 0:Se.parentElement;oe&&te.observe(oe);let Ce;const pe=()=>{B.current++,WO(L.current,B.current),_.current&&YO(_.current),GO(L.current,De,J.current.roleStatuses,_.current),Re(),Ce=requestAnimationFrame(pe)};return Ce=requestAnimationFrame(pe),()=>{cancelAnimationFrame(Ce),te.disconnect()}},[De,Ee]),S.useEffect(()=>{var pe;const ve=V.current;if(!ve)return;ve.innerHTML="";const be={};for(const Se of e)be[Se.id]=Se.name;for(const Se of le){const Me=Rf[Se]??"#8b949e",Ge=be[Se],Ie=Ge&&Ge.toLowerCase()!==Se.toLowerCase()?`${Se.toUpperCase()} · ${Ge}`:Se.toUpperCase(),qe=document.createElement("div");qe.className="td-nametag",qe.dataset.role=Se;const Xe=document.createElement("span");Xe.className="td-dot",Xe.style.background=Me,qe.appendChild(Xe),qe.appendChild(document.createTextNode(Ie));const et=((pe=C==null?void 0:C[Se])==null?void 0:pe.level)??1;if(et>1){const Be=document.createElement("span");Be.className="td-lvl",Be.textContent=`Lv.${et}`,qe.appendChild(Be)}ve.appendChild(qe);const ze=document.createElement("div");ze.className="td-bubble",ze.dataset.role=Se,ze.dataset.type="bubble",ve.appendChild(ze)}const te={meeting:()=>{const Se=t[0];Se?o(Se.id):c()},bulletin:c,decisions:d,knowledge:m,settings:f,theme:x,stats:p};for(const Se of Xi){const Me=document.createElement("div");Me.className="td-facility-label",Me.dataset.facility=Se.id,Se.id==="meeting"&&(Me.dataset.questTarget="meeting-room"),Se.id==="knowledge"&&(Me.dataset.questTarget="knowledge-hub"),Se.id==="bulletin"&&(Me.dataset.questTarget="bulletin-board"),Se.id==="stats"&&(Me.dataset.questTarget="stats-btn"),Se.id==="settings"&&(Me.dataset.questTarget="settings-btn"),Se.id==="theme"&&(Me.dataset.questTarget="theme-btn"),Me.textContent=`${Se.icon} ${Se.label}`,Me.style.borderColor=`${Se.color}44`;const Ge=te[Se.id];Ge&&Me.addEventListener("click",Ge),Me.addEventListener("mouseenter",()=>{al=Se.id}),Me.addEventListener("mouseleave",()=>{al=null}),ve.appendChild(Me)}const oe=document.createElement("div");oe.className="td-nametag td-nametag-mascot",oe.dataset.role="mascot";const Ce=document.createElement("span");Ce.className="td-dot",Ce.style.background="#ffd700",oe.appendChild(Ce),oe.appendChild(document.createTextNode("Pupu")),oe.addEventListener("click",()=>j==null?void 0:j()),ve.appendChild(oe)},[le,e,t,o,c,d,m,f,x,p,j,C]);const Re=S.useCallback(()=>{var Ge;const ve=V.current;if(!ve)return;const be=X.current,te=L.current,{getRoleSpeech:oe,roleStatuses:Ce,activeExecs:pe}=J.current;for(const Ie of Object.keys(te)){const qe=te[Ie],Xe=_n[Ie];if(!Xe)continue;let et,ze,Be;qe.state==="sitting"?(et=Xe.dx+13,Be=Xe.dy+2,ze=Xe.dy+37):(et=Math.round(qe.x)+6,Be=Math.round(qe.y)-2,ze=Math.round(qe.y)+18);const _t=et/rt.canvasW*100,en=ve.querySelector(`.td-nametag[data-role="${Ie}"]`);if(en){en.style.left=_t+"%",en.style.top=ze*be+2+"px";const Pt=en.querySelector(".td-dot");if(Pt){const hn=tr(Ce[Ie]);Pt.style.background=hn?"#FBBF24":Rf[Ie]??"#8b949e",hn?Pt.style.animation="td-pulse 1s ease-in-out infinite":Pt.style.animation=""}}const Tt=ve.querySelector(`.td-bubble[data-role="${Ie}"]`);if(Tt){const Pt=Date.now(),hn=tr(Ce[Ie]),Zt=(Ge=pe.find(Ne=>Ne.roleId===Ie))==null?void 0:Ge.task,ae=oe(Ie);let Ve="";const We=se.current[Ie];if(We){if(We.speechDismissTime&&Pt>=We.speechDismissTime&&(We.currentSpeech=null,We.speechDismissTime=null),We.hoverStartTime&&!We.currentSpeech){const Ne=Pt-We.hoverStartTime,Ct=!We.lastSpeechTime||Pt-We.lastSpeechTime>=5e3;if(Ne>=2e3&&Ct){const ln=MO(Ie,D),nn=ln[Math.floor(Math.random()*ln.length)];We.currentSpeech=nn,We.lastSpeechTime=Pt,We.speechDismissTime=Pt+3e3}}Ve=We.currentSpeech||""}const tn=hn&&Zt?Zt.slice(0,60):Ve?Ve.slice(0,60):ae?ae.slice(0,60):"";tn&&qe.state==="sitting"?(Tt.style.display="",Tt.style.left=_t+"%",Tt.style.top=(Be-10)*be+"px",Tt.textContent=tn):Tt.style.display="none"}}const Se=ve.querySelector(".td-nametag-mascot"),Me=_.current;if(Se&&Me){const Ie=Me.dir==="left"||Me.dir==="right",qe=Math.round(Me.x)+(Ie?6:4),Xe=Math.round(Me.y)+(Ie?7:10);Se.style.left=qe/rt.canvasW*100+"%",Se.style.top=Xe*be+2+"px"}for(const Ie of Xi){const qe=ve.querySelector(`.td-facility-label[data-facility="${Ie.id}"]`);if(qe){const Xe=eS(Ie);qe.style.left=Xe.cx/rt.canvasW*100+"%",qe.style.top=Xe.botY*be-4+"px",qe.classList.toggle("td-facility-label--hover",al===Ie.id)}}},[]),me=S.useCallback(ve=>{const be=F.current;if(!be)return null;const te=be.getBoundingClientRect(),oe=X.current,Ce=(ve.clientX-te.left)/oe,pe=(ve.clientY-te.top)/oe,Se=L.current;for(const[Ge,Ie]of Object.entries(_n)){if(!Se[Ge])continue;const qe=Se[Ge];if(qe.state==="sitting"){if(Ce>=Ie.dx&&Ce<=Ie.dx+26&&pe>=Ie.dy&&pe<=Ie.dy+40)return{type:"role",id:Ge}}else if(Ce>=qe.x-2&&Ce<=qe.x+14&&pe>=qe.y-2&&pe<=qe.y+20)return{type:"role",id:Ge}}const Me=_.current;if(Me){const Ge=Me.dir==="left"||Me.dir==="right",Ie=Ge?13:9,qe=Ge?7:10;if(Ce>=Me.x&&Ce<=Me.x+Ie&&pe>=Me.y&&pe<=Me.y+qe)return{type:"mascot",id:"mascot"}}for(const Ge of Xi){const Ie=J3(Ge);if(Ce>=Ie.x&&Ce<=Ie.x+Ie.w&&pe>=Ie.y&&pe<=Ie.y+Ie.h)return{type:"facility",id:Ge.id}}return null},[]),Fe=S.useCallback(ve=>{const be=F.current;if(!be)return{mx:0,my:0};const te=be.getBoundingClientRect(),oe=X.current;return{mx:(ve.clientX-te.left)/oe,my:(ve.clientY-te.top)/oe}},[]),Je=S.useCallback(ve=>{ke.updatePreferences(ve).catch(()=>{})},[]),Pe=S.useCallback(ve=>{const be=O.current.some(oe=>oe.id===ve),te={};if(be){const oe=O.current.filter(Ce=>Ce.id!==ve);O.current=oe,te.addedFurniture=oe}else{const oe=[...P.current,ve];P.current=oe,te.removedFurniture=oe}rt=Jw(rt,[ve]),Xi=sl(rt),Yr=null,ki=null,Je(te)},[Je]),it=S.useCallback((ve,be)=>{if(!va||!Pi)return;const te=r2.find(qe=>qe.type===va),oe=(te==null?void 0:te.price)??0;if(oe>0&&N<oe)return;let Ce=null;for(const[qe,Xe]of Object.entries(rt.rooms)){const et=Pi==="wall"?Xe.wx:Xe.fx,ze=Pi==="wall"?Xe.wy:Xe.fy,Be=Pi==="wall"?Xe.ww:Xe.fw,_t=Pi==="wall"?Xe.wh:Xe.fh;if(ve>=et&&ve<=et+Be&&be>=ze&&be<=ze+_t){Ce=qe;break}}if(!Ce)return;const pe=rt.rooms[Ce],Se=Pi==="wall"?pe.wx:pe.fx,Me=Pi==="wall"?pe.wy:pe.fy,Ge={id:`user-${va}-${Date.now()}`,type:va,room:Ce,zone:Pi,offsetX:Math.round(ve-Se),offsetY:Math.round(be-Me)},Ie=[...O.current,Ge];if(O.current=Ie,Pi==="wall"?rt.wallDecorations.push(Ge):rt.furniture.push(Ge),Xi=sl(rt),Je({addedFurniture:Ie}),A==null||A(va,oe),oe>0){const qe=Ge.type;Px(async()=>{const{api:Xe}=await Promise.resolve().then(()=>X4);return{api:Xe}},void 0).then(({api:Xe})=>{Xe.spendCoins(oe,`furniture: ${qe}`,Ge.id).then(et=>E==null?void 0:E(et.balance)).catch(()=>{})})}G(null),K(null)},[Je,N,E,A]),ht=S.useCallback(ve=>{const be=F.current;if(Ts&&mr){const{mx:Se,my:Me}=Fe(ve),Ie=[...rt.furniture,...rt.wallDecorations].find(et=>et.id===mr.defId);if(!Ie)return;const qe=Se-mr.startMx,Xe=Me-mr.startMy;Ie.offsetX=Math.round(mr.origOffX+qe),Ie.offsetY=Math.round(mr.origOffY+Xe),Xi=sl(rt),be&&(be.style.cursor="grabbing");return}if(Ts&&Wn){const{mx:Se,my:Me}=Fe(ve),Ge=_n[Wn.roleId];if(!Ge)return;Ge.dx=Math.round(Wn.origDx+(Se-Wn.startMx)),Ge.dy=Math.round(Wn.origDy+(Me-Wn.startMy));const Ie=L.current[Wn.roleId];Ie&&(Ie.homeX=Ge.dx+8,Ie.homeY=Ge.dy+34),be&&(be.style.cursor="grabbing");return}if(Ts){const{mx:Se,my:Me}=Fe(ve);if(va){be&&(be.style.cursor="crosshair");return}const Ge=new Set(Object.values(_n).map(qe=>qe.room)),Ie=Xp(rt,Se,Me,Ge);if(Ie)ki=Ie;else{const qe=n2(_n,Se,Me);ki=qe?`desk:${qe}`:null}cr=null,al=null,be&&(be.style.cursor=ki?"grab":"default");return}const te=me(ve),oe=cr;cr=(te==null?void 0:te.type)==="role"?te.id:null,al=(te==null?void 0:te.type)==="facility"?te.id:null,fl=(te==null?void 0:te.type)==="mascot",ki=null,be&&(be.style.cursor=te?"pointer":"default");const{mx:Ce}=Fe(ve);tS=Ce;const pe=Date.now();if(cr&&cr!==oe){se.current[cr]||(se.current[cr]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const Se=se.current[cr];Se.hoverStartTime=pe}else if(!cr&&oe){const Se=se.current[oe];Se&&(Se.hoverStartTime=null)}},[me,Fe]),Ye=S.useCallback(ve=>{if(!Ts)return;const{mx:be,my:te}=Fe(ve);if(va){it(be,te),ve.preventDefault();return}const oe=new Set(Object.values(_n).map(Se=>Se.room)),Ce=Xp(rt,be,te,oe);if(Ce){const Me=[...rt.furniture,...rt.wallDecorations].find(Ge=>Ge.id===Ce);Me&&(Yr=Ce,mr={defId:Ce,startMx:be,startMy:te,origOffX:Me.offsetX,origOffY:Me.offsetY},ve.preventDefault());return}const pe=n2(_n,be,te);if(pe){const Se=_n[pe];Yr=`desk:${pe}`,Wn={roleId:pe,startMx:be,startMy:te,origDx:Se.dx,origDy:Se.dy},ve.preventDefault();return}Yr=null},[Fe,it]),nt=S.useCallback(ve=>{if(mr){const te=[...rt.furniture,...rt.wallDecorations].find(oe=>oe.id===mr.defId);if(te){const oe={...M.current,[te.id]:{offsetX:te.offsetX,offsetY:te.offsetY}};M.current=oe,Je({furnitureOverrides:oe}),Xi=sl(rt)}mr=null,F.current&&(F.current.style.cursor="grab");return}if(Wn){const be=_n[Wn.roleId];if(be){const te={...U.current,[Wn.roleId]:{dx:be.dx,dy:be.dy}};U.current=te,Je({deskOverrides:te})}Wn=null,F.current&&(F.current.style.cursor="grab")}},[Je]),ut=S.useCallback(ve=>{if(!Ts)return;ve.preventDefault();const{mx:be,my:te}=Fe(ve),oe=new Set(Object.values(_n).map(pe=>pe.room)),Ce=Xp(rt,be,te,oe);Ce&&Pe(Ce)},[Fe,Pe]);S.useEffect(()=>{const ve=be=>{!Ts||!Yr||(be.key==="Delete"||be.key==="Backspace")&&(Yr.startsWith("desk:")||Pe(Yr))};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[Pe]);const kt=S.useCallback(()=>{if(mr){const be=[...rt.furniture,...rt.wallDecorations].find(te=>te.id===mr.defId);be&&(be.offsetX=mr.origOffX,be.offsetY=mr.origOffY,Xi=sl(rt)),mr=null}if(Wn){const ve=_n[Wn.roleId];ve&&(ve.dx=Wn.origDx,ve.dy=Wn.origDy);const be=L.current[Wn.roleId];be&&(be.homeX=ve.dx+8,be.homeY=ve.dy+34),Wn=null}cr=null,al=null,fl=!1,ki=null,F.current&&(F.current.style.cursor="default")},[]),mt=S.useCallback(ve=>{if(Ts)return;const be=me(ve);if(be){if(be.type==="role"){const te=L.current[be.id],oe=_n[be.id];if(te&&oe){const Ce=te.state==="sitting"?oe.dx+13:Math.round(te.x)+6,pe=te.state==="sitting"?oe.dy+2:Math.round(te.y)-2;QO(Ce,pe)}a(be.id);return}if(be.type==="mascot"){const te=_.current;te&&KO(Math.round(te.x)+4,Math.round(te.y)-2),j==null||j();return}switch(be.id){case"meeting":{const te=t[0];te?o(te.id):c();break}case"bulletin":c();break;case"decisions":d();break;case"knowledge":m();break;case"settings":f==null||f();break;case"theme":x==null||x();break;case"stats":p==null||p();break}}},[me,a,o,c,d,m,f,x,p]);return l.jsxs("div",{className:`td-scene${R?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:q,className:"td-wrap",children:[l.jsx("canvas",{ref:F,width:rt.canvasW,height:rt.canvasH,className:"td-canvas",onClick:mt,onMouseDown:Ye,onMouseUp:nt,onMouseMove:ht,onMouseLeave:kt,onContextMenu:ut}),l.jsx("div",{ref:V,className:"td-overlay"})]}),R&&l.jsxs("div",{className:"td-edit-banner",children:[l.jsx("span",{className:"td-edit-banner__icon",children:"✎"})," EDIT MODE — Click DONE when finished"]}),l.jsxs("button",{className:`td-edit-btn${R?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{H(ve=>{const be=!ve;return be||(G(null),K(null)),be}),Yr=null,mr=null,Wn=null},title:R?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:R?"✓":"✎"}),l.jsx("span",{className:"td-edit-btn__label",children:R?"DONE":"EDIT"})]}),R&&l.jsx("div",{className:"td-palette",children:r2.map(ve=>{const be=ve.price===0||N>=ve.price,te=ve.price===0?"Free":`${ve.price>=1e3?`${(ve.price/1e3).toFixed(ve.price%1e3===0?0:1)}K`:ve.price}`;return l.jsxs("button",{className:`td-palette__item${$===ve.type?" td-palette__item--active":""}${be?"":" td-palette__item--locked"}`,onClick:()=>{be&&($===ve.type?(G(null),K(null)):(G(ve.type),K(ve.zone)))},title:`${ve.label} — ${te}`,style:be?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:ve.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:ve.price===0?"#4CAF50":be?"#FFD54F":"#EF5350"},children:te})]},ve.type)})}),w&&l.jsxs("button",{className:"td-hire-btn","data-quest-target":"hire-btn",onClick:w,title:"Hire New Role",children:[l.jsx("span",{className:"td-hire-btn__icon",children:"+"}),l.jsx("span",{className:"td-hire-btn__label",children:"HIRE"})]}),k&&l.jsxs("button",{className:"td-hire-btn",onClick:k,title:"Team Presets",style:{right:"auto",left:12},children:[l.jsx("span",{className:"td-hire-btn__icon",children:"📦"}),l.jsx("span",{className:"td-hire-btn__label",children:"TEAMS"})]})]})}function JO({role:e,appearance:t,onSave:n,onReset:i,onClose:a,theme:o,onThemeChange:c,onUpdateName:d,initialTab:m,characterOnly:f,speechSettings:x,onSpeechSettingsChange:p,language:y,onLanguageChange:g,roleLevel:w,coinBalance:k,purchased:j,onPurchase:C}){var R;const[N,E]=S.useState(m??"character"),[A,z]=S.useState({...t}),[D,F]=S.useState(e.name),[q,V]=S.useState(!1),L=S.useCallback(()=>z(to(w)),[w]),_=S.useCallback(()=>{const H=I0(e.id);z({...H}),i()},[e.id,i]),B=S.useCallback(async()=>{n(A);const H=D.trim();if(d&&H&&H!==e.name){V(!0);try{await d(e.id,H)}catch{}V(!1)}a()},[A,n,a,D,e.name,e.id,d]),X=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),d?l.jsx("input",{value:D,onChange:H=>F(H.target.value),disabled:q,className:"customize-name-input",style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:4,color:"inherit",font:"inherit",padding:"2px 6px",flex:1,minWidth:0}}):l.jsx("span",{children:e.name})]});return l.jsx("div",{className:"customize-overlay",onClick:a,children:l.jsxs("div",{className:"customize-modal",onClick:H=>H.stopPropagation(),children:[l.jsxs("div",{className:"customize-header",children:[l.jsxs("div",{className:"customize-tabs",children:[l.jsx("button",{className:`customize-tab ${N==="character"?"active":""}`,onClick:()=>E("character"),children:"CHARACTER"}),!f&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${N==="office"?"active":""}`,onClick:()=>E("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${N==="settings"?"active":""}`,onClick:()=>E("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:a,children:"X"})]}),N==="character"?l.jsx("div",{className:"customize-body",children:l.jsx(O3,{roleId:e.id,appearance:A,onChange:z,onRandomize:L,onReset:_,label:X,roleLevel:w,coinBalance:k,purchased:j,onPurchase:C})}):N==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(Bs).map(([H,$])=>l.jsxs("button",{className:`customize-theme-card ${o===H?"active":""}`,onClick:()=>c(H),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:$.vars["--floor-light"],borderColor:$.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:$.vars["--hud-bg"],height:8,borderBottom:`2px solid ${$.vars["--pixel-border"]}`}}),l.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 p-1",children:[l.jsx("div",{style:{width:10,height:14,background:$.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:$.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:$.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:$.vars["--hud-bg"],height:6,borderTop:`2px solid ${$.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[$.icon," ",$.name]})]},H))})}):l.jsx("div",{className:"customize-body",children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,padding:"8px 0"},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"AMBIENT SPEECH MODE"}),l.jsx("div",{style:{display:"flex",gap:6},children:["template","llm","auto"].map(H=>l.jsxs("button",{onClick:()=>p==null?void 0:p({mode:H}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(x==null?void 0:x.mode)===H?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(x==null?void 0:x.mode)===H?"rgba(255,255,255,0.08)":"transparent",color:(x==null?void 0:x.mode)===H?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:H==="template"?"TEMPLATE":H==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:H==="template"?"Static pool ($0)":H==="llm"?"LLM generated":"Detect engine"})]},H))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Auto: CLI Max = AI, BYOK = Template"})]}),l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["SPEECH INTERVAL: ",(x==null?void 0:x.intervalSec)??18,"s"]}),l.jsx("input",{type:"range",min:5,max:120,step:5,value:(x==null?void 0:x.intervalSec)??18,onChange:H=>p==null?void 0:p({intervalSec:Number(H.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"5s (frequent)"}),l.jsx("span",{children:"120s (rare)"})]})]}),(x==null?void 0:x.mode)!=="template"&&l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",((R=x==null?void 0:x.dailyBudgetUsd)==null?void 0:R.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(x==null?void 0:x.dailyBudgetUsd)??1,onChange:H=>p==null?void 0:p({dailyBudgetUsd:Number(H.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"$0 (unlimited)"}),l.jsx("span",{children:"$5.00/day"})]})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"LANGUAGE"}),l.jsx("div",{style:{display:"flex",gap:6},children:[{key:"auto",label:"Auto"},{key:"en",label:"English"},{key:"ko",label:"한국어"},{key:"ja",label:"日本語"}].map(({key:H,label:$})=>l.jsx("button",{onClick:()=>g==null?void 0:g(H),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(y??"auto")===H?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(y??"auto")===H?"rgba(255,255,255,0.08)":"transparent",color:(y??"auto")===H?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:$},H))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),N==="character"&&l.jsxs("div",{className:"customize-footer",children:[l.jsx("button",{className:"customize-btn customize-btn--cancel",onClick:a,children:"CANCEL"}),l.jsx("button",{className:"customize-btn customize-btn--save",onClick:B,children:"SAVE"})]})]})})}function l2(e){if(e.length===0)return"";const t={};for(const{file:d}of e){const m=d.split("/"),f=m[0]==="."?m[1]??"root":m[0];(t[f]??(t[f]=[])).push(d)}const n={roles:"roles",projects:"projects",operations:"operations",knowledge:"knowledge",architecture:"architecture",company:"company",".tycono":"config",".claude":"skills"},i=[];for(const[d,m]of Object.entries(t)){const f=n[d]??d;if(m.length===1){const x=m[0].split("/").pop()??m[0];i.push(`${f}/${x}`)}else i.push(`${f} (${m.length} files)`)}const a=e.some(d=>d.status==="A"),o=e.some(d=>d.status==="M");return`${a&&!o?"add":"update"}: ${i.join(", ")}`}function o2(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function eL({onInitGit:e,onDelegate:t,delegateRoleName:n}){const[i,a]=S.useState(!1),[o,c]=S.useState(null),d=async()=>{a(!0),c(null);try{await e(),c({ok:!0,message:"Git repository initialized!"})}catch(f){const x=f instanceof Error?f.message:"Failed";x.includes("not installed")||x.includes("noGitBinary")?c({ok:!1,message:"git is not installed on this system"}):c({ok:!1,message:x})}finally{a(!1)}},m=o&&!o.ok&&o.message.includes("not installed");return l.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(211,47,47,0.05)",border:"1px solid var(--pixel-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"No Git Repository"}),!o&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"This project has no git repository. Initialize one to start saving."}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:d,disabled:i,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:i?"INITIALIZING...":"GIT INIT"}),t&&l.jsxs("button",{onClick:t,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["🤖"," ",(n==null?void 0:n.toUpperCase())??"AI"," FIX"]})]})]}),o&&o.ok&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:o.message}),m&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"#EF5350"},children:"git is not installed on this system."}),l.jsxs("div",{className:"text-[10px] space-y-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:[l.jsx("b",{children:"macOS:"})," xcode-select --install"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Ubuntu/Debian:"})," sudo apt install git"]}),l.jsxs("div",{children:[l.jsx("b",{children:"Windows:"})," ",l.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"git-scm.com/downloads"})]})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:()=>{c(null)},className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),t&&l.jsxs("button",{onClick:t,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},children:["🤖"," ",(n==null?void 0:n.toUpperCase())??"AI"," FIX"]})]})]}),o&&!o.ok&&!m&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:o.message})]})}function tL({repo:e,onConnected:t,onDelegate:n,delegateRoleName:i}){const[a,o]=S.useState("idle"),[c,d]=S.useState(null),[m,f]=S.useState(""),[x,p]=S.useState("private"),[y,g]=S.useState(""),[w,k]=S.useState(null),[j,C]=S.useState(!1),N=async()=>{o("checking"),k(null);try{const D=await ke.getGithubStatus(e);d(D),D.hasRemote?t():D.ghInstalled&&D.authenticated?o("ready"):o("idle")}catch{o("idle")}},E=async()=>{if(m.trim()){C(!0),k(null);try{const D=await ke.githubCreateRepo(m.trim(),x,e);k(D),D.ok&&setTimeout(t,1500)}catch(D){k({ok:!1,message:D instanceof Error?D.message:"Failed"})}finally{C(!1)}}},A=async()=>{if(y.trim()){C(!0),k(null);try{const D=await ke.addRemote(y.trim(),e);k(D),D.ok&&setTimeout(t,1500)}catch(D){k({ok:!1,message:D instanceof Error?D.message:"Failed"})}finally{C(!1)}}},z=n?l.jsxs("button",{onClick:n,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--idle-amber)",border:"1px solid var(--idle-amber)"},title:`Ask ${i??"AI"} to set up GitHub remote`,children:["🤖"," ",(i==null?void 0:i.toUpperCase())??"AI"," FIX"]}):null;return l.jsxs("div",{className:"p-3 space-y-2",style:{background:"rgba(100,100,255,0.05)",border:"1px solid var(--pixel-border)"},children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"No Remote — Local Only"}),a==="idle"&&!c&&l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:N,className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"CONNECT GITHUB"}),l.jsx("button",{onClick:()=>o("manual"),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),z]}),a==="checking"&&l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:"Checking GitHub CLI..."}),a==="idle"&&c&&!c.ghInstalled&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI (gh) not installed."}),l.jsxs("div",{className:"text-[10px] space-y-0.5",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("div",{children:["Install:"," ",l.jsx("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"cli.github.com"})]}),l.jsx("div",{style:{fontFamily:"var(--pixel-font)"},children:"brew install gh && gh auth login"})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:N,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>o("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD URL MANUALLY"}),z]})]}),a==="idle"&&c&&c.ghInstalled&&!c.authenticated&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-[10px]",style:{color:"var(--idle-amber)"},children:"GitHub CLI installed but not logged in."}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)",fontFamily:"var(--pixel-font)"},children:"Run in terminal: gh auth login"}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx("button",{onClick:N,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--accent)",color:"#fff",border:"none"},children:"RETRY"}),l.jsx("button",{onClick:()=>o("manual"),className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:"ADD REMOTE URL"}),z]})]}),a==="ready"&&c&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--active-green)"},children:["Logged in as ",c.username||"GitHub user"]}),l.jsxs("div",{className:"flex gap-2 items-center",children:[l.jsx("input",{type:"text",value:m,onChange:D=>f(D.target.value),placeholder:"repository-name",className:"flex-1 px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("select",{value:x,onChange:D=>p(D.target.value),className:"px-2 py-1.5 text-[10px] outline-none cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:[l.jsx("option",{value:"private",children:"Private"}),l.jsx("option",{value:"public",children:"Public"})]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:E,disabled:j||!m.trim(),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:j?"CREATING...":"CREATE & PUSH"}),l.jsx("button",{onClick:()=>o("manual"),className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"USE URL INSTEAD"})]})]}),a==="manual"&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("a",{href:"https://github.com/new",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)",textDecoration:"underline"},children:"Create a new repo on GitHub"})," ","then paste the URL below:"]}),l.jsx("input",{type:"text",value:y,onChange:D=>g(D.target.value),placeholder:"https://github.com/username/repo-name.git",className:"w-full px-2 py-1.5 text-[11px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:A,disabled:j||!y.trim(),className:"text-[10px] font-bold px-3 py-1.5 cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"none"},children:j?"ADDING...":"ADD REMOTE & PUSH"}),l.jsx("button",{onClick:()=>{o("idle"),d(null)},className:"text-[10px] px-2 py-1 cursor-pointer",style:{background:"transparent",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"BACK"})]})]}),w&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:w.ok?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${w.ok?"var(--active-green)":"#D32F2F"}`,color:w.ok?"var(--active-green)":"#EF5350"},children:w.message})]})}function nL({status:e,history:t,onClose:n,onSave:i,onLoadHistory:a,onRestore:o,saving:c,onDelegate:d,delegateRoleName:m,repo:f,onRepoChange:x,syncInfo:p,onPull:y,pulling:g,onRefresh:w,onInitGit:k}){const[j,C]=S.useState("save"),[N,E]=S.useState(""),[A,z]=S.useState(null),[D,F]=S.useState(!1),[q,V]=S.useState(null),[L,_]=S.useState(null),B=S.useRef(null);S.useEffect(()=>{j==="history"&&a()},[j,a]),S.useEffect(()=>{var M;(M=B.current)==null||M.focus()},[]);const X=[...((e==null?void 0:e.modified)??[]).map(M=>({status:"M",file:M})),...((e==null?void 0:e.untracked)??[]).map(M=>({status:"A",file:M}))],R=S.useRef(!1);S.useEffect(()=>{!R.current&&X.length>0&&!N&&(E(l2(X)),R.current=!0)},[X.length]),S.useEffect(()=>{R.current=!1,E(""),_(null),V(null),z(null)},[f]);const H=S.useCallback(()=>{E(l2(X))},[X]),$=async()=>{z(null),V(null);try{const M=await i(N||void 0);V(M),E("")}catch(M){z(M instanceof Error?M.message:"Save failed")}},G=async()=>{_(null),z(null);try{const M=await y();_(M)}catch(M){z(M instanceof Error?M.message:"Pull failed")}},Q=async M=>{if(confirm(`Restore from commit ${M.slice(0,7)}? This creates a new commit with those files.`)){F(!0);try{await o(M),F(!1)}catch(U){z(U instanceof Error?U.message:"Restore failed"),F(!1)}}};S.useEffect(()=>{const M=U=>{U.key==="Escape"&&n()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[n]);const K=M=>{M.key==="Enter"&&(M.metaKey||M.ctrlKey)&&$()};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:n}),l.jsxs("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] max-h-[80vh] z-[61] overflow-hidden flex flex-col",style:{background:"var(--hud-bg)",border:"3px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",color:"var(--terminal-text)"},onKeyDown:K,children:[l.jsxs("div",{className:"px-5 py-3 flex items-center justify-between shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-lg font-black tracking-tight",children:"SAVE COMPANY"}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-secondary)"},children:(e==null?void 0:e.branch)??""})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[p&&p.hasRemote&&(p.behind>0||p.ahead>0)&&l.jsxs("span",{className:"text-[10px] font-bold",style:{color:p.behind>0?"var(--idle-amber)":"var(--active-green)"},children:[p.behind>0&&`↓${p.behind}`,p.behind>0&&p.ahead>0&&" ",p.ahead>0&&`↑${p.ahead}`]}),l.jsx("button",{onClick:n,className:"text-[var(--terminal-text-secondary)] hover:text-[var(--terminal-text)] cursor-pointer text-lg",children:"×"})]})]}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["akb","code"].map(M=>l.jsx("button",{onClick:()=>x(M),className:"flex-1 py-1.5 text-[10px] font-bold uppercase tracking-wider cursor-pointer",style:{background:f===M?"var(--hud-bg-alt)":"transparent",color:f===M?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:f===M?"2px solid var(--accent)":"2px solid transparent"},children:M==="akb"?"AKB":"CODE"},M))}),l.jsx("div",{className:"flex shrink-0",style:{borderBottom:"2px solid var(--pixel-border)"},children:["save","history"].map(M=>l.jsx("button",{onClick:()=>C(M),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:j===M?"var(--hud-bg-alt)":"transparent",color:j===M?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:j===M?"2px solid var(--accent)":"2px solid transparent"},children:M==="save"?"SAVE":"HISTORY"},M))}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:[j==="save"&&l.jsxs(l.Fragment,{children:[(e==null?void 0:e.noGit)&&l.jsx(eL,{onInitGit:async()=>{await(k==null?void 0:k()),w==null||w()},onDelegate:d?()=>{d(`Git is not initialized or not installed for this project. Please check if git is installed (run "git --version"). If git is available, initialize the repository with "git init" and make an initial commit. If git is not installed, provide clear instructions for the user's OS to install it.`)}:void 0,delegateRoleName:m}),p&&p.hasRemote&&p.behind>0&&l.jsxs("div",{className:"flex items-center justify-between p-2",style:{background:"rgba(255,180,0,0.08)",border:"1px solid var(--idle-amber)"},children:[l.jsxs("span",{className:"text-[11px]",style:{color:"var(--idle-amber)"},children:[p.behind," commit",p.behind>1?"s":""," behind remote"]}),l.jsx("button",{onClick:G,disabled:g,className:"text-[10px] font-bold px-3 py-1 cursor-pointer",style:{background:"var(--idle-amber)",color:"#000",border:"none",opacity:g?.5:1},children:g?"PULLING...":"↓ PULL"})]}),L&&l.jsx("div",{className:"text-[11px] p-2",style:{background:L.status==="ok"||L.status==="up-to-date"?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${L.status==="ok"||L.status==="up-to-date"?"var(--active-green)":"#D32F2F"}`,color:L.status==="ok"||L.status==="up-to-date"?"var(--active-green)":"#EF5350"},children:L.message}),l.jsx("div",{className:"text-[11px]",style:{color:"var(--terminal-text-secondary)"},children:X.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",X.length," unsaved change",X.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),X.length>0&&l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider mb-2",style:{color:"var(--terminal-text-muted)"},children:"Changed Files"}),l.jsx("div",{className:"text-[11px] max-h-[160px] overflow-y-auto p-2 space-y-0.5",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)"},children:X.map(({status:M,file:U})=>l.jsxs("div",{className:"flex gap-2",children:[l.jsx("span",{style:{color:M==="A"?"var(--active-green)":"var(--idle-amber)",width:"14px"},children:M}),l.jsx("span",{style:{color:"var(--terminal-text-secondary)"},children:U})]},U))})]}),X.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"var(--terminal-text-muted)"},children:"Save Message"}),l.jsxs("button",{onClick:H,className:"text-[9px] px-1.5 py-0.5 cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--accent)",fontFamily:"var(--pixel-font)"},title:"Auto-generate message from changes",children:["✨"," AUTO"]})]}),l.jsx("input",{ref:B,type:"text",value:N,onChange:M=>E(M.target.value),placeholder:"Auto-generated — edit if needed",className:"w-full px-3 py-2 text-[12px] outline-none",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"}})]}),X.length>0&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:$,disabled:c,className:"flex-1 py-2.5 text-[12px] font-black uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--accent)",color:"#fff",border:"2px solid var(--accent)"},children:c?"SAVING...":e!=null&&e.hasRemote?"SAVE & PUSH":"SAVE"}),d&&l.jsxs("button",{onClick:()=>{const M=X.map(U=>`${U.status} ${U.file}`).join(`
120
+ `);d(M)},disabled:c,className:"py-2.5 px-4 text-[11px] font-bold uppercase tracking-wider cursor-pointer disabled:opacity-50",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"2px solid var(--pixel-border)"},title:`Delegate to ${m??"AI role"} — they'll review, commit, push & merge`,children:["🤖"," ",(m==null?void 0:m.toUpperCase())??"DELEGATE"]})]}),e&&!e.hasRemote&&!e.noGit&&l.jsx(tL,{repo:f,onConnected:()=>w==null?void 0:w(),onDelegate:d?()=>{d(`Set up a GitHub remote for the ${f==="akb"?"AKB":"Code"} repository and push all commits. If gh CLI is available, use "gh repo create". Otherwise, guide through manual setup. Current repo path can be found in config.`)}:void 0,delegateRoleName:m}),q&&l.jsxs("div",{className:"text-[11px] p-2",style:{background:"rgba(59,185,80,0.1)",border:"1px solid var(--active-green)",color:"var(--active-green)"},children:["Saved! ",q.filesChanged," file",q.filesChanged>1?"s":""," committed",q.pushed?" & pushed":"",q.pushError?` (push error: ${q.pushError})`:""]}),A&&l.jsx("div",{className:"text-[11px] p-2",style:{background:"rgba(211,47,47,0.1)",border:"1px solid #D32F2F",color:"#EF5350"},children:A}),(e==null?void 0:e.lastCommit)&&l.jsxs("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:["Last save: ",e.lastCommit.message," (",o2(e.lastCommit.date),")"]})]}),j==="history"&&l.jsxs(l.Fragment,{children:[t.length===0&&l.jsx("div",{className:"text-[11px] text-center py-8",style:{color:"var(--terminal-text-muted)"},children:"No save history"}),l.jsx("div",{className:"space-y-1",children:t.map(M=>l.jsxs("div",{className:"flex items-center justify-between py-2 px-3 group",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--accent)"},children:M.shortSha}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:M.message})]}),l.jsx("div",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:o2(M.date)})]}),l.jsx("button",{onClick:()=>Q(M.sha),disabled:D,className:"text-[10px] font-bold px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--idle-amber)"},children:"LOAD"})]},M.sha))})]})]})]})]})}function rL({onClose:e}){const[t,n]=S.useState(null),[i,a]=S.useState(!0),[o,c]=S.useState(null),[,d]=S.useState(!1);return S.useEffect(()=>{Promise.all([ke.getCompanyStats(),ke.getPreferences()]).then(async([m,f])=>{n(m);const x=f;if(x.instanceId)try{await ur.syncStats({instanceId:x.instanceId,roleCount:m.company.roleCount,totalTokens:m.company.totalTokens,rolesData:m.roles.map(p=>({roleId:p.roleId,name:p.name,tokens:p.totalTokens}))}),d(!0)}catch{}}).catch(m=>c(m.message)).finally(()=>a(!1))},[]),i?l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading stats..."}):o||!t?l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[o||"Failed to load stats",l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]}):l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Company Stats"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginBottom:20},children:[l.jsx(Jd,{label:"Roles",value:String(t.company.roleCount)}),l.jsx(Jd,{label:"Avg Level",value:`Lv.${t.company.avgLevel}`}),l.jsx(Jd,{label:"Total Tokens",value:t.company.formattedTokens}),l.jsx(Jd,{label:"Total Cost",value:`$${t.company.totalCostUsd.toFixed(2)}`})]}),l.jsx("h4",{style:{margin:"0 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Role Leaderboard"}),l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.roles.map((m,f)=>l.jsx(iL,{role:m,rank:f+1},m.roleId)),t.roles.length===0&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"8px 0"},children:"No role activity yet. Assign tasks to start leveling up!"})]}),Object.keys(t.byModel).length>0&&l.jsxs(l.Fragment,{children:[l.jsx("h4",{style:{margin:"20px 0 12px",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},children:"Model Usage"}),l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:Object.entries(t.byModel).map(([m,f])=>l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",background:"rgba(255,255,255,0.03)",borderRadius:6,fontSize:12},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.7)"},children:sL(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",f.costUsd.toFixed(2)]})]},m))})]})]})}function Jd({label:e,value:t}){return l.jsxs("div",{style:{padding:"12px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[l.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.45)",marginBottom:4},children:e}),l.jsx("div",{style:{fontSize:18,fontWeight:600},children:t})]})}function iL({role:e,rank:t}){const n=["🥇","🥈","🥉"],i=t<=3?n[t-1]:`#${t}`;return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",background:"rgba(255,255,255,0.03)",borderRadius:8},children:[l.jsx("span",{style:{fontSize:14,width:28,textAlign:"center",flexShrink:0},children:i}),l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:4},children:[l.jsx("span",{style:{fontSize:13,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),l.jsxs("span",{style:{fontSize:12,color:c2(e.level),fontWeight:600,flexShrink:0,marginLeft:8},children:["Lv.",e.level]})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("div",{style:{flex:1,height:4,background:"rgba(255,255,255,0.08)",borderRadius:2,overflow:"hidden"},children:l.jsx("div",{style:{width:`${e.progress*100}%`,height:"100%",background:c2(e.level),borderRadius:2,transition:"width 0.3s ease"}})}),l.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",flexShrink:0},children:e.formattedTokens})]})]})]})}function c2(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function sL(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function aL({onClose:e,onSyncComplete:t}){const[n,i]=S.useState([]),[a,o]=S.useState([]),[c,d]=S.useState(!0),[m,f]=S.useState(null),[x,p]=S.useState(new Set),[y,g]=S.useState(null),[w,k]=S.useState(null),j=S.useCallback(async()=>{d(!0),g(null);try{const{roles:N}=await ke.getSyncRoles();i(N);const E=N.filter(A=>A.source.sync!=="off");if(E.length===0){o([]),k(null);return}try{const A=await ur.syncCheck(E.map(D=>({roleId:D.roleId,sourceId:D.source.id,currentVersion:D.source.upstream_version??D.source.forked_at??"0.0.0"})));k(!0);const z=[];for(const D of A.updates){if(!D.hasUpdate)continue;const F=E.find(B=>B.roleId===D.roleId);if(!F)continue;const{character:q}=await ur.syncPull(D.sourceId),V=[];F.persona.trim()!==q.persona.trim()&&V.push({field:"persona",local:F.persona.slice(0,120)+(F.persona.length>120?"...":""),upstream:q.persona.slice(0,120)+(q.persona.length>120?"...":"")});const L=JSON.stringify(F.authority),_=JSON.stringify(q.authority);L!==_&&V.push({field:"authority",local:`${F.authority.autonomous.length} autonomous, ${F.authority.needsApproval.length} approval`,upstream:`${q.authority.autonomous.length} autonomous, ${q.authority.needsApproval.length} approval`}),V.length>0&&z.push({roleId:D.roleId,roleName:F.name,sourceId:D.sourceId,currentVersion:D.currentVersion,latestVersion:D.latestVersion,fields:V})}o(z)}catch{k(!1),o([])}}catch(N){g(N instanceof Error?N.message:"Failed to check for updates")}finally{d(!1)}},[]);S.useEffect(()=>{j()},[j]);const C=async N=>{f(N.roleId);try{const{character:E,version:A}=await ur.syncPull(N.sourceId);await ke.applySyncUpdate({roleId:N.roleId,changes:{persona:E.persona,authority:E.authority},upstreamVersion:A}),p(z=>new Set(z).add(N.roleId)),t==null||t()}catch(E){g(E instanceof Error?E.message:"Failed to apply update")}finally{f(null)}};return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"Role Sync"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:j,disabled:c,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:c?"wait":"pointer"},children:c?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),w===!1&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,180,0,0.1)",borderRadius:6,color:"#FFB74D",fontSize:12,marginBottom:12},children:"Cloud API unreachable. Sync requires connection to api.tycono.ai."}),y&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:y}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Tracked roles: "}),l.jsx("span",{style:{fontWeight:500},children:n.length}),l.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"·"}),l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Updates available: "}),l.jsx("span",{style:{fontWeight:500,color:a.length>0?"#4FC3F7":"rgba(255,255,255,0.7)"},children:a.filter(N=>!x.has(N.roleId)).length}),w===!0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.3)",margin:"0 8px"},children:"·"}),l.jsx("span",{style:{fontSize:11,color:"#81C784"},children:"Cloud connected"})]})]}),a.length===0&&!c&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:n.length===0?"No roles with source tracking. Hire from the Store to enable sync.":"All roles are up to date!"}),a.map(N=>l.jsxs("div",{style:{marginBottom:12,padding:14,background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:14,fontWeight:500},children:N.roleName}),l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[N.sourceId," · v",N.currentVersion," → v",N.latestVersion]})]}),x.has(N.roleId)?l.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied ✓"}):l.jsx("button",{onClick:()=>C(N),disabled:m===N.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:m===N.roleId?"wait":"pointer",opacity:m===N.roleId?.6:1},children:m===N.roleId?"Applying...":"Apply Update"})]}),N.fields.map(E=>l.jsxs("div",{style:{marginBottom:6,fontSize:12},children:[l.jsx("div",{style:{color:"rgba(255,255,255,0.5)",marginBottom:2,textTransform:"uppercase",fontSize:10,letterSpacing:.5},children:E.field}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[l.jsxs("div",{style:{padding:"4px 8px",background:"rgba(255,100,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[l.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"LOCAL"}),l.jsx("br",{}),E.local]}),l.jsxs("div",{style:{padding:"4px 8px",background:"rgba(100,255,100,0.08)",borderRadius:4,color:"rgba(255,255,255,0.6)"},children:[l.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.3)"},children:"UPSTREAM"}),l.jsx("br",{}),E.upstream]})]})]},E.field))]},N.roleId)),n.length>0&&l.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Roles hired from the Store are tracked automatically. Set ",l.jsx("code",{style:{background:"rgba(255,255,255,0.06)",padding:"1px 4px",borderRadius:3},children:"sync: off"})," in role.yaml to stop tracking."]})]})}function lL({onClose:e}){const[t,n]=S.useState(null),[i,a]=S.useState(!0),[o,c]=S.useState(null),[d,m]=S.useState(null),f=S.useCallback(async()=>{a(!0),c(null);try{const N=await ke.getGitStatus();n(N)}catch(N){c(N instanceof Error?N.message:"Failed to load git status")}finally{a(!1)}},[]);S.useEffect(()=>{f()},[f]);const x=async N=>{m(N.path);try{await ke.deleteWorktree(N.path),await f()}catch(E){c(E instanceof Error?E.message:"Failed to remove worktree")}finally{m(null)}},p=async N=>{m(N);try{await ke.deleteBranch(N),await f()}catch(E){c(E instanceof Error?E.message:"Failed to delete branch")}finally{m(null)}};if(i&&!t)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading git status..."});if(o&&!t)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[o,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!t)return null;const y=t.worktrees.filter(N=>N.status==="active"),g=t.worktrees.filter(N=>N.status==="pending-merge"),w=t.worktrees.filter(N=>N.status==="stale");function k(N){const E=N.split("/");if(E.length>1){const A=E[E.length-1],z=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const D of z)if(A.toLowerCase().includes(D))return D}return null}function j(N,E=40){return N.length<=E?N:"..."+N.slice(N.length-E+3)}function C(N){const E=Date.now()-new Date(N).getTime(),A=Math.floor(E/6e4);if(A<1)return"just now";if(A<60)return`${A}m ago`;const z=Math.floor(A/60);return z<24?`${z}h ago`:`${Math.floor(z/24)}d ago`}return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"GIT STATUS"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:f,disabled:i,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:i?"wait":"pointer"},children:i?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),o&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:o}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Branch: "}),l.jsx("span",{style:{fontWeight:500},children:t.currentBranch})]}),l.jsx("div",{children:t.unsavedCount>0&&l.jsxs("span",{style:{color:"#FFB74D",fontSize:12},children:[t.unsavedCount," unsaved"]})})]}),t.lastCommit&&l.jsxs("div",{style:{marginTop:6,fontSize:11,color:"rgba(255,255,255,0.4)"},children:["Last commit: ",t.lastCommit.message.slice(0,60),t.lastCommit.message.length>60?"...":""," · ",C(t.lastCommit.date)]})]}),y.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ef,{label:"Active Worktrees",count:y.length}),y.map(N=>l.jsx(Kp,{wt:N,roleFromBranch:N.roleId||k(N.branch),truncatePath:j,timeAgo:C,removing:d===N.path,onRemove:()=>x(N),statusColor:"#4FC3F7",statusIcon:"📂"},N.path))]}),g.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ef,{label:"Pending Merge",count:g.length}),g.map(N=>l.jsx(Kp,{wt:N,roleFromBranch:N.roleId||k(N.branch),truncatePath:j,timeAgo:C,removing:d===N.path,onRemove:()=>x(N),statusColor:"#FFB74D",statusIcon:"⚠️"},N.path))]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ef,{label:"Stale",count:w.length}),w.map(N=>l.jsx(Kp,{wt:N,roleFromBranch:N.roleId||k(N.branch),truncatePath:j,timeAgo:C,removing:d===N.path,onRemove:()=>x(N),statusColor:"#ff6b6b",statusIcon:"🔴"},N.path))]}),t.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(ef,{label:"Unmerged Branches",count:t.staleBranches.length}),t.staleBranches.map(N=>l.jsxs("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{style:{fontSize:13},children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)",marginRight:6},children:"⚠️"}),l.jsx("span",{style:{fontWeight:500},children:N})]}),l.jsx("button",{onClick:()=>p(N),disabled:d===N,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:d===N?"wait":"pointer",opacity:d===N?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:d===N?"...":"DELETE"})]},N))]}),y.length===0&&g.length===0&&w.length===0&&t.staleBranches.length===0&&l.jsxs("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:["✓"," All clean. No active worktrees or stale branches."]}),t.lastMerge&&l.jsxs("div",{style:{marginTop:16,fontSize:11,color:"rgba(255,255,255,0.3)",lineHeight:1.5},children:["Last merge: ",l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:t.lastMerge.branch})," · ",t.lastMerge.roleId," · ",C(t.lastMerge.mergedAt)]})]})}function ef({label:e,count:t}){return l.jsxs("h4",{style:{margin:"16px 0 8px",fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:1},children:[e," (",t,")"]})}function Kp({wt:e,roleFromBranch:t,truncatePath:n,timeAgo:i,removing:a,onRemove:o,statusColor:c,statusIcon:d}){return l.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[l.jsx("span",{style:{marginRight:6},children:d}),e.branch,t&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)",textTransform:"uppercase"},children:t})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:2},children:['"',e.task.slice(0,50),e.task.length>50?"...":"",'"']}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[n(e.path)," · ",e.filesChanged," file",e.filesChanged!==1?"s":""," changed"," · ",i(e.createdAt)]}),e.conflictFiles&&e.conflictFiles.length>0&&l.jsxs("div",{style:{fontSize:10,color:"#ff6b6b",marginTop:4},children:["⛔"," CONFLICT: ",e.conflictFiles.join(", ")]})]}),l.jsx("button",{onClick:o,disabled:a,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:c,borderRadius:4,padding:"3px 8px",fontSize:10,cursor:a?"wait":"pointer",opacity:a?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,flexShrink:0,marginLeft:8},children:a?"...":"REMOVE"})]})})}function oL({onClose:e,onOpenSession:t}){const[n,i]=S.useState(null),[a,o]=S.useState(!0),[c,d]=S.useState(null),[m,f]=S.useState(null),x=S.useCallback(async()=>{o(!0),d(null);try{const j=await ke.getActiveSessions();i(j)}catch(j){d(j instanceof Error?j.message:"Failed to load sessions")}finally{o(!1)}},[]);S.useEffect(()=>{x();const j=setInterval(x,1e4);return()=>clearInterval(j)},[x]);const p=async j=>{f(j);try{await ke.deleteActiveSession(j),await x()}catch(C){d(C instanceof Error?C.message:"Failed to remove session")}finally{f(null)}},y=async()=>{try{await ke.cleanupActiveSessions(),await x()}catch(j){d(j instanceof Error?j.message:"Failed to cleanup sessions")}};if(a&&!n)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading sessions..."});if(c&&!n)return l.jsxs("div",{style:{padding:24,color:"#ff6b6b"},children:[c,l.jsx("button",{onClick:e,style:{marginLeft:12,color:"rgba(255,255,255,0.6)",background:"none",border:"none",cursor:"pointer"},children:"Close"})]});if(!n)return null;const g=n.sessions.filter(j=>j.status==="active"),w=n.sessions.filter(j=>j.status==="idle"),k=n.sessions.filter(j=>j.status==="dead");return l.jsxs("div",{style:{padding:20,color:"rgba(255,255,255,0.9)",maxHeight:"100%",overflowY:"auto"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:"ACTIVE SESSIONS"}),l.jsxs("div",{style:{display:"flex",gap:8},children:[k.length>0&&l.jsx("button",{onClick:y,style:{background:"rgba(255,180,100,0.15)",border:"1px solid rgba(255,180,100,0.2)",color:"#FFB74D",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Cleanup Dead"}),l.jsx("button",{onClick:x,disabled:a,style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.7)",borderRadius:6,padding:"4px 10px",fontSize:12,cursor:a?"wait":"pointer"},children:a?"Checking...":"Refresh"}),l.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"rgba(255,255,255,0.5)",cursor:"pointer",fontSize:18},children:"×"})]})]}),c&&l.jsx("div",{style:{padding:"8px 12px",background:"rgba(255,100,100,0.1)",borderRadius:6,color:"#ff6b6b",fontSize:12,marginBottom:12},children:c}),l.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,255,255,0.04)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)",marginBottom:16,fontSize:13,display:"flex",justifyContent:"space-between"},children:[l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Sessions: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.active})]}),l.jsxs("div",{children:[l.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Ports in use: "}),l.jsx("span",{style:{fontWeight:500},children:n.summary.totalPorts})]})]}),g.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Qp,{label:"Active",count:g.length}),g.map(j=>l.jsx(Zp,{session:j,removing:m===j.sessionId,onRemove:()=>p(j.sessionId),statusColor:"#4FC3F7",onOpen:t},j.sessionId))]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Qp,{label:"Idle",count:w.length}),w.map(j=>l.jsx(Zp,{session:j,removing:m===j.sessionId,onRemove:()=>p(j.sessionId),statusColor:"#FFB74D",onOpen:t},j.sessionId))]}),k.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Qp,{label:"Dead",count:k.length}),k.map(j=>l.jsx(Zp,{session:j,removing:m===j.sessionId,onRemove:()=>p(j.sessionId),statusColor:"#ff6b6b",onOpen:t},j.sessionId))]}),n.sessions.length===0&&l.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:13,padding:"20px 0",textAlign:"center"},children:"No active sessions. Sessions appear when jobs run with port allocation."})]})}function Qp({label:e,count:t}){return l.jsxs("h4",{style:{margin:"16px 0 8px",fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:1},children:[e," (",t,")"]})}function cL(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Zp({session:e,removing:t,onRemove:n,statusColor:i,onOpen:a}){const{ports:o}=e;return l.jsx("div",{style:{marginBottom:8,padding:"10px 14px",background:"rgba(255,255,255,0.03)",borderRadius:8,border:"1px solid rgba(255,255,255,0.06)"},children:l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:500,marginBottom:2},children:[l.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:i,marginRight:8,verticalAlign:"middle"}}),l.jsx("span",{style:{textTransform:"uppercase"},children:e.roleName||e.roleId}),e.messageStatus&&l.jsx("span",{style:{marginLeft:8,fontSize:10,padding:"1px 6px",background:"rgba(255,255,255,0.08)",borderRadius:3,color:"rgba(255,255,255,0.6)"},children:e.messageStatus})]}),e.task&&l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:4},children:['"',e.task.slice(0,60),e.task.length>60?"...":"",'"']}),l.jsxs("div",{style:{fontSize:11,display:"flex",gap:8,marginBottom:2},children:[l.jsxs("span",{style:{color:"#81C784"},children:["API:",o.api||"?"]}),l.jsxs("span",{style:{color:"#64B5F6"},children:["Vite:",o.vite||"?"]}),o.hmr&&l.jsxs("span",{style:{color:"#FFB74D"},children:["HMR:",o.hmr]})]}),l.jsxs("div",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:[e.sessionId.slice(0,12),"...",e.worktreePath&&l.jsxs(l.Fragment,{children:[" · ",uL(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",cL(e.startedAt)]})]}),l.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0,marginLeft:8},children:[l.jsx("button",{onClick:()=>a==null?void 0:a(e.roleId,e.sessionId),style:{background:"rgba(100,200,255,0.15)",border:"1px solid rgba(100,200,255,0.2)",color:"#64B5F6",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:"pointer",fontWeight:600,textTransform:"uppercase",letterSpacing:.5},title:"Open session chat",children:"OPEN"}),l.jsx("button",{onClick:n,disabled:t,style:{background:"rgba(255,100,100,0.15)",border:"1px solid rgba(255,100,100,0.2)",color:"#ff6b6b",borderRadius:4,padding:"3px 8px",fontSize:10,cursor:t?"wait":"pointer",opacity:t?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:t?"...":"STOP"})]})]})})}function uL(e,t=35){return e.length<=t?e:"..."+e.slice(e.length-t+3)}function dL({onClose:e,speechSettings:t,onSpeechSettingsChange:n,language:i,onLanguageChange:a,onOpenSync:o,onOpenGitStatus:c,onOpenSessions:d,onOpenStats:m}){var G;const[f,x]=S.useState(null),[p,y]=S.useState(null),[g,w]=S.useState(!1),[k,j]=S.useState(!1),[C,N]=S.useState(!1),[E,A]=S.useState(null),[z,D]=S.useState(""),[F,q]=S.useState(!1),[V,L]=S.useState(!1),[_,B]=S.useState(null),[X,R]=S.useState(!1);S.useEffect(()=>{ke.getPreferences().then(async Q=>{const K=Q;if(x(K.instanceId??null),K.instanceId)try{const{name:M}=await ur.getMyName(K.instanceId);y(M)}catch{}}).catch(()=>{}),ke.getCodeRoot().then(({codeRoot:Q})=>{A(Q),Q&&D(Q)}).catch(()=>{})},[]);const H=async()=>{N(!0);try{const K=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();K.ok&&(x(K.newInstanceId),j(!1))}catch{}N(!1)},$=()=>{f&&navigator.clipboard.writeText(f).then(()=>{w(!0),setTimeout(()=>w(!1),2e3)})};return l.jsx("div",{className:"customize-overlay",onClick:e,children:l.jsxs("div",{className:"customize-modal",onClick:Q=>Q.stopPropagation(),style:{maxWidth:480},children:[l.jsxs("div",{className:"customize-header",children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,letterSpacing:1,color:"var(--terminal-text)"},children:"SETTINGS"}),l.jsx("button",{className:"customize-close",onClick:e,children:"X"})]}),l.jsx("div",{className:"customize-body",style:{padding:"12px 20px 20px"},children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"AMBIENT SPEECH MODE"}),l.jsx("div",{style:{display:"flex",gap:6},children:["template","llm","auto"].map(Q=>l.jsxs("button",{onClick:()=>n==null?void 0:n({mode:Q}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(t==null?void 0:t.mode)===Q?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(t==null?void 0:t.mode)===Q?"rgba(255,255,255,0.08)":"transparent",color:(t==null?void 0:t.mode)===Q?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:Q==="template"?"TEMPLATE":Q==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:Q==="template"?"Static pool ($0)":Q==="llm"?"LLM generated":"Detect engine"})]},Q))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Auto: CLI Max = AI, BYOK = Template"})]}),l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["SPEECH INTERVAL: ",(t==null?void 0:t.intervalSec)??18,"s"]}),l.jsx("input",{type:"range",min:5,max:120,step:5,value:(t==null?void 0:t.intervalSec)??18,onChange:Q=>n==null?void 0:n({intervalSec:Number(Q.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"5s (frequent)"}),l.jsx("span",{children:"120s (rare)"})]})]}),(t==null?void 0:t.mode)!=="template"&&l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:["DAILY LLM BUDGET: $",((G=t==null?void 0:t.dailyBudgetUsd)==null?void 0:G.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(t==null?void 0:t.dailyBudgetUsd)??1,onChange:Q=>n==null?void 0:n({dailyBudgetUsd:Number(Q.target.value)}),style:{width:"100%",accentColor:"var(--accent)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--terminal-text-muted)"},children:[l.jsx("span",{children:"$0 (unlimited)"}),l.jsx("span",{children:"$5.00/day"})]})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"LANGUAGE"}),l.jsx("div",{style:{display:"flex",gap:6},children:[{key:"auto",label:"Auto"},{key:"en",label:"English"},{key:"ko",label:"한국어"},{key:"ja",label:"日本語"}].map(({key:Q,label:K})=>l.jsx("button",{onClick:()=>a==null?void 0:a(Q),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===Q?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===Q?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===Q?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:K},Q))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"CODE REPOSITORY"}),F?l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:z,onChange:Q=>{D(Q.target.value),B(null)},placeholder:"/path/to/code/repo",style:{flex:1,padding:"8px 10px",fontSize:11,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:6,color:"var(--terminal-text)",fontFamily:"monospace",outline:"none"},autoFocus:!0}),l.jsx("button",{onClick:async()=>{if(z.trim()){L(!0),B(null);try{const Q=await ke.setCodeRoot(z.trim());A(Q.codeRoot),D(Q.codeRoot),q(!1),R(!0),setTimeout(()=>R(!1),3e3)}catch(Q){B(Q instanceof Error?Q.message:"Failed to set code root")}finally{L(!1)}}},disabled:V||!z.trim(),style:{padding:"8px 12px",fontSize:10,fontWeight:600,background:"var(--accent)",border:"none",color:"#fff",borderRadius:6,cursor:"pointer",opacity:V||!z.trim()?.5:1},children:V?"...":"Save"}),l.jsx("button",{onClick:()=>{q(!1),D(E||""),B(null)},style:{padding:"8px 10px",fontSize:10,background:"transparent",border:"1px solid rgba(255,255,255,0.1)",color:"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer"},children:"Cancel"})]}),_&&l.jsx("div",{style:{fontSize:9,color:"#ff6b6b",marginTop:4},children:_})]}):l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l.jsx("code",{style:{flex:1,padding:"8px 10px",fontSize:10,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:E?"var(--terminal-text)":"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E||"Not configured"}),l.jsx("button",{onClick:()=>{q(!0),B(null),R(!1)},style:{padding:"8px 12px",fontSize:10,fontWeight:600,border:"2px solid rgba(255,255,255,0.1)",background:"transparent",color:"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer"},children:"Change"})]}),X&&l.jsx("div",{style:{fontSize:9,color:"#4ade80",marginTop:4},children:"Code repository updated!"}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Path to your code repository (separate from AKB). If not set, auto-created as ../[company]-code/ when AI starts working."})]}),f&&l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:8,color:"var(--terminal-text)"},children:"STORE TOKEN"}),l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[l.jsx("code",{style:{flex:1,padding:"8px 10px",fontSize:10,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f}),l.jsx("button",{onClick:$,style:{padding:"8px 12px",fontSize:10,fontWeight:600,border:"2px solid rgba(255,255,255,0.1)",background:"transparent",color:g?"#4ade80":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",whiteSpace:"nowrap"},children:g?"Copied!":"Copy"})]}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Use this token to sign in on the web Store. Keep it secret — anyone with this token can act as you."}),l.jsx("div",{style:{marginTop:6},children:k?l.jsxs("div",{style:{background:"rgba(255,50,50,0.08)",border:"1px solid rgba(255,50,50,0.2)",borderRadius:6,padding:"8px 10px"},children:[l.jsx("div",{style:{fontSize:9,color:"rgba(255,100,100,0.8)",marginBottom:6},children:"This will invalidate your current token. Published characters will lose ownership. No migration."}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("button",{onClick:H,disabled:C,style:{padding:"4px 12px",fontSize:9,fontWeight:700,border:"1px solid rgba(255,50,50,0.4)",background:"rgba(255,50,50,0.15)",color:"#ff6464",borderRadius:4,cursor:"pointer"},children:C?"...":"Confirm Regenerate"}),l.jsx("button",{onClick:()=>j(!1),style:{padding:"4px 12px",fontSize:9,border:"none",background:"transparent",color:"var(--terminal-text-muted)",cursor:"pointer"},children:"Cancel"})]})]}):l.jsx("button",{onClick:()=>j(!0),style:{padding:"4px 10px",fontSize:9,fontWeight:600,border:"1px solid rgba(255,100,100,0.2)",background:"transparent",color:"rgba(255,100,100,0.6)",borderRadius:4,cursor:"pointer"},children:"Regenerate Token"})})]}),l.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.08)",paddingTop:16,display:"flex",gap:8},children:[o&&l.jsx("button",{onClick:()=>{e(),o()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🔄 ROLE SYNC"}),c&&l.jsx("button",{onClick:()=>{e(),c()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"📂 GIT STATUS"}),d&&l.jsx("button",{onClick:()=>{e(),d()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🖥 SESSIONS"}),m&&l.jsx("button",{onClick:()=>{e(),m()},className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"📊 COMPANY STATS"}),l.jsx("button",{onClick:()=>window.open("https://tycono.ai/store.html","_blank"),className:"theme-btn",style:{flex:1,padding:"8px 12px",fontSize:10},children:"🌐 WEB STORE"})]}),p&&l.jsx("div",{style:{textAlign:"center",marginTop:-8},children:l.jsx("a",{href:`https://tycono.ai/profile.html?u=${encodeURIComponent(p)}`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:10,color:"var(--terminal-text-muted)",textDecoration:"none"},onMouseEnter:Q=>Q.currentTarget.style.color="var(--accent)",onMouseLeave:Q=>Q.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function fL({theme:e,onThemeChange:t,onClose:n}){const i=S.useRef(null);return S.useEffect(()=>{const a=o=>{i.current&&!i.current.contains(o.target)&&n()};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[n]),l.jsx("div",{ref:i,className:"theme-dropup",children:Object.entries(Bs).map(([a,o])=>l.jsxs("button",{className:`theme-dropup__item${e===a?" theme-dropup__item--active":""}`,onClick:()=>{t(a),n()},title:o.name,children:[l.jsxs("span",{className:"theme-dropup__swatch",style:{background:o.vars["--hud-bg"],borderColor:o.vars["--pixel-border"]},children:[l.jsx("span",{style:{background:o.vars["--accent"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:o.vars["--active-green"],width:5,height:5,borderRadius:1}}),l.jsx("span",{style:{background:o.vars["--idle-amber"],width:5,height:5,borderRadius:1}})]}),l.jsx("span",{className:"theme-dropup__name",children:o.icon})]},a))})}const oo={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function hL({roles:e,roleStatuses:t,activeExecs:n,sessions:i,knowledgeDocs:a,roleLevels:o,companyName:c,getAppearance:d,waveCenterWaves:m,renderProfile:f,channel:x,onChannelChange:p,onClose:y,children:g}){const[w,k]=S.useState(!1),j=m.filter(F=>F.rootDispatches.some(q=>{const V=t[q.roleId];return V==="working"||V==="thinking"})),C=[...e].sort((F,q)=>F.level==="c-level"&&q.level!=="c-level"?-1:F.level!=="c-level"&&q.level==="c-level"?1:F.name.localeCompare(q.name)),N=e.filter(F=>tr(t[F.id])).length,E=i.filter(F=>F.status==="active").length,A=x.type==="role"?e.find(F=>F.id===x.roleId):null,z=x.type==="dashboard"?"Dashboard":x.type==="terminal"?"Chats":x.type==="wave"?"Wave Center":x.type==="knowledge"?"Knowledge Base":x.type==="operations"?"Operations":x.type==="role"?(A==null?void 0:A.name)??x.roleId:"Dashboard",D=x.type==="terminal"?`${E} active sessions`:x.type==="wave"?`${j.length} running`:x.type==="knowledge"?`${a.length} documents`:x.type==="role"?(A==null?void 0:A.level)==="c-level"?"C-Level":"Team member":`${N} working · ${e.length} total`;return l.jsxs("div",{className:"fixed inset-0 z-[60] flex",style:{background:"var(--terminal-bg, #1C1612)"},children:[l.jsxs("div",{className:"flex flex-col shrink-0 overflow-y-auto",style:{width:240,borderRight:"1px solid var(--terminal-border, #2E261F)",background:"var(--terminal-surface, #1a1510)"},children:[l.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 shrink-0",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsx("span",{className:"text-[11px] font-bold tracking-wider flex-1",style:{color:"var(--terminal-text, #fff5eb)",fontFamily:"var(--pixel-font)"},children:c}),N>0&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full animate-pulse",style:{background:"#4CAF5020",color:"#4CAF50"},children:[N," live"]})]}),j.length>0&&l.jsxs("button",{className:"mx-3 mt-3 px-3 py-2.5 rounded-lg text-left transition-all hover:opacity-90",style:{background:x.type==="wave"?"#EF444420":"#EF444410",border:"1px solid #EF444430"},onClick:()=>p({type:"wave"}),children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:"text-[10px] font-bold truncate flex-1",style:{color:"#EF4444"},children:["⚡"," ",j[0].directive.slice(0,28)]}),l.jsx("span",{className:"text-[7px] px-1.5 py-0.5 rounded font-bold shrink-0",style:{background:"#EF4444",color:"#fff"},children:"LIVE"})]}),l.jsxs("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted)"},children:[j[0].rootDispatches.filter(F=>{const q=t[F.roleId];return q==="working"||q==="thinking"}).length,"/",j[0].rootDispatches.length," roles working"]})]}),l.jsxs("div",{className:"mx-3 mt-3 grid grid-cols-2 gap-1.5",children:[l.jsx(tf,{icon:"💬",label:"Chats",badge:E||void 0,active:x.type==="terminal",onClick:()=>p({type:"terminal"})}),l.jsx(tf,{icon:"⚡",label:"Waves",live:j.length>0,active:x.type==="wave",onClick:()=>p({type:"wave"})}),l.jsx(tf,{icon:"📋",label:"Decisions",active:x.type==="operations",onClick:()=>p({type:"operations"})}),l.jsx(tf,{icon:"📚",label:"Knowledge",badge:a.length||void 0,active:x.type==="knowledge",onClick:()=>p({type:"knowledge"})})]}),l.jsxs("div",{className:"mt-4",children:[l.jsx("div",{className:"px-4 py-1 text-[9px] font-bold tracking-widest",style:{color:"var(--terminal-text-muted)"},children:"TEAM"}),C.map(F=>{var X;const q=t[F.id],V=n.find(R=>R.roleId===F.id),L=oo[F.id]??"#666",_=(X=o[F.id])==null?void 0:X.level,B=x.type==="role"&&x.roleId===F.id;return l.jsxs("button",{onClick:()=>p({type:"role",roleId:F.id}),className:"flex items-center gap-2.5 w-full px-4 py-1.5 text-left hover:opacity-80 transition-all",style:{background:B?`${L}18`:"transparent",borderLeft:B?`2px solid ${L}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(Aa,{roleId:F.id,appearance:d(F.id),scale:1.3}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full",style:{background:tr(q)?"#4CAF50":q==="idle"?"#FFC107":"#9E9E9E",border:"1.5px solid var(--terminal-surface, #1a1510)"}})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"text-[11px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:[F.name,_!=null&&l.jsxs("span",{className:"ml-1 opacity-40 text-[8px]",children:["Lv.",_]})]}),V?l.jsx("div",{className:"text-[9px] truncate",style:{color:L},children:V.task.slice(0,28)}):l.jsx("div",{className:"text-[9px]",style:{color:"var(--terminal-text-muted, #887766)"},children:F.level==="c-level"?F.id.toUpperCase():F.id})]}),tr(q)&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:L}})]},F.id)})]}),l.jsx("div",{className:"flex-1"}),n.length>0&&l.jsxs("div",{className:"shrink-0 px-3 pb-2",style:{borderTop:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsxs("div",{className:"px-1 py-1.5 text-[8px] font-bold tracking-widest",style:{color:"var(--terminal-text-muted)"},children:["ACTIVE JOBS (",n.length,")"]}),l.jsx("div",{className:"space-y-0.5 max-h-[140px] overflow-y-auto",children:n.map(F=>{const q=e.find(_=>_.id===F.roleId),V=oo[F.roleId]??"#666",L=x.type==="role"&&x.roleId===F.roleId;return l.jsxs("button",{onClick:()=>p({type:"role",roleId:F.roleId}),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded text-left hover:opacity-80 transition-all",style:{background:L?`${V}18`:"transparent"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse shrink-0",style:{background:V}}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text, #fff5eb)"},children:(q==null?void 0:q.name)??F.roleId}),l.jsx("div",{className:"text-[8px] truncate",style:{color:"var(--terminal-text-muted)"},children:F.task.slice(0,40)})]})]},F.sessionId??F.roleId)})})]}),l.jsx("div",{className:"px-3 py-3 shrink-0",style:{borderTop:"1px solid var(--terminal-border, #2E261F)"},children:l.jsxs("button",{onClick:y,className:"flex items-center gap-2 w-full px-3 py-2.5 rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--terminal-border, #2E261F)",color:"var(--terminal-text, #fff5eb)"},children:[l.jsx("span",{className:"text-[12px]",children:"🏢"}),l.jsx("span",{className:"text-[11px] font-medium",children:"OFFICE"})]})})]}),l.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 shrink-0",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[x.type==="role"&&A&&l.jsxs("button",{onClick:()=>k(F=>!F),className:"relative shrink-0 rounded-lg overflow-hidden hover:opacity-80 transition-opacity cursor-pointer",style:{width:28,height:28,background:`${oo[A.id]??"#666"}30`},title:"View profile",children:[l.jsx(Aa,{roleId:A.id,appearance:d(A.id),scale:1.5}),l.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full",style:{background:tr(t[A.id])?"#4CAF50":t[A.id]==="idle"?"#FFC107":"#9E9E9E",border:"2px solid var(--terminal-bg, #1C1612)"}})]}),l.jsx("span",{className:"text-[15px] font-semibold",style:{color:"var(--terminal-text, #fff5eb)"},children:z}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted, #887766)"},children:D}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>k(F=>!F),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:w?"var(--terminal-text)":"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)",background:w?"var(--terminal-border)":"transparent"},children:"Profile"}),x.type!=="dashboard"&&l.jsx("button",{onClick:()=>p({type:"dashboard"}),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},children:"Dashboard"})]}),l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx("div",{className:"flex-1 overflow-hidden relative pro-panel-inline",children:g}),w&&x.type==="role"&&f&&l.jsx("div",{className:"shrink-0 overflow-hidden pro-panel-inline",style:{width:420,borderLeft:"1px solid var(--terminal-border, #2E261F)"},children:f(()=>k(!1))})]})]})]})}function mL({role:e,messages:t,isStreaming:n,mode:i,onModeChange:a,onSend:o,isWave:c}){const d=oo[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsx(L3,{messages:t,roleId:e.id,roleColor:d}),c?l.jsxs("div",{className:"shrink-0 px-4 py-2 border-t flex items-center gap-2",style:{borderColor:"var(--terminal-border)",background:"var(--terminal-bg-deeper)"},children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0",style:{animation:"pulse 2s infinite"}}),l.jsx("span",{className:"text-[11px] text-amber-400/80",children:"Wave execution · read-only"})]}):l.jsx(H0,{mode:i,onModeChange:a,onSend:(m,f)=>o(m,i,f),disabled:n,disabledReason:n?`${e.id.toUpperCase()} is responding...`:void 0})]})}function pL({role:e,onSend:t,getAppearance:n,onOpenProfile:i}){const[a,o]=S.useState("talk"),c=oo[e.id]??"#666";return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[l.jsx("button",{onClick:i,className:"cursor-pointer hover:opacity-80 transition-opacity",children:l.jsx("div",{className:"rounded-lg p-1",style:{background:`${c}20`},children:l.jsx(Aa,{roleId:e.id,appearance:n(e.id),scale:5})})}),l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--terminal-text)"},children:e.name}),l.jsxs("div",{className:"text-xs mt-0.5",style:{color:"var(--terminal-text-muted)"},children:[e.level==="c-level"?e.id.toUpperCase():e.id," · Start a conversation"]})]})]}),l.jsx(H0,{mode:a,onModeChange:o,onSend:d=>t(d,a),disabled:!1})]})}function tf({icon:e,label:t,active:n,badge:i,live:a,onClick:o}){return l.jsxs("button",{onClick:o,className:"flex flex-col items-center gap-1 py-3 rounded-lg transition-all hover:opacity-90",style:{background:n?"var(--desk-wood, #5C3D2E)":"var(--terminal-border, #2E261F)",border:n?"1px solid var(--desk-wood, #5C3D2E)":"1px solid transparent"},children:[l.jsxs("div",{className:"relative",children:[l.jsx("span",{className:"text-[16px]",children:e}),a&&l.jsx("span",{className:"absolute -top-1 -right-2 w-2 h-2 rounded-full animate-pulse",style:{background:"#EF4444"}}),i!==void 0&&i>0&&!a&&l.jsx("span",{className:"absolute -top-1.5 -right-3 text-[7px] px-1 py-0.5 rounded-full font-bold leading-none",style:{background:"var(--desk-wood, #5C3D2E)",color:"#fff",minWidth:14,textAlign:"center"},children:i})]}),l.jsx("span",{className:"text-[10px] font-semibold",style:{color:n?"#fff":"var(--terminal-text, #fff5eb)"},children:t})]})}function xL({roles:e,roleStatuses:t,activeExecs:n,waves:i,knowledgeDocs:a,roleLevels:o,getAppearance:c,onRoleClick:d,onWaveClick:m,onKnowledgeClick:f}){const x=e.filter(p=>tr(t[p.id]));return l.jsx("div",{className:"h-full overflow-y-auto px-6 py-5",children:l.jsxs("div",{className:"space-y-5 max-w-4xl",children:[l.jsxs("div",{className:"flex gap-3",children:[l.jsx(u2,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(u2,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:f})]}),x.length>0&&l.jsx(nf,{title:"Currently Working",count:x.length,children:n.map(p=>{const y=e.find(w=>w.id===p.roleId),g=oo[p.roleId]??"#666";return l.jsxs("button",{onClick:()=>d(p.roleId),className:"flex items-center gap-3 px-4 py-2.5 rounded hover:opacity-80 w-full text-left",style:{background:`${g}10`},children:[l.jsx("div",{className:"shrink-0",style:{width:24,height:24},children:l.jsx(Aa,{roleId:p.roleId,appearance:c(p.roleId),scale:1.2})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-[12px] font-medium",style:{color:g},children:y==null?void 0:y.name}),l.jsx("span",{className:"text-[11px] ml-2 truncate",style:{color:"var(--terminal-text-muted)"},children:p.task.slice(0,60)})]}),l.jsx("span",{className:"text-[10px] animate-pulse",style:{color:g},children:"●"})]},p.roleId)})}),l.jsx(nf,{title:"Team",count:e.length,children:l.jsx("div",{className:"grid grid-cols-3 gap-1 px-2",children:e.map(p=>{var w;const y=t[p.id]??"offline",g=(w=o[p.id])==null?void 0:w.level;return l.jsxs("button",{onClick:()=>d(p.id),className:"flex items-center gap-2 px-3 py-2 rounded hover:opacity-80 text-left",children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:tr(y)?"#4CAF50":y==="idle"?"#FFC107":"#9E9E9E"}}),l.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--terminal-text)"},children:p.name}),g!=null&&l.jsxs("span",{className:"text-[9px] opacity-40",children:["Lv.",g]})]},p.id)})})}),i.length>0&&l.jsx(nf,{title:"Recent Waves",count:i.length,children:i.slice(0,5).map(p=>{var y;return l.jsxs("div",{className:"px-4 py-2 text-[11px]",style:{color:"var(--terminal-text-muted)"},children:[l.jsxs("span",{style:{color:"var(--terminal-text)"},children:["Wave ",p.id]})," — ",(y=p.directive)==null?void 0:y.slice(0,80)]},p.id)})}),l.jsx(nf,{title:"Knowledge Base",count:a.length,children:l.jsxs("button",{onClick:f,className:"px-4 py-3 text-[11px] hover:opacity-80",style:{color:"var(--terminal-text-muted)"},children:[a.length," documents · Click to explore ","→"]})})]})})}function u2({label:e,icon:t,color:n,onClick:i}){return l.jsxs("button",{onClick:i,className:"flex items-center gap-2 px-5 py-3 rounded-lg hover:opacity-80 transition-opacity",style:{background:`${n}15`,border:`1px solid ${n}30`},children:[l.jsx("span",{className:"text-sm",children:t}),l.jsx("span",{className:"text-[12px] font-medium",style:{color:n},children:e})]})}function nf({title:e,count:t,children:n}){return l.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--terminal-surface, #241E19)",border:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsxs("div",{className:"px-4 py-2.5 flex items-center gap-2",style:{borderBottom:"1px solid var(--terminal-border, #2E261F)"},children:[l.jsx("span",{className:"text-[10px] font-bold tracking-wider",style:{color:"var(--terminal-text-muted)"},children:e.toUpperCase()}),t!==void 0&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full",style:{background:"var(--terminal-border)",color:"var(--terminal-text-muted)"},children:t})]}),l.jsx("div",{className:"py-1",children:n})]})}const qx=5e4;function nS(e){return e<qx?1:Math.max(1,Math.floor(Math.sqrt(e/qx)))}function d2(e){return qx*e*e}function gL(e){const t=nS(e),n=d2(t),i=d2(t+1);return Math.min(1,(e-n)/(i-n))}function Jp(e){const t={};for(const[n,i]of Object.entries(e)){const a=i.inputTokens+i.outputTokens;t[n]={level:nS(a),totalTokens:a,progress:gL(a)}}return t}const yL=[{id:"first-employee",name:"First Employee",icon:"🏆",description:"Hired your first role",check:e=>e.roleCount>=1},{id:"full-team",name:"Full Team",icon:"👥",description:"Hired 5+ roles",check:e=>e.roleCount>=5},{id:"token-10k",name:"Getting Started",icon:"📊",description:"Used 10K tokens total",check:e=>e.totalTokens>=1e4},{id:"token-100k",name:"Power User",icon:"💪",description:"Used 100K tokens total",check:e=>e.totalTokens>=1e5},{id:"token-millionaire",name:"Token Millionaire",icon:"🎖",description:"Used 1M tokens total",check:e=>e.totalTokens>=1e6},{id:"token-mogul",name:"Token Mogul",icon:"💎",description:"Used 10M tokens total",check:e=>e.totalTokens>=1e7},{id:"first-promotion",name:"First Promotion",icon:"⭐",description:"Any role reached Lv.3",check:e=>e.roles.some(t=>t.level>=3)},{id:"senior-staff",name:"Senior Staff",icon:"🌟",description:"Any role reached Lv.5",check:e=>e.roles.some(t=>t.level>=5)},{id:"master-class",name:"Master Class",icon:"👑",description:"Any role reached Lv.10",check:e=>e.roles.some(t=>t.level>=10)},{id:"full-house",name:"Full House",icon:"🏠",description:"All roles Lv.5+",check:e=>e.roleCount>=3&&e.roles.every(t=>t.level>=5)},{id:"first-launch",name:"First Launch",icon:"🚀",description:"Completed Chapter 2 — gave your first order",check:e=>{var t;return((t=e.completedQuests)==null?void 0:t.includes("ch2-q2"))??!1}},{id:"team-builder",name:"Team Builder",icon:"🏗️",description:"Completed Chapter 4 — dispatched your first wave",check:e=>{var t;return((t=e.completedQuests)==null?void 0:t.includes("ch4-q2"))??!1}},{id:"explorer",name:"Explorer",icon:"🔍",description:"Completed Chapter 5 — customized a character",check:e=>{var t;return((t=e.completedQuests)==null?void 0:t.includes("ch5-q2"))??!1}},{id:"interior-designer",name:"Interior Designer",icon:"🎨",description:"Completed Chapter 7 — bought premium furniture",check:e=>{var t;return((t=e.completedQuests)==null?void 0:t.includes("ch7-q2"))??!1}},{id:"tycoon-master",name:"Tycoon Master",icon:"🎯",description:"Completed all 10 chapters",check:e=>{var t;return((t=e.completedQuests)==null?void 0:t.includes("ch10-q3"))??!1}}];function f2(e){return yL.filter(t=>t.check(e))}const h2={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function bL({importReq:e,onImportDone:t}){var Fo,Su,ju,Cu,Nu;const[n,i]=S.useState([]),[a,o]=S.useState([]),[c,d]=S.useState([]),[m,f]=S.useState([]),[x,p]=S.useState([]),[y,g]=S.useState([]),[w,k]=S.useState("TYCONO"),[j,C]=S.useState(!0),[N,E]=S.useState(null),[A,z]=S.useState({type:"none"}),[D,F]=S.useState(null),[q,V]=S.useState(null),[L,_]=S.useState([]),[B,X]=S.useState(!1),[R,H]=S.useState(!1),[$,G]=S.useState([]),[Q,K]=S.useState([]),[M,U]=S.useState(0),[P,O]=S.useState(!1),[Z,ee]=S.useState({}),[J,se]=S.useState("ceo"),[le,ye]=S.useState(null),[De,Ee]=S.useState(!1),[Re,me]=S.useState(!1),[Fe,Je]=S.useState({}),Pe=S.useRef({}),[it,ht]=S.useState(!1),[Ye,nt]=S.useState(!1),[ut,kt]=S.useState(null),[mt,ve]=S.useState({}),[be,te]=S.useState([]),oe=S.useMemo(()=>{const I={};for(const re of be)I[re.roleId]=re;return I},[be]),[Ce,pe]=S.useState([]),[Se,Me]=S.useState(0),[Ge,Ie]=S.useState(Rv()),qe=S.useRef(Rv()),Xe=S.useRef(!1),et=S.useRef(-1),[ze,Be]=S.useState(null),_t=S.useRef(null),[en,Tt]=S.useState(void 0),[Pt,hn]=S.useState(!1);S.useEffect(()=>{ke.getStatus().then(I=>{Tt(I.engine),hn(!!I.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:Zt,setAppearance:ae,resetAppearance:Ve,theme:We,setTheme:tn,speechSettings:Ne,setSpeechSettings:Ct,language:ln,setLanguage:nn,purchasedItems:Kr,addPurchasedItem:gr}=b$(),[vn,ce]=S.useState(null),[,Ue]=S.useState("character"),$e=k$(),[dt,wt]=S.useState(!1),[yr,Pn]=S.useState(!1),[Qr,fi]=S.useState(!1),[Ls,Zr]=S.useState(!1),[Ma,jr]=S.useState(!1),[dr,Ai]=S.useState([]),[Di,Sn]=S.useState(!1),[Fa,Is]=S.useState(!1),[$n,Ti]=S.useState(null);S.useEffect(()=>{$e.refresh()},[]),S.useEffect(()=>{const I=re=>{(re.metaKey||re.ctrlKey)&&re.key==="s"&&(re.preventDefault(),wt(!0))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[]),S.useEffect(()=>{if(!Ls)return;let I=!1;const re=async()=>{try{const we=await ke.getGitStatus();I||Ti(we)}catch{}};re();const de=setInterval(re,1e4);return()=>{I=!0,clearInterval(de)}},[Ls]),S.useEffect(()=>{let I=!1;const re=async()=>{try{const we=await ke.getActiveSessions();I||Ai(we.sessions)}catch{}};re();const de=setInterval(re,5e3);return()=>{I=!0,clearInterval(de)}},[]);const[_i,is]=S.useState(null),[hi,Mi]=S.useState(null),[Fr,ss]=S.useState([]),[Zn,nr]=S.useState(!1),Ra=S.useRef(!1),za=S.useRef(null);let mi=S.useRef(0);const Ba=S.useRef(new Set),as=S.useRef(Date.now()),pi=(I,re,de)=>{const we={id:mi.current++,type:I,text:re,detail:de};ss(Te=>[...Te,we])};S.useEffect(()=>{var I;Zn&&((I=za.current)==null||I.scrollIntoView({behavior:"smooth"}))},[Fr,Zn]),S.useEffect(()=>{e&&(Ra.current||(Ra.current=!0,Mi("Scanning knowledge sources..."),ss([{id:0,type:"scan",text:"Starting knowledge import..."}]),mi.current=1,fetch("/api/setup/import-knowledge",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e.paths,companyRoot:e.companyRoot})}).then(async I=>{var Te;const re=(Te=I.body)==null?void 0:Te.getReader();if(!re)return;const de=new TextDecoder;let we="";for(;;){const{done:Ke,value:$t}=await re.read();if(Ke)break;we+=de.decode($t,{stream:!0});const yt=we.split(`
121
+ `);we=yt.pop()||"";let ct="";for(const ot of yt)if(ot.startsWith("event: "))ct=ot.slice(7).trim();else if(ot.startsWith("data: ")&&ct){try{const vt=JSON.parse(ot.slice(6));switch(ct){case"scanning":Mi(`Scanning: ${vt.path} (${vt.fileCount} files)`),pi("scan",`Found ${vt.fileCount} files`,vt.path);break;case"processing":is({index:vt.index,total:vt.total}),Mi(`Importing knowledge... (${vt.index}/${vt.total})`),pi("process",`Processing: ${vt.file}`,`${vt.index} / ${vt.total}`);break;case"created":pi("created",vt.title,vt.summary);break;case"skipped":pi("process",`Skipped: ${vt.file}`,vt.reason);break;case"done":Mi(null),is(null),pi("done",`Import complete! ${vt.created} created, ${vt.skipped} skipped.`),Mt(`Knowledge import complete! ${vt.created} documents imported.`,"#2E7D32"),t==null||t();break;case"error":Mi(null),is(null),pi("error",vt.message),Mt(`Import failed: ${vt.message}`,"#B71C1C"),t==null||t();break}}catch{}ct=""}}}).catch(I=>{Mi(null),pi("error",I.message),Mt(`Import error: ${I.message}`,"#B71C1C"),t==null||t()})))},[e]);const[jn,Jn]=S.useState("iso"),Rr=S.useRef("iso"),[br,mn]=S.useState({type:"dashboard"}),[Eo,uu]=S.useState(typeof window<"u"?window.innerWidth:1200);S.useEffect(()=>{const I=()=>uu(window.innerWidth);return window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]);const Fi=Eo<1024,[Jr,ls]=S.useState(!1),[Ri,Ao]=S.useState(560),[rr,yn]=S.useState([]),[zr,Cn]=S.useState(null),[ei,xi]=S.useState(null),{sendMessage:Hs}=x$();S.useEffect(()=>{Promise.all([ke.getCompany().then(I=>{k(I.name),i(I.roles)}),ke.getOrgTree().then(I=>{ee(I.nodes),se(I.root)}).catch(()=>{}),ke.getCostSummary().then(I=>qs(Jp(I.byRole))).catch(()=>{})]).catch(I=>E(`Failed to load: ${I.message}`)).finally(()=>C(!1)),ke.getProjects().then(o).catch(()=>{}),ke.getStandups().then(d).catch(()=>{}),ke.getWaves().then(f).catch(()=>{}),ke.getDecisions().then(p).catch(()=>{}),ke.getActiveWaves().then(({waves:I})=>{I.length>0&&G(I.map(re=>({...re,rootDispatches:re.dispatches.map(({sessionId:de,roleId:we,roleName:Te})=>({sessionId:de,roleId:we,roleName:Te}))})))}).catch(()=>{}),ke.getKnowledge().then(g).catch(()=>{}),ke.getQuestProgress().then(I=>{const re=zv(I);re.activeChapter!==I.activeChapter&&ke.saveQuestProgress(re).catch(()=>{}),Ie(re),qe.current=re,Xe.current=!0,ke.getCoins().then(de=>{var we;de.totalEarned===0?ke.migrateCoins(((we=re.completedQuests)==null?void 0:we.length)??0).then(Te=>Me(Te.balance)).catch(()=>{}):Me(de.balance)}).catch(()=>{})}).catch(()=>{Xe.current=!0})},[]),S.useEffect(()=>{if(et.current===-1){et.current=a.length;return}a.length>et.current&&on({type:"project_created"}),et.current=a.length},[a.length]);const os=S.useRef(!1);S.useEffect(()=>{if(!(!Xe.current||n.length===0||os.current)){os.current=!0;for(const I of n)on({type:"role_hired",condition:{roleId:I.id,roleCount:n.length}})}},[n.length]),S.useEffect(()=>{ke.getSessions().then(I=>{const re=I.filter(de=>de.source!=="wave");if(re.length>0){const de=re.map(Te=>({...Te,messages:[]}));yn(de);const we=de.find(Te=>Te.status==="active")??de[0];Cn(we.id),us()}}).catch(I=>{console.error("Failed to load sessions",I)})},[]),S.useEffect(()=>{const I=()=>{fetch("/api/exec/status").then(de=>de.json()).then(de=>{ve(de.statuses??{}),te(de.activeExecutions??[])}).catch(()=>{})};I();const re=setInterval(I,3e3);return()=>clearInterval(re)},[]);const cs=S.useMemo(()=>{const I={...mt};if(ei){const re=rr.find(de=>de.id===ei);re&&I[re.roleId]!=="awaiting_input"&&(I[re.roleId]="working")}return I},[mt,ei,rr]);S.useEffect(()=>{A.type==="role"?ke.getRole(A.roleId).then(F).catch(console.error):F(null)},[A]);const gi=()=>z({type:"none"}),Do=async(I,re)=>{const de=await ke.updateDecision(I,re);p(we=>we.map(Te=>Te.id===I?de:Te))},Us=async I=>{await ke.deleteDecision(I),p(re=>re.filter(de=>de.id!==I))},Tn=I=>{z(I),ls(!1),H(!1)},us=()=>{ls(!0),z({type:"none"}),H(!1)},zi=()=>{Rr.current="iso",mn({type:"wave"}),Jn("pro"),H(!0),ls(!1),z({type:"none"})},Bi=async(I,re)=>{const de=n.find(Te=>Te.id===I),we=(q==null?void 0:q.mode)==="ask";V(null);try{const Ke=(await ke.execute({type:"assign",roleId:I,task:re,readOnly:we})).sessionId,$t=h2[I]??"#666",yt=`${I.toUpperCase()} · ${(de==null?void 0:de.name)??I}`;O(!1),_([{sessionId:Ke,title:yt,color:$t}]),on({type:"task_executed",condition:{roleId:I}}),Jt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(de==null?void 0:de.name)??I}] ${we?"Ask":"Assign"}: ${re}`,type:"dispatch",targetRoleId:I})}catch(Te){Mt(`Failed to execute: ${Te instanceof Error?Te.message:"unknown"}`,"#C62828")}},To=S.useRef(0),Mt=(I,re)=>{const de=++To.current;pe(we=>[...we,{id:de,message:I,color:re}]),setTimeout(()=>pe(we=>we.filter(Te=>Te.id!==de)),4e3)},du=I=>{_t.current&&clearTimeout(_t.current),Be(I),_t.current=setTimeout(()=>Be(null),8e3)},on=I=>{if(!Xe.current)return;let re=qe.current;const de=G5(re);let we=0;const Te=[];for(const $t of de){if(!i_($t,I))continue;const{progress:yt,quest:ct}=n_(re,$t.id);ct&&(re=yt,we+=ct.rewards.coins??0,Te.push(ct.title))}if(Te.length===0)return;re=zv(re),qe.current=re,Ie(re);const Ke=we>0?` 💰 +${we.toLocaleString()}`:"";Te.length===1?Mt(`📋 Quest complete: ${Te[0]}${Ke}`,"#7C3AED"):Mt(`📋 ${Te.length} quests complete!${Ke}`,"#7C3AED"),Be(null),ke.saveQuestProgress(re).catch(()=>{}),we>0&&ke.earnCoins(we,`quests: ${Te.length}`,Te.join(",")).then($t=>Me($t.balance)).catch(()=>{})};S.useEffect(()=>{if(!ze)return;const I=document.querySelector(`[data-quest-target="${ze}"]`);if(!I)return;I.classList.add("quest-spotlight");const re=()=>{I.classList.remove("quest-spotlight"),Be(null),_t.current&&clearTimeout(_t.current)};return I.addEventListener("click",re,{once:!0}),()=>{I.classList.remove("quest-spotlight"),I.removeEventListener("click",re)}},[ze]);const qs=I=>{var de,we;const re=Pe.current;for(const[Te,Ke]of Object.entries(I)){const $t=((de=re[Te])==null?void 0:de.level)??0;if($t>0&&Ke.level>$t){const yt=((we=n.find(ct=>ct.id===Te))==null?void 0:we.name)??Te.toUpperCase();Mt(`${yt} leveled up to Lv.${Ke.level}!`,"#7C3AED")}}Pe.current=I,Je(I)};S.useEffect(()=>{const I={roles:Object.entries(Fe).map(([Te,Ke])=>({id:Te,level:Ke.level,totalTokens:Ke.totalTokens})),totalTokens:Object.values(Fe).reduce((Te,Ke)=>Te+Ke.totalTokens,0),roleCount:n.length,completedQuests:Ge.completedQuests},re=f2(I),de=new Set(re.map(Te=>Te.id));if(Date.now()-as.current>5e3){const Te=Ba.current;for(const Ke of re)Te.has(Ke.id)||Mt(`${Ke.icon} Badge earned: ${Ke.name}!`,"#D4A017")}Ba.current=de},[Fe,n.length,Ge.completedQuests]);const Ys=S.useMemo(()=>t_(Ge),[Ge]),fr=()=>{var re;const I=L[L.length-1];I&&(Mt(`${I.title} completed`,I.color),Jt.pushMessage({ts:Date.now(),roleId:((re=I.title.split(" · ")[0])==null?void 0:re.toLowerCase())??"unknown",text:`[${I.title}] Completed`,type:"dispatch"})),ke.getStandups().then(d).catch(console.error),ke.getCompany().then(de=>i(de.roles)).catch(console.error),ke.getCostSummary().then(de=>qs(Jp(de.byRole))).catch(()=>{})},ir=S.useRef(new Map),vl=I=>{if(ir.current.has(I))return;const re=new AbortController;ir.current.set(I,re),xi(de=>de??I),fetch(`/api/sessions/${I}/stream?from=0`,{signal:re.signal}).then(async de=>{var $t,yt;if(!de.ok||!de.body)return;const we=de.body.getReader(),Te=new TextDecoder;let Ke="";for(;;){const{done:ct,value:ot}=await we.read();if(ct)break;Ke+=Te.decode(ot,{stream:!0});const vt=Ke.split(`
122
+ `);Ke=vt.pop()??"";let Yt="";for(const Xs of vt)if(Xs.startsWith("event: "))Yt=Xs.slice(7).trim();else if(Xs.startsWith("data: ")){try{const Xn=JSON.parse(Xs.slice(6));Yt==="stream:end"?(yn(jt=>jt.map(Xt=>{if(Xt.id!==I)return Xt;const Mn=Xt.messages.map(pn=>pn.status==="streaming"?{...pn,status:"done"}:pn);return{...Xt,messages:Mn}})),xi(jt=>jt===I?null:jt),ir.current.delete(I)):Yt==="activity"&&(Xn.type==="text"&&(($t=Xn.data)!=null&&$t.text)?yn(jt=>jt.map(Xt=>{if(Xt.id!==I)return Xt;const Mn=[...Xt.messages],pn=Mn[Mn.length-1];return(pn==null?void 0:pn.from)==="role"&&pn.status==="streaming"&&(Mn[Mn.length-1]={...pn,content:pn.content+Xn.data.text}),{...Xt,messages:Mn}})):Xn.type==="thinking"&&((yt=Xn.data)!=null&&yt.text)?yn(jt=>jt.map(Xt=>{if(Xt.id!==I)return Xt;const Mn=[...Xt.messages],pn=Mn[Mn.length-1];return(pn==null?void 0:pn.from)==="role"&&pn.status==="streaming"&&(Mn[Mn.length-1]={...pn,thinking:(pn.thinking??"")+Xn.data.text}),{...Xt,messages:Mn}})):(Xn.type==="msg:done"||Xn.type==="msg:error")&&(yn(jt=>jt.map(Xt=>{if(Xt.id!==I)return Xt;const Mn=Xt.messages.map(pn=>pn.status==="streaming"?{...pn,status:Xn.type==="msg:done"?"done":"error"}:pn);return{...Xt,messages:Mn}})),xi(jt=>jt===I?null:jt),ir.current.delete(I)))}catch{}Yt=""}}}).catch(()=>{ir.current.delete(I),xi(de=>de===I?null:de)})},ds=async(I,re,de,we)=>{X(!1);try{const Te=await ke.execute({type:"wave",directive:I,targetRoles:re,...de&&{attachments:de},...we&&{continuous:we}});on({type:"wave_dispatched"});const Ke=Te.waveId??`wave-${Date.now()}`,$t=Te.sessionIds??[],yt=J&&Z[J]?Z[J].children.map(jt=>n.find(Xt=>Xt.id===jt)).filter(jt=>!!jt):n.filter(jt=>jt.level==="c-level"),ct=re?yt.filter(jt=>re.includes(jt.id)):yt,ot=$t.map((jt,Xt)=>{var Mn,pn;return{roleId:((Mn=ct[Xt])==null?void 0:Mn.id)??`role-${Xt}`,roleName:((pn=ct[Xt])==null?void 0:pn.name)??`C-Level ${Xt+1}`,sessionId:jt}});Jt.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${I}" → ${ot.map(jt=>jt.roleName).join(", ")}`,type:"dispatch"});const vt={id:Ke,directive:I,rootDispatches:ot.map(({roleId:jt,roleName:Xt,sessionId:Mn})=>({roleId:jt,roleName:Xt,sessionId:Mn})),startedAt:Date.now(),sessionIds:$t};G(jt=>[vt,...jt]),zi();const Yt=new Date().toISOString(),Xn=ot.map(jt=>({id:jt.sessionId,roleId:jt.roleId,title:`WAVE: ${jt.roleName}`,mode:"do",source:"wave",messages:[{id:`msg-${jt.sessionId}-ceo`,from:"ceo",content:I,type:"directive",status:"done",timestamp:Yt}],status:"active",createdAt:Yt,updatedAt:Yt})).map((jt,Xt)=>({...jt,messages:[...jt.messages,{id:`msg-${ot[Xt].sessionId}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:Yt}]}));yn(jt=>[...Xn,...jt]);for(const jt of Xn)vl(jt.id)}catch(Te){Mt(`Failed to start wave: ${Te instanceof Error?Te.message:"unknown"}`,"#C62828")}},fs=()=>{ke.getWaves().then(f).catch(console.error),ke.getStandups().then(d).catch(console.error)},$a=()=>{ke.getCompany().then(I=>i(I.roles)).catch(console.error),ke.getOrgTree().then(I=>{ee(I.nodes),se(I.root)}).catch(console.error),ke.getCostSummary().then(I=>qs(Jp(I.byRole))).catch(()=>{})},_o=async(I,re)=>{await ke.createRole(I),ae(I.id,re),$a(),Mt(`${I.name} hired!`,"#2E7D32"),on({type:"role_hired",condition:{roleId:I.id,roleCount:n.length+1}})},Oa=async I=>{var re;await ke.deleteRole(I),$a(),yn(de=>de.filter(we=>we.roleId!==I)),zr&&((re=rr.find(de=>de.id===zr))==null?void 0:re.roleId)===I&&Cn(null),kt(null),Mt(`${I.toUpperCase()} removed`,"#B71C1C")},Ps=async(I,re)=>{await ke.updateRole(I,re),$a(),A.type==="role"&&A.roleId===I&&ke.getRole(I).then(F).catch(console.error),re.name&&Mt(`${I.toUpperCase()} renamed to "${re.name}"`,"#1565C0"),re.persona!==void 0&&(Mt(`${I.toUpperCase()} persona updated`,"#2E7D32"),on({type:"persona_updated"}))},fu=I=>{us(),on({type:"terminal_opened"})},hu=async I=>{try{const re=await ke.createSession(I,"talk");yn(de=>[re,...de]),Cn(re.id),us()}catch(re){console.error("Failed to create session",re),Mt(`Failed to create session: ${re instanceof Error?re.message:"API unreachable"}`,"#B71C1C")}},mu=async I=>{try{const re=await ke.createSession(I,"talk");yn(de=>[re,...de]),Cn(re.id)}catch(re){console.error("Failed to create session",re),Mt(`Failed to create session: ${re instanceof Error?re.message:"API unreachable"}`,"#B71C1C")}},Jf=async I=>{const re=oe[I],de=(re==null?void 0:re.sessionId)??(re==null?void 0:re.id);if(de&&tr(cs[I])){const Te=n.find(ot=>ot.id===I),Ke=h2[I]??"#666",$t=`${I.toUpperCase()} · ${(Te==null?void 0:Te.name)??I}`,yt=rr.find(ot=>ot.roleId===I&&ot.status==="active"),ct=(yt==null?void 0:yt.id)??de;_([{sessionId:ct,title:$t,color:Ke}]),O(!1);return}const we=rr.find(Te=>Te.roleId===I);if(we)Cn(we.id),Jt.setActiveChannelId(null);else try{const Te=await ke.createSession(I,"talk");yn(Ke=>[Te,...Ke]),Cn(Te.id),Jt.setActiveChannelId(null)}catch(Te){console.error("Failed to create session",Te)}us()},wl=async I=>{const re=rr.find(de=>de.id===I);if((re==null?void 0:re.source)==="wave"){{const de=ir.current.get(re.id);de&&(de.abort(),ir.current.delete(re.id))}yn(de=>{var Te;const we=de.filter(Ke=>Ke.id!==I);return zr===I&&Cn(((Te=we[0])==null?void 0:Te.id)??null),we});return}try{await ke.deleteSession(I),yn(de=>{var Te;const we=de.filter(Ke=>Ke.id!==I);return zr===I&&Cn(((Te=we[0])==null?void 0:Te.id)??null),we})}catch(de){console.error("Failed to delete session",de),Mt(`Failed to close session: ${de instanceof Error?de.message:"API error"}`,"#B71C1C")}},pu=async()=>{try{const{ids:I}=await ke.deleteEmptySessions();if(I.length===0)return;yn(re=>{var we;const de=re.filter(Te=>!I.includes(Te.id));return zr&&I.includes(zr)&&Cn(((we=de[0])==null?void 0:we.id)??null),de}),Mt(`Cleared ${I.length} empty session${I.length!==1?"s":""}`,"#2E7D32")}catch(I){Mt(`Failed to clear empty sessions: ${I instanceof Error?I.message:"API error"}`,"#B71C1C")}},xu=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const I=rr.filter(re=>re.source!=="wave").map(re=>re.id);for(const re of rr)if(re.source==="wave"){const de=ir.current.get(re.id);de&&(de.abort(),ir.current.delete(re.id))}try{I.length>0&&await ke.deleteSessions(I),yn([]),Cn(null),Mt("All sessions closed","#2E7D32")}catch(re){Mt(`Failed to close sessions: ${re instanceof Error?re.message:"API error"}`,"#B71C1C")}},$i=(I,re)=>{yn(de=>de.map(we=>{if(we.id!==I)return we;const Te=[...we.messages],Ke=Te[Te.length-1];if(Ke&&Ke.from==="role"&&Ke.status==="streaming"){const $t=[...Ke.streamEvents??[],re];Te[Te.length-1]={...Ke,streamEvents:$t}}return{...we,messages:Te}}))},hs=(I,re,de,we)=>{const Te={id:`msg-${Date.now()}-ceo`,from:"ceo",content:re,type:de==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:we},Ke={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};yn(yt=>yt.map(ct=>ct.id===I?{...ct,messages:[...ct.messages,Te,Ke],updatedAt:new Date().toISOString()}:ct));const $t=rr.find(yt=>yt.id===I);de==="talk"?on({type:"talk_mode_used"}):de==="do"&&(on({type:"do_mode_used"}),$t&&on({type:"task_executed",condition:{roleId:$t.roleId}})),xi(I),Hs(I,re,de,{onThinking:yt=>{yn(ct=>ct.map(ot=>{if(ot.id!==I)return ot;const vt=[...ot.messages],Yt=vt[vt.length-1];return Yt&&Yt.from==="role"&&Yt.status==="streaming"&&(vt[vt.length-1]={...Yt,thinking:(Yt.thinking??"")+yt}),{...ot,messages:vt}})),$i(I,{type:"thinking",timestamp:Date.now(),text:yt})},onText:yt=>{yn(ct=>ct.map(ot=>{if(ot.id!==I)return ot;const vt=[...ot.messages],Yt=vt[vt.length-1];return Yt&&Yt.from==="role"&&Yt.status==="streaming"&&(vt[vt.length-1]={...Yt,content:Yt.content+yt}),{...ot,messages:vt}}))},onToolUse:(yt,ct)=>{$i(I,{type:"tool",timestamp:Date.now(),toolName:yt,toolInput:ct})},onDispatch:(yt,ct)=>{$i(I,{type:"dispatch",timestamp:Date.now(),roleId:yt,task:ct})},onDispatchProgress:(yt,ct,ot)=>{var vt;ct==="tool"?$i(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:yt,progressType:"tool",toolName:ot.name,toolInput:ot.input}):ct==="thinking"?$i(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:yt,progressType:"thinking",text:ot.text}):ct==="text"?$i(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:yt,progressType:"text",text:(vt=ot.text)==null?void 0:vt.slice(-200)}):(ct==="done"||ct==="error")&&$i(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:yt,progressType:ct})},onTurn:yt=>{$i(I,{type:"turn",timestamp:Date.now(),turn:yt})},onDone:()=>{yn(yt=>yt.map(ct=>{if(ct.id!==I)return ct;const ot=ct.messages.map(Yt=>Yt.status==="streaming"?{...Yt,status:"done"}:Yt),vt=ct.messages.length<=2?re.slice(0,40).replace(/\n/g," "):ct.title;return{...ct,messages:ot,title:vt}})),xi(null)},onError:yt=>{yn(ct=>ct.map(ot=>{if(ot.id!==I)return ot;const vt=ot.messages.map(Yt=>Yt.status==="streaming"?{...Yt,status:"error",content:Yt.content||yt}:Yt);return{...ot,messages:vt}})),xi(null)}},we)},Mo=(I,re)=>{yn(de=>de.map(we=>we.id===I?{...we,mode:re}:we)),ke.updateSession(I,{mode:re}).catch(console.error)},gu=new Date().toISOString().slice(0,10),yu=a[0],bu={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},eh=I=>{const re=bu[I];if(!re)return"";for(const de of c){const we=de.content,Te=we.indexOf(`## ${re}`);if(Te===-1)continue;const Ke=we.indexOf(`
123
+ ## `,Te+10),yt=(Ke===-1?we.slice(Te):we.slice(Te,Ke)).split(`
124
+ `).filter(ct=>ct.trim().length>0);for(const ct of yt){const ot=ct.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(ot.startsWith("|")||ot.startsWith("{")||ot.startsWith("[")||ot.startsWith("```")||ot.startsWith("---")||ot.includes("Journal")||ot.includes("(c-level)")||ot.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(ot))&&ot.length>15&&ot.length<120)return ot}}return""},vu=I=>{const re=bu[I];if(!re)return"";for(const de of c){const we=de.content,Te=we.indexOf(`## ${re}`);if(Te===-1)continue;const Ke=we.indexOf(`
125
+ ## `,Te+10),yt=(Ke===-1?we.slice(Te):we.slice(Te,Ke)).replace(/^## .+\n/,"").trim();if(yt)return yt.slice(0,1500)}return""},Jt=B$();S.useEffect(()=>{n.length>0&&Jt.syncDefaultMembers(n)},[n]);const kl=_$({roles:n,roleStatuses:mt,activeExecs:be,getStandupSpeech:eh}),wu=I$({roles:n,roleStatuses:mt,activeExecs:be,channels:Jt.channels,relationships:kl.relationships,pushMessage:Jt.pushMessage,speechSettings:Ne,engineType:en,hasApiKey:Pt}),ku=S.useCallback((I,re)=>{Jt.pushMessage({ts:Date.now(),roleId:"ceo",text:re,type:"chat",channelId:I}),wu.triggerCeoReaction(I)},[Jt,wu]);return j?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(hi||Fr.length>0)&&l.jsxs("div",{className:"shrink-0 z-[44]",children:[l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>nr(I=>!I),children:[hi?l.jsx("div",{className:"w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin shrink-0"}):l.jsx("span",{className:"shrink-0",children:"✅"}),l.jsx("span",{className:"flex-1",children:hi||"Knowledge import finished"}),_i&&l.jsx("div",{className:"w-24 h-1.5 rounded-full overflow-hidden shrink-0",style:{background:"rgba(255,255,255,0.3)"},children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${_i.index/_i.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:Zn?"▲":"▼"})]}),Zn&&l.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[Fr.map(I=>l.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[I.type==="scan"&&"🔍",I.type==="process"&&"⚙️",I.type==="created"&&"✅",I.type==="done"&&"🎉",I.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:I.type==="error"?"#EF4444":I.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:I.text}),I.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:I.detail})]})]},I.id)),l.jsx("div",{ref:za})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"text-4xl mb-3",children:"🏢"}),l.jsx("div",{className:"text-gray-600 font-semibold text-xs",children:"LOADING OFFICE..."})]})})]}):N?l.jsx("div",{className:"h-screen flex items-center justify-center bg-[var(--floor-light)]",children:l.jsxs("div",{className:"text-center max-w-md",style:{fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"text-4xl mb-3",children:"⚠️"}),l.jsx("div",{className:"text-gray-800 font-semibold mb-2 text-xs",children:"CONNECTION ERROR"}),l.jsx("div",{className:"text-gray-500 text-xs mb-4",children:N}),l.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-800 text-white text-xs font-bold cursor-pointer border-2 border-gray-600",style:{fontFamily:"var(--pixel-font)"},children:"RETRY"})]})}):l.jsxs("div",{className:"flex flex-col",style:{height:"100dvh",fontFamily:"var(--pixel-font)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-white text-sm shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",borderBottom:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"font-black text-[13px] tracking-tight",style:{color:"var(--idle-amber)",textShadow:"2px 2px 0 rgba(0,0,0,0.5)"},children:["🏢"," ",l.jsx("span",{style:{color:"var(--bar-text, var(--terminal-text))"},children:w})]}),l.jsxs("div",{className:"flex gap-4 text-[11px] items-center",style:{color:"var(--bar-text, var(--terminal-text-secondary))"},children:[(()=>{const I=Se>=1e6?`${(Se/1e6).toFixed(1)}M`:Se>=1e3?`${(Se/1e3).toFixed(1)}K`:String(Se),re=be.length,de=n.length>0?Math.round(re/n.length*100):0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["💰",l.jsx("strong",{className:"text-[var(--active-green)]",children:I})]}),l.jsxs("div",{className:"hidden md:flex items-center gap-1",children:["⚡",l.jsx("div",{className:"w-[50px] h-2 bg-[#111] overflow-hidden",style:{border:"2px solid var(--pixel-border)"},children:l.jsx("div",{className:"h-full",style:{width:`${de}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:de})]})]})})(),l.jsxs("span",{className:"hidden sm:inline",children:["Roles: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:n.length})]}),l.jsxs("span",{className:"hidden sm:inline",children:["Projects: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:a.length})]}),be.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:be.length})]}),(()=>{const I={roles:Object.entries(Fe).map(([de,we])=>({id:de,level:we.level,totalTokens:we.totalTokens})),totalTokens:Object.values(Fe).reduce((de,we)=>de+we.totalTokens,0),roleCount:n.length},re=f2(I);return re.length>0?l.jsx("div",{className:"hidden sm:flex",style:{gap:2,alignItems:"center",marginLeft:8,paddingLeft:8,borderLeft:"1px solid rgba(255,255,255,0.1)"},children:re.map(de=>l.jsx("span",{title:`${de.name}: ${de.description}`,style:{fontSize:12,cursor:"default"},children:de.icon},de.id))}):null})(),l.jsx("span",{className:"px-1.5 py-0.5",style:{background:"var(--bar-border, var(--hud-bg-alt))",border:"1px solid var(--bar-border, var(--pixel-border))",color:"var(--bar-text, var(--terminal-text))"},children:gu})]})]}),(hi||Fr.length>0)&&l.jsxs("div",{className:"shrink-0 z-[44]",children:[l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-xs cursor-pointer select-none",style:{background:"var(--accent)",color:"#fff",fontFamily:"var(--pixel-font)"},onClick:()=>nr(I=>!I),children:[hi?l.jsx("div",{className:"w-3 h-3 border-2 border-white/40 border-t-white rounded-full animate-spin shrink-0"}):l.jsx("span",{className:"shrink-0",children:"✅"}),l.jsx("span",{className:"flex-1",children:hi||"Knowledge import finished"}),_i&&l.jsx("div",{className:"w-24 h-1.5 rounded-full overflow-hidden shrink-0",style:{background:"rgba(255,255,255,0.3)"},children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${_i.index/_i.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:Zn?"▲":"▼"})]}),Zn&&l.jsxs("div",{className:"overflow-y-auto text-xs",style:{background:"var(--terminal-bg)",borderBottom:"2px solid var(--accent)",maxHeight:240,fontFamily:"var(--pixel-font)"},children:[Fr.map(I=>l.jsxs("div",{className:"flex items-start gap-2 px-5 py-1.5",style:{borderBottom:"1px solid var(--terminal-border)"},children:[l.jsxs("span",{className:"shrink-0 mt-0.5",style:{width:14,textAlign:"center"},children:[I.type==="scan"&&"🔍",I.type==="process"&&"⚙️",I.type==="created"&&"✅",I.type==="done"&&"🎉",I.type==="error"&&"❌"]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{style:{color:I.type==="error"?"#EF4444":I.type==="done"?"var(--active-green)":"var(--terminal-text)"},children:I.text}),I.detail&&l.jsx("div",{className:"text-[10px] truncate",style:{color:"var(--terminal-text-muted)"},children:I.detail})]})]},I.id)),l.jsx("div",{ref:za}),Fr.length===0&&l.jsx("div",{className:"px-5 py-4 text-center",style:{color:"var(--terminal-text-muted)"},children:"Waiting for events..."})]})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex relative",children:[l.jsx("div",{className:"flex-1 overflow-y-auto relative floor-grid",style:{background:"var(--floor-light)"},children:l.jsx(ZO,{roles:n,projects:a,waves:m,standups:c,decisions:x,roleStatuses:cs,activeExecs:be,onRoleClick:I=>Tn({type:"role",roleId:I}),onProjectClick:I=>Tn({type:"project",projectId:I}),onBulletinClick:()=>{Tn({type:"bulletin"}),on({type:"bulletin_visited"})},onDecisionsClick:()=>Tn({type:"decisions"}),onKnowledgeClick:()=>{Tn({type:"knowledge"}),on({type:"knowledge_visited"})},onSettingsClick:()=>{Sn(!0),on({type:"settings_visited"})},onThemeClick:()=>Is(I=>!I),onStatsClick:()=>{Pn(!0),on({type:"stats_visited"})},knowledgeDocsCount:y.length,getRoleSpeech:kl.getSpeech,getAppearance:Zt,onHireClick:()=>ht(!0),onPresetsClick:()=>nt(!0),onMascotClick:()=>Tn({type:"quest"}),roleLevels:Fe,language:ln,coinBalance:Se,onCoinsSpent:I=>Me(I),onFurniturePlaced:(I,re)=>{on({type:"furniture_placed"}),re>0&&on({type:"furniture_purchased"})}})}),Jr&&l.jsx("div",{className:Fi?"absolute inset-0 z-50":"contents",children:l.jsx(Uw,{sessions:rr,activeSessionId:zr,roles:n,streamingSessionId:ei,width:Fi?Eo:Ri,onWidthChange:Fi?void 0:Ao,onSwitchSession:Cn,onCloseSession:wl,onCreateSession:hu,onClearEmpty:pu,onCloseAll:xu,onSendMessage:hs,onModeChange:Mo,onStopSession:I=>ke.abortSession(I).catch(()=>{}),onCloseTerminal:()=>ls(!1),onMaximize:()=>{Rr.current="iso",mn({type:"terminal"}),Jn("pro")},chatChannels:Jt.channels,activeChatChannelId:Jt.activeChannelId,onSwitchChatChannel:Jt.setActiveChannelId,onCreateChatChannel:(...I)=>{const re=Jt.createChannel(...I);return on({type:"chat_channel_created"}),re},onDeleteChatChannel:Jt.deleteChannel,onUpdateChatMembers:Jt.updateMembers,onUpdateChatTopic:Jt.updateTopic,onSendChatMessage:ku,unreadChannels:Jt.unreadChannels})})]}),l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 text-[10px] shrink-0 z-[45]",style:{background:"var(--bar-bg, var(--hud-bg))",color:"var(--bar-text, var(--terminal-text-secondary))",borderTop:"3px solid var(--bar-border, var(--pixel-border))"},children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>Jn("iso"),className:`view-toggle-btn ${jn==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{Rr.current="iso",Jn("pro")},className:`view-toggle-btn ${jn==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${Fa?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>Is(I=>!I),title:"Office Theme",children:[((Fo=Bs[We])==null?void 0:Fo.icon)??"","▾"]}),Fa&&l.jsx(fL,{theme:We,onThemeChange:I=>{tn(I),on({type:"theme_changed"})},onClose:()=>Is(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>Sn(!0),title:"Settings",children:"⚙"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("button",{"data-quest-target":"save-btn",onClick:()=>{$e.state==="no-git"||$e.state==="dirty"?wt(!0):Zr(!0)},title:$e.state==="dirty"?`${$e.dirtyCount} unsaved — click to save`:"Git Status",style:{background:"none",border:"none",cursor:"pointer",fontSize:10,fontFamily:"var(--pixel-font)",color:"var(--bar-text, var(--terminal-text-muted))",display:"flex",alignItems:"center",gap:4},children:[l.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:$e.state==="no-git"?"var(--terminal-text-muted)":$e.state==="saving"||$e.state==="dirty"?"var(--idle-amber)":$e.state==="error"?"#EF5350":"var(--active-green)",animation:$e.state==="saving"?"pulse 1s infinite":void 0}}),l.jsx("span",{style:{color:$e.state==="dirty"?"var(--idle-amber)":"var(--bar-text, var(--terminal-text-muted))"},children:$e.state==="no-git"?"No git":$e.state==="saving"?"Saving...":$e.state==="dirty"?`${$e.dirtyCount} unsaved`:"Saved"}),$n&&($n.worktrees.length>0||$n.staleBranches.length>0)&&l.jsxs("span",{style:{color:$n.worktrees.some(I=>I.status==="stale")?"#ff6b6b":$n.worktrees.some(I=>I.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",$n.worktrees.length," worktree",$n.worktrees.length!==1?"s":"",$n.staleBranches.length>0&&` · ⚠ ${$n.staleBranches.length} branch${$n.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[$.length>0&&!R&&l.jsx("button",{onClick:()=>zi(),className:`px-3 py-1 font-black text-white cursor-pointer ${Re?"":"animate-pulse"}`,style:{background:Re?"#2E7D32":"#B71C1C",border:`2px solid ${Re?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Re?"WAVE DONE":`WAVE (${$.length})`}),le&&De&&$.length===0&&l.jsx("button",{onClick:()=>Ee(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${Re?"":"animate-pulse"}`,style:{background:Re?"#2E7D32":"#B71C1C",border:`2px solid ${Re?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Re?"WAVE DONE":"WAVE"}),L.length>0&&P&&l.jsxs("button",{onClick:()=>O(!1),className:"px-3 py-1 font-black text-white cursor-pointer animate-pulse",style:{background:L[L.length-1].color,border:`2px solid ${L[L.length-1].color}88`,fontFamily:"var(--pixel-font)",borderRadius:4},children:[L[L.length-1].title.slice(0,20),L[L.length-1].title.length>20?"..":""]}),dr.length>0&&l.jsxs("button",{onClick:()=>jr(!0),className:"px-2 py-1 font-black cursor-pointer text-[10px]",style:{background:"var(--hud-bg-alt)",color:dr.some(I=>I.messageStatus==="awaiting_input")?"#FFB74D":dr.some(I=>I.messageStatus==="streaming")?"#4FC3F7":"var(--terminal-text-muted)",border:"2px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",borderRadius:4},title:`${dr.length} active session${dr.length!==1?"s":""}`,children:["🔄"," ",dr.length," session",dr.length!==1?"s":""]}),l.jsxs("button",{onClick:()=>zi(),className:"wave-btn px-3 py-1 font-black text-white cursor-pointer","data-quest-target":"wave-btn",style:{background:"#B71C1C",border:"2px solid #7f1212",fontFamily:"var(--pixel-font)"},children:["🔴"," CEO WAVE"]}),l.jsx("button",{onClick:()=>Jr?ls(!1):fu(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:Jr?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${Jr?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),jn!=="pro"&&A.type==="role"&&D&&(()=>{var re,de;const I=oe[D.id];return l.jsx(yv,{role:D,allRoles:n,recentActivity:vu(D.id),onClose:gi,onFireRole:(we,Te)=>{kt({roleId:we,roleName:Te}),gi()},terminalWidth:Jr?Ri:0,activeSessionId:((re=L.find(we=>we.sessionId===(I==null?void 0:I.sessionId)))==null?void 0:re.sessionId)??(I==null?void 0:I.sessionId),activeTask:I==null?void 0:I.task,isWorking:tr(cs[D.id]),startedAt:I==null?void 0:I.startedAt,onAbortSession:we=>{ke.abortSession(we).catch(()=>{})},sessions:rr,streamingSessionId:ei,onCreateSessionSilent:mu,onSendMessage:hs,onFocusTerminal:Jf,onCustomize:we=>{const Te=n.find(Ke=>Ke.id===we);Te&&(Ue("character"),ce(Te))},onUpdateRole:Ps,appearance:Zt(D.id),relationships:kl.relationships,roleLevel:(de=Fe[D.id])==null?void 0:de.level,onMaximize:()=>{Rr.current="iso",mn({type:"role",roleId:D.id}),Jn("pro")}})})(),jn!=="pro"&&A.type==="project"&&yu&&l.jsx(a_,{projectId:yu.id,onClose:gi,terminalWidth:Jr?Ri:0}),jn!=="pro"&&(A.type==="bulletin"||A.type==="decisions")&&l.jsx(Fv,{standups:c,waves:m,decisions:x,mode:A.type==="bulletin"?"bulletin":"decisions",onClose:gi,onOpenWaveCenter:()=>zi(),onUpdateDecision:Do,onDeleteDecision:Us,terminalWidth:Jr?Ri:0,onMaximize:()=>{Rr.current="iso",mn({type:"operations"}),Jn("pro")}}),jn!=="pro"&&A.type==="quest"&&l.jsx(s_,{progress:Ge,onClose:gi,terminalWidth:Jr?Ri:0,onQuestAction:I=>{var de;gi();const re=fo.find(we=>we.id===I);(de=re==null?void 0:re.hint)!=null&&de.target&&du(re.hint.target)}}),jn!=="pro"&&A.type==="knowledge"&&l.jsx(Mv,{docs:y,onClose:gi,onRefresh:()=>ke.getKnowledge().then(g).catch(()=>{}),terminalWidth:Jr?Ri:0,initialDocId:A.docId,onMaximize:()=>{Rr.current="iso",mn({type:"knowledge"}),Jn("pro")}}),jn==="pro"&&l.jsxs(hL,{roles:n,roleStatuses:cs,activeExecs:be,waves:m,knowledgeDocs:y,sessions:rr,roleLevels:Fe,companyName:w,getAppearance:Zt,waveCenterWaves:$,renderProfile:br.type==="role"&&D?I=>{var de,we;const re=oe[D.id];return l.jsx(yv,{role:D,allRoles:n,recentActivity:vu(D.id),onClose:I,onFireRole:(Te,Ke)=>{kt({roleId:Te,roleName:Ke})},terminalWidth:0,activeSessionId:((de=L.find(Te=>Te.sessionId===(re==null?void 0:re.sessionId)))==null?void 0:de.sessionId)??(re==null?void 0:re.sessionId),activeTask:re==null?void 0:re.task,isWorking:tr(cs[D.id]),startedAt:re==null?void 0:re.startedAt,onAbortSession:Te=>{ke.abortSession(Te).catch(()=>{})},sessions:rr,streamingSessionId:ei,onCreateSessionSilent:mu,onSendMessage:hs,onFocusTerminal:()=>{},onCustomize:Te=>{const Ke=n.find($t=>$t.id===Te);Ke&&(Ue("character"),ce(Ke))},onUpdateRole:Ps,appearance:Zt(D.id),relationships:kl.relationships,roleLevel:(we=Fe[D.id])==null?void 0:we.level})}:void 0,channel:br,onChannelChange:I=>{mn(I),I.type==="role"?Tn({type:"role",roleId:I.roleId}):I.type==="knowledge"?Tn({type:"knowledge"}):I.type==="operations"?Tn({type:"bulletin"}):I.type==="wave"?H(!0):I.type==="terminal"?ls(!0):(z({type:"none"}),H(!1))},onClose:()=>{Jn(Rr.current),z({type:"none"}),H(!1)},children:[br.type==="dashboard"&&l.jsx(xL,{roles:n,roleStatuses:cs,activeExecs:be,waves:m,knowledgeDocs:y,roleLevels:Fe,getAppearance:Zt,onRoleClick:I=>mn({type:"role",roleId:I}),onWaveClick:()=>mn({type:"wave"}),onKnowledgeClick:()=>mn({type:"knowledge"})}),br.type==="terminal"&&l.jsx(Uw,{sessions:rr,activeSessionId:zr,roles:n,streamingSessionId:ei,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:Cn,onCloseSession:wl,onCreateSession:hu,onClearEmpty:pu,onCloseAll:xu,onSendMessage:hs,onModeChange:Mo,onStopSession:I=>ke.abortSession(I).catch(()=>{}),onCloseTerminal:()=>mn({type:"dashboard"}),chatChannels:Jt.channels,activeChatChannelId:Jt.activeChannelId,onSwitchChatChannel:Jt.setActiveChannelId,onCreateChatChannel:(...I)=>{const re=Jt.createChannel(...I);return on({type:"chat_channel_created"}),re},onDeleteChatChannel:Jt.deleteChannel,onUpdateChatMembers:Jt.updateMembers,onUpdateChatTopic:Jt.updateTopic,onSendChatMessage:ku,unreadChannels:Jt.unreadChannels}),br.type==="wave"&&l.jsx(Iw,{orgNodes:Z,rootRoleId:J,cLevelRoles:J&&Z[J]?Z[J].children.map(I=>n.find(re=>re.id===I)).filter(I=>!!I):n.filter(I=>I.level==="c-level"),pastWaves:m,activeWaves:$,onDispatch:(I,re,de,we)=>ds(I,re,de,we),onClose:()=>mn({type:"dashboard"}),onDone:()=>{fs(),me(!0),Mt("Wave complete","#2E7D32")},onSave:async(I,re,de)=>{try{await ke.saveWave({directive:I,sessionIds:re,waveId:de==null?void 0:de.waveId}),fs(),Mt("Wave saved","#2E7D32")}catch(we){Mt(`Save failed: ${we instanceof Error?we.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:I=>{mn({type:"knowledge"}),Tn({type:"knowledge",docId:I}),ke.getKnowledge().then(g).catch(()=>{})},onRefreshWaves:()=>ke.getWaves().then(f).catch(()=>{}),terminalWidth:0,inline:!0,onOpenSaveModal:()=>wt(!0)}),br.type==="knowledge"&&l.jsx(Mv,{docs:y,onClose:()=>mn({type:"dashboard"}),onRefresh:()=>ke.getKnowledge().then(g).catch(()=>{}),terminalWidth:0,hideHeader:!0}),br.type==="operations"&&l.jsx(Fv,{standups:c,waves:m,decisions:x,mode:"bulletin",onClose:()=>mn({type:"dashboard"}),onOpenWaveCenter:()=>mn({type:"wave"}),onUpdateDecision:Do,onDeleteDecision:Us,terminalWidth:0}),br.type==="role"&&(()=>{const I=br.roleId,re=n.find(we=>we.id===I);if(!re)return null;const de=rr.find(we=>we.roleId===I);return de?l.jsx(mL,{role:re,messages:de.messages,isStreaming:ei===de.id,mode:de.mode,onModeChange:we=>Mo(de.id,we),onSend:(we,Te,Ke)=>hs(de.id,we,Te,Ke),isWave:de.source==="wave"}):l.jsx(pL,{role:re,getAppearance:Zt,onSend:async(we,Te)=>{try{const Ke=await ke.createSession(I,"talk");yn($t=>[Ke,...$t]),Cn(Ke.id),hs(Ke.id,we,Te)}catch(Ke){Mt(`Failed to create session: ${Ke instanceof Error?Ke.message:"API unreachable"}`,"#B71C1C")}}})})()]}),q&&l.jsx(c_,{roleId:q.roleId,roleName:q.roleName,mode:q.mode,onClose:()=>V(null),onExecutionStart:Bi}),le&&!De&&l.jsx(FB,{directive:le.directive,rootDispatches:le.rootDispatches,orgNodes:Z,rootRoleId:J,onClose:()=>{ye(null),Ee(!1),me(!1)},onMinimize:()=>Ee(!0),onDone:()=>{fs(),me(!0),Mt("Wave complete","#2E7D32")},onSave:async I=>{try{await ke.saveWave({directive:le.directive,sessionIds:I}),fs(),Mt("Wave saved to bulletin","#2E7D32")}catch(re){Mt(`Save failed: ${re instanceof Error?re.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:I=>{ye(null),Ee(!1),me(!1),Tn({type:"knowledge",docId:I}),ke.getKnowledge().then(g).catch(()=>{})}}),R&&jn!=="pro"&&l.jsx(Iw,{orgNodes:Z,rootRoleId:J,cLevelRoles:J&&Z[J]?Z[J].children.map(I=>n.find(re=>re.id===I)).filter(I=>!!I):n.filter(I=>I.level==="c-level"),pastWaves:m,activeWaves:$,onDispatch:(I,re,de,we)=>ds(I,re,de,we),onClose:()=>H(!1),onMaximize:()=>{Rr.current="iso",mn({type:"wave"}),Jn("pro")},onDone:()=>{fs(),me(!0),Mt("Wave complete","#2E7D32")},onSave:async(I,re,de)=>{try{await ke.saveWave({directive:I,sessionIds:re,waveId:de==null?void 0:de.waveId}),fs(),Mt("Wave saved","#2E7D32")}catch(we){Mt(`Save failed: ${we instanceof Error?we.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:I=>{H(!1),Tn({type:"knowledge",docId:I}),ke.getKnowledge().then(g).catch(()=>{})},onRefreshWaves:()=>ke.getWaves().then(f).catch(()=>{}),terminalWidth:Jr?Ri:0,onOpenSaveModal:()=>wt(!0)}),L.length>0&&!P&&(()=>{var de;const I=L[L.length-1],re=Q.length>1;return l.jsxs(l.Fragment,{children:[re&&L.length===1&&l.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[63] flex gap-1 px-2 pt-2",children:Q.map((we,Te)=>l.jsx("button",{onClick:()=>{U(Te),_([{sessionId:we.sessionId,title:`CEO WAVE · ${we.roleId.toUpperCase()}`,color:"#B71C1C"}])},className:"px-3 py-1.5 text-xs font-bold rounded-t-lg cursor-pointer transition-colors",style:{background:M===Te?"#B71C1C":"var(--terminal-bg)",color:M===Te?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${M===Te?"#B71C1C":"var(--terminal-border)"}`,borderBottom:"none"},children:we.roleId.toUpperCase()},we.sessionId))}),l.jsx(u_,{sessionId:I.sessionId,title:L.length>1?I.title:re?`CEO WAVE · ${((de=Q[M])==null?void 0:de.roleName)??""}`:I.title,color:I.color,variant:"modal",style:re&&L.length===1?{marginTop:28}:void 0,onClose:()=>{yn(we=>we.filter(Te=>Te.source!=="wave")),_([]),K([]),U(0),O(!1)},onMinimize:()=>O(!0),onDone:()=>{fr(),fs()},onNavigateToSession:()=>{},onOpenKnowledgeDoc:we=>{_([]),K([]),U(0),O(!1),Tn({type:"knowledge",docId:we}),ke.getKnowledge().then(g).catch(()=>{})}},I.sessionId)]})})(),L.length>1&&l.jsx("div",{className:"fixed top-[5%] left-1/2 -translate-x-1/2 w-[720px] max-w-[95vw] z-[62] pointer-events-none",children:l.jsx("div",{className:"pointer-events-auto",children:l.jsxs("button",{onClick:()=>_(I=>I.slice(0,-1)),className:"mt-2 ml-2 px-3 py-1 text-xs font-bold text-[var(--terminal-text)] bg-[var(--terminal-bg)] border border-[var(--terminal-border)] rounded-lg cursor-pointer hover:bg-[var(--terminal-inline-bg)]",children:["←"," Back to ",(Su=L[L.length-2])==null?void 0:Su.title]})})}),B&&l.jsx(m_,{cLevelRoles:J&&Z[J]?Z[J].children.map(I=>n.find(re=>re.id===I)).filter(I=>!!I):n.filter(I=>I.level==="c-level"),orgNodes:Z,rootId:J,onClose:()=>X(!1),onDispatch:(I,re)=>ds(I,re)}),it&&l.jsx(qB,{existingRoles:n,onClose:()=>ht(!1),onHire:_o,onStoreVisit:()=>on({type:"store_visited"}),questHint:((ju=Ys==null?void 0:Ys.hint)==null?void 0:ju.target)==="hire-btn"?{message:Ys.description,roleId:((Cu=Ys.trigger.condition)==null?void 0:Cu.roleId)??void 0}:void 0}),Ye&&l.jsx(XB,{onClose:()=>nt(!1)}),ut&&l.jsx(KB,{roleId:ut.roleId,roleName:ut.roleName,onClose:()=>kt(null),onConfirm:Oa}),vn&&l.jsx(JO,{role:vn,appearance:Zt(vn.id),onSave:I=>{ae(vn.id,I),on({type:"accessory_changed"})},onReset:()=>Ve(vn.id),onClose:()=>{ce(null),Ue("character")},theme:We,onThemeChange:I=>{tn(I),on({type:"theme_changed"})},onUpdateName:async(I,re)=>{await Ps(I,{name:re})},initialTab:"character",characterOnly:!0,speechSettings:Ne,onSpeechSettingsChange:Ct,language:ln,onLanguageChange:nn,roleLevel:(Nu=Fe[vn.id])==null?void 0:Nu.level,coinBalance:Se,purchased:Kr,onPurchase:(I,re)=>{ke.spendCoins(re,`Purchased ${I}`,I).then(de=>{Me(de.balance),gr(I)}).catch(()=>{})}}),dt&&(()=>{const I=n.find(re=>re.id==="cto")??n.find(re=>re.level==="c-level")??n[0];return l.jsx(nL,{status:$e.status,history:$e.history,onClose:()=>wt(!1),onSave:async re=>{const de=await $e.save(re);return de!=null&&de.ok&&on({type:"save_committed"}),de},onLoadHistory:$e.loadHistory,onRestore:$e.restore,saving:$e.state==="saving",repo:$e.repo,onRepoChange:$e.setRepo,syncInfo:$e.syncInfo,onPull:$e.pull,pulling:$e.pulling,onRefresh:$e.refresh,onInitGit:$e.initGit,delegateRoleName:(I==null?void 0:I.name)??(I==null?void 0:I.id),onDelegate:I?async re=>{wt(!1);try{const de=await ke.createSession(I.id,"do");yn(Te=>[de,...Te]),Cn(de.id),us();const we=`Review the following unsaved changes, write a proper commit message, save (git add + commit), and push. If the current branch is not the main branch, create a PR and merge it.
126
+
127
+ Changed files:
128
+ ${re}`;hs(de.id,we,"do")}catch(de){Mt(`Failed to delegate: ${de instanceof Error?de.message:"error"}`,"#B71C1C")}}:void 0})})(),yr&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Pn(!1),children:l.jsx("div",{style:{width:420,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8},onClick:I=>I.stopPropagation(),children:l.jsx(rL,{onClose:()=>Pn(!1)})})}),Qr&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>fi(!1),children:l.jsx("div",{style:{width:480,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:I=>I.stopPropagation(),children:l.jsx(aL,{onClose:()=>fi(!1),onSyncComplete:()=>{}})})}),Di&&l.jsx(dL,{onClose:()=>Sn(!1),speechSettings:Ne,onSpeechSettingsChange:Ct,language:ln,onLanguageChange:nn,onOpenSync:()=>fi(!0),onOpenGitStatus:()=>Zr(!0),onOpenSessions:()=>jr(!0),onOpenStats:()=>Pn(!0)}),Ls&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Zr(!1),children:l.jsx("div",{style:{width:520,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:I=>I.stopPropagation(),children:l.jsx(lL,{onClose:()=>Zr(!1)})})}),Ma&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>jr(!1),children:l.jsx("div",{style:{width:520,maxHeight:"80vh",background:"var(--terminal-bg)",border:"2px solid var(--pixel-border)",borderRadius:8,overflowY:"auto"},onClick:I=>I.stopPropagation(),children:l.jsx(oL,{onClose:()=>jr(!1),onOpenSession:I=>{jr(!1),mn({type:"role",roleId:I}),Jn("pro")}})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:Ce.map(I=>l.jsxs("div",{className:"toast-enter flex items-center gap-2 px-4 py-2.5 shadow-lg text-white text-xs font-black",style:{background:I.color,border:"2px solid rgba(0,0,0,0.3)",fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"w-2 h-2 bg-white/60"}),I.message]},I.id))})]})}function rf({onSelect:e,onClose:t}){const[n,i]=S.useState(null),[a,o]=S.useState(!0),[c,d]=S.useState(""),[m,f]=S.useState(!1),[x,p]=S.useState(!1),y=S.useRef(null),g=S.useCallback(async k=>{o(!0);try{const j=await ke.browse(k);i(j)}catch{}finally{o(!1)}},[]);S.useEffect(()=>{g()},[g]),S.useEffect(()=>{var k;m&&((k=y.current)==null||k.focus())},[m]);const w=async()=>{if(!(!n||!c.trim())){p(!0);try{const k=await ke.mkdir(n.current,c.trim());k.ok&&(d(""),f(!1),await g(k.path))}catch{}finally{p(!1)}}};return a&&!n?l.jsx("div",{className:"mt-3 rounded-lg p-4 text-xs text-center",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",color:"var(--terminal-text-muted)"},children:"Loading..."}):n?l.jsxs("div",{className:"mt-3 rounded-lg overflow-hidden text-xs",style:{background:"var(--terminal-bg)",border:"1px solid var(--terminal-border)",maxHeight:260,overflowY:"auto"},children:[l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 sticky top-0 z-10",style:{background:"var(--terminal-surface)",borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("span",{style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},className:"truncate flex-1",children:n.current}),l.jsx("button",{onClick:()=>{f(!m),d("")},className:"px-2 py-1 rounded text-[10px] font-medium shrink-0 cursor-pointer",style:{background:"var(--terminal-bg)",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},title:"New folder",children:"+ Folder"}),l.jsx("button",{onClick:()=>e(n.current),className:"px-2 py-1 rounded text-[10px] font-medium shrink-0 cursor-pointer",style:{background:"var(--active-green)",color:"#fff"},children:"Select"}),l.jsx("button",{onClick:t,className:"opacity-50 hover:opacity-100 shrink-0 cursor-pointer",style:{color:"var(--terminal-text)"},children:"✕"})]}),m&&l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid var(--terminal-border)",background:"var(--hud-bg-alt)"},children:[l.jsx("input",{ref:y,className:"flex-1 px-2 py-1 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",outline:"none"},placeholder:"folder name",value:c,onChange:k=>d(k.target.value),onKeyDown:k=>{k.key==="Enter"&&w(),k.key==="Escape"&&f(!1)}}),l.jsx("button",{onClick:w,disabled:x||!c.trim(),className:"px-2 py-1 rounded text-[10px] font-medium shrink-0 cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:x||!c.trim()?.5:1},children:x?"...":"Create"})]}),n.parent&&l.jsxs("div",{className:"px-3 py-1.5 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)]",style:{color:"var(--terminal-text-secondary)"},onClick:()=>g(n.parent),children:[l.jsx("span",{children:"⬆️"}),l.jsx("span",{children:".."})]}),n.dirs.map(k=>l.jsxs("div",{className:"px-3 py-1.5 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)]",style:{color:"var(--terminal-text)"},onClick:()=>g(k.path),children:[l.jsx("span",{children:"📁"}),l.jsx("span",{children:k.name})]},k.path)),n.dirs.length===0&&!m&&l.jsx("div",{className:"px-3 py-3 text-center",style:{color:"var(--terminal-text-muted)"},children:"No subdirectories"})]}):null}const vL={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function m2(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function wL({onComplete:e}){const[t,n]=S.useState(0),[i,a]=S.useState(null),[o,c]=S.useState("none"),[d,m]=S.useState(""),[f,x]=S.useState(!0),[p,y]=S.useState(""),[g,w]=S.useState(""),[k,j]=S.useState("en"),C=S.useRef(null),[N,E]=S.useState("new"),[A,z]=S.useState(""),[D,F]=S.useState(""),[q,V]=S.useState(!1),[L,_]=S.useState(!1),[B,X]=S.useState(!1),[R,H]=S.useState(""),[$,G]=S.useState(!1),[Q,K]=S.useState(!1),[M,U]=S.useState([]),[P,O]=S.useState(""),[Z,ee]=S.useState(!1),[J,se]=S.useState(""),[le,ye]=S.useState(null),[De,Ee]=S.useState(!1),[Re,me]=S.useState(!1),[Fe,Je]=S.useState([]),[Pe,it]=S.useState("startup"),[ht,Ye]=S.useState(!1),[nt,ut]=S.useState(!1),[kt,mt]=S.useState(null),[ve,be]=S.useState([]),[te,oe]=S.useState(""),[Ce,pe]=S.useState(!1),[Se,Me]=S.useState(!1),[Ge,Ie]=S.useState([]),qe=S.useMemo(()=>m2(N),[N]),Xe=qe[t]??"engine";S.useEffect(()=>{ke.detectEngine().then(Ne=>{a(Ne),c(Ne.recommended),x(!1)}).catch(()=>x(!1)),ke.getTeams().then(Je).catch(()=>{}),ke.getStatus().then(Ne=>{F(Ne.companyRoot||"")}).catch(()=>{})},[]),S.useEffect(()=>{var Ne;Xe==="company"&&((Ne=C.current)==null||Ne.focus())},[Xe]),S.useEffect(()=>{if(q||!D)return;const Ne=p.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");z(Ne?`${D}/${Ne}`:D)},[p,D,q]);const et=()=>{switch(Xe){case"engine":return o!=="none"||d.length>10;case"company":return p.trim().length>0;case"workspace":return N==="existing-akb"?le===!0:!0;case"team":return!0;case"create":return!nt;default:return!1}},ze=()=>{t<qe.length-1&&et()&&n(t+1),Xe==="create"&&!ht&&!Ce&&(N==="existing-akb"?Zt():hn())},Be=()=>{t>0&&n(t-1)},_t=S.useRef(N);S.useEffect(()=>{if(_t.current===N)return;_t.current=N;const Ct=m2(N).indexOf("workspace");Ct>=0&&n(Ct)},[N]);const en=async()=>{if(J.trim()){Ee(!0);try{const Ne=await ke.validatePath(J.trim());ye(Ne.valid&&Ne.hasClaudeMd===!0)}catch{ye(!1)}finally{Ee(!1)}}},Tt=()=>{const Ne=P.trim();Ne&&!M.includes(Ne)&&(U([...M,Ne]),O(""))},Pt=async Ne=>{Me(!0),Ie([]);try{const{tools:Ct}=await ke.getRequiredTools(Ne);if(Ct.filter(nn=>!nn.installed).length===0){Me(!1);return}await ke.installTools(Ne,(nn,Kr)=>{const gr=Kr.tool||"";nn==="checking"?Ie(vn=>[...vn,{event:nn,tool:gr,detail:"checking..."}]):nn==="installing"?Ie(vn=>[...vn,{event:nn,tool:gr,detail:"installing..."}]):nn==="installed"?Ie(vn=>[...vn,{event:nn,tool:gr,detail:"installed"}]):nn==="skipped"?Ie(vn=>[...vn,{event:nn,tool:gr,detail:Kr.reason||"skipped"}]):nn==="error"&&Ie(vn=>[...vn,{event:nn,tool:gr,detail:Kr.error||"failed"}])})}catch{}finally{Me(!1)}},hn=async()=>{Ye(!0),mt(null);try{const Ne={companyName:p.trim(),description:g.trim()||"An AI-powered organization",team:Pe,knowledgePaths:M.length>0?M:void 0,language:k!=="auto"?k:void 0,location:A.trim()||void 0,codeRoot:R.trim()||void 0};(o==="direct-api"||d)&&(Ne.apiKey=d||void 0);const Ct=await ke.scaffold(Ne);be(Ct.created),oe(Ct.projectRoot),ut(!0),Ye(!1),Pe!=="custom"&&Pt(Pe)}catch(Ne){mt(Ne instanceof Error?Ne.message:"Scaffold failed"),Ye(!1)}},Zt=async()=>{pe(!0),mt(null);try{const Ne=await ke.connectAkb(J.trim());Ne.ok?(ut(!0),be([`Connected to: ${Ne.companyRoot}`])):mt(Ne.error||"Failed to connect")}catch(Ne){mt(Ne instanceof Error?Ne.message:"Connect failed")}finally{pe(!1)}},ae=()=>{M.length>0?e({paths:M,companyRoot:""}):e()},Ve=Ne=>{Ne.key==="Enter"&&et()&&(Ne.preventDefault(),ze())},We=`w-full px-3 py-2 rounded text-sm outline-none transition-colors
129
+ bg-[var(--terminal-bg)] text-[var(--terminal-text)]
130
+ border border-[var(--terminal-border)]
131
+ focus:border-[var(--terminal-border-hover)]
132
+ placeholder:text-[var(--terminal-text-muted)]`,tn=Ne=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${Ne?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--terminal-border)] bg-[var(--hud-bg-alt)] hover:border-[var(--accent)]/50"}`;return l.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},onKeyDown:Ve,children:l.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl overflow-hidden",style:{background:"var(--hud-bg)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"px-6 py-5",style:{background:"var(--terminal-bg)",borderBottom:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"text-lg font-bold",style:{color:"var(--terminal-text)",fontFamily:"var(--pixel-font)"},children:"tycono"}),l.jsx("div",{className:"text-xs mt-1",style:{color:"var(--terminal-text-secondary)"},children:"Build an AI company. Watch them work."}),l.jsx("div",{className:"flex gap-1.5 mt-4",children:qe.map((Ne,Ct)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:Ct<=t?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:Ct===t?"var(--terminal-text)":"var(--terminal-text-muted)"},children:vL[Ne]})]},Ne))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[Xe==="engine"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"AI Engine Setup"}),f?l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:"Detecting AI engine..."}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:tn(o==="claude-cli"),onClick:()=>(i==null?void 0:i.claudeCli)&&c("claude-cli"),style:{opacity:i!=null&&i.claudeCli?1:.4},children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-lg",children:i!=null&&i.claudeCli?"✅":"❌"}),l.jsxs("div",{children:[l.jsx("div",{className:"font-medium text-sm",children:"Claude Code CLI"}),l.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.claudeCli?"Detected! Recommended — zero config needed.":"Not installed. Get it at claude.ai/download"})]})]})}),l.jsxs("div",{className:tn(o==="direct-api"),onClick:()=>c("direct-api"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-lg",children:i!=null&&i.apiKey?"✅":"🔑"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"font-medium text-sm",children:"Anthropic API Key (BYOK)"}),l.jsx("div",{className:"text-xs opacity-70",children:i!=null&&i.apiKey?"API key found in environment.":"Enter your ANTHROPIC_API_KEY"})]})]}),o==="direct-api"&&!(i!=null&&i.apiKey)&&l.jsx("input",{type:"password",className:`${We} mt-3`,placeholder:"sk-ant-...",value:d,onChange:Ne=>m(Ne.target.value),autoFocus:!0})]})]})]}),Xe==="company"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Company"}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Company Name *"}),l.jsx("input",{ref:C,className:We,placeholder:"e.g. Acme Corp",value:p,onChange:Ne=>y(Ne.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"Description"}),l.jsx("textarea",{className:`${We} resize-none`,rows:3,placeholder:"What does your AI company do?",value:g,onChange:Ne=>w(Ne.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"text-xs font-medium block mb-1",style:{color:"var(--terminal-text-secondary)"},children:"AI Response Language"}),l.jsxs("select",{className:We,value:k,onChange:Ne=>j(Ne.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),Xe==="workspace"&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Workspace"}),l.jsx(X0,{text:`"New Company" creates a fresh workspace with roles, knowledge base, and project structure.
133
+
134
+ "Connect Existing" links to an existing Tycono workspace you've set up before.`})]}),l.jsxs("div",{className:"flex rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:N==="new"?"var(--accent)":"var(--hud-bg-alt)",color:N==="new"?"#fff":"var(--terminal-text-muted)"},onClick:()=>E("new"),children:"New Company"}),l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:N==="existing-akb"?"var(--accent)":"var(--hud-bg-alt)",color:N==="existing-akb"?"#fff":"var(--terminal-text-muted)",borderLeft:"1px solid var(--terminal-border)"},onClick:()=>E("existing-akb"),children:"Connect Existing"})]}),N==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(p2,{icon:"📁",title:"Company Location",hint:"Where your AI company files will be created.",help:"Roles, knowledge, decisions, and project files are stored here. This is your AI company's home directory. Auto-generated from your company name — change it if needed.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${We} flex-1`,placeholder:"/path/to/your-company",value:A,onChange:Ne=>{z(Ne.target.value),V(!0)}}),l.jsx("button",{onClick:()=>_(!L),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),L&&l.jsx(rf,{onSelect:Ne=>{z(Ne),V(!0),_(!1)},onClose:()=>_(!1)})]}),l.jsxs(x2,{icon:"💻",title:"Code Repository",hint:"Connect a separate code repo.",help:`Link your existing code repo so AI roles can read and write code there.
135
+
136
+ Skip this if you don't have a codebase yet — you can connect one later from Settings.`,tag:"optional",open:B,onToggle:()=>X(!B),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${We} flex-1`,placeholder:"/path/to/code/repo",value:R,onChange:Ne=>H(Ne.target.value)}),l.jsx("button",{onClick:()=>G(!$),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"})]}),$&&l.jsx(rf,{onSelect:Ne=>{H(Ne),G(!1)},onClose:()=>G(!1)})]}),l.jsxs(x2,{icon:"📚",title:"Knowledge Import",hint:"Import existing documents into knowledge base.",help:`Point to folders with docs (.md, .txt, etc.) — AI will read, summarize, and organize them into a searchable knowledge base.
137
+
138
+ Skip this to start with an empty knowledge base. You can import documents anytime from the office.`,tag:"optional",open:Q,onToggle:()=>K(!Q),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${We} flex-1`,placeholder:"/path/to/docs",value:P,onChange:Ne=>O(Ne.target.value),onKeyDown:Ne=>{Ne.key==="Enter"&&(Ne.preventDefault(),Tt())}}),l.jsx("button",{onClick:()=>ee(!Z),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"}),l.jsx("button",{onClick:Tt,disabled:!P.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:P.trim()?1:.5},children:"Add"})]}),Z&&l.jsx(rf,{onSelect:Ne=>{M.includes(Ne)||U([...M,Ne]),ee(!1)},onClose:()=>ee(!1)}),M.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:M.map((Ne,Ct)=>l.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:[l.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"var(--pixel-font)"},children:Ne}),l.jsx("button",{onClick:()=>U(M.filter((ln,nn)=>nn!==Ct)),className:"opacity-50 hover:opacity-100",children:"✕"})]},Ct))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(p2,{icon:"🔗",title:"AKB Path",hint:"Directory with existing CLAUDE.md and AKB structure.",help:"Connect to a directory that was previously set up with Tycono. It must contain a CLAUDE.md file. All existing roles, knowledge, and settings will be loaded.",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${We} flex-1`,placeholder:"/path/to/your/akb",value:J,onChange:Ne=>{se(Ne.target.value),ye(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>me(!Re),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0 cursor-pointer hover:brightness-125",style:{background:"var(--terminal-surface)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},title:"Browse folders",children:"📁"}),l.jsx("button",{onClick:en,disabled:De||!J.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:De||!J.trim()?.5:1},children:De?"...":"Verify"})]}),le===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found"]}),le===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),Re&&l.jsx(rf,{onSelect:Ne=>{se(Ne),ye(null),me(!1)},onClose:()=>me(!1)})]})})]}),Xe==="team"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:"Team Template"}),l.jsx("p",{className:"text-xs",style:{color:"var(--terminal-text-secondary)"},children:"Choose a starting team. You can add or remove roles later."}),Fe.map(Ne=>l.jsxs("div",{className:tn(Pe===Ne.id),onClick:()=>it(Ne.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:Ne.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:Ne.roles.map(Ct=>l.jsx("span",{className:"px-2 py-0.5 rounded text-[10px]",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)"},children:Ct.id.toUpperCase()},Ct.id))})]},Ne.id)),l.jsxs("div",{className:tn(Pe==="custom"),onClick:()=>it("custom"),children:[l.jsx("div",{className:"font-medium text-sm",children:"Custom"}),l.jsx("div",{className:"text-xs opacity-70 mt-1",children:"Start with no pre-built roles. Hire them from the office."})]})]}),Xe==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:nt?N==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!nt&&!ht&&!Ce&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"rounded-lg p-4 space-y-2 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:N==="existing-akb"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Mode:"})," Connect Existing AKB"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Path:"})," ",J]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",o==="claude-cli"?"Claude Code CLI":"Direct API"]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Company:"})," ",p]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Location:"})," ",A||"(default)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Engine:"})," ",o==="claude-cli"?"Claude Code CLI":"Direct API"]}),R.trim()&&l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Code Repo:"})," ",R]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Knowledge:"})," ",M.length>0?`Import ${M.length} source(s)`:"Fresh (empty)"]}),l.jsxs("div",{children:[l.jsx("span",{className:"opacity-50",children:"Team:"})," ",Pe]}),M.length>0&&l.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--idle-amber)"},children:"Knowledge import will run in the background after entering the office."})]})}),kt&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:kt})]}),(ht||Ce)&&l.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[l.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),l.jsx("div",{className:"text-sm",style:{color:"var(--terminal-text-secondary)"},children:Ce?"Connecting to AKB...":"Scaffolding your company..."})]}),nt&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),te&&l.jsxs("div",{className:"rounded-lg p-3 text-xs",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[l.jsx("span",{className:"opacity-50",children:"Location:"})," ",te]}),l.jsx("div",{className:"rounded-lg p-4 text-xs max-h-40 overflow-y-auto",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:ve.map((Ne,Ct)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",Ne]},Ct))}),(Se||Ge.length>0)&&l.jsxs("div",{className:"rounded-lg p-4 text-xs space-y-1",style:{background:"var(--terminal-bg)",color:"var(--terminal-text)",border:"1px solid var(--terminal-border)",fontFamily:"var(--pixel-font)"},children:[l.jsx("div",{className:"font-medium mb-2",style:{color:"var(--terminal-text-secondary)"},children:Se?"Installing skill tools...":"Skill tools"}),Ge.map((Ne,Ct)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:Ne.event==="installed"||Ne.event==="skipped"?"var(--active-green)":Ne.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:Ne.event==="installed"||Ne.event==="skipped"?"✓":Ne.event==="error"?"✗":"…"}),l.jsx("span",{children:Ne.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:Ne.detail})]},Ct)),Se&&l.jsxs("div",{className:"flex items-center gap-2 mt-1",style:{color:"var(--terminal-text-muted)"},children:[l.jsx("div",{className:"w-3 h-3 border border-current rounded-full animate-spin",style:{borderTopColor:"var(--accent)"}}),l.jsx("span",{children:"Please wait..."})]})]}),M.length>0&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"var(--accent)",color:"#fff",opacity:.9},children:"Knowledge import will start in the background after entering the office."})]})]})]}),l.jsxs("div",{className:"px-6 py-4 flex justify-between items-center",style:{borderTop:"1px solid var(--terminal-border)"},children:[l.jsx("div",{children:t>0&&!nt&&l.jsx("button",{onClick:Be,className:"px-4 py-2 rounded text-sm transition-colors",style:{color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:"Back"})}),l.jsxs("div",{className:"text-xs",style:{color:"var(--terminal-text-muted)"},children:[t+1," / ",qe.length]}),l.jsx("div",{children:nt?l.jsx("button",{onClick:ae,disabled:Se,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:Se?.5:1},children:Se?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:ze,disabled:!et()||ht||Ce,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:et()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:et()&&!ht&&!Ce?1:.5},children:Xe==="create"?ht||Ce?Ce?"Connecting...":"Creating...":N==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function X0({text:e}){const[t,n]=S.useState(!1),[i,a]=S.useState({top:0,left:0}),o=S.useRef(null),c=()=>{if(o.current){const d=o.current.getBoundingClientRect();a({top:d.bottom+6,left:d.left})}n(!0)};return l.jsxs("span",{className:"inline-flex",ref:o,children:[l.jsx("span",{className:"w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center cursor-help shrink-0 select-none",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)"},onMouseEnter:c,onMouseLeave:()=>n(!1),onClick:d=>{d.stopPropagation(),t?n(!1):c()},children:"?"}),t&&l.jsxs("div",{className:"fixed z-[9999] px-3 py-2 rounded-lg text-[11px] leading-relaxed whitespace-pre-line w-60 shadow-lg pointer-events-none",style:{top:i.top,left:Math.min(i.left,window.innerWidth-260),background:"var(--terminal-bg)",color:"var(--terminal-text-secondary)",border:"1px solid var(--terminal-border)"},children:[l.jsx("div",{className:"absolute bottom-full w-0 h-0",style:{left:8,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderBottom:"5px solid var(--terminal-border)"}}),e]})]})}function p2({icon:e,title:t,hint:n,help:i,children:a}){return l.jsxs("div",{className:"rounded-lg p-3 space-y-2",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{className:"text-xs font-medium",style:{color:"var(--terminal-text)"},children:t}),i&&l.jsx(X0,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:n})]}),a]})}function x2({icon:e,title:t,hint:n,help:i,tag:a,open:o,onToggle:c,children:d}){return l.jsxs("div",{className:"rounded-lg",style:{background:"var(--hud-bg-alt)",border:"1px solid var(--terminal-border)"},children:[l.jsxs("div",{className:"p-3 cursor-pointer flex items-center gap-2 hover:bg-[var(--terminal-surface-light)] transition-colors",onClick:c,children:[l.jsx("span",{className:"text-sm",children:e}),l.jsx("span",{className:"text-xs font-medium flex-1",style:{color:"var(--terminal-text)"},children:t}),i&&l.jsx(X0,{text:i}),a&&l.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded",style:{background:"var(--terminal-surface)",color:"var(--terminal-text-muted)"},children:a}),l.jsx("span",{className:"text-[10px]",style:{color:"var(--terminal-text-muted)"},children:o?"▲":"▼"})]}),!o&&l.jsx("div",{className:"px-3 pb-2 -mt-1",children:l.jsx("div",{className:"text-[10px] ml-6",style:{color:"var(--terminal-text-muted)"},children:n})}),o&&l.jsx("div",{className:"px-3 pb-3 space-y-2",children:d})]})}function kL(){const[e,t]=S.useState(null),[n,i]=S.useState(!0),[a,o]=S.useState(null),c=S.useCallback(async()=>{i(!0),o(null);try{const d=await ke.getStatus();t(d)}catch(d){o(d instanceof Error?d.message:"Failed to fetch status")}finally{i(!1)}},[]);return S.useEffect(()=>{c()},[c]),{initialized:(e==null?void 0:e.initialized)??!1,companyName:(e==null?void 0:e.companyName)??null,engine:(e==null?void 0:e.engine)??"none",companyRoot:(e==null?void 0:e.companyRoot)??"",loading:n,error:a,refetch:c}}const SL=S.lazy(()=>Px(()=>import("./preview-app-CMGFfqT-.js"),[])),jL=S.lazy(()=>Px(()=>import("./index-Czp8wshq.js"),__vite__mapDeps([0,1])));function Yx(){return l.jsx("div",{className:"h-full flex items-center justify-center",style:{background:"var(--floor-dark)"},children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"w-10 h-10 mx-auto border-2 rounded-full animate-spin",style:{borderColor:"var(--terminal-border)",borderTopColor:"var(--accent)"}}),l.jsx("div",{className:"mt-4 text-sm",style:{color:"var(--terminal-text-secondary)",fontFamily:"var(--pixel-font)"},children:"Loading..."})]})})}function CL(){var e;try{const t=localStorage.getItem("tycono-theme"),n=t&&t in Bs?t:"default",i=(e=Bs[n])==null?void 0:e.vars;if(!i)return;const a=document.documentElement;for(const[o,c]of Object.entries(i))a.style.setProperty(o,c)}catch{}}function NL(){const{initialized:e,loading:t,refetch:n}=kL(),[i,a]=S.useState(null);S.useEffect(()=>{CL()},[]);const o=c=>{c&&a(c),n()};return t?l.jsx(Yx,{}):e?l.jsx(bL,{importReq:i,onImportDone:()=>a(null)}):l.jsx(wL,{onComplete:o})}function EL(){const e=new URLSearchParams(window.location.search),t=e.has("sprite-preview"),n=e.has("rpg-game");return l.jsx(Y4,{children:t?l.jsx(S.Suspense,{fallback:l.jsx(Yx,{}),children:l.jsx(SL,{})}):n?l.jsx(S.Suspense,{fallback:l.jsx(Yx,{}),children:l.jsx(jL,{})}):l.jsx(NL,{})})}H4.createRoot(document.getElementById("root")).render(l.jsx(S.StrictMode,{children:l.jsx(EL,{})}));export{ML as A,R3 as H,_L as O,B3 as P,$3 as S,z3 as a,F3 as b,DL as c,TL as d,l as j,S as r};