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.
@@ -1,138 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-uwS0YSTU.js","assets/index-BOuHc64o.css"])))=>i.map(i=>d[i]);
2
- var D4=Object.defineProperty;var _4=(e,t,r)=>t in e?D4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var db=(e,t,r)=>_4(e,typeof t!="symbol"?t+"":t,r);(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 r(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=r(a);fetch(a.href,o)}})();function _f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pm={exports:{}},yc={};/**
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 fb;function M4(){if(fb)return yc;fb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(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 yc.Fragment=t,yc.jsx=r,yc.jsxs=r,yc}var hb;function F4(){return hb||(hb=1,Pm.exports=M4()),Pm.exports}var l=F4(),Vm={exports:{}},kt={};/**
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 mb;function R4(){if(mb)return kt;mb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=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 k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,C={};function j(U,Y,$){this.props=U,this.context=Y,this.refs=C,this.updater=$||k}j.prototype.isReactComponent={},j.prototype.setState=function(U,Y){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,Y,"setState")},j.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function E(){}E.prototype=j.prototype;function N(U,Y,$){this.props=U,this.context=Y,this.refs=C,this.updater=$||k}var A=N.prototype=new E;A.constructor=N,w(A,j.prototype),A.isPureReactComponent=!0;var z=Array.isArray;function T(){}var F={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function V(U,Y,$){var Q=$.ref;return{$$typeof:e,type:U,key:Y,ref:Q!==void 0?Q:null,props:$}}function L(U,Y){return V(U.type,Y,U.props)}function _(U){return typeof U=="object"&&U!==null&&U.$$typeof===e}function O(U){var Y={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function($){return Y[$]})}var P=/\/+/g;function R(U,Y){return typeof U=="object"&&U!==null&&U.key!=null?O(""+U.key):Y.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(T,T):(U.status="pending",U.then(function(Y){U.status==="pending"&&(U.status="fulfilled",U.value=Y)},function(Y){U.status==="pending"&&(U.status="rejected",U.reason=Y)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function B(U,Y,$,Q,ee){var J=typeof U;(J==="undefined"||J==="boolean")&&(U=null);var ae=!1;if(U===null)ae=!0;else switch(J){case"bigint":case"string":case"number":ae=!0;break;case"object":switch(U.$$typeof){case e:case t:ae=!0;break;case x:return ae=U._init,B(ae(U._payload),Y,$,Q,ee)}}if(ae)return ee=ee(U),ae=Q===""?"."+R(U,0):Q,z(ee)?($="",ae!=null&&($=ae.replace(P,"$&/")+"/"),B(ee,Y,$,"",function(Ee){return Ee})):ee!=null&&(_(ee)&&(ee=L(ee,$+(ee.key==null||U&&U.key===ee.key?"":(""+ee.key).replace(P,"$&/")+"/")+ae)),Y.push(ee)),1;ae=0;var oe=Q===""?".":Q+":";if(z(U))for(var be=0;be<U.length;be++)Q=U[be],J=oe+R(Q,be),ae+=B(Q,Y,$,J,ee);else if(be=g(U),typeof be=="function")for(U=be.call(U),be=0;!(Q=U.next()).done;)Q=Q.value,J=oe+R(Q,be++),ae+=B(Q,Y,$,J,ee);else if(J==="object"){if(typeof U.then=="function")return B(H(U),Y,$,Q,ee);throw Y=String(U),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ae}function Z(U,Y,$){if(U==null)return U;var Q=[],ee=0;return B(U,Q,"","",function(J){return Y.call($,J,ee++)}),Q}function G(U){if(U._status===-1){var Y=U._result;Y=Y(),Y.then(function($){(U._status===0||U._status===-1)&&(U._status=1,U._result=$)},function($){(U._status===0||U._status===-1)&&(U._status=2,U._result=$)}),U._status===-1&&(U._status=0,U._result=Y)}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 Y=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(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},M={map:Z,forEach:function(U,Y,$){Z(U,function(){Y.apply(this,arguments)},$)},count:function(U){var Y=0;return Z(U,function(){Y++}),Y},toArray:function(U){return Z(U,function(Y){return Y})||[]},only:function(U){if(!_(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return kt.Activity=p,kt.Children=M,kt.Component=j,kt.Fragment=r,kt.Profiler=a,kt.PureComponent=N,kt.StrictMode=i,kt.Suspense=m,kt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=F,kt.__COMPILER_RUNTIME={__proto__:null,c:function(U){return F.H.useMemoCache(U)}},kt.cache=function(U){return function(){return U.apply(null,arguments)}},kt.cacheSignal=function(){return null},kt.cloneElement=function(U,Y,$){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var Q=w({},U.props),ee=U.key;if(Y!=null)for(J in Y.key!==void 0&&(ee=""+Y.key),Y)!q.call(Y,J)||J==="key"||J==="__self"||J==="__source"||J==="ref"&&Y.ref===void 0||(Q[J]=Y[J]);var J=arguments.length-2;if(J===1)Q.children=$;else if(1<J){for(var ae=Array(J),oe=0;oe<J;oe++)ae[oe]=arguments[oe+2];Q.children=ae}return V(U.type,ee,Q)},kt.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},kt.createElement=function(U,Y,$){var Q,ee={},J=null;if(Y!=null)for(Q in Y.key!==void 0&&(J=""+Y.key),Y)q.call(Y,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(ee[Q]=Y[Q]);var ae=arguments.length-2;if(ae===1)ee.children=$;else if(1<ae){for(var oe=Array(ae),be=0;be<ae;be++)oe[be]=arguments[be+2];ee.children=oe}if(U&&U.defaultProps)for(Q in ae=U.defaultProps,ae)ee[Q]===void 0&&(ee[Q]=ae[Q]);return V(U,J,ee)},kt.createRef=function(){return{current:null}},kt.forwardRef=function(U){return{$$typeof:d,render:U}},kt.isValidElement=_,kt.lazy=function(U){return{$$typeof:x,_payload:{_status:-1,_result:U},_init:G}},kt.memo=function(U,Y){return{$$typeof:f,type:U,compare:Y===void 0?null:Y}},kt.startTransition=function(U){var Y=F.T,$={};F.T=$;try{var Q=U(),ee=F.S;ee!==null&&ee($,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(T,K)}catch(J){K(J)}finally{Y!==null&&$.types!==null&&(Y.types=$.types),F.T=Y}},kt.unstable_useCacheRefresh=function(){return F.H.useCacheRefresh()},kt.use=function(U){return F.H.use(U)},kt.useActionState=function(U,Y,$){return F.H.useActionState(U,Y,$)},kt.useCallback=function(U,Y){return F.H.useCallback(U,Y)},kt.useContext=function(U){return F.H.useContext(U)},kt.useDebugValue=function(){},kt.useDeferredValue=function(U,Y){return F.H.useDeferredValue(U,Y)},kt.useEffect=function(U,Y){return F.H.useEffect(U,Y)},kt.useEffectEvent=function(U){return F.H.useEffectEvent(U)},kt.useId=function(){return F.H.useId()},kt.useImperativeHandle=function(U,Y,$){return F.H.useImperativeHandle(U,Y,$)},kt.useInsertionEffect=function(U,Y){return F.H.useInsertionEffect(U,Y)},kt.useLayoutEffect=function(U,Y){return F.H.useLayoutEffect(U,Y)},kt.useMemo=function(U,Y){return F.H.useMemo(U,Y)},kt.useOptimistic=function(U,Y){return F.H.useOptimistic(U,Y)},kt.useReducer=function(U,Y,$){return F.H.useReducer(U,Y,$)},kt.useRef=function(U){return F.H.useRef(U)},kt.useState=function(U){return F.H.useState(U)},kt.useSyncExternalStore=function(U,Y,$){return F.H.useSyncExternalStore(U,Y,$)},kt.useTransition=function(){return F.H.useTransition()},kt.version="19.2.4",kt}var pb;function eu(){return pb||(pb=1,Vm.exports=R4()),Vm.exports}var S=eu();const z4=_f(S);var Wm={exports:{}},bc={},Gm={exports:{}},Km={};/**
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 xb;function B4(){return xb||(xb=1,(function(e){function t(B,Z){var G=B.length;B.push(Z);e:for(;0<G;){var K=G-1>>>1,M=B[K];if(0<a(M,Z))B[K]=Z,B[G]=M,G=K;else break e}}function r(B){return B.length===0?null:B[0]}function i(B){if(B.length===0)return null;var Z=B[0],G=B.pop();if(G!==Z){B[0]=G;e:for(var K=0,M=B.length,U=M>>>1;K<U;){var Y=2*(K+1)-1,$=B[Y],Q=Y+1,ee=B[Q];if(0>a($,G))Q<M&&0>a(ee,$)?(B[K]=ee,B[Q]=G,K=Q):(B[K]=$,B[Y]=G,K=Y);else if(Q<M&&0>a(ee,G))B[K]=ee,B[Q]=G,K=Q;else break e}}return Z}function a(B,Z){var G=B.sortIndex-Z.sortIndex;return G!==0?G:B.id-Z.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,k=!1,w=!1,C=!1,j=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function A(B){for(var Z=r(f);Z!==null;){if(Z.callback===null)i(f);else if(Z.startTime<=B)i(f),Z.sortIndex=Z.expirationTime,t(m,Z);else break;Z=r(f)}}function z(B){if(w=!1,A(B),!k)if(r(m)!==null)k=!0,T||(T=!0,O());else{var Z=r(f);Z!==null&&H(z,Z.startTime-B)}}var T=!1,F=-1,q=5,V=-1;function L(){return C?!0:!(e.unstable_now()-V<q)}function _(){if(C=!1,T){var B=e.unstable_now();V=B;var Z=!0;try{e:{k=!1,w&&(w=!1,E(F),F=-1),g=!0;var G=y;try{t:{for(A(B),p=r(m);p!==null&&!(p.expirationTime>B&&L());){var K=p.callback;if(typeof K=="function"){p.callback=null,y=p.priorityLevel;var M=K(p.expirationTime<=B);if(B=e.unstable_now(),typeof M=="function"){p.callback=M,A(B),Z=!0;break t}p===r(m)&&i(m),A(B)}else i(m);p=r(m)}if(p!==null)Z=!0;else{var U=r(f);U!==null&&H(z,U.startTime-B),Z=!1}}break e}finally{p=null,y=G,g=!1}Z=void 0}}finally{Z?O():T=!1}}}var O;if(typeof N=="function")O=function(){N(_)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,R=P.port2;P.port1.onmessage=_,O=function(){R.postMessage(null)}}else O=function(){j(_,0)};function H(B,Z){F=j(function(){B(e.unstable_now())},Z)}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(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_next=function(B){switch(y){case 1:case 2:case 3:var Z=3;break;default:Z=y}var G=y;y=Z;try{return B()}finally{y=G}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(B,Z){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var G=y;y=B;try{return Z()}finally{y=G}},e.unstable_scheduleCallback=function(B,Z,G){var K=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?K+G:K):G=K,B){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=G+M,B={id:x++,callback:Z,priorityLevel:B,startTime:G,expirationTime:M,sortIndex:-1},G>K?(B.sortIndex=G,t(f,B),r(m)===null&&B===r(f)&&(w?(E(F),F=-1):w=!0,H(z,G-K))):(B.sortIndex=M,t(m,B),k||g||(k=!0,T||(T=!0,O()))),B},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(B){var Z=y;return function(){var G=y;y=Z;try{return B.apply(this,arguments)}finally{y=G}}}})(Km)),Km}var gb;function $4(){return gb||(gb=1,Gm.exports=B4()),Gm.exports}var Qm={exports:{}},fr={};/**
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 yb;function O4(){if(yb)return fr;yb=1;var e=eu();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 r(){}var i={d:{f:r,r:function(){throw Error(t(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},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 fr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,fr.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)},fr.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()}},fr.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))},fr.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},fr.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})}},fr.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)},fr.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})}},fr.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)},fr.requestFormReset=function(m){i.d.r(m)},fr.unstable_batchedUpdates=function(m,f){return m(f)},fr.useFormState=function(m,f,x){return c.H.useFormState(m,f,x)},fr.useFormStatus=function(){return c.H.useHostTransitionStatus()},fr.version="19.2.4",fr}var bb;function x2(){if(bb)return Qm.exports;bb=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(),Qm.exports=O4(),Qm.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 vb;function L4(){if(vb)return bc;vb=1;var e=$4(),t=eu(),r=x2();function i(n){var s="https://react.dev/errors/"+n;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 #"+n+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function o(n){var s=n,u=n;if(n.alternate)for(;s.return;)s=s.return;else{n=s;do s=n,(s.flags&4098)!==0&&(u=s.return),n=s.return;while(n)}return s.tag===3?u:null}function c(n){if(n.tag===13){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function d(n){if(n.tag===31){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function m(n){if(o(n)!==n)throw Error(i(188))}function f(n){var s=n.alternate;if(!s){if(s=o(n),s===null)throw Error(i(188));return s!==n?null:n}for(var u=n,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),n;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 D=!1,X=b.child;X;){if(X===u){D=!0,u=b,h=v;break}if(X===h){D=!0,h=b,u=v;break}X=X.sibling}if(!D){for(X=v.child;X;){if(X===u){D=!0,u=v,h=b;break}if(X===h){D=!0,h=v,u=b;break}X=X.sibling}if(!D)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?n:s}function x(n){var s=n.tag;if(s===5||s===26||s===27||s===6)return n;for(n=n.child;n!==null;){if(s=x(n),s!==null)return s;n=n.sibling}return null}var p=Object.assign,y=Symbol.for("react.element"),g=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),N=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),T=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 O(n){return n===null||typeof n!="object"?null:(n=_&&n[_]||n["@@iterator"],typeof n=="function"?n:null)}var P=Symbol.for("react.client.reference");function R(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===P?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case w:return"Fragment";case j:return"Profiler";case C:return"StrictMode";case z:return"Suspense";case T:return"SuspenseList";case V:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case k:return"Portal";case N:return n.displayName||"Context";case E:return(n._context.displayName||"Context")+".Consumer";case A:var s=n.render;return n=n.displayName,n||(n=s.displayName||s.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case F:return s=n.displayName||null,s!==null?s:R(n.type)||"Memo";case q:s=n._payload,n=n._init;try{return R(n(s))}catch{}}return null}var H=Array.isArray,B=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G={pending:!1,data:null,method:null,action:null},K=[],M=-1;function U(n){return{current:n}}function Y(n){0>M||(n.current=K[M],K[M]=null,M--)}function $(n,s){M++,K[M]=n.current,n.current=s}var Q=U(null),ee=U(null),J=U(null),ae=U(null);function oe(n,s){switch($(J,s),$(ee,n),$(Q,null),s.nodeType){case 9:case 11:n=(n=s.documentElement)&&(n=n.namespaceURI)?Ry(n):0;break;default:if(n=s.tagName,s=s.namespaceURI)s=Ry(s),n=zy(s,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Y(Q),$(Q,n)}function be(){Y(Q),Y(ee),Y(J)}function Ee(n){n.memoizedState!==null&&$(ae,n);var s=Q.current,u=zy(s,n.type);s!==u&&($(ee,n),$(Q,u))}function Ae(n){ee.current===n&&(Y(Q),Y(ee)),ae.current===n&&(Y(ae),mc._currentValue=G)}var Fe,he;function Re(n){if(Fe===void 0)try{throw Error()}catch(u){var s=u.stack.trim().match(/\n( *(at )?)/);Fe=s&&s[1]||"",he=-1<u.stack.indexOf(`
43
- at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
44
- `+Fe+n+he}var et=!1;function We(n,s){if(!n||et)return"";et=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var h={DetermineComponentFrameRoot:function(){try{if(s){var Me=function(){throw Error()};if(Object.defineProperty(Me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Me,[])}catch(ye){var xe=ye}Reflect.construct(n,[],Me)}else{try{Me.call()}catch(ye){xe=ye}n.call(Me.prototype)}}else{try{throw Error()}catch(ye){xe=ye}(Me=n())&&typeof Me.catch=="function"&&Me.catch(function(){})}}catch(ye){if(ye&&xe&&typeof ye.stack=="string")return[ye.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(),D=v[0],X=v[1];if(D&&X){var te=D.split(`
45
- `),pe=X.split(`
46
- `);for(b=h=0;h<te.length&&!te[h].includes("DetermineComponentFrameRoot");)h++;for(;b<pe.length&&!pe[b].includes("DetermineComponentFrameRoot");)b++;if(h===te.length||b===pe.length)for(h=te.length-1,b=pe.length-1;1<=h&&0<=b&&te[h]!==pe[b];)b--;for(;1<=h&&0<=b;h--,b--)if(te[h]!==pe[b]){if(h!==1||b!==1)do if(h--,b--,0>b||te[h]!==pe[b]){var ke=`
47
- `+te[h].replace(" at new "," at ");return n.displayName&&ke.includes("<anonymous>")&&(ke=ke.replace("<anonymous>",n.displayName)),ke}while(1<=h&&0<=b);break}}}finally{et=!1,Error.prepareStackTrace=u}return(u=n?n.displayName||n.name:"")?Re(u):""}function it(n,s){switch(n.tag){case 26:case 27:case 5:return Re(n.type);case 16:return Re("Lazy");case 13:return n.child!==s&&s!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("SuspenseList");case 0:case 15:return We(n.type,!1);case 11:return We(n.type.render,!1);case 1:return We(n.type,!0);case 31:return Re("Activity");default:return""}}function mt(n){try{var s="",u=null;do s+=it(n,u),u=n,n=n.return;while(n);return s}catch(h){return`
48
- Error generating stack: `+h.message+`
49
- `+h.stack}}var Ye=Object.prototype.hasOwnProperty,Ze=e.unstable_scheduleCallback,ut=e.unstable_cancelCallback,jt=e.unstable_shouldYield,ge=e.unstable_requestPaint,ve=e.unstable_now,Ce=e.unstable_getCurrentPriorityLevel,ne=e.unstable_ImmediatePriority,de=e.unstable_UserBlockingPriority,_e=e.unstable_NormalPriority,ce=e.unstable_LowPriority,Te=e.unstable_IdlePriority,Le=e.log,Xe=e.unstable_setDisableYieldValue,Ue=null,Pe=null;function lt(n){if(typeof Le=="function"&&Xe(n),Pe&&typeof Pe.setStrictMode=="function")try{Pe.setStrictMode(Ue,n)}catch{}}var tt=Math.clz32?Math.clz32:qt,ze=Math.log,He=Math.LN2;function qt(n){return n>>>=0,n===0?32:31-(ze(n)/He|0)|0}var Kt=256,Et=262144,Xt=4194304;function hn(n){var s=n&42;if(s!==0)return s;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function vn(n,s,u){var h=n.pendingLanes;if(h===0)return 0;var b=0,v=n.suspendedLanes,D=n.pingedLanes;n=n.warmLanes;var X=h&134217727;return X!==0?(h=X&~v,h!==0?b=hn(h):(D&=X,D!==0?b=hn(D):u||(u=X&~n,u!==0&&(b=hn(u))))):(X=h&~v,X!==0?b=hn(X):D!==0?b=hn(D):u||(u=h&~n,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 le(n,s){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&s)===0}function qe(n,s){switch(n){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 ot(){var n=Xt;return Xt<<=1,(Xt&62914560)===0&&(Xt=4194304),n}function Jt(n){for(var s=[],u=0;31>u;u++)s.push(n);return s}function je(n,s){n.pendingLanes|=s,s!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function St(n,s,u,h,b,v){var D=n.pendingLanes;n.pendingLanes=u,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=u,n.entangledLanes&=u,n.errorRecoveryDisabledLanes&=u,n.shellSuspendCounter=0;var X=n.entanglements,te=n.expirationTimes,pe=n.hiddenUpdates;for(u=D&~u;0<u;){var ke=31-tt(u),Me=1<<ke;X[ke]=0,te[ke]=-1;var xe=pe[ke];if(xe!==null)for(pe[ke]=null,ke=0;ke<xe.length;ke++){var ye=xe[ke];ye!==null&&(ye.lane&=-536870913)}u&=~Me}h!==0&&gn(n,h,0),v!==0&&b===0&&n.tag!==0&&(n.suspendedLanes|=v&~(D&~s))}function gn(n,s,u){n.pendingLanes|=s,n.suspendedLanes&=~s;var h=31-tt(s);n.entangledLanes|=s,n.entanglements[h]=n.entanglements[h]|1073741824|u&261930}function mn(n,s){var u=n.entangledLanes|=s;for(n=n.entanglements;u;){var h=31-tt(u),b=1<<h;b&s|n[h]&s&&(n[h]|=s),u&=~b}}function Zn(n,s){var u=s&-s;return u=(u&42)!==0?1:Jn(u),(u&(n.suspendedLanes|s))!==0?0:u}function Jn(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function An(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function ie(){var n=Z.p;return n!==0?n:(n=window.event,n===void 0?32:ib(n.type))}function Ie(n,s){var u=Z.p;try{return Z.p=n,s()}finally{Z.p=u}}var Ve=Math.random().toString(36).slice(2),ft="__reactFiber$"+Ve,Ct="__reactProps$"+Ve,xr="__reactContainer$"+Ve,Vn="__reactEvents$"+Ve,Sr="__reactListeners$"+Ve,ii="__reactHandles$"+Ve,dl="__reactResources$"+Ve,$r="__reactMarker$"+Ve;function Or(n){delete n[ft],delete n[Ct],delete n[Vn],delete n[Sr],delete n[ii]}function $i(n){var s=n[ft];if(s)return s;for(var u=n.parentNode;u;){if(s=u[xr]||u[ft]){if(u=s.alternate,s.child!==null||u!==null&&u.child!==null)for(n=Uy(n);n!==null;){if(u=n[ft])return u;n=Uy(n)}return s}n=u,u=n.parentNode}return null}function Oi(n){if(n=n[ft]||n[xr]){var s=n.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return n}return null}function si(n){var s=n.tag;if(s===5||s===26||s===27||s===6)return n.stateNode;throw Error(i(33))}function ki(n){var s=n[dl];return s||(s=n[dl]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function wn(n){n[$r]=!0}var gr=new Set,fl={};function or(n,s){ai(n,s),ai(n+"Capture",s)}function ai(n,s){for(fl[n]=s,n=0;n<s.length;n++)gr.add(s[n])}var Li=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]*$"),li={},Si={};function hl(n){return Ye.call(Si,n)?!0:Ye.call(li,n)?!1:Li.test(n)?Si[n]=!0:(li[n]=!0,!1)}function Lr(n,s,u){if(hl(s))if(u===null)n.removeAttribute(s);else{switch(typeof u){case"undefined":case"function":case"symbol":n.removeAttribute(s);return;case"boolean":var h=s.toLowerCase().slice(0,5);if(h!=="data-"&&h!=="aria-"){n.removeAttribute(s);return}}n.setAttribute(s,""+u)}}function os(n,s,u){if(u===null)n.removeAttribute(s);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(s);return}n.setAttribute(s,""+u)}}function Cr(n,s,u,h){if(h===null)n.removeAttribute(u);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(u);return}n.setAttributeNS(s,u,""+h)}}function Wn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ja(n){var s=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ml(n,s,u){var h=Object.getOwnPropertyDescriptor(n.constructor.prototype,s);if(!n.hasOwnProperty(s)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var b=h.get,v=h.set;return Object.defineProperty(n,s,{configurable:!0,get:function(){return b.call(this)},set:function(D){u=""+D,v.call(this,D)}}),Object.defineProperty(n,s,{enumerable:h.enumerable}),{getValue:function(){return u},setValue:function(D){u=""+D},stopTracking:function(){n._valueTracker=null,delete n[s]}}}}function Ii(n){if(!n._valueTracker){var s=ja(n)?"checked":"value";n._valueTracker=ml(n,s,""+n[s])}}function oi(n){if(!n)return!1;var s=n._valueTracker;if(!s)return!0;var u=s.getValue(),h="";return n&&(h=ja(n)?n.checked?"true":"false":n.value),n=h,n!==u?(s.setValue(n),!0):!1}function er(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var jr=/[\n"\\]/g;function En(n){return n.replace(jr,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function tr(n,s,u,h,b,v,D,X){n.name="",D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?n.type=D:n.removeAttribute("type"),s!=null?D==="number"?(s===0&&n.value===""||n.value!=s)&&(n.value=""+Wn(s)):n.value!==""+Wn(s)&&(n.value=""+Wn(s)):D!=="submit"&&D!=="reset"||n.removeAttribute("value"),s!=null?Os(n,D,Wn(s)):u!=null?Os(n,D,Wn(u)):h!=null&&n.removeAttribute("value"),b==null&&v!=null&&(n.defaultChecked=!!v),b!=null&&(n.checked=b&&typeof b!="function"&&typeof b!="symbol"),X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?n.name=""+Wn(X):n.removeAttribute("name")}function Tn(n,s,u,h,b,v,D,X){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(n.type=v),s!=null||u!=null){if(!(v!=="submit"&&v!=="reset"||s!=null)){Ii(n);return}u=u!=null?""+Wn(u):"",s=s!=null?""+Wn(s):u,X||s===n.value||(n.value=s),n.defaultValue=s}h=h??b,h=typeof h!="function"&&typeof h!="symbol"&&!!h,n.checked=X?n.checked:!!h,n.defaultChecked=!!h,D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"&&(n.name=D),Ii(n)}function Os(n,s,u){s==="number"&&er(n.ownerDocument)===n||n.defaultValue===""+u||(n.defaultValue=""+u)}function Ci(n,s,u,h){if(n=n.options,s){s={};for(var b=0;b<u.length;b++)s["$"+u[b]]=!0;for(u=0;u<n.length;u++)b=s.hasOwnProperty("$"+n[u].value),n[u].selected!==b&&(n[u].selected=b),b&&h&&(n[u].defaultSelected=!0)}else{for(u=""+Wn(u),s=null,b=0;b<n.length;b++){if(n[b].value===u){n[b].selected=!0,h&&(n[b].defaultSelected=!0);return}s!==null||n[b].disabled||(s=n[b])}s!==null&&(s.selected=!0)}}function pl(n,s,u){if(s!=null&&(s=""+Wn(s),s!==n.value&&(n.value=s),u==null)){n.defaultValue!==s&&(n.defaultValue=s);return}n.defaultValue=u!=null?""+Wn(u):""}function Ir(n,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=Wn(s),n.defaultValue=u,h=n.textContent,h===u&&h!==""&&h!==null&&(n.value=h),Ii(n)}function Hr(n,s){if(s){var u=n.firstChild;if(u&&u===n.lastChild&&u.nodeType===3){u.nodeValue=s;return}}n.textContent=s}var cs=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 hu(n,s,u){var h=s.indexOf("--")===0;u==null||typeof u=="boolean"||u===""?h?n.setProperty(s,""):s==="float"?n.cssFloat="":n[s]="":h?n.setProperty(s,u):typeof u!="number"||u===0||cs.has(s)?s==="float"?n.cssFloat=u:n[s]=(""+u).trim():n[s]=u+"px"}function Gn(n,s,u){if(s!=null&&typeof s!="object")throw Error(i(62));if(n=n.style,u!=null){for(var h in u)!u.hasOwnProperty(h)||s!=null&&s.hasOwnProperty(h)||(h.indexOf("--")===0?n.setProperty(h,""):h==="float"?n.cssFloat="":n[h]="");for(var b in s)h=s[b],s.hasOwnProperty(b)&&u[b]!==h&&hu(n,b,h)}else for(var v in s)s.hasOwnProperty(v)&&hu(n,v,s[v])}function nn(n){if(n.indexOf("-")===-1)return!1;switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Hi=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"]]),cr=/^[\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 Ur(n){return cr.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function nr(){}var No=null;function xl(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var qr=null,Er=null;function Ao(n){var s=Oi(n);if(s&&(n=s.stateNode)){var u=n[Ct]||null;e:switch(n=s.stateNode,s.type){case"input":if(tr(n,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name),s=u.name,u.type==="radio"&&s!=null){for(u=n;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll('input[name="'+En(""+s)+'"][type="radio"]'),s=0;s<u.length;s++){var h=u[s];if(h!==n&&h.form===n.form){var b=h[Ct]||null;if(!b)throw Error(i(90));tr(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===n.form&&oi(h)}break e;case"textarea":pl(n,u.value,u.defaultValue);break e;case"select":s=u.value,s!=null&&Ci(n,!!u.multiple,s,!1)}}}var gl=!1;function ur(n,s,u){if(gl)return n(s,u);gl=!0;try{var h=n(s);return h}finally{if(gl=!1,(qr!==null||Er!==null)&&(id(),qr&&(s=qr,n=Er,Er=qr=null,Ao(s),n)))for(s=0;s<n.length;s++)Ao(n[s])}}function ji(n,s){var u=n.stateNode;if(u===null)return null;var h=u[Ct]||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)||(n=n.type,h=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!h;break e;default:n=!1}if(n)return null;if(u&&typeof u!="function")throw Error(i(231,s,typeof u));return u}var Nr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),To=!1;if(Nr)try{var Ea={};Object.defineProperty(Ea,"passive",{get:function(){To=!0}}),window.addEventListener("test",Ea,Ea),window.removeEventListener("test",Ea,Ea)}catch{To=!1}var At=null,Do=null,rn=null;function yl(){if(rn)return rn;var n,s=Do,u=s.length,h,b="value"in At?At.value:At.textContent,v=b.length;for(n=0;n<u&&s[n]===b[n];n++);var D=u-n;for(h=1;h<=D&&s[u-h]===b[v-h];h++);return rn=b.slice(n,1<h?1-h:void 0)}function Ui(n){var s=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&s===13&&(n=13)):n=s,n===10&&(n=13),32<=n||n===13?n:0}function bl(){return!0}function ci(){return!1}function dr(n){function s(u,h,b,v,D){this._reactName=u,this._targetInst=b,this.type=h,this.nativeEvent=v,this.target=D,this.currentTarget=null;for(var X in n)n.hasOwnProperty(X)&&(u=n[X],this[X]=u?u(v):v[X]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?bl:ci,this.isPropagationStopped=ci,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=bl)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=bl)},persist:function(){},isPersistent:bl}),s}var Ei={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ui=dr(Ei),us=p({},Ei,{view:0,detail:0}),Gf=dr(us),_o,Na,Aa,Ta=p({},us,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:kl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Aa&&(Aa&&n.type==="mousemove"?(_o=n.screenX-Aa.screenX,Na=n.screenY-Aa.screenY):Na=_o=0,Aa=n),_o)},movementY:function(n){return"movementY"in n?n.movementY:Na}}),Mo=dr(Ta),Kf=p({},Ta,{dataTransfer:0}),mu=dr(Kf),pu=p({},us,{relatedTarget:0}),vl=dr(pu),qi=p({},Ei,{animationName:0,elapsedTime:0,pseudoElement:0}),ds=dr(qi),Fo=p({},Ei,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Qf=dr(Fo),xu=p({},Ei,{data:0}),Ro=dr(xu),Zf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},gu={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},sn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wl(n){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(n):(n=sn[n])?!!s[n]:!1}function kl(){return wl}var yu=p({},us,{key:function(n){if(n.key){var s=Zf[n.key]||n.key;if(s!=="Unidentified")return s}return n.type==="keypress"?(n=Ui(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?gu[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:kl,charCode:function(n){return n.type==="keypress"?Ui(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Ui(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),bu=dr(yu),vu=p({},Ta,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),zo=dr(vu),wu=p({},us,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:kl}),ku=dr(wu),I=p({},Ei,{propertyName:0,elapsedTime:0,pseudoElement:0}),re=dr(I),fe=p({},Ta,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),we=dr(fe),De=p({},Ei,{newState:0,oldState:0}),Qe=dr(De),Pt=[9,13,27,32],pt=Nr&&"CompositionEvent"in window,st=null;Nr&&"documentMode"in document&&(st=document.documentMode);var dt=Nr&&"TextEvent"in window&&!st,vt=Nr&&(!pt||st&&8<st&&11>=st),Yt=" ",Ls=!1;function yr(n,s){switch(n){case"keyup":return Pt.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wt(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Mt=!1;function Dn(n,s){switch(n){case"compositionend":return wt(s);case"keypress":return s.which!==32?null:(Ls=!0,Yt);case"textInput":return n=s.data,n===Yt&&Ls?null:n;default:return null}}function pn(n,s){if(Mt)return n==="compositionend"||!pt&&yr(n,s)?(n=yl(),rn=Do=At=null,Mt=!1,n):null;switch(n){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 vt&&s.locale!=="ko"?null:s.data;default:return null}}var nS={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 X0(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s==="input"?!!nS[n.type]:s==="textarea"}function P0(n,s,u,h){qr?Er?Er.push(h):Er=[h]:qr=h,s=dd(s,"onChange"),0<s.length&&(u=new ui("onChange","change",null,u,h),n.push({event:u,listeners:s}))}var Bo=null,$o=null;function rS(n){Ay(n,0)}function Su(n){var s=si(n);if(oi(s))return n}function V0(n,s){if(n==="change")return s}var W0=!1;if(Nr){var Jf;if(Nr){var eh="oninput"in document;if(!eh){var G0=document.createElement("div");G0.setAttribute("oninput","return;"),eh=typeof G0.oninput=="function"}Jf=eh}else Jf=!1;W0=Jf&&(!document.documentMode||9<document.documentMode)}function K0(){Bo&&(Bo.detachEvent("onpropertychange",Q0),$o=Bo=null)}function Q0(n){if(n.propertyName==="value"&&Su($o)){var s=[];P0(s,$o,n,xl(n)),ur(rS,s)}}function iS(n,s,u){n==="focusin"?(K0(),Bo=s,$o=u,Bo.attachEvent("onpropertychange",Q0)):n==="focusout"&&K0()}function sS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Su($o)}function aS(n,s){if(n==="click")return Su(s)}function lS(n,s){if(n==="input"||n==="change")return Su(s)}function oS(n,s){return n===s&&(n!==0||1/n===1/s)||n!==n&&s!==s}var Yr=typeof Object.is=="function"?Object.is:oS;function Oo(n,s){if(Yr(n,s))return!0;if(typeof n!="object"||n===null||typeof s!="object"||s===null)return!1;var u=Object.keys(n),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)||!Yr(n[b],s[b]))return!1}return!0}function Z0(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function J0(n,s){var u=Z0(n);n=0;for(var h;u;){if(u.nodeType===3){if(h=n+u.textContent.length,n<=s&&h>=s)return{node:u,offset:s-n};n=h}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Z0(u)}}function eg(n,s){return n&&s?n===s?!0:n&&n.nodeType===3?!1:s&&s.nodeType===3?eg(n,s.parentNode):"contains"in n?n.contains(s):n.compareDocumentPosition?!!(n.compareDocumentPosition(s)&16):!1:!1}function tg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var s=er(n.document);s instanceof n.HTMLIFrameElement;){try{var u=typeof s.contentWindow.location.href=="string"}catch{u=!1}if(u)n=s.contentWindow;else break;s=er(n.document)}return s}function th(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s&&(s==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||s==="textarea"||n.contentEditable==="true")}var cS=Nr&&"documentMode"in document&&11>=document.documentMode,Sl=null,nh=null,Lo=null,rh=!1;function ng(n,s,u){var h=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;rh||Sl==null||Sl!==er(h)||(h=Sl,"selectionStart"in h&&th(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}),Lo&&Oo(Lo,h)||(Lo=h,h=dd(nh,"onSelect"),0<h.length&&(s=new ui("onSelect","select",null,s,u),n.push({event:s,listeners:h}),s.target=Sl)))}function Da(n,s){var u={};return u[n.toLowerCase()]=s.toLowerCase(),u["Webkit"+n]="webkit"+s,u["Moz"+n]="moz"+s,u}var Cl={animationend:Da("Animation","AnimationEnd"),animationiteration:Da("Animation","AnimationIteration"),animationstart:Da("Animation","AnimationStart"),transitionrun:Da("Transition","TransitionRun"),transitionstart:Da("Transition","TransitionStart"),transitioncancel:Da("Transition","TransitionCancel"),transitionend:Da("Transition","TransitionEnd")},ih={},rg={};Nr&&(rg=document.createElement("div").style,"AnimationEvent"in window||(delete Cl.animationend.animation,delete Cl.animationiteration.animation,delete Cl.animationstart.animation),"TransitionEvent"in window||delete Cl.transitionend.transition);function _a(n){if(ih[n])return ih[n];if(!Cl[n])return n;var s=Cl[n],u;for(u in s)if(s.hasOwnProperty(u)&&u in rg)return ih[n]=s[u];return n}var ig=_a("animationend"),sg=_a("animationiteration"),ag=_a("animationstart"),uS=_a("transitionrun"),dS=_a("transitionstart"),fS=_a("transitioncancel"),lg=_a("transitionend"),og=new Map,sh="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(" ");sh.push("scrollEnd");function Ni(n,s){og.set(n,s),or(s,[n])}var Cu=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},di=[],jl=0,ah=0;function ju(){for(var n=jl,s=ah=jl=0;s<n;){var u=di[s];di[s++]=null;var h=di[s];di[s++]=null;var b=di[s];di[s++]=null;var v=di[s];if(di[s++]=null,h!==null&&b!==null){var D=h.pending;D===null?b.next=b:(b.next=D.next,D.next=b),h.pending=b}v!==0&&cg(u,b,v)}}function Eu(n,s,u,h){di[jl++]=n,di[jl++]=s,di[jl++]=u,di[jl++]=h,ah|=h,n.lanes|=h,n=n.alternate,n!==null&&(n.lanes|=h)}function lh(n,s,u,h){return Eu(n,s,u,h),Nu(n)}function Ma(n,s){return Eu(n,null,null,s),Nu(n)}function cg(n,s,u){n.lanes|=u;var h=n.alternate;h!==null&&(h.lanes|=u);for(var b=!1,v=n.return;v!==null;)v.childLanes|=u,h=v.alternate,h!==null&&(h.childLanes|=u),v.tag===22&&(n=v.stateNode,n===null||n._visibility&1||(b=!0)),n=v,v=v.return;return n.tag===3?(v=n.stateNode,b&&s!==null&&(b=31-tt(u),n=v.hiddenUpdates,h=n[b],h===null?n[b]=[s]:h.push(s),s.lane=u|536870912),v):null}function Nu(n){if(50<lc)throw lc=0,xm=null,Error(i(185));for(var s=n.return;s!==null;)n=s,s=n.return;return n.tag===3?n.stateNode:null}var El={};function hS(n,s,u,h){this.tag=n,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 Xr(n,s,u,h){return new hS(n,s,u,h)}function oh(n){return n=n.prototype,!(!n||!n.isReactComponent)}function fs(n,s){var u=n.alternate;return u===null?(u=Xr(n.tag,s,n.key,n.mode),u.elementType=n.elementType,u.type=n.type,u.stateNode=n.stateNode,u.alternate=n,n.alternate=u):(u.pendingProps=s,u.type=n.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=n.flags&65011712,u.childLanes=n.childLanes,u.lanes=n.lanes,u.child=n.child,u.memoizedProps=n.memoizedProps,u.memoizedState=n.memoizedState,u.updateQueue=n.updateQueue,s=n.dependencies,u.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},u.sibling=n.sibling,u.index=n.index,u.ref=n.ref,u.refCleanup=n.refCleanup,u}function ug(n,s){n.flags&=65011714;var u=n.alternate;return u===null?(n.childLanes=0,n.lanes=s,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=u.childLanes,n.lanes=u.lanes,n.child=u.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=u.memoizedProps,n.memoizedState=u.memoizedState,n.updateQueue=u.updateQueue,n.type=u.type,s=u.dependencies,n.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),n}function Au(n,s,u,h,b,v){var D=0;if(h=n,typeof n=="function")oh(n)&&(D=1);else if(typeof n=="string")D=y4(n,u,Q.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case V:return n=Xr(31,u,s,b),n.elementType=V,n.lanes=v,n;case w:return Fa(u.children,b,v,s);case C:D=8,b|=24;break;case j:return n=Xr(12,u,s,b|2),n.elementType=j,n.lanes=v,n;case z:return n=Xr(13,u,s,b),n.elementType=z,n.lanes=v,n;case T:return n=Xr(19,u,s,b),n.elementType=T,n.lanes=v,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case N:D=10;break e;case E:D=9;break e;case A:D=11;break e;case F:D=14;break e;case q:D=16,h=null;break e}D=29,u=Error(i(130,n===null?"null":typeof n,"")),h=null}return s=Xr(D,u,s,b),s.elementType=n,s.type=h,s.lanes=v,s}function Fa(n,s,u,h){return n=Xr(7,n,h,s),n.lanes=u,n}function ch(n,s,u){return n=Xr(6,n,null,s),n.lanes=u,n}function dg(n){var s=Xr(18,null,null,0);return s.stateNode=n,s}function uh(n,s,u){return s=Xr(4,n.children!==null?n.children:[],n.key,s),s.lanes=u,s.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},s}var fg=new WeakMap;function fi(n,s){if(typeof n=="object"&&n!==null){var u=fg.get(n);return u!==void 0?u:(s={value:n,source:s,stack:mt(s)},fg.set(n,s),s)}return{value:n,source:s,stack:mt(s)}}var Nl=[],Al=0,Tu=null,Io=0,hi=[],mi=0,Is=null,Yi=1,Xi="";function hs(n,s){Nl[Al++]=Io,Nl[Al++]=Tu,Tu=n,Io=s}function hg(n,s,u){hi[mi++]=Yi,hi[mi++]=Xi,hi[mi++]=Is,Is=n;var h=Yi;n=Xi;var b=32-tt(h)-1;h&=~(1<<b),u+=1;var v=32-tt(s)+b;if(30<v){var D=b-b%5;v=(h&(1<<D)-1).toString(32),h>>=D,b-=D,Yi=1<<32-tt(s)+b|u<<b|h,Xi=v+n}else Yi=1<<v|u<<b|h,Xi=n}function dh(n){n.return!==null&&(hs(n,1),hg(n,1,0))}function fh(n){for(;n===Tu;)Tu=Nl[--Al],Nl[Al]=null,Io=Nl[--Al],Nl[Al]=null;for(;n===Is;)Is=hi[--mi],hi[mi]=null,Xi=hi[--mi],hi[mi]=null,Yi=hi[--mi],hi[mi]=null}function mg(n,s){hi[mi++]=Yi,hi[mi++]=Xi,hi[mi++]=Is,Yi=s.id,Xi=s.overflow,Is=n}var rr=null,yn=null,Lt=!1,Hs=null,pi=!1,hh=Error(i(519));function Us(n){var s=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ho(fi(s,n)),hh}function pg(n){var s=n.stateNode,u=n.type,h=n.memoizedProps;switch(s[ft]=n,s[Ct]=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<cc.length;u++)Rt(cc[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),Tn(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),Ir(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||My(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=nr),s=!0):s=!1,s||Us(n,!0)}function xg(n){for(rr=n.return;rr;)switch(rr.tag){case 5:case 31:case 13:pi=!1;return;case 27:case 3:pi=!0;return;default:rr=rr.return}}function Tl(n){if(n!==rr)return!1;if(!Lt)return xg(n),Lt=!0,!1;var s=n.tag,u;if((u=s!==3&&s!==27)&&((u=s===5)&&(u=n.type,u=!(u!=="form"&&u!=="button")||_m(n.type,n.memoizedProps)),u=!u),u&&yn&&Us(n),xg(n),s===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));yn=Hy(n)}else if(s===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));yn=Hy(n)}else s===27?(s=yn,na(n.type)?(n=Bm,Bm=null,yn=n):yn=s):yn=rr?gi(n.stateNode.nextSibling):null;return!0}function Ra(){yn=rr=null,Lt=!1}function mh(){var n=Hs;return n!==null&&(_r===null?_r=n:_r.push.apply(_r,n),Hs=null),n}function Ho(n){Hs===null?Hs=[n]:Hs.push(n)}var ph=U(null),za=null,ms=null;function qs(n,s,u){$(ph,s._currentValue),s._currentValue=u}function ps(n){n._currentValue=ph.current,Y(ph)}function xh(n,s,u){for(;n!==null;){var h=n.alternate;if((n.childLanes&s)!==s?(n.childLanes|=s,h!==null&&(h.childLanes|=s)):h!==null&&(h.childLanes&s)!==s&&(h.childLanes|=s),n===u)break;n=n.return}}function gh(n,s,u,h){var b=n.child;for(b!==null&&(b.return=n);b!==null;){var v=b.dependencies;if(v!==null){var D=b.child;v=v.firstContext;e:for(;v!==null;){var X=v;v=b;for(var te=0;te<s.length;te++)if(X.context===s[te]){v.lanes|=u,X=v.alternate,X!==null&&(X.lanes|=u),xh(v.return,u,n),h||(D=null);break e}v=X.next}}else if(b.tag===18){if(D=b.return,D===null)throw Error(i(341));D.lanes|=u,v=D.alternate,v!==null&&(v.lanes|=u),xh(D,u,n),D=null}else D=b.child;if(D!==null)D.return=b;else for(D=b;D!==null;){if(D===n){D=null;break}if(b=D.sibling,b!==null){b.return=D.return,D=b;break}D=D.return}b=D}}function Dl(n,s,u,h){n=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 D=b.alternate;if(D===null)throw Error(i(387));if(D=D.memoizedProps,D!==null){var X=b.type;Yr(b.pendingProps.value,D.value)||(n!==null?n.push(X):n=[X])}}else if(b===ae.current){if(D=b.alternate,D===null)throw Error(i(387));D.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(n!==null?n.push(mc):n=[mc])}b=b.return}n!==null&&gh(s,n,u,h),s.flags|=262144}function Du(n){for(n=n.firstContext;n!==null;){if(!Yr(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Ba(n){za=n,ms=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function ir(n){return gg(za,n)}function _u(n,s){return za===null&&Ba(n),gg(n,s)}function gg(n,s){var u=s._currentValue;if(s={context:s,memoizedValue:u,next:null},ms===null){if(n===null)throw Error(i(308));ms=s,n.dependencies={lanes:0,firstContext:s},n.flags|=524288}else ms=ms.next=s;return u}var mS=typeof AbortController<"u"?AbortController:function(){var n=[],s=this.signal={aborted:!1,addEventListener:function(u,h){n.push(h)}};this.abort=function(){s.aborted=!0,n.forEach(function(u){return u()})}},pS=e.unstable_scheduleCallback,xS=e.unstable_NormalPriority,zn={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function yh(){return{controller:new mS,data:new Map,refCount:0}}function Uo(n){n.refCount--,n.refCount===0&&pS(xS,function(){n.controller.abort()})}var qo=null,bh=0,_l=0,Ml=null;function gS(n,s){if(qo===null){var u=qo=[];bh=0,_l=km(),Ml={status:"pending",value:void 0,then:function(h){u.push(h)}}}return bh++,s.then(yg,yg),s}function yg(){if(--bh===0&&qo!==null){Ml!==null&&(Ml.status="fulfilled");var n=qo;qo=null,_l=0,Ml=null;for(var s=0;s<n.length;s++)(0,n[s])()}}function yS(n,s){var u=[],h={status:"pending",value:null,reason:null,then:function(b){u.push(b)}};return n.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 bg=B.S;B.S=function(n,s){ny=ve(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&gS(n,s),bg!==null&&bg(n,s)};var $a=U(null);function vh(){var n=$a.current;return n!==null?n:dn.pooledCache}function Mu(n,s){s===null?$($a,$a.current):$($a,s.pool)}function vg(){var n=vh();return n===null?null:{parent:zn._currentValue,pool:n}}var Fl=Error(i(460)),wh=Error(i(474)),Fu=Error(i(542)),Ru={then:function(){}};function wg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function kg(n,s,u){switch(u=n[u],u===void 0?n.push(s):u!==s&&(s.then(nr,nr),s=u),s.status){case"fulfilled":return s.value;case"rejected":throw n=s.reason,Cg(n),n;default:if(typeof s.status=="string")s.then(nr,nr);else{if(n=dn,n!==null&&100<n.shellSuspendCounter)throw Error(i(482));n=s,n.status="pending",n.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 n=s.reason,Cg(n),n}throw La=s,Fl}}function Oa(n){try{var s=n._init;return s(n._payload)}catch(u){throw u!==null&&typeof u=="object"&&typeof u.then=="function"?(La=u,Fl):u}}var La=null;function Sg(){if(La===null)throw Error(i(459));var n=La;return La=null,n}function Cg(n){if(n===Fl||n===Fu)throw Error(i(483))}var Rl=null,Yo=0;function zu(n){var s=Yo;return Yo+=1,Rl===null&&(Rl=[]),kg(Rl,n,s)}function Xo(n,s){s=s.props.ref,n.ref=s!==void 0?s:null}function Bu(n,s){throw s.$$typeof===y?Error(i(525)):(n=Object.prototype.toString.call(s),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":n)))}function jg(n){function s(ue,se){if(n){var me=ue.deletions;me===null?(ue.deletions=[se],ue.flags|=16):me.push(se)}}function u(ue,se){if(!n)return null;for(;se!==null;)s(ue,se),se=se.sibling;return null}function h(ue){for(var se=new Map;ue!==null;)ue.key!==null?se.set(ue.key,ue):se.set(ue.index,ue),ue=ue.sibling;return se}function b(ue,se){return ue=fs(ue,se),ue.index=0,ue.sibling=null,ue}function v(ue,se,me){return ue.index=me,n?(me=ue.alternate,me!==null?(me=me.index,me<se?(ue.flags|=67108866,se):me):(ue.flags|=67108866,se)):(ue.flags|=1048576,se)}function D(ue){return n&&ue.alternate===null&&(ue.flags|=67108866),ue}function X(ue,se,me,Ne){return se===null||se.tag!==6?(se=ch(me,ue.mode,Ne),se.return=ue,se):(se=b(se,me),se.return=ue,se)}function te(ue,se,me,Ne){var ct=me.type;return ct===w?ke(ue,se,me.props.children,Ne,me.key):se!==null&&(se.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===q&&Oa(ct)===se.type)?(se=b(se,me.props),Xo(se,me),se.return=ue,se):(se=Au(me.type,me.key,me.props,null,ue.mode,Ne),Xo(se,me),se.return=ue,se)}function pe(ue,se,me,Ne){return se===null||se.tag!==4||se.stateNode.containerInfo!==me.containerInfo||se.stateNode.implementation!==me.implementation?(se=uh(me,ue.mode,Ne),se.return=ue,se):(se=b(se,me.children||[]),se.return=ue,se)}function ke(ue,se,me,Ne,ct){return se===null||se.tag!==7?(se=Fa(me,ue.mode,Ne,ct),se.return=ue,se):(se=b(se,me),se.return=ue,se)}function Me(ue,se,me){if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return se=ch(""+se,ue.mode,me),se.return=ue,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case g:return me=Au(se.type,se.key,se.props,null,ue.mode,me),Xo(me,se),me.return=ue,me;case k:return se=uh(se,ue.mode,me),se.return=ue,se;case q:return se=Oa(se),Me(ue,se,me)}if(H(se)||O(se))return se=Fa(se,ue.mode,me,null),se.return=ue,se;if(typeof se.then=="function")return Me(ue,zu(se),me);if(se.$$typeof===N)return Me(ue,_u(ue,se),me);Bu(ue,se)}return null}function xe(ue,se,me,Ne){var ct=se!==null?se.key:null;if(typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint")return ct!==null?null:X(ue,se,""+me,Ne);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case g:return me.key===ct?te(ue,se,me,Ne):null;case k:return me.key===ct?pe(ue,se,me,Ne):null;case q:return me=Oa(me),xe(ue,se,me,Ne)}if(H(me)||O(me))return ct!==null?null:ke(ue,se,me,Ne,null);if(typeof me.then=="function")return xe(ue,se,zu(me),Ne);if(me.$$typeof===N)return xe(ue,se,_u(ue,me),Ne);Bu(ue,me)}return null}function ye(ue,se,me,Ne,ct){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number"||typeof Ne=="bigint")return ue=ue.get(me)||null,X(se,ue,""+Ne,ct);if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case g:return ue=ue.get(Ne.key===null?me:Ne.key)||null,te(se,ue,Ne,ct);case k:return ue=ue.get(Ne.key===null?me:Ne.key)||null,pe(se,ue,Ne,ct);case q:return Ne=Oa(Ne),ye(ue,se,me,Ne,ct)}if(H(Ne)||O(Ne))return ue=ue.get(me)||null,ke(se,ue,Ne,ct,null);if(typeof Ne.then=="function")return ye(ue,se,me,zu(Ne),ct);if(Ne.$$typeof===N)return ye(ue,se,me,_u(se,Ne),ct);Bu(se,Ne)}return null}function Ge(ue,se,me,Ne){for(var ct=null,Vt=null,Je=se,Tt=se=0,$t=null;Je!==null&&Tt<me.length;Tt++){Je.index>Tt?($t=Je,Je=null):$t=Je.sibling;var Wt=xe(ue,Je,me[Tt],Ne);if(Wt===null){Je===null&&(Je=$t);break}n&&Je&&Wt.alternate===null&&s(ue,Je),se=v(Wt,se,Tt),Vt===null?ct=Wt:Vt.sibling=Wt,Vt=Wt,Je=$t}if(Tt===me.length)return u(ue,Je),Lt&&hs(ue,Tt),ct;if(Je===null){for(;Tt<me.length;Tt++)Je=Me(ue,me[Tt],Ne),Je!==null&&(se=v(Je,se,Tt),Vt===null?ct=Je:Vt.sibling=Je,Vt=Je);return Lt&&hs(ue,Tt),ct}for(Je=h(Je);Tt<me.length;Tt++)$t=ye(Je,ue,Tt,me[Tt],Ne),$t!==null&&(n&&$t.alternate!==null&&Je.delete($t.key===null?Tt:$t.key),se=v($t,se,Tt),Vt===null?ct=$t:Vt.sibling=$t,Vt=$t);return n&&Je.forEach(function(la){return s(ue,la)}),Lt&&hs(ue,Tt),ct}function xt(ue,se,me,Ne){if(me==null)throw Error(i(151));for(var ct=null,Vt=null,Je=se,Tt=se=0,$t=null,Wt=me.next();Je!==null&&!Wt.done;Tt++,Wt=me.next()){Je.index>Tt?($t=Je,Je=null):$t=Je.sibling;var la=xe(ue,Je,Wt.value,Ne);if(la===null){Je===null&&(Je=$t);break}n&&Je&&la.alternate===null&&s(ue,Je),se=v(la,se,Tt),Vt===null?ct=la:Vt.sibling=la,Vt=la,Je=$t}if(Wt.done)return u(ue,Je),Lt&&hs(ue,Tt),ct;if(Je===null){for(;!Wt.done;Tt++,Wt=me.next())Wt=Me(ue,Wt.value,Ne),Wt!==null&&(se=v(Wt,se,Tt),Vt===null?ct=Wt:Vt.sibling=Wt,Vt=Wt);return Lt&&hs(ue,Tt),ct}for(Je=h(Je);!Wt.done;Tt++,Wt=me.next())Wt=ye(Je,ue,Tt,Wt.value,Ne),Wt!==null&&(n&&Wt.alternate!==null&&Je.delete(Wt.key===null?Tt:Wt.key),se=v(Wt,se,Tt),Vt===null?ct=Wt:Vt.sibling=Wt,Vt=Wt);return n&&Je.forEach(function(T4){return s(ue,T4)}),Lt&&hs(ue,Tt),ct}function on(ue,se,me,Ne){if(typeof me=="object"&&me!==null&&me.type===w&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case g:e:{for(var ct=me.key;se!==null;){if(se.key===ct){if(ct=me.type,ct===w){if(se.tag===7){u(ue,se.sibling),Ne=b(se,me.props.children),Ne.return=ue,ue=Ne;break e}}else if(se.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===q&&Oa(ct)===se.type){u(ue,se.sibling),Ne=b(se,me.props),Xo(Ne,me),Ne.return=ue,ue=Ne;break e}u(ue,se);break}else s(ue,se);se=se.sibling}me.type===w?(Ne=Fa(me.props.children,ue.mode,Ne,me.key),Ne.return=ue,ue=Ne):(Ne=Au(me.type,me.key,me.props,null,ue.mode,Ne),Xo(Ne,me),Ne.return=ue,ue=Ne)}return D(ue);case k:e:{for(ct=me.key;se!==null;){if(se.key===ct)if(se.tag===4&&se.stateNode.containerInfo===me.containerInfo&&se.stateNode.implementation===me.implementation){u(ue,se.sibling),Ne=b(se,me.children||[]),Ne.return=ue,ue=Ne;break e}else{u(ue,se);break}else s(ue,se);se=se.sibling}Ne=uh(me,ue.mode,Ne),Ne.return=ue,ue=Ne}return D(ue);case q:return me=Oa(me),on(ue,se,me,Ne)}if(H(me))return Ge(ue,se,me,Ne);if(O(me)){if(ct=O(me),typeof ct!="function")throw Error(i(150));return me=ct.call(me),xt(ue,se,me,Ne)}if(typeof me.then=="function")return on(ue,se,zu(me),Ne);if(me.$$typeof===N)return on(ue,se,_u(ue,me),Ne);Bu(ue,me)}return typeof me=="string"&&me!==""||typeof me=="number"||typeof me=="bigint"?(me=""+me,se!==null&&se.tag===6?(u(ue,se.sibling),Ne=b(se,me),Ne.return=ue,ue=Ne):(u(ue,se),Ne=ch(me,ue.mode,Ne),Ne.return=ue,ue=Ne),D(ue)):u(ue,se)}return function(ue,se,me,Ne){try{Yo=0;var ct=on(ue,se,me,Ne);return Rl=null,ct}catch(Je){if(Je===Fl||Je===Fu)throw Je;var Vt=Xr(29,Je,null,ue.mode);return Vt.lanes=Ne,Vt.return=ue,Vt}finally{}}}var Ia=jg(!0),Eg=jg(!1),Ys=!1;function kh(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sh(n,s){n=n.updateQueue,s.updateQueue===n&&(s.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Xs(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Ps(n,s,u){var h=n.updateQueue;if(h===null)return null;if(h=h.shared,(Qt&2)!==0){var b=h.pending;return b===null?s.next=s:(s.next=b.next,b.next=s),h.pending=s,s=Nu(n),cg(n,null,u),s}return Eu(n,h,s,u),Nu(n)}function Po(n,s,u){if(s=s.updateQueue,s!==null&&(s=s.shared,(u&4194048)!==0)){var h=s.lanes;h&=n.pendingLanes,u|=h,s.lanes=u,mn(n,u)}}function Ch(n,s){var u=n.updateQueue,h=n.alternate;if(h!==null&&(h=h.updateQueue,u===h)){var b=null,v=null;if(u=u.firstBaseUpdate,u!==null){do{var D={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};v===null?b=v=D:v=v.next=D,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},n.updateQueue=u;return}n=u.lastBaseUpdate,n===null?u.firstBaseUpdate=s:n.next=s,u.lastBaseUpdate=s}var jh=!1;function Vo(){if(jh){var n=Ml;if(n!==null)throw n}}function Wo(n,s,u,h){jh=!1;var b=n.updateQueue;Ys=!1;var v=b.firstBaseUpdate,D=b.lastBaseUpdate,X=b.shared.pending;if(X!==null){b.shared.pending=null;var te=X,pe=te.next;te.next=null,D===null?v=pe:D.next=pe,D=te;var ke=n.alternate;ke!==null&&(ke=ke.updateQueue,X=ke.lastBaseUpdate,X!==D&&(X===null?ke.firstBaseUpdate=pe:X.next=pe,ke.lastBaseUpdate=te))}if(v!==null){var Me=b.baseState;D=0,ke=pe=te=null,X=v;do{var xe=X.lane&-536870913,ye=xe!==X.lane;if(ye?(Bt&xe)===xe:(h&xe)===xe){xe!==0&&xe===_l&&(jh=!0),ke!==null&&(ke=ke.next={lane:0,tag:X.tag,payload:X.payload,callback:null,next:null});e:{var Ge=n,xt=X;xe=s;var on=u;switch(xt.tag){case 1:if(Ge=xt.payload,typeof Ge=="function"){Me=Ge.call(on,Me,xe);break e}Me=Ge;break e;case 3:Ge.flags=Ge.flags&-65537|128;case 0:if(Ge=xt.payload,xe=typeof Ge=="function"?Ge.call(on,Me,xe):Ge,xe==null)break e;Me=p({},Me,xe);break e;case 2:Ys=!0}}xe=X.callback,xe!==null&&(n.flags|=64,ye&&(n.flags|=8192),ye=b.callbacks,ye===null?b.callbacks=[xe]:ye.push(xe))}else ye={lane:xe,tag:X.tag,payload:X.payload,callback:X.callback,next:null},ke===null?(pe=ke=ye,te=Me):ke=ke.next=ye,D|=xe;if(X=X.next,X===null){if(X=b.shared.pending,X===null)break;ye=X,X=ye.next,ye.next=null,b.lastBaseUpdate=ye,b.shared.pending=null}}while(!0);ke===null&&(te=Me),b.baseState=te,b.firstBaseUpdate=pe,b.lastBaseUpdate=ke,v===null&&(b.shared.lanes=0),Qs|=D,n.lanes=D,n.memoizedState=Me}}function Ng(n,s){if(typeof n!="function")throw Error(i(191,n));n.call(s)}function Ag(n,s){var u=n.callbacks;if(u!==null)for(n.callbacks=null,n=0;n<u.length;n++)Ng(u[n],s)}var zl=U(null),$u=U(0);function Tg(n,s){n=Cs,$($u,n),$(zl,s),Cs=n|s.baseLanes}function Eh(){$($u,Cs),$(zl,zl.current)}function Nh(){Cs=$u.current,Y(zl),Y($u)}var Pr=U(null),xi=null;function Vs(n){var s=n.alternate;$(Fn,Fn.current&1),$(Pr,n),xi===null&&(s===null||zl.current!==null||s.memoizedState!==null)&&(xi=n)}function Ah(n){$(Fn,Fn.current),$(Pr,n),xi===null&&(xi=n)}function Dg(n){n.tag===22?($(Fn,Fn.current),$(Pr,n),xi===null&&(xi=n)):Ws()}function Ws(){$(Fn,Fn.current),$(Pr,Pr.current)}function Vr(n){Y(Pr),xi===n&&(xi=null),Y(Fn)}var Fn=U(0);function Ou(n){for(var s=n;s!==null;){if(s.tag===13){var u=s.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||Rm(u)||zm(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===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var xs=0,Nt=null,an=null,Bn=null,Lu=!1,Bl=!1,Ha=!1,Iu=0,Go=0,$l=null,bS=0;function _n(){throw Error(i(321))}function Th(n,s){if(s===null)return!1;for(var u=0;u<s.length&&u<n.length;u++)if(!Yr(n[u],s[u]))return!1;return!0}function Dh(n,s,u,h,b,v){return xs=v,Nt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,B.H=n===null||n.memoizedState===null?h1:Xh,Ha=!1,v=u(h,b),Ha=!1,Bl&&(v=Mg(s,u,h,b)),_g(n),v}function _g(n){B.H=Zo;var s=an!==null&&an.next!==null;if(xs=0,Bn=an=Nt=null,Lu=!1,Go=0,$l=null,s)throw Error(i(300));n===null||$n||(n=n.dependencies,n!==null&&Du(n)&&($n=!0))}function Mg(n,s,u,h){Nt=n;var b=0;do{if(Bl&&($l=null),Go=0,Bl=!1,25<=b)throw Error(i(301));if(b+=1,Bn=an=null,n.updateQueue!=null){var v=n.updateQueue;v.lastEffect=null,v.events=null,v.stores=null,v.memoCache!=null&&(v.memoCache.index=0)}B.H=m1,v=s(u,h)}while(Bl);return v}function vS(){var n=B.H,s=n.useState()[0];return s=typeof s.then=="function"?Ko(s):s,n=n.useState()[0],(an!==null?an.memoizedState:null)!==n&&(Nt.flags|=1024),s}function _h(){var n=Iu!==0;return Iu=0,n}function Mh(n,s,u){s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~u}function Fh(n){if(Lu){for(n=n.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}Lu=!1}xs=0,Bn=an=Nt=null,Bl=!1,Go=Iu=0,$l=null}function br(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bn===null?Nt.memoizedState=Bn=n:Bn=Bn.next=n,Bn}function Rn(){if(an===null){var n=Nt.alternate;n=n!==null?n.memoizedState:null}else n=an.next;var s=Bn===null?Nt.memoizedState:Bn.next;if(s!==null)Bn=s,an=n;else{if(n===null)throw Nt.alternate===null?Error(i(467)):Error(i(310));an=n,n={memoizedState:an.memoizedState,baseState:an.baseState,baseQueue:an.baseQueue,queue:an.queue,next:null},Bn===null?Nt.memoizedState=Bn=n:Bn=Bn.next=n}return Bn}function Hu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ko(n){var s=Go;return Go+=1,$l===null&&($l=[]),n=kg($l,n,s),s=Nt,(Bn===null?s.memoizedState:Bn.next)===null&&(s=s.alternate,B.H=s===null||s.memoizedState===null?h1:Xh),n}function Uu(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Ko(n);if(n.$$typeof===N)return ir(n)}throw Error(i(438,String(n)))}function Rh(n){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=Hu(),Nt.updateQueue=u),u.memoCache=s,u=s.data[s.index],u===void 0)for(u=s.data[s.index]=Array(n),h=0;h<n;h++)u[h]=L;return s.index++,u}function gs(n,s){return typeof s=="function"?s(n):s}function qu(n){var s=Rn();return zh(s,an,n)}function zh(n,s,u){var h=n.queue;if(h===null)throw Error(i(311));h.lastRenderedReducer=u;var b=n.baseQueue,v=h.pending;if(v!==null){if(b!==null){var D=b.next;b.next=v.next,v.next=D}s.baseQueue=b=v,h.pending=null}if(v=n.baseState,b===null)n.memoizedState=v;else{s=b.next;var X=D=null,te=null,pe=s,ke=!1;do{var Me=pe.lane&-536870913;if(Me!==pe.lane?(Bt&Me)===Me:(xs&Me)===Me){var xe=pe.revertLane;if(xe===0)te!==null&&(te=te.next={lane:0,revertLane:0,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null}),Me===_l&&(ke=!0);else if((xs&xe)===xe){pe=pe.next,xe===_l&&(ke=!0);continue}else Me={lane:0,revertLane:pe.revertLane,gesture:null,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},te===null?(X=te=Me,D=v):te=te.next=Me,Nt.lanes|=xe,Qs|=xe;Me=pe.action,Ha&&u(v,Me),v=pe.hasEagerState?pe.eagerState:u(v,Me)}else xe={lane:Me,revertLane:pe.revertLane,gesture:pe.gesture,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null},te===null?(X=te=xe,D=v):te=te.next=xe,Nt.lanes|=Me,Qs|=Me;pe=pe.next}while(pe!==null&&pe!==s);if(te===null?D=v:te.next=X,!Yr(v,n.memoizedState)&&($n=!0,ke&&(u=Ml,u!==null)))throw u;n.memoizedState=v,n.baseState=D,n.baseQueue=te,h.lastRenderedState=v}return b===null&&(h.lanes=0),[n.memoizedState,h.dispatch]}function Bh(n){var s=Rn(),u=s.queue;if(u===null)throw Error(i(311));u.lastRenderedReducer=n;var h=u.dispatch,b=u.pending,v=s.memoizedState;if(b!==null){u.pending=null;var D=b=b.next;do v=n(v,D.action),D=D.next;while(D!==b);Yr(v,s.memoizedState)||($n=!0),s.memoizedState=v,s.baseQueue===null&&(s.baseState=v),u.lastRenderedState=v}return[v,h]}function Fg(n,s,u){var h=Nt,b=Rn(),v=Lt;if(v){if(u===void 0)throw Error(i(407));u=u()}else u=s();var D=!Yr((an||b).memoizedState,u);if(D&&(b.memoizedState=u,$n=!0),b=b.queue,Lh(Bg.bind(null,h,b,n),[n]),b.getSnapshot!==s||D||Bn!==null&&Bn.memoizedState.tag&1){if(h.flags|=2048,Ol(9,{destroy:void 0},zg.bind(null,h,b,u,s),null),dn===null)throw Error(i(349));v||(xs&127)!==0||Rg(h,s,u)}return u}function Rg(n,s,u){n.flags|=16384,n={getSnapshot:s,value:u},s=Nt.updateQueue,s===null?(s=Hu(),Nt.updateQueue=s,s.stores=[n]):(u=s.stores,u===null?s.stores=[n]:u.push(n))}function zg(n,s,u,h){s.value=u,s.getSnapshot=h,$g(s)&&Og(n)}function Bg(n,s,u){return u(function(){$g(s)&&Og(n)})}function $g(n){var s=n.getSnapshot;n=n.value;try{var u=s();return!Yr(n,u)}catch{return!0}}function Og(n){var s=Ma(n,2);s!==null&&Mr(s,n,2)}function $h(n){var s=br();if(typeof n=="function"){var u=n;if(n=u(),Ha){lt(!0);try{u()}finally{lt(!1)}}}return s.memoizedState=s.baseState=n,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gs,lastRenderedState:n},s}function Lg(n,s,u,h){return n.baseState=u,zh(n,an,typeof h=="function"?h:gs)}function wS(n,s,u,h,b){if(Pu(n))throw Error(i(485));if(n=s.action,n!==null){var v={payload:b,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(D){v.listeners.push(D)}};B.T!==null?u(!0):v.isTransition=!1,h(v),u=s.pending,u===null?(v.next=s.pending=v,Ig(s,v)):(v.next=u.next,s.pending=u.next=v)}}function Ig(n,s){var u=s.action,h=s.payload,b=n.state;if(s.isTransition){var v=B.T,D={};B.T=D;try{var X=u(b,h),te=B.S;te!==null&&te(D,X),Hg(n,s,X)}catch(pe){Oh(n,s,pe)}finally{v!==null&&D.types!==null&&(v.types=D.types),B.T=v}}else try{v=u(b,h),Hg(n,s,v)}catch(pe){Oh(n,s,pe)}}function Hg(n,s,u){u!==null&&typeof u=="object"&&typeof u.then=="function"?u.then(function(h){Ug(n,s,h)},function(h){return Oh(n,s,h)}):Ug(n,s,u)}function Ug(n,s,u){s.status="fulfilled",s.value=u,qg(s),n.state=u,s=n.pending,s!==null&&(u=s.next,u===s?n.pending=null:(u=u.next,s.next=u,Ig(n,u)))}function Oh(n,s,u){var h=n.pending;if(n.pending=null,h!==null){h=h.next;do s.status="rejected",s.reason=u,qg(s),s=s.next;while(s!==h)}n.action=null}function qg(n){n=n.listeners;for(var s=0;s<n.length;s++)(0,n[s])()}function Yg(n,s){return s}function Xg(n,s){if(Lt){var u=dn.formState;if(u!==null){e:{var h=Nt;if(Lt){if(yn){t:{for(var b=yn,v=pi;b.nodeType!==8;){if(!v){b=null;break t}if(b=gi(b.nextSibling),b===null){b=null;break t}}v=b.data,b=v==="F!"||v==="F"?b:null}if(b){yn=gi(b.nextSibling),h=b.data==="F!";break e}}Us(h)}h=!1}h&&(s=u[0])}}return u=br(),u.memoizedState=u.baseState=s,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yg,lastRenderedState:s},u.queue=h,u=u1.bind(null,Nt,h),h.dispatch=u,h=$h(!1),v=Yh.bind(null,Nt,!1,h.queue),h=br(),b={state:s,dispatch:null,action:n,pending:null},h.queue=b,u=wS.bind(null,Nt,b,v,u),b.dispatch=u,h.memoizedState=n,[s,u,!1]}function Pg(n){var s=Rn();return Vg(s,an,n)}function Vg(n,s,u){if(s=zh(n,s,Yg)[0],n=qu(gs)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var h=Ko(s)}catch(D){throw D===Fl?Fu:D}else h=s;s=Rn();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,n]}function kS(n,s){n.action=s}function Wg(n){var s=Rn(),u=an;if(u!==null)return Vg(s,u,n);Rn(),s=s.memoizedState,u=Rn();var h=u.queue.dispatch;return u.memoizedState=n,[s,h,!1]}function Ol(n,s,u,h){return n={tag:n,create:u,deps:h,inst:s,next:null},s=Nt.updateQueue,s===null&&(s=Hu(),Nt.updateQueue=s),u=s.lastEffect,u===null?s.lastEffect=n.next=n:(h=u.next,u.next=n,n.next=h,s.lastEffect=n),n}function Gg(){return Rn().memoizedState}function Yu(n,s,u,h){var b=br();Nt.flags|=n,b.memoizedState=Ol(1|s,{destroy:void 0},u,h===void 0?null:h)}function Xu(n,s,u,h){var b=Rn();h=h===void 0?null:h;var v=b.memoizedState.inst;an!==null&&h!==null&&Th(h,an.memoizedState.deps)?b.memoizedState=Ol(s,v,u,h):(Nt.flags|=n,b.memoizedState=Ol(1|s,v,u,h))}function Kg(n,s){Yu(8390656,8,n,s)}function Lh(n,s){Xu(2048,8,n,s)}function SS(n){Nt.flags|=4;var s=Nt.updateQueue;if(s===null)s=Hu(),Nt.updateQueue=s,s.events=[n];else{var u=s.events;u===null?s.events=[n]:u.push(n)}}function Qg(n){var s=Rn().memoizedState;return SS({ref:s,nextImpl:n}),function(){if((Qt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}function Zg(n,s){return Xu(4,2,n,s)}function Jg(n,s){return Xu(4,4,n,s)}function e1(n,s){if(typeof s=="function"){n=n();var u=s(n);return function(){typeof u=="function"?u():s(null)}}if(s!=null)return n=n(),s.current=n,function(){s.current=null}}function t1(n,s,u){u=u!=null?u.concat([n]):null,Xu(4,4,e1.bind(null,s,n),u)}function Ih(){}function n1(n,s){var u=Rn();s=s===void 0?null:s;var h=u.memoizedState;return s!==null&&Th(s,h[1])?h[0]:(u.memoizedState=[n,s],n)}function r1(n,s){var u=Rn();s=s===void 0?null:s;var h=u.memoizedState;if(s!==null&&Th(s,h[1]))return h[0];if(h=n(),Ha){lt(!0);try{n()}finally{lt(!1)}}return u.memoizedState=[h,s],h}function Hh(n,s,u){return u===void 0||(xs&1073741824)!==0&&(Bt&261930)===0?n.memoizedState=s:(n.memoizedState=u,n=iy(),Nt.lanes|=n,Qs|=n,u)}function i1(n,s,u,h){return Yr(u,s)?u:zl.current!==null?(n=Hh(n,u,h),Yr(n,s)||($n=!0),n):(xs&42)===0||(xs&1073741824)!==0&&(Bt&261930)===0?($n=!0,n.memoizedState=u):(n=iy(),Nt.lanes|=n,Qs|=n,s)}function s1(n,s,u,h,b){var v=Z.p;Z.p=v!==0&&8>v?v:8;var D=B.T,X={};B.T=X,Yh(n,!1,s,u);try{var te=b(),pe=B.S;if(pe!==null&&pe(X,te),te!==null&&typeof te=="object"&&typeof te.then=="function"){var ke=yS(te,h);Qo(n,s,ke,Kr(n))}else Qo(n,s,h,Kr(n))}catch(Me){Qo(n,s,{then:function(){},status:"rejected",reason:Me},Kr())}finally{Z.p=v,D!==null&&X.types!==null&&(D.types=X.types),B.T=D}}function CS(){}function Uh(n,s,u,h){if(n.tag!==5)throw Error(i(476));var b=a1(n).queue;s1(n,b,s,G,u===null?CS:function(){return l1(n),u(h)})}function a1(n){var s=n.memoizedState;if(s!==null)return s;s={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gs,lastRenderedState:G},next:null};var u={};return s.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gs,lastRenderedState:u},next:null},n.memoizedState=s,n=n.alternate,n!==null&&(n.memoizedState=s),s}function l1(n){var s=a1(n);s.next===null&&(s=n.alternate.memoizedState),Qo(n,s.next.queue,{},Kr())}function qh(){return ir(mc)}function o1(){return Rn().memoizedState}function c1(){return Rn().memoizedState}function jS(n){for(var s=n.return;s!==null;){switch(s.tag){case 24:case 3:var u=Kr();n=Xs(u);var h=Ps(s,n,u);h!==null&&(Mr(h,s,u),Po(h,s,u)),s={cache:yh()},n.payload=s;return}s=s.return}}function ES(n,s,u){var h=Kr();u={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Pu(n)?d1(s,u):(u=lh(n,s,u,h),u!==null&&(Mr(u,n,h),f1(u,s,h)))}function u1(n,s,u){var h=Kr();Qo(n,s,u,h)}function Qo(n,s,u,h){var b={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Pu(n))d1(s,b);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=s.lastRenderedReducer,v!==null))try{var D=s.lastRenderedState,X=v(D,u);if(b.hasEagerState=!0,b.eagerState=X,Yr(X,D))return Eu(n,s,b,0),dn===null&&ju(),!1}catch{}finally{}if(u=lh(n,s,b,h),u!==null)return Mr(u,n,h),f1(u,s,h),!0}return!1}function Yh(n,s,u,h){if(h={lane:2,revertLane:km(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Pu(n)){if(s)throw Error(i(479))}else s=lh(n,u,h,2),s!==null&&Mr(s,n,2)}function Pu(n){var s=n.alternate;return n===Nt||s!==null&&s===Nt}function d1(n,s){Bl=Lu=!0;var u=n.pending;u===null?s.next=s:(s.next=u.next,u.next=s),n.pending=s}function f1(n,s,u){if((u&4194048)!==0){var h=s.lanes;h&=n.pendingLanes,u|=h,s.lanes=u,mn(n,u)}}var Zo={readContext:ir,use:Uu,useCallback:_n,useContext:_n,useEffect:_n,useImperativeHandle:_n,useLayoutEffect:_n,useInsertionEffect:_n,useMemo:_n,useReducer:_n,useRef:_n,useState:_n,useDebugValue:_n,useDeferredValue:_n,useTransition:_n,useSyncExternalStore:_n,useId:_n,useHostTransitionStatus:_n,useFormState:_n,useActionState:_n,useOptimistic:_n,useMemoCache:_n,useCacheRefresh:_n};Zo.useEffectEvent=_n;var h1={readContext:ir,use:Uu,useCallback:function(n,s){return br().memoizedState=[n,s===void 0?null:s],n},useContext:ir,useEffect:Kg,useImperativeHandle:function(n,s,u){u=u!=null?u.concat([n]):null,Yu(4194308,4,e1.bind(null,s,n),u)},useLayoutEffect:function(n,s){return Yu(4194308,4,n,s)},useInsertionEffect:function(n,s){Yu(4,2,n,s)},useMemo:function(n,s){var u=br();s=s===void 0?null:s;var h=n();if(Ha){lt(!0);try{n()}finally{lt(!1)}}return u.memoizedState=[h,s],h},useReducer:function(n,s,u){var h=br();if(u!==void 0){var b=u(s);if(Ha){lt(!0);try{u(s)}finally{lt(!1)}}}else b=s;return h.memoizedState=h.baseState=b,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:b},h.queue=n,n=n.dispatch=ES.bind(null,Nt,n),[h.memoizedState,n]},useRef:function(n){var s=br();return n={current:n},s.memoizedState=n},useState:function(n){n=$h(n);var s=n.queue,u=u1.bind(null,Nt,s);return s.dispatch=u,[n.memoizedState,u]},useDebugValue:Ih,useDeferredValue:function(n,s){var u=br();return Hh(u,n,s)},useTransition:function(){var n=$h(!1);return n=s1.bind(null,Nt,n.queue,!0,!1),br().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,s,u){var h=Nt,b=br();if(Lt){if(u===void 0)throw Error(i(407));u=u()}else{if(u=s(),dn===null)throw Error(i(349));(Bt&127)!==0||Rg(h,s,u)}b.memoizedState=u;var v={value:u,getSnapshot:s};return b.queue=v,Kg(Bg.bind(null,h,v,n),[n]),h.flags|=2048,Ol(9,{destroy:void 0},zg.bind(null,h,v,u,s),null),u},useId:function(){var n=br(),s=dn.identifierPrefix;if(Lt){var u=Xi,h=Yi;u=(h&~(1<<32-tt(h)-1)).toString(32)+u,s="_"+s+"R_"+u,u=Iu++,0<u&&(s+="H"+u.toString(32)),s+="_"}else u=bS++,s="_"+s+"r_"+u.toString(32)+"_";return n.memoizedState=s},useHostTransitionStatus:qh,useFormState:Xg,useActionState:Xg,useOptimistic:function(n){var s=br();s.memoizedState=s.baseState=n;var u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=u,s=Yh.bind(null,Nt,!0,u),u.dispatch=s,[n,s]},useMemoCache:Rh,useCacheRefresh:function(){return br().memoizedState=jS.bind(null,Nt)},useEffectEvent:function(n){var s=br(),u={impl:n};return s.memoizedState=u,function(){if((Qt&2)!==0)throw Error(i(440));return u.impl.apply(void 0,arguments)}}},Xh={readContext:ir,use:Uu,useCallback:n1,useContext:ir,useEffect:Lh,useImperativeHandle:t1,useInsertionEffect:Zg,useLayoutEffect:Jg,useMemo:r1,useReducer:qu,useRef:Gg,useState:function(){return qu(gs)},useDebugValue:Ih,useDeferredValue:function(n,s){var u=Rn();return i1(u,an.memoizedState,n,s)},useTransition:function(){var n=qu(gs)[0],s=Rn().memoizedState;return[typeof n=="boolean"?n:Ko(n),s]},useSyncExternalStore:Fg,useId:o1,useHostTransitionStatus:qh,useFormState:Pg,useActionState:Pg,useOptimistic:function(n,s){var u=Rn();return Lg(u,an,n,s)},useMemoCache:Rh,useCacheRefresh:c1};Xh.useEffectEvent=Qg;var m1={readContext:ir,use:Uu,useCallback:n1,useContext:ir,useEffect:Lh,useImperativeHandle:t1,useInsertionEffect:Zg,useLayoutEffect:Jg,useMemo:r1,useReducer:Bh,useRef:Gg,useState:function(){return Bh(gs)},useDebugValue:Ih,useDeferredValue:function(n,s){var u=Rn();return an===null?Hh(u,n,s):i1(u,an.memoizedState,n,s)},useTransition:function(){var n=Bh(gs)[0],s=Rn().memoizedState;return[typeof n=="boolean"?n:Ko(n),s]},useSyncExternalStore:Fg,useId:o1,useHostTransitionStatus:qh,useFormState:Wg,useActionState:Wg,useOptimistic:function(n,s){var u=Rn();return an!==null?Lg(u,an,n,s):(u.baseState=n,[n,u.queue.dispatch])},useMemoCache:Rh,useCacheRefresh:c1};m1.useEffectEvent=Qg;function Ph(n,s,u,h){s=n.memoizedState,u=u(h,s),u=u==null?s:p({},s,u),n.memoizedState=u,n.lanes===0&&(n.updateQueue.baseState=u)}var Vh={enqueueSetState:function(n,s,u){n=n._reactInternals;var h=Kr(),b=Xs(h);b.payload=s,u!=null&&(b.callback=u),s=Ps(n,b,h),s!==null&&(Mr(s,n,h),Po(s,n,h))},enqueueReplaceState:function(n,s,u){n=n._reactInternals;var h=Kr(),b=Xs(h);b.tag=1,b.payload=s,u!=null&&(b.callback=u),s=Ps(n,b,h),s!==null&&(Mr(s,n,h),Po(s,n,h))},enqueueForceUpdate:function(n,s){n=n._reactInternals;var u=Kr(),h=Xs(u);h.tag=2,s!=null&&(h.callback=s),s=Ps(n,h,u),s!==null&&(Mr(s,n,u),Po(s,n,u))}};function p1(n,s,u,h,b,v,D){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(h,v,D):s.prototype&&s.prototype.isPureReactComponent?!Oo(u,h)||!Oo(b,v):!0}function x1(n,s,u,h){n=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(u,h),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(u,h),s.state!==n&&Vh.enqueueReplaceState(s,s.state,null)}function Ua(n,s){var u=s;if("ref"in s){u={};for(var h in s)h!=="ref"&&(u[h]=s[h])}if(n=n.defaultProps){u===s&&(u=p({},u));for(var b in n)u[b]===void 0&&(u[b]=n[b])}return u}function g1(n){Cu(n)}function y1(n){console.error(n)}function b1(n){Cu(n)}function Vu(n,s){try{var u=n.onUncaughtError;u(s.value,{componentStack:s.stack})}catch(h){setTimeout(function(){throw h})}}function v1(n,s,u){try{var h=n.onCaughtError;h(u.value,{componentStack:u.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function Wh(n,s,u){return u=Xs(u),u.tag=3,u.payload={element:null},u.callback=function(){Vu(n,s)},u}function w1(n){return n=Xs(n),n.tag=3,n}function k1(n,s,u,h){var b=u.type.getDerivedStateFromError;if(typeof b=="function"){var v=h.value;n.payload=function(){return b(v)},n.callback=function(){v1(s,u,h)}}var D=u.stateNode;D!==null&&typeof D.componentDidCatch=="function"&&(n.callback=function(){v1(s,u,h),typeof b!="function"&&(Zs===null?Zs=new Set([this]):Zs.add(this));var X=h.stack;this.componentDidCatch(h.value,{componentStack:X!==null?X:""})})}function NS(n,s,u,h,b){if(u.flags|=32768,h!==null&&typeof h=="object"&&typeof h.then=="function"){if(s=u.alternate,s!==null&&Dl(s,u,b,!0),u=Pr.current,u!==null){switch(u.tag){case 31:case 13:return xi===null?sd():u.alternate===null&&Mn===0&&(Mn=3),u.flags&=-257,u.flags|=65536,u.lanes=b,h===Ru?u.flags|=16384:(s=u.updateQueue,s===null?u.updateQueue=new Set([h]):s.add(h),bm(n,h,b)),!1;case 22:return u.flags|=65536,h===Ru?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)),bm(n,h,b)),!1}throw Error(i(435,u.tag))}return bm(n,h,b),sd(),!1}if(Lt)return s=Pr.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=b,h!==hh&&(n=Error(i(422),{cause:h}),Ho(fi(n,u)))):(h!==hh&&(s=Error(i(423),{cause:h}),Ho(fi(s,u))),n=n.current.alternate,n.flags|=65536,b&=-b,n.lanes|=b,h=fi(h,u),b=Wh(n.stateNode,h,b),Ch(n,b),Mn!==4&&(Mn=2)),!1;var v=Error(i(520),{cause:h});if(v=fi(v,u),ac===null?ac=[v]:ac.push(v),Mn!==4&&(Mn=2),s===null)return!0;h=fi(h,u),u=s;do{switch(u.tag){case 3:return u.flags|=65536,n=b&-b,u.lanes|=n,n=Wh(u.stateNode,h,n),Ch(u,n),!1;case 1:if(s=u.type,v=u.stateNode,(u.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(Zs===null||!Zs.has(v))))return u.flags|=65536,b&=-b,u.lanes|=b,b=w1(b),k1(b,n,u,h),Ch(u,b),!1}u=u.return}while(u!==null);return!1}var Gh=Error(i(461)),$n=!1;function sr(n,s,u,h){s.child=n===null?Eg(s,null,u,h):Ia(s,n.child,u,h)}function S1(n,s,u,h,b){u=u.render;var v=s.ref;if("ref"in h){var D={};for(var X in h)X!=="ref"&&(D[X]=h[X])}else D=h;return Ba(s),h=Dh(n,s,u,D,v,b),X=_h(),n!==null&&!$n?(Mh(n,s,b),ys(n,s,b)):(Lt&&X&&dh(s),s.flags|=1,sr(n,s,h,b),s.child)}function C1(n,s,u,h,b){if(n===null){var v=u.type;return typeof v=="function"&&!oh(v)&&v.defaultProps===void 0&&u.compare===null?(s.tag=15,s.type=v,j1(n,s,v,h,b)):(n=Au(u.type,null,h,s,s.mode,b),n.ref=s.ref,n.return=s,s.child=n)}if(v=n.child,!rm(n,b)){var D=v.memoizedProps;if(u=u.compare,u=u!==null?u:Oo,u(D,h)&&n.ref===s.ref)return ys(n,s,b)}return s.flags|=1,n=fs(v,h),n.ref=s.ref,n.return=s,s.child=n}function j1(n,s,u,h,b){if(n!==null){var v=n.memoizedProps;if(Oo(v,h)&&n.ref===s.ref)if($n=!1,s.pendingProps=h=v,rm(n,b))(n.flags&131072)!==0&&($n=!0);else return s.lanes=n.lanes,ys(n,s,b)}return Kh(n,s,u,h,b)}function E1(n,s,u,h){var b=h.children,v=n!==null?n.memoizedState:null;if(n===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,n!==null){for(h=s.child=n.child,b=0;h!==null;)b=b|h.lanes|h.childLanes,h=h.sibling;h=b&~v}else h=0,s.child=null;return N1(n,s,v,u,h)}if((u&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},n!==null&&Mu(s,v!==null?v.cachePool:null),v!==null?Tg(s,v):Eh(),Dg(s);else return h=s.lanes=536870912,N1(n,s,v!==null?v.baseLanes|u:u,u,h)}else v!==null?(Mu(s,v.cachePool),Tg(s,v),Ws(),s.memoizedState=null):(n!==null&&Mu(s,null),Eh(),Ws());return sr(n,s,b,u),s.child}function Jo(n,s){return n!==null&&n.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function N1(n,s,u,h,b){var v=vh();return v=v===null?null:{parent:zn._currentValue,pool:v},s.memoizedState={baseLanes:u,cachePool:v},n!==null&&Mu(s,null),Eh(),Dg(s),n!==null&&Dl(n,s,h,!0),s.childLanes=b,null}function Wu(n,s){return s=Ku({mode:s.mode,children:s.children},n.mode),s.ref=n.ref,n.child=s,s.return=n,s}function A1(n,s,u){return Ia(s,n.child,null,u),n=Wu(s,s.pendingProps),n.flags|=2,Vr(s),s.memoizedState=null,n}function AS(n,s,u){var h=s.pendingProps,b=(s.flags&128)!==0;if(s.flags&=-129,n===null){if(Lt){if(h.mode==="hidden")return n=Wu(s,h),s.lanes=536870912,Jo(null,n);if(Ah(s),(n=yn)?(n=Iy(n,pi),n=n!==null&&n.data==="&"?n:null,n!==null&&(s.memoizedState={dehydrated:n,treeContext:Is!==null?{id:Yi,overflow:Xi}:null,retryLane:536870912,hydrationErrors:null},u=dg(n),u.return=s,s.child=u,rr=s,yn=null)):n=null,n===null)throw Us(s);return s.lanes=536870912,null}return Wu(s,h)}var v=n.memoizedState;if(v!==null){var D=v.dehydrated;if(Ah(s),b)if(s.flags&256)s.flags&=-257,s=A1(n,s,u);else if(s.memoizedState!==null)s.child=n.child,s.flags|=128,s=null;else throw Error(i(558));else if($n||Dl(n,s,u,!1),b=(u&n.childLanes)!==0,$n||b){if(h=dn,h!==null&&(D=Zn(h,u),D!==0&&D!==v.retryLane))throw v.retryLane=D,Ma(n,D),Mr(h,n,D),Gh;sd(),s=A1(n,s,u)}else n=v.treeContext,yn=gi(D.nextSibling),rr=s,Lt=!0,Hs=null,pi=!1,n!==null&&mg(s,n),s=Wu(s,h),s.flags|=4096;return s}return n=fs(n.child,{mode:h.mode,children:h.children}),n.ref=s.ref,s.child=n,n.return=s,n}function Gu(n,s){var u=s.ref;if(u===null)n!==null&&n.ref!==null&&(s.flags|=4194816);else{if(typeof u!="function"&&typeof u!="object")throw Error(i(284));(n===null||n.ref!==u)&&(s.flags|=4194816)}}function Kh(n,s,u,h,b){return Ba(s),u=Dh(n,s,u,h,void 0,b),h=_h(),n!==null&&!$n?(Mh(n,s,b),ys(n,s,b)):(Lt&&h&&dh(s),s.flags|=1,sr(n,s,u,b),s.child)}function T1(n,s,u,h,b,v){return Ba(s),s.updateQueue=null,u=Mg(s,h,u,b),_g(n),h=_h(),n!==null&&!$n?(Mh(n,s,v),ys(n,s,v)):(Lt&&h&&dh(s),s.flags|=1,sr(n,s,u,v),s.child)}function D1(n,s,u,h,b){if(Ba(s),s.stateNode===null){var v=El,D=u.contextType;typeof D=="object"&&D!==null&&(v=ir(D)),v=new u(h,v),s.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=Vh,s.stateNode=v,v._reactInternals=s,v=s.stateNode,v.props=h,v.state=s.memoizedState,v.refs={},kh(s),D=u.contextType,v.context=typeof D=="object"&&D!==null?ir(D):El,v.state=s.memoizedState,D=u.getDerivedStateFromProps,typeof D=="function"&&(Ph(s,u,D,h),v.state=s.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(D=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),D!==v.state&&Vh.enqueueReplaceState(v,v.state,null),Wo(s,h,v,b),Vo(),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308),h=!0}else if(n===null){v=s.stateNode;var X=s.memoizedProps,te=Ua(u,X);v.props=te;var pe=v.context,ke=u.contextType;D=El,typeof ke=="object"&&ke!==null&&(D=ir(ke));var Me=u.getDerivedStateFromProps;ke=typeof Me=="function"||typeof v.getSnapshotBeforeUpdate=="function",X=s.pendingProps!==X,ke||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(X||pe!==D)&&x1(s,v,h,D),Ys=!1;var xe=s.memoizedState;v.state=xe,Wo(s,h,v,b),Vo(),pe=s.memoizedState,X||xe!==pe||Ys?(typeof Me=="function"&&(Ph(s,u,Me,h),pe=s.memoizedState),(te=Ys||p1(s,u,te,h,xe,pe,D))?(ke||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=pe),v.props=h,v.state=pe,v.context=D,h=te):(typeof v.componentDidMount=="function"&&(s.flags|=4194308),h=!1)}else{v=s.stateNode,Sh(n,s),D=s.memoizedProps,ke=Ua(u,D),v.props=ke,Me=s.pendingProps,xe=v.context,pe=u.contextType,te=El,typeof pe=="object"&&pe!==null&&(te=ir(pe)),X=u.getDerivedStateFromProps,(pe=typeof X=="function"||typeof v.getSnapshotBeforeUpdate=="function")||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(D!==Me||xe!==te)&&x1(s,v,h,te),Ys=!1,xe=s.memoizedState,v.state=xe,Wo(s,h,v,b),Vo();var ye=s.memoizedState;D!==Me||xe!==ye||Ys||n!==null&&n.dependencies!==null&&Du(n.dependencies)?(typeof X=="function"&&(Ph(s,u,X,h),ye=s.memoizedState),(ke=Ys||p1(s,u,ke,h,xe,ye,te)||n!==null&&n.dependencies!==null&&Du(n.dependencies))?(pe||typeof v.UNSAFE_componentWillUpdate!="function"&&typeof v.componentWillUpdate!="function"||(typeof v.componentWillUpdate=="function"&&v.componentWillUpdate(h,ye,te),typeof v.UNSAFE_componentWillUpdate=="function"&&v.UNSAFE_componentWillUpdate(h,ye,te)),typeof v.componentDidUpdate=="function"&&(s.flags|=4),typeof v.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof v.componentDidUpdate!="function"||D===n.memoizedProps&&xe===n.memoizedState||(s.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||D===n.memoizedProps&&xe===n.memoizedState||(s.flags|=1024),s.memoizedProps=h,s.memoizedState=ye),v.props=h,v.state=ye,v.context=te,h=ke):(typeof v.componentDidUpdate!="function"||D===n.memoizedProps&&xe===n.memoizedState||(s.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||D===n.memoizedProps&&xe===n.memoizedState||(s.flags|=1024),h=!1)}return v=h,Gu(n,s),h=(s.flags&128)!==0,v||h?(v=s.stateNode,u=h&&typeof u.getDerivedStateFromError!="function"?null:v.render(),s.flags|=1,n!==null&&h?(s.child=Ia(s,n.child,null,b),s.child=Ia(s,null,u,b)):sr(n,s,u,b),s.memoizedState=v.state,n=s.child):n=ys(n,s,b),n}function _1(n,s,u,h){return Ra(),s.flags|=256,sr(n,s,u,h),s.child}var Qh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zh(n){return{baseLanes:n,cachePool:vg()}}function Jh(n,s,u){return n=n!==null?n.childLanes&~u:0,s&&(n|=Gr),n}function M1(n,s,u){var h=s.pendingProps,b=!1,v=(s.flags&128)!==0,D;if((D=v)||(D=n!==null&&n.memoizedState===null?!1:(Fn.current&2)!==0),D&&(b=!0,s.flags&=-129),D=(s.flags&32)!==0,s.flags&=-33,n===null){if(Lt){if(b?Vs(s):Ws(),(n=yn)?(n=Iy(n,pi),n=n!==null&&n.data!=="&"?n:null,n!==null&&(s.memoizedState={dehydrated:n,treeContext:Is!==null?{id:Yi,overflow:Xi}:null,retryLane:536870912,hydrationErrors:null},u=dg(n),u.return=s,s.child=u,rr=s,yn=null)):n=null,n===null)throw Us(s);return zm(n)?s.lanes=32:s.lanes=536870912,null}var X=h.children;return h=h.fallback,b?(Ws(),b=s.mode,X=Ku({mode:"hidden",children:X},b),h=Fa(h,b,u,null),X.return=s,h.return=s,X.sibling=h,s.child=X,h=s.child,h.memoizedState=Zh(u),h.childLanes=Jh(n,D,u),s.memoizedState=Qh,Jo(null,h)):(Vs(s),em(s,X))}var te=n.memoizedState;if(te!==null&&(X=te.dehydrated,X!==null)){if(v)s.flags&256?(Vs(s),s.flags&=-257,s=tm(n,s,u)):s.memoizedState!==null?(Ws(),s.child=n.child,s.flags|=128,s=null):(Ws(),X=h.fallback,b=s.mode,h=Ku({mode:"visible",children:h.children},b),X=Fa(X,b,u,null),X.flags|=2,h.return=s,X.return=s,h.sibling=X,s.child=h,Ia(s,n.child,null,u),h=s.child,h.memoizedState=Zh(u),h.childLanes=Jh(n,D,u),s.memoizedState=Qh,s=Jo(null,h));else if(Vs(s),zm(X)){if(D=X.nextSibling&&X.nextSibling.dataset,D)var pe=D.dgst;D=pe,h=Error(i(419)),h.stack="",h.digest=D,Ho({value:h,source:null,stack:null}),s=tm(n,s,u)}else if($n||Dl(n,s,u,!1),D=(u&n.childLanes)!==0,$n||D){if(D=dn,D!==null&&(h=Zn(D,u),h!==0&&h!==te.retryLane))throw te.retryLane=h,Ma(n,h),Mr(D,n,h),Gh;Rm(X)||sd(),s=tm(n,s,u)}else Rm(X)?(s.flags|=192,s.child=n.child,s=null):(n=te.treeContext,yn=gi(X.nextSibling),rr=s,Lt=!0,Hs=null,pi=!1,n!==null&&mg(s,n),s=em(s,h.children),s.flags|=4096);return s}return b?(Ws(),X=h.fallback,b=s.mode,te=n.child,pe=te.sibling,h=fs(te,{mode:"hidden",children:h.children}),h.subtreeFlags=te.subtreeFlags&65011712,pe!==null?X=fs(pe,X):(X=Fa(X,b,u,null),X.flags|=2),X.return=s,h.return=s,h.sibling=X,s.child=h,Jo(null,h),h=s.child,X=n.child.memoizedState,X===null?X=Zh(u):(b=X.cachePool,b!==null?(te=zn._currentValue,b=b.parent!==te?{parent:te,pool:te}:b):b=vg(),X={baseLanes:X.baseLanes|u,cachePool:b}),h.memoizedState=X,h.childLanes=Jh(n,D,u),s.memoizedState=Qh,Jo(n.child,h)):(Vs(s),u=n.child,n=u.sibling,u=fs(u,{mode:"visible",children:h.children}),u.return=s,u.sibling=null,n!==null&&(D=s.deletions,D===null?(s.deletions=[n],s.flags|=16):D.push(n)),s.child=u,s.memoizedState=null,u)}function em(n,s){return s=Ku({mode:"visible",children:s},n.mode),s.return=n,n.child=s}function Ku(n,s){return n=Xr(22,n,null,s),n.lanes=0,n}function tm(n,s,u){return Ia(s,n.child,null,u),n=em(s,s.pendingProps.children),n.flags|=2,s.memoizedState=null,n}function F1(n,s,u){n.lanes|=s;var h=n.alternate;h!==null&&(h.lanes|=s),xh(n.return,s,u)}function nm(n,s,u,h,b,v){var D=n.memoizedState;D===null?n.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:h,tail:u,tailMode:b,treeForkCount:v}:(D.isBackwards=s,D.rendering=null,D.renderingStartTime=0,D.last=h,D.tail=u,D.tailMode=b,D.treeForkCount=v)}function R1(n,s,u){var h=s.pendingProps,b=h.revealOrder,v=h.tail;h=h.children;var D=Fn.current,X=(D&2)!==0;if(X?(D=D&1|2,s.flags|=128):D&=1,$(Fn,D),sr(n,s,h,u),h=Lt?Io:0,!X&&n!==null&&(n.flags&128)!==0)e:for(n=s.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&F1(n,u,s);else if(n.tag===19)F1(n,u,s);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===s)break e;for(;n.sibling===null;){if(n.return===null||n.return===s)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(b){case"forwards":for(u=s.child,b=null;u!==null;)n=u.alternate,n!==null&&Ou(n)===null&&(b=u),u=u.sibling;u=b,u===null?(b=s.child,s.child=null):(b=u.sibling,u.sibling=null),nm(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(n=b.alternate,n!==null&&Ou(n)===null){s.child=b;break}n=b.sibling,b.sibling=u,u=b,b=n}nm(s,!0,u,null,v,h);break;case"together":nm(s,!1,null,null,void 0,h);break;default:s.memoizedState=null}return s.child}function ys(n,s,u){if(n!==null&&(s.dependencies=n.dependencies),Qs|=s.lanes,(u&s.childLanes)===0)if(n!==null){if(Dl(n,s,u,!1),(u&s.childLanes)===0)return null}else return null;if(n!==null&&s.child!==n.child)throw Error(i(153));if(s.child!==null){for(n=s.child,u=fs(n,n.pendingProps),s.child=u,u.return=s;n.sibling!==null;)n=n.sibling,u=u.sibling=fs(n,n.pendingProps),u.return=s;u.sibling=null}return s.child}function rm(n,s){return(n.lanes&s)!==0?!0:(n=n.dependencies,!!(n!==null&&Du(n)))}function TS(n,s,u){switch(s.tag){case 3:oe(s,s.stateNode.containerInfo),qs(s,zn,n.memoizedState.cache),Ra();break;case 27:case 5:Ee(s);break;case 4:oe(s,s.stateNode.containerInfo);break;case 10:qs(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Ah(s),null;break;case 13:var h=s.memoizedState;if(h!==null)return h.dehydrated!==null?(Vs(s),s.flags|=128,null):(u&s.child.childLanes)!==0?M1(n,s,u):(Vs(s),n=ys(n,s,u),n!==null?n.sibling:null);Vs(s);break;case 19:var b=(n.flags&128)!==0;if(h=(u&s.childLanes)!==0,h||(Dl(n,s,u,!1),h=(u&s.childLanes)!==0),b){if(h)return R1(n,s,u);s.flags|=128}if(b=s.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),$(Fn,Fn.current),h)break;return null;case 22:return s.lanes=0,E1(n,s,u,s.pendingProps);case 24:qs(s,zn,n.memoizedState.cache)}return ys(n,s,u)}function z1(n,s,u){if(n!==null)if(n.memoizedProps!==s.pendingProps)$n=!0;else{if(!rm(n,u)&&(s.flags&128)===0)return $n=!1,TS(n,s,u);$n=(n.flags&131072)!==0}else $n=!1,Lt&&(s.flags&1048576)!==0&&hg(s,Io,s.index);switch(s.lanes=0,s.tag){case 16:e:{var h=s.pendingProps;if(n=Oa(s.elementType),s.type=n,typeof n=="function")oh(n)?(h=Ua(n,h),s.tag=1,s=D1(null,s,n,h,u)):(s.tag=0,s=Kh(null,s,n,h,u));else{if(n!=null){var b=n.$$typeof;if(b===A){s.tag=11,s=S1(null,s,n,h,u);break e}else if(b===F){s.tag=14,s=C1(null,s,n,h,u);break e}}throw s=R(n)||n,Error(i(306,s,""))}}return s;case 0:return Kh(n,s,s.type,s.pendingProps,u);case 1:return h=s.type,b=Ua(h,s.pendingProps),D1(n,s,h,b,u);case 3:e:{if(oe(s,s.stateNode.containerInfo),n===null)throw Error(i(387));h=s.pendingProps;var v=s.memoizedState;b=v.element,Sh(n,s),Wo(s,h,null,u);var D=s.memoizedState;if(h=D.cache,qs(s,zn,h),h!==v.cache&&gh(s,[zn],u,!0),Vo(),h=D.element,v.isDehydrated)if(v={element:h,isDehydrated:!1,cache:D.cache},s.updateQueue.baseState=v,s.memoizedState=v,s.flags&256){s=_1(n,s,h,u);break e}else if(h!==b){b=fi(Error(i(424)),s),Ho(b),s=_1(n,s,h,u);break e}else{switch(n=s.stateNode.containerInfo,n.nodeType){case 9:n=n.body;break;default:n=n.nodeName==="HTML"?n.ownerDocument.body:n}for(yn=gi(n.firstChild),rr=s,Lt=!0,Hs=null,pi=!0,u=Eg(s,null,h,u),s.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling}else{if(Ra(),h===b){s=ys(n,s,u);break e}sr(n,s,h,u)}s=s.child}return s;case 26:return Gu(n,s),n===null?(u=Py(s.type,null,s.pendingProps,null))?s.memoizedState=u:Lt||(u=s.type,n=s.pendingProps,h=fd(J.current).createElement(u),h[ft]=s,h[Ct]=n,ar(h,u,n),wn(h),s.stateNode=h):s.memoizedState=Py(s.type,n.memoizedProps,s.pendingProps,n.memoizedState),null;case 27:return Ee(s),n===null&&Lt&&(h=s.stateNode=qy(s.type,s.pendingProps,J.current),rr=s,pi=!0,b=yn,na(s.type)?(Bm=b,yn=gi(h.firstChild)):yn=b),sr(n,s,s.pendingProps.children,u),Gu(n,s),n===null&&(s.flags|=4194304),s.child;case 5:return n===null&&Lt&&((b=h=yn)&&(h=s4(h,s.type,s.pendingProps,pi),h!==null?(s.stateNode=h,rr=s,yn=gi(h.firstChild),pi=!1,b=!0):b=!1),b||Us(s)),Ee(s),b=s.type,v=s.pendingProps,D=n!==null?n.memoizedProps:null,h=v.children,_m(b,v)?h=null:D!==null&&_m(b,D)&&(s.flags|=32),s.memoizedState!==null&&(b=Dh(n,s,vS,null,null,u),mc._currentValue=b),Gu(n,s),sr(n,s,h,u),s.child;case 6:return n===null&&Lt&&((n=u=yn)&&(u=a4(u,s.pendingProps,pi),u!==null?(s.stateNode=u,rr=s,yn=null,n=!0):n=!1),n||Us(s)),null;case 13:return M1(n,s,u);case 4:return oe(s,s.stateNode.containerInfo),h=s.pendingProps,n===null?s.child=Ia(s,null,h,u):sr(n,s,h,u),s.child;case 11:return S1(n,s,s.type,s.pendingProps,u);case 7:return sr(n,s,s.pendingProps,u),s.child;case 8:return sr(n,s,s.pendingProps.children,u),s.child;case 12:return sr(n,s,s.pendingProps.children,u),s.child;case 10:return h=s.pendingProps,qs(s,s.type,h.value),sr(n,s,h.children,u),s.child;case 9:return b=s.type._context,h=s.pendingProps.children,Ba(s),b=ir(b),h=h(b),s.flags|=1,sr(n,s,h,u),s.child;case 14:return C1(n,s,s.type,s.pendingProps,u);case 15:return j1(n,s,s.type,s.pendingProps,u);case 19:return R1(n,s,u);case 31:return AS(n,s,u);case 22:return E1(n,s,u,s.pendingProps);case 24:return Ba(s),h=ir(zn),n===null?(b=vh(),b===null&&(b=dn,v=yh(),b.pooledCache=v,v.refCount++,v!==null&&(b.pooledCacheLanes|=u),b=v),s.memoizedState={parent:h,cache:b},kh(s),qs(s,zn,b)):((n.lanes&u)!==0&&(Sh(n,s),Wo(s,null,null,u),Vo()),b=n.memoizedState,v=s.memoizedState,b.parent!==h?(b={parent:h,cache:h},s.memoizedState=b,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=b),qs(s,zn,h)):(h=v.cache,qs(s,zn,h),h!==b.cache&&gh(s,[zn],u,!0))),sr(n,s,s.pendingProps.children,u),s.child;case 29:throw s.pendingProps}throw Error(i(156,s.tag))}function bs(n){n.flags|=4}function im(n,s,u,h,b){if((s=(n.mode&32)!==0)&&(s=!1),s){if(n.flags|=16777216,(b&335544128)===b)if(n.stateNode.complete)n.flags|=8192;else if(oy())n.flags|=8192;else throw La=Ru,wh}else n.flags&=-16777217}function B1(n,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!Qy(s))if(oy())n.flags|=8192;else throw La=Ru,wh}function Qu(n,s){s!==null&&(n.flags|=4),n.flags&16384&&(s=n.tag!==22?ot():536870912,n.lanes|=s,Ul|=s)}function ec(n,s){if(!Lt)switch(n.tailMode){case"hidden":s=n.tail;for(var u=null;s!==null;)s.alternate!==null&&(u=s),s=s.sibling;u===null?n.tail=null:u.sibling=null;break;case"collapsed":u=n.tail;for(var h=null;u!==null;)u.alternate!==null&&(h=u),u=u.sibling;h===null?s||n.tail===null?n.tail=null:n.tail.sibling=null:h.sibling=null}}function bn(n){var s=n.alternate!==null&&n.alternate.child===n.child,u=0,h=0;if(s)for(var b=n.child;b!==null;)u|=b.lanes|b.childLanes,h|=b.subtreeFlags&65011712,h|=b.flags&65011712,b.return=n,b=b.sibling;else for(b=n.child;b!==null;)u|=b.lanes|b.childLanes,h|=b.subtreeFlags,h|=b.flags,b.return=n,b=b.sibling;return n.subtreeFlags|=h,n.childLanes=u,s}function DS(n,s,u){var h=s.pendingProps;switch(fh(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bn(s),null;case 1:return bn(s),null;case 3:return u=s.stateNode,h=null,n!==null&&(h=n.memoizedState.cache),s.memoizedState.cache!==h&&(s.flags|=2048),ps(zn),be(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(n===null||n.child===null)&&(Tl(s)?bs(s):n===null||n.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,mh())),bn(s),null;case 26:var b=s.type,v=s.memoizedState;return n===null?(bs(s),v!==null?(bn(s),B1(s,v)):(bn(s),im(s,b,null,h,u))):v?v!==n.memoizedState?(bs(s),bn(s),B1(s,v)):(bn(s),s.flags&=-16777217):(n=n.memoizedProps,n!==h&&bs(s),bn(s),im(s,b,n,h,u)),null;case 27:if(Ae(s),u=J.current,b=s.type,n!==null&&s.stateNode!=null)n.memoizedProps!==h&&bs(s);else{if(!h){if(s.stateNode===null)throw Error(i(166));return bn(s),null}n=Q.current,Tl(s)?pg(s):(n=qy(b,h,u),s.stateNode=n,bs(s))}return bn(s),null;case 5:if(Ae(s),b=s.type,n!==null&&s.stateNode!=null)n.memoizedProps!==h&&bs(s);else{if(!h){if(s.stateNode===null)throw Error(i(166));return bn(s),null}if(v=Q.current,Tl(s))pg(s);else{var D=fd(J.current);switch(v){case 1:v=D.createElementNS("http://www.w3.org/2000/svg",b);break;case 2:v=D.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;default:switch(b){case"svg":v=D.createElementNS("http://www.w3.org/2000/svg",b);break;case"math":v=D.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;case"script":v=D.createElement("div"),v.innerHTML="<script><\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof h.is=="string"?D.createElement("select",{is:h.is}):D.createElement("select"),h.multiple?v.multiple=!0:h.size&&(v.size=h.size);break;default:v=typeof h.is=="string"?D.createElement(b,{is:h.is}):D.createElement(b)}}v[ft]=s,v[Ct]=h;e:for(D=s.child;D!==null;){if(D.tag===5||D.tag===6)v.appendChild(D.stateNode);else if(D.tag!==4&&D.tag!==27&&D.child!==null){D.child.return=D,D=D.child;continue}if(D===s)break e;for(;D.sibling===null;){if(D.return===null||D.return===s)break e;D=D.return}D.sibling.return=D.return,D=D.sibling}s.stateNode=v;e:switch(ar(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&&bs(s)}}return bn(s),im(s,s.type,n===null?null:n.memoizedProps,s.pendingProps,u),null;case 6:if(n&&s.stateNode!=null)n.memoizedProps!==h&&bs(s);else{if(typeof h!="string"&&s.stateNode===null)throw Error(i(166));if(n=J.current,Tl(s)){if(n=s.stateNode,u=s.memoizedProps,h=null,b=rr,b!==null)switch(b.tag){case 27:case 5:h=b.memoizedProps}n[ft]=s,n=!!(n.nodeValue===u||h!==null&&h.suppressHydrationWarning===!0||My(n.nodeValue,u)),n||Us(s,!0)}else n=fd(n).createTextNode(h),n[ft]=s,s.stateNode=n}return bn(s),null;case 31:if(u=s.memoizedState,n===null||n.memoizedState!==null){if(h=Tl(s),u!==null){if(n===null){if(!h)throw Error(i(318));if(n=s.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(557));n[ft]=s}else Ra(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;bn(s),n=!1}else u=mh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=u),n=!0;if(!n)return s.flags&256?(Vr(s),s):(Vr(s),null);if((s.flags&128)!==0)throw Error(i(558))}return bn(s),null;case 13:if(h=s.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(b=Tl(s),h!==null&&h.dehydrated!==null){if(n===null){if(!b)throw Error(i(318));if(b=s.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(i(317));b[ft]=s}else Ra(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;bn(s),b=!1}else b=mh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=b),b=!0;if(!b)return s.flags&256?(Vr(s),s):(Vr(s),null)}return Vr(s),(s.flags&128)!==0?(s.lanes=u,s):(u=h!==null,n=n!==null&&n.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!==n&&u&&(s.child.flags|=8192),Qu(s,s.updateQueue),bn(s),null);case 4:return be(),n===null&&Em(s.stateNode.containerInfo),bn(s),null;case 10:return ps(s.type),bn(s),null;case 19:if(Y(Fn),h=s.memoizedState,h===null)return bn(s),null;if(b=(s.flags&128)!==0,v=h.rendering,v===null)if(b)ec(h,!1);else{if(Mn!==0||n!==null&&(n.flags&128)!==0)for(n=s.child;n!==null;){if(v=Ou(n),v!==null){for(s.flags|=128,ec(h,!1),n=v.updateQueue,s.updateQueue=n,Qu(s,n),s.subtreeFlags=0,n=u,u=s.child;u!==null;)ug(u,n),u=u.sibling;return $(Fn,Fn.current&1|2),Lt&&hs(s,h.treeForkCount),s.child}n=n.sibling}h.tail!==null&&ve()>nd&&(s.flags|=128,b=!0,ec(h,!1),s.lanes=4194304)}else{if(!b)if(n=Ou(v),n!==null){if(s.flags|=128,b=!0,n=n.updateQueue,s.updateQueue=n,Qu(s,n),ec(h,!0),h.tail===null&&h.tailMode==="hidden"&&!v.alternate&&!Lt)return bn(s),null}else 2*ve()-h.renderingStartTime>nd&&u!==536870912&&(s.flags|=128,b=!0,ec(h,!1),s.lanes=4194304);h.isBackwards?(v.sibling=s.child,s.child=v):(n=h.last,n!==null?n.sibling=v:s.child=v,h.last=v)}return h.tail!==null?(n=h.tail,h.rendering=n,h.tail=n.sibling,h.renderingStartTime=ve(),n.sibling=null,u=Fn.current,$(Fn,b?u&1|2:u&1),Lt&&hs(s,h.treeForkCount),n):(bn(s),null);case 22:case 23:return Vr(s),Nh(),h=s.memoizedState!==null,n!==null?n.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(u&536870912)!==0&&(s.flags&128)===0&&(bn(s),s.subtreeFlags&6&&(s.flags|=8192)):bn(s),u=s.updateQueue,u!==null&&Qu(s,u.retryQueue),u=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==u&&(s.flags|=2048),n!==null&&Y($a),null;case 24:return u=null,n!==null&&(u=n.memoizedState.cache),s.memoizedState.cache!==u&&(s.flags|=2048),ps(zn),bn(s),null;case 25:return null;case 30:return null}throw Error(i(156,s.tag))}function _S(n,s){switch(fh(s),s.tag){case 1:return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 3:return ps(zn),be(),n=s.flags,(n&65536)!==0&&(n&128)===0?(s.flags=n&-65537|128,s):null;case 26:case 27:case 5:return Ae(s),null;case 31:if(s.memoizedState!==null){if(Vr(s),s.alternate===null)throw Error(i(340));Ra()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 13:if(Vr(s),n=s.memoizedState,n!==null&&n.dehydrated!==null){if(s.alternate===null)throw Error(i(340));Ra()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 19:return Y(Fn),null;case 4:return be(),null;case 10:return ps(s.type),null;case 22:case 23:return Vr(s),Nh(),n!==null&&Y($a),n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 24:return ps(zn),null;case 25:return null;default:return null}}function $1(n,s){switch(fh(s),s.tag){case 3:ps(zn),be();break;case 26:case 27:case 5:Ae(s);break;case 4:be();break;case 31:s.memoizedState!==null&&Vr(s);break;case 13:Vr(s);break;case 19:Y(Fn);break;case 10:ps(s.type);break;case 22:case 23:Vr(s),Nh(),n!==null&&Y($a);break;case 24:ps(zn)}}function tc(n,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&n)===n){h=void 0;var v=u.create,D=u.inst;h=v(),D.destroy=h}u=u.next}while(u!==b)}}catch(X){tn(s,s.return,X)}}function Gs(n,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&n)===n){var D=h.inst,X=D.destroy;if(X!==void 0){D.destroy=void 0,b=s;var te=u,pe=X;try{pe()}catch(ke){tn(b,te,ke)}}}h=h.next}while(h!==v)}}catch(ke){tn(s,s.return,ke)}}function O1(n){var s=n.updateQueue;if(s!==null){var u=n.stateNode;try{Ag(s,u)}catch(h){tn(n,n.return,h)}}}function L1(n,s,u){u.props=Ua(n.type,n.memoizedProps),u.state=n.memoizedState;try{u.componentWillUnmount()}catch(h){tn(n,s,h)}}function nc(n,s){try{var u=n.ref;if(u!==null){switch(n.tag){case 26:case 27:case 5:var h=n.stateNode;break;case 30:h=n.stateNode;break;default:h=n.stateNode}typeof u=="function"?n.refCleanup=u(h):u.current=h}}catch(b){tn(n,s,b)}}function Pi(n,s){var u=n.ref,h=n.refCleanup;if(u!==null)if(typeof h=="function")try{h()}catch(b){tn(n,s,b)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(b){tn(n,s,b)}else u.current=null}function I1(n){var s=n.type,u=n.memoizedProps,h=n.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){tn(n,n.return,b)}}function sm(n,s,u){try{var h=n.stateNode;JS(h,n.type,u,s),h[Ct]=s}catch(b){tn(n,n.return,b)}}function H1(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&na(n.type)||n.tag===4}function am(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||H1(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&na(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function lm(n,s,u){var h=n.tag;if(h===5||h===6)n=n.stateNode,s?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(n,s):(s=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,s.appendChild(n),u=u._reactRootContainer,u!=null||s.onclick!==null||(s.onclick=nr));else if(h!==4&&(h===27&&na(n.type)&&(u=n.stateNode,s=null),n=n.child,n!==null))for(lm(n,s,u),n=n.sibling;n!==null;)lm(n,s,u),n=n.sibling}function Zu(n,s,u){var h=n.tag;if(h===5||h===6)n=n.stateNode,s?u.insertBefore(n,s):u.appendChild(n);else if(h!==4&&(h===27&&na(n.type)&&(u=n.stateNode),n=n.child,n!==null))for(Zu(n,s,u),n=n.sibling;n!==null;)Zu(n,s,u),n=n.sibling}function U1(n){var s=n.stateNode,u=n.memoizedProps;try{for(var h=n.type,b=s.attributes;b.length;)s.removeAttributeNode(b[0]);ar(s,h,u),s[ft]=n,s[Ct]=u}catch(v){tn(n,n.return,v)}}var vs=!1,On=!1,om=!1,q1=typeof WeakSet=="function"?WeakSet:Set,Kn=null;function MS(n,s){if(n=n.containerInfo,Tm=bd,n=tg(n),th(n)){if("selectionStart"in n)var u={start:n.selectionStart,end:n.selectionEnd};else e:{u=(u=n.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 D=0,X=-1,te=-1,pe=0,ke=0,Me=n,xe=null;t:for(;;){for(var ye;Me!==u||b!==0&&Me.nodeType!==3||(X=D+b),Me!==v||h!==0&&Me.nodeType!==3||(te=D+h),Me.nodeType===3&&(D+=Me.nodeValue.length),(ye=Me.firstChild)!==null;)xe=Me,Me=ye;for(;;){if(Me===n)break t;if(xe===u&&++pe===b&&(X=D),xe===v&&++ke===h&&(te=D),(ye=Me.nextSibling)!==null)break;Me=xe,xe=Me.parentNode}Me=ye}u=X===-1||te===-1?null:{start:X,end:te}}else u=null}u=u||{start:0,end:0}}else u=null;for(Dm={focusedElem:n,selectionRange:u},bd=!1,Kn=s;Kn!==null;)if(s=Kn,n=s.child,(s.subtreeFlags&1028)!==0&&n!==null)n.return=s,Kn=n;else for(;Kn!==null;){switch(s=Kn,v=s.alternate,n=s.flags,s.tag){case 0:if((n&4)!==0&&(n=s.updateQueue,n=n!==null?n.events:null,n!==null))for(u=0;u<n.length;u++)b=n[u],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&v!==null){n=void 0,u=s,b=v.memoizedProps,v=v.memoizedState,h=u.stateNode;try{var Ge=Ua(u.type,b);n=h.getSnapshotBeforeUpdate(Ge,v),h.__reactInternalSnapshotBeforeUpdate=n}catch(xt){tn(u,u.return,xt)}}break;case 3:if((n&1024)!==0){if(n=s.stateNode.containerInfo,u=n.nodeType,u===9)Fm(n);else if(u===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Fm(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(i(163))}if(n=s.sibling,n!==null){n.return=s.return,Kn=n;break}Kn=s.return}}function Y1(n,s,u){var h=u.flags;switch(u.tag){case 0:case 11:case 15:ks(n,u),h&4&&tc(5,u);break;case 1:if(ks(n,u),h&4)if(n=u.stateNode,s===null)try{n.componentDidMount()}catch(D){tn(u,u.return,D)}else{var b=Ua(u.type,s.memoizedProps);s=s.memoizedState;try{n.componentDidUpdate(b,s,n.__reactInternalSnapshotBeforeUpdate)}catch(D){tn(u,u.return,D)}}h&64&&O1(u),h&512&&nc(u,u.return);break;case 3:if(ks(n,u),h&64&&(n=u.updateQueue,n!==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{Ag(n,s)}catch(D){tn(u,u.return,D)}}break;case 27:s===null&&h&4&&U1(u);case 26:case 5:ks(n,u),s===null&&h&4&&I1(u),h&512&&nc(u,u.return);break;case 12:ks(n,u);break;case 31:ks(n,u),h&4&&V1(n,u);break;case 13:ks(n,u),h&4&&W1(n,u),h&64&&(n=u.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(u=HS.bind(null,u),l4(n,u))));break;case 22:if(h=u.memoizedState!==null||vs,!h){s=s!==null&&s.memoizedState!==null||On,b=vs;var v=On;vs=h,(On=s)&&!v?Ss(n,u,(u.subtreeFlags&8772)!==0):ks(n,u),vs=b,On=v}break;case 30:break;default:ks(n,u)}}function X1(n){var s=n.alternate;s!==null&&(n.alternate=null,X1(s)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(s=n.stateNode,s!==null&&Or(s)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var kn=null,Ar=!1;function ws(n,s,u){for(u=u.child;u!==null;)P1(n,s,u),u=u.sibling}function P1(n,s,u){if(Pe&&typeof Pe.onCommitFiberUnmount=="function")try{Pe.onCommitFiberUnmount(Ue,u)}catch{}switch(u.tag){case 26:On||Pi(u,s),ws(n,s,u),u.memoizedState?u.memoizedState.count--:u.stateNode&&(u=u.stateNode,u.parentNode.removeChild(u));break;case 27:On||Pi(u,s);var h=kn,b=Ar;na(u.type)&&(kn=u.stateNode,Ar=!1),ws(n,s,u),dc(u.stateNode),kn=h,Ar=b;break;case 5:On||Pi(u,s);case 6:if(h=kn,b=Ar,kn=null,ws(n,s,u),kn=h,Ar=b,kn!==null)if(Ar)try{(kn.nodeType===9?kn.body:kn.nodeName==="HTML"?kn.ownerDocument.body:kn).removeChild(u.stateNode)}catch(v){tn(u,s,v)}else try{kn.removeChild(u.stateNode)}catch(v){tn(u,s,v)}break;case 18:kn!==null&&(Ar?(n=kn,Oy(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,u.stateNode),Kl(n)):Oy(kn,u.stateNode));break;case 4:h=kn,b=Ar,kn=u.stateNode.containerInfo,Ar=!0,ws(n,s,u),kn=h,Ar=b;break;case 0:case 11:case 14:case 15:Gs(2,u,s),On||Gs(4,u,s),ws(n,s,u);break;case 1:On||(Pi(u,s),h=u.stateNode,typeof h.componentWillUnmount=="function"&&L1(u,s,h)),ws(n,s,u);break;case 21:ws(n,s,u);break;case 22:On=(h=On)||u.memoizedState!==null,ws(n,s,u),On=h;break;default:ws(n,s,u)}}function V1(n,s){if(s.memoizedState===null&&(n=s.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Kl(n)}catch(u){tn(s,s.return,u)}}}function W1(n,s){if(s.memoizedState===null&&(n=s.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Kl(n)}catch(u){tn(s,s.return,u)}}function FS(n){switch(n.tag){case 31:case 13:case 19:var s=n.stateNode;return s===null&&(s=n.stateNode=new q1),s;case 22:return n=n.stateNode,s=n._retryCache,s===null&&(s=n._retryCache=new q1),s;default:throw Error(i(435,n.tag))}}function Ju(n,s){var u=FS(n);s.forEach(function(h){if(!u.has(h)){u.add(h);var b=US.bind(null,n,h);h.then(b,b)}})}function Tr(n,s){var u=s.deletions;if(u!==null)for(var h=0;h<u.length;h++){var b=u[h],v=n,D=s,X=D;e:for(;X!==null;){switch(X.tag){case 27:if(na(X.type)){kn=X.stateNode,Ar=!1;break e}break;case 5:kn=X.stateNode,Ar=!1;break e;case 3:case 4:kn=X.stateNode.containerInfo,Ar=!0;break e}X=X.return}if(kn===null)throw Error(i(160));P1(v,D,b),kn=null,Ar=!1,v=b.alternate,v!==null&&(v.return=null),b.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)G1(s,n),s=s.sibling}var Ai=null;function G1(n,s){var u=n.alternate,h=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:Tr(s,n),Dr(n),h&4&&(Gs(3,n,n.return),tc(3,n),Gs(5,n,n.return));break;case 1:Tr(s,n),Dr(n),h&512&&(On||u===null||Pi(u,u.return)),h&64&&vs&&(n=n.updateQueue,n!==null&&(h=n.callbacks,h!==null&&(u=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=u===null?h:u.concat(h))));break;case 26:var b=Ai;if(Tr(s,n),Dr(n),h&512&&(On||u===null||Pi(u,u.return)),h&4){var v=u!==null?u.memoizedState:null;if(h=n.memoizedState,u===null)if(h===null)if(n.stateNode===null){e:{h=n.type,u=n.memoizedProps,b=b.ownerDocument||b;t:switch(h){case"title":v=b.getElementsByTagName("title")[0],(!v||v[$r]||v[ft]||v.namespaceURI==="http://www.w3.org/2000/svg"||v.hasAttribute("itemprop"))&&(v=b.createElement(h),b.head.insertBefore(v,b.querySelector("head > title"))),ar(v,h,u),v[ft]=n,wn(v),h=v;break e;case"link":var D=Gy("link","href",b).get(h+(u.href||""));if(D){for(var X=0;X<D.length;X++)if(v=D[X],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)){D.splice(X,1);break t}}v=b.createElement(h),ar(v,h,u),b.head.appendChild(v);break;case"meta":if(D=Gy("meta","content",b).get(h+(u.content||""))){for(X=0;X<D.length;X++)if(v=D[X],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)){D.splice(X,1);break t}}v=b.createElement(h),ar(v,h,u),b.head.appendChild(v);break;default:throw Error(i(468,h))}v[ft]=n,wn(v),h=v}n.stateNode=h}else Ky(b,n.type,n.stateNode);else n.stateNode=Wy(b,h,n.memoizedProps);else v!==h?(v===null?u.stateNode!==null&&(u=u.stateNode,u.parentNode.removeChild(u)):v.count--,h===null?Ky(b,n.type,n.stateNode):Wy(b,h,n.memoizedProps)):h===null&&n.stateNode!==null&&sm(n,n.memoizedProps,u.memoizedProps)}break;case 27:Tr(s,n),Dr(n),h&512&&(On||u===null||Pi(u,u.return)),u!==null&&h&4&&sm(n,n.memoizedProps,u.memoizedProps);break;case 5:if(Tr(s,n),Dr(n),h&512&&(On||u===null||Pi(u,u.return)),n.flags&32){b=n.stateNode;try{Hr(b,"")}catch(Ge){tn(n,n.return,Ge)}}h&4&&n.stateNode!=null&&(b=n.memoizedProps,sm(n,b,u!==null?u.memoizedProps:b)),h&1024&&(om=!0);break;case 6:if(Tr(s,n),Dr(n),h&4){if(n.stateNode===null)throw Error(i(162));h=n.memoizedProps,u=n.stateNode;try{u.nodeValue=h}catch(Ge){tn(n,n.return,Ge)}}break;case 3:if(pd=null,b=Ai,Ai=hd(s.containerInfo),Tr(s,n),Ai=b,Dr(n),h&4&&u!==null&&u.memoizedState.isDehydrated)try{Kl(s.containerInfo)}catch(Ge){tn(n,n.return,Ge)}om&&(om=!1,K1(n));break;case 4:h=Ai,Ai=hd(n.stateNode.containerInfo),Tr(s,n),Dr(n),Ai=h;break;case 12:Tr(s,n),Dr(n);break;case 31:Tr(s,n),Dr(n),h&4&&(h=n.updateQueue,h!==null&&(n.updateQueue=null,Ju(n,h)));break;case 13:Tr(s,n),Dr(n),n.child.flags&8192&&n.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(td=ve()),h&4&&(h=n.updateQueue,h!==null&&(n.updateQueue=null,Ju(n,h)));break;case 22:b=n.memoizedState!==null;var te=u!==null&&u.memoizedState!==null,pe=vs,ke=On;if(vs=pe||b,On=ke||te,Tr(s,n),On=ke,vs=pe,Dr(n),h&8192)e:for(s=n.stateNode,s._visibility=b?s._visibility&-2:s._visibility|1,b&&(u===null||te||vs||On||qa(n)),u=null,s=n;;){if(s.tag===5||s.tag===26){if(u===null){te=u=s;try{if(v=te.stateNode,b)D=v.style,typeof D.setProperty=="function"?D.setProperty("display","none","important"):D.display="none";else{X=te.stateNode;var Me=te.memoizedProps.style,xe=Me!=null&&Me.hasOwnProperty("display")?Me.display:null;X.style.display=xe==null||typeof xe=="boolean"?"":(""+xe).trim()}}catch(Ge){tn(te,te.return,Ge)}}}else if(s.tag===6){if(u===null){te=s;try{te.stateNode.nodeValue=b?"":te.memoizedProps}catch(Ge){tn(te,te.return,Ge)}}}else if(s.tag===18){if(u===null){te=s;try{var ye=te.stateNode;b?Ly(ye,!0):Ly(te.stateNode,!1)}catch(Ge){tn(te,te.return,Ge)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===n)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break e;for(;s.sibling===null;){if(s.return===null||s.return===n)break e;u===s&&(u=null),s=s.return}u===s&&(u=null),s.sibling.return=s.return,s=s.sibling}h&4&&(h=n.updateQueue,h!==null&&(u=h.retryQueue,u!==null&&(h.retryQueue=null,Ju(n,u))));break;case 19:Tr(s,n),Dr(n),h&4&&(h=n.updateQueue,h!==null&&(n.updateQueue=null,Ju(n,h)));break;case 30:break;case 21:break;default:Tr(s,n),Dr(n)}}function Dr(n){var s=n.flags;if(s&2){try{for(var u,h=n.return;h!==null;){if(H1(h)){u=h;break}h=h.return}if(u==null)throw Error(i(160));switch(u.tag){case 27:var b=u.stateNode,v=am(n);Zu(n,v,b);break;case 5:var D=u.stateNode;u.flags&32&&(Hr(D,""),u.flags&=-33);var X=am(n);Zu(n,X,D);break;case 3:case 4:var te=u.stateNode.containerInfo,pe=am(n);lm(n,pe,te);break;default:throw Error(i(161))}}catch(ke){tn(n,n.return,ke)}n.flags&=-3}s&4096&&(n.flags&=-4097)}function K1(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var s=n;K1(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),n=n.sibling}}function ks(n,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)Y1(n,s.alternate,s),s=s.sibling}function qa(n){for(n=n.child;n!==null;){var s=n;switch(s.tag){case 0:case 11:case 14:case 15:Gs(4,s,s.return),qa(s);break;case 1:Pi(s,s.return);var u=s.stateNode;typeof u.componentWillUnmount=="function"&&L1(s,s.return,u),qa(s);break;case 27:dc(s.stateNode);case 26:case 5:Pi(s,s.return),qa(s);break;case 22:s.memoizedState===null&&qa(s);break;case 30:qa(s);break;default:qa(s)}n=n.sibling}}function Ss(n,s,u){for(u=u&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var h=s.alternate,b=n,v=s,D=v.flags;switch(v.tag){case 0:case 11:case 15:Ss(b,v,u),tc(4,v);break;case 1:if(Ss(b,v,u),h=v,b=h.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(pe){tn(h,h.return,pe)}if(h=v,b=h.updateQueue,b!==null){var X=h.stateNode;try{var te=b.shared.hiddenCallbacks;if(te!==null)for(b.shared.hiddenCallbacks=null,b=0;b<te.length;b++)Ng(te[b],X)}catch(pe){tn(h,h.return,pe)}}u&&D&64&&O1(v),nc(v,v.return);break;case 27:U1(v);case 26:case 5:Ss(b,v,u),u&&h===null&&D&4&&I1(v),nc(v,v.return);break;case 12:Ss(b,v,u);break;case 31:Ss(b,v,u),u&&D&4&&V1(b,v);break;case 13:Ss(b,v,u),u&&D&4&&W1(b,v);break;case 22:v.memoizedState===null&&Ss(b,v,u),nc(v,v.return);break;case 30:break;default:Ss(b,v,u)}s=s.sibling}}function cm(n,s){var u=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),n=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(n=s.memoizedState.cachePool.pool),n!==u&&(n!=null&&n.refCount++,u!=null&&Uo(u))}function um(n,s){n=null,s.alternate!==null&&(n=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==n&&(s.refCount++,n!=null&&Uo(n))}function Ti(n,s,u,h){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Q1(n,s,u,h),s=s.sibling}function Q1(n,s,u,h){var b=s.flags;switch(s.tag){case 0:case 11:case 15:Ti(n,s,u,h),b&2048&&tc(9,s);break;case 1:Ti(n,s,u,h);break;case 3:Ti(n,s,u,h),b&2048&&(n=null,s.alternate!==null&&(n=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==n&&(s.refCount++,n!=null&&Uo(n)));break;case 12:if(b&2048){Ti(n,s,u,h),n=s.stateNode;try{var v=s.memoizedProps,D=v.id,X=v.onPostCommit;typeof X=="function"&&X(D,s.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(te){tn(s,s.return,te)}}else Ti(n,s,u,h);break;case 31:Ti(n,s,u,h);break;case 13:Ti(n,s,u,h);break;case 23:break;case 22:v=s.stateNode,D=s.alternate,s.memoizedState!==null?v._visibility&2?Ti(n,s,u,h):rc(n,s):v._visibility&2?Ti(n,s,u,h):(v._visibility|=2,Ll(n,s,u,h,(s.subtreeFlags&10256)!==0||!1)),b&2048&&cm(D,s);break;case 24:Ti(n,s,u,h),b&2048&&um(s.alternate,s);break;default:Ti(n,s,u,h)}}function Ll(n,s,u,h,b){for(b=b&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var v=n,D=s,X=u,te=h,pe=D.flags;switch(D.tag){case 0:case 11:case 15:Ll(v,D,X,te,b),tc(8,D);break;case 23:break;case 22:var ke=D.stateNode;D.memoizedState!==null?ke._visibility&2?Ll(v,D,X,te,b):rc(v,D):(ke._visibility|=2,Ll(v,D,X,te,b)),b&&pe&2048&&cm(D.alternate,D);break;case 24:Ll(v,D,X,te,b),b&&pe&2048&&um(D.alternate,D);break;default:Ll(v,D,X,te,b)}s=s.sibling}}function rc(n,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var u=n,h=s,b=h.flags;switch(h.tag){case 22:rc(u,h),b&2048&&cm(h.alternate,h);break;case 24:rc(u,h),b&2048&&um(h.alternate,h);break;default:rc(u,h)}s=s.sibling}}var ic=8192;function Il(n,s,u){if(n.subtreeFlags&ic)for(n=n.child;n!==null;)Z1(n,s,u),n=n.sibling}function Z1(n,s,u){switch(n.tag){case 26:Il(n,s,u),n.flags&ic&&n.memoizedState!==null&&b4(u,Ai,n.memoizedState,n.memoizedProps);break;case 5:Il(n,s,u);break;case 3:case 4:var h=Ai;Ai=hd(n.stateNode.containerInfo),Il(n,s,u),Ai=h;break;case 22:n.memoizedState===null&&(h=n.alternate,h!==null&&h.memoizedState!==null?(h=ic,ic=16777216,Il(n,s,u),ic=h):Il(n,s,u));break;default:Il(n,s,u)}}function J1(n){var s=n.alternate;if(s!==null&&(n=s.child,n!==null)){s.child=null;do s=n.sibling,n.sibling=null,n=s;while(n!==null)}}function sc(n){var s=n.deletions;if((n.flags&16)!==0){if(s!==null)for(var u=0;u<s.length;u++){var h=s[u];Kn=h,ty(h,n)}J1(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)ey(n),n=n.sibling}function ey(n){switch(n.tag){case 0:case 11:case 15:sc(n),n.flags&2048&&Gs(9,n,n.return);break;case 3:sc(n);break;case 12:sc(n);break;case 22:var s=n.stateNode;n.memoizedState!==null&&s._visibility&2&&(n.return===null||n.return.tag!==13)?(s._visibility&=-3,ed(n)):sc(n);break;default:sc(n)}}function ed(n){var s=n.deletions;if((n.flags&16)!==0){if(s!==null)for(var u=0;u<s.length;u++){var h=s[u];Kn=h,ty(h,n)}J1(n)}for(n=n.child;n!==null;){switch(s=n,s.tag){case 0:case 11:case 15:Gs(8,s,s.return),ed(s);break;case 22:u=s.stateNode,u._visibility&2&&(u._visibility&=-3,ed(s));break;default:ed(s)}n=n.sibling}}function ty(n,s){for(;Kn!==null;){var u=Kn;switch(u.tag){case 0:case 11:case 15:Gs(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:Uo(u.memoizedState.cache)}if(h=u.child,h!==null)h.return=u,Kn=h;else e:for(u=n;Kn!==null;){h=Kn;var b=h.sibling,v=h.return;if(X1(h),h===u){Kn=null;break e}if(b!==null){b.return=v,Kn=b;break e}Kn=v}}}var RS={getCacheForType:function(n){var s=ir(zn),u=s.data.get(n);return u===void 0&&(u=n(),s.data.set(n,u)),u},cacheSignal:function(){return ir(zn).controller.signal}},zS=typeof WeakMap=="function"?WeakMap:Map,Qt=0,dn=null,Ft=null,Bt=0,en=0,Wr=null,Ks=!1,Hl=!1,dm=!1,Cs=0,Mn=0,Qs=0,Ya=0,fm=0,Gr=0,Ul=0,ac=null,_r=null,hm=!1,td=0,ny=0,nd=1/0,rd=null,Zs=null,Un=0,Js=null,ql=null,js=0,mm=0,pm=null,ry=null,lc=0,xm=null;function Kr(){return(Qt&2)!==0&&Bt!==0?Bt&-Bt:B.T!==null?km():ie()}function iy(){if(Gr===0)if((Bt&536870912)===0||Lt){var n=Et;Et<<=1,(Et&3932160)===0&&(Et=262144),Gr=n}else Gr=536870912;return n=Pr.current,n!==null&&(n.flags|=32),Gr}function Mr(n,s,u){(n===dn&&(en===2||en===9)||n.cancelPendingCommit!==null)&&(Yl(n,0),ea(n,Bt,Gr,!1)),je(n,u),((Qt&2)===0||n!==dn)&&(n===dn&&((Qt&2)===0&&(Ya|=u),Mn===4&&ea(n,Bt,Gr,!1)),Vi(n))}function sy(n,s,u){if((Qt&6)!==0)throw Error(i(327));var h=!u&&(s&127)===0&&(s&n.expiredLanes)===0||le(n,s),b=h?OS(n,s):ym(n,s,!0),v=h;do{if(b===0){Hl&&!h&&ea(n,s,0,!1);break}else{if(u=n.current.alternate,v&&!BS(u)){b=ym(n,s,!1),v=!1;continue}if(b===2){if(v=s,n.errorRecoveryDisabledLanes&v)var D=0;else D=n.pendingLanes&-536870913,D=D!==0?D:D&536870912?536870912:0;if(D!==0){s=D;e:{var X=n;b=ac;var te=X.current.memoizedState.isDehydrated;if(te&&(Yl(X,D).flags|=256),D=ym(X,D,!1),D!==2){if(dm&&!te){X.errorRecoveryDisabledLanes|=v,Ya|=v,b=4;break e}v=_r,_r=b,v!==null&&(_r===null?_r=v:_r.push.apply(_r,v))}b=D}if(v=!1,b!==2)continue}}if(b===1){Yl(n,0),ea(n,s,0,!0);break}e:{switch(h=n,v=b,v){case 0:case 1:throw Error(i(345));case 4:if((s&4194048)!==s)break;case 6:ea(h,s,Gr,!Ks);break e;case 2:_r=null;break;case 3:case 5:break;default:throw Error(i(329))}if((s&62914560)===s&&(b=td+300-ve(),10<b)){if(ea(h,s,Gr,!Ks),vn(h,0,!0)!==0)break e;js=s,h.timeoutHandle=By(ay.bind(null,h,u,_r,rd,hm,s,Gr,Ya,Ul,Ks,v,"Throttled",-0,0),b);break e}ay(h,u,_r,rd,hm,s,Gr,Ya,Ul,Ks,v,null,-0,0)}}break}while(!0);Vi(n)}function ay(n,s,u,h,b,v,D,X,te,pe,ke,Me,xe,ye){if(n.timeoutHandle=-1,Me=s.subtreeFlags,Me&8192||(Me&16785408)===16785408){Me={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:nr},Z1(s,v,Me);var Ge=(v&62914560)===v?td-ve():(v&4194048)===v?ny-ve():0;if(Ge=v4(Me,Ge),Ge!==null){js=v,n.cancelPendingCommit=Ge(my.bind(null,n,s,v,u,h,b,D,X,te,ke,Me,null,xe,ye)),ea(n,v,D,!pe);return}}my(n,s,v,u,h,b,D,X,te)}function BS(n){for(var s=n;;){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(!Yr(v(),b))return!1}catch{return!1}}if(u=s.child,s.subtreeFlags&16384&&u!==null)u.return=s,s=u;else{if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function ea(n,s,u,h){s&=~fm,s&=~Ya,n.suspendedLanes|=s,n.pingedLanes&=~s,h&&(n.warmLanes|=s),h=n.expirationTimes;for(var b=s;0<b;){var v=31-tt(b),D=1<<v;h[v]=-1,b&=~D}u!==0&&gn(n,u,s)}function id(){return(Qt&6)===0?(oc(0),!1):!0}function gm(){if(Ft!==null){if(en===0)var n=Ft.return;else n=Ft,ms=za=null,Fh(n),Rl=null,Yo=0,n=Ft;for(;n!==null;)$1(n.alternate,n),n=n.return;Ft=null}}function Yl(n,s){var u=n.timeoutHandle;u!==-1&&(n.timeoutHandle=-1,n4(u)),u=n.cancelPendingCommit,u!==null&&(n.cancelPendingCommit=null,u()),js=0,gm(),dn=n,Ft=u=fs(n.current,null),Bt=s,en=0,Wr=null,Ks=!1,Hl=le(n,s),dm=!1,Ul=Gr=fm=Ya=Qs=Mn=0,_r=ac=null,hm=!1,(s&8)!==0&&(s|=s&32);var h=n.entangledLanes;if(h!==0)for(n=n.entanglements,h&=s;0<h;){var b=31-tt(h),v=1<<b;s|=n[b],h&=~v}return Cs=s,ju(),u}function ly(n,s){Nt=null,B.H=Zo,s===Fl||s===Fu?(s=Sg(),en=3):s===wh?(s=Sg(),en=4):en=s===Gh?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Wr=s,Ft===null&&(Mn=1,Vu(n,fi(s,n.current)))}function oy(){var n=Pr.current;return n===null?!0:(Bt&4194048)===Bt?xi===null:(Bt&62914560)===Bt||(Bt&536870912)!==0?n===xi:!1}function cy(){var n=B.H;return B.H=Zo,n===null?Zo:n}function uy(){var n=B.A;return B.A=RS,n}function sd(){Mn=4,Ks||(Bt&4194048)!==Bt&&Pr.current!==null||(Hl=!0),(Qs&134217727)===0&&(Ya&134217727)===0||dn===null||ea(dn,Bt,Gr,!1)}function ym(n,s,u){var h=Qt;Qt|=2;var b=cy(),v=uy();(dn!==n||Bt!==s)&&(rd=null,Yl(n,s)),s=!1;var D=Mn;e:do try{if(en!==0&&Ft!==null){var X=Ft,te=Wr;switch(en){case 8:gm(),D=6;break e;case 3:case 2:case 9:case 6:Pr.current===null&&(s=!0);var pe=en;if(en=0,Wr=null,Xl(n,X,te,pe),u&&Hl){D=0;break e}break;default:pe=en,en=0,Wr=null,Xl(n,X,te,pe)}}$S(),D=Mn;break}catch(ke){ly(n,ke)}while(!0);return s&&n.shellSuspendCounter++,ms=za=null,Qt=h,B.H=b,B.A=v,Ft===null&&(dn=null,Bt=0,ju()),D}function $S(){for(;Ft!==null;)dy(Ft)}function OS(n,s){var u=Qt;Qt|=2;var h=cy(),b=uy();dn!==n||Bt!==s?(rd=null,nd=ve()+500,Yl(n,s)):Hl=le(n,s);e:do try{if(en!==0&&Ft!==null){s=Ft;var v=Wr;t:switch(en){case 1:en=0,Wr=null,Xl(n,s,v,1);break;case 2:case 9:if(wg(v)){en=0,Wr=null,fy(s);break}s=function(){en!==2&&en!==9||dn!==n||(en=7),Vi(n)},v.then(s,s);break e;case 3:en=7;break e;case 4:en=5;break e;case 7:wg(v)?(en=0,Wr=null,fy(s)):(en=0,Wr=null,Xl(n,s,v,7));break;case 5:var D=null;switch(Ft.tag){case 26:D=Ft.memoizedState;case 5:case 27:var X=Ft;if(D?Qy(D):X.stateNode.complete){en=0,Wr=null;var te=X.sibling;if(te!==null)Ft=te;else{var pe=X.return;pe!==null?(Ft=pe,ad(pe)):Ft=null}break t}}en=0,Wr=null,Xl(n,s,v,5);break;case 6:en=0,Wr=null,Xl(n,s,v,6);break;case 8:gm(),Mn=6;break e;default:throw Error(i(462))}}LS();break}catch(ke){ly(n,ke)}while(!0);return ms=za=null,B.H=h,B.A=b,Qt=u,Ft!==null?0:(dn=null,Bt=0,ju(),Mn)}function LS(){for(;Ft!==null&&!jt();)dy(Ft)}function dy(n){var s=z1(n.alternate,n,Cs);n.memoizedProps=n.pendingProps,s===null?ad(n):Ft=s}function fy(n){var s=n,u=s.alternate;switch(s.tag){case 15:case 0:s=T1(u,s,s.pendingProps,s.type,void 0,Bt);break;case 11:s=T1(u,s,s.pendingProps,s.type.render,s.ref,Bt);break;case 5:Fh(s);default:$1(u,s),s=Ft=ug(s,Cs),s=z1(u,s,Cs)}n.memoizedProps=n.pendingProps,s===null?ad(n):Ft=s}function Xl(n,s,u,h){ms=za=null,Fh(s),Rl=null,Yo=0;var b=s.return;try{if(NS(n,b,s,u,Bt)){Mn=1,Vu(n,fi(u,n.current)),Ft=null;return}}catch(v){if(b!==null)throw Ft=b,v;Mn=1,Vu(n,fi(u,n.current)),Ft=null;return}s.flags&32768?(Lt||h===1?n=!0:Hl||(Bt&536870912)!==0?n=!1:(Ks=n=!0,(h===2||h===9||h===3||h===6)&&(h=Pr.current,h!==null&&h.tag===13&&(h.flags|=16384))),hy(s,n)):ad(s)}function ad(n){var s=n;do{if((s.flags&32768)!==0){hy(s,Ks);return}n=s.return;var u=DS(s.alternate,s,Cs);if(u!==null){Ft=u;return}if(s=s.sibling,s!==null){Ft=s;return}Ft=s=n}while(s!==null);Mn===0&&(Mn=5)}function hy(n,s){do{var u=_S(n.alternate,n);if(u!==null){u.flags&=32767,Ft=u;return}if(u=n.return,u!==null&&(u.flags|=32768,u.subtreeFlags=0,u.deletions=null),!s&&(n=n.sibling,n!==null)){Ft=n;return}Ft=n=u}while(n!==null);Mn=6,Ft=null}function my(n,s,u,h,b,v,D,X,te){n.cancelPendingCommit=null;do ld();while(Un!==0);if((Qt&6)!==0)throw Error(i(327));if(s!==null){if(s===n.current)throw Error(i(177));if(v=s.lanes|s.childLanes,v|=ah,St(n,u,v,D,X,te),n===dn&&(Ft=dn=null,Bt=0),ql=s,Js=n,js=u,mm=v,pm=b,ry=h,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,qS(_e,function(){return by(),null})):(n.callbackNode=null,n.callbackPriority=0),h=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||h){h=B.T,B.T=null,b=Z.p,Z.p=2,D=Qt,Qt|=4;try{MS(n,s,u)}finally{Qt=D,Z.p=b,B.T=h}}Un=1,py(),xy(),gy()}}function py(){if(Un===1){Un=0;var n=Js,s=ql,u=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||u){u=B.T,B.T=null;var h=Z.p;Z.p=2;var b=Qt;Qt|=4;try{G1(s,n);var v=Dm,D=tg(n.containerInfo),X=v.focusedElem,te=v.selectionRange;if(D!==X&&X&&X.ownerDocument&&eg(X.ownerDocument.documentElement,X)){if(te!==null&&th(X)){var pe=te.start,ke=te.end;if(ke===void 0&&(ke=pe),"selectionStart"in X)X.selectionStart=pe,X.selectionEnd=Math.min(ke,X.value.length);else{var Me=X.ownerDocument||document,xe=Me&&Me.defaultView||window;if(xe.getSelection){var ye=xe.getSelection(),Ge=X.textContent.length,xt=Math.min(te.start,Ge),on=te.end===void 0?xt:Math.min(te.end,Ge);!ye.extend&&xt>on&&(D=on,on=xt,xt=D);var ue=J0(X,xt),se=J0(X,on);if(ue&&se&&(ye.rangeCount!==1||ye.anchorNode!==ue.node||ye.anchorOffset!==ue.offset||ye.focusNode!==se.node||ye.focusOffset!==se.offset)){var me=Me.createRange();me.setStart(ue.node,ue.offset),ye.removeAllRanges(),xt>on?(ye.addRange(me),ye.extend(se.node,se.offset)):(me.setEnd(se.node,se.offset),ye.addRange(me))}}}}for(Me=[],ye=X;ye=ye.parentNode;)ye.nodeType===1&&Me.push({element:ye,left:ye.scrollLeft,top:ye.scrollTop});for(typeof X.focus=="function"&&X.focus(),X=0;X<Me.length;X++){var Ne=Me[X];Ne.element.scrollLeft=Ne.left,Ne.element.scrollTop=Ne.top}}bd=!!Tm,Dm=Tm=null}finally{Qt=b,Z.p=h,B.T=u}}n.current=s,Un=2}}function xy(){if(Un===2){Un=0;var n=Js,s=ql,u=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||u){u=B.T,B.T=null;var h=Z.p;Z.p=2;var b=Qt;Qt|=4;try{Y1(n,s.alternate,s)}finally{Qt=b,Z.p=h,B.T=u}}Un=3}}function gy(){if(Un===4||Un===3){Un=0,ge();var n=Js,s=ql,u=js,h=ry;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Un=5:(Un=0,ql=Js=null,yy(n,n.pendingLanes));var b=n.pendingLanes;if(b===0&&(Zs=null),An(u),s=s.stateNode,Pe&&typeof Pe.onCommitFiberRoot=="function")try{Pe.onCommitFiberRoot(Ue,s,void 0,(s.current.flags&128)===128)}catch{}if(h!==null){s=B.T,b=Z.p,Z.p=2,B.T=null;try{for(var v=n.onRecoverableError,D=0;D<h.length;D++){var X=h[D];v(X.value,{componentStack:X.stack})}}finally{B.T=s,Z.p=b}}(js&3)!==0&&ld(),Vi(n),b=n.pendingLanes,(u&261930)!==0&&(b&42)!==0?n===xm?lc++:(lc=0,xm=n):lc=0,oc(0)}}function yy(n,s){(n.pooledCacheLanes&=s)===0&&(s=n.pooledCache,s!=null&&(n.pooledCache=null,Uo(s)))}function ld(){return py(),xy(),gy(),by()}function by(){if(Un!==5)return!1;var n=Js,s=mm;mm=0;var u=An(js),h=B.T,b=Z.p;try{Z.p=32>u?32:u,B.T=null,u=pm,pm=null;var v=Js,D=js;if(Un=0,ql=Js=null,js=0,(Qt&6)!==0)throw Error(i(331));var X=Qt;if(Qt|=4,ey(v.current),Q1(v,v.current,D,u),Qt=X,oc(0,!1),Pe&&typeof Pe.onPostCommitFiberRoot=="function")try{Pe.onPostCommitFiberRoot(Ue,v)}catch{}return!0}finally{Z.p=b,B.T=h,yy(n,s)}}function vy(n,s,u){s=fi(u,s),s=Wh(n.stateNode,s,2),n=Ps(n,s,2),n!==null&&(je(n,2),Vi(n))}function tn(n,s,u){if(n.tag===3)vy(n,n,u);else for(;s!==null;){if(s.tag===3){vy(s,n,u);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Zs===null||!Zs.has(h))){n=fi(u,n),u=w1(2),h=Ps(s,u,2),h!==null&&(k1(u,h,s,n),je(h,2),Vi(h));break}}s=s.return}}function bm(n,s,u){var h=n.pingCache;if(h===null){h=n.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)||(dm=!0,b.add(u),n=IS.bind(null,n,s,u),s.then(n,n))}function IS(n,s,u){var h=n.pingCache;h!==null&&h.delete(s),n.pingedLanes|=n.suspendedLanes&u,n.warmLanes&=~u,dn===n&&(Bt&u)===u&&(Mn===4||Mn===3&&(Bt&62914560)===Bt&&300>ve()-td?(Qt&2)===0&&Yl(n,0):fm|=u,Ul===Bt&&(Ul=0)),Vi(n)}function wy(n,s){s===0&&(s=ot()),n=Ma(n,s),n!==null&&(je(n,s),Vi(n))}function HS(n){var s=n.memoizedState,u=0;s!==null&&(u=s.retryLane),wy(n,u)}function US(n,s){var u=0;switch(n.tag){case 31:case 13:var h=n.stateNode,b=n.memoizedState;b!==null&&(u=b.retryLane);break;case 19:h=n.stateNode;break;case 22:h=n.stateNode._retryCache;break;default:throw Error(i(314))}h!==null&&h.delete(s),wy(n,u)}function qS(n,s){return Ze(n,s)}var od=null,Pl=null,vm=!1,cd=!1,wm=!1,ta=0;function Vi(n){n!==Pl&&n.next===null&&(Pl===null?od=Pl=n:Pl=Pl.next=n),cd=!0,vm||(vm=!0,XS())}function oc(n,s){if(!wm&&cd){wm=!0;do for(var u=!1,h=od;h!==null;){if(n!==0){var b=h.pendingLanes;if(b===0)var v=0;else{var D=h.suspendedLanes,X=h.pingedLanes;v=(1<<31-tt(42|n)+1)-1,v&=b&~(D&~X),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(u=!0,jy(h,v))}else v=Bt,v=vn(h,h===dn?v:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(v&3)===0||le(h,v)||(u=!0,jy(h,v));h=h.next}while(u);wm=!1}}function YS(){ky()}function ky(){cd=vm=!1;var n=0;ta!==0&&t4()&&(n=ta);for(var s=ve(),u=null,h=od;h!==null;){var b=h.next,v=Sy(h,s);v===0?(h.next=null,u===null?od=b:u.next=b,b===null&&(Pl=u)):(u=h,(n!==0||(v&3)!==0)&&(cd=!0)),h=b}Un!==0&&Un!==5||oc(n),ta!==0&&(ta=0)}function Sy(n,s){for(var u=n.suspendedLanes,h=n.pingedLanes,b=n.expirationTimes,v=n.pendingLanes&-62914561;0<v;){var D=31-tt(v),X=1<<D,te=b[D];te===-1?((X&u)===0||(X&h)!==0)&&(b[D]=qe(X,s)):te<=s&&(n.expiredLanes|=X),v&=~X}if(s=dn,u=Bt,u=vn(n,n===s?u:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),h=n.callbackNode,u===0||n===s&&(en===2||en===9)||n.cancelPendingCommit!==null)return h!==null&&h!==null&&ut(h),n.callbackNode=null,n.callbackPriority=0;if((u&3)===0||le(n,u)){if(s=u&-u,s===n.callbackPriority)return s;switch(h!==null&&ut(h),An(u)){case 2:case 8:u=de;break;case 32:u=_e;break;case 268435456:u=Te;break;default:u=_e}return h=Cy.bind(null,n),u=Ze(u,h),n.callbackPriority=s,n.callbackNode=u,s}return h!==null&&h!==null&&ut(h),n.callbackPriority=2,n.callbackNode=null,2}function Cy(n,s){if(Un!==0&&Un!==5)return n.callbackNode=null,n.callbackPriority=0,null;var u=n.callbackNode;if(ld()&&n.callbackNode!==u)return null;var h=Bt;return h=vn(n,n===dn?h:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),h===0?null:(sy(n,h,s),Sy(n,ve()),n.callbackNode!=null&&n.callbackNode===u?Cy.bind(null,n):null)}function jy(n,s){if(ld())return null;sy(n,s,!0)}function XS(){r4(function(){(Qt&6)!==0?Ze(ne,YS):ky()})}function km(){if(ta===0){var n=_l;n===0&&(n=Kt,Kt<<=1,(Kt&261888)===0&&(Kt=256)),ta=n}return ta}function Ey(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Ur(""+n)}function Ny(n,s){var u=s.ownerDocument.createElement("input");return u.name=s.name,u.value=s.value,n.id&&u.setAttribute("form",n.id),s.parentNode.insertBefore(u,s),n=new FormData(n),u.parentNode.removeChild(u),n}function PS(n,s,u,h,b){if(s==="submit"&&u&&u.stateNode===b){var v=Ey((b[Ct]||null).action),D=h.submitter;D&&(s=(s=D[Ct]||null)?Ey(s.formAction):D.getAttribute("formAction"),s!==null&&(v=s,D=null));var X=new ui("action","action",null,h,b);n.push({event:X,listeners:[{instance:null,listener:function(){if(h.defaultPrevented){if(ta!==0){var te=D?Ny(b,D):new FormData(b);Uh(u,{pending:!0,data:te,method:b.method,action:v},null,te)}}else typeof v=="function"&&(X.preventDefault(),te=D?Ny(b,D):new FormData(b),Uh(u,{pending:!0,data:te,method:b.method,action:v},v,te))},currentTarget:b}]})}}for(var Sm=0;Sm<sh.length;Sm++){var Cm=sh[Sm],VS=Cm.toLowerCase(),WS=Cm[0].toUpperCase()+Cm.slice(1);Ni(VS,"on"+WS)}Ni(ig,"onAnimationEnd"),Ni(sg,"onAnimationIteration"),Ni(ag,"onAnimationStart"),Ni("dblclick","onDoubleClick"),Ni("focusin","onFocus"),Ni("focusout","onBlur"),Ni(uS,"onTransitionRun"),Ni(dS,"onTransitionStart"),Ni(fS,"onTransitionCancel"),Ni(lg,"onTransitionEnd"),ai("onMouseEnter",["mouseout","mouseover"]),ai("onMouseLeave",["mouseout","mouseover"]),ai("onPointerEnter",["pointerout","pointerover"]),ai("onPointerLeave",["pointerout","pointerover"]),or("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),or("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),or("onBeforeInput",["compositionend","keypress","textInput","paste"]),or("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),or("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),or("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var cc="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(cc));function Ay(n,s){s=(s&4)!==0;for(var u=0;u<n.length;u++){var h=n[u],b=h.event;h=h.listeners;e:{var v=void 0;if(s)for(var D=h.length-1;0<=D;D--){var X=h[D],te=X.instance,pe=X.currentTarget;if(X=X.listener,te!==v&&b.isPropagationStopped())break e;v=X,b.currentTarget=pe;try{v(b)}catch(ke){Cu(ke)}b.currentTarget=null,v=te}else for(D=0;D<h.length;D++){if(X=h[D],te=X.instance,pe=X.currentTarget,X=X.listener,te!==v&&b.isPropagationStopped())break e;v=X,b.currentTarget=pe;try{v(b)}catch(ke){Cu(ke)}b.currentTarget=null,v=te}}}}function Rt(n,s){var u=s[Vn];u===void 0&&(u=s[Vn]=new Set);var h=n+"__bubble";u.has(h)||(Ty(s,n,2,!1),u.add(h))}function jm(n,s,u){var h=0;s&&(h|=4),Ty(u,n,h,s)}var ud="_reactListening"+Math.random().toString(36).slice(2);function Em(n){if(!n[ud]){n[ud]=!0,gr.forEach(function(u){u!=="selectionchange"&&(GS.has(u)||jm(u,!1,n),jm(u,!0,n))});var s=n.nodeType===9?n:n.ownerDocument;s===null||s[ud]||(s[ud]=!0,jm("selectionchange",!1,s))}}function Ty(n,s,u,h){switch(ib(s)){case 2:var b=S4;break;case 8:b=C4;break;default:b=Hm}u=b.bind(null,s,u,n),b=void 0,!To||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(b=!0),h?b!==void 0?n.addEventListener(s,u,{capture:!0,passive:b}):n.addEventListener(s,u,!0):b!==void 0?n.addEventListener(s,u,{passive:b}):n.addEventListener(s,u,!1)}function Nm(n,s,u,h,b){var v=h;if((s&1)===0&&(s&2)===0&&h!==null)e:for(;;){if(h===null)return;var D=h.tag;if(D===3||D===4){var X=h.stateNode.containerInfo;if(X===b)break;if(D===4)for(D=h.return;D!==null;){var te=D.tag;if((te===3||te===4)&&D.stateNode.containerInfo===b)return;D=D.return}for(;X!==null;){if(D=$i(X),D===null)return;if(te=D.tag,te===5||te===6||te===26||te===27){h=v=D;continue e}X=X.parentNode}}h=h.return}ur(function(){var pe=v,ke=xl(u),Me=[];e:{var xe=og.get(n);if(xe!==void 0){var ye=ui,Ge=n;switch(n){case"keypress":if(Ui(u)===0)break e;case"keydown":case"keyup":ye=bu;break;case"focusin":Ge="focus",ye=vl;break;case"focusout":Ge="blur",ye=vl;break;case"beforeblur":case"afterblur":ye=vl;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":ye=Mo;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=mu;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=ku;break;case ig:case sg:case ag:ye=ds;break;case lg:ye=re;break;case"scroll":case"scrollend":ye=Gf;break;case"wheel":ye=we;break;case"copy":case"cut":case"paste":ye=Qf;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=zo;break;case"toggle":case"beforetoggle":ye=Qe}var xt=(s&4)!==0,on=!xt&&(n==="scroll"||n==="scrollend"),ue=xt?xe!==null?xe+"Capture":null:xe;xt=[];for(var se=pe,me;se!==null;){var Ne=se;if(me=Ne.stateNode,Ne=Ne.tag,Ne!==5&&Ne!==26&&Ne!==27||me===null||ue===null||(Ne=ji(se,ue),Ne!=null&&xt.push(uc(se,Ne,me))),on)break;se=se.return}0<xt.length&&(xe=new ye(xe,Ge,null,u,ke),Me.push({event:xe,listeners:xt}))}}if((s&7)===0){e:{if(xe=n==="mouseover"||n==="pointerover",ye=n==="mouseout"||n==="pointerout",xe&&u!==No&&(Ge=u.relatedTarget||u.fromElement)&&($i(Ge)||Ge[xr]))break e;if((ye||xe)&&(xe=ke.window===ke?ke:(xe=ke.ownerDocument)?xe.defaultView||xe.parentWindow:window,ye?(Ge=u.relatedTarget||u.toElement,ye=pe,Ge=Ge?$i(Ge):null,Ge!==null&&(on=o(Ge),xt=Ge.tag,Ge!==on||xt!==5&&xt!==27&&xt!==6)&&(Ge=null)):(ye=null,Ge=pe),ye!==Ge)){if(xt=Mo,Ne="onMouseLeave",ue="onMouseEnter",se="mouse",(n==="pointerout"||n==="pointerover")&&(xt=zo,Ne="onPointerLeave",ue="onPointerEnter",se="pointer"),on=ye==null?xe:si(ye),me=Ge==null?xe:si(Ge),xe=new xt(Ne,se+"leave",ye,u,ke),xe.target=on,xe.relatedTarget=me,Ne=null,$i(ke)===pe&&(xt=new xt(ue,se+"enter",Ge,u,ke),xt.target=me,xt.relatedTarget=on,Ne=xt),on=Ne,ye&&Ge)t:{for(xt=KS,ue=ye,se=Ge,me=0,Ne=ue;Ne;Ne=xt(Ne))me++;Ne=0;for(var ct=se;ct;ct=xt(ct))Ne++;for(;0<me-Ne;)ue=xt(ue),me--;for(;0<Ne-me;)se=xt(se),Ne--;for(;me--;){if(ue===se||se!==null&&ue===se.alternate){xt=ue;break t}ue=xt(ue),se=xt(se)}xt=null}else xt=null;ye!==null&&Dy(Me,xe,ye,xt,!1),Ge!==null&&on!==null&&Dy(Me,on,Ge,xt,!0)}}e:{if(xe=pe?si(pe):window,ye=xe.nodeName&&xe.nodeName.toLowerCase(),ye==="select"||ye==="input"&&xe.type==="file")var Vt=V0;else if(X0(xe))if(W0)Vt=lS;else{Vt=sS;var Je=iS}else ye=xe.nodeName,!ye||ye.toLowerCase()!=="input"||xe.type!=="checkbox"&&xe.type!=="radio"?pe&&nn(pe.elementType)&&(Vt=V0):Vt=aS;if(Vt&&(Vt=Vt(n,pe))){P0(Me,Vt,u,ke);break e}Je&&Je(n,xe,pe),n==="focusout"&&pe&&xe.type==="number"&&pe.memoizedProps.value!=null&&Os(xe,"number",xe.value)}switch(Je=pe?si(pe):window,n){case"focusin":(X0(Je)||Je.contentEditable==="true")&&(Sl=Je,nh=pe,Lo=null);break;case"focusout":Lo=nh=Sl=null;break;case"mousedown":rh=!0;break;case"contextmenu":case"mouseup":case"dragend":rh=!1,ng(Me,u,ke);break;case"selectionchange":if(cS)break;case"keydown":case"keyup":ng(Me,u,ke)}var Tt;if(pt)e:{switch(n){case"compositionstart":var $t="onCompositionStart";break e;case"compositionend":$t="onCompositionEnd";break e;case"compositionupdate":$t="onCompositionUpdate";break e}$t=void 0}else Mt?yr(n,u)&&($t="onCompositionEnd"):n==="keydown"&&u.keyCode===229&&($t="onCompositionStart");$t&&(vt&&u.locale!=="ko"&&(Mt||$t!=="onCompositionStart"?$t==="onCompositionEnd"&&Mt&&(Tt=yl()):(At=ke,Do="value"in At?At.value:At.textContent,Mt=!0)),Je=dd(pe,$t),0<Je.length&&($t=new Ro($t,n,null,u,ke),Me.push({event:$t,listeners:Je}),Tt?$t.data=Tt:(Tt=wt(u),Tt!==null&&($t.data=Tt)))),(Tt=dt?Dn(n,u):pn(n,u))&&($t=dd(pe,"onBeforeInput"),0<$t.length&&(Je=new Ro("onBeforeInput","beforeinput",null,u,ke),Me.push({event:Je,listeners:$t}),Je.data=Tt)),PS(Me,n,pe,u,ke)}Ay(Me,s)})}function uc(n,s,u){return{instance:n,listener:s,currentTarget:u}}function dd(n,s){for(var u=s+"Capture",h=[];n!==null;){var b=n,v=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||v===null||(b=ji(n,u),b!=null&&h.unshift(uc(n,b,v)),b=ji(n,s),b!=null&&h.push(uc(n,b,v))),n.tag===3)return h;n=n.return}return[]}function KS(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function Dy(n,s,u,h,b){for(var v=s._reactName,D=[];u!==null&&u!==h;){var X=u,te=X.alternate,pe=X.stateNode;if(X=X.tag,te!==null&&te===h)break;X!==5&&X!==26&&X!==27||pe===null||(te=pe,b?(pe=ji(u,v),pe!=null&&D.unshift(uc(u,pe,te))):b||(pe=ji(u,v),pe!=null&&D.push(uc(u,pe,te)))),u=u.return}D.length!==0&&n.push({event:s,listeners:D})}var QS=/\r\n?/g,ZS=/\u0000|\uFFFD/g;function _y(n){return(typeof n=="string"?n:""+n).replace(QS,`
50
- `).replace(ZS,"")}function My(n,s){return s=_y(s),_y(n)===s}function ln(n,s,u,h,b,v){switch(u){case"children":typeof h=="string"?s==="body"||s==="textarea"&&h===""||Hr(n,h):(typeof h=="number"||typeof h=="bigint")&&s!=="body"&&Hr(n,""+h);break;case"className":os(n,"class",h);break;case"tabIndex":os(n,"tabindex",h);break;case"dir":case"role":case"viewBox":case"width":case"height":os(n,u,h);break;case"style":Gn(n,h,v);break;case"data":if(s!=="object"){os(n,"data",h);break}case"src":case"href":if(h===""&&(s!=="a"||u!=="href")){n.removeAttribute(u);break}if(h==null||typeof h=="function"||typeof h=="symbol"||typeof h=="boolean"){n.removeAttribute(u);break}h=Ur(""+h),n.setAttribute(u,h);break;case"action":case"formAction":if(typeof h=="function"){n.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"&&ln(n,s,"name",b.name,b,null),ln(n,s,"formEncType",b.formEncType,b,null),ln(n,s,"formMethod",b.formMethod,b,null),ln(n,s,"formTarget",b.formTarget,b,null)):(ln(n,s,"encType",b.encType,b,null),ln(n,s,"method",b.method,b,null),ln(n,s,"target",b.target,b,null)));if(h==null||typeof h=="symbol"||typeof h=="boolean"){n.removeAttribute(u);break}h=Ur(""+h),n.setAttribute(u,h);break;case"onClick":h!=null&&(n.onclick=nr);break;case"onScroll":h!=null&&Rt("scroll",n);break;case"onScrollEnd":h!=null&&Rt("scrollend",n);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));n.innerHTML=u}}break;case"multiple":n.multiple=h&&typeof h!="function"&&typeof h!="symbol";break;case"muted":n.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"){n.removeAttribute("xlink:href");break}u=Ur(""+h),n.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"?n.setAttribute(u,""+h):n.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"?n.setAttribute(u,""):n.removeAttribute(u);break;case"capture":case"download":h===!0?n.setAttribute(u,""):h!==!1&&h!=null&&typeof h!="function"&&typeof h!="symbol"?n.setAttribute(u,h):n.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":h!=null&&typeof h!="function"&&typeof h!="symbol"&&!isNaN(h)&&1<=h?n.setAttribute(u,h):n.removeAttribute(u);break;case"rowSpan":case"start":h==null||typeof h=="function"||typeof h=="symbol"||isNaN(h)?n.removeAttribute(u):n.setAttribute(u,h);break;case"popover":Rt("beforetoggle",n),Rt("toggle",n),Lr(n,"popover",h);break;case"xlinkActuate":Cr(n,"http://www.w3.org/1999/xlink","xlink:actuate",h);break;case"xlinkArcrole":Cr(n,"http://www.w3.org/1999/xlink","xlink:arcrole",h);break;case"xlinkRole":Cr(n,"http://www.w3.org/1999/xlink","xlink:role",h);break;case"xlinkShow":Cr(n,"http://www.w3.org/1999/xlink","xlink:show",h);break;case"xlinkTitle":Cr(n,"http://www.w3.org/1999/xlink","xlink:title",h);break;case"xlinkType":Cr(n,"http://www.w3.org/1999/xlink","xlink:type",h);break;case"xmlBase":Cr(n,"http://www.w3.org/XML/1998/namespace","xml:base",h);break;case"xmlLang":Cr(n,"http://www.w3.org/XML/1998/namespace","xml:lang",h);break;case"xmlSpace":Cr(n,"http://www.w3.org/XML/1998/namespace","xml:space",h);break;case"is":Lr(n,"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=Hi.get(u)||u,Lr(n,u,h))}}function Am(n,s,u,h,b,v){switch(u){case"style":Gn(n,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));n.innerHTML=u}}break;case"children":typeof h=="string"?Hr(n,h):(typeof h=="number"||typeof h=="bigint")&&Hr(n,""+h);break;case"onScroll":h!=null&&Rt("scroll",n);break;case"onScrollEnd":h!=null&&Rt("scrollend",n);break;case"onClick":h!=null&&(n.onclick=nr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!fl.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=n[Ct]||null,v=v!=null?v[u]:null,typeof v=="function"&&n.removeEventListener(s,v,b),typeof h=="function")){typeof v!="function"&&v!==null&&(u in n?n[u]=null:n.hasAttribute(u)&&n.removeAttribute(u)),n.addEventListener(s,h,b);break e}u in n?n[u]=h:h===!0?n.setAttribute(u,""):Lr(n,u,h)}}}function ar(n,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",n),Rt("load",n);var h=!1,b=!1,v;for(v in u)if(u.hasOwnProperty(v)){var D=u[v];if(D!=null)switch(v){case"src":h=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,s));default:ln(n,s,v,D,u,null)}}b&&ln(n,s,"srcSet",u.srcSet,u,null),h&&ln(n,s,"src",u.src,u,null);return;case"input":Rt("invalid",n);var X=v=D=b=null,te=null,pe=null;for(h in u)if(u.hasOwnProperty(h)){var ke=u[h];if(ke!=null)switch(h){case"name":b=ke;break;case"type":D=ke;break;case"checked":te=ke;break;case"defaultChecked":pe=ke;break;case"value":v=ke;break;case"defaultValue":X=ke;break;case"children":case"dangerouslySetInnerHTML":if(ke!=null)throw Error(i(137,s));break;default:ln(n,s,h,ke,u,null)}}Tn(n,v,X,te,pe,D,b,!1);return;case"select":Rt("invalid",n),h=D=v=null;for(b in u)if(u.hasOwnProperty(b)&&(X=u[b],X!=null))switch(b){case"value":v=X;break;case"defaultValue":D=X;break;case"multiple":h=X;default:ln(n,s,b,X,u,null)}s=v,u=D,n.multiple=!!h,s!=null?Ci(n,!!h,s,!1):u!=null&&Ci(n,!!h,u,!0);return;case"textarea":Rt("invalid",n),v=b=h=null;for(D in u)if(u.hasOwnProperty(D)&&(X=u[D],X!=null))switch(D){case"value":h=X;break;case"defaultValue":b=X;break;case"children":v=X;break;case"dangerouslySetInnerHTML":if(X!=null)throw Error(i(91));break;default:ln(n,s,D,X,u,null)}Ir(n,h,b,v);return;case"option":for(te in u)if(u.hasOwnProperty(te)&&(h=u[te],h!=null))switch(te){case"selected":n.selected=h&&typeof h!="function"&&typeof h!="symbol";break;default:ln(n,s,te,h,u,null)}return;case"dialog":Rt("beforetoggle",n),Rt("toggle",n),Rt("cancel",n),Rt("close",n);break;case"iframe":case"object":Rt("load",n);break;case"video":case"audio":for(h=0;h<cc.length;h++)Rt(cc[h],n);break;case"image":Rt("error",n),Rt("load",n);break;case"details":Rt("toggle",n);break;case"embed":case"source":case"link":Rt("error",n),Rt("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(pe in u)if(u.hasOwnProperty(pe)&&(h=u[pe],h!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,s));default:ln(n,s,pe,h,u,null)}return;default:if(nn(s)){for(ke in u)u.hasOwnProperty(ke)&&(h=u[ke],h!==void 0&&Am(n,s,ke,h,u,void 0));return}}for(X in u)u.hasOwnProperty(X)&&(h=u[X],h!=null&&ln(n,s,X,h,u,null))}function JS(n,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,D=null,X=null,te=null,pe=null,ke=null;for(ye in u){var Me=u[ye];if(u.hasOwnProperty(ye)&&Me!=null)switch(ye){case"checked":break;case"value":break;case"defaultValue":te=Me;default:h.hasOwnProperty(ye)||ln(n,s,ye,null,h,Me)}}for(var xe in h){var ye=h[xe];if(Me=u[xe],h.hasOwnProperty(xe)&&(ye!=null||Me!=null))switch(xe){case"type":v=ye;break;case"name":b=ye;break;case"checked":pe=ye;break;case"defaultChecked":ke=ye;break;case"value":D=ye;break;case"defaultValue":X=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(i(137,s));break;default:ye!==Me&&ln(n,s,xe,ye,h,Me)}}tr(n,D,X,te,pe,ke,v,b);return;case"select":ye=D=X=xe=null;for(v in u)if(te=u[v],u.hasOwnProperty(v)&&te!=null)switch(v){case"value":break;case"multiple":ye=te;default:h.hasOwnProperty(v)||ln(n,s,v,null,h,te)}for(b in h)if(v=h[b],te=u[b],h.hasOwnProperty(b)&&(v!=null||te!=null))switch(b){case"value":xe=v;break;case"defaultValue":X=v;break;case"multiple":D=v;default:v!==te&&ln(n,s,b,v,h,te)}s=X,u=D,h=ye,xe!=null?Ci(n,!!u,xe,!1):!!h!=!!u&&(s!=null?Ci(n,!!u,s,!0):Ci(n,!!u,u?[]:"",!1));return;case"textarea":ye=xe=null;for(X in u)if(b=u[X],u.hasOwnProperty(X)&&b!=null&&!h.hasOwnProperty(X))switch(X){case"value":break;case"children":break;default:ln(n,s,X,null,h,b)}for(D in h)if(b=h[D],v=u[D],h.hasOwnProperty(D)&&(b!=null||v!=null))switch(D){case"value":xe=b;break;case"defaultValue":ye=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(i(91));break;default:b!==v&&ln(n,s,D,b,h,v)}pl(n,xe,ye);return;case"option":for(var Ge in u)if(xe=u[Ge],u.hasOwnProperty(Ge)&&xe!=null&&!h.hasOwnProperty(Ge))switch(Ge){case"selected":n.selected=!1;break;default:ln(n,s,Ge,null,h,xe)}for(te in h)if(xe=h[te],ye=u[te],h.hasOwnProperty(te)&&xe!==ye&&(xe!=null||ye!=null))switch(te){case"selected":n.selected=xe&&typeof xe!="function"&&typeof xe!="symbol";break;default:ln(n,s,te,xe,h,ye)}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 xt in u)xe=u[xt],u.hasOwnProperty(xt)&&xe!=null&&!h.hasOwnProperty(xt)&&ln(n,s,xt,null,h,xe);for(pe in h)if(xe=h[pe],ye=u[pe],h.hasOwnProperty(pe)&&xe!==ye&&(xe!=null||ye!=null))switch(pe){case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(i(137,s));break;default:ln(n,s,pe,xe,h,ye)}return;default:if(nn(s)){for(var on in u)xe=u[on],u.hasOwnProperty(on)&&xe!==void 0&&!h.hasOwnProperty(on)&&Am(n,s,on,void 0,h,xe);for(ke in h)xe=h[ke],ye=u[ke],!h.hasOwnProperty(ke)||xe===ye||xe===void 0&&ye===void 0||Am(n,s,ke,xe,h,ye);return}}for(var ue in u)xe=u[ue],u.hasOwnProperty(ue)&&xe!=null&&!h.hasOwnProperty(ue)&&ln(n,s,ue,null,h,xe);for(Me in h)xe=h[Me],ye=u[Me],!h.hasOwnProperty(Me)||xe===ye||xe==null&&ye==null||ln(n,s,Me,xe,h,ye)}function Fy(n){switch(n){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 n=0,s=0,u=performance.getEntriesByType("resource"),h=0;h<u.length;h++){var b=u[h],v=b.transferSize,D=b.initiatorType,X=b.duration;if(v&&X&&Fy(D)){for(D=0,X=b.responseEnd,h+=1;h<u.length;h++){var te=u[h],pe=te.startTime;if(pe>X)break;var ke=te.transferSize,Me=te.initiatorType;ke&&Fy(Me)&&(te=te.responseEnd,D+=ke*(te<X?1:(X-pe)/(te-pe)))}if(--h,s+=8*(v+D)/(b.duration/1e3),n++,10<n)break}}if(0<n)return s/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Tm=null,Dm=null;function fd(n){return n.nodeType===9?n:n.ownerDocument}function Ry(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function zy(n,s){if(n===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&s==="foreignObject"?0:n}function _m(n,s){return n==="textarea"||n==="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 Mm=null;function t4(){var n=window.event;return n&&n.type==="popstate"?n===Mm?!1:(Mm=n,!0):(Mm=null,!1)}var By=typeof setTimeout=="function"?setTimeout:void 0,n4=typeof clearTimeout=="function"?clearTimeout:void 0,$y=typeof Promise=="function"?Promise:void 0,r4=typeof queueMicrotask=="function"?queueMicrotask:typeof $y<"u"?function(n){return $y.resolve(null).then(n).catch(i4)}:By;function i4(n){setTimeout(function(){throw n})}function na(n){return n==="head"}function Oy(n,s){var u=s,h=0;do{var b=u.nextSibling;if(n.removeChild(u),b&&b.nodeType===8)if(u=b.data,u==="/$"||u==="/&"){if(h===0){n.removeChild(b),Kl(s);return}h--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")h++;else if(u==="html")dc(n.ownerDocument.documentElement);else if(u==="head"){u=n.ownerDocument.head,dc(u);for(var v=u.firstChild;v;){var D=v.nextSibling,X=v.nodeName;v[$r]||X==="SCRIPT"||X==="STYLE"||X==="LINK"&&v.rel.toLowerCase()==="stylesheet"||u.removeChild(v),v=D}}else u==="body"&&dc(n.ownerDocument.body);u=b}while(u);Kl(s)}function Ly(n,s){var u=n;n=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(n===0)break;n--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||n++;u=h}while(u)}function Fm(n){var s=n.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":Fm(u),Or(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}n.removeChild(u)}}function s4(n,s,u,h){for(;n.nodeType===1;){var b=u;if(n.nodeName.toLowerCase()!==s.toLowerCase()){if(!h&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(h){if(!n[$r])switch(s){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(v=n.getAttribute("rel"),v==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(v!==b.rel||n.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||n.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||n.getAttribute("title")!==(b.title==null?null:b.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(v=n.getAttribute("src"),(v!==(b.src==null?null:b.src)||n.getAttribute("type")!==(b.type==null?null:b.type)||n.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&v&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(s==="input"&&n.type==="hidden"){var v=b.name==null?null:""+b.name;if(b.type==="hidden"&&n.getAttribute("name")===v)return n}else return n;if(n=gi(n.nextSibling),n===null)break}return null}function a4(n,s,u){if(s==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!u||(n=gi(n.nextSibling),n===null))return null;return n}function Iy(n,s){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!s||(n=gi(n.nextSibling),n===null))return null;return n}function Rm(n){return n.data==="$?"||n.data==="$~"}function zm(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function l4(n,s){var u=n.ownerDocument;if(n.data==="$~")n._reactRetry=s;else if(n.data!=="$?"||u.readyState!=="loading")s();else{var h=function(){s(),u.removeEventListener("DOMContentLoaded",h)};u.addEventListener("DOMContentLoaded",h),n._reactRetry=h}}function gi(n){for(;n!=null;n=n.nextSibling){var s=n.nodeType;if(s===1||s===3)break;if(s===8){if(s=n.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return n}var Bm=null;function Hy(n){n=n.nextSibling;for(var s=0;n;){if(n.nodeType===8){var u=n.data;if(u==="/$"||u==="/&"){if(s===0)return gi(n.nextSibling);s--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||s++}n=n.nextSibling}return null}function Uy(n){n=n.previousSibling;for(var s=0;n;){if(n.nodeType===8){var u=n.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(s===0)return n;s--}else u!=="/$"&&u!=="/&"||s++}n=n.previousSibling}return null}function qy(n,s,u){switch(s=fd(u),n){case"html":if(n=s.documentElement,!n)throw Error(i(452));return n;case"head":if(n=s.head,!n)throw Error(i(453));return n;case"body":if(n=s.body,!n)throw Error(i(454));return n;default:throw Error(i(451))}}function dc(n){for(var s=n.attributes;s.length;)n.removeAttributeNode(s[0]);Or(n)}var yi=new Map,Yy=new Set;function hd(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Es=Z.d;Z.d={f:o4,r:c4,D:u4,C:d4,L:f4,m:h4,X:p4,S:m4,M:x4};function o4(){var n=Es.f(),s=id();return n||s}function c4(n){var s=Oi(n);s!==null&&s.tag===5&&s.type==="form"?l1(s):Es.r(n)}var Vl=typeof document>"u"?null:document;function Xy(n,s,u){var h=Vl;if(h&&typeof s=="string"&&s){var b=En(s);b='link[rel="'+n+'"][href="'+b+'"]',typeof u=="string"&&(b+='[crossorigin="'+u+'"]'),Yy.has(b)||(Yy.add(b),n={rel:n,crossOrigin:u,href:s},h.querySelector(b)===null&&(s=h.createElement("link"),ar(s,"link",n),wn(s),h.head.appendChild(s)))}}function u4(n){Es.D(n),Xy("dns-prefetch",n,null)}function d4(n,s){Es.C(n,s),Xy("preconnect",n,s)}function f4(n,s,u){Es.L(n,s,u);var h=Vl;if(h&&n&&s){var b='link[rel="preload"][as="'+En(s)+'"]';s==="image"&&u&&u.imageSrcSet?(b+='[imagesrcset="'+En(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(b+='[imagesizes="'+En(u.imageSizes)+'"]')):b+='[href="'+En(n)+'"]';var v=b;switch(s){case"style":v=Wl(n);break;case"script":v=Gl(n)}yi.has(v)||(n=p({rel:"preload",href:s==="image"&&u&&u.imageSrcSet?void 0:n,as:s},u),yi.set(v,n),h.querySelector(b)!==null||s==="style"&&h.querySelector(fc(v))||s==="script"&&h.querySelector(hc(v))||(s=h.createElement("link"),ar(s,"link",n),wn(s),h.head.appendChild(s)))}}function h4(n,s){Es.m(n,s);var u=Vl;if(u&&n){var h=s&&typeof s.as=="string"?s.as:"script",b='link[rel="modulepreload"][as="'+En(h)+'"][href="'+En(n)+'"]',v=b;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Gl(n)}if(!yi.has(v)&&(n=p({rel:"modulepreload",href:n},s),yi.set(v,n),u.querySelector(b)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(hc(v)))return}h=u.createElement("link"),ar(h,"link",n),wn(h),u.head.appendChild(h)}}}function m4(n,s,u){Es.S(n,s,u);var h=Vl;if(h&&n){var b=ki(h).hoistableStyles,v=Wl(n);s=s||"default";var D=b.get(v);if(!D){var X={loading:0,preload:null};if(D=h.querySelector(fc(v)))X.loading=5;else{n=p({rel:"stylesheet",href:n,"data-precedence":s},u),(u=yi.get(v))&&$m(n,u);var te=D=h.createElement("link");wn(te),ar(te,"link",n),te._p=new Promise(function(pe,ke){te.onload=pe,te.onerror=ke}),te.addEventListener("load",function(){X.loading|=1}),te.addEventListener("error",function(){X.loading|=2}),X.loading|=4,md(D,s,h)}D={type:"stylesheet",instance:D,count:1,state:X},b.set(v,D)}}}function p4(n,s){Es.X(n,s);var u=Vl;if(u&&n){var h=ki(u).hoistableScripts,b=Gl(n),v=h.get(b);v||(v=u.querySelector(hc(b)),v||(n=p({src:n,async:!0},s),(s=yi.get(b))&&Om(n,s),v=u.createElement("script"),wn(v),ar(v,"link",n),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},h.set(b,v))}}function x4(n,s){Es.M(n,s);var u=Vl;if(u&&n){var h=ki(u).hoistableScripts,b=Gl(n),v=h.get(b);v||(v=u.querySelector(hc(b)),v||(n=p({src:n,async:!0,type:"module"},s),(s=yi.get(b))&&Om(n,s),v=u.createElement("script"),wn(v),ar(v,"link",n),u.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},h.set(b,v))}}function Py(n,s,u,h){var b=(b=J.current)?hd(b):null;if(!b)throw Error(i(446));switch(n){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(s=Wl(u.href),u=ki(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"){n=Wl(u.href);var v=ki(b).hoistableStyles,D=v.get(n);if(D||(b=b.ownerDocument||b,D={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(n,D),(v=b.querySelector(fc(n)))&&!v._p&&(D.instance=v,D.state.loading=5),yi.has(n)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},yi.set(n,u),v||g4(b,n,u,D.state))),s&&h===null)throw Error(i(528,""));return D}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=ki(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,n))}}function Wl(n){return'href="'+En(n)+'"'}function fc(n){return'link[rel="stylesheet"]['+n+"]"}function Vy(n){return p({},n,{"data-precedence":n.precedence,precedence:null})}function g4(n,s,u,h){n.querySelector('link[rel="preload"][as="style"]['+s+"]")?h.loading=1:(s=n.createElement("link"),h.preload=s,s.addEventListener("load",function(){return h.loading|=1}),s.addEventListener("error",function(){return h.loading|=2}),ar(s,"link",u),wn(s),n.head.appendChild(s))}function Gl(n){return'[src="'+En(n)+'"]'}function hc(n){return"script[async]"+n}function Wy(n,s,u){if(s.count++,s.instance===null)switch(s.type){case"style":var h=n.querySelector('style[data-href~="'+En(u.href)+'"]');if(h)return s.instance=h,wn(h),h;var b=p({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return h=(n.ownerDocument||n).createElement("style"),wn(h),ar(h,"style",b),md(h,u.precedence,n),s.instance=h;case"stylesheet":b=Wl(u.href);var v=n.querySelector(fc(b));if(v)return s.state.loading|=4,s.instance=v,wn(v),v;h=Vy(u),(b=yi.get(b))&&$m(h,b),v=(n.ownerDocument||n).createElement("link"),wn(v);var D=v;return D._p=new Promise(function(X,te){D.onload=X,D.onerror=te}),ar(v,"link",h),s.state.loading|=4,md(v,u.precedence,n),s.instance=v;case"script":return v=Gl(u.src),(b=n.querySelector(hc(v)))?(s.instance=b,wn(b),b):(h=u,(b=yi.get(v))&&(h=p({},u),Om(h,b)),n=n.ownerDocument||n,b=n.createElement("script"),wn(b),ar(b,"link",h),n.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,md(h,u.precedence,n));return s.instance}function md(n,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,D=0;D<h.length;D++){var X=h[D];if(X.dataset.precedence===s)v=X;else if(v!==b)break}v?v.parentNode.insertBefore(n,v.nextSibling):(s=u.nodeType===9?u.head:u,s.insertBefore(n,s.firstChild))}function $m(n,s){n.crossOrigin==null&&(n.crossOrigin=s.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=s.referrerPolicy),n.title==null&&(n.title=s.title)}function Om(n,s){n.crossOrigin==null&&(n.crossOrigin=s.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=s.referrerPolicy),n.integrity==null&&(n.integrity=s.integrity)}var pd=null;function Gy(n,s,u){if(pd===null){var h=new Map,b=pd=new Map;b.set(u,h)}else b=pd,h=b.get(u),h||(h=new Map,b.set(u,h));if(h.has(n))return h;for(h.set(n,null),u=u.getElementsByTagName(n),b=0;b<u.length;b++){var v=u[b];if(!(v[$r]||v[ft]||n==="link"&&v.getAttribute("rel")==="stylesheet")&&v.namespaceURI!=="http://www.w3.org/2000/svg"){var D=v.getAttribute(s)||"";D=n+D;var X=h.get(D);X?X.push(v):h.set(D,[v])}}return h}function Ky(n,s,u){n=n.ownerDocument||n,n.head.insertBefore(u,s==="title"?n.querySelector("head > title"):null)}function y4(n,s,u){if(u===1||s.itemProp!=null)return!1;switch(n){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 n=s.disabled,typeof s.precedence=="string"&&n==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 Qy(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function b4(n,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(fc(b));if(v){s=v._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(n.count++,n=xd.bind(n),s.then(n,n)),u.state.loading|=4,u.instance=v,wn(v);return}v=s.ownerDocument||s,h=Vy(h),(b=yi.get(b))&&$m(h,b),v=v.createElement("link"),wn(v);var D=v;D._p=new Promise(function(X,te){D.onload=X,D.onerror=te}),ar(v,"link",h),u.instance=v}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(u,s),(s=u.state.preload)&&(u.state.loading&3)===0&&(n.count++,u=xd.bind(n),s.addEventListener("load",u),s.addEventListener("error",u))}}var Lm=0;function v4(n,s){return n.stylesheets&&n.count===0&&yd(n,n.stylesheets),0<n.count||0<n.imgCount?function(u){var h=setTimeout(function(){if(n.stylesheets&&yd(n,n.stylesheets),n.unsuspend){var v=n.unsuspend;n.unsuspend=null,v()}},6e4+s);0<n.imgBytes&&Lm===0&&(Lm=62500*e4());var b=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&yd(n,n.stylesheets),n.unsuspend)){var v=n.unsuspend;n.unsuspend=null,v()}},(n.imgBytes>Lm?50:800)+s);return n.unsuspend=u,function(){n.unsuspend=null,clearTimeout(h),clearTimeout(b)}}:null}function xd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yd(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var gd=null;function yd(n,s){n.stylesheets=null,n.unsuspend!==null&&(n.count++,gd=new Map,s.forEach(w4,n),gd=null,xd.call(n))}function w4(n,s){if(!(s.state.loading&4)){var u=gd.get(n);if(u)var h=u.get(null);else{u=new Map,gd.set(n,u);for(var b=n.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v<b.length;v++){var D=b[v];(D.nodeName==="LINK"||D.getAttribute("media")!=="not all")&&(u.set(D.dataset.precedence,D),h=D)}h&&u.set(null,h)}b=s.instance,D=b.getAttribute("data-precedence"),v=u.get(D)||h,v===h&&u.set(null,b),u.set(D,b),this.count++,h=xd.bind(this),b.addEventListener("load",h),b.addEventListener("error",h),v?v.parentNode.insertBefore(b,v.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(b,n.firstChild)),s.state.loading|=4}}var mc={$$typeof:N,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function k4(n,s,u,h,b,v,D,X,te){this.tag=1,this.containerInfo=n,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Jt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jt(0),this.hiddenUpdates=Jt(null),this.identifierPrefix=h,this.onUncaughtError=b,this.onCaughtError=v,this.onRecoverableError=D,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=te,this.incompleteTransitions=new Map}function Zy(n,s,u,h,b,v,D,X,te,pe,ke,Me){return n=new k4(n,s,u,D,te,pe,ke,Me,X),s=1,v===!0&&(s|=24),v=Xr(3,null,null,s),n.current=v,v.stateNode=n,s=yh(),s.refCount++,n.pooledCache=s,s.refCount++,v.memoizedState={element:h,isDehydrated:u,cache:s},kh(v),n}function Jy(n){return n?(n=El,n):El}function eb(n,s,u,h,b,v){b=Jy(b),h.context===null?h.context=b:h.pendingContext=b,h=Xs(s),h.payload={element:u},v=v===void 0?null:v,v!==null&&(h.callback=v),u=Ps(n,h,s),u!==null&&(Mr(u,n,s),Po(u,n,s))}function tb(n,s){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var u=n.retryLane;n.retryLane=u!==0&&u<s?u:s}}function Im(n,s){tb(n,s),(n=n.alternate)&&tb(n,s)}function nb(n){if(n.tag===13||n.tag===31){var s=Ma(n,67108864);s!==null&&Mr(s,n,67108864),Im(n,67108864)}}function rb(n){if(n.tag===13||n.tag===31){var s=Kr();s=Jn(s);var u=Ma(n,s);u!==null&&Mr(u,n,s),Im(n,s)}}var bd=!0;function S4(n,s,u,h){var b=B.T;B.T=null;var v=Z.p;try{Z.p=2,Hm(n,s,u,h)}finally{Z.p=v,B.T=b}}function C4(n,s,u,h){var b=B.T;B.T=null;var v=Z.p;try{Z.p=8,Hm(n,s,u,h)}finally{Z.p=v,B.T=b}}function Hm(n,s,u,h){if(bd){var b=Um(h);if(b===null)Nm(n,s,h,vd,u),sb(n,h);else if(E4(b,n,s,u,h))h.stopPropagation();else if(sb(n,h),s&4&&-1<j4.indexOf(n)){for(;b!==null;){var v=Oi(b);if(v!==null)switch(v.tag){case 3:if(v=v.stateNode,v.current.memoizedState.isDehydrated){var D=hn(v.pendingLanes);if(D!==0){var X=v;for(X.pendingLanes|=2,X.entangledLanes|=2;D;){var te=1<<31-tt(D);X.entanglements[1]|=te,D&=~te}Vi(v),(Qt&6)===0&&(nd=ve()+500,oc(0))}}break;case 31:case 13:X=Ma(v,2),X!==null&&Mr(X,v,2),id(),Im(v,2)}if(v=Um(h),v===null&&Nm(n,s,h,vd,u),v===b)break;b=v}b!==null&&h.stopPropagation()}else Nm(n,s,h,null,u)}}function Um(n){return n=xl(n),qm(n)}var vd=null;function qm(n){if(vd=null,n=$i(n),n!==null){var s=o(n);if(s===null)n=null;else{var u=s.tag;if(u===13){if(n=c(s),n!==null)return n;n=null}else if(u===31){if(n=d(s),n!==null)return n;n=null}else if(u===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;n=null}else s!==n&&(n=null)}}return vd=n,null}function ib(n){switch(n){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ce()){case ne:return 2;case de:return 8;case _e:case ce:return 32;case Te:return 268435456;default:return 32}default:return 32}}var Ym=!1,ra=null,ia=null,sa=null,pc=new Map,xc=new Map,aa=[],j4="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 sb(n,s){switch(n){case"focusin":case"focusout":ra=null;break;case"dragenter":case"dragleave":ia=null;break;case"mouseover":case"mouseout":sa=null;break;case"pointerover":case"pointerout":pc.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":xc.delete(s.pointerId)}}function gc(n,s,u,h,b,v){return n===null||n.nativeEvent!==v?(n={blockedOn:s,domEventName:u,eventSystemFlags:h,nativeEvent:v,targetContainers:[b]},s!==null&&(s=Oi(s),s!==null&&nb(s)),n):(n.eventSystemFlags|=h,s=n.targetContainers,b!==null&&s.indexOf(b)===-1&&s.push(b),n)}function E4(n,s,u,h,b){switch(s){case"focusin":return ra=gc(ra,n,s,u,h,b),!0;case"dragenter":return ia=gc(ia,n,s,u,h,b),!0;case"mouseover":return sa=gc(sa,n,s,u,h,b),!0;case"pointerover":var v=b.pointerId;return pc.set(v,gc(pc.get(v)||null,n,s,u,h,b)),!0;case"gotpointercapture":return v=b.pointerId,xc.set(v,gc(xc.get(v)||null,n,s,u,h,b)),!0}return!1}function ab(n){var s=$i(n.target);if(s!==null){var u=o(s);if(u!==null){if(s=u.tag,s===13){if(s=c(u),s!==null){n.blockedOn=s,Ie(n.priority,function(){rb(u)});return}}else if(s===31){if(s=d(u),s!==null){n.blockedOn=s,Ie(n.priority,function(){rb(u)});return}}else if(s===3&&u.stateNode.current.memoizedState.isDehydrated){n.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}n.blockedOn=null}function wd(n){if(n.blockedOn!==null)return!1;for(var s=n.targetContainers;0<s.length;){var u=Um(n.nativeEvent);if(u===null){u=n.nativeEvent;var h=new u.constructor(u.type,u);No=h,u.target.dispatchEvent(h),No=null}else return s=Oi(u),s!==null&&nb(s),n.blockedOn=u,!1;s.shift()}return!0}function lb(n,s,u){wd(n)&&u.delete(s)}function N4(){Ym=!1,ra!==null&&wd(ra)&&(ra=null),ia!==null&&wd(ia)&&(ia=null),sa!==null&&wd(sa)&&(sa=null),pc.forEach(lb),xc.forEach(lb)}function kd(n,s){n.blockedOn===s&&(n.blockedOn=null,Ym||(Ym=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,N4)))}var Sd=null;function ob(n){Sd!==n&&(Sd=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Sd===n&&(Sd=null);for(var s=0;s<n.length;s+=3){var u=n[s],h=n[s+1],b=n[s+2];if(typeof h!="function"){if(qm(h||u)===null)continue;break}var v=Oi(u);v!==null&&(n.splice(s,3),s-=3,Uh(v,{pending:!0,data:b,method:u.method,action:h},h,b))}}))}function Kl(n){function s(te){return kd(te,n)}ra!==null&&kd(ra,n),ia!==null&&kd(ia,n),sa!==null&&kd(sa,n),pc.forEach(s),xc.forEach(s);for(var u=0;u<aa.length;u++){var h=aa[u];h.blockedOn===n&&(h.blockedOn=null)}for(;0<aa.length&&(u=aa[0],u.blockedOn===null);)ab(u),u.blockedOn===null&&aa.shift();if(u=(n.ownerDocument||n).$$reactFormReplay,u!=null)for(h=0;h<u.length;h+=3){var b=u[h],v=u[h+1],D=b[Ct]||null;if(typeof v=="function")D||ob(u);else if(D){var X=null;if(v&&v.hasAttribute("formAction")){if(b=v,D=v[Ct]||null)X=D.formAction;else if(qm(b)!==null)continue}else X=D.action;typeof X=="function"?u[h+1]=X:(u.splice(h,3),h-=3),ob(u)}}}function cb(){function n(v){v.canIntercept&&v.info==="react-transition"&&v.intercept({handler:function(){return new Promise(function(D){return b=D})},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",n),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(u,100),function(){h=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),b!==null&&(b(),b=null)}}}function Xm(n){this._internalRoot=n}Cd.prototype.render=Xm.prototype.render=function(n){var s=this._internalRoot;if(s===null)throw Error(i(409));var u=s.current,h=Kr();eb(u,h,n,s,null,null)},Cd.prototype.unmount=Xm.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var s=n.containerInfo;eb(n.current,2,null,n,null,null),id(),s[xr]=null}};function Cd(n){this._internalRoot=n}Cd.prototype.unstable_scheduleHydration=function(n){if(n){var s=ie();n={blockedOn:null,target:n,priority:s};for(var u=0;u<aa.length&&s!==0&&s<aa[u].priority;u++);aa.splice(u,0,n),u===0&&ab(n)}};var ub=t.version;if(ub!=="19.2.4")throw Error(i(527,ub,"19.2.4"));Z.findDOMNode=function(n){var s=n._reactInternals;if(s===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=f(s),n=n!==null?x(n):null,n=n===null?null:n.stateNode,n};var A4={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jd.isDisabled&&jd.supportsFiber)try{Ue=jd.inject(A4),Pe=jd}catch{}}return bc.createRoot=function(n,s){if(!a(n))throw Error(i(299));var u=!1,h="",b=g1,v=y1,D=b1;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&&(D=s.onRecoverableError)),s=Zy(n,1,!1,null,null,u,h,null,b,v,D,cb),n[xr]=s.current,Em(n),new Xm(s)},bc.hydrateRoot=function(n,s,u){if(!a(n))throw Error(i(299));var h=!1,b="",v=g1,D=y1,X=b1,te=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&&(D=u.onCaughtError),u.onRecoverableError!==void 0&&(X=u.onRecoverableError),u.formState!==void 0&&(te=u.formState)),s=Zy(n,1,!0,s,u??null,h,b,te,v,D,X,cb),s.context=Jy(null),u=s.current,h=Kr(),h=Jn(h),b=Xs(h),b.callback=null,Ps(u,b,h),u=h,s.current.lanes=u,je(s,u),Vi(s),n[xr]=s.current,Em(n),new Cd(s)},bc.version="19.2.4",bc}var wb;function I4(){if(wb)return Wm.exports;wb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wm.exports=L4(),Wm.exports}var H4=I4();const U4="modulepreload",q4=function(e){return"/"+e},kb={},qx=function(t,r,i){let a=Promise.resolve();if(r&&r.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(r.map(f=>{if(f=q4(f),f in kb)return;kb[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,k)=>{y.addEventListener("load",g),y.addEventListener("error",()=>k(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);db(this,"state",{hasError:!1,error:null})}static getDerivedStateFromError(r){return{hasError:!0,error:r}}render(){var r;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:((r=this.state.error)==null?void 0:r.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 Ji="/api";async function It(e){const t=await fetch(`${Ji}${e}`);if(!t.ok)throw new Error(`API error: ${t.status}`);return t.json()}async function cn(e,t){const r=await fetch(`${Ji}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`API error: ${r.status}`);return r.json()}async function Ed(e,t){const r=await fetch(`${Ji}${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`API error: ${r.status}`);return r.json()}async function X4(e,t){const r=await fetch(`${Ji}${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`API error: ${r.status}`);return r.json()}async function Ns(e,t){const r={method:"DELETE"};t!==void 0&&(r.headers={"Content-Type":"application/json"},r.body=JSON.stringify(t));const i=await fetch(`${Ji}${e}`,r);if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}const Se={getCompany:()=>It("/company"),getRoles:()=>It("/roles"),getRole:e=>It(`/roles/${e}`),getProjects:()=>It("/projects"),getProject:e=>It(`/projects/${e}`),getStandups:()=>It("/operations/standups"),getWaves:()=>It("/operations/waves"),getActiveWaves:()=>It("/waves/active"),getWaveDetail:e=>It(`/operations/waves/${e}`),patchWave:(e,t)=>Ed(`/operations/waves/${e}`,t),getDecisions:()=>It("/operations/decisions"),updateDecision:(e,t)=>X4(`/operations/decisions/${e}`,{content:t}),deleteDecision:e=>Ns(`/operations/decisions/${e}`),getOrgTree:()=>It("/engine/org"),getSkills:()=>It("/skills"),exportSkills:e=>It(`/skills/export/${e}`),getSkillRegistry:()=>It("/skills/registry"),installRegistrySkill:(e,t)=>cn("/skills/registry/install",{skillId:e,url:t}),createRole:e=>cn("/engine/roles",e),updateRole:(e,t)=>Ed(`/engine/roles/${e}`,t),deleteRole:e=>Ns(`/engine/roles/${e}`),getSessions:()=>It("/sessions"),getSession:e=>It(`/sessions/${e}`),createSession:(e,t="talk")=>cn("/sessions",{roleId:e,mode:t}),deleteSession:e=>Ns(`/sessions/${e}`),deleteSessions:e=>Ns("/sessions",{ids:e}),deleteEmptySessions:()=>Ns("/sessions?empty=true"),updateSession:(e,t)=>Ed(`/sessions/${e}`,t),abortSession:e=>cn(`/sessions/${e}/abort`,{}),abortExec:e=>cn(`/jobs/${e}/abort`,{}),replyToSession:(e,t,r)=>cn(`/sessions/${e}/reply`,{message:t,...r&&{attachments:r}}),execute:e=>cn("/jobs",e),saveWave:e=>cn("/waves/save",e),getStatus:()=>It("/status"),detectEngine:()=>cn("/setup/detect-engine",{}),validatePath:e=>cn("/setup/validate-path",{path:e}),scaffold:e=>cn("/setup/scaffold",e),getTeams:()=>It("/setup/teams"),browse:e=>cn("/setup/browse",{path:e}),mkdir:(e,t)=>cn("/setup/mkdir",{path:e,name:t}),connectAkb:e=>cn("/setup/connect-akb",{path:e}),getRequiredTools:e=>cn("/setup/required-tools",{team:e}),installTools:(e,t)=>fetch(`${Ji}/setup/install-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({team:e})}).then(r=>{var d;const i=(d=r.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:()=>It("/knowledge"),getKnowledgeDoc:e=>{const t=e.split("/").map(encodeURIComponent).join("/");return It(`/knowledge/${t}`)},createKnowledgeDoc:e=>cn("/knowledge",e),updateKnowledgeDoc:(e,t)=>{const r=e.split("/").map(encodeURIComponent).join("/");return fetch(`${Ji}/knowledge/${r}`,{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 Ns(`/knowledge/${t}`)},getKnowledgeHealth:()=>It("/knowledge/health"),getPreferences:()=>It("/preferences"),updatePreferences:e=>Ed("/preferences",e),chatInChannel:e=>cn("/speech/chat",e),getSaveStatus:(e="akb")=>It(`/save/status?repo=${e}`),save:(e,t="akb")=>cn(`/save?repo=${t}`,{message:e}),getSaveHistory:(e=20,t="akb")=>It(`/save/history?limit=${e}&repo=${t}`),restoreSave:(e,t,r="akb")=>cn(`/save/restore?repo=${r}`,{sha:e,paths:t}),initGit:(e="akb")=>cn(`/save/init?repo=${e}`,{}),getSyncStatus:(e="akb")=>It(`/save/sync-status?repo=${e}`),pull:async(e="akb")=>await(await fetch(`${Ji}/save/pull?repo=${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json(),getGithubStatus:(e="akb")=>It(`/save/github-status?repo=${e}`),githubCreateRepo:(e,t="private",r="akb")=>cn(`/save/github-create-repo?repo=${r}`,{name:e,visibility:t}),addRemote:(e,t="akb")=>cn(`/save/remote?repo=${t}`,{url:e}),setCodeRoot:async e=>{const t=await fetch(`${Ji}/setup/code-root`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({codeRoot:e})}),r=await t.json();if(!t.ok)throw new Error(r.error||`API error: ${t.status}`);return r},getCodeRoot:()=>It("/setup/code-root"),getCostSummary:()=>It("/cost/summary"),getSyncRoles:()=>It("/sync/roles"),applySyncUpdate:e=>cn("/sync/apply",e),getCompanyStats:()=>It("/sync/stats"),getCoins:()=>It("/coins"),earnCoins:(e,t,r)=>cn("/coins/earn",{amount:e,reason:t,ref:r}),spendCoins:(e,t,r)=>cn("/coins/spend",{amount:e,reason:t,ref:r}),migrateCoins:e=>cn("/coins/migrate",{completedQuests:e}),getQuestProgress:()=>It("/quests/progress"),saveQuestProgress:e=>fetch(`${Ji}/quests/progress`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>t.json()),getActiveSessions:()=>It("/active-sessions"),getActiveSession:e=>It(`/active-sessions/${e}`),registerActiveSession:e=>cn("/active-sessions/register",e),deleteActiveSession:e=>Ns(`/active-sessions/${e}`),cleanupActiveSessions:()=>cn("/active-sessions/cleanup",{}),getGitStatus:(e="akb")=>It(`/git/status?repo=${e}`),deleteWorktree:(e,t="akb")=>Ns(`/git/worktrees/${encodeURIComponent(e)}?repo=${t}`),deleteBranch:(e,t="akb")=>Ns(`/git/branches/${encodeURIComponent(e)}?repo=${t}`)},P4=Object.freeze(Object.defineProperty({__proto__:null,api:Se},Symbol.toStringTag,{value:"Module"}));function Qn(e){return e==="working"||e==="awaiting_input"}function g2(e){return e==="streaming"||e==="awaiting_input"}function ba(e){return e==="streaming"||e==="awaiting_input"}function y2(e){const[t,r]=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 j;if(!e)return;(j=x.current)==null||j.abort();const k=new AbortController;x.current=k,a("connecting");const w=f.current+1,C=`/api/sessions/${e}/stream?from=${w}`;fetch(C,{signal:k.signal}).then(async E=>{if(!E.ok||!E.body){a("error");return}a("streaming");const N=E.body.getReader(),A=new TextDecoder;let z="";for(;;){const{done:T,value:F}=await N.read();if(T)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 O=_;O.seq>f.current&&(f.current=O.seq),r(P=>P.some(R=>R.seq===O.seq)?P:[...P,O]),O.type==="text"&&c(P=>P+(O.data.text??"")),O.type==="dispatch:start"&&O.data.childSessionId&&m(P=>[...P,O.data.childSessionId]),O.type==="msg:done"?a("done"):O.type==="msg:error"&&a("error")}else if(V==="stream:end"){const O=_.reason;a(O==="done"?"done":O==="error"?"error":"done")}}catch{}V=""}}i==="streaming"&&a("done")}).catch(E=>{E.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){r([]),a("idle"),c(""),m([]),f.current=-1;return}return r([]),c(""),m([]),f.current=-1,p.current=0,y(),()=>{var k;(k=x.current)==null||k.abort()}},[e,y]),{events:t,status:i,textOutput:o,childSessionIds:d,reconnect:g}}function V4(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.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 Sb(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 tu{constructor(t,r,i){this.normal=r,this.property=t,i&&(this.space=i)}}tu.prototype.normal={};tu.prototype.property={};tu.prototype.space=void 0;function b2(e,t){const r={},i={};for(const a of e)Object.assign(r,a.property),Object.assign(i,a.normal);return new tu(r,i,t)}function Zp(e){return e.toLowerCase()}class Br{constructor(t,r){this.attribute=r,this.property=t}}Br.prototype.attribute="";Br.prototype.booleanish=!1;Br.prototype.boolean=!1;Br.prototype.commaOrSpaceSeparated=!1;Br.prototype.commaSeparated=!1;Br.prototype.defined=!1;Br.prototype.mustUseProperty=!1;Br.prototype.number=!1;Br.prototype.overloadedBoolean=!1;Br.prototype.property="";Br.prototype.spaceSeparated=!1;Br.prototype.space=void 0;let J4=0;const Dt=ul(),Ln=ul(),Jp=ul(),Oe=ul(),xn=ul(),so=ul(),Qr=ul();function ul(){return 2**++J4}const ex=Object.freeze(Object.defineProperty({__proto__:null,boolean:Dt,booleanish:Ln,commaOrSpaceSeparated:Qr,commaSeparated:so,number:Oe,overloadedBoolean:Jp,spaceSeparated:xn},Symbol.toStringTag,{value:"Module"})),Zm=Object.keys(ex);class Yx extends Br{constructor(t,r,i,a){let o=-1;if(super(t,r),jb(this,"space",a),typeof i=="number")for(;++o<Zm.length;){const c=Zm[o];jb(this,Zm[o],(i&ex[c])===ex[c])}}}Yx.prototype.defined=!0;function jb(e,t,r){r&&(e[t]=r)}function ko(e){const t={},r={};for(const[i,a]of Object.entries(e.properties)){const o=new Yx(i,e.transform(e.attributes||{},i),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),t[i]=o,r[Zp(i)]=i,r[Zp(o.attribute)]=i}return new tu(t,r,e.space)}const v2=ko({properties:{ariaActiveDescendant:null,ariaAtomic:Ln,ariaAutoComplete:null,ariaBusy:Ln,ariaChecked:Ln,ariaColCount:Oe,ariaColIndex:Oe,ariaColSpan:Oe,ariaControls:xn,ariaCurrent:null,ariaDescribedBy:xn,ariaDetails:null,ariaDisabled:Ln,ariaDropEffect:xn,ariaErrorMessage:null,ariaExpanded:Ln,ariaFlowTo:xn,ariaGrabbed:Ln,ariaHasPopup:null,ariaHidden:Ln,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:xn,ariaLevel:Oe,ariaLive:null,ariaModal:Ln,ariaMultiLine:Ln,ariaMultiSelectable:Ln,ariaOrientation:null,ariaOwns:xn,ariaPlaceholder:null,ariaPosInSet:Oe,ariaPressed:Ln,ariaReadOnly:Ln,ariaRelevant:null,ariaRequired:Ln,ariaRoleDescription:xn,ariaRowCount:Oe,ariaRowIndex:Oe,ariaRowSpan:Oe,ariaSelected:Ln,ariaSetSize:Oe,ariaSort:null,ariaValueMax:Oe,ariaValueMin:Oe,ariaValueNow:Oe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function w2(e,t){return t in e?e[t]:t}function k2(e,t){return w2(e,t.toLowerCase())}const eC=ko({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:so,acceptCharset:xn,accessKey:xn,action:null,allow:null,allowFullScreen:Dt,allowPaymentRequest:Dt,allowUserMedia:Dt,alt:null,as:null,async:Dt,autoCapitalize:null,autoComplete:xn,autoFocus:Dt,autoPlay:Dt,blocking:xn,capture:null,charSet:null,checked:Dt,cite:null,className:xn,cols:Oe,colSpan:null,content:null,contentEditable:Ln,controls:Dt,controlsList:xn,coords:Oe|so,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Dt,defer:Dt,dir:null,dirName:null,disabled:Dt,download:Jp,draggable:Ln,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Dt,formTarget:null,headers:xn,height:Oe,hidden:Jp,high:Oe,href:null,hrefLang:null,htmlFor:xn,httpEquiv:xn,id:null,imageSizes:null,imageSrcSet:null,inert:Dt,inputMode:null,integrity:null,is:null,isMap:Dt,itemId:null,itemProp:xn,itemRef:xn,itemScope:Dt,itemType:xn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Dt,low:Oe,manifest:null,max:null,maxLength:Oe,media:null,method:null,min:null,minLength:Oe,multiple:Dt,muted:Dt,name:null,nonce:null,noModule:Dt,noValidate:Dt,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:Dt,optimum:Oe,pattern:null,ping:xn,placeholder:null,playsInline:Dt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Dt,referrerPolicy:null,rel:xn,required:Dt,reversed:Dt,rows:Oe,rowSpan:Oe,sandbox:xn,scope:null,scoped:Dt,seamless:Dt,selected:Dt,shadowRootClonable:Dt,shadowRootDelegatesFocus:Dt,shadowRootMode:null,shape:null,size:Oe,sizes:null,slot:null,span:Oe,spellCheck:Ln,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Oe,step:null,style:null,tabIndex:Oe,target:null,title:null,translate:null,type:null,typeMustMatch:Dt,useMap:null,value:Ln,width:Oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:xn,axis:null,background:null,bgColor:null,border:Oe,borderColor:null,bottomMargin:Oe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Dt,declare:Dt,event:null,face:null,frame:null,frameBorder:null,hSpace:Oe,leftMargin:Oe,link:null,longDesc:null,lowSrc:null,marginHeight:Oe,marginWidth:Oe,noResize:Dt,noHref:Dt,noShade:Dt,noWrap:Dt,object:null,profile:null,prompt:null,rev:null,rightMargin:Oe,rules:null,scheme:null,scrolling:Ln,standby:null,summary:null,text:null,topMargin:Oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Oe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Dt,disableRemotePlayback:Dt,prefix:null,property:null,results:Oe,security:null,unselectable:null},space:"html",transform:k2}),tC=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:Oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Oe,amplitude:Oe,arabicForm:null,ascent:Oe,attributeName:null,attributeType:null,azimuth:Oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Oe,by:null,calcMode:null,capHeight:Oe,className:xn,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:Oe,diffuseConstant:Oe,direction:null,display:null,dur:null,divisor:Oe,dominantBaseline:null,download:Dt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Oe,enableBackground:null,end:null,event:null,exponent:Oe,externalResourcesRequired:null,fill:null,fillOpacity:Oe,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:Oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Oe,horizOriginX:Oe,horizOriginY:Oe,id:null,ideographic:Oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Oe,k:Oe,k1:Oe,k2:Oe,k3:Oe,k4:Oe,kernelMatrix:Qr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Oe,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:Oe,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:Oe,overlineThickness:Oe,paintOrder:null,panose1:null,path:null,pathLength:Oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:xn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Oe,pointsAtY:Oe,pointsAtZ:Oe,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:Oe,specularExponent:Oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Oe,strikethroughThickness:Oe,string:null,stroke:null,strokeDashArray:Qr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Oe,strokeOpacity:Oe,strokeWidth:null,style:null,surfaceScale:Oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Qr,tabIndex:Oe,tableValues:null,target:null,targetX:Oe,targetY:Oe,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:Oe,underlineThickness:Oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Oe,values:null,vAlphabetic:Oe,vMathematical:Oe,vectorEffect:null,vHanging:Oe,vIdeographic:Oe,version:null,vertAdvY:Oe,vertOriginX:Oe,vertOriginY:Oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:w2}),S2=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:k2}),j2=ko({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nC={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"},rC=/[A-Z]/g,Eb=/-[a-z]/g,iC=/^data[-\w.:]+$/i;function sC(e,t){const r=Zp(t);let i=t,a=Br;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&iC.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Eb,lC);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Eb.test(o)){let c=o.replace(rC,aC);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Yx}return new a(i,t)}function aC(e){return"-"+e.toLowerCase()}function lC(e){return e.charAt(1).toUpperCase()}const oC=b2([v2,eC,S2,C2,j2],"html"),Xx=b2([v2,tC,S2,C2,j2],"svg");function cC(e){return e.join(" ").trim()}var Ql={},Jm,Nb;function uC(){if(Nb)return Jm;Nb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\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 k(C,j){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];j=j||{};var E=1,N=1;function A(R){var H=R.match(t);H&&(E+=H.length);var B=R.lastIndexOf(m);N=~B?R.length-B:N+R.length}function z(){var R={line:E,column:N};return function(H){return H.position=new T(R),V(),H}}function T(R){this.start=R,this.end={line:E,column:N},this.source=j.source}T.prototype.content=C;function F(R){var H=new Error(j.source+":"+E+":"+N+": "+R);if(H.reason=R,H.filename=j.source,H.line=E,H.column=N,H.source=C,!j.silent)throw H}function q(R){var H=R.exec(C);if(H){var B=H[0];return A(B),C=C.slice(B.length),H}}function V(){q(r)}function L(R){var H;for(R=R||[];H=_();)H!==!1&&R.push(H);return R}function _(){var R=z();if(!(f!=C.charAt(0)||x!=C.charAt(1))){for(var H=2;p!=C.charAt(H)&&(x!=C.charAt(H)||f!=C.charAt(H+1));)++H;if(H+=2,p===C.charAt(H-1))return F("End of comment missing");var B=C.slice(2,H-2);return N+=2,A(B),C=C.slice(H),N+=2,R({type:y,comment:B})}}function O(){var R=z(),H=q(i);if(H){if(_(),!q(a))return F("property missing ':'");var B=q(o),Z=R({type:g,property:w(H[0].replace(e,p)),value:B?w(B[0].replace(e,p)):p});return q(c),Z}}function P(){var R=[];L(R);for(var H;H=O();)H!==!1&&(R.push(H),L(R));return R}return V(),P()}function w(C){return C?C.replace(d,p):p}return Jm=k,Jm}var Ab;function dC(){if(Ab)return Ql;Ab=1;var e=Ql&&Ql.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ql,"__esModule",{value:!0}),Ql.default=r;const t=e(uC());function r(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 vc={},Tb;function fC(){if(Tb)return vc;Tb=1,Object.defineProperty(vc,"__esModule",{value:!0}),vc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(f){return!f||r.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 vc.camelCase=m,vc}var wc,Db;function hC(){if(Db)return wc;Db=1;var e=wc&&wc.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(dC()),r=fC();function i(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(d,m){d&&m&&(c[(0,r.camelCase)(d,o)]=m)}),c}return i.default=i,wc=i,wc}var mC=hC();const pC=_f(mC),E2=N2("end"),Px=N2("start");function N2(e){return t;function t(r){const i=r&&r.position&&r.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 xC(e){const t=Px(e),r=E2(e);if(t&&r)return{start:t,end:r}}function zc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?_b(e.position):"start"in e||"end"in e?_b(e):"line"in e||"column"in e?tx(e):""}function tx(e){return Mb(e&&e.line)+":"+Mb(e&&e.column)}function _b(e){return tx(e&&e.start)+"-"+tx(e&&e.end)}function Mb(e){return e&&typeof e=="number"?e:1}class pr extends Error{constructor(t,r,i){super(),typeof r=="string"&&(i=r,r=void 0);let a="",o={},c=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),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=zc(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}}pr.prototype.file="";pr.prototype.name="";pr.prototype.reason="";pr.prototype.message="";pr.prototype.stack="";pr.prototype.column=void 0;pr.prototype.line=void 0;pr.prototype.ancestors=void 0;pr.prototype.cause=void 0;pr.prototype.fatal=void 0;pr.prototype.place=void 0;pr.prototype.ruleId=void 0;pr.prototype.source=void 0;const Vx={}.hasOwnProperty,gC=new Map,yC=/[A-Z]/g,bC=new Set(["table","tbody","thead","tfoot","tr"]),vC=new Set(["td","th"]),A2="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wC(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=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=TC(r,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=AC(r,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:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Xx:oC,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,r){if(t.type==="element")return kC(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return SC(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return jC(e,t,r);if(t.type==="mdxjsEsm")return CC(e,t);if(t.type==="root")return EC(e,t,r);if(t.type==="text")return NC(e,t)}function kC(e,t,r){const i=e.schema;let a=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(a=Xx,e.schema=a),e.ancestors.push(t);const o=_2(e,t.tagName,!1),c=DC(e,t);let d=Gx(e,t);return bC.has(t.tagName)&&(d=d.filter(function(m){return typeof m=="string"?!Z4(m):!0})),D2(e,c,o,t),Wx(c,d),e.ancestors.pop(),e.schema=i,e.create(t,o,c,r)}function SC(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)}Hc(e,t.position)}function CC(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Hc(e,t.position)}function jC(e,t,r){const i=e.schema;let a=i;t.name==="svg"&&i.space==="html"&&(a=Xx,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:_2(e,t.name,!0),c=_C(e,t),d=Gx(e,t);return D2(e,c,o,t),Wx(c,d),e.ancestors.pop(),e.schema=i,e.create(t,o,c,r)}function EC(e,t,r){const i={};return Wx(i,Gx(e,t)),e.create(t,e.Fragment,i,r)}function NC(e,t){return t.value}function D2(e,t,r,i){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=i)}function Wx(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function AC(e,t,r){return i;function i(a,o,c,d){const f=Array.isArray(c.children)?r:t;return d?f(o,c,d):f(o,c)}}function TC(e,t){return r;function r(i,a,o,c){const d=Array.isArray(o.children),m=Px(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 DC(e,t){const r={};let i,a;for(a in t.properties)if(a!=="children"&&Vx.call(t.properties,a)){const o=MC(e,a,t.properties[a]);if(o){const[c,d]=o;e.tableCellAlignToStyle&&c==="align"&&typeof d=="string"&&vC.has(t.tagName)?i=d:r[c]=d}}if(i){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return r}function _C(e,t){const r={};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(r,e.evaluater.evaluateExpression(d.argument))}else Hc(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 Hc(e,t.position);else o=i.value===null?!0:i.value;r[a]=o}return r}function Gx(e,t){const r=[];let i=-1;const a=e.passKeys?new Map:gC;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&&r.push(d)}return r}function MC(e,t,r){const i=sC(e.schema,t);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=i.commaSeparated?V4(r):cC(r)),i.property==="style"){let a=typeof r=="object"?r:FC(e,String(r));return e.stylePropertyNameCase==="css"&&(a=RC(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&i.space?nC[i.property]||i.property:i.attribute,r]}}function FC(e,t){try{return pC(t,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};const i=r,a=new pr("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=A2+"#cannot-parse-style-attribute",a}}function _2(e,t,r){let i;if(!r)i={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,c;for(;++o<a.length;){const d=Sb(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=Sb(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(i.type==="Literal"){const a=i.value;return Vx.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(i);Hc(e)}function Hc(e,t){const r=new pr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=A2+"#cannot-handle-mdx-estrees-without-createevaluater",r}function RC(e){const t={};let r;for(r in e)Vx.call(e,r)&&(t[zC(r)]=e[r]);return t}function zC(e){let t=e.replace(yC,BC);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function BC(e){return"-"+e.toLowerCase()}const ep={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"]},$C={};function Kx(e,t){const r=$C,i=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,a=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return M2(e,i,a)}function M2(e,t,r){if(OC(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Fb(e.children,t,r)}return Array.isArray(e)?Fb(e,t,r):""}function Fb(e,t,r){const i=[];let a=-1;for(;++a<e.length;)i[a]=M2(e[a],t,r);return i.join("")}function OC(e){return!!(e&&typeof e=="object")}const Rb=document.createElement("i");function Qx(e){const t="&"+e+";";Rb.innerHTML=t;const r=Rb.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===t?!1:r}function ni(e,t,r,i){const a=e.length;let o=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,r=r>0?r:0,i.length<1e4)c=Array.from(i),c.unshift(t,r),e.splice(...c);else for(r&&e.splice(t,r);o<i.length;)c=i.slice(o,o+1e4),c.unshift(t,0),e.splice(...c),o+=1e4,t+=1e4}function bi(e,t){return e.length>0?(ni(e,e.length,0,t),e):t}const zb={}.hasOwnProperty;function F2(e){const t={};let r=-1;for(;++r<e.length;)LC(t,e[r]);return t}function LC(e,t){let r;for(r in t){const a=(zb.call(e,r)?e[r]:void 0)||(e[r]={}),o=t[r];let c;if(o)for(c in o){zb.call(a,c)||(a[c]=[]);const d=o[c];IC(a[c],Array.isArray(d)?d:d?[d]:[])}}}function IC(e,t){let r=-1;const i=[];for(;++r<t.length;)(t[r].add==="after"?e:i).push(t[r]);ni(e,0,0,i)}function R2(e,t){const r=Number.parseInt(e,t);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function zi(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const vr=ka(/[A-Za-z]/),mr=ka(/[\dA-Za-z]/),HC=ka(/[#-'*+\--9=?A-Z^-~]/);function uf(e){return e!==null&&(e<32||e===127)}const nx=ka(/\d/),UC=ka(/[\dA-Fa-f]/),qC=ka(/[!-/:-@[-`{-~]/);function ht(e){return e!==null&&e<-2}function fn(e){return e!==null&&(e<0||e===32)}function zt(e){return e===-2||e===-1||e===32}const Mf=ka(new RegExp("\\p{P}|\\p{S}","u")),sl=ka(/\s/);function ka(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function So(e){const t=[];let r=-1,i=0,a=0;for(;++r<e.length;){const o=e.charCodeAt(r);let c="";if(o===37&&mr(e.charCodeAt(r+1))&&mr(e.charCodeAt(r+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(r+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,r),encodeURIComponent(c)),i=r+a+1,c=""),a&&(r+=a,a=0)}return t.join("")+e.slice(i)}function Ht(e,t,r,i){const a=i?i-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(m){return zt(m)?(e.enter(r),d(m)):t(m)}function d(m){return zt(m)&&o++<a?(e.consume(m),d):(e.exit(r),t(m))}}const YC={tokenize:XC};function XC(e){const t=e.attempt(this.parser.constructs.contentInitial,i,a);let r;return t;function i(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Ht(e,t,"linePrefix")}function a(d){return e.enter("paragraph"),o(d)}function o(d){const m=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=m),r=m,c(d)}function c(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return ht(d)?(e.consume(d),e.exit("chunkText"),o):(e.consume(d),c)}}const PC={tokenize:VC},Bb={tokenize:WC};function VC(e){const t=this,r=[];let i=0,a,o,c;return d;function d(N){if(i<r.length){const A=r[i];return t.containerState=A[1],e.attempt(A[0].continuation,m,f)(N)}return f(N)}function m(N){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&E();const A=t.events.length;let z=A,T;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){T=t.events[z][1].end;break}j(i);let F=A;for(;F<t.events.length;)t.events[F][1].end={...T},F++;return ni(t.events,z+1,0,t.events.slice(A)),t.events.length=F,f(N)}return d(N)}function f(N){if(i===r.length){if(!a)return y(N);if(a.currentConstruct&&a.currentConstruct.concrete)return k(N);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Bb,x,p)(N)}function x(N){return a&&E(),j(i),y(N)}function p(N){return t.parser.lazy[t.now().line]=i!==r.length,c=t.now().offset,k(N)}function y(N){return t.containerState={},e.attempt(Bb,g,k)(N)}function g(N){return i++,r.push([t.currentConstruct,t.containerState]),y(N)}function k(N){if(N===null){a&&E(),j(0),e.consume(N);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),w(N)}function w(N){if(N===null){C(e.exit("chunkFlow"),!0),j(0),e.consume(N);return}return ht(N)?(e.consume(N),C(e.exit("chunkFlow")),i=0,t.interrupt=void 0,d):(e.consume(N),w)}function C(N,A){const z=t.sliceStream(N);if(A&&z.push(null),N.previous=o,o&&(o.next=N),o=N,a.defineSkip(N.start),a.write(z),t.parser.lazy[N.start.line]){let T=a.events.length;for(;T--;)if(a.events[T][1].start.offset<c&&(!a.events[T][1].end||a.events[T][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(j(i),T=F;T<t.events.length;)t.events[T][1].end={...L},T++;ni(t.events,q+1,0,t.events.slice(F)),t.events.length=T}}function j(N){let A=r.length;for(;A-- >N;){const z=r[A];t.containerState=z[1],z[0].exit.call(t,e)}r.length=N}function E(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function WC(e,t,r){return Ht(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function co(e){if(e===null||fn(e)||sl(e))return 1;if(Mf(e))return 2}function Ff(e,t,r){const i=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!i.includes(o)&&(t=o(t,r),i.push(o))}return t}const rx={name:"attention",resolveAll:GC,tokenize:KC};function GC(e,t){let r=-1,i,a,o,c,d,m,f,x;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(i=r;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[r][1]).charCodeAt(0)){if((e[i][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;m=e[i][1].end.offset-e[i][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p={...e[i][1].end},y={...e[r][1].start};$b(p,-m),$b(y,m),c={type:m>1?"strongSequence":"emphasisSequence",start:p,end:{...e[i][1].end}},d={type:m>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:y},o={type:m>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[r][1].start}},a={type:m>1?"strong":"emphasis",start:{...c.start},end:{...d.end}},e[i][1].end={...c.start},e[r][1].start={...d.end},f=[],e[i][1].end.offset-e[i][1].start.offset&&(f=bi(f,[["enter",e[i][1],t],["exit",e[i][1],t]])),f=bi(f,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),f=bi(f,Ff(t.parser.constructs.insideSpan.null,e.slice(i+1,r),t)),f=bi(f,[["exit",o,t],["enter",d,t],["exit",d,t],["exit",a,t]]),e[r][1].end.offset-e[r][1].start.offset?(x=2,f=bi(f,[["enter",e[r][1],t],["exit",e[r][1],t]])):x=0,ni(e,i-1,r-i+3,f),r=i+f.length-x-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function KC(e,t){const r=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||r.includes(m),y=!a||a===2&&x||r.includes(i);return f._open=!!(o===42?p:p&&(a||!y)),f._close=!!(o===42?y:y&&(x||!p)),t(m)}}function $b(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const QC={name:"autolink",tokenize:ZC};function ZC(e,t,r){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 vr(g)?(e.consume(g),c):g===64?r(g):f(g)}function c(g){return g===43||g===45||g===46||mr(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||mr(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||uf(g)?r(g):(e.consume(g),m)}function f(g){return g===64?(e.consume(g),x):HC(g)?(e.consume(g),f):r(g)}function x(g){return mr(g)?p(g):r(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||mr(g))&&i++<63){const k=g===45?y:p;return e.consume(g),k}return r(g)}}const nu={partial:!0,tokenize:JC};function JC(e,t,r){return i;function i(o){return zt(o)?Ht(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||ht(o)?t(o):r(o)}}const z2={continuation:{tokenize:tj},exit:nj,name:"blockQuote",tokenize:ej};function ej(e,t,r){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 r(c)}function o(c){return zt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function tj(e,t,r){const i=this;return a;function a(c){return zt(c)?Ht(e,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(z2,t,r)(c)}}function nj(e){e.exit("blockQuote")}const B2={name:"characterEscape",tokenize:rj};function rj(e,t,r){return i;function i(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return qC(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(o)}}const $2={name:"characterReference",tokenize:ij};function ij(e,t,r){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=mr,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=UC,x):(e.enter("characterReferenceValue"),o=7,c=nx,x(p))}function x(p){if(p===59&&a){const y=e.exit("characterReferenceValue");return c===mr&&!Qx(i.sliceSerialize(y))?r(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(p)&&a++<o?(e.consume(p),x):r(p)}}const Ob={partial:!0,tokenize:aj},Lb={concrete:!0,name:"codeFenced",tokenize:sj};function sj(e,t,r){const i=this,a={partial:!0,tokenize:z};let o=0,c=0,d;return m;function m(T){return f(T)}function f(T){const F=i.events[i.events.length-1];return o=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,d=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(T)}function x(T){return T===d?(c++,e.consume(T),x):c<3?r(T):(e.exit("codeFencedFenceSequence"),zt(T)?Ht(e,p,"whitespace")(T):p(T))}function p(T){return T===null||ht(T)?(e.exit("codeFencedFence"),i.interrupt?t(T):e.check(Ob,w,A)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(T))}function y(T){return T===null||ht(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(T)):zt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ht(e,g,"whitespace")(T)):T===96&&T===d?r(T):(e.consume(T),y)}function g(T){return T===null||ht(T)?p(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(T))}function k(T){return T===null||ht(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(T)):T===96&&T===d?r(T):(e.consume(T),k)}function w(T){return e.attempt(a,A,C)(T)}function C(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),j}function j(T){return o>0&&zt(T)?Ht(e,E,"linePrefix",o+1)(T):E(T)}function E(T){return T===null||ht(T)?e.check(Ob,w,A)(T):(e.enter("codeFlowValue"),N(T))}function N(T){return T===null||ht(T)?(e.exit("codeFlowValue"),E(T)):(e.consume(T),N)}function A(T){return e.exit("codeFenced"),t(T)}function z(T,F,q){let V=0;return L;function L(H){return T.enter("lineEnding"),T.consume(H),T.exit("lineEnding"),_}function _(H){return T.enter("codeFencedFence"),zt(H)?Ht(T,O,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):O(H)}function O(H){return H===d?(T.enter("codeFencedFenceSequence"),P(H)):q(H)}function P(H){return H===d?(V++,T.consume(H),P):V>=c?(T.exit("codeFencedFenceSequence"),zt(H)?Ht(T,R,"whitespace")(H):R(H)):q(H)}function R(H){return H===null||ht(H)?(T.exit("codeFencedFence"),F(H)):q(H)}}}function aj(e,t,r){const i=this;return a;function a(c){return c===null?r(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return i.parser.lazy[i.now().line]?r(c):t(c)}}const tp={name:"codeIndented",tokenize:oj},lj={partial:!0,tokenize:cj};function oj(e,t,r){const i=this;return a;function a(f){return e.enter("codeIndented"),Ht(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):r(f)}function c(f){return f===null?m(f):ht(f)?e.attempt(lj,c,m)(f):(e.enter("codeFlowValue"),d(f))}function d(f){return f===null||ht(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),d)}function m(f){return e.exit("codeIndented"),t(f)}}function cj(e,t,r){const i=this;return a;function a(c){return i.parser.lazy[i.now().line]?r(c):ht(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Ht(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):ht(c)?a(c):r(c)}}const uj={name:"codeText",previous:fj,resolve:dj,tokenize:hj};function dj(e){let t=e.length-4,r=3,i,a;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=r;++i<t;)if(e[i][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[t][1].type="codeTextPadding",r+=2,t-=2;break}}for(i=r-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 fj(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hj(e,t,r){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?r(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),m):p===96?(o=e.enter("codeTextSequence"),a=0,x(p)):ht(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||ht(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 mj{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,r){const i=r??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,r,i){const a=r||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return i&&kc(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),kc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),kc(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 r=this.left.splice(t,Number.POSITIVE_INFINITY);kc(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);kc(this.left,r.reverse())}}}function kc(e,t){let r=0;if(t.length<1e4)e.push(...t);else for(;r<t.length;)e.push(...t.slice(r,r+1e4)),r+=1e4}function O2(e){const t={};let r=-1,i,a,o,c,d,m,f;const x=new mj(e);for(;++r<x.length;){for(;r in t;)r=t[r];if(i=x.get(r),r&&i[1].type==="chunkFlow"&&x.get(r-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,pj(x,r)),r=t[r],f=!0);else if(i[1]._container){for(o=r,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,r),d.unshift(i),x.splice(a,r-a+1,d))}}return ni(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!f}function pj(e,t){const r=e.get(t)[1],i=e.get(t)[2];let a=t-1;const o=[];let c=r._tokenizer;c||(c=i.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const d=c.events,m=[],f={};let x,p,y=-1,g=r,k=0,w=0;const C=[w];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=r;++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&&(w=y+1,C.push(w),g._tokenizer=void 0,g.previous=void 0,g=g.next);for(c.events=[],g?(g._tokenizer=void 0,g.previous=void 0):C.pop(),y=C.length;y--;){const j=d.slice(C[y],C[y+1]),E=o.pop();m.push([E,E+j.length-1]),e.splice(E,2,j)}for(m.reverse(),y=-1;++y<m.length;)f[k+m[y][0]]=k+m[y][1],k+=m[y][1]-m[y][0]-1;return f}const xj={resolve:yj,tokenize:bj},gj={partial:!0,tokenize:vj};function yj(e){return O2(e),e}function bj(e,t){let r;return i;function i(d){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),a(d)}function a(d){return d===null?o(d):ht(d)?e.check(gj,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"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,a}}function vj(e,t,r){const i=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ht(e,o,"linePrefix")}function o(c){if(c===null||ht(c))return r(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,r,t)(c)}}function L2(e,t,r,i,a,o,c,d,m){const f=m||Number.POSITIVE_INFINITY;let x=0;return p;function p(j){return j===60?(e.enter(i),e.enter(a),e.enter(o),e.consume(j),e.exit(o),y):j===null||j===32||j===41||uf(j)?r(j):(e.enter(i),e.enter(c),e.enter(d),e.enter("chunkString",{contentType:"string"}),w(j))}function y(j){return j===62?(e.enter(o),e.consume(j),e.exit(o),e.exit(a),e.exit(i),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),g(j))}function g(j){return j===62?(e.exit("chunkString"),e.exit(d),y(j)):j===null||j===60||ht(j)?r(j):(e.consume(j),j===92?k:g)}function k(j){return j===60||j===62||j===92?(e.consume(j),g):g(j)}function w(j){return!x&&(j===null||j===41||fn(j))?(e.exit("chunkString"),e.exit(d),e.exit(c),e.exit(i),t(j)):x<f&&j===40?(e.consume(j),x++,w):j===41?(e.consume(j),x--,w):j===null||j===32||j===40||uf(j)?r(j):(e.consume(j),j===92?C:w)}function C(j){return j===40||j===41||j===92?(e.consume(j),w):w(j)}}function I2(e,t,r,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?r(g):g===93?(e.exit(o),e.enter(a),e.consume(g),e.exit(a),e.exit(i),t):ht(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||ht(g)||d++>999?(e.exit("chunkString"),x(g)):(e.consume(g),m||(m=!zt(g)),g===92?y:p)}function y(g){return g===91||g===92||g===93?(e.consume(g),d++,p):p(g)}}function H2(e,t,r,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):r(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?r(y):ht(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Ht(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(y))}function x(y){return y===c||y===null||ht(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 Bc(e,t){let r;return i;function i(a){return ht(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r=!0,i):zt(a)?Ht(e,i,r?"linePrefix":"lineSuffix")(a):t(a)}}const wj={name:"definition",tokenize:Sj},kj={partial:!0,tokenize:Cj};function Sj(e,t,r){const i=this;let a;return o;function o(g){return e.enter("definition"),c(g)}function c(g){return I2.call(i,e,d,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function d(g){return a=zi(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),m):r(g)}function m(g){return fn(g)?Bc(e,f)(g):f(g)}function f(g){return L2(e,x,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function x(g){return e.attempt(kj,p,p)(g)}function p(g){return zt(g)?Ht(e,y,"whitespace")(g):y(g)}function y(g){return g===null||ht(g)?(e.exit("definition"),i.parser.defined.push(a),t(g)):r(g)}}function Cj(e,t,r){return i;function i(d){return fn(d)?Bc(e,a)(d):r(d)}function a(d){return H2(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function o(d){return zt(d)?Ht(e,c,"whitespace")(d):c(d)}function c(d){return d===null||ht(d)?t(d):r(d)}}const jj={name:"hardBreakEscape",tokenize:Ej};function Ej(e,t,r){return i;function i(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return ht(o)?(e.exit("hardBreakEscape"),t(o)):r(o)}}const Nj={name:"headingAtx",resolve:Aj,tokenize:Tj};function Aj(e,t){let r=e.length-2,i=3,a,o;return e[i][1].type==="whitespace"&&(i+=2),r-2>i&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(i===r-1||r-4>i&&e[r-2][1].type==="whitespace")&&(r-=i+1===r?2:4),r>i&&(a={type:"atxHeadingText",start:e[i][1].start,end:e[r][1].end},o={type:"chunkText",start:e[i][1].start,end:e[r][1].end,contentType:"text"},ni(e,i,r-i+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function Tj(e,t,r){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||fn(x)?(e.exit("atxHeadingSequence"),d(x)):r(x)}function d(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||ht(x)?(e.exit("atxHeading"),t(x)):zt(x)?Ht(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||fn(x)?(e.exit("atxHeadingText"),d(x)):(e.consume(x),f)}}const Dj=["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"],Ib=["pre","script","style","textarea"],_j={concrete:!0,name:"htmlFlow",resolveTo:Rj,tokenize:zj},Mj={partial:!0,tokenize:$j},Fj={partial:!0,tokenize:Bj};function Rj(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 zj(e,t,r){const i=this;let a,o,c,d,m;return f;function f($){return x($)}function x($){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume($),p}function p($){return $===33?(e.consume($),y):$===47?(e.consume($),o=!0,w):$===63?(e.consume($),a=3,i.interrupt?t:M):vr($)?(e.consume($),c=String.fromCharCode($),C):r($)}function y($){return $===45?(e.consume($),a=2,g):$===91?(e.consume($),a=5,d=0,k):vr($)?(e.consume($),a=4,i.interrupt?t:M):r($)}function g($){return $===45?(e.consume($),i.interrupt?t:M):r($)}function k($){const Q="CDATA[";return $===Q.charCodeAt(d++)?(e.consume($),d===Q.length?i.interrupt?t:O:k):r($)}function w($){return vr($)?(e.consume($),c=String.fromCharCode($),C):r($)}function C($){if($===null||$===47||$===62||fn($)){const Q=$===47,ee=c.toLowerCase();return!Q&&!o&&Ib.includes(ee)?(a=1,i.interrupt?t($):O($)):Dj.includes(c.toLowerCase())?(a=6,Q?(e.consume($),j):i.interrupt?t($):O($)):(a=7,i.interrupt&&!i.parser.lazy[i.now().line]?r($):o?E($):N($))}return $===45||mr($)?(e.consume($),c+=String.fromCharCode($),C):r($)}function j($){return $===62?(e.consume($),i.interrupt?t:O):r($)}function E($){return zt($)?(e.consume($),E):L($)}function N($){return $===47?(e.consume($),L):$===58||$===95||vr($)?(e.consume($),A):zt($)?(e.consume($),N):L($)}function A($){return $===45||$===46||$===58||$===95||mr($)?(e.consume($),A):z($)}function z($){return $===61?(e.consume($),T):zt($)?(e.consume($),z):N($)}function T($){return $===null||$===60||$===61||$===62||$===96?r($):$===34||$===39?(e.consume($),m=$,F):zt($)?(e.consume($),T):q($)}function F($){return $===m?(e.consume($),m=null,V):$===null||ht($)?r($):(e.consume($),F)}function q($){return $===null||$===34||$===39||$===47||$===60||$===61||$===62||$===96||fn($)?z($):(e.consume($),q)}function V($){return $===47||$===62||zt($)?N($):r($)}function L($){return $===62?(e.consume($),_):r($)}function _($){return $===null||ht($)?O($):zt($)?(e.consume($),_):r($)}function O($){return $===45&&a===2?(e.consume($),B):$===60&&a===1?(e.consume($),Z):$===62&&a===4?(e.consume($),U):$===63&&a===3?(e.consume($),M):$===93&&a===5?(e.consume($),K):ht($)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(Mj,Y,P)($)):$===null||ht($)?(e.exit("htmlFlowData"),P($)):(e.consume($),O)}function P($){return e.check(Fj,R,Y)($)}function R($){return e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),H}function H($){return $===null||ht($)?P($):(e.enter("htmlFlowData"),O($))}function B($){return $===45?(e.consume($),M):O($)}function Z($){return $===47?(e.consume($),c="",G):O($)}function G($){if($===62){const Q=c.toLowerCase();return Ib.includes(Q)?(e.consume($),U):O($)}return vr($)&&c.length<8?(e.consume($),c+=String.fromCharCode($),G):O($)}function K($){return $===93?(e.consume($),M):O($)}function M($){return $===62?(e.consume($),U):$===45&&a===2?(e.consume($),M):O($)}function U($){return $===null||ht($)?(e.exit("htmlFlowData"),Y($)):(e.consume($),U)}function Y($){return e.exit("htmlFlow"),t($)}}function Bj(e,t,r){const i=this;return a;function a(c){return ht(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):r(c)}function o(c){return i.parser.lazy[i.now().line]?r(c):t(c)}}function $j(e,t,r){return i;function i(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(nu,t,r)}}const Oj={name:"htmlText",tokenize:Lj};function Lj(e,t,r){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),N):vr(M)?(e.consume(M),q):r(M)}function f(M){return M===45?(e.consume(M),x):M===91?(e.consume(M),o=0,k):vr(M)?(e.consume(M),E):r(M)}function x(M){return M===45?(e.consume(M),g):r(M)}function p(M){return M===null?r(M):M===45?(e.consume(M),y):ht(M)?(c=p,Z(M)):(e.consume(M),p)}function y(M){return M===45?(e.consume(M),g):p(M)}function g(M){return M===62?B(M):M===45?y(M):p(M)}function k(M){const U="CDATA[";return M===U.charCodeAt(o++)?(e.consume(M),o===U.length?w:k):r(M)}function w(M){return M===null?r(M):M===93?(e.consume(M),C):ht(M)?(c=w,Z(M)):(e.consume(M),w)}function C(M){return M===93?(e.consume(M),j):w(M)}function j(M){return M===62?B(M):M===93?(e.consume(M),j):w(M)}function E(M){return M===null||M===62?B(M):ht(M)?(c=E,Z(M)):(e.consume(M),E)}function N(M){return M===null?r(M):M===63?(e.consume(M),A):ht(M)?(c=N,Z(M)):(e.consume(M),N)}function A(M){return M===62?B(M):N(M)}function z(M){return vr(M)?(e.consume(M),T):r(M)}function T(M){return M===45||mr(M)?(e.consume(M),T):F(M)}function F(M){return ht(M)?(c=F,Z(M)):zt(M)?(e.consume(M),F):B(M)}function q(M){return M===45||mr(M)?(e.consume(M),q):M===47||M===62||fn(M)?V(M):r(M)}function V(M){return M===47?(e.consume(M),B):M===58||M===95||vr(M)?(e.consume(M),L):ht(M)?(c=V,Z(M)):zt(M)?(e.consume(M),V):B(M)}function L(M){return M===45||M===46||M===58||M===95||mr(M)?(e.consume(M),L):_(M)}function _(M){return M===61?(e.consume(M),O):ht(M)?(c=_,Z(M)):zt(M)?(e.consume(M),_):V(M)}function O(M){return M===null||M===60||M===61||M===62||M===96?r(M):M===34||M===39?(e.consume(M),a=M,P):ht(M)?(c=O,Z(M)):zt(M)?(e.consume(M),O):(e.consume(M),R)}function P(M){return M===a?(e.consume(M),a=void 0,H):M===null?r(M):ht(M)?(c=P,Z(M)):(e.consume(M),P)}function R(M){return M===null||M===34||M===39||M===60||M===61||M===96?r(M):M===47||M===62||fn(M)?V(M):(e.consume(M),R)}function H(M){return M===47||M===62||fn(M)?V(M):r(M)}function B(M){return M===62?(e.consume(M),e.exit("htmlTextData"),e.exit("htmlText"),t):r(M)}function Z(M){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),G}function G(M){return zt(M)?Ht(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 Zx={name:"labelEnd",resolveAll:qj,resolveTo:Yj,tokenize:Xj},Ij={tokenize:Pj},Hj={tokenize:Vj},Uj={tokenize:Wj};function qj(e){let t=-1;const r=[];for(;++t<e.length;){const i=e[t][1];if(r.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!==r.length&&ni(e,0,e.length,r),e}function Yj(e,t){let r=e.length,i=0,a,o,c,d;for(;r--;)if(a=e[r][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[r][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[r][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=r,a.type!=="labelLink")){i=2;break}}else a.type==="labelEnd"&&(c=r);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=bi(d,e.slice(o+1,o+i+3)),d=bi(d,[["enter",x,t]]),d=bi(d,Ff(t.parser.constructs.insideSpan.null,e.slice(o+i+4,c-3),t)),d=bi(d,[["exit",x,t],e[c-2],e[c-1],["exit",f,t]]),d=bi(d,e.slice(c+1)),d=bi(d,[["exit",m,t]]),ni(e,o,e.length,d),e}function Xj(e,t,r){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(zi(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),m):r(y)}function m(y){return y===40?e.attempt(Ij,x,c?x:p)(y):y===91?e.attempt(Hj,x,c?f:p)(y):c?x(y):p(y)}function f(y){return e.attempt(Uj,x,p)(y)}function x(y){return t(y)}function p(y){return o._balanced=!0,r(y)}}function Pj(e,t,r){return i;function i(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),a}function a(p){return fn(p)?Bc(e,o)(p):o(p)}function o(p){return p===41?x(p):L2(e,c,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function c(p){return fn(p)?Bc(e,m)(p):x(p)}function d(p){return r(p)}function m(p){return p===34||p===39||p===40?H2(e,f,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):x(p)}function f(p){return fn(p)?Bc(e,x)(p):x(p)}function x(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):r(p)}}function Vj(e,t,r){const i=this;return a;function a(d){return I2.call(i,e,o,c,"reference","referenceMarker","referenceString")(d)}function o(d){return i.parser.defined.includes(zi(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(d):r(d)}function c(d){return r(d)}}function Wj(e,t,r){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):r(o)}}const Gj={name:"labelStartImage",resolveAll:Zx.resolveAll,tokenize:Kj};function Kj(e,t,r){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):r(d)}function c(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?r(d):t(d)}}const Qj={name:"labelStartLink",resolveAll:Zx.resolveAll,tokenize:Zj};function Zj(e,t,r){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?r(c):t(c)}}const np={name:"lineEnding",tokenize:Jj};function Jj(e,t){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Ht(e,t,"linePrefix")}}const ef={name:"thematicBreak",tokenize:eE};function eE(e,t,r){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||ht(f))?(e.exit("thematicBreak"),t(f)):r(f)}function m(f){return f===a?(e.consume(f),i++,m):(e.exit("thematicBreakSequence"),zt(f)?Ht(e,d,"whitespace")(f):d(f))}}const Fr={continuation:{tokenize:iE},exit:aE,name:"list",tokenize:rE},tE={partial:!0,tokenize:lE},nE={partial:!0,tokenize:sE};function rE(e,t,r){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 k=i.containerState.type||(g===42||g===43||g===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!i.containerState.marker||g===i.containerState.marker:nx(g)){if(i.containerState.type||(i.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),g===42||g===45?e.check(ef,r,f)(g):f(g);if(!i.interrupt||g===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(g)}return r(g)}function m(g){return nx(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)):r(g)}function f(g){return e.enter("listItemMarker"),e.consume(g),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||g,e.check(nu,i.interrupt?r:x,e.attempt(tE,y,p))}function x(g){return i.containerState.initialBlankLine=!0,o++,y(g)}function p(g){return zt(g)?(e.enter("listItemPrefixWhitespace"),e.consume(g),e.exit("listItemPrefixWhitespace"),y):r(g)}function y(g){return i.containerState.size=o+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(g)}}function iE(e,t,r){const i=this;return i.containerState._closeFlow=void 0,e.check(nu,a,o);function a(d){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Ht(e,t,"listItemIndent",i.containerState.size+1)(d)}function o(d){return i.containerState.furtherBlankLines||!zt(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(nE,t,c)(d))}function c(d){return i.containerState._closeFlow=!0,i.interrupt=void 0,Ht(e,e.attempt(Fr,t,r),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function sE(e,t,r){const i=this;return Ht(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):r(o)}}function aE(e){e.exit(this.containerState.type)}function lE(e,t,r){const i=this;return Ht(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!zt(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):r(o)}}const Hb={name:"setextUnderline",resolveTo:oE,tokenize:cE};function oE(e,t){let r=e.length,i,a,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){i=r;break}e[r][1].type==="paragraph"&&(a=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);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 cE(e,t,r){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)):r(f)}function c(f){return e.enter("setextHeadingLineSequence"),d(f)}function d(f){return f===a?(e.consume(f),d):(e.exit("setextHeadingLineSequence"),zt(f)?Ht(e,m,"lineSuffix")(f):m(f))}function m(f){return f===null||ht(f)?(e.exit("setextHeadingLine"),t(f)):r(f)}}const uE={tokenize:dE};function dE(e){const t=this,r=e.attempt(nu,i,e.attempt(this.parser.constructs.flowInitial,a,Ht(e,e.attempt(this.parser.constructs.flow,a,e.attempt(xj,a)),"linePrefix")));return r;function i(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const fE={resolveAll:q2()},hE=U2("string"),mE=U2("text");function U2(e){return{resolveAll:q2(e==="text"?pE:void 0),tokenize:t};function t(r){const i=this,a=this.parser.constructs[e],o=r.attempt(a,c,d);return c;function c(x){return f(x)?o(x):d(x)}function d(x){if(x===null){r.consume(x);return}return r.enter("data"),r.consume(x),m}function m(x){return f(x)?(r.exit("data"),o(x)):(r.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 q2(e){return t;function t(r,i){let a=-1,o;for(;++a<=r.length;)o===void 0?r[a]&&r[a][1].type==="data"&&(o=a,a++):(!r[a]||r[a][1].type!=="data")&&(a!==o+2&&(r[o][1].end=r[a-1][1].end,r.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(r,i):r}}function pE(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const i=e[r-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&&r===e.length&&(d=0),d){const f={type:r===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(r,0,["enter",f,t],["exit",f,t]),r+=2)}r++}return e}const xE={42:Fr,43:Fr,45:Fr,48:Fr,49:Fr,50:Fr,51:Fr,52:Fr,53:Fr,54:Fr,55:Fr,56:Fr,57:Fr,62:z2},gE={91:wj},yE={[-2]:tp,[-1]:tp,32:tp},bE={35:Nj,42:ef,45:[Hb,ef],60:_j,61:Hb,95:ef,96:Lb,126:Lb},vE={38:$2,92:B2},wE={[-5]:np,[-4]:np,[-3]:np,33:Gj,38:$2,42:rx,60:[QC,Oj],91:Qj,92:[jj,B2],93:Zx,95:rx,96:uj},kE={null:[rx,fE]},SE={null:[42,95]},CE={null:[]},jE=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:SE,contentInitial:gE,disable:CE,document:xE,flow:bE,flowInitial:yE,insideSpan:kE,string:vE,text:wE},Symbol.toStringTag,{value:"Module"}));function EE(e,t,r){let i={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const a={},o=[];let c=[],d=[];const m={attempt:F(z),check:F(T),consume:E,enter:N,exit:A,interrupt:F(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:w,events:[],now:k,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=bi(c,_),C(),c[c.length-1]!==null?[]:(q(t,0),f.events=Ff(o,f.events,f),f.events)}function y(_,O){return AE(g(_),O)}function g(_){return NE(c,_)}function k(){const{_bufferIndex:_,_index:O,line:P,column:R,offset:H}=i;return{_bufferIndex:_,_index:O,line:P,column:R,offset:H}}function w(_){a[_.line]=_.column,L()}function C(){let _;for(;i._index<c.length;){const O=c[i._index];if(typeof O=="string")for(_=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===_&&i._bufferIndex<O.length;)j(O.charCodeAt(i._bufferIndex));else j(O)}}function j(_){x=x(_)}function E(_){ht(_)?(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 N(_,O){const P=O||{};return P.type=_,P.start=k(),f.events.push(["enter",P,f]),d.push(P),P}function A(_){const O=d.pop();return O.end=k(),f.events.push(["exit",O,f]),O}function z(_,O){q(_,O.from)}function T(_,O){O.restore()}function F(_,O){return P;function P(R,H,B){let Z,G,K,M;return Array.isArray(R)?Y(R):"tokenize"in R?Y([R]):U(R);function U(J){return ae;function ae(oe){const be=oe!==null&&J[oe],Ee=oe!==null&&J.null,Ae=[...Array.isArray(be)?be:be?[be]:[],...Array.isArray(Ee)?Ee:Ee?[Ee]:[]];return Y(Ae)(oe)}}function Y(J){return Z=J,G=0,J.length===0?B:$(J[G])}function $(J){return ae;function ae(oe){return M=V(),K=J,J.partial||(f.currentConstruct=J),J.name&&f.parser.constructs.disable.null.includes(J.name)?ee():J.tokenize.call(O?Object.assign(Object.create(f),O):f,m,Q,ee)(oe)}}function Q(J){return _(K,M),H}function ee(J){return M.restore(),++G<Z.length?$(Z[G]):B}}}function q(_,O){_.resolveAll&&!o.includes(_)&&o.push(_),_.resolve&&ni(f.events,O,f.events.length-O,_.resolve(f.events.slice(O),f)),_.resolveTo&&(f.events=_.resolveTo(f.events,f))}function V(){const _=k(),O=f.previous,P=f.currentConstruct,R=f.events.length,H=Array.from(d);return{from:R,restore:B};function B(){i=_,f.previous=O,f.currentConstruct=P,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 NE(e,t){const r=t.start._index,i=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let c;if(r===a)c=[e[r].slice(i,o)];else{if(c=e.slice(r,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 AE(e,t){let r=-1;const i=[];let a;for(;++r<e.length;){const o=e[r];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 TE(e){const i={constructs:F2([jE,...(e||{}).extensions||[]]),content:a(YC),defined:[],document:a(PC),flow:a(uE),lazy:{},string:a(hE),text:a(mE)};return i;function a(o){return c;function c(d){return EE(i,o,d)}}}function DE(e){for(;!O2(e););return e}const Ub=/[\0\t\n\r]/g;function _E(){let e=1,t="",r=!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="",r&&(o.charCodeAt(0)===65279&&p++,r=void 0);p<o.length;){if(Ub.lastIndex=p,f=Ub.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 ME=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FE(e){return e.replace(ME,RE)}function RE(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){const a=r.charCodeAt(1),o=a===120||a===88;return R2(r.slice(o?2:1),o?16:10)}return Qx(r)||e}const Y2={}.hasOwnProperty;function zE(e,t,r){return t&&typeof t=="object"&&(r=t,t=void 0),BE(r)(DE(TE(r).document().write(_E()(e,t,!0))))}function BE(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ye),autolinkProtocol:V,autolinkEmail:V,atxHeading:o(et),blockQuote:o(Ee),characterEscape:V,characterReference:V,codeFenced:o(Ae),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(Ae,c),codeText:o(Fe,c),codeTextData:V,data:V,codeFlowValue:V,definition:o(he),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(Re),hardBreakEscape:o(We),hardBreakTrailing:o(We),htmlFlow:o(it,c),htmlFlowData:V,htmlText:o(it,c),htmlTextData:V,image:o(mt),label:c,link:o(Ye),listItem:o(ut),listItemValue:y,listOrdered:o(Ze,p),listUnordered:o(Ze),paragraph:o(jt),reference:$,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(et),strong:o(ge),thematicBreak:o(Ce)},exit:{atxHeading:m(),atxHeadingSequence:z,autolink:m(),autolinkEmail:be,autolinkProtocol:oe,blockQuote:m(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:J,characterReference:ae,codeFenced:m(C),codeFencedFence:w,codeFencedFenceInfo:g,codeFencedFenceMeta:k,codeFlowValue:L,codeIndented:m(j),codeText:m(H),codeTextData:L,data:L,definition:m(),definitionDestinationString:A,definitionLabelString:E,definitionTitleString:N,emphasis:m(),hardBreakEscape:m(O),hardBreakTrailing:m(O),htmlFlow:m(P),htmlFlowData:L,htmlText:m(R),htmlTextData:L,image:m(Z),label:K,labelText:G,lineEnding:_,link:m(B),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Q,resourceDestinationString:M,resourceTitleString:U,resource:Y,setextHeading:m(q),setextHeadingLineSequence:F,setextHeadingText:T,strong:m(),thematicBreak:m()}};X2(t,(e||{}).mdastExtensions||[]);const r={};return i;function i(ne){let de={type:"root",children:[]};const _e={stack:[de],tokenStack:[],config:t,enter:d,exit:f,buffer:c,resume:x,data:r},ce=[];let Te=-1;for(;++Te<ne.length;)if(ne[Te][1].type==="listOrdered"||ne[Te][1].type==="listUnordered")if(ne[Te][0]==="enter")ce.push(Te);else{const Le=ce.pop();Te=a(ne,Le,Te)}for(Te=-1;++Te<ne.length;){const Le=t[ne[Te][0]];Y2.call(Le,ne[Te][1].type)&&Le[ne[Te][1].type].call(Object.assign({sliceSerialize:ne[Te][2].sliceSerialize},_e),ne[Te][1])}if(_e.tokenStack.length>0){const Le=_e.tokenStack[_e.tokenStack.length-1];(Le[1]||qb).call(_e,void 0,Le[0])}for(de.position={start:oa(ne.length>0?ne[0][1].start:{line:1,column:1,offset:0}),end:oa(ne.length>0?ne[ne.length-2][1].end:{line:1,column:1,offset:0})},Te=-1;++Te<t.transforms.length;)de=t.transforms[Te](de)||de;return de}function a(ne,de,_e){let ce=de-1,Te=-1,Le=!1,Xe,Ue,Pe,lt;for(;++ce<=_e;){const tt=ne[ce];switch(tt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{tt[0]==="enter"?Te++:Te--,lt=void 0;break}case"lineEndingBlank":{tt[0]==="enter"&&(Xe&&!lt&&!Te&&!Pe&&(Pe=ce),lt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:lt=void 0}if(!Te&&tt[0]==="enter"&&tt[1].type==="listItemPrefix"||Te===-1&&tt[0]==="exit"&&(tt[1].type==="listUnordered"||tt[1].type==="listOrdered")){if(Xe){let ze=ce;for(Ue=void 0;ze--;){const He=ne[ze];if(He[1].type==="lineEnding"||He[1].type==="lineEndingBlank"){if(He[0]==="exit")continue;Ue&&(ne[Ue][1].type="lineEndingBlank",Le=!0),He[1].type="lineEnding",Ue=ze}else if(!(He[1].type==="linePrefix"||He[1].type==="blockQuotePrefix"||He[1].type==="blockQuotePrefixWhitespace"||He[1].type==="blockQuoteMarker"||He[1].type==="listItemIndent"))break}Pe&&(!Ue||Pe<Ue)&&(Xe._spread=!0),Xe.end=Object.assign({},Ue?ne[Ue][1].start:tt[1].end),ne.splice(Ue||ce,0,["exit",Xe,tt[2]]),ce++,_e++}if(tt[1].type==="listItemPrefix"){const ze={type:"listItem",_spread:!1,start:Object.assign({},tt[1].start),end:void 0};Xe=ze,ne.splice(ce,0,["enter",ze,tt[2]]),ce++,_e++,Pe=void 0,lt=!0}}}return ne[de][1]._spread=Le,_e}function o(ne,de){return _e;function _e(ce){d.call(this,ne(ce),ce),de&&de.call(this,ce)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(ne,de,_e){this.stack[this.stack.length-1].children.push(ne),this.stack.push(ne),this.tokenStack.push([de,_e||void 0]),ne.position={start:oa(de.start),end:void 0}}function m(ne){return de;function de(_e){ne&&ne.call(this,_e),f.call(this,_e)}}function f(ne,de){const _e=this.stack.pop(),ce=this.tokenStack.pop();if(ce)ce[0].type!==ne.type&&(de?de.call(this,ne,ce[0]):(ce[1]||qb).call(this,ne,ce[0]));else throw new Error("Cannot close `"+ne.type+"` ("+zc({start:ne.start,end:ne.end})+"): it’s not open");_e.position.end=oa(ne.end)}function x(){return Kx(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function y(ne){if(this.data.expectingFirstListItemValue){const de=this.stack[this.stack.length-2];de.start=Number.parseInt(this.sliceSerialize(ne),10),this.data.expectingFirstListItemValue=void 0}}function g(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.lang=ne}function k(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.meta=ne}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.value=ne.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function j(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.value=ne.replace(/(\r?\n|\r)$/g,"")}function E(ne){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.label=de,_e.identifier=zi(this.sliceSerialize(ne)).toLowerCase()}function N(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.title=ne}function A(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.url=ne}function z(ne){const de=this.stack[this.stack.length-1];if(!de.depth){const _e=this.sliceSerialize(ne).length;de.depth=_e}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function F(ne){const de=this.stack[this.stack.length-1];de.depth=this.sliceSerialize(ne).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function V(ne){const _e=this.stack[this.stack.length-1].children;let ce=_e[_e.length-1];(!ce||ce.type!=="text")&&(ce=ve(),ce.position={start:oa(ne.start),end:void 0},_e.push(ce)),this.stack.push(ce)}function L(ne){const de=this.stack.pop();de.value+=this.sliceSerialize(ne),de.position.end=oa(ne.end)}function _(ne){const de=this.stack[this.stack.length-1];if(this.data.atHardBreak){const _e=de.children[de.children.length-1];_e.position.end=oa(ne.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(de.type)&&(V.call(this,ne),L.call(this,ne))}function O(){this.data.atHardBreak=!0}function P(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.value=ne}function R(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.value=ne}function H(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.value=ne}function B(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=de,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function Z(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=de,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function G(ne){const de=this.sliceSerialize(ne),_e=this.stack[this.stack.length-2];_e.label=FE(de),_e.identifier=zi(de).toLowerCase()}function K(){const ne=this.stack[this.stack.length-1],de=this.resume(),_e=this.stack[this.stack.length-1];if(this.data.inReference=!0,_e.type==="link"){const ce=ne.children;_e.children=ce}else _e.alt=de}function M(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.url=ne}function U(){const ne=this.resume(),de=this.stack[this.stack.length-1];de.title=ne}function Y(){this.data.inReference=void 0}function $(){this.data.referenceType="collapsed"}function Q(ne){const de=this.resume(),_e=this.stack[this.stack.length-1];_e.label=de,_e.identifier=zi(this.sliceSerialize(ne)).toLowerCase(),this.data.referenceType="full"}function ee(ne){this.data.characterReferenceType=ne.type}function J(ne){const de=this.sliceSerialize(ne),_e=this.data.characterReferenceType;let ce;_e?(ce=R2(de,_e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ce=Qx(de);const Te=this.stack[this.stack.length-1];Te.value+=ce}function ae(ne){const de=this.stack.pop();de.position.end=oa(ne.end)}function oe(ne){L.call(this,ne);const de=this.stack[this.stack.length-1];de.url=this.sliceSerialize(ne)}function be(ne){L.call(this,ne);const de=this.stack[this.stack.length-1];de.url="mailto:"+this.sliceSerialize(ne)}function Ee(){return{type:"blockquote",children:[]}}function Ae(){return{type:"code",lang:null,meta:null,value:""}}function Fe(){return{type:"inlineCode",value:""}}function he(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Re(){return{type:"emphasis",children:[]}}function et(){return{type:"heading",depth:0,children:[]}}function We(){return{type:"break"}}function it(){return{type:"html",value:""}}function mt(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function Ze(ne){return{type:"list",ordered:ne.type==="listOrdered",start:null,spread:ne._spread,children:[]}}function ut(ne){return{type:"listItem",spread:ne._spread,checked:null,children:[]}}function jt(){return{type:"paragraph",children:[]}}function ge(){return{type:"strong",children:[]}}function ve(){return{type:"text",value:""}}function Ce(){return{type:"thematicBreak"}}}function oa(e){return{line:e.line,column:e.column,offset:e.offset}}function X2(e,t){let r=-1;for(;++r<t.length;){const i=t[r];Array.isArray(i)?X2(e,i):$E(e,i)}}function $E(e,t){let r;for(r in t)if(Y2.call(t,r))switch(r){case"canContainEols":{const i=t[r];i&&e[r].push(...i);break}case"transforms":{const i=t[r];i&&e[r].push(...i);break}case"enter":case"exit":{const i=t[r];i&&Object.assign(e[r],i);break}}}function qb(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+zc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+zc({start:t.start,end:t.end})+") is still open")}function OE(e){const t=this;t.parser=r;function r(i){return zE(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function LE(e,t){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function IE(e,t){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
56
- `}]}function HE(e,t){const r=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:r}]};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 UE(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function qE(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function YE(e,t){const r=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:"#"+r+"fn-"+a,id:r+"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 XE(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function PE(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function P2(e,t){const r=t.referenceType;let i="]";if(r==="collapsed"?i+="[]":r==="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 VE(e,t){const r=String(t.identifier).toUpperCase(),i=e.definitionById.get(r);if(!i)return P2(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 WE(e,t){const r={src:So(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const i={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,i),e.applyData(t,i)}function GE(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const i={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,i),e.applyData(t,i)}function KE(e,t){const r=String(t.identifier).toUpperCase(),i=e.definitionById.get(r);if(!i)return P2(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 QE(e,t){const r={href:So(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const i={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function ZE(e,t,r){const i=e.all(t),a=r?JE(r):V2(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 JE(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const r=e.children;let i=-1;for(;!t&&++i<r.length;)t=V2(r[i])}return t}function V2(e){const t=e.spread;return t??e.children.length>1}function eN(e,t){const r={},i=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(r.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")){r.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:r,children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function tN(e,t){const r={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function nN(e,t){const r={type:"root",children:e.wrap(e.all(t))};return e.patch(t,r),e.applyData(t,r)}function rN(e,t){const r={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function iN(e,t){const r=e.all(t),i=r.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(r.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},d=Px(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 sN(e,t,r){const i=r?r.children:void 0,o=(i?i.indexOf(t):1)===0?"th":"td",c=r&&r.type==="table"?r.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 k={type:"element",tagName:o,properties:y,children:[]};p&&(k.children=e.all(p),e.patch(p,k),k=e.applyData(p,k)),f.push(k)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,x),e.applyData(t,x)}function aN(e,t){const r={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}const Yb=9,Xb=32;function lN(e){const t=String(e),r=/\r?\n|\r/g;let i=r.exec(t),a=0;const o=[];for(;i;)o.push(Pb(t.slice(a,i.index),a>0,!0),i[0]),a=i.index+i[0].length,i=r.exec(t);return o.push(Pb(t.slice(a),a>0,!1)),o.join("")}function Pb(e,t,r){let i=0,a=e.length;if(t){let o=e.codePointAt(i);for(;o===Yb||o===Xb;)i++,o=e.codePointAt(i)}if(r){let o=e.codePointAt(a-1);for(;o===Yb||o===Xb;)a--,o=e.codePointAt(a-1)}return a>i?e.slice(i,a):""}function oN(e,t){const r={type:"text",value:lN(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function cN(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const uN={blockquote:LE,break:IE,code:HE,delete:UE,emphasis:qE,footnoteReference:YE,heading:XE,html:PE,imageReference:VE,image:WE,inlineCode:GE,linkReference:KE,link:QE,listItem:ZE,list:eN,paragraph:tN,root:nN,strong:rN,table:iN,tableCell:aN,tableRow:sN,text:oN,thematicBreak:cN,toml:Nd,yaml:Nd,definition:Nd,footnoteDefinition:Nd};function Nd(){}const W2=-1,Rf=0,$c=1,df=2,Jx=3,e0=4,t0=5,n0=6,G2=7,K2=8,Vb=typeof self=="object"?self:globalThis,dN=(e,t)=>{const r=(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 Rf:case W2:return r(c,a);case $c:{const d=r([],a);for(const m of c)d.push(i(m));return d}case df:{const d=r({},a);for(const[m,f]of c)d[i(m)]=i(f);return d}case Jx:return r(new Date(c),a);case e0:{const{source:d,flags:m}=c;return r(new RegExp(d,m),a)}case t0:{const d=r(new Map,a);for(const[m,f]of c)d.set(i(m),i(f));return d}case n0:{const d=r(new Set,a);for(const m of c)d.add(i(m));return d}case G2:{const{name:d,message:m}=c;return r(new Vb[d](m),a)}case K2:return r(BigInt(c),a);case"BigInt":return r(Object(BigInt(c)),a);case"ArrayBuffer":return r(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:d}=new Uint8Array(c);return r(new DataView(d),c)}}return r(new Vb[o](c),a)};return i},Wb=e=>dN(new Map,e)(0),Zl="",{toString:fN}={},{keys:hN}=Object,Sc=e=>{const t=typeof e;if(t!=="object"||!e)return[Rf,t];const r=fN.call(e).slice(8,-1);switch(r){case"Array":return[$c,Zl];case"Object":return[df,Zl];case"Date":return[Jx,Zl];case"RegExp":return[e0,Zl];case"Map":return[t0,Zl];case"Set":return[n0,Zl];case"DataView":return[$c,r]}return r.includes("Array")?[$c,r]:r.includes("Error")?[G2,r]:[df,r]},Ad=([e,t])=>e===Rf&&(t==="function"||t==="symbol"),mN=(e,t,r,i)=>{const a=(c,d)=>{const m=i.push(c)-1;return r.set(d,m),m},o=c=>{if(r.has(c))return r.get(c);let[d,m]=Sc(c);switch(d){case Rf:{let x=c;switch(m){case"bigint":d=K2,x=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+m);x=null;break;case"undefined":return a([W2],c)}return a([d,x],c)}case $c:{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 df:{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 hN(c))(e||!Ad(Sc(c[y])))&&x.push([o(y),o(c[y])]);return p}case Jx:return a([d,c.toISOString()],c);case e0:{const{source:x,flags:p}=c;return a([d,{source:x,flags:p}],c)}case t0:{const x=[],p=a([d,x],c);for(const[y,g]of c)(e||!(Ad(Sc(y))||Ad(Sc(g))))&&x.push([o(y),o(g)]);return p}case n0:{const x=[],p=a([d,x],c);for(const y of c)(e||!Ad(Sc(y)))&&x.push(o(y));return p}}const{message:f}=c;return a([d,{name:m,message:f}],c)};return o},Gb=(e,{json:t,lossy:r}={})=>{const i=[];return mN(!(t||r),!!t,new Map,i)(e),i},ff=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Wb(Gb(e,t)):structuredClone(e):(e,t)=>Wb(Gb(e,t));function pN(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function xN(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function gN(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||pN,i=e.options.footnoteBackLabel||xN,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 k=[],w=e.footnoteCounts.get(p);for(;w!==void 0&&++g<=w;){k.length>0&&k.push({type:"text",value:" "});let E=typeof r=="string"?r:r(m,g);typeof E=="string"&&(E={type:"text",value:E}),k.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(E)?E:[E]})}const C=x[x.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const E=C.children[C.children.length-1];E&&E.type==="text"?E.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...k)}else x.push(...k);const j={type:"element",tagName:"li",properties:{id:t+"fn-"+y},children:e.wrap(x,!0)};e.patch(f,j),d.push(j)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...ff(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 zf=(function(e){if(e==null)return wN;if(typeof e=="function")return Bf(e);if(typeof e=="object")return Array.isArray(e)?yN(e):bN(e);if(typeof e=="string")return vN(e);throw new Error("Expected function, string, or object as test")});function yN(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=zf(e[r]);return Bf(i);function i(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function bN(e){const t=e;return Bf(r);function r(i){const a=i;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function vN(e){return Bf(t);function t(r){return r&&r.type===e}}function Bf(e){return t;function t(r,i,a){return!!(kN(r)&&e.call(this,r,typeof i=="number"?i:void 0,a||void 0))}}function wN(){return!0}function kN(e){return e!==null&&typeof e=="object"&&"type"in e}const Q2=[],SN=!0,ix=!1,CN="skip";function Z2(e,t,r,i){let a;typeof t=="function"&&typeof r!="function"?(i=r,r=t):a=t;const o=zf(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=Q2,k,w,C;if((!t||o(m,f,x[x.length-1]||void 0))&&(g=jN(r(m,x)),g[0]===ix))return g;if("children"in m&&m.children){const j=m;if(j.children&&g[0]!==CN)for(w=(i?j.children.length:-1)+c,C=x.concat(j);w>-1&&w<j.children.length;){const E=j.children[w];if(k=d(E,w,C)(),k[0]===ix)return k;w=typeof k[1]=="number"?k[1]:w+c}}return g}}}function jN(e){return Array.isArray(e)?e:typeof e=="number"?[SN,e]:e==null?Q2:[e]}function r0(e,t,r,i){let a,o,c;typeof t=="function"&&typeof r!="function"?(o=void 0,c=t,a=r):(o=t,c=r,a=i),Z2(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 sx={}.hasOwnProperty,EN={};function NN(e,t){const r=t||EN,i=new Map,a=new Map,o=new Map,c={...uN,...r.handlers},d={all:f,applyData:TN,definitionById:i,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:m,options:r,patch:AN,wrap:_N};return r0(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(sx.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:w,...C}=x,j=ff(C);return j.children=d.all(x),j}return ff(x)}return(d.options.unknownHandler||DN)(d,x,p)}function f(x){const p=[];if("children"in x){const y=x.children;let g=-1;for(;++g<y.length;){const k=d.one(y[g],x);if(k){if(g&&y[g-1].type==="break"&&(!Array.isArray(k)&&k.type==="text"&&(k.value=Kb(k.value)),!Array.isArray(k)&&k.type==="element")){const w=k.children[0];w&&w.type==="text"&&(w.value=Kb(w.value))}Array.isArray(k)?p.push(...k):p.push(k)}}}return p}}function AN(e,t){e.position&&(t.position=xC(e))}function TN(e,t){let r=t;if(e&&e.data){const i=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof i=="string")if(r.type==="element")r.tagName=i;else{const c="children"in r?r.children:[r];r={type:"element",tagName:i,properties:{},children:c}}r.type==="element"&&o&&Object.assign(r.properties,ff(o)),"children"in r&&r.children&&a!==null&&a!==void 0&&(r.children=a)}return r}function DN(e,t){const r=t.data||{},i="value"in t&&!(sx.call(r,"hProperties")||sx.call(r,"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 _N(e,t){const r=[];let i=-1;for(t&&r.push({type:"text",value:`
62
- `});++i<e.length;)i&&r.push({type:"text",value:`
63
- `}),r.push(e[i]);return t&&e.length>0&&r.push({type:"text",value:`
64
- `}),r}function Kb(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function Qb(e,t){const r=NN(e,t),i=r.one(e,void 0),a=gN(r),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
65
- `},a),o}function MN(e,t){return e&&"run"in e?async function(r,i){const a=Qb(r,{file:i,...t});await e.run(a,i)}:function(r,i){return Qb(r,{file:i,...e||t})}}function Zb(e){if(e)throw e}var rp,Jb;function FN(){if(Jb)return rp;Jb=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=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){r&&x.name==="__proto__"?r(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 rp=function m(){var f,x,p,y,g,k,w=arguments[0],C=1,j=arguments.length,E=!1;for(typeof w=="boolean"&&(E=w,w=arguments[1]||{},C=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});C<j;++C)if(f=arguments[C],f!=null)for(x in f)p=d(w,x),y=d(f,x),w!==y&&(E&&y&&(o(y)||(g=a(y)))?(g?(g=!1,k=p&&a(p)?p:[]):k=p&&o(p)?p:{},c(w,{name:x,newValue:m(E,k,y)})):typeof y<"u"&&c(w,{name:x,newValue:y}));return w},rp}var RN=FN();const ip=_f(RN);function ax(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 zN(){const e=[],t={run:r,use:i};return t;function r(...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?BN(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 BN(e,t){let r;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&&r)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){r||(r=!0,t(c,...d))}function o(c){a(null,c)}}const Qi={basename:$N,dirname:ON,extname:LN,join:IN,sep:"/"};function $N(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ru(e);let r=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){r=a+1;break}}else i<0&&(o=!0,i=a+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let c=-1,d=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){r=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 r===i?i=c:i<0&&(i=e.length),e.slice(r,i)}function ON(e){if(ru(e),e.length===0)return".";let t=-1,r=e.length,i;for(;--r;)if(e.codePointAt(r)===47){if(i){t=r;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function LN(e){ru(e);let t=e.length,r=-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}r<0&&(c=!0,r=t+1),d===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||r<0||o===0||o===1&&a===r-1&&a===i+1?"":e.slice(a,r)}function IN(...e){let t=-1,r;for(;++t<e.length;)ru(e[t]),e[t]&&(r=r===void 0?e[t]:r+"/"+e[t]);return r===void 0?".":HN(r)}function HN(e){ru(e);const t=e.codePointAt(0)===47;let r=UN(e,!t);return r.length===0&&!t&&(r="."),r.length>0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function UN(e,t){let r="",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(r.length<2||i!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(m=r.lastIndexOf("/"),m!==r.length-1){m<0?(r="",i=0):(r=r.slice(0,m),i=r.length-1-r.lastIndexOf("/")),a=c,o=0;continue}}else if(r.length>0){r="",i=0,a=c,o=0;continue}}t&&(r=r.length>0?r+"/..":"..",i=2)}else r.length>0?r+="/"+e.slice(a+1,c):r=e.slice(a+1,c),i=c-a-1;a=c,o=0}else d===46&&o>-1?o++:o=-1}return r}function ru(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const qN={cwd:YN};function YN(){return"/"}function lx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function XN(e){if(typeof e=="string")e=new URL(e);else if(!lx(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 PN(e)}function PN(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 r=-1;for(;++r<t.length;)if(t.codePointAt(r)===37&&t.codePointAt(r+1)===50){const i=t.codePointAt(r+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 sp=["history","path","basename","stem","extname","dirname"];class J2{constructor(t){let r;t?lx(t)?r={path:t}:typeof t=="string"||VN(t)?r={value:t}:r=t:r={},this.cwd="cwd"in r?"":qN.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<sp.length;){const o=sp[i];o in r&&r[o]!==void 0&&r[o]!==null&&(this[o]=o==="history"?[...r[o]]:r[o])}let a;for(a in r)sp.includes(a)||(this[a]=r[a])}get basename(){return typeof this.path=="string"?Qi.basename(this.path):void 0}set basename(t){lp(t,"basename"),ap(t,"basename"),this.path=Qi.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Qi.dirname(this.path):void 0}set dirname(t){ev(this.basename,"dirname"),this.path=Qi.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Qi.extname(this.path):void 0}set extname(t){if(ap(t,"extname"),ev(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=Qi.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){lx(t)&&(t=XN(t)),lp(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Qi.basename(this.path,this.extname):void 0}set stem(t){lp(t,"stem"),ap(t,"stem"),this.path=Qi.join(this.dirname||"",t+(this.extname||""))}fail(t,r,i){const a=this.message(t,r,i);throw a.fatal=!0,a}info(t,r,i){const a=this.message(t,r,i);return a.fatal=void 0,a}message(t,r,i){const a=new pr(t,r,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 ap(e,t){if(e&&e.includes(Qi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Qi.sep+"`")}function lp(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ev(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function VN(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const WN=(function(e){const i=this.constructor.prototype,a=i[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,i),o}),GN={}.hasOwnProperty;class i0 extends WN{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=zN()}copy(){const t=new i0;let r=-1;for(;++r<this.attachers.length;){const i=this.attachers[r];t.use(...i)}return t.data(ip(!0,{},this.namespace)),t}data(t,r){return typeof t=="string"?arguments.length===2?(up("data",this.frozen),this.namespace[t]=r,this):GN.call(this.namespace,t)&&this.namespace[t]||void 0:t?(up("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[r,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const a=r.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 r=Td(t),i=this.parser||this.Parser;return op("parse",i),i(String(r),r)}process(t,r){const i=this;return this.freeze(),op("process",this.parser||this.Parser),cp("process",this.compiler||this.Compiler),r?a(void 0,r):new Promise(a);function a(o,c){const d=Td(t),m=i.parse(d);i.run(m,d,function(x,p,y){if(x||!p||!y)return f(x);const g=p,k=i.stringify(g,y);ZN(k)?y.value=k:y.result=k,f(x,y)});function f(x,p){x||!p?c(x):o?o(p):r(void 0,p)}}}processSync(t){let r=!1,i;return this.freeze(),op("processSync",this.parser||this.Parser),cp("processSync",this.compiler||this.Compiler),this.process(t,a),nv("processSync","process",r),i;function a(o,c){r=!0,Zb(o),i=c}}run(t,r,i){tv(t),this.freeze();const a=this.transformers;return!i&&typeof r=="function"&&(i=r,r=void 0),i?o(void 0,i):new Promise(o);function o(c,d){const m=Td(r);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,r){let i=!1,a;return this.run(t,r,o),nv("runSync","run",i),a;function o(c,d){Zb(c),a=d,i=!0}}stringify(t,r){this.freeze();const i=Td(r),a=this.compiler||this.Compiler;return cp("stringify",a),tv(t),a(t,i)}use(t,...r){const i=this.attachers,a=this.namespace;if(up("use",this.frozen),t!=null)if(typeof t=="function")m(t,r);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=ip(!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,...k]=x;const w=i[y][1];ax(w)&&ax(g)&&(g=ip(!0,w,g)),i[y]=[f,g,...k]}}}}const KN=new i0().freeze();function op(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function cp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function up(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 tv(e){if(!ax(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function nv(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Td(e){return QN(e)?e:new J2(e)}function QN(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function ZN(e){return typeof e=="string"||JN(e)}function JN(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const eA="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",rv=[],iv={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 s0(e){const t=rA(e),r=iA(e);return sA(t.runSync(t.parse(r),r),e)}function rA(e){const t=e.rehypePlugins||rv,r=e.remarkPlugins||rv,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...iv}:iv;return KN().use(OE).use(r).use(MN,i).use(t)}function iA(e){const t=e.children||"",r=new J2;return typeof t=="string"&&(r.value=t),r}function sA(e,t){const r=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 r0(e,f),wC(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 ep)if(Object.hasOwn(ep,g)&&Object.hasOwn(x.properties,g)){const k=x.properties[g],w=ep[g];(w===null||w.includes(x.tagName))&&(x.properties[g]=m(String(k||""),g,x))}}if(x.type==="element"){let g=r?!r.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(":"),r=e.indexOf("?"),i=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||r!==-1&&t>r||i!==-1&&t>i||tA.test(e.slice(0,t))?e:""}function sv(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let i=0,a=r.indexOf(t);for(;a!==-1;)i++,a=r.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,r){const a=zf((r||{}).ignore||[]),o=cA(t);let c=-1;for(;++c<o.length;)Z2(e,"text",d);function d(f,x){let p=-1,y;for(;++p<x.length;){const g=x[p],k=y?y.children:void 0;if(a(g,k?k.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 k=0;const C=p.children.indexOf(f);let j=!1,E=[];y.lastIndex=0;let N=y.exec(f.value);for(;N;){const A=N.index,z={index:N.index,input:N.input,stack:[...x,f]};let T=g(...N,z);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?y.lastIndex=A+1:(k!==A&&E.push({type:"text",value:f.value.slice(k,A)}),Array.isArray(T)?E.push(...T):T&&E.push(T),k=A+N[0].length,j=!0),!y.global)break;N=y.exec(f.value)}return j?(k<f.value.length&&E.push({type:"text",value:f.value.slice(k)}),p.children.splice(C,1,...E)):E=[f],C+E.length}}function cA(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const r=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<r.length;){const a=r[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 dp="phrasing",fp=["autolink","link","image","label"];function fA(){return{transforms:[bA],enter:{literalAutolink:mA,literalAutolinkEmail:hp,literalAutolinkHttp:hp,literalAutolinkWww:hp},exit:{literalAutolink:yA,literalAutolinkEmail:gA,literalAutolinkHttp:pA,literalAutolinkWww:xA}}}function hA(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:dp,notInConstruct:fp},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:dp,notInConstruct:fp},{character:":",before:"[ps]",after:"\\/",inConstruct:dp,notInConstruct:fp}]}}function mA(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function hp(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,r,i,a){let o="";if(!e5(a)||(/^w/i.test(t)&&(r=t+r,t="",o="http://"),!kA(r)))return!1;const c=SA(r+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,r,i){return!e5(i,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+r,children:[{type:"text",value:t+"@"+r}]}}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 r=t[0],i=r.indexOf(")");const a=sv(e,"(");let o=sv(e,")");for(;i!==-1&&a>o;)e+=r.slice(0,i+1),r=r.slice(i+1),i=r.indexOf(")"),o++;return[e,r]}function e5(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||sl(r)||Mf(r))&&(!t||r!==47)}t5.peek=MA;function CA(){this.buffer()}function jA(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function EA(){this.buffer()}function NA(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function AA(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=zi(this.sliceSerialize(e)).toLowerCase(),r.label=t}function TA(e){this.exit(e)}function DA(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=zi(this.sliceSerialize(e)).toLowerCase(),r.label=t}function _A(e){this.exit(e)}function MA(){return"["}function t5(e,t,r,i){const a=r.createTracker(i);let o=a.move("[^");const c=r.enter("footnoteReference"),d=r.enter("reference");return o+=a.move(r.safe(r.associationId(e),{after:"]",before:o})),d(),c(),o+=a.move("]"),o}function FA(){return{enter:{gfmFootnoteCallString:CA,gfmFootnoteCall:jA,gfmFootnoteDefinitionLabelString:EA,gfmFootnoteDefinition:NA},exit:{gfmFootnoteCallString:AA,gfmFootnoteCall:TA,gfmFootnoteDefinitionLabelString:DA,gfmFootnoteDefinition:_A}}}function RA(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:t5},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(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?n5:zA))),f(),m}}function zA(e,t,r){return t===0?e:n5(e,t,r)}function n5(e,t,r){return(r?"":" ")+e}const BA=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];r5.peek=HA;function $A(){return{canContainEols:["delete"],enter:{strikethrough:LA},exit:{strikethrough:IA}}}function OA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:BA}],handlers:{delete:r5}}}function LA(e){this.enter({type:"delete",children:[]},e)}function IA(e){this.exit(e)}function r5(e,t,r,i){const a=r.createTracker(i),o=r.enter("strikethrough");let c=a.move("~~");return c+=r.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 r=t||{},i=(r.align||[]).concat(),a=r.stringLength||UA,o=[],c=[],d=[],m=[];let f=0,x=-1;for(;++x<e.length;){const w=[],C=[];let j=-1;for(e[x].length>f&&(f=e[x].length);++j<e[x].length;){const E=YA(e[x][j]);if(r.alignDelimiters!==!1){const N=a(E);C[j]=N,(m[j]===void 0||N>m[j])&&(m[j]=N)}w.push(E)}c[x]=w,d[x]=C}let p=-1;if(typeof i=="object"&&"length"in i)for(;++p<f;)o[p]=av(i[p]);else{const w=av(i);for(;++p<f;)o[p]=w}p=-1;const y=[],g=[];for(;++p<f;){const w=o[p];let C="",j="";w===99?(C=":",j=":"):w===108?C=":":w===114&&(j=":");let E=r.alignDelimiters===!1?1:Math.max(1,m[p]-C.length-j.length);const N=C+"-".repeat(E)+j;r.alignDelimiters!==!1&&(E=C.length+E+j.length,E>m[p]&&(m[p]=E),g[p]=E),y[p]=N}c.splice(1,0,y),d.splice(1,0,g),x=-1;const k=[];for(;++x<c.length;){const w=c[x],C=d[x];p=-1;const j=[];for(;++p<f;){const E=w[p]||"";let N="",A="";if(r.alignDelimiters!==!1){const z=m[p]-(C[p]||0),T=o[p];T===114?N=" ".repeat(z):T===99?z%2?(N=" ".repeat(z/2+.5),A=" ".repeat(z/2-.5)):(N=" ".repeat(z/2),A=N):A=" ".repeat(z)}r.delimiterStart!==!1&&!p&&j.push("|"),r.padding!==!1&&!(r.alignDelimiters===!1&&E==="")&&(r.delimiterStart!==!1||p)&&j.push(" "),r.alignDelimiters!==!1&&j.push(N),j.push(E),r.alignDelimiters!==!1&&j.push(A),r.padding!==!1&&j.push(" "),(r.delimiterEnd!==!1||p!==f-1)&&j.push("|")}k.push(r.delimiterEnd===!1?j.join("").replace(/ +$/,""):j.join(""))}return k.join(`
67
- `)}function YA(e){return e==null?"":String(e)}function av(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 XA(e,t,r,i){const a=r.enter("blockquote"),o=r.createTracker(i);o.move("> "),o.shift(2);const c=r.indentLines(r.containerFlow(e,o.current()),PA);return a(),c}function PA(e,t,r){return">"+(r?"":" ")+e}function VA(e,t){return lv(e,t.inConstruct,!0)&&!lv(e,t.notInConstruct,!1)}function lv(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let i=-1;for(;++i<t.length;)if(e.includes(t[i]))return!0;return!1}function ov(e,t,r,i){let a=-1;for(;++a<r.unsafe.length;)if(r.unsafe[a].character===`
68
- `&&VA(r.stack,r.unsafe[a]))return/[ \t]/.test(i.before)?"":" ";return`\\
69
- `}function WA(e,t){const r=String(e);let i=r.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=r.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,r,i){const a=KA(r),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(GA(e,r)){const p=r.enter("codeIndented"),y=r.indentLines(o,ZA);return p(),y}const d=r.createTracker(i),m=a.repeat(Math.max(WA(o,a)+1,3)),f=r.enter("codeFenced");let x=d.move(m);if(e.lang){const p=r.enter(`codeFencedLang${c}`);x+=d.move(r.safe(e.lang,{before:x,after:" ",encode:["`"],...d.current()})),p()}if(e.lang&&e.meta){const p=r.enter(`codeFencedMeta${c}`);x+=d.move(" "),x+=d.move(r.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,r){return(r?"":" ")+e}function a0(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,r,i){const a=a0(r),o=a==='"'?"Quote":"Apostrophe",c=r.enter("definition");let d=r.enter("label");const m=r.createTracker(i);let f=m.move("[");return f+=m.move(r.safe(r.associationId(e),{before:f,after:"]",...m.current()})),f+=m.move("]: "),d(),!e.url||/[\0- \u007F]/.test(e.url)?(d=r.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(r.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(d=r.enter("destinationRaw"),f+=m.move(r.safe(e.url,{before:f,after:e.title?" ":`
73
- `,...m.current()}))),d(),e.title&&(d=r.enter(`title${o}`),f+=m.move(" "+a),f+=m.move(r.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 Uc(e){return"&#x"+e.toString(16).toUpperCase()+";"}function hf(e,t,r){const i=co(e),a=co(t);return i===void 0?a===void 0?r==="_"?{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}}i5.peek=t6;function i5(e,t,r,i){const a=e6(r),o=r.enter("emphasis"),c=r.createTracker(i),d=c.move(a);let m=c.move(r.containerPhrasing(e,{after:a,before:d,...c.current()}));const f=m.charCodeAt(0),x=hf(i.before.charCodeAt(i.before.length-1),f,a);x.inside&&(m=Uc(f)+m.slice(1));const p=m.charCodeAt(m.length-1),y=hf(i.after.charCodeAt(0),p,a);y.inside&&(m=m.slice(0,-1)+Uc(p));const g=c.move(a);return o(),r.attentionEncodeSurroundingInfo={after:y.outside,before:x.outside},d+m+g}function t6(e,t,r){return r.options.emphasis||"*"}function n6(e,t){let r=!1;return r0(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return r=!0,ix}),!!((!e.depth||e.depth<3)&&Kx(e)&&(t.options.setext||r))}function r6(e,t,r,i){const a=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(i);if(n6(e,r)){const x=r.enter("headingSetext"),p=r.enter("phrasing"),y=r.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=r.enter("headingAtx"),m=r.enter("phrasing");o.move(c+" ");let f=r.containerPhrasing(e,{before:"# ",after:`
78
- `,...o.current()});return/^[\t ]/.test(f)&&(f=Uc(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,r.options.closeAtx&&(f+=" "+c),m(),d(),f}s5.peek=i6;function s5(e){return e.value||""}function i6(){return"<"}a5.peek=s6;function a5(e,t,r,i){const a=a0(r),o=a==='"'?"Quote":"Apostrophe",c=r.enter("image");let d=r.enter("label");const m=r.createTracker(i);let f=m.move("![");return f+=m.move(r.safe(e.alt,{before:f,after:"]",...m.current()})),f+=m.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=r.enter("destinationLiteral"),f+=m.move("<"),f+=m.move(r.safe(e.url,{before:f,after:">",...m.current()})),f+=m.move(">")):(d=r.enter("destinationRaw"),f+=m.move(r.safe(e.url,{before:f,after:e.title?" ":")",...m.current()}))),d(),e.title&&(d=r.enter(`title${o}`),f+=m.move(" "+a),f+=m.move(r.safe(e.title,{before:f,after:a,...m.current()})),f+=m.move(a),d()),f+=m.move(")"),c(),f}function s6(){return"!"}l5.peek=a6;function l5(e,t,r,i){const a=e.referenceType,o=r.enter("imageReference");let c=r.enter("label");const d=r.createTracker(i);let m=d.move("![");const f=r.safe(e.alt,{before:m,after:"]",...d.current()});m+=d.move(f+"]["),c();const x=r.stack;r.stack=[],c=r.enter("reference");const p=r.safe(r.associationId(e),{before:m,after:"]",...d.current()});return c(),r.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"!"}o5.peek=l6;function o5(e,t,r){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<r.unsafe.length;){const c=r.unsafe[o],d=r.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 c5(e,t){const r=Kx(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}u5.peek=o6;function u5(e,t,r,i){const a=a0(r),o=a==='"'?"Quote":"Apostrophe",c=r.createTracker(i);let d,m;if(c5(e,r)){const x=r.stack;r.stack=[],d=r.enter("autolink");let p=c.move("<");return p+=c.move(r.containerPhrasing(e,{before:p,after:">",...c.current()})),p+=c.move(">"),d(),r.stack=x,p}d=r.enter("link"),m=r.enter("label");let f=c.move("[");return f+=c.move(r.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=r.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(r.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(m=r.enter("destinationRaw"),f+=c.move(r.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),m(),e.title&&(m=r.enter(`title${o}`),f+=c.move(" "+a),f+=c.move(r.safe(e.title,{before:f,after:a,...c.current()})),f+=c.move(a),m()),f+=c.move(")"),d(),f}function o6(e,t,r){return c5(e,r)?"<":"["}d5.peek=c6;function d5(e,t,r,i){const a=e.referenceType,o=r.enter("linkReference");let c=r.enter("label");const d=r.createTracker(i);let m=d.move("[");const f=r.containerPhrasing(e,{before:m,after:"]",...d.current()});m+=d.move(f+"]["),c();const x=r.stack;r.stack=[],c=r.enter("reference");const p=r.safe(r.associationId(e),{before:m,after:"]",...d.current()});return c(),r.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 l0(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=l0(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}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 f5(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,r,i){const a=r.enter("list"),o=r.bulletCurrent;let c=e.ordered?d6(r):l0(r);const d=e.ordered?c==="."?")":".":u6(r);let m=t&&r.bulletLastUsed?c===r.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&x&&(!x.children||!x.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(m=!0),f5(r)===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),r.bulletCurrent=c;const f=r.containerFlow(e,i);return r.bulletLastUsed=c,r.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,r,i){const a=h6(r);let o=r.bulletCurrent||l0(r);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(r.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=r.createTracker(i);d.move(o+" ".repeat(c-o.length)),d.shift(c);const m=r.enter("listItem"),f=r.indentLines(r.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,r,i){const a=r.enter("paragraph"),o=r.enter("phrasing"),c=r.containerPhrasing(e,i);return o(),a(),c}const x6=zf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function g6(e,t,r,i){return(e.children.some(function(c){return x6(c)})?r.containerPhrasing:r.containerFlow).call(r,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}h5.peek=b6;function h5(e,t,r,i){const a=y6(r),o=r.enter("strong"),c=r.createTracker(i),d=c.move(a+a);let m=c.move(r.containerPhrasing(e,{after:a,before:d,...c.current()}));const f=m.charCodeAt(0),x=hf(i.before.charCodeAt(i.before.length-1),f,a);x.inside&&(m=Uc(f)+m.slice(1));const p=m.charCodeAt(m.length-1),y=hf(i.after.charCodeAt(0),p,a);y.inside&&(m=m.slice(0,-1)+Uc(p));const g=c.move(a+a);return o(),r.attentionEncodeSurroundingInfo={after:y.outside,before:x.outside},d+m+g}function b6(e,t,r){return r.options.strong||"*"}function v6(e,t,r,i){return r.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,r){const i=(f5(r)+(r.options.ruleSpaces?" ":"")).repeat(w6(r));return r.options.ruleSpaces?i.slice(0,-1):i}const m5={blockquote:XA,break:ov,code:QA,definition:JA,emphasis:i5,hardBreak:ov,heading:r6,html:s5,image:a5,imageReference:l5,inlineCode:o5,link:u5,linkReference:d5,list:f6,listItem:m6,paragraph:p6,root:g6,strong:h5,text:v6,thematicBreak:k6};function S6(){return{enter:{table:C6,tableData:cv,tableHeader:cv,tableRow:E6},exit:{codeText:N6,table:j6,tableData:mp,tableHeader:mp,tableRow:mp}}}function C6(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function j6(e){this.exit(e),this.data.inTable=void 0}function E6(e){this.enter({type:"tableRow",children:[]},e)}function mp(e){this.exit(e)}function cv(e){this.enter({type:"tableCell",children:[]},e)}function N6(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,A6));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function A6(e,t){return t==="|"?t:e}function T6(e){const t=e||{},r=t.tableCellPadding,i=t.tablePipeAlign,a=t.stringLength,o=r?" ":"|";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,k,w,C){return f(x(g,w,C),g.align)}function d(g,k,w,C){const j=p(g,w,C),E=f([j]);return E.slice(0,E.indexOf(`
80
- `))}function m(g,k,w,C){const j=w.enter("tableCell"),E=w.enter("phrasing"),N=w.containerPhrasing(g,{...C,before:o,after:o});return E(),j(),N}function f(g,k){return qA(g,{align:k,alignDelimiters:i,padding:r,stringLength:a})}function x(g,k,w){const C=g.children;let j=-1;const E=[],N=k.enter("table");for(;++j<C.length;)E[j]=p(C[j],k,w);return N(),E}function p(g,k,w){const C=g.children;let j=-1;const E=[],N=k.enter("tableRow");for(;++j<C.length;)E[j]=m(C[j],g,k,w);return N(),E}function y(g,k,w){let C=m5.inlineCode(g,k,w);return w.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function D6(){return{exit:{taskListCheckValueChecked:uv,taskListCheckValueUnchecked:uv,paragraph:M6}}}function _6(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:F6}}}function uv(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 r=this.stack[this.stack.length-1];r.type;const i=r.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===r&&(i.value=i.value.slice(1),i.value.length===0?r.children.shift():r.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,r.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function F6(e,t,r,i){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",d=r.createTracker(i);o&&d.move(c);let m=m5.listItem(e,t,r,{...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(),D6()]}function z6(e){return{extensions:[hA(),RA(e),OA(),T6(e),_6()]}}const B6={tokenize:U6,partial:!0},p5={tokenize:q6,partial:!0},x5={tokenize:Y6,partial:!0},g5={tokenize:X6,partial:!0},$6={tokenize:P6,partial:!0},y5={name:"wwwAutolink",tokenize:I6,previous:v5},b5={name:"protocolAutolink",tokenize:H6,previous:w5},Bs={name:"emailAutolink",tokenize:L6,previous:k5},ss={};function O6(){return{text:ss}}let Xa=48;for(;Xa<123;)ss[Xa]=Bs,Xa++,Xa===58?Xa=65:Xa===91&&(Xa=97);ss[43]=Bs;ss[45]=Bs;ss[46]=Bs;ss[95]=Bs;ss[72]=[Bs,b5];ss[104]=[Bs,b5];ss[87]=[Bs,y5];ss[119]=[Bs,y5];function L6(e,t,r){const i=this;let a,o;return c;function c(p){return!ox(p)||!k5.call(i,i.previous)||o0(i.events)?r(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(p))}function d(p){return ox(p)?(e.consume(p),d):p===64?(e.consume(p),m):r(p)}function m(p){return p===46?e.check($6,x,f)(p):p===45||p===95||mr(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&&vr(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):r(p)}}function I6(e,t,r){const i=this;return a;function a(c){return c!==87&&c!==119||!v5.call(i,i.previous)||o0(i.events)?r(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(B6,e.attempt(p5,e.attempt(x5,o),r),r)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function H6(e,t,r){const i=this;let a="",o=!1;return c;function c(p){return(p===72||p===104)&&w5.call(i,i.previous)&&!o0(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(p),e.consume(p),d):r(p)}function d(p){if(vr(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 r(p)}function m(p){return p===47?(e.consume(p),o?f:(o=!0,m)):r(p)}function f(p){return p===null||uf(p)||fn(p)||sl(p)||Mf(p)?r(p):e.attempt(p5,e.attempt(x5,x),r)(p)}function x(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function U6(e,t,r){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):r(c)}function o(c){return c===null?r(c):t(c)}}function q6(e,t,r){let i,a,o;return c;function c(f){return f===46||f===95?e.check(g5,m,d)(f):f===null||fn(f)||sl(f)||f!==45&&Mf(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?r(f):t(f)}}function Y6(e,t){let r=0,i=0;return a;function a(c){return c===40?(r++,e.consume(c),a):c===41&&i<r?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(g5,t,o)(c):c===null||fn(c)||sl(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&i++,e.consume(c),a}}function X6(e,t,r){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||fn(d)||sl(d)?t(d):r(d)}function a(d){return d===null||d===40||d===91||fn(d)||sl(d)?t(d):i(d)}function o(d){return vr(d)?c(d):r(d)}function c(d){return d===59?(e.consume(d),i):vr(d)?(e.consume(d),c):r(d)}}function P6(e,t,r){return i;function i(o){return e.consume(o),a}function a(o){return mr(o)?r(o):t(o)}}function v5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||fn(e)}function w5(e){return!vr(e)}function k5(e){return!(e===47||ox(e))}function ox(e){return e===43||e===45||e===46||e===95||mr(e)}function o0(e){let t=e.length,r=!1;for(;t--;){const i=e[t][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){r=!0;break}if(i._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}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,r){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 r(m);const f=zi(i.sliceSerialize({start:c.end,end:i.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?r(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),t(m))}}function K6(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+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[r+1],e[r+2],["enter",i,t],e[r+3],e[r+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(r,e.length-r+1,...d),e}function Q6(e,t,r){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?r(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||fn(p))return r(p);if(p===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return a.includes(zi(i.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return fn(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,r){const i=this,a=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,c=0,d;return m;function m(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):r(k)}function x(k){if(c>999||k===93&&!d||k===null||k===91||fn(k))return r(k);if(k===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return o=zi(i.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return fn(k)||(d=!0),c++,e.consume(k),k===92?p:x}function p(k){return k===91||k===92||k===93?(e.consume(k),c++,x):x(k)}function y(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),a.includes(o)||a.push(o),Ht(e,g,"gfmFootnoteDefinitionWhitespace")):r(k)}function g(k){return t(k)}}function J6(e,t,r){return e.check(nu,t,e.attempt(V6,t,r))}function e8(e){e.exit("gfmFootnoteDefinition")}function t8(e,t,r){const i=this;return Ht(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):r(o)}}function n8(e){let r=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:a};return r==null&&(r=!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&&ni(y,y.length,0,Ff(g,c.slice(f+1,m),d)),ni(y,y.length,0,[["exit",p,d],["enter",c[m][1],d],["exit",c[m][1],d],["exit",x,d]]),ni(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(k){return f===126&&x[x.length-1][1].type!=="characterEscape"?m(k):(c.enter("strikethroughSequenceTemporary"),g(k))}function g(k){const w=co(f);if(k===126)return p>1?m(k):(c.consume(k),p++,g);if(p<2&&!r)return m(k);const C=c.exit("strikethroughSequenceTemporary"),j=co(k);return C._open=!j||j===2&&!!w,C._close=!w||w===2&&!!j,d(k)}}}class r8{constructor(){this.map=[]}add(t,r,i){i8(this,t,r,i)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const i=[];for(;r>0;)r-=1,i.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][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,r,i){let a=0;if(!(r===0&&i.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=r,e.map[a][2].push(...i);return}a+=1}e.map.push([t,r,i])}}function s8(e,t){let r=!1;const i=[];for(;t<e.length;){const a=e[t];if(r){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"&&(r=!0);t+=1}return i}function a8(){return{flow:{null:{name:"table",tokenize:l8,resolveAll:o8}}}}function l8(e,t,r){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 O=_>-1?i.events[_][1].type:null,P=O==="tableHead"||O==="tableRow"?T:m;return P===T&&i.parser.lazy[i.now().line]?r(L):P(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?r(L):ht(L)?o>1?(o=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),g):r(L):zt(L)?Ht(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||fn(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]?r(L):(e.enter("tableDelimiterRow"),c=!1,zt(L)?Ht(e,k,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):k(L))}function k(L){return L===45||L===58?C(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),w):z(L)}function w(L){return zt(L)?Ht(e,C,"whitespace")(L):C(L)}function C(L){return L===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),j):L===45?(o+=1,j(L)):L===null||ht(L)?A(L):z(L)}function j(L){return L===45?(e.enter("tableDelimiterFiller"),E(L)):z(L)}function E(L){return L===45?(e.consume(L),E):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),N):(e.exit("tableDelimiterFiller"),N(L))}function N(L){return zt(L)?Ht(e,A,"whitespace")(L):A(L)}function A(L){return L===124?k(L):L===null||ht(L)?!c||a!==o?z(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):z(L)}function z(L){return r(L)}function T(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||ht(L)?(e.exit("tableRow"),t(L)):zt(L)?Ht(e,F,"whitespace")(L):(e.enter("data"),q(L))}function q(L){return L===null||L===124||fn(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 r=-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(;++r<e.length;){const g=e[r],k=g[1];g[0]==="enter"?k.type==="tableHead"?(d=!1,m!==0&&(dv(y,t,m,f,x),x=void 0,m=0),f={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},y.add(r,0,[["enter",f,t]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(i=!0,p=void 0,o=[0,0,0,0],c=[0,r+1,0,0],d&&(d=!1,x={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},y.add(r,0,[["enter",x,t]])),a=k.type==="tableDelimiterRow"?2:x?3:1):a&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],p=Dd(y,t,o,a,void 0,p),o=[0,0,0,0]),c[2]=r)):k.type==="tableCellDivider"&&(i?i=!1:(o[1]!==0&&(c[0]=c[1],p=Dd(y,t,o,a,void 0,p)),o=c,c=[o[1],r,0,0])):k.type==="tableHead"?(d=!0,m=r):k.type==="tableRow"||k.type==="tableDelimiterRow"?(m=r,o[1]!==0?(c[0]=c[1],p=Dd(y,t,o,a,r,p)):c[1]!==0&&(p=Dd(y,t,c,a,r,p)),a=0):a&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(c[3]=r)}for(m!==0&&dv(y,t,m,f,x),y.consume(t.events),r=-1;++r<t.events.length;){const g=t.events[r];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=s8(t.events,r))}return e}function Dd(e,t,r,i,a,o){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",d="tableContent";r[0]!==0&&(o.end=Object.assign({},eo(t.events,r[0])),e.add(r[0],0,[["exit",o,t]]));const m=eo(t.events,r[1]);if(o={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(r[1],0,[["enter",o,t]]),r[2]!==0){const f=eo(t.events,r[2]),x=eo(t.events,r[3]),p={type:d,start:Object.assign({},f),end:Object.assign({},x)};if(e.add(r[2],0,[["enter",p,t]]),i!==2){const y=t.events[r[2]],g=t.events[r[3]];if(y[1].end=Object.assign({},g[1].end),y[1].type="chunkText",y[1].contentType="text",r[3]>r[2]+1){const k=r[2]+1,w=r[3]-r[2]-1;e.add(k,w,[])}}e.add(r[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 dv(e,t,r,i,a){const o=[],c=eo(t.events,r);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),i.end=Object.assign({},c),o.push(["exit",i,t]),e.add(r+1,0,o)}function eo(e,t){const r=e[t],i=r[0]==="enter"?"start":"end";return r[1][i]}const c8={name:"tasklistCheck",tokenize:d8};function u8(){return{text:{91:c8}}}function d8(e,t,r){const i=this;return a;function a(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?r(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),o)}function o(m){return fn(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):r(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):r(m)}function d(m){return ht(m)?t(m):zt(m)?e.check({tokenize:f8},t,r)(m):r(m)}}function f8(e,t,r){return Ht(e,i,"whitespace");function i(a){return a===null?r(a):t(a)}}function h8(e){return F2([O6(),W6(),n8(e),a8(),u8()])}const m8={};function c0(e){const t=this,r=e||m8,i=t.data(),a=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);a.push(h8(r)),o.push(R6()),c.push(z6(r))}function Co({content:e,className:t=""}){return l.jsx("div",{className:`office-markdown ${t}`,children:l.jsx(s0,{remarkPlugins:[c0],components:{code:p8,table:({children:r})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"office-table",children:r})})},children:e})})}function p8({className:e,children:t,...r}){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)"},...r,children:t})}function x8({children:e,language:t}){const[r,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:r?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:a})})]})}var fv={$skin:"skinColor",$hair:"hairColor",$shirt:"shirtColor",$pants:"pantsColor",$shoes:"shoeColor"},g8=/^(darken|lighten)\((\$\w+),\s*(\d+)\)$/;function y8(e,t){const r=parseInt(e.replace("#",""),16),i=Math.max(0,(r>>16&255)-t),a=Math.max(0,(r>>8&255)-t),o=Math.max(0,(r&255)-t);return`#${(i<<16|a<<8|o).toString(16).padStart(6,"0")}`}function b8(e,t){const r=parseInt(e.replace("#",""),16),i=Math.min(255,(r>>16&255)+t),a=Math.min(255,(r>>8&255)+t),o=Math.min(255,(r&255)+t);return`#${(i<<16|a<<8|o).toString(16).padStart(6,"0")}`}function u0(e,t){const r=fv[e];if(r&&t)return t[r];const i=g8.exec(e);if(i){const[,a,o,c]=i,d=fv[o],m=d&&t?t[d]:o,f=parseInt(c,10);return a==="darken"?y8(m,f):b8(m,f)}return e}function cx(e,t=12){return e.map(r=>({...r,x:t-r.x-r.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:cx(e.left.pixels)}:t==="left"&&e.right?{name:e.right.name,pixels:cx(e.right.pixels)}:e.down}function w8(e,t){return ux(e,"hair",t,1)}function ux(e,t,r,i){const a=e.layers.findIndex(c=>c.name===t),o=[...e.layers];if(a>=0)o[a]={...r,name:t};else{const c=i??o.length;o.splice(c,0,{...r,name:t})}return{...e,layers:o}}var S5=new Map,k8=new Map;function C5(e,t){S5.set(e,t)}function $f(e,t){k8.set(e,t)}function dx(e){return S5.get(e)}function S8(e,t,r,i,a=2){e.clearRect(0,0,t.width*a,t.height*a);for(const o of t.layers)C8(e,o.pixels,a,r,i)}function xa(e,t,r,i,a){for(const o of t){const c=u0(o.c,a);o.a!==void 0&&o.a!==1&&(e.globalAlpha=o.a),e.fillStyle=c,e.fillRect(r+o.x,i+o.y,o.w,o.h),o.a!==void 0&&o.a!==1&&(e.globalAlpha=1)}}function C8(e,t,r,i,a){for(const o of t){const c=u0(o.c,a);o.a!==void 0&&o.a!==1&&(e.globalAlpha=o.a),e.fillStyle=c,e.fillRect(o.x*r,(o.y+i)*r,o.w*r,o.h*r),o.a!==void 0&&o.a!==1&&(e.globalAlpha=1)}}var mf=new Map;function Sa(e,t,r){if("down"in r&&!("pixels"in r)){const a=r;mf.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=r;mf.set(e,{id:e,name:t,layer:{...a,name:"hair"}})}}function fx(e){return mf.get(e)}function d0(){return Array.from(mf.values())}Sa("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}]}});Sa("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}]}});Sa("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}]}});Sa("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}]}});Sa("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"}]}});Sa("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}]}});Sa("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}]}});Sa("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 j8={short:1,messy:1,bun:2,long:2,mohawk:3,slicked:3,bob:4,curly:4},E8={short:0,messy:0,bun:500,long:500,mohawk:2e3,slicked:2e3,bob:5e3,curly:5e3};function j5(e){return j8[e]??1}function E5(e,t){return t>=j5(e)}function N8(e){return E8[e]??0}var pf=new Map;function as(e,t,r){if("down"in r&&!("pixels"in r)){const a=r;pf.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=r;pf.set(e,{id:e,name:t,layer:{...a,name:"torso"}})}}function hx(e){return pf.get(e)}function f0(){return Array.from(pf.values())}as("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"}]}});as("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"}]}});as("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"}]}});as("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)"}]}});as("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)"}]}});as("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"}]}});as("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"}]}});as("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"}]}});as("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"}]}});as("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},T8={tshirt:0,polo:0,hoodie:500,vest:500,suit:3e3,tank:1e3,overalls:5e3,turtleneck:5e3,labcoat:1e4,robe:1e4};function N5(e){return A8[e]??1}function A5(e,t){return t>=N5(e)}function D8(e){return T8[e]??0}var qc=new Map;function Zt(e,t,r){if("down"in r&&!("pixels"in r)){const a=r;qc.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=r;qc.set(e,{id:e,name:t,layer:{...a,name:"accessory"}})}}function T5(e){return qc.get(e)}function _8(e,t){const r=qc.get(e);if(!r)return;if(r.directions)return v8(r.directions,t);if(t==="down")return r.layer;const i=r.layer.pixels.filter(o=>o.y<2);if(i.length===0)return;const a=t==="right"?1:t==="left"?-1:0;return{name:r.layer.name,pixels:a?i.map(o=>({...o,x:o.x+a})):i}}function h0(){return Array.from(qc.values())}Zt("none","None",{name:"accessory",pixels:[]});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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"}]}});Zt("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}]}});Zt("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}]}});Zt("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"}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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"}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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}]}});Zt("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"}]}});Zt("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"}]}});Zt("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}]}});Zt("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}]}});Zt("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 D5(e){return M8[e]??1}function _5(e,t){return t>=D5(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}Zt("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 Cc({r:e,g:t,b:r}){return`#${(e<<16|t<<8|r).toString(16).padStart(6,"0")}`}function tf(e,t){const r=e.r-t.r,i=e.g-t.g,a=e.b-t.b;return r*r+i*i+a*a}function z8(e,t){const r=[];r.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 r)m=Math.min(m,tf(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){r.push(e[d]);break}r.length<=i&&r.push(e[Math.floor(Math.random()*e.length)])}return r}function B8(e,t,r=20){if(e.length===0)return[];const i=z8(e,t);for(let o=0;o<r;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=tf(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)};tf(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=tf(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 r=document.createElement("canvas"),i=e instanceof HTMLImageElement?e.naturalWidth:e.width,a=e instanceof HTMLImageElement?e.naturalHeight:e.height;r.width=i,r.height=a;const o=r.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 hv(e){return .299*e.r+.587*e.g+.114*e.b}function mv(e){const t=Math.max(e.r,e.g,e.b),r=Math.min(e.r,e.g,e.b);return t===0?0:(t-r)/t*255}function O8(e,t=8){const r=$8(e),i=B8(r,t);if(i.length<5)return{skinColor:"#F5CBA7",hairColor:"#2C1810",shirtColor:"#1565C0",pantsColor:"#37474F",shoeColor:"#212121"};const a=[...i].sort((p,y)=>hv(y)-hv(p)),o=[...i].sort((p,y)=>mv(y)-mv(p)),c=a[0],d=a[a.length-1],m=o[0],f=a[a.length-2],x=a[a.length-1];return{skinColor:Cc(c),hairColor:Cc(d),shirtColor:Cc(m),pantsColor:Cc(f),shoeColor:Cc(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 jc(e,t,r,i,a,o){for(const c of t){const d=u0(c.c,o);c.a!==void 0&&c.a!==1&&(e.globalAlpha=c.a),e.fillStyle=d,e.fillRect((c.x+i)*r,(c.y+a)*r,c.w*r,c.h*r),c.a!==void 0&&c.a!==1&&(e.globalAlpha=1)}}function H8(e){var r;const t=fx(e);return t?(r=t.directions)!=null&&r.down?t.directions.down.pixels:t.layer.pixels:fx("short").layer.pixels}function U8(e){var r;const t=hx(e);return t?(r=t.directions)!=null&&r.down?t.directions.down.pixels:t.layer.pixels:hx("tshirt").layer.pixels}function q8(e){var r;const t=T5(e);return t?(r=t.directions)!=null&&r.down?t.directions.down.pixels:t.layer.pixels:[]}function jL(e,t){const r=(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*r,m.height=d*r,m.style.imageRendering="pixelated";const f=m.getContext("2d"),x=i,p=a;jc(f,L8,r,x,p,e);const y=e.outfitStyle||"tshirt";jc(f,U8(y),r,x,p,e),jc(f,I8,r,x,p,e);const g=e.hairStyle||"short";jc(f,H8(g),r,x,p,e);const k=e.accessory||"none";return jc(f,q8(k),r,x,p,e),m}var EL=d0().map(e=>e.id),Y8=f0().map(e=>e.id),NL=Y8,AL=h0().map(e=>e.id);const X8=[{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}],P8=[{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:X8},{name:"torso",pixels:P8},{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 eT(){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",eT());const tT={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"}]},nT={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"}]},rT={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"}]},iT={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"}]};$f("meeting",tT);$f("bulletin",nT);$f("decision",iT);$f("knowledge",rT);const pp=16,xp=24,sT=60,aT={cbo:0,cto:8,pm:15,engineer:22,designer:5,qa:12};function M5(e,t){if(!e)return e;let r=e;if(t!=null&&t.hairStyle){const i=fx(t.hairStyle);i&&(r=w8(r,i.layer))}if(t!=null&&t.outfitStyle){const i=hx(t.outfitStyle);i&&(r=ux(r,"torso",i.layer,1))}if(t!=null&&t.accessory&&t.accessory!=="none"){const i=T5(t.accessory);i&&(r=ux(r,"accessory",i.layer))}return r}function wa({roleId:e,className:t,appearance:r,scale:i}){const a=S.useRef(null),o=S.useRef(0),c=S.useRef(0),d=S.useRef(r);d.current=r;const m=i??4,f=pp*m,x=xp*m,p=S.useMemo(()=>{const y=dx(`mini:${e}`)??dx("mini:default");return M5(y,r)},[e,r==null?void 0:r.hairStyle,r==null?void 0:r.outfitStyle,r==null?void 0:r.accessory]);return S.useEffect(()=>{const y=a.current;if(!y)return;const g=y.getContext("2d");if(!g)return;const k=aT[e]??0,w=()=>{c.current++;const C=d.current;if(!C||!p){o.current=requestAnimationFrame(w);return}const E=(c.current+k)%sT<30?1:0;g.clearRect(0,0,pp,xp),g.save(),g.translate(2,1),S8(g,p,E,C,1),g.restore(),o.current=requestAnimationFrame(w)};return o.current=requestAnimationFrame(w),()=>cancelAnimationFrame(o.current)},[e,p]),l.jsx("canvas",{ref:a,width:pp,height:xp,className:t,style:{imageRendering:"pixelated",display:"block",width:f,height:x}})}const lT="https://api.tycono.ai",m0=lT;async function Ec(e){const t=await fetch(`${m0}${e}`);if(!t.ok)throw new Error(`Cloud API error: ${t.status}`);return t.json()}async function Pa(e,t){const r=await fetch(`${m0}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`Cloud API error: ${r.status}`);return r.json()}const Rr={health:()=>Ec("/api/health"),getMyName:e=>Ec(`/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 r=t.toString();return Ec(`/api/store/characters${r?`?${r}`:""}`)},getCharacter:e=>Ec(`/api/store/characters/${e}`),getCharacterVersion:e=>Ec(`/api/store/characters/${e}/version`),voteCharacter:(e,t,r)=>Pa(`/api/store/characters/${e}/vote`,{instanceId:t,vote:r}),trackInstall:e=>Pa(`/api/store/characters/${e}/install`,{}),syncCheck:e=>Pa("/api/sync/check",{roles:e}),syncPull:e=>Pa("/api/sync/pull",{sourceId:e}),publishCharacter:e=>Pa("/api/store/publish",e),deleteCharacter:(e,t)=>{const r=t?`?publisher_id=${encodeURIComponent(t)}`:"";return fetch(`${m0}/api/store/characters/${e}${r}`,{method:"DELETE"}).then(i=>i.json())},uploadTelemetry:e=>Pa("/api/telemetry",e),syncStats:e=>Pa("/api/stats/sync",e)},oT={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"},gp={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},cT={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},uT=500,pv=360,xv=700,dT=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function gv({role:e,allRoles:t,recentActivity:r,onClose:i,onFireRole:a,terminalWidth:o=0,activeSessionId:c,activeTask:d,isWorking:m,startedAt:f,onAbortSession:x,sessions:p,streamingSessionId:y,onCreateSessionSilent:g,onSendMessage:k,onFocusTerminal:w,onCustomize:C,onUpdateRole:j,appearance:E,relationships:N,roleLevel:A,onMaximize:z}){var lt,tt;const[T,F]=S.useState(uT),[q,V]=S.useState(!1),L=S.useRef(0),_=S.useRef(0),[O,P]=S.useState(!1),[R,H]=S.useState(!1),[B,Z]=S.useState(!1),[G,K]=S.useState(!1),[M,U]=S.useState("talk"),[Y,$]=S.useState(!1),[Q,ee]=S.useState(""),[J,ae]=S.useState(!1),oe=S.useRef(null),[be,Ee]=S.useState(!1),[Ae,Fe]=S.useState(""),[he,Re]=S.useState(!1),{events:et,status:We}=y2(c??null),[it,mt]=S.useState(0);S.useEffect(()=>{if(!m||!f){mt(0);return}const ze=new Date(f).getTime(),He=()=>mt(Math.floor((Date.now()-ze)/1e3));He();const qt=setInterval(He,1e3);return()=>clearInterval(qt)},[m,f]);const Ye=o>0,Ze=Ye?o:0,ut=Ye?Math.max(pv,window.innerWidth-o-100):xv,jt=Math.min(T,ut),ge=S.useCallback(ze=>{ze.preventDefault(),L.current=ze.clientX,_.current=jt,V(!0);const He=z,qt=()=>{V(!1),document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",qt)},Kt=Et=>{const Xt=L.current-Et.clientX,hn=_.current+Xt;if(hn>=window.innerWidth*.6&&He){qt(),He();return}const vn=Math.min(xv,Math.max(pv,hn));F(vn)};document.addEventListener("mousemove",Kt),document.addEventListener("mouseup",qt)},[jt,z]),ve=S.useRef(null),Ce=e?p.find(ze=>ze.roleId===e.id):null,ne=ze=>{if(!e)return;const He=m?"talk":M;Ce?(k(Ce.id,ze,He),w(e.id)):(ve.current={content:ze,mode:He},g(e.id))};S.useEffect(()=>{if(Ce&&ve.current){const{content:ze,mode:He}=ve.current;ve.current=null,k(Ce.id,ze,He),e&&w(e.id)}},[Ce==null?void 0:Ce.id]);const de=(()=>{if(!et.length)return null;const ze=[];let He=0,qt=0,Kt=0;for(const Et of et)if(Et.type==="thinking")He++;else if(Et.type==="text")qt++;else if(Et.type==="tool:start"){const Xt=String(Et.data.name??"");ze.includes(Xt)||ze.push(Xt)}else Et.type==="dispatch:start"&&Kt++;return{tools:ze,thinkCount:He,textCount:qt,dispatchCount:Kt,total:et.length}})(),_e=d||(()=>{if(!Ce)return null;const ze=Ce.messages;for(let He=ze.length-1;He>=0;He--)if(ze[He].from==="ceo")return ze[He].content;return null})(),ce=(()=>{if(!Ce)return null;const ze=Ce.messages;for(let He=ze.length-1;He>=0;He--)if(ze[He].from==="role"&&ze[He].content)return ze[He].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:Ze},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:Ze,width:jt,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 Te=gp[e.id]??"#666",Le=oT[e.id]??"👤",Xe=t.filter(ze=>ze.reportsTo===e.id),Ue=Ce&&y===Ce.id,Pe=e.name||cT[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:Ze},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:Te,right:Ze,width:jt,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:ge}),l.jsxs("div",{className:"relative shrink-0 overflow-hidden",style:{background:`linear-gradient(135deg, ${Te}ee, ${Te}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:[C&&l.jsx("button",{onClick:()=>C(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(wa,{roleId:e.id,appearance:E,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:[Le," ",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"})]}),Y?l.jsxs("form",{className:"flex items-center gap-1.5 mt-0.5",onSubmit:async ze=>{ze.preventDefault();const He=Q.trim();if(!He||He===Pe||!j){$(!1);return}ae(!0);try{await j(e.id,{name:He})}catch{}ae(!1),$(!1)},children:[l.jsx("input",{ref:oe,value:Q,onChange:ze=>ee(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&$(!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:()=>$(!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:()=>{j&&(ee(Pe),$(!0))},title:j?"Click to edit name":void 0,children:[Pe,j&&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?` · ${dT(it)}`:""]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>w(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"})]})]}),_e&&l.jsx("div",{className:"text-xs truncate",style:{color:"var(--terminal-text-secondary)"},children:_e})]}),m&&c&&de&&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:()=>w(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:[de.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 ×",de.thinkCount]}),de.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)),de.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 ×",de.dispatchCount]}),de.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 ×",de.textCount]}),(We==="streaming"||We==="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:[de.total," events"]})]}),m&&ce&&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:()=>w(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:[ce.slice(0,200),ce.length>200&&"..."]})]}),m&&l.jsx("div",{className:"px-4 py-2.5 shrink-0",style:{borderBottom:"1px solid var(--terminal-border)"},children:l.jsx(yv,{onSend:ne,disabled:!!Ue,placeholder:"Ask something...",color:Te})}),!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(hT,{icon:Le,roleId:e.id,roleName:Pe,color:Te,text:r})]}),!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:[ce&&l.jsxs("div",{className:"px-3 pt-2.5 pb-2 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--terminal-border)"},onClick:()=>w(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:[ce.slice(0,150),ce.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(yv,{onSend:ne,disabled:!!Ue,placeholder:M==="talk"?"Ask something...":"Give a directive...",color:Te})]})})]})}),l.jsxs("div",{className:"px-4 py-2 space-y-1",children:[l.jsxs(_d,{title:`Profile${e.persona?"":" (empty)"}`,open:O,onToggle:()=>P(ze=>!ze),children:[be?l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{value:Ae,onChange:ze=>Fe(ze.target.value),onKeyDown:ze=>{ze.key==="Escape"&&Ee(!1)},disabled:he,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:()=>Ee(!1),disabled:he,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(j){Re(!0);try{await j(e.id,{persona:Ae.trim()})}catch{}Re(!1),Ee(!1)}},disabled:he,className:"text-[10px] px-2 py-0.5 rounded cursor-pointer font-semibold",style:{background:"var(--active-green)",color:"#000"},children:he?"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:()=>{j&&(Fe(e.persona||""),Ee(!0))},title:j?"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."}),j&&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(yp,{label:"Level",value:e.level}),l.jsx(yp,{label:"Reports to",value:e.reportsTo}),l.jsx(yp,{label:"Status",value:e.status})]}),Xe.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:Xe.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:gp[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(_d,{title:"Authority",open:R,onToggle:()=>H(ze=>!ze),children:[((lt=e.authority.autonomous)==null?void 0:lt.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,He)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",ze]},He))]}),((tt=e.authority.needsApproval)==null?void 0:tt.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,He)=>l.jsxs("div",{className:"text-xs pl-3 py-0.5",style:{color:"var(--terminal-text-secondary)"},children:["- ",ze]},He))]})]}),e&&N&&(()=>{const ze=N.filter(He=>He.roleA===e.id||He.roleB===e.id).filter(He=>He.familiarity>0).sort((He,qt)=>qt.familiarity-He.familiarity);return ze.length===0?null:l.jsx(_d,{title:`Relationships (${ze.length})`,open:B,onToggle:()=>Z(He=>!He),children:l.jsx("div",{className:"space-y-1.5",children:ze.map((He,qt)=>{const Kt=He.roleA===e.id?He.roleB:He.roleA,Et=t.find(vn=>vn.id===Kt),Xt=He.familiarity>=80?"Best Partner":He.familiarity>=50?"Friend":He.familiarity>=20?"Colleague":"Acquaintance",hn=He.familiarity>=80?"#4CAF50":He.familiarity>=50?"#2196F3":He.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:gp[Kt]??"var(--terminal-text-secondary)"},children:(Et==null?void 0:Et.name)??Kt}),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:`${He.familiarity}%`,background:hn}})}),l.jsx("span",{className:"text-[10px] w-16 text-right",style:{color:"var(--terminal-text-muted)"},children:Xt})]},qt)})})})})(),e.journal&&l.jsx(_d,{title:`Journal (${(e.journal.match(/### /g)??[]).length})`,open:G,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(Co,{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(fT,{role:e,appearance:E}),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 fT({role:e,appearance:t}){const[r,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),[k,w]=S.useState(null);S.useEffect(()=>{Rr.getCharacterVersion(e.id).then(E=>f((E==null?void 0:E.version)??null)).catch(()=>f(null)),Se.getPreferences().then(E=>w(E.instanceId??null)).catch(()=>{})},[e.id]);const C=async()=>{var E,N;if(!c){d(!0);return}i("publishing");try{let A=null;try{A=await Se.exportSkills(e.id)}catch{}const z={roleId:e.id,persona:e.persona??"",authority:e.authority??{autonomous:[],needsApproval:[]},level:e.level,tagline:((E=(e.persona??"").split(/[.\n]/)[0])==null?void 0:E.trim().slice(0,80))||e.name,chatStyle:"Professional and focused",skills:A??[],resume:{summary:((N=e.persona)==null?void 0:N.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 T="1.0.0";try{const F=await Rr.getCharacterVersion(e.id);if(F!=null&&F.version){const q=F.version.split(".").map(Number);q[2]=(q[2]??0)+1,T=q.join(".")}}catch{}await Rr.publishCharacter({id:e.id,name:e.name||e.id,version:T,data:z,publisherId:k??void 0}),i("done"),o(`Published v${T}`),f(T),d(!1)}catch(A){i("error"),o(A instanceof Error?A.message:"Failed"),d(!1)}},j=async()=>{g(!0);try{await Rr.deleteCharacter(e.id,k??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:E=>E.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:[r==="done"?l.jsx(l.Fragment,{children:l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"var(--active-green)"},children:a})}):r==="error"?l.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#ef4444"},children:a}):l.jsx("button",{onClick:C,disabled:r==="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:r==="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:j,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 hT({icon:e,roleId:t,roleName:r,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:r}),o?l.jsx("div",{className:"text-sm leading-relaxed",style:{color:"var(--terminal-text)"},children:l.jsx(Co,{content:a})}):l.jsx("div",{className:"text-sm italic",style:{color:"var(--terminal-text-muted)"},children:"No recent activity."})]})]})})]})})}function _d({title:e,open:t,onToggle:r,children:i}){return l.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--terminal-border)"},children:[l.jsxs("button",{onClick:r,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 yv({onSend:e,disabled:t,placeholder:r,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...":r,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 yp({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 mT(e,t){var r,i=1;e==null&&(e=0),t==null&&(t=0);function a(){var o,c=r.length,d,m=0,f=0;for(o=0;o<c;++o)d=r[o],m+=d.x,f+=d.y;for(m=(m/c-e)*i,f=(f/c-t)*i,o=0;o<c;++o)d=r[o],d.x-=m,d.y-=f}return a.initialize=function(o){r=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 pT(e){const t=+this._x.call(null,e),r=+this._y.call(null,e);return F5(this.cover(t,r),t,r,e)}function F5(e,t,r,i){if(isNaN(t)||isNaN(r))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,k,w,C,j,E;if(!o)return e._root=c,e;for(;o.length;)if((w=t>=(p=(d+f)/2))?d=p:f=p,(C=r>=(y=(m+x)/2))?m=y:x=y,a=o,!(o=o[j=C<<1|w]))return a[j]=c,e;if(g=+e._x.call(null,o.data),k=+e._y.call(null,o.data),t===g&&r===k)return c.next=o,a?a[j]=c:e._root=c,e;do a=a?a[j]=new Array(4):e._root=new Array(4),(w=t>=(p=(d+f)/2))?d=p:f=p,(C=r>=(y=(m+x)/2))?m=y:x=y;while((j=C<<1|w)===(E=(k>=y)<<1|g>=p));return a[E]=o,a[j]=c,e}function xT(e){var t,r,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(r=0;r<i;++r)isNaN(a=+this._x.call(null,t=e[r]))||isNaN(o=+this._y.call(null,t))||(c[r]=a,d[r]=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),r=0;r<i;++r)F5(this,c[r],d[r],e[r]);return this}function gT(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var r=this._x0,i=this._y0,a=this._x1,o=this._y1;if(isNaN(r))a=(r=Math.floor(e))+1,o=(i=Math.floor(t))+1;else{for(var c=a-r||1,d=this._root,m,f;r>e||e>=a||i>t||t>=o;)switch(f=(t<i)<<1|e<r,m=new Array(4),m[f]=d,d=m,c*=2,f){case 0:a=r+c,o=i+c;break;case 1:r=a-c,o=i+c;break;case 2:a=r+c,i=o-c;break;case 3:r=a-c,i=o-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._x1=a,this._y1=o,this}function yT(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function bT(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 wr(e,t,r,i,a){this.node=e,this.x0=t,this.y0=r,this.x1=i,this.y1=a}function vT(e,t,r){var i,a=this._x0,o=this._y0,c,d,m,f,x=this._x1,p=this._y1,y=[],g=this._root,k,w;for(g&&y.push(new wr(g,a,o,x,p)),r==null?r=1/0:(a=e-r,o=t-r,x=e+r,p=t+r,r*=r);k=y.pop();)if(!(!(g=k.node)||(c=k.x0)>x||(d=k.y0)>p||(m=k.x1)<a||(f=k.y1)<o))if(g.length){var C=(c+m)/2,j=(d+f)/2;y.push(new wr(g[3],C,j,m,f),new wr(g[2],c,j,C,f),new wr(g[1],C,d,m,j),new wr(g[0],c,d,C,j)),(w=(t>=j)<<1|e>=C)&&(k=y[y.length-1],y[y.length-1]=y[y.length-1-w],y[y.length-1-w]=k)}else{var E=e-+this._x.call(null,g.data),N=t-+this._y.call(null,g.data),A=E*E+N*N;if(A<r){var z=Math.sqrt(r=A);a=e-z,o=t-z,x=e+z,p=t+z,i=g.data}}return i}function wT(e){if(isNaN(x=+this._x.call(null,e))||isNaN(p=+this._y.call(null,e)))return this;var t,r=this._root,i,a,o,c=this._x0,d=this._y0,m=this._x1,f=this._y1,x,p,y,g,k,w,C,j;if(!r)return this;if(r.length)for(;;){if((k=x>=(y=(c+m)/2))?c=y:m=y,(w=p>=(g=(d+f)/2))?d=g:f=g,t=r,!(r=r[C=w<<1|k]))return this;if(!r.length)break;(t[C+1&3]||t[C+2&3]||t[C+3&3])&&(i=t,j=C)}for(;r.data!==e;)if(a=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,a?(o?a.next=o:delete a.next,this):t?(o?t[C]=o:delete t[C],(r=t[0]||t[1]||t[2]||t[3])&&r===(t[3]||t[2]||t[1]||t[0])&&!r.length&&(i?i[j]=r:this._root=r),this):(this._root=o,this)}function kT(e){for(var t=0,r=e.length;t<r;++t)this.remove(e[t]);return this}function ST(){return this._root}function CT(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function jT(e){var t=[],r,i=this._root,a,o,c,d,m;for(i&&t.push(new wr(i,this._x0,this._y0,this._x1,this._y1));r=t.pop();)if(!e(i=r.node,o=r.x0,c=r.y0,d=r.x1,m=r.y1)&&i.length){var f=(o+d)/2,x=(c+m)/2;(a=i[3])&&t.push(new wr(a,f,x,d,m)),(a=i[2])&&t.push(new wr(a,o,x,f,m)),(a=i[1])&&t.push(new wr(a,f,c,d,x)),(a=i[0])&&t.push(new wr(a,o,c,f,x))}return this}function ET(e){var t=[],r=[],i;for(this._root&&t.push(new wr(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 wr(o,c,d,x,p)),(o=a[1])&&t.push(new wr(o,x,d,m,p)),(o=a[2])&&t.push(new wr(o,c,p,x,f)),(o=a[3])&&t.push(new wr(o,x,p,m,f))}r.push(i)}for(;i=r.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function NT(e){return e[0]}function AT(e){return arguments.length?(this._x=e,this):this._x}function TT(e){return e[1]}function DT(e){return arguments.length?(this._y=e,this):this._y}function p0(e,t,r){var i=new x0(t??NT,r??TT,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function x0(e,t,r,i,a,o){this._x=e,this._y=t,this._x0=r,this._y0=i,this._x1=a,this._y1=o,this._root=void 0}function bv(e){for(var t={data:e.data},r=t;e=e.next;)r=r.next={data:e.data};return t}var kr=p0.prototype=x0.prototype;kr.copy=function(){var e=new x0(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,r,i;if(!t)return e;if(!t.length)return e._root=bv(t),e;for(r=[{source:t,target:e._root=new Array(4)}];t=r.pop();)for(var a=0;a<4;++a)(i=t.source[a])&&(i.length?r.push({source:i,target:t.target[a]=new Array(4)}):t.target[a]=bv(i));return e};kr.add=pT;kr.addAll=xT;kr.cover=gT;kr.data=yT;kr.extent=bT;kr.find=vT;kr.remove=wT;kr.removeAll=kT;kr.root=ST;kr.size=CT;kr.visit=jT;kr.visitAfter=ET;kr.x=AT;kr.y=DT;function el(e){return function(){return e}}function ya(e){return(e()-.5)*1e-6}function _T(e){return e.x+e.vx}function MT(e){return e.y+e.vy}function FT(e){var t,r,i,a=1,o=1;typeof e!="function"&&(e=el(e==null?1:+e));function c(){for(var f,x=t.length,p,y,g,k,w,C,j=0;j<o;++j)for(p=p0(t,_T,MT).visitAfter(d),f=0;f<x;++f)y=t[f],w=r[y.index],C=w*w,g=y.x+y.vx,k=y.y+y.vy,p.visit(E);function E(N,A,z,T,F){var q=N.data,V=N.r,L=w+V;if(q){if(q.index>y.index){var _=g-q.x-q.vx,O=k-q.y-q.vy,P=_*_+O*O;P<L*L&&(_===0&&(_=ya(i),P+=_*_),O===0&&(O=ya(i),P+=O*O),P=(L-(P=Math.sqrt(P)))/P*a,y.vx+=(_*=P)*(L=(V*=V)/(C+V)),y.vy+=(O*=P)*L,q.vx-=_*(L=1-L),q.vy-=O*L)}return}return A>g+L||T<g-L||z>k+L||F<k-L}}function d(f){if(f.data)return f.r=r[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(r=new Array(x),f=0;f<x;++f)p=t[f],r[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:el(+f),m(),c):e},c}function RT(e){return e.index}function vv(e,t){var r=e.get(t);if(!r)throw new Error("node not found: "+t);return r}function zT(e){var t=RT,r=p,i,a=el(30),o,c,d,m,f,x=1;e==null&&(e=[]);function p(C){return 1/Math.min(d[C.source.index],d[C.target.index])}function y(C){for(var j=0,E=e.length;j<x;++j)for(var N=0,A,z,T,F,q,V,L;N<E;++N)A=e[N],z=A.source,T=A.target,F=T.x+T.vx-z.x-z.vx||ya(f),q=T.y+T.vy-z.y-z.vy||ya(f),V=Math.sqrt(F*F+q*q),V=(V-o[N])/V*C*i[N],F*=V,q*=V,T.vx-=F*(L=m[N]),T.vy-=q*L,z.vx+=F*(L=1-L),z.vy+=q*L}function g(){if(c){var C,j=c.length,E=e.length,N=new Map(c.map((z,T)=>[t(z,T,c),z])),A;for(C=0,d=new Array(j);C<E;++C)A=e[C],A.index=C,typeof A.source!="object"&&(A.source=vv(N,A.source)),typeof A.target!="object"&&(A.target=vv(N,A.target)),d[A.source.index]=(d[A.source.index]||0)+1,d[A.target.index]=(d[A.target.index]||0)+1;for(C=0,m=new Array(E);C<E;++C)A=e[C],m[C]=d[A.source.index]/(d[A.source.index]+d[A.target.index]);i=new Array(E),k(),o=new Array(E),w()}}function k(){if(c)for(var C=0,j=e.length;C<j;++C)i[C]=+r(e[C],C,e)}function w(){if(c)for(var C=0,j=e.length;C<j;++C)o[C]=+a(e[C],C,e)}return y.initialize=function(C,j){c=C,f=j,g()},y.links=function(C){return arguments.length?(e=C,g(),y):e},y.id=function(C){return arguments.length?(t=C,y):t},y.iterations=function(C){return arguments.length?(x=+C,y):x},y.strength=function(C){return arguments.length?(r=typeof C=="function"?C:el(+C),k(),y):r},y.distance=function(C){return arguments.length?(a=typeof C=="function"?C:el(+C),w(),y):a},y}var BT={value:()=>{}};function iu(){for(var e=0,t=arguments.length,r={},i;e<t;++e){if(!(i=arguments[e]+"")||i in r||/[\s.]/.test(i))throw new Error("illegal type: "+i);r[i]=[]}return new nf(r)}function nf(e){this._=e}function $T(e,t){return e.trim().split(/^|\s+/).map(function(r){var i="",a=r.indexOf(".");if(a>=0&&(i=r.slice(a+1),r=r.slice(0,a)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:i}})}nf.prototype=iu.prototype={constructor:nf,on:function(e,t){var r=this._,i=$T(e+"",r),a,o=-1,c=i.length;if(arguments.length<2){for(;++o<c;)if((a=(e=i[o]).type)&&(a=OT(r[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)r[a]=wv(r[a],e.name,t);else if(t==null)for(a in r)r[a]=wv(r[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new nf(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var r=new Array(a),i=0,a,o;i<a;++i)r[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,r)},apply:function(e,t,r){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,r)}};function OT(e,t){for(var r=0,i=e.length,a;r<i;++r)if((a=e[r]).name===t)return a.value}function wv(e,t,r){for(var i=0,a=e.length;i<a;++i)if(e[i].name===t){e[i]=BT,e=e.slice(0,i).concat(e.slice(i+1));break}return r!=null&&e.push({name:t,value:r}),e}var uo=0,Mc=0,Nc=0,R5=1e3,xf,Fc,gf=0,al=0,Of=0,Yc=typeof performance=="object"&&performance.now?performance:Date,z5=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function g0(){return al||(z5(LT),al=Yc.now()+Of)}function LT(){al=0}function yf(){this._call=this._time=this._next=null}yf.prototype=y0.prototype={constructor:yf,restart:function(e,t,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?g0():+r)+(t==null?0:+t),!this._next&&Fc!==this&&(Fc?Fc._next=this:xf=this,Fc=this),this._call=e,this._time=r,mx()},stop:function(){this._call&&(this._call=null,this._time=1/0,mx())}};function y0(e,t,r){var i=new yf;return i.restart(e,t,r),i}function IT(){g0(),++uo;for(var e=xf,t;e;)(t=al-e._time)>=0&&e._call.call(void 0,t),e=e._next;--uo}function kv(){al=(gf=Yc.now())+Of,uo=Mc=0;try{IT()}finally{uo=0,UT(),al=0}}function HT(){var e=Yc.now(),t=e-gf;t>R5&&(Of-=t,gf=e)}function UT(){for(var e,t=xf,r,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:xf=r);Fc=e,mx(i)}function mx(e){if(!uo){Mc&&(Mc=clearTimeout(Mc));var t=e-al;t>24?(e<1/0&&(Mc=setTimeout(kv,e-Yc.now()-Of)),Nc&&(Nc=clearInterval(Nc))):(Nc||(gf=Yc.now(),Nc=setInterval(HT,R5)),uo=1,z5(kv))}}function Sv(e,t,r){var i=new yf;return t=t==null?0:+t,i.restart(a=>{i.stop(),e(a+t)},t,r),i}const qT=1664525,YT=1013904223,Cv=4294967296;function XT(){let e=1;return()=>(e=(qT*e+YT)%Cv)/Cv}function PT(e){return e.x}function VT(e){return e.y}var WT=10,GT=Math.PI*(3-Math.sqrt(5));function KT(e){var t,r=1,i=.001,a=1-Math.pow(i,1/300),o=0,c=.6,d=new Map,m=y0(p),f=iu("tick","end"),x=XT();e==null&&(e=[]);function p(){y(),f.call("tick",t),r<i&&(m.stop(),f.call("end",t))}function y(w){var C,j=e.length,E;w===void 0&&(w=1);for(var N=0;N<w;++N)for(r+=(o-r)*a,d.forEach(function(A){A(r)}),C=0;C<j;++C)E=e[C],E.fx==null?E.x+=E.vx*=c:(E.x=E.fx,E.vx=0),E.fy==null?E.y+=E.vy*=c:(E.y=E.fy,E.vy=0);return t}function g(){for(var w=0,C=e.length,j;w<C;++w){if(j=e[w],j.index=w,j.fx!=null&&(j.x=j.fx),j.fy!=null&&(j.y=j.fy),isNaN(j.x)||isNaN(j.y)){var E=WT*Math.sqrt(.5+w),N=w*GT;j.x=E*Math.cos(N),j.y=E*Math.sin(N)}(isNaN(j.vx)||isNaN(j.vy))&&(j.vx=j.vy=0)}}function k(w){return w.initialize&&w.initialize(e,x),w}return g(),t={tick:y,restart:function(){return m.restart(p),t},stop:function(){return m.stop(),t},nodes:function(w){return arguments.length?(e=w,g(),d.forEach(k),t):e},alpha:function(w){return arguments.length?(r=+w,t):r},alphaMin:function(w){return arguments.length?(i=+w,t):i},alphaDecay:function(w){return arguments.length?(a=+w,t):+a},alphaTarget:function(w){return arguments.length?(o=+w,t):o},velocityDecay:function(w){return arguments.length?(c=1-w,t):1-c},randomSource:function(w){return arguments.length?(x=w,d.forEach(k),t):x},force:function(w,C){return arguments.length>1?(C==null?d.delete(w):d.set(w,k(C)),t):d.get(w)},find:function(w,C,j){var E=0,N=e.length,A,z,T,F,q;for(j==null?j=1/0:j*=j,E=0;E<N;++E)F=e[E],A=w-F.x,z=C-F.y,T=A*A+z*z,T<j&&(q=F,j=T);return q},on:function(w,C){return arguments.length>1?(f.on(w,C),t):f.on(w)}}}function QT(){var e,t,r,i,a=el(-30),o,c=1,d=1/0,m=.81;function f(g){var k,w=e.length,C=p0(e,PT,VT).visitAfter(p);for(i=g,k=0;k<w;++k)t=e[k],C.visit(y)}function x(){if(e){var g,k=e.length,w;for(o=new Array(k),g=0;g<k;++g)w=e[g],o[w.index]=+a(w,g,e)}}function p(g){var k=0,w,C,j=0,E,N,A;if(g.length){for(E=N=A=0;A<4;++A)(w=g[A])&&(C=Math.abs(w.value))&&(k+=w.value,j+=C,E+=C*w.x,N+=C*w.y);g.x=E/j,g.y=N/j}else{w=g,w.x=w.data.x,w.y=w.data.y;do k+=o[w.data.index];while(w=w.next)}g.value=k}function y(g,k,w,C){if(!g.value)return!0;var j=g.x-t.x,E=g.y-t.y,N=C-k,A=j*j+E*E;if(N*N/m<A)return A<d&&(j===0&&(j=ya(r),A+=j*j),E===0&&(E=ya(r),A+=E*E),A<c&&(A=Math.sqrt(c*A)),t.vx+=j*g.value*i/A,t.vy+=E*g.value*i/A),!0;if(g.length||A>=d)return;(g.data!==t||g.next)&&(j===0&&(j=ya(r),A+=j*j),E===0&&(E=ya(r),A+=E*E),A<c&&(A=Math.sqrt(c*A)));do g.data!==t&&(N=o[g.data.index]*i/A,t.vx+=j*N,t.vy+=E*N);while(g=g.next)}return f.initialize=function(g,k){e=g,r=k,x()},f.strength=function(g){return arguments.length?(a=typeof g=="function"?g:el(+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 Fs(e){return Array.isArray?Array.isArray(e):O5(e)==="[object Array]"}function ZT(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function JT(e){return e==null?"":ZT(e)}function es(e){return typeof e=="string"}function B5(e){return typeof e=="number"}function eD(e){return e===!0||e===!1||tD(e)&&O5(e)=="[object Boolean]"}function $5(e){return typeof e=="object"}function tD(e){return $5(e)&&e!==null}function Jr(e){return e!=null}function bp(e){return!e.trim().length}function O5(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const nD="Incorrect 'index' type",rD=e=>`Invalid value for key ${e}`,iD=e=>`Pattern length exceeds max of ${e}.`,sD=e=>`Missing ${e} property in key`,aD=e=>`Property 'weight' in key '${e}' must be a positive integer`,jv=Object.prototype.hasOwnProperty;class lD{constructor(t){this._keys=[],this._keyMap={};let r=0;t.forEach(i=>{let a=L5(i);this._keys.push(a),this._keyMap[a.id]=a,r+=a.weight}),this._keys.forEach(i=>{i.weight/=r})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function L5(e){let t=null,r=null,i=null,a=1,o=null;if(es(e)||Fs(e))i=e,t=Ev(e),r=px(e);else{if(!jv.call(e,"name"))throw new Error(sD("name"));const c=e.name;if(i=c,jv.call(e,"weight")&&(a=e.weight,a<=0))throw new Error(aD(c));t=Ev(c),r=px(c),o=e.getFn}return{path:t,id:r,weight:a,src:i,getFn:o}}function Ev(e){return Fs(e)?e:e.split(".")}function px(e){return Fs(e)?e.join("."):e}function oD(e,t){let r=[],i=!1;const a=(o,c,d)=>{if(Jr(o))if(!c[d])r.push(o);else{let m=c[d];const f=o[m];if(!Jr(f))return;if(d===c.length-1&&(es(f)||B5(f)||eD(f)))r.push(JT(f));else if(Fs(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,es(t)?t.split("."):t,0),i?r:r[0]}const cD={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},uD={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},dD={location:0,threshold:.6,distance:100},fD={useExtendedSearch:!1,getFn:oD,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var bt={...uD,...cD,...dD,...fD};const hD=/[^ ]+/g;function mD(e=1,t=3){const r=new Map,i=Math.pow(10,t);return{get(a){const o=a.match(hD).length;if(r.has(o))return r.get(o);const c=1/Math.pow(o,.5*e),d=parseFloat(Math.round(c*i)/i);return r.set(o,d),d},clear(){r.clear()}}}class b0{constructor({getFn:t=bt.getFn,fieldNormWeight:r=bt.fieldNormWeight}={}){this.norm=mD(r,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((r,i)=>{this._keysMap[r.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,es(this.docs[0])?this.docs.forEach((t,r)=>{this._addString(t,r)}):this.docs.forEach((t,r)=>{this._addObject(t,r)}),this.norm.clear())}add(t){const r=this.size();es(t)?this._addString(t,r):this._addObject(t,r)}removeAt(t){this.records.splice(t,1);for(let r=t,i=this.size();r<i;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(t,r){return t[this._keysMap[r]]}size(){return this.records.length}_addString(t,r){if(!Jr(t)||bp(t))return;let i={v:t,i:r,n:this.norm.get(t)};this.records.push(i)}_addObject(t,r){let i={i:r,$:{}};this.keys.forEach((a,o)=>{let c=a.getFn?a.getFn(t):this.getFn(t,a.path);if(Jr(c)){if(Fs(c)){let d=[];const m=[{nestedArrIndex:-1,value:c}];for(;m.length;){const{nestedArrIndex:f,value:x}=m.pop();if(Jr(x))if(es(x)&&!bp(x)){let p={v:x,i:f,n:this.norm.get(x)};d.push(p)}else Fs(x)&&x.forEach((p,y)=>{m.push({nestedArrIndex:y,value:p})})}i.$[o]=d}else if(es(c)&&!bp(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 I5(e,t,{getFn:r=bt.getFn,fieldNormWeight:i=bt.fieldNormWeight}={}){const a=new b0({getFn:r,fieldNormWeight:i});return a.setKeys(e.map(L5)),a.setSources(t),a.create(),a}function pD(e,{getFn:t=bt.getFn,fieldNormWeight:r=bt.fieldNormWeight}={}){const{keys:i,records:a}=e,o=new b0({getFn:t,fieldNormWeight:r});return o.setKeys(i),o.setIndexRecords(a),o}function Md(e,{errors:t=0,currentLocation:r=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-r);return a?c+d/a:d?1:c}function xD(e=[],t=bt.minMatchCharLength){let r=[],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&&r.push([i,a]),i=-1)}return e[o-1]&&o-i>=t&&r.push([i,o-1]),r}const Za=32;function gD(e,t,r,{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>Za)throw new Error(iD(Za));const x=t.length,p=e.length,y=Math.max(0,Math.min(i,p));let g=o,k=y;const w=d>1||m,C=w?Array(p):[];let j;for(;(j=e.indexOf(t,k))>-1;){let F=Md(t,{currentLocation:j,expectedLocation:y,distance:a,ignoreLocation:f});if(g=Math.min(F,g),k=j+x,w){let q=0;for(;q<x;)C[j+q]=1,q+=1}}k=-1;let E=[],N=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;)Md(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,O=Array(_+2);O[_+1]=(1<<F)-1;for(let R=_;R>=L;R-=1){let H=R-1,B=r[e.charAt(H)];if(w&&(C[H]=+!!B),O[R]=(O[R+1]<<1|1)&B,F&&(O[R]|=(E[R+1]|E[R])<<1|1|E[R+1]),O[R]&z&&(N=Md(t,{errors:F,currentLocation:H,expectedLocation:y,distance:a,ignoreLocation:f}),N<=g)){if(g=N,k=H,k<=y)break;L=Math.max(1,2*y-k)}}if(Md(t,{errors:F+1,currentLocation:y,expectedLocation:y,distance:a,ignoreLocation:f})>g)break;E=O}const T={isMatch:k>=0,score:Math.max(.001,N)};if(w){const F=xD(C,d);F.length?m&&(T.indices=F):T.isMatch=!1}return T}function yD(e){let t={};for(let r=0,i=e.length;r<i;r+=1){const a=e.charAt(r);t[a]=(t[a]||0)|1<<i-r-1}return t}const bf=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 H5{constructor(t,{location:r=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:r,threshold:i,distance:a,includeMatches:o,findAllMatches:c,minMatchCharLength:d,isCaseSensitive:m,ignoreDiacritics:f,ignoreLocation:x},t=m?t:t.toLowerCase(),t=f?bf(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const p=(g,k)=>{this.chunks.push({pattern:g,alphabet:yD(g),startIndex:k})},y=this.pattern.length;if(y>Za){let g=0;const k=y%Za,w=y-k;for(;g<w;)p(this.pattern.substr(g,Za),g),g+=Za;if(k){const C=y-Za;p(this.pattern.substr(C),C)}}else p(this.pattern,0)}searchIn(t){const{isCaseSensitive:r,ignoreDiacritics:i,includeMatches:a}=this.options;if(t=r?t:t.toLowerCase(),t=i?bf(t):t,this.pattern===t){let w={isMatch:!0,score:0};return a&&(w.indices=[[0,t.length-1]]),w}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:w,alphabet:C,startIndex:j})=>{const{isMatch:E,score:N,indices:A}=gD(t,w,C,{location:o+j,distance:c,threshold:d,findAllMatches:m,minMatchCharLength:f,includeMatches:a,ignoreLocation:x});E&&(g=!0),y+=N,E&&A&&(p=[...p,...A])});let k={isMatch:g,score:g?y/this.chunks.length:1};return g&&a&&(k.indices=p),k}}class Ca{constructor(t){this.pattern=t}static isMultiMatch(t){return Nv(t,this.multiRegex)}static isSingleMatch(t){return Nv(t,this.singleRegex)}search(){}}function Nv(e,t){const r=e.match(t);return r?r[1]:null}class bD extends Ca{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const r=t===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class vD extends Ca{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 wD extends Ca{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const r=t.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class kD extends Ca{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const r=!t.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class SD extends Ca{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const r=t.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class CD extends Ca{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const r=!t.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class U5 extends Ca{constructor(t,{location:r=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 H5(t,{location:r,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 q5 extends Ca{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let r=0,i;const a=[],o=this.pattern.length;for(;(i=t.indexOf(this.pattern,r))>-1;)r=i+o,a.push([i,r-1]);const c=!!a.length;return{isMatch:c,score:c?0:1,indices:a}}}const xx=[bD,q5,wD,kD,CD,SD,vD,U5],Av=xx.length,jD=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ED="|";function ND(e,t={}){return e.split(ED).map(r=>{let i=r.trim().split(jD).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<Av;){const x=xx[f];let p=x.isMultiMatch(d);p&&(a.push(new x(p,t)),m=!0)}if(!m)for(f=-1;++f<Av;){const x=xx[f];let p=x.isSingleMatch(d);if(p){a.push(new x(p,t));break}}}return a})}const AD=new Set([U5.type,q5.type]);class TD{constructor(t,{isCaseSensitive:r=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:r,ignoreDiacritics:i,includeMatches:a,minMatchCharLength:o,findAllMatches:d,ignoreLocation:c,location:m,threshold:f,distance:x},t=r?t:t.toLowerCase(),t=i?bf(t):t,this.pattern=t,this.query=ND(this.pattern,this.options)}static condition(t,r){return r.useExtendedSearch}searchIn(t){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:a,ignoreDiacritics:o}=this.options;t=a?t:t.toLowerCase(),t=o?bf(t):t;let c=0,d=[],m=0;for(let f=0,x=r.length;f<x;f+=1){const p=r[f];d.length=0,c=0;for(let y=0,g=p.length;y<g;y+=1){const k=p[y],{isMatch:w,indices:C,score:j}=k.search(t);if(w){if(c+=1,m+=j,i){const E=k.constructor.type;AD.has(E)?d=[...d,...C]:d.push(C)}}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 gx=[];function DD(...e){gx.push(...e)}function yx(e,t){for(let r=0,i=gx.length;r<i;r+=1){let a=gx[r];if(a.condition(e,t))return new a(e,t)}return new H5(e,t)}const vf={AND:"$and",OR:"$or"},bx={PATH:"$path",PATTERN:"$val"},vx=e=>!!(e[vf.AND]||e[vf.OR]),_D=e=>!!e[bx.PATH],MD=e=>!Fs(e)&&$5(e)&&!vx(e),Tv=e=>({[vf.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Y5(e,t,{auto:r=!0}={}){const i=a=>{let o=Object.keys(a);const c=_D(a);if(!c&&o.length>1&&!vx(a))return i(Tv(a));if(MD(a)){const m=c?a[bx.PATH]:o[0],f=c?a[bx.PATTERN]:a[m];if(!es(f))throw new Error(rD(m));const x={keyId:px(m),pattern:f};return r&&(x.searcher=yx(f,t)),x}let d={children:[],operator:o[0]};return o.forEach(m=>{const f=a[m];Fs(f)&&f.forEach(x=>{d.children.push(i(x))})}),d};return vx(e)||(e=Tv(e)),i(e)}function FD(e,{ignoreFieldNorm:t=bt.ignoreFieldNorm}){e.forEach(r=>{let i=1;r.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))}),r.score=i})}function RD(e,t){const r=e.matches;t.matches=[],Jr(r)&&r.forEach(i=>{if(!Jr(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 zD(e,t){t.score=e.score}function BD(e,t,{includeMatches:r=bt.includeMatches,includeScore:i=bt.includeScore}={}){const a=[];return r&&a.push(RD),i&&a.push(zD),e.map(o=>{const{idx:c}=o,d={item:t[c],refIndex:c};return a.length&&a.forEach(m=>{m(o,d)}),d})}class jo{constructor(t,r={},i){this.options={...bt,...r},this.options.useExtendedSearch,this._keyStore=new lD(this.options.keys),this.setCollection(t,i)}setCollection(t,r){if(this._docs=t,r&&!(r instanceof b0))throw new Error(nD);this._myIndex=r||I5(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Jr(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const r=[];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,r.push(o))}return r}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:r=-1}={}){const{includeMatches:i,includeScore:a,shouldSort:o,sortFn:c,ignoreFieldNorm:d}=this.options;let m=es(t)?es(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return FD(m,{ignoreFieldNorm:d}),o&&m.sort(c),B5(r)&&r>-1&&(m=m.slice(0,r)),BD(m,this._docs,{includeMatches:i,includeScore:a})}_searchStringList(t){const r=yx(t,this.options),{records:i}=this._myIndex,a=[];return i.forEach(({v:o,i:c,n:d})=>{if(!Jr(o))return;const{isMatch:m,score:f,indices:x}=r.searchIn(o);m&&a.push({item:o,idx:c,matches:[{score:f,value:o,norm:d,indices:x}]})}),a}_searchLogical(t){const r=Y5(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],k=i(g,m,f);if(k.length)x.push(...k);else if(d.operator===vf.AND)return[]}return x},a=this._myIndex.records,o={},c=[];return a.forEach(({$:d,i:m})=>{if(Jr(d)){let f=i(r,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 r=yx(t,this.options),{keys:i,records:a}=this._myIndex,o=[];return a.forEach(({$:c,i:d})=>{if(!Jr(c))return;let m=[];i.forEach((f,x)=>{m.push(...this._findMatches({key:f,value:c[x],searcher:r}))}),m.length&&o.push({idx:d,item:c,matches:m})}),o}_findMatches({key:t,value:r,searcher:i}){if(!Jr(r))return[];let a=[];if(Fs(r))r.forEach(({v:o,i:c,n:d})=>{if(!Jr(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}=r,{isMatch:d,score:m,indices:f}=i.searchIn(o);d&&a.push({score:m,key:t,value:o,norm:c,indices:f})}return a}}jo.version="7.1.0";jo.createIndex=I5;jo.parseIndex=pD;jo.config=bt;jo.parseQuery=Y5;DD(TD);const Ds={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 wx(e){return Ds[e]??Ds.general}function $D(e){return e>1600?"macro":e<800?"micro":"standard"}function OD(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 r=[];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;r.push({domain:i,count:d,centerX:o/d,centerY:c/d,nodes:a})}return r}function LD(e,t=60){if(!e)return"";const r=e.match(/^[^.!?]+[.!?]/),i=r?r[0]:e;return i.length>t?i.slice(0,t-2)+"..":i}function ID(e,t,r){const i=[...new Set(r.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 HD(e,t=.12){let r;function i(a){for(const o of r){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){r=a},i}function UD(e){return e.map(t=>{let r=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>r&&(r=d)}const i=Math.max(40,t.count*8);return{...t,radius:r+i}})}function qD(e,t,r,i){if(!e)return r;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 YD({docs:e,onNodeClick:t,selectedDocId:r,matchedIds:i,localGraphMode:a,onLocalModeChange:o,onClusterClick:c}){var $;const d=S.useRef(null),m=S.useRef(null),[f,x]=S.useState({width:600,height:400}),[p,y]=S.useState({nodes:[],links:[]}),[g,k]=S.useState(null),[w,C]=S.useState(null),[j,E]=S.useState(new Set),[N,A]=S.useState(null),[z,T]=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),O=S.useRef(null),P=S.useMemo(()=>$D(F.w),[F.w]),R=S.useMemo(()=>OD(p.nodes),[p.nodes]),H=S.useMemo(()=>UD(R),[R]),B=S.useMemo(()=>{if(a==="global"||!r)return null;const Q=new Set(p.nodes.map(J=>J.id)),ee=a==="1-hop"?1:2;return qD(r,p.links,Q,ee)},[a,r,p.nodes,p.links]);S.useEffect(()=>{const Q=d.current;if(!Q)return;const ee=new ResizeObserver(J=>{const{width:ae,height:oe}=J[0].contentRect;ae>0&&oe>0&&(x({width:ae,height:oe}),q(be=>({...be,w:ae,h:oe})))});return ee.observe(Q),()=>ee.disconnect()},[]),S.useEffect(()=>{if(e.length===0)return;const Q=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,Ze)=>{if(!Ze.startsWith(".")&&!Ze.startsWith("/"))return Ze;const ut=Ye.split("/");ut.pop();const jt=Ze.split("/");for(const ge of jt)ge===".."?ut.pop():ge!=="."&&ge!==""&&ut.push(ge);return ut.join("/")},ae=[];for(const Ye of e)for(const Ze of Ye.links){const ut=J(Ye.id,Ze.href);Q.has(ut)&&ut!==Ye.id&&(ae.some(jt=>jt.source===Ye.id&&jt.target===ut||jt.source===ut&&jt.target===Ye.id)||ae.push({source:Ye.id,target:ut,label:Ze.text}))}const{width:oe,height:be}=f,Ee=ee.length,Ae=Ee>100?-600:Ee>50?-500:-400,Fe=Ee>100?180:Ee>50?160:140,he=Ee>100?60:50,Re=Math.max(oe,Ee*12),et=Math.max(be,Ee*10),We=ID(Re,et,ee),it=KT(ee).force("link",zT(ae).id(Ye=>Ye.id).distance(Fe)).force("charge",QT().strength(Ae)).force("center",mT(Re/2,et/2)).force("collide",FT(he)).force("cluster",HD(We,.15));O.current=it,it.on("tick",()=>{y({nodes:[...ee],links:[...ae]})}),it.alpha(1).restart();const mt=Ee>100?300:150;for(let Ye=0;Ye<mt;Ye++)it.tick();if(it.stop(),y({nodes:[...ee],links:[...ae]}),ee.length>0){let Ye=1/0,Ze=1/0,ut=-1/0,jt=-1/0;for(const ve of ee){const Ce=ve.x??0,ne=ve.y??0;Ce<Ye&&(Ye=Ce),ne<Ze&&(Ze=ne),Ce>ut&&(ut=Ce),ne>jt&&(jt=ne)}const ge=100;q({x:Ye-ge,y:Ze-ge,w:Math.max(oe,ut-Ye+ge*2),h:Math.max(be,jt-Ze+ge*2)})}return()=>{it.stop()}},[e,f]);const Z=Q=>{if(typeof Q=="string"){const ee=p.nodes.find(J=>J.id===Q);return{x:(ee==null?void 0:ee.x)??0,y:(ee==null?void 0:ee.y)??0}}return{x:Q.x??0,y:Q.y??0}},G=S.useCallback(Q=>{Q.preventDefault();const ee=Q.deltaY>0?1.1:.9;q(J=>{const ae=Math.max(200,Math.min(f.width*3,J.w*ee)),oe=Math.max(150,Math.min(f.height*3,J.h*ee)),be=(ae-J.w)/2,Ee=(oe-J.h)/2;return{x:J.x-be,y:J.y-Ee,w:ae,h:oe}})},[f]),K=S.useCallback(Q=>{Q.button===0&&(V.current=!0,L.current={x:Q.clientX,y:Q.clientY,vx:F.x,vy:F.y})},[F]),M=S.useCallback(Q=>{var ee;if(_.current){const J=m.current;if(!J)return;const ae=J.getBoundingClientRect(),oe=F.w/ae.width,be=F.h/ae.height,Ee=F.x+(Q.clientX-ae.left)*oe,Ae=F.y+(Q.clientY-ae.top)*be;_.current.fx=Ee,_.current.fy=Ae,(ee=O.current)==null||ee.alpha(.3).restart();return}if(V.current){const J=(Q.clientX-L.current.x)*(F.w/f.width),ae=(Q.clientY-L.current.y)*(F.h/f.height);q(oe=>({...oe,x:L.current.vx-J,y:L.current.vy-ae}))}},[F,f]),U=S.useCallback(()=>{V.current=!1,_.current&&(_.current.fx=null,_.current.fy=null,_.current=null)},[]),Y=S.useCallback((Q,ee)=>{var J;Q.stopPropagation(),_.current=ee,(J=O.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:G,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"}),P==="macro"&&l.jsx("g",{className:"macro-clusters",style:{transition:"opacity 0.3s ease"},children:R.map(Q=>{const ee=Ds[Q.domain]??Ds.general,J=Math.max(40,Math.sqrt(Q.count)*25),oe=i===null||Q.nodes.some(be=>i.has(be.id))?1:.4;return l.jsxs("g",{transform:`translate(${Q.centerX}, ${Q.centerY})`,style:{cursor:"pointer",opacity:oe,transition:"opacity 0.3s ease"},onMouseEnter:be=>{var Ae;const Ee=(Ae=d.current)==null?void 0:Ae.getBoundingClientRect();Ee&&T({x:be.clientX-Ee.left,y:be.clientY-Ee.top}),k({id:`cluster-${Q.domain}`,title:`${Q.domain} (${Q.count})`,category:Q.domain,akb_type:"hub"})},onMouseLeave:()=>k(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:Q.domain}),l.jsxs("text",{y:20,textAnchor:"middle",dominantBaseline:"middle",fill:ee.text,fontSize:12,fontFamily:"monospace",opacity:.8,style:{pointerEvents:"none"},children:["(",Q.count,")"]})]},Q.domain)})}),P!=="macro"&&l.jsxs(l.Fragment,{children:[P==="standard"&&H.map(Q=>{const ee=Ds[Q.domain]??Ds.general;if(Q.count<2)return null;const J=i===null||Q.nodes.some(oe=>i.has(oe.id)),ae=J?.08:.04;return l.jsxs("g",{children:[l.jsx("circle",{cx:Q.centerX,cy:Q.centerY,r:Q.radius,fill:ee.bg,stroke:ee.border,strokeWidth:1,opacity:ae,style:{transition:"opacity 0.3s ease"},pointerEvents:"none"}),l.jsxs("text",{x:Q.centerX,y:Q.centerY-Q.radius-8,textAnchor:"middle",fill:ee.text,fontSize:12,fontFamily:"monospace",fontWeight:"600",opacity:J?.85:.5,onClick:()=>c(Q.domain),style:{cursor:"pointer",pointerEvents:"auto",transition:"opacity 0.3s ease"},children:[Q.domain," (",Q.count,")"]})]},`cluster-bg-${Q.domain}`)}),p.links.map((Q,ee)=>{const J=Z(Q.source),ae=Z(Q.target),oe=w===ee,be=(J.x+ae.x)/2,Ee=(J.y+ae.y)/2,Ae=typeof Q.source=="string"?Q.source:Q.source.id,Fe=typeof Q.target=="string"?Q.target:Q.target.id,he=B===null||B.has(Ae)&&B.has(Fe),We=oe||N!==null&&(Ae===N||Fe===N)||r&&(Ae===r||Fe===r),it=he?1:.3,mt=We?it:it*.15;return l.jsxs("g",{style:{opacity:mt,transition:"opacity 0.25s ease"},children:[l.jsx("line",{x1:J.x,y1:J.y,x2:ae.x,y2:ae.y,stroke:"transparent",strokeWidth:12,style:{cursor:"default"},onMouseEnter:()=>{C(ee),E(new Set([Ae,Fe]))},onMouseLeave:()=>{C(null),E(new Set)}}),l.jsx("line",{x1:J.x,y1:J.y,x2:ae.x,y2:ae.y,stroke:We?"rgba(148,163,184,0.8)":"rgba(148,163,184,0.4)",strokeWidth:We?1.5:.5,pointerEvents:"none"}),oe&&Q.label&&l.jsx("text",{x:be,y:Ee-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:Q.label.length>30?Q.label.slice(0,28)+"..":Q.label})})]},ee)}),p.nodes.map(Q=>{const ee=Ds[Q.category]??Ds.general,J=Q.akb_type==="hub",ae=J?24:16,oe=P==="micro"?ae*1.5:ae,be=(g==null?void 0:g.id)===Q.id,Ee=r===Q.id,Ae=j.has(Q.id),Fe=be?1.1:Ee?1.05:1,he=i===null||i.has(Q.id),Re=B===null||B.has(Q.id),et=he&&Re?1:.35,We=P==="micro"?LD(Q.tldr,60):"",it=P==="micro"&&Q.tags?Q.tags.slice(0,3):[];return l.jsxs("g",{transform:`translate(${Q.x??0}, ${Q.y??0}) scale(${Fe})`,style:{cursor:"pointer",transition:"transform 0.2s ease, opacity 0.3s ease",opacity:et},onClick:mt=>{mt.stopPropagation();const Ye=e.find(Ze=>Ze.id===Q.id);Ye&&t(Ye)},onMouseDown:mt=>Y(mt,Q),onMouseEnter:mt=>{var Ze;k(Q),A(Q.id);const Ye=(Ze=d.current)==null?void 0:Ze.getBoundingClientRect();Ye&&T({x:mt.clientX-Ye.left,y:mt.clientY-Ye.top})},onMouseLeave:()=>{k(null),A(null)},children:[Ee&&l.jsx("rect",{x:-oe/2-4,y:-oe/2-4,width:oe+8,height:oe+8,fill:"none",stroke:"#22c55e",strokeWidth:2,rx:J?5:2,opacity:.6}),!Ee&&Ae&&l.jsx("rect",{x:-oe/2-3,y:-oe/2-3,width:oe+6,height:oe+6,fill:"none",stroke:"#60a5fa",strokeWidth:1.5,rx:J?5:2,opacity:.7}),l.jsx("rect",{x:-oe/2,y:-oe/2,width:oe,height:oe,fill:ee.border,rx:J?4:2,opacity:be?1:.9}),l.jsx("rect",{x:-oe/2+3,y:-oe/2+3,width:Math.max(0,oe-6),height:Math.max(0,oe-6),fill:ee.bg,rx:J?3:1}),l.jsx("text",{y:oe/2+14,textAnchor:"middle",fill:Ee?"#e2e8f0":"#cbd5e1",fontSize:P==="micro"?13:12,fontFamily:"monospace",fontWeight:Ee?"bold":"normal",style:{pointerEvents:"none"},children:Q.title.length>36?Q.title.slice(0,34)+"..":Q.title}),P==="micro"&&We&&l.jsx("text",{y:oe/2+28,textAnchor:"middle",fill:"#94a3b8",fontSize:10,fontFamily:"system-ui, sans-serif",opacity:.85,style:{pointerEvents:"none"},children:We}),P==="micro"&&it.length>0&&l.jsx("g",{transform:`translate(0, ${oe/2+(We?42:28)})`,children:it.map((mt,Ye)=>{const Ze=mt.length*5+8;let jt=-it.reduce((ge,ve)=>ge+ve.length*5+10,0)/2;for(let ge=0;ge<Ye;ge++)jt+=it[ge].length*5+10;return l.jsxs("g",{transform:`translate(${jt+Ze/2}, 0)`,children:[l.jsx("rect",{x:-Ze/2,y:-6,width:Ze,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:mt})]},mt)})})]},Q.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:[(($=e.find(Q=>Q.id===g.id))==null?void 0:$.tldr)&&l.jsx("div",{className:"text-[10px] opacity-80 mb-1",children:e.find(Q=>Q.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:P==="macro"?"#f59e0b":P==="micro"?"#22c55e":"#94a3b8",transition:"color 0.3s ease"},children:[P==="macro"&&"📍 Overview",P==="standard"&&"📍 Standard",P==="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(Q=>{const ee=a===Q,J=Q!=="global"&&!r,ae=Q==="global"?"🌐 All":Q==="1-hop"?"1-hop":"2-hop";return l.jsx("button",{onClick:()=>!J&&o(Q),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 ${Q==="global"?"all nodes":`nodes within ${Q}`}`,children:ae},Q)})}),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 XD(e){const t=[],r=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],r.has(d))c=r.get(d).children;else{const f={type:"folder",name:o[m],path:d,children:[]};r.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 PD({docs:e,onDocumentClick:t,selectedDocId:r,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(()=>XD(e),[e]),g=z=>{o(T=>{const F=new Set(T);return F.has(z)?F.delete(z):F.add(z),F})},k=z=>{d(z),t(z);const T=m.slice(0,x+1);T.push(z),T.length>10&&T.shift(),f(T),p(T.length-1)},w=()=>{d(null),t(null)},C=()=>{if(x>0){const z=x-1;p(z),d(m[z]),t(m[z])}},j=()=>{if(x<m.length-1){const z=x+1;p(z),d(m[z]),t(m[z])}},E=z=>{const T=m.indexOf(z);T!==-1&&(p(T),d(z),t(z))},N=z=>{z==="hub"&&w()},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:r,viewingDocId:c,onToggleFolder:g,onFileClick:k,matchedIds:i},z.path))]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:A?l.jsx(P5,{doc:A,onClose:w,onBreadcrumbClick:N,history:m,historyIndex:x,onHistoryBack:C,onHistoryForward:j,onHistoryJump:E,onNavigateDoc:k,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:r,selectedDocId:i,viewingDocId:a,onToggleFolder:o,onFileClick:c,matchedIds:d}){var g,k,w;const m=r.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 C=d===null||(((k=e.children)==null?void 0:k.some(j=>{if(j.type==="file")return d.has(j.path);const E=N=>{var A;return N.type==="file"?d.has(N.path):((A=N.children)==null?void 0:A.some(E))??!1};return E(j)}))??!1);return l.jsxs("div",{style:{opacity:C?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&&((w=e.children)==null?void 0:w.map(j=>l.jsx(X5,{node:j,level:t+1,expandedFolders:r,selectedDocId:i,viewingDocId:a,onToggleFolder:o,onFileClick:c,matchedIds:d},j.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 VD(e){const t=e.split(`
83
- `),r=[],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;r.push({id:x,text:d,level:c})}return r}function P5({doc:e,onClose:t,onBreadcrumbClick:r,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),[k,w]=S.useState(null),C=S.useRef(null),[j,E]=S.useState(null);S.useEffect(()=>{if("content"in e&&e.content){p(e);return}g(!0),w(null),Se.getKnowledgeDoc(e.id).then(p).catch(P=>w(P instanceof Error?P.message:"Failed to load")).finally(()=>g(!1))},[e]);const N=S.useMemo(()=>!x||e.format==="html"?[]:VD(x.content),[x,e.format]),A=P=>{if(!C.current)return;const R=C.current.querySelectorAll("h2, h3");for(const H of R){const Z=(H.textContent||"").toLowerCase().replace(/[^a-z0-9가-힣\s-]/g,"").replace(/\s+/g,"-").slice(0,50);if(P.startsWith(Z)){H.scrollIntoView({behavior:"smooth",block:"start"}),E(P);break}}},z=wx(e.category),T=e.akb_type==="hub",F=N.length>0&&!y&&!k,q=S.useMemo(()=>new Set(f.map(P=>P.id)),[f]),V=S.useCallback(P=>{const H=P.target.closest("a");if(!H)return;const B=H.getAttribute("href");if(!B||B.startsWith("http://")||B.startsWith("https://")||B.startsWith("#"))return;const Z=B.split("#")[0];if(!Z.endsWith(".md"))return;P.preventDefault();const G=e.id.substring(0,e.id.lastIndexOf("/"));let K=Z;if(Z.startsWith("./")||Z.startsWith("../")){const M=G.split("/"),U=Z.split("/");for(const Y of U)Y===".."?M.pop():Y!=="."&&M.push(Y);K=M.join("/")}if(q.has(K))m(K);else{const M=K.split("/").pop()||"",U=f.find(Y=>Y.id.endsWith("/"+M)||Y.id===M);U&&m(U.id)}},[e.id,f,q,m]),L=i.slice(0,a).reverse().filter(P=>P!==e.id).slice(0,3).map(P=>f.find(R=>R.id===P)).filter(P=>P!==void 0),_=a>0,O=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:!O,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(P=>l.jsxs("button",{onClick:()=>d(P.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:P.title,children:["📄 ",P.title.length>15?P.title.slice(0,15)+"...":P.title]},P.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:()=>r("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:T?"📘":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(P=>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:P},P))})]})]}),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:C,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..."}),k&&l.jsx("div",{className:"text-xs p-2 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#f87171"},children:k}),x&&l.jsx(Co,{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:N.map(P=>l.jsx("button",{onClick:()=>A(P.id),className:"block w-full text-left text-[10px] py-1 px-2 rounded cursor-pointer hover:bg-white/5 transition-colors",style:{paddingLeft:(P.level-2)*8+8,color:j===P.id?"#4ade80":"var(--terminal-text-secondary)",fontWeight:j===P.id?"bold":"normal"},children:P.text.length>30?P.text.slice(0,28)+"..":P.text},P.id))})]})]})]})}const WD=500,Dv=360,GD=700;function su(e,t,r){const i=t??WD,[a,o]=S.useState(i),[c,d]=S.useState(!1),m=S.useRef(0),f=S.useRef(0),x=S.useRef(r);x.current=r;const p=e>0,y=p?e:0,g=Math.max(GD,i),k=p?Math.max(Dv,window.innerWidth-e-100):g,w=Math.min(a,k),C=S.useCallback(j=>{j.preventDefault(),m.current=j.clientX,f.current=w,d(!0);const E=()=>{d(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",E)},N=A=>{const z=m.current-A.clientX,T=f.current+z;if(T>=window.innerWidth*.6&&x.current){E(),x.current();return}const F=Math.min(g,Math.max(Dv,T));o(F)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",E)},[w]);return{panelRight:y,panelWidth:w,isResizing:c,handleResizeStart:C}}function _v({docs:e,onClose:t,onRefresh:r,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,k]=S.useState([]),[w,C]=S.useState(-1),[j,E]=S.useState("global"),[N,A]=S.useState(""),z=S.useMemo(()=>{const ee=new Set(e.map(ae=>ae.category)),J=Object.keys(Ds);return[...ee].sort((ae,oe)=>{const be=J.includes(ae)?0:1,Ee=J.includes(oe)?0:1;return be-Ee||ae.localeCompare(oe)})},[e]),[T,F]=S.useState(()=>new Set);S.useEffect(()=>{localStorage.setItem("kb-view-mode",d)},[d]);const q=S.useMemo(()=>new jo(e,{keys:["title","tldr","tags","id"],threshold:.3,includeScore:!0}),[e]),V=S.useMemo(()=>{let ee=new Set(e.map(J=>J.id));if(N.trim()){const J=q.search(N);ee=new Set(J.map(ae=>ae.item.id))}return T.size>0&&(ee=new Set(Array.from(ee).filter(J=>{const ae=e.find(oe=>oe.id===J);return ae&&T.has(ae.category)}))),ee.size===e.length?null:ee},[e,N,q,T]),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(be=>be!==ee));const ae=new Set(J);if(ae.has(ee)){if(ae.delete(ee),ae.size===0)return new Set}else if(ae.add(ee),ae.size===z.length)return new Set;return ae})},{panelRight:O,panelWidth:P,isResizing:R,handleResizeStart:H}=su(i,void 0,o),B=ee=>{x(ee.id),Z(ee.id)},Z=ee=>{y(ee);const J=g.slice(0,w+1);J.push(ee),J.length>10&&J.shift(),k(J),C(J.length-1)},G=()=>{y(null)},K=()=>{if(w>0){const ee=w-1;C(ee),y(g[ee]),x(g[ee])}},M=()=>{if(w<g.length-1){const ee=w+1;C(ee),y(g[ee]),x(g[ee])}},U=ee=>{const J=g.indexOf(ee);J!==-1&&(C(J),y(ee),x(ee))},Y=ee=>{ee==="hub"&&G()},$=ee=>{F(J=>J.size===1&&J.has(ee)?new Set:new Set([ee]))},Q=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:O},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:O,width:P,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(Fd,{icon:"🕸️",label:"Graph",active:d==="graph",onClick:()=>m("graph")}),l.jsx(Fd,{icon:"🌲",label:"Tree",active:d==="tree",onClick:()=>{m("tree"),x(null)}}),l.jsx(Fd,{icon:"📋",label:"List",active:d==="list",onClick:()=>{m("list"),x(null)}}),l.jsx(Fd,{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:N,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)"}}),N&&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=wx(ee),ae=T.size===0||T.has(ee);return l.jsx("button",{onClick:()=>_(ee),className:"px-2 py-1 text-[10px] font-medium rounded cursor-pointer transition-all",style:{background:ae?J.bg:"transparent",color:ae?J.text:"var(--terminal-text-muted)",border:`1px solid ${ae?J.border:"var(--terminal-border)"}`,opacity:ae?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(P5,{doc:ee,onClose:G,onBreadcrumbClick:Y,history:g,historyIndex:w,onHistoryBack:K,onHistoryForward:M,onHistoryJump:U,onNavigateDoc:Z,allDocs:e})}):null})(),!p&&l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsx(YD,{docs:e,onNodeClick:B,selectedDocId:f,matchedIds:V,localGraphMode:j,onLocalModeChange:E,onClusterClick:$}),Q&&!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:Q.title}),l.jsx("div",{className:"w-2 h-2 rounded-full mb-2",style:{background:Q.status==="active"?"#16a34a":Q.status==="draft"?"#f59e0b":"#94a3b8"}}),Q.tldr&&l.jsx("div",{className:"text-[10px] mb-2 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:Q.tldr}),Q.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"}),Q.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=wx(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(PD,{docs:e,onDocumentClick:ee=>x(ee),selectedDocId:f,matchedIds:V}),d==="list"&&l.jsx(KD,{icon:"📋",title:"List View",message:"Coming soon in KB-002",description:"Table format with sortable columns and quick scanning"}),d==="health"&&l.jsx(QD,{onNavigateDoc:ee=>x(ee)})]})]})}function Fd({icon:e,label:t,active:r,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:r?"rgba(22,163,106,0.2)":"transparent",color:r?"#4ade80":"var(--terminal-text-muted)",border:r?"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 KD({icon:e,title:t,message:r,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:r}),l.jsx("div",{className:"text-xs leading-relaxed",style:{color:"var(--terminal-text-muted)"},children:i})]})})}function QD({onNavigateDoc:e}){const[t,r]=S.useState(null),[i,a]=S.useState(!0),[o,c]=S.useState(null);if(S.useEffect(()=>{Se.getKnowledgeHealth().then(w=>{r(w),a(!1)}).catch(w=>{c(w.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 k="#4ade80";return d<70&&(k="#f59e0b"),d<50&&(k="#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:k,background:`${k}15`,border:`2px solid ${k}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:k}})})]}),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((w,C)=>l.jsxs("li",{className:"text-xs",style:{color:"var(--terminal-text)"},children:["• ",w]},C))})]}),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((w,C)=>l.jsx("li",{children:l.jsx("button",{onClick:()=>e(w),className:"text-xs hover:underline",style:{color:"#fbbf24"},children:w})},C))})]}),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((w,C)=>l.jsx("li",{children:l.jsx("button",{onClick:()=>e(w),className:"text-xs hover:underline",style:{color:"#f472b6"},children:w})},C))})]}),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((w,C)=>l.jsxs("li",{className:"space-y-0.5",children:[l.jsx("button",{onClick:()=>e(w.file),className:"text-xs hover:underline block",style:{color:"#f87171"},children:w.file}),l.jsxs("div",{className:"text-xs pl-4",style:{color:"var(--terminal-text-muted)"},children:["→ ",w.link]})]},C))})]}),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 Mv({waves:e,decisions:t,mode:r,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:k}=su(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:k}),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(vp,{label:`Decisions (${t.length})`,active:f==="decisions",onClick:()=>x("decisions")}),a?l.jsx(vp,{label:"Waves →",active:!1,onClick:a}):l.jsx(vp,{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(w=>l.jsx(ZD,{decision:w,onSave:o,onDelete:c},w.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((w,C)=>l.jsx(JD,{title:`Wave ${w.id}`,subtitle:w.startedAt,content:w.directive},C))]})]})]})}function ZD({decision:e,onSave:t,onDelete:r}){const[i,a]=S.useState(!1),[o,c]=S.useState(!1),[d,m]=S.useState(e.content),[f,x]=S.useState(!1),p=V5(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]),k=S.useCallback(async()=>{if(r){x(!0);try{await r(e.id)}finally{x(!1)}}},[r,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:w=>{w.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:w=>m(w.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:r&&l.jsx("button",{onClick:k,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(Co,{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 vp({label:e,active:t,onClick:r}){return l.jsx("button",{onClick:r,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 V5(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 JD({title:e,subtitle:t,content:r}){const[i,a]=S.useState(!1),o=r.length>100,c=V5(r).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(Co,{content:r})}),!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"}}],kx=[{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 Fv(){return{...e_}}function Sx(e,t){return t.completedQuests.includes(e.id)?"completed":"active"}function W5(e){return fo.filter(t=>Sx(t,e)==="active")}function t_(e){const t=W5(e);return t.find(i=>i.chapter===e.activeChapter)??t[0]??null}function n_(e,t){const r=fo.find(a=>a.id===t);return r?e.completedQuests.includes(t)?{progress:e,quest:null}:{progress:{...e,completedQuests:[...e.completedQuests,t],firstCompletedAt:e.firstCompletedAt??new Date().toISOString()},quest:r}:{progress:e,quest:null}}function Rv(e){let t=1;for(const r of kx)if(r.questIds.every(i=>e.completedQuests.includes(i))){const i=kx.find(a=>a.num===r.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[r,i]of Object.entries(e.trigger.condition))if(r==="minRoles"){if(t.condition.roleCount<i)return!1}else if(t.condition[r]!==i)return!1}return!0}function s_({progress:e,onQuestAction:t,onClose:r,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}=su(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:r}),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:r,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:kx.map(p=>{const y=fo.filter(w=>p.questIds.includes(w.id)),g=y.every(w=>e.completedQuests.includes(w.id)),k=y.some(w=>Sx(w,e)==="active");return l.jsxs("div",{className:"rounded-lg",style:{background:k?"var(--hud-bg-alt)":"transparent",border:k?"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:k?"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(w=>{const C=Sx(w,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:C==="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:C==="completed"?"var(--terminal-text-muted)":"var(--terminal-text)",textDecoration:C==="completed"?"line-through":"none"},children:w.title}),C==="active"&&w.hint&&t&&l.jsx("button",{onClick:()=>t(w.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 →"})]}),C==="active"&&l.jsx("div",{className:"text-[10px] mt-1 leading-relaxed",style:{color:"var(--terminal-text-secondary)"},children:w.description}),C==="active"&&w.hint&&l.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--accent)"},children:["💡 ",w.hint.message]})]})]},w.id)})})]},p.num)})})]})]})}function a_({projectId:e,onClose:t,terminalWidth:r=0}){const[i,a]=S.useState(null),{panelRight:o,panelWidth:c,isResizing:d,handleResizeStart:m}=su(r);if(S.useEffect(()=>{Se.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(Co,{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)"}},r=t[e]??t.todo;return l.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:r.bg,color:r.color},children:e})}const o_={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function c_({roleId:e,roleName:t,mode:r="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:r==="ask"?"Ask":"Assign Task"}),l.jsx("div",{className:"text-sm opacity-80 mt-0.5",children:r==="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:r==="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:r==="ask"?"Ask":"Assign"})]})]})]})}const zv={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"};function v0({event:e,isThinkingCollapsed:t,onToggleThinking:r,onNavigateToSession:i,onOpenKnowledgeDoc:a,compact:o}){var d;const c=zv[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(s0,{remarkPlugins:[c0],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:r,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),k=(d=p.match(/(?:^|\/)knowledge\/(.+\.md)$/))==null?void 0:d[1],w=g&&k&&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] ${w?"text-green-400/80 bg-green-400/10":"text-blue-400/80 bg-blue-400/10"}`,children:w?g&&m.toLowerCase().includes("edit")?"Edit":"Write":m}),w?l.jsx("button",{onClick:()=>a(k),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=zv[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:r,variant:i,style:a,onClose:o,onMinimize:c,onDone:d,onNavigateToSession:m,onOpenKnowledgeDoc:f}){const{events:x,status:p,textOutput:y,childSessionIds:g}=y2(e),[k,w]=S.useState(0),[C,j]=S.useState(new Set),E=S.useRef(null),N=S.useRef(Date.now()),A=S.useRef(!1);S.useEffect(()=>{const _=setInterval(()=>{w(Math.floor((Date.now()-N.current)/1e3))},1e3);return()=>clearInterval(_)},[]),S.useEffect(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[x]),S.useEffect(()=>{(p==="done"||p==="error")&&!A.current&&(A.current=!0,d==null||d())},[p,d]);const z=_=>{j(O=>{const P=new Set(O);return P.has(_)?P.delete(_):P.add(_),P})},T={idle:"Waiting",connecting:"Connecting...",streaming:"Working",done:"Complete",error:"Error"}[p],F={idle:"#888",connecting:"#888",streaming:r,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(k)}),l.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-semibold",style:{background:`${F}22`,color:F},children:T}),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:E,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(v0,{event:_,isThinkingCollapsed:C.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:r},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:r,onToggleRole:i}){const a=e[t];if(!a)return null;const o=!!r&&!!i,d=a.children.map(g=>e[g]).filter(Boolean),m=new Map,f=[];for(const g of d){const k=[];for(const w of g.children){const C=e[w];C&&(k.push(C),f.push(C))}m.set(g.id,k)}const x=g=>!r||r.has(g),p=o?d.filter(g=>r.has(g.id)).length+f.filter(g=>r.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 k=x(g.id),w=d_[g.id]??"#888";return l.jsx(h_,{node:g,active:k,color:w,interactive:o,onToggle:i,subRoles:m.get(g.id)??[],activeRoles:r},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 E;const k=x(g.id),w=(E=d.find(N=>N.children.includes(g.id)))==null?void 0:E.id,C=w?x(w):!0,j=o&&C;return l.jsx("span",{className:`px-2 py-0.5 text-[9px] font-semibold rounded border uppercase transition-all ${j?"cursor-pointer select-none":o?"cursor-not-allowed":""} ${k&&C?"border-white/15 text-white/40":"border-white/5 text-white/15 opacity-50"}`,onClick:j?()=>i(g.id,!k):void 0,title:o?C?k?"Click to exclude":"Click to include":`Enable ${w==null?void 0:w.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:r,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?r:`${r}44`,color:t?r:`${r}44`,background:t?`${r}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:r,onClose:i,onDispatch:a}){const[o,c]=S.useState(""),d=S.useRef(null),[m,f]=S.useState(()=>{const w=new Set,C=t[r];if(C)for(const j of C.children){w.add(j);const E=t[j];if(E)for(const N of E.children)w.add(N)}return w});S.useEffect(()=>{var w;(w=d.current)==null||w.focus()},[]);const x=S.useCallback((w,C)=>{f(j=>{const E=new Set(j);return C?E.add(w):E.delete(w),E})},[]),p=e.filter(w=>m.has(w.id)).length,y=()=>{if(!o.trim()||p===0)return;const w=t[r];let C=0;if(w)for(const N of w.children){C++;const A=t[N];A&&(C+=A.children.length)}const E=m.size>=C?void 0:Array.from(m);a(o.trim(),E),i()},g=w=>{w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&y(),w.key==="Escape"&&i()},k=r&&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:k?"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:[k&&l.jsx(f_,{orgNodes:t,rootId:r,activeRoles:m,onToggleRole:x}),!k&&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(w=>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:[w.id.toUpperCase()," · ",w.name]},w.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:w=>c(w.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),r=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="",k="",w=Date.now();const C=6e4,j=setInterval(()=>{Date.now()-w>C&&(console.warn("[WaveStream] Stale connection — no data for 60s"),d.abort(),clearInterval(j))},1e4);try{for(;;){const{done:E,value:N}=await p.read();if(E)break;w=Date.now(),g+=y.decode(N,{stream:!0});const A=g.split(`
89
- `);g=A.pop()??"";for(const z of A)if(z.startsWith("event: "))k=z.slice(7).trim();else if(z.startsWith("data: ")){try{const T=JSON.parse(z.slice(6));x_(k,T,o,c)}catch{}k=""}}}finally{clearInterval(j)}}).catch(x=>{x.name!=="AbortError"&&console.error("[WaveStream] Connection error:",x)})},[]),i=S.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{connectWaveStream:r,disconnectWaveStream:i}}function x_(e,t,r,i){switch(e){case"wave:event":g_(t,r);break;case"wave:role-attached":y_(t,r,i);break;case"wave:role-detached":b_(t,r);break;case"wave:done":v_(r);break}}function g_(e,t){const{event:r,sessionId:i}=e,{roleId:a}=r;t(o=>{const c=new Map(o),d=c.get(a);if(!d||d.events.some(f=>f.seq===r.seq&&f.roleId===r.roleId))return o;const m={...d,sessionId:i||d.sessionId,events:[...d.events,r]};return r.type==="msg:start"?(m.status="streaming",m.streamStatus="streaming"):r.type==="msg:done"?(m.status="done",m.streamStatus="done"):r.type==="msg:error"?(m.status="error",m.streamStatus="error"):r.type==="msg:awaiting_input"?(m.status="awaiting_input",m.streamStatus="done"):r.type==="msg:reply"&&(m.status="streaming",m.streamStatus="streaming"),c.set(a,m),c})}function y_(e,t,r){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=r[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:r,reason:i}=e,a=i==="error"?"error":"done";t(o=>{const c=new Map(o),d=c.get(r);return!d||d.status==="done"||d.status==="error"?o:(c.set(r,{...d,status:a,streamStatus:a==="error"?"error":"done"}),c)})}function v_(e){e(t=>{const r=new Map(t);let i=!1;for(const[a,o]of r)o.status==="waiting"&&(r.set(a,{...o,status:"not-dispatched"}),i=!0);return i?r:t})}function G5(e,t,r,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:k}=p_(),w=S.useCallback(()=>{if(!r||Object.keys(t).length===0)return null;const _=new Map,O=new Set,P=H=>{const B=t[H];B&&(O.add(H),_.set(H,{sessionId:"",roleId:H,roleName:B.name,children:B.children,status:"waiting",events:[],streamStatus:"idle"}),B.children.forEach(P))},R=t[r];return R&&(_.set(r,{sessionId:"",roleId:r,roleName:"CEO",children:R.children,status:"not-dispatched",events:[],streamStatus:"idle"}),R.children.forEach(P)),{initial:_,allRoles:O}},[t,r]),C=S.useRef(!1);S.useEffect(()=>{if(y.current)if(e.length>0)y.current=!1;else return;if(e.length===0&&C.current&&p.current.size>0)return;C.current=e.length>0;const _=w();if(!_)return;const{initial:O,allRoles:P}=_;for(const R of e){const H=O.get(R.roleId);H&&(H.sessionId=R.sessionId,H.status="streaming",H.streamStatus="connecting")}o(O),f(R=>{if(R.size===0){const H=new Set(P);return H.delete(r),H}return R}),e.length>0&&d(R=>R??e[0].roleId)},[e,t,r,w]);const j=S.useCallback(_=>{f(O=>{const P=new Set(O);return P.has(_)?P.delete(_):P.add(_),P})},[]),E=S.useCallback(_=>{for(const[,O]of x.current)O.controller.abort();x.current.clear(),y.current=!0,o(_);for(const[O,P]of _)if(O!==r&&P.events.length>0){d(O);break}},[r]),N=S.useCallback((_,O)=>{const P=x.current.get(_);if(P&&!P.controller.signal.aborted){console.log(`[WaveTree] connectStream SKIP (already connected) → role=${O} session=${_}`);return}P&&P.controller.abort(),console.log(`[WaveTree] connectStream → role=${O} session=${_}`),o(Z=>{const G=new Map(Z),K=G.get(O);return K&&G.set(O,{...K,sessionId:_,status:"streaming",streamStatus:"connecting",events:[]}),G});const R=new AbortController,H={controller:R,lastSeq:-1};x.current.set(_,H);const B=`/api/sessions/${_}/stream?from=0`;fetch(B,{signal:R.signal}).then(async Z=>{if(!Z.ok||!Z.body){o(Y=>{const $=new Map(Y),Q=$.get(O);return Q&&$.set(O,{...Q,streamStatus:"error"}),$});return}console.log(`[WaveTree SSE] connected → role=${O} status=${Z.status}`),o(Y=>{const $=new Map(Y),Q=$.get(O);return Q&&$.set(O,{...Q,streamStatus:"streaming",status:"streaming"}),$});const G=Z.body.getReader(),K=new TextDecoder;let M="",U="";for(;;){const{done:Y,value:$}=await G.read();if(Y){R.abort();break}M+=K.decode($,{stream:!0});const Q=M.split(`
90
- `);M=Q.pop()??"";for(const ee of Q)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=${O} event=${U} type=${(J==null?void 0:J.type)??"?"} seq=${(J==null?void 0:J.seq)??"?"}`),U==="activity"){const ae=J;ae.seq>H.lastSeq&&(H.lastSeq=ae.seq),o(oe=>{const be=new Map(oe),Ee=be.get(O);if(!Ee||Ee.events.some(Fe=>Fe.seq===ae.seq))return oe;const Ae={...Ee,events:[...Ee.events,ae]};if(ae.type==="dispatch:start"&&ae.data.childSessionId){const Fe=ae.data.targetRoleId??ae.data.roleId,he=ae.data.childSessionId;if(console.log(`[WaveTree] dispatch:start → target=${Fe} childSession=${he??"none"} from=${O}`),Fe&&he){const Re=be.get(Fe);Re&&(be.set(Fe,{...Re,sessionId:he,status:"streaming",streamStatus:"connecting"}),setTimeout(()=>N(he,Fe),0))}}return ae.type==="msg:done"?(Ae.status="done",Ae.streamStatus="done"):ae.type==="msg:error"?(Ae.status="error",Ae.streamStatus="error"):ae.type==="msg:awaiting_input"?(Ae.status="awaiting_input",Ae.streamStatus="done"):ae.type==="msg:reply"&&(Ae.status="streaming",Ae.streamStatus="streaming"),be.set(O,Ae),be})}else if(U==="stream:end"){const ae=J.reason;ae!=="replied"&&o(oe=>{const be=new Map(oe),Ee=be.get(O);if(!Ee)return oe;const Ae=ae==="error"?"error":ae==="awaiting_input"?"awaiting_input":"done";return be.set(O,{...Ee,status:Ee.status==="streaming"?Ae:Ee.status,streamStatus:Ae==="error"?"error":"done"}),be})}}catch{}U=""}}}).catch(Z=>{Z.name!=="AbortError"&&o(G=>{const K=new Map(G),M=K.get(O);return M&&K.set(O,{...M,streamStatus:"error"}),K})})},[]),A=S.useRef(new Set),z=S.useRef(!1),T=S.useRef(t);T.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,T.current),()=>{k(),z.current=!1}},[i,g,k]),S.useEffect(()=>{if(i||e.length===0)return;z.current=!1;const _=new Set;for(const O of e)_.add(O.sessionId),N(O.sessionId,O.roleId);return A.current=_,()=>{for(const O of A.current){const P=x.current.get(O);P&&(P.controller.abort(),x.current.delete(O))}A.current.clear()}},[e,N,i]);const q=(()=>{let _=0,O=0,P=0,R=0;for(const[H,B]of a)H!==r&&(R++,B.status==="done"?_++:B.status==="streaming"?O++:B.status==="awaiting_input"&&P++);return{done:_,total:R,running:O,awaitingInput:P}})(),V=q.total>0&&q.done>0&&q.running===0&&q.awaitingInput===0&&Array.from(a.values()).every(_=>!ba(_.status)&&_.streamStatus!=="streaming"&&_.streamStatus!=="connecting");S.useEffect(()=>{V&&o(_=>{const O=new Map(_);let P=!1;for(const[R,H]of O)H.status==="waiting"&&(O.set(R,{...H,status:"not-dispatched"}),P=!0);return P?O:_})},[V]);const L=S.useCallback(()=>{for(const[,O]of x.current)O.controller.abort();x.current.clear(),y.current=!1;const _=w();if(_){o(_.initial);const O=new Set(_.allRoles);O.delete(r),f(O)}d(r)},[w,r]);return{nodes:a,selectedRoleId:c,selectNode:d,checkedRoles:m,toggleCheck:j,setCheckedRoles:f,progress:q,allDone:V,connectStream:N,injectStaticNodes:E,reset:L}}function Hn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let r=0,i;r<e.length;r++)(i=Hn(e[r]))!==""&&(t+=(t&&" ")+i);else for(let r in e)e[r]&&(t+=(t&&" ")+r);return t}var Cx="http://www.w3.org/1999/xhtml";const Bv={svg:"http://www.w3.org/2000/svg",xhtml:Cx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Lf(e){var t=e+="",r=t.indexOf(":");return r>=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),Bv.hasOwnProperty(t)?{space:Bv[t],local:e}:e}function w_(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Cx&&t.documentElement.namespaceURI===Cx?t.createElement(e):t.createElementNS(r,e)}}function k_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function K5(e){var t=Lf(e);return(t.local?k_:w_)(t)}function S_(){}function w0(e){return e==null?S_:function(){return this.querySelector(e)}}function C_(e){typeof e!="function"&&(e=w0(e));for(var t=this._groups,r=t.length,i=new Array(r),a=0;a<r;++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 ri(i,this._parents)}function j_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function E_(){return[]}function Q5(e){return e==null?E_:function(){return this.querySelectorAll(e)}}function N_(e){return function(){return j_(e.apply(this,arguments))}}function A_(e){typeof e=="function"?e=N_(e):e=Q5(e);for(var t=this._groups,r=t.length,i=[],a=[],o=0;o<r;++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 ri(i,a)}function Z5(e){return function(){return this.matches(e)}}function J5(e){return function(t){return t.matches(e)}}var T_=Array.prototype.find;function D_(e){return function(){return T_.call(this.children,e)}}function __(){return this.firstElementChild}function M_(e){return this.select(e==null?__:D_(typeof e=="function"?e:J5(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:J5(e)))}function $_(e){typeof e!="function"&&(e=Z5(e));for(var t=this._groups,r=t.length,i=new Array(r),a=0;a<r;++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 ri(i,this._parents)}function ek(e){return new Array(e.length)}function O_(){return new ri(this._enter||this._groups.map(ek),this._parents)}function wf(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}wf.prototype={constructor:wf,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,r,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):r[c]=new wf(e,o[c]);for(;c<m;++c)(d=t[c])&&(a[c]=d)}function H_(e,t,r,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)):r[d]=new wf(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 r=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)),k=g.length,w=d[f]=new Array(k),C=c[f]=new Array(k),j=m[f]=new Array(y);r(x,p,w,C,j,g,t);for(var E=0,N=0,A,z;E<k;++E)if(A=w[E]){for(E>=N&&(N=E+1);!(z=C[N])&&++N<k;);A._next=z||null}}return c=new ri(c,i),c._enter=d,c._exit=m,c}function Y_(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function X_(){return new ri(this._exit||this._groups.map(ek),this._parents)}function P_(e,t,r){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())),r==null?o.remove():r(o),i&&a?i.merge(a).order():a}function V_(e){for(var t=e.selection?e.selection():e,r=this._groups,i=t._groups,a=r.length,o=i.length,c=Math.min(a,o),d=new Array(a),m=0;m<c;++m)for(var f=r[m],x=i[m],p=f.length,y=d[m]=new Array(p),g,k=0;k<p;++k)(g=f[k]||x[k])&&(y[k]=g);for(;m<a;++m)d[m]=r[m];return new ri(d,this._parents)}function W_(){for(var e=this._groups,t=-1,r=e.length;++t<r;)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 r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o){for(var c=r[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 ri(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,r=e.length;t<r;++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,r=0,i=t.length;r<i;++r)for(var a=t[r],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 r=t.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function oM(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,r)}}function cM(e,t){var r=Lf(e);if(arguments.length<2){var i=this.node();return r.local?i.getAttributeNS(r.space,r.local):i.getAttribute(r)}return this.each((t==null?r.local?iM:rM:typeof t=="function"?r.local?oM:lM:r.local?aM:sM)(r,t))}function tk(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,r){return function(){this.style.setProperty(e,t,r)}}function fM(e,t,r){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,r)}}function hM(e,t,r){return arguments.length>1?this.each((t==null?uM:typeof t=="function"?fM:dM)(e,t,r??"")):ho(this.node(),e)}function ho(e,t){return e.style.getPropertyValue(t)||tk(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 r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function gM(e,t){return arguments.length>1?this.each((t==null?mM:typeof t=="function"?xM:pM)(e,t)):this.node()[e]}function nk(e){return e.trim().split(/^|\s+/)}function k0(e){return e.classList||new rk(e)}function rk(e){this._node=e,this._names=nk(e.getAttribute("class")||"")}rk.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 ik(e,t){for(var r=k0(e),i=-1,a=t.length;++i<a;)r.add(t[i])}function sk(e,t){for(var r=k0(e),i=-1,a=t.length;++i<a;)r.remove(t[i])}function yM(e){return function(){ik(this,e)}}function bM(e){return function(){sk(this,e)}}function vM(e,t){return function(){(t.apply(this,arguments)?ik:sk)(this,e)}}function wM(e,t){var r=nk(e+"");if(arguments.length<2){for(var i=k0(this.node()),a=-1,o=r.length;++a<o;)if(!i.contains(r[a]))return!1;return!0}return this.each((typeof t=="function"?vM:t?yM:bM)(r,t))}function kM(){this.textContent=""}function SM(e){return function(){this.textContent=e}}function CM(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function jM(e){return arguments.length?this.each(e==null?kM:(typeof e=="function"?CM:SM)(e)):this.node().textContent}function EM(){this.innerHTML=""}function NM(e){return function(){this.innerHTML=e}}function AM(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function TM(e){return arguments.length?this.each(e==null?EM:(typeof e=="function"?AM:NM)(e)):this.node().innerHTML}function DM(){this.nextSibling&&this.parentNode.appendChild(this)}function _M(){return this.each(DM)}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:K5(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function zM(){return null}function BM(e,t){var r=typeof e=="function"?e:K5(e),i=t==null?zM:typeof t=="function"?t:w0(t);return this.select(function(){return this.insertBefore(r.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 r="",i=t.indexOf(".");return i>=0&&(r=t.slice(i+1),t=t.slice(0,i)),{type:t,name:r}})}function XM(e){return function(){var t=this.__on;if(t){for(var r=0,i=-1,a=t.length,o;r<a;++r)o=t[r],(!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 PM(e,t,r){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=r),a.value=t;return}}this.addEventListener(e.type,o,r),a={type:e.type,name:e.name,value:t,listener:o,options:r},i?i.push(a):this.__on=[a]}}function VM(e,t,r){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?PM:XM,a=0;a<o;++a)this.each(d(i[a],t,r));return this}function ak(e,t,r){var i=tk(e),a=i.CustomEvent;typeof a=="function"?a=new a(t,r):(a=i.document.createEvent("Event"),r?(a.initEvent(t,r.bubbles,r.cancelable),a.detail=r.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function WM(e,t){return function(){return ak(this,e,t)}}function GM(e,t){return function(){return ak(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,r=e.length;t<r;++t)for(var i=e[t],a=0,o=i.length,c;a<o;++a)(c=i[a])&&(yield c)}var lk=[null];function ri(e,t){this._groups=e,this._parents=t}function au(){return new ri([[document.documentElement]],lk)}function ZM(){return this}ri.prototype=au.prototype={constructor:ri,select:C_,selectAll:A_,selectChild:M_,selectChildren:B_,filter:$_,data:q_,enter:O_,exit:X_,join:P_,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:jM,html:TM,raise:_M,lower:FM,append:RM,insert:BM,remove:OM,clone:HM,datum:UM,on:VM,dispatch:KM,[Symbol.iterator]:QM};function ti(e){return typeof e=="string"?new ri([[document.querySelector(e)]],[document.documentElement]):new ri([[e]],lk)}function JM(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Di(e,t){if(e=JM(e),t===void 0&&(t=e.currentTarget),t){var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.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},Xc={capture:!0,passive:!1};function wp(e){e.stopImmediatePropagation()}function ao(e){e.preventDefault(),e.stopImmediatePropagation()}function ok(e){var t=e.document.documentElement,r=ti(e).on("dragstart.drag",ao,Xc);"onselectstart"in t?r.on("selectstart.drag",ao,Xc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function ck(e,t){var r=e.document.documentElement,i=ti(e).on("dragstart.drag",null);t&&(i.on("click.drag",ao,Xc),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in r?i.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const Rd=e=>()=>e;function jx(e,{sourceEvent:t,subject:r,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:r,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}})}jx.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 uk(){var e=tF,t=nF,r=rF,i=iF,a={},o=iu("start","drag","end"),c=0,d,m,f,x,p=0;function y(A){A.on("mousedown.drag",g).filter(i).on("touchstart.drag",C).on("touchmove.drag",j,eF).on("touchend.drag touchcancel.drag",E).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 T=N(this,t.call(this,A,z),A,z,"mouse");T&&(ti(A.view).on("mousemove.drag",k,Xc).on("mouseup.drag",w,Xc),ok(A.view),wp(A),f=!1,d=A.clientX,m=A.clientY,T("start",A))}}function k(A){if(ao(A),!f){var z=A.clientX-d,T=A.clientY-m;f=z*z+T*T>p}a.mouse("drag",A)}function w(A){ti(A.view).on("mousemove.drag mouseup.drag",null),ck(A.view,f),ao(A),a.mouse("end",A)}function C(A,z){if(e.call(this,A,z)){var T=A.changedTouches,F=t.call(this,A,z),q=T.length,V,L;for(V=0;V<q;++V)(L=N(this,F,A,z,T[V].identifier,T[V]))&&(wp(A),L("start",A,T[V]))}}function j(A){var z=A.changedTouches,T=z.length,F,q;for(F=0;F<T;++F)(q=a[z[F].identifier])&&(ao(A),q("drag",A,z[F]))}function E(A){var z=A.changedTouches,T=z.length,F,q;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),F=0;F<T;++F)(q=a[z[F].identifier])&&(wp(A),q("end",A,z[F]))}function N(A,z,T,F,q,V){var L=o.copy(),_=Di(V||T,z),O,P,R;if((R=r.call(A,new jx("beforestart",{sourceEvent:T,target:y,identifier:q,active:c,x:_[0],y:_[1],dx:0,dy:0,dispatch:L}),F))!=null)return O=R.x-_[0]||0,P=R.y-_[1]||0,function H(B,Z,G){var K=_,M;switch(B){case"start":a[q]=H,M=c++;break;case"end":delete a[q],--c;case"drag":_=Di(G||Z,z),M=c;break}L.call(B,A,new jx(B,{sourceEvent:Z,subject:R,target:y,identifier:q,active:M,x:_[0]+O,y:_[1]+P,dx:_[0]-K[0],dy:_[1]-K[1],dispatch:L}),F)}}return y.filter=function(A){return arguments.length?(e=typeof A=="function"?A:Rd(!!A),y):e},y.container=function(A){return arguments.length?(t=typeof A=="function"?A:Rd(A),y):t},y.subject=function(A){return arguments.length?(r=typeof A=="function"?A:Rd(A),y):r},y.touchable=function(A){return arguments.length?(i=typeof A=="function"?A:Rd(!!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 S0(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function dk(e,t){var r=Object.create(e.prototype);for(var i in t)r[i]=t[i];return r}function lu(){}var Pc=.7,kf=1/Pc,lo="\\s*([+-]?\\d+)\\s*",Vc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ns="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sF=/^#([0-9a-f]{3,8})$/,aF=new RegExp(`^rgb\\(${lo},${lo},${lo}\\)$`),lF=new RegExp(`^rgb\\(${ns},${ns},${ns}\\)$`),oF=new RegExp(`^rgba\\(${lo},${lo},${lo},${Vc}\\)$`),cF=new RegExp(`^rgba\\(${ns},${ns},${ns},${Vc}\\)$`),uF=new RegExp(`^hsl\\(${Vc},${ns},${ns}\\)$`),dF=new RegExp(`^hsla\\(${Vc},${ns},${ns},${Vc}\\)$`),$v={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};S0(lu,ll,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ov,formatHex:Ov,formatHex8:fF,formatHsl:hF,formatRgb:Lv,toString:Lv});function Ov(){return this.rgb().formatHex()}function fF(){return this.rgb().formatHex8()}function hF(){return fk(this).formatHsl()}function Lv(){return this.rgb().formatRgb()}function ll(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=sF.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?Iv(t):r===3?new zr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?zd(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?zd(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 zr(t[1],t[2],t[3],1):(t=lF.exec(e))?new zr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oF.exec(e))?zd(t[1],t[2],t[3],t[4]):(t=cF.exec(e))?zd(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uF.exec(e))?qv(t[1],t[2]/100,t[3]/100,1):(t=dF.exec(e))?qv(t[1],t[2]/100,t[3]/100,t[4]):$v.hasOwnProperty(e)?Iv($v[e]):e==="transparent"?new zr(NaN,NaN,NaN,0):null}function Iv(e){return new zr(e>>16&255,e>>8&255,e&255,1)}function zd(e,t,r,i){return i<=0&&(e=t=r=NaN),new zr(e,t,r,i)}function mF(e){return e instanceof lu||(e=ll(e)),e?(e=e.rgb(),new zr(e.r,e.g,e.b,e.opacity)):new zr}function Ex(e,t,r,i){return arguments.length===1?mF(e):new zr(e,t,r,i??1)}function zr(e,t,r,i){this.r=+e,this.g=+t,this.b=+r,this.opacity=+i}S0(zr,Ex,dk(lu,{brighter(e){return e=e==null?kf:Math.pow(kf,e),new zr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Pc:Math.pow(Pc,e),new zr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new zr(tl(this.r),tl(this.g),tl(this.b),Sf(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:Hv,formatHex:Hv,formatHex8:pF,formatRgb:Uv,toString:Uv}));function Hv(){return`#${Ja(this.r)}${Ja(this.g)}${Ja(this.b)}`}function pF(){return`#${Ja(this.r)}${Ja(this.g)}${Ja(this.b)}${Ja((isNaN(this.opacity)?1:this.opacity)*255)}`}function Uv(){const e=Sf(this.opacity);return`${e===1?"rgb(":"rgba("}${tl(this.r)}, ${tl(this.g)}, ${tl(this.b)}${e===1?")":`, ${e})`}`}function Sf(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function tl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ja(e){return e=tl(e),(e<16?"0":"")+e.toString(16)}function qv(e,t,r,i){return i<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Mi(e,t,r,i)}function fk(e){if(e instanceof Mi)return new Mi(e.h,e.s,e.l,e.opacity);if(e instanceof lu||(e=ll(e)),!e)return new Mi;if(e instanceof Mi)return e;e=e.rgb();var t=e.r/255,r=e.g/255,i=e.b/255,a=Math.min(t,r,i),o=Math.max(t,r,i),c=NaN,d=o-a,m=(o+a)/2;return d?(t===o?c=(r-i)/d+(r<i)*6:r===o?c=(i-t)/d+2:c=(t-r)/d+4,d/=m<.5?o+a:2-o-a,c*=60):d=m>0&&m<1?0:c,new Mi(c,d,m,e.opacity)}function xF(e,t,r,i){return arguments.length===1?fk(e):new Mi(e,t,r,i??1)}function Mi(e,t,r,i){this.h=+e,this.s=+t,this.l=+r,this.opacity=+i}S0(Mi,xF,dk(lu,{brighter(e){return e=e==null?kf:Math.pow(kf,e),new Mi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Pc:Math.pow(Pc,e),new Mi(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,r=this.l,i=r+(r<.5?r:1-r)*t,a=2*r-i;return new zr(kp(e>=240?e-240:e+120,a,i),kp(e,a,i),kp(e<120?e+240:e-120,a,i),this.opacity)},clamp(){return new Mi(Yv(this.h),Bd(this.s),Bd(this.l),Sf(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=Sf(this.opacity);return`${e===1?"hsl(":"hsla("}${Yv(this.h)}, ${Bd(this.s)*100}%, ${Bd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Yv(e){return e=(e||0)%360,e<0?e+360:e}function Bd(e){return Math.max(0,Math.min(1,e||0))}function kp(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const C0=e=>()=>e;function gF(e,t){return function(r){return e+r*t}}function yF(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(i){return Math.pow(e+i*t,r)}}function bF(e){return(e=+e)==1?hk:function(t,r){return r-t?yF(t,r,e):C0(isNaN(t)?r:t)}}function hk(e,t){var r=t-e;return r?gF(e,r):C0(isNaN(e)?t:e)}const Cf=(function e(t){var r=bF(t);function i(a,o){var c=r((a=Ex(a)).r,(o=Ex(o)).r),d=r(a.g,o.g),m=r(a.b,o.b),f=hk(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 r=e?Math.min(t.length,e.length):0,i=t.slice(),a;return function(o){for(a=0;a<r;++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 r=t?t.length:0,i=e?Math.min(r,e.length):0,a=new Array(i),o=new Array(r),c;for(c=0;c<i;++c)a[c]=Oc(e[c],t[c]);for(;c<r;++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 r=new Date;return e=+e,t=+t,function(i){return r.setTime(e*(1-i)+t*i),r}}function Zi(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}function CF(e,t){var r={},i={},a;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(a in t)a in e?r[a]=Oc(e[a],t[a]):i[a]=t[a];return function(o){for(a in r)i[a]=r[a](o);return i}}var Nx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Sp=new RegExp(Nx.source,"g");function jF(e){return function(){return e}}function EF(e){return function(t){return e(t)+""}}function mk(e,t){var r=Nx.lastIndex=Sp.lastIndex=0,i,a,o,c=-1,d=[],m=[];for(e=e+"",t=t+"";(i=Nx.exec(e))&&(a=Sp.exec(t));)(o=a.index)>r&&(o=t.slice(r,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:Zi(i,a)})),r=Sp.lastIndex;return r<t.length&&(o=t.slice(r),d[c]?d[c]+=o:d[++c]=o),d.length<2?m[0]?EF(m[0].x):jF(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 Oc(e,t){var r=typeof t,i;return t==null||r==="boolean"?C0(t):(r==="number"?Zi:r==="string"?(i=ll(t))?(t=i,Cf):mk:t instanceof ll?Cf:t instanceof Date?SF:wF(t)?vF:Array.isArray(t)?kF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?CF:Zi)(e,t)}var Xv=180/Math.PI,Ax={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function pk(e,t,r,i,a,o){var c,d,m;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(m=e*r+t*i)&&(r-=e*m,i-=t*m),(d=Math.sqrt(r*r+i*i))&&(r/=d,i/=d,m/=d),e*i<t*r&&(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 $d;function NF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ax:pk(t.a,t.b,t.c,t.d,t.e,t.f)}function AF(e){return e==null||($d||($d=document.createElementNS("http://www.w3.org/2000/svg","g")),$d.setAttribute("transform",e),!(e=$d.transform.baseVal.consolidate()))?Ax:(e=e.matrix,pk(e.a,e.b,e.c,e.d,e.e,e.f))}function xk(e,t,r,i){function a(f){return f.length?f.pop()+" ":""}function o(f,x,p,y,g,k){if(f!==p||x!==y){var w=g.push("translate(",null,t,null,r);k.push({i:w-4,x:Zi(f,p)},{i:w-2,x:Zi(x,y)})}else(p||y)&&g.push("translate("+p+t+y+r)}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:Zi(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:Zi(f,x)}):x&&p.push(a(p)+"skewX("+x+i)}function m(f,x,p,y,g,k){if(f!==p||x!==y){var w=g.push(a(g)+"scale(",null,",",null,")");k.push({i:w-4,x:Zi(f,p)},{i:w-2,x:Zi(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 k=-1,w=y.length,C;++k<w;)p[(C=y[k]).i]=C.x(g);return p.join("")}}}var TF=xk(NF,"px, ","px)","deg)"),DF=xk(AF,", ",")",")"),_F=1e-12;function Pv(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 rf=(function e(t,r,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,k=p-m,w=g*g+k*k,C,j;if(w<_F)j=Math.log(y/f)/t,C=function(F){return[d+F*g,m+F*k,f*Math.exp(t*F*j)]};else{var E=Math.sqrt(w),N=(y*y-f*f+i*w)/(2*f*r*E),A=(y*y-f*f-i*w)/(2*y*r*E),z=Math.log(Math.sqrt(N*N+1)-N),T=Math.log(Math.sqrt(A*A+1)-A);j=(T-z)/t,C=function(F){var q=F*j,V=Pv(z),L=f/(r*E)*(V*FF(t*q+z)-MF(z));return[d+L*g,m+L*k,f*V/Pv(t*q+z)]}}return C.duration=j*1e3*t/Math.SQRT2,C}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=iu("start","end","cancel","interrupt"),zF=[],gk=0,Vv=1,Tx=2,sf=3,Wv=4,Dx=5,af=6;function If(e,t,r,i,a,o){var c=e.__transition;if(!c)e.__transition={};else if(r in c)return;BF(e,r,{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:gk})}function j0(e,t){var r=Bi(e,t);if(r.state>gk)throw new Error("too late; already scheduled");return r}function ls(e,t){var r=Bi(e,t);if(r.state>sf)throw new Error("too late; already running");return r}function Bi(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function BF(e,t,r){var i=e.__transition,a;i[t]=r,r.timer=y0(o,0,r.time);function o(f){r.state=Vv,r.timer.restart(c,r.delay,r.time),r.delay<=f&&c(f-r.delay)}function c(f){var x,p,y,g;if(r.state!==Vv)return m();for(x in i)if(g=i[x],g.name===r.name){if(g.state===sf)return Sv(c);g.state===Wv?(g.state=af,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete i[x]):+x<t&&(g.state=af,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete i[x])}if(Sv(function(){r.state===sf&&(r.state=Wv,r.timer.restart(d,r.delay,r.time),d(f))}),r.state=Tx,r.on.call("start",e,e.__data__,r.index,r.group),r.state===Tx){for(r.state=sf,a=new Array(y=r.tween.length),x=0,p=-1;x<y;++x)(g=r.tween[x].value.call(e,e.__data__,r.index,r.group))&&(a[++p]=g);a.length=p+1}}function d(f){for(var x=f<r.duration?r.ease.call(null,f/r.duration):(r.timer.restart(m),r.state=Dx,1),p=-1,y=a.length;++p<y;)a[p].call(e,x);r.state===Dx&&(r.on.call("end",e,e.__data__,r.index,r.group),m())}function m(){r.state=af,r.timer.stop(),delete i[t];for(var f in i)return;delete e.__transition}}function lf(e,t){var r=e.__transition,i,a,o=!0,c;if(r){t=t==null?null:t+"";for(c in r){if((i=r[c]).name!==t){o=!1;continue}a=i.state>Tx&&i.state<Dx,i.state=af,i.timer.stop(),i.on.call(a?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete r[c]}o&&delete e.__transition}}function $F(e){return this.each(function(){lf(this,e)})}function OF(e,t){var r,i;return function(){var a=ls(this,e),o=a.tween;if(o!==r){i=r=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,r){var i,a;if(typeof r!="function")throw new Error;return function(){var o=ls(this,e),c=o.tween;if(c!==i){a=(i=c).slice();for(var d={name:t,value:r},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 r=this._id;if(e+="",arguments.length<2){for(var i=Bi(this.node(),r).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)(r,e,t))}function E0(e,t,r){var i=e._id;return e.each(function(){var a=ls(this,i);(a.value||(a.value={}))[t]=r.apply(this,arguments)}),function(a){return Bi(a,i).value[t]}}function yk(e,t){var r;return(typeof t=="number"?Zi:t instanceof ll?Cf:(r=ll(t))?(t=r,Cf):mk)(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,r){var i,a=r+"",o;return function(){var c=this.getAttribute(e);return c===a?null:c===i?o:o=t(i=c,r)}}function YF(e,t,r){var i,a=r+"",o;return function(){var c=this.getAttributeNS(e.space,e.local);return c===a?null:c===i?o:o=t(i=c,r)}}function XF(e,t,r){var i,a,o;return function(){var c,d=r(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 PF(e,t,r){var i,a,o;return function(){var c,d=r(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 r=Lf(e),i=r==="transform"?DF:yk;return this.attrTween(e,typeof t=="function"?(r.local?PF:XF)(r,i,E0(this,"attr."+e,t)):t==null?(r.local?UF:HF)(r):(r.local?YF:qF)(r,i,t))}function WF(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function GF(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function KF(e,t){var r,i;function a(){var o=t.apply(this,arguments);return o!==i&&(r=(i=o)&&GF(e,o)),r}return a._value=t,a}function QF(e,t){var r,i;function a(){var o=t.apply(this,arguments);return o!==i&&(r=(i=o)&&WF(e,o)),r}return a._value=t,a}function ZF(e,t){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;var i=Lf(e);return this.tween(r,(i.local?KF:QF)(i,t))}function JF(e,t){return function(){j0(this,e).delay=+t.apply(this,arguments)}}function eR(e,t){return t=+t,function(){j0(this,e).delay=t}}function tR(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?JF:eR)(t,e)):Bi(this.node(),t).delay}function nR(e,t){return function(){ls(this,e).duration=+t.apply(this,arguments)}}function rR(e,t){return t=+t,function(){ls(this,e).duration=t}}function iR(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?nR:rR)(t,e)):Bi(this.node(),t).duration}function sR(e,t){if(typeof t!="function")throw new Error;return function(){ls(this,e).ease=t}}function aR(e){var t=this._id;return arguments.length?this.each(sR(t,e)):Bi(this.node(),t).ease}function lR(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!="function")throw new Error;ls(this,e).ease=r}}function oR(e){if(typeof e!="function")throw new Error;return this.each(lR(this._id,e))}function cR(e){typeof e!="function"&&(e=Z5(e));for(var t=this._groups,r=t.length,i=new Array(r),a=0;a<r;++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 Rs(i,this._parents,this._name,this._id)}function uR(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,r=e._groups,i=t.length,a=r.length,o=Math.min(i,a),c=new Array(i),d=0;d<o;++d)for(var m=t[d],f=r[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 Rs(c,this._parents,this._name,this._id)}function dR(e){return(e+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");return r>=0&&(t=t.slice(0,r)),!t||t==="start"})}function fR(e,t,r){var i,a,o=dR(t)?j0:ls;return function(){var c=o(this,e),d=c.on;d!==i&&(a=(i=d).copy()).on(t,r),c.on=a}}function hR(e,t){var r=this._id;return arguments.length<2?Bi(this.node(),r).on.on(e):this.each(fR(r,e,t))}function mR(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function pR(){return this.on("end.remove",mR(this._id))}function xR(e){var t=this._name,r=this._id;typeof e!="function"&&(e=w0(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,If(f[y],t,r,y,f,Bi(x,r)));return new Rs(o,this._parents,t,r)}function gR(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Q5(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,k=Bi(x,r),w=0,C=y.length;w<C;++w)(g=y[w])&&If(g,t,r,w,y,k);o.push(y),c.push(x)}return new Rs(o,c,t,r)}var yR=au.prototype.constructor;function bR(){return new yR(this._groups,this._parents)}function vR(e,t){var r,i,a;return function(){var o=ho(this,e),c=(this.style.removeProperty(e),ho(this,e));return o===c?null:o===r&&c===i?a:a=t(r=o,i=c)}}function bk(e){return function(){this.style.removeProperty(e)}}function wR(e,t,r){var i,a=r+"",o;return function(){var c=ho(this,e);return c===a?null:c===i?o:o=t(i=c,r)}}function kR(e,t,r){var i,a,o;return function(){var c=ho(this,e),d=r(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 r,i,a,o="style."+t,c="end."+o,d;return function(){var m=ls(this,e),f=m.on,x=m.value[o]==null?d||(d=bk(t)):void 0;(f!==r||a!==x)&&(i=(r=f).copy()).on(c,a=x),m.on=i}}function CR(e,t,r){var i=(e+="")=="transform"?TF:yk;return t==null?this.styleTween(e,vR(e,i)).on("end.style."+e,bk(e)):typeof t=="function"?this.styleTween(e,kR(e,i,E0(this,"style."+e,t))).each(SR(this._id,e)):this.styleTween(e,wR(e,i,t),r).on("end.style."+e,null)}function jR(e,t,r){return function(i){this.style.setProperty(e,t.call(this,i),r)}}function ER(e,t,r){var i,a;function o(){var c=t.apply(this,arguments);return c!==a&&(i=(a=c)&&jR(e,c,r)),i}return o._value=t,o}function NR(e,t,r){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,ER(e,t,r??""))}function AR(e){return function(){this.textContent=e}}function TR(e){return function(){var t=e(this);this.textContent=t??""}}function DR(e){return this.tween("text",typeof e=="function"?TR(E0(this,"text",e)):AR(e==null?"":e+""))}function _R(e){return function(t){this.textContent=e.call(this,t)}}function MR(e){var t,r;function i(){var a=e.apply(this,arguments);return a!==r&&(t=(r=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,r=vk(),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=Bi(m,t);If(m,e,r,f,c,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new Rs(i,this._parents,e,r)}function zR(){var e,t,r=this,i=r._id,a=r.size();return new Promise(function(o,c){var d={value:c},m={value:function(){--a===0&&o()}};r.each(function(){var f=ls(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 Rs(e,t,r,i){this._groups=e,this._parents=t,this._name=r,this._id=i}function vk(){return++BR}var As=au.prototype;Rs.prototype={constructor:Rs,select:xR,selectAll:gR,selectChild:As.selectChild,selectChildren:As.selectChildren,filter:cR,merge:uR,selection:bR,transition:RR,call:As.call,nodes:As.nodes,node:As.node,size:As.size,empty:As.empty,each:As.each,on:hR,attr:VF,attrTween:ZF,style:CR,styleTween:NR,text:DR,textTween:FR,remove:pR,tween:IF,delay:tR,duration:iR,ease:aR,easeVarying:oR,end:zR,[Symbol.iterator]:As[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 r;!(r=e.__transition)||!(r=r[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return r}function IR(e){var t,r;e instanceof Rs?(t=e._id,e=e._name):(t=vk(),(r=OR).time=g0(),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])&&If(m,e,t,f,c,r||LR(m,t));return new Rs(i,this._parents,e,t)}au.prototype.interrupt=$F;au.prototype.transition=IR;const Od=e=>()=>e;function HR(e,{sourceEvent:t,target:r,transform:i,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function _s(e,t,r){this.k=e,this.x=t,this.y=r}_s.prototype={constructor:_s,scale:function(e){return e===1?this:new _s(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _s(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 Hf=new _s(1,0,0);wk.prototype=_s.prototype;function wk(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Hf;return e.__zoom}function Cp(e){e.stopImmediatePropagation()}function Ac(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 Gv(){return this.__zoom||Hf}function YR(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function XR(){return navigator.maxTouchPoints||"ontouchstart"in this}function PR(e,t,r){var i=e.invertX(t[0][0])-r[0][0],a=e.invertX(t[1][0])-r[1][0],o=e.invertY(t[0][1])-r[0][1],c=e.invertY(t[1][1])-r[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 kk(){var e=UR,t=qR,r=PR,i=YR,a=XR,o=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,m=rf,f=iu("start","zoom","end"),x,p,y,g=500,k=150,w=0,C=10;function j(R){R.property("__zoom",Gv).on("wheel.zoom",q,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",L).filter(a).on("touchstart.zoom",_).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}j.transform=function(R,H,B,Z){var G=R.selection?R.selection():R;G.property("__zoom",Gv),R!==G?z(R,H,B,Z):G.interrupt().each(function(){T(this,arguments).event(Z).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},j.scaleBy=function(R,H,B,Z){j.scaleTo(R,function(){var G=this.__zoom.k,K=typeof H=="function"?H.apply(this,arguments):H;return G*K},B,Z)},j.scaleTo=function(R,H,B,Z){j.transform(R,function(){var G=t.apply(this,arguments),K=this.__zoom,M=B==null?A(G):typeof B=="function"?B.apply(this,arguments):B,U=K.invert(M),Y=typeof H=="function"?H.apply(this,arguments):H;return r(N(E(K,Y),M,U),G,c)},B,Z)},j.translateBy=function(R,H,B,Z){j.transform(R,function(){return r(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof B=="function"?B.apply(this,arguments):B),t.apply(this,arguments),c)},null,Z)},j.translateTo=function(R,H,B,Z,G){j.transform(R,function(){var K=t.apply(this,arguments),M=this.__zoom,U=Z==null?A(K):typeof Z=="function"?Z.apply(this,arguments):Z;return r(Hf.translate(U[0],U[1]).scale(M.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof B=="function"?-B.apply(this,arguments):-B),K,c)},Z,G)};function E(R,H){return H=Math.max(o[0],Math.min(o[1],H)),H===R.k?R:new _s(H,R.x,R.y)}function N(R,H,B){var Z=H[0]-B[0]*R.k,G=H[1]-B[1]*R.k;return Z===R.x&&G===R.y?R:new _s(R.k,Z,G)}function A(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function z(R,H,B,Z){R.on("start.zoom",function(){T(this,arguments).event(Z).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(Z).end()}).tween("zoom",function(){var G=this,K=arguments,M=T(G,K).event(Z),U=t.apply(G,K),Y=B==null?A(U):typeof B=="function"?B.apply(G,K):B,$=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),Q=G.__zoom,ee=typeof H=="function"?H.apply(G,K):H,J=m(Q.invert(Y).concat($/Q.k),ee.invert(Y).concat($/ee.k));return function(ae){if(ae===1)ae=ee;else{var oe=J(ae),be=$/oe[2];ae=new _s(be,Y[0]-oe[0]*be,Y[1]-oe[1]*be)}M.zoom(null,ae)}})}function T(R,H,B){return!B&&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=ti(this.that).datum();f.call(R,this.that,new HR(R,{sourceEvent:this.sourceEvent,target:j,transform:this.that.__zoom,dispatch:f}),H)}};function q(R,...H){if(!e.apply(this,arguments))return;var B=T(this,H).event(R),Z=this.__zoom,G=Math.max(o[0],Math.min(o[1],Z.k*Math.pow(2,i.apply(this,arguments)))),K=Di(R);if(B.wheel)(B.mouse[0][0]!==K[0]||B.mouse[0][1]!==K[1])&&(B.mouse[1]=Z.invert(B.mouse[0]=K)),clearTimeout(B.wheel);else{if(Z.k===G)return;B.mouse=[K,Z.invert(K)],lf(this),B.start()}Ac(R),B.wheel=setTimeout(M,k),B.zoom("mouse",r(N(E(Z,G),B.mouse[0],B.mouse[1]),B.extent,c));function M(){B.wheel=null,B.end()}}function V(R,...H){if(y||!e.apply(this,arguments))return;var B=R.currentTarget,Z=T(this,H,!0).event(R),G=ti(R.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",$,!0),K=Di(R,B),M=R.clientX,U=R.clientY;ok(R.view),Cp(R),Z.mouse=[K,this.__zoom.invert(K)],lf(this),Z.start();function Y(Q){if(Ac(Q),!Z.moved){var ee=Q.clientX-M,J=Q.clientY-U;Z.moved=ee*ee+J*J>w}Z.event(Q).zoom("mouse",r(N(Z.that.__zoom,Z.mouse[0]=Di(Q,B),Z.mouse[1]),Z.extent,c))}function $(Q){G.on("mousemove.zoom mouseup.zoom",null),ck(Q.view,Z.moved),Ac(Q),Z.event(Q).end()}}function L(R,...H){if(e.apply(this,arguments)){var B=this.__zoom,Z=Di(R.changedTouches?R.changedTouches[0]:R,this),G=B.invert(Z),K=B.k*(R.shiftKey?.5:2),M=r(N(E(B,K),Z,G),t.apply(this,H),c);Ac(R),d>0?ti(this).transition().duration(d).call(z,M,Z,R):ti(this).call(j.transform,M,Z,R)}}function _(R,...H){if(e.apply(this,arguments)){var B=R.touches,Z=B.length,G=T(this,H,R.changedTouches.length===Z).event(R),K,M,U,Y;for(Cp(R),M=0;M<Z;++M)U=B[M],Y=Di(U,this),Y=[Y,this.__zoom.invert(Y),U.identifier],G.touch0?!G.touch1&&G.touch0[2]!==Y[2]&&(G.touch1=Y,G.taps=0):(G.touch0=Y,K=!0,G.taps=1+!!x);x&&(x=clearTimeout(x)),K&&(G.taps<2&&(p=Y[0],x=setTimeout(function(){x=null},g)),lf(this),G.start())}}function O(R,...H){if(this.__zooming){var B=T(this,H).event(R),Z=R.changedTouches,G=Z.length,K,M,U,Y;for(Ac(R),K=0;K<G;++K)M=Z[K],U=Di(M,this),B.touch0&&B.touch0[2]===M.identifier?B.touch0[0]=U:B.touch1&&B.touch1[2]===M.identifier&&(B.touch1[0]=U);if(M=B.that.__zoom,B.touch1){var $=B.touch0[0],Q=B.touch0[1],ee=B.touch1[0],J=B.touch1[1],ae=(ae=ee[0]-$[0])*ae+(ae=ee[1]-$[1])*ae,oe=(oe=J[0]-Q[0])*oe+(oe=J[1]-Q[1])*oe;M=E(M,Math.sqrt(ae/oe)),U=[($[0]+ee[0])/2,($[1]+ee[1])/2],Y=[(Q[0]+J[0])/2,(Q[1]+J[1])/2]}else if(B.touch0)U=B.touch0[0],Y=B.touch0[1];else return;B.zoom("touch",r(N(M,U,Y),B.extent,c))}}function P(R,...H){if(this.__zooming){var B=T(this,H).event(R),Z=R.changedTouches,G=Z.length,K,M;for(Cp(R),y&&clearTimeout(y),y=setTimeout(function(){y=null},g),K=0;K<G;++K)M=Z[K],B.touch0&&B.touch0[2]===M.identifier?delete B.touch0:B.touch1&&B.touch1[2]===M.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(M=Di(M,this),Math.hypot(p[0]-M[0],p[1]-M[1])<C)){var U=ti(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return j.wheelDelta=function(R){return arguments.length?(i=typeof R=="function"?R:Od(+R),j):i},j.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Od(!!R),j):e},j.touchable=function(R){return arguments.length?(a=typeof R=="function"?R:Od(!!R),j):a},j.extent=function(R){return arguments.length?(t=typeof R=="function"?R:Od([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),j):t},j.scaleExtent=function(R){return arguments.length?(o[0]=+R[0],o[1]=+R[1],j):[o[0],o[1]]},j.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],j):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},j.constrain=function(R){return arguments.length?(r=R,j):r},j.duration=function(R){return arguments.length?(d=+R,j):d},j.interpolate=function(R){return arguments.length?(m=R,j):m},j.on=function(){var R=f.on.apply(f,arguments);return R===f?j:R},j.clickDistance=function(R){return arguments.length?(w=(R=+R)*R,j):Math.sqrt(w)},j.tapDistance=function(R){return arguments.length?(C=+R,j):C},j}const rs={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:r,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?r: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."},Wc=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Sk=["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:r})=>`Moved selected node ${e}. New position, x: ${t}, y: ${r}`,"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 nl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(nl||(nl={}));var Gc;(function(e){e.Partial="partial",e.Full="full"})(Gc||(Gc={}));const jk={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ga;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ga||(ga={}));var jf;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(jf||(jf={}));var at;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(at||(at={}));const Kv={[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 Nk=e=>"id"in e&&"source"in e&&"target"in e,VR=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),N0=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ou=(e,t=[0,0])=>{const{width:r,height:i}=$s(e),a=e.origin??t,o=r*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 r=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):N0(a)?a:t.nodeLookup.get(a.id));const d=c?Ef(c,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Uf(i,d)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return qf(r)},cu=(e,t={})=>{let r={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))&&(r=Uf(r,Ef(a)),i=!0)}),i?qf(r):{x:0,y:0,width:0,height:0}},A0=(e,t,[r,i,a]=[0,0,1],o=!1,c=!1)=>{const d={...du(t,[r,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,k=x.height??f.height??f.initialHeight??null,w=Kc(d,xo(f)),C=(g??0)*(k??0),j=o&&w>0;(!f.internals.handleBounds||j||w>=C||f.dragging)&&m.push(f)}return m},GR=(e,t)=>{const r=new Set;return e.forEach(i=>{r.add(i.id)}),t.filter(i=>r.has(i.source)||r.has(i.target))};function KR(e,t){const r=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))&&r.set(a.id,a)}),r}async function QR({nodes:e,width:t,height:r,panZoom:i,minZoom:a,maxZoom:o},c){if(e.size===0)return Promise.resolve(!0);const d=KR(e,c),m=cu(d),f=T0(m,t,r,(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 Ak({nodeId:e,nextPosition:t,nodeLookup:r,nodeOrigin:i=[0,0],nodeExtent:a,onError:o}){const c=r.get(e),d=c.parentId?r.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",rs.error005());else{const g=d.measured.width,k=d.measured.height;g&&k&&(p=[[m,f],[m+g,f+k]])}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)?ol(t,p,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(o==null||o("015",rs.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:r,edges:i,onBeforeDelete:a}){const o=new Set(e.map(y=>y.id)),c=[];for(const y of r){if(y.deletable===!1)continue;const g=o.has(y.id),k=!g&&y.parentId&&c.find(w=>w.id===y.parentId);(g||k)&&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(k=>k.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,r=1)=>Math.min(Math.max(e,t),r),ol=(e={x:0,y:0},t,r)=>({x:po(e.x,t[0][0],t[1][0]-((r==null?void 0:r.width)??0)),y:po(e.y,t[0][1],t[1][1]-((r==null?void 0:r.height)??0))});function Tk(e,t,r){const{width:i,height:a}=$s(r),{x:o,y:c}=r.internals.positionAbsolute;return ol(e,[[o,c],[o+i,c+a]],t)}const Qv=(e,t,r)=>e<t?po(Math.abs(e-t),1,t)/t:e>r?-po(Math.abs(e-r),1,t)/t:0,Dk=(e,t,r=15,i=40)=>{const a=Qv(e.x,i,t.width-i)*r,o=Qv(e.y,i,t.height-i)*r;return[a,o]},Uf=(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)}),_x=({x:e,y:t,width:r,height:i})=>({x:e,y:t,x2:e+r,y2:t+i}),qf=({x:e,y:t,x2:r,y2:i})=>({x:e,y:t,width:r-e,height:i-t}),xo=(e,t=[0,0])=>{var a,o;const{x:r,y:i}=N0(e)?e.internals.positionAbsolute:ou(e,t);return{x:r,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}},Ef=(e,t=[0,0])=>{var a,o;const{x:r,y:i}=N0(e)?e.internals.positionAbsolute:ou(e,t);return{x:r,y:i,x2:r+(((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)}},_k=(e,t)=>qf(Uf(_x(e),_x(t))),Kc=(e,t)=>{const r=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(r*i)},Zv=e=>Fi(e.width)&&Fi(e.height)&&Fi(e.x)&&Fi(e.y),Fi=e=>!isNaN(e)&&isFinite(e),JR=(e,t)=>{},uu=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),du=({x:e,y:t},[r,i,a],o=!1,c=[1,1])=>{const d={x:(e-r)/a,y:(t-i)/a};return o?uu(d,c):d},Nf=({x:e,y:t},[r,i,a])=>({x:e*a+r,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 r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(r)}if(typeof e=="string"&&e.endsWith("%")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(t*r*.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,r){if(typeof e=="string"||typeof e=="number"){const i=Jl(e,r),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,r),a=Jl(e.bottom??e.y??0,r),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,r,i,a,o){const{x:c,y:d}=Nf(e,[t,r,i]),{x:m,y:f}=Nf({x:e.x+e.width,y:e.y+e.height},[t,r,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 T0=(e,t,r,i,a,o)=>{const c=ez(o,t,r),d=(t-c.x)/e.width,m=(r-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,k=r/2-y*x,w=tz(e,g,k,x,t,r),C={left:Math.min(w.left-c.left,0),top:Math.min(w.top-c.top,0),right:Math.min(w.right-c.right,0),bottom:Math.min(w.bottom-c.bottom,0)};return{x:g-C.left+C.right,y:k-C.top+C.bottom,zoom:x}},Qc=()=>{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 $s(e){var t,r;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}}function Mk(e){var t,r;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight)!==void 0}function Fk(e,t={width:0,height:0},r,i,a){const o={...e},c=i.get(r);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 Jv(e,t){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))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 Lc(e,{snapGrid:t=[0,0],snapToGrid:r=!1,transform:i,containerBounds:a}){const{x:o,y:c}=Ri(e),d=du({x:o-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},i),{x:m,y:f}=r?uu(d,t):d;return{xSnapped:m,ySnapped:f,...d}}const D0=e=>({width:e.offsetWidth,height:e.offsetHeight}),Rk=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 zk(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 Bk=e=>"clientX"in e,Ri=(e,t)=>{var o,c;const r=Bk(e),i=r?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=r?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)}},ew=(e,t,r,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-r.left)/i,y:(d.top-r.top)/i,...D0(c)}})};function $k({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:o,targetControlX:c,targetControlY:d}){const m=e*.125+a*.375+c*.375+r*.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 Ld(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function tw({pos:e,x1:t,y1:r,x2:i,y2:a,c:o}){switch(e){case at.Left:return[t-Ld(t-i,o),r];case at.Right:return[t+Ld(i-t,o),r];case at.Top:return[t,r-Ld(r-a,o)];case at.Bottom:return[t,r+Ld(a-r,o)]}}function Ok({sourceX:e,sourceY:t,sourcePosition:r=at.Bottom,targetX:i,targetY:a,targetPosition:o=at.Top,curvature:c=.25}){const[d,m]=tw({pos:r,x1:e,y1:t,x2:i,y2:a,c}),[f,x]=tw({pos:o,x1:i,y1:a,x2:e,y2:t,c}),[p,y,g,k]=$k({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,k]}function Lk({sourceX:e,sourceY:t,targetX:r,targetY:i}){const a=Math.abs(r-e)/2,o=r<e?r+a:r-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:r=!1,zIndex:i=0,elevateOnSelect:a=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const c=a&&r?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:r,height:i,transform:a}){const o=Uf(Ef(e),Ef(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:r/a[2],height:i/a[2]};return Kc(c,qf(o))>0}const lz=({source:e,sourceHandle:t,target:r,targetHandle:i})=>`xy-edge__${e}${t||""}-${r}${i||""}`,oz=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),cz=(e,t,r={})=>{if(!e.source||!e.target)return t;const i=r.getEdgeId||lz;let a;return Nk(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 Ik({sourceX:e,sourceY:t,targetX:r,targetY:i}){const[a,o,c,d]=Lk({sourceX:e,sourceY:t,targetX:r,targetY:i});return[`M ${e},${t}L ${r},${i}`,a,o,c,d]}const nw={[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:r})=>t===at.Left||t===at.Right?e.x<r.x?{x:1,y:0}:{x:-1,y:0}:e.y<r.y?{x:0,y:1}:{x:0,y:-1},rw=(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:r,targetPosition:i=at.Top,center:a,offset:o,stepPosition:c}){const d=nw[t],m=nw[i],f={x:e.x+d.x*o,y:e.y+d.y*o},x={x:r.x+m.x*o,y:r.y+m.y*o},p=uz({source:f,sourcePosition:t,target:x}),y=p.x!==0?"x":"y",g=p[y];let k=[],w,C;const j={x:0,y:0},E={x:0,y:0},[,,N,A]=Lk({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(d[y]*m[y]===-1){y==="x"?(w=a.x??f.x+(x.x-f.x)*c,C=a.y??(f.y+x.y)/2):(w=a.x??(f.x+x.x)/2,C=a.y??f.y+(x.y-f.y)*c);const T=[{x:w,y:f.y},{x:w,y:x.y}],F=[{x:f.x,y:C},{x:x.x,y:C}];d[y]===g?k=y==="x"?T:F:k=y==="x"?F:T}else{const T=[{x:f.x,y:x.y}],F=[{x:x.x,y:f.y}];if(y==="x"?k=d.x===g?F:T:k=d.y===g?T:F,t===i){const O=Math.abs(e[y]-r[y]);if(O<=o){const P=Math.min(o-1,o-O);d[y]===g?j[y]=(f[y]>e[y]?-1:1)*P:E[y]=(x[y]>r[y]?-1:1)*P}}if(t!==i){const O=y==="x"?"y":"x",P=d[y]===m[O],R=f[O]>x[O],H=f[O]<x[O];(d[y]===1&&(!P&&R||P&&H)||d[y]!==1&&(!P&&H||P&&R))&&(k=y==="x"?T:F)}const q={x:f.x+j.x,y:f.y+j.y},V={x:x.x+E.x,y:x.y+E.y},L=Math.max(Math.abs(q.x-k[0].x),Math.abs(V.x-k[0].x)),_=Math.max(Math.abs(q.y-k[0].y),Math.abs(V.y-k[0].y));L>=_?(w=(q.x+V.x)/2,C=k[0].y):(w=k[0].x,C=(q.y+V.y)/2)}return[[e,{x:f.x+j.x,y:f.y+j.y},...k,{x:x.x+E.x,y:x.y+E.y},r],w,C,N,A]}function fz(e,t,r,i){const a=Math.min(rw(e,t)/2,rw(t,r)/2,i),{x:o,y:c}=t;if(e.x===o&&o===r.x||e.y===c&&c===r.y)return`L${o} ${c}`;if(e.y===c){const f=e.x<r.x?-1:1,x=e.y<r.y?1:-1;return`L ${o+a*f},${c}Q ${o},${c} ${o},${c+a*x}`}const d=e.x<r.x?1:-1,m=e.y<r.y?-1:1;return`L ${o},${c+a*m}Q ${o},${c} ${o+a*d},${c}`}function Af({sourceX:e,sourceY:t,sourcePosition:r=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,k,w]=dz({source:{x:e,y:t},sourcePosition:r,target:{x:i,y:a},targetPosition:o,center:{x:d,y:m},offset:f,stepPosition:x});return[p.reduce((j,E,N)=>{let A="";return N>0&&N<p.length-1?A=fz(p[N-1],E,p[N+1],c):A=`${N===0?"M":"L"}${E.x} ${E.y}`,j+=A,j},""),y,g,k,w]}function iw(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:r}=e;if(!iw(t)||!iw(r))return null;const i=t.internals.handleBounds||sw(t.handles),a=r.internals.handleBounds||sw(r.handles),o=aw((i==null?void 0:i.source)??[],e.sourceHandle),c=aw(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",rs.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=cl(t,o,d),x=cl(r,c,m);return{sourceX:f.x,sourceY:f.y,targetX:x.x,targetY:x.y,sourcePosition:d,targetPosition:m}}function sw(e){if(!e)return null;const t=[],r=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&r.push(i);return{source:t,target:r}}function cl(e,t,r=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??$s(e);if(i)return{x:a+c/2,y:o+d/2};switch((t==null?void 0:t.position)??r){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 aw(e,t){return e&&(t?e.find(r=>r.id===t):e[0])||null}function Mx(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:r,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=Mx(m,t);o.has(f)||(c.push({id:f,color:m.color||r,...m}),o.add(f))}}),c),[]).sort((c,d)=>c.id.localeCompare(d.id))}const Hk=1e3,pz=10,_0={nodeOrigin:[0,0],nodeExtent:Wc,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},xz={..._0,checkEquality:!0};function M0(e,t){const r={...e};for(const i in t)t[i]!==void 0&&(r[i]=t[i]);return r}function gz(e,t,r){const i=M0(_0,r);for(const a of e.values())if(a.parentId)R0(a,e,t,i);else{const o=ou(a,i.nodeOrigin),c=go(a.extent)?a.extent:i.nodeExtent,d=ol(o,c,$s(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 r=[],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"?r.push(o):a.type==="target"&&i.push(o)}return{source:r,target:i}}function F0(e){return e==="manual"}function Fx(e,t,r,i={}){var f,x;const a=M0(xz,i),o={i:0},c=new Map(t),d=a!=null&&a.elevateNodesOnSelect&&!F0(a.zIndexMode)?Hk:0;let m=e.length>0;t.clear(),r.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=ou(p,a.nodeOrigin),k=go(p.extent)?p.extent:a.nodeExtent,w=ol(g,k,$s(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:w,handleBounds:yz(p,y),z:Uk(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&&R0(y,t,r,i,o)}return m}function bz(e,t){if(!e.parentId)return;const r=t.get(e.parentId);r?r.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function R0(e,t,r,i,a){const{elevateNodesOnSelect:o,nodeOrigin:c,nodeExtent:d,zIndexMode:m}=M0(_0,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,r),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&&!F0(m)?Hk:0,{x:y,y:g,z:k}=vz(e,x,c,d,p,m),{positionAbsolute:w}=e.internals,C=y!==w.x||g!==w.y;(C||k!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:y,y:g}:w,z:k}})}function Uk(e,t,r){const i=Fi(e.zIndex)?e.zIndex:0;return F0(r)?i:i+(e.selected?t:0)}function vz(e,t,r,i,a,o){const{x:c,y:d}=t.internals.positionAbsolute,m=$s(e),f=ou(e,r),x=go(e.extent)?ol(f,e.extent,m):f;let p=ol({x:c+x.x,y:d+x.y},i,m);e.extent==="parent"&&(p=Tk(p,m,t));const y=Uk(e,a,o),g=t.internals.z??0;return{x:p.x,y:p.y,z:g>=y?g+1:y}}function z0(e,t,r,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=_k(f,d.rect);o.set(d.parentId,{expandedRect:x,parent:m})}return o.size>0&&o.forEach(({expandedRect:d,parent:m},f)=>{var N;const x=m.internals.positionAbsolute,p=$s(m),y=m.origin??i,g=d.x<x.x?Math.round(Math.abs(x.x-d.x)):0,k=d.y<x.y?Math.round(Math.abs(x.y-d.y)):0,w=Math.max(p.width,Math.round(d.width)),C=Math.max(p.height,Math.round(d.height)),j=(w-p.width)*y[0],E=(C-p.height)*y[1];(g>0||k>0||j||E)&&(a.push({id:f,type:"position",position:{x:m.position.x-g+j,y:m.position.y-k+E}}),(N=r.get(f))==null||N.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+k}})})),(p.width<d.width||p.height<d.height||g||k)&&a.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?y[0]*g-j:0),height:C+(k?y[1]*k-E:0)}})}),a}function wz(e,t,r,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 k=t.get(g.id);if(!k)continue;if(k.hidden){t.set(k.id,{...k,internals:{...k.internals,handleBounds:void 0}}),m=!0;continue}const w=D0(g.nodeElement),C=k.measured.width!==w.width||k.measured.height!==w.height;if(!!(w.width&&w.height&&(C||!k.internals.handleBounds||g.force))){const E=g.nodeElement.getBoundingClientRect(),N=go(k.extent)?k.extent:o;let{positionAbsolute:A}=k.internals;k.parentId&&k.extent==="parent"?A=Tk(A,w,t.get(k.parentId)):N&&(A=ol(A,N,w));const z={...k,measured:w,internals:{...k.internals,positionAbsolute:A,handleBounds:{source:ew("source",g.nodeElement,E,p,k.id),target:ew("target",g.nodeElement,E,p,k.id)}}};t.set(k.id,z),k.parentId&&R0(z,t,r,{nodeOrigin:a,zIndexMode:c}),m=!0,C&&(f.push({id:k.id,type:"dimensions",dimensions:w}),k.expandParent&&k.parentId&&y.push({id:k.id,parentId:k.parentId,rect:xo(z,a)}))}}if(y.length>0){const g=z0(y,t,r,a);f.push(...g)}return{changes:f,updatedInternals:m}}async function kz({delta:e,panZoom:t,transform:r,translateExtent:i,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const c=await t.setViewportConstrained({x:r[0]+e.x,y:r[1]+e.y,zoom:r[2]},[[0,0],[a,o]],i),d=!!c&&(c.x!==r[0]||c.y!==r[1]||c.k!==r[2]);return Promise.resolve(d)}function lw(e,t,r,i,a,o){let c=a;const d=i.get(c)||new Map;i.set(c,d.set(r,t)),c=`${a}-${e}`;const m=i.get(c)||new Map;if(i.set(c,m.set(r,t)),o){c=`${a}-${e}-${o}`;const f=i.get(c)||new Map;i.set(c,f.set(r,t))}}function qk(e,t,r){e.clear(),t.clear();for(const i of r){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}`;lw("source",m,x,e,a,c),lw("target",m,f,e,o,d),t.set(i.id,i)}}function Yk(e,t){if(!e.parentId)return!1;const r=t.get(e.parentId);return r?r.selected?!0:Yk(r,t):!1}function ow(e,t,r){var a;let i=e;do{if((a=i==null?void 0:i.matches)!=null&&a.call(i,t))return!0;if(i===r)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Sz(e,t,r,i){const a=new Map;for(const[o,c]of e)if((c.selected||c.id===i)&&(!c.parentId||!Yk(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:r.x-d.internals.positionAbsolute.x,y:r.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 jp({nodeId:e,dragItems:t,nodeLookup:r,dragging:i=!0}){var c,d,m;const a=[];for(const[f,x]of t){const p=(c=r.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=r.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 Cz({dragItems:e,snapGrid:t,x:r,y:i}){const a=e.values().next().value;if(!a)return null;const o={x:r-a.distance.x,y:i-a.distance.y},c=uu(o,t);return{x:c.x-o.x,y:c.y-o.y}}function jz({onNodeMouseDown:e,getStoreItems:t,onDragStart:r,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,k=!1,w=null;function C({noDragClassName:E,handleSelector:N,domNode:A,isSelectable:z,nodeId:T,nodeClickDistance:F=0}){y=ti(A);function q({x:O,y:P}){const{nodeLookup:R,nodeExtent:H,snapGrid:B,snapToGrid:Z,nodeOrigin:G,onNodeDrag:K,onSelectionDrag:M,onError:U,updateNodePositions:Y}=t();o={x:O,y:P};let $=!1;const Q=d.size>1,ee=Q&&H?_x(cu(d)):null,J=Q&&Z?Cz({dragItems:d,snapGrid:B,x:O,y:P}):null;for(const[ae,oe]of d){if(!R.has(ae))continue;let be={x:O-oe.distance.x,y:P-oe.distance.y};Z&&(be=J?{x:Math.round(be.x+J.x),y:Math.round(be.y+J.y)}:uu(be,B));let Ee=null;if(Q&&H&&!oe.extent&&ee){const{positionAbsolute:he}=oe.internals,Re=he.x-ee.x+H[0][0],et=he.x+oe.measured.width-ee.x2+H[1][0],We=he.y-ee.y+H[0][1],it=he.y+oe.measured.height-ee.y2+H[1][1];Ee=[[Re,We],[et,it]]}const{position:Ae,positionAbsolute:Fe}=Ak({nodeId:ae,nextPosition:be,nodeLookup:R,nodeExtent:Ee||H,nodeOrigin:G,onError:U});$=$||oe.position.x!==Ae.x||oe.position.y!==Ae.y,oe.position=Ae,oe.internals.positionAbsolute=Fe}if(k=k||$,!!$&&(Y(d,!0),w&&(i||K||!T&&M))){const[ae,oe]=jp({nodeId:T,dragItems:d,nodeLookup:R});i==null||i(w,d,ae,oe),K==null||K(w,ae,oe),T||M==null||M(w,oe)}}async function V(){if(!x)return;const{transform:O,panBy:P,autoPanSpeed:R,autoPanOnNodeDrag:H}=t();if(!H){m=!1,cancelAnimationFrame(c);return}const[B,Z]=Dk(f,x,R);(B!==0||Z!==0)&&(o.x=(o.x??0)-B/O[2],o.y=(o.y??0)-Z/O[2],await P({x:B,y:Z})&&q(o)),c=requestAnimationFrame(V)}function L(O){var Q;const{nodeLookup:P,multiSelectionActive:R,nodesDraggable:H,transform:B,snapGrid:Z,snapToGrid:G,selectNodesOnDrag:K,onNodeDragStart:M,onSelectionDragStart:U,unselectNodesAndEdges:Y}=t();p=!0,(!K||!z)&&!R&&T&&((Q=P.get(T))!=null&&Q.selected||Y()),z&&K&&T&&(e==null||e(T));const $=Lc(O.sourceEvent,{transform:B,snapGrid:Z,snapToGrid:G,containerBounds:x});if(o=$,d=Sz(P,H,$,T),d.size>0&&(r||M||!T&&U)){const[ee,J]=jp({nodeId:T,dragItems:d,nodeLookup:P});r==null||r(O.sourceEvent,d,ee,J),M==null||M(O.sourceEvent,ee,J),T||U==null||U(O.sourceEvent,J)}}const _=uk().clickDistance(F).on("start",O=>{const{domNode:P,nodeDragThreshold:R,transform:H,snapGrid:B,snapToGrid:Z}=t();x=(P==null?void 0:P.getBoundingClientRect())||null,g=!1,k=!1,w=O.sourceEvent,R===0&&L(O),o=Lc(O.sourceEvent,{transform:H,snapGrid:B,snapToGrid:Z,containerBounds:x}),f=Ri(O.sourceEvent,x)}).on("drag",O=>{const{autoPanOnNodeDrag:P,transform:R,snapGrid:H,snapToGrid:B,nodeDragThreshold:Z,nodeLookup:G}=t(),K=Lc(O.sourceEvent,{transform:R,snapGrid:H,snapToGrid:B,containerBounds:x});if(w=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||T&&!G.has(T))&&(g=!0),!g){if(!m&&P&&p&&(m=!0,V()),!p){const M=Ri(O.sourceEvent,x),U=M.x-f.x,Y=M.y-f.y;Math.sqrt(U*U+Y*Y)>Z&&L(O)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&d&&p&&(f=Ri(O.sourceEvent,x),q(K))}}).on("end",O=>{if(!(!p||g)&&(m=!1,p=!1,cancelAnimationFrame(c),d.size>0)){const{nodeLookup:P,updateNodePositions:R,onNodeDragStop:H,onSelectionDragStop:B}=t();if(k&&(R(d,!1),k=!1),a||H||!T&&B){const[Z,G]=jp({nodeId:T,dragItems:d,nodeLookup:P,dragging:!1});a==null||a(O.sourceEvent,d,Z,G),H==null||H(O.sourceEvent,Z,G),T||B==null||B(O.sourceEvent,G)}}}).filter(O=>{const P=O.target;return!O.button&&(!E||!ow(P,`.${E}`,A))&&(!N||ow(P,N,A))});y.call(_)}function j(){y==null||y.on(".drag",null)}return{update:C,destroy:j}}function Ez(e,t,r){const i=[],a={x:e.x-r,y:e.y-r,width:r*2,height:r*2};for(const o of t.values())Kc(a,xo(o))>0&&i.push(o);return i}const Nz=250;function Az(e,t,r,i){var d,m;let a=[],o=1/0;const c=Ez(e,r,t+Nz);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}=cl(f,p,p.position,!0),k=Math.sqrt(Math.pow(y-e.x,2)+Math.pow(g-e.y,2));k>t||(k<o?(a=[{...p,x:y,y:g}],o=k):k===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,r,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=(r?d==null?void 0:d.find(y=>y.id===r):d==null?void 0:d[0])??null;return m&&o?{...m,...cl(c,m,m.position,!0)}:m}function Pk(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Tz(e,t){let r=null;return t?r=!0:e&&!t&&(r=!1),r}const Vk=()=>!0;function Dz(e,{connectionMode:t,connectionRadius:r,handleId:i,nodeId:a,edgeUpdaterType:o,isTarget:c,domNode:d,nodeLookup:m,lib:f,autoPanOnConnect:x,flowId:p,panBy:y,cancelConnection:g,onConnectStart:k,onConnect:w,onConnectEnd:C,isValidConnection:j=Vk,onReconnectEnd:E,updateConnection:N,getTransform:A,getFromHandle:z,autoPanSpeed:T,dragThreshold:F=1,handleDomNode:q}){const V=Rk(e.target);let L=0,_;const{x:O,y:P}=Ri(e),R=Pk(o,q),H=d==null?void 0:d.getBoundingClientRect();let B=!1;if(!H||!R)return;const Z=Xk(a,R,i,m,t);if(!Z)return;let G=Ri(e,H),K=!1,M=null,U=!1,Y=null;function $(){if(!x||!H)return;const[Ae,Fe]=Dk(G,H,T);y({x:Ae,y:Fe}),L=requestAnimationFrame($)}const Q={...Z,nodeId:a,type:R,position:Z.position},ee=m.get(a);let ae={inProgress:!0,isValid:null,from:cl(ee,Q,at.Left,!0),fromHandle:Q,fromPosition:Q.position,fromNode:ee,to:G,toHandle:null,toPosition:Kv[Q.position],toNode:null,pointer:G};function oe(){B=!0,N(ae),k==null||k(e,{nodeId:a,handleId:i,handleType:R})}F===0&&oe();function be(Ae){if(!B){const{x:it,y:mt}=Ri(Ae),Ye=it-O,Ze=mt-P;if(!(Ye*Ye+Ze*Ze>F*F))return;oe()}if(!z()||!Q){Ee(Ae);return}const Fe=A();G=Ri(Ae,H),_=Az(du(G,Fe,!1,[1,1]),r,m,Q),K||($(),K=!0);const he=Wk(Ae,{handle:_,connectionMode:t,fromNodeId:a,fromHandleId:i,fromType:c?"target":"source",isValidConnection:j,doc:V,lib:f,flowId:p,nodeLookup:m});Y=he.handleDomNode,M=he.connection,U=Tz(!!_,he.isValid);const Re=m.get(a),et=Re?cl(Re,Q,at.Left,!0):ae.from,We={...ae,from:et,isValid:U,to:he.toHandle&&U?Nf({x:he.toHandle.x,y:he.toHandle.y},Fe):G,toHandle:he.toHandle,toPosition:U&&he.toHandle?he.toHandle.position:Kv[Q.position],toNode:he.toHandle?m.get(he.toHandle.nodeId):null,pointer:G};N(We),ae=We}function Ee(Ae){if(!("touches"in Ae&&Ae.touches.length>0)){if(B){(_||Y)&&M&&U&&(w==null||w(M));const{inProgress:Fe,...he}=ae,Re={...he,toPosition:ae.toHandle?ae.toPosition:null};C==null||C(Ae,Re),o&&(E==null||E(Ae,Re))}g(),cancelAnimationFrame(L),K=!1,U=!1,M=null,Y=null,V.removeEventListener("mousemove",be),V.removeEventListener("mouseup",Ee),V.removeEventListener("touchmove",be),V.removeEventListener("touchend",Ee)}}V.addEventListener("mousemove",be),V.addEventListener("mouseup",Ee),V.addEventListener("touchmove",be),V.addEventListener("touchend",Ee)}function Wk(e,{handle:t,connectionMode:r,fromNodeId:i,fromHandleId:a,fromType:o,doc:c,lib:d,flowId:m,isValidConnection:f=Vk,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:k}=Ri(e),w=c.elementFromPoint(g,k),C=w!=null&&w.classList.contains(`${d}-flow__handle`)?w:y,j={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const E=Pk(void 0,C),N=C.getAttribute("data-nodeid"),A=C.getAttribute("data-handleid"),z=C.classList.contains("connectable"),T=C.classList.contains("connectableend");if(!N||!E)return j;const F={source:p?N:i,sourceHandle:p?A:a,target:p?i:N,targetHandle:p?a:A};j.connection=F;const V=z&&T&&(r===mo.Strict?p&&E==="source"||!p&&E==="target":N!==i||A!==a);j.isValid=V&&f(F),j.toHandle=Xk(N,E,A,x,r,!0)}return j}const Rx={onPointerDown:Dz,isValid:Wk};function _z({domNode:e,panZoom:t,getTransform:r,getViewScale:i}){const a=ti(e);function o({translateExtent:d,width:m,height:f,zoomStep:x=1,pannable:p=!0,zoomable:y=!0,inversePan:g=!1}){const k=N=>{if(N.sourceEvent.type!=="wheel"||!t)return;const A=r(),z=N.sourceEvent.ctrlKey&&Qc()?10:1,T=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*x,F=A[2]*Math.pow(2,T*z);t.scaleTo(F)};let w=[0,0];const C=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(w=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},j=N=>{const A=r();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!t)return;const z=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],T=[z[0]-w[0],z[1]-w[1]];w=z;const F=i()*Math.max(A[2],Math.log(A[2]))*(g?-1:1),q={x:A[0]-T[0]*F,y:A[1]-T[1]*F},V=[[0,0],[m,f]];t.setViewportConstrained({x:q.x,y:q.y,zoom:A[2]},V,d)},E=kk().on("start",C).on("zoom",p?j:null).on("zoom.wheel",y?k:null);a.call(E,{})}function c(){a.on("zoom",null)}return{update:o,destroy:c,pointer:Di}}const Yf=e=>({x:e.x,y:e.y,zoom:e.k}),Ep=({x:e,y:t,zoom:r})=>Hf.translate(e,t).scale(r),no=(e,t)=>e.target.closest(`.${t}`),Gk=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Mz=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Np=(e,t=0,r=Mz,i=()=>{})=>{const a=typeof t=="number"&&t>0;return a||i(),a?e.transition().duration(t).ease(r).on("end",i):e},Kk=e=>{const t=e.ctrlKey&&Qc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fz({zoomPanValues:e,noWheelClassName:t,d3Selection:r,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=r.property("__zoom").k||1;if(x.ctrlKey&&c){const C=Di(x),j=Kk(x),E=p*Math.pow(2,j);i.scaleTo(r,E,C,x);return}const y=x.deltaMode===1?20:1;let g=a===nl.Vertical?0:x.deltaX*y,k=a===nl.Horizontal?0:x.deltaY*y;!Qc()&&x.shiftKey&&a!==nl.Vertical&&(g=x.deltaY*y,k=0),i.translateBy(r,-(g/p)*o,-(k/p)*o,{internal:!0});const w=Yf(r.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(m==null||m(x,w),e.panScrollTimeout=setTimeout(()=>{f==null||f(x,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,d==null||d(x,w))}}function Rz({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:r}){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(),r.call(this,i,a)}}function zz({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:r}){return i=>{var o,c,d;if((o=i.sourceEvent)!=null&&o.internal)return;const a=Yf(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),r&&(r==null||r(i.sourceEvent,a))}}function Bz({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:r,onTransformChange:i,onPanZoom:a}){return o=>{var c,d;e.usedRightMouseButton=!!(r&&Gk(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,Yf(o.transform)))}}function $z({zoomPanValues:e,panOnDrag:t,panOnScroll:r,onDraggingChange:i,onPanZoomEnd:a,onPaneContextMenu:o}){return c=>{var d;if(!((d=c.sourceEvent)!=null&&d.internal)&&(e.isZoomingOrPanning=!1,o&&Gk(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&o(c.sourceEvent),e.usedRightMouseButton=!1,i(!1),a)){const m=Yf(c.transform);e.prevViewport=m,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,m)},r?150:0)}}}function Oz({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:c,noWheelClassName:d,noPanClassName:m,lib:f,connectionInProgress:x}){return p=>{var C;const y=e||t,g=r&&p.ctrlKey,k=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&&!r||c||x&&!k||no(p,d)&&k||no(p,m)&&(!k||a&&k&&!e)||!r&&p.ctrlKey&&k)return!1;if(!r&&p.type==="touchstart"&&((C=p.touches)==null?void 0:C.length)>1)return p.preventDefault(),!1;if(!y&&!a&&!g&&k||!i&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(i)&&!i.includes(p.button)&&p.type==="mousedown")return!1;const w=Array.isArray(i)&&i.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||k)&&w}}function Lz({domNode:e,minZoom:t,maxZoom:r,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=kk().scaleExtent([t,r]).translateExtent(i),y=ti(e).call(p);E({x:a.x,y:a.y,zoom:po(a.zoom,t,r)},[[0,0],[x.width,x.height]],i);const g=y.on("wheel.zoom"),k=y.on("dblclick.zoom");p.wheelDelta(Kk);function w(_,O){return y?new Promise(P=>{p==null||p.interpolate((O==null?void 0:O.interpolate)==="linear"?Oc:rf).transform(Np(y,O==null?void 0:O.duration,O==null?void 0:O.ease,()=>P(!0)),_)}):Promise.resolve(!1)}function C({noWheelClassName:_,noPanClassName:O,onPaneContextMenu:P,userSelectionActive:R,panOnScroll:H,panOnDrag:B,panOnScrollMode:Z,panOnScrollSpeed:G,preventScrolling:K,zoomOnPinch:M,zoomOnScroll:U,zoomOnDoubleClick:Y,zoomActivationKeyPressed:$,lib:Q,onTransformChange:ee,connectionInProgress:J,paneClickDistance:ae,selectionOnDrag:oe}){R&&!f.isZoomingOrPanning&&j();const be=H&&!$&&!R;p.clickDistance(oe?1/0:!Fi(ae)||ae<0?0:ae);const Ee=be?Fz({zoomPanValues:f,noWheelClassName:_,d3Selection:y,d3Zoom:p,panOnScrollMode:Z,panOnScrollSpeed:G,zoomOnPinch:M,onPanZoomStart:c,onPanZoom:o,onPanZoomEnd:d}):Rz({noWheelClassName:_,preventScrolling:K,d3ZoomHandler:g});if(y.on("wheel.zoom",Ee,{passive:!1}),!R){const Fe=zz({zoomPanValues:f,onDraggingChange:m,onPanZoomStart:c});p.on("start",Fe);const he=Bz({zoomPanValues:f,panOnDrag:B,onPaneContextMenu:!!P,onPanZoom:o,onTransformChange:ee});p.on("zoom",he);const Re=$z({zoomPanValues:f,panOnDrag:B,panOnScroll:H,onPaneContextMenu:P,onPanZoomEnd:d,onDraggingChange:m});p.on("end",Re)}const Ae=Oz({zoomActivationKeyPressed:$,panOnDrag:B,zoomOnScroll:U,panOnScroll:H,zoomOnDoubleClick:Y,zoomOnPinch:M,userSelectionActive:R,noPanClassName:O,noWheelClassName:_,lib:Q,connectionInProgress:J});p.filter(Ae),Y?y.on("dblclick.zoom",k):y.on("dblclick.zoom",null)}function j(){p.on("zoom",null)}async function E(_,O,P){const R=Ep(_),H=p==null?void 0:p.constrain()(R,O,P);return H&&await w(H),new Promise(B=>B(H))}async function N(_,O){const P=Ep(_);return await w(P,O),new Promise(R=>R(P))}function A(_){if(y){const O=Ep(_),P=y.property("__zoom");(P.k!==_.zoom||P.x!==_.x||P.y!==_.y)&&(p==null||p.transform(y,O,null,{sync:!0}))}}function z(){const _=y?wk(y.node()):{x:0,y:0,k:1};return{x:_.x,y:_.y,zoom:_.k}}function T(_,O){return y?new Promise(P=>{p==null||p.interpolate((O==null?void 0:O.interpolate)==="linear"?Oc:rf).scaleTo(Np(y,O==null?void 0:O.duration,O==null?void 0:O.ease,()=>P(!0)),_)}):Promise.resolve(!1)}function F(_,O){return y?new Promise(P=>{p==null||p.interpolate((O==null?void 0:O.interpolate)==="linear"?Oc:rf).scaleBy(Np(y,O==null?void 0:O.duration,O==null?void 0:O.ease,()=>P(!0)),_)}):Promise.resolve(!1)}function q(_){p==null||p.scaleExtent(_)}function V(_){p==null||p.translateExtent(_)}function L(_){const O=!Fi(_)||_<0?0:_;p==null||p.clickDistance(O)}return{update:C,destroy:j,setViewport:N,setViewportConstrained:E,getViewport:z,scaleTo:T,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:r,prevHeight:i,affectsX:a,affectsY:o}){const c=e-t,d=r-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 cw(e){const t=e.includes("right")||e.includes("left"),r=e.includes("bottom")||e.includes("top"),i=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:r,affectsX:i,affectsY:a}}function ca(e,t){return Math.max(0,t-e)}function ua(e,t){return Math.max(0,e-t)}function Id(e,t,r){return Math.max(0,t-e,e-r)}function uw(e,t){return e?!t:t}function Hz(e,t,r,i,a,o,c,d){let{affectsX:m,affectsY:f}=t;const{isHorizontal:x,isVertical:p}=t,y=x&&p,{xSnapped:g,ySnapped:k}=r,{minWidth:w,maxWidth:C,minHeight:j,maxHeight:E}=i,{x:N,y:A,width:z,height:T,aspectRatio:F}=e;let q=Math.floor(x?g-e.pointerX:0),V=Math.floor(p?k-e.pointerY:0);const L=z+(m?-q:q),_=T+(f?-V:V),O=-o[0]*z,P=-o[1]*T;let R=Id(L,w,C),H=Id(_,j,E);if(c){let G=0,K=0;m&&q<0?G=ca(N+q+O,c[0][0]):!m&&q>0&&(G=ua(N+L+O,c[1][0])),f&&V<0?K=ca(A+V+P,c[0][1]):!f&&V>0&&(K=ua(A+_+P,c[1][1])),R=Math.max(R,G),H=Math.max(H,K)}if(d){let G=0,K=0;m&&q>0?G=ua(N+q,d[0][0]):!m&&q<0&&(G=ca(N+L,d[1][0])),f&&V>0?K=ua(A+V,d[0][1]):!f&&V<0&&(K=ca(A+_,d[1][1])),R=Math.max(R,G),H=Math.max(H,K)}if(a){if(x){const G=Id(L/F,j,E)*F;if(R=Math.max(R,G),c){let K=0;!m&&!f||m&&!f&&y?K=ua(A+P+L/F,c[1][1])*F:K=ca(A+P+(m?q:-q)/F,c[0][1])*F,R=Math.max(R,K)}if(d){let K=0;!m&&!f||m&&!f&&y?K=ca(A+L/F,d[1][1])*F:K=ua(A+(m?q:-q)/F,d[0][1])*F,R=Math.max(R,K)}}if(p){const G=Id(_*F,w,C)/F;if(H=Math.max(H,G),c){let K=0;!m&&!f||f&&!m&&y?K=ua(N+_*F+O,c[1][0])/F:K=ca(N+(f?V:-V)*F+O,c[0][0])/F,H=Math.max(H,K)}if(d){let K=0;!m&&!f||f&&!m&&y?K=ca(N+_*F,d[1][0])/F:K=ua(N+(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=(uw(m,f)?-q:q)/F:q=(uw(m,f)?-V:V)*F:x?(V=q/F,f=m):(q=V*F,m=f));const B=m?N+q:N,Z=f?A+V:A;return{width:z+(m?-q:q),height:T+(f?-V:V),x:o[0]*q*(m?-1:1)+B,y:o[1]*V*(f?-1:1)+Z}}const Qk={width:0,height:0,x:0,y:0},Uz={...Qk,pointerX:0,pointerY:0,aspectRatio:1};function qz(e){return[[0,0],[e.measured.width,e.measured.height]]}function Yz(e,t,r){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=r[0]*o,m=r[1]*c;return[[i-d,a-m],[i+o-d,a+c-m]]}function Xz({domNode:e,nodeId:t,getStoreItems:r,onChange:i,onEnd:a}){const o=ti(e);let c={controlDirection:cw("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:k,onResizeEnd:w,shouldResize:C}){let j={...Qk},E={...Uz};c={boundaries:x,resizeDirection:y,keepAspectRatio:p,controlDirection:cw(f)};let N,A=null,z=[],T,F,q,V=!1;const L=uk().on("start",_=>{const{nodeLookup:O,transform:P,snapGrid:R,snapToGrid:H,nodeOrigin:B,paneDomNode:Z}=r();if(N=O.get(t),!N)return;A=(Z==null?void 0:Z.getBoundingClientRect())??null;const{xSnapped:G,ySnapped:K}=Lc(_.sourceEvent,{transform:P,snapGrid:R,snapToGrid:H,containerBounds:A});j={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},E={...j,pointerX:G,pointerY:K,aspectRatio:j.width/j.height},T=void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(T=O.get(N.parentId),F=T&&N.extent==="parent"?qz(T):void 0),z=[],q=void 0;for(const[M,U]of O)if(U.parentId===t&&(z.push({id:M,position:{...U.position},extent:U.extent}),U.extent==="parent"||U.expandParent)){const Y=Yz(U,N,U.origin??B);q?q=[[Math.min(Y[0][0],q[0][0]),Math.min(Y[0][1],q[0][1])],[Math.max(Y[1][0],q[1][0]),Math.max(Y[1][1],q[1][1])]]:q=Y}g==null||g(_,{...j})}).on("drag",_=>{const{transform:O,snapGrid:P,snapToGrid:R,nodeOrigin:H}=r(),B=Lc(_.sourceEvent,{transform:O,snapGrid:P,snapToGrid:R,containerBounds:A}),Z=[];if(!N)return;const{x:G,y:K,width:M,height:U}=j,Y={},$=N.origin??H,{width:Q,height:ee,x:J,y:ae}=Hz(E,c.controlDirection,B,c.boundaries,c.keepAspectRatio,$,F,q),oe=Q!==M,be=ee!==U,Ee=J!==G&&oe,Ae=ae!==K&&be;if(!Ee&&!Ae&&!oe&&!be)return;if((Ee||Ae||$[0]===1||$[1]===1)&&(Y.x=Ee?J:j.x,Y.y=Ae?ae:j.y,j.x=Y.x,j.y=Y.y,z.length>0)){const et=J-G,We=ae-K;for(const it of z)it.position={x:it.position.x-et+$[0]*(Q-M),y:it.position.y-We+$[1]*(ee-U)},Z.push(it)}if((oe||be)&&(Y.width=oe&&(!c.resizeDirection||c.resizeDirection==="horizontal")?Q:j.width,Y.height=be&&(!c.resizeDirection||c.resizeDirection==="vertical")?ee:j.height,j.width=Y.width,j.height=Y.height),T&&N.expandParent){const et=$[0]*(Y.width??0);Y.x&&Y.x<et&&(j.x=et,E.x=E.x-(Y.x-et));const We=$[1]*(Y.height??0);Y.y&&Y.y<We&&(j.y=We,E.y=E.y-(Y.y-We))}const Fe=Iz({width:j.width,prevWidth:M,height:j.height,prevHeight:U,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),he={...j,direction:Fe};(C==null?void 0:C(_,he))!==!1&&(V=!0,k==null||k(_,he),i(Y,Z))}).on("end",_=>{V&&(w==null||w(_,{...j}),a==null||a({...j}),V=!1)});o.call(L)}function m(){o.on(".drag",null)}return{update:d,destroy:m}}var Ap={exports:{}},Tp={},Dp={exports:{}},_p={};/**
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 dw;function Pz(){if(dw)return _p;dw=1;var e=eu();function t(p,y){return p===y&&(p!==0||1/p===1/y)||p!==p&&y!==y}var r=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(),k=i({inst:{value:g,getSnapshot:y}}),w=k[0].inst,C=k[1];return o(function(){w.value=g,w.getSnapshot=y,m(w)&&C({inst:w})},[p,g,y]),a(function(){return m(w)&&C({inst:w}),p(function(){m(w)&&C({inst:w})})},[p]),c(g),g}function m(p){var y=p.getSnapshot;p=p.value;try{var g=y();return!r(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 _p.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,_p}var fw;function Vz(){return fw||(fw=1,Dp.exports=Pz()),Dp.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 hw;function Wz(){if(hw)return Tp;hw=1;var e=eu(),t=Vz();function r(f,x){return f===x&&(f!==0||1/f===1/x)||f!==f&&x!==x}var i=typeof Object.is=="function"?Object.is:r,a=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,d=e.useMemo,m=e.useDebugValue;return Tp.useSyncExternalStoreWithSelector=function(f,x,p,y,g){var k=o(null);if(k.current===null){var w={hasValue:!1,value:null};k.current=w}else w=k.current;k=d(function(){function j(T){if(!E){if(E=!0,N=T,T=y(T),g!==void 0&&w.hasValue){var F=w.value;if(g(F,T))return A=F}return A=T}if(F=A,i(N,T))return F;var q=y(T);return g!==void 0&&g(F,q)?(N=T,F):(N=T,A=q)}var E=!1,N,A,z=p===void 0?null:p;return[function(){return j(x())},z===null?void 0:function(){return j(z())}]},[x,p,y,g]);var C=a(f,k[0],k[1]);return c(function(){w.hasValue=!0,w.value=C},[C]),m(C),C},Tp}var mw;function Gz(){return mw||(mw=1,Ap.exports=Wz()),Ap.exports}var Kz=Gz();const Qz=_f(Kz),Zz={},pw=e=>{let t;const r=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),r.forEach(k=>k(t,g))}},a=()=>t,m={setState:i,getState:a,getInitialState:()=>f,subscribe:x=>(r.add(x),()=>r.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."),r.clear()}},f=t=e(i,a,m);return m},Jz=e=>e?pw(e):pw,{useDebugValue:e9}=z4,{useSyncExternalStoreWithSelector:t9}=Qz,n9=e=>e;function Zk(e,t=n9,r){const i=t9(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return e9(i),i}const xw=(e,t)=>{const r=Jz(e),i=(a,o=t)=>Zk(r,a,o);return Object.assign(i,r),i},r9=(e,t)=>e?xw(e,t):xw;function Cn(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 r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const i of r)if(!Object.prototype.hasOwnProperty.call(t,i)||!Object.is(e[i],t[i]))return!1;return!0}x2();const Xf=S.createContext(null),i9=Xf.Provider,Jk=rs.error001();function Ut(e,t){const r=S.useContext(Xf);if(r===null)throw new Error(Jk);return Zk(r,e,t)}function jn(){const e=S.useContext(Xf);if(e===null)throw new Error(Jk);return S.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gw={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%)"},e3="react-flow__node-desc",t3="react-flow__edge-desc",a9="react-flow__aria-live",l9=e=>e.ariaLiveMessage,o9=e=>e.ariaLabelConfig;function c9({rfId:e}){const t=Ut(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 r=Ut(o9);return l.jsxs(l.Fragment,{children:[l.jsx("div",{id:`${e3}-${e}`,style:gw,children:t?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),l.jsx("div",{id:`${t3}-${e}`,style:gw,children:r["edge.a11yDescription.default"]}),!t&&l.jsx(c9,{rfId:e})]})}const Pf=S.forwardRef(({position:e="top-left",children:t,className:r,style:i,...a},o)=>{const c=`${e}`.split("-");return l.jsx("div",{className:Hn(["react-flow__panel",r,...c]),style:i,ref:o,...a,children:t})});Pf.displayName="Panel";function d9({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:l.jsx(Pf,{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=[],r=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&r.push(i);return{selectedNodes:t,selectedEdges:r}},Hd=e=>e.id;function h9(e,t){return Cn(e.selectedNodes.map(Hd),t.selectedNodes.map(Hd))&&Cn(e.selectedEdges.map(Hd),t.selectedEdges.map(Hd))}function m9({onSelectionChange:e}){const t=jn(),{selectedNodes:r,selectedEdges:i}=Ut(f9,h9);return S.useEffect(()=>{const a={nodes:r,edges:i};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[r,i,e]),null}const p9=e=>!!e.onSelectionChangeHandlers;function x9({onSelectionChange:e}){const t=Ut(p9);return e||t?l.jsx(m9,{onSelectionChange:e}):null}const n3=[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"],yw=[...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}),bw={translateExtent:Wc,nodeOrigin:n3,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function v9(e){const{setNodes:t,setEdges:r,setMinZoom:i,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:c,reset:d,setDefaultNodesAndEdges:m}=Ut(b9,Cn),f=jn();S.useEffect(()=>(m(e.defaultNodes,e.defaultEdges),()=>{x.current=bw,d()}),[]);const x=S.useRef(bw);return S.useEffect(()=>{for(const p of yw){const y=e[p],g=x.current[p];y!==g&&(typeof e[p]>"u"||(p==="nodes"?t(y):p==="edges"?r(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},yw.map(p=>e[p])),null}function vw(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function w9(e){var i;const[t,r]=S.useState(e==="system"?null:e);return S.useEffect(()=>{if(e!=="system"){r(e);return}const a=vw(),o=()=>r(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=vw())!=null&&i.matches?"dark":"light"}const ww=typeof document<"u"?document:null;function Zc(e=null,t={target:ww,actInsideInputWithModifier:!0}){const[r,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)??ww,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const x=g=>{var C,j;if(a.current=g.ctrlKey||g.metaKey||g.shiftKey||g.altKey,(!a.current||a.current&&!f)&&zk(g))return!1;const w=Sw(g.code,d);if(o.current.add(g[w]),kw(c,o.current,!1)){const E=((j=(C=g.composedPath)==null?void 0:C.call(g))==null?void 0:j[0])||g.target,N=(E==null?void 0:E.nodeName)==="BUTTON"||(E==null?void 0:E.nodeName)==="A";t.preventDefault!==!1&&(a.current||!N)&&g.preventDefault(),i(!0)}},p=g=>{const k=Sw(g.code,d);kw(c,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(g[k]),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]),r}function kw(e,t,r){return e.filter(i=>r||i.length===t.size).some(i=>i.every(a=>t.has(a)))}function Sw(e,t){return t.includes(e)?"code":"key"}const k9=()=>{const e=jn();return S.useMemo(()=>({zoomIn:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,r)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,{duration:r==null?void 0:r.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,r)=>{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},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,r,i]=e.getState().transform;return{x:t,y:r,zoom:i}},setCenter:async(t,r,i)=>e.getState().setCenter(t,r,i),fitBounds:async(t,r)=>{const{width:i,height:a,minZoom:o,maxZoom:c,panZoom:d}=e.getState(),m=T0(t,i,a,o,c,(r==null?void 0:r.padding)??.1);return d?(await d.setViewport(m,{duration:r==null?void 0:r.duration,ease:r==null?void 0:r.ease,interpolate:r==null?void 0:r.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,r={})=>{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=r.snapGrid??a,p=r.snapToGrid??o;return du(f,i,p,x)},flowToScreenPosition:t=>{const{transform:r,domNode:i}=e.getState();if(!i)return t;const{x:a,y:o}=i.getBoundingClientRect(),c=Nf(t,r);return{x:c.x+a,y:c.y+o}}}),[])};function r3(e,t){const r=[],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){r.push(o);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){r.push({...c[0].item});continue}const d={...o};for(const m of c)S9(m,d);r.push(d)}return a.length&&a.forEach(o=>{o.index!==void 0?r.splice(o.index,0,{...o.item}):r.push({...o.item})}),r}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 C9(e,t){return r3(e,t)}function j9(e,t){return r3(e,t)}function Wa(e,t){return{id:e,type:"select",selected:t}}function ro(e,t=new Set,r=!1){const i=[];for(const[a,o]of e){const c=t.has(a);!(o.selected===void 0&&!c)&&o.selected!==c&&(r&&(o.selected=c),i.push(Wa(o.id,c)))}return i}function Cw({items:e=[],lookup:t}){var a;const r=[],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&&r.push({id:c.id,item:c,type:"replace"}),m===void 0&&r.push({item:c,type:"add",index:o})}for(const[o]of t)i.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function jw(e){return{id:e.id,type:"remove"}}const Ew=e=>VR(e),E9=e=>Nk(e);function i3(e){return S.forwardRef(e)}const N9=typeof window<"u"?S.useLayoutEffect:S.useEffect;function Nw(e){const[t,r]=S.useState(BigInt(0)),[i]=S.useState(()=>A9(()=>r(a=>a+BigInt(1))));return N9(()=>{const a=i.get();a.length&&(e(a),i.reset())},[t]),i}function A9(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:r=>{t.push(r),e()}}}const s3=S.createContext(null);function T9({children:e}){const t=jn(),r=S.useCallback(d=>{const{nodes:m=[],setNodes:f,hasDefaultNodes:x,onNodesChange:p,nodeLookup:y,fitViewQueued:g,onNodesChangeMiddlewareMap:k}=t.getState();let w=m;for(const j of d)w=typeof j=="function"?j(w):j;let C=Cw({items:w,lookup:y});for(const j of k.values())C=j(C);x&&f(w),C.length>0?p==null||p(C):g&&window.requestAnimationFrame(()=>{const{fitViewQueued:j,nodes:E,setNodes:N}=t.getState();j&&N(E)})},[]),i=Nw(r),a=S.useCallback(d=>{const{edges:m=[],setEdges:f,hasDefaultEdges:x,onEdgesChange:p,edgeLookup:y}=t.getState();let g=m;for(const k of d)g=typeof k=="function"?k(g):k;x?f(g):p&&p(Cw({items:g,lookup:y}))},[]),o=Nw(a),c=S.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return l.jsx(s3.Provider,{value:c,children:e})}function D9(){const e=S.useContext(s3);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const _9=e=>!!e.panZoom;function B0(){const e=k9(),t=jn(),r=D9(),i=Ut(_9),a=S.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),c=p=>{r.nodeQueue.push(p)},d=p=>{r.edgeQueue.push(p)},m=p=>{var j,E;const{nodeLookup:y,nodeOrigin:g}=t.getState(),k=Ew(p)?p:y.get(p.id),w=k.parentId?Fk(k.position,k.measured,k.parentId,y,g):k.position,C={...k,position:w,width:((j=k.measured)==null?void 0:j.width)??k.width,height:((E=k.measured)==null?void 0:E.height)??k.height};return xo(C)},f=(p,y,g={replace:!1})=>{c(k=>k.map(w=>{if(w.id===p){const C=typeof y=="function"?y(w):y;return g.replace&&Ew(C)?C:{...w,...C}}return w}))},x=(p,y,g={replace:!1})=>{d(k=>k.map(w=>{if(w.id===p){const C=typeof y=="function"?y(w):y;return g.replace&&E9(C)?C:{...w,...C}}return w}))};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];r.nodeQueue.push(g=>[...g,...y])},addEdges:p=>{const y=Array.isArray(p)?p:[p];r.edgeQueue.push(g=>[...g,...y])},toObject:()=>{const{nodes:p=[],edges:y=[],transform:g}=t.getState(),[k,w,C]=g;return{nodes:p.map(j=>({...j})),edges:y.map(j=>({...j})),viewport:{x:k,y:w,zoom:C}}},deleteElements:async({nodes:p=[],edges:y=[]})=>{const{nodes:g,edges:k,onNodesDelete:w,onEdgesDelete:C,triggerNodeChanges:j,triggerEdgeChanges:E,onDelete:N,onBeforeDelete:A}=t.getState(),{nodes:z,edges:T}=await ZR({nodesToRemove:p,edgesToRemove:y,nodes:g,edges:k,onBeforeDelete:A}),F=T.length>0,q=z.length>0;if(F){const V=T.map(jw);C==null||C(T),E(V)}if(q){const V=z.map(jw);w==null||w(z),j(V)}return(q||F)&&(N==null||N({nodes:z,edges:T})),{deletedNodes:z,deletedEdges:T}},getIntersectingNodes:(p,y=!0,g)=>{const k=Zv(p),w=k?p:m(p),C=g!==void 0;return w?(g||t.getState().nodes).filter(j=>{const E=t.getState().nodeLookup.get(j.id);if(E&&!k&&(j.id===p.id||!E.internals.positionAbsolute))return!1;const N=xo(C?j:E),A=Kc(N,w);return y&&A>0||A>=N.width*N.height||A>=w.width*w.height}):[]},isNodeIntersecting:(p,y,g=!0)=>{const w=Zv(p)?p:m(p);if(!w)return!1;const C=Kc(w,y);return g&&C>0||C>=y.width*y.height||C>=w.width*w.height},updateNode:f,updateNodeData:(p,y,g={replace:!1})=>{f(p,k=>{const w=typeof y=="function"?y(k):y;return g.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},g)},updateEdge:x,updateEdgeData:(p,y,g={replace:!1})=>{x(p,k=>{const w=typeof y=="function"?y(k):y;return g.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},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 k;return Array.from(((k=t.getState().connectionLookup.get(`${g}-${p}${y?`-${y}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:p,handleId:y,nodeId:g})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${g}${p?y?`-${p}-${y}`:`-${p}`:""}`))==null?void 0:k.values())??[])},fitView:async p=>{const y=t.getState().fitViewResolver??nz();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:y}),r.nodeQueue.push(g=>[...g]),y.promise}}},[]);return S.useMemo(()=>({...a,...e,viewportInitialized:i}),[i])}const Aw=e=>e.selected,M9=typeof window<"u"?window:void 0;function F9({deleteKeyCode:e,multiSelectionKeyCode:t}){const r=jn(),{deleteElements:i}=B0(),a=Zc(e,{actInsideInputWithModifier:!1}),o=Zc(t,{target:M9});S.useEffect(()=>{if(a){const{edges:c,nodes:d}=r.getState();i({nodes:d.filter(Aw),edges:c.filter(Aw)}),r.setState({nodesSelectionActive:!1})}},[a]),S.useEffect(()=>{r.setState({multiSelectionActive:o})},[o])}function R9(e){const t=jn();S.useEffect(()=>{const r=()=>{var a,o,c,d;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const i=D0(e.current);(i.height===0||i.width===0)&&((d=(c=t.getState()).onError)==null||d.call(c,"004",rs.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){r(),window.addEventListener("resize",r);const i=new ResizeObserver(()=>r());return i.observe(e.current),()=>{window.removeEventListener("resize",r),i&&e.current&&i.unobserve(e.current)}}},[])}const Vf={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:r=!0,panOnScroll:i=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=nl.Free,zoomOnDoubleClick:c=!0,panOnDrag:d=!0,defaultViewport:m,translateExtent:f,minZoom:x,maxZoom:p,zoomActivationKeyCode:y,preventScrolling:g=!0,children:k,noWheelClassName:w,noPanClassName:C,onViewportChange:j,isControlledViewport:E,paneClickDistance:N,selectionOnDrag:A}){const z=jn(),T=S.useRef(null),{userSelectionActive:F,lib:q,connectionInProgress:V}=Ut(z9,Cn),L=Zc(y),_=S.useRef();R9(T);const O=S.useCallback(P=>{j==null||j({x:P[0],y:P[1],zoom:P[2]}),E||z.setState({transform:P})},[j,E]);return S.useEffect(()=>{if(T.current){_.current=Lz({domNode:T.current,minZoom:x,maxZoom:p,translateExtent:f,viewport:m,onDraggingChange:B=>z.setState(Z=>Z.paneDragging===B?Z:{paneDragging:B}),onPanZoomStart:(B,Z)=>{const{onViewportChangeStart:G,onMoveStart:K}=z.getState();K==null||K(B,Z),G==null||G(Z)},onPanZoom:(B,Z)=>{const{onViewportChange:G,onMove:K}=z.getState();K==null||K(B,Z),G==null||G(Z)},onPanZoomEnd:(B,Z)=>{const{onViewportChangeEnd:G,onMoveEnd:K}=z.getState();K==null||K(B,Z),G==null||G(Z)}});const{x:P,y:R,zoom:H}=_.current.getViewport();return z.setState({panZoom:_.current,transform:[P,R,H],domNode:T.current.closest(".react-flow")}),()=>{var B;(B=_.current)==null||B.destroy()}}},[]),S.useEffect(()=>{var P;(P=_.current)==null||P.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:r,panOnScroll:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:c,panOnDrag:d,zoomActivationKeyPressed:L,preventScrolling:g,noPanClassName:C,userSelectionActive:F,noWheelClassName:w,lib:q,onTransformChange:O,connectionInProgress:V,selectionOnDrag:A,paneClickDistance:N})},[e,t,r,i,a,o,c,d,L,g,C,F,w,q,O,V,A,N]),l.jsx("div",{className:"react-flow__renderer",ref:T,style:Vf,children:k})}const $9=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function O9(){const{userSelectionActive:e,userSelectionRect:t}=Ut($9,Cn);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 Mp=(e,t)=>r=>{r.target===t.current&&(e==null||e(r))},L9=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function I9({isSelecting:e,selectionKeyPressed:t,selectionMode:r=Gc.Full,panOnDrag:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:c,onSelectionEnd:d,onPaneClick:m,onPaneContextMenu:f,onPaneScroll:x,onPaneMouseEnter:p,onPaneMouseMove:y,onPaneMouseLeave:g,children:k}){const w=jn(),{userSelectionActive:C,elementsSelectable:j,dragging:E,connectionInProgress:N}=Ut(L9,Cn),A=j&&(e||C),z=S.useRef(null),T=S.useRef(),F=S.useRef(new Set),q=S.useRef(new Set),V=S.useRef(!1),L=G=>{if(V.current||N){V.current=!1;return}m==null||m(G),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},_=G=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){G.preventDefault();return}f==null||f(G)},O=x?G=>x(G):void 0,P=G=>{V.current&&(G.stopPropagation(),V.current=!1)},R=G=>{var ee,J;const{domNode:K}=w.getState();if(T.current=K==null?void 0:K.getBoundingClientRect(),!T.current)return;const M=G.target===z.current;if(!M&&!!G.target.closest(".nokey")||!e||!(o&&M||t)||G.button!==0||!G.isPrimary)return;(J=(ee=G.target)==null?void 0:ee.setPointerCapture)==null||J.call(ee,G.pointerId),V.current=!1;const{x:$,y:Q}=Ri(G.nativeEvent,T.current);w.setState({userSelectionRect:{width:0,height:0,startX:$,startY:Q,x:$,y:Q}}),M||(G.stopPropagation(),G.preventDefault())},H=G=>{const{userSelectionRect:K,transform:M,nodeLookup:U,edgeLookup:Y,connectionLookup:$,triggerNodeChanges:Q,triggerEdgeChanges:ee,defaultEdgeOptions:J,resetSelectedElements:ae}=w.getState();if(!T.current||!K)return;const{x:oe,y:be}=Ri(G.nativeEvent,T.current),{startX:Ee,startY:Ae}=K;if(!V.current){const We=t?0:a;if(Math.hypot(oe-Ee,be-Ae)<=We)return;ae(),c==null||c(G)}V.current=!0;const Fe={startX:Ee,startY:Ae,x:oe<Ee?oe:Ee,y:be<Ae?be:Ae,width:Math.abs(oe-Ee),height:Math.abs(be-Ae)},he=F.current,Re=q.current;F.current=new Set(A0(U,Fe,M,r===Gc.Partial,!0).map(We=>We.id)),q.current=new Set;const et=(J==null?void 0:J.selectable)??!0;for(const We of F.current){const it=$.get(We);if(it)for(const{edgeId:mt}of it.values()){const Ye=Y.get(mt);Ye&&(Ye.selectable??et)&&q.current.add(mt)}}if(!Jv(he,F.current)){const We=ro(U,F.current,!0);Q(We)}if(!Jv(Re,q.current)){const We=ro(Y,q.current);ee(We)}w.setState({userSelectionRect:Fe,userSelectionActive:!0,nodesSelectionActive:!1})},B=G=>{var K,M;G.button===0&&((M=(K=G.target)==null?void 0:K.releasePointerCapture)==null||M.call(K,G.pointerId),!C&&G.target===z.current&&w.getState().userSelectionRect&&(L==null||L(G)),w.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(d==null||d(G),w.setState({nodesSelectionActive:F.current.size>0})))},Z=i===!0||Array.isArray(i)&&i.includes(0);return l.jsxs("div",{className:Hn(["react-flow__pane",{draggable:Z,dragging:E,selection:e}]),onClick:A?void 0:Mp(L,z),onContextMenu:Mp(_,z),onWheel:Mp(O,z),onPointerEnter:A?void 0:p,onPointerMove:A?H:y,onPointerUp:A?B:void 0,onPointerDownCapture:A?R:void 0,onClickCapture:A?P:void 0,onPointerLeave:g,ref:z,style:Vf,children:[k,l.jsx(O9,{})]})}function zx({id:e,store:t,unselect:r=!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",rs.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(r||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 a3({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:i,nodeId:a,isSelectable:o,nodeClickDistance:c}){const d=jn(),[m,f]=S.useState(!1),x=S.useRef();return S.useEffect(()=>{x.current=jz({getStoreItems:()=>d.getState(),onNodeMouseDown:p=>{zx({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:r,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:c}),()=>{var p;(p=x.current)==null||p.destroy()}},[r,i,t,o,e,a,c]),m}const H9=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function l3(){const e=jn();return S.useCallback(r=>{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,k=a?o[1]:5,w=r.direction.x*g*r.factor,C=r.direction.y*k*r.factor;for(const[,j]of f){if(!y(j))continue;let E={x:j.internals.positionAbsolute.x+w,y:j.internals.positionAbsolute.y+C};a&&(E=uu(E,o));const{position:N,positionAbsolute:A}=Ak({nodeId:j.id,nextPosition:E,nodeLookup:f,nodeExtent:i,nodeOrigin:x,onError:d});j.position=N,j.internals.positionAbsolute=A,p.set(j.id,j)}m(p)},[])}const $0=S.createContext(null),U9=$0.Provider;$0.Consumer;const o3=()=>S.useContext($0),q9=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Y9=(e,t,r)=>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)===r;return{connectingFrom:(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===r,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===r,isPossibleEndHandle:o===mo.Strict?(d==null?void 0:d.type)!==r:e!==(d==null?void 0:d.nodeId)||t!==(d==null?void 0:d.id),connectionInProcess:!!d,clickConnectionInProcess:!!a,valid:x&&f}};function X9({type:e="source",position:t=at.Top,isValidConnection:r,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,B;const k=c||null,w=e==="target",C=jn(),j=o3(),{connectOnClick:E,noPanClassName:N,rfId:A}=Ut(q9,Cn),{connectingFrom:z,connectingTo:T,clickConnecting:F,isPossibleEndHandle:q,connectionInProcess:V,clickConnectionInProcess:L,valid:_}=Ut(Y9(j,k,e),Cn);j||(B=(H=C.getState()).onError)==null||B.call(H,"010",rs.error010());const O=Z=>{const{defaultEdgeOptions:G,onConnect:K,hasDefaultEdges:M}=C.getState(),U={...G,...Z};if(M){const{edges:Y,setEdges:$}=C.getState();$(cz(U,Y))}K==null||K(U),d==null||d(U)},P=Z=>{if(!j)return;const G=Bk(Z.nativeEvent);if(a&&(G&&Z.button===0||!G)){const K=C.getState();Rx.onPointerDown(Z.nativeEvent,{handleDomNode:Z.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:w,handleId:k,nodeId:j,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...M)=>{var U,Y;return(Y=(U=C.getState()).onConnectEnd)==null?void 0:Y.call(U,...M)},updateConnection:K.updateConnection,onConnect:O,isValidConnection:r||((...M)=>{var U,Y;return((Y=(U=C.getState()).isValidConnection)==null?void 0:Y.call(U,...M))??!0}),getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}G?x==null||x(Z):p==null||p(Z)},R=Z=>{const{onClickConnectStart:G,onClickConnectEnd:K,connectionClickStartHandle:M,connectionMode:U,isValidConnection:Y,lib:$,rfId:Q,nodeLookup:ee,connection:J}=C.getState();if(!j||!M&&!a)return;if(!M){G==null||G(Z.nativeEvent,{nodeId:j,handleId:k,handleType:e}),C.setState({connectionClickStartHandle:{nodeId:j,type:e,id:k}});return}const ae=Rk(Z.target),oe=r||Y,{connection:be,isValid:Ee}=Rx.isValid(Z.nativeEvent,{handle:{nodeId:j,id:k,type:e},connectionMode:U,fromNodeId:M.nodeId,fromHandleId:M.id||null,fromType:M.type,isValidConnection:oe,flowId:Q,doc:ae,lib:$,nodeLookup:ee});Ee&&be&&O(be);const Ae=structuredClone(J);delete Ae.inProgress,Ae.toPosition=Ae.toHandle?Ae.toHandle.position:null,K==null||K(Z,Ae),C.setState({connectionClickStartHandle:null})};return l.jsx("div",{"data-handleid":k,"data-nodeid":j,"data-handlepos":t,"data-id":`${A}-${j}-${k}-${e}`,className:Hn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,f,{source:!w,target:w,connectable:i,connectablestart:a,connectableend:o,clickconnecting:F,connectingfrom:z,connectingto:T,valid:_,connectionindicator:i&&(!V||q)&&(V||L?o:a)}]),onMouseDown:P,onTouchStart:P,onClick:E?R:void 0,ref:g,...y,children:m})}const bo=S.memo(i3(X9));function P9({data:e,isConnectable:t,sourcePosition:r=at.Bottom}){return l.jsxs(l.Fragment,{children:[e==null?void 0:e.label,l.jsx(bo,{type:"source",position:r,isConnectable:t})]})}function V9({data:e,isConnectable:t,targetPosition:r=at.Top,sourcePosition:i=at.Bottom}){return l.jsxs(l.Fragment,{children:[l.jsx(bo,{type:"target",position:r,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:r=at.Top}){return l.jsxs(l.Fragment,{children:[l.jsx(bo,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label]})}const Tf={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Tw={input:P9,default:V9,output:G9,group:W9};function K9(e){var t,r,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??((r=e.style)==null?void 0:r.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:r,x:i,y:a}=cu(e.nodeLookup,{filter:o=>!!o.selected});return{width:Fi(t)?t:null,height:Fi(r)?r: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:r}){const i=jn(),{width:a,height:o,transformString:c,userSelectionActive:d}=Ut(Q9,Cn),m=l3(),f=S.useRef(null);S.useEffect(()=>{var g;r||(g=f.current)==null||g.focus({preventScroll:!0})},[r]);const x=!d&&a!==null&&o!==null;if(a3({nodeRef:f,disabled:!x}),!x)return null;const p=e?g=>{const k=i.getState().nodes.filter(w=>w.selected);e(g,k)}:void 0,y=g=>{Object.prototype.hasOwnProperty.call(Tf,g.key)&&(g.preventDefault(),m({direction:Tf[g.key],factor:g.shiftKey?4:1}))};return l.jsx("div",{className:Hn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:l.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:y,style:{width:a,height:o}})})}const Dw=typeof window<"u"?window:void 0,J9=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function c3({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:c,paneClickDistance:d,deleteKeyCode:m,selectionKeyCode:f,selectionOnDrag:x,selectionMode:p,onSelectionStart:y,onSelectionEnd:g,multiSelectionKeyCode:k,panActivationKeyCode:w,zoomActivationKeyCode:C,elementsSelectable:j,zoomOnScroll:E,zoomOnPinch:N,panOnScroll:A,panOnScrollSpeed:z,panOnScrollMode:T,zoomOnDoubleClick:F,panOnDrag:q,defaultViewport:V,translateExtent:L,minZoom:_,maxZoom:O,preventScrolling:P,onSelectionContextMenu:R,noWheelClassName:H,noPanClassName:B,disableKeyboardA11y:Z,onViewportChange:G,isControlledViewport:K}){const{nodesSelectionActive:M,userSelectionActive:U}=Ut(J9,Cn),Y=Zc(f,{target:Dw}),$=Zc(w,{target:Dw}),Q=$||q,ee=$||A,J=x&&Q!==!0,ae=Y||U||J;return F9({deleteKeyCode:m,multiSelectionKeyCode:k}),l.jsx(B9,{onPaneContextMenu:o,elementsSelectable:j,zoomOnScroll:E,zoomOnPinch:N,panOnScroll:ee,panOnScrollSpeed:z,panOnScrollMode:T,zoomOnDoubleClick:F,panOnDrag:!Y&&Q,defaultViewport:V,translateExtent:L,minZoom:_,maxZoom:O,zoomActivationKeyCode:C,preventScrolling:P,noWheelClassName:H,noPanClassName:B,onViewportChange:G,isControlledViewport:K,paneClickDistance:d,selectionOnDrag:J,children:l.jsxs(I9,{onSelectionStart:y,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:c,panOnDrag:Q,isSelecting:!!ae,selectionMode:p,selectionKeyPressed:Y,paneClickDistance:d,selectionOnDrag:J,children:[e,M&&l.jsx(Z9,{onSelectionContextMenu:R,noPanClassName:B,disableKeyboardA11y:Z})]})})}c3.displayName="FlowRenderer";const e7=S.memo(c3),t7=e=>t=>e?A0(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(r=>r.id):Array.from(t.nodeLookup.keys());function n7(e){return Ut(S.useCallback(t7(e),[e]),Cn)}const r7=e=>e.updateNodeInternals;function i7(){const e=Ut(r7),[t]=S.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{const i=new Map;r.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:r,resizeObserver:i}){const a=jn(),o=S.useRef(null),c=S.useRef(null),d=S.useRef(e.sourcePosition),m=S.useRef(e.targetPosition),f=S.useRef(t),x=r&&!!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:r,onMouseMove:i,onMouseLeave:a,onContextMenu:o,onDoubleClick:c,nodesDraggable:d,elementsSelectable:m,nodesConnectable:f,nodesFocusable:x,resizeObserver:p,noDragClassName:y,noPanClassName:g,disableKeyboardA11y:k,rfId:w,nodeTypes:C,nodeClickDistance:j,onError:E}){const{node:N,internals:A,isParent:z}=Ut(oe=>{const be=oe.nodeLookup.get(e),Ee=oe.parentLookup.has(e);return{node:be,internals:be.internals,isParent:Ee}},Cn);let T=N.type||"default",F=(C==null?void 0:C[T])||Tw[T];F===void 0&&(E==null||E("003",rs.error003(T)),T="default",F=(C==null?void 0:C.default)||Tw.default);const q=!!(N.draggable||d&&typeof N.draggable>"u"),V=!!(N.selectable||m&&typeof N.selectable>"u"),L=!!(N.connectable||f&&typeof N.connectable>"u"),_=!!(N.focusable||x&&typeof N.focusable>"u"),O=jn(),P=Mk(N),R=s7({node:N,nodeType:T,hasDimensions:P,resizeObserver:p}),H=a3({nodeRef:R,disabled:N.hidden||!q,noDragClassName:y,handleSelector:N.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:j}),B=l3();if(N.hidden)return null;const Z=$s(N),G=K9(N),K=V||q||t||r||i||a,M=r?oe=>r(oe,{...A.userNode}):void 0,U=i?oe=>i(oe,{...A.userNode}):void 0,Y=a?oe=>a(oe,{...A.userNode}):void 0,$=o?oe=>o(oe,{...A.userNode}):void 0,Q=c?oe=>c(oe,{...A.userNode}):void 0,ee=oe=>{const{selectNodesOnDrag:be,nodeDragThreshold:Ee}=O.getState();V&&(!be||!q||Ee>0)&&zx({id:e,store:O,nodeRef:R}),t&&t(oe,{...A.userNode})},J=oe=>{if(!(zk(oe.nativeEvent)||k)){if(Sk.includes(oe.key)&&V){const be=oe.key==="Escape";zx({id:e,store:O,unselect:be,nodeRef:R})}else if(q&&N.selected&&Object.prototype.hasOwnProperty.call(Tf,oe.key)){oe.preventDefault();const{ariaLabelConfig:be}=O.getState();O.setState({ariaLiveMessage:be["node.a11yDescription.ariaLiveMessage"]({direction:oe.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),B({direction:Tf[oe.key],factor:oe.shiftKey?4:1})}}},ae=()=>{var Re;if(k||!((Re=R.current)!=null&&Re.matches(":focus-visible")))return;const{transform:oe,width:be,height:Ee,autoPanOnNodeFocus:Ae,setCenter:Fe}=O.getState();if(!Ae)return;A0(new Map([[e,N]]),{x:0,y:0,width:be,height:Ee},oe,!0).length>0||Fe(N.position.x+Z.width/2,N.position.y+Z.height/2,{zoom:oe[2]})};return l.jsx("div",{className:Hn(["react-flow__node",`react-flow__node-${T}`,{[g]:q},N.className,{selected:N.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:P?"visible":"hidden",...N.style,...G},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:M,onMouseMove:U,onMouseLeave:Y,onContextMenu:$,onClick:ee,onDoubleClick:Q,onKeyDown:_?J:void 0,tabIndex:_?0:void 0,onFocus:_?ae:void 0,role:N.ariaRole??(_?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${e3}-${w}`,"aria-label":N.ariaLabel,...N.domAttributes,children:l.jsx(U9,{value:e,children:l.jsx(F,{id:e,data:N.data,type:T,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.positionAbsolute.y,selected:N.selected??!1,selectable:V,draggable:q,deletable:N.deletable??!0,isConnectable:L,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:H,dragHandle:N.dragHandle,zIndex:A.z,parentId:N.parentId,...Z})})})}var l7=S.memo(a7);const o7=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function u3(e){const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:i,elementsSelectable:a,onError:o}=Ut(o7,Cn),c=n7(e.onlyRenderVisibleElements),d=i7();return l.jsx("div",{className:"react-flow__nodes",style:Vf,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:r,nodesFocusable:i,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},m))})}u3.displayName="NodeRenderer";const c7=S.memo(u3);function u7(e){return Ut(S.useCallback(r=>{if(!e)return r.edges.map(a=>a.id);const i=[];if(r.width&&r.height)for(const a of r.edges){const o=r.nodeLookup.get(a.source),c=r.nodeLookup.get(a.target);o&&c&&az({sourceNode:o,targetNode:c,width:r.width,height:r.height,transform:r.transform})&&i.push(a.id)}return i},[e]),Cn)}const d7=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e}};return l.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},f7=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e,fill:e}};return l.jsx("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},_w={[jf.Arrow]:d7,[jf.ArrowClosed]:f7};function h7(e){const t=jn();return S.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(_w,e)?_w[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",rs.error009(e)),null)},[e])}const m7=({id:e,type:t,color:r,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:r,strokeWidth:c})}):null},d3=({defaultColor:e,rfId:t})=>{const r=Ut(o=>o.edges),i=Ut(o=>o.defaultEdgeOptions),a=S.useMemo(()=>mz(r,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[r,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};d3.displayName="MarkerDefinitions";var p7=S.memo(d3);function f3({x:e,y:t,label:r,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=Hn(["react-flow__edge-textwrapper",f]),k=S.useRef(null);return S.useEffect(()=>{if(k.current){const w=k.current.getBBox();y({x:w.x,y:w.y,width:w.width,height:w.height})}},[r]),r?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:k,style:i,children:r}),m]}):null}f3.displayName="EdgeText";const x7=S.memo(f3);function fu({path:e,labelX:t,labelY:r,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:Hn(["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&&Fi(t)&&Fi(r)?l.jsx(x7,{x:t,y:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:m}):null]})}function Mw({pos:e,x1:t,y1:r,x2:i,y2:a}){return e===at.Left||e===at.Right?[.5*(t+i),r]:[t,.5*(r+a)]}function h3({sourceX:e,sourceY:t,sourcePosition:r=at.Bottom,targetX:i,targetY:a,targetPosition:o=at.Top}){const[c,d]=Mw({pos:r,x1:e,y1:t,x2:i,y2:a}),[m,f]=Mw({pos:o,x1:i,y1:a,x2:e,y2:t}),[x,p,y,g]=$k({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 m3(e){return S.memo(({id:t,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:c,targetPosition:d,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:g,style:k,markerEnd:w,markerStart:C,interactionWidth:j})=>{const[E,N,A]=h3({sourceX:r,sourceY:i,sourcePosition:c,targetX:a,targetY:o,targetPosition:d}),z=e.isInternal?void 0:t;return l.jsx(fu,{id:z,path:E,labelX:N,labelY:A,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:g,style:k,markerEnd:w,markerStart:C,interactionWidth:j})})}const g7=m3({isInternal:!1}),p3=m3({isInternal:!0});g7.displayName="SimpleBezierEdge";p3.displayName="SimpleBezierEdgeInternal";function x3(e){return S.memo(({id:t,sourceX:r,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:k=at.Top,markerEnd:w,markerStart:C,pathOptions:j,interactionWidth:E})=>{const[N,A,z]=Af({sourceX:r,sourceY:i,sourcePosition:g,targetX:a,targetY:o,targetPosition:k,borderRadius:j==null?void 0:j.borderRadius,offset:j==null?void 0:j.offset,stepPosition:j==null?void 0:j.stepPosition}),T=e.isInternal?void 0:t;return l.jsx(fu,{id:T,path:N,labelX:A,labelY:z,label:c,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:y,markerEnd:w,markerStart:C,interactionWidth:E})})}const g3=x3({isInternal:!1}),y3=x3({isInternal:!0});g3.displayName="SmoothStepEdge";y3.displayName="SmoothStepEdgeInternal";function b3(e){return S.memo(({id:t,...r})=>{var a;const i=e.isInternal?void 0:t;return l.jsx(g3,{...r,id:i,pathOptions:S.useMemo(()=>{var o;return{borderRadius:0,offset:(o=r.pathOptions)==null?void 0:o.offset}},[(a=r.pathOptions)==null?void 0:a.offset])})})}const y7=b3({isInternal:!1}),v3=b3({isInternal:!0});y7.displayName="StepEdge";v3.displayName="StepEdgeInternal";function w3(e){return S.memo(({id:t,sourceX:r,sourceY:i,targetX:a,targetY:o,label:c,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:y,markerEnd:g,markerStart:k,interactionWidth:w})=>{const[C,j,E]=Ik({sourceX:r,sourceY:i,targetX:a,targetY:o}),N=e.isInternal?void 0:t;return l.jsx(fu,{id:N,path:C,labelX:j,labelY:E,label:c,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:x,labelBgBorderRadius:p,style:y,markerEnd:g,markerStart:k,interactionWidth:w})})}const b7=w3({isInternal:!1}),k3=w3({isInternal:!0});b7.displayName="StraightEdge";k3.displayName="StraightEdgeInternal";function S3(e){return S.memo(({id:t,sourceX:r,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:k,markerEnd:w,markerStart:C,pathOptions:j,interactionWidth:E})=>{const[N,A,z]=Ok({sourceX:r,sourceY:i,sourcePosition:c,targetX:a,targetY:o,targetPosition:d,curvature:j==null?void 0:j.curvature}),T=e.isInternal?void 0:t;return l.jsx(fu,{id:T,path:N,labelX:A,labelY:z,label:m,labelStyle:f,labelShowBg:x,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:g,style:k,markerEnd:w,markerStart:C,interactionWidth:E})})}const v7=S3({isInternal:!1}),C3=S3({isInternal:!0});v7.displayName="BezierEdge";C3.displayName="BezierEdgeInternal";const Fw={default:C3,straight:k3,step:v3,smoothstep:y3,simplebezier:p3},Rw={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},w7=(e,t,r)=>r===at.Left?e-t:r===at.Right?e+t:e,k7=(e,t,r)=>r===at.Top?e-t:r===at.Bottom?e+t:e,zw="react-flow__edgeupdater";function Bw({position:e,centerX:t,centerY:r,radius:i=10,onMouseDown:a,onMouseEnter:o,onMouseOut:c,type:d}){return l.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:c,className:Hn([zw,`${zw}-${d}`]),cx:w7(t,i,e),cy:k7(r,i,e),r:i,stroke:"transparent",fill:"transparent"})}function S7({isReconnectable:e,reconnectRadius:t,edge:r,sourceX:i,sourceY:a,targetX:o,targetY:c,sourcePosition:d,targetPosition:m,onReconnect:f,onReconnectStart:x,onReconnectEnd:p,setReconnecting:y,setUpdateHover:g}){const k=jn(),w=(A,z)=>{if(A.button!==0)return;const{autoPanOnConnect:T,domNode:F,connectionMode:q,connectionRadius:V,lib:L,onConnectStart:_,cancelConnection:O,nodeLookup:P,rfId:R,panBy:H,updateConnection:B}=k.getState(),Z=z.type==="target",G=(U,Y)=>{y(!1),p==null||p(U,r,z.type,Y)},K=U=>f==null?void 0:f(r,U),M=(U,Y)=>{y(!0),x==null||x(A,r,z.type),_==null||_(U,Y)};Rx.onPointerDown(A.nativeEvent,{autoPanOnConnect:T,connectionMode:q,connectionRadius:V,domNode:F,handleId:z.id,nodeId:z.nodeId,nodeLookup:P,isTarget:Z,edgeUpdaterType:z.type,lib:L,flowId:R,cancelConnection:O,panBy:H,isValidConnection:(...U)=>{var Y,$;return(($=(Y=k.getState()).isValidConnection)==null?void 0:$.call(Y,...U))??!0},onConnect:K,onConnectStart:M,onConnectEnd:(...U)=>{var Y,$;return($=(Y=k.getState()).onConnectEnd)==null?void 0:$.call(Y,...U)},onReconnectEnd:G,updateConnection:B,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},C=A=>w(A,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),j=A=>w(A,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),E=()=>g(!0),N=()=>g(!1);return l.jsxs(l.Fragment,{children:[(e===!0||e==="source")&&l.jsx(Bw,{position:d,centerX:i,centerY:a,radius:t,onMouseDown:C,onMouseEnter:E,onMouseOut:N,type:"source"}),(e===!0||e==="target")&&l.jsx(Bw,{position:m,centerX:o,centerY:c,radius:t,onMouseDown:j,onMouseEnter:E,onMouseOut:N,type:"target"})]})}function C7({id:e,edgesFocusable:t,edgesReconnectable:r,elementsSelectable:i,onClick:a,onDoubleClick:o,onContextMenu:c,onMouseEnter:d,onMouseMove:m,onMouseLeave:f,reconnectRadius:x,onReconnect:p,onReconnectStart:y,onReconnectEnd:g,rfId:k,edgeTypes:w,noPanClassName:C,onError:j,disableKeyboardA11y:E}){let N=Ut(Fe=>Fe.edgeLookup.get(e));const A=Ut(Fe=>Fe.defaultEdgeOptions);N=A?{...A,...N}:N;let z=N.type||"default",T=(w==null?void 0:w[z])||Fw[z];T===void 0&&(j==null||j("011",rs.error011(z)),z="default",T=(w==null?void 0:w.default)||Fw.default);const F=!!(N.focusable||t&&typeof N.focusable>"u"),q=typeof p<"u"&&(N.reconnectable||r&&typeof N.reconnectable>"u"),V=!!(N.selectable||i&&typeof N.selectable>"u"),L=S.useRef(null),[_,O]=S.useState(!1),[P,R]=S.useState(!1),H=jn(),{zIndex:B,sourceX:Z,sourceY:G,targetX:K,targetY:M,sourcePosition:U,targetPosition:Y}=Ut(S.useCallback(Fe=>{const he=Fe.nodeLookup.get(N.source),Re=Fe.nodeLookup.get(N.target);if(!he||!Re)return{zIndex:N.zIndex,...Rw};const et=hz({id:e,sourceNode:he,targetNode:Re,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:Fe.connectionMode,onError:j});return{zIndex:sz({selected:N.selected,zIndex:N.zIndex,sourceNode:he,targetNode:Re,elevateOnSelect:Fe.elevateEdgesOnSelect,zIndexMode:Fe.zIndexMode}),...et||Rw}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex]),Cn),$=S.useMemo(()=>N.markerStart?`url('#${Mx(N.markerStart,k)}')`:void 0,[N.markerStart,k]),Q=S.useMemo(()=>N.markerEnd?`url('#${Mx(N.markerEnd,k)}')`:void 0,[N.markerEnd,k]);if(N.hidden||Z===null||G===null||K===null||M===null)return null;const ee=Fe=>{var We;const{addSelectedEdges:he,unselectNodesAndEdges:Re,multiSelectionActive:et}=H.getState();V&&(H.setState({nodesSelectionActive:!1}),N.selected&&et?(Re({nodes:[],edges:[N]}),(We=L.current)==null||We.blur()):he([e])),a&&a(Fe,N)},J=o?Fe=>{o(Fe,{...N})}:void 0,ae=c?Fe=>{c(Fe,{...N})}:void 0,oe=d?Fe=>{d(Fe,{...N})}:void 0,be=m?Fe=>{m(Fe,{...N})}:void 0,Ee=f?Fe=>{f(Fe,{...N})}:void 0,Ae=Fe=>{var he;if(!E&&Sk.includes(Fe.key)&&V){const{unselectNodesAndEdges:Re,addSelectedEdges:et}=H.getState();Fe.key==="Escape"?((he=L.current)==null||he.blur(),Re({edges:[N]})):et([e])}};return l.jsx("svg",{style:{zIndex:B},children:l.jsxs("g",{className:Hn(["react-flow__edge",`react-flow__edge-${z}`,N.className,C,{selected:N.selected,animated:N.animated,inactive:!V&&!a,updating:_,selectable:V}]),onClick:ee,onDoubleClick:J,onContextMenu:ae,onMouseEnter:oe,onMouseMove:be,onMouseLeave:Ee,onKeyDown:F?Ae:void 0,tabIndex:F?0:void 0,role:N.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":F?`${t3}-${k}`:void 0,ref:L,...N.domAttributes,children:[!P&&l.jsx(T,{id:e,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:V,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:Z,sourceY:G,targetX:K,targetY:M,sourcePosition:U,targetPosition:Y,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:$,markerEnd:Q,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),q&&l.jsx(S7,{edge:N,isReconnectable:q,reconnectRadius:x,onReconnect:p,onReconnectStart:y,onReconnectEnd:g,sourceX:Z,sourceY:G,targetX:K,targetY:M,sourcePosition:U,targetPosition:Y,setUpdateHover:O,setReconnecting:R})]})})}var j7=S.memo(C7);const E7=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function j3({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:r,edgeTypes:i,noPanClassName:a,onReconnect:o,onEdgeContextMenu:c,onEdgeMouseEnter:d,onEdgeMouseMove:m,onEdgeMouseLeave:f,onEdgeClick:x,reconnectRadius:p,onEdgeDoubleClick:y,onReconnectStart:g,onReconnectEnd:k,disableKeyboardA11y:w}){const{edgesFocusable:C,edgesReconnectable:j,elementsSelectable:E,onError:N}=Ut(E7,Cn),A=u7(t);return l.jsxs("div",{className:"react-flow__edges",children:[l.jsx(p7,{defaultColor:e,rfId:r}),A.map(z=>l.jsx(j7,{id:z,edgesFocusable:C,edgesReconnectable:j,elementsSelectable:E,noPanClassName:a,onReconnect:o,onContextMenu:c,onMouseEnter:d,onMouseMove:m,onMouseLeave:f,onClick:x,reconnectRadius:p,onDoubleClick:y,onReconnectStart:g,onReconnectEnd:k,rfId:r,onError:N,edgeTypes:i,disableKeyboardA11y:w},z))]})}j3.displayName="EdgeRenderer";const N7=S.memo(j3),A7=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function T7({children:e}){const t=Ut(A7);return l.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function D7(e){const t=B0(),r=S.useRef(!1);S.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const _7=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function M7(e){const t=Ut(_7),r=jn();return S.useEffect(()=>{e&&(t==null||t(e),r.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function F7(e){return e.connection.inProgress?{...e.connection,to:du(e.connection.to,e.transform)}:{...e.connection}}function R7(e){return F7}function z7(e){const t=R7();return Ut(t,Cn)}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:r,component:i}){const{nodesConnectable:a,width:o,height:c,isValid:d,inProgress:m}=Ut(B7,Cn);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:Hn(["react-flow__connection",Ek(d)]),children:l.jsx(E3,{style:t,type:r,CustomComponent:i,isValid:d})})})}const E3=({style:e,type:t=ga.Bezier,CustomComponent:r,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(r)return l.jsx(r,{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 k="";const w={sourceX:o.x,sourceY:o.y,sourcePosition:m,targetX:f.x,targetY:f.y,targetPosition:y};switch(t){case ga.Bezier:[k]=Ok(w);break;case ga.SimpleBezier:[k]=h3(w);break;case ga.Step:[k]=Af({...w,borderRadius:0});break;case ga.SmoothStep:[k]=Af(w);break;default:[k]=Ik(w)}return l.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};E3.displayName="ConnectionLine";const O7={};function $w(e=O7){S.useRef(e),jn(),S.useEffect(()=>{},[e])}function L7(){jn(),S.useRef(!1),S.useEffect(()=>{},[])}function N3({nodeTypes:e,edgeTypes:t,onInit:r,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:m,onNodeMouseLeave:f,onNodeContextMenu:x,onSelectionContextMenu:p,onSelectionStart:y,onSelectionEnd:g,connectionLineType:k,connectionLineStyle:w,connectionLineComponent:C,connectionLineContainerStyle:j,selectionKeyCode:E,selectionOnDrag:N,selectionMode:A,multiSelectionKeyCode:z,panActivationKeyCode:T,zoomActivationKeyCode:F,deleteKeyCode:q,onlyRenderVisibleElements:V,elementsSelectable:L,defaultViewport:_,translateExtent:O,minZoom:P,maxZoom:R,preventScrolling:H,defaultMarkerColor:B,zoomOnScroll:Z,zoomOnPinch:G,panOnScroll:K,panOnScrollSpeed:M,panOnScrollMode:U,zoomOnDoubleClick:Y,panOnDrag:$,onPaneClick:Q,onPaneMouseEnter:ee,onPaneMouseMove:J,onPaneMouseLeave:ae,onPaneScroll:oe,onPaneContextMenu:be,paneClickDistance:Ee,nodeClickDistance:Ae,onEdgeContextMenu:Fe,onEdgeMouseEnter:he,onEdgeMouseMove:Re,onEdgeMouseLeave:et,reconnectRadius:We,onReconnect:it,onReconnectStart:mt,onReconnectEnd:Ye,noDragClassName:Ze,noWheelClassName:ut,noPanClassName:jt,disableKeyboardA11y:ge,nodeExtent:ve,rfId:Ce,viewport:ne,onViewportChange:de}){return $w(e),$w(t),L7(),D7(r),M7(ne),l.jsx(e7,{onPaneClick:Q,onPaneMouseEnter:ee,onPaneMouseMove:J,onPaneMouseLeave:ae,onPaneContextMenu:be,onPaneScroll:oe,paneClickDistance:Ee,deleteKeyCode:q,selectionKeyCode:E,selectionOnDrag:N,selectionMode:A,onSelectionStart:y,onSelectionEnd:g,multiSelectionKeyCode:z,panActivationKeyCode:T,zoomActivationKeyCode:F,elementsSelectable:L,zoomOnScroll:Z,zoomOnPinch:G,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:M,panOnScrollMode:U,panOnDrag:$,defaultViewport:_,translateExtent:O,minZoom:P,maxZoom:R,onSelectionContextMenu:p,preventScrolling:H,noDragClassName:Ze,noWheelClassName:ut,noPanClassName:jt,disableKeyboardA11y:ge,onViewportChange:de,isControlledViewport:!!ne,children:l.jsxs(T7,{children:[l.jsx(N7,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:it,onReconnectStart:mt,onReconnectEnd:Ye,onlyRenderVisibleElements:V,onEdgeContextMenu:Fe,onEdgeMouseEnter:he,onEdgeMouseMove:Re,onEdgeMouseLeave:et,reconnectRadius:We,defaultMarkerColor:B,noPanClassName:jt,disableKeyboardA11y:ge,rfId:Ce}),l.jsx($7,{style:w,type:k,component:C,containerStyle:j}),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:Ae,onlyRenderVisibleElements:V,noPanClassName:jt,noDragClassName:Ze,disableKeyboardA11y:ge,nodeExtent:ve,rfId:Ce}),l.jsx("div",{className:"react-flow__viewport-portal"})]})})}N3.displayName="GraphView";const I7=S.memo(N3),Ow=({nodes:e,edges:t,defaultNodes:r,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,k=new Map,w=new Map,C=new Map,j=i??t??[],E=r??e??[],N=x??[0,0],A=p??Wc;qk(w,C,j);const z=Fx(E,g,k,{nodeOrigin:N,nodeExtent:A,zIndexMode:y});let T=[0,0,1];if(c&&a&&o){const F=cu(g,{filter:_=>!!((_.width||_.initialWidth)&&(_.height||_.initialHeight))}),{x:q,y:V,zoom:L}=T0(F,a,o,m,f,(d==null?void 0:d.padding)??.1);T=[q,V,L]}return{rfId:"1",width:a??0,height:o??0,transform:T,nodes:E,nodesInitialized:z,nodeLookup:g,parentLookup:k,edges:j,edgeLookup:C,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:m,maxZoom:f,translateExtent:Wc,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:mo.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:d,fitViewResolver:null,connection:{...jk},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:r,defaultEdges:i,width:a,height:o,fitView:c,fitViewOptions:d,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:p,zIndexMode:y})=>r9((g,k)=>{async function w(){const{nodeLookup:C,panZoom:j,fitViewOptions:E,fitViewResolver:N,width:A,height:z,minZoom:T,maxZoom:F}=k();j&&(await QR({nodes:C,width:A,height:z,panZoom:j,minZoom:T,maxZoom:F},E),N==null||N.resolve(!0),g({fitViewResolver:null}))}return{...Ow({nodes:e,edges:t,width:a,height:o,fitView:c,fitViewOptions:d,minZoom:m,maxZoom:f,nodeOrigin:x,nodeExtent:p,defaultNodes:r,defaultEdges:i,zIndexMode:y}),setNodes:C=>{const{nodeLookup:j,parentLookup:E,nodeOrigin:N,elevateNodesOnSelect:A,fitViewQueued:z,zIndexMode:T}=k(),F=Fx(C,j,E,{nodeOrigin:N,nodeExtent:p,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:T});z&&F?(w(),g({nodes:C,nodesInitialized:F,fitViewQueued:!1,fitViewOptions:void 0})):g({nodes:C,nodesInitialized:F})},setEdges:C=>{const{connectionLookup:j,edgeLookup:E}=k();qk(j,E,C),g({edges:C})},setDefaultNodesAndEdges:(C,j)=>{if(C){const{setNodes:E}=k();E(C),g({hasDefaultNodes:!0})}if(j){const{setEdges:E}=k();E(j),g({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:j,nodeLookup:E,parentLookup:N,domNode:A,nodeOrigin:z,nodeExtent:T,debug:F,fitViewQueued:q,zIndexMode:V}=k(),{changes:L,updatedInternals:_}=wz(C,E,N,A,z,T,V);_&&(gz(E,N,{nodeOrigin:z,nodeExtent:T,zIndexMode:V}),q?(w(),g({fitViewQueued:!1,fitViewOptions:void 0})):g({}),(L==null?void 0:L.length)>0&&(F&&console.log("React Flow: trigger node changes",L),j==null||j(L)))},updateNodePositions:(C,j=!1)=>{const E=[];let N=[];const{nodeLookup:A,triggerNodeChanges:z,connection:T,updateConnection:F,onNodesChangeMiddlewareMap:q}=k();for(const[V,L]of C){const _=A.get(V),O=!!(_!=null&&_.expandParent&&(_!=null&&_.parentId)&&(L!=null&&L.position)),P={id:V,type:"position",position:O?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:j};if(_&&T.inProgress&&T.fromNode.id===_.id){const R=cl(_,T.fromHandle,at.Left,!0);F({...T,from:R})}O&&_.parentId&&E.push({id:V,parentId:_.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),N.push(P)}if(E.length>0){const{parentLookup:V,nodeOrigin:L}=k(),_=z0(E,A,V,L);N.push(..._)}for(const V of q.values())N=V(N);z(N)},triggerNodeChanges:C=>{const{onNodesChange:j,setNodes:E,nodes:N,hasDefaultNodes:A,debug:z}=k();if(C!=null&&C.length){if(A){const T=C9(C,N);E(T)}z&&console.log("React Flow: trigger node changes",C),j==null||j(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:j,setEdges:E,edges:N,hasDefaultEdges:A,debug:z}=k();if(C!=null&&C.length){if(A){const T=j9(C,N);E(T)}z&&console.log("React Flow: trigger edge changes",C),j==null||j(C)}},addSelectedNodes:C=>{const{multiSelectionActive:j,edgeLookup:E,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:z}=k();if(j){const T=C.map(F=>Wa(F,!0));A(T);return}A(ro(N,new Set([...C]),!0)),z(ro(E))},addSelectedEdges:C=>{const{multiSelectionActive:j,edgeLookup:E,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:z}=k();if(j){const T=C.map(F=>Wa(F,!0));z(T);return}z(ro(E,new Set([...C]))),A(ro(N,new Set,!0))},unselectNodesAndEdges:({nodes:C,edges:j}={})=>{const{edges:E,nodes:N,nodeLookup:A,triggerNodeChanges:z,triggerEdgeChanges:T}=k(),F=C||N,q=j||E,V=[];for(const _ of F){if(!_.selected)continue;const O=A.get(_.id);O&&(O.selected=!1),V.push(Wa(_.id,!1))}const L=[];for(const _ of q)_.selected&&L.push(Wa(_.id,!1));z(V),T(L)},setMinZoom:C=>{const{panZoom:j,maxZoom:E}=k();j==null||j.setScaleExtent([C,E]),g({minZoom:C})},setMaxZoom:C=>{const{panZoom:j,minZoom:E}=k();j==null||j.setScaleExtent([E,C]),g({maxZoom:C})},setTranslateExtent:C=>{var j;(j=k().panZoom)==null||j.setTranslateExtent(C),g({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:j,triggerNodeChanges:E,triggerEdgeChanges:N,elementsSelectable:A}=k();if(!A)return;const z=j.reduce((F,q)=>q.selected?[...F,Wa(q.id,!1)]:F,[]),T=C.reduce((F,q)=>q.selected?[...F,Wa(q.id,!1)]:F,[]);E(z),N(T)},setNodeExtent:C=>{const{nodes:j,nodeLookup:E,parentLookup:N,nodeOrigin:A,elevateNodesOnSelect:z,nodeExtent:T,zIndexMode:F}=k();C[0][0]===T[0][0]&&C[0][1]===T[0][1]&&C[1][0]===T[1][0]&&C[1][1]===T[1][1]||(Fx(j,E,N,{nodeOrigin:A,nodeExtent:C,elevateNodesOnSelect:z,checkEquality:!1,zIndexMode:F}),g({nodeExtent:C}))},panBy:C=>{const{transform:j,width:E,height:N,panZoom:A,translateExtent:z}=k();return kz({delta:C,panZoom:A,transform:j,translateExtent:z,width:E,height:N})},setCenter:async(C,j,E)=>{const{width:N,height:A,maxZoom:z,panZoom:T}=k();if(!T)return Promise.resolve(!1);const F=typeof(E==null?void 0:E.zoom)<"u"?E.zoom:z;return await T.setViewport({x:N/2-C*F,y:A/2-j*F,zoom:F},{duration:E==null?void 0:E.duration,ease:E==null?void 0:E.ease,interpolate:E==null?void 0:E.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{g({connection:{...jk}})},updateConnection:C=>{g({connection:C})},reset:()=>g({...Ow()})}},Object.is);function U7({initialNodes:e,initialEdges:t,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,initialMinZoom:c,initialMaxZoom:d,initialFitViewOptions:m,fitView:f,nodeOrigin:x,nodeExtent:p,zIndexMode:y,children:g}){const[k]=S.useState(()=>H7({nodes:e,edges:t,defaultNodes:r,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:k,children:l.jsx(T9,{children:g})})}function q7({children:e,nodes:t,edges:r,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(Xf)?l.jsx(l.Fragment,{children:e}):l.jsx(U7,{initialNodes:t,initialEdges:r,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 X7({nodes:e,edges:t,defaultNodes:r,defaultEdges:i,className:a,nodeTypes:o,edgeTypes:c,onNodeClick:d,onEdgeClick:m,onInit:f,onMove:x,onMoveStart:p,onMoveEnd:y,onConnect:g,onConnectStart:k,onConnectEnd:w,onClickConnectStart:C,onClickConnectEnd:j,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:A,onNodeContextMenu:z,onNodeDoubleClick:T,onNodeDragStart:F,onNodeDrag:q,onNodeDragStop:V,onNodesDelete:L,onEdgesDelete:_,onDelete:O,onSelectionChange:P,onSelectionDragStart:R,onSelectionDrag:H,onSelectionDragStop:B,onSelectionContextMenu:Z,onSelectionStart:G,onSelectionEnd:K,onBeforeDelete:M,connectionMode:U,connectionLineType:Y=ga.Bezier,connectionLineStyle:$,connectionLineComponent:Q,connectionLineContainerStyle:ee,deleteKeyCode:J="Backspace",selectionKeyCode:ae="Shift",selectionOnDrag:oe=!1,selectionMode:be=Gc.Full,panActivationKeyCode:Ee="Space",multiSelectionKeyCode:Ae=Qc()?"Meta":"Control",zoomActivationKeyCode:Fe=Qc()?"Meta":"Control",snapToGrid:he,snapGrid:Re,onlyRenderVisibleElements:et=!1,selectNodesOnDrag:We,nodesDraggable:it,autoPanOnNodeFocus:mt,nodesConnectable:Ye,nodesFocusable:Ze,nodeOrigin:ut=n3,edgesFocusable:jt,edgesReconnectable:ge,elementsSelectable:ve=!0,defaultViewport:Ce=g9,minZoom:ne=.5,maxZoom:de=2,translateExtent:_e=Wc,preventScrolling:ce=!0,nodeExtent:Te,defaultMarkerColor:Le="#b1b1b7",zoomOnScroll:Xe=!0,zoomOnPinch:Ue=!0,panOnScroll:Pe=!1,panOnScrollSpeed:lt=.5,panOnScrollMode:tt=nl.Free,zoomOnDoubleClick:ze=!0,panOnDrag:He=!0,onPaneClick:qt,onPaneMouseEnter:Kt,onPaneMouseMove:Et,onPaneMouseLeave:Xt,onPaneScroll:hn,onPaneContextMenu:vn,paneClickDistance:le=1,nodeClickDistance:qe=0,children:ot,onReconnect:Jt,onReconnectStart:je,onReconnectEnd:St,onEdgeContextMenu:gn,onEdgeDoubleClick:mn,onEdgeMouseEnter:Zn,onEdgeMouseMove:Jn,onEdgeMouseLeave:An,reconnectRadius:ie=10,onNodesChange:Ie,onEdgesChange:Ve,noDragClassName:ft="nodrag",noWheelClassName:Ct="nowheel",noPanClassName:xr="nopan",fitView:Vn,fitViewOptions:Sr,connectOnClick:ii,attributionPosition:dl,proOptions:$r,defaultEdgeOptions:Or,elevateNodesOnSelect:$i=!0,elevateEdgesOnSelect:Oi=!1,disableKeyboardA11y:si=!1,autoPanOnConnect:ki,autoPanOnNodeDrag:wn,autoPanSpeed:gr,connectionRadius:fl,isValidConnection:or,onError:ai,style:Li,id:li,nodeDragThreshold:Si,connectionDragThreshold:hl,viewport:Lr,onViewportChange:os,width:Cr,height:Wn,colorMode:ja="light",debug:ml,onScroll:Ii,ariaLabelConfig:oi,zIndexMode:er="basic",...jr},En){const tr=li||"1",Tn=w9(ja),Os=S.useCallback(Ci=>{Ci.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ii==null||Ii(Ci)},[Ii]);return l.jsx("div",{"data-testid":"rf__wrapper",...jr,onScroll:Os,style:{...Li,...Y7},ref:En,className:Hn(["react-flow",a,Tn]),id:li,role:"application",children:l.jsxs(q7,{nodes:e,edges:t,width:Cr,height:Wn,fitView:Vn,fitViewOptions:Sr,minZoom:ne,maxZoom:de,nodeOrigin:ut,nodeExtent:Te,zIndexMode:er,children:[l.jsx(I7,{onInit:f,onNodeClick:d,onEdgeClick:m,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:A,onNodeContextMenu:z,onNodeDoubleClick:T,nodeTypes:o,edgeTypes:c,connectionLineType:Y,connectionLineStyle:$,connectionLineComponent:Q,connectionLineContainerStyle:ee,selectionKeyCode:ae,selectionOnDrag:oe,selectionMode:be,deleteKeyCode:J,multiSelectionKeyCode:Ae,panActivationKeyCode:Ee,zoomActivationKeyCode:Fe,onlyRenderVisibleElements:et,defaultViewport:Ce,translateExtent:_e,minZoom:ne,maxZoom:de,preventScrolling:ce,zoomOnScroll:Xe,zoomOnPinch:Ue,zoomOnDoubleClick:ze,panOnScroll:Pe,panOnScrollSpeed:lt,panOnScrollMode:tt,panOnDrag:He,onPaneClick:qt,onPaneMouseEnter:Kt,onPaneMouseMove:Et,onPaneMouseLeave:Xt,onPaneScroll:hn,onPaneContextMenu:vn,paneClickDistance:le,nodeClickDistance:qe,onSelectionContextMenu:Z,onSelectionStart:G,onSelectionEnd:K,onReconnect:Jt,onReconnectStart:je,onReconnectEnd:St,onEdgeContextMenu:gn,onEdgeDoubleClick:mn,onEdgeMouseEnter:Zn,onEdgeMouseMove:Jn,onEdgeMouseLeave:An,reconnectRadius:ie,defaultMarkerColor:Le,noDragClassName:ft,noWheelClassName:Ct,noPanClassName:xr,rfId:tr,disableKeyboardA11y:si,nodeExtent:Te,viewport:Lr,onViewportChange:os}),l.jsx(v9,{nodes:e,edges:t,defaultNodes:r,defaultEdges:i,onConnect:g,onConnectStart:k,onConnectEnd:w,onClickConnectStart:C,onClickConnectEnd:j,nodesDraggable:it,autoPanOnNodeFocus:mt,nodesConnectable:Ye,nodesFocusable:Ze,edgesFocusable:jt,edgesReconnectable:ge,elementsSelectable:ve,elevateNodesOnSelect:$i,elevateEdgesOnSelect:Oi,minZoom:ne,maxZoom:de,nodeExtent:Te,onNodesChange:Ie,onEdgesChange:Ve,snapToGrid:he,snapGrid:Re,connectionMode:U,translateExtent:_e,connectOnClick:ii,defaultEdgeOptions:Or,fitView:Vn,fitViewOptions:Sr,onNodesDelete:L,onEdgesDelete:_,onDelete:O,onNodeDragStart:F,onNodeDrag:q,onNodeDragStop:V,onSelectionDrag:H,onSelectionDragStart:R,onSelectionDragStop:B,onMove:x,onMoveStart:p,onMoveEnd:y,noPanClassName:xr,nodeOrigin:ut,rfId:tr,autoPanOnConnect:ki,autoPanOnNodeDrag:wn,autoPanSpeed:gr,onError:ai,connectionRadius:fl,isValidConnection:or,selectNodesOnDrag:We,nodeDragThreshold:Si,connectionDragThreshold:hl,onBeforeDelete:M,debug:ml,ariaLabelConfig:oi,zIndexMode:er}),l.jsx(x9,{onSelectionChange:P}),ot,l.jsx(d9,{proOptions:$r,position:dl}),l.jsx(u9,{rfId:tr,disableKeyboardA11y:si})]})})}var P7=i3(X7);function V7({dimensions:e,lineWidth:t,variant:r,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:Hn(["react-flow__background-pattern",r,i])})}function W7({radius:e,className:t}){return l.jsx("circle",{cx:e,cy:e,r:e,className:Hn(["react-flow__background-pattern","dots",t])})}var va;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(va||(va={}));const G7={[va.Dots]:1,[va.Lines]:1,[va.Cross]:6},K7=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function A3({id:e,variant:t=va.Dots,gap:r=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}=Ut(K7,Cn),k=i||G7[t],w=t===va.Dots,C=t===va.Cross,j=Array.isArray(r)?r:[r,r],E=[j[0]*y[2]||1,j[1]*y[2]||1],N=k*y[2],A=Array.isArray(o)?o:[o,o],z=C?[N,N]:E,T=[A[0]*y[2]||1+z[0]/2,A[1]*y[2]||1+z[1]/2],F=`${g}${e||""}`;return l.jsxs("svg",{className:Hn(["react-flow__background",f]),style:{...m,...Vf,"--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]%E[0],y:y[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:w?l.jsx(W7,{radius:N/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})`})]})}A3.displayName="Background";S.memo(A3);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 Ud({children:e,className:t,...r}){return l.jsx("button",{type:"button",className:Hn(["react-flow__controls-button",t]),...r,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:r=!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 k=jn(),{isInteractive:w,minZoomReached:C,maxZoomReached:j,ariaLabelConfig:E}=Ut(nB,Cn),{zoomIn:N,zoomOut:A,fitView:z}=B0(),T=()=>{N(),o==null||o()},F=()=>{A(),c==null||c()},q=()=>{z(a),d==null||d()},V=()=>{k.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),m==null||m(!w)},L=y==="horizontal"?"horizontal":"vertical";return l.jsxs(Pf,{className:Hn(["react-flow__controls",L,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":g??E["controls.ariaLabel"],children:[t&&l.jsxs(l.Fragment,{children:[l.jsx(Ud,{onClick:T,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:j,children:l.jsx(Q7,{})}),l.jsx(Ud,{onClick:F,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:C,children:l.jsx(Z7,{})})]}),r&&l.jsx(Ud,{className:"react-flow__controls-fitview",onClick:q,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:l.jsx(J7,{})}),i&&l.jsx(Ud,{className:"react-flow__controls-interactive",onClick:V,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:w?l.jsx(tB,{}):l.jsx(eB,{})}),x]})}T3.displayName="Controls";S.memo(T3);function rB({id:e,x:t,y:r,width:i,height:a,style:o,color:c,strokeColor:d,strokeWidth:m,className:f,borderRadius:x,shapeRendering:p,selected:y,onClick:g}){const{background:k,backgroundColor:w}=o||{},C=c||k||w;return l.jsx("rect",{className:Hn(["react-flow__minimap-node",{selected:y},f]),x:t,y:r,rx:x,ry:x,width:i,height:a,style:{fill:C,stroke:d,strokeWidth:m},shapeRendering:p,onClick:g?j=>g(j,e):void 0})}const iB=S.memo(rB),sB=e=>e.nodes.map(t=>t.id),Fp=e=>e instanceof Function?e:()=>e;function aB({nodeStrokeColor:e,nodeColor:t,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:o=iB,onClick:c}){const d=Ut(sB,Cn),m=Fp(t),f=Fp(e),x=Fp(r),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:r,nodeClassNameFunc:i,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:c,NodeComponent:d,onClick:m}){const{node:f,x,y:p,width:y,height:g}=Ut(k=>{const w=k.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const C=w.internals.userNode,{x:j,y:E}=w.internals.positionAbsolute,{width:N,height:A}=$s(C);return{node:C,x:j,y:E,width:N,height:A}},Cn);return!f||f.hidden||!Mk(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:r(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?_k(cu(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 D3({style:e,className:t,nodeStrokeColor:r,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:k,pannable:w=!1,zoomable:C=!1,ariaLabel:j,inversePan:E,zoomStep:N=1,offsetScale:A=5}){const z=jn(),T=S.useRef(null),{boundingRect:F,viewBB:q,rfId:V,panZoom:L,translateExtent:_,flowWidth:O,flowHeight:P,ariaLabelConfig:R}=Ut(hB,Cn),H=(e==null?void 0:e.width)??uB,B=(e==null?void 0:e.height)??dB,Z=F.width/H,G=F.height/B,K=Math.max(Z,G),M=K*H,U=K*B,Y=A*K,$=F.x-(M-F.width)/2-Y,Q=F.y-(U-F.height)/2-Y,ee=M+Y*2,J=U+Y*2,ae=`${mB}-${V}`,oe=S.useRef(0),be=S.useRef();oe.current=K,S.useEffect(()=>{if(T.current&&L)return be.current=_z({domNode:T.current,panZoom:L,getTransform:()=>z.getState().transform,getViewScale:()=>oe.current}),()=>{var he;(he=be.current)==null||he.destroy()}},[L]),S.useEffect(()=>{var he;(he=be.current)==null||he.update({translateExtent:_,width:O,height:P,inversePan:E,pannable:w,zoomStep:N,zoomable:C})},[w,C,E,N,_,O,P]);const Ee=g?he=>{var We;const[Re,et]=((We=be.current)==null?void 0:We.pointer(he))||[0,0];g(he,{x:Re,y:et})}:void 0,Ae=k?S.useCallback((he,Re)=>{const et=z.getState().nodeLookup.get(Re).internals.userNode;k(he,et)},[]):void 0,Fe=j??R["minimap.ariaLabel"];return l.jsx(Pf,{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 r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:Hn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:l.jsxs("svg",{width:H,height:B,viewBox:`${$} ${Q} ${ee} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ae,ref:T,onClick:Ee,children:[Fe&&l.jsx("title",{id:ae,children:Fe}),l.jsx(cB,{onClick:Ae,nodeColor:i,nodeStrokeColor:r,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:d}),l.jsx("path",{className:"react-flow__minimap-mask",d:`M${$-Y},${Q-Y}h${ee+Y*2}v${J+Y*2}h${-ee-Y*2}z
112
- M${q.x},${q.y}h${q.width}v${q.height}h${-q.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}D3.displayName="MiniMap";S.memo(D3);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:r=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:k,onResizeStart:w,onResize:C,onResizeEnd:j}){const E=o3(),N=typeof e=="string"?e:E,A=jn(),z=S.useRef(null),T=r===yo.Handle,F=Ut(S.useCallback(pB(T&&g),[T,g]),Cn),q=S.useRef(null),V=t??xB[r];S.useEffect(()=>{if(!(!z.current||!N))return q.current||(q.current=Xz({domNode:z.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:_,transform:O,snapGrid:P,snapToGrid:R,nodeOrigin:H,domNode:B}=A.getState();return{nodeLookup:_,transform:O,snapGrid:P,snapToGrid:R,nodeOrigin:H,paneDomNode:B}},onChange:(_,O)=>{const{triggerNodeChanges:P,nodeLookup:R,parentLookup:H,nodeOrigin:B}=A.getState(),Z=[],G={x:_.x,y:_.y},K=R.get(N);if(K&&K.expandParent&&K.parentId){const M=K.origin??B,U=_.width??K.measured.width??0,Y=_.height??K.measured.height??0,$={id:K.id,parentId:K.parentId,rect:{width:U,height:Y,...Fk({x:_.x??K.position.x,y:_.y??K.position.y},{width:U,height:Y},K.parentId,R,M)}},Q=z0([$],R,H,B);Z.push(...Q),G.x=_.x?Math.max(M[0]*U,_.x):void 0,G.y=_.y?Math.max(M[1]*Y,_.y):void 0}if(G.x!==void 0&&G.y!==void 0){const M={id:N,type:"position",position:{...G}};Z.push(M)}if(_.width!==void 0&&_.height!==void 0){const U={id:N,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:_.width,height:_.height}};Z.push(U)}for(const M of O){const U={...M,type:"position"};Z.push(U)}P(Z)},onEnd:({width:_,height:O})=>{const P={id:N,type:"dimensions",resizing:!1,dimensions:{width:_,height:O}};A.getState().triggerNodeChanges([P])}})),q.current.update({controlPosition:V,boundaries:{minWidth:d,minHeight:m,maxWidth:f,maxHeight:x},keepAspectRatio:p,resizeDirection:y,onResizeStart:w,onResize:C,onResizeEnd:j,shouldResize:k}),()=>{var _;(_=q.current)==null||_.destroy()}},[V,d,m,f,x,p,w,C,j,k]);const L=V.split("-");return l.jsx("div",{className:Hn(["react-flow__resize-control","nodrag",...L,r,i]),ref:z,style:{...a,scale:F,...c&&{[T?"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 r=e,{node:i,roleLevel:a,isSelected:o,isChecked:c,showCheckbox:d,isEligible:m,hasActiveChildren:f}=r,x=yB[i.roleId]??"#6B7280",p=vB(i),y=ba(i.status),g=a==="ceo",k=io[a],w=bB[i.roleId]??"👤",C=i.status==="not-dispatched",j=g?o?.9:.65:C&&!c?.4:1;return l.jsxs("div",{className:"org-rf-node",style:{width:k.w,height:k.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 ${C?"#333":x+"30"}`,borderStyle:C&&!c?"dashed":"solid",cursor:"pointer",opacity:j,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:w}),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:E=>{E.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),CB={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#7C4DFF",designer:"#E91E63",qa:"#00897B","data-analyst":"#0288D1","designer-seek":"#E91E63",test:"#78909C"};function jB(e){const{sourceX:t,sourceY:r,targetX:i,targetY:a,data:o}=e,c=o??{},[d]=Af({sourceX:t,sourceY:r,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=(CB[c.childRoleId??""]??"#60A5FA")+"55",f="8 5",x=!0,p=2.2),l.jsx(fu,{path:d,style:{stroke:m,strokeWidth:p,strokeDasharray:f},className:x?"wave-edge-flow":void 0})}const EB=S.memo(jB),Rp=24,NB=56,AB={orgRole:SB},TB={orgEdge:EB};function DB(e,t,r){var i,a;return e===t?"ceo":((i=r==null?void 0:r[e])==null?void 0:i.level)==="c-level"||((a=r==null?void 0:r[e])==null?void 0:a.reportsTo)===t?"c-level":"member"}function _B(e,t,r){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=DB(f,t,r);a.push({roleId:f,x:0,y:0,parentId:p,level:y});const g=e.get(f);if(g)for(const k of g.children)e.has(k)&&!d.has(k)&&c.push({id:k,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(k=>{const w=a.find(C=>C.roleId===k);return w?io[w.level].h:44}));let g=-x.reduce((k,w)=>{const C=a.find(j=>j.roleId===w);return k+(C?io[C.level].w:130)+Rp},-Rp)/2;for(const k of x){const w=a.find(j=>j.roleId===k);if(!w)continue;const C=io[w.level];w.x=g+C.w/2,w.y=m+(p-C.h)/2,g+=C.w+Rp}m+=p+NB}for(const f of a){const x=io[f.level];f.x-=x.w/2}return a}function _3({nodes:e,rootId:t,selectedRoleId:r,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(w=>{const C=e.get(w.roleId);if(!C)return null;const j=C.children.some(A=>{const z=e.get(A);return z&&ba(z.status)}),E={node:C,roleLevel:w.level,isSelected:r===w.roleId,isChecked:(a==null?void 0:a.has(w.roleId))??!1,showCheckbox:m,isEligible:!c||c.has(w.roleId),hasActiveChildren:j},N=io[w.level];return{id:w.roleId,type:"orgRole",position:{x:w.x,y:w.y},data:E,draggable:!1,selectable:!1,width:N.w,height:N.h}}).filter(Boolean),k=y.filter(w=>w.parentId).map(w=>{const C=e.get(w.roleId),j=e.get(w.parentId);return{id:`${w.parentId}-${w.roleId}`,source:w.parentId,target:w.roleId,type:"orgEdge",data:{childStatus:C==null?void 0:C.status,parentStatus:j==null?void 0:j.status,childRoleId:w.roleId},selectable:!1}});return{rfNodes:g,rfEdges:k}},[e,t,r,a,c,m,d]),p=S.useCallback((y,g)=>{i(g.id)},[i]);return S.useEffect(()=>{if(!o)return;const y=g=>{var w;const k=(w=g.detail)==null?void 0:w.roleId;k&&o(k)};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(P7,{nodes:f,edges:x,nodeTypes:AB,edgeTypes:TB,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:r,rootRoleId:i,waveId:a,onClose:o,onMinimize:c,onDone:d,onOpenKnowledgeDoc:m,onSave:f}){const{nodes:x,selectedRoleId:p,selectNode:y,progress:g,allDone:k,connectStream:w}=G5(t,r,i,a),[C,j]=S.useState(0),[E,N]=S.useState(new Set),[A,z]=S.useState(""),[T,F]=S.useState(!1),[q,V]=S.useState(!1),L=S.useRef(null),_=S.useRef(Date.now()),O=S.useRef(!1),P=S.useCallback(async()=>{if(f){V(!0);try{const Y=t.map($=>$.sessionId).filter(Boolean);await f(Y)}catch(Y){console.error("Save failed:",Y)}finally{V(!1),o()}}},[f,t,o]),R=S.useCallback(async()=>{if(!p||!A.trim())return;const Y=x.get(p);if(!(!(Y!=null&&Y.sessionId)||Y.status!=="awaiting_input"&&Y.status!=="done")){F(!0);try{await Se.replyToSession(Y.sessionId,A.trim()),z(""),w(Y.sessionId,p)}catch($){console.error("Reply failed:",$)}finally{F(!1)}}},[p,A,x,w]),H=S.useCallback(async Y=>{const $=x.get(Y);if($!=null&&$.sessionId)try{await Se.abortSession($.sessionId)}catch{}},[x]),B=S.useCallback(async()=>{for(const[,Y]of x)if(ba(Y.status))try{Y.sessionId&&await Se.abortSession(Y.sessionId)}catch{}},[x]);S.useEffect(()=>{const Y=setInterval(()=>{j(Math.floor((Date.now()-_.current)/1e3))},1e3);return()=>clearInterval(Y)},[]);const Z=S.useRef(!1);S.useEffect(()=>{const Y=L.current;if(!Y)return;const $=()=>{const Q=Y.scrollHeight-Y.scrollTop-Y.clientHeight<60;Z.current=!Q};return Y.addEventListener("scroll",$),()=>Y.removeEventListener("scroll",$)},[]),S.useEffect(()=>{Z.current=!1,L.current&&(L.current.scrollTop=L.current.scrollHeight)},[p]),S.useEffect(()=>{L.current&&!Z.current&&(L.current.scrollTop=L.current.scrollHeight)},[x]),S.useEffect(()=>{k&&!O.current&&(O.current=!0,d==null||d()),!k&&O.current&&(O.current=!1)},[k,d]);const G=Y=>`${Math.floor(Y/60)}:${String(Y%60).padStart(2,"0")}`,K=p?x.get(p):null,M=p?MB[p]??"#888":"#888",U=Y=>{N($=>{const Q=new Set($);return Q.has(Y)?Q.delete(Y):Q.add(Y),Q})};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:k?"#2E7D32":"#B71C1C",animation:k?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:k?"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:G(C)}),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:k?"#2E7D3222":"#B71C1C22",color:k?"#2E7D32":"#B71C1C"},children:[g.done,"/",g.total," done"]}),!k&&(g.running>0||g.awaitingInput>0)&&l.jsx("button",{onClick:B,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:k?"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(Y=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:Y.color,animation:Y.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:Y.label})]},Y.label))})]}),l.jsx("div",{className:"px-3 pb-2",style:{height:"35vh"},children:l.jsx(_3,{nodes:x,rootId:i,selectedRoleId:p,onSelectNode:y,orgNodes:r})})]}),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"}),ba(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(Y=>l.jsx(v0,{event:Y,isThinkingCollapsed:E.has(Y.seq),onToggleThinking:()=>U(Y.seq),onNavigateToSession:$=>{const Q=K==null?void 0:K.events.find(J=>J.type==="dispatch:start"&&J.data.childSessionId===$),ee=Q==null?void 0:Q.data.targetRoleId;ee&&x.has(ee)&&y(ee)},onOpenKnowledgeDoc:m},Y.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:Y=>z(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),R())},placeholder:"Type your response...",disabled:T,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:T||!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:T?"...":"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:Y=>z(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),R())},placeholder:"e.g., 좋아 KB-3 진행해, Engineer에게 시켜...",disabled:T,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:T||!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:T?"...":"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`}),k&&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:P,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 Lw({orgNodes:e,rootRoleId:t,cLevelRoles:r,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:k}){const[w,C]=S.useState(""),[j,E]=S.useState(!1),[N,A]=S.useState(null),[z,T]=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,O=S.useMemo(()=>[],[]),P=(_==null?void 0:_.rootDispatches)??O,R=G5(P,e,t,(_==null?void 0:_.id)??null);S.useEffect(()=>{if(N){const ie=zB(e,t,N.roles);R.injectStaticNodes(ie);for(const Ie of N.roles??[])if(g2(Ie.status)&&Ie.sessionId){const Ve=ie.get(Ie.roleId);Ve!=null&&Ve.sessionId&&setTimeout(()=>R.connectStream(Ve.sessionId,Ie.roleId),100)}}},[N,e,t]),S.useEffect(()=>{!R.selectedRoleId&&t&&R.selectNode(t)},[t]);const H=S.useRef(a.length);S.useEffect(()=>{const ie=a.length>H.current;H.current=a.length,ie&&(q(0),A(null),V(!1))},[a.length]);const[B,Z]=S.useState(null),G=S.useMemo(()=>{if(!B)return null;const ie=B.modified.length+B.untracked.length;return{branch:B.branch,dirty:ie>0,count:ie}},[B]),K=S.useCallback(()=>{Se.getSaveStatus("code").then(ie=>{Z({dirty:ie.modified.length+ie.untracked.length>0,modified:ie.modified,untracked:ie.untracked,lastCommit:ie.lastCommit,branch:ie.branch})}).catch(()=>{})},[]);S.useEffect(()=>{K()},[K]);const[M,U]=S.useState(0);S.useEffect(()=>{if(!_)return;const ie=setInterval(()=>{U(Math.floor((Date.now()-_.startedAt)/1e3))},1e3);return()=>clearInterval(ie)},[_]);const[Y,$]=S.useState(""),[Q,ee]=S.useState(!1),[J,ae]=S.useState([]),[oe,be]=S.useState(!1),[Ee,Ae]=S.useState(null),Fe=S.useRef(null);S.useEffect(()=>{if(Ee){const ie=setTimeout(()=>Ae(null),3e3);return()=>clearTimeout(ie)}},[Ee]);const he=S.useCallback(async ie=>["image/png","image/jpeg","image/gif","image/webp"].includes(ie.type)?ie.size>5*1024*1024?(Ae(`Too large: ${(ie.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(Ve=>{const ft=new FileReader;ft.onload=()=>{const Ct=ft.result.split(",")[1];Ve({type:"image",data:Ct,name:ie.name,mediaType:ie.type})},ft.onerror=()=>{Ae("Failed to read file"),Ve(null)},ft.readAsDataURL(ie)}):(Ae(`Unsupported: ${ie.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),Re=S.useCallback(async ie=>{const Ie=[];for(const Ve of Array.from(ie)){const ft=await he(Ve);ft&&Ie.push(ft)}Ie.length>0&&ae(Ve=>[...Ve,...Ie])},[he]),et=S.useCallback(ie=>{ie.preventDefault(),ie.stopPropagation(),be(!0)},[]),We=S.useCallback(ie=>{ie.preventDefault(),ie.stopPropagation(),be(!1)},[]),it=S.useCallback(ie=>{ie.preventDefault(),ie.stopPropagation(),be(!1),ie.dataTransfer.files.length>0&&Re(ie.dataTransfer.files)},[Re]),mt=S.useCallback(ie=>{const Ie=[];for(let Ve=0;Ve<ie.clipboardData.items.length;Ve++){const ft=ie.clipboardData.items[Ve];if(ft.type.startsWith("image/")){const Ct=ft.getAsFile();Ct&&Ie.push(Ct)}}Ie.length>0&&(ie.preventDefault(),Re(Ie))},[Re]),[Ye,Ze]=S.useState(320),ut=S.useRef(!1),jt=S.useRef(0),ge=S.useRef(0),ve=S.useCallback(ie=>{ie.preventDefault(),ut.current=!0,jt.current=ie.clientX,ge.current=Ye;const Ie=ft=>{if(!ut.current)return;const Ct=jt.current-ft.clientX;Ze(Math.max(200,Math.min(500,ge.current+Ct)))},Ve=()=>{ut.current=!1,window.removeEventListener("mousemove",Ie),window.removeEventListener("mouseup",Ve)};window.addEventListener("mousemove",Ie),window.addEventListener("mouseup",Ve)},[Ye]),[Ce,ne]=S.useState(new Set),de=S.useRef(null),_e=S.useRef(!1);S.useEffect(()=>{const ie=de.current;if(!ie)return;const Ie=()=>{const Ve=ie.scrollHeight-ie.scrollTop-ie.clientHeight<60;_e.current=!Ve};return ie.addEventListener("scroll",Ie),()=>ie.removeEventListener("scroll",Ie)},[]),S.useEffect(()=>{!_e.current&&de.current&&(de.current.scrollTop=de.current.scrollHeight)},[R.nodes,R.selectedRoleId]);const ce=R.selectedRoleId?R.nodes.get(R.selectedRoleId)??null:null,Te=ce?RB[ce.roleId]??"#888":"#888",Le=R.progress.running>0||R.progress.awaitingInput>0,Xe=R.selectedRoleId===t,Ue=!!N&&!_,Pe=(_==null?void 0:_.directive)??(N==null?void 0:N.directive)??"",lt=S.useCallback(ie=>{const Ie=new Set,Ve=[ie];for(;Ve.length>0;){const ft=Ve.shift();if(Ie.has(ft))continue;Ie.add(ft);const Ct=e[ft];Ct&&Ve.push(...Ct.children)}return Ie},[e]),tt=S.useMemo(()=>{if(!R.selectedRoleId)return new Set;const ie=lt(R.selectedRoleId);return ie.delete(t),ie},[R.selectedRoleId,lt,t]),ze=S.useRef(null);S.useEffect(()=>{if(R.selectedRoleId===ze.current||(ze.current=R.selectedRoleId,!R.selectedRoleId))return;const ie=lt(R.selectedRoleId);ie.delete(t),R.setCheckedRoles(ie)},[R.selectedRoleId,lt,t]);const He=R.checkedRoles.size,qt=()=>{if(!w.trim()&&J.length===0||He===0)return;const Ie=Array.from(R.nodes.keys()).filter(ft=>ft!==t).every(ft=>R.checkedRoles.has(ft)),Ve=J.length>0?J:void 0;o(w.trim(),Ie?void 0:Array.from(R.checkedRoles),Ve,j||void 0),C(""),ae([])},Kt=ie=>{ie.key==="Enter"&&(ie.metaKey||ie.ctrlKey)&&(ie.preventDefault(),qt()),ie.key==="Escape"&&c()},Et=S.useCallback(async()=>{if(!R.selectedRoleId||!Y.trim()&&J.length===0)return;const ie=R.nodes.get(R.selectedRoleId);if(!ie)return;const Ie=J.length>0?J:void 0;ee(!0);try{if(ie.status==="awaiting_input"&&ie.sessionId){const Ve=await Se.replyToSession(ie.sessionId,Y.trim(),Ie);$(""),ae([]),!!(_!=null&&_.id)||R.connectStream(Ve.sessionId||ie.sessionId,R.selectedRoleId)}else{const Ve=(_==null?void 0:_.id)??(N==null?void 0:N.waveId)??(N==null?void 0:N.id),ft=await Se.execute({type:"assign",roleId:R.selectedRoleId,task:Y.trim(),...Ve&&{waveId:Ve},...Ie&&{attachments:Ie}});$(""),ae([]),ft.sessionId&&(_!=null&&_.id||R.connectStream(ft.sessionId,R.selectedRoleId))}}catch(Ve){console.error("Reply failed:",Ve)}finally{ee(!1)}},[R,Y,J,_,N]),Xt=S.useCallback(async ie=>{const Ie=R.nodes.get(ie);if(Ie!=null&&Ie.sessionId)try{await Se.abortSession(Ie.sessionId)}catch{}},[R.nodes]),hn=S.useCallback(async()=>{for(const[,ie]of R.nodes)if(ba(ie.status))try{ie.sessionId&&await Se.abortSession(ie.sessionId)}catch{}},[R.nodes]),vn=S.useCallback(async ie=>{T(!0),A(null),q(-1);try{const Ie=await Se.getWaveDetail(ie);Ie.replay&&A(Ie.replay)}catch(Ie){console.error("Failed to load wave:",Ie)}finally{T(!1)}},[]),le=S.useRef(!1);S.useEffect(()=>{le.current||a.length===0&&i.length>0&&!N&&!z&&(le.current=!0,vn(i[0].id))},[a.length,i,N,z,vn]);const qe=S.useRef(!1),ot=S.useRef(null);S.useEffect(()=>{if(!(N||z)&&((_==null?void 0:_.id)!==ot.current&&(qe.current=!1,ot.current=(_==null?void 0:_.id)??null),R.allDone&&!qe.current&&_&&(qe.current=!0,K(),d==null||d(),m))){const ie=_.rootDispatches.map(Ie=>Ie.sessionId).filter(Boolean);m(_.directive,ie,{waveId:_.id,sessionIds:_.sessionIds}).catch(()=>{})}},[R.allDone,_,d,m,K,N,z]);const Jt=S.useCallback(async()=>{if(!m||!_)return;const ie=_.rootDispatches.map(Ie=>Ie.sessionId).filter(Boolean);await m(_.directive,ie,{waveId:_.id,sessionIds:_.sessionIds})},[m,_]),je=ie=>{ne(Ie=>{const Ve=new Set(Ie);return Ve.has(ie)?Ve.delete(ie):Ve.add(ie),Ve})},St=ie=>{const Ie=Math.floor(ie/60),Ve=ie%60;return`${Ie}:${Ve.toString().padStart(2,"0")}`},{panelRight:gn,panelWidth:mn,isResizing:Zn,handleResizeStart:Jn}=su(p,700,y),An=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"}),Le&&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":""}`:Ue?"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:[(_||Ue)&&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:Le?"#FBBF24":R.allDone||Ue?"#2E7D32":"#B71C1C",animation:Le?"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:["“",Pe,"”"]}),_&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs font-mono shrink-0",children:St(M)}),Ue&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold shrink-0",style:{background:Le?"#FBBF2422":"#2E7D3222",color:Le?"#FBBF24":"#2E7D32"},children:Le?"LIVE":"REPLAY"}),Ue&&(N==null?void 0:N.startedAt)&&l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-[10px] shrink-0",children:new Date(N.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||Ue&&!Le?"#2E7D3222":"#B71C1C22",color:R.allDone||Ue&&!Le?"#2E7D32":"#B71C1C"},children:[R.progress.done,"/",R.progress.total]}),Le&&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:_||Ue?"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"]}),(_||Ue)&&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(ie=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{background:ie.color,animation:ie.dot?"wave-pulse 1.5s ease-in-out infinite":void 0}}),l.jsx("span",{className:"text-[8px] text-[var(--terminal-text-muted)]",children:ie.label})]},ie.label))})]}),l.jsx("div",{className:"px-3 pb-2",style:{height:"38vh"},children:l.jsx(_3,{nodes:R.nodes,rootId:t,selectedRoleId:R.selectedRoleId,onSelectNode:R.selectNode,checkedRoles:R.checkedRoles,onToggleCheck:R.toggleCheck,eligibleRoles:tt,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..."}):Xe?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:[He," target role",He!==1?"s":""," selected"]})]}),l.jsxs("div",{ref:de,className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-2 text-xs font-mono select-text",children:[Pe&&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:Pe}),_&&l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-1",children:["dispatched ",St(M)," ago to ",_.rootDispatches.length," role",_.rootDispatches.length!==1?"s":""]})]})]}),!Pe&&!_&&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((ie,Ie)=>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:${ie.mediaType};base64,${ie.data}`,alt:ie.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>ae(Ve=>Ve.filter((ft,Ct)=>Ct!==Ie)),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:ie.name})]},Ie))}),Ee&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:Ee}),l.jsxs("div",{className:"flex gap-2 items-end",children:[l.jsx("button",{onClick:()=>{var ie;return(ie=Fe.current)==null?void 0:ie.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:w,onChange:ie=>C(ie.target.value),onKeyDown:Kt,onPaste:mt,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:qt,disabled:!w.trim()&&J.length===0||He===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:w.trim()&&He>0?"#B71C1C":"#333",color:"#fff",minWidth:140},children:["Dispatch to ",He," Role",He!==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:j,onChange:ie=>E(ie.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:[ce&&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:Te}}),l.jsx("span",{className:"text-[var(--terminal-text)] font-bold text-xs",children:ce.roleId.toUpperCase()}),l.jsx("span",{className:"text-[var(--terminal-text-muted)] text-xs",children:ce.roleName}),l.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full font-semibold",style:{background:ce.status==="awaiting_input"?"#F59E0B22":ce.status==="streaming"?"#FBBF2422":`${Te}22`,color:ce.status==="awaiting_input"?"#F59E0B":ce.status==="streaming"?"#FBBF24":Te},children:ce.status==="streaming"?"Working...":ce.status==="done"?ce.children.some(ie=>{const Ie=R.nodes.get(ie);return Ie&&ba(Ie.status)})?"Supervising...":"Complete":ce.status==="error"?"Error":ce.status==="waiting"?"Waiting":ce.status==="awaiting_input"?"Awaiting Reply":"Not dispatched"}),l.jsxs("span",{className:"text-[10px] text-[var(--terminal-text-muted)]",children:[ce.events.length," events"]}),ba(ce.status)&&ce.sessionId&&l.jsx("button",{onClick:()=>Xt(ce.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"})]}),ce&&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:[ce.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:ce.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:ce.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:ce.streamStatus})]}),(()=>{const ie=ce.events[ce.events.length-1];if(!(ie!=null&&ie.ts))return null;const Ie=Math.floor((Date.now()-new Date(ie.ts).getTime())/1e3);if(isNaN(Ie)||Ie<0)return null;const Ve=Ie<60?`${Ie}s ago`:Ie<3600?`${Math.floor(Ie/60)}m ago`:`${Math.floor(Ie/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:Ve})]})})()]}),(()=>{var Ct,xr;const ie=ce.events.filter(Vn=>Vn.type==="text"||Vn.type==="tool:result"),Ie=ie[ie.length-1];if(!Ie)return null;const Ve=typeof((Ct=Ie.data)==null?void 0:Ct.text)=="string"?Ie.data.text:typeof((xr=Ie.data)==null?void 0:xr.content)=="string"?Ie.data.content:null;if(!Ve)return null;const ft=Ve.length>120?Ve.slice(0,120)+"...":Ve;return l.jsx("div",{className:"mt-1.5 text-[10px] text-[var(--terminal-text-muted)] italic truncate",title:Ve,children:ft})})()]}),l.jsx("input",{ref:Fe,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:ie=>{var Ie;(Ie=ie.target.files)!=null&&Ie.length&&Re(ie.target.files),ie.target.value=""},className:"hidden"}),l.jsxs("div",{ref:de,className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-1 text-xs font-mono select-text transition-colors ${oe?"bg-amber-500/5 ring-1 ring-inset ring-amber-500/30":""}`,onDragOver:et,onDragLeave:We,onDrop:it,children:[ce&&Pe&&ce.status!=="waiting"&&ce.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:Pe})]}),ce&&ce.events.length===0&&l.jsx("div",{className:"text-[var(--terminal-text-muted)]",children:ce.status==="waiting"?"Waiting for dispatch...":ce.status==="streaming"?"Connecting to activity stream...":ce.status==="not-dispatched"?"This role was not dispatched. Send a follow-up to activate.":""}),ce==null?void 0:ce.events.map((ie,Ie)=>{const Ve=ce.events,ft=ie.type==="msg:start"&&Ie>0,Ct=Ve[Ie+1];if((ie.type==="msg:done"||ie.type==="msg:error"||ie.type==="msg:awaiting_input")&&(Ct==null?void 0:Ct.type)==="msg:start")return null;if(ft){const Vn=ie.data.task??"",Sr=Vn.match(/\[CEO Follow-up\]\n([\s\S]+)$/),ii=Sr?Sr[1].trim():Vn;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:ii})]})},`followup-${ie.seq}`)}return l.jsx(v0,{event:ie,isThinkingCollapsed:Ce.has(ie.seq),onToggleThinking:()=>je(ie.seq),onNavigateToSession:Vn=>{for(const[,Sr]of R.nodes)if(Sr.events.some(ii=>ii.data.childSessionId===Vn)){R.selectNode(Sr.roleId);return}},onOpenKnowledgeDoc:f},ie.seq)}),(ce==null?void 0:ce.status)==="streaming"&&l.jsx("span",{className:"inline-block w-2 h-4 bg-green-400 animate-pulse ml-0.5"}),!ce&&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"})]}),((ce==null?void 0:ce.status)==="awaiting_input"||(ce==null?void 0:ce.status)==="done"||(ce==null?void 0:ce.status)==="not-dispatched")&&(J.length>0||Ee||oe)&&l.jsxs("div",{className:"px-4 pt-2 border-t shrink-0",style:{borderColor:"var(--terminal-border)"},children:[Ee&&l.jsx("div",{className:"text-[10px] text-red-400 mb-1",children:Ee}),oe&&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((ie,Ie)=>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:${ie.mediaType};base64,${ie.data}`,alt:ie.name,className:"w-full h-full object-cover"}),l.jsx("button",{onClick:()=>ae(Ve=>Ve.filter((ft,Ct)=>Ct!==Ie)),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:ie.name})]},Ie))})]}),(ce==null?void 0:ce.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:[ce.roleName," is waiting for your response"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ie;return(ie=Fe.current)==null?void 0:ie.click()},disabled:Q,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:Y,onChange:ie=>$(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),Et())},onPaste:mt,placeholder:"Type your response...",disabled:Q,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:Et,disabled:Q||!Y.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:Q?"...":"Reply"})]})]}),ce&&(ce.status==="done"||ce.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 ",ce.roleName]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>{var ie;return(ie=Fe.current)==null?void 0:ie.click()},disabled:Q,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:Y,onChange:ie=>$(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),Et())},onPaste:mt,placeholder:"Send a follow-up directive...",disabled:Q,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:Et,disabled:Q||!Y.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:Q?"...":"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:Jt,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:!N&&F<0?"#B71C1C":"var(--terminal-inline-bg)",color:!N&&F<0?"#fff":"var(--terminal-text-secondary)",border:"1px solid",borderColor:!N&&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((ie,Ie)=>l.jsxs("button",{onClick:()=>{q(Ie),A(null),V(!1),R.reset()},className:"text-left p-2 rounded-lg cursor-pointer transition-colors",style:{background:F===Ie&&!N?"var(--terminal-bg)":"transparent",border:F===Ie&&!N?"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:[ie.directive.slice(0,40),ie.directive.length>40?"...":""]})]}),l.jsxs("div",{className:"text-[9px] text-[var(--terminal-text-muted)] mt-0.5 pl-3.5",children:[ie.rootDispatches.length," role",ie.rootDispatches.length!==1?"s":""]})]},ie.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(ie=>l.jsx(BB,{wave:ie,active:(N==null?void 0:N.id)===ie.id,onLoad:()=>vn(ie.id)},ie.id))})]}),G&&l.jsxs("button",{onClick:k,disabled:!k,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:G.dirty?"var(--idle-amber)":"#2E7D32"}}),l.jsx("span",{className:"text-[10px] font-mono text-[var(--terminal-text-muted)] truncate",children:G.branch}),G.dirty&&l.jsxs("span",{className:"text-[9px] ml-auto shrink-0",style:{color:"var(--idle-amber)"},children:[G.count," unsaved"]}),!G.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:An}):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:gn},onClick:c}),l.jsxs("div",{className:"fixed top-0 bottom-0 z-50 flex flex-col",style:{right:gn,width:mn,background:"var(--terminal-bg)",borderLeft:"1px solid var(--terminal-border)",transition:Zn?"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:Jn}),An]})]})}function zB(e,t,r){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 r){const d=i.get(c.roleId);if(d){const f=g2(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:r}){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:r,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 O0(e){return $B[e]??{skinColor:"#B0BEC5",hairColor:"#78909C",shirtColor:"#607D8B",pantsColor:"#455A64",shoeColor:"#37474F"}}const M3=["#FDEBD0","#F5CBA7","#D4A07A","#C68642","#8D5524","#5C3A1E","#F3D1C7","#E8BEAC","#B07D62","#704214"],F3=["#1A0A00","#2C1810","#4E342E","#6D4C41","#8D6E63","#D4A574","#F5E6CA","#FFD700","#B71C1C","#AD1457","#4A148C","#1A237E","#004D40","#1A1A1A","#78909C","#E0E0E0"],R3=["#1565C0","#E65100","#2E7D32","#4A148C","#AD1457","#00695C","#D32F2F","#F57F17","#1B5E20","#283593","#4E342E","#37474F","#880E4F","#00838F","#6A1B9A","#FF6F00"],z3=["#37474F","#1A237E","#3E2723","#263238","#1B5E20","#455A64","#212121","#4E342E","#0D47A1","#311B92"],B3=["#212121","#1A1A1A","#37474F","#4E342E","#7B1FA2","#D32F2F","#1565C0","#F57F17","#2E7D32","#FFFFFF"],zs={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:r}){return l.jsx("button",{onClick:r,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 Tc({label:e,presets:t,value:r,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:r}})]}),l.jsx("div",{className:"customize-swatches",children:t.map(a=>l.jsx(OB,{color:a,selected:a===r,onClick:()=>i(a)},a))})]})}function zp({label:e,items:t,value:r,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===r,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===r?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 Bp({label:e,active:t,onClick:r}){return l.jsx("button",{onClick:r,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 da(e){return e[Math.floor(Math.random()*e.length)]}function to(e){var a,o,c;const t=d0().filter(d=>!e||E5(d.id,e)),r=f0().filter(d=>!e||A5(d.id,e)),i=h0().filter(d=>!e||_5(d.id,e));return{skinColor:da(M3),hairColor:da(F3),shirtColor:da(R3),pantsColor:da(z3),shoeColor:da(B3),hairStyle:(a=da(t))==null?void 0:a.id,outfitStyle:(o=da(r))==null?void 0:o.id,accessory:(c=da(i))==null?void 0:c.id}}function $3({roleId:e,appearance:t,onChange:r,onRandomize:i,onReset:a,label:o,roleLevel:c,coinBalance:d,purchased:m,onPurchase:f}){const[x,p]=S.useState("look"),y=S.useCallback((T,F)=>{r({...t,[T]:F})},[t,r]),g=S.useRef(null),k=S.useCallback(T=>{var V;const F=(V=T.target.files)==null?void 0:V[0];if(!F)return;const q=new Image;q.onload=()=>{const L=O8(q);r({...L,hairStyle:t.hairStyle,outfitStyle:t.outfitStyle,accessory:t.accessory}),URL.revokeObjectURL(q.src)},q.src=URL.createObjectURL(F),T.target.value=""},[t.hairStyle,t.outfitStyle,t.accessory,r]),w=d0(),C=f0(),j=h0(),E=c!==void 0?w.filter(T=>E5(T.id,c)).length:w.length,N=c!==void 0?C.filter(T=>A5(T.id,c)).length:C.length,A=c!==void 0?j.filter(T=>_5(T.id,c)).length:j.length,z=(T,F)=>c!==void 0?{roleLevel:c,getLockLevel:T,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(wa,{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 T;return(T=g.current)==null?void 0:T.click()},style:{fontSize:9,opacity:.7},children:"PHOTO"}),l.jsx("input",{ref:g,type:"file",accept:"image/*",onChange:k,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(Bp,{label:"LOOK",active:x==="look",onClick:()=>p("look")}),l.jsx(Bp,{label:"OUTFIT",active:x==="outfit",onClick:()=>p("outfit")}),l.jsx(Bp,{label:"ACCESSORY",active:x==="accessory",onClick:()=>p("accessory")})]}),x==="look"&&l.jsxs(l.Fragment,{children:[l.jsx(Tc,{label:"SKIN",presets:M3,value:t.skinColor,onChange:T=>y("skinColor",T)}),l.jsx(Tc,{label:"HAIR COLOR",presets:F3,value:t.hairColor,onChange:T=>y("hairColor",T)}),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,"/",w.length," unlocked"]})]}),l.jsx(zp,{label:"HAIR STYLE",items:w,value:t.hairStyle,onChange:T=>y("hairStyle",T),lockInfo:z(j5,N8)})]}),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:[N,"/",C.length," unlocked"]})]}),l.jsx(zp,{label:"STYLE",items:C,value:t.outfitStyle,onChange:T=>y("outfitStyle",T),lockInfo:z(N5,D8)}),l.jsx(Tc,{label:"TOP",presets:R3,value:t.shirtColor,onChange:T=>y("shirtColor",T)}),l.jsx(Tc,{label:"PANTS",presets:z3,value:t.pantsColor,onChange:T=>y("pantsColor",T)}),l.jsx(Tc,{label:"SHOES",presets:B3,value:t.shoeColor,onChange:T=>y("shoeColor",T)})]}),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,"/",j.length," unlocked"]})]}),l.jsx(zp,{label:"ACCESSORY",items:j,value:t.accessory,onChange:T=>y("accessory",T),lockInfo:z(D5,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 Bx(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,24)}function $p(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 ma=null;async function HB(){if(ma)return ma;try{const r=await Se.getPreferences();if(r.instanceId)return ma=r.instanceId,localStorage.setItem("tycono_instance_id",ma),ma}catch{}const e="tycono_instance_id";let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),ma=t,t}const Dc=4;function UB(e,t,r){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=Bx(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":r.has(c)&&(x="Duplicate ID in batch"),r.add(c),{name:o,id:c,level:m,reportsTo:f,error:x}}function qB({existingRoles:e,onClose:t,onHire:r,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,k]=S.useState(""),[w,C]=S.useState(null),[j,E]=S.useState(!1),[N,A]=S.useState(""),[z,T]=S.useState("browse"),[F,q]=S.useState(""),[V,L]=S.useState(""),[_,O]=S.useState("ceo"),[P,R]=S.useState(null),[H,B]=S.useState(1),[Z,G]=S.useState(""),[K,M]=S.useState(""),[U,Y]=S.useState(!1),[$,Q]=S.useState("member"),[ee,J]=S.useState(()=>{const le=e.find(qe=>qe.level==="c-level");return(le==null?void 0:le.id)??"ceo"}),[ae,oe]=S.useState(""),[be,Ee]=S.useState(to),[Ae,Fe]=S.useState(!1),[he,Re]=S.useState(""),[et,We]=S.useState([]),[it,mt]=S.useState(new Set),[Ye,Ze]=S.useState(""),[ut,jt]=S.useState("input"),[ge,ve]=S.useState({done:0,total:0}),Ce=S.useRef(null),ne=S.useRef(null),de=S.useRef(null);S.useEffect(()=>{Se.getSkills().then(le=>We(le.filter(qe=>qe.installed))).catch(()=>{}),HB().then(le=>R(le)).catch(()=>{})},[]),S.useEffect(()=>{var le,qe,ot;o==="single"?(H===1&&((le=Ce.current)==null||le.focus()),H===2&&((qe=ne.current)==null||qe.focus())):o==="bulk"&&ut==="input"&&((ot=de.current)==null||ot.focus())},[H,o,ut]),S.useEffect(()=>{o==="store"&&z==="browse"&&d.length===0&&_e()},[o,z]);const _e=async()=>{x(!0);try{const le=await Rr.getCharacters({sort:p,instanceId:P??void 0});m(le.characters)}catch{A("Failed to load job board")}x(!1)};S.useEffect(()=>{o==="store"&&z==="browse"&&_e()},[p,P]);const ce=S.useMemo(()=>{if(!g.trim())return d;const le=g.toLowerCase();return d.filter(qe=>qe.name.toLowerCase().includes(le)||qe.id.toLowerCase().includes(le)||(qe.tagline??"").toLowerCase().includes(le))},[d,g]),Te=S.useMemo(()=>new Set(e.map(le=>le.id)),[e]),Le=S.useMemo(()=>{const le=Ye.split(`
113
- `),qe=new Set;return le.map(ot=>UB(ot,Te,qe)).filter(ot=>ot!==null)},[Ye,Te]),Xe=Le.length>0&&Le.every(le=>!le.error),Ue=le=>{G(le),U||M(Bx(le))},Pe=Z.trim().length>0&&K.trim().length>0&&!e.some(le=>le.id===K),lt=ae.trim().length>0,tt=async()=>{Fe(!0),Re("");const le=$p($);try{await r({id:K,name:Z.trim(),level:$,reportsTo:ee,persona:ae.trim(),...le,skills:it.size>0?[...it]:void 0},be),t()}catch(qe){Re(qe instanceof Error?qe.message:"Failed to create role"),Fe(!1)}},ze=le=>le===1?Pe:le===2?lt:!0,He=async()=>{Fe(!0),Re(""),ve({done:0,total:Le.length});try{for(let le=0;le<Le.length;le++){const qe=Le[le],ot=$p(qe.level),Jt=to(),je=`${qe.name}. A ${qe.level} role reporting to ${qe.reportsTo}.`;await r({id:qe.id,name:qe.name,level:qe.level,reportsTo:qe.reportsTo,persona:je,...ot},Jt),ve({done:le+1,total:Le.length})}t()}catch(le){Re(le instanceof Error?le.message:"Failed to create roles"),Fe(!1)}},qt=async le=>{E(!0),A("");try{const qe=await Rr.getCharacter(le);C(qe),q(qe.name||""),L(Bx(qe.name||le)),T("review")}catch{A("Failed to load character details")}finally{E(!1)}},Kt=async(le,qe)=>{if(!P)return;const ot=d.find(je=>je.id===le);if(!ot)return;const Jt=ot.my_vote===qe?0:qe;try{const je=await Rr.voteCharacter(le,P,Jt);m(St=>St.map(gn=>gn.id===le?{...gn,upvotes:je.upvotes,downvotes:je.downvotes,vote_score:je.upvotes-je.downvotes,my_vote:Jt===0?null:Jt}:gn))}catch{}},Et=async()=>{if(!w)return;Fe(!0),Re("");const le=w,qe=le.level==="c-level"?"c-level":"member",ot=$p(qe),Jt=le.skills!=null&&typeof le.skills=="object"&&!Array.isArray(le.skills)&&"primary"in le.skills;try{await r({id:V,name:F.trim(),level:qe,reportsTo:_,persona:le.persona||`${F}. Imported from Job Board.`,authority:le.authority||ot.authority,knowledge:ot.knowledge,reports:ot.reports,source:{id:`tycono/${le.id}`,sync:"manual",forked_at:"1.0.0",upstream_version:"1.0.0"},skillContent:Jt?le.skills:void 0},le.appearance?le.appearance:to()),Rr.trackInstall(le.id).catch(()=>{}),t()}catch(je){Re(je instanceof Error?je.message:"Failed to hire"),Fe(!1)}},Xt=async le=>{if(P)try{await Rr.deleteCharacter(le,P),m(qe=>qe.filter(ot=>ot.id!==le))}catch{}},hn=le=>{le.key==="Escape"&&t(),le.key==="Enter"&&(le.metaKey||le.ctrlKey)&&(o==="single"?H<Dc&&ze(H)?B(H+1):H===Dc&&tt():o==="bulk"?ut==="input"&&Xe?jt("review"):ut==="review"&&He():o==="store"&&z==="review"&&Et())},vn=e.some(le=>le.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"),Re("")},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"),Re("")},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"),Re(""),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&&!Z&&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 le=IB[a.roleId];le&&(G(le.name),M(le.id),Y(!0),Q(le.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 ${Dc}`:o==="bulk"?ut==="input"?"Enter roles, one per line":`Review ${Le.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:le=>le.stopPropagation(),children:"Open in browser ↗"})]})]}),o==="single"&&l.jsx("div",{className:"flex gap-1 px-5 pt-4",children:Array.from({length:Dc},(le,qe)=>qe+1).map(le=>l.jsx("div",{className:"flex-1 h-1 rounded-full transition-colors",style:{background:le<=H?"#2E7D32":"rgba(255,255,255,0.1)"}},le))}),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:[P?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:[P.slice(0,8),"..."]})]}),l.jsx("button",{onClick:()=>{ma=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:le=>{ma=le,localStorage.setItem("tycono_instance_id",le),R(le)}}),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:le=>{if(le.key==="Enter"){const ot=le.target.value.trim().replace(/^tycono:/,"");ot&&(qt(ot),le.target.value="")}}}),l.jsx("button",{onClick:()=>{const le=document.querySelector('[placeholder="Paste ID (tycono:engineer)"]');if(le){const ot=le.value.trim().replace(/^tycono:/,"");ot&&(qt(ot),le.value="")}},disabled:j,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:j?"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:le=>k(le.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:le=>y(le.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..."}):N?l.jsxs("div",{className:"text-center py-8",children:[l.jsx("div",{className:"text-xs text-red-400 mb-2",children:N}),l.jsx("button",{onClick:_e,className:"text-xs text-green-400 hover:underline cursor-pointer",children:"Retry"})]}):ce.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:ce.map(le=>l.jsx(XB,{char:le,isHired:Te.has(le.id),onSelect:()=>qt(le.id),onVote:qe=>Kt(le.id,qe),onDelete:()=>Xt(le.id),fetching:j,token:P},le.id))})]}),z==="review"&&w&&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:[w.appearance&&l.jsx("div",{className:"flex-shrink-0 rounded-lg overflow-hidden",style:{background:"#0d1117",padding:8},children:l.jsx(wa,{roleId:"store-preview",appearance:w.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:le=>q(le.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:le=>L(le.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(le=>le.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:w.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:le=>O(le.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(le=>l.jsxs("option",{value:le.id,className:"bg-[var(--wall)] text-white",children:[le.name," (",le.id,")"]},le.id))]})]})]})]})]}),w.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:w.persona})]}),w.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 Jt,je;const le=w.skills;if(le&&typeof le=="object"&&!Array.isArray(le)&&"primary"in le){const St=[];return(je=(Jt=le.primary)==null?void 0:Jt.frontmatter)!=null&&je.name&&St.push(le.primary.frontmatter.name),le.shared&&le.shared.forEach(gn=>{var mn;return St.push(((mn=gn.frontmatter)==null?void 0:mn.name)||gn.id)}),St.map(gn=>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:gn},gn))}return(Array.isArray(le)?le:[]).map((St,gn)=>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 St=="string"?St:St.name},gn))})()})]})]}),he&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:he})]})]}):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:Ce,value:Z,onChange:le=>Ue(le.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:le=>{M(le.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),Y(!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 ${vn?"border-red-400":"border-white/10 focus:border-white/25"}`}),vn&&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(le=>l.jsx("button",{onClick:()=>{if(Q(le.value),le.value==="c-level")J("ceo");else{const qe=e.find(ot=>ot.level==="c-level");J((qe==null?void 0:qe.id)??"ceo")}},className:`flex-1 p-2 text-xs font-semibold rounded-lg border cursor-pointer transition-colors ${$===le.value?"border-green-600 bg-green-900/30 text-green-400":"border-white/10 text-white/50 hover:border-white/20"}`,children:le.label},le.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"}),$==="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:le=>J(le.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(le=>le.level==="c-level").map(le=>l.jsxs("option",{value:le.id,className:"bg-[var(--wall)] text-white",children:[le.name," (",le.id,")"]},le.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:ne,value:ae,onChange:le=>oe(le.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"})]}),et.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:et.map(le=>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(le.id),onChange:()=>mt(qe=>{const ot=new Set(qe);return ot.has(le.id)?ot.delete(le.id):ot.add(le.id),ot}),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:le.name}),l.jsx("div",{className:"text-[10px] text-white/40 truncate",children:le.description})]})]},le.id))})]})]}),H===3&&l.jsx("div",{className:"customize-body",style:{padding:0},children:l.jsx($3,{roleId:"default",appearance:be,onChange:Ee,onRandomize:()=>Ee(to()),onReset:()=>Ee(to()),label:l.jsxs("span",{children:[K||"new-role"," — ",Z||"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(wa,{roleId:"default",appearance:be,scale:4})}),l.jsxs("div",{className:"flex-1 space-y-2.5",children:[l.jsx(_c,{label:"Name",value:Z}),l.jsx(_c,{label:"ID",value:K,mono:!0}),l.jsx(_c,{label:"Level",value:$}),l.jsx(_c,{label:"Reports To",value:ee}),it.size>0&&l.jsx(_c,{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:ae})]})]}),he&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:he})]})]}):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:de,value:Ye,onChange:le=>Ze(le.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."})]}),Le.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 (",Le.length," role",Le.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:Le.map((le,qe)=>l.jsxs("tr",{className:`border-b border-white/5 ${le.error?"bg-red-900/10":""}`,children:[l.jsx("td",{className:"p-2 text-white/80",children:le.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:le.id}),l.jsx("td",{className:"p-2 text-white/60",children:le.level}),l.jsx("td",{className:"p-2 text-white/60",children:le.reportsTo}),le.error&&l.jsx("td",{className:"p-2 text-red-400 text-[10px]",children:le.error})]},qe))})]})})]})]}),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 — ",Le.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:Le.map((le,qe)=>l.jsxs("tr",{className:"border-b border-white/5",children:[l.jsx("td",{className:"p-2 text-white/30",children:qe+1}),l.jsx("td",{className:"p-2 text-white/80",children:le.name}),l.jsx("td",{className:"p-2 text-white/60 font-mono",children:le.id}),l.jsx("td",{className:"p-2 text-white/60",children:le.level}),l.jsx("td",{className:"p-2 text-white/60",children:le.reportsTo})]},qe))})]})}),Ae&&ge.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:[ge.done,"/",ge.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:`${ge.done/ge.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."}),he&&l.jsx("div",{className:"text-xs text-red-400 bg-red-900/20 p-2 rounded-lg border border-red-800/30",children:he})]})]})}),l.jsxs("div",{className:"flex justify-between px-5 pb-5",children:[l.jsxs("div",{children:[o==="single"&&H>1&&l.jsx("button",{onClick:()=>B(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:()=>jt("input"),disabled:Ae,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:()=>{T("browse"),C(null),Re("")},disabled:Ae,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<Dc?l.jsx("button",{onClick:()=>B(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:tt,disabled:Ae,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:Ae?"Hiring...":"HIRE"}):o==="bulk"?ut==="input"?l.jsxs("button",{onClick:()=>jt("review"),disabled:!Xe,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 (",Le.length,")"]}):l.jsx("button",{onClick:He,disabled:Ae,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:Ae?`Hiring ${ge.done}/${ge.total}...`:`HIRE ALL (${Le.length})`}):z==="review"?l.jsx("button",{onClick:Et,disabled:Ae||!F.trim()||!V.trim()||e.some(le=>le.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:Ae?"Hiring...":"HIRE"}):null]})]})]})]})}function YB({onLogin:e}){const[t,r]=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=>{r(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 XB({char:e,isHired:t,onSelect:r,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:r,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:r,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 _c({label:e,value:t,mono:r}){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 ${r?"font-mono":""}`,children:t})]})}function PB({roleId:e,roleName:t,onClose:r,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:r}),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:r,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 VB={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function WB({roleId:e,title:t,roleColor:r,active:i,isWave:a,isWaveStreaming:o,onClick:c,onClose:d,"data-session-id":m}){const f=a?"#F59E0B":r;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:VB[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 GB({content:e,streaming:t}){let r=e;return t&&(e.match(/```/g)??[]).length%2!==0&&(r+="\n```"),l.jsx("div",{className:"terminal-markdown",children:l.jsx(s0,{remarkPlugins:[c0],components:{code:KB,table:({children:i})=>l.jsx("div",{className:"overflow-x-auto my-2",children:l.jsx("table",{className:"terminal-table",children:i})})},children:r})})}function KB({className:e,children:t,...r}){const i=/language-(\w+)/.exec(e??"");return i||typeof t=="string"&&t.includes(`
118
- `)?l.jsx(QB,{language:i==null?void 0:i[1],children:t}):l.jsx("code",{className:"terminal-inline-code",...r,children:t})}function QB({children:e,language:t}){const[r,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:r?"Copied!":"Copy"}),l.jsx("pre",{className:"overflow-x-auto p-3 text-xs leading-relaxed",children:l.jsx("code",{children:a})})]})}const ZB={cto:"🏗️",cbo:"📊",pm:"📋",engineer:"⚙️",designer:"🎨",qa:"🔍"};function JB({attachments:e}){const[t,r]=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:()=>r(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:()=>r(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:()=>r(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 Op(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 e$(e){const t=[];let r="";for(const i of e)if(i.type==="thinking")i.text&&(r=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:Op(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=Op(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?Op(i.toolName,i.toolInput):void 0})}if(r){const i=t.filter(a=>a.type==="thinking");i.length>0&&(i[i.length-1].text=r)}return t}function t$({event:e,isStreaming:t}){var a,o,c;const[r,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(!r),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:r?"▾":"▸"})]}),(t||r)&&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(!r),children:r?"▾":"▸"}),r&&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 n$({events:e,isStreaming:t}){const[r,i]=S.useState(!1);if(e.length===0)return null;const a=e$(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=!r;return l.jsxs("div",{className:"stream-activity-log",children:[l.jsxs("div",{className:"stream-activity-header",onClick:()=>i(!r),children:[t&&l.jsx("span",{className:"stream-activity-pulse"}),l.jsxs("span",{className:"stream-activity-summary",children:[r?"▸":"▾"," ",x,t?"...":""]})]}),p&&l.jsx("div",{className:"stream-activity-events",children:a.map((y,g)=>l.jsx(t$,{event:y,isStreaming:t&&g===a.length-1},g))})]})}function r$(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 i$({message:e,roleId:t,roleColor:r}){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(JB,{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?r$(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:`${r}33`},children:ZB[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(n$,{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 ${r}`,background:"var(--terminal-surface)"},children:[e.content?l.jsx(GB,{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 O3({messages:e,roleId:t,roleColor:r}){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(i$,{message:o,roleId:t,roleColor:r},o.id)),l.jsx("div",{ref:i})]})}const s$=5*1024*1024,a$=["image/png","image/jpeg","image/gif","image/webp"];function L0({mode:e,onModeChange:t,onSend:r,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),k=S.useRef(null),w=S.useRef(null),C=S.useRef(!1);S.useEffect(()=>{const _=k.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 j=S.useCallback(async _=>a$.includes(_.type)?_.size>s$?(g(`File too large: ${(_.size/1024/1024).toFixed(1)}MB. Max 5MB.`),null):new Promise(O=>{const P=new FileReader;P.onload=()=>{const H=P.result.split(",")[1];O({type:"image",data:H,name:_.name,mediaType:_.type})},P.onerror=()=>{g("Failed to read file"),O(null)},P.readAsDataURL(_)}):(g(`Unsupported format: ${_.type}. Use PNG, JPG, GIF, or WebP.`),null),[]),E=S.useCallback(async _=>{const O=Array.from(_),P=[];for(const R of O){const H=await j(R);H&&P.push(H)}P.length>0&&f(R=>[...R,...P])},[j]),N=S.useCallback(_=>{_.preventDefault(),_.stopPropagation(),p(!0)},[]),A=S.useCallback(_=>{_.preventDefault(),_.stopPropagation(),p(!1)},[]),z=S.useCallback(_=>{_.preventDefault(),_.stopPropagation(),p(!1);const O=_.dataTransfer.files;O.length>0&&E(O)},[E]),T=S.useCallback(_=>{const O=_.clipboardData.items,P=[];for(let R=0;R<O.length;R++){const H=O[R];if(H.type.startsWith("image/")){const B=H.getAsFile();B&&P.push(B)}}P.length>0&&(_.preventDefault(),E(P))},[E]),F=S.useCallback(_=>{const O=_.target.files;O&&O.length>0&&E(O),_.target.value=""},[E]),q=S.useCallback(_=>{f(O=>O.filter((P,R)=>R!==_))},[]),V=()=>{const _=c.trim();!_&&m.length===0||i||(r(_,m.length>0?m:void 0),d(""),f([]))},L=_=>{if(_.key==="Enter"&&!_.shiftKey){if(C.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:N,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((_,O)=>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(O),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})]},O))}),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(_=w.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:w,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,onChange:F,className:"hidden"}),l.jsx("textarea",{ref:k,value:c,onChange:_=>d(_.target.value),onKeyDown:L,onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},onPaste:T,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 l$={ceo:"#FFB300",cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},L3={ceo:"CEO (You)",cto:"CTO",cbo:"CBO",pm:"PM",engineer:"Engineer",designer:"Designer",qa:"QA","data-analyst":"Data Analyst"};function Iw(e){return new Date(e).toLocaleTimeString("ko-KR",{hour:"2-digit",minute:"2-digit"})}function o$({msg:e}){const t=l$[e.roleId]??"#888",r=L3[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:Iw(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:Iw(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:r}),l.jsx("span",{className:"text-xs text-[var(--terminal-text-secondary)]",children:e.text})]})]})}function c$({channel:e,allRoles:t,onUpdateMembers:r,onUpdateTopic:i,onSendMessage:a}){const o=S.useRef(null),c=S.useRef(null),[d,m]=S.useState("");S.useEffect(()=>{var N;const j=c.current;if(!j)return;j.scrollHeight-j.scrollTop-j.clientHeight<80&&((N=o.current)==null||N.scrollIntoView({behavior:"smooth"}))},[e.messages.length]);const[f,x]=S.useState(!1),[p,y]=S.useState(!1),[g,k]=S.useState(""),w=a&&e.id!=="general",C=()=>{!d.trim()||!a||(a(e.id,d.trim()),m(""),setTimeout(()=>{var j;return(j=o.current)==null?void 0:j.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(j=>L3[j]??j).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&&r&&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:j=>k(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(i(e.id,g.trim()),y(!1)),j.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:()=>{k(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&&r&&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(j=>{const E=e.members.includes(j.id);return l.jsxs("button",{className:`text-[10px] px-2 py-1 rounded ${E?"bg-white/15 text-[var(--terminal-text)]":"bg-white/5 text-[var(--terminal-text-muted)]"}`,onClick:()=>{const N=E?e.members.filter(A=>A!==j.id):[...e.members,j.id];r(e.id,N)},children:[E?"✓ ":"",j.name]},j.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(j=>l.jsx(o$,{msg:j},j.id)),l.jsx("div",{ref:o})]}),w&&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:j=>m(j.target.value),onKeyDown:j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),C())},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 Lp={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C"},u$=400,d$=800;function Hw({sessions:e,activeSessionId:t,roles:r,streamingSessionId:i,width:a,onWidthChange:o,onSwitchSession:c,onCloseSession:d,onCreateSession:m,onClearEmpty:f,onCloseAll:x,onSendMessage:p,onModeChange:y,onStopSession:g,onCloseTerminal:k,onMaximize:w,chatChannels:C,activeChatChannelId:j,onSwitchChatChannel:E,onCreateChatChannel:N,onDeleteChatChannel:A,onUpdateChatMembers:z,onUpdateChatTopic:T,onSendChatMessage:F,unreadChannels:q}){const[V,L]=S.useState(!1),[_,O]=S.useState(!1),[P,R]=S.useState(!1),[H,B]=S.useState(""),Z=j!=null,G=C==null?void 0:C.find(he=>he.id===j),[K,M]=S.useState(!1),[U,Y]=S.useState(!1),[$,Q]=S.useState(!1),ee=S.useRef(0),J=S.useRef(0),ae=S.useRef(null),oe=e.find(he=>he.id===t),be=i===t,Ee=e.filter(he=>he.messages.length===0).length,Ae=S.useCallback(()=>{const he=ae.current;he&&(Y(he.scrollLeft>0),Q(he.scrollLeft+he.clientWidth<he.scrollWidth-1))},[]);S.useEffect(()=>{if(!t||!ae.current)return;const he=ae.current.querySelector(`[data-session-id="${t}"]`);he&&he.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),Ae()},[t,e.length,Ae]),S.useEffect(()=>{const he=ae.current;if(!he)return;Ae(),he.addEventListener("scroll",Ae);const Re=new ResizeObserver(Ae);return Re.observe(he),()=>{he.removeEventListener("scroll",Ae),Re.disconnect()}},[Ae]);const Fe=S.useCallback(he=>{he.preventDefault(),ee.current=he.clientX,J.current=a,M(!0);const Re=w,et=()=>{M(!1),document.removeEventListener("mousemove",We),document.removeEventListener("mouseup",et)},We=it=>{const mt=ee.current-it.clientX,Ye=J.current+mt;if(Ye>=window.innerWidth*.6&&Re){et(),Re();return}const Ze=Math.min(d$,Math.max(u$,Ye));o==null||o(Ze)};document.addEventListener("mousemove",We),document.addEventListener("mouseup",et)},[a,o,w]);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:Fe}),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:ae,className:"flex items-center overflow-x-auto terminal-tab-scroll gap-px px-1 py-1",children:[C==null?void 0:C.map(he=>l.jsxs("button",{onClick:()=>{E==null||E(he.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 ${j===he.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:j===he.id?{borderTop:"2px solid #4CAF50"}:void 0,children:[l.jsx("span",{className:"text-[10px]",children:"💬"}),l.jsx("span",{className:"truncate",children:he.name}),(q==null?void 0:q.has(he.id))&&j!==he.id&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 shrink-0"}),!he.isDefault&&l.jsx("span",{onClick:Re=>{Re.stopPropagation(),A==null||A(he.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:"×"})]},he.id)),C&&C.length>0&&e.length>0&&l.jsx("div",{className:"w-px h-4 bg-[var(--terminal-border)] shrink-0 mx-1"}),e.map(he=>l.jsx(WB,{roleId:he.roleId,title:he.title,roleColor:Lp[he.roleId]??"#666",active:!Z&&he.id===t,isWave:he.source==="wave",isWaveStreaming:he.source==="wave"&&he.status==="active",onClick:()=>{E==null||E(null),c(he.id)},onClose:Re=>{Re.stopPropagation(),d(he.id)},"data-session-id":he.id},he.id))]}),$&&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),O(!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:[N&&l.jsxs(l.Fragment,{children:[P?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:he=>B(he.target.value),onKeyDown:he=>{he.key==="Enter"&&H.trim()&&(N(H.trim(),[]),B(""),R(!1),L(!1)),he.key==="Escape"&&(R(!1),B(""))},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"})]}),r.map(he=>l.jsxs("button",{onClick:()=>{m(he.id),E==null||E(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:Lp[he.id]??"#666"}}),he.id.toUpperCase()," — ",he.name]},he.id))]})]}),l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("button",{onClick:()=>{O(!_),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":""]}),Ee>0&&f&&l.jsxs("button",{onClick:()=>{f(),O(!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 (",Ee,")"]}),e.length>0&&x&&l.jsx("button",{onClick:()=>{x(),O(!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"})]})]}),w&&l.jsx("button",{onClick:w,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:k,className:"px-2 py-1 text-[var(--terminal-text-muted)] hover:text-[var(--terminal-text-secondary)] text-sm cursor-pointer shrink-0",children:"×"})]}),Z&&G?l.jsx(c$,{channel:G,allRoles:r,onUpdateMembers:z,onUpdateTopic:T,onSendMessage:F}):oe?l.jsxs(l.Fragment,{children:[l.jsx(O3,{messages:oe.messages,roleId:oe.roleId,roleColor:Lp[oe.roleId]??"#666"}),l.jsx(L0,{mode:oe.mode,onModeChange:he=>y(oe.id,he),onSend:(he,Re)=>p(oe.id,he,oe.mode,Re),disabled:be,disabledReason:be?`${oe.roleId.toUpperCase()} is responding...`:void 0,onStop:be&&g?()=>g(oe.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 f$(){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 C,j,E,N,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 k=6e4,w=setInterval(()=>{Date.now()-g>k&&(clearInterval(w),m.abort(),c.onError("Connection stale — no data received for 60s"))},1e4);try{for(;;){const{done:z,value:T}=await x.read();if(z)break;g=Date.now(),y+=p.decode(T,{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&&((C=c.onThinking)==null||C.call(c,_.text));break;case"output":_.text&&c.onText(_.text);break;case"tool":(j=c.onToolUse)==null||j.call(c,_.name,_.input);break;case"dispatch":(E=c.onDispatch)==null||E.call(c,_.roleId,_.task);break;case"dispatch:progress":(N=c.onDispatchProgress)==null||N.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(w)}}).catch(f=>{f.name!=="AbortError"&&c.onError(f.message)}),{abort:t}},[t]),abort:t}}const I3="tycono-appearances",$x="tycono-theme";function Uw(){try{const e=localStorage.getItem(I3);return e?JSON.parse(e):{}}catch{return{}}}function Ip(e){localStorage.setItem(I3,JSON.stringify(e))}function qw(){try{const e=localStorage.getItem($x);if(e&&e in zs)return e}catch{}return"default"}const H3=new Set;for(const e of Object.values(zs))for(const t of Object.keys(e.vars))H3.add(t);function h$(e){var i;const t=(i=zs[e])==null?void 0:i.vars;if(!t)return;const r=document.documentElement;for(const a of H3)a in t||r.style.removeProperty(a);for(const[a,o]of Object.entries(t))r.style.setProperty(a,o)}const Hp={mode:"auto",intervalSec:18,dailyBudgetUsd:1},Ox="tycono-speech-settings",Up="tycono-language";function m$(){try{const e=localStorage.getItem(Ox);return e?{...Hp,...JSON.parse(e)}:Hp}catch{return Hp}}function p$(){const[e,t]=S.useState(Uw),[r,i]=S.useState(qw),[a,o]=S.useState(m$),[c,d]=S.useState(()=>{try{return localStorage.getItem(Up)??"auto"}catch{return"auto"}}),[m,f]=S.useState(new Set),x=S.useRef(!1);S.useEffect(()=>{x.current||(x.current=!0,Se.getPreferences().then(E=>{const N=Object.keys(E.appearances??{}).length>0||E.theme!=="default";if(E.speech&&(o(A=>({...A,...E.speech})),localStorage.setItem(Ox,JSON.stringify(E.speech))),E.language&&(d(E.language),localStorage.setItem(Up,E.language)),E.purchasedItems&&f(new Set(E.purchasedItems)),N){const A=E.appearances;t(A),Ip(A),E.theme&&E.theme in zs&&(i(E.theme),localStorage.setItem($x,E.theme))}else{const A=Uw(),z=qw();(Object.keys(A).length>0||z!=="default")&&Se.updatePreferences({appearances:A,theme:z}).catch(()=>{})}}).catch(()=>{}))},[]),S.useEffect(()=>{h$(r)},[r]);const p=S.useCallback(E=>e[E]??O0(E),[e]),y=S.useCallback((E,N)=>{t(A=>{const z={...A,[E]:N};return Ip(z),Se.updatePreferences({appearances:z}).catch(()=>{}),z})},[]),g=S.useCallback(E=>{t(N=>{const A={...N};return delete A[E],Ip(A),Se.updatePreferences({appearances:A}).catch(()=>{}),A})},[]),k=S.useCallback(E=>{i(E),localStorage.setItem($x,E),Se.updatePreferences({theme:E}).catch(()=>{})},[]),w=S.useCallback(E=>{o(N=>{const A={...N,...E};return localStorage.setItem(Ox,JSON.stringify(A)),Se.updatePreferences({speech:A}).catch(()=>{}),A})},[]),C=S.useCallback(E=>{d(E),localStorage.setItem(Up,E),Se.updatePreferences({language:E}).catch(()=>{})},[]),j=S.useCallback(E=>{f(N=>{const A=new Set(N);return A.add(E),Se.updatePreferences({purchasedItems:Array.from(A)}).catch(()=>{}),A})},[]);return{appearances:e,getAppearance:p,setAppearance:y,resetAppearance:g,theme:r,setTheme:k,speechSettings:a,setSpeechSettings:w,language:c,setLanguage:C,purchasedItems:m,addPurchasedItem:j}}const x$=3e4,g$=3e5;function y$(){var _;const[e,t]=S.useState("akb"),[r,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),k=S.useRef(e);k.current=e;const w=S.useCallback(async()=>{try{const O=await Se.getSaveStatus(k.current);i(O),O.noGit?o("no-git"):o(P=>P==="saving"?P:O.dirty?"dirty":"synced")}catch{o("error")}},[]),C=S.useCallback(async()=>{try{const O=await Se.getSyncStatus(k.current);f({ahead:O.ahead,behind:O.behind,branch:O.branch,hasRemote:O.hasRemote})}catch{}},[]),j=S.useCallback(()=>{y.current&&clearInterval(y.current),w(),y.current=setInterval(w,x$),g.current&&clearInterval(g.current),C(),g.current=setInterval(C,g$)},[w,C]);S.useEffect(()=>()=>{y.current&&clearInterval(y.current),g.current&&clearInterval(g.current)},[]);const E=S.useCallback(O=>{t(O),k.current=O,i(null),f(null),d([]),setTimeout(()=>{w(),C()},0)},[w,C]),N=S.useCallback(async O=>{o("saving");try{const P=await Se.save(O,k.current);return await w(),P}catch(P){throw o("error"),P}},[w]),A=S.useCallback(async()=>{try{const O=await Se.getSaveHistory(20,k.current);d(O)}catch{}},[]),z=S.useCallback(async O=>{o("saving");try{await Se.restoreSave(O,void 0,k.current),await w()}catch(P){throw o("error"),P}},[w]),T=S.useCallback(async()=>{p(!0);try{const O=await Se.pull(k.current);return await w(),await C(),O}catch(O){throw O}finally{p(!1)}},[w,C]),F=S.useCallback(async()=>{try{await Se.initGit(k.current),await w()}catch{o("error")}},[w]),q=r?r.modified.length+r.untracked.length:0,V=((_=r==null?void 0:r.lastCommit)==null?void 0:_.date)??null,L=S.useCallback(async()=>{j()},[j]);return{state:a,dirtyCount:q,lastSaved:V,status:r,save:N,history:c,loadHistory:A,restore:z,refresh:L,initGit:F,repo:e,setRepo:E,syncInfo:m,fetchSyncStatus:C,pull:T,pulling:x}}const Yw={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."]},b$=[{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."}]}],v$=18e3,Pw=6e3,w$=2500,k$=30*6e4,U3="tycono:relationships";function S$(){try{const e=localStorage.getItem(U3);return e?JSON.parse(e):[]}catch{return[]}}function C$(e){localStorage.setItem(U3,JSON.stringify(e))}function qd(e,t,r){const[i,a]=t<r?[t,r]:[r,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 Yd(e){return Math.min(100,e.dispatches*5+e.wavesTogether*10+e.conversations*2)}function Xd(e){return e[Math.floor(Math.random()*e.length)]}function j$(e,t,r){const i=r.find(d=>d.id===e),a=r.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 E$(e,t){return e.relation==="any"?!0:e.relation===t}function N$({roles:e,roleStatuses:t,activeExecs:r,getStandupSpeech:i}){const[a,o]=S.useState(new Map),[c,d]=S.useState(S$),m=S.useRef({}),f=S.useRef(null),x=S.useRef(e),p=S.useRef(t),y=S.useRef(r),g=S.useRef(i),k=S.useRef(c);x.current=e,p.current=t,y.current=r,g.current=i,k.current=c,S.useEffect(()=>{const A=Date.now();for(const[z,T]of Object.entries(t))Qn(T)&&(m.current[z]=A)},[t]),S.useEffect(()=>{C$(c)},[c]);const w=S.useCallback(A=>{const z=p.current[A],T=y.current.find(_=>_.roleId===A);if(Qn(z)&&(T!=null&&T.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>k$&&Math.random()<.5){const _=Xw[A]??Xw.engineer;return{text:Xd(_),type:"guilt",ts:q}}const L=Yw[A]??Yw.engineer;return{text:Xd(L),type:"personality",ts:q}},[]),C=S.useCallback(A=>{if(f.current)return!1;const z=A.filter(Z=>!Qn(p.current[Z.id]));if(z.length<2)return!1;const T=[...z].sort(()=>Math.random()-.5),F=T[0],q=T[1],V=j$(F.id,q.id,A);if(!V)return!1;const L=qd(k.current,F.id,q.id),_=Yd(L),O=b$.filter(Z=>E$(Z,V)&&_>=Z.minFamiliarity);if(O.length===0)return!1;const P=Xd(O);let R=F.id,H=q.id;P.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:P.id,roleA:R,roleB:H,turnIdx:0,timer:null};const B=Z=>{if(!f.current||Z>=P.turns.length){f.current=null,d(U=>{const Y=[...U],$=qd(Y,R,H);return $.conversations++,$.familiarity=Yd($),$.lastInteraction=new Date().toISOString(),Y}),setTimeout(()=>{o(U=>{const Y=new Map(U);return Y.delete(R),Y.delete(H),Y})},Pw);return}const G=P.turns[Z],K=G.speaker==="A"?R:H,M=G.speaker==="A"?H:R;o(U=>{const Y=new Map(U);if(Y.set(K,{text:G.text,type:"social",partnerId:M,ts:Date.now()}),Z>0){const $=P.turns[Z-1].speaker==="A"?R:H;$!==K&&Y.delete($)}return Y}),f.current.turnIdx=Z,f.current.timer=setTimeout(()=>B(Z+1),w$)};return B(0),!0},[]);S.useEffect(()=>{const A=setInterval(()=>{const z=x.current;if(z.length===0||f.current||Math.random()<.35&&C(z))return;const T=z.filter(V=>!Qn(p.current[V.id]));if(T.length===0)return;const F=Xd(T),q=w(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})},Pw))},v$);return()=>{var z;clearInterval(A),(z=f.current)!=null&&z.timer&&clearTimeout(f.current.timer)}},[w,C]);const j=S.useCallback(A=>{const z=a.get(A);return(z==null?void 0:z.text)??""},[a]),E=S.useCallback((A,z)=>{d(T=>{const F=[...T],q=qd(F,A,z);return q.dispatches++,q.familiarity=Yd(q),q.lastInteraction=new Date().toISOString(),F})},[]),N=S.useCallback(A=>{A.length<2||d(z=>{const T=[...z];for(let F=0;F<A.length;F++)for(let q=F+1;q<A.length;q++){const V=qd(T,A[F],A[q]);V.wavesTogether++,V.familiarity=Yd(V),V.lastInteraction=new Date().toISOString()}return T})},[]);return{speeches:a,getSpeech:j,relationships:c,notifyDispatch:E,notifyWave:N}}const q3="tycono:office-chat";let A$=0;function T$(){return`chat-${Date.now()}-${++A$}`}function qp(){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 D$(){try{const e=localStorage.getItem(q3);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[...qp(),...i]}const r=qp();for(const i of r)t.find(a=>a.id===i.id)||t.unshift(i);return t}}catch{}return qp()}function _$(e){const t=e.map(r=>({...r,messages:r.messages.slice(-200)}));localStorage.setItem(q3,JSON.stringify(t))}function M$(){const[e,t]=S.useState(D$),[r,i]=S.useState(null),[a,o]=S.useState(new Set);S.useEffect(()=>{_$(e)},[e]);const c=S.useCallback(g=>{i(g),g&&o(k=>{const w=new Set(k);return w.delete(g),w})},[]),d=S.useCallback(g=>{const k={...g,id:T$()};t(w=>{const C=w.map(j=>j.id==="general"?g.type==="dispatch"?{...j,messages:[...j.messages,k].slice(-200)}:j:g.channelId?j.id===g.channelId?{...j,messages:[...j.messages,k].slice(-200)}:j:j.members.length>0&&j.members.includes(g.roleId)?{...j,messages:[...j.messages,k].slice(-200)}:j);return o(j=>{const E=new Set(j);for(const N of C){const A=w.find(z=>z.id===N.id);A&&N.messages.length>A.messages.length&&E.add(N.id)}return E}),C})},[]),m=S.useCallback((g,k,w)=>{const C=`ch-${Date.now()}`,j={id:C,name:g.startsWith("#")?g:`#${g}`,members:k,isDefault:!1,messages:[],topic:w};t(E=>[...E,j]),i(C)},[]),f=S.useCallback(g=>{t(k=>k.filter(w=>w.id!==g||w.isDefault)),i(k=>k===g?"general":k)},[]),x=S.useCallback((g,k)=>{t(w=>w.map(C=>C.id===g&&!C.isDefault?{...C,members:k}:C))},[]),p=S.useCallback((g,k)=>{t(w=>w.map(C=>C.id===g&&!C.isDefault?{...C,topic:k||void 0}:C))},[]),y=S.useCallback(g=>{t(k=>k.map(w=>{if(w.id==="watercooler"){const C=g.filter(j=>j.level!=="c-level").map(j=>j.id);if(w.members.length!==C.length||!C.every(j=>w.members.includes(j)))return{...w,members:C}}return w}))},[]);return{channels:e,activeChannelId:r,setActiveChannelId:c,pushMessage:d,createChannel:m,deleteChannel:f,updateMembers:x,updateTopic:p,unreadChannels:a,syncDefaultMembers:y}}const F$=45e3,Vw=5e3,R$=4,z$=20;function B$({roles:e,roleStatuses:t,activeExecs:r,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)??F$/1e3)*1e3,y=S.useRef(e),g=S.useRef(t),k=S.useRef(r),w=S.useRef(i),C=S.useRef(a),j=S.useRef(o),E=S.useRef(0),N=S.useRef(!1);y.current=e,g.current=t,k.current=r,w.current=i,C.current=a,j.current=o;const A=S.useCallback(async(F,q)=>{if(N.current)return!1;N.current=!0;try{if(!y.current.find(B=>B.id===F))return!1;const L=q.messages.slice(-z$).map(B=>({roleId:B.roleId,text:B.text,ts:B.ts})),_=y.current.filter(B=>q.members.includes(B.id)),O=C.current.filter(B=>B.roleA===F||B.roleB===F).map(B=>({partnerId:B.roleA===F?B.roleB:B.roleA,familiarity:B.familiarity})),P=k.current.find(B=>B.roleId===F),R=P?{currentTask:P.task,taskProgress:null}:{currentTask:null,taskProgress:null},H=await Se.chatInChannel({channelId:q.name.replace("#",""),channelTopic:q.topic,roleId:F,history:L,members:_.map(B=>({id:B.id,name:B.name,level:B.level})),relationships:O,workContext:R});return H.message?(j.current({ts:Date.now(),roleId:F,text:H.message,type:"chat",channelId:q.id}),!0):!1}catch{return!1}finally{N.current=!1}},[]),z=S.useCallback(async(F,q)=>{if(E.current>=R$){E.current=0;return}const V=F.members.filter(P=>P!==q&&!Qn(g.current[P]));if(V.length===0){E.current=0;return}const L=V[Math.floor(Math.random()*V.length)];if(Math.random()>.7){E.current=0;return}const _=E.current*2e3,O=Math.random()*5e3;setTimeout(async()=>{E.current++;const P=w.current.find(H=>H.id===F.id);if(!P)return;if(await A(L,P)){const H=.6-E.current*.1;Math.random()<H?z(P,L):E.current=0}else E.current=0},Vw+_+O)},[A]);return S.useEffect(()=>{if(!x)return;const F=setInterval(async()=>{const q=y.current;if(q.length===0||N.current)return;const V=q.filter(R=>!Qn(g.current[R.id]));if(V.length===0)return;const L=V[Math.floor(Math.random()*V.length)],_=w.current.filter(R=>R.members.length===0?!0:R.members.includes(L.id));if(_.length===0)return;const O=_[Math.floor(Math.random()*_.length)];E.current=0,await A(L.id,O)&&z(O,L.id)},p);return()=>clearInterval(F)},[x,p,A,z]),{triggerCeoReaction:S.useCallback(F=>{if(!x)return;const q=w.current.find(V=>V.id===F);q&&(E.current=0,setTimeout(()=>{z(q,"ceo")},Vw))},[x,z])}}const Y3=[[1,8],[3,5],[8,1],[5,3]],$$=[[1,4],[2,3],[4,1],[3,2]];function Pd(e){const t=e===1||e===3?-1:0,r=Y3[e],i=e<2?[0,1]:[1,0],a=t;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:r[0],y:13,w:3,h:4,c:"$pants"},{x:r[1],y:13,w:3,h:4,c:"$pants"},{x:r[0]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:r[1]+1,y:13,w:1,h:3,c:"darken($pants, 25)",a:.2},{x:r[0],y:16,w:3,h:2,c:"$shoes"},{x:r[1],y:16,w:3,h:2,c:"$shoes"},{x:r[0],y:16,w:3,h:1,c:"lighten($shoes, 25)",a:.4},{x:r[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 Vd(e){const t=e===1||e===3?-1:0,r=Y3[e],i=e<2?[0,1]:[1,0],a=t;return[{x:1,y:17,w:10,h:2,c:"#100A06",a:.18},{x:r[0],y:13,w:3,h:4,c:"$pants"},{x:r[1],y:13,w:3,h:4,c:"$pants"},{x:r[0],y:16,w:3,h:2,c:"$shoes"},{x:r[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 fa(e,t){const r=e===1||e===3?-1:0,i=$$[e],a=r,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 Ww={down:[Pd(0),Pd(1),Pd(2),Pd(3)],up:[Vd(0),Vd(1),Vd(2),Vd(3)],right:[fa(0,!0),fa(1,!0),fa(2,!0),fa(3,!0)],left:[fa(0,!1),fa(1,!1),fa(2,!1),fa(3,!1)]},$e="#FAFAF7",Pn="#FFFFFF",Be="#EDE8E2",rt="#DDD6CC",Jc="#1A1A2E",Wf="#2A2A2A",I0="#FFB0B0",Gw=[{x:2,y:0,w:1,h:1,c:Be},{x:3,y:0,w:1,h:1,c:$e},{x:4,y:0,w:1,h:1,c:Pn},{x:5,y:0,w:1,h:1,c:$e},{x:6,y:0,w:1,h:1,c:Be},{x:1,y:1,w:1,h:1,c:rt},{x:2,y:1,w:1,h:1,c:$e},{x:3,y:1,w:1,h:1,c:Pn},{x:4,y:1,w:1,h:1,c:$e},{x:5,y:1,w:1,h:1,c:Pn},{x:6,y:1,w:1,h:1,c:$e},{x:7,y:1,w:1,h:1,c:rt},{x:0,y:2,w:1,h:1,c:rt},{x:1,y:2,w:1,h:1,c:Be},{x:2,y:2,w:1,h:1,c:$e},{x:3,y:2,w:1,h:1,c:$e},{x:4,y:2,w:1,h:1,c:Pn},{x:5,y:2,w:1,h:1,c:$e},{x:6,y:2,w:1,h:1,c:$e},{x:7,y:2,w:1,h:1,c:Be},{x:8,y:2,w:1,h:1,c:rt},{x:1,y:3,w:1,h:1,c:Be},{x:2,y:3,w:1,h:1,c:$e},{x:3,y:3,w:1,h:1,c:Jc},{x:4,y:3,w:1,h:1,c:$e},{x:5,y:3,w:1,h:1,c:Jc},{x:6,y:3,w:1,h:1,c:$e},{x:7,y:3,w:1,h:1,c:Be},{x:2,y:4,w:1,h:1,c:Be},{x:3,y:4,w:1,h:1,c:$e},{x:4,y:4,w:1,h:1,c:Wf},{x:5,y:4,w:1,h:1,c:$e},{x:6,y:4,w:1,h:1,c:Be},{x:3,y:5,w:1,h:1,c:rt},{x:4,y:5,w:1,h:1,c:Be},{x:5,y:5,w:1,h:1,c:rt},{x:2,y:6,w:1,h:1,c:Be},{x:3,y:6,w:1,h:1,c:$e},{x:4,y:6,w:1,h:1,c:Pn},{x:5,y:6,w:1,h:1,c:$e},{x:6,y:6,w:1,h:1,c:Be},{x:2,y:7,w:1,h:1,c:rt},{x:3,y:7,w:1,h:1,c:Be},{x:4,y:7,w:1,h:1,c:$e},{x:5,y:7,w:1,h:1,c:Be},{x:6,y:7,w:1,h:1,c:rt}],O$=[{x:3,y:8,w:1,h:1,c:Be},{x:5,y:8,w:1,h:1,c:Be},{x:3,y:9,w:1,h:1,c:rt},{x:5,y:9,w:1,h:1,c:rt}],L$=[{x:2,y:8,w:1,h:1,c:Be},{x:6,y:8,w:1,h:1,c:Be},{x:2,y:9,w:1,h:1,c:rt},{x:6,y:9,w:1,h:1,c:rt}],Kw=[{x:2,y:0,w:1,h:1,c:Be},{x:3,y:0,w:1,h:1,c:$e},{x:4,y:0,w:1,h:1,c:Pn},{x:5,y:0,w:1,h:1,c:$e},{x:6,y:0,w:1,h:1,c:Be},{x:1,y:1,w:1,h:1,c:rt},{x:2,y:1,w:1,h:1,c:Be},{x:3,y:1,w:1,h:1,c:$e},{x:4,y:1,w:1,h:1,c:Pn},{x:5,y:1,w:1,h:1,c:$e},{x:6,y:1,w:1,h:1,c:Be},{x:7,y:1,w:1,h:1,c:rt},{x:0,y:2,w:1,h:1,c:rt},{x:1,y:2,w:1,h:1,c:Be},{x:2,y:2,w:1,h:1,c:$e},{x:3,y:2,w:1,h:1,c:$e},{x:4,y:2,w:1,h:1,c:$e},{x:5,y:2,w:1,h:1,c:$e},{x:6,y:2,w:1,h:1,c:$e},{x:7,y:2,w:1,h:1,c:Be},{x:8,y:2,w:1,h:1,c:rt},{x:1,y:3,w:1,h:1,c:rt},{x:2,y:3,w:1,h:1,c:Be},{x:3,y:3,w:1,h:1,c:$e},{x:4,y:3,w:1,h:1,c:$e},{x:5,y:3,w:1,h:1,c:$e},{x:6,y:3,w:1,h:1,c:Be},{x:7,y:3,w:1,h:1,c:rt},{x:2,y:4,w:1,h:1,c:rt},{x:3,y:4,w:1,h:1,c:Be},{x:4,y:4,w:1,h:1,c:$e},{x:5,y:4,w:1,h:1,c:Be},{x:6,y:4,w:1,h:1,c:rt},{x:3,y:5,w:1,h:1,c:rt},{x:4,y:5,w:1,h:1,c:Be},{x:5,y:5,w:1,h:1,c:rt},{x:2,y:6,w:1,h:1,c:Be},{x:3,y:6,w:1,h:1,c:$e},{x:4,y:6,w:1,h:1,c:$e},{x:5,y:6,w:1,h:1,c:$e},{x:6,y:6,w:1,h:1,c:Be},{x:2,y:7,w:1,h:1,c:rt},{x:3,y:7,w:1,h:1,c:Be},{x:4,y:7,w:1,h:1,c:$e},{x:5,y:7,w:1,h:1,c:Be},{x:6,y:7,w:1,h:1,c:rt},{x:4,y:5,w:1,h:1,c:$e},{x:4,y:4,w:1,h:1,c:Pn}],I$=[{x:3,y:8,w:1,h:1,c:Be},{x:5,y:8,w:1,h:1,c:Be},{x:3,y:9,w:1,h:1,c:rt},{x:5,y:9,w:1,h:1,c:rt}],H$=[{x:2,y:8,w:1,h:1,c:Be},{x:6,y:8,w:1,h:1,c:Be},{x:2,y:9,w:1,h:1,c:rt},{x:6,y:9,w:1,h:1,c:rt}],Lx=[{x:8,y:0,w:1,h:1,c:Be},{x:9,y:0,w:1,h:1,c:$e},{x:10,y:0,w:1,h:1,c:Pn},{x:11,y:0,w:1,h:1,c:$e},{x:7,y:1,w:1,h:1,c:rt},{x:8,y:1,w:1,h:1,c:$e},{x:9,y:1,w:1,h:1,c:Pn},{x:10,y:1,w:1,h:1,c:$e},{x:11,y:1,w:1,h:1,c:$e},{x:12,y:1,w:1,h:1,c:Be},{x:0,y:2,w:1,h:1,c:Pn},{x:1,y:2,w:1,h:1,c:$e},{x:3,y:2,w:1,h:1,c:Be},{x:4,y:2,w:1,h:1,c:$e},{x:5,y:2,w:1,h:1,c:$e},{x:6,y:2,w:1,h:1,c:$e},{x:7,y:2,w:1,h:1,c:Be},{x:8,y:2,w:1,h:1,c:$e},{x:9,y:2,w:1,h:1,c:$e},{x:10,y:2,w:1,h:1,c:$e},{x:11,y:2,w:1,h:1,c:$e},{x:12,y:2,w:1,h:1,c:Be},{x:0,y:3,w:1,h:1,c:Be},{x:1,y:3,w:1,h:1,c:rt},{x:3,y:3,w:1,h:1,c:rt},{x:4,y:3,w:1,h:1,c:Be},{x:5,y:3,w:1,h:1,c:$e},{x:6,y:3,w:1,h:1,c:Be},{x:7,y:3,w:1,h:1,c:rt},{x:8,y:3,w:1,h:1,c:$e},{x:9,y:3,w:1,h:1,c:Jc},{x:10,y:3,w:1,h:1,c:$e},{x:11,y:3,w:1,h:1,c:Be},{x:3,y:4,w:1,h:1,c:rt},{x:4,y:4,w:1,h:1,c:Be},{x:5,y:4,w:1,h:1,c:$e},{x:6,y:4,w:1,h:1,c:Be},{x:8,y:4,w:1,h:1,c:Be},{x:9,y:4,w:1,h:1,c:$e},{x:10,y:4,w:1,h:1,c:Wf}],X3=[{x:4,y:5,w:1,h:1,c:Be},{x:6,y:5,w:1,h:1,c:Be},{x:8,y:5,w:1,h:1,c:Be},{x:10,y:5,w:1,h:1,c:Be},{x:4,y:6,w:1,h:1,c:rt},{x:6,y:6,w:1,h:1,c:rt},{x:8,y:6,w:1,h:1,c:rt},{x:10,y:6,w:1,h:1,c:rt}],P3=[{x:3,y:5,w:1,h:1,c:Be},{x:5,y:5,w:1,h:1,c:Be},{x:9,y:5,w:1,h:1,c:Be},{x:11,y:5,w:1,h:1,c:Be},{x:3,y:6,w:1,h:1,c:rt},{x:5,y:6,w:1,h:1,c:rt},{x:9,y:6,w:1,h:1,c:rt},{x:11,y:6,w:1,h:1,c:rt}];function H0(e,t=13){return e.map(r=>({...r,x:t-1-r.x}))}const Qw=H0(Lx),U$=H0(X3),q$=H0(P3),Y$={down:[[...Gw,...O$],[...Gw,...L$]],up:[[...Kw,...I$],[...Kw,...H$]],right:[[...Lx,...X3],[...Lx,...P3]],left:[[...Qw,...U$],[...Qw,...q$]]},X$=[{x:4,y:5,w:1,h:1,c:I0}],In="#FFD4D4",vi="#FFCCD5",P$=[{x:2,y:0,w:1,h:1,c:rt},{x:3,y:0,w:1,h:1,c:Be},{x:4,y:0,w:1,h:1,c:$e},{x:5,y:0,w:1,h:1,c:Pn},{x:6,y:0,w:1,h:1,c:Be},{x:7,y:0,w:1,h:1,c:rt},{x:1,y:1,w:1,h:1,c:rt},{x:2,y:1,w:1,h:1,c:Be},{x:3,y:1,w:1,h:1,c:$e},{x:4,y:1,w:1,h:1,c:Pn},{x:5,y:1,w:1,h:1,c:$e},{x:6,y:1,w:1,h:1,c:Pn},{x:7,y:1,w:1,h:1,c:Be},{x:8,y:1,w:1,h:1,c:rt},{x:1,y:2,w:1,h:1,c:Be},{x:2,y:2,w:1,h:1,c:$e},{x:3,y:2,w:1,h:1,c:Jc},{x:4,y:2,w:1,h:1,c:$e},{x:5,y:2,w:1,h:1,c:$e},{x:6,y:2,w:1,h:1,c:Jc},{x:7,y:2,w:1,h:1,c:$e},{x:8,y:2,w:1,h:1,c:Be},{x:2,y:3,w:1,h:1,c:Be},{x:3,y:3,w:1,h:1,c:$e},{x:4,y:3,w:1,h:1,c:Wf},{x:5,y:3,w:1,h:1,c:I0},{x:6,y:3,w:1,h:1,c:$e},{x:7,y:3,w:1,h:1,c:Be},{x:2,y:4,w:1,h:1,c:rt},{x:3,y:4,w:1,h:1,c:Be},{x:4,y:4,w:1,h:1,c:$e},{x:5,y:4,w:1,h:1,c:$e},{x:6,y:4,w:1,h:1,c:Be},{x:7,y:4,w:1,h:1,c:rt},{x:0,y:5,w:1,h:1,c:Be},{x:1,y:5,w:1,h:1,c:vi},{x:2,y:5,w:1,h:1,c:$e},{x:3,y:5,w:1,h:1,c:In},{x:4,y:5,w:1,h:1,c:In},{x:5,y:5,w:1,h:1,c:In},{x:6,y:5,w:1,h:1,c:In},{x:7,y:5,w:1,h:1,c:$e},{x:8,y:5,w:1,h:1,c:vi},{x:9,y:5,w:1,h:1,c:Be},{x:1,y:6,w:1,h:1,c:Be},{x:2,y:6,w:1,h:1,c:$e},{x:3,y:6,w:1,h:1,c:In},{x:4,y:6,w:1,h:1,c:vi},{x:5,y:6,w:1,h:1,c:vi},{x:6,y:6,w:1,h:1,c:In},{x:7,y:6,w:1,h:1,c:$e},{x:8,y:6,w:1,h:1,c:Be},{x:2,y:7,w:1,h:1,c:$e},{x:3,y:7,w:1,h:1,c:In},{x:4,y:7,w:1,h:1,c:In},{x:5,y:7,w:1,h:1,c:In},{x:6,y:7,w:1,h:1,c:In},{x:7,y:7,w:1,h:1,c:$e},{x:0,y:8,w:1,h:1,c:Be},{x:1,y:8,w:1,h:1,c:vi},{x:2,y:8,w:1,h:1,c:rt},{x:3,y:8,w:1,h:1,c:Be},{x:4,y:8,w:1,h:1,c:$e},{x:5,y:8,w:1,h:1,c:$e},{x:6,y:8,w:1,h:1,c:Be},{x:7,y:8,w:1,h:1,c:rt},{x:8,y:8,w:1,h:1,c:vi},{x:9,y:8,w:1,h:1,c:Be},{x:4,y:9,w:1,h:1,c:$e},{x:5,y:9,w:1,h:1,c:Pn}],V$=[{x:2,y:0,w:1,h:1,c:rt},{x:3,y:0,w:1,h:1,c:Be},{x:4,y:0,w:1,h:1,c:$e},{x:5,y:0,w:1,h:1,c:Pn},{x:6,y:0,w:1,h:1,c:Be},{x:7,y:0,w:1,h:1,c:rt},{x:1,y:1,w:1,h:1,c:rt},{x:2,y:1,w:1,h:1,c:Be},{x:3,y:1,w:1,h:1,c:$e},{x:4,y:1,w:1,h:1,c:Pn},{x:5,y:1,w:1,h:1,c:$e},{x:6,y:1,w:1,h:1,c:Pn},{x:7,y:1,w:1,h:1,c:Be},{x:8,y:1,w:1,h:1,c:rt},{x:1,y:2,w:1,h:1,c:Be},{x:2,y:2,w:1,h:1,c:$e},{x:3,y:2,w:1,h:1,c:Be},{x:4,y:2,w:1,h:1,c:$e},{x:5,y:2,w:1,h:1,c:$e},{x:6,y:2,w:1,h:1,c:Be},{x:7,y:2,w:1,h:1,c:$e},{x:8,y:2,w:1,h:1,c:Be},{x:2,y:3,w:1,h:1,c:Be},{x:3,y:3,w:1,h:1,c:$e},{x:4,y:3,w:1,h:1,c:Wf},{x:5,y:3,w:1,h:1,c:I0},{x:6,y:3,w:1,h:1,c:$e},{x:7,y:3,w:1,h:1,c:Be},{x:2,y:4,w:1,h:1,c:rt},{x:3,y:4,w:1,h:1,c:Be},{x:4,y:4,w:1,h:1,c:$e},{x:5,y:4,w:1,h:1,c:$e},{x:6,y:4,w:1,h:1,c:Be},{x:7,y:4,w:1,h:1,c:rt},{x:0,y:5,w:1,h:1,c:Be},{x:1,y:5,w:1,h:1,c:vi},{x:2,y:5,w:1,h:1,c:$e},{x:3,y:5,w:1,h:1,c:In},{x:4,y:5,w:1,h:1,c:In},{x:5,y:5,w:1,h:1,c:In},{x:6,y:5,w:1,h:1,c:In},{x:7,y:5,w:1,h:1,c:$e},{x:8,y:5,w:1,h:1,c:vi},{x:9,y:5,w:1,h:1,c:Be},{x:1,y:6,w:1,h:1,c:Be},{x:2,y:6,w:1,h:1,c:$e},{x:3,y:6,w:1,h:1,c:In},{x:4,y:6,w:1,h:1,c:vi},{x:5,y:6,w:1,h:1,c:vi},{x:6,y:6,w:1,h:1,c:In},{x:7,y:6,w:1,h:1,c:$e},{x:8,y:6,w:1,h:1,c:Be},{x:2,y:7,w:1,h:1,c:$e},{x:3,y:7,w:1,h:1,c:In},{x:4,y:7,w:1,h:1,c:In},{x:5,y:7,w:1,h:1,c:In},{x:6,y:7,w:1,h:1,c:In},{x:7,y:7,w:1,h:1,c:$e},{x:0,y:8,w:1,h:1,c:Be},{x:1,y:8,w:1,h:1,c:vi},{x:2,y:8,w:1,h:1,c:rt},{x:3,y:8,w:1,h:1,c:Be},{x:4,y:8,w:1,h:1,c:$e},{x:5,y:8,w:1,h:1,c:$e},{x:6,y:8,w:1,h:1,c:Be},{x:7,y:8,w:1,h:1,c:rt},{x:8,y:8,w:1,h:1,c:vi},{x:9,y:8,w:1,h:1,c:Be},{x:5,y:9,w:1,h:1,c:$e},{x:6,y:9,w:1,h:1,c:Pn}],W$=[{x:1,y:9,w:7,h:1,c:"#100A06",a:.12}],G$=[{x:2,y:6,w:9,h:1,c:"#100A06",a:.12}],K$=[{x:1,y:10,w:8,h:1,c:"#100A06",a:.12}],yt=4,un=28,Xn=2,Ot=4,_t=4,Ms=[{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 U0(e,t,r){const o=e.fy+Math.max(10,Math.floor(e.fh*.18)),c=Math.min(t,r),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 Q$(e){const i=Ms[0],a={id:"main",wx:yt+_t,wy:yt,ww:160-2*(yt+_t),wh:un,fx:yt+_t,fy:yt+un+Xn,fw:160-2*(yt+_t),fh:120-yt-un-Xn-yt,...i},o=U0(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*(yt+_t))/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 Z$(e){const a={id:"exec",wx:yt+_t,wy:yt,ww:144-yt-_t-Ot/2,wh:un,fx:yt+_t,fy:yt+un+Xn,fw:144-yt-_t-Ot/2,fh:66,...Ms[0]},o={id:"work",wx:144+Ot/2+_t,wy:yt,ww:144-Ot/2-_t-yt,wh:un,fx:144+Ot/2+_t,fy:yt+un+Xn,fw:144-Ot/2-_t-yt,fh:66,...Ms[1]},c={id:"meet",wx:yt+_t,wy:yt+un+Xn+66+Ot,ww:144-yt-_t-Ot/2,wh:un,fx:yt+_t,fy:yt+un+Xn+66+Ot+un+Xn,fw:144-yt-_t-Ot/2,fh:70,...Ms[2]},d={id:"comm",wx:144+Ot/2+_t,wy:yt+un+Xn+66+Ot,ww:144-Ot/2-_t-yt,wh:un,fx:144+Ot/2+_t,fy:yt+un+Xn+66+Ot+un+Xn,fw:144-Ot/2-_t-yt,fh:70,...Ms[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[T,F]of[...p,...y])F>0&&f.push(...U0(T,F,3));const k=yt+un+Xn+66,w=144-Ot/2,C={exec_work:{id:"exec_work",type:"v",doorY:yt+un+Xn+20+12,xA:w-2,xB:o.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:yt+un+Xn+66+Ot+un+Xn+20+12,xA:w-2,xB:d.fx+2},exec_meet:{id:"exec_meet",type:"h",doorX:yt+_t+40+14,yA:k-2,yB:c.fy+2},work_comm:{id:"work_comm",type:"h",doorX:144+Ot/2+_t+40+14,yA:k-2,yB:d.fy+2}},j={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"}]},E={exec:a.fy+52,work:o.fy+48,meet:c.fy+56,comm:d.fy+54},N={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:C,adjacency:j,corridorY:E,waypoints:N,wallDecorations:A,furniture:z}}function J$(e){const c={id:"exec",wx:yt+_t,wy:yt,ww:180-yt-_t-Ot/2,wh:un,fx:yt+_t,fy:yt+un+Xn,fw:180-yt-_t-Ot/2,fh:82,...Ms[0]},d={id:"work",wx:180+Ot/2+_t,wy:yt,ww:180-Ot/2-_t-yt,wh:un,fx:180+Ot/2+_t,fy:yt+un+Xn,fw:180-Ot/2-_t-yt,fh:82,...Ms[1]},m=yt+un+Xn+82,f={id:"meet",wx:yt+_t,wy:m+Ot,ww:180-yt-_t-Ot/2,wh:un,fx:yt+_t,fy:m+Ot+un+Xn,fw:180-yt-_t-Ot/2,fh:86,...Ms[2]},x={id:"comm",wx:180+Ot/2+_t,wy:m+Ot,ww:180-Ot/2-_t-yt,wh:un,fx:180+Ot/2+_t,fy:m+Ot+un+Xn,fw:180-Ot/2-_t-yt,fh:86,...Ms[3]},p={exec:c,work:d,meet:f,comm:x},y=[];let g=e;const k=[[c,Math.min(5,g)],[d,0]];k[1][1]=Math.min(5,g-k[0][1]);const w=[[f,0],[x,0]];let C=g-k[0][1]-k[1][1];C>0&&(w[0][1]=Math.min(3,C),C-=w[0][1]),C>0&&(w[1][1]=Math.min(3,C));for(const[q,V]of[...k,...w])V>0&&y.push(...U0(q,V,4));const j=180-Ot/2,E={exec_work:{id:"exec_work",type:"v",doorY:c.fy+82/2,xA:j-2,xB:d.fx+2},meet_comm:{id:"meet_comm",type:"v",doorY:f.fy+86/2,xA:j-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}},N={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}]},T=[{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:E,adjacency:N,corridorY:A,waypoints:z,wallDecorations:T,furniture:F}}const eO=2;function V3(e,t,r){return r||(t?t==="L"&&e<=12-eO?"M":t==="M"&&e>12?"L":t:e<=12?"M":"L")}function W3(e,t){switch(t??V3(e)){case"S":return Q$(e);case"M":return Z$(e);case"L":return J$(e)}}function tO(e,t){if(!t||Object.keys(t).length===0)return e;const r=i=>i.map(a=>{const o=t[a.id];return o?{...a,offsetX:o.offsetX,offsetY:o.offsetY}:a});return{...e,wallDecorations:r(e.wallDecorations),furniture:r(e.furniture)}}function nO(e,t){if(t)for(const[r,i]of Object.entries(t))e[r]&&(e[r]={...e[r],dx:i.dx,dy:i.dy})}function Zw(e,t){if(!t||t.length===0)return e;const r=new Set(t);return{...e,wallDecorations:e.wallDecorations.filter(i=>!r.has(i.id)),furniture:e.furniture.filter(i=>!r.has(i.id))}}function rO(e,t){if(!t||t.length===0)return e;const r=[],i=[];for(const a of t)a.zone==="wall"?r.push(a):i.push(a);return{...e,wallDecorations:[...e.wallDecorations,...r],furniture:[...e.furniture,...i]}}let Rc;function iO(e){Rc=e}function W(e,t,r,i,a,o){e=Math.round(e),t=Math.round(t),!(o!==void 0&&o<.01)&&(o!==void 0&&o!==1&&(Rc.globalAlpha=o),Rc.fillStyle=a,Rc.fillRect(e,t,r,i),o!==void 0&&o!==1&&(Rc.globalAlpha=1))}function gt(e,t,r,i){W(e,t,1,1,r,i)}let of=1;function Eo(e){of=e}function ts(){return of=of*16807%2147483647,(of&65535)/65535}function G3(e){const t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255,a=Math.max(t,r,i),o=Math.min(t,r,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=((r-i)/f+(r<i?6:0))/6:a===r?c=((i-t)/f+2)/6:c=((t-r)/f+4)/6}return[c*360,d*100,m*100]}function K3(e,t,r){e=(e%360+360)%360,t=Math.max(0,Math.min(100,t))/100,r=Math.max(0,Math.min(100,r))/100;const i=t*Math.min(r,1-r),a=c=>{const d=(c+e/30)%12;return r-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 is(e,t=1){const[r,i,a]=G3(e);return K3(r+15*t,Math.min(100,i+8),a-12*t)}function Sn(e,t=1){const[r,i,a]=G3(e);return K3(r-10*t,i-3,a+10*t)}const Yn={hi:"#D4AA5C",base:"#B08040",sh:"#7A5038",deep:"#4E3028"},ei={hi:"#8A6848",base:"#604832",sh:"#3A2E24",deep:"#2A1E18"},Wi={hi:"#5A6A80",base:"#485868",sh:"#364858",deep:"#283848"},wi="#100A06";function sO(e,t,r=14,i=12){W(e,t,r,i,"#4A3828"),W(e+1,t+1,r-2,i-2,"#5A4838"),W(e+2,t+2,r-4,i-4,"#4A7098"),W(e+2,t+2,r-4,Math.floor((i-4)/2),"#6A90B8",.35);const a=Math.floor(r/2);W(e+a,t+1,1,i-2,"#4A3828"),W(e+1,t+Math.floor(i/2),r-2,1,"#4A3828",.5),gt(e+3,t+3,"#8AB8E8",.35),gt(e+a+2,t+3,"#8AB8E8",.25),W(e-1,t+i,r+2,2,"#5A4838"),W(e-1,t+i,r+2,1,Sn("#5A4838",.5),.35)}function aO(e,t,r){W(e,t,10,8,"#3A2818"),W(e+1,t+1,8,6,r),W(e+2,t+2,4,3,Sn(r,1.2),.3),gt(e+3,t+2,Sn(r,2),.25)}function lO(e,t){W(e,t,7,7,"#3A2818"),W(e+1,t+1,5,5,"#F0EDE5"),gt(e+3,t+1,"#AAA"),gt(e+3,t+5,"#AAA"),gt(e+1,t+3,"#AAA"),gt(e+5,t+3,"#AAA"),gt(e+3,t+3,"#222"),W(e+3,t+1,1,2,"#333"),gt(e+4,t+3,"#D32F2F")}function oO(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 cO(e,t){W(e,t,22,16,"#6A5030"),W(e+1,t+1,20,14,"#C4A66A"),Eo(88);for(let r=0;r<14;r++)for(let i=0;i<20;i++)ts()>.5&&gt(e+1+i,t+1+r,ts()>.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"),gt(e+4,t+2,"#E53935"),gt(e+10,t+2,"#1E88E5"),gt(e+16,t+3,"#FF9800")}function uO(e,t){W(e,t,20,3,"#5A4030"),W(e,t,20,1,Sn("#5A4030",.5),.35),W(e,t+2,20,1,is("#5A4030",.5),.3),W(e+2,t-4,3,4,"#E53935"),W(e+2,t-4,3,1,Sn("#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"),gt(e+15,t-3,"#FFF176",.4)}function dO(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),gt(e+2,t+4,"#4CAF50"),W(e+4,t+4,7,1,"#8b949e",.4),gt(e+2,t+6,"#FF9800"),W(e+4,t+6,5,1,"#8b949e",.3),gt(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 fO(e,t,r){W(e+2,t+20,22,2,wi,.15),W(e,t,22,20,ei.deep),W(e+1,t+1,20,18,ei.base),W(e,t,22,1,ei.hi,.35),W(e,t,1,20,ei.hi,.2);for(const o of[6,12])W(e+1,t+o,20,2,ei.sh),W(e+1,t+o,20,1,ei.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,Sn(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,Sn(i[o+3],1),.25),a+=5;W(e+2,t+14,4,4,"#FFD54F"),W(e+8,t+14,7,4,"#90CAF9"),r&&W(e,t-1,22,1,r,.7)}function hO(e,t){W(e+2,t+11,6,2,wi,.1),W(e+2,t+8,6,4,"#8B5E3C"),W(e+1,t+7,8,2,is("#A06E48",.3)),W(e+2,t+7,6,1,Sn("#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"),gt(e+4,t,"#81C784"),gt(e+3,t+1,"#A5D6A7",.4)}function mO(e,t){Ga(e+4,t-4,"down"),Ga(e+16,t-4,"down"),Ga(e+28,t-4,"down"),W(e+3,t+24,34,3,wi,.15),W(e,t+2,36,18,Yn.deep),W(e+1,t+3,34,16,Yn.base),W(e+1,t+3,34,1,Yn.hi,.35);for(let r=0;r<14;r+=3)W(e+1,t+4+r,34,1,is(Yn.base,.2),.08);W(e,t+20,36,4,Yn.deep),W(e+1,t+21,34,2,Yn.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"),gt(e+16,t+8,"#795548"),Ga(e+4,t+24,"up"),Ga(e+16,t+24,"up"),Ga(e+28,t+24,"up")}function pO(e,t){W(e+2,t+16,36,3,wi,.15),W(e,t,36,5,"#5D4037"),W(e+1,t+1,34,3,"#6D4C41"),W(e+1,t+1,34,1,Sn("#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,Sn("#6D4C41",.5),.35),W(e+19,t+6,15,6,"#6D4C41"),W(e+20,t+6,13,1,Sn("#6D4C41",.5),.35),W(e+17,t+6,2,6,"#5D4037"),W(e,t+13,36,3,is("#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,Sn("#FF8A65",1),.35)}function xO(e,t){W(e+2,t+10,22,2,wi,.12),W(e,t,22,8,ei.deep),W(e+1,t+1,20,6,ei.base),W(e+1,t+1,20,1,ei.hi,.3),W(e,t+8,22,2,ei.sh),W(e+3,t+2,6,4,"#F0F0F0"),W(e+13,t+3,3,3,"#ECEFF1"),gt(e+14,t+4,"#795548")}function gO(e,t){W(e+1,t+14,10,2,wi,.12),W(e,t,10,14,"#546E7A"),W(e,t,10,1,Sn("#546E7A",1),.35),W(e+1,t+1,8,3,"#78909C"),W(e+1,t+5,8,4,"#37474F"),gt(e+2,t+6,"#EF5350"),gt(e+4,t+6,"#66BB6A"),W(e+2,t+11,4,2,"#ECEFF1")}function yO(e,t){W(e+2,t+18,28,3,wi,.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"),gt(e+12,t+5,"#FF5722"),W(e+16,t+8,3,2,"#FFD54F"),gt(e+15,t+8,"#FFC107"),gt(e+13,t+3,"#90CAF9",.5),gt(e+14,t+4,"#BBDEFB",.35),gt(e+8,t+3,"#BBDEFB",.3),W(e,t+16,28,2,"#455A64"),W(e+1,t+16,26,1,Sn("#455A64",.5),.3)}function bO(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 vO(e,t){W(e+2,t+28,16,3,wi,.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"),gt(e+6,t+7,"#81C784"),W(e+1,t+14,14,6,"#1A237E"),W(e+2,t+15,4,4,"#212121"),gt(e+4,t+16,"#F44336"),gt(e+9,t+16,"#F44336"),gt(e+11,t+16,"#2196F3"),gt(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 wO(e,t){W(e+2,t+24,20,3,wi,.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 r=0;r<7;r++)W(e+4+r*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 kO(e,t){W(e+2,t+22,22,2,wi,.12),W(e,t,22,22,ei.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,ei.base),W(e+1,t+10,20,1,ei.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"),gt(e+5,t+3,"#FFF176",.5),W(e+13,t+4,4,4,"#B0BEC5"),W(e+14,t+3,2,1,"#CFD8DC"),gt(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 SO(e,t){W(e+2,t+16,26,3,wi,.18),W(e,t,26,10,Yn.deep),W(e+1,t+1,24,8,Yn.base),W(e+1,t+2,24,1,Yn.hi,.2),W(e+1,t+4,24,1,is(Yn.base,.2),.1),W(e+1,t+6,24,1,Yn.hi,.15),W(e+1,t+1,24,1,Yn.hi,.4),W(e+1,t+1,1,8,Yn.hi,.2),W(e,t+10,26,5,Yn.deep),W(e+1,t+11,24,3,Yn.sh),W(e+1,t+10,24,1,is(Yn.base,1.5),.4),W(e+1,t+14,24,1,Yn.base,.15),W(e+2,t+12,10,1,Yn.deep,.4),W(e+14,t+12,10,1,Yn.deep,.4),gt(e+7,t+11,"#C8D0D8",.6),gt(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),gt(e+7,t-4,"#4A98D8",.25),gt(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 r=0;r<5;r++)gt(e+7+r*2,t+5,"#444",.6),gt(e+7+r*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"),gt(e+2,t+5,"#6D4C41")}function Ga(e,t,r){W(e+1,t+9,10,2,wi,.1),gt(e+5,t+9,"#1E1E22"),gt(e+1,t+10,"#1A1A1E"),gt(e+9,t+10,"#1A1A1E"),gt(e+3,t+11,"#1A1A1E"),gt(e+7,t+11,"#1A1A1E"),W(e+1,t+2,8,6,Wi.base),W(e+2,t+3,6,4,Wi.hi,.35),W(e+2,t+3,6,1,Sn(Wi.hi,.5),.25),W(e+1,t+7,8,1,Wi.deep),r==="up"?(W(e,t+7,10,3,Wi.deep),W(e+1,t+8,8,1,Wi.sh)):(W(e,t-1,10,3,Wi.deep),W(e+1,t,8,1,Wi.sh)),W(e,t+3,1,4,Wi.sh),W(e+9,t+3,1,4,Wi.sh)}const Q3={bookshelf:(e,t,r)=>fO(e,t,r.accent),plant:(e,t)=>hO(e,t),"meeting-table":(e,t)=>mO(e,t),sofa:(e,t)=>pO(e,t),"coffee-table":(e,t)=>xO(e,t),"coffee-machine":(e,t)=>gO(e,t),window:(e,t,r)=>sO(e,t,r.windowW??16,r.windowH??14),picture:(e,t,r)=>aO(e,t,r.pictureColor??"#1565C0"),clock:(e,t)=>lO(e,t),whiteboard:(e,t)=>oO(e,t),"bulletin-board":(e,t)=>cO(e,t),shelf:(e,t)=>uO(e,t),screen:(e,t)=>dO(e,t),aquarium:(e,t)=>yO(e,t),"neon-sign":(e,t)=>bO(e,t),arcade:(e,t)=>vO(e,t),jukebox:(e,t)=>wO(e,t),"trophy-case":(e,t)=>kO(e,t)};function vo(e,t){const r=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:r+e.offsetX,y:i+e.offsetY}}function CO(e){for(const t of e.wallDecorations){const r=e.rooms[t.room];if(!r)continue;const{x:i,y:a}=vo(t,r),o=Q3[t.type];o&&o(i,a,t)}}function jO(e,t,r){for(const i of e.furniture){const a=e.rooms[i.room];if(!a||i.condition==="no-desks"&&r.has(i.room))continue;const{x:o,y:c}=vo(i,a),d=Q3[i.type];d&&t.push({y:c,draw:()=>d(o,c,i)})}}function Ka(e){const t=[],r=[...e.wallDecorations,...e.furniture];for(const i of r){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 EO={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 Ix(e){return EO[e]??{w:16,h:16}}function Yp(e,t,r,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=Ix(o.type);if(t>=d&&t<=d+f.w&&r>=m&&r<=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=Ix(o.type);if(t>=d&&t<=d+f.w&&r>=m&&r<=m+f.h)return o.id}return null}function Jw(e,t,r,i,a){const c=[...t.wallDecorations,...t.furniture].find(p=>p.id===r);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=Ix(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 e2(e,t,r,i){e.save(),e.fillStyle=i,e.globalAlpha=.2,e.fillRect(t-1,r-1,28,42),e.globalAlpha=.9,e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t-.5,r-.5,27,41),e.restore()}function t2(e,t,r){for(const[i,a]of Object.entries(e))if(t>=a.dx&&t<=a.dx+26&&r>=a.dy&&r<=a.dy+40)return i;return null}const n2=[{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}],Wd=16,NO=4,Va=4,cf=2,Gt=4,pa=4;let nt=W3(7);const Df={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"},r2={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 AO(e,t){const r=r2[e]||r2.default;return r[t]||r.en||r.default||[]}let Ki=Ka(nt);function Z3(e){return{x:e.dx,y:e.dy,w:e.pw,h:e.ph}}function J3(e){return{cx:e.dx+e.pw/2,botY:e.dy+e.ph}}let Nn={};function TO(e){const t={};for(let r=0;r<e.length&&r<nt.desks.length;r++)t[e[r]]=nt.desks[r];return t}let Ke,lr=null,Qa=null,Ts=!1,_i=null,Zr=null,eS=0,hr=null,qn=null,ha=null,Gi=null,Xp=900;function DO(e,t){const{wx:r,wy:i,ww:a,wh:o,wallColor:c,baseboardColor:d}=e,m=is(c,.5),f=Sn(c,.5),x=[];if(t){const p=t.x-r,y=t.w;p>0&&x.push({sx:r,sw:p}),p+y<a&&x.push({sx:t.x+y,sw:a-p-y})}else x.push({sx:r,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);Eo(Math.round(p.sx*7+i*13));for(let y=0;y<p.sw;y+=3)ts()>.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,Sn(c,1),.2),W(p.sx,i+o-2,p.sw,2,m,.3),W(p.sx,i+o,p.sw,cf,d),W(p.sx,i+o,p.sw,1,Sn(d,.5),.4)}t&&(W(t.x-1,i,1,o+cf,"#4A3828"),W(t.x+t.w,i,1,o+cf,"#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 _O(e){const t="#504038",r=is(t,.5),i=Sn(t,.5),a=e.wx-pa,o=e.wy,c=e.wh+cf+e.fh;W(a,o,pa,c,t),W(a,o,1,c,i,.3),W(a+pa-1,o,1,c,r,.4);for(let m=0;m<c;m+=6)W(a+1,o+m,pa-2,1,i,.06);const d=e.wx+e.ww;W(d,o,pa,c,t),W(d,o,1,c,i,.2),W(d+pa-1,o,1,c,r,.3)}function Pp(e){const{fx:t,fy:r,fw:i,fh:a}=e,o="#B08040",c="#C89848",d="#8A6030",m="#6A4820";W(t,r,i,a,o),Eo(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),k=Math.min(y+19,t+i)-g;if(k<=0)continue;const w=ts()>.5?c:o;W(g,r+f,k,4,w,.25),W(g,r+f,k,1,c,.3),W(g,r+f+4,k,1,m,.35),y>=t&&y<t+i&&W(y,r+f,1,4,m,.2),W(g,r+f+2,k,1,d,.1)}}W(t,r,i,2,"#0A0808",.08),W(t,r,2,a,"#0A0808",.06)}function i2(e){const{fx:t,fy:r,fw:i,fh:a}=e,o="#1C2A38",c="#101820";Eo(99),W(t,r,i,a,o);for(let d=0;d<a;d+=Wd)for(let m=0;m<i;m+=Wd){const f=Math.min(Wd,i-m),x=Math.min(Wd,a-d);ts()>.5&&W(t+m,r+d,f,x,Sn(o,.2),.15),W(t+m+2,r+d+2,f-4,x-4,Sn(o,.3),.08),W(t+m,r+d,f,1,c,.5),W(t+m,r+d,1,x,c,.5),W(t+m+1,r+d+1,1,x-1,Sn(o,.4),.1),ts()>.85&&gt(t+m+4+Math.floor(ts()*8),r+d+4+Math.floor(ts()*8),"#3A6A9A",.08)}}function MO(e){const{fx:t,fy:r,fw:i,fh:a}=e,o="#387848",c="#4A9058",d="#285E38";W(t,r,i,a,o),Eo(77);for(let f=0;f<a;f+=2)for(let x=0;x<i;x+=2)ts()>.5&&gt(t+x,r+f,c,.1),ts()>.8&&gt(t+x+1,r+f+1,d,.12);const m=5;W(t+m,r+m,i-m*2,1,c,.45),W(t+m,r+a-m-1,i-m*2,1,d,.45),W(t+m,r+m,1,a-m*2,c,.35),W(t+i-m-1,r+m,1,a-m*2,d,.35)}function FO(e){const{fx:t,fy:r,fw:i,fh:a}=e,o="#D8C490",c="#B09060",d="#907848";Eo(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,r+m,x,p,y),W(t+f+1,r+m+1,x-2,1,Sn(y,.4),.2),W(t+f+1,r+m+1,1,p-2,Sn(y,.4),.15),W(t+f+x-2,r+m+2,1,p-3,is(y,.4),.15),W(t+f+2,r+m+p-2,x-3,1,is(y,.4),.15),W(t+f,r+m,x,1,d,.3),W(t+f,r+m,1,p,d,.3)}}function RO(){const{canvasW:e,canvasH:t,rooms:r,doors:i}=nt,a="#2A1E14",o="#3A2E24";if(W(0,0,e,Va,a),W(0,t-Va,e,Va,a),W(0,0,Va,t,a),W(e-Va,0,Va,t,a),W(0,0,e,1,o,.3),W(0,0,1,t,o,.2),!r.exec||!r.work||!r.meet||!r.comm)return;const c=r.exec,d=r.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,k=i.work_comm,w=24,C=28,j=((p==null?void 0:p.doorY)??c.fy+20)-w/2,E=((g==null?void 0:g.doorX)??Va+pa+54)-C/2,N=((k==null?void 0:k.doorX)??m+Gt/2+pa+54)-C/2,A=((y==null?void 0:y.doorY)??d.fy+20)-w/2;W(0,x,E,Gt,a),W(E+C,x,f-E-C,Gt,a),W(f+Gt,x,N-f-Gt,Gt,a),W(N+C,x,e-N-C,Gt,a),W(0,x,E,1,o,.3),W(E+C,x,f-E-C,1,o,.3),W(f+Gt,x,N-f-Gt,1,o,.3),W(N+C,x,e-N-C,1,o,.3),W(f,0,Gt,j,a),W(f,j+w,Gt,x-j-w,a),W(f,x+Gt,Gt,A-x-Gt,a),W(f,A+w,Gt,t-A-w,a),W(f,0,1,j,o,.2),W(f,j+w,1,x-j-w,o,.2),W(f,x+Gt,1,A-x-Gt,o,.2),W(f,A+w,1,t-A-w,o,.2),W(f,j,Gt,w,"#C4A070"),W(f+Gt/2,j,Gt/2,w,"#3A4858"),W(f,A,Gt,w,"#7AA880"),W(f+Gt/2,A,Gt/2,w,"#C8B890");const z="#4A3828";W(f,j-1,Gt,1,z),W(f,j+w,Gt,1,z),W(E-1,x,1,Gt,z),W(E+C,x,1,Gt,z),W(N-1,x,1,Gt,z),W(N+C,x,1,Gt,z),W(f,A-1,Gt,1,z),W(f,A+w,Gt,1,z)}const s2=new Map;function zO(e,t="right"){const r=`${e.hairStyle??""}|${e.outfitStyle??""}|${e.accessory??""}|${t}`;let i=s2.get(r);if(!i){const a=dx("mini-seated:default"),o=M5(a,e);let c=o?o.layers.flatMap(d=>d.pixels):[];t==="left"&&c.length>0&&(c=cx(c,12)),i=c,s2.set(r,i)}return i}function BO(e,t,r,i="right"){xa(Ke,zO(r,i),e,t,r)}function $O(e,t,r,i,a,o="right"){Ga(e+8,t+20,"up"),a||BO(e+8,t+0+i,r,o),SO(e,t+14)}function OO(e,t,r,i,a){const o=i in Ww?i:"down",c=a%4,d=Ww[o][c];xa(Ke,d,e,t,r);const m=c===1||c===3?-1:0;if(r.accessory&&r.accessory!=="none"){const f=_8(r.accessory,o);f&&f.pixels.length>0&&xa(Ke,f.pixels,e,t+m,r)}Ke.globalAlpha=1}let Ic=[],rl=!1,wo=0;function LO(){const e=Object.keys(nt.rooms),t=e[Math.floor(Math.random()*e.length)],r=nt.rooms[t];return{x:r.fx+r.fw/2,y:r.fy+r.fh/2,dir:"down",walkFrame:0,walkTimer:0,path:[],room:t,state:"walking",stateTimer:0,tongueTimer:0,idleTime:0}}function IO(e){if(e.stateTimer--,rl){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(nt.rooms);if(Math.random()<.35&&t.length>1){const r=t.filter(c=>c!==e.room),i=r[Math.floor(Math.random()*r.length)],a=q0(e,i),o=nt.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=il(d.x,d.y,c.x,c.y,i);e.path=[...a,...m]}else e.path=a}else{const r=nt.waypoints[e.room];if(r&&r.length>0){const i=r[Math.floor(Math.random()*r.length)];e.path=il(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],r=t.x-e.x,i=t.y-e.y,a=Math.sqrt(r*r+i*i);if(a<1.5){e.x=t.x,e.y=t.y,e.path.shift();for(const[o,c]of Object.entries(nt.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+=r/a*.15,e.y+=i/a*.15,Math.abs(r)>Math.abs(i)?e.dir=r>0?"right":"left":e.dir=i>0?"down":"up",e.walkTimer++,e.walkFrame=Math.floor(e.walkTimer/15)%2}}function HO(e){const t=Math.round(e.x),r=Math.round(e.y);if(rl&&wo>90){const c=Math.floor(wo/12)%2===0?P$:V$;xa(Ke,K$,t,r),xa(Ke,c,t,r);return}const i=e.state==="walking"?e.walkFrame:0,a=Y$[e.dir][i],o=e.dir==="left"||e.dir==="right";xa(Ke,o?G$:W$,t,r),xa(Ke,a,t,r),e.state==="idle"&&e.dir==="down"&&e.tongueTimer%80<50&&xa(Ke,X$,t,r)}function UO(e){const t={};let r=0;for(const i of e){const a=Nn[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:r*17,stateTimer:1200+Math.floor(Math.random()*1800),sittingTime:0,lookDir:"right",isStretching:!1,stretchTimer:0},r++)}return t}function il(e,t,r,i,a){const o=nt.corridorY[a]??t,c=[];return t<o-4&&c.push({x:e,y:o}),Math.abs(e-r)>4&&c.push({x:r,y:o}),c.push({x:r,y:i}),c}function Vp(e,t,r,i){const a=nt.adjacency[r];if(!a)return[];const o=a.find(x=>x.room===i);if(!o)return[];const c=nt.doors[o.door];if(!c)return[];const d=[],m=nt.corridorY[r]??t,f=nt.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 q0(e,t){const r=nt.adjacency[e.room];if(!r)return[];if(!r.find(a=>a.room===t)){for(const a of r){const o=nt.adjacency[a.room];if(o!=null&&o.find(c=>c.room===t)){const c=Vp(e.x,e.y,e.room,a.room),d=c[c.length-1],m=Vp((d==null?void 0:d.x)??e.x,(d==null?void 0:d.y)??e.y,a.room,t);return[...c,...m]}}return[]}return Vp(e.x,e.y,e.room,t)}function qO(e){if(e.room!==e.homeRoom){const t=q0({...e},e.homeRoom),r=t[t.length-1],i=il((r==null?void 0:r.x)??e.x,(r==null?void 0:r.y)??e.y,e.homeX,e.homeY,e.homeRoom);return[...t,...i]}return il(e.x,e.y,e.homeX,e.homeY,e.room)}function YO(e,t){if(Xp--,Xp<=0){const r=Object.entries(e).filter(([,i])=>i.state==="sitting"&&!i.isStretching);if(r.length>0){const[,i]=r[Math.floor(Math.random()*r.length)];i.isStretching=!0,i.stretchTimer=120}Xp=900}for(const[r,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++,lr===r){i.sittingTime=0,i.bobY=-3;const o=Nn[r];if(o){const c=o.dx+13;i.lookDir=eS<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(nt.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=q0(i,d),f=nt.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=il(p.x,p.y,x.x,x.y,d);i.path=[...m,...y]}else i.path=m;i.walkTimer=0}else{const c=nt.waypoints[i.room];if(c&&c.length>0){const d=c[Math.floor(Math.random()*c.length)];i.path=il(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,lr===r){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(nt.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(lr===r){i.dir="down";continue}if(i.stateTimer<=0)if(Math.random()<.15){i.state="walking";const a=nt.waypoints[i.room];if(a&&a.length>0){const o=a[Math.floor(Math.random()*a.length)];i.path=il(i.x,i.y,o.x,o.y,i.room)}i.walkTimer=0}else i.state="returning",i.path=qO(i),i.walkTimer=0}}function XO(e,t,r,i){const{canvasW:a,canvasH:o,rooms:c}=nt;Ke.clearRect(0,0,a,o),W(0,0,a,o,"#2A1E14");const d={wood:Pp,dark:i2,carpet:MO,tile:FO};for(const g of Object.values(c))(d[g.floorType]??Pp)(g);const m=Object.keys(c);if(m.length>=4){const g=c.exec,k=c.meet,{doors:w}=nt;if(g&&k&&w.exec_meet&&w.work_comm){const j=(w.exec_meet.doorX??0)-14,E=(w.work_comm.doorX??0)-28/2,N=g.fy+g.fh,A=k.fy;Pp({fx:j,fy:N,fw:28,fh:A-N}),i2({fx:E,fy:N,fw:28,fh:A-N})}}const f={};if(m.length>=4){const{doors:g}=nt,k=28,w=g.exec_meet,C=g.work_comm;w!=null&&w.doorX&&(f.meet={x:w.doorX-k/2,w:k}),C!=null&&C.doorX&&(f.comm={x:C.doorX-k/2,w:k})}for(const g of Object.values(c))DO(g,f[g.id]),_O(g);RO(),CO(nt);const x=[],p=new Set(Object.values(Nn).map(g=>g.room));jO(nt,x,p);for(const[g,k]of Object.entries(Nn)){const w=e[g];if(!w)continue;const C=w.state==="sitting",j=t(g),E=Qn(r[g]),N=w.isStretching&&w.stretchTimer>0?Math.sin(w.stretchTimer*.15)*1:0;x.push({y:k.dy+14,draw:()=>{const A=C?w.bobY+N:0;if($O(k.dx,k.dy,j,A,!C,w.lookDir),C&&E){const z=Df[g]??"#388bfd";W(k.dx+7,k.dy+14-4,12,5,z,.15),gt(k.dx+12,k.dy+14+1,"#4CAF50",.8)}}})}for(const[g,k]of Object.entries(e))if(k.state!=="sitting"){const w=t(g);x.push({y:k.y+14,draw:()=>OO(Math.round(k.x),Math.round(k.y),w,k.dir,k.walkFrame)})}i&&x.push({y:i.y+10,draw:()=>HO(i)}),x.sort((g,k)=>g.y-k.y);for(const g of x)g.draw();for(const g of Ki){const k=Qa===g.id,w=J3(g);if(Ke.save(),Ke.globalAlpha=k?.9:.5,Ke.fillStyle=g.color,Ke.fillRect(w.cx-1,w.botY-2,3,3),k){const C=Z3(g);Ke.globalAlpha=.3,Ke.strokeStyle=g.color,Ke.lineWidth=1,Ke.strokeRect(C.x-1,C.y-1,C.w+2,C.h+2)}Ke.restore()}if(Ts){const g=new Set(Object.values(Nn).map(k=>k.room));if(_i&&_i!==Zr)if(_i.startsWith("desk:")){const k=_i.slice(5),w=Nn[k];w&&e2(Ke,w.dx,w.dy,"#FBBF24")}else Jw(Ke,nt,_i,"#FBBF24",g);if(Zr)if(Zr.startsWith("desk:")){const k=Zr.slice(5),w=Nn[k];w&&e2(Ke,w.dx,w.dy,"#3B82F6")}else Jw(Ke,nt,Zr,"#3B82F6",g)}if(lr){const g=Nn[lr],k=e[lr];if(g&&k){Ke.save(),Ke.globalAlpha=.25,Ke.fillStyle=Df[lr]??"#fff",k.state==="sitting"?Ke.fillRect(g.dx-1,g.dy+6,28,30):Ke.fillRect(Math.round(k.x)-1,Math.round(k.y)-1,14,24),Ke.globalAlpha=.95,Ke.fillStyle="#FBBF24",Ke.font="bold 8px monospace",Ke.textAlign="center";const w=k.state==="sitting"?g.dx+13:Math.round(k.x)+6,C=k.state==="sitting"?g.dy-1:Math.round(k.y)-5;Ke.fillText("!",w,C),Ke.restore()}}const y=3600;for(const[,g]of Object.entries(e))if(g.state==="sitting"&&g.sittingTime>y&&!g.isStretching){const k=Object.values(Nn).find(A=>A.dx+8===g.homeX&&A.dy+34===g.homeY);if(!k)continue;const w=k.dx+13,C=k.dy,j=Math.floor(g.sittingTime/40)%3;Ke.save(),Ke.font="5px monospace",Ke.textAlign="center";const E=[.7,.5,.3],N=[{x:3,y:-2-j},{x:6,y:-5-(j+1)%3},{x:4,y:-8-(j+2)%3}];for(let A=0;A<3;A++)Ke.globalAlpha=E[A],Ke.fillStyle="#93C5FD",Ke.font=`${4+A}px monospace`,Ke.fillText("z",w+N[A].x,C+N[A].y);Ke.restore()}Ic=Ic.filter(g=>g.life>0);for(const g of Ic)g.x+=g.vx,g.y+=g.vy,g.life--,Ke.save(),Ke.globalAlpha=Math.min(1,g.life/(g.maxLife*.3)),Ke.fillStyle=g.color??"#FF6B8A",Ke.font="8px serif",Ke.fillText(g.char,Math.round(g.x),Math.round(g.y)),Ke.restore();if(rl&&i&&wo<=90){const g=Math.round(i.x),k=Math.round(i.y);Ke.save(),Ke.globalAlpha=.9,Ke.fillStyle="#FBBF24",Ke.font="bold 5px monospace",Ke.textAlign="center",Ke.fillText("!",g+4,k-2),Ke.restore()}if(i&&!rl&&i.state==="idle"&&i.idleTime>600){const g=Math.round(i.x),k=Math.round(i.y),w=Math.floor(i.idleTime/40)%3;Ke.save();const C=[{x:3,y:-2-w},{x:5,y:-5-(w+1)%3},{x:4,y:-8-(w+2)%3}];for(let j=0;j<3;j++)Ke.globalAlpha=[.7,.5,.3][j],Ke.fillStyle="#93C5FD",Ke.font=`${3+j}px monospace`,Ke.textAlign="center",Ke.fillText("z",g+C[j].x,k+C[j].y);Ke.restore()}if(rl&&i&&wo<=90){const g=Math.round(i.x),k=Math.round(i.y),w=Math.floor(Date.now()/150)%2===0?-1:1;i.dir==="down"&&(Ke.fillStyle="#FAFAF7",Ke.fillRect(g+4+w,k-1,2,2))}}function PO(e,t){for(let r=0;r<4;r++)Ic.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:r%2===0?"♥":"♡",color:"#FF6B8A"})}function VO(e,t){for(let r=0;r<3;r++)Ic.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 WO({roles:e,projects:t,roleStatuses:r,activeExecs:i,onRoleClick:a,onProjectClick:o,onBulletinClick:c,onDecisionsClick:d,onKnowledgeClick:m,onSettingsClick:f,onThemeClick:x,onStatsClick:p,getRoleSpeech:y,getAppearance:g,onHireClick:k,onMascotClick:w,roleLevels:C,coinBalance:j=0,onCoinsSpent:E,onFurniturePlaced:N,purchasedPreset:A,language:z="en"}){const T=S.useRef(null),F=S.useRef(null),q=S.useRef(null),V=S.useRef({}),L=S.useRef(null),_=S.useRef(0),O=S.useRef(NO),[P,R]=S.useState(!1),[H,B]=S.useState(null),[Z,G]=S.useState(null),K=S.useRef({}),M=S.useRef({}),U=S.useRef([]),Y=S.useRef([]);S.useEffect(()=>{Ts=P},[P]),S.useEffect(()=>{ha=H,Gi=Z},[H,Z]);const[$,Q]=S.useState(!1);S.useEffect(()=>{Se.getPreferences().then(ge=>{const ve=ge.furnitureOverrides;ve&&Object.keys(ve).length>0&&(K.current=ve);const Ce=ge.deskOverrides;Ce&&Object.keys(Ce).length>0&&(M.current=Ce);const ne=ge.removedFurniture;ne&&ne.length>0&&(U.current=ne);const de=ge.addedFurniture;de&&de.length>0&&(Y.current=de),Q(!0)}).catch(()=>{Q(!0)})},[]);const ee=S.useRef({roleStatuses:r,activeExecs:i,getRoleSpeech:y,getAppearance:g});ee.current={roleStatuses:r,activeExecs:i,getRoleSpeech:y,getAppearance:g};const J=S.useRef({}),ae=S.useMemo(()=>e.map(ge=>ge.id),[e]),oe=S.useRef(nt);S.useEffect(()=>{if(!$)return;const ge=ae.length,ve=V3(ge,oe.current.preset,A),Ce=oe.current.preset!==ve;let ne=W3(ge,ve);U.current.length>0&&(ne=Zw(ne,U.current)),Y.current.length>0&&(ne=rO(ne,Y.current)),Object.keys(K.current).length>0&&(ne=tO(ne,K.current)),nt=ne,oe.current=ne,Nn=TO(ae),Object.keys(M.current).length>0&&nO(Nn,M.current),Ki=Ka(ne),V.current=UO(ae),L.current=LO();const de=T.current;de&&(de.width=ne.canvasW,de.height=ne.canvasH,Ce&&(de.style.opacity="0",de.style.transition="opacity 0.3s",setTimeout(()=>{de.style.opacity="1"},50))),Ee()},[ae,A,$]);const be=S.useCallback(ge=>{var ve,Ce;return((Ce=(ve=ee.current).getAppearance)==null?void 0:Ce.call(ve,ge))??O0(ge)},[]),Ee=S.useCallback(()=>{const ge=F.current,ve=T.current;if(!ge||!ve)return;const Ce=ge.parentElement;if(!Ce)return;const ne=Ce.clientWidth,de=Ce.clientHeight;if(ne===0||de===0)return;const{canvasW:_e,canvasH:ce}=nt;let Te=Math.min(ne/_e,de/ce);Te=Math.round(Te*2)/2,Te=Math.max(2,Math.min(Te,5)),O.current=Te,ve.style.width=_e*Te+"px",ve.style.height=ce*Te+"px",ge.style.width=_e*Te+"px",ge.style.height=ce*Te+"px"},[]);S.useEffect(()=>{var ce;const ge=T.current;if(!ge)return;const ve=ge.getContext("2d");if(!ve)return;Ke=ve,iO(ve),Ee();const Ce=new ResizeObserver(()=>Ee()),ne=(ce=F.current)==null?void 0:ce.parentElement;ne&&Ce.observe(ne);let de;const _e=()=>{_.current++,YO(V.current,_.current),L.current&&IO(L.current),XO(V.current,be,ee.current.roleStatuses,L.current),Ae(),de=requestAnimationFrame(_e)};return de=requestAnimationFrame(_e),()=>{cancelAnimationFrame(de),Ce.disconnect()}},[be,Ee]),S.useEffect(()=>{var _e;const ge=q.current;if(!ge)return;ge.innerHTML="";const ve={};for(const ce of e)ve[ce.id]=ce.name;for(const ce of ae){const Te=Df[ce]??"#8b949e",Le=ve[ce],Xe=Le&&Le.toLowerCase()!==ce.toLowerCase()?`${ce.toUpperCase()} · ${Le}`:ce.toUpperCase(),Ue=document.createElement("div");Ue.className="td-nametag",Ue.dataset.role=ce;const Pe=document.createElement("span");Pe.className="td-dot",Pe.style.background=Te,Ue.appendChild(Pe),Ue.appendChild(document.createTextNode(Xe));const lt=((_e=C==null?void 0:C[ce])==null?void 0:_e.level)??1;if(lt>1){const ze=document.createElement("span");ze.className="td-lvl",ze.textContent=`Lv.${lt}`,Ue.appendChild(ze)}ge.appendChild(Ue);const tt=document.createElement("div");tt.className="td-bubble",tt.dataset.role=ce,tt.dataset.type="bubble",ge.appendChild(tt)}const Ce={meeting:()=>{const ce=t[0];ce?o(ce.id):c()},bulletin:c,decisions:d,knowledge:m,settings:f,theme:x,stats:p};for(const ce of Ki){const Te=document.createElement("div");Te.className="td-facility-label",Te.dataset.facility=ce.id,ce.id==="meeting"&&(Te.dataset.questTarget="meeting-room"),ce.id==="knowledge"&&(Te.dataset.questTarget="knowledge-hub"),ce.id==="bulletin"&&(Te.dataset.questTarget="bulletin-board"),ce.id==="stats"&&(Te.dataset.questTarget="stats-btn"),ce.id==="settings"&&(Te.dataset.questTarget="settings-btn"),ce.id==="theme"&&(Te.dataset.questTarget="theme-btn"),Te.textContent=`${ce.icon} ${ce.label}`,Te.style.borderColor=`${ce.color}44`;const Le=Ce[ce.id];Le&&Te.addEventListener("click",Le),Te.addEventListener("mouseenter",()=>{Qa=ce.id}),Te.addEventListener("mouseleave",()=>{Qa=null}),ge.appendChild(Te)}const ne=document.createElement("div");ne.className="td-nametag td-nametag-mascot",ne.dataset.role="mascot";const de=document.createElement("span");de.className="td-dot",de.style.background="#ffd700",ne.appendChild(de),ne.appendChild(document.createTextNode("Pupu")),ne.addEventListener("click",()=>w==null?void 0:w()),ge.appendChild(ne)},[ae,e,t,o,c,d,m,f,x,p,w,C]);const Ae=S.useCallback(()=>{var Le;const ge=q.current;if(!ge)return;const ve=O.current,Ce=V.current,{getRoleSpeech:ne,roleStatuses:de,activeExecs:_e}=ee.current;for(const Xe of Object.keys(Ce)){const Ue=Ce[Xe],Pe=Nn[Xe];if(!Pe)continue;let lt,tt,ze;Ue.state==="sitting"?(lt=Pe.dx+13,ze=Pe.dy+2,tt=Pe.dy+37):(lt=Math.round(Ue.x)+6,ze=Math.round(Ue.y)-2,tt=Math.round(Ue.y)+18);const He=lt/nt.canvasW*100,qt=ge.querySelector(`.td-nametag[data-role="${Xe}"]`);if(qt){qt.style.left=He+"%",qt.style.top=tt*ve+2+"px";const Et=qt.querySelector(".td-dot");if(Et){const Xt=Qn(de[Xe]);Et.style.background=Xt?"#FBBF24":Df[Xe]??"#8b949e",Xt?Et.style.animation="td-pulse 1s ease-in-out infinite":Et.style.animation=""}}const Kt=ge.querySelector(`.td-bubble[data-role="${Xe}"]`);if(Kt){const Et=Date.now(),Xt=Qn(de[Xe]),hn=(Le=_e.find(Jt=>Jt.roleId===Xe))==null?void 0:Le.task,vn=ne(Xe);let le="";const qe=J.current[Xe];if(qe){if(qe.speechDismissTime&&Et>=qe.speechDismissTime&&(qe.currentSpeech=null,qe.speechDismissTime=null),qe.hoverStartTime&&!qe.currentSpeech){const Jt=Et-qe.hoverStartTime,je=!qe.lastSpeechTime||Et-qe.lastSpeechTime>=5e3;if(Jt>=2e3&&je){const St=AO(Xe,z),gn=St[Math.floor(Math.random()*St.length)];qe.currentSpeech=gn,qe.lastSpeechTime=Et,qe.speechDismissTime=Et+3e3}}le=qe.currentSpeech||""}const ot=Xt&&hn?hn.slice(0,60):le?le.slice(0,60):vn?vn.slice(0,60):"";ot&&Ue.state==="sitting"?(Kt.style.display="",Kt.style.left=He+"%",Kt.style.top=(ze-10)*ve+"px",Kt.textContent=ot):Kt.style.display="none"}}const ce=ge.querySelector(".td-nametag-mascot"),Te=L.current;if(ce&&Te){const Xe=Te.dir==="left"||Te.dir==="right",Ue=Math.round(Te.x)+(Xe?6:4),Pe=Math.round(Te.y)+(Xe?7:10);ce.style.left=Ue/nt.canvasW*100+"%",ce.style.top=Pe*ve+2+"px"}for(const Xe of Ki){const Ue=ge.querySelector(`.td-facility-label[data-facility="${Xe.id}"]`);if(Ue){const Pe=J3(Xe);Ue.style.left=Pe.cx/nt.canvasW*100+"%",Ue.style.top=Pe.botY*ve-4+"px",Ue.classList.toggle("td-facility-label--hover",Qa===Xe.id)}}},[]),Fe=S.useCallback(ge=>{const ve=T.current;if(!ve)return null;const Ce=ve.getBoundingClientRect(),ne=O.current,de=(ge.clientX-Ce.left)/ne,_e=(ge.clientY-Ce.top)/ne,ce=V.current;for(const[Le,Xe]of Object.entries(Nn)){if(!ce[Le])continue;const Ue=ce[Le];if(Ue.state==="sitting"){if(de>=Xe.dx&&de<=Xe.dx+26&&_e>=Xe.dy&&_e<=Xe.dy+40)return{type:"role",id:Le}}else if(de>=Ue.x-2&&de<=Ue.x+14&&_e>=Ue.y-2&&_e<=Ue.y+20)return{type:"role",id:Le}}const Te=L.current;if(Te){const Le=Te.dir==="left"||Te.dir==="right",Xe=Le?13:9,Ue=Le?7:10;if(de>=Te.x&&de<=Te.x+Xe&&_e>=Te.y&&_e<=Te.y+Ue)return{type:"mascot",id:"mascot"}}for(const Le of Ki){const Xe=Z3(Le);if(de>=Xe.x&&de<=Xe.x+Xe.w&&_e>=Xe.y&&_e<=Xe.y+Xe.h)return{type:"facility",id:Le.id}}return null},[]),he=S.useCallback(ge=>{const ve=T.current;if(!ve)return{mx:0,my:0};const Ce=ve.getBoundingClientRect(),ne=O.current;return{mx:(ge.clientX-Ce.left)/ne,my:(ge.clientY-Ce.top)/ne}},[]),Re=S.useCallback(ge=>{Se.updatePreferences(ge).catch(()=>{})},[]),et=S.useCallback(ge=>{const ve=Y.current.some(ne=>ne.id===ge),Ce={};if(ve){const ne=Y.current.filter(de=>de.id!==ge);Y.current=ne,Ce.addedFurniture=ne}else{const ne=[...U.current,ge];U.current=ne,Ce.removedFurniture=ne}nt=Zw(nt,[ge]),Ki=Ka(nt),Zr=null,_i=null,Re(Ce)},[Re]),We=S.useCallback((ge,ve)=>{if(!ha||!Gi)return;const Ce=n2.find(Ue=>Ue.type===ha),ne=(Ce==null?void 0:Ce.price)??0;if(ne>0&&j<ne)return;let de=null;for(const[Ue,Pe]of Object.entries(nt.rooms)){const lt=Gi==="wall"?Pe.wx:Pe.fx,tt=Gi==="wall"?Pe.wy:Pe.fy,ze=Gi==="wall"?Pe.ww:Pe.fw,He=Gi==="wall"?Pe.wh:Pe.fh;if(ge>=lt&&ge<=lt+ze&&ve>=tt&&ve<=tt+He){de=Ue;break}}if(!de)return;const _e=nt.rooms[de],ce=Gi==="wall"?_e.wx:_e.fx,Te=Gi==="wall"?_e.wy:_e.fy,Le={id:`user-${ha}-${Date.now()}`,type:ha,room:de,zone:Gi,offsetX:Math.round(ge-ce),offsetY:Math.round(ve-Te)},Xe=[...Y.current,Le];if(Y.current=Xe,Gi==="wall"?nt.wallDecorations.push(Le):nt.furniture.push(Le),Ki=Ka(nt),Re({addedFurniture:Xe}),N==null||N(ha,ne),ne>0){const Ue=Le.type;qx(async()=>{const{api:Pe}=await Promise.resolve().then(()=>P4);return{api:Pe}},void 0).then(({api:Pe})=>{Pe.spendCoins(ne,`furniture: ${Ue}`,Le.id).then(lt=>E==null?void 0:E(lt.balance)).catch(()=>{})})}B(null),G(null)},[Re,j,E,N]),it=S.useCallback(ge=>{const ve=T.current;if(Ts&&hr){const{mx:ce,my:Te}=he(ge),Xe=[...nt.furniture,...nt.wallDecorations].find(lt=>lt.id===hr.defId);if(!Xe)return;const Ue=ce-hr.startMx,Pe=Te-hr.startMy;Xe.offsetX=Math.round(hr.origOffX+Ue),Xe.offsetY=Math.round(hr.origOffY+Pe),Ki=Ka(nt),ve&&(ve.style.cursor="grabbing");return}if(Ts&&qn){const{mx:ce,my:Te}=he(ge),Le=Nn[qn.roleId];if(!Le)return;Le.dx=Math.round(qn.origDx+(ce-qn.startMx)),Le.dy=Math.round(qn.origDy+(Te-qn.startMy));const Xe=V.current[qn.roleId];Xe&&(Xe.homeX=Le.dx+8,Xe.homeY=Le.dy+34),ve&&(ve.style.cursor="grabbing");return}if(Ts){const{mx:ce,my:Te}=he(ge);if(ha){ve&&(ve.style.cursor="crosshair");return}const Le=new Set(Object.values(Nn).map(Ue=>Ue.room)),Xe=Yp(nt,ce,Te,Le);if(Xe)_i=Xe;else{const Ue=t2(Nn,ce,Te);_i=Ue?`desk:${Ue}`:null}lr=null,Qa=null,ve&&(ve.style.cursor=_i?"grab":"default");return}const Ce=Fe(ge),ne=lr;lr=(Ce==null?void 0:Ce.type)==="role"?Ce.id:null,Qa=(Ce==null?void 0:Ce.type)==="facility"?Ce.id:null,rl=(Ce==null?void 0:Ce.type)==="mascot",_i=null,ve&&(ve.style.cursor=Ce?"pointer":"default");const{mx:de}=he(ge);eS=de;const _e=Date.now();if(lr&&lr!==ne){J.current[lr]||(J.current[lr]={hoverStartTime:null,lastSpeechTime:null,currentSpeech:null,speechDismissTime:null});const ce=J.current[lr];ce.hoverStartTime=_e}else if(!lr&&ne){const ce=J.current[ne];ce&&(ce.hoverStartTime=null)}},[Fe,he]),mt=S.useCallback(ge=>{if(!Ts)return;const{mx:ve,my:Ce}=he(ge);if(ha){We(ve,Ce),ge.preventDefault();return}const ne=new Set(Object.values(Nn).map(ce=>ce.room)),de=Yp(nt,ve,Ce,ne);if(de){const Te=[...nt.furniture,...nt.wallDecorations].find(Le=>Le.id===de);Te&&(Zr=de,hr={defId:de,startMx:ve,startMy:Ce,origOffX:Te.offsetX,origOffY:Te.offsetY},ge.preventDefault());return}const _e=t2(Nn,ve,Ce);if(_e){const ce=Nn[_e];Zr=`desk:${_e}`,qn={roleId:_e,startMx:ve,startMy:Ce,origDx:ce.dx,origDy:ce.dy},ge.preventDefault();return}Zr=null},[he,We]),Ye=S.useCallback(ge=>{if(hr){const Ce=[...nt.furniture,...nt.wallDecorations].find(ne=>ne.id===hr.defId);if(Ce){const ne={...K.current,[Ce.id]:{offsetX:Ce.offsetX,offsetY:Ce.offsetY}};K.current=ne,Re({furnitureOverrides:ne}),Ki=Ka(nt)}hr=null,T.current&&(T.current.style.cursor="grab");return}if(qn){const ve=Nn[qn.roleId];if(ve){const Ce={...M.current,[qn.roleId]:{dx:ve.dx,dy:ve.dy}};M.current=Ce,Re({deskOverrides:Ce})}qn=null,T.current&&(T.current.style.cursor="grab")}},[Re]),Ze=S.useCallback(ge=>{if(!Ts)return;ge.preventDefault();const{mx:ve,my:Ce}=he(ge),ne=new Set(Object.values(Nn).map(_e=>_e.room)),de=Yp(nt,ve,Ce,ne);de&&et(de)},[he,et]);S.useEffect(()=>{const ge=ve=>{!Ts||!Zr||(ve.key==="Delete"||ve.key==="Backspace")&&(Zr.startsWith("desk:")||et(Zr))};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[et]);const ut=S.useCallback(()=>{if(hr){const ve=[...nt.furniture,...nt.wallDecorations].find(Ce=>Ce.id===hr.defId);ve&&(ve.offsetX=hr.origOffX,ve.offsetY=hr.origOffY,Ki=Ka(nt)),hr=null}if(qn){const ge=Nn[qn.roleId];ge&&(ge.dx=qn.origDx,ge.dy=qn.origDy);const ve=V.current[qn.roleId];ve&&(ve.homeX=ge.dx+8,ve.homeY=ge.dy+34),qn=null}lr=null,Qa=null,rl=!1,_i=null,T.current&&(T.current.style.cursor="default")},[]),jt=S.useCallback(ge=>{if(Ts)return;const ve=Fe(ge);if(ve){if(ve.type==="role"){const Ce=V.current[ve.id],ne=Nn[ve.id];if(Ce&&ne){const de=Ce.state==="sitting"?ne.dx+13:Math.round(Ce.x)+6,_e=Ce.state==="sitting"?ne.dy+2:Math.round(Ce.y)-2;VO(de,_e)}a(ve.id);return}if(ve.type==="mascot"){const Ce=L.current;Ce&&PO(Math.round(Ce.x)+4,Math.round(Ce.y)-2),w==null||w();return}switch(ve.id){case"meeting":{const Ce=t[0];Ce?o(Ce.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}}},[Fe,a,o,c,d,m,f,x,p]);return l.jsxs("div",{className:`td-scene${P?" td-scene--editing":""}`,children:[l.jsxs("div",{ref:F,className:"td-wrap",children:[l.jsx("canvas",{ref:T,width:nt.canvasW,height:nt.canvasH,className:"td-canvas",onClick:jt,onMouseDown:mt,onMouseUp:Ye,onMouseMove:it,onMouseLeave:ut,onContextMenu:Ze}),l.jsx("div",{ref:q,className:"td-overlay"})]}),P&&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${P?" td-edit-btn--active":""}`,"data-quest-target":"edit-btn",onClick:()=>{R(ge=>{const ve=!ge;return ve||(B(null),G(null)),ve}),Zr=null,hr=null,qn=null},title:P?"Exit Edit Mode":"Edit Furniture Layout",children:[l.jsx("span",{className:"td-edit-btn__icon",children:P?"✓":"✎"}),l.jsx("span",{className:"td-edit-btn__label",children:P?"DONE":"EDIT"})]}),P&&l.jsx("div",{className:"td-palette",children:n2.map(ge=>{const ve=ge.price===0||j>=ge.price,Ce=ge.price===0?"Free":`${ge.price>=1e3?`${(ge.price/1e3).toFixed(ge.price%1e3===0?0:1)}K`:ge.price}`;return l.jsxs("button",{className:`td-palette__item${H===ge.type?" td-palette__item--active":""}${ve?"":" td-palette__item--locked"}`,onClick:()=>{ve&&(H===ge.type?(B(null),G(null)):(B(ge.type),G(ge.zone)))},title:`${ge.label} — ${Ce}`,style:ve?void 0:{opacity:.4,cursor:"not-allowed"},children:[l.jsx("span",{children:ge.icon}),l.jsx("span",{className:"td-palette__price",style:{fontSize:"7px",color:ge.price===0?"#4CAF50":ve?"#FFD54F":"#EF5350"},children:Ce})]},ge.type)})}),k&&l.jsxs("button",{className:"td-hire-btn","data-quest-target":"hire-btn",onClick:k,title:"Hire New Role",children:[l.jsx("span",{className:"td-hire-btn__icon",children:"+"}),l.jsx("span",{className:"td-hire-btn__label",children:"HIRE"})]})]})}function GO({role:e,appearance:t,onSave:r,onReset:i,onClose:a,theme:o,onThemeChange:c,onUpdateName:d,initialTab:m,characterOnly:f,speechSettings:x,onSpeechSettingsChange:p,language:y,onLanguageChange:g,roleLevel:k,coinBalance:w,purchased:C,onPurchase:j}){var R;const[E,N]=S.useState(m??"character"),[A,z]=S.useState({...t}),[T,F]=S.useState(e.name),[q,V]=S.useState(!1),L=S.useCallback(()=>z(to(k)),[k]),_=S.useCallback(()=>{const H=O0(e.id);z({...H}),i()},[e.id,i]),O=S.useCallback(async()=>{r(A);const H=T.trim();if(d&&H&&H!==e.name){V(!0);try{await d(e.id,H)}catch{}V(!1)}a()},[A,r,a,T,e.name,e.id,d]),P=l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsxs("span",{children:[e.id.toUpperCase()," –"]}),d?l.jsx("input",{value:T,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 ${E==="character"?"active":""}`,onClick:()=>N("character"),children:"CHARACTER"}),!f&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:`customize-tab ${E==="office"?"active":""}`,onClick:()=>N("office"),children:"OFFICE THEME"}),l.jsx("button",{className:`customize-tab ${E==="settings"?"active":""}`,onClick:()=>N("settings"),children:"SETTINGS"})]})]}),l.jsx("button",{className:"customize-close",onClick:a,children:"X"})]}),E==="character"?l.jsx("div",{className:"customize-body",children:l.jsx($3,{roleId:e.id,appearance:A,onChange:z,onRandomize:L,onReset:_,label:P,roleLevel:k,coinBalance:w,purchased:C,onPurchase:j})}):E==="office"?l.jsx("div",{className:"customize-body",children:l.jsx("div",{className:"customize-themes",children:Object.entries(zs).map(([H,B])=>l.jsxs("button",{className:`customize-theme-card ${o===H?"active":""}`,onClick:()=>c(H),children:[l.jsxs("div",{className:"customize-theme-preview",style:{background:B.vars["--floor-light"],borderColor:B.vars["--pixel-border"]},children:[l.jsx("div",{style:{background:B.vars["--hud-bg"],height:8,borderBottom:`2px solid ${B.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:B.vars["--accent"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:B.vars["--active-green"],borderRadius:1}}),l.jsx("div",{style:{width:10,height:14,background:B.vars["--idle-amber"],borderRadius:1}})]}),l.jsx("div",{style:{background:B.vars["--hud-bg"],height:6,borderTop:`2px solid ${B.vars["--pixel-border"]}`}})]}),l.jsxs("div",{className:"customize-theme-name",children:[B.icon," ",B.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:B})=>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:B},H))}),l.jsx("div",{style:{fontSize:9,color:"var(--terminal-text-muted)",marginTop:4},children:"Sets language for AI responses and speech bubbles"})]})]})}),E==="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:O,children:"SAVE"})]})]})})}function a2(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 r={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=r[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 l2(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function KO({onInitGit:e,onDelegate:t,delegateRoleName:r}){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:["🤖"," ",(r==null?void 0:r.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:["🤖"," ",(r==null?void 0:r.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 QO({repo:e,onConnected:t,onDelegate:r,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(""),[k,w]=S.useState(null),[C,j]=S.useState(!1),E=async()=>{o("checking"),w(null);try{const T=await Se.getGithubStatus(e);d(T),T.hasRemote?t():T.ghInstalled&&T.authenticated?o("ready"):o("idle")}catch{o("idle")}},N=async()=>{if(m.trim()){j(!0),w(null);try{const T=await Se.githubCreateRepo(m.trim(),x,e);w(T),T.ok&&setTimeout(t,1500)}catch(T){w({ok:!1,message:T instanceof Error?T.message:"Failed"})}finally{j(!1)}}},A=async()=>{if(y.trim()){j(!0),w(null);try{const T=await Se.addRemote(y.trim(),e);w(T),T.ok&&setTimeout(t,1500)}catch(T){w({ok:!1,message:T instanceof Error?T.message:"Failed"})}finally{j(!1)}}},z=r?l.jsxs("button",{onClick:r,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:E,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:E,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:E,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:T=>f(T.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:T=>p(T.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:N,disabled:C||!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:C?"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:T=>g(T.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:C||!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:C?"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"})]})]}),k&&l.jsx("div",{className:"text-[10px] p-1.5",style:{background:k.ok?"rgba(59,185,80,0.1)":"rgba(211,47,47,0.1)",border:`1px solid ${k.ok?"var(--active-green)":"#D32F2F"}`,color:k.ok?"var(--active-green)":"#EF5350"},children:k.message})]})}function ZO({status:e,history:t,onClose:r,onSave:i,onLoadHistory:a,onRestore:o,saving:c,onDelegate:d,delegateRoleName:m,repo:f,onRepoChange:x,syncInfo:p,onPull:y,pulling:g,onRefresh:k,onInitGit:w}){const[C,j]=S.useState("save"),[E,N]=S.useState(""),[A,z]=S.useState(null),[T,F]=S.useState(!1),[q,V]=S.useState(null),[L,_]=S.useState(null),O=S.useRef(null);S.useEffect(()=>{C==="history"&&a()},[C,a]),S.useEffect(()=>{var M;(M=O.current)==null||M.focus()},[]);const P=[...((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&&P.length>0&&!E&&(N(a2(P)),R.current=!0)},[P.length]),S.useEffect(()=>{R.current=!1,N(""),_(null),V(null),z(null)},[f]);const H=S.useCallback(()=>{N(a2(P))},[P]),B=async()=>{z(null),V(null);try{const M=await i(E||void 0);V(M),N("")}catch(M){z(M instanceof Error?M.message:"Save failed")}},Z=async()=>{_(null),z(null);try{const M=await y();_(M)}catch(M){z(M instanceof Error?M.message:"Pull failed")}},G=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"&&r()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[r]);const K=M=>{M.key==="Enter"&&(M.metaKey||M.ctrlKey)&&B()};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 bg-black/40 z-[60] backdrop-blur-sm",onClick:r}),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:r,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:()=>j(M),className:"flex-1 py-2 text-[11px] font-bold uppercase tracking-wider cursor-pointer",style:{background:C===M?"var(--hud-bg-alt)":"transparent",color:C===M?"var(--terminal-text)":"var(--terminal-text-muted)",borderBottom:C===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:[C==="save"&&l.jsxs(l.Fragment,{children:[(e==null?void 0:e.noGit)&&l.jsx(KO,{onInitGit:async()=>{await(w==null?void 0:w()),k==null||k()},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:Z,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:P.length>0?l.jsxs("span",{style:{color:"var(--idle-amber)"},children:["* ",P.length," unsaved change",P.length>1?"s":""]}):l.jsx("span",{style:{color:"var(--active-green)"},children:"All changes saved"})}),P.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:P.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))})]}),P.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:O,type:"text",value:E,onChange:M=>N(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)"}})]}),P.length>0&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:B,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=P.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(QO,{repo:f,onConnected:()=>k==null?void 0:k(),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," (",l2(e.lastCommit.date),")"]})]}),C==="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:l2(M.date)})]}),l.jsx("button",{onClick:()=>G(M.sha),disabled:T,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 JO({onClose:e}){const[t,r]=S.useState(null),[i,a]=S.useState(!0),[o,c]=S.useState(null),[,d]=S.useState(!1);return S.useEffect(()=>{Promise.all([Se.getCompanyStats(),Se.getPreferences()]).then(async([m,f])=>{r(m);const x=f;if(x.instanceId)try{await Rr.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(Gd,{label:"Roles",value:String(t.company.roleCount)}),l.jsx(Gd,{label:"Avg Level",value:`Lv.${t.company.avgLevel}`}),l.jsx(Gd,{label:"Total Tokens",value:t.company.formattedTokens}),l.jsx(Gd,{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(eL,{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:tL(m)}),l.jsxs("span",{style:{color:"rgba(255,255,255,0.5)"},children:["$",f.costUsd.toFixed(2)]})]},m))})]})]})}function Gd({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 eL({role:e,rank:t}){const r=["🥇","🥈","🥉"],i=t<=3?r[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:o2(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:o2(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 o2(e){return e>=20?"#FFD700":e>=10?"#C0A0FF":e>=5?"#4FC3F7":e>=3?"#81C784":"rgba(255,255,255,0.4)"}function tL(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.includes("haiku")?"Haiku":e.split("-").slice(0,2).join(" ")}function nL({onClose:e,onSyncComplete:t}){const[r,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),[k,w]=S.useState(null),C=S.useCallback(async()=>{d(!0),g(null);try{const{roles:E}=await Se.getSyncRoles();i(E);const N=E.filter(A=>A.source.sync!=="off");if(N.length===0){o([]),w(null);return}try{const A=await Rr.syncCheck(N.map(T=>({roleId:T.roleId,sourceId:T.source.id,currentVersion:T.source.upstream_version??T.source.forked_at??"0.0.0"})));w(!0);const z=[];for(const T of A.updates){if(!T.hasUpdate)continue;const F=N.find(O=>O.roleId===T.roleId);if(!F)continue;const{character:q}=await Rr.syncPull(T.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:T.roleId,roleName:F.name,sourceId:T.sourceId,currentVersion:T.currentVersion,latestVersion:T.latestVersion,fields:V})}o(z)}catch{w(!1),o([])}}catch(E){g(E instanceof Error?E.message:"Failed to check for updates")}finally{d(!1)}},[]);S.useEffect(()=>{C()},[C]);const j=async E=>{f(E.roleId);try{const{character:N,version:A}=await Rr.syncPull(E.sourceId);await Se.applySyncUpdate({roleId:E.roleId,changes:{persona:N.persona,authority:N.authority},upstreamVersion:A}),p(z=>new Set(z).add(E.roleId)),t==null||t()}catch(N){g(N instanceof Error?N.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:C,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:"×"})]})]}),k===!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:r.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(E=>!x.has(E.roleId)).length}),k===!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:r.length===0?"No roles with source tracking. Hire from the Store to enable sync.":"All roles are up to date!"}),a.map(E=>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:E.roleName}),l.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[E.sourceId," · v",E.currentVersion," → v",E.latestVersion]})]}),x.has(E.roleId)?l.jsx("span",{style:{fontSize:12,color:"#81C784"},children:"Applied ✓"}):l.jsx("button",{onClick:()=>j(E),disabled:m===E.roleId,style:{background:"#1565C0",border:"none",color:"white",borderRadius:6,padding:"5px 12px",fontSize:12,cursor:m===E.roleId?"wait":"pointer",opacity:m===E.roleId?.6:1},children:m===E.roleId?"Applying...":"Apply Update"})]}),E.fields.map(N=>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:N.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",{}),N.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",{}),N.upstream]})]})]},N.field))]},E.roleId)),r.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 rL({onClose:e}){const[t,r]=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 E=await Se.getGitStatus();r(E)}catch(E){c(E instanceof Error?E.message:"Failed to load git status")}finally{a(!1)}},[]);S.useEffect(()=>{f()},[f]);const x=async E=>{m(E.path);try{await Se.deleteWorktree(E.path),await f()}catch(N){c(N instanceof Error?N.message:"Failed to remove worktree")}finally{m(null)}},p=async E=>{m(E);try{await Se.deleteBranch(E),await f()}catch(N){c(N instanceof Error?N.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(E=>E.status==="active"),g=t.worktrees.filter(E=>E.status==="pending-merge"),k=t.worktrees.filter(E=>E.status==="stale");function w(E){const N=E.split("/");if(N.length>1){const A=N[N.length-1],z=["cto","cbo","pm","engineer","designer","qa","data-analyst"];for(const T of z)if(A.toLowerCase().includes(T))return T}return null}function C(E,N=40){return E.length<=N?E:"..."+E.slice(E.length-N+3)}function j(E){const N=Date.now()-new Date(E).getTime(),A=Math.floor(N/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?"...":""," · ",j(t.lastCommit.date)]})]}),y.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Kd,{label:"Active Worktrees",count:y.length}),y.map(E=>l.jsx(Wp,{wt:E,roleFromBranch:E.roleId||w(E.branch),truncatePath:C,timeAgo:j,removing:d===E.path,onRemove:()=>x(E),statusColor:"#4FC3F7",statusIcon:"📂"},E.path))]}),g.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Kd,{label:"Pending Merge",count:g.length}),g.map(E=>l.jsx(Wp,{wt:E,roleFromBranch:E.roleId||w(E.branch),truncatePath:C,timeAgo:j,removing:d===E.path,onRemove:()=>x(E),statusColor:"#FFB74D",statusIcon:"⚠️"},E.path))]}),k.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Kd,{label:"Stale",count:k.length}),k.map(E=>l.jsx(Wp,{wt:E,roleFromBranch:E.roleId||w(E.branch),truncatePath:C,timeAgo:j,removing:d===E.path,onRemove:()=>x(E),statusColor:"#ff6b6b",statusIcon:"🔴"},E.path))]}),t.staleBranches.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Kd,{label:"Unmerged Branches",count:t.staleBranches.length}),t.staleBranches.map(E=>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:E})]}),l.jsx("button",{onClick:()=>p(E),disabled:d===E,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===E?"wait":"pointer",opacity:d===E?.6:1,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:d===E?"...":"DELETE"})]},E))]}),y.length===0&&g.length===0&&k.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," · ",j(t.lastMerge.mergedAt)]})]})}function Kd({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 Wp({wt:e,roleFromBranch:t,truncatePath:r,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:[r(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 iL({onClose:e,onOpenSession:t}){const[r,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 C=await Se.getActiveSessions();i(C)}catch(C){d(C instanceof Error?C.message:"Failed to load sessions")}finally{o(!1)}},[]);S.useEffect(()=>{x();const C=setInterval(x,1e4);return()=>clearInterval(C)},[x]);const p=async C=>{f(C);try{await Se.deleteActiveSession(C),await x()}catch(j){d(j instanceof Error?j.message:"Failed to remove session")}finally{f(null)}},y=async()=>{try{await Se.cleanupActiveSessions(),await x()}catch(C){d(C instanceof Error?C.message:"Failed to cleanup sessions")}};if(a&&!r)return l.jsx("div",{style:{padding:24,color:"rgba(255,255,255,0.6)"},children:"Loading sessions..."});if(c&&!r)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(!r)return null;const g=r.sessions.filter(C=>C.status==="active"),k=r.sessions.filter(C=>C.status==="idle"),w=r.sessions.filter(C=>C.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:[w.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:r.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:r.summary.totalPorts})]})]}),g.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Gp,{label:"Active",count:g.length}),g.map(C=>l.jsx(Kp,{session:C,removing:m===C.sessionId,onRemove:()=>p(C.sessionId),statusColor:"#4FC3F7",onOpen:t},C.sessionId))]}),k.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Gp,{label:"Idle",count:k.length}),k.map(C=>l.jsx(Kp,{session:C,removing:m===C.sessionId,onRemove:()=>p(C.sessionId),statusColor:"#FFB74D",onOpen:t},C.sessionId))]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Gp,{label:"Dead",count:w.length}),w.map(C=>l.jsx(Kp,{session:C,removing:m===C.sessionId,onRemove:()=>p(C.sessionId),statusColor:"#ff6b6b",onOpen:t},C.sessionId))]}),r.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 Gp({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 sL(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Kp({session:e,removing:t,onRemove:r,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:[" · ",aL(e.worktreePath)]}),e.pid&&l.jsxs(l.Fragment,{children:[" · ","PID:",e.pid]})," · ",sL(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:r,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 aL(e,t=35){return e.length<=t?e:"..."+e.slice(e.length-t+3)}function lL({onClose:e,speechSettings:t,onSpeechSettingsChange:r,language:i,onLanguageChange:a,onOpenSync:o,onOpenGitStatus:c,onOpenSessions:d,onOpenStats:m}){var Z;const[f,x]=S.useState(null),[p,y]=S.useState(null),[g,k]=S.useState(!1),[w,C]=S.useState(!1),[j,E]=S.useState(!1),[N,A]=S.useState(null),[z,T]=S.useState(""),[F,q]=S.useState(!1),[V,L]=S.useState(!1),[_,O]=S.useState(null),[P,R]=S.useState(!1);S.useEffect(()=>{Se.getPreferences().then(async G=>{const K=G;if(x(K.instanceId??null),K.instanceId)try{const{name:M}=await Rr.getMyName(K.instanceId);y(M)}catch{}}).catch(()=>{}),Se.getCodeRoot().then(({codeRoot:G})=>{A(G),G&&T(G)}).catch(()=>{})},[]);const H=async()=>{E(!0);try{const K=await(await fetch("/api/preferences/regenerate-token",{method:"POST"})).json();K.ok&&(x(K.newInstanceId),C(!1))}catch{}E(!1)},B=()=>{f&&navigator.clipboard.writeText(f).then(()=>{k(!0),setTimeout(()=>k(!1),2e3)})};return l.jsx("div",{className:"customize-overlay",onClick:e,children:l.jsxs("div",{className:"customize-modal",onClick:G=>G.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(G=>l.jsxs("button",{onClick:()=>r==null?void 0:r({mode:G}),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(t==null?void 0:t.mode)===G?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(t==null?void 0:t.mode)===G?"rgba(255,255,255,0.08)":"transparent",color:(t==null?void 0:t.mode)===G?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center"},children:[l.jsx("div",{style:{fontWeight:600,marginBottom:2},children:G==="template"?"TEMPLATE":G==="llm"?"AI":"AUTO"}),l.jsx("div",{style:{fontSize:9,opacity:.7},children:G==="template"?"Static pool ($0)":G==="llm"?"LLM generated":"Detect engine"})]},G))}),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:G=>r==null?void 0:r({intervalSec:Number(G.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: $",((Z=t==null?void 0:t.dailyBudgetUsd)==null?void 0:Z.toFixed(2))??"1.00"]}),l.jsx("input",{type:"range",min:0,max:5,step:.25,value:(t==null?void 0:t.dailyBudgetUsd)??1,onChange:G=>r==null?void 0:r({dailyBudgetUsd:Number(G.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:G,label:K})=>l.jsx("button",{onClick:()=>a==null?void 0:a(G),style:{flex:1,padding:"8px 12px",fontSize:11,border:`2px solid ${(i??"auto")===G?"var(--accent)":"rgba(255,255,255,0.1)"}`,background:(i??"auto")===G?"rgba(255,255,255,0.08)":"transparent",color:(i??"auto")===G?"var(--terminal-text)":"var(--terminal-text-muted)",borderRadius:6,cursor:"pointer",textAlign:"center",fontWeight:600},children:K},G))}),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:G=>{T(G.target.value),O(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),O(null);try{const G=await Se.setCodeRoot(z.trim());A(G.codeRoot),T(G.codeRoot),q(!1),R(!0),setTimeout(()=>R(!1),3e3)}catch(G){O(G instanceof Error?G.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),T(N||""),O(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:N?"var(--terminal-text)":"var(--terminal-text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N||"Not configured"}),l.jsx("button",{onClick:()=>{q(!0),O(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"})]}),P&&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:B,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:w?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:j,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:j?"...":"Confirm Regenerate"}),l.jsx("button",{onClick:()=>C(!1),style:{padding:"4px 12px",fontSize:9,border:"none",background:"transparent",color:"var(--terminal-text-muted)",cursor:"pointer"},children:"Cancel"})]})]}):l.jsx("button",{onClick:()=>C(!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:G=>G.currentTarget.style.color="var(--accent)",onMouseLeave:G=>G.currentTarget.style.color="var(--terminal-text-muted)",children:"View public profile →"})})]})})]})})}function oL({theme:e,onThemeChange:t,onClose:r}){const i=S.useRef(null);return S.useEffect(()=>{const a=o=>{i.current&&!i.current.contains(o.target)&&r()};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[r]),l.jsx("div",{ref:i,className:"theme-dropup",children:Object.entries(zs).map(([a,o])=>l.jsxs("button",{className:`theme-dropup__item${e===a?" theme-dropup__item--active":""}`,onClick:()=>{t(a),r()},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 cL({roles:e,roleStatuses:t,activeExecs:r,sessions:i,knowledgeDocs:a,roleLevels:o,companyName:c,getAppearance:d,waveCenterWaves:m,renderProfile:f,channel:x,onChannelChange:p,onClose:y,children:g}){const[k,w]=S.useState(!1),C=m.filter(F=>F.rootDispatches.some(q=>{const V=t[q.roleId];return V==="working"||V==="thinking"})),j=[...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)),E=e.filter(F=>Qn(t[F.id])).length,N=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",T=x.type==="terminal"?`${N} active sessions`:x.type==="wave"?`${C.length} running`:x.type==="knowledge"?`${a.length} documents`:x.type==="role"?(A==null?void 0:A.level)==="c-level"?"C-Level":"Team member":`${E} 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}),E>0&&l.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full animate-pulse",style:{background:"#4CAF5020",color:"#4CAF50"},children:[E," live"]})]}),C.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:["⚡"," ",C[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:[C[0].rootDispatches.filter(F=>{const q=t[F.roleId];return q==="working"||q==="thinking"}).length,"/",C[0].rootDispatches.length," roles working"]})]}),l.jsxs("div",{className:"mx-3 mt-3 grid grid-cols-2 gap-1.5",children:[l.jsx(Qd,{icon:"💬",label:"Chats",badge:N||void 0,active:x.type==="terminal",onClick:()=>p({type:"terminal"})}),l.jsx(Qd,{icon:"⚡",label:"Waves",live:C.length>0,active:x.type==="wave",onClick:()=>p({type:"wave"})}),l.jsx(Qd,{icon:"📋",label:"Decisions",active:x.type==="operations",onClick:()=>p({type:"operations"})}),l.jsx(Qd,{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"}),j.map(F=>{var P;const q=t[F.id],V=r.find(R=>R.roleId===F.id),L=oo[F.id]??"#666",_=(P=o[F.id])==null?void 0:P.level,O=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:O?`${L}18`:"transparent",borderLeft:O?`2px solid ${L}`:"2px solid transparent"},children:[l.jsxs("div",{className:"relative shrink-0",style:{width:22,height:22},children:[l.jsx(wa,{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:Qn(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})]}),Qn(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"}),r.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 (",r.length,")"]}),l.jsx("div",{className:"space-y-0.5 max-h-[140px] overflow-y-auto",children:r.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:()=>w(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(wa,{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:Qn(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:T}),l.jsx("span",{className:"flex-1"}),x.type==="role"&&l.jsx("button",{onClick:()=>w(F=>!F),className:"text-[10px] px-2 py-1 rounded hover:opacity-80 transition-opacity",style:{color:k?"var(--terminal-text)":"var(--terminal-text-muted)",border:"1px solid var(--terminal-border)",background:k?"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}),k&&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(()=>w(!1))})]})]})]})}function uL({role:e,messages:t,isStreaming:r,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(O3,{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(L0,{mode:i,onModeChange:a,onSend:(m,f)=>o(m,i,f),disabled:r,disabledReason:r?`${e.id.toUpperCase()} is responding...`:void 0})]})}function dL({role:e,onSend:t,getAppearance:r,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(wa,{roleId:e.id,appearance:r(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(L0,{mode:a,onModeChange:o,onSend:d=>t(d,a),disabled:!1})]})}function Qd({icon:e,label:t,active:r,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:r?"var(--desk-wood, #5C3D2E)":"var(--terminal-border, #2E261F)",border:r?"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:r?"#fff":"var(--terminal-text, #fff5eb)"},children:t})]})}function fL({roles:e,roleStatuses:t,activeExecs:r,waves:i,knowledgeDocs:a,roleLevels:o,getAppearance:c,onRoleClick:d,onWaveClick:m,onKnowledgeClick:f}){const x=e.filter(p=>Qn(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(c2,{label:"New Wave",icon:"⚡",color:"#EF4444",onClick:m}),l.jsx(c2,{label:"Knowledge",icon:"📚",color:"#0D9488",onClick:f})]}),x.length>0&&l.jsx(Zd,{title:"Currently Working",count:x.length,children:r.map(p=>{const y=e.find(k=>k.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(wa,{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(Zd,{title:"Team",count:e.length,children:l.jsx("div",{className:"grid grid-cols-3 gap-1 px-2",children:e.map(p=>{var k;const y=t[p.id]??"offline",g=(k=o[p.id])==null?void 0:k.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:Qn(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(Zd,{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(Zd,{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 c2({label:e,icon:t,color:r,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:`${r}15`,border:`1px solid ${r}30`},children:[l.jsx("span",{className:"text-sm",children:t}),l.jsx("span",{className:"text-[12px] font-medium",style:{color:r},children:e})]})}function Zd({title:e,count:t,children:r}){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:r})]})}const Hx=5e4;function tS(e){return e<Hx?1:Math.max(1,Math.floor(Math.sqrt(e/Hx)))}function u2(e){return Hx*e*e}function hL(e){const t=tS(e),r=u2(t),i=u2(t+1);return Math.min(1,(e-r)/(i-r))}function Qp(e){const t={};for(const[r,i]of Object.entries(e)){const a=i.inputTokens+i.outputTokens;t[r]={level:tS(a),totalTokens:a,progress:hL(a)}}return t}const mL=[{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 d2(e){return mL.filter(t=>t.check(e))}const f2={cto:"#1565C0",cbo:"#E65100",pm:"#2E7D32",engineer:"#4A148C",designer:"#AD1457",qa:"#00695C","data-analyst":"#0277BD"};function pL({importReq:e,onImportDone:t}){var bu,vu,zo,wu,ku;const[r,i]=S.useState([]),[a,o]=S.useState([]),[c,d]=S.useState([]),[m,f]=S.useState([]),[x,p]=S.useState([]),[y,g]=S.useState([]),[k,w]=S.useState("TYCONO"),[C,j]=S.useState(!0),[E,N]=S.useState(null),[A,z]=S.useState({type:"none"}),[T,F]=S.useState(null),[q,V]=S.useState(null),[L,_]=S.useState([]),[O,P]=S.useState(!1),[R,H]=S.useState(!1),[B,Z]=S.useState([]),[G,K]=S.useState([]),[M,U]=S.useState(0),[Y,$]=S.useState(!1),[Q,ee]=S.useState({}),[J,ae]=S.useState("ceo"),[oe,be]=S.useState(null),[Ee,Ae]=S.useState(!1),[Fe,he]=S.useState(!1),[Re,et]=S.useState({}),We=S.useRef({}),[it,mt]=S.useState(!1),[Ye,Ze]=S.useState(null),[ut,jt]=S.useState({}),[ge,ve]=S.useState([]),Ce=S.useMemo(()=>{const I={};for(const re of ge)I[re.roleId]=re;return I},[ge]),[ne,de]=S.useState([]),[_e,ce]=S.useState(0),[Te,Le]=S.useState(Fv()),Xe=S.useRef(Fv()),Ue=S.useRef(!1),Pe=S.useRef(-1),[lt,tt]=S.useState(null),ze=S.useRef(null),[He,qt]=S.useState(void 0),[Kt,Et]=S.useState(!1);S.useEffect(()=>{Se.getStatus().then(I=>{qt(I.engine),Et(!!I.hasApiKey)}).catch(()=>{})},[]);const{getAppearance:Xt,setAppearance:hn,resetAppearance:vn,theme:le,setTheme:qe,speechSettings:ot,setSpeechSettings:Jt,language:je,setLanguage:St,purchasedItems:gn,addPurchasedItem:mn}=p$(),[Zn,Jn]=S.useState(null),[,An]=S.useState("character"),ie=y$(),[Ie,Ve]=S.useState(!1),[ft,Ct]=S.useState(!1),[xr,Vn]=S.useState(!1),[Sr,ii]=S.useState(!1),[dl,$r]=S.useState(!1),[Or,$i]=S.useState([]),[Oi,si]=S.useState(!1),[ki,wn]=S.useState(!1),[gr,fl]=S.useState(null);S.useEffect(()=>{ie.refresh()},[]),S.useEffect(()=>{const I=re=>{(re.metaKey||re.ctrlKey)&&re.key==="s"&&(re.preventDefault(),Ve(!0))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[]),S.useEffect(()=>{if(!Sr)return;let I=!1;const re=async()=>{try{const we=await Se.getGitStatus();I||fl(we)}catch{}};re();const fe=setInterval(re,1e4);return()=>{I=!0,clearInterval(fe)}},[Sr]),S.useEffect(()=>{let I=!1;const re=async()=>{try{const we=await Se.getActiveSessions();I||$i(we.sessions)}catch{}};re();const fe=setInterval(re,5e3);return()=>{I=!0,clearInterval(fe)}},[]);const[or,ai]=S.useState(null),[Li,li]=S.useState(null),[Si,hl]=S.useState([]),[Lr,os]=S.useState(!1),Cr=S.useRef(!1),Wn=S.useRef(null);let ja=S.useRef(0);const ml=S.useRef(new Set),Ii=S.useRef(Date.now()),oi=(I,re,fe)=>{const we={id:ja.current++,type:I,text:re,detail:fe};hl(De=>[...De,we])};S.useEffect(()=>{var I;Lr&&((I=Wn.current)==null||I.scrollIntoView({behavior:"smooth"}))},[Si,Lr]),S.useEffect(()=>{e&&(Cr.current||(Cr.current=!0,li("Scanning knowledge sources..."),hl([{id:0,type:"scan",text:"Starting knowledge import..."}]),ja.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 De;const re=(De=I.body)==null?void 0:De.getReader();if(!re)return;const fe=new TextDecoder;let we="";for(;;){const{done:Qe,value:Pt}=await re.read();if(Qe)break;we+=fe.decode(Pt,{stream:!0});const pt=we.split(`
121
- `);we=pt.pop()||"";let st="";for(const dt of pt)if(dt.startsWith("event: "))st=dt.slice(7).trim();else if(dt.startsWith("data: ")&&st){try{const vt=JSON.parse(dt.slice(6));switch(st){case"scanning":li(`Scanning: ${vt.path} (${vt.fileCount} files)`),oi("scan",`Found ${vt.fileCount} files`,vt.path);break;case"processing":ai({index:vt.index,total:vt.total}),li(`Importing knowledge... (${vt.index}/${vt.total})`),oi("process",`Processing: ${vt.file}`,`${vt.index} / ${vt.total}`);break;case"created":oi("created",vt.title,vt.summary);break;case"skipped":oi("process",`Skipped: ${vt.file}`,vt.reason);break;case"done":li(null),ai(null),oi("done",`Import complete! ${vt.created} created, ${vt.skipped} skipped.`),At(`Knowledge import complete! ${vt.created} documents imported.`,"#2E7D32"),t==null||t();break;case"error":li(null),ai(null),oi("error",vt.message),At(`Import failed: ${vt.message}`,"#B71C1C"),t==null||t();break}}catch{}st=""}}}).catch(I=>{li(null),oi("error",I.message),At(`Import error: ${I.message}`,"#B71C1C"),t==null||t()})))},[e]);const[er,jr]=S.useState("iso"),En=S.useRef("iso"),[tr,Tn]=S.useState({type:"dashboard"}),[Os,Ci]=S.useState(typeof window<"u"?window.innerWidth:1200);S.useEffect(()=>{const I=()=>Ci(window.innerWidth);return window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]);const pl=Os<1024,[Ir,Hr]=S.useState(!1),[cs,hu]=S.useState(560),[Gn,nn]=S.useState([]),[Hi,cr]=S.useState(null),[Ur,nr]=S.useState(null),{sendMessage:No}=f$();S.useEffect(()=>{Promise.all([Se.getCompany().then(I=>{w(I.name),i(I.roles)}),Se.getOrgTree().then(I=>{ee(I.nodes),ae(I.root)}).catch(()=>{}),Se.getCostSummary().then(I=>yl(Qp(I.byRole))).catch(()=>{})]).catch(I=>N(`Failed to load: ${I.message}`)).finally(()=>j(!1)),Se.getProjects().then(o).catch(()=>{}),Se.getStandups().then(d).catch(()=>{}),Se.getWaves().then(f).catch(()=>{}),Se.getDecisions().then(p).catch(()=>{}),Se.getActiveWaves().then(({waves:I})=>{I.length>0&&Z(I.map(re=>({...re,rootDispatches:re.dispatches.map(({sessionId:fe,roleId:we,roleName:De})=>({sessionId:fe,roleId:we,roleName:De}))})))}).catch(()=>{}),Se.getKnowledge().then(g).catch(()=>{}),Se.getQuestProgress().then(I=>{const re=Rv(I);re.activeChapter!==I.activeChapter&&Se.saveQuestProgress(re).catch(()=>{}),Le(re),Xe.current=re,Ue.current=!0,Se.getCoins().then(fe=>{var we;fe.totalEarned===0?Se.migrateCoins(((we=re.completedQuests)==null?void 0:we.length)??0).then(De=>ce(De.balance)).catch(()=>{}):ce(fe.balance)}).catch(()=>{})}).catch(()=>{Ue.current=!0})},[]),S.useEffect(()=>{if(Pe.current===-1){Pe.current=a.length;return}a.length>Pe.current&&rn({type:"project_created"}),Pe.current=a.length},[a.length]);const xl=S.useRef(!1);S.useEffect(()=>{if(!(!Ue.current||r.length===0||xl.current)){xl.current=!0;for(const I of r)rn({type:"role_hired",condition:{roleId:I.id,roleCount:r.length}})}},[r.length]),S.useEffect(()=>{Se.getSessions().then(I=>{const re=I.filter(fe=>fe.source!=="wave");if(re.length>0){const fe=re.map(De=>({...De,messages:[]}));nn(fe);const we=fe.find(De=>De.status==="active")??fe[0];cr(we.id),ji()}}).catch(I=>{console.error("Failed to load sessions",I)})},[]),S.useEffect(()=>{const I=()=>{fetch("/api/exec/status").then(fe=>fe.json()).then(fe=>{jt(fe.statuses??{}),ve(fe.activeExecutions??[])}).catch(()=>{})};I();const re=setInterval(I,3e3);return()=>clearInterval(re)},[]);const qr=S.useMemo(()=>{const I={...ut};if(Ur){const re=Gn.find(fe=>fe.id===Ur);re&&I[re.roleId]!=="awaiting_input"&&(I[re.roleId]="working")}return I},[ut,Ur,Gn]);S.useEffect(()=>{A.type==="role"?Se.getRole(A.roleId).then(F).catch(console.error):F(null)},[A]);const Er=()=>z({type:"none"}),Ao=async(I,re)=>{const fe=await Se.updateDecision(I,re);p(we=>we.map(De=>De.id===I?fe:De))},gl=async I=>{await Se.deleteDecision(I),p(re=>re.filter(fe=>fe.id!==I))},ur=I=>{z(I),Hr(!1),H(!1)},ji=()=>{Hr(!0),z({type:"none"}),H(!1)},Nr=()=>{En.current="iso",Tn({type:"wave"}),jr("pro"),H(!0),Hr(!1),z({type:"none"})},To=async(I,re)=>{const fe=r.find(De=>De.id===I),we=(q==null?void 0:q.mode)==="ask";V(null);try{const Qe=(await Se.execute({type:"assign",roleId:I,task:re,readOnly:we})).sessionId,Pt=f2[I]??"#666",pt=`${I.toUpperCase()} · ${(fe==null?void 0:fe.name)??I}`;$(!1),_([{sessionId:Qe,title:pt,color:Pt}]),rn({type:"task_executed",condition:{roleId:I}}),sn.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO → ${(fe==null?void 0:fe.name)??I}] ${we?"Ask":"Assign"}: ${re}`,type:"dispatch",targetRoleId:I})}catch(De){At(`Failed to execute: ${De instanceof Error?De.message:"unknown"}`,"#C62828")}},Ea=S.useRef(0),At=(I,re)=>{const fe=++Ea.current;de(we=>[...we,{id:fe,message:I,color:re}]),setTimeout(()=>de(we=>we.filter(De=>De.id!==fe)),4e3)},Do=I=>{ze.current&&clearTimeout(ze.current),tt(I),ze.current=setTimeout(()=>tt(null),8e3)},rn=I=>{if(!Ue.current)return;let re=Xe.current;const fe=W5(re);let we=0;const De=[];for(const Pt of fe){if(!i_(Pt,I))continue;const{progress:pt,quest:st}=n_(re,Pt.id);st&&(re=pt,we+=st.rewards.coins??0,De.push(st.title))}if(De.length===0)return;re=Rv(re),Xe.current=re,Le(re);const Qe=we>0?` 💰 +${we.toLocaleString()}`:"";De.length===1?At(`📋 Quest complete: ${De[0]}${Qe}`,"#7C3AED"):At(`📋 ${De.length} quests complete!${Qe}`,"#7C3AED"),tt(null),Se.saveQuestProgress(re).catch(()=>{}),we>0&&Se.earnCoins(we,`quests: ${De.length}`,De.join(",")).then(Pt=>ce(Pt.balance)).catch(()=>{})};S.useEffect(()=>{if(!lt)return;const I=document.querySelector(`[data-quest-target="${lt}"]`);if(!I)return;I.classList.add("quest-spotlight");const re=()=>{I.classList.remove("quest-spotlight"),tt(null),ze.current&&clearTimeout(ze.current)};return I.addEventListener("click",re,{once:!0}),()=>{I.classList.remove("quest-spotlight"),I.removeEventListener("click",re)}},[lt]);const yl=I=>{var fe,we;const re=We.current;for(const[De,Qe]of Object.entries(I)){const Pt=((fe=re[De])==null?void 0:fe.level)??0;if(Pt>0&&Qe.level>Pt){const pt=((we=r.find(st=>st.id===De))==null?void 0:we.name)??De.toUpperCase();At(`${pt} leveled up to Lv.${Qe.level}!`,"#7C3AED")}}We.current=I,et(I)};S.useEffect(()=>{const I={roles:Object.entries(Re).map(([De,Qe])=>({id:De,level:Qe.level,totalTokens:Qe.totalTokens})),totalTokens:Object.values(Re).reduce((De,Qe)=>De+Qe.totalTokens,0),roleCount:r.length,completedQuests:Te.completedQuests},re=d2(I),fe=new Set(re.map(De=>De.id));if(Date.now()-Ii.current>5e3){const De=ml.current;for(const Qe of re)De.has(Qe.id)||At(`${Qe.icon} Badge earned: ${Qe.name}!`,"#D4A017")}ml.current=fe},[Re,r.length,Te.completedQuests]);const Ui=S.useMemo(()=>t_(Te),[Te]),bl=()=>{var re;const I=L[L.length-1];I&&(At(`${I.title} completed`,I.color),sn.pushMessage({ts:Date.now(),roleId:((re=I.title.split(" · ")[0])==null?void 0:re.toLowerCase())??"unknown",text:`[${I.title}] Completed`,type:"dispatch"})),Se.getStandups().then(d).catch(console.error),Se.getCompany().then(fe=>i(fe.roles)).catch(console.error),Se.getCostSummary().then(fe=>yl(Qp(fe.byRole))).catch(()=>{})},ci=S.useRef(new Map),dr=I=>{if(ci.current.has(I))return;const re=new AbortController;ci.current.set(I,re),nr(fe=>fe??I),fetch(`/api/sessions/${I}/stream?from=0`,{signal:re.signal}).then(async fe=>{var Pt,pt;if(!fe.ok||!fe.body)return;const we=fe.body.getReader(),De=new TextDecoder;let Qe="";for(;;){const{done:st,value:dt}=await we.read();if(st)break;Qe+=De.decode(dt,{stream:!0});const vt=Qe.split(`
122
- `);Qe=vt.pop()??"";let Yt="";for(const Ls of vt)if(Ls.startsWith("event: "))Yt=Ls.slice(7).trim();else if(Ls.startsWith("data: ")){try{const yr=JSON.parse(Ls.slice(6));Yt==="stream:end"?(nn(wt=>wt.map(Mt=>{if(Mt.id!==I)return Mt;const Dn=Mt.messages.map(pn=>pn.status==="streaming"?{...pn,status:"done"}:pn);return{...Mt,messages:Dn}})),nr(wt=>wt===I?null:wt),ci.current.delete(I)):Yt==="activity"&&(yr.type==="text"&&((Pt=yr.data)!=null&&Pt.text)?nn(wt=>wt.map(Mt=>{if(Mt.id!==I)return Mt;const Dn=[...Mt.messages],pn=Dn[Dn.length-1];return(pn==null?void 0:pn.from)==="role"&&pn.status==="streaming"&&(Dn[Dn.length-1]={...pn,content:pn.content+yr.data.text}),{...Mt,messages:Dn}})):yr.type==="thinking"&&((pt=yr.data)!=null&&pt.text)?nn(wt=>wt.map(Mt=>{if(Mt.id!==I)return Mt;const Dn=[...Mt.messages],pn=Dn[Dn.length-1];return(pn==null?void 0:pn.from)==="role"&&pn.status==="streaming"&&(Dn[Dn.length-1]={...pn,thinking:(pn.thinking??"")+yr.data.text}),{...Mt,messages:Dn}})):(yr.type==="msg:done"||yr.type==="msg:error")&&(nn(wt=>wt.map(Mt=>{if(Mt.id!==I)return Mt;const Dn=Mt.messages.map(pn=>pn.status==="streaming"?{...pn,status:yr.type==="msg:done"?"done":"error"}:pn);return{...Mt,messages:Dn}})),nr(wt=>wt===I?null:wt),ci.current.delete(I)))}catch{}Yt=""}}}).catch(()=>{ci.current.delete(I),nr(fe=>fe===I?null:fe)})},Ei=async(I,re,fe,we)=>{P(!1);try{const De=await Se.execute({type:"wave",directive:I,targetRoles:re,...fe&&{attachments:fe},...we&&{continuous:we}});rn({type:"wave_dispatched"});const Qe=De.waveId??`wave-${Date.now()}`,Pt=De.sessionIds??[],pt=J&&Q[J]?Q[J].children.map(wt=>r.find(Mt=>Mt.id===wt)).filter(wt=>!!wt):r.filter(wt=>wt.level==="c-level"),st=re?pt.filter(wt=>re.includes(wt.id)):pt,dt=Pt.map((wt,Mt)=>{var Dn,pn;return{roleId:((Dn=st[Mt])==null?void 0:Dn.id)??`role-${Mt}`,roleName:((pn=st[Mt])==null?void 0:pn.name)??`C-Level ${Mt+1}`,sessionId:wt}});sn.pushMessage({ts:Date.now(),roleId:"ceo",text:`[CEO WAVE] "${I}" → ${dt.map(wt=>wt.roleName).join(", ")}`,type:"dispatch"});const vt={id:Qe,directive:I,rootDispatches:dt.map(({roleId:wt,roleName:Mt,sessionId:Dn})=>({roleId:wt,roleName:Mt,sessionId:Dn})),startedAt:Date.now(),sessionIds:Pt};Z(wt=>[vt,...wt]),Nr();const Yt=new Date().toISOString(),yr=dt.map(wt=>({id:wt.sessionId,roleId:wt.roleId,title:`WAVE: ${wt.roleName}`,mode:"do",source:"wave",messages:[{id:`msg-${wt.sessionId}-ceo`,from:"ceo",content:I,type:"directive",status:"done",timestamp:Yt}],status:"active",createdAt:Yt,updatedAt:Yt})).map((wt,Mt)=>({...wt,messages:[...wt.messages,{id:`msg-${dt[Mt].sessionId}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:Yt}]}));nn(wt=>[...yr,...wt]);for(const wt of yr)dr(wt.id)}catch(De){At(`Failed to start wave: ${De instanceof Error?De.message:"unknown"}`,"#C62828")}},ui=()=>{Se.getWaves().then(f).catch(console.error),Se.getStandups().then(d).catch(console.error)},us=()=>{Se.getCompany().then(I=>i(I.roles)).catch(console.error),Se.getOrgTree().then(I=>{ee(I.nodes),ae(I.root)}).catch(console.error),Se.getCostSummary().then(I=>yl(Qp(I.byRole))).catch(()=>{})},Gf=async(I,re)=>{await Se.createRole(I),hn(I.id,re),us(),At(`${I.name} hired!`,"#2E7D32"),rn({type:"role_hired",condition:{roleId:I.id,roleCount:r.length+1}})},_o=async I=>{var re;await Se.deleteRole(I),us(),nn(fe=>fe.filter(we=>we.roleId!==I)),Hi&&((re=Gn.find(fe=>fe.id===Hi))==null?void 0:re.roleId)===I&&cr(null),Ze(null),At(`${I.toUpperCase()} removed`,"#B71C1C")},Na=async(I,re)=>{await Se.updateRole(I,re),us(),A.type==="role"&&A.roleId===I&&Se.getRole(I).then(F).catch(console.error),re.name&&At(`${I.toUpperCase()} renamed to "${re.name}"`,"#1565C0"),re.persona!==void 0&&(At(`${I.toUpperCase()} persona updated`,"#2E7D32"),rn({type:"persona_updated"}))},Aa=I=>{ji(),rn({type:"terminal_opened"})},Ta=async I=>{try{const re=await Se.createSession(I,"talk");nn(fe=>[re,...fe]),cr(re.id),ji()}catch(re){console.error("Failed to create session",re),At(`Failed to create session: ${re instanceof Error?re.message:"API unreachable"}`,"#B71C1C")}},Mo=async I=>{try{const re=await Se.createSession(I,"talk");nn(fe=>[re,...fe]),cr(re.id)}catch(re){console.error("Failed to create session",re),At(`Failed to create session: ${re instanceof Error?re.message:"API unreachable"}`,"#B71C1C")}},Kf=async I=>{const re=Ce[I],fe=(re==null?void 0:re.sessionId)??(re==null?void 0:re.id);if(fe&&Qn(qr[I])){const De=r.find(dt=>dt.id===I),Qe=f2[I]??"#666",Pt=`${I.toUpperCase()} · ${(De==null?void 0:De.name)??I}`,pt=Gn.find(dt=>dt.roleId===I&&dt.status==="active"),st=(pt==null?void 0:pt.id)??fe;_([{sessionId:st,title:Pt,color:Qe}]),$(!1);return}const we=Gn.find(De=>De.roleId===I);if(we)cr(we.id),sn.setActiveChannelId(null);else try{const De=await Se.createSession(I,"talk");nn(Qe=>[De,...Qe]),cr(De.id),sn.setActiveChannelId(null)}catch(De){console.error("Failed to create session",De)}ji()},mu=async I=>{const re=Gn.find(fe=>fe.id===I);if((re==null?void 0:re.source)==="wave"){{const fe=ci.current.get(re.id);fe&&(fe.abort(),ci.current.delete(re.id))}nn(fe=>{var De;const we=fe.filter(Qe=>Qe.id!==I);return Hi===I&&cr(((De=we[0])==null?void 0:De.id)??null),we});return}try{await Se.deleteSession(I),nn(fe=>{var De;const we=fe.filter(Qe=>Qe.id!==I);return Hi===I&&cr(((De=we[0])==null?void 0:De.id)??null),we})}catch(fe){console.error("Failed to delete session",fe),At(`Failed to close session: ${fe instanceof Error?fe.message:"API error"}`,"#B71C1C")}},pu=async()=>{try{const{ids:I}=await Se.deleteEmptySessions();if(I.length===0)return;nn(re=>{var we;const fe=re.filter(De=>!I.includes(De.id));return Hi&&I.includes(Hi)&&cr(((we=fe[0])==null?void 0:we.id)??null),fe}),At(`Cleared ${I.length} empty session${I.length!==1?"s":""}`,"#2E7D32")}catch(I){At(`Failed to clear empty sessions: ${I instanceof Error?I.message:"API error"}`,"#B71C1C")}},vl=async()=>{if(!confirm("Close all sessions? This cannot be undone."))return;const I=Gn.filter(re=>re.source!=="wave").map(re=>re.id);for(const re of Gn)if(re.source==="wave"){const fe=ci.current.get(re.id);fe&&(fe.abort(),ci.current.delete(re.id))}try{I.length>0&&await Se.deleteSessions(I),nn([]),cr(null),At("All sessions closed","#2E7D32")}catch(re){At(`Failed to close sessions: ${re instanceof Error?re.message:"API error"}`,"#B71C1C")}},qi=(I,re)=>{nn(fe=>fe.map(we=>{if(we.id!==I)return we;const De=[...we.messages],Qe=De[De.length-1];if(Qe&&Qe.from==="role"&&Qe.status==="streaming"){const Pt=[...Qe.streamEvents??[],re];De[De.length-1]={...Qe,streamEvents:Pt}}return{...we,messages:De}}))},ds=(I,re,fe,we)=>{const De={id:`msg-${Date.now()}-ceo`,from:"ceo",content:re,type:fe==="do"?"directive":"conversation",status:"done",timestamp:new Date().toISOString(),attachments:we},Qe={id:`msg-${Date.now()+1}-role`,from:"role",content:"",type:"conversation",status:"streaming",timestamp:new Date().toISOString(),streamEvents:[]};nn(pt=>pt.map(st=>st.id===I?{...st,messages:[...st.messages,De,Qe],updatedAt:new Date().toISOString()}:st));const Pt=Gn.find(pt=>pt.id===I);fe==="talk"?rn({type:"talk_mode_used"}):fe==="do"&&(rn({type:"do_mode_used"}),Pt&&rn({type:"task_executed",condition:{roleId:Pt.roleId}})),nr(I),No(I,re,fe,{onThinking:pt=>{nn(st=>st.map(dt=>{if(dt.id!==I)return dt;const vt=[...dt.messages],Yt=vt[vt.length-1];return Yt&&Yt.from==="role"&&Yt.status==="streaming"&&(vt[vt.length-1]={...Yt,thinking:(Yt.thinking??"")+pt}),{...dt,messages:vt}})),qi(I,{type:"thinking",timestamp:Date.now(),text:pt})},onText:pt=>{nn(st=>st.map(dt=>{if(dt.id!==I)return dt;const vt=[...dt.messages],Yt=vt[vt.length-1];return Yt&&Yt.from==="role"&&Yt.status==="streaming"&&(vt[vt.length-1]={...Yt,content:Yt.content+pt}),{...dt,messages:vt}}))},onToolUse:(pt,st)=>{qi(I,{type:"tool",timestamp:Date.now(),toolName:pt,toolInput:st})},onDispatch:(pt,st)=>{qi(I,{type:"dispatch",timestamp:Date.now(),roleId:pt,task:st})},onDispatchProgress:(pt,st,dt)=>{var vt;st==="tool"?qi(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:pt,progressType:"tool",toolName:dt.name,toolInput:dt.input}):st==="thinking"?qi(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:pt,progressType:"thinking",text:dt.text}):st==="text"?qi(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:pt,progressType:"text",text:(vt=dt.text)==null?void 0:vt.slice(-200)}):(st==="done"||st==="error")&&qi(I,{type:"dispatch:progress",timestamp:Date.now(),roleId:pt,progressType:st})},onTurn:pt=>{qi(I,{type:"turn",timestamp:Date.now(),turn:pt})},onDone:()=>{nn(pt=>pt.map(st=>{if(st.id!==I)return st;const dt=st.messages.map(Yt=>Yt.status==="streaming"?{...Yt,status:"done"}:Yt),vt=st.messages.length<=2?re.slice(0,40).replace(/\n/g," "):st.title;return{...st,messages:dt,title:vt}})),nr(null)},onError:pt=>{nn(st=>st.map(dt=>{if(dt.id!==I)return dt;const vt=dt.messages.map(Yt=>Yt.status==="streaming"?{...Yt,status:"error",content:Yt.content||pt}:Yt);return{...dt,messages:vt}})),nr(null)}},we)},Fo=(I,re)=>{nn(fe=>fe.map(we=>we.id===I?{...we,mode:re}:we)),Se.updateSession(I,{mode:re}).catch(console.error)},Qf=new Date().toISOString().slice(0,10),xu=a[0],Ro={cto:"Chief Technology Officer",cbo:"Chief Business Officer",pm:"Product Manager",engineer:"Software Engineer",designer:"UI/UX Designer",qa:"QA Engineer"},Zf=I=>{const re=Ro[I];if(!re)return"";for(const fe of c){const we=fe.content,De=we.indexOf(`## ${re}`);if(De===-1)continue;const Qe=we.indexOf(`
123
- ## `,De+10),pt=(Qe===-1?we.slice(De):we.slice(De,Qe)).split(`
124
- `).filter(st=>st.trim().length>0);for(const st of pt){const dt=st.replace(/^#+\s*/,"").replace(/\*\*/g,"").replace(/^[-*]\s+/,"").trim();if(!(dt.startsWith("|")||dt.startsWith("{")||dt.startsWith("[")||dt.startsWith("```")||dt.startsWith("---")||dt.includes("Journal")||dt.includes("(c-level)")||dt.includes("(member)")||/^(CEO |작업 결과|생성\/수정|APPROVAL|비고|상황 보고|태스크$)/.test(dt))&&dt.length>15&&dt.length<120)return dt}}return""},gu=I=>{const re=Ro[I];if(!re)return"";for(const fe of c){const we=fe.content,De=we.indexOf(`## ${re}`);if(De===-1)continue;const Qe=we.indexOf(`
125
- ## `,De+10),pt=(Qe===-1?we.slice(De):we.slice(De,Qe)).replace(/^## .+\n/,"").trim();if(pt)return pt.slice(0,1500)}return""},sn=M$();S.useEffect(()=>{r.length>0&&sn.syncDefaultMembers(r)},[r]);const wl=N$({roles:r,roleStatuses:ut,activeExecs:ge,getStandupSpeech:Zf}),kl=B$({roles:r,roleStatuses:ut,activeExecs:ge,channels:sn.channels,relationships:wl.relationships,pushMessage:sn.pushMessage,speechSettings:ot,engineType:He,hasApiKey:Kt}),yu=S.useCallback((I,re)=>{sn.pushMessage({ts:Date.now(),roleId:"ceo",text:re,type:"chat",channelId:I}),kl.triggerCeoReaction(I)},[sn,kl]);return C?l.jsxs("div",{className:"h-screen flex flex-col bg-[var(--floor-light)]",style:{fontFamily:"var(--pixel-font)"},children:[(Li||Si.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:()=>os(I=>!I),children:[Li?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:Li||"Knowledge import finished"}),or&&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:`${or.index/or.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:Lr?"▲":"▼"})]}),Lr&&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:[Si.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:Wn})]})]}),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..."})]})})]}):E?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:E}),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:k})]}),l.jsxs("div",{className:"flex gap-4 text-[11px] items-center",style:{color:"var(--bar-text, var(--terminal-text-secondary))"},children:[(()=>{const I=_e>=1e6?`${(_e/1e6).toFixed(1)}M`:_e>=1e3?`${(_e/1e3).toFixed(1)}K`:String(_e),re=ge.length,fe=r.length>0?Math.round(re/r.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:`${fe}%`,background:"linear-gradient(90deg,#3b82f6,#60A5FA)"}})}),l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:fe})]})]})})(),l.jsxs("span",{className:"hidden sm:inline",children:["Roles: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:r.length})]}),l.jsxs("span",{className:"hidden sm:inline",children:["Projects: ",l.jsx("strong",{style:{color:"var(--bar-text, var(--terminal-text))"},children:a.length})]}),ge.length>0&&l.jsxs("span",{className:"text-amber-400",children:["Working: ",l.jsx("strong",{children:ge.length})]}),(()=>{const I={roles:Object.entries(Re).map(([fe,we])=>({id:fe,level:we.level,totalTokens:we.totalTokens})),totalTokens:Object.values(Re).reduce((fe,we)=>fe+we.totalTokens,0),roleCount:r.length},re=d2(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(fe=>l.jsx("span",{title:`${fe.name}: ${fe.description}`,style:{fontSize:12,cursor:"default"},children:fe.icon},fe.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:Qf})]})]}),(Li||Si.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:()=>os(I=>!I),children:[Li?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:Li||"Knowledge import finished"}),or&&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:`${or.index/or.total*100}%`,background:"#fff"}})}),l.jsx("span",{className:"text-[10px] opacity-70 shrink-0",children:Lr?"▲":"▼"})]}),Lr&&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:[Si.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:Wn}),Si.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(WO,{roles:r,projects:a,waves:m,standups:c,decisions:x,roleStatuses:qr,activeExecs:ge,onRoleClick:I=>ur({type:"role",roleId:I}),onProjectClick:I=>ur({type:"project",projectId:I}),onBulletinClick:()=>{ur({type:"bulletin"}),rn({type:"bulletin_visited"})},onDecisionsClick:()=>ur({type:"decisions"}),onKnowledgeClick:()=>{ur({type:"knowledge"}),rn({type:"knowledge_visited"})},onSettingsClick:()=>{si(!0),rn({type:"settings_visited"})},onThemeClick:()=>wn(I=>!I),onStatsClick:()=>{Ct(!0),rn({type:"stats_visited"})},knowledgeDocsCount:y.length,getRoleSpeech:wl.getSpeech,getAppearance:Xt,onHireClick:()=>mt(!0),onMascotClick:()=>ur({type:"quest"}),roleLevels:Re,language:je,coinBalance:_e,onCoinsSpent:I=>ce(I),onFurniturePlaced:(I,re)=>{rn({type:"furniture_placed"}),re>0&&rn({type:"furniture_purchased"})}})}),Ir&&l.jsx("div",{className:pl?"absolute inset-0 z-50":"contents",children:l.jsx(Hw,{sessions:Gn,activeSessionId:Hi,roles:r,streamingSessionId:Ur,width:pl?Os:cs,onWidthChange:pl?void 0:hu,onSwitchSession:cr,onCloseSession:mu,onCreateSession:Ta,onClearEmpty:pu,onCloseAll:vl,onSendMessage:ds,onModeChange:Fo,onStopSession:I=>Se.abortSession(I).catch(()=>{}),onCloseTerminal:()=>Hr(!1),onMaximize:()=>{En.current="iso",Tn({type:"terminal"}),jr("pro")},chatChannels:sn.channels,activeChatChannelId:sn.activeChannelId,onSwitchChatChannel:sn.setActiveChannelId,onCreateChatChannel:(...I)=>{const re=sn.createChannel(...I);return rn({type:"chat_channel_created"}),re},onDeleteChatChannel:sn.deleteChannel,onUpdateChatMembers:sn.updateMembers,onUpdateChatTopic:sn.updateTopic,onSendChatMessage:yu,unreadChannels:sn.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:()=>jr("iso"),className:`view-toggle-btn ${er==="iso"?"active":""}`,children:"OFFICE"}),l.jsx("button",{onClick:()=>{En.current="iso",jr("pro")},className:`view-toggle-btn ${er==="pro"?"active":""}`,children:"PRO"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("div",{style:{position:"relative"},children:[l.jsxs("button",{className:`theme-btn${ki?" active":""}`,"data-quest-target":"theme-btn",onClick:()=>wn(I=>!I),title:"Office Theme",children:[((bu=zs[le])==null?void 0:bu.icon)??"","▾"]}),ki&&l.jsx(oL,{theme:le,onThemeChange:I=>{qe(I),rn({type:"theme_changed"})},onClose:()=>wn(!1)})]}),l.jsx("button",{className:"theme-btn","data-quest-target":"settings-btn",onClick:()=>si(!0),title:"Settings",children:"⚙"}),l.jsx("span",{className:"mx-1",children:"|"}),l.jsxs("button",{"data-quest-target":"save-btn",onClick:()=>{ie.state==="no-git"||ie.state==="dirty"?Ve(!0):ii(!0)},title:ie.state==="dirty"?`${ie.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:ie.state==="no-git"?"var(--terminal-text-muted)":ie.state==="saving"||ie.state==="dirty"?"var(--idle-amber)":ie.state==="error"?"#EF5350":"var(--active-green)",animation:ie.state==="saving"?"pulse 1s infinite":void 0}}),l.jsx("span",{style:{color:ie.state==="dirty"?"var(--idle-amber)":"var(--bar-text, var(--terminal-text-muted))"},children:ie.state==="no-git"?"No git":ie.state==="saving"?"Saving...":ie.state==="dirty"?`${ie.dirtyCount} unsaved`:"Saved"}),gr&&(gr.worktrees.length>0||gr.staleBranches.length>0)&&l.jsxs("span",{style:{color:gr.worktrees.some(I=>I.status==="stale")?"#ff6b6b":gr.worktrees.some(I=>I.status==="pending-merge")?"#FFB74D":"#4FC3F7"},children:["·"," ","📂"," ",gr.worktrees.length," worktree",gr.worktrees.length!==1?"s":"",gr.staleBranches.length>0&&` · ⚠ ${gr.staleBranches.length} branch${gr.staleBranches.length!==1?"es":""}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[B.length>0&&!R&&l.jsx("button",{onClick:()=>Nr(),className:`px-3 py-1 font-black text-white cursor-pointer ${Fe?"":"animate-pulse"}`,style:{background:Fe?"#2E7D32":"#B71C1C",border:`2px solid ${Fe?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Fe?"WAVE DONE":`WAVE (${B.length})`}),oe&&Ee&&B.length===0&&l.jsx("button",{onClick:()=>Ae(!1),className:`px-3 py-1 font-black text-white cursor-pointer ${Fe?"":"animate-pulse"}`,style:{background:Fe?"#2E7D32":"#B71C1C",border:`2px solid ${Fe?"#1b5e2088":"#7f121288"}`,fontFamily:"var(--pixel-font)",borderRadius:4},children:Fe?"WAVE DONE":"WAVE"}),L.length>0&&Y&&l.jsxs("button",{onClick:()=>$(!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?"..":""]}),Or.length>0&&l.jsxs("button",{onClick:()=>$r(!0),className:"px-2 py-1 font-black cursor-pointer text-[10px]",style:{background:"var(--hud-bg-alt)",color:Or.some(I=>I.messageStatus==="awaiting_input")?"#FFB74D":Or.some(I=>I.messageStatus==="streaming")?"#4FC3F7":"var(--terminal-text-muted)",border:"2px solid var(--pixel-border)",fontFamily:"var(--pixel-font)",borderRadius:4},title:`${Or.length} active session${Or.length!==1?"s":""}`,children:["🔄"," ",Or.length," session",Or.length!==1?"s":""]}),l.jsxs("button",{onClick:()=>Nr(),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:()=>Ir?Hr(!1):Aa(),className:"px-3 py-1 font-black cursor-pointer","data-quest-target":"terminal-btn",style:{background:Ir?"var(--terminal-bg)":"var(--hud-bg-alt)",color:"var(--terminal-text)",border:`2px solid ${Ir?"var(--terminal-border-hover)":"var(--pixel-border)"}`,fontFamily:"var(--pixel-font)"},children:"TERMINAL"})]})]}),er!=="pro"&&A.type==="role"&&T&&(()=>{var re,fe;const I=Ce[T.id];return l.jsx(gv,{role:T,allRoles:r,recentActivity:gu(T.id),onClose:Er,onFireRole:(we,De)=>{Ze({roleId:we,roleName:De}),Er()},terminalWidth:Ir?cs: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:Qn(qr[T.id]),startedAt:I==null?void 0:I.startedAt,onAbortSession:we=>{Se.abortSession(we).catch(()=>{})},sessions:Gn,streamingSessionId:Ur,onCreateSessionSilent:Mo,onSendMessage:ds,onFocusTerminal:Kf,onCustomize:we=>{const De=r.find(Qe=>Qe.id===we);De&&(An("character"),Jn(De))},onUpdateRole:Na,appearance:Xt(T.id),relationships:wl.relationships,roleLevel:(fe=Re[T.id])==null?void 0:fe.level,onMaximize:()=>{En.current="iso",Tn({type:"role",roleId:T.id}),jr("pro")}})})(),er!=="pro"&&A.type==="project"&&xu&&l.jsx(a_,{projectId:xu.id,onClose:Er,terminalWidth:Ir?cs:0}),er!=="pro"&&(A.type==="bulletin"||A.type==="decisions")&&l.jsx(Mv,{standups:c,waves:m,decisions:x,mode:A.type==="bulletin"?"bulletin":"decisions",onClose:Er,onOpenWaveCenter:()=>Nr(),onUpdateDecision:Ao,onDeleteDecision:gl,terminalWidth:Ir?cs:0,onMaximize:()=>{En.current="iso",Tn({type:"operations"}),jr("pro")}}),er!=="pro"&&A.type==="quest"&&l.jsx(s_,{progress:Te,onClose:Er,terminalWidth:Ir?cs:0,onQuestAction:I=>{var fe;Er();const re=fo.find(we=>we.id===I);(fe=re==null?void 0:re.hint)!=null&&fe.target&&Do(re.hint.target)}}),er!=="pro"&&A.type==="knowledge"&&l.jsx(_v,{docs:y,onClose:Er,onRefresh:()=>Se.getKnowledge().then(g).catch(()=>{}),terminalWidth:Ir?cs:0,initialDocId:A.docId,onMaximize:()=>{En.current="iso",Tn({type:"knowledge"}),jr("pro")}}),er==="pro"&&l.jsxs(cL,{roles:r,roleStatuses:qr,activeExecs:ge,waves:m,knowledgeDocs:y,sessions:Gn,roleLevels:Re,companyName:k,getAppearance:Xt,waveCenterWaves:B,renderProfile:tr.type==="role"&&T?I=>{var fe,we;const re=Ce[T.id];return l.jsx(gv,{role:T,allRoles:r,recentActivity:gu(T.id),onClose:I,onFireRole:(De,Qe)=>{Ze({roleId:De,roleName:Qe})},terminalWidth:0,activeSessionId:((fe=L.find(De=>De.sessionId===(re==null?void 0:re.sessionId)))==null?void 0:fe.sessionId)??(re==null?void 0:re.sessionId),activeTask:re==null?void 0:re.task,isWorking:Qn(qr[T.id]),startedAt:re==null?void 0:re.startedAt,onAbortSession:De=>{Se.abortSession(De).catch(()=>{})},sessions:Gn,streamingSessionId:Ur,onCreateSessionSilent:Mo,onSendMessage:ds,onFocusTerminal:()=>{},onCustomize:De=>{const Qe=r.find(Pt=>Pt.id===De);Qe&&(An("character"),Jn(Qe))},onUpdateRole:Na,appearance:Xt(T.id),relationships:wl.relationships,roleLevel:(we=Re[T.id])==null?void 0:we.level})}:void 0,channel:tr,onChannelChange:I=>{Tn(I),I.type==="role"?ur({type:"role",roleId:I.roleId}):I.type==="knowledge"?ur({type:"knowledge"}):I.type==="operations"?ur({type:"bulletin"}):I.type==="wave"?H(!0):I.type==="terminal"?Hr(!0):(z({type:"none"}),H(!1))},onClose:()=>{jr(En.current),z({type:"none"}),H(!1)},children:[tr.type==="dashboard"&&l.jsx(fL,{roles:r,roleStatuses:qr,activeExecs:ge,waves:m,knowledgeDocs:y,roleLevels:Re,getAppearance:Xt,onRoleClick:I=>Tn({type:"role",roleId:I}),onWaveClick:()=>Tn({type:"wave"}),onKnowledgeClick:()=>Tn({type:"knowledge"})}),tr.type==="terminal"&&l.jsx(Hw,{sessions:Gn,activeSessionId:Hi,roles:r,streamingSessionId:Ur,width:typeof window<"u"?window.innerWidth-240:1e3,onSwitchSession:cr,onCloseSession:mu,onCreateSession:Ta,onClearEmpty:pu,onCloseAll:vl,onSendMessage:ds,onModeChange:Fo,onStopSession:I=>Se.abortSession(I).catch(()=>{}),onCloseTerminal:()=>Tn({type:"dashboard"}),chatChannels:sn.channels,activeChatChannelId:sn.activeChannelId,onSwitchChatChannel:sn.setActiveChannelId,onCreateChatChannel:(...I)=>{const re=sn.createChannel(...I);return rn({type:"chat_channel_created"}),re},onDeleteChatChannel:sn.deleteChannel,onUpdateChatMembers:sn.updateMembers,onUpdateChatTopic:sn.updateTopic,onSendChatMessage:yu,unreadChannels:sn.unreadChannels}),tr.type==="wave"&&l.jsx(Lw,{orgNodes:Q,rootRoleId:J,cLevelRoles:J&&Q[J]?Q[J].children.map(I=>r.find(re=>re.id===I)).filter(I=>!!I):r.filter(I=>I.level==="c-level"),pastWaves:m,activeWaves:B,onDispatch:(I,re,fe,we)=>Ei(I,re,fe,we),onClose:()=>Tn({type:"dashboard"}),onDone:()=>{ui(),he(!0),At("Wave complete","#2E7D32")},onSave:async(I,re,fe)=>{try{await Se.saveWave({directive:I,sessionIds:re,waveId:fe==null?void 0:fe.waveId}),ui(),At("Wave saved","#2E7D32")}catch(we){At(`Save failed: ${we instanceof Error?we.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:I=>{Tn({type:"knowledge"}),ur({type:"knowledge",docId:I}),Se.getKnowledge().then(g).catch(()=>{})},onRefreshWaves:()=>Se.getWaves().then(f).catch(()=>{}),terminalWidth:0,inline:!0,onOpenSaveModal:()=>Ve(!0)}),tr.type==="knowledge"&&l.jsx(_v,{docs:y,onClose:()=>Tn({type:"dashboard"}),onRefresh:()=>Se.getKnowledge().then(g).catch(()=>{}),terminalWidth:0,hideHeader:!0}),tr.type==="operations"&&l.jsx(Mv,{standups:c,waves:m,decisions:x,mode:"bulletin",onClose:()=>Tn({type:"dashboard"}),onOpenWaveCenter:()=>Tn({type:"wave"}),onUpdateDecision:Ao,onDeleteDecision:gl,terminalWidth:0}),tr.type==="role"&&(()=>{const I=tr.roleId,re=r.find(we=>we.id===I);if(!re)return null;const fe=Gn.find(we=>we.roleId===I);return fe?l.jsx(uL,{role:re,messages:fe.messages,isStreaming:Ur===fe.id,mode:fe.mode,onModeChange:we=>Fo(fe.id,we),onSend:(we,De,Qe)=>ds(fe.id,we,De,Qe),isWave:fe.source==="wave"}):l.jsx(dL,{role:re,getAppearance:Xt,onSend:async(we,De)=>{try{const Qe=await Se.createSession(I,"talk");nn(Pt=>[Qe,...Pt]),cr(Qe.id),ds(Qe.id,we,De)}catch(Qe){At(`Failed to create session: ${Qe instanceof Error?Qe.message:"API unreachable"}`,"#B71C1C")}}})})()]}),q&&l.jsx(c_,{roleId:q.roleId,roleName:q.roleName,mode:q.mode,onClose:()=>V(null),onExecutionStart:To}),oe&&!Ee&&l.jsx(FB,{directive:oe.directive,rootDispatches:oe.rootDispatches,orgNodes:Q,rootRoleId:J,onClose:()=>{be(null),Ae(!1),he(!1)},onMinimize:()=>Ae(!0),onDone:()=>{ui(),he(!0),At("Wave complete","#2E7D32")},onSave:async I=>{try{await Se.saveWave({directive:oe.directive,sessionIds:I}),ui(),At("Wave saved to bulletin","#2E7D32")}catch(re){At(`Save failed: ${re instanceof Error?re.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:I=>{be(null),Ae(!1),he(!1),ur({type:"knowledge",docId:I}),Se.getKnowledge().then(g).catch(()=>{})}}),R&&er!=="pro"&&l.jsx(Lw,{orgNodes:Q,rootRoleId:J,cLevelRoles:J&&Q[J]?Q[J].children.map(I=>r.find(re=>re.id===I)).filter(I=>!!I):r.filter(I=>I.level==="c-level"),pastWaves:m,activeWaves:B,onDispatch:(I,re,fe,we)=>Ei(I,re,fe,we),onClose:()=>H(!1),onMaximize:()=>{En.current="iso",Tn({type:"wave"}),jr("pro")},onDone:()=>{ui(),he(!0),At("Wave complete","#2E7D32")},onSave:async(I,re,fe)=>{try{await Se.saveWave({directive:I,sessionIds:re,waveId:fe==null?void 0:fe.waveId}),ui(),At("Wave saved","#2E7D32")}catch(we){At(`Save failed: ${we instanceof Error?we.message:"unknown"}`,"#C62828")}},onOpenKnowledgeDoc:I=>{H(!1),ur({type:"knowledge",docId:I}),Se.getKnowledge().then(g).catch(()=>{})},onRefreshWaves:()=>Se.getWaves().then(f).catch(()=>{}),terminalWidth:Ir?cs:0,onOpenSaveModal:()=>Ve(!0)}),L.length>0&&!Y&&(()=>{var fe;const I=L[L.length-1],re=G.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:G.map((we,De)=>l.jsx("button",{onClick:()=>{U(De),_([{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===De?"#B71C1C":"var(--terminal-bg)",color:M===De?"#fff":"var(--terminal-text-secondary)",border:`1px solid ${M===De?"#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 · ${((fe=G[M])==null?void 0:fe.roleName)??""}`:I.title,color:I.color,variant:"modal",style:re&&L.length===1?{marginTop:28}:void 0,onClose:()=>{nn(we=>we.filter(De=>De.source!=="wave")),_([]),K([]),U(0),$(!1)},onMinimize:()=>$(!0),onDone:()=>{bl(),ui()},onNavigateToSession:()=>{},onOpenKnowledgeDoc:we=>{_([]),K([]),U(0),$(!1),ur({type:"knowledge",docId:we}),Se.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 ",(vu=L[L.length-2])==null?void 0:vu.title]})})}),O&&l.jsx(m_,{cLevelRoles:J&&Q[J]?Q[J].children.map(I=>r.find(re=>re.id===I)).filter(I=>!!I):r.filter(I=>I.level==="c-level"),orgNodes:Q,rootId:J,onClose:()=>P(!1),onDispatch:(I,re)=>Ei(I,re)}),it&&l.jsx(qB,{existingRoles:r,onClose:()=>mt(!1),onHire:Gf,onStoreVisit:()=>rn({type:"store_visited"}),questHint:((zo=Ui==null?void 0:Ui.hint)==null?void 0:zo.target)==="hire-btn"?{message:Ui.description,roleId:((wu=Ui.trigger.condition)==null?void 0:wu.roleId)??void 0}:void 0}),Ye&&l.jsx(PB,{roleId:Ye.roleId,roleName:Ye.roleName,onClose:()=>Ze(null),onConfirm:_o}),Zn&&l.jsx(GO,{role:Zn,appearance:Xt(Zn.id),onSave:I=>{hn(Zn.id,I),rn({type:"accessory_changed"})},onReset:()=>vn(Zn.id),onClose:()=>{Jn(null),An("character")},theme:le,onThemeChange:I=>{qe(I),rn({type:"theme_changed"})},onUpdateName:async(I,re)=>{await Na(I,{name:re})},initialTab:"character",characterOnly:!0,speechSettings:ot,onSpeechSettingsChange:Jt,language:je,onLanguageChange:St,roleLevel:(ku=Re[Zn.id])==null?void 0:ku.level,coinBalance:_e,purchased:gn,onPurchase:(I,re)=>{Se.spendCoins(re,`Purchased ${I}`,I).then(fe=>{ce(fe.balance),mn(I)}).catch(()=>{})}}),Ie&&(()=>{const I=r.find(re=>re.id==="cto")??r.find(re=>re.level==="c-level")??r[0];return l.jsx(ZO,{status:ie.status,history:ie.history,onClose:()=>Ve(!1),onSave:async re=>{const fe=await ie.save(re);return fe!=null&&fe.ok&&rn({type:"save_committed"}),fe},onLoadHistory:ie.loadHistory,onRestore:ie.restore,saving:ie.state==="saving",repo:ie.repo,onRepoChange:ie.setRepo,syncInfo:ie.syncInfo,onPull:ie.pull,pulling:ie.pulling,onRefresh:ie.refresh,onInitGit:ie.initGit,delegateRoleName:(I==null?void 0:I.name)??(I==null?void 0:I.id),onDelegate:I?async re=>{Ve(!1);try{const fe=await Se.createSession(I.id,"do");nn(De=>[fe,...De]),cr(fe.id),ji();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}`;ds(fe.id,we,"do")}catch(fe){At(`Failed to delegate: ${fe instanceof Error?fe.message:"error"}`,"#B71C1C")}}:void 0})})(),ft&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Ct(!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(JO,{onClose:()=>Ct(!1)})})}),xr&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>Vn(!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(nL,{onClose:()=>Vn(!1),onSyncComplete:()=>{}})})}),Oi&&l.jsx(lL,{onClose:()=>si(!1),speechSettings:ot,onSpeechSettingsChange:Jt,language:je,onLanguageChange:St,onOpenSync:()=>Vn(!0),onOpenGitStatus:()=>ii(!0),onOpenSessions:()=>$r(!0),onOpenStats:()=>Ct(!0)}),Sr&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>ii(!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(rL,{onClose:()=>ii(!1)})})}),dl&&l.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>$r(!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(iL,{onClose:()=>$r(!1),onOpenSession:I=>{$r(!1),Tn({type:"role",roleId:I}),jr("pro")}})})}),l.jsx("div",{className:"fixed top-16 right-4 z-[70] flex flex-col gap-2",children:ne.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 Jd({onSelect:e,onClose:t}){const[r,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 w=>{o(!0);try{const C=await Se.browse(w);i(C)}catch{}finally{o(!1)}},[]);S.useEffect(()=>{g()},[g]),S.useEffect(()=>{var w;m&&((w=y.current)==null||w.focus())},[m]);const k=async()=>{if(!(!r||!c.trim())){p(!0);try{const w=await Se.mkdir(r.current,c.trim());w.ok&&(d(""),f(!1),await g(w.path))}catch{}finally{p(!1)}}};return a&&!r?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..."}):r?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:r.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(r.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:w=>d(w.target.value),onKeyDown:w=>{w.key==="Enter"&&k(),w.key==="Escape"&&f(!1)}}),l.jsx("button",{onClick:k,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"})]}),r.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(r.parent),children:[l.jsx("span",{children:"⬆️"}),l.jsx("span",{children:".."})]}),r.dirs.map(w=>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(w.path),children:[l.jsx("span",{children:"📁"}),l.jsx("span",{children:w.name})]},w.path)),r.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 xL={engine:"AI Engine",company:"Company",workspace:"Workspace",team:"Team",create:"Create"};function h2(e){return e==="existing-akb"?["engine","workspace","create"]:["engine","company","workspace","team","create"]}function gL({onComplete:e}){const[t,r]=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,k]=S.useState(""),[w,C]=S.useState("en"),j=S.useRef(null),[E,N]=S.useState("new"),[A,z]=S.useState(""),[T,F]=S.useState(""),[q,V]=S.useState(!1),[L,_]=S.useState(!1),[O,P]=S.useState(!1),[R,H]=S.useState(""),[B,Z]=S.useState(!1),[G,K]=S.useState(!1),[M,U]=S.useState([]),[Y,$]=S.useState(""),[Q,ee]=S.useState(!1),[J,ae]=S.useState(""),[oe,be]=S.useState(null),[Ee,Ae]=S.useState(!1),[Fe,he]=S.useState(!1),[Re,et]=S.useState([]),[We,it]=S.useState("startup"),[mt,Ye]=S.useState(!1),[Ze,ut]=S.useState(!1),[jt,ge]=S.useState(null),[ve,Ce]=S.useState([]),[ne,de]=S.useState(""),[_e,ce]=S.useState(!1),[Te,Le]=S.useState(!1),[Xe,Ue]=S.useState([]),Pe=S.useMemo(()=>h2(E),[E]),lt=Pe[t]??"engine";S.useEffect(()=>{Se.detectEngine().then(je=>{a(je),c(je.recommended),x(!1)}).catch(()=>x(!1)),Se.getTeams().then(et).catch(()=>{}),Se.getStatus().then(je=>{F(je.companyRoot||"")}).catch(()=>{})},[]),S.useEffect(()=>{var je;lt==="company"&&((je=j.current)==null||je.focus())},[lt]),S.useEffect(()=>{if(q||!T)return;const je=p.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");z(je?`${T}/${je}`:T)},[p,T,q]);const tt=()=>{switch(lt){case"engine":return o!=="none"||d.length>10;case"company":return p.trim().length>0;case"workspace":return E==="existing-akb"?oe===!0:!0;case"team":return!0;case"create":return!Ze;default:return!1}},ze=()=>{t<Pe.length-1&&tt()&&r(t+1),lt==="create"&&!mt&&!_e&&(E==="existing-akb"?vn():hn())},He=()=>{t>0&&r(t-1)},qt=S.useRef(E);S.useEffect(()=>{if(qt.current===E)return;qt.current=E;const St=h2(E).indexOf("workspace");St>=0&&r(St)},[E]);const Kt=async()=>{if(J.trim()){Ae(!0);try{const je=await Se.validatePath(J.trim());be(je.valid&&je.hasClaudeMd===!0)}catch{be(!1)}finally{Ae(!1)}}},Et=()=>{const je=Y.trim();je&&!M.includes(je)&&(U([...M,je]),$(""))},Xt=async je=>{Le(!0),Ue([]);try{const{tools:St}=await Se.getRequiredTools(je);if(St.filter(mn=>!mn.installed).length===0){Le(!1);return}await Se.installTools(je,(mn,Zn)=>{const Jn=Zn.tool||"";mn==="checking"?Ue(An=>[...An,{event:mn,tool:Jn,detail:"checking..."}]):mn==="installing"?Ue(An=>[...An,{event:mn,tool:Jn,detail:"installing..."}]):mn==="installed"?Ue(An=>[...An,{event:mn,tool:Jn,detail:"installed"}]):mn==="skipped"?Ue(An=>[...An,{event:mn,tool:Jn,detail:Zn.reason||"skipped"}]):mn==="error"&&Ue(An=>[...An,{event:mn,tool:Jn,detail:Zn.error||"failed"}])})}catch{}finally{Le(!1)}},hn=async()=>{Ye(!0),ge(null);try{const je={companyName:p.trim(),description:g.trim()||"An AI-powered organization",team:We,knowledgePaths:M.length>0?M:void 0,language:w!=="auto"?w:void 0,location:A.trim()||void 0,codeRoot:R.trim()||void 0};(o==="direct-api"||d)&&(je.apiKey=d||void 0);const St=await Se.scaffold(je);Ce(St.created),de(St.projectRoot),ut(!0),Ye(!1),We!=="custom"&&Xt(We)}catch(je){ge(je instanceof Error?je.message:"Scaffold failed"),Ye(!1)}},vn=async()=>{ce(!0),ge(null);try{const je=await Se.connectAkb(J.trim());je.ok?(ut(!0),Ce([`Connected to: ${je.companyRoot}`])):ge(je.error||"Failed to connect")}catch(je){ge(je instanceof Error?je.message:"Connect failed")}finally{ce(!1)}},le=()=>{M.length>0?e({paths:M,companyRoot:""}):e()},qe=je=>{je.key==="Enter"&&tt()&&(je.preventDefault(),ze())},ot=`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)]`,Jt=je=>`p-4 rounded-lg border-2 cursor-pointer transition-all text-[var(--terminal-text)] ${je?"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:qe,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:Pe.map((je,St)=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"h-1 rounded-full transition-colors",style:{background:St<=t?"var(--accent)":"var(--terminal-surface-light)"}}),l.jsx("div",{className:"text-[9px] mt-1 truncate",style:{color:St===t?"var(--terminal-text)":"var(--terminal-text-muted)"},children:xL[je]})]},je))})]}),l.jsxs("div",{className:"px-6 py-5 min-h-[280px] max-h-[480px] overflow-y-auto",children:[lt==="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:Jt(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:Jt(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:`${ot} mt-3`,placeholder:"sk-ant-...",value:d,onChange:je=>m(je.target.value),autoFocus:!0})]})]})]}),lt==="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:j,className:ot,placeholder:"e.g. Acme Corp",value:p,onChange:je=>y(je.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:`${ot} resize-none`,rows:3,placeholder:"What does your AI company do?",value:g,onChange:je=>k(je.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:ot,value:w,onChange:je=>C(je.target.value),children:[l.jsx("option",{value:"en",children:"English"}),l.jsx("option",{value:"ko",children:"한국어"}),l.jsx("option",{value:"ja",children:"日本語"})]})]})]}),lt==="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(Y0,{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:E==="new"?"var(--accent)":"var(--hud-bg-alt)",color:E==="new"?"#fff":"var(--terminal-text-muted)"},onClick:()=>N("new"),children:"New Company"}),l.jsx("button",{className:"flex-1 px-3 py-2 text-xs font-medium transition-colors",style:{background:E==="existing-akb"?"var(--accent)":"var(--hud-bg-alt)",color:E==="existing-akb"?"#fff":"var(--terminal-text-muted)",borderLeft:"1px solid var(--terminal-border)"},onClick:()=>N("existing-akb"),children:"Connect Existing"})]}),E==="new"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs(m2,{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:`${ot} flex-1`,placeholder:"/path/to/your-company",value:A,onChange:je=>{z(je.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(Jd,{onSelect:je=>{z(je),V(!0),_(!1)},onClose:()=>_(!1)})]}),l.jsxs(p2,{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:O,onToggle:()=>P(!O),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${ot} flex-1`,placeholder:"/path/to/code/repo",value:R,onChange:je=>H(je.target.value)}),l.jsx("button",{onClick:()=>Z(!B),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:"📁"})]}),B&&l.jsx(Jd,{onSelect:je=>{H(je),Z(!1)},onClose:()=>Z(!1)})]}),l.jsxs(p2,{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:G,onToggle:()=>K(!G),children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{className:`${ot} flex-1`,placeholder:"/path/to/docs",value:Y,onChange:je=>$(je.target.value),onKeyDown:je=>{je.key==="Enter"&&(je.preventDefault(),Et())}}),l.jsx("button",{onClick:()=>ee(!Q),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:Et,disabled:!Y.trim(),className:"px-3 py-2 rounded text-xs font-medium shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:Y.trim()?1:.5},children:"Add"})]}),Q&&l.jsx(Jd,{onSelect:je=>{M.includes(je)||U([...M,je]),ee(!1)},onClose:()=>ee(!1)}),M.length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:M.map((je,St)=>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:je}),l.jsx("button",{onClick:()=>U(M.filter((gn,mn)=>mn!==St)),className:"opacity-50 hover:opacity-100",children:"✕"})]},St))})]})]}):l.jsx("div",{className:"space-y-3",children:l.jsxs(m2,{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:`${ot} flex-1`,placeholder:"/path/to/your/akb",value:J,onChange:je=>{ae(je.target.value),be(null)},autoFocus:!0}),l.jsx("button",{onClick:()=>he(!Fe),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:Kt,disabled:Ee||!J.trim(),className:"px-3 py-2 rounded text-xs font-medium transition-colors shrink-0",style:{background:"var(--accent)",color:"#fff",opacity:Ee||!J.trim()?.5:1},children:Ee?"...":"Verify"})]}),oe===!0&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"var(--active-green)"},children:["✅"," Valid AKB found"]}),oe===!1&&l.jsxs("div",{className:"text-xs mt-2",style:{color:"#EF4444"},children:["❌"," No valid AKB (CLAUDE.md required)"]}),Fe&&l.jsx(Jd,{onSelect:je=>{ae(je),be(null),he(!1)},onClose:()=>he(!1)})]})})]}),lt==="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."}),Re.map(je=>l.jsxs("div",{className:Jt(We===je.id),onClick:()=>it(je.id),children:[l.jsx("div",{className:"font-medium text-sm capitalize",children:je.id}),l.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:je.roles.map(St=>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:St.id.toUpperCase()},St.id))})]},je.id)),l.jsxs("div",{className:Jt(We==="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."})]})]}),lt==="create"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-base font-semibold",style:{color:"var(--terminal-text)"},children:Ze?E==="existing-akb"?"AKB Connected!":"Company Created!":"Review & Create"}),!Ze&&!mt&&!_e&&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:E==="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:"})," ",We]}),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."})]})}),jt&&l.jsx("div",{className:"text-xs p-3 rounded",style:{background:"rgba(220,38,38,0.15)",color:"#f87171"},children:jt})]}),(mt||_e)&&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:_e?"Connecting to AKB...":"Scaffolding your company..."})]}),Ze&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-center py-4 text-4xl",children:"🏢"}),ne&&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:"})," ",ne]}),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((je,St)=>l.jsxs("div",{className:"py-0.5",children:[l.jsx("span",{style:{color:"var(--active-green)"},children:"✓"})," ",je]},St))}),(Te||Xe.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:Te?"Installing skill tools...":"Skill tools"}),Xe.map((je,St)=>l.jsxs("div",{className:"py-0.5 flex items-center gap-2",children:[l.jsx("span",{style:{color:je.event==="installed"||je.event==="skipped"?"var(--active-green)":je.event==="error"?"#f87171":"var(--terminal-text-muted)"},children:je.event==="installed"||je.event==="skipped"?"✓":je.event==="error"?"✗":"…"}),l.jsx("span",{children:je.tool}),l.jsx("span",{style:{color:"var(--terminal-text-muted)"},children:je.detail})]},St)),Te&&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&&!Ze&&l.jsx("button",{onClick:He,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," / ",Pe.length]}),l.jsx("div",{children:Ze?l.jsx("button",{onClick:le,disabled:Te,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:"var(--active-green)",color:"#fff",opacity:Te?.5:1},children:Te?"Setting up tools...":"Enter Office"}):l.jsx("button",{onClick:ze,disabled:!tt()||mt||_e,className:"px-5 py-2 rounded text-sm font-medium transition-colors",style:{background:tt()?"var(--accent)":"var(--terminal-border)",color:"#fff",opacity:tt()&&!mt&&!_e?1:.5},children:lt==="create"?mt||_e?_e?"Connecting...":"Creating...":E==="existing-akb"?"Connect AKB":"Create Company":"Next"})})]})]})})}function Y0({text:e}){const[t,r]=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})}r(!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:()=>r(!1),onClick:d=>{d.stopPropagation(),t?r(!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 m2({icon:e,title:t,hint:r,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(Y0,{text:i})]}),l.jsx("div",{className:"text-[10px] mt-0.5 ml-6",style:{color:"var(--terminal-text-muted)"},children:r})]}),a]})}function p2({icon:e,title:t,hint:r,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(Y0,{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:r})}),o&&l.jsx("div",{className:"px-3 pb-3 space-y-2",children:d})]})}function yL(){const[e,t]=S.useState(null),[r,i]=S.useState(!0),[a,o]=S.useState(null),c=S.useCallback(async()=>{i(!0),o(null);try{const d=await Se.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:r,error:a,refetch:c}}const bL=S.lazy(()=>qx(()=>import("./preview-app-CAohaHWp.js"),[])),vL=S.lazy(()=>qx(()=>import("./index-uwS0YSTU.js"),__vite__mapDeps([0,1])));function Ux(){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 wL(){var e;try{const t=localStorage.getItem("tycono-theme"),r=t&&t in zs?t:"default",i=(e=zs[r])==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 kL(){const{initialized:e,loading:t,refetch:r}=yL(),[i,a]=S.useState(null);S.useEffect(()=>{wL()},[]);const o=c=>{c&&a(c),r()};return t?l.jsx(Ux,{}):e?l.jsx(pL,{importReq:i,onImportDone:()=>a(null)}):l.jsx(gL,{onComplete:o})}function SL(){const e=new URLSearchParams(window.location.search),t=e.has("sprite-preview"),r=e.has("rpg-game");return l.jsx(Y4,{children:t?l.jsx(S.Suspense,{fallback:l.jsx(Ux,{}),children:l.jsx(bL,{})}):r?l.jsx(S.Suspense,{fallback:l.jsx(Ux,{}),children:l.jsx(vL,{})}):l.jsx(kL,{})})}H4.createRoot(document.getElementById("root")).render(l.jsx(S.StrictMode,{children:l.jsx(SL,{})}));export{AL as A,F3 as H,NL as O,z3 as P,B3 as S,R3 as a,M3 as b,jL as c,EL as d,l as j,S as r};